[cairo-commit] 2 commits - src/cairo-gl-composite.c src/cairo-gl-msaa-compositor.c
Martin Robinson
mrobinson at kemper.freedesktop.org
Thu May 17 14:53:05 PDT 2012
src/cairo-gl-composite.c | 37 ++++++++++++++++++++++++-------------
src/cairo-gl-msaa-compositor.c | 33 ++++++++++++++++-----------------
2 files changed, 40 insertions(+), 30 deletions(-)
New commits:
commit ced090871bbc4c052fd4ac627cdd8fc7e80f0d62
Author: Martin Robinson <mrobinson at igalia.com>
Date: Thu May 17 14:37:57 2012 -0700
gl/msaa: Improve fallback detection
Rename should_fall_back to can_use_msaa_compositor to make it
more comprehensible and also modify the logic to fall back
when the antialias mode is not "fast" or "default."
diff --git a/src/cairo-gl-msaa-compositor.c b/src/cairo-gl-msaa-compositor.c
index 1054457..35715d3 100644
--- a/src/cairo-gl-msaa-compositor.c
+++ b/src/cairo-gl-msaa-compositor.c
@@ -48,8 +48,8 @@
#include "cairo-traps-private.h"
static cairo_bool_t
-should_fall_back (cairo_gl_surface_t *surface,
- cairo_antialias_t antialias);
+can_use_msaa_compositor (cairo_gl_surface_t *surface,
+ cairo_antialias_t antialias);
static void
query_surface_capabilities (cairo_gl_surface_t *surface);
@@ -252,12 +252,12 @@ finish:
}
static cairo_bool_t
-should_fall_back (cairo_gl_surface_t *surface,
- cairo_antialias_t antialias)
+can_use_msaa_compositor (cairo_gl_surface_t *surface,
+ cairo_antialias_t antialias)
{
query_surface_capabilities (surface);
if (! surface->supports_stencil)
- return TRUE;
+ return FALSE;
/* Multisampling OpenGL ES surfaces only maintain one multisampling
framebuffer and thus must use the spans compositor to do non-antialiased
@@ -265,13 +265,16 @@ should_fall_back (cairo_gl_surface_t *surface,
if (((cairo_gl_context_t *) surface->base.device)->gl_flavor == CAIRO_GL_FLAVOR_ES
&& surface->supports_msaa
&& antialias == CAIRO_ANTIALIAS_NONE)
- return TRUE;
+ return FALSE;
- if (antialias == CAIRO_ANTIALIAS_FAST)
- return TRUE;
+ /* The MSAA compositor has a single-sample mode, so we can
+ support non-antialiased rendering. */
if (antialias == CAIRO_ANTIALIAS_NONE)
- return FALSE;
- return ! surface->supports_msaa;
+ return TRUE;
+
+ if (antialias == CAIRO_ANTIALIAS_FAST || antialias == CAIRO_ANTIALIAS_DEFAULT)
+ return surface->supports_msaa;
+ return FALSE;
}
static void
@@ -293,7 +296,7 @@ _cairo_gl_msaa_compositor_mask (const cairo_compositor_t *compositor,
cairo_int_status_t status;
cairo_operator_t op = composite->op;
- if (should_fall_back (dst, CAIRO_ANTIALIAS_GOOD))
+ if (! can_use_msaa_compositor (dst, CAIRO_ANTIALIAS_DEFAULT))
return CAIRO_INT_STATUS_UNSUPPORTED;
/* GL compositing operators cannot properly represent a mask operation
@@ -497,7 +500,7 @@ _cairo_gl_msaa_compositor_stroke (const cairo_compositor_t *compositor,
cairo_gl_surface_t *dst = (cairo_gl_surface_t *) composite->surface;
struct _tristrip_composite_info info;
- if (should_fall_back (dst, antialias))
+ if (! can_use_msaa_compositor (dst, antialias))
return CAIRO_INT_STATUS_UNSUPPORTED;
if (composite->is_bounded == FALSE) {
@@ -581,7 +584,7 @@ _cairo_gl_msaa_compositor_fill (const cairo_compositor_t *compositor,
cairo_int_status_t status;
cairo_traps_t traps;
- if (should_fall_back (dst, antialias))
+ if (! can_use_msaa_compositor (dst, antialias))
return CAIRO_INT_STATUS_UNSUPPORTED;
if (composite->is_bounded == FALSE) {
commit 707bb8663980e66e8406351b68c230b63a0265c6
Author: Martin Robinson <mrobinson at igalia.com>
Date: Mon Apr 2 13:45:15 2012 -0700
gl/msaa: Lazily flush the context
Instead of conservatively flushing after every single drawing
operation. Wait until we are certain we need to flush, which
in the case of the MSAA compositor is when we start compositing
with a different type of geometry.
diff --git a/src/cairo-gl-composite.c b/src/cairo-gl-composite.c
index 6063dca..b4c3e3d 100644
--- a/src/cairo-gl-composite.c
+++ b/src/cairo-gl-composite.c
@@ -789,12 +789,27 @@ _cairo_gl_composite_flush (cairo_gl_context_t *ctx)
_cairo_gl_glyph_cache_unlock (&ctx->glyph_cache[i]);
}
+typedef enum cairo_gl_geometry {
+ CAIRO_GL_GEOMETRY_TYPE_TRIANGLES,
+ CAIRO_GL_GEOMETRY_TYPE_TRISTRIPS
+} cairo_gl_geometry_t;
+
static void
_cairo_gl_composite_prepare_buffer (cairo_gl_context_t *ctx,
- unsigned int n_vertices)
+ unsigned int n_vertices,
+ cairo_gl_geometry_t geometry_type)
{
cairo_gl_dispatch_t *dispatch = &ctx->dispatch;
+ size_t tristrip_indices =_cairo_array_num_elements (&ctx->tristrip_indices);
+ if (geometry_type == CAIRO_GL_GEOMETRY_TYPE_TRIANGLES &&
+ tristrip_indices != 0) {
+ _cairo_gl_composite_flush (ctx);
+ } else if (geometry_type == CAIRO_GL_GEOMETRY_TYPE_TRISTRIPS &&
+ ! _cairo_gl_context_is_flushed (ctx) && tristrip_indices == 0) {
+ _cairo_gl_composite_flush (ctx);
+ }
+
if (ctx->vb_offset + n_vertices * ctx->vertex_size > CAIRO_GL_VBO_SIZE)
_cairo_gl_composite_flush (ctx);
@@ -859,7 +874,8 @@ _cairo_gl_composite_emit_rect (cairo_gl_context_t *ctx,
GLfloat y2,
uint8_t alpha)
{
- _cairo_gl_composite_prepare_buffer (ctx, 6);
+ _cairo_gl_composite_prepare_buffer (ctx, 6,
+ CAIRO_GL_GEOMETRY_TYPE_TRIANGLES);
_cairo_gl_composite_emit_vertex (ctx, x1, y1, alpha);
_cairo_gl_composite_emit_vertex (ctx, x2, y1, alpha);
@@ -901,7 +917,8 @@ _cairo_gl_composite_emit_glyph (cairo_gl_context_t *ctx,
GLfloat glyph_x2,
GLfloat glyph_y2)
{
- _cairo_gl_composite_prepare_buffer (ctx, 6);
+ _cairo_gl_composite_prepare_buffer (ctx, 6,
+ CAIRO_GL_GEOMETRY_TYPE_TRIANGLES);
_cairo_gl_composite_emit_glyph_vertex (ctx, x1, y1, glyph_x1, glyph_y1);
_cairo_gl_composite_emit_glyph_vertex (ctx, x2, y1, glyph_x2, glyph_y1);
@@ -988,11 +1005,8 @@ _cairo_gl_composite_emit_quad_as_tristrip (cairo_gl_context_t *ctx,
cairo_gl_composite_t *setup,
const cairo_point_t quad[4])
{
- if (_cairo_array_num_elements (&ctx->tristrip_indices) == 0 &&
- ! _cairo_gl_context_is_flushed (ctx))
- _cairo_gl_composite_flush (ctx);
-
- _cairo_gl_composite_prepare_buffer (ctx, 4);
+ _cairo_gl_composite_prepare_buffer (ctx, 4,
+ CAIRO_GL_GEOMETRY_TYPE_TRISTRIPS);
_cairo_gl_composite_emit_point (ctx, &quad[0], 0);
_cairo_gl_composite_emit_point (ctx, &quad[1], 0);
@@ -1011,11 +1025,8 @@ _cairo_gl_composite_emit_triangle_as_tristrip (cairo_gl_context_t *ctx,
cairo_gl_composite_t *setup,
const cairo_point_t triangle[3])
{
- if (_cairo_array_num_elements (&ctx->tristrip_indices) == 0 &&
- ! _cairo_gl_context_is_flushed (ctx))
- _cairo_gl_composite_flush (ctx);
-
- _cairo_gl_composite_prepare_buffer (ctx, 3);
+ _cairo_gl_composite_prepare_buffer (ctx, 3,
+ CAIRO_GL_GEOMETRY_TYPE_TRISTRIPS);
_cairo_gl_composite_emit_point (ctx, &triangle[0], 0);
_cairo_gl_composite_emit_point (ctx, &triangle[1], 0);
diff --git a/src/cairo-gl-msaa-compositor.c b/src/cairo-gl-msaa-compositor.c
index f0a8c96..1054457 100644
--- a/src/cairo-gl-msaa-compositor.c
+++ b/src/cairo-gl-msaa-compositor.c
@@ -373,7 +373,6 @@ _cairo_gl_msaa_compositor_mask (const cairo_compositor_t *compositor,
goto finish;
_draw_int_rect (ctx, &setup, &composite->bounded);
- _cairo_gl_composite_flush (ctx);
finish:
_cairo_gl_composite_fini (&setup);
@@ -559,8 +558,6 @@ _cairo_gl_msaa_compositor_stroke (const cairo_compositor_t *compositor,
if (unlikely (status))
goto finish;
- _cairo_gl_composite_flush (info.ctx);
-
finish:
_cairo_gl_composite_fini (&info.setup);
@@ -638,7 +635,6 @@ _cairo_gl_msaa_compositor_fill (const cairo_compositor_t *compositor,
if (unlikely (status))
goto cleanup_setup;
- _cairo_gl_composite_flush (ctx);
cleanup_setup:
_cairo_gl_composite_fini (&setup);
More information about the cairo-commit
mailing list