texture: Export gdk_texture_get_format()
authorBenjamin Otte <otte@redhat.com>
Tue, 14 Feb 2023 06:33:46 +0000 (07:33 +0100)
committerBenjamin Otte <otte@redhat.com>
Tue, 14 Feb 2023 23:39:18 +0000 (00:39 +0100)
The API docs outline why quite well.

This should make it possible to do saving of textures to image files
without any private API with the same featureset that GTK uses.

Also remove the gsktextureprivate.h include where
gdk_texture_get_format() was the only reason for it.

gdk/gdkgltexture.c
gdk/gdkpixbuf.c
gdk/gdktexture.c
gdk/gdktexture.h
gdk/gdktextureprivate.h
gdk/loaders/gdkpng.c
gdk/loaders/gdktiff.c
gsk/gl/gskgldriver.c

index a5be81e676387a97676c4b0d239015296e30883d..f8ff9344c1e9202b399243630c7452f0e3dbf08e 100644 (file)
@@ -24,7 +24,6 @@
 #include "gdkglcontextprivate.h"
 #include "gdkmemoryformatprivate.h"
 #include "gdkmemorytextureprivate.h"
-#include "gdktextureprivate.h"
 
 #include <epoxy/gl.h>
 
index 7a4e35962d813cf44ae7ed3d2c29c7bd763b524d..3e3a20336fb0aab09ae1eddbcd9f27efdf417a8a 100644 (file)
@@ -27,7 +27,6 @@
 #include "gdkmemoryformatprivate.h"
 #include "gdkmemorytextureprivate.h"
 #include "gdksurface.h"
-#include "gdktextureprivate.h"
 #include "gdktexturedownloaderprivate.h"
 
 #include <gdk-pixbuf/gdk-pixbuf.h>
index c37fd248aa28bd32fe551eca7f65ee2fa5216345..007901ffe847ef1f11c22fadf084510aaa918de5 100644 (file)
@@ -741,9 +741,29 @@ gdk_texture_download (GdkTexture *texture,
                            stride);
 }
 
+/**
+ * gdk_texture_get_format:
+ * @self: a GdkTexture
+ *
+ * Gets the memory format most closely associated with the data of
+ * the texture.
+ *
+ * Note that it may not be an exact match for texture data
+ * stored on the GPU or with compression.
+ *
+ * The format can give an indication about the bit depth and opacity
+ * of the texture and is useful to determine the best format for
+ * downloading the texture.
+ *
+ * Returns: the preferred format for the texture's data
+ *
+ * Since: 4.10
+ **/
 GdkMemoryFormat
 gdk_texture_get_format (GdkTexture *self)
 {
+  g_return_val_if_fail (GDK_IS_TEXTURE (self), GDK_MEMORY_DEFAULT);
+
   return self->format;
 }
 
index 8ce4bae5b2cf83e7b718a45652175a11c32ae644..5a28f55ad0eaa16a8bd82d41f61cd5d761b5c008 100644 (file)
@@ -24,6 +24,7 @@
 #endif
 
 #include <gdk/gdkversionmacros.h>
+#include <gdk/gdkenums.h>
 #include <gdk/gdktypes.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
 
@@ -82,6 +83,8 @@ GDK_AVAILABLE_IN_ALL
 int                     gdk_texture_get_width                  (GdkTexture      *texture) G_GNUC_PURE;
 GDK_AVAILABLE_IN_ALL
 int                     gdk_texture_get_height                 (GdkTexture      *texture) G_GNUC_PURE;
+GDK_AVAILABLE_IN_4_10
+GdkMemoryFormat         gdk_texture_get_format                 (GdkTexture      *self) G_GNUC_PURE;
 
 GDK_AVAILABLE_IN_ALL
 void                    gdk_texture_download                   (GdkTexture      *texture,
index fd9f78053ee5dcc28a7a2d58e367b9a98773b2c5..3a2330c37361fba44074d08cdeec31f62efcf0f0 100644 (file)
@@ -43,7 +43,6 @@ void                    gdk_texture_do_download         (GdkTexture
                                                          GdkMemoryFormat         format,
                                                          guchar                 *data,
                                                          gsize                   stride);
-GdkMemoryFormat         gdk_texture_get_format          (GdkTexture             *self);
 gboolean                gdk_texture_set_render_data     (GdkTexture             *self,
                                                          gpointer                key,
                                                          gpointer                data,
index fb4158f3cb56121042abc446fb9659e2831ce048..d5991fde380670334a53ae263c689494d77599f0 100644 (file)
@@ -24,7 +24,6 @@
 #include "gdkmemorytexture.h"
 #include "gdkprofilerprivate.h"
 #include "gdktexturedownloaderprivate.h"
-#include "gdktextureprivate.h"
 #include "gsk/gl/fp16private.h"
 #include <png.h>
 #include <stdio.h>
index 489a962bd82abd8b430a09c543f8cf9195305c0c..d112ff1626415e713dd4772e42da2d003652525f 100644 (file)
@@ -24,7 +24,6 @@
 #include "gdkmemorytexture.h"
 #include "gdkprofilerprivate.h"
 #include "gdktexturedownloaderprivate.h"
-#include "gdktextureprivate.h"
 
 #include <tiffio.h>
 
index 4e38dad68506ae7dbce0891c561368d003fbc66b..727ce079bb10eeb182ce9be83b6f98a1a7c3a355 100644 (file)
@@ -35,7 +35,6 @@
 #include "gskgliconlibraryprivate.h"
 #include "gskglprogramprivate.h"
 #include "gskglshadowlibraryprivate.h"
-#include "gskgltextureprivate.h"
 #include "fp16private.h"
 
 #include <gdk/gdkglcontextprivate.h>