gl renderer: add basic code to support texture tiling

This commit is contained in:
Timm Bäder 2018-03-19 11:34:01 +01:00
parent a9fec38680
commit 4240119d64
3 changed files with 42 additions and 21 deletions

View File

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

View File

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

View File

@ -555,11 +555,18 @@ render_texture_node (GskGLRenderer *self,
GskRenderNode *node,
RenderOpBuilder *builder)
{
GdkTexture *texture = gsk_texture_node_get_texture (node);
if (gsk_gl_driver_texture_needs_tiling (self->gl_driver, texture))
{
}
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;
GdkTexture *texture = gsk_texture_node_get_texture (node);
int gl_min_filter = GL_NEAREST, gl_mag_filter = GL_NEAREST;
int texture_id;
@ -582,6 +589,7 @@ render_texture_node (GskGLRenderer *self,
{ { min_x, max_y }, { 0, 1 }, },
{ { max_x, min_y }, { 1, 0 }, },
});
}
}
static inline void