diff --git a/gsk/gl/gskgliconlibrary.c b/gsk/gl/gskgliconlibrary.c index d10487d684..63b25dea4b 100644 --- a/gsk/gl/gskgliconlibrary.c +++ b/gsk/gl/gskgliconlibrary.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "gskglcommandqueueprivate.h" #include "gskgldriverprivate.h" @@ -78,11 +79,9 @@ gsk_gl_icon_library_add (GskGLIconLibrary *self, { GskGLTextureLibrary *tl = (GskGLTextureLibrary *)self; G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME; - cairo_surface_t *surface; GskGLIconData *icon_data; + GdkTextureDownloader downloader; guint8 *pixel_data; - guint8 *surface_data; - guint8 *free_data = NULL; guint gl_format; guint gl_type; guint packed_x; @@ -106,27 +105,25 @@ gsk_gl_icon_library_add (GskGLIconLibrary *self, icon_data->source_texture = g_object_ref (key); /* actually upload the texture */ - surface = gdk_texture_download_surface (key); - surface_data = cairo_image_surface_get_data (surface); + gdk_texture_downloader_init (&downloader, key); gdk_gl_context_push_debug_group_printf (gdk_gl_context_get_current (), "Uploading texture"); if (gdk_gl_context_get_use_es (gdk_gl_context_get_current ())) { - pixel_data = free_data = g_malloc (width * height * 4); - gdk_memory_convert (pixel_data, width * 4, - GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, - surface_data, cairo_image_surface_get_stride (surface), - GDK_MEMORY_DEFAULT, width, height); + gdk_texture_downloader_set_format (&downloader, GDK_MEMORY_R8G8B8A8_PREMULTIPLIED); gl_format = GL_RGBA; gl_type = GL_UNSIGNED_BYTE; } else { - pixel_data = surface_data; + gdk_texture_downloader_set_format (&downloader, GDK_MEMORY_DEFAULT); gl_format = GL_BGRA; gl_type = GL_UNSIGNED_INT_8_8_8_8_REV; } + pixel_data = g_malloc (width * height * 4); + gdk_texture_downloader_download_into (&downloader, pixel_data, width * 4); + gdk_texture_downloader_finish (&downloader); texture_id = GSK_GL_TEXTURE_ATLAS_ENTRY_TEXTURE (icon_data); @@ -202,8 +199,7 @@ gsk_gl_icon_library_add (GskGLIconLibrary *self, *out_value = icon_data; - cairo_surface_destroy (surface); - g_free (free_data); + g_free (pixel_data); tl->driver->command_queue->n_uploads++; diff --git a/testsuite/gdk/memorytexture.c b/testsuite/gdk/memorytexture.c index d1bfb0110e..4f7a3379a9 100644 --- a/testsuite/gdk/memorytexture.c +++ b/testsuite/gdk/memorytexture.c @@ -372,88 +372,102 @@ gdk_memory_format_pixel_print (GdkMemoryFormat format, case GDK_MEMORY_A8R8G8B8: case GDK_MEMORY_R8G8B8A8: case GDK_MEMORY_A8B8G8R8: - g_string_append_printf (string, "%d %d %d %d", data[0], data[1], data[2], data[3]); + g_string_append_printf (string, "%02X %02X %02X %02X", data[0], data[1], data[2], data[3]); break; case GDK_MEMORY_B8G8R8X8: case GDK_MEMORY_R8G8B8X8: case GDK_MEMORY_R8G8B8: case GDK_MEMORY_B8G8R8: - g_string_append_printf (string, "%d %d %d", data[0], data[1], data[2]); + g_string_append_printf (string, "%02X %02X %02X", data[0], data[1], data[2]); break; case GDK_MEMORY_G8A8: case GDK_MEMORY_G8A8_PREMULTIPLIED: - g_string_append_printf (string, "%d %d", data[0], data[1]); + g_string_append_printf (string, "%02X %02X", data[0], data[1]); break; case GDK_MEMORY_A8: case GDK_MEMORY_G8: - g_string_append_printf (string, "%d", data[0]); + g_string_append_printf (string, "%02X", data[0]); break; case GDK_MEMORY_X8R8G8B8: case GDK_MEMORY_X8B8G8R8: - g_string_append_printf (string, "%d %d %d", data[1], data[2], data[3]); + g_string_append_printf (string, "%02X %02X %02X", data[1], data[2], data[3]); break; case GDK_MEMORY_R16G16B16A16: case GDK_MEMORY_R16G16B16A16_PREMULTIPLIED: { - guint16 *data16 = (guint16 *) data; - g_string_append_printf (string, "%d %d %d %d", data16[0], data16[1], data16[2], data16[3]); + const guint16 *data16 = (const guint16 *) data; + g_string_append_printf (string, "%04X %04X %04X %04X", data16[0], data16[1], data16[2], data16[3]); } break; case GDK_MEMORY_R16G16B16: { - guint16 *data16 = (guint16 *) data; - g_string_append_printf (string, "%d %d %d", data16[0], data16[1], data16[2]); + const guint16 *data16 = (const guint16 *) data; + g_string_append_printf (string, "%04X %04X %04X", data16[0], data16[1], data16[2]); } break; case GDK_MEMORY_G16A16: case GDK_MEMORY_G16A16_PREMULTIPLIED: { - guint16 *data16 = (guint16 *) data; - g_string_append_printf (string, "%d %d", data16[0], data16[1]); + const guint16 *data16 = (const guint16 *) data; + g_string_append_printf (string, "%04X %04X", data16[0], data16[1]); } break; case GDK_MEMORY_G16: case GDK_MEMORY_A16: { - guint16 *data16 = (guint16 *) data; - g_string_append_printf (string, "%d", data16[0]); + const guint16 *data16 = (const guint16 *) data; + g_string_append_printf (string, "%04X", data16[0]); } break; case GDK_MEMORY_R16G16B16_FLOAT: + { + const guint16 *data16 = (const guint16 *) data; + g_string_append_printf (string, "%f %f %f", half_to_float (data16[0]), half_to_float (data16[1]), half_to_float (data16[2])); + } + break; + case GDK_MEMORY_R16G16B16A16_FLOAT: case GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED: + { + const guint16 *data16 = (const guint16 *) data; + g_string_append_printf (string, "%f %f %f %f", half_to_float (data16[0]), half_to_float (data16[1]), half_to_float (data16[2]), half_to_float (data16[3])); + } + break; case GDK_MEMORY_A16_FLOAT: - g_string_append (string, "FIXME print f16\n"); + { + const guint16 *data16 = (const guint16 *) data; + g_string_append_printf (string, "%f", half_to_float (data16[0])); + } break; case GDK_MEMORY_R32G32B32A32_FLOAT: case GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED: { - float *dataf = (float *)data; + const float *dataf = (const float *) data; g_string_append_printf (string, "%f %f %f %f", dataf[0], dataf[1], dataf[2], dataf[3]); } break; case GDK_MEMORY_R32G32B32_FLOAT: { - float *dataf = (float *)data; + const float *dataf = (const float *) data; g_string_append_printf (string, "%f %f %f", dataf[0], dataf[1], dataf[2]); } break; case GDK_MEMORY_A32_FLOAT: { - float *dataf = (float *)data; + const float *dataf = (const float *) data; g_string_append_printf (string, "%f", dataf[0]); } break; @@ -947,9 +961,9 @@ compare_textures (GdkTexture *texture1, GString *msg = g_string_new (NULL); g_string_append_printf (msg, "(%u %u): ", x, y); - gdk_memory_format_pixel_print (format, data1 + bpp + x, msg); + gdk_memory_format_pixel_print (format, data1 + bpp * x, msg); g_string_append (msg, " != "); - gdk_memory_format_pixel_print (format, data2 + bpp + x, msg); + gdk_memory_format_pixel_print (format, data2 + bpp * x, msg); g_test_message ("%s", msg->str); g_string_free (msg, TRUE); g_test_fail (); diff --git a/testsuite/gsk/compare-render.c b/testsuite/gsk/compare-render.c index 4738414a4c..d7ef1445d0 100644 --- a/testsuite/gsk/compare-render.c +++ b/testsuite/gsk/compare-render.c @@ -313,7 +313,7 @@ main (int argc, char **argv) GdkSurface *window; GskRenderNode *node; const char *node_file; - const char *png_file; + char *png_file; gboolean success = TRUE; GError *error = NULL; GOptionContext *context; @@ -321,7 +321,7 @@ main (int argc, char **argv) (g_test_init) (&argc, &argv, NULL); - context = g_option_context_new ("NODE REF - run GSK node tests"); + context = g_option_context_new ("NODE [REF] - run GSK node tests"); g_option_context_add_main_entries (context, options, NULL); g_option_context_set_ignore_unknown_options (context, TRUE); @@ -330,7 +330,7 @@ main (int argc, char **argv) g_error ("Option parsing failed: %s\n", error->message); return 1; } - else if (argc != 3) + else if (argc != 3 && argc != 2) { char *help = g_option_context_get_help (context, TRUE, NULL); g_print ("%s", help); @@ -345,7 +345,10 @@ main (int argc, char **argv) gtk_init (); node_file = argv[1]; - png_file = argv[2]; + if (argc <= 2) + png_file = file_replace_extension (node_file, ".node", ".png"); + else + png_file = g_strdup (argv[2]); g_print ("Node file: '%s'\n", node_file); g_print ("PNG file: '%s'\n", png_file); @@ -729,6 +732,7 @@ skip_clip: gsk_renderer_unrealize (renderer); g_object_unref (renderer); gdk_surface_destroy (window); + g_free (png_file); return success ? 0 : 1; } diff --git a/tools/gtk-rendernode-tool-show.c b/tools/gtk-rendernode-tool-show.c index 2892869d9b..653ed9c617 100644 --- a/tools/gtk-rendernode-tool-show.c +++ b/tools/gtk-rendernode-tool-show.c @@ -57,6 +57,7 @@ show_file (const char *filename, gboolean decorated) { GskRenderNode *node; + graphene_rect_t node_bounds; GdkPaintable *paintable; GtkWidget *sw; GtkWidget *window; @@ -65,8 +66,10 @@ show_file (const char *filename, GtkWidget *picture; node = load_node_file (filename); + gsk_render_node_get_bounds (node, &node_bounds); snapshot = gtk_snapshot_new (); + gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (- node_bounds.origin.x, - node_bounds.origin.y)); gtk_snapshot_append_node (snapshot, node); paintable = gtk_snapshot_free_to_paintable (snapshot, NULL);