[gtkmm] Add Gdk::MemoryTexture



commit 909800416eb8fe191ae4f15391d8bf7a1a4b9738
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Mon Nov 30 18:19:47 2020 +0100

    Add Gdk::MemoryTexture
    
    * .gitignore:
    * gdk/gdkmm.h:
    * gdk/gdkmm/meson.build:
    * gdk/src/filelist.am: Add new filenames.
    * gdk/src/gltexture.hg: Remove most of the class description.
    It had been copied from Texture. GdkGLTexture has no class description.
    * gdk/src/memorytexture.[ccg|hg]: New files.
    * gdk/src/texture.hg: Update the class description.
    * tools/m4/convert_gdk.m4: Add conversions for enum GdkMemoryFormat.
    Remove conversions for GdkAtom.

 .gitignore                |  2 ++
 gdk/gdkmm.h               |  1 +
 gdk/gdkmm/meson.build     |  1 +
 gdk/src/filelist.am       |  1 +
 gdk/src/gltexture.hg      | 10 +-------
 gdk/src/memorytexture.ccg | 15 ++++++++++++
 gdk/src/memorytexture.hg  | 59 +++++++++++++++++++++++++++++++++++++++++++++++
 gdk/src/texture.hg        |  6 ++++-
 tools/m4/convert_gdk.m4   |  7 +-----
 9 files changed, 86 insertions(+), 16 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index f27d9f0e..dcdd0ed8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -93,6 +93,8 @@ gdk/gdkmm/glcontext.cc
 gdk/gdkmm/glcontext.h
 gdk/gdkmm/gltexture.cc
 gdk/gdkmm/gltexture.h
+gdk/gdkmm/memorytexture.cc
+gdk/gdkmm/memorytexture.h
 gdk/gdkmm/monitor.cc
 gdk/gdkmm/monitor.h
 gdk/gdkmm/paintable.cc
diff --git a/gdk/gdkmm.h b/gdk/gdkmm.h
index 382c67dc..b3618d4a 100644
--- a/gdk/gdkmm.h
+++ b/gdk/gdkmm.h
@@ -39,6 +39,7 @@
 #include <gdkmm/general.h>
 #include <gdkmm/glcontext.h>
 #include <gdkmm/gltexture.h>
+#include <gdkmm/memorytexture.h>
 #include <gdkmm/monitor.h>
 #include <gdkmm/paintable.h>
 #include <gdkmm/pixbuf.h>
diff --git a/gdk/gdkmm/meson.build b/gdk/gdkmm/meson.build
index 95776c16..da92fef2 100644
--- a/gdk/gdkmm/meson.build
+++ b/gdk/gdkmm/meson.build
@@ -51,6 +51,7 @@ gdkmm_any_hg_ccg_basenames = [
   'frametimings',
   'glcontext',
   'gltexture',
+  'memorytexture',
   'monitor',
   'paintable',
   'pixbuf',
diff --git a/gdk/src/filelist.am b/gdk/src/filelist.am
index 3dcb85f7..52604489 100644
--- a/gdk/src/filelist.am
+++ b/gdk/src/filelist.am
@@ -36,6 +36,7 @@ gdkmm_files_any_hg =          \
        frametimings.hg \
        glcontext.hg            \
        gltexture.hg            \
+       memorytexture.hg \
        monitor.hg \
        paintable.hg            \
        pixbuf.hg               \
diff --git a/gdk/src/gltexture.hg b/gdk/src/gltexture.hg
index 10c2ea36..2e382a6c 100644
--- a/gdk/src/gltexture.hg
+++ b/gdk/src/gltexture.hg
@@ -23,16 +23,8 @@ namespace Gdk
 {
 class GDKMM_API GLContext;
 
+//TODO: When GdkGLTexture gets a class description, copy it.
 /** Pixel data.
- *
- * %Gdk::GLTexture is the basic element used to refer to pixel data.
- * It is primarily meant for pixel data that will not change over
- * multiple frames, and will be used for a long time.
- *
- * You cannot get your pixel data back once you've uploaded it.
- *
- * %Gdk::GLTexture is an immutable object: That means you cannot change
- * anything about it.
  *
  * @newin{3,94}
  */
diff --git a/gdk/src/memorytexture.ccg b/gdk/src/memorytexture.ccg
new file mode 100644
index 00000000..da1d97e5
--- /dev/null
+++ b/gdk/src/memorytexture.ccg
@@ -0,0 +1,15 @@
+/* Copyright (C) 2020 The gtkmm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
diff --git a/gdk/src/memorytexture.hg b/gdk/src/memorytexture.hg
new file mode 100644
index 00000000..c3d4184c
--- /dev/null
+++ b/gdk/src/memorytexture.hg
@@ -0,0 +1,59 @@
+/* Copyright (C) 2020 The gtkmm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <gdkmm/texture.h>
+#include <glibmm/bytes.h>
+#include <gdk/gdk.h> // For GDK_MEMORY_DEFAULT
+
+_DEFS(gdkmm,gdk)
+_PINCLUDE(gdkmm/private/texture_p.h)
+
+namespace Gdk
+{
+//TODO: When GdkMemoryTexture gets a class description, copy it.
+/** Pixel data.
+ *
+ * @newin{3,98}
+ */
+class GDKMM_API MemoryTexture : public Gdk::Texture
+{
+  _CLASS_GOBJECT(MemoryTexture, GdkMemoryTexture, GDK_MEMORY_TEXTURE, Gdk::Texture, GdkTexture, , , 
GDKMM_API)
+
+protected:
+  _CTOR_DEFAULT()
+
+public:
+  _WRAP_ENUM(Format, GdkMemoryFormat, decl_prefix GDKMM_API)
+
+  /** Default memory format used by GTK.
+   *
+   * It is the format provided by Gdk::Texture::download().
+   * It is equal to Cairo::Surface::Format::ARGB32.
+   *
+   * Be aware that unlike the Format values, this format is
+   * different for different endianness.
+   */
+  static const Format DEFAULT_FORMAT = static_cast<Format>(GDK_MEMORY_DEFAULT);
+
+  // gdk_memory_texture_new() does more than call g_object_new().
+  _WRAP_METHOD(static Glib::RefPtr<Texture> create(int width, int height,
+    Format format, const Glib::RefPtr<const Glib::Bytes>& bytes, gsize stride),
+    gdk_memory_texture_new)
+
+  // There are no public signals, properties or vfuncs.
+};
+
+} // namespace Gdk
diff --git a/gdk/src/texture.hg b/gdk/src/texture.hg
index 54a0d93d..cdd92574 100644
--- a/gdk/src/texture.hg
+++ b/gdk/src/texture.hg
@@ -35,7 +35,11 @@ class GDKMM_API Pixbuf;
  * It is primarily meant for pixel data that will not change over
  * multiple frames, and will be used for a long time.
  *
- * You cannot get your pixel data back once you've uploaded it.
+ * There are various ways to create %Gdk::Texture objects from a
+ * Gdk::Pixbuf, or a %Cairo surface, or other pixel data.
+ *
+ * The ownership of the pixel data is transferred to the %Gdk::Texture
+ * instance; you can only make a copy of it, via download().
  *
  * %Gdk::Texture is an immutable object: That means you cannot change
  * anything about it.
diff --git a/tools/m4/convert_gdk.m4 b/tools/m4/convert_gdk.m4
index b5fa7d21..9a6fb114 100644
--- a/tools/m4/convert_gdk.m4
+++ b/tools/m4/convert_gdk.m4
@@ -50,6 +50,7 @@ _CONV_ENUM(Gdk,InterpType)
 _CONV_ENUM(Gdk,JoinStyle)
 _CONV_ENUM(Gdk,KeyMatch)
 _CONV_ENUM(Gdk,LineStyle)
+_CONV_INCLASS_ENUM(Gdk,MemoryTexture,Format,GdkMemoryFormat)
 _CONV_ENUM(Gdk,ModifierType)
 _CONV_ENUM(Gdk,NotifyType)
 _CONV_ENUM(Gdk,OverlapType)
@@ -275,12 +276,6 @@ _CONVERSION(`GdkTimeCoord**&',`GdkTimeCoord***',`&($3)')
 
 dnl _CONVERSION(GdkBitmap*,Gdk::Bitmap&,`Glib::unwrap_boxed($3)',`$3')
 
-dnl GdkAtom -> Glib::ustring and std::string and vice versa
-_CONVERSION(`GdkAtom',`Glib::ustring',`Gdk::AtomUstring::to_cpp_type($3)')
-_CONVERSION(`const Glib::ustring&', `GdkAtom', `Gdk::AtomUstring::to_c_type($3)')
-_CONVERSION(`Glib::ustring&',`GdkAtom',`Gdk::AtomUstring::to_c_type($3)')
-_CONVERSION(`const std::string&', `GdkAtom', `Gdk::AtomString::to_c_type($3)')
-
 dnl GdkEvent and GdkEventSequence
 _CONVERSION(`GdkEvent*',`Glib::RefPtr<Event>',`Glib::wrap($3)')
 _CONVERSION(`GdkEvent*',`Glib::RefPtr<Gdk::Event>',`Glib::wrap($3)')


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