[PATCH] gl/msaa: Fix glScissor bounds

Martin Robinson <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
From: Martin Robinson <[email protected]>

When scissoring the compositing extents for windows, flip
the y coordinate as windows use a projection matrix that
does the same.
---
 src/cairo-gl-msaa-compositor.c |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/src/cairo-gl-msaa-compositor.c b/src/cairo-gl-msaa-compositor.c
index 01ef40f..08a4a2b 100644
--- a/src/cairo-gl-msaa-compositor.c
+++ b/src/cairo-gl-msaa-compositor.c
@@ -268,6 +268,18 @@ _prevent_overlapping_drawing (cairo_clip_t	*clip,
     glStencilOp (GL_ZERO, GL_ZERO, GL_ZERO);
 }
 
+static void
+_scissor_composite_extents (cairo_gl_surface_t		*surface,
+			    cairo_rectangle_int_t	*rect)
+{
+    int y = rect->y;
+    if (_cairo_gl_surface_is_texture (surface) == FALSE)
+	y = surface->height - (rect->y + rect->height);
+
+    glScissor (rect->x, y, rect->width, rect->height);
+    glEnable (GL_SCISSOR_TEST);
+}
+
 static cairo_int_status_t
 _cairo_gl_msaa_compositor_stroke (const cairo_compositor_t	*compositor,
 				  cairo_composite_rectangles_t	*composite,
@@ -312,9 +324,7 @@ _cairo_gl_msaa_compositor_stroke (const cairo_compositor_t	*compositor,
     if (unlikely (status))
 	goto finish;
 
-    glScissor (composite->unbounded.x, composite->unbounded.y,
-	       composite->unbounded.width, composite->unbounded.height);
-    glEnable (GL_SCISSOR_TEST);
+    _scissor_composite_extents (dst, &composite->unbounded);
 
     if (! _cairo_composite_rectangles_can_reduce_clip (composite,
 						       composite->clip))
@@ -398,9 +408,7 @@ _cairo_gl_msaa_compositor_fill (const cairo_compositor_t	*compositor,
     if (unlikely (status))
 	goto cleanup_setup;
 
-    glScissor (composite->unbounded.x, composite->unbounded.y,
-	       composite->unbounded.width, composite->unbounded.height);
-    glEnable (GL_SCISSOR_TEST);
+    _scissor_composite_extents (dst, &composite->unbounded);
 
     if (! _cairo_composite_rectangles_can_reduce_clip (composite,
 						       composite->clip))
-- 
1.7.7.237.g34c4

--
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.