cogl/texture: Avoid helper methods that just chain up

This was needed pre-GObjectified CoglTexture, not neccessary anymore
so clean those up a little bit

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3818>
This commit is contained in:
Bilal Elmoussaoui 2024-06-17 12:01:42 +02:00 committed by Marge Bot
parent a71e39b0e0
commit f004b560fc
9 changed files with 26 additions and 73 deletions

View File

@ -286,9 +286,10 @@ static int
_cogl_atlas_texture_get_max_waste (CoglTexture *tex) _cogl_atlas_texture_get_max_waste (CoglTexture *tex)
{ {
CoglAtlasTexture *atlas_tex = COGL_ATLAS_TEXTURE (tex); CoglAtlasTexture *atlas_tex = COGL_ATLAS_TEXTURE (tex);
CoglTextureClass *klass = COGL_TEXTURE_GET_CLASS (atlas_tex->sub_texture);
/* Forward on to the sub texture */ /* Forward on to the sub texture */
return cogl_texture_get_max_waste (atlas_tex->sub_texture); return klass->get_max_waste (COGL_TEXTURE (atlas_tex->sub_texture));
} }
static gboolean static gboolean
@ -315,9 +316,10 @@ _cogl_atlas_texture_transform_coords_to_gl (CoglTexture *tex,
float *t) float *t)
{ {
CoglAtlasTexture *atlas_tex = COGL_ATLAS_TEXTURE (tex); CoglAtlasTexture *atlas_tex = COGL_ATLAS_TEXTURE (tex);
CoglTextureClass *klass = COGL_TEXTURE_GET_CLASS (atlas_tex->sub_texture);
/* Forward on to the sub texture */ /* Forward on to the sub texture */
_cogl_texture_transform_coords_to_gl (atlas_tex->sub_texture, s, t); klass->transform_coords_to_gl (atlas_tex->sub_texture, s, t);
} }
static CoglTransformResult static CoglTransformResult
@ -325,10 +327,10 @@ _cogl_atlas_texture_transform_quad_coords_to_gl (CoglTexture *tex,
float *coords) float *coords)
{ {
CoglAtlasTexture *atlas_tex = COGL_ATLAS_TEXTURE (tex); CoglAtlasTexture *atlas_tex = COGL_ATLAS_TEXTURE (tex);
CoglTextureClass *klass = COGL_TEXTURE_GET_CLASS (atlas_tex->sub_texture);
/* Forward on to the sub texture */ /* Forward on to the sub texture */
return _cogl_texture_transform_quad_coords_to_gl (atlas_tex->sub_texture, return klass->transform_quad_coords_to_gl (atlas_tex->sub_texture, coords);
coords);
} }
static gboolean static gboolean
@ -427,13 +429,14 @@ static void
_cogl_atlas_texture_ensure_non_quad_rendering (CoglTexture *tex) _cogl_atlas_texture_ensure_non_quad_rendering (CoglTexture *tex)
{ {
CoglAtlasTexture *atlas_tex = COGL_ATLAS_TEXTURE (tex); CoglAtlasTexture *atlas_tex = COGL_ATLAS_TEXTURE (tex);
CoglTextureClass *klass = COGL_TEXTURE_GET_CLASS (atlas_tex->sub_texture);
/* Sub textures can't support non-quad rendering so we'll just /* Sub textures can't support non-quad rendering so we'll just
migrate the texture out */ migrate the texture out */
_cogl_atlas_texture_migrate_out_of_atlas (atlas_tex); _cogl_atlas_texture_migrate_out_of_atlas (atlas_tex);
/* Forward on to the sub texture */ /* Forward on to the sub texture */
_cogl_texture_ensure_non_quad_rendering (atlas_tex->sub_texture); klass->ensure_non_quad_rendering (atlas_tex->sub_texture);
} }
static gboolean static gboolean

View File

@ -290,7 +290,7 @@ validate_layer_cb (CoglPipeline *pipeline,
/* Give the texture a chance to know that we're rendering /* Give the texture a chance to know that we're rendering
non-quad shaped primitives. If the texture is in an atlas it non-quad shaped primitives. If the texture is in an atlas it
will be migrated */ will be migrated */
_cogl_texture_ensure_non_quad_rendering (texture); COGL_TEXTURE_GET_CLASS (texture)->ensure_non_quad_rendering (texture);
/* We need to ensure the mipmaps are ready before deciding /* We need to ensure the mipmaps are ready before deciding
* anything else about the texture because the texture storate * anything else about the texture because the texture storate

View File

@ -328,7 +328,7 @@ validate_tex_coords_cb (CoglPipeline *pipeline,
/* Convert the texture coordinates to GL. /* Convert the texture coordinates to GL.
*/ */
transform_result = transform_result =
_cogl_texture_transform_quad_coords_to_gl (texture, COGL_TEXTURE_GET_CLASS (texture)->transform_quad_coords_to_gl (texture,
out_tex_coords); out_tex_coords);
/* If the texture has waste or we are using GL_TEXTURE_RECT we /* 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 * can't handle texture repeating so we can't use the layer if

View File

@ -192,8 +192,9 @@ static int
_cogl_sub_texture_get_max_waste (CoglTexture *tex) _cogl_sub_texture_get_max_waste (CoglTexture *tex)
{ {
CoglSubTexture *sub_tex = COGL_SUB_TEXTURE (tex); CoglSubTexture *sub_tex = COGL_SUB_TEXTURE (tex);
CoglTextureClass *klass = COGL_TEXTURE_GET_CLASS (sub_tex->full_texture);
return cogl_texture_get_max_waste (sub_tex->full_texture); return klass->get_max_waste (sub_tex->full_texture);
} }
static gboolean static gboolean
@ -224,6 +225,7 @@ _cogl_sub_texture_transform_coords_to_gl (CoglTexture *tex,
float *t) float *t)
{ {
CoglSubTexture *sub_tex = COGL_SUB_TEXTURE (tex); CoglSubTexture *sub_tex = COGL_SUB_TEXTURE (tex);
CoglTextureClass *klass = COGL_TEXTURE_GET_CLASS (sub_tex->full_texture);
/* This won't work if the sub texture is not the size of the full /* This won't work if the sub texture is not the size of the full
texture and the coordinates are outside the range [0,1] */ texture and the coordinates are outside the range [0,1] */
@ -232,7 +234,7 @@ _cogl_sub_texture_transform_coords_to_gl (CoglTexture *tex,
*t = ((*t * cogl_texture_get_height (tex) + sub_tex->sub_y) / *t = ((*t * cogl_texture_get_height (tex) + sub_tex->sub_y) /
cogl_texture_get_height (sub_tex->full_texture)); cogl_texture_get_height (sub_tex->full_texture));
_cogl_texture_transform_coords_to_gl (sub_tex->full_texture, s, t); klass->transform_coords_to_gl (sub_tex->full_texture, s, t);
} }
static CoglTransformResult static CoglTransformResult
@ -240,6 +242,7 @@ _cogl_sub_texture_transform_quad_coords_to_gl (CoglTexture *tex,
float *coords) float *coords)
{ {
CoglSubTexture *sub_tex = COGL_SUB_TEXTURE (tex); CoglSubTexture *sub_tex = COGL_SUB_TEXTURE (tex);
CoglTextureClass *klass = COGL_TEXTURE_GET_CLASS (sub_tex->full_texture);
int i; int i;
/* We can't support repeating with this method. In this case /* We can't support repeating with this method. In this case
@ -250,8 +253,7 @@ _cogl_sub_texture_transform_quad_coords_to_gl (CoglTexture *tex,
_cogl_sub_texture_map_quad (sub_tex, coords); _cogl_sub_texture_map_quad (sub_tex, coords);
return _cogl_texture_transform_quad_coords_to_gl (sub_tex->full_texture, return klass->transform_quad_coords_to_gl (sub_tex->full_texture, coords);
coords);
} }
static gboolean static gboolean

View File

@ -800,7 +800,8 @@ _cogl_texture_2d_sliced_transform_coords_to_gl (CoglTexture *tex,
/* Let the child texture further transform the coords */ /* Let the child texture further transform the coords */
slice_tex = g_array_index (tex_2ds->slice_textures, CoglTexture2D *, 0); slice_tex = g_array_index (tex_2ds->slice_textures, CoglTexture2D *, 0);
_cogl_texture_transform_coords_to_gl (COGL_TEXTURE (slice_tex), s, t);
COGL_TEXTURE_GET_CLASS (slice_tex)->transform_coords_to_gl (COGL_TEXTURE (slice_tex), s, t);
} }
static CoglTransformResult static CoglTransformResult
@ -905,7 +906,7 @@ _cogl_texture_2d_sliced_ensure_non_quad_rendering (CoglTexture *tex)
{ {
CoglTexture2D *slice_tex = g_array_index (tex_2ds->slice_textures, CoglTexture2D *slice_tex = g_array_index (tex_2ds->slice_textures,
CoglTexture2D *, i); CoglTexture2D *, i);
_cogl_texture_ensure_non_quad_rendering (COGL_TEXTURE (slice_tex)); COGL_TEXTURE_GET_CLASS (slice_tex)->ensure_non_quad_rendering (COGL_TEXTURE (slice_tex));
} }
} }

View File

@ -216,20 +216,9 @@ struct _CoglTextureClass
gboolean gboolean
_cogl_texture_can_hardware_repeat (CoglTexture *texture); _cogl_texture_can_hardware_repeat (CoglTexture *texture);
void
_cogl_texture_transform_coords_to_gl (CoglTexture *texture,
float *s,
float *t);
CoglTransformResult
_cogl_texture_transform_quad_coords_to_gl (CoglTexture *texture,
float *coords);
void void
_cogl_texture_pre_paint (CoglTexture *texture, CoglTexturePrePaintFlags flags); _cogl_texture_pre_paint (CoglTexture *texture, CoglTexturePrePaintFlags flags);
void
_cogl_texture_ensure_non_quad_rendering (CoglTexture *texture);
/* /*
* This determines a CoglPixelFormat according to texture::components * This determines a CoglPixelFormat according to texture::components
* and texture::premultiplied (i.e. the user required components and * and texture::premultiplied (i.e. the user required components and

View File

@ -266,14 +266,6 @@ _cogl_texture_get_format (CoglTexture *texture)
return COGL_TEXTURE_GET_CLASS (texture)->get_format (texture); return COGL_TEXTURE_GET_CLASS (texture)->get_format (texture);
} }
int
cogl_texture_get_max_waste (CoglTexture *texture)
{
g_return_val_if_fail (COGL_IS_TEXTURE (texture), 0);
return COGL_TEXTURE_GET_CLASS (texture)->get_max_waste (texture);
}
int int
_cogl_texture_get_n_levels (CoglTexture *texture) _cogl_texture_get_n_levels (CoglTexture *texture)
{ {
@ -346,24 +338,6 @@ _cogl_texture_can_hardware_repeat (CoglTexture *texture)
return COGL_TEXTURE_GET_CLASS (texture)->can_hardware_repeat (texture); return COGL_TEXTURE_GET_CLASS (texture)->can_hardware_repeat (texture);
} }
/* NB: You can't use this with textures comprised of multiple sub textures (use
* cogl_texture_is_sliced() to check) since coordinate transformation for such
* textures will be different for each slice. */
void
_cogl_texture_transform_coords_to_gl (CoglTexture *texture,
float *s,
float *t)
{
COGL_TEXTURE_GET_CLASS (texture)->transform_coords_to_gl (texture, s, t);
}
CoglTransformResult
_cogl_texture_transform_quad_coords_to_gl (CoglTexture *texture,
float *coords)
{
return COGL_TEXTURE_GET_CLASS (texture)->transform_quad_coords_to_gl (texture, coords);
}
gboolean gboolean
cogl_texture_get_gl_texture (CoglTexture *texture, cogl_texture_get_gl_texture (CoglTexture *texture,
GLuint *out_gl_handle, GLuint *out_gl_handle,
@ -400,12 +374,6 @@ _cogl_texture_pre_paint (CoglTexture *texture, CoglTexturePrePaintFlags flags)
flags); flags);
} }
void
_cogl_texture_ensure_non_quad_rendering (CoglTexture *texture)
{
COGL_TEXTURE_GET_CLASS (texture)->ensure_non_quad_rendering (texture);
}
gboolean gboolean
_cogl_texture_set_region_from_bitmap (CoglTexture *texture, _cogl_texture_set_region_from_bitmap (CoglTexture *texture,
int src_x, int src_x,

View File

@ -235,17 +235,6 @@ cogl_texture_get_width (CoglTexture *texture);
COGL_EXPORT unsigned int COGL_EXPORT unsigned int
cogl_texture_get_height (CoglTexture *texture); cogl_texture_get_height (CoglTexture *texture);
/**
* cogl_texture_get_max_waste:
* @texture: a #CoglTexture pointer.
*
* Queries the maximum wasted (unused) pixels in one dimension of a GPU side
* texture.
*
* Return value: the maximum waste
*/
COGL_EXPORT int
cogl_texture_get_max_waste (CoglTexture *texture);
/** /**
* cogl_texture_is_sliced: * cogl_texture_is_sliced:

View File

@ -672,7 +672,7 @@ _cogl_texture_pixmap_x11_get_max_waste (CoglTexture *tex)
CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex); CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex);
CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap); CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
return cogl_texture_get_max_waste (child_tex); return COGL_TEXTURE_GET_CLASS (child_tex)->get_max_waste (child_tex);
} }
static void static void
@ -727,7 +727,7 @@ _cogl_texture_pixmap_x11_transform_coords_to_gl (CoglTexture *tex,
CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap); CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
/* Forward on to the child texture */ /* Forward on to the child texture */
_cogl_texture_transform_coords_to_gl (child_tex, s, t); COGL_TEXTURE_GET_CLASS (child_tex)->transform_coords_to_gl (child_tex, s, t);
} }
static CoglTransformResult static CoglTransformResult
@ -738,7 +738,8 @@ _cogl_texture_pixmap_x11_transform_quad_coords_to_gl (CoglTexture *tex,
CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap); CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
/* Forward on to the child texture */ /* Forward on to the child texture */
return _cogl_texture_transform_quad_coords_to_gl (child_tex, coords); return COGL_TEXTURE_GET_CLASS (child_tex)->transform_quad_coords_to_gl (child_tex,
coords);
} }
static gboolean static gboolean
@ -790,7 +791,7 @@ _cogl_texture_pixmap_x11_ensure_non_quad_rendering (CoglTexture *tex)
CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap); CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
/* Forward on to the child texture */ /* Forward on to the child texture */
_cogl_texture_ensure_non_quad_rendering (child_tex); COGL_TEXTURE_GET_CLASS (child_tex)->ensure_non_quad_rendering (child_tex);
} }
static void static void