cogl: Remove cogl_texture_new_with_size

Replace the deprecated function with the suggested alternative.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2058>
This commit is contained in:
Fernando Monteiro 2021-10-03 16:46:56 +01:00 committed by Marge Bot
parent 612da58c72
commit 44aa6ab735
5 changed files with 12 additions and 92 deletions

View File

@ -153,9 +153,10 @@ clutter_offscreen_effect_real_create_texture (ClutterOffscreenEffect *effect,
gfloat width, gfloat width,
gfloat height) gfloat height)
{ {
return cogl_texture_new_with_size (MAX (width, 1), MAX (height, 1), CoglContext *ctx =
COGL_TEXTURE_NO_SLICING, clutter_backend_get_cogl_context (clutter_get_default_backend ());
COGL_PIXEL_FORMAT_RGBA_8888_PRE);
return cogl_texture_2d_new_with_size (ctx, MAX (width, 1), MAX (height, 1));
} }
static void static void

View File

@ -68,66 +68,6 @@ set_auto_mipmap_cb (CoglTexture *sub_texture,
FALSE); FALSE);
} }
CoglTexture *
cogl_texture_new_with_size (unsigned int width,
unsigned int height,
CoglTextureFlags flags,
CoglPixelFormat internal_format)
{
CoglTexture *tex;
GError *skip_error = NULL;
_COGL_GET_CONTEXT (ctx, NULL);
/* First try creating a fast-path non-sliced texture */
tex = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx, width, height));
_cogl_texture_set_internal_format (tex, internal_format);
if (!cogl_texture_allocate (tex, &skip_error))
{
g_error_free (skip_error);
skip_error = NULL;
cogl_object_unref (tex);
tex = NULL;
}
if (!tex)
{
/* If it fails resort to sliced textures */
int max_waste = flags & COGL_TEXTURE_NO_SLICING ? -1 : COGL_TEXTURE_MAX_WASTE;
tex = COGL_TEXTURE (cogl_texture_2d_sliced_new_with_size (ctx,
width,
height,
max_waste));
_cogl_texture_set_internal_format (tex, internal_format);
}
/* NB: This api existed before Cogl introduced lazy allocation of
* textures and so we maintain its original synchronous allocation
* semantics and return NULL if allocation fails... */
if (!cogl_texture_allocate (tex, &skip_error))
{
g_error_free (skip_error);
cogl_object_unref (tex);
return NULL;
}
if (tex &&
flags & COGL_TEXTURE_NO_AUTO_MIPMAP)
{
cogl_meta_texture_foreach_in_region (COGL_META_TEXTURE (tex),
0, 0, 1, 1,
COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE,
COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE,
set_auto_mipmap_cb,
NULL);
}
return tex;
}
static CoglTexture * static CoglTexture *
_cogl_texture_new_from_data (CoglContext *ctx, _cogl_texture_new_from_data (CoglContext *ctx,
int width, int width,

View File

@ -35,29 +35,6 @@ G_BEGIN_DECLS
#include <cogl/cogl-texture.h> #include <cogl/cogl-texture.h>
/**
* cogl_texture_new_with_size:
* @width: width of texture in pixels.
* @height: height of texture in pixels.
* @flags: Optional flags for the texture, or %COGL_TEXTURE_NONE
* @internal_format: the #CoglPixelFormat to use for the GPU storage of the
* texture.
*
* Creates a new #CoglTexture with the specified dimensions and pixel format.
*
* Return value: (transfer full): A newly created #CoglTexture or %NULL on failure
*
* Since: 0.8
* Deprecated: 1.18: Use specific constructors such as
* cogl_texture_2d_new_with_size()
*/
COGL_DEPRECATED_FOR (cogl_texture_2d_new_with_size__OR__cogl_texture_2d_sliced_new_with_size)
COGL_EXPORT CoglTexture *
cogl_texture_new_with_size (unsigned int width,
unsigned int height,
CoglTextureFlags flags,
CoglPixelFormat internal_format);
/** /**
* cogl_texture_new_from_file: * cogl_texture_new_from_file:
* @filename: the file to load * @filename: the file to load

View File

@ -359,9 +359,11 @@ texture_tower_create_texture (MetaTextureTower *tower,
int width, int width,
int height) int height)
{ {
tower->textures[level] = cogl_texture_new_with_size (width, height, CoglContext *ctx =
COGL_TEXTURE_NO_AUTO_MIPMAP, clutter_backend_get_cogl_context (clutter_get_default_backend ());
TEXTURE_FORMAT);
tower->textures[level] =
COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx, width, height));
tower->invalid[level].x1 = 0; tower->invalid[level].x1 = 0;
tower->invalid[level].y1 = 0; tower->invalid[level].y1 = 0;

View File

@ -281,6 +281,8 @@ static void
test_coglbox_init (TestCoglbox *self) test_coglbox_init (TestCoglbox *self)
{ {
TestCoglboxPrivate *priv; TestCoglboxPrivate *priv;
CoglContext *ctx =
clutter_backend_get_cogl_context (clutter_get_default_backend ());
gchar *file; gchar *file;
self->priv = priv = TEST_COGLBOX_GET_PRIVATE(self); self->priv = priv = TEST_COGLBOX_GET_PRIVATE(self);
@ -294,9 +296,7 @@ test_coglbox_init (TestCoglbox *self)
g_free (file); g_free (file);
printf ("Creating texture with size\n"); printf ("Creating texture with size\n");
priv->texture_id = cogl_texture_new_with_size (200, 200, priv->texture_id = cogl_texture_2d_new_with_size (ctx, 200, 200);
COGL_TEXTURE_NONE,
COGL_PIXEL_FORMAT_RGB_888);
if (priv->texture_id == NULL) if (priv->texture_id == NULL)
printf ("Failed creating texture with size!\n"); printf ("Failed creating texture with size!\n");