@@ -1014,7 +1014,12 @@ _cairo_gl_composite_flush (cairo_gl_context_t *ctx)
count = ctx->vb_offset / ctx->vertex_size;
- ctx->dispatch.UnmapBuffer (GL_ARRAY_BUFFER);
+ if (ctx->has_map_buffer)
+ ctx->dispatch.UnmapBuffer (GL_ARRAY_BUFFER);
+ else
+ ctx->dispatch.BufferData (GL_ARRAY_BUFFER, ctx->vb_offset,
+ ctx->vb, GL_STREAM_DRAW);
+
ctx->vb = NULL;
ctx->vb_offset = 0;
@@ -1044,9 +1049,14 @@ _cairo_gl_composite_prepare_buffer (cairo_gl_context_t *ctx,
_cairo_gl_composite_flush (ctx);
if (ctx->vb == NULL) {
- dispatch->BufferData (GL_ARRAY_BUFFER, CAIRO_GL_VBO_SIZE,
- NULL, GL_STREAM_DRAW);
- ctx->vb = dispatch->MapBuffer (GL_ARRAY_BUFFER, GL_WRITE_ONLY);
+ if (ctx->has_map_buffer) {
+ dispatch->BufferData (GL_ARRAY_BUFFER, CAIRO_GL_VBO_SIZE,
+ NULL, GL_STREAM_DRAW);
+ ctx->vb = dispatch->MapBuffer (GL_ARRAY_BUFFER, GL_WRITE_ONLY);
+ }
+ else {
+ ctx->vb = ctx->vb_mem;
+ }
}
}
@@ -132,6 +132,8 @@ _gl_destroy (void *device)
cairo_region_destroy (ctx->clip_region);
+ free (ctx->vb_mem);
+
ctx->destroy (ctx);
free (ctx);
@@ -191,6 +193,10 @@ _cairo_gl_context_init (cairo_gl_context_t *ctx)
! _cairo_gl_has_extension ("GL_EXT_texture_format_BGRA8888"))
return _cairo_error (CAIRO_STATUS_DEVICE_ERROR);
+ ctx->has_map_buffer = (gl_flavor == CAIRO_GL_FLAVOR_DESKTOP ||
+ (gl_flavor == CAIRO_GL_FLAVOR_ES &&
+ _cairo_gl_has_extension ("GL_OES_mapbuffer")));
+
ctx->has_mesa_pack_invert =
_cairo_gl_has_extension ("GL_MESA_pack_invert");
@@ -209,6 +215,14 @@ _cairo_gl_context_init (cairo_gl_context_t *ctx)
if (unlikely (status))
return status;
+ if (! ctx->has_map_buffer) {
+ ctx->vb_mem = _cairo_malloc_ab (CAIRO_GL_VBO_SIZE, 1);
+ if (unlikely (ctx->vb_mem == NULL)) {
+ _cairo_cache_fini (&ctx->gradients);
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ }
+ }
+
/* PBO for any sort of texture upload */
dispatch->GenBuffers (1, &ctx->texture_load_pbo);
dispatch->GenBuffers (1, &ctx->vbo);
@@ -125,8 +125,7 @@ _cairo_gl_dispatch_init_buffers (cairo_gl_dispatch_t *dispatch,
return CAIRO_STATUS_DEVICE_ERROR;
}
else if (gl_flavor == CAIRO_GL_FLAVOR_ES &&
- gl_version >= CAIRO_GL_VERSION_ENCODE (2, 0) &&
- _cairo_gl_has_extension ("GL_OES_mapbuffer"))
+ gl_version >= CAIRO_GL_VERSION_ENCODE (2, 0))
{
dispatch_name = CAIRO_GL_DISPATCH_NAME_ES;
}
@@ -285,6 +285,7 @@ struct _cairo_gl_context {
cairo_gl_operand_t operands[2];
char *vb;
+ char *vb_mem;
unsigned int vb_offset;
unsigned int vertex_size;
cairo_region_t *clip_region;
@@ -293,6 +294,7 @@ struct _cairo_gl_context {
cairo_gl_dispatch_t dispatch;
GLfloat modelviewprojection_matrix[16];
cairo_gl_flavor_t gl_flavor;
+ cairo_bool_t has_map_buffer;
void (*acquire) (void *ctx);
void (*release) (void *ctx);