summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cairo-gl-glyphs.c43
-rw-r--r--src/cairo-gl-surface.c25
2 files changed, 27 insertions, 41 deletions
diff --git a/src/cairo-gl-glyphs.c b/src/cairo-gl-glyphs.c
index 161b270a..e3f8f80a 100644
--- a/src/cairo-gl-glyphs.c
+++ b/src/cairo-gl-glyphs.c
@@ -108,13 +108,13 @@ _cairo_gl_glyph_cache_add_glyph (cairo_gl_context_t *ctx,
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
glPixelStorei (GL_UNPACK_ROW_LENGTH,
- glyph_surface->stride /
+ pixman_image_get_stride (glyph_surface->pixman_image) /
(PIXMAN_FORMAT_BPP (glyph_surface->pixman_format) / 8));
glTexSubImage2D (ctx->tex_target, 0,
node->x, node->y,
glyph_surface->width, glyph_surface->height,
format, type,
- glyph_surface->data);
+ pixman_image_get_data (glyph_surface->pixman_image));
glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
scaled_glyph->surface_private = node;
@@ -152,46 +152,23 @@ cairo_gl_context_get_glyph_cache (cairo_gl_context_t *ctx,
cairo_format_t format)
{
cairo_gl_glyph_cache_t *cache;
+ GLenum internal_format;
- switch (format) {
- case CAIRO_FORMAT_RGB16_565:
- case CAIRO_FORMAT_ARGB32:
- case CAIRO_FORMAT_RGB24:
- cache = &ctx->glyph_cache[0];
- format = CAIRO_FORMAT_ARGB32;
- break;
- case CAIRO_FORMAT_A8:
- case CAIRO_FORMAT_A1:
+ if (format == CAIRO_FORMAT_A8 ||
+ format == CAIRO_FORMAT_A1) {
cache = &ctx->glyph_cache[1];
- format = CAIRO_FORMAT_A8;
- break;
- case CAIRO_FORMAT_INVALID:
- ASSERT_NOT_REACHED;
- return NULL;
+ internal_format = GL_ALPHA;
+ } else {
+ assert (format == CAIRO_FORMAT_ARGB32 || format == CAIRO_FORMAT_RGB24);
+ cache = &ctx->glyph_cache[0];
+ internal_format = GL_RGBA;
}
if (unlikely (cache->tex == 0)) {
- GLenum internal_format;
cache->width = GLYPH_CACHE_WIDTH;
cache->height = GLYPH_CACHE_HEIGHT;
- switch (format) {
- case CAIRO_FORMAT_A1:
- case CAIRO_FORMAT_RGB16_565:
- case CAIRO_FORMAT_RGB24:
- ASSERT_NOT_REACHED;
- case CAIRO_FORMAT_ARGB32:
- internal_format = GL_RGBA;
- break;
- case CAIRO_FORMAT_A8:
- internal_format = GL_ALPHA;
- break;
- case CAIRO_FORMAT_INVALID:
- ASSERT_NOT_REACHED;
- return NULL;
- }
-
glGenTextures (1, &cache->tex);
glBindTexture (ctx->tex_target, cache->tex);
glTexParameteri (ctx->tex_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
diff --git a/src/cairo-gl-surface.c b/src/cairo-gl-surface.c
index 1c1982ca..5c8419ab 100644
--- a/src/cairo-gl-surface.c
+++ b/src/cairo-gl-surface.c
@@ -308,10 +308,16 @@ _cairo_gl_get_image_format_and_type (pixman_format_code_t pixman_format,
case PIXMAN_g4:
case PIXMAN_a1:
case PIXMAN_g1:
- case PIXMAN_yuy2:
- case PIXMAN_yv12:
case PIXMAN_x2r10g10b10:
case PIXMAN_a2r10g10b10:
+ case PIXMAN_r8g8b8a8:
+ case PIXMAN_r8g8b8x8:
+ case PIXMAN_yv12:
+ case PIXMAN_y444:
+ case PIXMAN_yuy2:
+ case PIXMAN_yvyu:
+ case PIXMAN_vyuy:
+ case PIXMAN_uyvy:
default:
return FALSE;
}
@@ -731,7 +737,8 @@ _cairo_gl_surface_draw_image (cairo_gl_surface_t *dst,
int cpp;
cairo_status_t status = CAIRO_STATUS_SUCCESS;
- if (! _cairo_gl_get_image_format_and_type (src->pixman_format,
+ if (src->pixman_color_space != PIXMAN_COLOR_SPACE_ARGB ||
+ ! _cairo_gl_get_image_format_and_type (src->pixman_format,
&internal_format,
&format,
&type,
@@ -760,7 +767,7 @@ _cairo_gl_surface_draw_image (cairo_gl_surface_t *dst,
return status;
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
- glPixelStorei (GL_UNPACK_ROW_LENGTH, src->stride / cpp);
+ glPixelStorei (GL_UNPACK_ROW_LENGTH, pixman_image_get_stride (src->pixman_image) / cpp);
if (dst->fb) {
glBindTexture (ctx->tex_target, dst->tex);
glTexParameteri (ctx->tex_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
@@ -768,7 +775,8 @@ _cairo_gl_surface_draw_image (cairo_gl_surface_t *dst,
glTexSubImage2D (ctx->tex_target, 0,
dst_x, dst_y, width, height,
format, type,
- src->data + src_y * src->stride + src_x * cpp);
+ cairo_image_surface_get_data_for_row (src, src_y) +
+ src_x * cpp);
/* If we just treated some rgb-only data as rgba, then we have to
* go back and fix up the alpha channel where we filled in this
@@ -825,7 +833,7 @@ _cairo_gl_surface_draw_image (cairo_gl_surface_t *dst,
glTexParameteri (ctx->tex_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri (ctx->tex_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D (ctx->tex_target, 0, internal_format, width, height, 0,
- format, type, src->data + src_y * src->stride + src_x * cpp);
+ format, type, cairo_image_surface_get_data_for_row (src, src_y) + src_x * cpp);
glEnable (ctx->tex_target);
glDisable (GL_BLEND);
@@ -940,12 +948,12 @@ _cairo_gl_surface_get_image (cairo_gl_surface_t *surface,
_cairo_gl_set_destination (surface);
glPixelStorei (GL_PACK_ALIGNMENT, 1);
- glPixelStorei (GL_PACK_ROW_LENGTH, image->stride / cpp);
+ glPixelStorei (GL_PACK_ROW_LENGTH, pixman_image_get_stride (image->pixman_image) / cpp);
if (surface->fb == 0 && GLEW_MESA_pack_invert)
glPixelStorei (GL_PACK_INVERT_MESA, 1);
glReadPixels (interest->x, interest->y,
interest->width, interest->height,
- format, type, image->data);
+ format, type, pixman_image_get_data (image->pixman_image));
if (surface->fb == 0 && GLEW_MESA_pack_invert)
glPixelStorei (GL_PACK_INVERT_MESA, 0);
@@ -1124,6 +1132,7 @@ _cairo_gl_get_traps_pattern (cairo_gl_surface_t *dst,
}
surface = _cairo_image_surface_create_for_pixman_image (image,
+ PIXMAN_COLOR_SPACE_ARGB,
pixman_format);
if (unlikely (surface->status)) {
pixman_image_unref (image);