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:
@ -84,6 +84,8 @@ struct _CoglTextureVtable
|
||||
void (* transform_coords_to_gl) (CoglTexture *tex,
|
||||
float *s,
|
||||
float *t);
|
||||
gboolean (* transform_quad_coords_to_gl) (CoglTexture *tex,
|
||||
float *coords);
|
||||
|
||||
gboolean (* get_gl_texture) (CoglTexture *tex,
|
||||
GLuint *out_gl_handle,
|
||||
@ -94,6 +96,7 @@ struct _CoglTextureVtable
|
||||
GLenum mag_filter);
|
||||
|
||||
void (* ensure_mipmaps) (CoglTexture *tex);
|
||||
void (* ensure_non_quad_rendering) (CoglTexture *tex);
|
||||
|
||||
void (* set_wrap_mode_parameter) (CoglTexture *tex,
|
||||
GLenum wrap_mode);
|
||||
@ -137,6 +140,10 @@ void
|
||||
_cogl_texture_transform_coords_to_gl (CoglHandle handle,
|
||||
float *s,
|
||||
float *t);
|
||||
gboolean
|
||||
_cogl_texture_transform_quad_coords_to_gl (CoglHandle handle,
|
||||
float *coords);
|
||||
|
||||
GLenum
|
||||
_cogl_texture_get_gl_format (CoglHandle handle);
|
||||
|
||||
@ -152,6 +159,9 @@ _cogl_texture_set_filters (CoglHandle handle,
|
||||
void
|
||||
_cogl_texture_ensure_mipmaps (CoglHandle handle);
|
||||
|
||||
void
|
||||
_cogl_texture_ensure_non_quad_rendering (CoglHandle handle);
|
||||
|
||||
/* Utility functions to help uploading a bitmap. These are intended to
|
||||
* be used by CoglTexture implementations or drivers... */
|
||||
|
||||
|
Reference in New Issue
Block a user