diff options
author | Matthias Clasen <mclasen@redhat.com> | 2022-05-10 15:49:44 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2022-05-13 12:34:24 -0400 |
commit | dd16d7c4c86a371246010c2c920b1762416c9af2 (patch) | |
tree | 9daac660c3435731b86d0b38f1e5679fa3e4cc53 /gsk/gskrendernodeparser.c | |
parent | 122fa679a8a15610e0a3164bdf2e4ad1702f3fb1 (diff) | |
download | gtk+-dd16d7c4c86a371246010c2c920b1762416c9af2.tar.gz |
gsk: Serialize float textures as tiff
Otherwise, we lose precision when converting them
to 16bit integers.
Diffstat (limited to 'gsk/gskrendernodeparser.c')
-rw-r--r-- | gsk/gskrendernodeparser.c | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/gsk/gskrendernodeparser.c b/gsk/gskrendernodeparser.c index 11d5e61d70..b5f703bd79 100644 --- a/gsk/gskrendernodeparser.c +++ b/gsk/gskrendernodeparser.c @@ -1102,7 +1102,7 @@ parse_conic_gradient_node (GtkCssParser *parser) g_array_append_val (stops, to); } - result = gsk_conic_gradient_node_new (&bounds, ¢er, rotation, + result = gsk_conic_gradient_node_new (&bounds, ¢er, rotation, (GskColorStop *) stops->data, stops->len); g_array_free (stops, TRUE); @@ -1388,7 +1388,7 @@ parse_cairo_node (GtkCssParser *parser) parse_declarations (parser, declarations, G_N_ELEMENTS(declarations)); node = gsk_cairo_node_new (&bounds); - + if (surface != NULL) { cairo_t *cr = gsk_cairo_node_get_draw_context (node); @@ -2697,10 +2697,41 @@ render_node_print (Printer *p, start_node (p, "texture"); append_rect_param (p, "bounds", &node->bounds); - bytes = gdk_texture_save_to_png_bytes (texture); - _indent (p); - g_string_append (p->str, "texture: url(\"data:image/png;base64,"); + + switch (gdk_texture_get_format (texture)) + { + case GDK_MEMORY_B8G8R8A8_PREMULTIPLIED: + case GDK_MEMORY_A8R8G8B8_PREMULTIPLIED: + case GDK_MEMORY_R8G8B8A8_PREMULTIPLIED: + case GDK_MEMORY_B8G8R8A8: + case GDK_MEMORY_A8R8G8B8: + case GDK_MEMORY_R8G8B8A8: + case GDK_MEMORY_A8B8G8R8: + case GDK_MEMORY_R8G8B8: + case GDK_MEMORY_B8G8R8: + case GDK_MEMORY_R16G16B16: + case GDK_MEMORY_R16G16B16A16_PREMULTIPLIED: + case GDK_MEMORY_R16G16B16A16: + bytes = gdk_texture_save_to_png_bytes (texture); + g_string_append (p->str, "texture: url(\"data:image/png;base64,"); + break; + + case GDK_MEMORY_R16G16B16_FLOAT: + case GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED: + case GDK_MEMORY_R16G16B16A16_FLOAT: + case GDK_MEMORY_R32G32B32_FLOAT: + case GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED: + case GDK_MEMORY_R32G32B32A32_FLOAT: + bytes = gdk_texture_save_to_tiff_bytes (texture); + g_string_append (p->str, "texture: url(\"data:image/tiff;base64,"); + break; + + case GDK_MEMORY_N_FORMATS: + default: + g_assert_not_reached (); + } + b64 = base64_encode_with_linebreaks (g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes)); append_escaping_newlines (p->str, b64); |