diff --git a/gsk/gl/gskgldriver.c b/gsk/gl/gskgldriver.c index 7e64d218d8..c97522b812 100644 --- a/gsk/gl/gskgldriver.c +++ b/gsk/gl/gskgldriver.c @@ -654,3 +654,14 @@ gsk_gl_driver_init_texture_with_surface (GskGLDriver *self, if (t->min_filter != GL_NEAREST) glGenerateMipmap (GL_TEXTURE_2D); } + +gboolean +gsk_gl_driver_texture_needs_tiling (GskGLDriver *self, + GdkTexture *texture) +{ + int max = gsk_gl_driver_get_max_texture_size (self); + + g_assert (self->max_texture_size > -1); + + return texture->width > max || texture->height > max; +} diff --git a/gsk/gl/gskgldriverprivate.h b/gsk/gl/gskgldriverprivate.h index 17e7c5c84a..04f97a0661 100644 --- a/gsk/gl/gskgldriverprivate.h +++ b/gsk/gl/gskgldriverprivate.h @@ -33,6 +33,8 @@ int gsk_gl_driver_create_permanent_texture (GskGLDriver *driver int gsk_gl_driver_create_texture (GskGLDriver *driver, float width, float height); +gboolean gsk_gl_driver_texture_needs_tiling (GskGLDriver *driver, + GdkTexture *texture); int gsk_gl_driver_create_render_target (GskGLDriver *driver, int texture_id, gboolean add_depth_buffer, diff --git a/gsk/gl/gskglrenderer.c b/gsk/gl/gskglrenderer.c index b5f0e7dde5..f41ec1a64c 100644 --- a/gsk/gl/gskglrenderer.c +++ b/gsk/gl/gskglrenderer.c @@ -555,33 +555,41 @@ render_texture_node (GskGLRenderer *self, GskRenderNode *node, RenderOpBuilder *builder) { - const float min_x = builder->dx + node->bounds.origin.x; - const float min_y = builder->dy + node->bounds.origin.y; - const float max_x = min_x + node->bounds.size.width; - const float max_y = min_y + node->bounds.size.height; GdkTexture *texture = gsk_texture_node_get_texture (node); - int gl_min_filter = GL_NEAREST, gl_mag_filter = GL_NEAREST; - int texture_id; - get_gl_scaling_filters (node, &gl_min_filter, &gl_mag_filter); + if (gsk_gl_driver_texture_needs_tiling (self->gl_driver, texture)) + { - texture_id = gsk_gl_driver_get_texture_for_texture (self->gl_driver, - texture, - gl_min_filter, - gl_mag_filter); - ops_set_program (builder, &self->blit_program); - ops_set_texture (builder, texture_id); + } + else + { + const float min_x = builder->dx + node->bounds.origin.x; + const float min_y = builder->dy + node->bounds.origin.y; + const float max_x = min_x + node->bounds.size.width; + const float max_y = min_y + node->bounds.size.height; + int gl_min_filter = GL_NEAREST, gl_mag_filter = GL_NEAREST; + int texture_id; + + get_gl_scaling_filters (node, &gl_min_filter, &gl_mag_filter); + + texture_id = gsk_gl_driver_get_texture_for_texture (self->gl_driver, + texture, + gl_min_filter, + gl_mag_filter); + ops_set_program (builder, &self->blit_program); + ops_set_texture (builder, texture_id); - ops_draw (builder, (GskQuadVertex[GL_N_VERTICES]) { - { { min_x, min_y }, { 0, 0 }, }, - { { min_x, max_y }, { 0, 1 }, }, - { { max_x, min_y }, { 1, 0 }, }, + ops_draw (builder, (GskQuadVertex[GL_N_VERTICES]) { + { { min_x, min_y }, { 0, 0 }, }, + { { min_x, max_y }, { 0, 1 }, }, + { { max_x, min_y }, { 1, 0 }, }, - { { max_x, max_y }, { 1, 1 }, }, - { { min_x, max_y }, { 0, 1 }, }, - { { max_x, min_y }, { 1, 0 }, }, - }); + { { max_x, max_y }, { 1, 1 }, }, + { { min_x, max_y }, { 0, 1 }, }, + { { max_x, min_y }, { 1, 0 }, }, + }); + } } static inline void