forked from AuroraMiddleware/gtk
gl renderer: add basic code to support texture tiling
This commit is contained in:
parent
a9fec38680
commit
4240119d64
@ -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;
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user