mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-28 14:31:10 +00:00
Merge branch 'wip/otte/for-main' into 'main'
rendernode-tool: Show the whole node See merge request GNOME/gtk!7417
This commit is contained in:
commit
be8fef9811
@ -24,6 +24,7 @@
|
|||||||
#include <gdk/gdkmemoryformatprivate.h>
|
#include <gdk/gdkmemoryformatprivate.h>
|
||||||
#include <gdk/gdkprofilerprivate.h>
|
#include <gdk/gdkprofilerprivate.h>
|
||||||
#include <gdk/gdktextureprivate.h>
|
#include <gdk/gdktextureprivate.h>
|
||||||
|
#include <gdk/gdktexturedownloaderprivate.h>
|
||||||
|
|
||||||
#include "gskglcommandqueueprivate.h"
|
#include "gskglcommandqueueprivate.h"
|
||||||
#include "gskgldriverprivate.h"
|
#include "gskgldriverprivate.h"
|
||||||
@ -78,11 +79,9 @@ gsk_gl_icon_library_add (GskGLIconLibrary *self,
|
|||||||
{
|
{
|
||||||
GskGLTextureLibrary *tl = (GskGLTextureLibrary *)self;
|
GskGLTextureLibrary *tl = (GskGLTextureLibrary *)self;
|
||||||
G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
|
G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
|
||||||
cairo_surface_t *surface;
|
|
||||||
GskGLIconData *icon_data;
|
GskGLIconData *icon_data;
|
||||||
|
GdkTextureDownloader downloader;
|
||||||
guint8 *pixel_data;
|
guint8 *pixel_data;
|
||||||
guint8 *surface_data;
|
|
||||||
guint8 *free_data = NULL;
|
|
||||||
guint gl_format;
|
guint gl_format;
|
||||||
guint gl_type;
|
guint gl_type;
|
||||||
guint packed_x;
|
guint packed_x;
|
||||||
@ -106,27 +105,25 @@ gsk_gl_icon_library_add (GskGLIconLibrary *self,
|
|||||||
icon_data->source_texture = g_object_ref (key);
|
icon_data->source_texture = g_object_ref (key);
|
||||||
|
|
||||||
/* actually upload the texture */
|
/* actually upload the texture */
|
||||||
surface = gdk_texture_download_surface (key);
|
gdk_texture_downloader_init (&downloader, key);
|
||||||
surface_data = cairo_image_surface_get_data (surface);
|
|
||||||
gdk_gl_context_push_debug_group_printf (gdk_gl_context_get_current (),
|
gdk_gl_context_push_debug_group_printf (gdk_gl_context_get_current (),
|
||||||
"Uploading texture");
|
"Uploading texture");
|
||||||
|
|
||||||
if (gdk_gl_context_get_use_es (gdk_gl_context_get_current ()))
|
if (gdk_gl_context_get_use_es (gdk_gl_context_get_current ()))
|
||||||
{
|
{
|
||||||
pixel_data = free_data = g_malloc (width * height * 4);
|
gdk_texture_downloader_set_format (&downloader, GDK_MEMORY_R8G8B8A8_PREMULTIPLIED);
|
||||||
gdk_memory_convert (pixel_data, width * 4,
|
|
||||||
GDK_MEMORY_R8G8B8A8_PREMULTIPLIED,
|
|
||||||
surface_data, cairo_image_surface_get_stride (surface),
|
|
||||||
GDK_MEMORY_DEFAULT, width, height);
|
|
||||||
gl_format = GL_RGBA;
|
gl_format = GL_RGBA;
|
||||||
gl_type = GL_UNSIGNED_BYTE;
|
gl_type = GL_UNSIGNED_BYTE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pixel_data = surface_data;
|
gdk_texture_downloader_set_format (&downloader, GDK_MEMORY_DEFAULT);
|
||||||
gl_format = GL_BGRA;
|
gl_format = GL_BGRA;
|
||||||
gl_type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
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);
|
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;
|
*out_value = icon_data;
|
||||||
|
|
||||||
cairo_surface_destroy (surface);
|
g_free (pixel_data);
|
||||||
g_free (free_data);
|
|
||||||
|
|
||||||
tl->driver->command_queue->n_uploads++;
|
tl->driver->command_queue->n_uploads++;
|
||||||
|
|
||||||
|
@ -372,88 +372,102 @@ gdk_memory_format_pixel_print (GdkMemoryFormat format,
|
|||||||
case GDK_MEMORY_A8R8G8B8:
|
case GDK_MEMORY_A8R8G8B8:
|
||||||
case GDK_MEMORY_R8G8B8A8:
|
case GDK_MEMORY_R8G8B8A8:
|
||||||
case GDK_MEMORY_A8B8G8R8:
|
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;
|
break;
|
||||||
|
|
||||||
case GDK_MEMORY_B8G8R8X8:
|
case GDK_MEMORY_B8G8R8X8:
|
||||||
case GDK_MEMORY_R8G8B8X8:
|
case GDK_MEMORY_R8G8B8X8:
|
||||||
case GDK_MEMORY_R8G8B8:
|
case GDK_MEMORY_R8G8B8:
|
||||||
case GDK_MEMORY_B8G8R8:
|
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;
|
break;
|
||||||
|
|
||||||
case GDK_MEMORY_G8A8:
|
case GDK_MEMORY_G8A8:
|
||||||
case GDK_MEMORY_G8A8_PREMULTIPLIED:
|
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;
|
break;
|
||||||
|
|
||||||
case GDK_MEMORY_A8:
|
case GDK_MEMORY_A8:
|
||||||
case GDK_MEMORY_G8:
|
case GDK_MEMORY_G8:
|
||||||
g_string_append_printf (string, "%d", data[0]);
|
g_string_append_printf (string, "%02X", data[0]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GDK_MEMORY_X8R8G8B8:
|
case GDK_MEMORY_X8R8G8B8:
|
||||||
case GDK_MEMORY_X8B8G8R8:
|
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;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case GDK_MEMORY_R16G16B16A16:
|
case GDK_MEMORY_R16G16B16A16:
|
||||||
case GDK_MEMORY_R16G16B16A16_PREMULTIPLIED:
|
case GDK_MEMORY_R16G16B16A16_PREMULTIPLIED:
|
||||||
{
|
{
|
||||||
guint16 *data16 = (guint16 *) data;
|
const guint16 *data16 = (const guint16 *) data;
|
||||||
g_string_append_printf (string, "%d %d %d %d", data16[0], data16[1], data16[2], data16[3]);
|
g_string_append_printf (string, "%04X %04X %04X %04X", data16[0], data16[1], data16[2], data16[3]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GDK_MEMORY_R16G16B16:
|
case GDK_MEMORY_R16G16B16:
|
||||||
{
|
{
|
||||||
guint16 *data16 = (guint16 *) data;
|
const guint16 *data16 = (const guint16 *) data;
|
||||||
g_string_append_printf (string, "%d %d %d", data16[0], data16[1], data16[2]);
|
g_string_append_printf (string, "%04X %04X %04X", data16[0], data16[1], data16[2]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GDK_MEMORY_G16A16:
|
case GDK_MEMORY_G16A16:
|
||||||
case GDK_MEMORY_G16A16_PREMULTIPLIED:
|
case GDK_MEMORY_G16A16_PREMULTIPLIED:
|
||||||
{
|
{
|
||||||
guint16 *data16 = (guint16 *) data;
|
const guint16 *data16 = (const guint16 *) data;
|
||||||
g_string_append_printf (string, "%d %d", data16[0], data16[1]);
|
g_string_append_printf (string, "%04X %04X", data16[0], data16[1]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GDK_MEMORY_G16:
|
case GDK_MEMORY_G16:
|
||||||
case GDK_MEMORY_A16:
|
case GDK_MEMORY_A16:
|
||||||
{
|
{
|
||||||
guint16 *data16 = (guint16 *) data;
|
const guint16 *data16 = (const guint16 *) data;
|
||||||
g_string_append_printf (string, "%d", data16[0]);
|
g_string_append_printf (string, "%04X", data16[0]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GDK_MEMORY_R16G16B16_FLOAT:
|
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:
|
||||||
case GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED:
|
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:
|
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;
|
break;
|
||||||
|
|
||||||
case GDK_MEMORY_R32G32B32A32_FLOAT:
|
case GDK_MEMORY_R32G32B32A32_FLOAT:
|
||||||
case GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED:
|
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]);
|
g_string_append_printf (string, "%f %f %f %f", dataf[0], dataf[1], dataf[2], dataf[3]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GDK_MEMORY_R32G32B32_FLOAT:
|
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]);
|
g_string_append_printf (string, "%f %f %f", dataf[0], dataf[1], dataf[2]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GDK_MEMORY_A32_FLOAT:
|
case GDK_MEMORY_A32_FLOAT:
|
||||||
{
|
{
|
||||||
float *dataf = (float *)data;
|
const float *dataf = (const float *) data;
|
||||||
g_string_append_printf (string, "%f", dataf[0]);
|
g_string_append_printf (string, "%f", dataf[0]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -947,9 +961,9 @@ compare_textures (GdkTexture *texture1,
|
|||||||
GString *msg = g_string_new (NULL);
|
GString *msg = g_string_new (NULL);
|
||||||
|
|
||||||
g_string_append_printf (msg, "(%u %u): ", x, y);
|
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, " != ");
|
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_test_message ("%s", msg->str);
|
||||||
g_string_free (msg, TRUE);
|
g_string_free (msg, TRUE);
|
||||||
g_test_fail ();
|
g_test_fail ();
|
||||||
|
@ -313,7 +313,7 @@ main (int argc, char **argv)
|
|||||||
GdkSurface *window;
|
GdkSurface *window;
|
||||||
GskRenderNode *node;
|
GskRenderNode *node;
|
||||||
const char *node_file;
|
const char *node_file;
|
||||||
const char *png_file;
|
char *png_file;
|
||||||
gboolean success = TRUE;
|
gboolean success = TRUE;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
GOptionContext *context;
|
GOptionContext *context;
|
||||||
@ -321,7 +321,7 @@ main (int argc, char **argv)
|
|||||||
|
|
||||||
(g_test_init) (&argc, &argv, NULL);
|
(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_add_main_entries (context, options, NULL);
|
||||||
g_option_context_set_ignore_unknown_options (context, TRUE);
|
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);
|
g_error ("Option parsing failed: %s\n", error->message);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else if (argc != 3)
|
else if (argc != 3 && argc != 2)
|
||||||
{
|
{
|
||||||
char *help = g_option_context_get_help (context, TRUE, NULL);
|
char *help = g_option_context_get_help (context, TRUE, NULL);
|
||||||
g_print ("%s", help);
|
g_print ("%s", help);
|
||||||
@ -345,7 +345,10 @@ main (int argc, char **argv)
|
|||||||
gtk_init ();
|
gtk_init ();
|
||||||
|
|
||||||
node_file = argv[1];
|
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 ("Node file: '%s'\n", node_file);
|
||||||
g_print ("PNG file: '%s'\n", png_file);
|
g_print ("PNG file: '%s'\n", png_file);
|
||||||
@ -729,6 +732,7 @@ skip_clip:
|
|||||||
gsk_renderer_unrealize (renderer);
|
gsk_renderer_unrealize (renderer);
|
||||||
g_object_unref (renderer);
|
g_object_unref (renderer);
|
||||||
gdk_surface_destroy (window);
|
gdk_surface_destroy (window);
|
||||||
|
g_free (png_file);
|
||||||
|
|
||||||
return success ? 0 : 1;
|
return success ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,7 @@ show_file (const char *filename,
|
|||||||
gboolean decorated)
|
gboolean decorated)
|
||||||
{
|
{
|
||||||
GskRenderNode *node;
|
GskRenderNode *node;
|
||||||
|
graphene_rect_t node_bounds;
|
||||||
GdkPaintable *paintable;
|
GdkPaintable *paintable;
|
||||||
GtkWidget *sw;
|
GtkWidget *sw;
|
||||||
GtkWidget *window;
|
GtkWidget *window;
|
||||||
@ -65,8 +66,10 @@ show_file (const char *filename,
|
|||||||
GtkWidget *picture;
|
GtkWidget *picture;
|
||||||
|
|
||||||
node = load_node_file (filename);
|
node = load_node_file (filename);
|
||||||
|
gsk_render_node_get_bounds (node, &node_bounds);
|
||||||
|
|
||||||
snapshot = gtk_snapshot_new ();
|
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);
|
gtk_snapshot_append_node (snapshot, node);
|
||||||
paintable = gtk_snapshot_free_to_paintable (snapshot, NULL);
|
paintable = gtk_snapshot_free_to_paintable (snapshot, NULL);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user