diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2009-10-21 10:36:27 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2009-10-21 11:37:16 +0100 |
commit | f0cd20e6cec445eb627c2708c2230c8bad1b64ce (patch) | |
tree | 86a409633d5fb88a9eafaa746b3b69a05b619e2d /src/cairo-gl-surface.c | |
parent | 7c9ebd4a852ad709e57ed48b9610db00de79de7e (diff) |
[gl] Do not clear internal surfaces.
Create a scratch surface that will be initialised as required for
internal use. External surfaces, i.e. those returned to the user, are
cleared as normal.
Diffstat (limited to 'src/cairo-gl-surface.c')
-rw-r--r-- | src/cairo-gl-surface.c | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/src/cairo-gl-surface.c b/src/cairo-gl-surface.c index 5d4853dd..29bf950d 100644 --- a/src/cairo-gl-surface.c +++ b/src/cairo-gl-surface.c @@ -450,28 +450,20 @@ _cairo_gl_surface_init (cairo_gl_context_t *ctx, surface->height = height; } -cairo_surface_t * -cairo_gl_surface_create (cairo_gl_context_t *ctx, - cairo_content_t content, - int width, - int height) +static cairo_surface_t * +_cairo_gl_surface_create_scratch (cairo_gl_context_t *ctx, + cairo_content_t content, + int width, + int height) { cairo_gl_surface_t *surface; GLenum err, format; cairo_status_t status; - if (!CAIRO_CONTENT_VALID (content)) - return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_CONTENT)); - - if (ctx == NULL) { - return cairo_image_surface_create (_cairo_format_from_content (content), - width, height); - } if (ctx->status) return _cairo_surface_create_in_error (ctx->status); - if (width > ctx->max_framebuffer_size || height > ctx->max_framebuffer_size) - return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE)); + assert (width <= ctx->max_framebuffer_size && height <= ctx->max_framebuffer_size); surface = calloc (1, sizeof (cairo_gl_surface_t)); if (unlikely (surface == NULL)) @@ -520,6 +512,30 @@ cairo_gl_surface_create (cairo_gl_context_t *ctx, if (status != GL_FRAMEBUFFER_COMPLETE_EXT) fprintf (stderr, "destination is framebuffer incomplete\n"); + return &surface->base; +} + +cairo_surface_t * +cairo_gl_surface_create (cairo_gl_context_t *ctx, + cairo_content_t content, + int width, + int height) +{ + cairo_gl_surface_t *surface; + + if (!CAIRO_CONTENT_VALID (content)) + return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_CONTENT)); + + if (ctx == NULL) { + return cairo_image_surface_create (_cairo_format_from_content (content), + width, height); + } + + surface = (cairo_gl_surface_t *) + _cairo_gl_surface_create_scratch (ctx, content, width, height); + if (unlikely (surface->base.status)) + return &surface->base; + /* Cairo surfaces start out initialized to transparent (black) */ ctx = _cairo_gl_context_acquire (surface->ctx); _cairo_gl_set_destination (surface); @@ -611,7 +627,7 @@ _cairo_gl_surface_create_similar (void *abstract_surface, if (height < 1) height = 1; - return cairo_gl_surface_create (surface->ctx, content, width, height); + return _cairo_gl_surface_create_scratch (surface->ctx, content, width, height); } cairo_status_t |