gl: Add API for querying if we need GL_TEXTURE_RECTANGLE_EXT

We need to do that querying outside of taking the lock, so we want to be
able to query the device, not the context.
This commit is contained in:
Benjamin Otte 2010-05-26 11:59:36 +02:00
parent 9c6e1338a1
commit 88a70d66fc
3 changed files with 12 additions and 7 deletions

View file

@ -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:

View file

@ -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;

View file

@ -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)