Compare commits

..

3 Commits

Author SHA1 Message Date
Emmanuele Bassi
24b69a9a10 examples: Update to bind settings inside UI definitions 2021-09-09 19:22:48 +01:00
Emmanuele Bassi
043eea6ae3 docs: Document the settings binding in GtkBuilder UI files
And clean up the structure while we're at it.
2021-09-09 19:22:06 +01:00
Emmanuele Bassi
181fce8342 Support binding properties to GSettings keys in GtkBuilder
We already support binding properties; by adding new attributes to the
`property` element we can automatically call g_settings_bind() on the
object ourselves.
2021-09-09 19:12:40 +01:00
58 changed files with 9208 additions and 10090 deletions

View File

@@ -25,7 +25,7 @@ variables:
BACKEND_FLAGS: "-Dx11-backend=true -Dwayland-backend=true -Dbroadway-backend=true"
FEATURE_FLAGS: "-Dvulkan=enabled -Dcloudproviders=enabled"
MESON_TEST_TIMEOUT_MULTIPLIER: 3
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v34"
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v33"
FLATPAK_IMAGE: "registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master"
.only-default:

View File

@@ -53,7 +53,6 @@ RUN dnf -y install \
libpng-devel \
librsvg2 \
libselinux-devel \
libtiff-devel \
libubsan \
libXcomposite-devel \
libXcursor-devel \

286
config.h.meson Normal file
View File

@@ -0,0 +1,286 @@
/* always defined to indicate that i18n is enabled */
#define ENABLE_NLS 1
/* Use structured logging */
#define G_LOG_STRUCTURED 1
/* The prefix for our gettext translation domains. */
#mesondefine GETTEXT_PACKAGE
/* Disable deprecation warnings from glib */
#mesondefine GLIB_DISABLE_DEPRECATION_WARNINGS
/* Define the location where the catalogs will be installed */
#mesondefine GTK_LOCALEDIR
/* Define to 1 if you have the `bind_textdomain_codeset' function. */
#mesondefine HAVE_BIND_TEXTDOMAIN_CODESET
/* Have the cloudproviders library */
#mesondefine HAVE_CLOUDPROVIDERS
/* define if we have colord */
#mesondefine HAVE_COLORD
/* Define to 1 if you have the <crt_externs.h> header file. */
#mesondefine HAVE_CRT_EXTERNS_H
/* Define to 1 if you have the `dcgettext' function. */
#mesondefine HAVE_DCGETTEXT
/* Define to 1 if you have the <dlfcn.h> header file. */
#mesondefine HAVE_DLFCN_H
/* Have the ffmpeg library */
#mesondefine HAVE_FFMPEG
/* Define to 1 if you have the <ftw.h> header file. */
#mesondefine HAVE_FTW_H
/* Define to 1 if you have the `getpagesize' function. */
#mesondefine HAVE_GETPAGESIZE
/* Define to 1 if you have the `getresuid' function. */
#mesondefine HAVE_GETRESUID
/* Define if gio-unix is available */
#mesondefine HAVE_GIO_UNIX
/* Define if GStreamer support is available */
#mesondefine HAVE_GSTREAMER
/* Define to 1 if you have the <inttypes.h> header file. */
#mesondefine HAVE_INTTYPES_H
/* Define to 1 if the system has the type `IPrintDialogCallback'. */
#mesondefine HAVE_IPRINTDIALOGCALLBACK
/* Define to 1 if you have the <locale.h> header file. */
#mesondefine HAVE_LOCALE_H
/* Define to 1 if you have the `lstat' function. */
#mesondefine HAVE_LSTAT
/* Define to 1 if you have the `mallinfo' function. */
#mesondefine HAVE_MALLINFO
/* Define to 1 if you have the <memory.h> header file. */
#mesondefine HAVE_MEMORY_H
/* Define to 1 if you have the `mkstemp' function. */
#mesondefine HAVE_MKSTEMP
/* Define to 1 if you have the `mlock` function. */
#mesondefine HAVE_MLOCK
/* Define to 1 if you have a working `mmap' system call. */
#mesondefine HAVE_MMAP
/* Define to 1 if you have a working `madvise' system call. */
#mesondefine HAVE_MADVISE
/* Define to 1 if you have the `posix_fallocate' function. */
#mesondefine HAVE_POSIX_FALLOCATE
/* Have the Xrandr extension library */
#mesondefine HAVE_RANDR
/* Have the Xrandr 1.5 extension library */
#mesondefine HAVE_RANDR15
/* Define to 1 if you have the `sincos' function. */
#mesondefine HAVE_SINCOS
/* Define to 1 if you have the <stdint.h> header file. */
#mesondefine HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#mesondefine HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#mesondefine HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#mesondefine HAVE_STRING_H
/* Define to 1 if you have the <sys/mman.h> header file. */
#mesondefine HAVE_SYS_MMAN_H
/* Define to 1 if you have the <sys/param.h> header file. */
#mesondefine HAVE_SYS_PARAM_H
/* Have the sysprof-capture library */
#mesondefine HAVE_SYSPROF
/* Define to 1 if you have the <sys/stat.h> header file. */
#mesondefine HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/time.h> header file. */
#mesondefine HAVE_SYS_TIME_H
/* Define to 1 if you have the <sys/types.h> header file. */
#mesondefine HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
#mesondefine HAVE_UNISTD_H
/* Have the Xcursor library */
#mesondefine HAVE_XCURSOR
/* Have the XDAMAGE X extension */
#mesondefine HAVE_XDAMAGE
/* Have the XFIXES X extension */
#mesondefine HAVE_XFIXES
/* Define to 1 if XFree Xinerama is available */
#mesondefine HAVE_XFREE_XINERAMA
/* Have XGenericEvent */
#mesondefine HAVE_XGENERICEVENTS
/* Define to use XKB extension */
#mesondefine HAVE_XKB
/* Have the SYNC extension library */
#mesondefine HAVE_XSYNC
/* Define to 1 if you have the `_lock_file' function */
#mesondefine HAVE__LOCK_FILE
/* Define to 1 if you have the `flockfile' function */
#mesondefine HAVE_FLOCKFILE
/* Define if _NL_MEASUREMENT_MEASUREMENT is available */
#mesondefine HAVE__NL_MEASUREMENT_MEASUREMENT
/* Define if _NL_PAPER_HEIGHT is available */
#mesondefine HAVE__NL_PAPER_HEIGHT
/* Define if _NL_PAPER_WIDTH is available */
#mesondefine HAVE__NL_PAPER_WIDTH
/* Define if _NL_TIME_FIRST_WEEKDAY is available */
#mesondefine HAVE__NL_TIME_FIRST_WEEKDAY
/* Define to the sub-directory where libtool stores uninstalled libraries. */
#mesondefine LT_OBJDIR
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
#mesondefine NO_MINUS_C_MINUS_O
/* Define to the address where bug reports for this package should be sent. */
#mesondefine PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#mesondefine PACKAGE_NAME
/* Define to the full name and version of this package. */
#mesondefine PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#mesondefine PACKAGE_TARNAME
/* Define to the home page for this package. */
#mesondefine PACKAGE_URL
/* Define to the version of this package. */
#mesondefine PACKAGE_VERSION
/* Use NSBundle functions to determine load paths for libraries, translations,
etc. */
#mesondefine QUARTZ_RELOCATION
/* Define to 1 if you have the ANSI C header files. */
#mesondefine STDC_HEADERS
/* Enable extensions on AIX 3, Interix. */
#ifndef _ALL_SOURCE
# undef _ALL_SOURCE
#endif
/* Enable GNU extensions on systems that have them. */
#ifndef _GNU_SOURCE
# undef _GNU_SOURCE
#endif
/* Enable threading extensions on Solaris. */
#ifndef _POSIX_PTHREAD_SEMANTICS
# undef _POSIX_PTHREAD_SEMANTICS
#endif
/* Enable extensions on HP NonStop. */
#ifndef _TANDEM_SOURCE
# undef _TANDEM_SOURCE
#endif
/* Enable general extensions on Solaris. */
#ifndef __EXTENSIONS__
# undef __EXTENSIONS__
#endif
/* Define to 1 if XInput 2.2 is available */
#mesondefine XINPUT_2_2
/* Define to 1 if the X Window System is missing or not being used. */
#mesondefine X_DISPLAY_MISSING
/* Enable large inode numbers on Mac OS X 10.5. */
#ifndef _DARWIN_USE_64_BIT_INODE
# define _DARWIN_USE_64_BIT_INODE 1
#endif
/* Number of bits in a file offset, on hosts where this is settable. */
#mesondefine _FILE_OFFSET_BITS
/* defines how to decorate public symbols while building */
#mesondefine _GDK_EXTERN
/* Define for large files, on AIX-style hosts. */
#mesondefine _LARGE_FILES
/* Define to 1 if on MINIX. */
#mesondefine _MINIX
/* Define to 2 if the system does not provide POSIX.1 features except with
this defined. */
#mesondefine _POSIX_1_SOURCE
/* Define to 1 if you need to in order for `stat' and other things to work. */
#mesondefine _POSIX_SOURCE
/* Define to `int' if <sys/types.h> doesn't define. */
#mesondefine gid_t
/* Define to `int' if <sys/types.h> doesn't define. */
#mesondefine uid_t
/* Define to 1 if linux/memfd.h exists */
#mesondefine HAVE_LINUX_MEMFD_H
#mesondefine HAVE_LINUX_INPUT_H
#mesondefine HAVE_DEV_EVDEV_INPUT_H
#mesondefine GTK_SYSCONFDIR
#mesondefine GTK_LOCALEDIR
#mesondefine GTK_DATADIR
#mesondefine GTK_LIBDIR
#mesondefine GTK_PRINT_BACKENDS
#mesondefine HAVE_CAIRO_SCRIPT_INTERPRETER
#mesondefine HAVE_HARFBUZZ
#mesondefine HAVE_PANGOFT
#mesondefine ISO_CODES_PREFIX
/* Define if tracker3 is available */
#mesondefine HAVE_TRACKER3
#mesondefine HAVE_F16C
/* Does the OS support GDesktopAppInfo? */
#mesondefine HAVE_DESKTOPAPPINFO

View File

@@ -7,10 +7,6 @@
struct _ExampleAppPrefs
{
GtkDialog parent;
GSettings *settings;
GtkWidget *font;
GtkWidget *transition;
};
G_DEFINE_TYPE (ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
@@ -19,41 +15,20 @@ static void
example_app_prefs_init (ExampleAppPrefs *prefs)
{
gtk_widget_init_template (GTK_WIDGET (prefs));
prefs->settings = g_settings_new ("org.gtk.exampleapp");
g_settings_bind (prefs->settings, "font",
prefs->font, "font",
G_SETTINGS_BIND_DEFAULT);
g_settings_bind (prefs->settings, "transition",
prefs->transition, "active-id",
G_SETTINGS_BIND_DEFAULT);
}
static void
example_app_prefs_dispose (GObject *object)
{
ExampleAppPrefs *prefs;
prefs = EXAMPLE_APP_PREFS (object);
g_clear_object (&prefs->settings);
G_OBJECT_CLASS (example_app_prefs_parent_class)->dispose (object);
}
static void
example_app_prefs_class_init (ExampleAppPrefsClass *class)
{
G_OBJECT_CLASS (class)->dispose = example_app_prefs_dispose;
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/org/gtk/exampleapp/prefs.ui");
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppPrefs, font);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppPrefs, transition);
}
ExampleAppPrefs *
example_app_prefs_new (ExampleAppWindow *win)
{
return g_object_new (EXAMPLE_APP_PREFS_TYPE, "transient-for", win, "use-header-bar", TRUE, NULL);
return g_object_new (EXAMPLE_APP_PREFS_TYPE,
"transient-for", win,
"use-header-bar", TRUE,
NULL);
}

View File

@@ -28,6 +28,7 @@
</child>
<child>
<object class="GtkFontButton" id="font">
<property name="font" bind-settings-schema="org.gtk.exampleapp" bind-settings-key="font"/>
<layout>
<property name="column">1</property>
<property name="row">0</property>
@@ -48,6 +49,7 @@
</child>
<child>
<object class="GtkComboBoxText" id="transition">
<property name="active-id" bind-settings-schema="org.gtk.exampleapp" bind-settings-key="transition"/>
<items>
<item translatable="yes" id="none">None</item>
<item translatable="yes" id="crossfade">Fade</item>

View File

@@ -50,7 +50,7 @@ cairo_region_t *
gdk_cairo_region_create_from_surface
(cairo_surface_t *surface);
GDK_DEPRECATED_IN_4_6_FOR(gdk_gl_texture_new)
GDK_AVAILABLE_IN_ALL
void gdk_cairo_draw_from_gl (cairo_t *cr,
GdkSurface *surface,
int source,

View File

@@ -301,7 +301,7 @@ gdk_gl_texture_quads (GdkGLContext *paint_context,
* @width: The width of the region to draw
* @height: The height of the region to draw
*
* The main way to not draw GL content in GTK.
* The main way to draw GL content in GTK.
*
* It takes a render buffer ID (@source_type == GL_RENDERBUFFER) or a texture
* id (@source_type == GL_TEXTURE) and draws it onto @cr with an OVER operation,
@@ -319,12 +319,6 @@ gdk_gl_texture_quads (GdkGLContext *paint_context,
* with alpha components, so make sure you use GL_TEXTURE if using alpha.
*
* Calling this may change the current GL context.
*
* Deprecated: 4.6: The function is overly complex and produces broken output
* in various combinations of arguments. If you want to draw with GL textures
* in GTK, use [ctor@Gdk.GLTexture.new]; if you want to use that texture in
* Cairo, use [method@Gdk.Texture.download] to download the data into a Cairo
* image surface.
*/
void
gdk_cairo_draw_from_gl (cairo_t *cr,

View File

@@ -229,83 +229,64 @@ gdk_gl_context_upload_texture (GdkGLContext *context,
{
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
guchar *copy = NULL;
GLint gl_internalformat;
GLint gl_format;
GLint gl_type;
gsize bpp;
guint gl_format;
guint gl_type;
guint bpp;
g_return_if_fail (GDK_IS_GL_CONTEXT (context));
if (!priv->use_es && data_format == GDK_MEMORY_DEFAULT) /* Cairo surface format */
if (priv->use_es)
{
gl_internalformat = GL_RGBA8;
gl_format = GL_BGRA;
gl_type = GL_UNSIGNED_INT_8_8_8_8_REV;
}
else if (data_format == GDK_MEMORY_R8G8B8) /* Pixmap non-alpha data */
{
gl_internalformat = GL_RGBA8;
gl_format = GL_RGB;
gl_type = GL_UNSIGNED_BYTE;
}
else if (priv->use_es && data_format == GDK_MEMORY_B8G8R8)
{
gl_internalformat = GL_RGBA8;
gl_format = GL_BGR;
gl_type = GL_UNSIGNED_BYTE;
}
else if (data_format == GDK_MEMORY_R16G16B16)
{
gl_internalformat = GL_RGBA16;
gl_format = GL_RGB;
gl_type = GL_UNSIGNED_SHORT;
}
else if (data_format == GDK_MEMORY_R16G16B16A16_PREMULTIPLIED)
{
gl_internalformat = GL_RGBA16;
gl_format = GL_RGBA;
gl_type = GL_UNSIGNED_SHORT;
}
else if (data_format == GDK_MEMORY_R16G16B16_FLOAT)
{
gl_internalformat = GL_RGB16F;
gl_format = GL_RGB;
gl_type = GL_HALF_FLOAT;
}
else if (data_format == GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED)
{
gl_internalformat = GL_RGBA16F;
gl_format = GL_RGBA;
gl_type = GL_HALF_FLOAT;
}
else if (data_format == GDK_MEMORY_R32G32B32_FLOAT)
{
gl_internalformat = GL_RGB32F;
gl_format = GL_RGB;
gl_type = GL_FLOAT;
}
else if (data_format == GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED)
{
gl_internalformat = GL_RGBA32F;
gl_format = GL_RGBA;
gl_type = GL_FLOAT;
}
else /* Fall-back, convert to GLES format */
{
copy = g_malloc (width * height * 4);
gdk_memory_convert (copy, width * 4,
GDK_MEMORY_CONVERT_GLES_RGBA,
data, stride, data_format,
width, height);
data_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED;
stride = width * 4;
data = copy;
gl_internalformat = GL_RGBA8;
gl_format = GL_RGBA;
gl_type = GL_UNSIGNED_BYTE;
}
/* GLES only supports rgba, so convert if necessary */
if (data_format != GDK_MEMORY_R8G8B8A8_PREMULTIPLIED)
{
copy = g_malloc (width * height * 4);
gdk_memory_convert (copy, width * 4,
GDK_MEMORY_R8G8B8A8_PREMULTIPLIED,
data, stride, data_format,
width, height);
stride = width * 4;
data = copy;
}
bpp = gdk_memory_format_bytes_per_pixel (data_format);
bpp = 4;
gl_format = GL_RGBA;
gl_type = GL_UNSIGNED_BYTE;
}
else
{
if (data_format == GDK_MEMORY_DEFAULT) /* Cairo surface format */
{
gl_format = GL_BGRA;
gl_type = GL_UNSIGNED_INT_8_8_8_8_REV;
bpp = 4;
}
else if (data_format == GDK_MEMORY_R8G8B8) /* Pixmap non-alpha data */
{
gl_format = GL_RGB;
gl_type = GL_UNSIGNED_BYTE;
bpp = 3;
}
else if (data_format == GDK_MEMORY_B8G8R8)
{
gl_format = GL_BGR;
gl_type = GL_UNSIGNED_BYTE;
bpp = 3;
}
else /* Fall-back, convert to cairo-surface-format */
{
copy = g_malloc (width * height * 4);
gdk_memory_convert (copy, width * 4,
GDK_MEMORY_DEFAULT,
data, stride, data_format,
width, height);
stride = width * 4;
bpp = 4;
data = copy;
gl_format = GL_BGRA;
gl_type = GL_UNSIGNED_INT_8_8_8_8_REV;
}
}
/* GL_UNPACK_ROW_LENGTH is available on desktop GL, OpenGL ES >= 3.0, or if
* the GL_EXT_unpack_subimage extension for OpenGL ES 2.0 is available
@@ -314,7 +295,7 @@ gdk_gl_context_upload_texture (GdkGLContext *context,
{
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
glTexImage2D (texture_target, 0, gl_internalformat, width, height, 0, gl_format, gl_type, data);
glTexImage2D (texture_target, 0, GL_RGBA, width, height, 0, gl_format, gl_type, data);
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
}
else if ((!priv->use_es ||
@@ -322,14 +303,14 @@ gdk_gl_context_upload_texture (GdkGLContext *context,
{
glPixelStorei (GL_UNPACK_ROW_LENGTH, stride / bpp);
glTexImage2D (texture_target, 0, gl_internalformat, width, height, 0, gl_format, gl_type, data);
glTexImage2D (texture_target, 0, GL_RGBA, width, height, 0, gl_format, gl_type, data);
glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
}
else
{
int i;
glTexImage2D (texture_target, 0, gl_internalformat, width, height, 0, gl_format, gl_type, NULL);
glTexImage2D (texture_target, 0, GL_RGBA, width, height, 0, gl_format, gl_type, NULL);
for (i = 0; i < height; i++)
glTexSubImage2D (texture_target, 0, 0, i, width, 1, gl_format, gl_type, data + (i * stride));
}

View File

@@ -20,8 +20,7 @@
#include "gdkgltextureprivate.h"
#include "gdkdisplayprivate.h"
#include "gdkmemorytextureprivate.h"
#include "gdkcairo.h"
#include "gdktextureprivate.h"
#include <epoxy/gl.h>
@@ -38,7 +37,7 @@ struct _GdkGLTexture {
GdkGLContext *context;
guint id;
GdkTexture *saved;
cairo_surface_t *saved;
GDestroyNotify destroy;
gpointer data;
@@ -65,239 +64,50 @@ gdk_gl_texture_dispose (GObject *object)
g_clear_object (&self->context);
self->id = 0;
g_clear_object (&self->saved);
if (self->saved)
{
cairo_surface_destroy (self->saved);
self->saved = NULL;
}
G_OBJECT_CLASS (gdk_gl_texture_parent_class)->dispose (object);
}
typedef struct _InvokeData
{
GdkGLTexture *self;
volatile int spinlock;
GFunc func;
gpointer data;
} InvokeData;
static gboolean
gdk_gl_texture_invoke_callback (gpointer data)
{
InvokeData *invoke = data;
GdkGLContext *context;
context = gdk_display_get_gl_context (gdk_gl_context_get_display (invoke->self->context));
gdk_gl_context_make_current (context);
glBindTexture (GL_TEXTURE_2D, invoke->self->id);
invoke->func (invoke->self, invoke->data);
g_atomic_int_set (&invoke->spinlock, 1);
return FALSE;
}
static void
gdk_gl_texture_run (GdkGLTexture *self,
GFunc func,
gpointer data)
{
InvokeData invoke = { self, 0, func, data };
g_main_context_invoke (NULL, gdk_gl_texture_invoke_callback, &invoke);
while (g_atomic_int_get (&invoke.spinlock) == 0);
}
static void
gdk_gl_texture_do_download_texture (gpointer texture_,
gpointer result_)
{
GdkTexture *texture = texture_;
GdkTexture **result = result_;
GdkMemoryFormat format;
GLint internal_format, gl_format, gl_type;
guchar *data;
gsize stride;
GBytes *bytes;
glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &internal_format);
switch (internal_format)
{
case GL_RGB8:
format = GDK_MEMORY_R8G8B8;
gl_format = GL_RGB;
gl_type = GL_UNSIGNED_BYTE;
break;
case GL_RGBA8:
format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED;
gl_format = GL_RGBA;
gl_type = GL_UNSIGNED_BYTE;
break;
case GL_RGB16:
format = GDK_MEMORY_R16G16B16;
gl_format = GL_RGB;
gl_type = GL_UNSIGNED_SHORT;
break;
case GL_RGBA16:
format = GDK_MEMORY_R16G16B16A16_PREMULTIPLIED;
gl_format = GL_RGBA;
gl_type = GL_UNSIGNED_SHORT;
break;
case GL_RGB16F:
format = GDK_MEMORY_R16G16B16_FLOAT;
gl_format = GL_RGB;
gl_type = GL_HALF_FLOAT;
break;
case GL_RGBA16F:
format = GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED;
gl_format = GL_RGBA;
gl_type = GL_HALF_FLOAT;
break;
case GL_RGB32F:
format = GDK_MEMORY_R32G32B32_FLOAT;
gl_format = GL_RGB;
gl_type = GL_FLOAT;
break;
case GL_RGBA32F:
format = GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED;
gl_format = GL_RGBA;
gl_type = GL_FLOAT;
break;
default:
g_warning ("Texture in unexpected format 0x%X (%d). File a bug about adding it to GTK", internal_format, internal_format);
/* fallback to the dumbest possible format
* so that even age old GLES can do it */
format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED;
gl_format = GL_RGBA;
gl_type = GL_UNSIGNED_BYTE;
break;
}
stride = gdk_memory_format_bytes_per_pixel (format) * texture->width;
data = g_malloc (stride * texture->height);
glGetTexImage (GL_TEXTURE_2D,
0,
gl_format,
gl_type,
data);
bytes = g_bytes_new_take (data, stride * texture->height);
*result = gdk_memory_texture_new (texture->width,
texture->height,
format,
bytes,
stride);
g_bytes_unref (bytes);
}
static GdkTexture *
gdk_gl_texture_download_texture (GdkTexture *texture)
gdk_gl_texture_download (GdkTexture *texture,
const GdkRectangle *area,
guchar *data,
gsize stride)
{
GdkGLTexture *self = GDK_GL_TEXTURE (texture);
GdkTexture *result;
cairo_surface_t *surface;
cairo_t *cr;
if (self->saved)
return g_object_ref (self->saved);
surface = cairo_image_surface_create_for_data (data,
CAIRO_FORMAT_ARGB32,
area->width, area->height,
stride);
gdk_gl_texture_run (self, gdk_gl_texture_do_download_texture, &result);
return result;
}
static void
gdk_gl_texture_do_download (gpointer texture,
gpointer data)
{
glGetTexImage (GL_TEXTURE_2D,
0,
GL_BGRA,
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
GL_UNSIGNED_INT_8_8_8_8_REV,
#elif G_BYTE_ORDER == G_BIG_ENDIAN
GL_UNSIGNED_BYTE,
#else
#error "Unknown byte order for gdk_gl_texture_download()"
#endif
data);
}
static void
gdk_gl_texture_download (GdkTexture *texture,
guchar *data,
gsize stride)
{
GdkGLTexture *self = GDK_GL_TEXTURE (texture);
cr = cairo_create (surface);
if (self->saved)
{
gdk_texture_download (self->saved, data, stride);
return;
cairo_set_source_surface (cr, self->saved, 0, 0);
cairo_paint (cr);
}
if (gdk_gl_context_get_use_es (self->context) ||
stride != texture->width * 4)
else
{
GDK_TEXTURE_CLASS (gdk_gl_texture_parent_class)->download (texture, data, stride);
return;
GdkSurface *gl_surface;
gl_surface = gdk_gl_context_get_surface (self->context);
gdk_cairo_draw_from_gl (cr, gl_surface, self->id, GL_TEXTURE, 1,
area->x, area->y,
area->width, area->height);
}
gdk_gl_texture_run (self, gdk_gl_texture_do_download, data);
}
static void
gdk_gl_texture_do_download_float (gpointer texture,
gpointer data)
{
glGetTexImage (GL_TEXTURE_2D,
0,
GL_RGBA,
GL_FLOAT,
data);
}
static void
gdk_gl_texture_download_float (GdkTexture *texture,
float *data,
gsize stride)
{
GdkGLTexture *self = GDK_GL_TEXTURE (texture);
int width, height, y;
float *copy;
if (self->saved)
{
gdk_texture_download_float (self->saved, data, stride);
return;
}
width = gdk_texture_get_width (texture);
height = gdk_texture_get_height (texture);
if (stride == width * 4)
{
gdk_gl_texture_run (self, gdk_gl_texture_do_download_float, data);
return;
}
copy = g_new (float, width * height * 4);
gdk_gl_texture_run (self, gdk_gl_texture_do_download_float, copy);
for (y = 0; y < height; y++)
memcpy (data + y * stride, copy + y * 4 * width, 4 * width);
g_free (copy);
cairo_destroy (cr);
cairo_surface_finish (surface);
cairo_surface_destroy (surface);
}
static void
@@ -306,9 +116,7 @@ gdk_gl_texture_class_init (GdkGLTextureClass *klass)
GdkTextureClass *texture_class = GDK_TEXTURE_CLASS (klass);
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
texture_class->download_texture = gdk_gl_texture_download_texture;
texture_class->download = gdk_gl_texture_download;
texture_class->download_float = gdk_gl_texture_download_float;
gobject_class->dispose = gdk_gl_texture_dispose;
}
@@ -342,10 +150,24 @@ gdk_gl_texture_get_id (GdkGLTexture *self)
void
gdk_gl_texture_release (GdkGLTexture *self)
{
GdkSurface *surface;
GdkTexture *texture;
cairo_t *cr;
g_return_if_fail (GDK_IS_GL_TEXTURE (self));
g_return_if_fail (self->saved == NULL);
self->saved = gdk_texture_download_texture (GDK_TEXTURE (self));
texture = GDK_TEXTURE (self);
self->saved = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
texture->width, texture->height);
cr = cairo_create (self->saved);
surface = gdk_gl_context_get_surface (self->context);
gdk_cairo_draw_from_gl (cr, surface, self->id, GL_TEXTURE, 1, 0, 0,
texture->width, texture->height);
cairo_destroy (cr);
if (self->destroy)
{

View File

@@ -20,7 +20,6 @@
#include "config.h"
#include "gdkmemorytextureprivate.h"
#include "gsk/ngl/fp16private.h"
/**
* GdkMemoryTexture:
@@ -50,33 +49,19 @@ gdk_memory_format_bytes_per_pixel (GdkMemoryFormat format)
{
switch (format)
{
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 4;
case GDK_MEMORY_R8G8B8:
case GDK_MEMORY_B8G8R8:
return 3;
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 4;
case GDK_MEMORY_R16G16B16:
case GDK_MEMORY_R16G16B16_FLOAT:
return 6;
case GDK_MEMORY_R16G16B16A16_PREMULTIPLIED:
case GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED:
return 8;
case GDK_MEMORY_R32G32B32_FLOAT:
return 12;
case GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED:
return 16;
case GDK_MEMORY_N_FORMATS:
default:
g_assert_not_reached ();
@@ -84,41 +69,6 @@ gdk_memory_format_bytes_per_pixel (GdkMemoryFormat format)
}
}
static gsize
gdk_memory_format_alignment (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 G_ALIGNOF (guchar);
case GDK_MEMORY_R16G16B16:
case GDK_MEMORY_R16G16B16_FLOAT:
return G_ALIGNOF (guint16);
case GDK_MEMORY_R16G16B16A16_PREMULTIPLIED:
case GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED:
return G_ALIGNOF (guint16);
case GDK_MEMORY_R32G32B32_FLOAT:
case GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED:
return G_ALIGNOF (float);
case GDK_MEMORY_N_FORMATS:
default:
g_assert_not_reached ();
return G_ALIGNOF (double);
}
}
static void
gdk_memory_texture_dispose (GObject *object)
{
@@ -129,41 +79,22 @@ gdk_memory_texture_dispose (GObject *object)
G_OBJECT_CLASS (gdk_memory_texture_parent_class)->dispose (object);
}
static GdkTexture *
gdk_memory_texture_download_texture (GdkTexture *texture)
{
return g_object_ref (texture);
}
static void
gdk_memory_texture_download (GdkTexture *texture,
guchar *data,
gsize stride)
gdk_memory_texture_download (GdkTexture *texture,
const GdkRectangle *area,
guchar *data,
gsize stride)
{
GdkMemoryTexture *self = GDK_MEMORY_TEXTURE (texture);
gdk_memory_convert (data, stride,
GDK_MEMORY_CONVERT_DOWNLOAD,
(guchar *) g_bytes_get_data (self->bytes, NULL),
GDK_MEMORY_CAIRO_FORMAT_ARGB32,
(guchar *) g_bytes_get_data (self->bytes, NULL)
+ area->x * gdk_memory_format_bytes_per_pixel (self->format)
+ area->y * self->stride,
self->stride,
self->format,
gdk_texture_get_width (texture),
gdk_texture_get_height (texture));
}
static void
gdk_memory_texture_download_float (GdkTexture *texture,
float *data,
gsize stride)
{
GdkMemoryTexture *self = GDK_MEMORY_TEXTURE (texture);
gdk_memory_convert_to_float (data, stride,
(guchar *) g_bytes_get_data (self->bytes, NULL),
self->stride,
self->format,
gdk_texture_get_width (texture),
gdk_texture_get_height (texture));
area->width, area->height);
}
static void
@@ -172,9 +103,7 @@ gdk_memory_texture_class_init (GdkMemoryTextureClass *klass)
GdkTextureClass *texture_class = GDK_TEXTURE_CLASS (klass);
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
texture_class->download_texture = gdk_memory_texture_download_texture;
texture_class->download = gdk_memory_texture_download;
texture_class->download_float = gdk_memory_texture_download_float;
gobject_class->dispose = gdk_memory_texture_dispose;
}
@@ -183,41 +112,6 @@ gdk_memory_texture_init (GdkMemoryTexture *self)
{
}
static GBytes *
gdk_memory_sanitize (GBytes *bytes,
int width,
int height,
GdkMemoryFormat format,
gsize stride,
gsize *out_stride)
{
gsize align, size, copy_stride, bpp;
const guchar *data;
guchar *copy;
int y;
data = g_bytes_get_data (bytes, &size);
align = gdk_memory_format_alignment (format);
if (GPOINTER_TO_SIZE (data) % align == 0 &&
stride % align == 0)
{
*out_stride = stride;
return g_bytes_ref (bytes);
}
bpp = gdk_memory_format_bytes_per_pixel (format);
copy_stride = bpp * width;
/* align to multiples of 4, just to be sure */
copy_stride = (copy_stride + 3) & ~3;
copy = g_malloc (copy_stride * height);
for (y = 0; y < height; y++)
memcpy (copy + y * copy_stride, data + y * stride, bpp * width);
*out_stride = copy_stride;
return g_bytes_new_take (copy, copy_stride * height);
}
/**
* gdk_memory_texture_new:
* @width: the width of the texture
@@ -242,20 +136,13 @@ gdk_memory_texture_new (int width,
{
GdkMemoryTexture *self;
g_return_val_if_fail (width > 0, NULL);
g_return_val_if_fail (height > 0, NULL);
g_return_val_if_fail (bytes != NULL, NULL);
g_return_val_if_fail (stride >= width * gdk_memory_format_bytes_per_pixel (format), NULL);
bytes = gdk_memory_sanitize (bytes, width, height, format, stride, &stride);
self = g_object_new (GDK_TYPE_MEMORY_TEXTURE,
"width", width,
"height", height,
NULL);
self->format = format;
self->bytes = bytes;
self->bytes = g_bytes_ref (bytes);
self->stride = stride;
return GDK_TEXTURE (self);
@@ -396,109 +283,6 @@ SWIZZLE_PREMULTIPLY (3,0,1,2, 0,1,2,3)
SWIZZLE_PREMULTIPLY (3,0,1,2, 3,0,1,2)
SWIZZLE_PREMULTIPLY (3,0,1,2, 0,3,2,1)
#define CONVERT_FUNC(name,suffix,R,G,B,A,step) \
static void \
convert_ ## name ## _to_ ## suffix (guchar *dest_data, \
gsize dest_stride, \
const guchar *src_data, \
gsize src_stride, \
gsize width, \
gsize height) \
{ \
gsize x, y; \
\
for (y = 0; y < height; y++) \
{ \
for (x = 0; x < width; x++) \
{ \
guchar conv[4]; \
convert_pixel_ ## name (conv, src_data + step * x); \
dest_data[4 * x + R] = conv[0]; \
dest_data[4 * x + G] = conv[1]; \
dest_data[4 * x + B] = conv[2]; \
dest_data[4 * x + A] = conv[3]; \
} \
\
dest_data += dest_stride; \
src_data += src_stride; \
} \
}
#define CONVERT_FUNCS(name,step) \
CONVERT_FUNC(name, download_le, 2, 1, 0, 3, step) \
CONVERT_FUNC(name, download_be, 1, 2, 3, 0, step) \
CONVERT_FUNC(name, gles_rgba, 0, 1, 2, 3, step) \
static inline void
convert_pixel_rgb16 (guchar *dest_data, const guchar *src_data)
{
const guint16 *src = (const guint16 *) src_data;
dest_data[0] = (guchar)(src[0] >> 8);
dest_data[1] = (guchar)(src[1] >> 8);
dest_data[2] = (guchar)(src[2] >> 8);
dest_data[3] = 0xFF;
}
CONVERT_FUNCS(rgb16, 3 * sizeof (guint16))
static inline void
convert_pixel_rgba16 (guchar *dest_data, const guchar *src_data)
{
const guint16 *src = (const guint16 *) src_data;
dest_data[0] = (guchar)(src[0] >> 8);
dest_data[1] = (guchar)(src[1] >> 8);
dest_data[2] = (guchar)(src[2] >> 8);
dest_data[3] = (guchar)(src[3] >> 8);
}
CONVERT_FUNCS(rgba16, 4 * sizeof (guint16))
static inline void
convert_pixel_rgb16f (guchar *dest_data, const guchar *src_data)
{
float src[4];
guint16 tmp[4];
memcpy(tmp, src_data, sizeof(guint16) * 3);
half_to_float4(tmp, src);
dest_data[0] = CLAMP (src[0] * 256.f, 0.f, 255.f);
dest_data[1] = CLAMP (src[1] * 256.f, 0.f, 255.f);
dest_data[2] = CLAMP (src[2] * 256.f, 0.f, 255.f);
dest_data[3] = 0xFF;
}
CONVERT_FUNCS(rgb16f, 3 * sizeof (guint16))
static inline void
convert_pixel_rgba16f (guchar *dest_data, const guchar *src_data)
{
float src[4];
half_to_float4((const guint16 *) src_data, src);
dest_data[0] = CLAMP (src[0] * 256.f, 0.f, 255.f);
dest_data[1] = CLAMP (src[1] * 256.f, 0.f, 255.f);
dest_data[2] = CLAMP (src[2] * 256.f, 0.f, 255.f);
dest_data[3] = CLAMP (src[3] * 256.f, 0.f, 255.f);
}
CONVERT_FUNCS(rgba16f, 4 * sizeof (guint16))
static inline void
convert_pixel_rgb32f (guchar *dest_data, const guchar *src_data)
{
float *src = (float *) src_data;
dest_data[0] = CLAMP (src[0] * 256.f, 0.f, 255.f);
dest_data[1] = CLAMP (src[1] * 256.f, 0.f, 255.f);
dest_data[2] = CLAMP (src[2] * 256.f, 0.f, 255.f);
dest_data[3] = 0xFF;
}
CONVERT_FUNCS(rgb32f, 3 * sizeof (float))
static inline void
convert_pixel_rgba32f (guchar *dest_data, const guchar *src_data)
{
float *src = (float *) src_data;
dest_data[0] = CLAMP (src[0] * 256.f, 0.f, 255.f);
dest_data[1] = CLAMP (src[1] * 256.f, 0.f, 255.f);
dest_data[2] = CLAMP (src[2] * 256.f, 0.f, 255.f);
dest_data[3] = CLAMP (src[3] * 256.f, 0.f, 255.f);
}
CONVERT_FUNCS(rgba32f, 4 * sizeof (float))
typedef void (* ConversionFunc) (guchar *dest_data,
gsize dest_stride,
const guchar *src_data,
@@ -506,7 +290,7 @@ typedef void (* ConversionFunc) (guchar *dest_data,
gsize width,
gsize height);
static ConversionFunc converters[GDK_MEMORY_N_FORMATS][GDK_MEMORY_N_CONVERSIONS] =
static ConversionFunc converters[GDK_MEMORY_N_FORMATS][3] =
{
{ convert_memcpy, convert_swizzle3210, convert_swizzle2103 },
{ convert_swizzle3210, convert_memcpy, convert_swizzle3012 },
@@ -516,192 +300,21 @@ static ConversionFunc converters[GDK_MEMORY_N_FORMATS][GDK_MEMORY_N_CONVERSIONS]
{ convert_swizzle_premultiply_3210_3012, convert_swizzle_premultiply_0123_3012, convert_swizzle_premultiply_3012_3012 },
{ convert_swizzle_premultiply_3210_0321, convert_swizzle_premultiply_0123_0321, convert_swizzle_premultiply_3012_0321 },
{ convert_swizzle_opaque_3210, convert_swizzle_opaque_0123, convert_swizzle_opaque_3012 },
{ convert_swizzle_opaque_3012, convert_swizzle_opaque_0321, convert_swizzle_opaque_3210 },
{ convert_rgb16_to_download_le, convert_rgb16_to_download_be, convert_rgb16_to_gles_rgba },
{ convert_rgba16_to_download_le, convert_rgba16_to_download_be, convert_rgba16_to_gles_rgba },
{ convert_rgb16f_to_download_le, convert_rgb16f_to_download_be, convert_rgb16f_to_gles_rgba },
{ convert_rgba16f_to_download_le, convert_rgba16f_to_download_be, convert_rgba16f_to_gles_rgba },
{ convert_rgb32f_to_download_le, convert_rgb32f_to_download_be, convert_rgb32f_to_gles_rgba },
{ convert_rgba32f_to_download_le, convert_rgba32f_to_download_be, convert_rgba32f_to_gles_rgba }
{ convert_swizzle_opaque_3012, convert_swizzle_opaque_0321, convert_swizzle_opaque_3210 }
};
void
gdk_memory_convert (guchar *dest_data,
gsize dest_stride,
GdkMemoryConversion dest_format,
const guchar *src_data,
gsize src_stride,
GdkMemoryFormat src_format,
gsize width,
gsize height)
gdk_memory_convert (guchar *dest_data,
gsize dest_stride,
GdkMemoryFormat dest_format,
const guchar *src_data,
gsize src_stride,
GdkMemoryFormat src_format,
gsize width,
gsize height)
{
g_assert (dest_format < 3);
g_assert (src_format < GDK_MEMORY_N_FORMATS);
converters[src_format][dest_format] (dest_data, dest_stride, src_data, src_stride, width, height);
}
#define CONVERT_FLOAT(R,G,B,A,premultiply) G_STMT_START {\
for (y = 0; y < height; y++) \
{ \
for (x = 0; x < width; x++) \
{ \
if (A >= 0) \
{ \
dest_data[4 * x + 0] = src_data[4 * x + R] / 255.0f; \
dest_data[4 * x + 1] = src_data[4 * x + G] / 255.0f; \
dest_data[4 * x + 2] = src_data[4 * x + B] / 255.0f; \
dest_data[4 * x + 3] = src_data[4 * x + A] / 255.0f; \
if (premultiply) \
{ \
dest_data[4 * x + 0] *= dest_data[4 * x + 3]; \
dest_data[4 * x + 1] *= dest_data[4 * x + 3]; \
dest_data[4 * x + 2] *= dest_data[4 * x + 3]; \
} \
} \
else \
{ \
dest_data[4 * x + 0] = src_data[3 * x + R] / 255.0f; \
dest_data[4 * x + 1] = src_data[3 * x + G] / 255.0f; \
dest_data[4 * x + 2] = src_data[3 * x + B] / 255.0f; \
dest_data[4 * x + 3] = 1.0; \
} \
} \
\
dest_data += dest_stride; \
src_data += src_stride; \
} \
}G_STMT_END
#define CONVERT_FLOAT_PIXEL(func,step) G_STMT_START{\
for (y = 0; y < height; y++) \
{ \
for (x = 0; x < width; x++) \
{ \
func (dest_data + 4 * x, src_data + step * x); \
} \
\
dest_data += dest_stride; \
src_data += src_stride; \
} \
}G_STMT_END
static inline void
convert_rgb16_to_float (float *dest, const guchar *src_data)
{
const guint16 *src = (const guint16 *) src_data;
dest[0] = src[0] / 65535.f;
dest[1] = src[1] / 65535.f;
dest[2] = src[2] / 65535.f;
dest[3] = 1.0;
}
static inline void
convert_rgba16_to_float (float *dest, const guchar *src_data)
{
const guint16 *src = (const guint16 *) src_data;
dest[0] = src[0] / 65535.f;
dest[1] = src[1] / 65535.f;
dest[2] = src[2] / 65535.f;
dest[3] = 1.0;
}
static inline void
convert_rgb16f_to_float (float *dest, const guchar *src_data)
{
guint16 tmp[4];
memcpy(tmp, src_data, sizeof(guint16) * 3);
tmp[3] = FP16_ONE;
half_to_float4 (tmp, dest);
}
static inline void
convert_rgba16f_to_float (float *dest, const guchar *src_data)
{
half_to_float4 ((const guint16 *) src_data, dest);
}
static inline void
convert_rgb32f_to_float (float *dest, const guchar *src_data)
{
const float *src = (const float *) src_data;
dest[0] = src[0];
dest[1] = src[1];
dest[2] = src[2];
dest[3] = 1.0;
}
static inline void
convert_rgba32f_to_float (float *dest, const guchar *src_data)
{
const float *src = (const float *) src_data;
dest[0] = src[0];
dest[1] = src[1];
dest[2] = src[2];
dest[3] = src[3];
}
void
gdk_memory_convert_to_float (float *dest_data,
gsize dest_stride,
const guchar *src_data,
gsize src_stride,
GdkMemoryFormat src_format,
gsize width,
gsize height)
{
gsize x, y;
switch (src_format)
{
case GDK_MEMORY_B8G8R8A8_PREMULTIPLIED:
CONVERT_FLOAT (2, 1, 0, 3, FALSE);
break;
case GDK_MEMORY_A8R8G8B8_PREMULTIPLIED:
CONVERT_FLOAT (1, 2, 3, 0, FALSE);
break;
case GDK_MEMORY_R8G8B8A8_PREMULTIPLIED:
CONVERT_FLOAT (0, 1, 2, 3, FALSE);
break;
case GDK_MEMORY_B8G8R8A8:
CONVERT_FLOAT (2, 1, 0, 3, TRUE);
break;
case GDK_MEMORY_A8R8G8B8:
CONVERT_FLOAT (1, 2, 3, 0, TRUE);
break;
case GDK_MEMORY_R8G8B8A8:
CONVERT_FLOAT (0, 1, 2, 3, TRUE);
break;
case GDK_MEMORY_A8B8G8R8:
CONVERT_FLOAT (3, 2, 1, 0, TRUE);
break;
case GDK_MEMORY_R8G8B8:
CONVERT_FLOAT (0, 1, 2, -1, FALSE);
break;
case GDK_MEMORY_B8G8R8:
CONVERT_FLOAT (2, 1, 0, -1, FALSE);
break;
case GDK_MEMORY_R16G16B16:
CONVERT_FLOAT_PIXEL (convert_rgb16_to_float, 3 * sizeof (guint16));
break;
case GDK_MEMORY_R16G16B16A16_PREMULTIPLIED:
CONVERT_FLOAT_PIXEL (convert_rgba16_to_float, 4 * sizeof (guint16));
break;
case GDK_MEMORY_R16G16B16_FLOAT:
CONVERT_FLOAT_PIXEL (convert_rgb16f_to_float, 3 * sizeof (guint16));
break;
case GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED:
CONVERT_FLOAT_PIXEL (convert_rgba16f_to_float, 4 * sizeof (guint16));
break;
case GDK_MEMORY_R32G32B32_FLOAT:
CONVERT_FLOAT_PIXEL (convert_rgb32f_to_float, 3 * sizeof (float));
break;
case GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED:
CONVERT_FLOAT_PIXEL (convert_rgba32f_to_float, 4 * sizeof (float));
break;
case GDK_MEMORY_N_FORMATS:
default:
g_assert_not_reached();
}
}

View File

@@ -42,20 +42,6 @@ G_BEGIN_DECLS
* @GDK_MEMORY_A8B8G8R8: 4 bytes; for alpha, blue, green, red.
* @GDK_MEMORY_R8G8B8: 3 bytes; for red, green, blue. The data is opaque.
* @GDK_MEMORY_B8G8R8: 3 bytes; for blue, green, red. The data is opaque.
* @GDK_MEMORY_R16G16B16: 3 guint16 values; for red, green, blue. Since 4.6
* @GDK_MEMORY_R16G16B16A16_PREMULTIPLIED: 4 guint16 values; for red, green,
* blue, alpha. The color values are premultiplied with the alpha value.
* Since 4.6
* @GDK_MEMORY_R16G16B16_FLOAT: 3 half-float values; for red, green, blue.
* The data is opaque. Since 4.6
* @GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED: 4 half-float values; for
* red, green, blue and alpha. The color values are premultiplied with
* the alpha value. Since 4.6
* @GDK_MEMORY_B32G32R32_FLOAT: 3 float values; for blue, green, red.
* The data is opaque. Since 4.6
* @GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED: 4 float values; for
* red, green, blue and alpha. The color values are premultiplied with
* the alpha value. Since 4.6
* @GDK_MEMORY_N_FORMATS: The number of formats. This value will change as
* more formats get added, so do not rely on its concrete integer.
*
@@ -81,12 +67,6 @@ typedef enum {
GDK_MEMORY_A8B8G8R8,
GDK_MEMORY_R8G8B8,
GDK_MEMORY_B8G8R8,
GDK_MEMORY_R16G16B16,
GDK_MEMORY_R16G16B16A16_PREMULTIPLIED,
GDK_MEMORY_R16G16B16_FLOAT,
GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED,
GDK_MEMORY_R32G32B32_FLOAT,
GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED,
GDK_MEMORY_N_FORMATS
} GdkMemoryFormat;

View File

@@ -29,21 +29,7 @@ G_BEGIN_DECLS
#define GDK_MEMORY_GDK_PIXBUF_OPAQUE GDK_MEMORY_R8G8B8
#define GDK_MEMORY_GDK_PIXBUF_ALPHA GDK_MEMORY_R8G8B8A8
typedef enum {
GDK_MEMORY_CONVERT_DOWNLOAD_LITTLE_ENDIAN,
GDK_MEMORY_CONVERT_DOWNLOAD_BIT_ENDIAN,
GDK_MEMORY_CONVERT_GLES_RGBA,
GDK_MEMORY_N_CONVERSIONS
} GdkMemoryConversion;
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
#define GDK_MEMORY_CONVERT_DOWNLOAD GDK_MEMORY_CONVERT_DOWNLOAD_LITTLE_ENDIAN
#elif G_BYTE_ORDER == G_BIG_ENDIAN
#define GDK_MEMORY_CONVERT_DOWNLOAD GDK_MEMORY_CONVERT_DOWNLOAD_BIG_ENDIAN
#else
#error "Unknown byte order for GDK_MEMORY_CONVERT_DOWNLOAD"
#endif
#define GDK_MEMORY_CAIRO_FORMAT_ARGB32 GDK_MEMORY_DEFAULT
gsize gdk_memory_format_bytes_per_pixel (GdkMemoryFormat format);
@@ -51,22 +37,14 @@ GdkMemoryFormat gdk_memory_texture_get_format (GdkMemoryTexture *
const guchar * gdk_memory_texture_get_data (GdkMemoryTexture *self);
gsize gdk_memory_texture_get_stride (GdkMemoryTexture *self);
void gdk_memory_convert (guchar *dest_data,
gsize dest_stride,
GdkMemoryConversion dest_format,
const guchar *src_data,
gsize src_stride,
GdkMemoryFormat src_format,
gsize width,
gsize height);
void gdk_memory_convert_to_float (float *dest_data,
gsize dest_stride,
const guchar *src_data,
gsize src_stride,
GdkMemoryFormat src_format,
gsize width,
gsize height);
void gdk_memory_convert (guchar *dest_data,
gsize dest_stride,
GdkMemoryFormat dest_format,
const guchar *src_data,
gsize src_stride,
GdkMemoryFormat src_format,
gsize width,
gsize height);
G_END_DECLS

View File

@@ -30,7 +30,6 @@
#include <errno.h>
#include <math.h>
#include "gdkhslaprivate.h"
G_DEFINE_BOXED_TYPE (GdkRGBA, gdk_rgba,
gdk_rgba_copy, gdk_rgba_free)
@@ -187,7 +186,6 @@ gdk_rgba_parse (GdkRGBA *rgba,
const char *spec)
{
gboolean has_alpha;
gboolean is_hsl;
double r, g, b, a;
char *str = (char *) spec;
char *p;
@@ -198,26 +196,11 @@ gdk_rgba_parse (GdkRGBA *rgba,
if (strncmp (str, "rgba", 4) == 0)
{
has_alpha = TRUE;
is_hsl = FALSE;
str += 4;
}
else if (strncmp (str, "rgb", 3) == 0)
{
has_alpha = FALSE;
is_hsl = FALSE;
a = 1;
str += 3;
}
else if (strncmp (str, "hsla", 4) == 0)
{
has_alpha = TRUE;
is_hsl = TRUE;
str += 4;
}
else if (strncmp (str, "hsl", 3) == 0)
{
has_alpha = FALSE;
is_hsl = TRUE;
a = 1;
str += 3;
}
@@ -308,22 +291,10 @@ gdk_rgba_parse (GdkRGBA *rgba,
if (rgba)
{
if (is_hsl)
{
GdkHSLA hsla;
hsla.hue = r * 255;
hsla.saturation = CLAMP (g, 0, 1);
hsla.lightness = CLAMP (b, 0, 1);
hsla.alpha = CLAMP (a, 0, 1);
_gdk_rgba_init_from_hsla (rgba, &hsla);
}
else
{
rgba->red = CLAMP (r, 0, 1);
rgba->green = CLAMP (g, 0, 1);
rgba->blue = CLAMP (b, 0, 1);
rgba->alpha = CLAMP (a, 0, 1);
}
rgba->red = CLAMP (r, 0, 1);
rgba->green = CLAMP (g, 0, 1);
rgba->blue = CLAMP (b, 0, 1);
rgba->alpha = CLAMP (a, 0, 1);
}
return TRUE;
@@ -491,47 +462,6 @@ parse_color_channel (GtkCssParser *parser,
}
}
static guint
parse_hsla_color_channel (GtkCssParser *parser,
guint arg,
gpointer data)
{
GdkHSLA *hsla = data;
double dvalue;
switch (arg)
{
case 0:
if (!gtk_css_parser_consume_number (parser, &dvalue))
return 0;
hsla->hue = dvalue;
return 1;
case 1:
if (!gtk_css_parser_consume_percentage (parser, &dvalue))
return 0;
hsla->saturation = CLAMP (dvalue, 0.0, 100.0) / 100.0;
return 1;
case 2:
if (!gtk_css_parser_consume_percentage (parser, &dvalue))
return 0;
hsla->lightness = CLAMP (dvalue, 0.0, 100.0) / 100.0;
return 1;
case 3:
if (!gtk_css_parser_consume_number (parser, &dvalue))
return 0;
hsla->alpha = CLAMP (dvalue, 0.0, 1.0) / 1.0;
return 1;
default:
g_assert_not_reached ();
return 0;
}
}
static gboolean
rgba_init_chars (GdkRGBA *rgba,
const char s[8])
@@ -571,18 +501,6 @@ gdk_rgba_parser_parse (GtkCssParser *parser,
{
return gtk_css_parser_consume_function (parser, 4, 4, parse_color_channel, rgba);
}
else if (gtk_css_token_is_function (token, "hsl") || gtk_css_token_is_function (token, "hsla"))
{
GdkHSLA hsla;
hsla.alpha = 1.0;
if (!gtk_css_parser_consume_function (parser, 3, 4, parse_hsla_color_channel, &hsla))
return FALSE;
_gdk_rgba_init_from_hsla (rgba, &hsla);
return TRUE;
}
else if (gtk_css_token_is (token, GTK_CSS_TOKEN_HASH_ID) ||
gtk_css_token_is (token, GTK_CSS_TOKEN_HASH_UNRESTRICTED))
{

View File

@@ -115,35 +115,13 @@ G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GdkTexture, gdk_texture, G_TYPE_OBJECT,
#define GDK_TEXTURE_WARN_NOT_IMPLEMENTED_METHOD(obj,method) \
g_critical ("Texture of type '%s' does not implement GdkTexture::" # method, G_OBJECT_TYPE_NAME (obj))
static GdkTexture *
gdk_texture_real_download_texture (GdkTexture *self)
{
GDK_TEXTURE_WARN_NOT_IMPLEMENTED_METHOD (self, download_texture);
return NULL;
}
static void
gdk_texture_real_download (GdkTexture *texture,
guchar *data,
gsize stride)
gdk_texture_real_download (GdkTexture *self,
const GdkRectangle *area,
guchar *data,
gsize stride)
{
GdkTexture *memory_texture;
memory_texture = gdk_texture_download_texture (texture);
gdk_texture_download (memory_texture, data, stride);
g_object_unref (memory_texture);
}
static void
gdk_texture_real_download_float (GdkTexture *self,
float *data,
gsize stride)
{
GdkTexture *memory_texture;
memory_texture = gdk_texture_download_texture (self);
gdk_texture_download_float (memory_texture, data, stride);
g_object_unref (memory_texture);
GDK_TEXTURE_WARN_NOT_IMPLEMENTED_METHOD (self, download);
}
static void
@@ -209,9 +187,7 @@ gdk_texture_class_init (GdkTextureClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
klass->download_texture = gdk_texture_real_download_texture;
klass->download = gdk_texture_real_download;
klass->download_float = gdk_texture_real_download_float;
gobject_class->set_property = gdk_texture_set_property;
gobject_class->get_property = gdk_texture_get_property;
@@ -287,7 +263,7 @@ gdk_texture_new_for_surface (cairo_surface_t *surface)
texture = gdk_memory_texture_new (cairo_image_surface_get_width (surface),
cairo_image_surface_get_height (surface),
GDK_MEMORY_DEFAULT,
GDK_MEMORY_CAIRO_FORMAT_ARGB32,
bytes,
cairo_image_surface_get_stride (surface));
@@ -459,6 +435,20 @@ gdk_texture_download_surface (GdkTexture *texture)
return surface;
}
void
gdk_texture_download_area (GdkTexture *texture,
const GdkRectangle *area,
guchar *data,
gsize stride)
{
g_assert (area->x >= 0);
g_assert (area->y >= 0);
g_assert (area->x + area->width <= texture->width);
g_assert (area->y + area->height <= texture->height);
GDK_TEXTURE_GET_CLASS (texture)->download (texture, area, data, stride);
}
/**
* gdk_texture_download:
* @texture: a `GdkTexture`
@@ -495,62 +485,10 @@ gdk_texture_download (GdkTexture *texture,
g_return_if_fail (data != NULL);
g_return_if_fail (stride >= gdk_texture_get_width (texture) * 4);
GDK_TEXTURE_GET_CLASS (texture)->download (texture, data, 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_GET_CLASS (texture)->download_float (texture, data, stride);
}
GdkTexture *
gdk_texture_download_texture (GdkTexture *texture)
{
g_return_val_if_fail (GDK_IS_TEXTURE (texture), NULL);
g_object_ref (texture);
while (!GDK_IS_MEMORY_TEXTURE (texture))
{
GdkTexture *downloaded = GDK_TEXTURE_GET_CLASS (texture)->download_texture (texture);
g_object_unref (texture);
texture = downloaded;
}
return texture;
gdk_texture_download_area (texture,
&(GdkRectangle) { 0, 0, texture->width, texture->height },
data,
stride);
}
gboolean

View File

@@ -59,10 +59,6 @@ GDK_AVAILABLE_IN_ALL
void gdk_texture_download (GdkTexture *texture,
guchar *data,
gsize stride);
GDK_AVAILABLE_IN_4_6
void gdk_texture_download_float (GdkTexture *texture,
float *data,
gsize stride);
GDK_AVAILABLE_IN_ALL
gboolean gdk_texture_save_to_png (GdkTexture *texture,
const char *filename);

View File

@@ -24,15 +24,10 @@ struct _GdkTexture
struct _GdkTextureClass {
GObjectClass parent_class;
/* mandatory: Download into a GdkMemoryTexture */
GdkTexture * (* download_texture) (GdkTexture *texture);
/* optional */
void (* download) (GdkTexture *texture,
const GdkRectangle *area,
guchar *data,
gsize stride);
void (* download_float) (GdkTexture *texture,
float *data,
gsize stride);
};
gpointer gdk_texture_new (const GdkTextureClass *klass,
@@ -40,8 +35,10 @@ gpointer gdk_texture_new (const GdkTextureClass
int height);
GdkTexture * gdk_texture_new_for_surface (cairo_surface_t *surface);
cairo_surface_t * gdk_texture_download_surface (GdkTexture *texture);
/* NB: GdkMemoryTexture */
GdkTexture * gdk_texture_download_texture (GdkTexture *texture);
void gdk_texture_download_area (GdkTexture *texture,
const GdkRectangle *area,
guchar *data,
gsize stride);
gboolean gdk_texture_set_render_data (GdkTexture *self,
gpointer key,

View File

@@ -27,7 +27,6 @@ gdk_public_sources = files([
'gdkglcontext.c',
'gdkglobals.c',
'gdkgltexture.c',
'gdkhsla.c',
'gdkkeys.c',
'gdkkeyuni.c',
'gdkmemorytexture.c',
@@ -108,7 +107,6 @@ gdk_sources = gdk_public_sources
gdk_private_h_sources = files([
'gdkeventsprivate.h',
'gdkdevicetoolprivate.h',
'gdkhslaprivate.h',
'gdkmonitorprivate.h',
'gdkseatdefaultprivate.h',
'gdktoplevelsizeprivate.h',

View File

@@ -5674,7 +5674,7 @@ gsk_render_node_content_serializer_finish (GObject *source,
GOutputStream *stream = G_OUTPUT_STREAM (source);
GError *error = NULL;
if (g_output_stream_splice_finish (stream, result, &error) < 0)
if (!g_output_stream_write_bytes_finish (stream, result, &error))
gdk_content_serializer_return_error (serializer, error);
else
gdk_content_serializer_return_success (serializer);
@@ -5683,7 +5683,6 @@ gsk_render_node_content_serializer_finish (GObject *source,
static void
gsk_render_node_content_serializer (GdkContentSerializer *serializer)
{
GInputStream *input;
const GValue *value;
GskRenderNode *node;
GBytes *bytes;
@@ -5691,16 +5690,13 @@ gsk_render_node_content_serializer (GdkContentSerializer *serializer)
value = gdk_content_serializer_get_value (serializer);
node = gsk_value_get_render_node (value);
bytes = gsk_render_node_serialize (node);
input = g_memory_input_stream_new_from_bytes (bytes);
g_output_stream_splice_async (gdk_content_serializer_get_output_stream (serializer),
input,
G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE,
gdk_content_serializer_get_priority (serializer),
gdk_content_serializer_get_cancellable (serializer),
gsk_render_node_content_serializer_finish,
serializer);
g_object_unref (input);
g_output_stream_write_bytes_async (gdk_content_serializer_get_output_stream (serializer),
bytes,
gdk_content_serializer_get_priority (serializer),
gdk_content_serializer_get_cancellable (serializer),
gsk_render_node_content_serializer_finish,
serializer);
g_bytes_unref (bytes);
}

View File

@@ -37,7 +37,7 @@ as_float (const guint x)
// IEEE-754 16-bit floating-point format (without infinity): 1-5-10
static inline float
half_to_float_one (const guint16 x)
half_to_float (const guint16 x)
{
const guint e = (x&0x7C00)>>10; // exponent
const guint m = (x&0x03FF)<<13; // mantissa
@@ -46,7 +46,7 @@ half_to_float_one (const guint16 x)
}
static inline guint16
float_to_half_one (const float x)
float_to_half (const float x)
{
const guint b = as_uint(x)+0x00001000; // round-to-nearest-even
const guint e = (b&0x7F800000)>>23; // exponent
@@ -58,38 +58,20 @@ void
float_to_half4_c (const float f[4],
guint16 h[4])
{
h[0] = float_to_half_one (f[0]);
h[1] = float_to_half_one (f[1]);
h[2] = float_to_half_one (f[2]);
h[3] = float_to_half_one (f[3]);
h[0] = float_to_half (f[0]);
h[1] = float_to_half (f[1]);
h[2] = float_to_half (f[2]);
h[3] = float_to_half (f[3]);
}
void
half_to_float4_c (const guint16 h[4],
float f[4])
{
f[0] = half_to_float_one (h[0]);
f[1] = half_to_float_one (h[1]);
f[2] = half_to_float_one (h[2]);
f[3] = half_to_float_one (h[3]);
}
void
float_to_half_c (const float *f,
guint16 *h,
int n)
{
for (int i = 0; i < n; i++)
h[i] = float_to_half_one (f[i]);
}
void
half_to_float_c (const guint16 *h,
float *f,
int n)
{
for (int i = 0; i < n; i++)
f[i] = half_to_float_one (h[i]);
f[0] = half_to_float (h[0]);
f[1] = half_to_float (h[1]);
f[2] = half_to_float (h[2]);
f[3] = half_to_float (h[3]);
}
#ifdef HAVE_F16C
@@ -140,30 +122,10 @@ half_to_float4 (const guint16 h[4], float f[4])
half_to_float4_c (h, f);
}
void
float_to_half (const float *f, guint16 *h, int n)
{
if (have_f16c_msvc ())
float_to_half_f16c (f, h, n);
else
float_to_half4_c (f, h, n);
}
void
half_to_float (const guint16 *h, float *f, int n)
{
if (have_f16c_msvc ())
half_to_float_f16c (h, f, n);
else
half_to_float_c (h, f, n);
}
#else
void float_to_half4 (const float f[4], guint16 h[4]) __attribute__((ifunc ("resolve_float_to_half4")));
void half_to_float4 (const guint16 h[4], float f[4]) __attribute__((ifunc ("resolve_half_to_float4")));
void float_to_half (const float *f, guint16 *h, int n) __attribute__((ifunc ("resolve_float_to_half")));
void half_to_float (const guint16 *h, float *f, int n) __attribute__((ifunc ("resolve_half_to_float")));
static void *
resolve_float_to_half4 (void)
@@ -185,26 +147,6 @@ resolve_half_to_float4 (void)
return half_to_float4_c;
}
static void *
resolve_float_to_half (void)
{
__builtin_cpu_init ();
if (__builtin_cpu_supports ("f16c"))
return float_to_half_f16c;
else
return float_to_half_c;
}
static void *
resolve_half_to_float (void)
{
__builtin_cpu_init ();
if (__builtin_cpu_supports ("f16c"))
return half_to_float_f16c;
else
return half_to_float_c;
}
#endif
#else /* ! HAVE_F16C */
@@ -226,28 +168,10 @@ half_to_float4 (const guint16 h[4],
half_to_float4_c (h, f);
}
void
float_to_half (const float *f,
guint16 *h,
int n)
{
float_to_half_c (f, h, n);
}
void
half_to_float (const guint16 *h,
float *f,
int n)
{
half_to_float_c (h, f, n);
}
#else
void float_to_half4 (const float f[4], guint16 h[4]) __attribute__((alias ("float_to_half4_c")));
void half_to_float4 (const guint16 h[4], float f[4]) __attribute__((alias ("half_to_float4_c")));
void float_to_half (const float *f, guint16 *h, int n) __attribute__((alias ("float_to_half_c")));
void half_to_float (const guint16 *h, float *f, int n) __attribute__((alias ("half_to_float_c")));
#endif

View File

@@ -30,6 +30,7 @@
#else
#define CAST_M128I_P(a) (__m128i_u const *) a
#endif
void
float_to_half4_f16c (const float f[4],
guint16 h[4])
@@ -49,74 +50,4 @@ half_to_float4_f16c (const guint16 h[4],
_mm_store_ps (f, s);
}
#define ALIGNED(p, n) (GPOINTER_TO_UINT(p) % n == 0)
void
float_to_half_f16c (const float *f,
guint16 *h,
int n)
{
__m128 s;
__m128i i;
int j;
const float *ff = f;
guint16 *hh = h;
for (j = 0; j < n; j++)
{
if (ALIGNED (ff, 16) && ALIGNED (hh, 16))
break;
ff++;
hh++;
}
float_to_half_c (f, h, j);
for (; j + 4 < n; j += 4)
{
s = _mm_loadu_ps (ff);
i = _mm_cvtps_ph (s, 0);
_mm_storel_epi64 ((__m128i*)hh, i);
ff += 4;
hh += 4;
}
if (j < n)
float_to_half_c (ff, hh, n - j);
}
void
half_to_float_f16c (const guint16 *h,
float *f,
int n)
{
__m128i i;
__m128 s;
int j;
const guint16 *hh = h;
float *ff = f;
for (j = 0; j < n; j++)
{
if (ALIGNED (ff, 16) && ALIGNED (hh, 16))
break;
ff++;
hh++;
}
half_to_float_c (h, f, j);
for (; j + 4 < n; j += 4)
{
i = _mm_loadl_epi64 (CAST_M128I_P (hh));
s = _mm_cvtph_ps (i);
_mm_store_ps (ff, s);
hh += 4;
ff += 4;
}
if (j < n)
half_to_float_c (hh, ff, n - j);
}
#endif /* HAVE_F16C */

View File

@@ -35,42 +35,18 @@ void float_to_half4 (const float f[4],
void half_to_float4 (const guint16 h[4],
float f[4]);
void float_to_half (const float *f,
guint16 *h,
int n);
void half_to_float (const guint16 *h,
float *f,
int n);
void float_to_half4_f16c (const float f[4],
guint16 h[4]);
void half_to_float4_f16c (const guint16 h[4],
float f[4]);
void float_to_half_f16c (const float *f,
guint16 *h,
int n);
void half_to_float_f16c (const guint16 *h,
float *f,
int n);
void float_to_half4_c (const float f[4],
guint16 h[4]);
void half_to_float4_c (const guint16 h[4],
float f[4]);
void float_to_half_c (const float *f,
guint16 *h,
int n);
void half_to_float_c (const guint16 *h,
float *f,
int n);
G_END_DECLS
#endif

View File

@@ -735,7 +735,8 @@ gsk_ngl_driver_load_texture (GskNglDriver *self,
int mag_filter)
{
GdkGLContext *context;
GdkTexture *downloaded_texture;
GdkTexture *downloaded_texture = NULL;
GdkTexture *source_texture;
GskNglTexture *t;
guint texture_id;
int height;
@@ -759,7 +760,21 @@ gsk_ngl_driver_load_texture (GskNglDriver *self,
}
else
{
downloaded_texture = gdk_texture_download_texture (texture);
cairo_surface_t *surface;
/* In this case, we have to temporarily make the texture's
* context the current one, download its data into our context
* and then create a texture from it. */
if (texture_context != NULL)
gdk_gl_context_make_current (texture_context);
surface = gdk_texture_download_surface (texture);
downloaded_texture = gdk_texture_new_for_surface (surface);
cairo_surface_destroy (surface);
gdk_gl_context_make_current (context);
source_texture = downloaded_texture;
}
}
else
@@ -770,17 +785,13 @@ gsk_ngl_driver_load_texture (GskNglDriver *self,
return t->texture_id;
}
downloaded_texture = gdk_texture_download_texture (texture);
source_texture = texture;
}
/* The download_texture() call may have switched the GL context. Make sure
* the right context is at work again. */
gdk_gl_context_make_current (context);
width = gdk_texture_get_width (texture);
height = gdk_texture_get_height (texture);
texture_id = gsk_ngl_command_queue_upload_texture (self->command_queue,
downloaded_texture,
source_texture,
0,
0,
width,

View File

@@ -235,7 +235,7 @@ gsk_ngl_glyph_library_upload_glyph (GskNglGlyphLibrary *self,
pixel_data = free_data = g_malloc (width * height * 4);
gdk_memory_convert (pixel_data,
width * 4,
GDK_MEMORY_CONVERT_GLES_RGBA,
GDK_MEMORY_R8G8B8A8_PREMULTIPLIED,
cairo_image_surface_get_data (surface),
width * 4,
GDK_MEMORY_DEFAULT,

View File

@@ -115,7 +115,7 @@ gsk_ngl_icon_library_add (GskNglIconLibrary *self,
{
pixel_data = free_data = g_malloc (width * height * 4);
gdk_memory_convert (pixel_data, width * 4,
GDK_MEMORY_CONVERT_GLES_RGBA,
GDK_MEMORY_R8G8B8A8_PREMULTIPLIED,
surface_data, cairo_image_surface_get_stride (surface),
GDK_MEMORY_DEFAULT, width, height);
gl_format = GL_RGBA;

View File

@@ -65,6 +65,14 @@
* using `dgettext()` in the domain specified. This can also be done by
* calling [method@Gtk.Builder.set_translation_domain] on the builder.
*
* The target toolkit version(s) are described by `<requires>` elements,
* the “lib” attribute specifies the widget library in question (currently
* the only supported value is “gtk”) and the “version” attribute specifies
* the target version in the form “`<major>`.`<minor>`”. `GtkBuilder` will
* error out if the version requirements are not met.
*
* ### Objects
*
* Objects are described by `<object>` elements, which can contain
* `<property>` elements to set properties, `<signal>` elements which
* connect signals to handlers, and `<child>` elements, which describe
@@ -72,16 +80,10 @@
* actions in an action group, or columns in a tree model). A `<child>`
* element contains an `<object>` element which describes the child object.
*
* The target toolkit version(s) are described by `<requires>` elements,
* the “lib” attribute specifies the widget library in question (currently
* the only supported value is “gtk”) and the “version” attribute specifies
* the target version in the form “`<major>`.`<minor>`”. `GtkBuilder` will
* error out if the version requirements are not met.
*
* Typically, the specific kind of object represented by an `<object>`
* element is specified by the “class” attribute. If the type has not
* been loaded yet, GTK tries to find the `get_type()` function from the
* class name by applying heuristics. This works in most cases, but if
* class name by applying heuristics; this works in most cases, but if
* necessary, it is possible to specify the name of the `get_type()`
* function explicitly with the "type-func" attribute.
*
@@ -92,6 +94,8 @@
* reserves ids starting and ending with `___` (three consecutive
* underscores) for its own purposes.
*
* ### Properties and values
*
* Setting properties of objects is pretty straightforward with the
* `<property>` element: the “name” attribute specifies the name of the
* property, and the content of the element specifies the value.
@@ -125,12 +129,27 @@
* exception to this rule is that an object has to be constructed before
* it can be used as the value of a construct-only property.
*
* It is also possible to bind a property value to another object's
* ### Property bindings
*
* It is possible to bind a property value to another object's
* property value using the attributes "bind-source" to specify the
* source object of the binding, and optionally, "bind-property" and
* "bind-flags" to specify the source property and source binding flags
* respectively. Internally, `GtkBuilder` implements this using `GBinding`
* objects. For more information see g_object_bind_property().
* objects. For more information see the documentation for
* [method@GObject.Object.bind_property].
*
* ### Settings bindings
*
* It is possible to bind a property value to a [class@Gio.Settings] key
* inside a schema, by using the attributes "bind-settings-schema" to
* define the schema, and "bind-settings-key" to define the key. If either
* attribute is set, the other is mandatory. Additionally, you can use
* the "bind-flags" attribute to specify the [enum@Gio.SettingsBindFlags]
* to be used by the binding. For more information see the documentation
* for [method@Gio.Settings.bind].
*
* ### Internal children
*
* Sometimes it is necessary to refer to widgets which have implicitly
* been constructed by GTK as part of a composite widget, to set
@@ -146,7 +165,7 @@
* The possible values for the “type” attribute are described in the
* sections describing the widget-specific portions of UI definitions.
*
* # Signal handlers and function pointers
* ### Signal handlers and function pointers
*
* Signal handlers are set up with the `<signal>` element. The “name”
* attribute specifies the name of the signal, and the “handler” attribute
@@ -161,9 +180,9 @@
* the following details should be noted:
*
* When compiling applications for Windows, you must declare signal callbacks
* with %G_MODULE_EXPORT, or they will not be put in the symbol table.
* with `G_MODULE_EXPORT`, or they will not be put in the symbol table.
* On Linux and Unix, this is not necessary; applications should instead
* be compiled with the -Wl,--export-dynamic `CFLAGS`, and linked against
* be compiled with the `-Wl,--export-dynamic` `CFLAGS`, and linked against
* `gmodule-export-2.0`.
*
* # A GtkBuilder UI Definition
@@ -191,10 +210,10 @@
* ```
*
* Beyond this general structure, several object classes define their
* own XML DTD fragments for filling in the ANY placeholders in the DTD
* above. Note that a custom element in a <child> element gets parsed by
* own XML DTD fragments for filling in the `ANY` placeholders in the DTD
* above. Note that a custom element in a `<child>` element gets parsed by
* the custom tag handler of the parent object, while a custom element in
* an <object> element gets parsed by the custom tag handler of the object.
* an `<object>` element gets parsed by the custom tag handler of the object.
*
* These XML fragments are explained in the documentation of the
* respective objects.
@@ -719,6 +738,11 @@ gtk_builder_take_bindings (GtkBuilder *builder,
BindingExpressionInfo *info = l->data;
info->target = target;
}
else if (common_info->tag_type == TAG_BINDING_SETTING)
{
BindingSettingsInfo *info = l->data;
info->target = target;
}
else
{
g_assert_not_reached ();
@@ -1146,6 +1170,17 @@ gtk_builder_create_bindings (GtkBuilder *builder,
free_binding_expression_info (info);
}
else if (common_info->tag_type == TAG_BINDING_SETTING)
{
BindingSettingsInfo *info = l->data;
GSettings *settings;
settings = g_settings_new (info->schema);
g_settings_bind (settings, info->key, info->target, info->target_pspec->name, info->flags);
g_object_unref (settings);
free_binding_settings_info (info);
}
else
g_assert_not_reached ();
}

View File

@@ -874,7 +874,8 @@ parse_property (ParserData *data,
const char *bind_source = NULL;
const char *bind_property = NULL;
const char *bind_flags_str = NULL;
GBindingFlags bind_flags = G_BINDING_DEFAULT;
const char *bind_schema = NULL;
const char *bind_key = NULL;
gboolean translatable = FALSE;
ObjectInfo *object_info;
GParamSpec *pspec = NULL;
@@ -897,6 +898,8 @@ parse_property (ParserData *data,
G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "bind-source", &bind_source,
G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "bind-property", &bind_property,
G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "bind-flags", &bind_flags_str,
G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "bind-settings-schema", &bind_schema,
G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "bind-settings-key", &bind_key,
G_MARKUP_COLLECT_INVALID))
{
_gtk_builder_prefix_error (data->builder, &data->ctx, error);
@@ -916,21 +919,59 @@ parse_property (ParserData *data,
return;
}
if (bind_flags_str)
gtk_buildable_parse_context_get_position (&data->ctx, &line, &col);
if (bind_schema != NULL)
{
if (!_gtk_builder_flags_from_string (G_TYPE_BINDING_FLAGS, NULL, bind_flags_str, &bind_flags, error))
GSettingsBindFlags bind_flags = G_SETTINGS_BIND_DEFAULT;
if (bind_flags_str)
{
_gtk_builder_prefix_error (data->builder, &data->ctx, error);
if (!_gtk_builder_flags_from_string (G_TYPE_SETTINGS_BIND_FLAGS, NULL, bind_flags_str, &bind_flags, error))
{
_gtk_builder_prefix_error (data->builder, &data->ctx, error);
return;
}
}
if (bind_key != NULL)
{
BindingSettingsInfo *binfo;
binfo = g_slice_new0 (BindingSettingsInfo);
binfo->tag_type = TAG_BINDING_SETTING;
binfo->target = NULL;
binfo->target_pspec = pspec;
binfo->schema = g_strdup (bind_schema);
binfo->key = g_strdup (bind_key);
binfo->flags = bind_flags;
binfo->line = line;
binfo->col = col;
object_info->bindings = g_slist_prepend (object_info->bindings, binfo);
}
else
{
error_missing_attribute (data, element_name,
"bind-settings-key",
error);
return;
}
}
gtk_buildable_parse_context_get_position (&data->ctx, &line, &col);
if (bind_source)
else if (bind_source != NULL)
{
GBindingFlags bind_flags = G_BINDING_DEFAULT;
BindingInfo *binfo;
if (bind_flags_str)
{
if (!_gtk_builder_flags_from_string (G_TYPE_BINDING_FLAGS, NULL, bind_flags_str, &bind_flags, error))
{
_gtk_builder_prefix_error (data->builder, &data->ctx, error);
return;
}
}
binfo = g_slice_new0 (BindingInfo);
binfo->tag_type = TAG_BINDING;
binfo->target = NULL;
@@ -943,7 +984,14 @@ parse_property (ParserData *data,
object_info->bindings = g_slist_prepend (object_info->bindings, binfo);
}
else if (bind_property)
else if (bind_key != NULL)
{
error_missing_attribute (data, element_name,
"bind-settings-schema",
error);
return;
}
else if (bind_property != NULL)
{
error_missing_attribute (data, element_name,
"bind-source",
@@ -956,7 +1004,7 @@ parse_property (ParserData *data,
info->pspec = pspec;
info->text = g_string_new ("");
info->translatable = translatable;
info->bound = bind_source != NULL;
info->bound = bind_source != NULL || bind_schema != NULL;
info->context = g_strdup (context);
info->line = line;
info->col = col;
@@ -1563,6 +1611,14 @@ free_binding_expression_info (BindingExpressionInfo *info)
g_slice_free (BindingExpressionInfo, info);
}
void
free_binding_settings_info (BindingSettingsInfo *info)
{
g_free (info->schema);
g_free (info->key);
g_slice_free (BindingSettingsInfo, info);
}
static void
free_requires_info (RequiresInfo *info,
gpointer user_data)

View File

@@ -27,6 +27,7 @@ enum {
TAG_PROPERTY,
TAG_BINDING,
TAG_BINDING_EXPRESSION,
TAG_BINDING_SETTING,
TAG_REQUIRES,
TAG_OBJECT,
TAG_CHILD,
@@ -141,6 +142,18 @@ typedef struct
int col;
} BindingExpressionInfo;
typedef struct
{
guint tag_type;
GObject *target;
GParamSpec *target_pspec;
char *schema;
char *key;
GSettingsBindFlags flags;
int line;
int col;
} BindingSettingsInfo;
typedef struct {
guint tag_type;
char *library;
@@ -228,6 +241,7 @@ void _free_signal_info (SignalInfo *info,
void _free_binding_info (BindingInfo *info,
gpointer user_data);
void free_binding_expression_info (BindingExpressionInfo *info);
void free_binding_settings_info (BindingSettingsInfo *info);
GtkExpression * expression_info_construct (GtkBuilder *builder,
ExpressionInfo *info,
GError **error);

View File

@@ -20,10 +20,10 @@
#include "gtkcsscolorvalueprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtkhslaprivate.h"
#include "gtkprivate.h"
#include "gtkstylepropertyprivate.h"
#include "gdk/gdkhslaprivate.h"
#include "gdk/gdkrgbaprivate.h"
typedef enum {
@@ -309,10 +309,10 @@ apply_shade (const GdkRGBA *in,
GdkRGBA *out,
double factor)
{
GdkHSLA hsla;
GtkHSLA hsla;
_gdk_hsla_init_from_rgba (&hsla, in);
_gdk_hsla_shade (&hsla, &hsla, factor);
_gtk_hsla_init_from_rgba (&hsla, in);
_gtk_hsla_shade (&hsla, &hsla, factor);
_gdk_rgba_init_from_hsla (out, &hsla);
}
@@ -699,8 +699,6 @@ gtk_css_color_value_can_parse (GtkCssParser *parser)
|| gtk_css_parser_has_function (parser, "shade")
|| gtk_css_parser_has_function (parser, "alpha")
|| gtk_css_parser_has_function (parser, "mix")
|| gtk_css_parser_has_function (parser, "hsl")
|| gtk_css_parser_has_function (parser, "hsla")
|| gtk_css_parser_has_function (parser, "rgb")
|| gtk_css_parser_has_function (parser, "rgba");
}

View File

@@ -17,12 +17,12 @@
#include "config.h"
#include "gdkhslaprivate.h"
#include "gtkhslaprivate.h"
#include <math.h>
void
_gdk_hsla_init_from_rgba (GdkHSLA *hsla,
_gtk_hsla_init_from_rgba (GtkHSLA *hsla,
const GdkRGBA *rgba)
{
float min;
@@ -31,21 +31,21 @@ _gdk_hsla_init_from_rgba (GdkHSLA *hsla,
float green;
float blue;
float delta;
g_return_if_fail (hsla != NULL);
g_return_if_fail (rgba != NULL);
red = rgba->red;
green = rgba->green;
blue = rgba->blue;
if (red > green)
{
if (red > blue)
max = red;
else
max = blue;
if (green < blue)
min = green;
else
@@ -57,25 +57,25 @@ _gdk_hsla_init_from_rgba (GdkHSLA *hsla,
max = green;
else
max = blue;
if (red < blue)
min = red;
else
min = blue;
}
hsla->lightness = (max + min) / 2;
hsla->saturation = 0;
hsla->hue = 0;
hsla->alpha = rgba->alpha;
if (max != min)
{
if (hsla->lightness <= 0.5)
hsla->saturation = (max - min) / (max + min);
else
hsla->saturation = (max - min) / (2 - max - min);
delta = max -min;
if (red == max)
hsla->hue = (green - blue) / delta;
@@ -83,7 +83,7 @@ _gdk_hsla_init_from_rgba (GdkHSLA *hsla,
hsla->hue = 2 + (blue - red) / delta;
else if (blue == max)
hsla->hue = 4 + (red - green) / delta;
hsla->hue *= 60;
if (hsla->hue < 0.0)
hsla->hue += 360;
@@ -92,22 +92,22 @@ _gdk_hsla_init_from_rgba (GdkHSLA *hsla,
void
_gdk_rgba_init_from_hsla (GdkRGBA *rgba,
const GdkHSLA *hsla)
const GtkHSLA *hsla)
{
float hue;
float lightness;
float saturation;
float m1, m2;
lightness = hsla->lightness;
saturation = hsla->saturation;
if (lightness <= 0.5)
m2 = lightness * (1 + saturation);
else
m2 = lightness + saturation - lightness * saturation;
m1 = 2 * lightness - m2;
rgba->alpha = hsla->alpha;
if (saturation == 0)
@@ -123,7 +123,7 @@ _gdk_rgba_init_from_hsla (GdkRGBA *rgba,
hue -= 360;
while (hue < 0)
hue += 360;
if (hue < 60)
rgba->red = m1 + (m2 - m1) * hue / 60;
else if (hue < 180)
@@ -132,13 +132,13 @@ _gdk_rgba_init_from_hsla (GdkRGBA *rgba,
rgba->red = m1 + (m2 - m1) * (240 - hue) / 60;
else
rgba->red = m1;
hue = hsla->hue;
while (hue > 360)
hue -= 360;
while (hue < 0)
hue += 360;
if (hue < 60)
rgba->green = m1 + (m2 - m1) * hue / 60;
else if (hue < 180)
@@ -147,13 +147,13 @@ _gdk_rgba_init_from_hsla (GdkRGBA *rgba,
rgba->green = m1 + (m2 - m1) * (240 - hue) / 60;
else
rgba->green = m1;
hue = hsla->hue - 120;
while (hue > 360)
hue -= 360;
while (hue < 0)
hue += 360;
if (hue < 60)
rgba->blue = m1 + (m2 - m1) * hue / 60;
else if (hue < 180)
@@ -166,8 +166,8 @@ _gdk_rgba_init_from_hsla (GdkRGBA *rgba,
}
void
_gdk_hsla_shade (GdkHSLA *dest,
const GdkHSLA *src,
_gtk_hsla_shade (GtkHSLA *dest,
const GtkHSLA *src,
float factor)
{
g_return_if_fail (dest != NULL);

View File

@@ -22,23 +22,23 @@
G_BEGIN_DECLS
typedef struct _GdkHSLA GdkHSLA;
typedef struct _GtkHSLA GtkHSLA;
struct _GdkHSLA {
struct _GtkHSLA {
float hue;
float saturation;
float lightness;
float alpha;
};
void _gdk_hsla_init_from_rgba (GdkHSLA *hsla,
void _gtk_hsla_init_from_rgba (GtkHSLA *hsla,
const GdkRGBA *rgba);
/* Yes, I can name that function like this! */
void _gdk_rgba_init_from_hsla (GdkRGBA *rgba,
const GdkHSLA *hsla);
const GtkHSLA *hsla);
void _gdk_hsla_shade (GdkHSLA *dest,
const GdkHSLA *src,
void _gtk_hsla_shade (GtkHSLA *dest,
const GtkHSLA *src,
float factor);
G_END_DECLS

View File

@@ -33,10 +33,10 @@
#include "gtkcssrepeatvalueprivate.h"
#include "gtkcsscolorvalueprivate.h"
#include "gtkcssstyleprivate.h"
#include "gtkhslaprivate.h"
#include "gtkroundedboxprivate.h"
#include "gtksnapshotprivate.h"
#include "gdk/gdkhslaprivate.h"
#include "gsk/gskroundedrectprivate.h"
typedef struct _GtkBorderImage GtkBorderImage;
@@ -513,10 +513,10 @@ color_shade (const GdkRGBA *color,
double factor,
GdkRGBA *color_return)
{
GdkHSLA hsla;
GtkHSLA hsla;
_gdk_hsla_init_from_rgba (&hsla, color);
_gdk_hsla_shade (&hsla, &hsla, factor);
_gtk_hsla_init_from_rgba (&hsla, color);
_gtk_hsla_shade (&hsla, &hsla, factor);
_gdk_rgba_init_from_hsla (color_return, &hsla);
}

View File

@@ -366,7 +366,6 @@ gtk_search_bar_init (GtkSearchBar *bar)
gtk_widget_set_hexpand (bar->box_center, TRUE);
bar->close_button = gtk_button_new_from_icon_name ("window-close-symbolic");
gtk_widget_set_valign (bar->close_button, GTK_ALIGN_CENTER);
gtk_widget_add_css_class (bar->close_button, "close");
gtk_center_box_set_end_widget (GTK_CENTER_BOX (bar->box_center), bar->close_button);
gtk_widget_hide (bar->close_button);

View File

@@ -690,14 +690,13 @@ gtk_stack_dispose (GObject *obj)
GtkStack *stack = GTK_STACK (obj);
GtkStackPrivate *priv = gtk_stack_get_instance_private (stack);
GtkWidget *child;
guint n_pages = g_list_length (priv->children);
if (priv->pages)
g_list_model_items_changed (G_LIST_MODEL (priv->pages), 0, g_list_length (priv->children), 0);
while ((child = gtk_widget_get_first_child (GTK_WIDGET (stack))))
stack_remove (stack, child, TRUE);
if (priv->pages)
g_list_model_items_changed (G_LIST_MODEL (priv->pages), 0, n_pages, 0);
G_OBJECT_CLASS (gtk_stack_parent_class)->dispose (obj);
}

View File

@@ -111,6 +111,7 @@ gtk_private_sources = files([
'gtkfilechooserutils.c',
'gtkfilesystemmodel.c',
'gtkgizmo.c',
'gtkhsla.c',
'gtkiconcache.c',
'gtkiconcachevalidator.c',
'gtkiconhelper.c',

View File

@@ -23,7 +23,6 @@
<property name="receives-default">1</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="has-frame">0</property>
<property name="icon-name">media-playback-start-symbolic</property>
<signal name="clicked" handler="play_button_clicked" object="GtkMediaControls" swapped="no"/>
</object>

View File

@@ -150,6 +150,11 @@ cdata.set_quoted('GTK_DATADIR', gtk_datadir)
cdata.set_quoted('GTK_LIBDIR', gtk_libdir)
cdata.set_quoted('GTK_SYSCONFDIR', gtk_sysconfdir)
cdata.set_quoted('GETTEXT_PACKAGE', 'gtk40')
cdata.set('GTK_MAJOR_VERSION', gtk_major_version)
cdata.set('GTK_MINOR_VERSION', gtk_minor_version)
cdata.set('GTK_MICRO_VERSION', gtk_micro_version)
cdata.set('GTK_BINARY_AGE', gtk_binary_age)
cdata.set('GTK_INTERFACE_AGE', gtk_interface_age)
check_headers = [
'crt/externs.h',
@@ -742,7 +747,8 @@ if get_option('build-examples')
endif
# config.h
configure_file(output: 'config.h',
configure_file(input: 'config.h.meson',
output: 'config.h',
configuration: cdata)
# Requires

View File

@@ -119,11 +119,6 @@ option('build-tests',
value: 'true',
description : 'Build tests')
option('build-internal-tests',
type: 'boolean',
value: 'true',
description : 'Build tests for internal apis')
option('install-tests',
type: 'boolean',
value: 'false',

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1986
po/de.po

File diff suppressed because it is too large Load Diff

2122
po/fr.po

File diff suppressed because it is too large Load Diff

2404
po/hu.po

File diff suppressed because it is too large Load Diff

View File

@@ -10,8 +10,8 @@ msgid ""
msgstr ""
"Project-Id-Version: gtk\n"
"Report-Msgid-Bugs-To: https://gitlab.gnome.org/GNOME/gtk/-/issues/\n"
"POT-Creation-Date: 2021-09-05 14:13+0000\n"
"PO-Revision-Date: 2021-09-08 22:23+0200\n"
"POT-Creation-Date: 2021-09-03 00:57+0000\n"
"PO-Revision-Date: 2021-09-04 13:03+0200\n"
"Last-Translator: Anders Jonsson <anders.jonsson@norsjovallen.se>\n"
"Language-Team: Swedish <tp-sv@listor.tp-sv.se>\n"
"Language: sv\n"
@@ -459,54 +459,42 @@ msgstr "Inget kompatibelt överföringsformat hittades"
msgid "Failed to decode contents with mime-type of '%s'"
msgstr "Misslyckades med att avkoda innehåll med mime-typen ”%s”"
#: gdk/wayland/gdkglcontext-wayland.c:191
#: gdk/wayland/gdkglcontext-wayland.c:190
#: gdk/win32/gdkglcontext-win32-egl.c:399
#: gdk/win32/gdkglcontext-win32-wgl.c:628 gdk/x11/gdkglcontext-egl.c:600
#: gdk/x11/gdkglcontext-glx.c:613
msgid "Unable to create a GL context"
msgstr "Kan inte skapa en GL-kontext"
#: gdk/wayland/gdkglcontext-wayland.c:484
msgid "libEGL not available in this sandbox"
msgstr "libEGL är inte tillgängligt i denna sandlåda"
#: gdk/wayland/gdkglcontext-wayland.c:484 gdk/x11/gdkglcontext-egl.c:688
msgid "Failed to create EGL display"
msgstr "Misslyckades med att skapa EGL-display"
#: gdk/wayland/gdkglcontext-wayland.c:485
msgid "libEGL not available"
msgstr "libEGL inte tillgängligt"
#: gdk/wayland/gdkglcontext-wayland.c:498
msgid "Sandbox does not provide an OpenGL implementation"
msgstr "Sandlådan tillhandahåller ingen OpenGL-implementation"
#: gdk/wayland/gdkglcontext-wayland.c:499
msgid "No OpenGL implementation available"
msgstr "Ingen OpenGL-implementation tillgänglig"
#: gdk/wayland/gdkglcontext-wayland.c:508 gdk/x11/gdkglcontext-egl.c:697
#: gdk/wayland/gdkglcontext-wayland.c:493 gdk/x11/gdkglcontext-egl.c:697
msgid "Could not initialize EGL display"
msgstr "Kunde inte initiera EGL-display"
#: gdk/wayland/gdkglcontext-wayland.c:519 gdk/x11/gdkglcontext-egl.c:707
#: gdk/wayland/gdkglcontext-wayland.c:504 gdk/x11/gdkglcontext-egl.c:707
#, c-format
msgid "EGL version %d.%d is too old. GTK requires %d.%d"
msgstr "EGL-version %d.%d är för gammal. GTK kräver %d.%d"
#: gdk/wayland/gdkglcontext-wayland.c:530
#: gdk/wayland/gdkglcontext-wayland.c:515
#: gdk/win32/gdkglcontext-win32-egl.c:273
#: gdk/win32/gdkglcontext-win32-wgl.c:286
#: gdk/win32/gdkglcontext-win32-wgl.c:304
msgid "No GL implementation is available"
msgstr "Ingen GL-implementation tillgänglig"
#: gdk/wayland/gdkglcontext-wayland.c:540
#: gdk/wayland/gdkglcontext-wayland.c:525
msgid "Core GL is not available on EGL implementation"
msgstr "Kärn-GL är inte tillgängligt på EGL-implementation"
#: gdk/wayland/gdkglcontext-wayland.c:549 gdk/x11/gdkglcontext-egl.c:718
#: gdk/wayland/gdkglcontext-wayland.c:534 gdk/x11/gdkglcontext-egl.c:718
msgid "Surfaceless contexts are not supported on this EGL implementation"
msgstr "Ytlösa kontexter stöds inte på denna EGL-implementation"
#: gdk/wayland/gdkglcontext-wayland.c:561
#: gdk/wayland/gdkglcontext-wayland.c:546
#: gdk/win32/gdkglcontext-win32-egl.c:216
#: gdk/win32/gdkglcontext-win32-egl.c:226
#: gdk/win32/gdkglcontext-win32-wgl.c:594
@@ -729,10 +717,6 @@ msgstr "Ingen perfekt EGL-konfiguration hittades"
msgid "EGL is not supported"
msgstr "EGL stöds inte"
#: gdk/x11/gdkglcontext-egl.c:688
msgid "Failed to create EGL display"
msgstr "Misslyckades med att skapa EGL-display"
#: gdk/x11/gdkglcontext-glx.c:770
msgid "No GLX configurations available"
msgstr "Inga GLX-konfigurationer tillgängliga"
@@ -1010,7 +994,7 @@ msgstr ""
#. * translated on keyboards used for your language, don't translate
#. * this.
#.
#: gtk/gtkaccelgroup.c:837 gtk/gtkshortcutlabel.c:100
#: gtk/gtkaccelgroup.c:826 gtk/gtkshortcutlabel.c:100
#: gtk/gtkshortcutlabel.c:136
msgctxt "keyboard label"
msgid "Shift"
@@ -1021,7 +1005,7 @@ msgstr "Skift"
#. * translated on keyboards used for your language, don't translate
#. * this.
#.
#: gtk/gtkaccelgroup.c:856 gtk/gtkshortcutlabel.c:103
#: gtk/gtkaccelgroup.c:845 gtk/gtkshortcutlabel.c:103
#: gtk/gtkshortcutlabel.c:138
msgctxt "keyboard label"
msgid "Ctrl"
@@ -1032,7 +1016,7 @@ msgstr "Ctrl"
#. * translated on keyboards used for your language, don't translate
#. * this.
#.
#: gtk/gtkaccelgroup.c:875 gtk/gtkshortcutlabel.c:106
#: gtk/gtkaccelgroup.c:864 gtk/gtkshortcutlabel.c:106
#: gtk/gtkshortcutlabel.c:140
msgctxt "keyboard label"
msgid "Alt"
@@ -1043,7 +1027,7 @@ msgstr "Alt"
#. * translated on keyboards used for your language, don't translate
#. * this.
#.
#: gtk/gtkaccelgroup.c:893 gtk/gtkshortcutlabel.c:112
#: gtk/gtkaccelgroup.c:882 gtk/gtkshortcutlabel.c:112
#: gtk/gtkshortcutlabel.c:142
msgctxt "keyboard label"
msgid "Super"
@@ -1054,7 +1038,7 @@ msgstr "Super"
#. * translated on keyboards used for your language, don't translate
#. * this.
#.
#: gtk/gtkaccelgroup.c:907 gtk/gtkshortcutlabel.c:115
#: gtk/gtkaccelgroup.c:896 gtk/gtkshortcutlabel.c:115
#: gtk/gtkshortcutlabel.c:144
msgctxt "keyboard label"
msgid "Hyper"
@@ -1065,7 +1049,7 @@ msgstr "Hyper"
#. * translated on keyboards used for your language, don't translate
#. * this.
#.
#: gtk/gtkaccelgroup.c:922 gtk/gtkshortcutlabel.c:109
#: gtk/gtkaccelgroup.c:911 gtk/gtkshortcutlabel.c:109
#: gtk/gtkshortcutlabel.c:146
msgctxt "keyboard label"
msgid "Meta"
@@ -1075,17 +1059,17 @@ msgstr "Meta"
#. * be used in accelerators such as "Ctrl+Shift+KP 1" in menus,
#. * and therefore the translation needs to be very short.
#.
#: gtk/gtkaccelgroup.c:942
#: gtk/gtkaccelgroup.c:931
msgctxt "keyboard label"
msgid "KP"
msgstr "NUM"
#: gtk/gtkaccelgroup.c:949
#: gtk/gtkaccelgroup.c:938
msgctxt "keyboard label"
msgid "Space"
msgstr "Blanksteg"
#: gtk/gtkaccelgroup.c:952 gtk/gtkshortcutlabel.c:171
#: gtk/gtkaccelgroup.c:941 gtk/gtkshortcutlabel.c:171
msgctxt "keyboard label"
msgid "Backslash"
msgstr "Omvänt snedstreck"
@@ -1992,7 +1976,7 @@ msgstr "_Höger:"
msgid "Paper Margins"
msgstr "Pappersmarginaler"
#: gtk/gtkentry.c:3743
#: gtk/gtkentry.c:3726
msgid "Insert Emoji"
msgstr "Infoga emoji"
@@ -2063,7 +2047,7 @@ msgstr "Det finns redan en fil med det namnet"
#: gtk/gtkprintbackend.c:642 gtk/gtkprinteroptionwidget.c:713
#: gtk/gtkprintunixdialog.c:667 gtk/gtkprintunixdialog.c:823
#: gtk/gtkwindow.c:6140 gtk/inspector/css-editor.c:248
#: gtk/inspector/recorder.c:1271 gtk/ui/gtkappchooserdialog.ui:45
#: gtk/inspector/recorder.c:1245 gtk/ui/gtkappchooserdialog.ui:45
#: gtk/ui/gtkassistant.ui:52 gtk/ui/gtkcolorchooserdialog.ui:33
#: gtk/ui/gtkfontchooserdialog.ui:24
msgid "_Cancel"
@@ -2076,7 +2060,7 @@ msgid "_Open"
msgstr "_Öppna"
#: gtk/gtkfilechoosernative.c:574 gtk/inspector/css-editor.c:249
#: gtk/inspector/recorder.c:1272
#: gtk/inspector/recorder.c:1246
msgid "_Save"
msgstr "_Spara"
@@ -2154,7 +2138,7 @@ msgid "If you delete an item, it will be permanently lost."
msgstr "Om du tar bort ett objekt är det borta för alltid."
#: gtk/gtkfilechooserwidget.c:1210 gtk/gtkfilechooserwidget.c:1826
#: gtk/gtklabel.c:5483 gtk/gtktext.c:6062 gtk/gtktextview.c:8886
#: gtk/gtklabel.c:5483 gtk/gtktext.c:6060 gtk/gtktextview.c:8847
msgid "_Delete"
msgstr "_Ta bort"
@@ -2426,19 +2410,19 @@ msgstr "Teckenvarianter"
msgid "OpenGL context creation failed"
msgstr "Skapande av OpenGL-kontext misslyckades"
#: gtk/gtklabel.c:5480 gtk/gtktext.c:6050 gtk/gtktextview.c:8874
#: gtk/gtklabel.c:5480 gtk/gtktext.c:6048 gtk/gtktextview.c:8835
msgid "Cu_t"
msgstr "Klipp _ut"
#: gtk/gtklabel.c:5481 gtk/gtktext.c:6054 gtk/gtktextview.c:8878
#: gtk/gtklabel.c:5481 gtk/gtktext.c:6052 gtk/gtktextview.c:8839
msgid "_Copy"
msgstr "_Kopiera"
#: gtk/gtklabel.c:5482 gtk/gtktext.c:6058 gtk/gtktextview.c:8882
#: gtk/gtklabel.c:5482 gtk/gtktext.c:6056 gtk/gtktextview.c:8843
msgid "_Paste"
msgstr "Klistra _in"
#: gtk/gtklabel.c:5488 gtk/gtktext.c:6071 gtk/gtktextview.c:8907
#: gtk/gtklabel.c:5488 gtk/gtktext.c:6069 gtk/gtktextview.c:8868
msgid "Select _All"
msgstr "Markera _allt"
@@ -2726,19 +2710,19 @@ msgstr ""
msgid "Page Setup"
msgstr "Sidinställning"
#: gtk/gtkpasswordentry.c:173
#: gtk/gtkpasswordentry.c:167
msgid "Hide Text"
msgstr "Dölj text"
#: gtk/gtkpasswordentry.c:178 gtk/gtkpasswordentry.c:629
#: gtk/gtkpasswordentry.c:172 gtk/gtkpasswordentry.c:606
msgid "Show Text"
msgstr "Visa text"
#: gtk/gtkpasswordentry.c:216
#: gtk/gtkpasswordentry.c:199
msgid "Caps Lock is on"
msgstr "Caps Lock är aktiverad"
#: gtk/gtkpasswordentry.c:705
#: gtk/gtkpasswordentry.c:680
msgid "_Show Text"
msgstr "_Visa text"
@@ -3328,7 +3312,7 @@ msgid "No registered application with name “%s” for item with URI “%s” f
msgstr ""
"Inget registrerat program med namnet ”%s” hittades för objekt med URI ”%s”"
#: gtk/gtksearchentry.c:619
#: gtk/gtksearchentry.c:599
msgid "Clear entry"
msgstr "Töm sökruta"
@@ -3417,19 +3401,19 @@ msgstr "Försök med en annan sökning"
msgid "Could not show link"
msgstr "Kunde inte visa länken"
#: gtk/gtktext.c:6076 gtk/gtktextview.c:8912
#: gtk/gtktext.c:6074 gtk/gtktextview.c:8873
msgid "Insert _Emoji"
msgstr "Infoga _emoji"
#: gtk/gtktextview.c:8894
#: gtk/gtktextview.c:8855
msgid "_Undo"
msgstr "_Ångra"
#: gtk/gtktextview.c:8898
#: gtk/gtktextview.c:8859
msgid "_Redo"
msgstr "_Gör om"
#: gtk/gtktreeexpander.c:205
#: gtk/gtktreeexpander.c:196
msgid "Expand"
msgstr "Expandera"
@@ -3908,7 +3892,7 @@ msgstr "Källa:"
msgid "Defined At"
msgstr "Definierad vid"
#: gtk/inspector/recorder.c:1242
#: gtk/inspector/recorder.c:1216
#, c-format
msgid "Saving RenderNode failed"
msgstr "Sparande av RenderNode misslyckades"

687
po/tr.po

File diff suppressed because it is too large Load Diff

View File

@@ -3,7 +3,7 @@
static const char *format_name[] = {
"BGRAp", "ARGBp", "RGBAp",
"BGRA", "ARGB", "RGBA", "ABGR",
"RGB", "BGR", NULL
"RGB", "BGR",
};
static const char *

View File

@@ -30,36 +30,34 @@ test('api', test_api,
suite: 'css',
)
if get_option('build-internal-tests')
test_data = executable('data', 'data.c',
c_args: common_cflags,
include_directories: [confinc, ],
dependencies: libgtk_static_dep,
install: get_option('install-tests'),
install_dir: testexecdir,
)
test_data = executable('data', 'data.c',
c_args: common_cflags,
include_directories: [confinc, ],
dependencies: libgtk_static_dep,
install: get_option('install-tests'),
install_dir: testexecdir,
)
test('data', test_data,
args: ['--tap', '-k' ],
protocol: 'tap',
env: csstest_env,
suite: 'css',
)
test('data', test_data,
args: ['--tap', '-k' ],
protocol: 'tap',
env: csstest_env,
suite: 'css',
)
transition = executable('transition', 'transition.c',
c_args: common_cflags,
dependencies: libgtk_static_dep,
install: get_option('install-tests'),
install_dir: testexecdir,
)
transition = executable('transition', 'transition.c',
c_args: common_cflags,
dependencies: libgtk_static_dep,
install: get_option('install-tests'),
install_dir: testexecdir,
)
test('transition', transition,
args: [ '--tap', '-k' ],
protocol: 'tap',
env: csstest_env,
suite: 'css'
)
endif
test('transition', transition,
args: [ '--tap', '-k' ],
protocol: 'tap',
env: csstest_env,
suite: 'css'
)
if get_option('install-tests')
conf = configuration_data()

View File

@@ -1,23 +0,0 @@
a {
color: hsl(0, 0%, 0%);
}
b {
color: hsl(120, 100%, 50%);
}
c {
color: hsl(360, 100%, 50%);
}
d {
color: hsl(-314.159, 50%, 50%);
}
e {
color: hsl(0, 0%, 0%, 0.5);
}
f {
color: hsl(1, 2, 3);
}

View File

@@ -1 +0,0 @@
hsl.css:22:17-18: error: GTK_CSS_PARSER_ERROR_SYNTAX

View File

@@ -1,19 +0,0 @@
a {
color: rgb(0,0,0);
}
b {
color: rgb(0,255,0);
}
c {
color: rgb(255,0,0);
}
d {
color: rgb(191,161,64);
}
e {
color: rgba(0,0,0,0.5);
}

View File

@@ -358,9 +358,6 @@ test_data = [
'freed-string-in-error-messages.css',
'freed-string-in-error-messages.errors',
'freed-string-in-error-messages.ref.css',
'hsl.css',
'hsl.errors',
'hsl.ref.css',
'import-cyclic-1.css',
'import-cyclic-1.errors',
'import-cyclic-1.ref.css',

View File

@@ -1,629 +1,230 @@
#include <gtk/gtk.h>
#include <locale.h>
#include <gdk/gdk.h>
#include "gsk/ngl/gsknglrenderer.h"
#define N 20
static GskRenderer *gl_renderer = NULL;
typedef struct _TextureBuilder TextureBuilder;
/* maximum bytes per pixel */
#define MAX_BPP 4
typedef enum {
TEXTURE_METHOD_LOCAL,
TEXTURE_METHOD_GL,
TEXTURE_METHOD_GL_RELEASED,
BLUE,
GREEN,
RED,
TRANSPARENT,
ALMOST_OPAQUE_REBECCAPURPLE,
N_COLORS
} Color;
N_TEXTURE_METHODS
} TextureMethod;
struct _TextureBuilder
{
GdkMemoryFormat format;
int width;
int height;
guchar *pixels;
gsize stride;
gsize offset;
const char * color_names[N_COLORS] = {
"blue",
"green",
"red",
"transparent",
"almost_opaque_rebeccapurple"
};
static gsize
gdk_memory_format_bytes_per_pixel (GdkMemoryFormat format)
{
switch (format)
{
case GDK_MEMORY_R8G8B8:
case GDK_MEMORY_B8G8R8:
return 3;
typedef struct _MemoryData {
gsize bytes_per_pixel;
guint opaque : 1;
guchar data[N_COLORS][MAX_BPP];
} MemoryData;
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 4;
typedef struct _TestData {
GdkMemoryFormat format;
Color color;
} TestData;
case GDK_MEMORY_R16G16B16:
case GDK_MEMORY_R16G16B16_FLOAT:
return 6;
#define RGBA(a, b, c, d) { 0x ## a, 0x ## b, 0x ## c, 0x ## d }
case GDK_MEMORY_R16G16B16A16_PREMULTIPLIED:
case GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED:
return 8;
case GDK_MEMORY_R32G32B32_FLOAT:
return 12;
case GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED:
return 16;
case GDK_MEMORY_N_FORMATS:
default:
g_assert_not_reached ();
return 4;
}
}
static gboolean
gdk_memory_format_has_alpha (GdkMemoryFormat format)
{
switch (format)
{
case GDK_MEMORY_R8G8B8:
case GDK_MEMORY_B8G8R8:
case GDK_MEMORY_R16G16B16:
case GDK_MEMORY_R16G16B16_FLOAT:
case GDK_MEMORY_R32G32B32_FLOAT:
return FALSE;
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_R16G16B16A16_PREMULTIPLIED:
case GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED:
case GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED:
return TRUE;
case GDK_MEMORY_N_FORMATS:
default:
g_assert_not_reached ();
return TRUE;
}
}
static gpointer
encode (GdkMemoryFormat format,
TextureMethod method)
{
return GSIZE_TO_POINTER (method * GDK_MEMORY_N_FORMATS + format);
}
static MemoryData tests[GDK_MEMORY_N_FORMATS] = {
{ 4, FALSE, { RGBA(FF,00,00,FF), RGBA(00,FF,00,FF), RGBA(00,00,FF,FF), RGBA(00,00,00,00), RGBA(66,22,44,AA) } },
{ 4, FALSE, { RGBA(FF,00,00,FF), RGBA(FF,00,FF,00), RGBA(FF,FF,00,00), RGBA(00,00,00,00), RGBA(AA,44,22,66) } },
{ 4, FALSE, { RGBA(00,00,FF,FF), RGBA(00,FF,00,FF), RGBA(FF,00,00,FF), RGBA(00,00,00,00), RGBA(44,22,66,AA) } },
{ 4, FALSE, { RGBA(FF,00,00,FF), RGBA(00,FF,00,FF), RGBA(00,00,FF,FF), RGBA(00,00,00,00), RGBA(99,33,66,AA) } },
{ 4, FALSE, { RGBA(FF,00,00,FF), RGBA(FF,00,FF,00), RGBA(FF,FF,00,00), RGBA(00,00,00,00), RGBA(AA,66,33,99) } },
{ 4, FALSE, { RGBA(00,00,FF,FF), RGBA(00,FF,00,FF), RGBA(FF,00,00,FF), RGBA(00,00,00,00), RGBA(66,33,99,AA) } },
{ 4, FALSE, { RGBA(FF,FF,00,00), RGBA(FF,00,FF,00), RGBA(FF,00,00,FF), RGBA(00,00,00,00), RGBA(AA,99,33,66) } },
{ 3, TRUE, { RGBA(00,00,FF,00), RGBA(00,FF,00,00), RGBA(FF,00,00,00), RGBA(00,00,00,00), RGBA(44,22,66,00) } },
{ 3, TRUE, { RGBA(FF,00,00,00), RGBA(00,FF,00,00), RGBA(00,00,FF,00), RGBA(00,00,00,00), RGBA(66,22,44,00) } },
};
static void
decode (gconstpointer data,
GdkMemoryFormat *format,
TextureMethod *method)
compare_textures (GdkTexture *expected,
GdkTexture *test,
gboolean ignore_alpha)
{
gsize value = GPOINTER_TO_SIZE (data);
guchar *expected_data, *test_data;
int width, height;
int x, y;
*format = value % GDK_MEMORY_N_FORMATS;
value /= GDK_MEMORY_N_FORMATS;
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));
*method = value;
}
static void
texture_builder_init (TextureBuilder *builder,
GdkMemoryFormat format,
int width,
int height)
{
gsize extra_stride;
width = gdk_texture_get_width (expected);
height = gdk_texture_get_height (expected);
builder->format = format;
builder->width = width;
builder->height = height;
expected_data = g_malloc (width * height * 4);
gdk_texture_download (expected, expected_data, width * 4);
extra_stride = g_test_rand_bit() ? g_test_rand_int_range (0, 16) : 0;
builder->offset = g_test_rand_bit() ? g_test_rand_int_range (0, 128) : 0;
builder->stride = width * gdk_memory_format_bytes_per_pixel (format) + extra_stride;
builder->pixels = g_malloc0 (builder->offset + builder->stride * height);
test_data = g_malloc (width * height * 4);
gdk_texture_download (test, test_data, width * 4);
for (y = 0; y < height; y++)
{
for (x = 0; x < width; x++)
{
if (ignore_alpha)
g_assert_cmphex (*(guint32 *) &expected_data[y * width + x * 4] & 0xFFFFFF, ==, *(guint32 *) &test_data[y * width + x * 4] & 0xFFFFFF);
else
g_assert_cmphex (*(guint32 *) &expected_data[y * width + x * 4], ==, *(guint32 *) &test_data[y * width + x * 4]);
}
}
g_free (expected_data);
g_free (test_data);
}
static GdkTexture *
texture_builder_finish (TextureBuilder *builder)
create_texture (GdkMemoryFormat format,
Color color,
int width,
int height,
gsize stride)
{
GBytes *bytes;
GdkTexture *texture;
GBytes *bytes;
guchar *data;
int x, y;
bytes = g_bytes_new_with_free_func (builder->pixels + builder->offset,
builder->height * builder->stride,
g_free,
builder->pixels);
texture = gdk_memory_texture_new (builder->width,
builder->height,
builder->format,
data = g_malloc (height * MAX (stride, tests[format].bytes_per_pixel));
for (y = 0; y < height; y++)
for (x = 0; x < width; x++)
{
memcpy (&data[y * stride + x * tests[format].bytes_per_pixel],
&tests[format].data[color],
tests[format].bytes_per_pixel);
}
bytes = g_bytes_new_take (data, height * MAX (stride, tests[format].bytes_per_pixel));
texture = gdk_memory_texture_new (width, height,
format,
bytes,
builder->stride);
stride);
g_bytes_unref (bytes);
return texture;
}
static inline void
set_pixel_u8 (guchar *data,
int r,
int g,
int b,
int a,
gboolean premultiply,
const GdkRGBA *color)
{
if (a >= 0)
data[a] = CLAMP (color->alpha * 256.f, 0.f, 255.f);
if (premultiply)
{
data[r] = CLAMP (color->red * color->alpha * 256.f, 0.f, 255.f);
data[g] = CLAMP (color->green * color->alpha * 256.f, 0.f, 255.f);
data[b] = CLAMP (color->blue * color->alpha * 256.f, 0.f, 255.f);
}
else
{
data[r] = CLAMP (color->red * 256.f, 0.f, 255.f);
data[g] = CLAMP (color->green * 256.f, 0.f, 255.f);
data[b] = CLAMP (color->blue * 256.f, 0.f, 255.f);
}
}
static inline guint16
float_to_half (const float x)
{
const guint b = *(guint*)&x+0x00001000; // round-to-nearest-even
const guint e = (b&0x7F800000)>>23; // exponent
const guint m = b&0x007FFFFF; // mantissa
return (b&0x80000000)>>16 | (e>112)*((((e-112)<<10)&0x7C00)|m>>13) | ((e<113)&(e>101))*((((0x007FF000+m)>>(125-e))+1)>>1) | (e>143)*0x7FFF; // sign : normalized : denormalized : saturate
}
static void
texture_builder_set_pixel (TextureBuilder *builder,
int x,
int y,
const GdkRGBA *color)
{
guchar *data;
g_assert_cmpint (x, >=, 0);
g_assert_cmpint (x, <, builder->width);
g_assert_cmpint (y, >=, 0);
g_assert_cmpint (y, <, builder->height);
data = builder->pixels
+ builder->offset
+ y * builder->stride
+ x * gdk_memory_format_bytes_per_pixel (builder->format);
switch (builder->format)
{
case GDK_MEMORY_B8G8R8A8_PREMULTIPLIED:
set_pixel_u8 (data, 2, 1, 0, 3, TRUE, color);
break;
case GDK_MEMORY_A8R8G8B8_PREMULTIPLIED:
set_pixel_u8 (data, 1, 2, 3, 0, TRUE, color);
break;
case GDK_MEMORY_R8G8B8A8_PREMULTIPLIED:
set_pixel_u8 (data, 0, 1, 2, 3, TRUE, color);
break;
case GDK_MEMORY_B8G8R8A8:
set_pixel_u8 (data, 2, 1, 0, 3, FALSE, color);
break;
case GDK_MEMORY_A8R8G8B8:
set_pixel_u8 (data, 1, 2, 3, 0, FALSE, color);
break;
case GDK_MEMORY_R8G8B8A8:
set_pixel_u8 (data, 0, 1, 2, 3, FALSE, color);
break;
case GDK_MEMORY_A8B8G8R8:
set_pixel_u8 (data, 3, 2, 1, 0, FALSE, color);
break;
case GDK_MEMORY_R8G8B8:
set_pixel_u8 (data, 0, 1, 2, -1, TRUE, color);
break;
case GDK_MEMORY_B8G8R8:
set_pixel_u8 (data, 2, 1, 0, -1, TRUE, color);
break;
case GDK_MEMORY_R16G16B16:
{
guint16 pixels[3] = {
CLAMP (color->red * color->alpha * 65536.f, 0, 65535.f),
CLAMP (color->green * color->alpha * 65536.f, 0, 65535.f),
CLAMP (color->blue * color->alpha * 65536.f, 0, 65535.f),
};
memcpy (data, pixels, 3 * sizeof (guint16));
}
break;
case GDK_MEMORY_R16G16B16A16_PREMULTIPLIED:
{
guint16 pixels[4] = {
CLAMP (color->red * color->alpha * 65536.f, 0, 65535.f),
CLAMP (color->green * color->alpha * 65536.f, 0, 65535.f),
CLAMP (color->blue * color->alpha * 65536.f, 0, 65535.f),
CLAMP (color->alpha * 65536.f, 0, 65535.f),
};
memcpy (data, pixels, 4 * sizeof (guint16));
}
break;
case GDK_MEMORY_R16G16B16_FLOAT:
{
guint16 pixels[3] = {
float_to_half (color->red * color->alpha),
float_to_half (color->green * color->alpha),
float_to_half (color->blue * color->alpha)
};
memcpy (data, pixels, 3 * sizeof (guint16));
}
break;
case GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED:
{
guint16 pixels[4] = {
float_to_half (color->red * color->alpha),
float_to_half (color->green * color->alpha),
float_to_half (color->blue * color->alpha),
float_to_half (color->alpha)
};
memcpy (data, pixels, 4 * sizeof (guint16));
}
break;
case GDK_MEMORY_R32G32B32_FLOAT:
{
float pixels[3] = {
color->red * color->alpha,
color->green * color->alpha,
color->blue * color->alpha
};
memcpy (data, pixels, 3 * sizeof (float));
}
break;
case GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED:
{
float pixels[4] = {
color->red * color->alpha,
color->green * color->alpha,
color->blue * color->alpha,
color->alpha
};
memcpy (data, pixels, 4 * sizeof (float));
}
break;
case GDK_MEMORY_N_FORMATS:
default:
g_assert_not_reached ();
break;
}
}
static void
texture_builder_fill (TextureBuilder *builder,
const GdkRGBA *color)
{
int x, y;
for (y = 0; y < builder->height; y++)
for (x = 0; x < builder->width; x++)
texture_builder_set_pixel (builder, x, y, color);
}
static void
compare_textures (GdkTexture *expected,
GdkTexture *test,
gboolean has_alpha)
{
guint32 *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 (guint32, width * height);
gdk_texture_download (expected, (guchar *) expected_data, width * 4);
test_data = g_new (guint32, width * height);
gdk_texture_download (test, (guchar *) test_data, width * 4);
for (y = 0; y < height; y++)
{
for (x = 0; x < width; x++)
{
if (has_alpha)
g_assert_cmphex (expected_data[y * width + x], ==, test_data[y * width + x]);
else
g_assert_cmphex (expected_data[y * width + x] | 0xFF000000, ==, test_data[y * width + x]);
}
}
g_free (expected_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 *
upload_to_gl (GdkTexture *texture)
{
GskRenderNode *node;
GdkTexture *result;
if (gl_renderer == NULL)
return texture;
node = gsk_texture_node_new (texture,
&GRAPHENE_RECT_INIT(
0, 0,
gdk_texture_get_width (texture),
gdk_texture_get_height (texture)
));
result = gsk_renderer_render_texture (gl_renderer, node, NULL);
gsk_render_node_unref (node);
g_object_unref (texture);
return result;
}
static GdkTexture *
create_texture (GdkMemoryFormat format,
TextureMethod method,
int width,
int height,
const GdkRGBA *color)
{
TextureBuilder builder;
GdkTexture *texture;
texture_builder_init (&builder, format, width, height);
texture_builder_fill (&builder, color);
texture = texture_builder_finish (&builder);
switch (method)
{
case TEXTURE_METHOD_LOCAL:
break;
case TEXTURE_METHOD_GL:
texture = upload_to_gl (texture);
break;
case TEXTURE_METHOD_GL_RELEASED:
texture = upload_to_gl (texture);
gdk_gl_texture_release (GDK_GL_TEXTURE (texture));
break;
case N_TEXTURE_METHODS:
default:
g_assert_not_reached ();
break;
}
return texture;
}
static void
create_random_color (GdkRGBA *color)
{
/* Generate colors so that premultiplying will result in values in steps of 1/15th */
color->red = g_test_rand_int_range (0, 6) / 5.f;
color->green = g_test_rand_int_range (0, 6) / 5.f;
color->blue = g_test_rand_int_range (0, 6) / 5.f;
color->alpha = g_test_rand_int_range (0, 4) / 3.f;
}
static void
test_download_1x1 (gconstpointer data)
{
GdkMemoryFormat format;
TextureMethod method;
const TestData *test_data = data;
GdkTexture *expected, *test;
gsize i;
decode (data, &format, &method);
expected = create_texture (GDK_MEMORY_DEFAULT, test_data->color, 1, 1, tests[test_data->format].bytes_per_pixel);
test = create_texture (test_data->format, test_data->color, 1, 1, tests[test_data->format].bytes_per_pixel);
for (i = 0; i < N; i++)
{
GdkRGBA color;
compare_textures (expected, test, tests[test_data->format].opaque);
create_random_color (&color);
expected = create_texture (GDK_MEMORY_DEFAULT, TEXTURE_METHOD_LOCAL, 1, 1, &color);
test = create_texture (format, method, 1, 1, &color);
compare_textures (expected, test, gdk_memory_format_has_alpha (format));
g_object_unref (expected);
g_object_unref (test);
}
g_object_unref (expected);
g_object_unref (test);
}
static void
test_download_1x1_with_stride (gconstpointer data)
{
const TestData *test_data = data;
GdkTexture *expected, *test;
expected = create_texture (GDK_MEMORY_DEFAULT, test_data->color, 1, 1, 4);
test = create_texture (test_data->format, test_data->color, 1, 1, 2 * MAX_BPP);
compare_textures (expected, test, tests[test_data->format].opaque);
g_object_unref (expected);
g_object_unref (test);
}
static void
test_download_4x4 (gconstpointer data)
{
GdkMemoryFormat format;
TextureMethod method;
const TestData *test_data = data;
GdkTexture *expected, *test;
gsize i;
decode (data, &format, &method);
expected = create_texture (GDK_MEMORY_DEFAULT, test_data->color, 4, 4, 16);
test = create_texture (test_data->format, test_data->color, 4, 4, 4 * tests[test_data->format].bytes_per_pixel);
for (i = 0; i < N; i++)
{
GdkRGBA color;
compare_textures (expected, test, tests[test_data->format].opaque);
create_random_color (&color);
expected = create_texture (GDK_MEMORY_DEFAULT, TEXTURE_METHOD_LOCAL, 4, 4, &color);
test = create_texture (format, method, 4, 4, &color);
compare_textures (expected, test, gdk_memory_format_has_alpha (format));
g_object_unref (expected);
g_object_unref (test);
}
g_object_unref (expected);
g_object_unref (test);
}
static void
test_download_float_1x1 (gconstpointer data)
test_download_4x4_with_stride (gconstpointer data)
{
GdkMemoryFormat format;
TextureMethod method;
const TestData *test_data = data;
GdkTexture *expected, *test;
gsize i;
decode (data, &format, &method);
expected = create_texture (GDK_MEMORY_DEFAULT, test_data->color, 4, 4, 16);
test = create_texture (test_data->format, test_data->color, 4, 4, 4 * MAX_BPP);
for (i = 0; i < N; i++)
{
GdkRGBA color;
compare_textures (expected, test, tests[test_data->format].opaque);
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,
G_MINFLOAT,
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, G_MINFLOAT, gdk_memory_format_has_alpha (format));
g_object_unref (expected);
g_object_unref (test);
}
}
static void
add_test (const char *name,
GTestDataFunc func)
{
GdkMemoryFormat format;
TextureMethod method;
GEnumClass *enum_class;
enum_class = g_type_class_ref (GDK_TYPE_MEMORY_FORMAT);
for (format = 0; format < GDK_MEMORY_N_FORMATS; format++)
{
for (method = 0; method < N_TEXTURE_METHODS; method++)
{
const char *method_names[N_TEXTURE_METHODS] = { "local", "gl", "gl-released" };
char *test_name = g_strdup_printf ("%s/%s/%s",
name,
g_enum_get_value (enum_class, format)->value_nick,
method_names[method]);
g_test_add_data_func_full (test_name, encode (format, method), test_download_1x1, NULL);
g_free (test_name);
}
}
g_object_unref (expected);
g_object_unref (test);
}
int
main (int argc, char *argv[])
{
GdkSurface *surface;
int result;
GdkMemoryFormat format;
Color color;
GEnumClass *enum_class;
gtk_test_init (&argc, &argv, NULL);
(g_test_init) (&argc, &argv, NULL);
add_test ("/memorytexture/download_1x1", test_download_1x1);
add_test ("/memorytexture/download_4x4", test_download_4x4);
add_test ("/memorytexture/download_float_1x1", test_download_float_1x1);
add_test ("/memorytexture/download_float_4x4", test_download_float_4x4);
enum_class = g_type_class_ref (GDK_TYPE_MEMORY_FORMAT);
surface = gdk_surface_new_toplevel (gdk_display_get_default());
gl_renderer = gsk_ngl_renderer_new ();
if (!gsk_renderer_realize (gl_renderer, surface, NULL))
for (format = 0; format < GDK_MEMORY_N_FORMATS; format++)
{
g_clear_object (&gl_renderer);
g_clear_object (&surface);
for (color = 0; color < N_COLORS; color++)
{
TestData *test_data = g_new (TestData, 1);
char *test_name = g_strdup_printf ("/memorytexture/download_1x1/%s/%s",
g_enum_get_value (enum_class, format)->value_nick,
color_names[color]);
test_data->format = format;
test_data->color = color;
g_test_add_data_func_full (test_name, test_data, test_download_1x1, g_free);
g_free (test_name);
test_data = g_new (TestData, 1);
test_name = g_strdup_printf ("/memorytexture/download_1x1_with_stride/%s/%s",
g_enum_get_value (enum_class, format)->value_nick,
color_names[color]);
test_data->format = format;
test_data->color = color;
g_test_add_data_func_full (test_name, test_data, test_download_1x1_with_stride, g_free);
g_free (test_name);
test_data = g_new (TestData, 1);
test_name = g_strdup_printf ("/memorytexture/download_4x4/%s/%s",
g_enum_get_value (enum_class, format)->value_nick,
color_names[color]);
test_data->format = format;
test_data->color = color;
g_test_add_data_func_full (test_name, test_data, test_download_4x4, g_free);
g_free (test_name);
test_data = g_new (TestData, 1);
test_name = g_strdup_printf ("/memorytexture/download_4x4_with_stride/%s/%s",
g_enum_get_value (enum_class, format)->value_nick,
color_names[color]);
test_data->format = format;
test_data->color = color;
g_test_add_data_func_full (test_name, test_data, test_download_4x4_with_stride, g_free);
g_free (test_name);
}
}
result = g_test_run ();
if (gl_renderer)
{
gsk_renderer_unrealize (gl_renderer);
g_clear_object (&gl_renderer);
}
g_clear_object (&surface);
return result;
return g_test_run ();
}

View File

@@ -26,7 +26,6 @@ tests = [
'rgba',
'seat',
'texture',
'texture-threads',
]
foreach t : tests

View File

@@ -65,30 +65,6 @@ test_color_parse (void)
res = gdk_rgba_parse (&color, "#0080ff88");
g_assert_true (res);
g_assert_true (gdk_rgba_equal (&color, &expected));
expected.red = 1.0;
expected.green = 0.0;
expected.blue = 0.0;
expected.alpha = 1.0;
res = gdk_rgba_parse (&color, "hsl (0, 100%, 50%)");
g_assert_true (res);
g_assert_true (gdk_rgba_equal (&color, &expected));
expected.red = 0.0;
expected.green = 1.0;
expected.blue = 0.0;
expected.alpha = 0.1;
res = gdk_rgba_parse (&color, "hsla (120, 255, 50%, 0.1)");
g_assert_true (res);
g_assert_true (gdk_rgba_equal (&color, &expected));
expected.red = 0.0;
expected.green = 0.5;
expected.blue = 0.5;
expected.alpha = 1.0;
res = gdk_rgba_parse (&color, "hsl(180, 100%, 25%)");
g_assert_true (res);
g_assert_true (gdk_rgba_equal (&color, &expected));
}
static void

View File

@@ -1,103 +0,0 @@
#include <gtk/gtk.h>
#include "gsk/ngl/gsknglrenderer.h"
/* This function will be called from a thread and/or the main loop.
* Textures are threadsafe after all. */
static void
ensure_texture_access (GdkTexture *texture)
{
/* Make sure to initialize the pixel to anything but red */
guint32 pixel = 0;
float float_pixel[4] = { INFINITY, INFINITY, INFINITY, INFINITY };
/* Just to be sure */
g_assert_cmpint (gdk_texture_get_width (texture), ==, 1);
g_assert_cmpint (gdk_texture_get_height (texture), ==, 1);
/* download the pixel */
gdk_texture_download (texture, (guchar *) &pixel, 4);
gdk_texture_download_float (texture, float_pixel, 4);
/* check the pixel is now red */
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);
}
static void
texture_download_done (GObject *texture,
GAsyncResult *res,
gpointer loop)
{
ensure_texture_access (GDK_TEXTURE (texture));
g_main_loop_quit (loop);
}
static void
texture_download_thread (GTask *task,
gpointer texture,
gpointer unused,
GCancellable *cancellable)
{
ensure_texture_access (GDK_TEXTURE (texture));
g_task_return_boolean (task, TRUE);
}
static void
texture_threads (void)
{
GdkSurface *surface;
GskRenderer *gl_renderer;
GskRenderNode *node;
GMainLoop *loop;
GdkTexture *texture;
GTask *task;
/* 1. Get a GL renderer */
surface = gdk_surface_new_toplevel (gdk_display_get_default());
gl_renderer = gsk_ngl_renderer_new ();
g_assert_true (gsk_renderer_realize (gl_renderer, surface, NULL));
/* 2. Get a GL texture */
node = gsk_color_node_new (&(GdkRGBA) { 1, 0, 0, 1 }, &GRAPHENE_RECT_INIT(0, 0, 1, 1));
texture = gsk_renderer_render_texture (gl_renderer, node, &GRAPHENE_RECT_INIT(0, 0, 1, 1));
gsk_render_node_unref (node);
/* 3. This is a bit fishy, but we want to make sure that
* the texture's GL context is current in the main thread.
*
* If we had access to the context, we'd make_current() here.
*/
ensure_texture_access (texture);
g_assert_nonnull (gdk_gl_context_get_current ());
/* 4. Run a thread trying to download the texture */
loop = g_main_loop_new (NULL, TRUE);
task = g_task_new (texture, NULL, texture_download_done, loop);
g_task_run_in_thread (task, texture_download_thread);
g_clear_object (&task);
/* 5. Run the main loop waiting for the thread to return */
g_main_loop_run (loop);
/* 6. All good */
gsk_renderer_unrealize (gl_renderer);
g_clear_pointer (&loop, g_main_loop_unref);
g_clear_object (&gl_renderer);
g_clear_object (&surface);
}
int
main (int argc, char *argv[])
{
gtk_test_init (&argc, &argv, NULL);
g_test_add_func ("/texture-threads", texture_threads);
return g_test_run ();
}

View File

@@ -32,23 +32,6 @@ test_constants (void)
}
}
static float
random_representable_float (void)
{
guint16 h[4];
float f[4];
do
{
/* generate a random float thats representable as fp16 */
memset (h, 0, sizeof (h));
h[0] = g_random_int_range (G_MININT16, G_MAXINT16);
half_to_float4 (h, f);
}
while (!isnormal (f[0])); /* skip nans and infs since they don't compare well */
return f[0];
}
static void
test_roundtrip (void)
{
@@ -58,7 +41,15 @@ test_roundtrip (void)
float f2[4];
guint16 h[4];
f2[0] = random_representable_float ();
do
{
/* generate a random float thats representable as fp16 */
memset (h, 0, sizeof (h));
h[0] = g_random_int_range (G_MININT16, G_MAXINT16);
half_to_float4 (h, f2);
}
while (!isnormal (f2[0])); /* skip nans and infs since they don't compare well */
memset (f, 0, sizeof (f));
f[0] = f2[0];
@@ -69,32 +60,6 @@ test_roundtrip (void)
}
}
/* Test that the array version work as expected,
* in particular with unaligned boundaries.
*/
static void
test_many (void)
{
for (int i = 0; i < 100; i++)
{
int size = g_random_int_range (100, 200);
int offset = g_random_int_range (0, 20);
guint16 *h = g_new0 (guint16, size);
float *f = g_new0 (float, size);
float *f2 = g_new0 (float, size);
for (int j = offset; j < size; j++)
f[j] = random_representable_float ();
float_to_half (f + offset, h + offset, size - offset);
half_to_float (h + offset, f2 + offset, size - offset);
for (int j = offset; j < size; j++)
g_assert_cmpfloat (f[j], ==, f2[j]);
}
}
int
main (int argc, char *argv[])
{
@@ -102,7 +67,6 @@ main (int argc, char *argv[])
g_test_add_func ("/half-float/constants", test_constants);
g_test_add_func ("/half-float/roundtrip", test_roundtrip);
g_test_add_func ("/half-float/many", test_many);
return g_test_run ();
}

View File

@@ -239,31 +239,31 @@ internal_tests = [
[ 'half-float' ],
]
if get_option('build-internal-tests')
foreach t : internal_tests
test_name = t.get(0)
test_srcs = ['@0@.c'.format(test_name)] + t.get(1, [])
test_extra_cargs = t.get(2, [])
test_extra_ldflags = t.get(3, [])
foreach t : internal_tests
test_name = t.get(0)
test_srcs = ['@0@.c'.format(test_name)] + t.get(1, [])
test_extra_cargs = t.get(2, [])
test_extra_ldflags = t.get(3, [])
test_exe = executable(test_name, test_srcs,
c_args : test_cargs + test_extra_cargs + common_cflags,
link_args : test_extra_ldflags,
dependencies : libgtk_static_dep,
install: get_option('install-tests'),
install_dir: testexecdir,
)
test(test_name, test_exe,
args: [ '--tap', '-k' ],
protocol: 'tap',
env: [
'GSK_RENDERER=cairo',
'GTK_A11Y=test',
'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir())
],
suite: 'gsk',
)
endforeach
test_exe = executable(test_name, test_srcs,
c_args : test_cargs + test_extra_cargs + common_cflags,
link_args : test_extra_ldflags,
dependencies : libgtk_static_dep,
install: get_option('install-tests'),
install_dir: testexecdir,
)
test(test_name, test_exe,
args: [ '--tap', '-k' ],
protocol: 'tap',
env: [
'GSK_RENDERER=cairo',
'GTK_A11Y=test',
'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir())
],
suite: 'gsk',
)
endforeach
endif

View File

@@ -190,40 +190,38 @@ foreach t : tests
)
endforeach
if get_option('build-internal-tests')
foreach t : internal_tests
test_name = t.get('name')
test_srcs = ['@0@.c'.format(test_name)] + t.get('sources', [])
test_extra_cargs = t.get('c_args', [])
test_extra_ldflags = t.get('link_args', [])
test_extra_suites = t.get('suites', [])
test_timeout = 60
foreach t : internal_tests
test_name = t.get('name')
test_srcs = ['@0@.c'.format(test_name)] + t.get('sources', [])
test_extra_cargs = t.get('c_args', [])
test_extra_ldflags = t.get('link_args', [])
test_extra_suites = t.get('suites', [])
test_timeout = 60
test_exe = executable(test_name,
sources: test_srcs,
c_args: test_cargs + test_extra_cargs,
link_args: test_extra_ldflags,
dependencies: libgtk_static_dep,
install: get_option('install-tests'),
install_dir: testexecdir,
)
test_exe = executable(test_name,
sources: test_srcs,
c_args: test_cargs + test_extra_cargs,
link_args: test_extra_ldflags,
dependencies: libgtk_static_dep,
install: get_option('install-tests'),
install_dir: testexecdir,
)
expect_fail = xfail.contains(test_name)
expect_fail = xfail.contains(test_name)
if test_extra_suites.contains('slow')
test_timeout = 90
endif
if test_extra_suites.contains('slow')
test_timeout = 90
endif
test(test_name, test_exe,
args: [ '--tap', '-k' ],
protocol: 'tap',
timeout: test_timeout,
env: test_env,
suite: ['gtk'] + test_extra_suites,
should_fail: expect_fail,
)
endforeach
endif
test(test_name, test_exe,
args: [ '--tap', '-k' ],
protocol: 'tap',
timeout: test_timeout,
env: test_env,
suite: ['gtk'] + test_extra_suites,
should_fail: expect_fail,
)
endforeach
# FIXME: if objc autotestkeywords_CPPFLAGS += -DHAVE_OBJC=1 -x objective-c++
if add_languages('cpp', required: false, native: false)