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:
@ -278,14 +278,14 @@ _cogl_multitexture_quad_single_primitive (float x_1,
|
||||
the coordinates (such as in the sub texture backend). This
|
||||
should be safe to call because we know that the texture only
|
||||
has one slice. */
|
||||
for (coord_num = 0; coord_num < 2; coord_num++)
|
||||
{
|
||||
float *s = out_tex_coords + coord_num * 2;
|
||||
float *t = s + 1;
|
||||
_cogl_texture_transform_coords_to_gl (tex_handle, s, t);
|
||||
if (*s < 0.0f || *s > 1.0f || *t < 0.0f || *t > 1.0f)
|
||||
need_repeat = TRUE;
|
||||
}
|
||||
if (!_cogl_texture_transform_quad_coords_to_gl (tex_handle,
|
||||
out_tex_coords))
|
||||
/* If the backend can't support these coordinates then bail out */
|
||||
return FALSE;
|
||||
for (coord_num = 0; coord_num < 4; coord_num++)
|
||||
if (out_tex_coords[coord_num] < 0.0f ||
|
||||
out_tex_coords[coord_num] > 1.0f)
|
||||
need_repeat = TRUE;
|
||||
|
||||
/* If the texture has waste or we are using GL_TEXTURE_RECT we
|
||||
* can't handle texture repeating so we can't use the layer if
|
||||
@ -867,6 +867,11 @@ cogl_polygon (const CoglTextureVertex *vertices,
|
||||
if (tex_handle == COGL_INVALID_HANDLE)
|
||||
continue;
|
||||
|
||||
/* Give the texture a chance to know that we're rendering
|
||||
non-quad shaped primitives. If the texture is in an atlas it
|
||||
will be migrated */
|
||||
_cogl_texture_ensure_non_quad_rendering (tex_handle);
|
||||
|
||||
if (i == 0 && cogl_texture_is_sliced (tex_handle))
|
||||
{
|
||||
#if defined (HAVE_COGL_GLES) || defined (HAVE_COGL_GLES2)
|
||||
|
Reference in New Issue
Block a user