clutter/stage: Offset framebuffer capture origin by view layout

The rectangle passed to capture_view() is in stage coordinate space;
thus, to translate to framebuffer coordinate space, the origin need to
be translated by the view layout position.

This fixes capturing views not at position (0, 0).

https://bugzilla.gnome.org/show_bug.cgi?id=770127
This commit is contained in:
Jonas Ådahl 2016-08-19 10:45:08 +08:00
parent 4f58a46217
commit f36fa53b0e

View File

@ -4676,6 +4676,7 @@ capture_view (ClutterStage *stage,
uint8_t *data;
int stride;
CoglBitmap *bitmap;
cairo_rectangle_int_t view_layout;
framebuffer = clutter_stage_view_get_framebuffer (view);
@ -4700,8 +4701,11 @@ capture_view (ClutterStage *stage,
stride,
data);
clutter_stage_view_get_layout (view, &view_layout);
cogl_framebuffer_read_pixels_into_bitmap (framebuffer,
rect->x, rect->y,
view_layout.x - rect->x,
view_layout.y - rect->y,
COGL_READ_PIXELS_COLOR_BUFFER,
bitmap);