[cairo-commit] 3 commits - src/cairo-gl-composite.c src/cairo-gl-device.c src/cairo-gl-surface.c

Martin Robinson mrobinson at kemper.freedesktop.org
Mon Jul 15 19:31:42 PDT 2013


 src/cairo-gl-composite.c |   15 +++++++++------
 src/cairo-gl-device.c    |   28 ++++++++++++++++++++++++++++
 src/cairo-gl-surface.c   |    2 ++
 3 files changed, 39 insertions(+), 6 deletions(-)

New commits:
commit 03c81d414d4edb710c91f96ddb7dbf73e5432583
Author: Henry Song <henry.song at samsung.com>
Date:   Mon Jul 8 11:36:25 2013 -0700

    gl/msaa: Always use scissor when clipping
    
    Even when using the stencil buffer for clipping, always scissor the clip
    extents. This simplifies the code a bit.

diff --git a/src/cairo-gl-composite.c b/src/cairo-gl-composite.c
index b771979..30b7931 100644
--- a/src/cairo-gl-composite.c
+++ b/src/cairo-gl-composite.c
@@ -570,10 +570,14 @@ _cairo_gl_composite_setup_painted_clipping (cairo_gl_composite_t *setup,
 	goto disable_stencil_buffer_and_return;
     }
 
+    /* We only want to clear the part of the stencil buffer
+     * that we are about to use. It also does not hurt to
+     * scissor around the painted clip. */
+    _cairo_gl_scissor_to_rectangle (dst, _cairo_clip_get_extents (clip));
+
     /* The clip is not rectangular, so use the stencil buffer. */
     glDepthMask (GL_TRUE);
     glEnable (GL_STENCIL_TEST);
-    glDisable (GL_SCISSOR_TEST);
 
     /* Texture surfaces have private depth/stencil buffers, so we can
      * rely on any previous clip being cached there. */
@@ -582,10 +586,7 @@ _cairo_gl_composite_setup_painted_clipping (cairo_gl_composite_t *setup,
 	if (_cairo_clip_equal (old_clip, setup->clip))
 	    goto activate_stencil_buffer_and_return;
 
-      /* Clear the stencil buffer, but only the areas that we are
-       * going to be drawing to. */
 	if (old_clip) {
-	    _cairo_gl_scissor_to_rectangle (dst, _cairo_clip_get_extents (old_clip));
 	    _cairo_clip_destroy (setup->dst->clip_on_stencil_buffer);
 	}
 
@@ -594,7 +595,6 @@ _cairo_gl_composite_setup_painted_clipping (cairo_gl_composite_t *setup,
 
     glClearStencil (0);
     glClear (GL_STENCIL_BUFFER_BIT);
-    glDisable (GL_SCISSOR_TEST);
 
     glStencilOp (GL_REPLACE, GL_REPLACE, GL_REPLACE);
     glStencilFunc (GL_EQUAL, 1, 0xffffffff);
commit 8c710ed87244321dc18447936d629decc25d3d09
Author: Henry Song <henry.song at samsung.com>
Date:   Sun Jul 7 11:00:28 2013 -0700

    gl/msaa: Disable stencil and scissor during framebuffer blit
    
    When blitting the framebuffer during transitions to and from
    multi-sampling mode, we need to disable the stencil and scissor test so
    that the entire surface is preserved. This fixes the bitmap-font test
    for the MSAA compositor.

diff --git a/src/cairo-gl-device.c b/src/cairo-gl-device.c
index 91ce9de..054f145 100644
--- a/src/cairo-gl-device.c
+++ b/src/cairo-gl-device.c
@@ -618,6 +618,9 @@ static void
 bind_multisample_framebuffer (cairo_gl_context_t *ctx,
 			       cairo_gl_surface_t *surface)
 {
+    cairo_bool_t stencil_test_enabled;
+    cairo_bool_t scissor_test_enabled;
+
     assert (surface->supports_msaa);
     assert (ctx->gl_flavor == CAIRO_GL_FLAVOR_DESKTOP);
 
@@ -631,6 +634,12 @@ bind_multisample_framebuffer (cairo_gl_context_t *ctx,
     }
 
     _cairo_gl_composite_flush (ctx);
+
+    stencil_test_enabled = glIsEnabled (GL_STENCIL_TEST);
+    scissor_test_enabled = glIsEnabled (GL_SCISSOR_TEST);
+    glDisable (GL_STENCIL_TEST);
+    glDisable (GL_SCISSOR_TEST);
+
     glEnable (GL_MULTISAMPLE);
 
     /* The last time we drew to the surface, we were not using multisampling,
@@ -642,6 +651,11 @@ bind_multisample_framebuffer (cairo_gl_context_t *ctx,
 				   0, 0, surface->width, surface->height,
 				   GL_COLOR_BUFFER_BIT, GL_NEAREST);
     ctx->dispatch.BindFramebuffer (GL_FRAMEBUFFER, surface->msaa_fb);
+
+    if (stencil_test_enabled)
+	glEnable (GL_STENCIL_TEST);
+    if (scissor_test_enabled)
+	glEnable (GL_SCISSOR_TEST);
 }
 #endif
 
@@ -650,6 +664,9 @@ static void
 bind_singlesample_framebuffer (cairo_gl_context_t *ctx,
 			       cairo_gl_surface_t *surface)
 {
+    cairo_bool_t stencil_test_enabled;
+    cairo_bool_t scissor_test_enabled;
+
     assert (ctx->gl_flavor == CAIRO_GL_FLAVOR_DESKTOP);
     _cairo_gl_ensure_framebuffer (ctx, surface);
 
@@ -660,6 +677,12 @@ bind_singlesample_framebuffer (cairo_gl_context_t *ctx,
     }
 
     _cairo_gl_composite_flush (ctx);
+
+    stencil_test_enabled = glIsEnabled (GL_STENCIL_TEST);
+    scissor_test_enabled = glIsEnabled (GL_SCISSOR_TEST);
+    glDisable (GL_STENCIL_TEST);
+    glDisable (GL_SCISSOR_TEST);
+
     glDisable (GL_MULTISAMPLE);
 
     /* The last time we drew to the surface, we were using multisampling,
@@ -671,6 +694,11 @@ bind_singlesample_framebuffer (cairo_gl_context_t *ctx,
 				   0, 0, surface->width, surface->height,
 				   GL_COLOR_BUFFER_BIT, GL_NEAREST);
     ctx->dispatch.BindFramebuffer (GL_FRAMEBUFFER, surface->fb);
+
+    if (stencil_test_enabled)
+	glEnable (GL_STENCIL_TEST);
+    if (scissor_test_enabled)
+	glEnable (GL_SCISSOR_TEST);
 }
 #endif
 
commit be2c09a1f59ad677a2b4718d26687873093b466c
Author: Henry Song <henry.song at samsung.com>
Date:   Wed Jul 3 12:22:55 2013 -0700

    gl/msaa: Properly destroy stencil buffer clip cache
    
    When replacing the stencil buffer clip cache or destroying a surface,
    destroy the cached clip. This prevents the clip from leaking.

diff --git a/src/cairo-gl-composite.c b/src/cairo-gl-composite.c
index 68c9b80..b771979 100644
--- a/src/cairo-gl-composite.c
+++ b/src/cairo-gl-composite.c
@@ -584,8 +584,11 @@ _cairo_gl_composite_setup_painted_clipping (cairo_gl_composite_t *setup,
 
       /* Clear the stencil buffer, but only the areas that we are
        * going to be drawing to. */
-	if (old_clip)
+	if (old_clip) {
 	    _cairo_gl_scissor_to_rectangle (dst, _cairo_clip_get_extents (old_clip));
+	    _cairo_clip_destroy (setup->dst->clip_on_stencil_buffer);
+	}
+
 	setup->dst->clip_on_stencil_buffer = _cairo_clip_copy (setup->clip);
     }
 
diff --git a/src/cairo-gl-surface.c b/src/cairo-gl-surface.c
index d7a7836..f6b7928 100644
--- a/src/cairo-gl-surface.c
+++ b/src/cairo-gl-surface.c
@@ -1033,6 +1033,8 @@ _cairo_gl_surface_finish (void *abstract_surface)
 	ctx->dispatch.DeleteRenderbuffers (1, &surface->msaa_rb);
 #endif
 
+    _cairo_clip_destroy (surface->clip_on_stencil_buffer);
+
     return _cairo_gl_context_release (ctx, status);
 }
 


More information about the cairo-commit mailing list