From 9b1b4eb843aaababb797c57d91e8d2dd3bf7c72b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Wed, 27 Jan 2021 23:14:29 +0100 Subject: [PATCH] clutter: Expose 'capture_view_into()` as API It'll be used to explicitly capture the content of a single view. Part-of: --- clutter/clutter/clutter-mutter.h | 7 +++++++ clutter/clutter/clutter-stage.c | 34 ++++++++++++++++---------------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/clutter/clutter/clutter-mutter.h b/clutter/clutter/clutter-mutter.h index 8f4e2390a..88dee2658 100644 --- a/clutter/clutter/clutter-mutter.h +++ b/clutter/clutter/clutter-mutter.h @@ -54,6 +54,13 @@ void clutter_stage_capture_into (ClutterStage *stage, cairo_rectangle_int_t *rect, 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 void clutter_stage_clear_stage_views (ClutterStage *stage); diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c index 6e46187c5..5b574b5e1 100644 --- a/clutter/clutter/clutter-stage.c +++ b/clutter/clutter/clutter-stage.c @@ -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_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_set_viewport (ClutterStage *stage, float width, @@ -3227,12 +3222,12 @@ clutter_stage_paint_to_buffer (ClutterStage *stage, return TRUE; } -static void -capture_view_into (ClutterStage *stage, - ClutterStageView *view, - cairo_rectangle_int_t *rect, - uint8_t *data, - int stride) +void +clutter_stage_capture_view_into (ClutterStage *stage, + ClutterStageView *view, + cairo_rectangle_int_t *rect, + uint8_t *data, + int stride) { CoglFramebuffer *framebuffer; ClutterBackend *backend; @@ -3247,6 +3242,11 @@ capture_view_into (ClutterStage *stage, 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); texture_width = roundf (rect->width * view_scale); texture_height = roundf (rect->height * view_scale); @@ -3259,8 +3259,6 @@ capture_view_into (ClutterStage *stage, stride, data); - clutter_stage_view_get_layout (view, &view_layout); - cogl_framebuffer_read_pixels_into_bitmap (framebuffer, roundf ((rect->x - view_layout.x) * view_scale), roundf ((rect->y - view_layout.y) * view_scale), @@ -3300,10 +3298,12 @@ clutter_stage_capture_into (ClutterStage *stage, x_offset = capture_rect.x - rect->x; y_offset = capture_rect.y - rect->y; - capture_view_into (stage, view, - &capture_rect, - data + (x_offset * bpp) + (y_offset * stride), - stride); + clutter_stage_capture_view_into (stage, view, + &capture_rect, + (data + + (x_offset * bpp) + + (y_offset * stride)), + stride); } }