clutter: Expose 'capture_view_into()` as API

It'll be used to explicitly capture the content of a single view.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
This commit is contained in:
Jonas Ådahl 2021-01-27 23:14:29 +01:00 committed by Marge Bot
parent 005c49063d
commit 9b1b4eb843
2 changed files with 24 additions and 17 deletions

View File

@ -54,6 +54,13 @@ void clutter_stage_capture_into (ClutterStage *stage,
cairo_rectangle_int_t *rect, cairo_rectangle_int_t *rect,
uint8_t *data); uint8_t *data);
CLUTTER_EXPORT
void clutter_stage_capture_view_into (ClutterStage *stage,
ClutterStageView *view,
cairo_rectangle_int_t *rect,
uint8_t *data,
int stride);
CLUTTER_EXPORT CLUTTER_EXPORT
void clutter_stage_clear_stage_views (ClutterStage *stage); void clutter_stage_clear_stage_views (ClutterStage *stage);

View File

@ -175,11 +175,6 @@ static const ClutterColor default_stage_color = { 255, 255, 255, 255 };
static void free_queue_redraw_entry (QueueRedrawEntry *entry); static void free_queue_redraw_entry (QueueRedrawEntry *entry);
static void free_pointer_device_entry (PointerDeviceEntry *entry); static void free_pointer_device_entry (PointerDeviceEntry *entry);
static void capture_view_into (ClutterStage *stage,
ClutterStageView *view,
cairo_rectangle_int_t *rect,
uint8_t *data,
int stride);
static void clutter_stage_update_view_perspective (ClutterStage *stage); static void clutter_stage_update_view_perspective (ClutterStage *stage);
static void clutter_stage_set_viewport (ClutterStage *stage, static void clutter_stage_set_viewport (ClutterStage *stage,
float width, float width,
@ -3227,8 +3222,8 @@ clutter_stage_paint_to_buffer (ClutterStage *stage,
return TRUE; return TRUE;
} }
static void void
capture_view_into (ClutterStage *stage, clutter_stage_capture_view_into (ClutterStage *stage,
ClutterStageView *view, ClutterStageView *view,
cairo_rectangle_int_t *rect, cairo_rectangle_int_t *rect,
uint8_t *data, uint8_t *data,
@ -3247,6 +3242,11 @@ capture_view_into (ClutterStage *stage,
framebuffer = clutter_stage_view_get_framebuffer (view); framebuffer = clutter_stage_view_get_framebuffer (view);
clutter_stage_view_get_layout (view, &view_layout);
if (!rect)
rect = &view_layout;
view_scale = clutter_stage_view_get_scale (view); view_scale = clutter_stage_view_get_scale (view);
texture_width = roundf (rect->width * view_scale); texture_width = roundf (rect->width * view_scale);
texture_height = roundf (rect->height * view_scale); texture_height = roundf (rect->height * view_scale);
@ -3259,8 +3259,6 @@ capture_view_into (ClutterStage *stage,
stride, stride,
data); data);
clutter_stage_view_get_layout (view, &view_layout);
cogl_framebuffer_read_pixels_into_bitmap (framebuffer, cogl_framebuffer_read_pixels_into_bitmap (framebuffer,
roundf ((rect->x - view_layout.x) * view_scale), roundf ((rect->x - view_layout.x) * view_scale),
roundf ((rect->y - view_layout.y) * view_scale), roundf ((rect->y - view_layout.y) * view_scale),
@ -3300,9 +3298,11 @@ clutter_stage_capture_into (ClutterStage *stage,
x_offset = capture_rect.x - rect->x; x_offset = capture_rect.x - rect->x;
y_offset = capture_rect.y - rect->y; y_offset = capture_rect.y - rect->y;
capture_view_into (stage, view, clutter_stage_capture_view_into (stage, view,
&capture_rect, &capture_rect,
data + (x_offset * bpp) + (y_offset * stride), (data +
(x_offset * bpp) +
(y_offset * stride)),
stride); stride);
} }
} }