[mutter] cogl: Remove cogl_texture_new_with_size



commit 44aa6ab7352e6799bb90088dcfc0653a7b910d52
Author: Fernando Monteiro <fr02monteiro gmail com>
Date:   Sun Oct 3 16:46:56 2021 +0100

    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>

 clutter/clutter/clutter-offscreen-effect.c         |  7 +--
 cogl/cogl/deprecated/cogl-auto-texture.c           | 60 ----------------------
 cogl/cogl/deprecated/cogl-auto-texture.h           | 23 ---------
 src/compositor/meta-texture-tower.c                |  8 +--
 .../clutter/interactive/test-cogl-offscreen.c      |  6 +--
 5 files changed, 12 insertions(+), 92 deletions(-)
---
diff --git a/clutter/clutter/clutter-offscreen-effect.c b/clutter/clutter/clutter-offscreen-effect.c
index 7ff3a2ee00..bdb3288515 100644
--- a/clutter/clutter/clutter-offscreen-effect.c
+++ b/clutter/clutter/clutter-offscreen-effect.c
@@ -153,9 +153,10 @@ clutter_offscreen_effect_real_create_texture (ClutterOffscreenEffect *effect,
                                               gfloat                  width,
                                               gfloat                  height)
 {
-  return cogl_texture_new_with_size (MAX (width, 1), MAX (height, 1),
-                                     COGL_TEXTURE_NO_SLICING,
-                                     COGL_PIXEL_FORMAT_RGBA_8888_PRE);
+  CoglContext *ctx =
+    clutter_backend_get_cogl_context (clutter_get_default_backend ());
+
+  return cogl_texture_2d_new_with_size (ctx, MAX (width, 1), MAX (height, 1));
 }
 
 static void
diff --git a/cogl/cogl/deprecated/cogl-auto-texture.c b/cogl/cogl/deprecated/cogl-auto-texture.c
index c146c78056..f8dbb2aa06 100644
--- a/cogl/cogl/deprecated/cogl-auto-texture.c
+++ b/cogl/cogl/deprecated/cogl-auto-texture.c
@@ -68,66 +68,6 @@ set_auto_mipmap_cb (CoglTexture *sub_texture,
                                           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 *
 _cogl_texture_new_from_data (CoglContext *ctx,
                              int width,
diff --git a/cogl/cogl/deprecated/cogl-auto-texture.h b/cogl/cogl/deprecated/cogl-auto-texture.h
index 6e9bfa134b..1bfd472491 100644
--- a/cogl/cogl/deprecated/cogl-auto-texture.h
+++ b/cogl/cogl/deprecated/cogl-auto-texture.h
@@ -35,29 +35,6 @@ G_BEGIN_DECLS
 
 #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:
  * @filename: the file to load
diff --git a/src/compositor/meta-texture-tower.c b/src/compositor/meta-texture-tower.c
index 1fc4623e5e..9f9b605b5b 100644
--- a/src/compositor/meta-texture-tower.c
+++ b/src/compositor/meta-texture-tower.c
@@ -359,9 +359,11 @@ texture_tower_create_texture (MetaTextureTower *tower,
                               int               width,
                               int               height)
 {
-  tower->textures[level] = cogl_texture_new_with_size (width, height,
-                                                       COGL_TEXTURE_NO_AUTO_MIPMAP,
-                                                       TEXTURE_FORMAT);
+  CoglContext *ctx =
+    clutter_backend_get_cogl_context (clutter_get_default_backend ());
+
+  tower->textures[level] =
+    COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx, width, height));
 
   tower->invalid[level].x1 = 0;
   tower->invalid[level].y1 = 0;
diff --git a/src/tests/clutter/interactive/test-cogl-offscreen.c 
b/src/tests/clutter/interactive/test-cogl-offscreen.c
index 4f2e6bddb1..0b4a2f10f4 100644
--- a/src/tests/clutter/interactive/test-cogl-offscreen.c
+++ b/src/tests/clutter/interactive/test-cogl-offscreen.c
@@ -281,6 +281,8 @@ static void
 test_coglbox_init (TestCoglbox *self)
 {
   TestCoglboxPrivate *priv;
+  CoglContext *ctx =
+    clutter_backend_get_cogl_context (clutter_get_default_backend ());
   gchar *file;
 
   self->priv = priv = TEST_COGLBOX_GET_PRIVATE(self);
@@ -294,9 +296,7 @@ test_coglbox_init (TestCoglbox *self)
   g_free (file);
 
   printf ("Creating texture with size\n");
-  priv->texture_id = cogl_texture_new_with_size (200, 200,
-                                                 COGL_TEXTURE_NONE,
-                                                COGL_PIXEL_FORMAT_RGB_888);
+  priv->texture_id = cogl_texture_2d_new_with_size (ctx, 200, 200);
 
   if (priv->texture_id == NULL)
     printf ("Failed creating texture with size!\n");


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]