diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2016-08-08 12:42:44 +0200 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2016-08-23 19:24:35 +0200 |
commit | 534f3aa5c979f5a856edb8cc371a823b608926e2 (patch) | |
tree | f531fadbb8cac1815f8f1aff4e089fb3ac8b11ee | |
parent | f1a0985e3a7d2c20c25f9d9353ebc822e282ccb2 (diff) | |
download | mutter-534f3aa5c979f5a856edb8cc371a823b608926e2.tar.gz |
clutter/cogl: Transform swap buffers regions into onscreen coordinates
Those are given in view coordinates, so we must transform into onscreen
coordinates in order to perform swap_buffers on the right damage regions.
https://bugzilla.gnome.org/show_bug.cgi?id=745079
-rw-r--r-- | clutter/clutter/cogl/clutter-stage-cogl.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/clutter/clutter/cogl/clutter-stage-cogl.c b/clutter/clutter/cogl/clutter-stage-cogl.c index 6bf2f7b0a..f47573512 100644 --- a/clutter/clutter/cogl/clutter-stage-cogl.c +++ b/clutter/clutter/cogl/clutter-stage-cogl.c @@ -37,6 +37,7 @@ #include "clutter-stage-cogl.h" #include <stdlib.h> +#include <math.h> #include "clutter-actor-private.h" #include "clutter-backend-private.h" @@ -438,6 +439,42 @@ fill_current_damage_history_and_step (ClutterStageView *view) view_priv->damage_index++; } +static void +transform_swap_region_to_onscreen (ClutterStageView *view, + cairo_rectangle_int_t *swap_region) +{ + CoglFramebuffer *framebuffer; + cairo_rectangle_int_t layout; + gfloat x1, y1, x2, y2; + gint width, height; + + framebuffer = clutter_stage_view_get_onscreen (view); + clutter_stage_view_get_layout (view, &layout); + + x1 = (float) swap_region->x / layout.width; + y1 = (float) swap_region->y / layout.height; + x2 = (float) (swap_region->x + swap_region->width) / layout.width; + y2 = (float) (swap_region->y + swap_region->height) / layout.height; + + clutter_stage_view_transform_to_onscreen (view, &x1, &y1); + clutter_stage_view_transform_to_onscreen (view, &x2, &y2); + + width = cogl_framebuffer_get_width (framebuffer); + height = cogl_framebuffer_get_height (framebuffer); + + x1 = floor (x1 * width); + y1 = floor (height - (y1 * height)); + x2 = ceil (x2 * width); + y2 = ceil (height - (y2 * height)); + + *swap_region = (cairo_rectangle_int_t) { + .x = x1, + .y = y1, + .width = x2 - x1, + .height = y2 - y1 + }; +} + static gboolean clutter_stage_cogl_redraw_view (ClutterStageWindow *stage_window, ClutterStageView *view) @@ -708,6 +745,12 @@ clutter_stage_cogl_redraw_view (ClutterStageWindow *stage_window, if (do_swap_buffer) { + if (clutter_stage_view_get_onscreen (view) != + clutter_stage_view_get_framebuffer (view)) + { + transform_swap_region_to_onscreen (view, &swap_region); + } + return swap_framebuffer (stage_window, view, &swap_region, |