[mutter/wip/garnacho/wayland-emulated-output-transform: 9/15] clutter/cogl: Transform swap buffers regions into onscreen coordinates
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/garnacho/wayland-emulated-output-transform: 9/15] clutter/cogl: Transform swap buffers regions into onscreen coordinates
- Date: Mon, 8 Aug 2016 11:59:52 +0000 (UTC)
commit d23d8b4905c25027eecc3c130ebd984463071742
Author: Carlos Garnacho <carlosg gnome org>
Date: Mon Aug 8 12:42:44 2016 +0200
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
clutter/clutter/cogl/clutter-stage-cogl.c | 37 +++++++++++++++++++++++++++++
1 files changed, 37 insertions(+), 0 deletions(-)
---
diff --git a/clutter/clutter/cogl/clutter-stage-cogl.c b/clutter/clutter/cogl/clutter-stage-cogl.c
index 6bf2f7b..864917f 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,40 @@ 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 = (gdouble) swap_region->x / layout.width;
+ y1 = (gdouble) swap_region->y / layout.height;
+ x2 = (gdouble) (swap_region->x + swap_region->width) / layout.width;
+ y2 = (gdouble) (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->x = x1;
+ swap_region->y = y1;
+ swap_region->width = x2 - x1;
+ swap_region->height = y2 - y1;
+}
+
static gboolean
clutter_stage_cogl_redraw_view (ClutterStageWindow *stage_window,
ClutterStageView *view)
@@ -708,6 +743,8 @@ clutter_stage_cogl_redraw_view (ClutterStageWindow *stage_window,
if (do_swap_buffer)
{
+ transform_swap_region_to_onscreen (view, &swap_region);
+
return swap_framebuffer (stage_window,
view,
&swap_region,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]