diff options
author | Benjamin Otte <otte@redhat.com> | 2018-03-12 05:12:54 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2018-03-12 17:21:45 +0100 |
commit | e5813b3ae76c7a75ed42a932cf3b93a15596ff44 (patch) | |
tree | 79cf7d9c838017c7f6545d6d47a6f8c72e64c249 /gdk | |
parent | 5fe14e06da49af376ea84d4e81eba1a531700f73 (diff) | |
download | gtk+-e5813b3ae76c7a75ed42a932cf3b93a15596ff44.tar.gz |
texture: Export gdk_memory_texture_new() and GdkMemoryFormat
Also add tests for all these newfangled formats.
Diffstat (limited to 'gdk')
-rw-r--r-- | gdk/gdk.h | 1 | ||||
-rw-r--r-- | gdk/gdkmemorytexture.c | 4 | ||||
-rw-r--r-- | gdk/gdkmemorytexture.h | 81 | ||||
-rw-r--r-- | gdk/gdkmemorytextureprivate.h | 35 | ||||
-rw-r--r-- | gdk/meson.build | 1 |
5 files changed, 87 insertions, 35 deletions
@@ -54,6 +54,7 @@ #include <gdk/gdkgltexture.h> #include <gdk/gdkkeys.h> #include <gdk/gdkkeysyms.h> +#include <gdk/gdkmemorytexture.h> #include <gdk/gdkmonitor.h> #include <gdk/gdkpango.h> #include <gdk/gdkpixbuf.h> diff --git a/gdk/gdkmemorytexture.c b/gdk/gdkmemorytexture.c index 99c2e4a0d9..f44dff2139 100644 --- a/gdk/gdkmemorytexture.c +++ b/gdk/gdkmemorytexture.c @@ -241,8 +241,8 @@ static ConversionFunc converters[GDK_MEMORY_N_FORMATS][2] = { convert_swizzle_premultiply_3210_0123, convert_swizzle_premultiply_0123_0123 }, { convert_swizzle_premultiply_3210_3012, convert_swizzle_premultiply_0123_3012 }, { convert_swizzle_premultiply_3210_0321, convert_swizzle_premultiply_0123_0321 }, - { convert_swizzle_opaque_3210, convert_swizzle_opaque_3012 }, - { convert_swizzle_opaque_0123, convert_swizzle_opaque_0321 } + { convert_swizzle_opaque_3210, convert_swizzle_opaque_0123 }, + { convert_swizzle_opaque_3012, convert_swizzle_opaque_0321 } }; void diff --git a/gdk/gdkmemorytexture.h b/gdk/gdkmemorytexture.h new file mode 100644 index 0000000000..d442c1fbea --- /dev/null +++ b/gdk/gdkmemorytexture.h @@ -0,0 +1,81 @@ +/* + * Copyright © 2018 Benjamin Otte + * + * 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/>. + * + * Authors: Benjamin Otte <otte@gnome.org> + */ + +#ifndef __GDK_MEMORY_TEXTURE__H__ +#define __GDK_MEMORY_TEXTURE__H__ + +#if !defined (__GDK_H_INSIDE__) && !defined (GDK_COMPILATION) +#error "Only <gdk/gdk.h> can be included directly." +#endif + +#include <gdk/gdktexture.h> + +G_BEGIN_DECLS + +/* + * GdkMemoryFormat: + * @GDK_MEMORY_B8G8R8A8_PREMULTIPLIED: 4 bytes; for blue, green, red, alpha. + * The color values are premultiplied with the alpha value. + * @GDK_MEMORY_A8R8G8B8_PREMULTIPLIED: 4 bytes; for alpha, red, green, blue. + * The color values are premultiplied with the alpha value. + * @GDK_MEMORY_B8G8R8A8: 4 bytes; for blue, green, red, alpha. + * @GDK_MEMORY_A8R8G8B8: 4 bytes; for alpha, red, green, blue. + * @GDK_MEMORY_R8G8B8A8: 4 bytes; for red, green, blue, alpha. + * @GDK_MEMORY_A8B8G8R8: 4 bytes; for alpha, blue, green, red. + * @GDK_MEMORY_R8G8B8: 3 bytes; for red, green, blue. The data is opaque. + * @GDK_MEMORY_B8G8R8: 3 bytes; for blue, green, red. The data is opaque. + * @GDK_MEMORY_N_FORMATS: The number of formats. This value will change as + * more formats get added, so do not rely on its concrete integer. + * + * #GdkMemoryFormat describes a format that bytes can have in memory. + * + * It describes formats by listing the contents of the memory passed to it. + * So GDK_MEMORY_A8R8G8B8 will be 1 byte (8 bits) of alpha, followed by a + * byte each of red, green and blue. It is not endian-dependant, so + * CAIRO_FORMAT_ARGB32 is represented by different #GdkMemoryFormats on + * architectures with different endiannesses. + * + * Its naming is modelled after VkFormat (see + * https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VkFormat + * for details). + */ +typedef enum { + GDK_MEMORY_B8G8R8A8_PREMULTIPLIED, + GDK_MEMORY_A8R8G8B8_PREMULTIPLIED, + GDK_MEMORY_B8G8R8A8, + GDK_MEMORY_A8R8G8B8, + GDK_MEMORY_R8G8B8A8, + GDK_MEMORY_A8B8G8R8, + GDK_MEMORY_R8G8B8, + GDK_MEMORY_B8G8R8, + + GDK_MEMORY_N_FORMATS +} GdkMemoryFormat; + +GDK_AVAILABLE_IN_ALL +GdkTexture * gdk_memory_texture_new (int width, + int height, + GdkMemoryFormat format, + GBytes *bytes, + gsize stride); + + +G_END_DECLS + +#endif /* __GDK_MEMORY_TEXTURE_H__ */ diff --git a/gdk/gdkmemorytextureprivate.h b/gdk/gdkmemorytextureprivate.h index 540ec26a0f..bb39690790 100644 --- a/gdk/gdkmemorytextureprivate.h +++ b/gdk/gdkmemorytextureprivate.h @@ -20,37 +20,12 @@ #ifndef __GDK_MEMORY_TEXTURE_PRIVATE_H__ #define __GDK_MEMORY_TEXTURE_PRIVATE_H__ +#include "gdkmemorytexture.h" + #include "gdktextureprivate.h" G_BEGIN_DECLS -/* - * GdkMemoryFormat: - * - * #GdkMemroyFormat describes a format that bytes can have in memory. - * - * It describes formats by listing the contents of the memory passed to it. - * So GDK_MEMORY_A8R8G8B8 will be 8 bits of alpha, followed by 8 bites of each - * blue, green and red. It is not endian-dependant, so CAIRO_FORMAT_ARGB32 is - * represented by 2 different GdkMemoryFormats. - * - * Its naming is modelled after VkFormat (see - * https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VkFormat - * for details). - */ -typedef enum { - GDK_MEMORY_B8G8R8A8_PREMULTIPLIED, - GDK_MEMORY_A8R8G8B8_PREMULTIPLIED, - GDK_MEMORY_B8G8R8A8, - GDK_MEMORY_A8R8G8B8, - GDK_MEMORY_R8G8B8A8, - GDK_MEMORY_A8B8G8R8, - GDK_MEMORY_R8G8B8, - GDK_MEMORY_B8G8R8, - - GDK_MEMORY_N_FORMATS -} GdkMemoryFormat; - #define GDK_MEMORY_GDK_PIXBUF_OPAQUE GDK_MEMORY_R8G8B8 #define GDK_MEMORY_GDK_PIXBUF_ALPHA GDK_MEMORY_R8G8B8A8 @@ -66,12 +41,6 @@ typedef enum { G_DECLARE_FINAL_TYPE (GdkMemoryTexture, gdk_memory_texture, GDK, MEMORY_TEXTURE, GdkTexture) -GdkTexture * gdk_memory_texture_new (int width, - int height, - GdkMemoryFormat format, - GBytes *bytes, - gsize stride); - GdkMemoryFormat gdk_memory_texture_get_format (GdkMemoryTexture *self); const guchar * gdk_memory_texture_get_data (GdkMemoryTexture *self); gsize gdk_memory_texture_get_stride (GdkMemoryTexture *self); diff --git a/gdk/meson.build b/gdk/meson.build index 10d2c4e698..9264070f2b 100644 --- a/gdk/meson.build +++ b/gdk/meson.build @@ -71,6 +71,7 @@ gdk_public_headers = files([ 'gdkgltexture.h', 'gdkkeys.h', 'gdkkeysyms.h', + 'gdkmemorytexture.h', 'gdkmonitor.h', 'gdkpango.h', 'gdkpixbuf.h', |