cogl: Make CoglSubTexture only work for quad rendering
The sub texture backend doesn't work well as a completely general texture backend because for example when rendering with cogl_polygon it needs to be able to tranform arbitrary texture coordinates without reference to the other coordintes. This can't be done when the texture coordinates are a multiple of one because sometimes the coordinate should represent the left or top edge and sometimes it should represent the bottom or top edge. For example if the s coordinates are 0 and 1 then 1 represents the right edge but if they are 1 and 2 then 1 represents the left edge. Instead the sub-textures are now documented not to support coordinates outside the range [0,1]. The coordinates for the sub-region are now represented as integers as this helps avoid rounding issues. The region can no longer be a super-region of the texture as this simplifies the code quite a lot. There are two new texture virtual functions: transform_quad_coords_to_gl - This transforms two pairs of coordinates representing a quad. It will return FALSE if the coordinates can not be transformed. The sub texture backend uses this to detect coordinates that require repeating which causes cogl-primitives to use manual repeating. ensure_non_quad_rendering - This is used in cogl_polygon and cogl_vertex_buffer to inform the texture backend that transform_quad_to_gl is going to be used. The atlas backend migrates the texture out of the atlas when it hits this.
This commit is contained in:
@ -342,6 +342,15 @@ _cogl_texture_2d_transform_coords_to_gl (CoglTexture *tex,
|
||||
anything */
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_cogl_texture_2d_transform_quad_coords_to_gl (CoglTexture *tex,
|
||||
float *coords)
|
||||
{
|
||||
/* The texture coordinates map directly so we don't need to do
|
||||
anything */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_cogl_texture_2d_get_gl_texture (CoglTexture *tex,
|
||||
GLuint *out_gl_handle,
|
||||
@ -399,6 +408,12 @@ _cogl_texture_2d_ensure_mipmaps (CoglTexture *tex)
|
||||
tex_2d->mipmaps_dirty = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
_cogl_texture_2d_ensure_non_quad_rendering (CoglTexture *tex)
|
||||
{
|
||||
/* Nothing needs to be done */
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_cogl_texture_2d_set_region (CoglTexture *tex,
|
||||
int src_x,
|
||||
@ -612,9 +627,11 @@ cogl_texture_2d_vtable =
|
||||
_cogl_texture_2d_is_sliced,
|
||||
_cogl_texture_2d_can_hardware_repeat,
|
||||
_cogl_texture_2d_transform_coords_to_gl,
|
||||
_cogl_texture_2d_transform_quad_coords_to_gl,
|
||||
_cogl_texture_2d_get_gl_texture,
|
||||
_cogl_texture_2d_set_filters,
|
||||
_cogl_texture_2d_ensure_mipmaps,
|
||||
_cogl_texture_2d_ensure_non_quad_rendering,
|
||||
_cogl_texture_2d_set_wrap_mode_parameter,
|
||||
_cogl_texture_2d_get_format,
|
||||
_cogl_texture_2d_get_gl_format,
|
||||
|
Reference in New Issue
Block a user