diff --git a/src/cairo-gl-composite.c b/src/cairo-gl-composite.c index 7dc2a60e8..37a16852d 100644 --- a/src/cairo-gl-composite.c +++ b/src/cairo-gl-composite.c @@ -225,7 +225,7 @@ _cairo_gl_pattern_texture_setup (cairo_gl_context_t *ctx, if (unlikely (status)) return status; - if (ctx->tex_target == GL_TEXTURE_RECTANGLE_EXT && + if (_cairo_gl_device_requires_power_of_two_textures (&ctx->base) && (attributes->extend == CAIRO_EXTEND_REPEAT || attributes->extend == CAIRO_EXTEND_REFLECT)) { @@ -258,7 +258,7 @@ _cairo_gl_pattern_texture_setup (cairo_gl_context_t *ctx, * (unnormalized dst -> unnormalized src) to * (unnormalized dst -> normalized src) */ - if (ctx->tex_target == GL_TEXTURE_RECTANGLE_EXT) { + if (_cairo_gl_device_requires_power_of_two_textures (&ctx->base)) { cairo_matrix_init_scale (&m, 1.0, 1.0); @@ -566,10 +566,9 @@ static void _cairo_gl_texture_set_attributes (cairo_gl_context_t *ctx, cairo_surface_attributes_t *attributes) { - if (ctx->tex_target == GL_TEXTURE_RECTANGLE_EXT) { - assert (attributes->extend != CAIRO_EXTEND_REPEAT && - attributes->extend != CAIRO_EXTEND_REFLECT); - } + assert (! _cairo_gl_device_requires_power_of_two_textures (&ctx->base) || + (attributes->extend != CAIRO_EXTEND_REPEAT && + attributes->extend != CAIRO_EXTEND_REFLECT)); switch (attributes->extend) { case CAIRO_EXTEND_NONE: diff --git a/src/cairo-gl-glyphs.c b/src/cairo-gl-glyphs.c index 28a726459..f4de7b064 100644 --- a/src/cairo-gl-glyphs.c +++ b/src/cairo-gl-glyphs.c @@ -110,7 +110,7 @@ _cairo_gl_glyph_cache_add_glyph (cairo_gl_context_t *ctx, glyph_private->p1.y = node->y; glyph_private->p2.x = node->x + glyph_surface->width; glyph_private->p2.y = node->y + glyph_surface->height; - if (ctx->tex_target != GL_TEXTURE_RECTANGLE_EXT) { + if (! _cairo_gl_device_requires_power_of_two_textures (&ctx->base)) { glyph_private->p1.x /= cache_surface->width; glyph_private->p1.y /= cache_surface->height; glyph_private->p2.x /= cache_surface->width; diff --git a/src/cairo-gl-private.h b/src/cairo-gl-private.h index ef5ce160c..445a0f6f3 100644 --- a/src/cairo-gl-private.h +++ b/src/cairo-gl-private.h @@ -253,6 +253,12 @@ _cairo_gl_device_has_glsl (cairo_device_t *device) return ((cairo_gl_context_t *) device)->shader_impl != NULL; } +static cairo_always_inline cairo_bool_t +_cairo_gl_device_requires_power_of_two_textures (cairo_device_t *device) +{ + return ((cairo_gl_context_t *) device)->tex_target == GL_TEXTURE_RECTANGLE_EXT; +} + static cairo_always_inline cairo_status_t cairo_warn _cairo_gl_context_acquire (cairo_device_t *device, cairo_gl_context_t **ctx)