summaryrefslogtreecommitdiff
path: root/src/cairo-gl-surface.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2009-05-22 23:44:27 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2009-07-21 22:30:14 +0100
commit911482e5ae88ba26a1b3290731968f8b8a80cd70 (patch)
tree9db1454370efa43554f8d94c26105303f7e1f69d /src/cairo-gl-surface.c
parent1ae5942a3aa9f73aa71438dc40221836b0dff7e2 (diff)
[gl] Constrain image sources to max texture size
Diffstat (limited to 'src/cairo-gl-surface.c')
-rw-r--r--src/cairo-gl-surface.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/cairo-gl-surface.c b/src/cairo-gl-surface.c
index d54c0a20..df130f84 100644
--- a/src/cairo-gl-surface.c
+++ b/src/cairo-gl-surface.c
@@ -130,6 +130,11 @@ _cairo_gl_context_init (cairo_gl_context_t *ctx)
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0,
GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ ctx->max_framebuffer_size = 0;
+ glGetIntegerv (GL_MAX_RENDERBUFFER_SIZE, &ctx->max_framebuffer_size);
+ ctx->max_texture_size = 0;
+ glGetIntegerv (GL_MAX_TEXTURE_SIZE, &ctx->max_texture_size);
+
return CAIRO_STATUS_SUCCESS;
}
@@ -459,6 +464,9 @@ cairo_gl_surface_create (cairo_gl_context_t *ctx,
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));
+
surface = calloc (1, sizeof (cairo_gl_surface_t));
if (unlikely (surface == NULL))
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
@@ -584,6 +592,12 @@ _cairo_gl_surface_create_similar (void *abstract_surface,
assert (CAIRO_CONTENT_VALID (content));
+ if (width > surface->ctx->max_framebuffer_size ||
+ height > surface->ctx->max_framebuffer_size)
+ {
+ return NULL;
+ }
+
if (width < 1)
width = 1;
if (height < 1)
@@ -946,6 +960,11 @@ _cairo_gl_pattern_image_texture_setup (cairo_gl_composite_operand_t *operand,
return CAIRO_INT_STATUS_UNSUPPORTED;
image_surface = (cairo_image_surface_t *)surface_pattern->surface;
+ if (image_surface->width > dst->ctx->max_texture_size ||
+ image_surface->height > dst->ctx->max_texture_size)
+ {
+ return CAIRO_INT_STATUS_UNSUPPORTED;
+ }
/* The textures we create almost always has appropriate alpha channel
* contents. But sometimes GL sucks at image specification and we end up