[gtk/wip/chergert/glproto: 264/493] move texture cleanup to pooling code




commit 8e79ece93acd751a4cd4bd4838ffc5b3cffd1218
Author: Christian Hergert <chergert redhat com>
Date:   Wed Jan 27 14:06:32 2021 -0800

    move texture cleanup to pooling code

 gsk/next/gskgltexturepool.c        | 43 ++++++++++++++++++++++++++++++++------
 gsk/next/gskgltexturepoolprivate.h |  7 +++++++
 2 files changed, 44 insertions(+), 6 deletions(-)
---
diff --git a/gsk/next/gskgltexturepool.c b/gsk/next/gskgltexturepool.c
index 219539219e..e3a70bf91b 100644
--- a/gsk/next/gskgltexturepool.c
+++ b/gsk/next/gskgltexturepool.c
@@ -22,18 +22,26 @@
 
 #include <string.h>
 
+#include <gdk/gdktextureprivate.h>
+
 #include "gskgltexturepoolprivate.h"
 
-static void
+void
 gsk_gl_texture_free (GskGLTexture *texture)
 {
-  if (texture->texture_id != 0)
+  if (texture != NULL)
     {
-      glDeleteTextures (1, &texture->texture_id);
-      texture->texture_id = 0;
-    }
+      if (texture->user)
+        g_clear_pointer (&texture->user, gdk_texture_clear_render_data);
+
+      if (texture->texture_id != 0)
+        {
+          glDeleteTextures (1, &texture->texture_id);
+          texture->texture_id = 0;
+        }
 
-  g_slice_free (GskGLTexture, texture);
+      g_slice_free (GskGLTexture, texture);
+    }
 }
 
 void
@@ -183,3 +191,26 @@ create_texture:
 
   return texture;
 }
+
+GskGLTexture *
+gsk_gl_texture_new (guint  texture_id,
+                    int    width,
+                    int    height,
+                    int    min_filter,
+                    int    mag_filter,
+                    gint64 frame_id)
+{
+  GskGLTexture *texture;
+
+  texture = g_slice_new0 (GskGLTexture);
+  texture->texture_id = texture_id;
+  texture->width_link.data = texture;
+  texture->height_link.data = texture;
+  texture->min_filter = min_filter;
+  texture->mag_filter = mag_filter;
+  texture->width = width;
+  texture->height = height;
+  texture->last_used_in_frame = frame_id;
+
+  return texture;
+}
diff --git a/gsk/next/gskgltexturepoolprivate.h b/gsk/next/gskgltexturepoolprivate.h
index 98ba997607..0215db90c8 100644
--- a/gsk/next/gskgltexturepoolprivate.h
+++ b/gsk/next/gskgltexturepoolprivate.h
@@ -63,6 +63,13 @@ GskGLTexture *gsk_gl_texture_pool_get   (GskGLTexturePool *self,
                                          gboolean          always_create);
 void          gsk_gl_texture_pool_put   (GskGLTexturePool *self,
                                          GskGLTexture     *texture);
+GskGLTexture *gsk_gl_texture_new        (guint             texture_id,
+                                         int               width,
+                                         int               height,
+                                         int               min_filter,
+                                         int               mag_filter,
+                                         gint64            frame_id);
+void          gsk_gl_texture_free       (GskGLTexture     *texture);
 
 G_END_DECLS
 


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