@@ -176,7 +176,8 @@ _cairo_gl_context_init (cairo_gl_context_t *ctx)
else
return _cairo_error (CAIRO_STATUS_DEVICE_ERROR);
- if (gl_version < CAIRO_GL_VERSION_ENCODE (2, 1) &&
+ if (gl_flavor == CAIRO_GL_FLAVOR_DESKTOP &&
+ gl_version < CAIRO_GL_VERSION_ENCODE (2, 1) &&
! _cairo_gl_has_extension ("GL_ARB_pixel_buffer_object"))
return _cairo_error (CAIRO_STATUS_DEVICE_ERROR);
@@ -234,33 +234,42 @@ _cairo_gl_gradient_create (cairo_gl_context_t *ctx,
gradient->stops = gradient->stops_embedded;
memcpy (gradient->stops_embedded, stops, n_stops * sizeof (cairo_gradient_stop_t));
- dispatch->BindBuffer (GL_PIXEL_UNPACK_BUFFER, ctx->texture_load_pbo);
- dispatch->BufferData (GL_PIXEL_UNPACK_BUFFER,
- tex_width * sizeof (uint32_t), 0, GL_STREAM_DRAW);
- data = dispatch->MapBuffer (GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
+ glGenTextures (1, &gradient->tex);
+ _cairo_gl_context_activate (ctx, CAIRO_GL_TEX_TEMP);
+ glBindTexture (ctx->tex_target, gradient->tex);
- status = _cairo_gl_gradient_render (ctx, n_stops, stops, data, tex_width);
+ /* GL_PIXEL_UNPACK_BUFFER is only available in Desktop GL */
+ if (ctx->gl_flavor == CAIRO_GL_FLAVOR_DESKTOP) {
+ dispatch->BindBuffer (GL_PIXEL_UNPACK_BUFFER, ctx->texture_load_pbo);
+ dispatch->BufferData (GL_PIXEL_UNPACK_BUFFER,
+ tex_width * sizeof (uint32_t), 0, GL_STREAM_DRAW);
+ data = dispatch->MapBuffer (GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
- dispatch->UnmapBuffer (GL_PIXEL_UNPACK_BUFFER);
+ status = _cairo_gl_gradient_render (ctx, n_stops, stops, data, tex_width);
- if (unlikely (status)) {
- dispatch->BindBuffer (GL_PIXEL_UNPACK_BUFFER, 0);
- free (gradient);
- return status;
- }
+ dispatch->UnmapBuffer (GL_PIXEL_UNPACK_BUFFER);
- glGenTextures (1, &gradient->tex);
- _cairo_gl_context_activate (ctx, CAIRO_GL_TEX_TEMP);
- glBindTexture (ctx->tex_target, gradient->tex);
+ if (unlikely (status)) {
+ dispatch->BindBuffer (GL_PIXEL_UNPACK_BUFFER, 0);
+ free (gradient);
+ return status;
+ }
- if (ctx->gl_flavor == CAIRO_GL_FLAVOR_DESKTOP)
glTexImage2D (ctx->tex_target, 0, GL_RGBA8, tex_width, 1, 0,
GL_BGRA, GL_UNSIGNED_BYTE, 0);
- else
+
+ dispatch->BindBuffer (GL_PIXEL_UNPACK_BUFFER, 0);
+ }
+ else {
+ data = _cairo_malloc_ab (tex_width, sizeof (uint32_t));
+
+ status = _cairo_gl_gradient_render (ctx, n_stops, stops, data, tex_width);
+
glTexImage2D (ctx->tex_target, 0, GL_BGRA, tex_width, 1, 0,
GL_BGRA, GL_UNSIGNED_BYTE, data);
- dispatch->BindBuffer (GL_PIXEL_UNPACK_BUFFER, 0);
+ free (data);
+ }
/* we ignore errors here and just return an uncached gradient */
if (likely (! _cairo_cache_insert (&ctx->gradients, &gradient->cache_entry)))