From 17b41fe7e3b8b493341be6384d816105aadf0cb6 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sun, 10 May 2009 10:17:27 -0700 Subject: [PATCH] [gl] Use filtering of GL_NEAREST to hint to TexImage not to alloc for mipmaps. Gl defaults to NEAREST_MIPMAP_LINEAR on new texture objects. This should save space or bandwidth with DRI drivers, as they'll use the parameter as a hint, and then not have to either fix up later or waste space for unused mipmap levels. --- src/cairo-gl-surface.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/cairo-gl-surface.c b/src/cairo-gl-surface.c index 1f5b0d7ce..8bf6e2981 100644 --- a/src/cairo-gl-surface.c +++ b/src/cairo-gl-surface.c @@ -383,6 +383,8 @@ cairo_gl_surface_create (cairo_gl_context_t *ctx, /* Create the texture used to store the surface's data. */ glGenTextures (1, &surface->tex); glBindTexture (GL_TEXTURE_2D, surface->tex); + glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexImage2D (GL_TEXTURE_2D, 0, format, width, height, 0, format, GL_UNSIGNED_BYTE, NULL); @@ -955,6 +957,11 @@ _cairo_gl_pattern_image_texture_setup (cairo_gl_composite_operand_t *operand, image_surface->depth) == 0); glPixelStorei (GL_UNPACK_ROW_LENGTH, image_surface->stride / (image_surface->depth / 8)); + /* The filter will be correctly set up later, but for now we want to + * hint to glTexImage that we're not mipmapping. + */ + glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexImage2D (GL_TEXTURE_2D, 0, internal_format, image_surface->width, image_surface->height, 0, format, type, image_surface->data);