forked from AuroraMiddleware/gtk
Merge branch 'wip/otte/for-main' into 'main'
texture: Remove gdk_texture_download_float() See merge request GNOME/gtk!4202
This commit is contained in:
commit
e80238120e
@ -336,12 +336,39 @@ text_view_query_tooltip_cb (GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
load_bytes (NodeEditorWindow *self,
|
||||||
|
GBytes *bytes);
|
||||||
|
|
||||||
|
static void
|
||||||
|
load_error (NodeEditorWindow *self,
|
||||||
|
const char *error_message)
|
||||||
|
{
|
||||||
|
PangoLayout *layout;
|
||||||
|
GtkSnapshot *snapshot;
|
||||||
|
GskRenderNode *node;
|
||||||
|
GBytes *bytes;
|
||||||
|
|
||||||
|
layout = gtk_widget_create_pango_layout (GTK_WIDGET (self), error_message);
|
||||||
|
pango_layout_set_width (layout, 300 * PANGO_SCALE);
|
||||||
|
snapshot = gtk_snapshot_new ();
|
||||||
|
gtk_snapshot_append_layout (snapshot, layout, &(GdkRGBA) { 0.7, 0.13, 0.13, 1.0 });
|
||||||
|
node = gtk_snapshot_free_to_node (snapshot);
|
||||||
|
bytes = gsk_render_node_serialize (node);
|
||||||
|
|
||||||
|
load_bytes (self, bytes);
|
||||||
|
|
||||||
|
gsk_render_node_unref (node);
|
||||||
|
g_object_unref (layout);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
load_bytes (NodeEditorWindow *self,
|
load_bytes (NodeEditorWindow *self,
|
||||||
GBytes *bytes)
|
GBytes *bytes)
|
||||||
{
|
{
|
||||||
if (!g_utf8_validate (g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes), NULL))
|
if (!g_utf8_validate (g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes), NULL))
|
||||||
{
|
{
|
||||||
|
load_error (self, "Invalid UTF-8");
|
||||||
g_bytes_unref (bytes);
|
g_bytes_unref (bytes);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -359,11 +386,16 @@ static gboolean
|
|||||||
load_file_contents (NodeEditorWindow *self,
|
load_file_contents (NodeEditorWindow *self,
|
||||||
GFile *file)
|
GFile *file)
|
||||||
{
|
{
|
||||||
|
GError *error = NULL;
|
||||||
GBytes *bytes;
|
GBytes *bytes;
|
||||||
|
|
||||||
bytes = g_file_load_bytes (file, NULL, NULL, NULL);
|
bytes = g_file_load_bytes (file, NULL, NULL, &error);
|
||||||
if (bytes == NULL)
|
if (bytes == NULL)
|
||||||
|
{
|
||||||
|
load_error (self, error->message);
|
||||||
|
g_clear_error (&error);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
return load_bytes (self, bytes);
|
return load_bytes (self, bytes);
|
||||||
}
|
}
|
||||||
@ -473,17 +505,18 @@ node_editor_window_load (NodeEditorWindow *self,
|
|||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
|
g_clear_object (&self->file_monitor);
|
||||||
|
|
||||||
if (!load_file_contents (self, file))
|
if (!load_file_contents (self, file))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
g_clear_object (&self->file_monitor);
|
|
||||||
self->file_monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, &error);
|
self->file_monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, &error);
|
||||||
|
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
g_warning ("couldn't monitor file: %s", error->message);
|
g_warning ("couldn't monitor file: %s", error->message);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
|
g_clear_object (&self->file_monitor);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -28,8 +28,7 @@
|
|||||||
* `GdkPixbuf`, or a Cairo surface, or other pixel data.
|
* `GdkPixbuf`, or a Cairo surface, or other pixel data.
|
||||||
*
|
*
|
||||||
* The ownership of the pixel data is transferred to the `GdkTexture`
|
* The ownership of the pixel data is transferred to the `GdkTexture`
|
||||||
* instance; you can only make a copy of it, via [method@Gdk.Texture.download]
|
* instance; you can only make a copy of it, via [method@Gdk.Texture.download].
|
||||||
* or [method@Gdk.Texture.download_float].
|
|
||||||
*
|
*
|
||||||
* `GdkTexture` is an immutable object: That means you cannot change
|
* `GdkTexture` is an immutable object: That means you cannot change
|
||||||
* anything about it other than increasing the reference count via
|
* anything about it other than increasing the reference count via
|
||||||
@ -743,48 +742,6 @@ gdk_texture_download (GdkTexture *texture,
|
|||||||
stride);
|
stride);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* gdk_texture_download_float:
|
|
||||||
* @texture: a `GdkTexture`
|
|
||||||
* @data: (array): pointer to enough memory to be filled with the
|
|
||||||
* downloaded data of @texture
|
|
||||||
* @stride: rowstride in elements, will usually be equal to
|
|
||||||
* gdk_texture_get_width() * 4
|
|
||||||
*
|
|
||||||
* Downloads the @texture into local memory in a high dynamic range format.
|
|
||||||
*
|
|
||||||
* This may be an expensive operation, as the actual texture data
|
|
||||||
* may reside on a GPU or on a remote display server and because the data
|
|
||||||
* may need to be upsampled if it was not already available in this
|
|
||||||
* format.
|
|
||||||
*
|
|
||||||
* You may want to use [method@Gdk.Texture.download] instead if you don't
|
|
||||||
* need high dynamic range support.
|
|
||||||
*
|
|
||||||
* The data format of the downloaded data is equivalent to
|
|
||||||
* GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED, so every downloaded
|
|
||||||
* pixel requires 16 bytes of memory.
|
|
||||||
*
|
|
||||||
* Note that the caller is responsible to provide sufficiently
|
|
||||||
* aligned memory to access the resulting data directly as floats.
|
|
||||||
*
|
|
||||||
* Since: 4.6
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
gdk_texture_download_float (GdkTexture *texture,
|
|
||||||
float *data,
|
|
||||||
gsize stride)
|
|
||||||
{
|
|
||||||
g_return_if_fail (GDK_IS_TEXTURE (texture));
|
|
||||||
g_return_if_fail (data != NULL);
|
|
||||||
g_return_if_fail (stride >= gdk_texture_get_width (texture) * 4);
|
|
||||||
|
|
||||||
gdk_texture_do_download (texture,
|
|
||||||
GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED,
|
|
||||||
(guchar *) data,
|
|
||||||
stride);
|
|
||||||
}
|
|
||||||
|
|
||||||
GdkMemoryFormat
|
GdkMemoryFormat
|
||||||
gdk_texture_get_format (GdkTexture *self)
|
gdk_texture_get_format (GdkTexture *self)
|
||||||
{
|
{
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
uniform vec4 u_geometry;
|
uniform vec4 u_geometry;
|
||||||
|
|
||||||
_NOPERSPECTIVE_ _OUT_ vec2 coord;
|
_OUT_ vec2 coord;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
gl_Position = u_projection * (u_modelview * vec4(aPosition, 0.0, 1.0));
|
gl_Position = u_projection * (u_modelview * vec4(aPosition, 0.0, 1.0));
|
||||||
@ -29,7 +29,7 @@ uniform highp int u_num_color_stops; // Why? Because it works like this.
|
|||||||
uniform vec4 u_geometry;
|
uniform vec4 u_geometry;
|
||||||
uniform float u_color_stops[MAX_COLOR_STOPS * 5];
|
uniform float u_color_stops[MAX_COLOR_STOPS * 5];
|
||||||
|
|
||||||
_NOPERSPECTIVE_ _IN_ vec2 coord;
|
_IN_ vec2 coord;
|
||||||
|
|
||||||
float get_offset(int index) {
|
float get_offset(int index) {
|
||||||
// u_color_stops[5 * index] makes Intel Windows driver crash.
|
// u_color_stops[5 * index] makes Intel Windows driver crash.
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// linear_gradient.glsl
|
// linear_gradient.glsl
|
||||||
uniform vec4 u_points;
|
uniform vec4 u_points;
|
||||||
|
|
||||||
_NOPERSPECTIVE_ _OUT_ vec4 info;
|
_OUT_ vec4 info;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
gl_Position = u_projection * (u_modelview * vec4(aPosition, 0.0, 1.0));
|
gl_Position = u_projection * (u_modelview * vec4(aPosition, 0.0, 1.0));
|
||||||
@ -53,7 +53,7 @@ uniform highp int u_num_color_stops; // Why? Because it works like this.
|
|||||||
uniform float u_color_stops[MAX_COLOR_STOPS * 5];
|
uniform float u_color_stops[MAX_COLOR_STOPS * 5];
|
||||||
uniform bool u_repeat;
|
uniform bool u_repeat;
|
||||||
|
|
||||||
_NOPERSPECTIVE_ _IN_ vec4 info;
|
_IN_ vec4 info;
|
||||||
|
|
||||||
float get_offset(int index) {
|
float get_offset(int index) {
|
||||||
// u_color_stops[5 * index] makes Intel Windows driver crash.
|
// u_color_stops[5 * index] makes Intel Windows driver crash.
|
||||||
|
@ -5,12 +5,10 @@ precision highp float;
|
|||||||
#if defined(GSK_GLES) || defined(GSK_LEGACY)
|
#if defined(GSK_GLES) || defined(GSK_LEGACY)
|
||||||
#define _OUT_ varying
|
#define _OUT_ varying
|
||||||
#define _IN_ varying
|
#define _IN_ varying
|
||||||
#define _NOPERSPECTIVE_
|
|
||||||
#define _GSK_ROUNDED_RECT_UNIFORM_ vec4[3]
|
#define _GSK_ROUNDED_RECT_UNIFORM_ vec4[3]
|
||||||
#else
|
#else
|
||||||
#define _OUT_ out
|
#define _OUT_ out
|
||||||
#define _IN_ in
|
#define _IN_ in
|
||||||
#define _NOPERSPECTIVE_ noperspective
|
|
||||||
#define _GSK_ROUNDED_RECT_UNIFORM_ GskRoundedRect
|
#define _GSK_ROUNDED_RECT_UNIFORM_ GskRoundedRect
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
uniform vec4 u_geometry;
|
uniform vec4 u_geometry;
|
||||||
|
|
||||||
_NOPERSPECTIVE_ _OUT_ vec2 coord;
|
_OUT_ vec2 coord;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
gl_Position = u_projection * (u_modelview * vec4(aPosition, 0.0, 1.0));
|
gl_Position = u_projection * (u_modelview * vec4(aPosition, 0.0, 1.0));
|
||||||
@ -32,7 +32,7 @@ uniform bool u_repeat;
|
|||||||
uniform vec2 u_range;
|
uniform vec2 u_range;
|
||||||
uniform float u_color_stops[MAX_COLOR_STOPS * 5];
|
uniform float u_color_stops[MAX_COLOR_STOPS * 5];
|
||||||
|
|
||||||
_NOPERSPECTIVE_ _IN_ vec2 coord;
|
_IN_ vec2 coord;
|
||||||
|
|
||||||
float get_offset(int index) {
|
float get_offset(int index) {
|
||||||
// u_color_stops[5 * index] makes Intel Windows driver crash.
|
// u_color_stops[5 * index] makes Intel Windows driver crash.
|
||||||
|
@ -828,18 +828,14 @@ project (double angle,
|
|||||||
{
|
{
|
||||||
double x, y;
|
double x, y;
|
||||||
|
|
||||||
x = radius * cos (angle);
|
#ifdef HAVE_SINCOS
|
||||||
y = radius * sin (angle);
|
sincos (angle, &y, &x);
|
||||||
if (copysign (x, 1.0) > copysign (y, 1.0))
|
#else
|
||||||
{
|
x = cos (angle);
|
||||||
*x_out = copysign (radius, x);
|
y = sin (angle);
|
||||||
*y_out = y * radius / copysign (x, 1.0);
|
#endif
|
||||||
}
|
*x_out = radius * x;
|
||||||
else
|
*y_out = radius * y;
|
||||||
{
|
|
||||||
*x_out = x * radius / copysign (y, 1.0);
|
|
||||||
*y_out = copysign (radius, y);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1185,10 +1185,17 @@ get_width_for_height (GtkLabel *self,
|
|||||||
{
|
{
|
||||||
int min, max, mid, text_width, text_height;
|
int min, max, mid, text_width, text_height;
|
||||||
|
|
||||||
|
/* Can't use a measuring layout here, because we need to force
|
||||||
|
* ellipsizing mode */
|
||||||
|
gtk_label_ensure_layout (self);
|
||||||
|
layout = pango_layout_copy (self->layout);
|
||||||
|
pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_NONE);
|
||||||
|
|
||||||
/* binary search for the smallest width where the height doesn't
|
/* binary search for the smallest width where the height doesn't
|
||||||
* eclipse the given height */
|
* eclipse the given height */
|
||||||
min = MAX (minimum_default, 0);
|
min = MAX (minimum_default, 0);
|
||||||
layout = gtk_label_get_measuring_layout (self, NULL, -1);
|
|
||||||
|
pango_layout_set_width (layout, -1);
|
||||||
pango_layout_get_size (layout, &max, NULL);
|
pango_layout_get_size (layout, &max, NULL);
|
||||||
|
|
||||||
min = PANGO_PIXELS_CEIL (min);
|
min = PANGO_PIXELS_CEIL (min);
|
||||||
@ -1196,7 +1203,7 @@ get_width_for_height (GtkLabel *self,
|
|||||||
while (min < max)
|
while (min < max)
|
||||||
{
|
{
|
||||||
mid = (min + max) / 2;
|
mid = (min + max) / 2;
|
||||||
layout = gtk_label_get_measuring_layout (self, layout, mid * PANGO_SCALE);
|
pango_layout_set_width (layout, mid * PANGO_SCALE);
|
||||||
pango_layout_get_size (layout, &text_width, &text_height);
|
pango_layout_get_size (layout, &text_width, &text_height);
|
||||||
text_width = PANGO_PIXELS_CEIL (text_width);
|
text_width = PANGO_PIXELS_CEIL (text_width);
|
||||||
if (text_width > mid)
|
if (text_width > mid)
|
||||||
@ -1207,8 +1214,19 @@ get_width_for_height (GtkLabel *self,
|
|||||||
max = mid;
|
max = mid;
|
||||||
}
|
}
|
||||||
|
|
||||||
*minimum_width = min * PANGO_SCALE;
|
|
||||||
*natural_width = min * PANGO_SCALE;
|
*natural_width = min * PANGO_SCALE;
|
||||||
|
|
||||||
|
if (self->ellipsize != PANGO_ELLIPSIZE_NONE)
|
||||||
|
{
|
||||||
|
g_object_unref (layout);
|
||||||
|
layout = gtk_label_get_measuring_layout (self, NULL, MAX (minimum_default, 0));
|
||||||
|
pango_layout_get_size (layout, minimum_width, NULL);
|
||||||
|
*minimum_width = MAX (*minimum_width, minimum_default);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*minimum_width = *natural_width;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_unref (layout);
|
g_object_unref (layout);
|
||||||
|
@ -31,44 +31,6 @@ struct _TextureBuilder
|
|||||||
gsize offset;
|
gsize offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
static float
|
|
||||||
gdk_memory_format_precsion (GdkMemoryFormat format)
|
|
||||||
{
|
|
||||||
switch (format)
|
|
||||||
{
|
|
||||||
case GDK_MEMORY_R8G8B8:
|
|
||||||
case GDK_MEMORY_B8G8R8:
|
|
||||||
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:
|
|
||||||
return 1/256.f;
|
|
||||||
|
|
||||||
case GDK_MEMORY_R16G16B16:
|
|
||||||
case GDK_MEMORY_R16G16B16A16_PREMULTIPLIED:
|
|
||||||
case GDK_MEMORY_R16G16B16A16:
|
|
||||||
return 1/65536.f;
|
|
||||||
|
|
||||||
case GDK_MEMORY_R16G16B16_FLOAT:
|
|
||||||
case GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED:
|
|
||||||
case GDK_MEMORY_R16G16B16A16_FLOAT:
|
|
||||||
return 0.0009765625f;
|
|
||||||
|
|
||||||
case GDK_MEMORY_R32G32B32_FLOAT:
|
|
||||||
case GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED:
|
|
||||||
case GDK_MEMORY_R32G32B32A32_FLOAT:
|
|
||||||
return FLT_EPSILON;
|
|
||||||
|
|
||||||
case GDK_MEMORY_N_FORMATS:
|
|
||||||
default:
|
|
||||||
g_assert_not_reached ();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static gsize
|
static gsize
|
||||||
gdk_memory_format_bytes_per_pixel (GdkMemoryFormat format)
|
gdk_memory_format_bytes_per_pixel (GdkMemoryFormat format)
|
||||||
{
|
{
|
||||||
@ -434,50 +396,6 @@ compare_textures (GdkTexture *expected,
|
|||||||
g_free (test_data);
|
g_free (test_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
compare_textures_float (GdkTexture *expected,
|
|
||||||
GdkTexture *test,
|
|
||||||
float eps,
|
|
||||||
gboolean has_alpha)
|
|
||||||
{
|
|
||||||
static int R = 0;
|
|
||||||
static int G = 1;
|
|
||||||
static int B = 2;
|
|
||||||
static int A = 3;
|
|
||||||
float *expected_data, *test_data;
|
|
||||||
int width, height;
|
|
||||||
int x, y;
|
|
||||||
|
|
||||||
g_assert_cmpint (gdk_texture_get_width (expected), ==, gdk_texture_get_width (test));
|
|
||||||
g_assert_cmpint (gdk_texture_get_height (expected), ==, gdk_texture_get_height (test));
|
|
||||||
|
|
||||||
width = gdk_texture_get_width (expected);
|
|
||||||
height = gdk_texture_get_height (expected);
|
|
||||||
|
|
||||||
expected_data = g_new (float, width * height * 4);
|
|
||||||
gdk_texture_download_float (expected, expected_data, width * 4);
|
|
||||||
|
|
||||||
test_data = g_new (float, width * height * 4);
|
|
||||||
gdk_texture_download_float (test, test_data, width * 4);
|
|
||||||
|
|
||||||
for (y = 0; y < height; y++)
|
|
||||||
{
|
|
||||||
for (x = 0; x < width; x++)
|
|
||||||
{
|
|
||||||
g_assert_cmpfloat_with_epsilon (expected_data[y * width + 4 * x + R], test_data[y * width + 4 * x + R], eps);
|
|
||||||
g_assert_cmpfloat_with_epsilon (expected_data[y * width + 4 * x + G], test_data[y * width + 4 * x + G], eps);
|
|
||||||
g_assert_cmpfloat_with_epsilon (expected_data[y * width + 4 * x + B], test_data[y * width + 4 * x + B], eps);
|
|
||||||
if (has_alpha)
|
|
||||||
g_assert_cmpfloat_with_epsilon (expected_data[y * width + 4 * x + A], test_data[y * width + 4 * x + A], eps);
|
|
||||||
else
|
|
||||||
g_assert_cmpfloat (1.0, ==, test_data[y * width + 4 * x + A]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (expected_data);
|
|
||||||
g_free (test_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
static GdkTexture *
|
static GdkTexture *
|
||||||
upload_to_gl (GdkTexture *texture)
|
upload_to_gl (GdkTexture *texture)
|
||||||
{
|
{
|
||||||
@ -682,61 +600,6 @@ test_download_192x192 (gconstpointer data)
|
|||||||
g_object_unref (test);
|
g_object_unref (test);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
test_download_float_1x1 (gconstpointer data)
|
|
||||||
{
|
|
||||||
GdkMemoryFormat format;
|
|
||||||
TextureMethod method;
|
|
||||||
GdkTexture *expected, *test;
|
|
||||||
gsize i;
|
|
||||||
|
|
||||||
decode (data, &format, &method);
|
|
||||||
|
|
||||||
for (i = 0; i < N; i++)
|
|
||||||
{
|
|
||||||
GdkRGBA color;
|
|
||||||
|
|
||||||
create_random_color (&color);
|
|
||||||
expected = create_texture (GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED, TEXTURE_METHOD_LOCAL, 1, 1, &color);
|
|
||||||
test = create_texture (format, method, 1, 1, &color);
|
|
||||||
|
|
||||||
compare_textures_float (expected, test,
|
|
||||||
gdk_memory_format_precsion (format),
|
|
||||||
gdk_memory_format_has_alpha (format));
|
|
||||||
|
|
||||||
g_object_unref (expected);
|
|
||||||
g_object_unref (test);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
test_download_float_4x4 (gconstpointer data)
|
|
||||||
{
|
|
||||||
GdkMemoryFormat format;
|
|
||||||
TextureMethod method;
|
|
||||||
GdkTexture *expected, *test;
|
|
||||||
gsize i;
|
|
||||||
|
|
||||||
decode (data, &format, &method);
|
|
||||||
|
|
||||||
for (i = 0; i < N; i++)
|
|
||||||
{
|
|
||||||
GdkRGBA color;
|
|
||||||
|
|
||||||
create_random_color (&color);
|
|
||||||
expected = create_texture (GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED, TEXTURE_METHOD_LOCAL, 4, 4, &color);
|
|
||||||
test = create_texture (format, method, 4, 4, &color);
|
|
||||||
|
|
||||||
compare_textures_float (expected, test,
|
|
||||||
gdk_memory_format_precsion (format),
|
|
||||||
gdk_memory_format_has_alpha (format));
|
|
||||||
|
|
||||||
g_object_unref (expected);
|
|
||||||
g_object_unref (test);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
add_test (const char *name,
|
add_test (const char *name,
|
||||||
GTestDataFunc func)
|
GTestDataFunc func)
|
||||||
@ -772,8 +635,6 @@ main (int argc, char *argv[])
|
|||||||
add_test ("/memorytexture/download_1x1", test_download_1x1);
|
add_test ("/memorytexture/download_1x1", test_download_1x1);
|
||||||
add_test ("/memorytexture/download_4x4", test_download_4x4);
|
add_test ("/memorytexture/download_4x4", test_download_4x4);
|
||||||
add_test ("/memorytexture/download_192x192", test_download_192x192);
|
add_test ("/memorytexture/download_192x192", test_download_192x192);
|
||||||
add_test ("/memorytexture/download_float_1x1", test_download_float_1x1);
|
|
||||||
add_test ("/memorytexture/download_float_4x4", test_download_float_4x4);
|
|
||||||
|
|
||||||
gl_renderer = gsk_gl_renderer_new ();
|
gl_renderer = gsk_gl_renderer_new ();
|
||||||
if (!gsk_renderer_realize (gl_renderer, NULL, NULL))
|
if (!gsk_renderer_realize (gl_renderer, NULL, NULL))
|
||||||
|
@ -9,7 +9,6 @@ ensure_texture_access (GdkTexture *texture)
|
|||||||
{
|
{
|
||||||
/* Make sure to initialize the pixel to anything but red */
|
/* Make sure to initialize the pixel to anything but red */
|
||||||
guint32 pixel = 0;
|
guint32 pixel = 0;
|
||||||
float float_pixel[4] = { INFINITY, INFINITY, INFINITY, INFINITY };
|
|
||||||
|
|
||||||
g_test_message ("Checking texture access in thread %p...", g_thread_self());
|
g_test_message ("Checking texture access in thread %p...", g_thread_self());
|
||||||
/* Just to be sure */
|
/* Just to be sure */
|
||||||
@ -18,14 +17,9 @@ ensure_texture_access (GdkTexture *texture)
|
|||||||
|
|
||||||
/* download the pixel */
|
/* download the pixel */
|
||||||
gdk_texture_download (texture, (guchar *) &pixel, 4);
|
gdk_texture_download (texture, (guchar *) &pixel, 4);
|
||||||
gdk_texture_download_float (texture, float_pixel, 4);
|
|
||||||
|
|
||||||
/* check the pixel is now red */
|
/* check the pixel is now red */
|
||||||
g_assert_cmphex (pixel, ==, 0xFFFF0000);
|
g_assert_cmphex (pixel, ==, 0xFFFF0000);
|
||||||
g_assert_cmpfloat (float_pixel[0], ==, 1.0);
|
|
||||||
g_assert_cmpfloat (float_pixel[1], ==, 0.0);
|
|
||||||
g_assert_cmpfloat (float_pixel[2], ==, 0.0);
|
|
||||||
g_assert_cmpfloat (float_pixel[3], ==, 1.0);
|
|
||||||
|
|
||||||
g_test_message ("...done in thread %p", g_thread_self());
|
g_test_message ("...done in thread %p", g_thread_self());
|
||||||
}
|
}
|
||||||
|
15
testsuite/reftests/hbox-with-ellipsizing-label.ref.ui
Normal file
15
testsuite/reftests/hbox-with-ellipsizing-label.ref.ui
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<interface>
|
||||||
|
<object class="GtkWindow">
|
||||||
|
<property name="decorated">0</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="label">Hello World</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</interface>
|
16
testsuite/reftests/hbox-with-ellipsizing-label.ui
Normal file
16
testsuite/reftests/hbox-with-ellipsizing-label.ui
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<interface>
|
||||||
|
<object class="GtkWindow">
|
||||||
|
<property name="decorated">0</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="label">Hello World</property>
|
||||||
|
<property name="ellipsize">end</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</interface>
|
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<interface>
|
||||||
|
<object class="GtkWindow">
|
||||||
|
<property name="decorated">0</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="label">Hello World</property>
|
||||||
|
<property name="wrap">True</property>
|
||||||
|
<property name="wrap-mode">char</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</interface>
|
18
testsuite/reftests/hbox-with-ellipsizing-wrapping-label.ui
Normal file
18
testsuite/reftests/hbox-with-ellipsizing-wrapping-label.ui
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<interface>
|
||||||
|
<object class="GtkWindow">
|
||||||
|
<property name="decorated">0</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="label">Hello World</property>
|
||||||
|
<property name="ellipsize">end</property>
|
||||||
|
<property name="wrap">True</property>
|
||||||
|
<property name="wrap-mode">char</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</interface>
|
@ -2,7 +2,6 @@
|
|||||||
<interface>
|
<interface>
|
||||||
<object class="GtkWindow" id="window1">
|
<object class="GtkWindow" id="window1">
|
||||||
<property name="decorated">0</property>
|
<property name="decorated">0</property>
|
||||||
<signal name="realize" handler="reftest:set_default_direction_ltr"/>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkGrid" id="grid1">
|
<object class="GtkGrid" id="grid1">
|
||||||
<property name="row_spacing">1</property>
|
<property name="row_spacing">1</property>
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
<interface>
|
<interface>
|
||||||
<object class="GtkWindow" id="window1">
|
<object class="GtkWindow" id="window1">
|
||||||
<property name="decorated">0</property>
|
<property name="decorated">0</property>
|
||||||
<signal name="realize" handler="reftest:set_default_direction_ltr"/>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkGrid" id="grid1">
|
<object class="GtkGrid" id="grid1">
|
||||||
<property name="row-spacing">1</property>
|
<property name="row-spacing">1</property>
|
||||||
|
@ -310,6 +310,10 @@ testdata = [
|
|||||||
'gtk-icontheme-sizing.css',
|
'gtk-icontheme-sizing.css',
|
||||||
'gtk-icontheme-sizing.ref.ui',
|
'gtk-icontheme-sizing.ref.ui',
|
||||||
'gtk-icontheme-sizing.ui',
|
'gtk-icontheme-sizing.ui',
|
||||||
|
'hbox-with-ellipsizing-label.ref.ui',
|
||||||
|
'hbox-with-ellipsizing-label.ui',
|
||||||
|
'hbox-with-ellipsizing-wrapping-label.ref.ui',
|
||||||
|
'hbox-with-ellipsizing-wrapping-label.ui',
|
||||||
'icon-effect-missing.css',
|
'icon-effect-missing.css',
|
||||||
'icon-effect-missing.ref.ui',
|
'icon-effect-missing.ref.ui',
|
||||||
'icon-effect-missing.ui',
|
'icon-effect-missing.ui',
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
char *
|
char *
|
||||||
diff_with_file (const char *file1,
|
diff_with_file (const char *file1,
|
||||||
char *text,
|
const char *text,
|
||||||
gssize len,
|
gssize len,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
char * diff_with_file (const char *file1,
|
char * diff_with_file (const char *file1,
|
||||||
char *text,
|
const char *text,
|
||||||
gssize len,
|
gssize len,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user