Commit fef81cd6 authored by Jonas Ådahl's avatar Jonas Ådahl

clutter/stage: Fix capturing scaled views

Make clutter_stage_capture() work if views are scaled. This needs
adaptations on the using side to deal with the cairo surface device
scale that is used to communicate the scale used when capturing.
parent 3e8d0204
......@@ -4720,6 +4720,7 @@ capture_view (ClutterStage *stage,
int stride;
CoglBitmap *bitmap;
cairo_rectangle_int_t view_layout;
float view_scale;
framebuffer = clutter_stage_view_get_framebuffer (view);
......@@ -4730,8 +4731,11 @@ capture_view (ClutterStage *stage,
clutter_stage_do_paint_view (stage, view, rect);
view_scale = clutter_stage_view_get_scale (view);
image = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
rect->width, rect->height);
rect->width * view_scale,
rect->height * view_scale);
cairo_surface_set_device_scale (image, view_scale, view_scale);
data = cairo_image_surface_get_data (image);
stride = cairo_image_surface_get_stride (image);
......@@ -4739,7 +4743,8 @@ capture_view (ClutterStage *stage,
backend = clutter_get_default_backend ();
context = clutter_backend_get_cogl_context (backend);
bitmap = cogl_bitmap_new_for_data (context,
rect->width, rect->height,
rect->width * view_scale,
rect->height * view_scale,
......@@ -4747,8 +4752,8 @@ capture_view (ClutterStage *stage,
clutter_stage_view_get_layout (view, &view_layout);
cogl_framebuffer_read_pixels_into_bitmap (framebuffer,
rect->x - view_layout.x,
rect->y - view_layout.y,
(rect->x - view_layout.x) * view_scale,
(rect->y - view_layout.y) * view_scale,
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment