static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ int i,j; uint8_t *y_in, *cb_in, *cr_in; uint8_t *y_out, *cb_out, *cr_out; vf->dmpi=vf_get_image(vf->next,mpi->imgfmt, MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, mpi->width, mpi->height); y_in = mpi->planes[0]; cb_in = mpi->planes[1]; cr_in = mpi->planes[2]; y_out = vf->dmpi->planes[0]; cb_out = vf->dmpi->planes[1]; cr_out = vf->dmpi->planes[2]; for (i = 0; i < mpi->height; i++) for (j = 0; j < mpi->width; j++) y_out[i*vf->dmpi->stride[0]+j] = clamp_y(y_in[i*mpi->stride[0]+j]); for (i = 0; i < mpi->chroma_height; i++) for (j = 0; j < mpi->chroma_width; j++) { cb_out[i*vf->dmpi->stride[1]+j] = clamp_c(cb_in[i*mpi->stride[1]+j]); cr_out[i*vf->dmpi->stride[2]+j] = clamp_c(cr_in[i*mpi->stride[2]+j]); } return vf_next_put_image(vf,vf->dmpi, pts); }
static void paint_large_line (GooDemoLargeLine *line, cairo_t *cr, const GooCanvasBounds *bounds, gdouble line_width, gdouble x1, gdouble y1, gdouble x2, gdouble y2) { GooCanvasItem *item = (GooCanvasItem*) line; GooCanvasItemSimple *simple = (GooCanvasItemSimple*) line; GooCanvas *canvas = simple->canvas; GooCanvasBounds tmp_bounds = *bounds; gdouble point1[2], point2[2], *p1, *p2; point1[0] = x1; point1[1] = y1; point2[0] = x2; point2[1] = y2; /* Transform the coordinates to the canvas device space, so we can clamp the line to the bounds to be painted. */ goo_canvas_convert_from_item_space (canvas, item, &point1[0], &point1[1]); goo_canvas_convert_from_item_space (canvas, item, &point2[0], &point2[1]); /* Extend the bounds a bit to account for the line width. */ tmp_bounds.x1 -= line_width; tmp_bounds.y1 -= line_width; tmp_bounds.x2 += line_width; tmp_bounds.y2 += line_width; /* Make p1 the left-most point. */ if (point1[0] < point2[0]) { p1 = point1; p2 = point2; } else { p1 = point2; p2 = point1; } /* Just return if the line is completely outside the bounds horizontally. */ if (p2[0] < tmp_bounds.x1 || p1[0] > tmp_bounds.x2) return; /* Clamp each x coordinate to the bounds. */ if (p1[0] < tmp_bounds.x1) clamp_x (p1, p2, tmp_bounds.x1); if (p2[0] > tmp_bounds.x2) clamp_x (p2, p1, tmp_bounds.x2); /* Now make p1 the top-most point. */ if (point1[1] < point2[1]) { p1 = point1; p2 = point2; } else { p1 = point2; p2 = point1; } /* Just return if the line is completely outside the bounds vertically. */ if (p2[1] < tmp_bounds.y1 || p1[1] > tmp_bounds.y2) return; /* Clamp each y coordinate to the bounds. */ if (p1[1] < tmp_bounds.y1) clamp_y (p1, p2, tmp_bounds.y1); if (p2[1] > tmp_bounds.y2) clamp_y (p2, p1, tmp_bounds.y2); /* Convert back to item space. */ goo_canvas_convert_to_item_space (canvas, item, &point1[0], &point1[1]); goo_canvas_convert_to_item_space (canvas, item, &point2[0], &point2[1]); /* Draw the line. */ cairo_move_to (cr, point1[0], point1[1]); cairo_line_to (cr, point2[0], point2[1]); cairo_stroke (cr); }