mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 06:00:22 +00:00
testsuite: Add png and tiff methods
We encode the texture to a PNG or TIFF and then decode it again, in various ways.
This commit is contained in:
parent
b1bb7c3258
commit
577bf104c0
@ -12,6 +12,10 @@ typedef enum {
|
||||
TEXTURE_METHOD_LOCAL,
|
||||
TEXTURE_METHOD_GL,
|
||||
TEXTURE_METHOD_GL_RELEASED,
|
||||
TEXTURE_METHOD_PNG,
|
||||
TEXTURE_METHOD_PNG_PIXBUF,
|
||||
TEXTURE_METHOD_TIFF,
|
||||
TEXTURE_METHOD_TIFF_PIXBUF,
|
||||
|
||||
N_TEXTURE_METHODS
|
||||
} TextureMethod;
|
||||
@ -448,6 +452,68 @@ create_texture (GdkMemoryFormat format,
|
||||
gdk_gl_texture_release (GDK_GL_TEXTURE (texture));
|
||||
break;
|
||||
|
||||
case TEXTURE_METHOD_PNG:
|
||||
{
|
||||
GBytes *bytes = gdk_texture_save_to_png_bytes (texture);
|
||||
g_assert (bytes);
|
||||
g_object_unref (texture);
|
||||
texture = gdk_texture_new_from_bytes (bytes, NULL);
|
||||
g_assert (texture);
|
||||
g_bytes_unref (bytes);
|
||||
}
|
||||
break;
|
||||
|
||||
case TEXTURE_METHOD_PNG_PIXBUF:
|
||||
{
|
||||
GInputStream *stream;
|
||||
GdkPixbuf *pixbuf;
|
||||
GBytes *bytes;
|
||||
|
||||
bytes = gdk_texture_save_to_png_bytes (texture);
|
||||
g_assert (bytes);
|
||||
g_object_unref (texture);
|
||||
stream = g_memory_input_stream_new_from_bytes (bytes);
|
||||
pixbuf = gdk_pixbuf_new_from_stream (stream, NULL, NULL);
|
||||
g_object_unref (stream);
|
||||
g_assert (pixbuf);
|
||||
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
||||
g_assert (texture);
|
||||
g_object_unref (pixbuf);
|
||||
g_bytes_unref (bytes);
|
||||
}
|
||||
break;
|
||||
|
||||
case TEXTURE_METHOD_TIFF:
|
||||
{
|
||||
GBytes *bytes = gdk_texture_save_to_tiff_bytes (texture);
|
||||
g_assert (bytes);
|
||||
g_object_unref (texture);
|
||||
texture = gdk_texture_new_from_bytes (bytes, NULL);
|
||||
g_assert (texture);
|
||||
g_bytes_unref (bytes);
|
||||
}
|
||||
break;
|
||||
|
||||
case TEXTURE_METHOD_TIFF_PIXBUF:
|
||||
{
|
||||
GInputStream *stream;
|
||||
GdkPixbuf *pixbuf;
|
||||
GBytes *bytes;
|
||||
|
||||
bytes = gdk_texture_save_to_png_bytes (texture);
|
||||
g_assert (bytes);
|
||||
g_object_unref (texture);
|
||||
stream = g_memory_input_stream_new_from_bytes (bytes);
|
||||
pixbuf = gdk_pixbuf_new_from_stream (stream, NULL, NULL);
|
||||
g_object_unref (stream);
|
||||
g_assert (pixbuf);
|
||||
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
||||
g_assert (texture);
|
||||
g_object_unref (pixbuf);
|
||||
g_bytes_unref (bytes);
|
||||
}
|
||||
break;
|
||||
|
||||
case N_TEXTURE_METHODS:
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
@ -584,7 +650,7 @@ add_test (const char *name,
|
||||
{
|
||||
for (method = 0; method < N_TEXTURE_METHODS; method++)
|
||||
{
|
||||
const char *method_names[N_TEXTURE_METHODS] = { "local", "gl", "gl-released" };
|
||||
const char *method_names[N_TEXTURE_METHODS] = { "local", "gl", "gl-released", "png", "png-pixbuf", "tiff", "tiff-pixbuf" };
|
||||
char *test_name = g_strdup_printf ("%s/%s/%s",
|
||||
name,
|
||||
g_enum_get_value (enum_class, format)->value_nick,
|
||||
|
Loading…
Reference in New Issue
Block a user