summaryrefslogtreecommitdiff
path: root/src/cairo-gl-msaa-compositor.c
diff options
context:
space:
mode:
authorHenry (Yu) Song <hsong@sisa.samsung.com>2011-12-16 15:56:00 -0800
committerMartin Robinson <mrobinson@igalia.com>2012-05-17 11:06:47 -0700
commit4d9064d578434cadfae2b248ef29075a1a1be8b8 (patch)
tree1c75b5300acef5175a071395c4a21f4ca593cd70 /src/cairo-gl-msaa-compositor.c
parent50f08352f463d86022a0d7544d461fe2e5ac9076 (diff)
gl/msaa: Add ARB multisampling support
This implementation is not very efficient at the moment and does not work with platforms using the incompatible IMG extension (mobile GPUs). Performance improvements and mobile GPU support will follow.
Diffstat (limited to 'src/cairo-gl-msaa-compositor.c')
-rw-r--r--src/cairo-gl-msaa-compositor.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/cairo-gl-msaa-compositor.c b/src/cairo-gl-msaa-compositor.c
index 87cc535a..0080d142 100644
--- a/src/cairo-gl-msaa-compositor.c
+++ b/src/cairo-gl-msaa-compositor.c
@@ -319,6 +319,17 @@ finish:
return status;
}
+static cairo_bool_t
+should_fall_back (cairo_gl_surface_t *surface,
+ cairo_antialias_t antialias)
+{
+ if (antialias == CAIRO_ANTIALIAS_FAST)
+ return TRUE;
+ if (antialias == CAIRO_ANTIALIAS_NONE)
+ return FALSE;
+ return ! surface->supports_msaa;
+}
+
static cairo_int_status_t
_cairo_gl_msaa_compositor_paint (const cairo_compositor_t *compositor,
cairo_composite_rectangles_t *composite)
@@ -337,6 +348,9 @@ _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))
+ return CAIRO_INT_STATUS_UNSUPPORTED;
+
/* GL compositing operators cannot properly represent a mask operation
using the SOURCE compositing operator in one pass. This only matters if
there actually is a mask (there isn't in a paint operation) and if the
@@ -394,7 +408,9 @@ _cairo_gl_msaa_compositor_mask (const cairo_compositor_t *compositor,
if (unlikely (status))
goto finish;
- status = _cairo_gl_composite_begin (&setup, &ctx);
+ /* We always use multisampling here, because we do not yet have the smarts
+ to calculate when the clip or the source requires it. */
+ status = _cairo_gl_composite_begin_multisample (&setup, &ctx, TRUE);
if (unlikely (status))
goto finish;
@@ -493,7 +509,7 @@ _cairo_gl_msaa_compositor_stroke (const cairo_compositor_t *compositor,
struct _tristrip_composite_info info;
cairo_bool_t used_stencil_buffer_for_clip;
- if (antialias != CAIRO_ANTIALIAS_NONE)
+ if (should_fall_back (dst, antialias))
return CAIRO_INT_STATUS_UNSUPPORTED;
if (composite->is_bounded == FALSE) {
@@ -531,7 +547,8 @@ _cairo_gl_msaa_compositor_stroke (const cairo_compositor_t *compositor,
if (unlikely (status))
goto finish;
- status = _cairo_gl_composite_begin (&info.setup, &info.ctx);
+ status = _cairo_gl_composite_begin_multisample (&info.setup, &info.ctx,
+ antialias != CAIRO_ANTIALIAS_NONE);
if (unlikely (status))
goto finish;
@@ -586,7 +603,7 @@ _cairo_gl_msaa_compositor_fill (const cairo_compositor_t *compositor,
cairo_traps_t traps;
cairo_bool_t used_stencil_buffer;
- if (antialias != CAIRO_ANTIALIAS_NONE)
+ if (should_fall_back (dst, antialias))
return CAIRO_INT_STATUS_UNSUPPORTED;
if (composite->is_bounded == FALSE) {
@@ -629,7 +646,8 @@ _cairo_gl_msaa_compositor_fill (const cairo_compositor_t *compositor,
if (unlikely (status))
goto cleanup_setup;
- status = _cairo_gl_composite_begin (&setup, &ctx);
+ status = _cairo_gl_composite_begin_multisample (&setup, &ctx,
+ antialias != CAIRO_ANTIALIAS_NONE);
if (unlikely (status))
goto cleanup_setup;