diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2009-07-23 14:46:16 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2009-07-23 15:32:12 +0100 |
commit | f5a1cdf283a6aa1f4409ccbf3c2274fb587724fe (patch) | |
tree | b2059ff9013b3996c614b5882ff5be09e481eb1e /src/cairo-gl-surface.c | |
parent | eed17527f62eab826af65258b60cd4545a71a22d (diff) |
[gl] Simplify the common CLEAR of a surface
Almost every surface is at sometime cleared, so catch the operation in
paint(), and emit a simple glClear() instead.
Diffstat (limited to 'src/cairo-gl-surface.c')
-rw-r--r-- | src/cairo-gl-surface.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/cairo-gl-surface.c b/src/cairo-gl-surface.c index a5915941..571fc963 100644 --- a/src/cairo-gl-surface.c +++ b/src/cairo-gl-surface.c @@ -1861,6 +1861,29 @@ _cairo_gl_surface_get_font_options (void *abstract_surface, cairo_font_options_set_hint_metrics (options, CAIRO_HINT_METRICS_ON); } + +static cairo_int_status_t +_cairo_gl_surface_paint (void *abstract_surface, + cairo_operator_t op, + const cairo_pattern_t *source, + cairo_clip_t *clip) +{ + /* simplify the common case of clearing the surface */ + if (op == CAIRO_OPERATOR_CLEAR && clip == NULL) { + cairo_gl_surface_t *surface = abstract_surface; + cairo_gl_context_t *ctx; + + ctx = _cairo_gl_context_acquire (surface->ctx); + _cairo_gl_set_destination (surface); + glClear (GL_COLOR_BUFFER_BIT); + _cairo_gl_context_release (ctx); + + return CAIRO_STATUS_SUCCESS; + } + + return CAIRO_INT_STATUS_UNSUPPORTED; +} + static const cairo_surface_backend_t _cairo_gl_surface_backend = { CAIRO_SURFACE_TYPE_GL, _cairo_gl_surface_create_similar, @@ -1886,7 +1909,7 @@ static const cairo_surface_backend_t _cairo_gl_surface_backend = { NULL, /* mark_dirty_rectangle */ NULL, /* scaled_font_fini */ NULL, /* scaled_glyph_fini */ - NULL, /* paint */ + _cairo_gl_surface_paint, NULL, /* mask */ NULL, /* stroke */ NULL, /* fill */ |