mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-09-19 13:30:02 +00:00
reftest-compare: Respect color states when diffing
Always pick the color state from texture1 and download the data and generate the diff in that color state. That now means the order of the 2 arguments matters.
This commit is contained in:
parent
f9cbeeeedc
commit
e268041a42
@ -79,12 +79,13 @@ memory_format_is_high_depth (GdkMemoryFormat format)
|
|||||||
* Copyright © 2004 Richard D. Worth
|
* Copyright © 2004 Richard D. Worth
|
||||||
*/
|
*/
|
||||||
static GdkTexture *
|
static GdkTexture *
|
||||||
buffer_diff_u8 (const guchar *buf_a,
|
buffer_diff_u8 (GdkColorState *color_state,
|
||||||
int stride_a,
|
const guchar *buf_a,
|
||||||
const guchar *buf_b,
|
int stride_a,
|
||||||
int stride_b,
|
const guchar *buf_b,
|
||||||
int width,
|
int stride_b,
|
||||||
int height)
|
int width,
|
||||||
|
int height)
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
guchar *buf_diff = NULL;
|
guchar *buf_diff = NULL;
|
||||||
@ -113,15 +114,21 @@ buffer_diff_u8 (const guchar *buf_a,
|
|||||||
|
|
||||||
if (diff == NULL)
|
if (diff == NULL)
|
||||||
{
|
{
|
||||||
|
GdkMemoryTextureBuilder *builder;
|
||||||
GBytes *bytes;
|
GBytes *bytes;
|
||||||
|
|
||||||
stride_diff = 4 * width;
|
stride_diff = 4 * width;
|
||||||
buf_diff = g_malloc0_n (stride_diff, height);
|
buf_diff = g_malloc0_n (stride_diff, height);
|
||||||
bytes = g_bytes_new_take (buf_diff, stride_diff * height);
|
bytes = g_bytes_new_take (buf_diff, stride_diff * height);
|
||||||
diff = gdk_memory_texture_new (width, height,
|
builder = gdk_memory_texture_builder_new ();
|
||||||
GDK_MEMORY_DEFAULT,
|
gdk_memory_texture_builder_set_width (builder, width);
|
||||||
bytes,
|
gdk_memory_texture_builder_set_height (builder, height);
|
||||||
stride_diff);
|
gdk_memory_texture_builder_set_format (builder, GDK_MEMORY_DEFAULT);
|
||||||
|
gdk_memory_texture_builder_set_color_state (builder, color_state);
|
||||||
|
gdk_memory_texture_builder_set_bytes (builder, bytes);
|
||||||
|
gdk_memory_texture_builder_set_stride (builder, stride_diff);
|
||||||
|
diff = gdk_memory_texture_builder_build (builder);
|
||||||
|
g_object_unref (builder);
|
||||||
row = (guint32 *) (buf_diff + y * stride_diff);
|
row = (guint32 *) (buf_diff + y * stride_diff);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,12 +169,13 @@ buffer_diff_u8 (const guchar *buf_a,
|
|||||||
* surfaces.
|
* surfaces.
|
||||||
*/
|
*/
|
||||||
static GdkTexture *
|
static GdkTexture *
|
||||||
buffer_diff_float (const guchar *buf_a,
|
buffer_diff_float (GdkColorState *color_state,
|
||||||
int stride_a,
|
const guchar *buf_a,
|
||||||
const guchar *buf_b,
|
int stride_a,
|
||||||
int stride_b,
|
const guchar *buf_b,
|
||||||
int width,
|
int stride_b,
|
||||||
int height)
|
int width,
|
||||||
|
int height)
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
guchar *buf_diff = NULL;
|
guchar *buf_diff = NULL;
|
||||||
@ -199,15 +207,21 @@ buffer_diff_float (const guchar *buf_a,
|
|||||||
|
|
||||||
if (diff == NULL)
|
if (diff == NULL)
|
||||||
{
|
{
|
||||||
|
GdkMemoryTextureBuilder *builder;
|
||||||
GBytes *bytes;
|
GBytes *bytes;
|
||||||
|
|
||||||
stride_diff = 4 * width * sizeof (float);
|
stride_diff = 4 * width * sizeof (float);
|
||||||
buf_diff = g_malloc0_n (stride_diff, height);
|
buf_diff = g_malloc0_n (stride_diff, height);
|
||||||
bytes = g_bytes_new_take (buf_diff, stride_diff * height);
|
bytes = g_bytes_new_take (buf_diff, stride_diff * height);
|
||||||
diff = gdk_memory_texture_new (width, height,
|
builder = gdk_memory_texture_builder_new ();
|
||||||
GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED,
|
gdk_memory_texture_builder_set_width (builder, width);
|
||||||
bytes,
|
gdk_memory_texture_builder_set_height (builder, height);
|
||||||
stride_diff);
|
gdk_memory_texture_builder_set_format (builder, GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED);
|
||||||
|
gdk_memory_texture_builder_set_color_state (builder, color_state);
|
||||||
|
gdk_memory_texture_builder_set_bytes (builder, bytes);
|
||||||
|
gdk_memory_texture_builder_set_stride (builder, stride_diff);
|
||||||
|
diff = gdk_memory_texture_builder_build (builder);
|
||||||
|
g_object_unref (builder);
|
||||||
row = (float *) (buf_diff + y * stride_diff);
|
row = (float *) (buf_diff + y * stride_diff);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,13 +265,16 @@ reftest_compare_textures (GdkTexture *texture1,
|
|||||||
int w, h, stride;
|
int w, h, stride;
|
||||||
guchar *data1, *data2;
|
guchar *data1, *data2;
|
||||||
GdkTextureDownloader *downloader;
|
GdkTextureDownloader *downloader;
|
||||||
|
GdkColorState *color_state;
|
||||||
GdkTexture *diff;
|
GdkTexture *diff;
|
||||||
gboolean high_depth;
|
gboolean high_depth;
|
||||||
|
|
||||||
w = MAX (gdk_texture_get_width (texture1), gdk_texture_get_width (texture2));
|
w = MAX (gdk_texture_get_width (texture1), gdk_texture_get_width (texture2));
|
||||||
h = MAX (gdk_texture_get_height (texture1), gdk_texture_get_height (texture2));
|
h = MAX (gdk_texture_get_height (texture1), gdk_texture_get_height (texture2));
|
||||||
|
color_state = gdk_texture_get_color_state (texture1);
|
||||||
|
|
||||||
downloader = gdk_texture_downloader_new (texture1);
|
downloader = gdk_texture_downloader_new (texture1);
|
||||||
|
gdk_texture_downloader_set_color_state (downloader, color_state);
|
||||||
high_depth = memory_format_is_high_depth (gdk_texture_get_format (texture1)) ||
|
high_depth = memory_format_is_high_depth (gdk_texture_get_format (texture1)) ||
|
||||||
memory_format_is_high_depth (gdk_texture_get_format (texture1));
|
memory_format_is_high_depth (gdk_texture_get_format (texture1));
|
||||||
if (high_depth)
|
if (high_depth)
|
||||||
@ -279,13 +296,15 @@ reftest_compare_textures (GdkTexture *texture1,
|
|||||||
|
|
||||||
if (high_depth)
|
if (high_depth)
|
||||||
{
|
{
|
||||||
diff = buffer_diff_float (data1, stride,
|
diff = buffer_diff_float (color_state,
|
||||||
|
data1, stride,
|
||||||
data2, stride,
|
data2, stride,
|
||||||
w, h);
|
w, h);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
diff = buffer_diff_u8 (data1, stride,
|
diff = buffer_diff_u8 (color_state,
|
||||||
|
data1, stride,
|
||||||
data2, stride,
|
data2, stride,
|
||||||
w, h);
|
w, h);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user