Compare commits

..

9 Commits

Author SHA1 Message Date
Matthias Clasen d0c9c66c38 gsk: Don't notify surface properties during render
The offloading may change subsurface stacking order, and thereby
change the effective dmabuf formats of the surface. But we don't
want to trigger callbacks during frame processing, so delay the
change notification until after we're done with that.
2024-04-27 19:58:19 -04:00
Matthias Clasen 349a29bb49 gstreamer: Use surface dmabuf formats
Use surface formats instead of display formats, for better results.

This does not pay attention to priorities yet, and renegotiation
is still missing.
2024-04-27 19:55:01 -04:00
Matthias Clasen dbb890240a wayland: Hook up surface dmabuf feedback
Make the surface and subsurface code handle the dmabuf feedback,
and update the :dmabuf-formats property on the surface to reflect
the Wayland dmabuf information.
2024-04-27 19:55:01 -04:00
Matthias Clasen ad636b2afb wayland: Hook up default dmabuf feedback
Keep the dmabuf formats from the default feedback events around
in the display, instead of just printing out debug spew.

The formats will be used in the future.
2024-04-27 19:55:01 -04:00
Matthias Clasen 66bc0c968f surface: Add a dmabuf-formats property
Add a property to GdkSurface that carries the effective dmabuf
formats for the surface. This will be either the formats according
to the surfaces own Wayland dmabuf feedback, or the formats of the
topmost subsurface.
2024-04-27 19:54:59 -04:00
Matthias Clasen 3674497163 dmabuf: Add Wayland information
Add device and scanout information for dmabuf formats.

While this is not a great API, there is no good alternative to
making this information available to applications that want to
negotiate dmabuf formats suitable for graphics offload.

The getters for Wayland-specific information are kept as
Wayland backend apis.

Tests included.
2024-04-27 19:48:18 -04:00
Matthias Clasen 1217cc91d7 dmabuf: Redo format collection
Arrange for the following tranches to be collected With GL:
 - Regular EGL formats
 - Mmap formats (that aren't included already

And with GLES:
 - Regular EGL formats
 - External EGL formats
 - Mmap formats (that aren't included already

Also, move the debug spew for formats from the downloaders to the
display, so we can print them properly sorted, and in their tranches.
The only thing we don't have anymore here is the downloader name.
2024-04-27 19:13:13 -04:00
Matthias Clasen 4a8ecd4114 dmabuf: Add priorities to formats
This will be used to influence the sorting of formats, so we can
prefer 'native' formats over those that we can't import.

Test included.
2024-04-27 19:13:13 -04:00
Matthias Clasen 8182fb5704 dmabuf: Move a declaration
We will need to access this struct from the Wayland backend.
2024-04-27 19:13:13 -04:00
314 changed files with 3884 additions and 7603 deletions
-48
View File
@@ -1,54 +1,6 @@
Overview of Changes in 4.15.1, xx-xx-xxxx
=========================================
* GtkGraphicsOffload:
- Don't crash without a child
* CSS:
- Support the :root selector
* Icontheme:
- Make symbolic svg loading more efficient
- Handle color-free symbolics more efficiently
* Accessibility:
- Make the gtk-demo sidebar search more accessible
- Stop emitting focus events
* GDK:
- Support XDG_ACTIVATION_TOKEN
- dmabuf: Be more defensive when importing unknown formats to GL
- dmabuf: Use narrow range for YUV
* GSK:
- Improve logging for GDK_DEBUG=offload
- Improve logging for GSK_DEBUG=renderer
- gpu: Warn about inefficient texture import
- gpu: Handle tiny offscreens correctly
- vulkan: Add profiler marks in various places
- vulkan: Fix a problem with imported dmabufs showing up black
* Wayland:
- Use wl_compositor version 6
* X11:
- Implement a missing method
* Build:
- Fix many ubsan warnings
* Debugging:
- Show more texture details in the recorder
* macOS:
- Fix problems with events handed back to the OS
- Respect GDK_DEBUG=default-settings
* Translation updates:
Korean
Turkish
Overview of Changes in 4.15.0, 21-04-2024
=========================================
+2 -6
View File
@@ -363,9 +363,7 @@ insert_markup_idle (gpointer data)
if (g_get_monotonic_time () - begin > G_TIME_SPAN_MILLISECOND)
{
guint id;
id = g_idle_add (insert_markup_idle, data);
g_source_set_name_by_id (id, "[gtk-demo] insert_markup_idle");
g_idle_add (insert_markup_idle, data);
return G_SOURCE_REMOVE;
}
@@ -400,9 +398,7 @@ parse_markup_idle (gpointer data)
do {
if (g_get_monotonic_time () - begin > G_TIME_SPAN_MILLISECOND)
{
guint id;
id = g_idle_add (parse_markup_idle, data);
g_source_set_name_by_id (id, "[gtk-demo] parse_markup_idle");
g_idle_add (parse_markup_idle, data);
return G_SOURCE_REMOVE;
}
+2 -1
View File
@@ -40,7 +40,7 @@ get_win32_all_locales_scripts (LPWSTR locale_w, DWORD flags, LPARAM param)
{
wchar_t *langname_w = NULL;
wchar_t locale_abbrev_w[9];
gchar *langname, *locale_abbrev, *locale;
gchar *langname, *locale_abbrev, *locale, *p;
gint i;
const LCTYPE iso639_lctypes[] = { LOCALE_SISO639LANGNAME, LOCALE_SISO639LANGNAME2 };
GHashTable *ht_scripts_langs = (GHashTable *) param;
@@ -59,6 +59,7 @@ get_win32_all_locales_scripts (LPWSTR locale_w, DWORD flags, LPARAM param)
GetLocaleInfoEx (locale_w, LOCALE_SLOCALIZEDDISPLAYNAME, langname_w, langname_size);
langname = g_utf16_to_utf8 (langname_w, -1, NULL, NULL, NULL);
locale = g_utf16_to_utf8 (locale_w, -1, NULL, NULL, NULL);
p = strchr (locale, '-');
lang = pango_language_from_string (locale);
if (g_hash_table_lookup (ht_scripts_langs, lang) == NULL)
g_hash_table_insert (ht_scripts_langs, lang, langname);
-30
View File
@@ -20,7 +20,6 @@
#include "config.h"
#include <gtk/gtk.h>
#include <glib/gstdio.h>
#include <glib/gi18n.h>
#include "demos.h"
#include "fontify.h"
@@ -924,34 +923,6 @@ clear_search (GtkSearchBar *bar)
}
}
static void
search_results_update (GObject *filter_model,
GParamSpec *pspec,
GtkEntry *entry)
{
gsize n_items = g_list_model_get_n_items (G_LIST_MODEL (filter_model));
if (strlen (gtk_editable_get_text (GTK_EDITABLE (entry))) > 0)
{
char *text;
if (n_items > 0)
text = g_strdup_printf (ngettext ("%ld search result", "%ld search results", n_items), n_items);
else
text = g_strdup (_("No search results"));
gtk_accessible_update_property (GTK_ACCESSIBLE (entry),
GTK_ACCESSIBLE_PROPERTY_DESCRIPTION, text,
-1);
g_free (text);
}
else
{
gtk_accessible_reset_property (GTK_ACCESSIBLE (entry), GTK_ACCESSIBLE_PROPERTY_DESCRIPTION);
}
}
static void
activate (GApplication *app)
{
@@ -999,7 +970,6 @@ activate (GApplication *app)
search_entry = GTK_WIDGET (gtk_builder_get_object (builder, "search-entry"));
g_signal_connect (search_entry, "search-changed", G_CALLBACK (demo_search_changed_cb), filter);
g_signal_connect (filter_model, "notify::n-items", G_CALLBACK (search_results_update), search_entry);
selection = gtk_single_selection_new (G_LIST_MODEL (filter_model));
g_signal_connect (selection, "notify::selected-item", G_CALLBACK (selection_cb), NULL);
-2
View File
@@ -330,7 +330,6 @@ stroke bounds of the path.
| offset | `<point>` | 0 0 | non-default |
| hint-style | `<hint style>` | slight | non-default |
| antialias | `<antialias>` | gray | non-default |
| hint-metrics | `<hint metrics>` | off | non-default |
Creates a node like `gsk_text_node_new()` with the given properties.
@@ -347,7 +346,6 @@ font, an error node will be returned.
Possible values for hint-style are none, slight or full.
Possible value for antialias are none or gray.
Possible value for hint-metrics are on or off.
### texture
+2 -5
View File
@@ -5,11 +5,8 @@ Title: Cairo interaction
[Cairo](http://cairographics.org) is a graphics library that supports vector
graphics and image compositing that can be used with GTK.
GDK does not wrap the Cairo API and it is not possible to use cairo directly
to draw on a [class@Gdk.Surface]. You can either use a
[GtkDrawingArea](../gtk4/class.DrawingArea.html) widget or
[gtk_snapshot_append_cairo](../gtk4/func.Snapshot.append_cairo.html)
for drawing with cairo in a GTK4 application.
GDK does not wrap the Cairo API; instead it allows to create Cairo
drawing contexts which can be used to draw on [class@Gdk.Surface]s.
Additional functions allow use [struct@Gdk.Rectangle]s with Cairo
and to use [struct@Gdk.RGBA], `GdkPixbuf`, and [class@Gdk.Surface]
-24
View File
@@ -56,30 +56,6 @@ follows:
1 value:
: all
## Custom Properties
GTK supports custom properties as defined in the
[CSS Custom Properties for Cascading Variables](https://www.w3.org/TR/css-variables-1)
spec.
Custom properties are defined as follows:
```css
--prop: red;
```
and used via the `var` keyword:
```css
color: var(--prop);
```
Custom properties can have a fallback for when the referred property is invalid:
```css
color: var(--prop, green);
```
## Colors
GTK extends the CSS syntax with several additional ways to specify colors.
@@ -155,7 +155,6 @@ Each property name is part of the `GtkAccessibleProperty` enumeration.
| %GTK_ACCESSIBLE_PROPERTY_VALUE_MIN | “aria-valuemin” | double |
| %GTK_ACCESSIBLE_PROPERTY_VALUE_NOW | “aria-valuenow” | double |
| %GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT | “aria-valuetext” | translatable string |
| %GTK_ACCESSIBLE_PROPERTY_HELP_TEXT | N/A | translatable string |
#### List of accessible relations
@@ -217,10 +216,6 @@ are accessible as part of the development process. The GTK Inspector shows
the accessible attributes of each widget, and also provides an overlay that
can highlight accessibility issues.
If you support some non-standard keyboard interactions for a widget, you
**should** set an appropriate `GTK_ACCESSIBLE_PROPERTY_HELP_TEXT` to help
discoverability of the behavior.
It is possible to set accessible attributes in UI files as well:
```xml
<object class="GtkButton" id="button1">
+24
View File
@@ -2004,6 +2004,7 @@ gdk_display_init_dmabuf (GdkDisplay *self)
#ifdef HAVE_EGL
gdk_display_add_dmabuf_downloader (self, gdk_dmabuf_get_egl_downloader (self, builder));
gdk_dmabuf_formats_builder_next_priority (builder);
#endif
gdk_dmabuf_formats_builder_add_formats (builder,
@@ -2016,6 +2017,29 @@ gdk_display_init_dmabuf (GdkDisplay *self)
GDK_DISPLAY_DEBUG (self, DMABUF,
"Initialized support for %zu dmabuf formats",
gdk_dmabuf_formats_get_n_formats (self->dmabuf_formats));
#ifdef G_ENABLE_DEBUG
if (GDK_DISPLAY_DEBUG_CHECK (self, DMABUF))
{
for (gsize i = 0; i < gdk_dmabuf_formats_get_n_formats (self->dmabuf_formats); i++)
{
guint32 fourcc;
guint64 modifier;
gdk_dmabuf_formats_get_format (self->dmabuf_formats, i, &fourcc, &modifier);
gdk_debug_message (" %.4s:%#" G_GINT64_MODIFIER "x%s",
(char *) &fourcc,
modifier,
gdk_dmabuf_formats_contains (self->egl_external_formats, fourcc, modifier) ? " (external)" : "");
if (i + 1 < gdk_dmabuf_formats_get_n_formats (self->dmabuf_formats) &&
gdk_dmabuf_formats_next_priority (self->dmabuf_formats, i) == i + 1)
gdk_debug_message ("------");
}
}
#endif
}
/**
+5 -9
View File
@@ -144,8 +144,8 @@ struct _YUVCoefficients
};
/* multiplied by 65536 */
static const YUVCoefficients itu601_narrow = { 104597, -25675, -53279, 132201 };
//static const YUVCoefficients itu601_wide = { 74711, -25864, -38050, 133176 };
//static const YUVCoefficients itu601_narrow = { 104597, -25675, -53279, 132201 };
static const YUVCoefficients itu601_wide = { 74711, -25864, -38050, 133176 };
static inline void
get_uv_values (const YUVCoefficients *coeffs,
@@ -229,7 +229,7 @@ download_nv12 (guchar *dst_data,
int r, g, b;
gsize xs, ys;
get_uv_values (&itu601_narrow, uv_data[x / X_SUB * 2 + U], uv_data[x / X_SUB * 2 + V], &r, &g, &b);
get_uv_values (&itu601_wide, uv_data[x / X_SUB * 2 + U], uv_data[x / X_SUB * 2 + V], &r, &g, &b);
for (ys = 0; ys < Y_SUB && y + ys < height; ys++)
for (xs = 0; xs < X_SUB && x + xs < width; xs++)
@@ -309,7 +309,7 @@ download_yuv_3 (guchar *dst_data,
int r, g, b;
gsize xs, ys;
get_uv_values (&itu601_narrow, u_data[x / X_SUB], v_data[x / X_SUB], &r, &g, &b);
get_uv_values (&itu601_wide, u_data[x / X_SUB], v_data[x / X_SUB], &r, &g, &b);
for (ys = 0; ys < Y_SUB && y + ys < height; ys++)
for (xs = 0; xs < X_SUB && x + xs < width; xs++)
@@ -365,7 +365,7 @@ download_yuyv (guchar *dst_data,
{
int r, g, b;
get_uv_values (&itu601_narrow, src_data[2 * x + U], src_data[2 * x + V], &r, &g, &b);
get_uv_values (&itu601_wide, src_data[2 * x + U], src_data[2 * x + V], &r, &g, &b);
set_rgb_values (&dst_data[3 * x], src_data[2 * x + Y1], r, g, b);
if (x + 1 < width)
set_rgb_values (&dst_data[3 * (x + 1)], src_data[2 * x + Y2], r, g, b);
@@ -1965,10 +1965,6 @@ gdk_dmabuf_get_mmap_formats (void)
if (!supported_formats[i].download)
continue;
GDK_DEBUG (DMABUF,
"mmap dmabuf format %.4s:%#0" G_GINT64_MODIFIER "x",
(char *) &supported_formats[i].fourcc, (guint64) DRM_FORMAT_MOD_LINEAR);
gdk_dmabuf_formats_builder_add_format (builder,
supported_formats[i].fourcc,
DRM_FORMAT_MOD_LINEAR);
+19 -24
View File
@@ -93,24 +93,17 @@ gdk_dmabuf_egl_downloader_collect_formats (GdkDisplay *display,
for (int j = 0; j < num_modifiers; j++)
{
/* All linear formats we support are already added my the mmap downloader.
* We don't add external formats, unless we can use them (via GLES)
*/
if (modifiers[j] != DRM_FORMAT_MOD_LINEAR &&
(!external_only[j] || gdk_gl_context_get_use_es (context)))
if (!external_only[j])
{
GDK_DISPLAY_DEBUG (display, DMABUF,
"%s EGL dmabuf format %.4s:%#" G_GINT64_MODIFIER "x",
external_only[j] ? "external " : "",
(char *) &fourccs[i],
modifiers[j]);
gdk_dmabuf_formats_builder_add_format (formats, fourccs[i], modifiers[j]);
all_external = FALSE;
}
if (external_only[j])
gdk_dmabuf_formats_builder_add_format (external, fourccs[i], modifiers[j]);
else
all_external = FALSE;
{
if (gdk_gl_context_get_use_es (context))
gdk_dmabuf_formats_builder_add_format (external, fourccs[i], modifiers[j]);
}
}
/* Accept implicit modifiers as long as we accept the format at all.
@@ -120,9 +113,9 @@ gdk_dmabuf_egl_downloader_collect_formats (GdkDisplay *display,
* As an extra wrinkle, treat the implicit modifier as 'external only'
* if all formats with the same fourcc are 'external only'.
*/
if (!all_external || gdk_gl_context_get_use_es (context))
if (!all_external)
gdk_dmabuf_formats_builder_add_format (formats, fourccs[i], DRM_FORMAT_MOD_INVALID);
if (all_external)
else if (gdk_gl_context_get_use_es (context))
gdk_dmabuf_formats_builder_add_format (external, fourccs[i], DRM_FORMAT_MOD_INVALID);
}
@@ -149,6 +142,7 @@ GdkDmabufDownloader *
gdk_dmabuf_get_egl_downloader (GdkDisplay *display,
GdkDmabufFormatsBuilder *builder)
{
GdkGLContext *context;
GdkDmabufFormatsBuilder *formats;
GdkDmabufFormatsBuilder *external;
gboolean retval = FALSE;
@@ -163,8 +157,8 @@ gdk_dmabuf_get_egl_downloader (GdkDisplay *display,
return NULL;
previous = gdk_gl_context_get_current ();
if (previous)
g_object_ref (previous);
context = gdk_display_get_gl_context (display);
formats = gdk_dmabuf_formats_builder_new ();
external = gdk_dmabuf_formats_builder_new ();
@@ -174,6 +168,11 @@ gdk_dmabuf_get_egl_downloader (GdkDisplay *display,
display->egl_external_formats = gdk_dmabuf_formats_builder_free_to_formats (external);
gdk_dmabuf_formats_builder_add_formats (builder, display->egl_dmabuf_formats);
if (gdk_gl_context_get_use_es (context))
{
gdk_dmabuf_formats_builder_next_priority (builder);
gdk_dmabuf_formats_builder_add_formats (builder, display->egl_external_formats);
}
if (!retval)
{
@@ -196,10 +195,7 @@ gdk_dmabuf_get_egl_downloader (GdkDisplay *display,
}
if (previous)
{
gdk_gl_context_make_current (previous);
g_object_unref (previous);
}
gdk_gl_context_make_current (previous);
return GDK_DMABUF_DOWNLOADER (renderer);
}
@@ -244,7 +240,7 @@ gdk_dmabuf_egl_create_image (GdkDisplay *display,
attribs[i++] = EGL_YUV_COLOR_SPACE_HINT_EXT;
attribs[i++] = EGL_ITU_REC601_EXT;
attribs[i++] = EGL_SAMPLE_RANGE_HINT_EXT;
attribs[i++] = EGL_YUV_NARROW_RANGE_EXT;
attribs[i++] = EGL_YUV_FULL_RANGE_EXT;
#define ADD_PLANE(plane) \
{ \
@@ -270,7 +266,6 @@ gdk_dmabuf_egl_create_image (GdkDisplay *display,
if (dmabuf->n_planes > 3) ADD_PLANE (3);
attribs[i++] = EGL_NONE;
g_assert (i < G_N_ELEMENTS (attribs));
image = eglCreateImageKHR (egl_display,
EGL_NO_CONTEXT,
+42 -11
View File
@@ -49,14 +49,6 @@
* Since: 4.14
*/
struct _GdkDmabufFormats
{
int ref_count;
gsize n_formats;
GdkDmabufFormat *formats;
};
G_DEFINE_BOXED_TYPE (GdkDmabufFormats, gdk_dmabuf_formats, gdk_dmabuf_formats_ref, gdk_dmabuf_formats_unref)
/**
@@ -152,7 +144,36 @@ gdk_dmabuf_formats_get_format (GdkDmabufFormats *formats,
}
/**
* gdk_dmabuf_formats_contains:
* gdk_dmabuf_formats_next_priority:
* @formats: a `GdkDmabufFormats`
* @idx: the index of the format to query
*
* Returns the index of the next-lower-priority format.
*
* The formats in a `GdkDmabufFormats` are sorted by decreasing
* priority. This function lets you identify formats with the
* same priority: all the formats between @idx and the return
* value of this function have the same priority.
*
* Returns: the index of the next lower priority format
*
* Since: 4.16
*/
gsize
gdk_dmabuf_formats_next_priority (GdkDmabufFormats *formats,
gsize idx)
{
GdkDmabufFormat *format;
g_return_val_if_fail (idx < formats->n_formats, G_MAXSIZE);
format = &formats->formats[idx];
return format->next_priority;
}
/**
* gdk_dmabuf_format_contains:
* @formats: a `GdkDmabufFormats`
* @fourcc: a format code
* @modifier: a format modifier
@@ -184,6 +205,8 @@ gdk_dmabuf_formats_contains (GdkDmabufFormats *formats,
* gdk_dmabuf_formats_new:
* @formats: the formats
* @n_formats: the length of @formats
* @device: the DRM device that the compositor uses, or
* 0 if this object doesn't describe compositor formats
*
* Creates a new `GdkDmabufFormats struct for
* the given formats.
@@ -197,7 +220,8 @@ gdk_dmabuf_formats_contains (GdkDmabufFormats *formats,
*/
GdkDmabufFormats *
gdk_dmabuf_formats_new (GdkDmabufFormat *formats,
gsize n_formats)
gsize n_formats,
guint64 device)
{
GdkDmabufFormats *self;
@@ -206,6 +230,7 @@ gdk_dmabuf_formats_new (GdkDmabufFormat *formats,
self->ref_count = 1;
self->n_formats = n_formats;
self->formats = g_new (GdkDmabufFormat, n_formats);
self->device = device;
memcpy (self->formats, formats, n_formats * sizeof (GdkDmabufFormat));
@@ -240,6 +265,9 @@ gdk_dmabuf_formats_equal (const GdkDmabufFormats *formats1,
if (formats1 == NULL || formats2 == NULL)
return FALSE;
if (formats1->device != formats2->device)
return FALSE;
if (formats1->n_formats != formats2->n_formats)
return FALSE;
@@ -249,7 +277,10 @@ gdk_dmabuf_formats_equal (const GdkDmabufFormats *formats1,
GdkDmabufFormat *f2 = &formats2->formats[i];
if (f1->fourcc != f2->fourcc ||
f1->modifier != f2->modifier)
f1->modifier != f2->modifier ||
f1->next_priority != f2->next_priority ||
f1->flags != f2->flags ||
f1->device != f2->device)
return FALSE;
}
+4
View File
@@ -46,6 +46,10 @@ void gdk_dmabuf_formats_get_format (GdkDmabufFormats *formats
guint32 *fourcc,
guint64 *modifier);
GDK_AVAILABLE_IN_4_16
gsize gdk_dmabuf_formats_next_priority (GdkDmabufFormats *formats,
gsize idx);
GDK_AVAILABLE_IN_4_14
gboolean gdk_dmabuf_formats_contains (GdkDmabufFormats *formats,
guint32 fourcc,
+58 -30
View File
@@ -52,7 +52,9 @@ gdk_dmabuf_format_compare (gconstpointer data_a,
const GdkDmabufFormat *a = data_a;
const GdkDmabufFormat *b = data_b;
if (a->fourcc == b->fourcc)
if (a->next_priority != b->next_priority)
return (a->next_priority < b->next_priority) ? -1 : 1;
else if (a->fourcc == b->fourcc)
return (a->modifier - b->modifier) >> 8 * (sizeof (gint64) - sizeof (gint));
else
return a->fourcc - b->fourcc;
@@ -67,7 +69,9 @@ gdk_dmabuf_format_equal (gconstpointer data_a,
const GdkDmabufFormat *b = data_b;
return a->fourcc == b->fourcc &&
a->modifier == b->modifier;
a->flags == b->flags &&
a->modifier == b->modifier &&
a->device == b->device;
}
static void
@@ -79,38 +83,46 @@ gdk_dmabuf_formats_builder_sort (GdkDmabufFormatsBuilder *self)
gdk_dmabuf_format_compare);
}
/* list must be sorted */
static void
gdk_dmabuf_formats_builder_remove_duplicates (GdkDmabufFormatsBuilder *self)
GdkDmabufFormats *
gdk_dmabuf_formats_builder_free_to_formats_for_device (GdkDmabufFormatsBuilder *self,
guint64 device)
{
gsize i, j;
GdkDmabufFormats *formats;
for (i = 1, j = 0; i < gdk_dmabuf_formats_builder_get_size (self); i++)
{
if (gdk_dmabuf_format_equal (gdk_dmabuf_formats_builder_get (self, i),
gdk_dmabuf_formats_builder_get (self, j)))
continue;
gdk_dmabuf_formats_builder_next_priority (self);
gdk_dmabuf_formats_builder_sort (self);
j++;
if (i != j)
*gdk_dmabuf_formats_builder_index (self, j) = *gdk_dmabuf_formats_builder_index (self, i);
}
formats = gdk_dmabuf_formats_new (gdk_dmabuf_formats_builder_get_data (self),
gdk_dmabuf_formats_builder_get_size (self),
device);
gdk_dmabuf_formats_builder_clear (self);
g_free (self);
return formats;
}
GdkDmabufFormats *
gdk_dmabuf_formats_builder_free_to_formats (GdkDmabufFormatsBuilder *self)
{
GdkDmabufFormats *formats;
return gdk_dmabuf_formats_builder_free_to_formats_for_device (self, 0);
}
gdk_dmabuf_formats_builder_sort (self);
gdk_dmabuf_formats_builder_remove_duplicates (self);
void
gdk_dmabuf_formats_builder_add_format_for_device (GdkDmabufFormatsBuilder *self,
guint32 fourcc,
guint32 flags,
guint64 modifier,
guint64 device)
{
GdkDmabufFormat format = { fourcc, flags, modifier, device, G_MAXSIZE };
formats = gdk_dmabuf_formats_new (gdk_dmabuf_formats_builder_get_data (self),
gdk_dmabuf_formats_builder_get_size (self));
gdk_dmabuf_formats_builder_clear (self);
g_free (self);
for (gsize i = 0; i < gdk_dmabuf_formats_builder_get_size (self); i++)
{
if (gdk_dmabuf_format_equal (gdk_dmabuf_formats_builder_get (self, i), &format))
return;
}
return formats;
gdk_dmabuf_formats_builder_append (self, &format);
}
void
@@ -118,17 +130,33 @@ gdk_dmabuf_formats_builder_add_format (GdkDmabufFormatsBuilder *self,
guint32 fourcc,
guint64 modifier)
{
gdk_dmabuf_formats_builder_append (self, &(GdkDmabufFormat) { fourcc, modifier });
gdk_dmabuf_formats_builder_add_format_for_device (self, fourcc, 0, modifier, 0);
}
void
gdk_dmabuf_formats_builder_next_priority (GdkDmabufFormatsBuilder *self)
{
for (gsize i = gdk_dmabuf_formats_builder_get_size (self); i > 0; i--)
{
GdkDmabufFormat *format = gdk_dmabuf_formats_builder_get (self, i - 1);
if (format->next_priority != G_MAXSIZE)
break;
format->next_priority = gdk_dmabuf_formats_builder_get_size (self);
}
}
void
gdk_dmabuf_formats_builder_add_formats (GdkDmabufFormatsBuilder *self,
GdkDmabufFormats *formats)
{
gdk_dmabuf_formats_builder_splice (self,
gdk_dmabuf_formats_builder_get_size (self),
0,
FALSE,
gdk_dmabuf_formats_peek_formats (formats),
gdk_dmabuf_formats_get_n_formats (formats));
for (gsize i = 0; i < gdk_dmabuf_formats_get_n_formats (formats); i++)
{
guint32 fourcc;
guint64 modifier;
gdk_dmabuf_formats_get_format (formats, i, &fourcc, &modifier);
gdk_dmabuf_formats_builder_add_format (self, fourcc, modifier);
}
}
+17 -7
View File
@@ -4,11 +4,21 @@
typedef struct GdkDmabufFormatsBuilder GdkDmabufFormatsBuilder;
GdkDmabufFormatsBuilder * gdk_dmabuf_formats_builder_new (void);
GdkDmabufFormats * gdk_dmabuf_formats_builder_free_to_formats (GdkDmabufFormatsBuilder *self);
GdkDmabufFormatsBuilder *gdk_dmabuf_formats_builder_new (void);
GdkDmabufFormats * gdk_dmabuf_formats_builder_free_to_formats (GdkDmabufFormatsBuilder *self);
void gdk_dmabuf_formats_builder_add_format (GdkDmabufFormatsBuilder *self,
guint32 fourcc,
guint64 modifier);
void gdk_dmabuf_formats_builder_add_formats (GdkDmabufFormatsBuilder *self,
GdkDmabufFormats *formats);
void gdk_dmabuf_formats_builder_add_format (GdkDmabufFormatsBuilder *self,
guint32 fourcc,
guint64 modifier);
GdkDmabufFormats * gdk_dmabuf_formats_builder_free_to_formats_for_device (GdkDmabufFormatsBuilder *self,
guint64 device);
void gdk_dmabuf_formats_builder_add_format_for_device (GdkDmabufFormatsBuilder *self,
guint32 fourcc,
guint32 flags,
guint64 modifier,
guint64 device);
void gdk_dmabuf_formats_builder_next_priority (GdkDmabufFormatsBuilder *self);
void gdk_dmabuf_formats_builder_add_formats (GdkDmabufFormatsBuilder *self,
GdkDmabufFormats *formats);
+14 -1
View File
@@ -6,10 +6,23 @@ typedef struct _GdkDmabufFormat GdkDmabufFormat;
struct _GdkDmabufFormat
{
guint32 fourcc;
guint32 flags;
guint64 modifier;
guint64 device;
gsize next_priority;
};
struct _GdkDmabufFormats
{
int ref_count;
gsize n_formats;
GdkDmabufFormat *formats;
guint64 device;
};
GdkDmabufFormats * gdk_dmabuf_formats_new (GdkDmabufFormat *formats,
gsize n_formats);
gsize n_formats,
guint64 device);
const GdkDmabufFormat * gdk_dmabuf_formats_peek_formats (GdkDmabufFormats *self);
+7
View File
@@ -192,6 +192,13 @@ compute_smooth_frame_time (GdkFrameClock *clock,
* and new_frame_time >= old_frame_time. */
frames_passed = (new_frame_time - smoothed_frame_time_base + frame_interval / 2) / frame_interval;
if (frames_passed > 1)
gdk_profiler_add_markf ((smoothed_frame_time_base - (frame_interval * (frames_passed-1))) * 1000L,
frame_interval * (frames_passed-1) * 1000L,
"Dropped Frames",
"%u frames may have been dropped",
frames_passed-1);
/* We use an approximately whole number of frames in the future from
* last smoothed frame time. This way we avoid minor jitter in the
* frame times making the animation speed uneven, but still animate
+35 -72
View File
@@ -1956,6 +1956,8 @@ gdk_gl_context_get_glsl_version_string (GdkGLContext *self)
return "#version 310 es";
else if (gdk_gl_version_greater_equal (&priv->gl_version, &GDK_GL_VERSION_INIT (3, 0)))
return "#version 300 es";
else if (gdk_gl_version_greater_equal (&priv->gl_version, &GDK_GL_VERSION_INIT (3, 0)))
return "#version 300 es";
else
return "#version 100";
}
@@ -2196,78 +2198,12 @@ gdk_gl_context_import_dmabuf (GdkGLContext *self,
gdk_display_init_dmabuf (display);
if (gdk_dmabuf_formats_contains (display->egl_dmabuf_formats, dmabuf->fourcc, dmabuf->modifier))
if (!gdk_dmabuf_formats_contains (display->egl_external_formats, dmabuf->fourcc, dmabuf->modifier))
{
/* This is the path for modern drivers that support modifiers */
if (!gdk_dmabuf_formats_contains (display->egl_external_formats, dmabuf->fourcc, dmabuf->modifier))
{
texture_id = gdk_gl_context_import_dmabuf_for_target (self,
width, height,
dmabuf,
GL_TEXTURE_2D);
if (texture_id == 0)
{
GDK_DISPLAY_DEBUG (display, DMABUF,
"Import of %dx%d %.4s:%#" G_GINT64_MODIFIER "x dmabuf failed",
width, height,
(char *) &dmabuf->fourcc, dmabuf->modifier);
return 0;
}
GDK_DISPLAY_DEBUG (display, DMABUF,
"Imported %dx%d %.4s:%#" G_GINT64_MODIFIER "x dmabuf as GL_TEXTURE_2D texture",
width, height,
(char *) &dmabuf->fourcc, dmabuf->modifier);
*external = FALSE;
return texture_id;
}
if (!gdk_gl_context_get_use_es (self))
{
GDK_DISPLAY_DEBUG (display, DMABUF,
"Can't import external_only %.4s:%#" G_GINT64_MODIFIER "x outside of GLES",
(char *) &dmabuf->fourcc, dmabuf->modifier);
return 0;
}
texture_id = gdk_gl_context_import_dmabuf_for_target (self,
width, height,
dmabuf,
GL_TEXTURE_EXTERNAL_OES);
if (texture_id == 0)
{
GDK_DISPLAY_DEBUG (display, DMABUF,
"Import of external_only %dx%d %.4s:%#" G_GINT64_MODIFIER "x dmabuf failed",
width, height,
(char *) &dmabuf->fourcc, dmabuf->modifier);
return 0;
}
GDK_DISPLAY_DEBUG (display, DMABUF,
"Imported %dx%d %.4s:%#" G_GINT64_MODIFIER "x dmabuf as GL_TEXTURE_EXTERNAL_OES texture",
width, height,
(char *) &dmabuf->fourcc, dmabuf->modifier);
*external = TRUE;
return texture_id;
}
else
{
/* This is the opportunistic path.
* We hit it both for drivers that do not support modifiers as well as for dmabufs
* that the driver did not explicitly advertise. */
int target;
if (gdk_gl_context_get_use_es (self))
target = GL_TEXTURE_EXTERNAL_OES;
else
target = GL_TEXTURE_2D;
texture_id = gdk_gl_context_import_dmabuf_for_target (self,
width, height,
dmabuf,
target);
GL_TEXTURE_2D);
if (texture_id == 0)
{
GDK_DISPLAY_DEBUG (display, DMABUF,
@@ -2278,13 +2214,40 @@ gdk_gl_context_import_dmabuf (GdkGLContext *self,
}
GDK_DISPLAY_DEBUG (display, DMABUF,
"Imported %dx%d %.4s:%#" G_GINT64_MODIFIER "x dmabuf as %s texture",
"Imported %dx%d %.4s:%#" G_GINT64_MODIFIER "x dmabuf as GL_TEXTURE_2D texture",
width, height,
(char *) &dmabuf->fourcc, dmabuf->modifier,
target == GL_TEXTURE_EXTERNAL_OES ? "GL_TEXTURE_EXTERNAL_OES" : "GL_TEXTURE_2D");
*external = target == GL_TEXTURE_EXTERNAL_OES;
(char *) &dmabuf->fourcc, dmabuf->modifier);
*external = FALSE;
return texture_id;
}
if (!gdk_gl_context_get_use_es (self))
{
GDK_DISPLAY_DEBUG (display, DMABUF,
"Can't import external_only %.4s:%#" G_GINT64_MODIFIER "x outside of GLES",
(char *) &dmabuf->fourcc, dmabuf->modifier);
return 0;
}
texture_id = gdk_gl_context_import_dmabuf_for_target (self,
width, height,
dmabuf,
GL_TEXTURE_EXTERNAL_OES);
if (texture_id == 0)
{
GDK_DISPLAY_DEBUG (display, DMABUF,
"Import of external_only %dx%d %.4s:%#" G_GINT64_MODIFIER "x dmabuf failed",
width, height,
(char *) &dmabuf->fourcc, dmabuf->modifier);
return 0;
}
GDK_DISPLAY_DEBUG (display, DMABUF,
"Imported %dx%d %.4s:%#" G_GINT64_MODIFIER "x dmabuf as GL_TEXTURE_EXTERNAL_OES texture",
width, height,
(char *) &dmabuf->fourcc, dmabuf->modifier);
*external = TRUE;
return texture_id;
}
gboolean
+79 -1
View File
@@ -21,6 +21,7 @@
#include "gdksurfaceprivate.h"
#include "gdktexture.h"
#include "gsk/gskrectprivate.h"
#include "gdkdebugprivate.h"
G_DEFINE_TYPE (GdkSubsurface, gdk_subsurface, G_TYPE_OBJECT)
@@ -36,6 +37,7 @@ gdk_subsurface_finalize (GObject *object)
g_ptr_array_remove (subsurface->parent->subsurfaces, subsurface);
g_clear_object (&subsurface->parent);
g_clear_pointer (&subsurface->dmabuf_formats, gdk_dmabuf_formats_unref);
G_OBJECT_CLASS (gdk_subsurface_parent_class)->finalize (object);
}
@@ -116,6 +118,28 @@ insert_subsurface (GdkSubsurface *subsurface,
}
}
static inline gboolean
is_topmost_subsurface (GdkSubsurface *subsurface)
{
GdkSurface *parent = subsurface->parent;
return !subsurface->sibling_above && parent->subsurfaces_below != subsurface;
}
static inline GdkSubsurface *
find_topmost_subsurface (GdkSurface *surface)
{
GdkSubsurface *top = surface->subsurfaces_above;
if (top)
{
while (top->sibling_above)
top = top->sibling_above;
}
return top;
}
/*< private >
* gdk_subsurface_attach:
* @subsurface: the `GdkSubsurface`
@@ -150,7 +174,7 @@ gdk_subsurface_attach (GdkSubsurface *subsurface,
GdkSubsurface *sibling)
{
GdkSurface *parent = subsurface->parent;
gboolean result;
gboolean was_topmost, is_topmost, result;
g_return_val_if_fail (GDK_IS_SUBSURFACE (subsurface), FALSE);
g_return_val_if_fail (GDK_IS_TEXTURE (texture), FALSE);
@@ -164,6 +188,8 @@ gdk_subsurface_attach (GdkSubsurface *subsurface,
g_return_val_if_fail (sibling == NULL || GDK_IS_SUBSURFACE (sibling), FALSE);
g_return_val_if_fail (sibling == NULL || sibling->parent == subsurface->parent, FALSE);
was_topmost = is_topmost_subsurface (subsurface);
result = GDK_SUBSURFACE_GET_CLASS (subsurface)->attach (subsurface,
texture,
source,
@@ -198,6 +224,29 @@ gdk_subsurface_attach (GdkSubsurface *subsurface,
}
}
is_topmost = is_topmost_subsurface (subsurface);
if (!was_topmost && is_topmost)
{
GDK_DISPLAY_DEBUG (parent->display, DMABUF, "Using formats of topmost subsurface %p", subsurface);
gdk_surface_set_effective_dmabuf_formats (parent, subsurface->dmabuf_formats);
}
else if (was_topmost && !is_topmost)
{
GdkSubsurface *top = find_topmost_subsurface (parent);
if (top)
{
GDK_DISPLAY_DEBUG (parent->display, DMABUF, "Using formats of topmost subsurface %p", top);
gdk_surface_set_effective_dmabuf_formats (parent, top->dmabuf_formats);
}
else
{
GDK_DISPLAY_DEBUG (parent->display, DMABUF, "Using formats of main surface");
gdk_surface_set_effective_dmabuf_formats (parent, parent->dmabuf_formats);
}
}
return result;
}
@@ -212,10 +261,25 @@ gdk_subsurface_attach (GdkSubsurface *subsurface,
void
gdk_subsurface_detach (GdkSubsurface *subsurface)
{
gboolean was_topmost;
g_return_if_fail (GDK_IS_SUBSURFACE (subsurface));
was_topmost = is_topmost_subsurface (subsurface);
remove_subsurface (subsurface);
if (was_topmost)
{
GdkSurface *parent = subsurface->parent;
GdkSubsurface *top = find_topmost_subsurface (parent);
if (top)
gdk_surface_set_effective_dmabuf_formats (parent, top->dmabuf_formats);
else
gdk_surface_set_effective_dmabuf_formats (parent, parent->dmabuf_formats);
}
GDK_SUBSURFACE_GET_CLASS (subsurface)->detach (subsurface);
}
@@ -370,3 +434,17 @@ gdk_subsurface_get_bounds (GdkSubsurface *subsurface,
if (gdk_subsurface_get_background_rect (subsurface, &background))
graphene_rect_union (bounds, &background, bounds);
}
void
gdk_subsurface_set_dmabuf_formats (GdkSubsurface *subsurface,
GdkDmabufFormats *formats)
{
g_return_if_fail (GDK_IS_SUBSURFACE (subsurface));
g_return_if_fail (formats != NULL);
g_clear_pointer (&subsurface->dmabuf_formats, gdk_dmabuf_formats_unref);
subsurface->dmabuf_formats = gdk_dmabuf_formats_ref (formats);
if (subsurface->parent && is_topmost_subsurface (subsurface))
gdk_surface_set_effective_dmabuf_formats (subsurface->parent, formats);
}
+5
View File
@@ -21,6 +21,7 @@
#include "gdkenumtypes.h"
#include "gdksurface.h"
#include "gdkdmabufformats.h"
#include <graphene.h>
G_BEGIN_DECLS
@@ -45,6 +46,8 @@ struct _GdkSubsurface
gboolean above_parent;
GdkSubsurface *sibling_above;
GdkSubsurface *sibling_below;
GdkDmabufFormats *dmabuf_formats;
};
typedef enum {
@@ -109,6 +112,8 @@ gboolean gdk_subsurface_get_background_rect (GdkSubsurface *subsu
graphene_rect_t *rect);
void gdk_subsurface_get_bounds (GdkSubsurface *subsurface,
graphene_rect_t *bounds);
void gdk_subsurface_set_dmabuf_formats (GdkSubsurface *subsurface,
GdkDmabufFormats *formats);
G_END_DECLS
+87
View File
@@ -91,6 +91,7 @@ enum {
PROP_0,
PROP_CURSOR,
PROP_DISPLAY,
PROP_DMABUF_FORMATS,
PROP_FRAME_CLOCK,
PROP_MAPPED,
PROP_WIDTH,
@@ -548,6 +549,18 @@ gdk_surface_class_init (GdkSurfaceClass *klass)
GDK_TYPE_DISPLAY,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
/**
* GdkSurface:dmabuf-formats: (attributes org.gtk.Property.get=gdk_surface_get_dmabuf_formats)
*
* The dmabuf formats that can be used with this surface.
*
* Since: 4.14
*/
properties[PROP_DMABUF_FORMATS] =
g_param_spec_boxed ("dmabuf-formats", NULL, NULL,
GDK_TYPE_DMABUF_FORMATS,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
/**
* GdkSurface:frame-clock: (attributes org.gtk.Property.get=gdk_surface_get_frame_clock)
*
@@ -773,6 +786,9 @@ gdk_surface_finalize (GObject *object)
g_ptr_array_unref (surface->subsurfaces);
g_clear_pointer (&surface->dmabuf_formats, gdk_dmabuf_formats_unref);
g_clear_pointer (&surface->effective_dmabuf_formats, gdk_dmabuf_formats_unref);
G_OBJECT_CLASS (gdk_surface_parent_class)->finalize (object);
}
@@ -827,6 +843,10 @@ gdk_surface_get_property (GObject *object,
g_value_set_object (value, surface->display);
break;
case PROP_DMABUF_FORMATS:
g_value_set_boxed (value, surface->effective_dmabuf_formats);
break;
case PROP_FRAME_CLOCK:
g_value_set_object (value, surface->frame_clock);
break;
@@ -3076,3 +3096,70 @@ gdk_surface_get_subsurface (GdkSurface *surface,
{
return g_ptr_array_index (surface->subsurfaces, idx);
}
void
gdk_surface_set_dmabuf_formats (GdkSurface *surface,
GdkDmabufFormats *formats)
{
g_return_if_fail (GDK_IS_SURFACE (surface));
g_return_if_fail (formats != NULL);
g_clear_pointer (&surface->dmabuf_formats, gdk_dmabuf_formats_unref);
surface->dmabuf_formats = gdk_dmabuf_formats_ref (formats);
if (surface->subsurfaces_above == NULL)
{
GDK_DISPLAY_DEBUG (surface->display, DMABUF, "Using main surface formats");
gdk_surface_set_effective_dmabuf_formats (surface, formats);
}
}
void
gdk_surface_set_effective_dmabuf_formats (GdkSurface *surface,
GdkDmabufFormats *formats)
{
g_return_if_fail (GDK_IS_SURFACE (surface));
if (!formats)
return;
if (gdk_dmabuf_formats_equal (surface->effective_dmabuf_formats, formats))
{
GDK_DISPLAY_DEBUG (surface->display, DMABUF, "Formats unchanged");
return;
}
g_clear_pointer (&surface->effective_dmabuf_formats, gdk_dmabuf_formats_unref);
surface->effective_dmabuf_formats = gdk_dmabuf_formats_ref (formats);
g_object_notify_by_pspec (G_OBJECT (surface), properties[PROP_DMABUF_FORMATS]);
}
/**
* gdk_surface_get_dmabuf_formats:
* @surface: a `GdkSurface`
*
* Returns the dma-buf formats that are supported on this surface.
*
* What formats can be used may depend on the geometry and stacking
* order of the surface and its subsurfaces, and can change over time.
*
* The formats returned by this function can be used for negotiating
* buffer formats with producers such as v4l, pipewire or GStreamer.
*
* To learn more about dma-bufs, see [class@Gdk.DmabufTextureBuilder].
*
* Returns: (transfer none): a `GdkDmabufFormats` object
*
* Since: 4.16
*/
GdkDmabufFormats *
gdk_surface_get_dmabuf_formats (GdkSurface *surface)
{
g_return_val_if_fail (GDK_IS_SURFACE (surface), NULL);
if (surface->effective_dmabuf_formats)
return surface->effective_dmabuf_formats;
else
return gdk_display_get_dmabuf_formats (surface->display);
}
+4
View File
@@ -139,6 +139,10 @@ GdkVulkanContext *
gdk_surface_create_vulkan_context(GdkSurface *surface,
GError **error);
GDK_AVAILABLE_IN_4_16
GdkDmabufFormats *
gdk_surface_get_dmabuf_formats (GdkSurface *surface);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GdkSurface, g_object_unref)
G_END_DECLS
+9
View File
@@ -105,6 +105,9 @@ struct _GdkSurface
*/
GdkSubsurface *subsurfaces_above;
GdkSubsurface *subsurfaces_below;
GdkDmabufFormats *dmabuf_formats;
GdkDmabufFormats *effective_dmabuf_formats;
};
struct _GdkSurfaceClass
@@ -355,4 +358,10 @@ gsize gdk_surface_get_n_subsurfaces (GdkSurface *surface);
GdkSubsurface * gdk_surface_get_subsurface (GdkSurface *surface,
gsize idx);
void gdk_surface_set_dmabuf_formats (GdkSurface *surface,
GdkDmabufFormats *formats);
void gdk_surface_set_effective_dmabuf_formats (GdkSurface *surface,
GdkDmabufFormats *formats);
G_END_DECLS
+1 -1
View File
@@ -563,7 +563,7 @@ gdk_texture_new_from_bytes_internal (GBytes *bytes,
{
if (gdk_is_png (bytes))
{
return gdk_load_png (bytes, NULL, error);
return gdk_load_png (bytes, error);
}
else if (gdk_is_jpeg (bytes))
{
+10 -45
View File
@@ -29,7 +29,6 @@
#include "gdkdmabuffourccprivate.h"
#include "gdkdmabuftextureprivate.h"
#include "gdkdisplayprivate.h"
#include "gdkprofilerprivate.h"
#include <glib/gi18n-lib.h>
#include <math.h>
@@ -632,7 +631,6 @@ gdk_vulkan_context_begin_frame (GdkDrawContext *draw_context,
{
GdkVulkanContext *context = GDK_VULKAN_CONTEXT (draw_context);
GdkVulkanContextPrivate *priv = gdk_vulkan_context_get_instance_private (context);
VkResult acquire_result;
guint i;
if (depth != priv->current_format)
@@ -654,29 +652,12 @@ gdk_vulkan_context_begin_frame (GdkDrawContext *draw_context,
cairo_region_union (priv->regions[i], region);
}
acquire_next_image:
acquire_result = GDK_VK_CHECK (vkAcquireNextImageKHR, gdk_vulkan_context_get_device (context),
priv->swapchain,
UINT64_MAX,
priv->draw_semaphore,
VK_NULL_HANDLE,
&priv->draw_index);
if ((acquire_result == VK_ERROR_OUT_OF_DATE_KHR) ||
(acquire_result == VK_SUBOPTIMAL_KHR))
{
GError *error = NULL;
GDK_DEBUG (VULKAN, "Recreating the swapchain");
if (!gdk_vulkan_context_check_swapchain (context, &error))
{
g_warning ("%s", error->message);
g_error_free (error);
return;
}
goto acquire_next_image;
}
GDK_VK_CHECK (vkAcquireNextImageKHR, gdk_vulkan_context_get_device (context),
priv->swapchain,
UINT64_MAX,
priv->draw_semaphore,
VK_NULL_HANDLE,
&priv->draw_index);
cairo_region_union (region, priv->regions[priv->draw_index]);
}
@@ -1129,7 +1110,6 @@ gdk_display_load_pipeline_cache (GdkDisplay *display)
static gboolean
gdk_vulkan_save_pipeline_cache (GdkDisplay *display)
{
G_GNUC_UNUSED gint64 begin_time = GDK_PROFILER_CURRENT_TIME;
GError *error = NULL;
VkDevice device;
VkPipelineCache cache;
@@ -1144,13 +1124,14 @@ gdk_vulkan_save_pipeline_cache (GdkDisplay *display)
GDK_VK_CHECK (vkGetPipelineCacheData, device, cache, &size, NULL);
if (size == 0)
return TRUE;
if (size == display->vk_pipeline_cache_size)
{
GDK_DEBUG (VULKAN, "pipeline cache size (%zu bytes) unchanged, skipping save", size);
return TRUE;
}
data = g_malloc (size);
if (GDK_VK_CHECK (vkGetPipelineCacheData, device, cache, &size, data) != VK_SUCCESS)
{
@@ -1170,7 +1151,7 @@ gdk_vulkan_save_pipeline_cache (GdkDisplay *display)
file = gdk_vulkan_get_pipeline_cache_file (display);
GDK_DEBUG (VULKAN, "Saving pipeline cache of size %lu to %s", size, g_file_peek_path (file));
GDK_DEBUG (VULKAN, "Saving pipeline cache to %s", g_file_peek_path (file));
if (!g_file_replace_contents (file,
data,
@@ -1185,7 +1166,7 @@ gdk_vulkan_save_pipeline_cache (GdkDisplay *display)
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_WRONG_ETAG))
{
VkPipelineCache new_cache;
GDK_DEBUG (VULKAN, "Pipeline cache file modified, merging into current");
new_cache = gdk_display_load_pipeline_cache (display);
if (new_cache)
@@ -1212,15 +1193,10 @@ gdk_vulkan_save_pipeline_cache (GdkDisplay *display)
return FALSE;
}
gdk_profiler_end_markf (begin_time,
"Save Vulkan pipeline cache", "%s size %lu",
g_file_peek_path (file), size);
g_object_unref (file);
g_free (data);
g_free (display->vk_pipeline_cache_etag);
display->vk_pipeline_cache_etag = etag;
display->vk_pipeline_cache_size = size;
return TRUE;
}
@@ -1260,11 +1236,6 @@ gdk_display_create_pipeline_cache (GdkDisplay *display)
},
NULL,
&display->vk_pipeline_cache);
GDK_DEBUG (VULKAN, "Creating empty pipeline cache");
}
else
{
GDK_DEBUG (VULKAN, "Loading pipeline cache (%lu bytes)", display->vk_pipeline_cache_size);
}
}
@@ -1374,7 +1345,6 @@ static gboolean
gdk_display_create_vulkan_device (GdkDisplay *display,
GError **error)
{
G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
uint32_t i, j, k;
const char *override;
gboolean list_devices;
@@ -1583,8 +1553,6 @@ gdk_display_create_vulkan_device (GdkDisplay *display,
"Hum, what? This should not happen.")));
}
gdk_profiler_end_mark (start_time, "Create Vulkan device", NULL);
return TRUE;
}
}
@@ -1623,7 +1591,6 @@ static gboolean
gdk_display_create_vulkan_instance (GdkDisplay *display,
GError **error)
{
G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
uint32_t i;
GPtrArray *used_extensions;
GPtrArray *used_layers;
@@ -1785,8 +1752,6 @@ gdk_display_create_vulkan_instance (GdkDisplay *display,
display->vk_shader_modules = g_hash_table_new (g_str_hash, g_str_equal);
gdk_profiler_end_mark (start_time, "Create Vulkan instance", NULL);
return TRUE;
}
+3 -17
View File
@@ -127,18 +127,15 @@ png_simple_warning_callback (png_structp png,
}
/* }}} */
/* {{{ Public API */
/* {{{ Public API */
GdkTexture *
gdk_load_png (GBytes *bytes,
GHashTable *options,
GError **error)
gdk_load_png (GBytes *bytes,
GError **error)
{
png_io io;
png_struct *png = NULL;
png_info *info;
png_textp text;
int num_texts;
guint width, height;
gsize i, stride;
int depth, color_type;
@@ -300,17 +297,6 @@ gdk_load_png (GBytes *bytes,
texture = gdk_memory_texture_new (width, height, format, out_bytes, stride);
g_bytes_unref (out_bytes);
if (options && png_get_text (png, info, &text, &num_texts))
{
for (i = 0; i < num_texts; i++)
{
if (text->compression != -1)
continue;
g_hash_table_insert (options, g_strdup (text->key), g_strdup (text->text));
}
}
g_free (row_pointers);
png_destroy_read_struct (&png, &info, NULL);
-1
View File
@@ -23,7 +23,6 @@
#define PNG_SIGNATURE "\x89PNG"
GdkTexture *gdk_load_png (GBytes *bytes,
GHashTable *options,
GError **error);
GBytes *gdk_save_png (GdkTexture *texture);
+15 -1
View File
@@ -337,6 +337,16 @@ static void gdk_wayland_display_remove_output (GdkWaylandDisplay *display_wa
static void gdk_wayland_display_init_xdg_output (GdkWaylandDisplay *display_wayland);
static void gdk_wayland_display_get_xdg_output (GdkWaylandMonitor *monitor);
static void
dmabuf_formats_callback (gpointer data,
DmabufFormatsInfo *info)
{
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (data);
g_clear_pointer (&display_wayland->wayland_dmabuf_formats, gdk_dmabuf_formats_unref);
display_wayland->wayland_dmabuf_formats = gdk_dmabuf_formats_ref (info->formats);
}
static void
gdk_registry_handle_global (void *data,
struct wl_registry *registry,
@@ -370,7 +380,10 @@ gdk_registry_handle_global (void *data,
feedback = zwp_linux_dmabuf_v1_get_default_feedback (display_wayland->linux_dmabuf);
display_wayland->dmabuf_formats_info = dmabuf_formats_info_new (GDK_DISPLAY (display_wayland),
"default",
feedback);
NULL,
feedback,
dmabuf_formats_callback,
display_wayland);
_gdk_wayland_display_async_roundtrip (display_wayland);
}
else if (strcmp (interface, "xdg_wm_base") == 0)
@@ -744,6 +757,7 @@ gdk_wayland_display_dispose (GObject *object)
g_clear_pointer (&display_wayland->single_pixel_buffer, wp_single_pixel_buffer_manager_v1_destroy);
g_clear_pointer (&display_wayland->linux_dmabuf, zwp_linux_dmabuf_v1_destroy);
g_clear_pointer (&display_wayland->dmabuf_formats_info, dmabuf_formats_info_free);
g_clear_pointer (&display_wayland->wayland_dmabuf_formats, gdk_dmabuf_formats_unref);
g_clear_pointer (&display_wayland->shm, wl_shm_destroy);
g_clear_pointer (&display_wayland->wl_registry, wl_registry_destroy);
+1
View File
@@ -100,6 +100,7 @@ struct _GdkWaylandDisplay
struct wl_shm *shm;
struct zwp_linux_dmabuf_v1 *linux_dmabuf;
DmabufFormatsInfo *dmabuf_formats_info;
GdkDmabufFormats *wayland_dmabuf_formats;
struct xdg_wm_base *xdg_wm_base;
struct zxdg_shell_v6 *zxdg_shell_v6;
struct gtk_shell1 *gtk_shell;
+17 -1
View File
@@ -54,24 +54,40 @@ typedef struct
typedef struct DmabufFormatsInfo DmabufFormatsInfo;
typedef void (* DmabufFormatsUpdateCallback) (gpointer data,
DmabufFormatsInfo *formats);
struct DmabufFormatsInfo
{
GdkDisplay *display;
char *name;
struct zwp_linux_dmabuf_feedback_v1 *feedback;
DmabufFormatsUpdateCallback callback;
gpointer data;
gsize n_dmabuf_formats;
DmabufFormat *dmabuf_format_table;
DmabufFormats *dmabuf_formats;
DmabufFormats *pending_dmabuf_formats;
DmabufTranche *pending_tranche;
GdkDmabufFormats *egl_formats;
GdkDmabufFormats *formats;
};
DmabufFormatsInfo * dmabuf_formats_info_new (GdkDisplay *display,
const char *name,
struct zwp_linux_dmabuf_feedback_v1 *feedback);
GdkDmabufFormats *egl_formats,
struct zwp_linux_dmabuf_feedback_v1 *feedback,
DmabufFormatsUpdateCallback callback,
gpointer data);
void dmabuf_formats_info_free (DmabufFormatsInfo *info);
void dmabuf_formats_info_set_egl_formats
(DmabufFormatsInfo *info,
GdkDmabufFormats *egl_formats);
G_END_DECLS
+215 -39
View File
@@ -1,6 +1,7 @@
#include "config.h"
#include "gdkdmabuf-wayland-private.h"
#include "gdkwaylanddmabufformats.h"
#include "gdkdebugprivate.h"
#include "gdkdmabufformatsprivate.h"
@@ -45,44 +46,116 @@ dmabuf_formats_free (DmabufFormats *formats)
g_free (formats);
}
static void
update_dmabuf_formats (DmabufFormatsInfo *info)
static gboolean
is_in_tranche (GdkDmabufFormats *formats,
gsize idx,
guint32 fourcc,
guint64 modifier)
{
DmabufFormats *formats = info->dmabuf_formats;
gsize end;
guint32 f;
guint64 m;
GDK_DISPLAY_DEBUG (info->display, MISC,
"dmabuf format table (%lu entries)", info->n_dmabuf_formats);
GDK_DISPLAY_DEBUG (info->display, MISC,
"dmabuf main device: %u %u",
major (formats->main_device),
minor (formats->main_device));
for (gsize i = 0; i < formats->tranches->len; i++)
end = gdk_dmabuf_formats_next_priority (formats, idx);
for (gsize i = idx; i < end; i++)
{
DmabufTranche *tranche = g_ptr_array_index (formats->tranches, i);
gdk_dmabuf_formats_get_format (formats, i, &f, &m);
if (f == fourcc && m == modifier)
return TRUE;
}
GDK_DISPLAY_DEBUG (info->display, MISC,
"dmabuf tranche target device: %u %u",
major (tranche->target_device),
minor (tranche->target_device));
return FALSE;
}
GDK_DISPLAY_DEBUG (info->display, MISC,
"dmabuf%s tranche (%lu entries):",
tranche->flags & ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SCANOUT ? " scanout" : "",
tranche->n_formats);
static void
gdk_wayland_dmabuf_formats_dump (GdkDmabufFormats *formats,
const char *name)
{
gdk_debug_message ("Wayland %s dmabuf formats: (%lu entries)", name, formats->n_formats);
gdk_debug_message ("Main device: %u %u",
major (formats->device),
minor (formats->device));
for (gsize j = 0; j < tranche->n_formats; j++)
gsize i = 0;
while (i < formats->n_formats)
{
GdkDmabufFormat *format = &formats->formats[i];
gsize next_priority = format->next_priority;
if (i > 0)
gdk_debug_message ("------");
gdk_debug_message ("Tranche target device: %u %u",
major (format->device),
minor (format->device));
if (format->flags & ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SCANOUT)
gdk_debug_message ("Tranche is scanout");
gdk_debug_message ("Tranche formats (%lu entries)", next_priority - i);
for (; i < next_priority; i++)
{
GDK_DISPLAY_DEBUG (info->display, MISC,
" %.4s:%#" G_GINT64_MODIFIER "x",
(char *) &(tranche->formats[j].fourcc),
tranche->formats[j].modifier);
format = &formats->formats[i];
gdk_debug_message (" %.4s:%#" G_GINT64_MODIFIER "x", (char *) &format->fourcc, format->modifier);
}
}
}
static void
linux_dmabuf_done (void *data,
update_dmabuf_formats (DmabufFormatsInfo *info)
{
GdkDmabufFormatsBuilder *builder;
GdkDmabufFormats *egl_formats = info->egl_formats;
DmabufFormats *formats = info->dmabuf_formats;
builder = gdk_dmabuf_formats_builder_new ();
for (gsize i = 0; i < formats->tranches->len; i++)
{
DmabufTranche *tranche = g_ptr_array_index (formats->tranches, i);
if (egl_formats)
{
for (gsize k = 0; k < gdk_dmabuf_formats_get_n_formats (egl_formats); k = gdk_dmabuf_formats_next_priority (egl_formats, k))
{
for (gsize j = 0; j < tranche->n_formats; j++)
{
if (is_in_tranche (egl_formats, k,
tranche->formats[j].fourcc,
tranche->formats[j].modifier))
gdk_dmabuf_formats_builder_add_format_for_device (builder,
tranche->formats[j].fourcc,
tranche->flags,
tranche->formats[j].modifier,
tranche->target_device);
}
gdk_dmabuf_formats_builder_next_priority (builder);
}
}
else
{
for (gsize j = 0; j < tranche->n_formats; j++)
{
gdk_dmabuf_formats_builder_add_format_for_device (builder,
tranche->formats[j].fourcc,
tranche->flags,
tranche->formats[j].modifier,
tranche->target_device);
}
gdk_dmabuf_formats_builder_next_priority (builder);
}
}
g_clear_pointer (&info->formats, gdk_dmabuf_formats_unref);
info->formats = gdk_dmabuf_formats_builder_free_to_formats_for_device (builder, formats->main_device);
if (GDK_DISPLAY_DEBUG_CHECK (info->display, DMABUF))
gdk_wayland_dmabuf_formats_dump (info->formats, info->name);
info->callback (info->data, info);
}
static void
linux_dmabuf_done (void *data,
struct zwp_linux_dmabuf_feedback_v1 *feedback)
{
DmabufFormatsInfo *info = data;
@@ -96,10 +169,10 @@ linux_dmabuf_done (void *data,
}
static void
linux_dmabuf_format_table (void *data,
linux_dmabuf_format_table (void *data,
struct zwp_linux_dmabuf_feedback_v1 *feedback,
int32_t fd,
uint32_t size)
int32_t fd,
uint32_t size)
{
DmabufFormatsInfo *info = data;
@@ -111,9 +184,9 @@ linux_dmabuf_format_table (void *data,
}
static void
linux_dmabuf_main_device (void *data,
linux_dmabuf_main_device (void *data,
struct zwp_linux_dmabuf_feedback_v1 *feedback,
struct wl_array *device)
struct wl_array *device)
{
DmabufFormatsInfo *info = data;
dev_t dev;
@@ -127,7 +200,7 @@ linux_dmabuf_main_device (void *data,
}
static void
linux_dmabuf_tranche_done (void *data,
linux_dmabuf_tranche_done (void *data,
struct zwp_linux_dmabuf_feedback_v1 *feedback)
{
DmabufFormatsInfo *info = data;
@@ -139,9 +212,9 @@ linux_dmabuf_tranche_done (void *data,
}
static void
linux_dmabuf_tranche_target_device (void *data,
linux_dmabuf_tranche_target_device (void *data,
struct zwp_linux_dmabuf_feedback_v1 *feedback,
struct wl_array *device)
struct wl_array *device)
{
DmabufFormatsInfo *info = data;
dev_t dev;
@@ -158,9 +231,9 @@ linux_dmabuf_tranche_target_device (void *data,
}
static void
linux_dmabuf_tranche_formats (void *data,
linux_dmabuf_tranche_formats (void *data,
struct zwp_linux_dmabuf_feedback_v1 *feedback,
struct wl_array *indices)
struct wl_array *indices)
{
DmabufFormatsInfo *info = data;
DmabufTranche *tranche;
@@ -181,9 +254,9 @@ linux_dmabuf_tranche_formats (void *data,
}
static void
linux_dmabuf_tranche_flags (void *data,
linux_dmabuf_tranche_flags (void *data,
struct zwp_linux_dmabuf_feedback_v1 *feedback,
uint32_t flags)
uint32_t flags)
{
DmabufFormatsInfo *info = data;
DmabufTranche *tranche;
@@ -206,7 +279,10 @@ static const struct zwp_linux_dmabuf_feedback_v1_listener feedback_listener = {
DmabufFormatsInfo *
dmabuf_formats_info_new (GdkDisplay *display,
const char *name,
struct zwp_linux_dmabuf_feedback_v1 *feedback)
GdkDmabufFormats *egl_formats,
struct zwp_linux_dmabuf_feedback_v1 *feedback,
DmabufFormatsUpdateCallback callback,
gpointer data)
{
DmabufFormatsInfo *info;
@@ -214,11 +290,21 @@ dmabuf_formats_info_new (GdkDisplay *display,
info->display = display;
info->name = g_strdup (name);
if (egl_formats)
{
info->egl_formats = gdk_dmabuf_formats_ref (egl_formats);
info->formats = gdk_dmabuf_formats_ref (egl_formats);
}
info->feedback = feedback;
info->callback = callback;
info->data = data;
if (info->feedback)
zwp_linux_dmabuf_feedback_v1_add_listener (info->feedback,
&feedback_listener, info);
else
info->callback (info->data, info);
return info;
}
@@ -227,6 +313,8 @@ void
dmabuf_formats_info_free (DmabufFormatsInfo *info)
{
g_free (info->name);
g_clear_pointer (&info->formats, gdk_dmabuf_formats_unref);
g_clear_pointer (&info->egl_formats, gdk_dmabuf_formats_unref);
g_clear_pointer (&info->feedback, zwp_linux_dmabuf_feedback_v1_destroy);
if (info->dmabuf_format_table)
{
@@ -239,3 +327,91 @@ dmabuf_formats_info_free (DmabufFormatsInfo *info)
g_free (info);
}
void
dmabuf_formats_info_set_egl_formats (DmabufFormatsInfo *info,
GdkDmabufFormats *egl_formats)
{
if (info->egl_formats)
return;
info->egl_formats = gdk_dmabuf_formats_ref (egl_formats);
if (info->dmabuf_formats)
update_dmabuf_formats (info);
}
/**
* gdk_wayland_dmabuf_formats_get_main_device:
* @formats: a `GdkDmabufFormats`
*
* Returns the DRM device that the compositor uses for compositing.
*
* If this information isn't available (e.g. because @formats wasn't
* obtained from the compositor), then 0 is returned.
*
* Returns: the main DRM device that the compositor prefers
*
* Since: 4.16
*/
dev_t
gdk_wayland_dmabuf_formats_get_main_device (GdkDmabufFormats *formats)
{
return formats->device;
}
/**
* gdk_wayland_dmabuf_formats_get_target_device:
* @formats: a `GdkDmabufFormats`
* @idx: the index of the format to return
*
* Returns the target DRM device that should be used for creating buffers
* with this format.
*
* If this information isn't available (e.g. because @formats wasn't
* obtained from the compositor), then 0 is returned.
*
* Returns: the target DRM device for this format
*
* Since: 4.16
*/
dev_t
gdk_wayland_dmabuf_formats_get_target_device (GdkDmabufFormats *formats,
gsize idx)
{
GdkDmabufFormat *format;
g_return_val_if_fail (idx < formats->n_formats, 0);
format = &formats->formats[idx];
return format->device;
}
/**
* gdk_wayland_dmabuf_formats_is_scanout:
* @formats: a `GdkDmabufFormats`
* @idx: the index of the format to return
*
* Returns whether the compositor may use buffers with this
* format for scanout.
*
* If this information isn't available (e.g. because @formats wasn't
* obtained from the compositor), then `FALSE` is returned.
*
* Returns: whether the format will be used for scanout
*
* Since: 4.16
*/
gboolean
gdk_wayland_dmabuf_formats_is_scanout (GdkDmabufFormats *formats,
gsize idx)
{
GdkDmabufFormat *format;
g_return_val_if_fail (idx < formats->n_formats, FALSE);
format = &formats->formats[idx];
return (format->flags & ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SCANOUT) != 0;
}
+4 -1
View File
@@ -1,6 +1,8 @@
#pragma once
#include "gdk/gdkdmabufformats.h"
#include "gdksubsurfaceprivate.h"
#include "gdkdmabuf-wayland-private.h"
#include "wayland-client-protocol.h"
@@ -35,6 +37,8 @@ struct _GdkWaylandSubsurface
struct wp_viewport *bg_viewport;
cairo_rectangle_int_t bg_rect;
gboolean bg_attached;
DmabufFormatsInfo *formats;
};
struct _GdkWaylandSubsurfaceClass
@@ -48,4 +52,3 @@ void gdk_wayland_subsurface_request_frame (GdkSubsurface *subsurface);
void gdk_wayland_subsurface_clear_frame_callback (GdkSubsurface *subsurface);
GdkSubsurface * gdk_wayland_surface_create_subsurface (GdkSurface *surface);
+34 -1
View File
@@ -27,6 +27,7 @@
#include "gdksubsurfaceprivate.h"
#include "gdkdebugprivate.h"
#include "gsk/gskrectprivate.h"
#include "gdkprivate.h"
#include "linux-dmabuf-unstable-v1-client-protocol.h"
@@ -51,6 +52,7 @@ gdk_wayland_subsurface_finalize (GObject *object)
g_clear_pointer (&self->bg_viewport, wp_viewport_destroy);
g_clear_pointer (&self->bg_subsurface, wl_subsurface_destroy);
g_clear_pointer (&self->bg_surface, wl_surface_destroy);
g_clear_pointer (&self->formats, dmabuf_formats_info_free);
G_OBJECT_CLASS (gdk_wayland_subsurface_parent_class)->finalize (object);
}
@@ -790,6 +792,15 @@ gdk_wayland_subsurface_clear_frame_callback (GdkSubsurface *sub)
g_clear_pointer (&self->frame_callback, wl_callback_destroy);
}
static void
dmabuf_formats_callback (gpointer data,
DmabufFormatsInfo *info)
{
GdkSubsurface *sub = data;
gdk_subsurface_set_dmabuf_formats (sub, info->formats);
}
GdkSubsurface *
gdk_wayland_surface_create_subsurface (GdkSurface *surface)
{
@@ -798,6 +809,8 @@ gdk_wayland_surface_create_subsurface (GdkSurface *surface)
GdkWaylandDisplay *disp = GDK_WAYLAND_DISPLAY (display);
GdkWaylandSubsurface *sub;
struct wl_region *region;
struct zwp_linux_dmabuf_feedback_v1 *feedback;
char *name;
if (disp->subcompositor == NULL || disp->viewporter == NULL)
{
@@ -825,8 +838,28 @@ gdk_wayland_surface_create_subsurface (GdkSurface *surface)
wl_region_add (sub->opaque_region, 0, 0, G_MAXINT, G_MAXINT);
wl_surface_set_opaque_region (sub->surface, sub->opaque_region);
gdk_display_init_dmabuf (display);
if (disp->linux_dmabuf)
{
dmabuf_formats_info_set_egl_formats (disp->dmabuf_formats_info, display->dmabuf_formats);
feedback = zwp_linux_dmabuf_v1_get_surface_feedback (disp->linux_dmabuf, sub->surface);
}
else
{
feedback = NULL;
}
name = g_strdup_printf ("subsurface %p", sub);
sub->formats = dmabuf_formats_info_new (display,
name,
display->dmabuf_formats,
feedback,
dmabuf_formats_callback,
sub);
g_free (name);
GDK_DISPLAY_DEBUG (display, OFFLOAD, "Subsurface %p of surface %p created", sub, impl);
return GDK_SUBSURFACE (sub);
}
+2
View File
@@ -89,6 +89,8 @@ struct _GdkWaylandSurface
uint32_t last_configure_serial;
int state_freeze_count;
DmabufFormatsInfo *formats;
};
typedef struct _GdkWaylandSurfaceClass GdkWaylandSurfaceClass;
+34
View File
@@ -936,6 +936,15 @@ gdk_wayland_surface_create_wl_surface (GdkSurface *surface)
self->display_server.wl_surface = wl_surface;
}
static void
dmabuf_formats_callback (gpointer data,
DmabufFormatsInfo *info)
{
GdkSurface *surface = data;
gdk_surface_set_dmabuf_formats (surface, info->formats);
}
static void
gdk_wayland_surface_constructed (GObject *object)
{
@@ -944,6 +953,8 @@ gdk_wayland_surface_constructed (GObject *object)
GdkDisplay *display = gdk_surface_get_display (surface);
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
GdkFrameClock *frame_clock = gdk_surface_get_frame_clock (surface);
struct zwp_linux_dmabuf_feedback_v1 *feedback;
char *name;
self->event_queue = wl_display_create_queue (display_wayland->wl_display);
display_wayland->event_queues = g_list_prepend (display_wayland->event_queues,
@@ -969,6 +980,29 @@ gdk_wayland_surface_constructed (GObject *object)
gdk_wayland_surface_create_wl_surface (surface);
gdk_display_init_dmabuf (display);
if (display_wayland->linux_dmabuf)
{
dmabuf_formats_info_set_egl_formats (display_wayland->dmabuf_formats_info,
display->dmabuf_formats);
feedback = zwp_linux_dmabuf_v1_get_surface_feedback (display_wayland->linux_dmabuf,
self->display_server.wl_surface);
}
else
{
feedback = NULL;
}
name = g_strdup_printf ("surface %p", surface);
self->formats = dmabuf_formats_info_new (display,
name,
display->dmabuf_formats,
feedback,
dmabuf_formats_callback,
surface);
g_free (name);
g_signal_connect (frame_clock, "before-paint", G_CALLBACK (on_frame_clock_before_paint), surface);
g_signal_connect (frame_clock, "after-paint", G_CALLBACK (on_frame_clock_after_paint), surface);
+1
View File
@@ -30,6 +30,7 @@
#include <gdk/wayland/gdkwaylanddevice.h>
#include <gdk/wayland/gdkwaylanddisplay.h>
#include <gdk/wayland/gdkwaylanddmabufformats.h>
#include <gdk/wayland/gdkwaylandglcontext.h>
#include <gdk/wayland/gdkwaylandmonitor.h>
#include <gdk/wayland/gdkwaylandpopup.h>
+40
View File
@@ -0,0 +1,40 @@
/* gdkwaylanddmabufformats.h
*
* Copyright 2023 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#if !defined (__GDKWAYLAND_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gdk/wayland/gdkwayland.h> can be included directly."
#endif
#include <gdk/gdkdmabufformats.h>
G_BEGIN_DECLS
GDK_AVAILABLE_IN_4_16
dev_t gdk_wayland_dmabuf_formats_get_main_device (GdkDmabufFormats *formats);
GDK_AVAILABLE_IN_4_16
dev_t gdk_wayland_dmabuf_formats_get_target_device (GdkDmabufFormats *formats,
gsize idx);
GDK_AVAILABLE_IN_4_16
gboolean gdk_wayland_dmabuf_formats_is_scanout (GdkDmabufFormats *formats,
gsize idx);
G_END_DECLS
+1
View File
@@ -30,6 +30,7 @@ gdk_wayland_sources = files([
gdk_wayland_public_headers = files([
'gdkwaylanddevice.h',
'gdkwaylanddisplay.h',
'gdkwaylanddmabufformats.h',
'gdkwaylandglcontext.h',
'gdkwaylandmonitor.h',
'gdkwaylandpopup.h',
-2
View File
@@ -908,9 +908,7 @@ _gdk_win32_create_hicon_for_texture (GdkTexture *texture,
width = cairo_image_surface_get_width (surface);
height = cairo_image_surface_get_height (surface);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, width, height);
G_GNUC_END_IGNORE_DEPRECATIONS
icon = pixbuf_to_hicon (pixbuf, is_icon, x, y);
+1 -1
View File
@@ -267,7 +267,7 @@ create_dummy_gl_window (void)
{
WNDCLASS wclass = { 0, };
ATOM klass;
HWND hwnd = NULL;
HWND hwnd;
wclass.lpszClassName = "GdkGLDummyWindow";
wclass.lpfnWndProc = DefWindowProc;
+1
View File
@@ -38,6 +38,7 @@ gdk_win32_vulkan_context_create_surface (GdkVulkanContext *context,
{
GdkSurface *window = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (context));
GdkDisplay *display = gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context));
GdkWin32Surface *win32_surface = GDK_WIN32_SURFACE (window);
VkWin32SurfaceCreateInfoKHR info;
VkResult result;
-6
View File
@@ -68,11 +68,6 @@ gdk_x11_vulkan_context_end_frame (GdkDrawContext *context,
GDK_DRAW_CONTEXT_CLASS (gdk_x11_vulkan_context_parent_class)->end_frame (context, painted);
}
static void
gdk_x11_vulkan_context_empty_frame (GdkDrawContext *draw_context)
{
}
static void
gdk_x11_vulkan_context_class_init (GdkX11VulkanContextClass *klass)
{
@@ -80,7 +75,6 @@ gdk_x11_vulkan_context_class_init (GdkX11VulkanContextClass *klass)
GdkDrawContextClass *draw_context_class = GDK_DRAW_CONTEXT_CLASS (klass);
draw_context_class->end_frame = gdk_x11_vulkan_context_end_frame;
draw_context_class->empty_frame = gdk_x11_vulkan_context_empty_frame;
context_class->create_surface = gdk_x11_vulkan_context_create_surface;
}
+1 -1
View File
@@ -19,7 +19,7 @@ static gint64 profiler_buffer_uploads;
static void
gsk_gpu_buffer_class_init (GskGpuBufferClass *klass)
{
profiler_buffer_uploads_id = gdk_profiler_define_int_counter ("buffer-uploads", "Number of bytes uploaded to GPU");
profiler_buffer_uploads_id = gdk_profiler_define_int_counter ("ngl-buffer-uploads", "Number of bytes uploaded to GPU");
}
static void
+1 -1
View File
@@ -546,7 +546,7 @@ gsk_gpu_device_maybe_gc (GskGpuDevice *self)
if (priv->cache_timeout == 0 || dead_texture_pixels > 1000000)
{
GSK_DEBUG (GLYPH_CACHE, "Pre-frame GC (%" G_GSIZE_FORMAT " dead pixels)", dead_texture_pixels);
GSK_DEBUG (GLYPH_CACHE, "Pre-frame GC (%lu dead pixels)", dead_texture_pixels);
gsk_gpu_device_gc (self, g_get_monotonic_time ());
}
}
+2 -2
View File
@@ -345,8 +345,8 @@ gsk_gpu_node_processor_init_draw (GskGpuNodeProcessor *self,
area.x = 0;
area.y = 0;
area.width = MAX (1, ceilf (graphene_vec2_get_x (scale) * viewport->size.width - EPSILON));
area.height = MAX (1, ceilf (graphene_vec2_get_y (scale) * viewport->size.height - EPSILON));
area.width = ceilf (graphene_vec2_get_x (scale) * viewport->size.width - EPSILON);
area.height = ceilf (graphene_vec2_get_y (scale) * viewport->size.height - EPSILON);
image = gsk_gpu_device_create_offscreen_image (gsk_gpu_frame_get_device (frame),
FALSE,
+3 -22
View File
@@ -787,7 +787,7 @@ gsk_vulkan_device_get_vk_conversion (GskVulkanDevice *self,
.sType = VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_CREATE_INFO,
.format = vk_format,
.ycbcrModel = VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_601,
.ycbcrRange = VK_SAMPLER_YCBCR_RANGE_ITU_NARROW,
.ycbcrRange = VK_SAMPLER_YCBCR_RANGE_ITU_FULL,
.components = (VkComponentMapping) {
VK_COMPONENT_SWIZZLE_IDENTITY,
VK_COMPONENT_SWIZZLE_IDENTITY,
@@ -951,8 +951,6 @@ gsk_vulkan_device_get_vk_pipeline (GskVulkanDevice *self,
const char *version_string;
char *vertex_shader_name, *fragment_shader_name;
G_GNUC_UNUSED gint64 begin_time = GDK_PROFILER_CURRENT_TIME;
const char *clip_name[] = { "NONE", "RECT", "ROUNDED" };
const char *blend_name[] = { "OVER", "ADD", "CLEAR" };
cache_key = (PipelineCacheKey) {
.op_class = op_class,
@@ -1130,25 +1128,8 @@ gsk_vulkan_device_get_vk_pipeline (GskVulkanDevice *self,
&pipeline);
gdk_profiler_end_markf (begin_time,
"Create Vulkan pipeline", "%s version=%s variation=%u clip=%s blend=%s format=%u",
op_class->shader_name,
version_string + 1,
variation,
clip_name[clip],
blend_name[blend],
format);
GSK_DEBUG (SHADERS,
"Create Vulkan pipeline (%s %s, %u/%s/%s/%u) for layout (%" G_GSIZE_FORMAT "/%" G_GSIZE_FORMAT "/%" G_GSIZE_FORMAT ")",
op_class->shader_name,
version_string + 1,
variation,
clip_name[clip],
blend_name[blend],
format,
layout->setup.n_buffers,
layout->setup.n_samplers,
layout->setup.n_immutable_samplers);
"Create Vulkan pipeline", "frag=%s vert=%s",
fragment_shader_name, vertex_shader_name);
g_free (fragment_shader_name);
g_free (vertex_shader_name);
+3 -3
View File
@@ -1143,10 +1143,10 @@ gsk_path_builder_rel_conic_to (GskPathBuilder *self,
* @x2: x coordinate of second control point
* @y2: y coordinate of second control point
*
* Adds an elliptical arc from the current point to @x2, @y2
* Adds an elliptical arc from the current point to @x3, @y3
* with @x1, @y1 determining the tangent directions.
*
* After this, @x2, @y2 will be the new current point.
* After this, @x3, @y3 will be the new current point.
*
* Note: Two points and their tangents do not determine
* a unique ellipse, so GSK just picks one. If you need more
@@ -1180,7 +1180,7 @@ gsk_path_builder_arc_to (GskPathBuilder *self,
* @x2: x coordinate of second control point
* @y2: y coordinate of second control point
*
* Adds an elliptical arc from the current point to @x2, @y2
* Adds an elliptical arc from the current point to @x3, @y3
* with @x1, @y1 determining the tangent directions.
*
* All coordinates are given relative to the current point.
-2
View File
@@ -28,9 +28,7 @@ G_BEGIN_DECLS
typedef enum
{
/* path has only lines */
GSK_PATH_FLAT,
/* all contours are closed */
GSK_PATH_CLOSED
} GskPathFlags;
+80 -85
View File
@@ -428,6 +428,21 @@ gsk_renderer_render_texture (GskRenderer *renderer,
texture = GSK_RENDERER_GET_CLASS (renderer)->render_texture (renderer, root, viewport);
if (GSK_RENDERER_DEBUG_CHECK (renderer, RENDERER))
{
GString *buf = g_string_new ("*** Texture stats ***\n\n");
gsk_profiler_append_counters (priv->profiler, buf);
g_string_append_c (buf, '\n');
gsk_profiler_append_timers (priv->profiler, buf);
g_string_append_c (buf, '\n');
g_print ("%s\n***\n\n", buf->str);
g_string_free (buf, TRUE);
}
return texture;
}
@@ -468,6 +483,12 @@ gsk_renderer_render (GskRenderer *renderer,
if (priv->surface == NULL)
return;
/* Offloading can change subsurface stacking, which may trigger
* surface property changes. We don't want them to take effect
* during frame processing.
*/
g_object_freeze_notify (G_OBJECT (priv->surface));
renderer_class = GSK_RENDERER_GET_CLASS (renderer);
clip = cairo_region_copy (region);
@@ -494,10 +515,27 @@ gsk_renderer_render (GskRenderer *renderer,
renderer_class->render (renderer, root, clip);
if (GSK_RENDERER_DEBUG_CHECK (renderer, RENDERER))
{
GString *buf = g_string_new ("*** Frame stats ***\n\n");
gsk_profiler_append_counters (priv->profiler, buf);
g_string_append_c (buf, '\n');
gsk_profiler_append_timers (priv->profiler, buf);
g_string_append_c (buf, '\n');
g_print ("%s\n***\n\n", buf->str);
g_string_free (buf, TRUE);
}
g_clear_pointer (&priv->prev_node, gsk_render_node_unref);
cairo_region_destroy (clip);
g_clear_pointer (&offload, gsk_offload_free);
priv->prev_node = gsk_render_node_ref (root);
g_object_thaw_notify (G_OBJECT (priv->surface));
}
/*< private >
@@ -579,17 +617,12 @@ get_renderer_for_display (GdkSurface *surface)
static GType
get_renderer_for_env_var (GdkSurface *surface)
{
static GType env_var_type = G_TYPE_INVALID;
static GType env_var_type = G_TYPE_NONE;
if (env_var_type == G_TYPE_INVALID)
if (env_var_type == G_TYPE_NONE)
{
const char *renderer_name = g_getenv ("GSK_RENDERER");
env_var_type = get_renderer_for_name (renderer_name);
if (env_var_type != G_TYPE_INVALID)
GSK_DEBUG (RENDERER,
"Environment variable GSK_RENDERER=%s set, trying %s",
renderer_name,
g_type_name (env_var_type));
}
return env_var_type;
@@ -607,115 +640,83 @@ get_renderer_for_backend (GdkSurface *surface)
}
static gboolean
gl_supported_platform (GdkSurface *surface,
GType renderer_type,
gboolean as_fallback)
gl_software_rendering (GdkSurface *surface)
{
GdkDisplay *display = gdk_surface_get_display (surface);
GdkGLContext *context;
GError *error = NULL;
if (!gdk_display_prepare_gl (display, &error))
{
if (!as_fallback)
GSK_DEBUG (RENDERER, "Not using GL: %s", error->message);
g_clear_error (&error);
return FALSE;
}
if (as_fallback)
return TRUE;
if (!gdk_display_prepare_gl (display, NULL))
return G_TYPE_INVALID;
context = gdk_display_get_gl_context (display);
gdk_gl_context_make_current (context);
if (strstr ((const char *) glGetString (GL_RENDERER), "llvmpipe") != NULL)
{
GSK_DEBUG (RENDERER, "Not using '%s': renderer is llvmpipe", g_type_name (renderer_type));
return FALSE;
}
return TRUE;
return strstr ((const char *) glGetString (GL_RENDERER), "llvmpipe") != NULL;
}
static GType
get_renderer_for_gl (GdkSurface *surface)
{
if (!gl_supported_platform (surface, gsk_ngl_renderer_get_type (), FALSE))
if (gl_software_rendering (surface))
return G_TYPE_INVALID;
return gsk_ngl_renderer_get_type ();
}
static GType
get_renderer_for_gl_fallback (GdkSurface *surface)
{
if (!gl_supported_platform (surface, GSK_TYPE_GL_RENDERER, TRUE))
return G_TYPE_INVALID;
return GSK_TYPE_GL_RENDERER;
}
#ifdef GDK_RENDERING_VULKAN
static gboolean
vulkan_supported_platform (GdkSurface *surface,
GType renderer_type,
gboolean as_fallback)
vulkan_software_rendering (GdkSurface *surface)
{
GdkDisplay *display = gdk_surface_get_display (surface);
VkPhysicalDeviceProperties props;
GError *error = NULL;
if (!gdk_display_init_vulkan (display, &error))
{
if (!as_fallback)
GSK_DEBUG (RENDERER, "Not using Vulkan: %s", error->message);
g_clear_error (&error);
return FALSE;
}
if (!gdk_display_init_vulkan (display, NULL))
return G_TYPE_INVALID;
vkGetPhysicalDeviceProperties (display->vk_physical_device, &props);
if (props.deviceType == VK_PHYSICAL_DEVICE_TYPE_CPU)
{
if (!as_fallback)
GSK_DEBUG (RENDERER,
"Not using '%s': device is CPU",
g_type_name (renderer_type));
return FALSE;
}
return props.deviceType == VK_PHYSICAL_DEVICE_TYPE_CPU;
}
#endif
if (as_fallback)
return TRUE;
static GType
get_renderer_for_vulkan (GdkSurface *surface)
{
#ifdef GDK_RENDERING_VULKAN
if (vulkan_software_rendering (surface))
return G_TYPE_INVALID;
return GSK_TYPE_VULKAN_RENDERER;
#else
return G_TYPE_INVALID;
#endif
}
static gboolean
vulkan_friendly_platform (GdkSurface *surface)
{
#ifdef GDK_WINDOWING_WAYLAND
if (GDK_IS_WAYLAND_DISPLAY (gdk_surface_get_display (surface)))
return TRUE;
#endif
GSK_DEBUG (RENDERER, "Not using '%s': platform is not Wayland", g_type_name (renderer_type));
return FALSE;
}
static GType
get_renderer_for_vulkan (GdkSurface *surface)
get_renderer_for_vulkan_friendly_platform (GdkSurface *surface)
{
if (!vulkan_supported_platform (surface, GSK_TYPE_VULKAN_RENDERER, FALSE))
return G_TYPE_INVALID;
if (vulkan_friendly_platform (surface))
return get_renderer_for_vulkan (surface);
return GSK_TYPE_VULKAN_RENDERER;
return G_TYPE_INVALID;
}
static GType
get_renderer_for_vulkan_fallback (GdkSurface *surface)
get_renderer_for_gles2 (GdkSurface *surface)
{
if (!vulkan_supported_platform (surface, GSK_TYPE_VULKAN_RENDERER, TRUE))
return G_TYPE_INVALID;
return GSK_TYPE_VULKAN_RENDERER;
return GSK_TYPE_GL_RENDERER;
}
#endif
static GType
get_renderer_fallback (GdkSurface *surface)
@@ -729,14 +730,10 @@ static struct {
{ get_renderer_for_display },
{ get_renderer_for_env_var },
{ get_renderer_for_backend },
#ifdef GDK_RENDERING_VULKAN
{ get_renderer_for_vulkan },
#endif
{ get_renderer_for_vulkan_friendly_platform },
{ get_renderer_for_gl },
#ifdef GDK_RENDERING_VULKAN
{ get_renderer_for_vulkan_fallback },
#endif
{ get_renderer_for_gl_fallback },
{ get_renderer_for_vulkan },
{ get_renderer_for_gles2 },
{ get_renderer_fallback },
};
@@ -774,19 +771,17 @@ gsk_renderer_new_for_surface (GdkSurface *surface)
if (gsk_renderer_realize (renderer, surface, &error))
{
GSK_DEBUG (RENDERER,
"Using renderer '%s' for surface '%s'",
G_OBJECT_TYPE_NAME (renderer),
G_OBJECT_TYPE_NAME (surface));
GSK_RENDERER_DEBUG (renderer, RENDERER,
"Using renderer of type '%s' for surface '%s'",
G_OBJECT_TYPE_NAME (renderer),
G_OBJECT_TYPE_NAME (surface));
return renderer;
}
GSK_DEBUG (RENDERER,
"Failed to realize renderer '%s' for surface '%s': %s",
g_message ("Failed to realize renderer of type '%s' for surface '%s': %s\n",
G_OBJECT_TYPE_NAME (renderer),
G_OBJECT_TYPE_NAME (surface),
error->message);
g_object_unref (renderer);
g_clear_error (&error);
}
+6 -35
View File
@@ -2312,25 +2312,6 @@ parse_antialias (GtkCssParser *parser,
return TRUE;
}
static gboolean
parse_hint_metrics (GtkCssParser *parser,
Context *context,
gpointer out)
{
if (!parse_enum (parser, CAIRO_GOBJECT_TYPE_HINT_METRICS, out))
return FALSE;
if (*(cairo_hint_metrics_t *) out != CAIRO_HINT_METRICS_OFF &&
*(cairo_hint_metrics_t *) out != CAIRO_HINT_METRICS_ON)
{
gtk_css_parser_error_value (parser, "Unsupported value for enum \"%s\"",
g_type_name (CAIRO_GOBJECT_TYPE_HINT_METRICS));
return FALSE;
}
return TRUE;
}
static GskRenderNode *
parse_text_node (GtkCssParser *parser,
Context *context)
@@ -2341,7 +2322,6 @@ parse_text_node (GtkCssParser *parser,
PangoGlyphString *glyphs = NULL;
cairo_hint_style_t hint_style = CAIRO_HINT_STYLE_SLIGHT;
cairo_antialias_t antialias = CAIRO_ANTIALIAS_GRAY;
cairo_hint_metrics_t hint_metrics = CAIRO_HINT_METRICS_OFF;
PangoFont *hinted;
const Declaration declarations[] = {
{ "font", parse_font, clear_font, &font },
@@ -2350,7 +2330,6 @@ parse_text_node (GtkCssParser *parser,
{ "glyphs", parse_glyphs, clear_glyphs, &glyphs },
{ "hint-style", parse_hint_style, NULL, &hint_style },
{ "antialias", parse_antialias, NULL, &antialias },
{ "hint-metrics", parse_hint_metrics, NULL, &hint_metrics },
};
GskRenderNode *result;
@@ -2362,7 +2341,7 @@ parse_text_node (GtkCssParser *parser,
g_assert (font);
}
hinted = gsk_reload_font (font, 1.0, hint_metrics, hint_style, antialias);
hinted = gsk_reload_font (font, 1.0, CAIRO_HINT_METRICS_OFF, hint_style, antialias);
g_object_unref (font);
font = hinted;
@@ -3560,13 +3539,13 @@ append_texture_param (Printer *p,
case GDK_MEMORY_U8:
case GDK_MEMORY_U16:
bytes = gdk_texture_save_to_png_bytes (texture);
g_string_append (p->str, "url(\"data:image/png;base64,\\\n");
g_string_append (p->str, "url(\"data:image/png;base64,");
break;
case GDK_MEMORY_FLOAT16:
case GDK_MEMORY_FLOAT32:
bytes = gdk_texture_save_to_tiff_bytes (texture);
g_string_append (p->str, "url(\"data:image/tiff;base64,\\\n");
g_string_append (p->str, "url(\"data:image/tiff;base64,");
break;
default:
@@ -3625,7 +3604,7 @@ gsk_text_node_serialize_font (GskRenderNode *node,
b64 = base64_encode_with_linebreaks ((const guchar *) data, len);
g_string_append (p->str, " url(\"data:font/ttf;base64,\\\n");
g_string_append (p->str, " url(\"data:font/ttf;base64,");
append_escaping_newlines (p->str, b64);
g_string_append (p->str, "\")");
@@ -3644,13 +3623,11 @@ gsk_text_node_serialize_font_options (GskRenderNode *node,
cairo_font_options_t *options;
cairo_hint_style_t hint_style;
cairo_antialias_t antialias;
cairo_hint_metrics_t hint_metrics;
options = cairo_font_options_create ();
cairo_scaled_font_get_font_options (sf, options);
hint_style = cairo_font_options_get_hint_style (options);
antialias = cairo_font_options_get_antialias (options);
hint_metrics = cairo_font_options_get_hint_metrics (options);
cairo_font_options_destroy (options);
/* medium and full are identical in the absence of subpixel modes */
@@ -3666,12 +3643,6 @@ gsk_text_node_serialize_font_options (GskRenderNode *node,
*/
if (antialias == CAIRO_ANTIALIAS_NONE)
append_enum_param (p, "antialias", CAIRO_GOBJECT_TYPE_ANTIALIAS, antialias);
/* CAIRO_HINT_METRICS_ON is the only value we ever emit here, since off is the default,
* and we don't accept any other values.
*/
if (hint_metrics == CAIRO_HINT_METRICS_ON)
append_enum_param (p, "hint-metrics", CAIRO_GOBJECT_TYPE_HINT_METRICS, CAIRO_HINT_METRICS_ON);
}
void
@@ -4443,7 +4414,7 @@ render_node_print (Printer *p,
cairo_surface_write_to_png_stream (surface, cairo_write_array, array);
_indent (p);
g_string_append (p->str, "pixels: url(\"data:image/png;base64,\\\n");
g_string_append (p->str, "pixels: url(\"data:image/png;base64,");
b64 = base64_encode_with_linebreaks (array->data, array->len);
append_escaping_newlines (p->str, b64);
g_free (b64);
@@ -4463,7 +4434,7 @@ render_node_print (Printer *p,
if (cairo_script_from_recording_surface (script, surface) == CAIRO_STATUS_SUCCESS)
{
_indent (p);
g_string_append (p->str, "script: url(\"data:;base64,\\\n");
g_string_append (p->str, "script: url(\"data:;base64,");
b64 = base64_encode_with_linebreaks (array->data, array->len);
append_escaping_newlines (p->str, b64);
g_free (b64);
+6
View File
@@ -184,4 +184,10 @@
</signal>
</interface>
<interface name="org.a11y.atspi.Event.Focus">
<signal name="Focus"><arg direction="in" type="(suuv)"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QSpiEvent"/>
</signal>
</interface>
</node>
+20 -19
View File
@@ -720,16 +720,6 @@ handle_accessible_get_property (GDBusConnection *connection,
res = get_parent_context_ref (accessible);
else if (g_strcmp0 (property_name, "ChildCount") == 0)
res = g_variant_new_int32 (gtk_at_spi_context_get_child_count (self));
else if (g_strcmp0 (property_name, "HelpText"))
{
if (gtk_at_context_has_accessible_property (GTK_AT_CONTEXT (self), GTK_ACCESSIBLE_PROPERTY_HELP_TEXT))
{
GtkAccessibleValue *value = gtk_at_context_get_accessible_property (GTK_AT_CONTEXT (self), GTK_ACCESSIBLE_PROPERTY_HELP_TEXT);
res = g_variant_new_string (gtk_string_accessible_value_get (value));
}
else
res = g_variant_new_string ("");
}
else
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
"Unknown property '%s'", property_name);
@@ -909,6 +899,24 @@ emit_children_changed (GtkAtSpiContext *self,
context_ref);
}
static void
emit_focus (GtkAtSpiContext *self,
gboolean focus_in)
{
if (self->connection == NULL)
return;
if (focus_in)
g_dbus_connection_emit_signal (self->connection,
NULL,
self->context_path,
"org.a11y.atspi.Event.Focus",
"Focus",
g_variant_new ("(siiva{sv})",
"", 0, 0, g_variant_new_string ("0"), NULL),
NULL);
}
static void
emit_window_event (GtkAtSpiContext *self,
const char *event_type)
@@ -1146,7 +1154,7 @@ gtk_at_spi_context_state_change (GtkATContext *ctx,
}
if (changed_properties & GTK_ACCESSIBLE_PROPERTY_CHANGE_DESCRIPTION)
{
{
char *label = gtk_at_context_get_description (GTK_AT_CONTEXT (self));
GVariant *v = g_variant_new_take_string (label);
emit_property_changed (self, "accessible-description", v);
@@ -1159,14 +1167,6 @@ gtk_at_spi_context_state_change (GtkATContext *ctx,
"accessible-value",
g_variant_new_double (gtk_number_accessible_value_get (value)));
}
if (changed_properties & GTK_ACCESSIBLE_PROPERTY_CHANGE_HELP_TEXT)
{
value = gtk_accessible_attribute_set_get_value (properties, GTK_ACCESSIBLE_PROPERTY_HELP_TEXT);
emit_property_changed (self,
"accessible-help-text",
g_variant_new_string (gtk_string_accessible_value_get (value)));
}
}
static void
@@ -1196,6 +1196,7 @@ gtk_at_spi_context_platform_change (GtkATContext *ctx,
gboolean state = gtk_accessible_get_platform_state (GTK_ACCESSIBLE (widget),
GTK_ACCESSIBLE_PLATFORM_STATE_FOCUSED);
emit_state_changed (self, "focused", state);
emit_focus (self, state);
}
if (changed_platform & GTK_ACCESSIBLE_PLATFORM_CHANGE_ACTIVE)
+2 -2
View File
@@ -97,7 +97,7 @@ gtk_accessible_role_to_atspi_role (GtkAccessibleRole role)
return ATSPI_ROLE_FORM;
case GTK_ACCESSIBLE_ROLE_GENERIC:
return ATSPI_ROLE_PANEL;
return ATSPI_ROLE_FILLER;
case GTK_ACCESSIBLE_ROLE_GRID:
return ATSPI_ROLE_TABLE;
@@ -106,7 +106,7 @@ gtk_accessible_role_to_atspi_role (GtkAccessibleRole role)
return ATSPI_ROLE_TABLE_CELL;
case GTK_ACCESSIBLE_ROLE_GROUP:
return ATSPI_ROLE_GROUPING;
return ATSPI_ROLE_PANEL;
case GTK_ACCESSIBLE_ROLE_HEADING:
return ATSPI_ROLE_HEADING;
+47 -543
View File
@@ -26,18 +26,24 @@
#include "gtkcsserror.h"
#include "gtkcsslocationprivate.h"
static void clear_ref (GtkCssVariableValueReference *ref);
#define GDK_ARRAY_NAME gtk_css_parser_references
#define GDK_ARRAY_TYPE_NAME GtkCssParserReferences
#define GDK_ARRAY_ELEMENT_TYPE GtkCssVariableValueReference
#define GDK_ARRAY_BY_VALUE 1
#define GDK_ARRAY_NO_MEMSET 1
#define GDK_ARRAY_FREE_FUNC clear_ref
#include "gdk/gdkarrayimpl.c"
typedef struct _GtkCssParserBlock GtkCssParserBlock;
struct _GtkCssParser
{
volatile int ref_count;
GtkCssTokenizer *tokenizer;
GFile *file;
GFile *directory;
GtkCssParserErrorFunc error_func;
gpointer user_data;
GDestroyNotify user_destroy;
GArray *blocks;
GtkCssLocation location;
GtkCssToken token;
};
struct _GtkCssParserBlock
{
GtkCssLocation start_location;
@@ -46,97 +52,8 @@ struct _GtkCssParserBlock
GtkCssTokenType alternative_token;
};
#define GDK_ARRAY_NAME gtk_css_parser_blocks
#define GDK_ARRAY_TYPE_NAME GtkCssParserBlocks
#define GDK_ARRAY_ELEMENT_TYPE GtkCssParserBlock
#define GDK_ARRAY_PREALLOC 32
#define GDK_ARRAY_NO_MEMSET 1
#include "gdk/gdkarrayimpl.c"
static inline GtkCssParserBlock *
gtk_css_parser_blocks_get_last (GtkCssParserBlocks *blocks)
{
return gtk_css_parser_blocks_index (blocks, gtk_css_parser_blocks_get_size (blocks) - 1);
}
static inline void
gtk_css_parser_blocks_drop_last (GtkCssParserBlocks *blocks)
{
gtk_css_parser_blocks_set_size (blocks, gtk_css_parser_blocks_get_size (blocks) - 1);
}
typedef struct _GtkCssTokenizerData GtkCssTokenizerData;
struct _GtkCssTokenizerData
{
GtkCssTokenizer *tokenizer;
char *var_name;
GtkCssVariableValue *variable;
};
static void
gtk_css_tokenizer_data_clear (gpointer data)
{
GtkCssTokenizerData *td = data;
gtk_css_tokenizer_unref (td->tokenizer);
if (td->var_name)
g_free (td->var_name);
if (td->variable)
gtk_css_variable_value_unref (td->variable);
}
#define GDK_ARRAY_NAME gtk_css_tokenizers
#define GDK_ARRAY_TYPE_NAME GtkCssTokenizers
#define GDK_ARRAY_ELEMENT_TYPE GtkCssTokenizerData
#define GDK_ARRAY_FREE_FUNC gtk_css_tokenizer_data_clear
#define GDK_ARRAY_BY_VALUE 1
#define GDK_ARRAY_PREALLOC 16
#define GDK_ARRAY_NO_MEMSET 1
#include "gdk/gdkarrayimpl.c"
static inline GtkCssTokenizerData *
gtk_css_tokenizers_get_last (GtkCssTokenizers *tokenizers)
{
return gtk_css_tokenizers_index (tokenizers, gtk_css_tokenizers_get_size (tokenizers) - 1);
}
static inline void
gtk_css_tokenizers_drop_last (GtkCssTokenizers *tokenizers)
{
gtk_css_tokenizers_set_size (tokenizers, gtk_css_tokenizers_get_size (tokenizers) - 1);
}
struct _GtkCssParser
{
volatile int ref_count;
GtkCssTokenizers tokenizers;
GFile *file;
GFile *directory;
GtkCssParserErrorFunc error_func;
gpointer user_data;
GDestroyNotify user_destroy;
GtkCssParserBlocks blocks;
GtkCssLocation location;
GtkCssToken token;
GtkCssVariableValue **refs;
gsize n_refs;
gsize next_ref;
gboolean var_fallback;
};
static inline GtkCssTokenizer *
get_tokenizer (GtkCssParser *self)
{
return gtk_css_tokenizers_get_last (&self->tokenizers)->tokenizer;
}
static GtkCssParser *
gtk_css_parser_new (GtkCssTokenizer *tokenizer,
GtkCssVariableValue *value,
GFile *file,
GtkCssParserErrorFunc error_func,
gpointer user_data,
@@ -147,21 +64,17 @@ gtk_css_parser_new (GtkCssTokenizer *tokenizer,
self = g_new0 (GtkCssParser, 1);
self->ref_count = 1;
gtk_css_tokenizers_init (&self->tokenizers);
gtk_css_tokenizers_append (&self->tokenizers,
&(GtkCssTokenizerData) {
gtk_css_tokenizer_ref (tokenizer),
NULL,
value ? gtk_css_variable_value_ref (value) : NULL });
self->tokenizer = gtk_css_tokenizer_ref (tokenizer);
if (file)
self->file = g_object_ref (file);
{
self->file = g_object_ref (file);
self->directory = g_file_get_parent (file);
}
self->error_func = error_func;
self->user_data = user_data;
self->user_destroy = user_destroy;
gtk_css_parser_blocks_init (&self->blocks);
self->blocks = g_array_new (FALSE, FALSE, sizeof (GtkCssParserBlock));
return self;
}
@@ -196,50 +109,26 @@ gtk_css_parser_new_for_bytes (GBytes *bytes,
{
GtkCssTokenizer *tokenizer;
GtkCssParser *result;
tokenizer = gtk_css_tokenizer_new (bytes);
result = gtk_css_parser_new (tokenizer, NULL, file, error_func, user_data, user_destroy);
result = gtk_css_parser_new (tokenizer, file, error_func, user_data, user_destroy);
gtk_css_tokenizer_unref (tokenizer);
return result;
}
GtkCssParser *
gtk_css_parser_new_for_token_stream (GtkCssVariableValue *value,
GFile *file,
GtkCssVariableValue **refs,
gsize n_refs,
GtkCssParserErrorFunc error_func,
gpointer user_data,
GDestroyNotify user_destroy)
{
GtkCssTokenizer *tokenizer;
GtkCssParser *result;
tokenizer = gtk_css_tokenizer_new_for_range (value->bytes, value->offset,
value->end_offset - value->offset);
result = gtk_css_parser_new (tokenizer, value, file, error_func, user_data, user_destroy);
gtk_css_tokenizer_unref (tokenizer);
result->refs = refs;
result->n_refs = n_refs;
result->next_ref = 0;
return result;
}
static void
gtk_css_parser_finalize (GtkCssParser *self)
{
if (self->user_destroy)
self->user_destroy (self->user_data);
gtk_css_tokenizers_clear (&self->tokenizers);
g_clear_pointer (&self->tokenizer, gtk_css_tokenizer_unref);
g_clear_object (&self->file);
g_clear_object (&self->directory);
if (gtk_css_parser_blocks_get_size (&self->blocks) > 0)
g_critical ("Finalizing CSS parser with %lu remaining blocks", gtk_css_parser_blocks_get_size (&self->blocks));
gtk_css_parser_blocks_clear (&self->blocks);
if (self->blocks->len)
g_critical ("Finalizing CSS parser with %u remaining blocks", self->blocks->len);
g_array_free (self->blocks, TRUE);
g_free (self);
}
@@ -274,12 +163,6 @@ gtk_css_parser_get_file (GtkCssParser *self)
return self->file;
}
GBytes *
gtk_css_parser_get_bytes (GtkCssParser *self)
{
return gtk_css_tokenizer_get_bytes (gtk_css_tokenizers_get (&self->tokenizers, 0)->tokenizer);
}
/**
* gtk_css_parser_resolve_url:
* @self: a `GtkCssParser`
@@ -305,12 +188,7 @@ gtk_css_parser_resolve_url (GtkCssParser *self,
}
if (self->directory == NULL)
{
if (self->file)
self->directory = g_file_get_parent (self->file);
if (self->directory == NULL)
return NULL;
}
return NULL;
return g_file_resolve_relative_path (self->directory, url);
}
@@ -361,7 +239,7 @@ gtk_css_parser_get_start_location (GtkCssParser *self)
const GtkCssLocation *
gtk_css_parser_get_end_location (GtkCssParser *self)
{
return gtk_css_tokenizer_get_location (get_tokenizer (self));
return gtk_css_tokenizer_get_location (self->tokenizer);
}
/**
@@ -381,13 +259,13 @@ gtk_css_parser_get_block_location (GtkCssParser *self)
{
const GtkCssParserBlock *block;
if (gtk_css_parser_blocks_get_size (&self->blocks) == 0)
if (self->blocks->len == 0)
{
static const GtkCssLocation start_of_document = { 0, };
return &start_of_document;
}
block = gtk_css_parser_blocks_get_last (&self->blocks);
block = &g_array_index (self->blocks, GtkCssParserBlock, self->blocks->len - 1);
return &block->start_location;
}
@@ -395,14 +273,12 @@ static void
gtk_css_parser_ensure_token (GtkCssParser *self)
{
GError *error = NULL;
GtkCssTokenizer *tokenizer;
if (!gtk_css_token_is (&self->token, GTK_CSS_TOKEN_EOF))
return;
tokenizer = get_tokenizer (self);
self->location = *gtk_css_tokenizer_get_location (tokenizer);
if (!gtk_css_tokenizer_read_token (tokenizer, &self->token, &error))
self->location = *gtk_css_tokenizer_get_location (self->tokenizer);
if (!gtk_css_tokenizer_read_token (self->tokenizer, &self->token, &error))
{
/* We ignore the error here, because the resulting token will
* likely already trigger an error in the parsing code and
@@ -410,49 +286,6 @@ gtk_css_parser_ensure_token (GtkCssParser *self)
*/
g_clear_error (&error);
}
if (gtk_css_tokenizers_get_size (&self->tokenizers) > 1 && gtk_css_token_is (&self->token, GTK_CSS_TOKEN_EOF))
{
gtk_css_tokenizers_drop_last (&self->tokenizers);
gtk_css_parser_ensure_token (self);
return;
}
/* Resolve var(--name): skip it and insert the resolved reference instead */
if (self->n_refs > 0 && gtk_css_token_is_function (&self->token, "var") && self->var_fallback == 0)
{
GtkCssVariableValue *ref;
GtkCssTokenizer *ref_tokenizer;
gtk_css_parser_start_block (self);
g_assert (gtk_css_parser_has_token (self, GTK_CSS_TOKEN_IDENT));
char *var_name = gtk_css_parser_consume_ident (self);
g_assert (var_name[0] == '-' && var_name[1] == '-');
/* If we encounter var() in a fallback when we can already resolve the
* actual variable, skip it */
self->var_fallback++;
gtk_css_parser_skip (self);
gtk_css_parser_end_block (self);
self->var_fallback--;
g_assert (self->next_ref < self->n_refs);
ref = self->refs[self->next_ref++];
ref_tokenizer = gtk_css_tokenizer_new_for_range (ref->bytes, ref->offset,
ref->end_offset - ref->offset);
gtk_css_tokenizers_append (&self->tokenizers,
&(GtkCssTokenizerData) {
ref_tokenizer,
g_strdup (var_name),
gtk_css_variable_value_ref (ref)
});
gtk_css_parser_ensure_token (self);
g_free (var_name);
}
}
const GtkCssToken *
@@ -462,9 +295,9 @@ gtk_css_parser_peek_token (GtkCssParser *self)
gtk_css_parser_ensure_token (self);
if (gtk_css_parser_blocks_get_size (&self->blocks) > 0)
if (self->blocks->len)
{
const GtkCssParserBlock *block = gtk_css_parser_blocks_get_last (&self->blocks);
const GtkCssParserBlock *block = &g_array_index (self->blocks, GtkCssParserBlock, self->blocks->len - 1);
if (gtk_css_token_is (&self->token, block->end_token) ||
gtk_css_token_is (&self->token, block->inherited_end_token) ||
gtk_css_token_is (&self->token, block->alternative_token))
@@ -519,7 +352,7 @@ gtk_css_parser_start_block (GtkCssParser *self)
block.inherited_end_token = GTK_CSS_TOKEN_EOF;
block.alternative_token = GTK_CSS_TOKEN_EOF;
block.start_location = self->location;
gtk_css_parser_blocks_append (&self->blocks, block);
g_array_append_val (self->blocks, block);
gtk_css_token_clear (&self->token);
}
@@ -531,13 +364,13 @@ gtk_css_parser_start_semicolon_block (GtkCssParser *self,
GtkCssParserBlock block;
block.end_token = GTK_CSS_TOKEN_SEMICOLON;
if (gtk_css_parser_blocks_get_size (&self->blocks) > 0)
block.inherited_end_token = gtk_css_parser_blocks_get_last (&self->blocks)->end_token;
if (self->blocks->len)
block.inherited_end_token = g_array_index (self->blocks, GtkCssParserBlock, self->blocks->len - 1).end_token;
else
block.inherited_end_token = GTK_CSS_TOKEN_EOF;
block.alternative_token = alternative_token;
block.start_location = self->location;
gtk_css_parser_blocks_append (&self->blocks, block);
g_array_append_val (self->blocks, block);
}
void
@@ -545,9 +378,9 @@ gtk_css_parser_end_block_prelude (GtkCssParser *self)
{
GtkCssParserBlock *block;
g_return_if_fail (gtk_css_parser_blocks_get_size (&self->blocks) > 0);
g_return_if_fail (self->blocks->len > 0);
block = gtk_css_parser_blocks_get_last (&self->blocks);
block = &g_array_index (self->blocks, GtkCssParserBlock, self->blocks->len - 1);
if (block->alternative_token == GTK_CSS_TOKEN_EOF)
return;
@@ -572,11 +405,11 @@ gtk_css_parser_end_block (GtkCssParser *self)
{
GtkCssParserBlock *block;
g_return_if_fail (gtk_css_parser_blocks_get_size (&self->blocks) > 0);
g_return_if_fail (self->blocks->len > 0);
gtk_css_parser_skip_until (self, GTK_CSS_TOKEN_EOF);
block = gtk_css_parser_blocks_get_last (&self->blocks);
block = &g_array_index (self->blocks, GtkCssParserBlock, self->blocks->len - 1);
if (gtk_css_token_is (&self->token, GTK_CSS_TOKEN_EOF))
{
@@ -585,7 +418,7 @@ gtk_css_parser_end_block (GtkCssParser *self)
gtk_css_parser_get_block_location (self),
gtk_css_parser_get_start_location (self),
"Unterminated block at end of document");
gtk_css_parser_blocks_drop_last (&self->blocks);
g_array_set_size (self->blocks, self->blocks->len - 1);
}
else if (gtk_css_token_is (&self->token, block->inherited_end_token))
{
@@ -595,11 +428,11 @@ gtk_css_parser_end_block (GtkCssParser *self)
gtk_css_parser_get_block_location (self),
gtk_css_parser_get_start_location (self),
"Expected ';' at end of block");
gtk_css_parser_blocks_drop_last (&self->blocks);
g_array_set_size (self->blocks, self->blocks->len - 1);
}
else
{
gtk_css_parser_blocks_drop_last (&self->blocks);
g_array_set_size (self->blocks, self->blocks->len - 1);
if (gtk_css_token_is_preserved (&self->token, NULL))
{
gtk_css_token_clear (&self->token);
@@ -669,19 +502,6 @@ gtk_css_parser_skip_until (GtkCssParser *self,
}
}
void
gtk_css_parser_skip_whitespace (GtkCssParser *self)
{
const GtkCssToken *token;
for (token = gtk_css_parser_peek_token (self);
gtk_css_token_is (token, GTK_CSS_TOKEN_WHITESPACE);
token = gtk_css_parser_peek_token (self))
{
gtk_css_parser_consume_token (self);
}
}
void
gtk_css_parser_emit_error (GtkCssParser *self,
const GtkCssLocation *start,
@@ -1292,319 +1112,3 @@ gtk_css_parser_consume_any (GtkCssParser *parser,
return result;
}
gboolean
gtk_css_parser_has_references (GtkCssParser *self)
{
GtkCssTokenizer *tokenizer = get_tokenizer (self);
gboolean ret = FALSE;
int inner_blocks = 0, i;
gtk_css_tokenizer_save (tokenizer);
do {
const GtkCssToken *token;
token = gtk_css_parser_get_token (self);
if (inner_blocks == 0)
{
if (gtk_css_token_is (token, GTK_CSS_TOKEN_EOF))
break;
if (gtk_css_token_is (token, GTK_CSS_TOKEN_CLOSE_PARENS) ||
gtk_css_token_is (token, GTK_CSS_TOKEN_CLOSE_SQUARE))
{
goto error;
}
}
if (gtk_css_token_is_preserved (token, NULL))
{
if (inner_blocks > 0 && gtk_css_token_is (token, GTK_CSS_TOKEN_EOF))
{
gtk_css_parser_end_block (self);
inner_blocks--;
}
else
{
gtk_css_parser_consume_token (self);
}
}
else
{
gboolean is_var = gtk_css_token_is_function (token, "var");
inner_blocks++;
gtk_css_parser_start_block (self);
if (!ret && is_var)
{
token = gtk_css_parser_get_token (self);
if (gtk_css_token_is (token, GTK_CSS_TOKEN_IDENT))
{
const char *var_name = gtk_css_token_get_string (token);
if (var_name[0] != '-' || var_name[1] != '-')
goto error;
gtk_css_parser_consume_token (self);
if (!gtk_css_parser_has_token (self, GTK_CSS_TOKEN_EOF) &&
!gtk_css_parser_has_token (self, GTK_CSS_TOKEN_COMMA))
{
goto error;
}
ret = TRUE;
}
}
}
}
while (!gtk_css_parser_has_token (self, GTK_CSS_TOKEN_SEMICOLON) &&
!gtk_css_parser_has_token (self, GTK_CSS_TOKEN_CLOSE_CURLY));
if (inner_blocks > 0)
goto error;
g_assert (tokenizer == get_tokenizer (self));
gtk_css_tokenizer_restore (tokenizer);
self->location = *gtk_css_tokenizer_get_location (tokenizer);
gtk_css_tokenizer_read_token (tokenizer, &self->token, NULL);
return ret;
error:
for (i = 0; i < inner_blocks; i++)
gtk_css_parser_end_block (self);
g_assert (tokenizer == get_tokenizer (self));
gtk_css_tokenizer_restore (tokenizer);
self->location = *gtk_css_tokenizer_get_location (tokenizer);
gtk_css_tokenizer_read_token (tokenizer, &self->token, NULL);
return FALSE;
}
static void
clear_ref (GtkCssVariableValueReference *ref)
{
g_free (ref->name);
if (ref->fallback)
gtk_css_variable_value_unref (ref->fallback);
}
#define GDK_ARRAY_NAME gtk_css_parser_references
#define GDK_ARRAY_TYPE_NAME GtkCssParserReferences
#define GDK_ARRAY_ELEMENT_TYPE GtkCssVariableValueReference
GtkCssVariableValue *
gtk_css_parser_parse_value_into_token_stream (GtkCssParser *self)
{
GBytes *bytes = gtk_css_tokenizer_get_bytes (get_tokenizer (self));
const GtkCssToken *token;
gsize offset;
gsize length = 0;
GtkCssParserReferences refs;
int inner_blocks = 0, i;
gboolean is_initial = FALSE;
for (token = gtk_css_parser_peek_token (self);
gtk_css_token_is (token, GTK_CSS_TOKEN_WHITESPACE);
token = gtk_css_parser_peek_token (self))
{
gtk_css_parser_consume_token (self);
}
gtk_css_parser_references_init (&refs);
offset = self->location.bytes;
do {
token = gtk_css_parser_get_token (self);
if (length == 0 && gtk_css_token_is_ident (token, "initial"))
is_initial = TRUE;
if (gtk_css_token_is (token, GTK_CSS_TOKEN_BAD_STRING) ||
gtk_css_token_is (token, GTK_CSS_TOKEN_BAD_URL))
{
gtk_css_parser_error_syntax (self, "Invalid property value");
goto error;
}
if (inner_blocks == 0)
{
if (gtk_css_token_is (token, GTK_CSS_TOKEN_EOF))
break;
if (gtk_css_token_is (token, GTK_CSS_TOKEN_CLOSE_PARENS) ||
gtk_css_token_is (token, GTK_CSS_TOKEN_CLOSE_SQUARE))
{
gtk_css_parser_error_syntax (self, "Invalid property value");
goto error;
}
}
if (gtk_css_token_is_preserved (token, NULL))
{
if (inner_blocks > 0 && gtk_css_token_is (token, GTK_CSS_TOKEN_EOF))
{
length++;
gtk_css_parser_end_block (self);
inner_blocks--;
}
else
{
length++;
gtk_css_parser_consume_token (self);
}
}
else
{
gboolean is_var = gtk_css_token_is_function (token, "var");
length++;
inner_blocks++;
gtk_css_parser_start_block (self);
if (is_var)
{
token = gtk_css_parser_get_token (self);
if (gtk_css_token_is (token, GTK_CSS_TOKEN_IDENT))
{
GtkCssVariableValueReference ref;
char *var_name = g_strdup (gtk_css_token_get_string (token));
if (var_name[0] != '-' || var_name[1] != '-')
{
gtk_css_parser_error_value (self, "Invalid variable name: %s", var_name);
g_free (var_name);
goto error;
}
length++;
gtk_css_parser_consume_token (self);
if (!gtk_css_parser_has_token (self, GTK_CSS_TOKEN_EOF) &&
!gtk_css_parser_has_token (self, GTK_CSS_TOKEN_COMMA))
{
gtk_css_parser_error_syntax (self, "Invalid property value");
g_free (var_name);
goto error;
}
ref.name = var_name;
if (gtk_css_parser_has_token (self, GTK_CSS_TOKEN_EOF))
{
ref.length = 3;
ref.fallback = NULL;
}
else
{
length++;
gtk_css_parser_consume_token (self);
ref.fallback = gtk_css_parser_parse_value_into_token_stream (self);
if (ref.fallback == NULL)
{
gtk_css_parser_error_value (self, "Invalid fallback for: %s", var_name);
g_free (var_name);
goto error;
}
ref.length = 4 + ref.fallback->length;
length += ref.fallback->length;
}
gtk_css_parser_references_append (&refs, &ref);
}
}
}
}
while (!gtk_css_parser_has_token (self, GTK_CSS_TOKEN_SEMICOLON) &&
!gtk_css_parser_has_token (self, GTK_CSS_TOKEN_CLOSE_CURLY));
if (inner_blocks > 0)
{
gtk_css_parser_error_syntax (self, "Invalid property value");
goto error;
}
if (is_initial && length == 1)
{
gtk_css_parser_references_clear (&refs);
return gtk_css_variable_value_new_initial (bytes,
offset,
self->location.bytes);
}
else
{
GtkCssVariableValueReference *out_refs;
gsize n_refs;
n_refs = gtk_css_parser_references_get_size (&refs);
out_refs = gtk_css_parser_references_steal (&refs);
return gtk_css_variable_value_new (bytes,
offset,
self->location.bytes,
length,
out_refs,
n_refs);
}
error:
for (i = 0; i < inner_blocks; i++)
gtk_css_parser_end_block (self);
gtk_css_parser_references_clear (&refs);
return NULL;
}
void
gtk_css_parser_get_expanding_variables (GtkCssParser *self,
GtkCssVariableValue ***variables,
char ***variable_names,
gsize *n_variables)
{
gsize len = gtk_css_tokenizers_get_size (&self->tokenizers);
GtkCssVariableValue **vars = NULL;
char **names = NULL;
gsize n;
if (variables)
vars = g_new0 (GtkCssVariableValue *, len + 1);
if (variable_names)
names = g_new0 (char *, len + 1);
n = 0;
for (gsize i = 0; i < gtk_css_tokenizers_get_size (&self->tokenizers); i++)
{
GtkCssTokenizerData *data = gtk_css_tokenizers_index (&self->tokenizers, i);
if (variables && data->variable)
vars[n] = gtk_css_variable_value_ref (data->variable);
if (variable_names)
names[n] = g_strdup (data->var_name);
n++;
}
if (variables)
*variables = vars;
if (variable_names)
*variable_names = names;
if (n_variables)
*n_variables = n;
}
-19
View File
@@ -22,7 +22,6 @@
#include "gtkcssenums.h"
#include "gtkcsstokenizerprivate.h"
#include "gtkcssvariablevalueprivate.h"
#include <gio/gio.h>
@@ -59,18 +58,10 @@ GtkCssParser * gtk_css_parser_new_for_bytes (GBytes
GtkCssParserErrorFunc error_func,
gpointer user_data,
GDestroyNotify user_destroy);
GtkCssParser * gtk_css_parser_new_for_token_stream (GtkCssVariableValue *value,
GFile *file,
GtkCssVariableValue **refs,
gsize n_refs,
GtkCssParserErrorFunc error_func,
gpointer user_data,
GDestroyNotify user_destroy);
GtkCssParser * gtk_css_parser_ref (GtkCssParser *self);
void gtk_css_parser_unref (GtkCssParser *self);
GFile * gtk_css_parser_get_file (GtkCssParser *self) G_GNUC_PURE;
GBytes * gtk_css_parser_get_bytes (GtkCssParser *self) G_GNUC_PURE;
GFile * gtk_css_parser_resolve_url (GtkCssParser *self,
const char *url);
@@ -90,7 +81,6 @@ void gtk_css_parser_end_block (GtkCssParser
void gtk_css_parser_skip (GtkCssParser *self);
void gtk_css_parser_skip_until (GtkCssParser *self,
GtkCssTokenType token_type);
void gtk_css_parser_skip_whitespace (GtkCssParser *self);
void gtk_css_parser_emit_error (GtkCssParser *self,
const GtkCssLocation *start,
@@ -160,14 +150,5 @@ gsize gtk_css_parser_consume_any (GtkCssParser
gsize n_options,
gpointer user_data);
gboolean gtk_css_parser_has_references (GtkCssParser *parser);
GtkCssVariableValue * gtk_css_parser_parse_value_into_token_stream (GtkCssParser *parser);
void gtk_css_parser_get_expanding_variables (GtkCssParser *parser,
GtkCssVariableValue ***variables,
char ***names,
gsize *n_variables);
G_END_DECLS
-22
View File
@@ -26,7 +26,6 @@ struct _GtkCssSection
int ref_count;
GtkCssSection *parent;
GFile *file;
GBytes *bytes;
GtkCssLocation start_location;
GtkCssLocation end_location; /* end location if parser is %NULL */
};
@@ -49,15 +48,6 @@ GtkCssSection *
gtk_css_section_new (GFile *file,
const GtkCssLocation *start,
const GtkCssLocation *end)
{
return gtk_css_section_new_with_bytes (file, NULL,start, end);
}
GtkCssSection *
gtk_css_section_new_with_bytes (GFile *file,
GBytes *bytes,
const GtkCssLocation *start,
const GtkCssLocation *end)
{
GtkCssSection *result;
@@ -70,8 +60,6 @@ gtk_css_section_new_with_bytes (GFile *file,
result->ref_count = 1;
if (file)
result->file = g_object_ref (file);
if (bytes)
result->bytes = g_bytes_ref (bytes);
result->start_location = *start;
result->end_location = *end;
@@ -116,8 +104,6 @@ gtk_css_section_unref (GtkCssSection *section)
gtk_css_section_unref (section->parent);
if (section->file)
g_object_unref (section->file);
if (section->bytes)
g_bytes_unref (section->bytes);
g_free (section);
}
@@ -165,14 +151,6 @@ gtk_css_section_get_file (const GtkCssSection *section)
return section->file;
}
GBytes *
gtk_css_section_get_bytes (const GtkCssSection *section)
{
g_return_val_if_fail (section != NULL, NULL);
return section->bytes;
}
/**
* gtk_css_section_get_start_location:
* @section: the section
-7
View File
@@ -46,11 +46,6 @@ GDK_AVAILABLE_IN_ALL
GtkCssSection * gtk_css_section_new (GFile *file,
const GtkCssLocation *start,
const GtkCssLocation *end);
GDK_AVAILABLE_IN_4_16
GtkCssSection * gtk_css_section_new_with_bytes (GFile *file,
GBytes *bytes,
const GtkCssLocation *start,
const GtkCssLocation *end);
GDK_AVAILABLE_IN_ALL
GtkCssSection * gtk_css_section_ref (GtkCssSection *section);
GDK_AVAILABLE_IN_ALL
@@ -66,8 +61,6 @@ GDK_AVAILABLE_IN_ALL
GtkCssSection * gtk_css_section_get_parent (const GtkCssSection *section);
GDK_AVAILABLE_IN_ALL
GFile * gtk_css_section_get_file (const GtkCssSection *section);
GDK_AVAILABLE_IN_4_16
GBytes * gtk_css_section_get_bytes (const GtkCssSection *section);
GDK_AVAILABLE_IN_ALL
const GtkCssLocation *
gtk_css_section_get_start_location (const GtkCssSection *section);
+2 -39
View File
@@ -36,9 +36,6 @@ struct _GtkCssTokenizer
const char *end;
GtkCssLocation position;
GtkCssLocation saved_position;
const char *saved_data;
};
void
@@ -571,14 +568,6 @@ gtk_css_token_init_dimension (GtkCssToken *token,
GtkCssTokenizer *
gtk_css_tokenizer_new (GBytes *bytes)
{
return gtk_css_tokenizer_new_for_range (bytes, 0, g_bytes_get_size (bytes));
}
GtkCssTokenizer *
gtk_css_tokenizer_new_for_range (GBytes *bytes,
gsize offset,
gsize length)
{
GtkCssTokenizer *tokenizer;
@@ -587,8 +576,8 @@ gtk_css_tokenizer_new_for_range (GBytes *bytes,
tokenizer->bytes = g_bytes_ref (bytes);
tokenizer->name_buffer = g_string_new (NULL);
tokenizer->data = g_bytes_get_region (bytes, 1, offset, length);
tokenizer->end = tokenizer->data + length;
tokenizer->data = g_bytes_get_data (bytes, NULL);
tokenizer->end = tokenizer->data + g_bytes_get_size (bytes);
gtk_css_location_init (&tokenizer->position);
@@ -615,12 +604,6 @@ gtk_css_tokenizer_unref (GtkCssTokenizer *tokenizer)
g_free (tokenizer);
}
GBytes *
gtk_css_tokenizer_get_bytes (GtkCssTokenizer *tokenizer)
{
return tokenizer->bytes;
}
const GtkCssLocation *
gtk_css_tokenizer_get_location (GtkCssTokenizer *tokenizer)
{
@@ -1501,23 +1484,3 @@ gtk_css_tokenizer_read_token (GtkCssTokenizer *tokenizer,
}
}
void
gtk_css_tokenizer_save (GtkCssTokenizer *tokenizer)
{
g_assert (!tokenizer->saved_data);
tokenizer->saved_position = tokenizer->position;
tokenizer->saved_data = tokenizer->data;
}
void
gtk_css_tokenizer_restore (GtkCssTokenizer *tokenizer)
{
g_assert (tokenizer->saved_data);
tokenizer->position = tokenizer->saved_position;
tokenizer->data = tokenizer->saved_data;
gtk_css_location_init (&tokenizer->saved_position);
tokenizer->saved_data = NULL;
}
-7
View File
@@ -138,22 +138,15 @@ void gtk_css_token_print (const GtkCssTok
char * gtk_css_token_to_string (const GtkCssToken *token);
GtkCssTokenizer * gtk_css_tokenizer_new (GBytes *bytes);
GtkCssTokenizer * gtk_css_tokenizer_new_for_range (GBytes *bytes,
gsize offset,
gsize length);
GtkCssTokenizer * gtk_css_tokenizer_ref (GtkCssTokenizer *tokenizer);
void gtk_css_tokenizer_unref (GtkCssTokenizer *tokenizer);
GBytes * gtk_css_tokenizer_get_bytes (GtkCssTokenizer *tokenizer);
const GtkCssLocation * gtk_css_tokenizer_get_location (GtkCssTokenizer *tokenizer) G_GNUC_CONST;
gboolean gtk_css_tokenizer_read_token (GtkCssTokenizer *tokenizer,
GtkCssToken *token,
GError **error);
void gtk_css_tokenizer_save (GtkCssTokenizer *tokenizer);
void gtk_css_tokenizer_restore (GtkCssTokenizer *tokenizer);
G_END_DECLS
-158
View File
@@ -1,158 +0,0 @@
/*
* Copyright (C) 2023 GNOME Foundation Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Alice Mikhaylenko <alicem@gnome.org>
*/
#include "gtkcssvariablevalueprivate.h"
GtkCssVariableValue *
gtk_css_variable_value_new (GBytes *bytes,
gsize offset,
gsize end_offset,
gsize length,
GtkCssVariableValueReference *references,
gsize n_references)
{
GtkCssVariableValue *self = g_new0 (GtkCssVariableValue, 1);
self->ref_count = 1;
self->bytes = g_bytes_ref (bytes);
self->offset = offset;
self->end_offset = end_offset;
self->length = length;
self->references = references;
self->n_references = n_references;
return self;
}
GtkCssVariableValue *
gtk_css_variable_value_new_initial (GBytes *bytes,
gsize offset,
gsize end_offset)
{
GtkCssVariableValue *self = gtk_css_variable_value_new (bytes, offset, end_offset, 1, NULL, 0);
self->is_invalid = TRUE;
return self;
}
GtkCssVariableValue *
gtk_css_variable_value_ref (GtkCssVariableValue *self)
{
self->ref_count++;
return self;
}
void
gtk_css_variable_value_unref (GtkCssVariableValue *self)
{
gsize i;
self->ref_count--;
if (self->ref_count > 0)
return;
g_bytes_unref (self->bytes);
for (i = 0; i < self->n_references; i++)
{
GtkCssVariableValueReference *ref = &self->references[i];
g_free (ref->name);
if (ref->fallback)
gtk_css_variable_value_unref (ref->fallback);
}
if (self->section)
gtk_css_section_unref (self->section);
g_free (self->references);
g_free (self);
}
void
gtk_css_variable_value_print (GtkCssVariableValue *self,
GString *string)
{
gsize len = self->end_offset - self->offset;
gconstpointer data = g_bytes_get_region (self->bytes, 1, self->offset, len);
g_assert (data != NULL);
g_string_append_len (string, (const char *) data, len);
}
char *
gtk_css_variable_value_to_string (GtkCssVariableValue *self)
{
GString *string = g_string_new (NULL);
gtk_css_variable_value_print (self, string);
return g_string_free (string, FALSE);
}
gboolean
gtk_css_variable_value_equal (const GtkCssVariableValue *value1,
const GtkCssVariableValue *value2)
{
if (value1 == value2)
return TRUE;
if (value1 == NULL || value2 == NULL)
return FALSE;
if (value1->bytes != value2->bytes)
return FALSE;
if (value1->offset != value2->offset)
return FALSE;
if (value1->end_offset != value2->end_offset)
return FALSE;
return TRUE;
}
GtkCssVariableValue *
gtk_css_variable_value_transition (GtkCssVariableValue *start,
GtkCssVariableValue *end,
double progress)
{
GtkCssVariableValue *ret = progress < 0.5 ? start : end;
if (ret == NULL)
return NULL;
return gtk_css_variable_value_ref (ret);
}
void
gtk_css_variable_value_set_section (GtkCssVariableValue *self,
GtkCssSection *section)
{
self->section = gtk_css_section_ref (section);
}
void
gtk_css_variable_value_taint (GtkCssVariableValue *self)
{
self->is_animation_tainted = TRUE;
}
-77
View File
@@ -1,77 +0,0 @@
/*
* Copyright (C) 2023 GNOME Foundation Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Alice Mikhaylenko <alicem@gnome.org>
*/
#pragma once
#include "gtkcss.h"
#include "gtkcsstokenizerprivate.h"
G_BEGIN_DECLS
typedef struct _GtkCssVariableValueReference GtkCssVariableValueReference;
typedef struct _GtkCssVariableValue GtkCssVariableValue;
struct _GtkCssVariableValueReference
{
char *name;
gsize length;
GtkCssVariableValue *fallback;
};
struct _GtkCssVariableValue
{
int ref_count;
GBytes *bytes;
gsize offset;
gsize end_offset;
gsize length;
GtkCssVariableValueReference *references;
gsize n_references;
GtkCssSection *section;
gboolean is_invalid;
gboolean is_animation_tainted;
};
GtkCssVariableValue *gtk_css_variable_value_new (GBytes *bytes,
gsize offset,
gsize end_offset,
gsize length,
GtkCssVariableValueReference *references,
gsize n_references);
GtkCssVariableValue *gtk_css_variable_value_new_initial (GBytes *bytes,
gsize offset,
gsize end_offset);
GtkCssVariableValue *gtk_css_variable_value_ref (GtkCssVariableValue *self);
void gtk_css_variable_value_unref (GtkCssVariableValue *self);
void gtk_css_variable_value_print (GtkCssVariableValue *self,
GString *string);
char * gtk_css_variable_value_to_string (GtkCssVariableValue *self);
gboolean gtk_css_variable_value_equal (const GtkCssVariableValue *value1,
const GtkCssVariableValue *value2) G_GNUC_PURE;
GtkCssVariableValue *gtk_css_variable_value_transition (GtkCssVariableValue *start,
GtkCssVariableValue *end,
double progress);
void gtk_css_variable_value_set_section (GtkCssVariableValue *self,
GtkCssSection *section);
void gtk_css_variable_value_taint (GtkCssVariableValue *self);
G_END_DECLS
+1 -2
View File
@@ -6,9 +6,8 @@ gtk_css_public_sources = files([
gtk_css_private_sources = files([
'gtkcssdataurl.c',
'gtkcssparser.c',
'gtkcssserializer.c',
'gtkcsstokenizer.c',
'gtkcssvariablevalue.c',
'gtkcssserializer.c',
])
gtk_css_public_headers = files([
+103 -289
View File
@@ -21,16 +21,9 @@
#include "gtkscalerprivate.h"
#include "gdk/gdktextureprivate.h"
#include "gdk/loaders/gdkpngprivate.h"
/* {{{ Pixbuf helpers */
static inline gboolean
pixbuf_is_only_fg (GdkPixbuf *pixbuf)
{
return gdk_pixbuf_get_option (pixbuf, "tEXt::only-foreground") != NULL;
}
static GdkPixbuf *
load_from_stream (GdkPixbufLoader *loader,
GInputStream *stream,
@@ -206,7 +199,6 @@ _gdk_pixbuf_new_from_resource_at_scale (const char *resource_path,
static GdkPixbuf *
load_symbolic_svg (const char *escaped_file_data,
gsize len,
int width,
int height,
const char *icon_width_str,
@@ -222,38 +214,37 @@ load_symbolic_svg (const char *escaped_file_data,
char *data;
data = g_strconcat ("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"
"<svg version=\"1.1\" "
"xmlns=\"http://www.w3.org/2000/svg\" "
"xmlns:xi=\"http://www.w3.org/2001/XInclude\" "
"width=\"", icon_width_str, "\" "
"height=\"", icon_height_str, "\">"
"<style type=\"text/css\">"
"rect,circle,path {"
"fill: ", fg_string," !important;"
"}\n"
".warning {"
"fill: ", warning_color_string, " !important;"
"}\n"
".error {"
"fill: ", error_color_string ," !important;"
"}\n"
".success {"
"fill: ", success_color_string, " !important;"
"}"
"</style>"
"<xi:include href=\"data:text/xml;base64,",
"<svg version=\"1.1\"\n"
" xmlns=\"http://www.w3.org/2000/svg\"\n"
" xmlns:xi=\"http://www.w3.org/2001/XInclude\"\n"
" width=\"", icon_width_str, "\"\n"
" height=\"", icon_height_str, "\">\n"
" <style type=\"text/css\">\n"
" rect,circle,path {\n"
" fill: ", fg_string," !important;\n"
" }\n"
" .warning {\n"
" fill: ", warning_color_string, " !important;\n"
" }\n"
" .error {\n"
" fill: ", error_color_string ," !important;\n"
" }\n"
" .success {\n"
" fill: ", success_color_string, " !important;\n"
" }\n"
" </style>\n"
" <xi:include href=\"data:text/xml;base64,", escaped_file_data, "\"/>\n"
"</svg>",
NULL);
stream = g_memory_input_stream_new_from_data (data, -1, g_free);
g_memory_input_stream_add_data (G_MEMORY_INPUT_STREAM (stream), escaped_file_data, len, NULL);
g_memory_input_stream_add_data (G_MEMORY_INPUT_STREAM (stream), "\"/></svg>", strlen ("\"/></svg>"), NULL);
pixbuf = gdk_pixbuf_new_from_stream_at_scale (stream, width, height, TRUE, NULL, error);
g_object_unref (stream);
return pixbuf;
}
static gboolean
static void
extract_plane (GdkPixbuf *src,
GdkPixbuf *dst,
int from_plane,
@@ -264,7 +255,6 @@ extract_plane (GdkPixbuf *src,
gsize src_stride, dst_stride;
guchar *src_row, *dst_row;
int x, y;
gboolean all_clear = TRUE;
width = gdk_pixbuf_get_width (src);
height = gdk_pixbuf_get_height (src);
@@ -284,109 +274,11 @@ extract_plane (GdkPixbuf *src,
dst_row = dst_data + dst_stride * y;
for (x = 0; x < width; x++)
{
if (src_row[from_plane] != 0)
all_clear = FALSE;
dst_row[to_plane] = src_row[from_plane];
src_row += 4;
dst_row += 4;
}
}
return all_clear;
}
static void
keep_alpha (GdkPixbuf *src)
{
guchar *data;
int width, height;
gsize stride;
data = gdk_pixbuf_get_pixels (src);
width = gdk_pixbuf_get_width (src);
height = gdk_pixbuf_get_height (src);
stride = gdk_pixbuf_get_rowstride (src);
for (int y = 0; y < height; y++)
{
guchar *row = data + stride * y;
for (int x = 0; x < width; x++)
{
row[0] = row[1] = row[2] = 0;
row += 4;
}
}
}
static void
svg_find_size_strings (const char *data,
gsize len,
char **width,
char **height)
{
gsize i, j, k, l;
*width = NULL;
*height = NULL;
for (i = 0; i < len - 4; i++)
{
if (strncmp (data + i, "<svg", 4) == 0)
{
for (j = i + strlen ("<svg"); j < len - 9; j++)
{
if (strncmp (data + j, "height=\"", strlen ("height=\"")) == 0)
{
k = l = j + strlen ("height=\"");
while (l < len && data[l] != '\"')
l++;
*height = g_strndup (data + k, l - k);
if (*width && *height)
return;
j = l;
}
else if (strncmp (data + j, "width=\"", strlen ("width=\"")) == 0)
{
k = l = j + strlen ("width=\"");
while (l < len && data[l] != '\"')
l++;
*width = g_strndup (data + k, l - k);
if (*width && *height)
return;
j = l;
}
else if (data[j] == '>')
{
break;
}
}
break;
}
}
*width = g_strdup ("16px");
*height = g_strdup ("16px");
}
static gboolean
svg_has_symbolic_classes (const char *data,
gsize len)
{
#ifdef HAVE_MEMMEM
return memmem (data, len, "class=\"error\"", strlen ("class=\"error\"")) != NULL ||
memmem (data, len, "class=\"warning\"", strlen ("class=\"warning\"")) != NULL ||
memmem (data, len, "class=\"success\"", strlen ("class=\"success\"")) != NULL;
#else
return TRUE;
#endif
}
GdkPixbuf *
@@ -401,46 +293,38 @@ gtk_make_symbolic_pixbuf_from_data (const char *file_data,
{
const char *r_string = "rgb(255,0,0)";
const char *g_string = "rgb(0,255,0)";
char *icon_width_str = NULL;
char *icon_height_str = NULL;
char *escaped_file_data = NULL;
gsize len;
char *icon_width_str;
char *icon_height_str;
GdkPixbuf *loaded;
GdkPixbuf *pixbuf = NULL;
gboolean has_symbolic_classes;
gboolean only_fg = TRUE;
has_symbolic_classes = svg_has_symbolic_classes (file_data, file_len);
int plane;
int icon_width, icon_height;
char *escaped_file_data;
/* Fetch size from the original icon */
if (has_symbolic_classes || width == 0 || height == 0)
svg_find_size_strings (file_data, file_len, &icon_width_str, &icon_height_str);
GInputStream *stream = g_memory_input_stream_new_from_data (file_data, file_len, NULL);
GdkPixbuf *reference = gdk_pixbuf_new_from_stream (stream, NULL, error);
if (width == 0)
width = (int) (g_ascii_strtoull (icon_width_str, NULL, 0) * scale);
if (height == 0)
height = (int) (g_ascii_strtoull (icon_height_str, NULL, 0) * scale);
g_object_unref (stream);
if (!has_symbolic_classes)
{
GInputStream *stream;
if (!reference)
return NULL;
stream = g_memory_input_stream_new_from_data (file_data, file_len, NULL);
pixbuf = gdk_pixbuf_new_from_stream_at_scale (stream, width, height, TRUE, NULL, error);
g_object_unref (stream);
if (pixbuf)
keep_alpha (pixbuf);
goto out;
}
icon_width = gdk_pixbuf_get_width (reference);
icon_height = gdk_pixbuf_get_height (reference);
g_object_unref (reference);
escaped_file_data = g_base64_encode ((guchar *) file_data, file_len);
len = strlen (escaped_file_data);
icon_width_str = g_strdup_printf ("%d", icon_width);
icon_height_str = g_strdup_printf ("%d", icon_height);
for (int plane = 0; plane < 3; plane++)
if (width == 0)
width = icon_width * scale;
if (height == 0)
height = icon_height * scale;
for (plane = 0; plane < 3; plane++)
{
GdkPixbuf *loaded;
/* Here we render the svg with all colors solid, this should
* always make the alpha channel the same and it should match
* the final alpha channel for all possible renderings. We
@@ -453,7 +337,7 @@ gtk_make_symbolic_pixbuf_from_data (const char *file_data,
* channels, with the color of the fg being implicitly
* the "rest", as all color fractions should add up to 1.
*/
loaded = load_symbolic_svg (escaped_file_data, len, width, height,
loaded = load_symbolic_svg (escaped_file_data, width, height,
icon_width_str,
icon_height_str,
g_string,
@@ -474,26 +358,25 @@ gtk_make_symbolic_pixbuf_from_data (const char *file_data,
g_free (filename);
}
if (plane == 0)
if (pixbuf == NULL)
{
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8,
gdk_pixbuf_get_width (loaded),
gdk_pixbuf_get_height (loaded));
memset (gdk_pixbuf_get_pixels (pixbuf), 0, gdk_pixbuf_get_byte_length (pixbuf));
extract_plane (loaded, pixbuf, 3, 3);
gdk_pixbuf_fill (pixbuf, 0);
}
only_fg &= extract_plane (loaded, pixbuf, 0, plane);
if (plane == 0)
extract_plane (loaded, pixbuf, 3, 3);
extract_plane (loaded, pixbuf, 0, plane);
g_object_unref (loaded);
}
out:
if (only_fg && pixbuf)
gdk_pixbuf_set_option (pixbuf, "tEXt::only-foreground", "true");
g_free (escaped_file_data);
out:
g_free (icon_width_str);
g_free (icon_height_str);
@@ -526,17 +409,17 @@ make_symbolic_pixbuf_from_resource (const char *path,
}
static GdkPixbuf *
make_symbolic_pixbuf_from_filename (const char *filename,
int width,
int height,
double scale,
GError **error)
make_symbolic_pixbuf_from_path (const char *path,
int width,
int height,
double scale,
GError **error)
{
char *data;
gsize size;
GdkPixbuf *pixbuf;
if (!g_file_get_contents (filename, &data, &size, error))
if (!g_file_get_contents (path, &data, &size, error))
return NULL;
pixbuf = gtk_make_symbolic_pixbuf_from_data (data, size, width, height, scale, NULL, error);
@@ -570,85 +453,11 @@ make_symbolic_pixbuf_from_file (GFile *file,
/* }}} */
/* {{{ Texture API */
static GdkTexture *
texture_new_from_bytes (GBytes *bytes,
gboolean *only_fg,
GError **error)
{
GHashTable *options;
GdkTexture *texture;
if (!gdk_is_png (bytes))
return gdk_texture_new_from_bytes (bytes, error);
options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
texture = gdk_load_png (bytes, options, error);
*only_fg = g_hash_table_contains (options, "foreground-only");
g_hash_table_unref (options);
return texture;
}
GdkTexture *
gdk_texture_new_from_filename_with_fg (const char *filename,
gboolean *only_fg,
GError **error)
{
GFile *file;
GBytes *bytes;
GdkTexture *texture = NULL;
file = g_file_new_for_path (filename);
bytes = g_file_load_bytes (file, NULL, NULL, error);
if (bytes)
texture = texture_new_from_bytes (bytes, only_fg, error);
g_bytes_unref (bytes);
g_object_unref (file);
return texture;
}
GdkTexture *
gdk_texture_new_from_resource_with_fg (const char *path,
gboolean *only_fg)
{
GBytes *bytes;
GdkTexture *texture = NULL;
bytes = g_resources_lookup_data (path, 0, NULL);
if (bytes)
texture = texture_new_from_bytes (bytes, only_fg, NULL);
g_bytes_unref (bytes);
return texture;
}
GdkTexture *
gdk_texture_new_from_stream_with_fg (GInputStream *stream,
gboolean *only_fg,
GCancellable *cancellable,
GError **error)
{
GdkPixbuf *pixbuf;
GdkTexture *texture = NULL;
pixbuf = _gdk_pixbuf_new_from_stream_scaled (stream, 0, cancellable, error);
if (pixbuf)
{
*only_fg = pixbuf_is_only_fg (pixbuf);
texture = gdk_texture_new_for_pixbuf (pixbuf);
g_object_unref (pixbuf);
}
return texture;
}
GdkTexture *
gdk_texture_new_from_stream_at_scale (GInputStream *stream,
int width,
int height,
gboolean aspect,
gboolean *only_fg,
GCancellable *cancellable,
GError **error)
{
@@ -658,7 +467,24 @@ gdk_texture_new_from_stream_at_scale (GInputStream *stream,
pixbuf = _gdk_pixbuf_new_from_stream_at_scale (stream, width, height, aspect, cancellable, error);
if (pixbuf)
{
*only_fg = pixbuf_is_only_fg (pixbuf);
texture = gdk_texture_new_for_pixbuf (pixbuf);
g_object_unref (pixbuf);
}
return texture;
}
GdkTexture *
gdk_texture_new_from_stream (GInputStream *stream,
GCancellable *cancellable,
GError **error)
{
GdkPixbuf *pixbuf;
GdkTexture *texture = NULL;
pixbuf = _gdk_pixbuf_new_from_stream_scaled (stream, 0, cancellable, error);
if (pixbuf)
{
texture = gdk_texture_new_for_pixbuf (pixbuf);
g_object_unref (pixbuf);
}
@@ -671,7 +497,6 @@ gdk_texture_new_from_resource_at_scale (const char *path,
int width,
int height,
gboolean preserve_aspect,
gboolean *only_fg,
GError **error)
{
GdkPixbuf *pixbuf;
@@ -680,7 +505,6 @@ gdk_texture_new_from_resource_at_scale (const char *path,
pixbuf = _gdk_pixbuf_new_from_resource_at_scale (path, width, height, preserve_aspect, error);
if (pixbuf)
{
*only_fg = pixbuf_is_only_fg (pixbuf);
texture = gdk_texture_new_for_pixbuf (pixbuf);
g_object_unref (pixbuf);
}
@@ -692,20 +516,18 @@ gdk_texture_new_from_resource_at_scale (const char *path,
/* {{{ Symbolic texture API */
GdkTexture *
gdk_texture_new_from_filename_symbolic (const char *filename,
int width,
int height,
double scale,
gboolean *only_fg,
GError **error)
gdk_texture_new_from_path_symbolic (const char *path,
int width,
int height,
double scale,
GError **error)
{
GdkPixbuf *pixbuf;
GdkTexture *texture = NULL;
pixbuf = make_symbolic_pixbuf_from_filename (filename, width, height, scale, error);
pixbuf = make_symbolic_pixbuf_from_path (path, width, height, scale, error);
if (pixbuf)
{
*only_fg = pixbuf_is_only_fg (pixbuf);
texture = gdk_texture_new_for_pixbuf (pixbuf);
g_object_unref (pixbuf);
}
@@ -724,7 +546,6 @@ gdk_texture_new_from_resource_symbolic (const char *path,
int width,
int height,
double scale,
gboolean *only_fg,
GError **error)
{
GdkPixbuf *pixbuf;
@@ -733,7 +554,6 @@ gdk_texture_new_from_resource_symbolic (const char *path,
pixbuf = make_symbolic_pixbuf_from_resource (path, width, height, scale, error);
if (pixbuf)
{
*only_fg = pixbuf_is_only_fg (pixbuf);
texture = gdk_texture_new_for_pixbuf (pixbuf);
g_object_unref (pixbuf);
}
@@ -768,19 +588,14 @@ gdk_texture_new_from_file_symbolic (GFile *file,
int width,
int height,
double scale,
gboolean *only_fg,
GError **error)
{
GdkPixbuf *pixbuf;
GdkTexture *texture = NULL;
GdkTexture *texture;
pixbuf = make_symbolic_pixbuf_from_file (file, width, height, scale, error);
if (pixbuf)
{
*only_fg = pixbuf_is_only_fg (pixbuf);
texture = gdk_texture_new_for_pixbuf (pixbuf);
g_object_unref (pixbuf);
}
texture = gdk_texture_new_for_pixbuf (pixbuf);
g_object_unref (pixbuf);
return texture;
}
@@ -789,7 +604,7 @@ gdk_texture_new_from_file_symbolic (GFile *file,
/* {{{ Scaled paintable API */
typedef struct {
double scale;
int scale_factor;
} LoaderData;
static void
@@ -805,24 +620,24 @@ on_loader_size_prepared (GdkPixbufLoader *loader,
format = gdk_pixbuf_loader_get_format (loader);
if (!gdk_pixbuf_format_is_scalable (format))
{
loader_data->scale = 1.0;
loader_data->scale_factor = 1;
return;
}
gdk_pixbuf_loader_set_size (loader,
width * loader_data->scale,
height * loader_data->scale);
width * loader_data->scale_factor,
height * loader_data->scale_factor);
}
static GdkPaintable *
gdk_paintable_new_from_bytes_scaled (GBytes *bytes,
double scale)
int scale_factor)
{
LoaderData loader_data;
GdkTexture *texture;
GdkPaintable *paintable;
loader_data.scale = scale;
loader_data.scale_factor = scale_factor;
if (gdk_texture_can_load (bytes))
{
@@ -852,8 +667,8 @@ gdk_paintable_new_from_bytes_scaled (GBytes *bytes,
texture = gdk_texture_new_for_pixbuf (gdk_pixbuf_loader_get_pixbuf (loader));
g_object_unref (loader);
if (loader_data.scale != 1.0)
paintable = gtk_scaler_new (GDK_PAINTABLE (texture), loader_data.scale);
if (loader_data.scale_factor != 1)
paintable = gtk_scaler_new (GDK_PAINTABLE (texture), loader_data.scale_factor);
else
paintable = g_object_ref (GDK_PAINTABLE (texture));
@@ -864,20 +679,20 @@ gdk_paintable_new_from_bytes_scaled (GBytes *bytes,
}
GdkPaintable *
gdk_paintable_new_from_filename_scaled (const char *filename,
double scale)
gdk_paintable_new_from_path_scaled (const char *path,
int scale_factor)
{
char *contents;
gsize length;
GBytes *bytes;
GdkPaintable *paintable;
if (!g_file_get_contents (filename, &contents, &length, NULL))
if (!g_file_get_contents (path, &contents, &length, NULL))
return NULL;
bytes = g_bytes_new_take (contents, length);
paintable = gdk_paintable_new_from_bytes_scaled (bytes, scale);
paintable = gdk_paintable_new_from_bytes_scaled (bytes, scale_factor);
g_bytes_unref (bytes);
@@ -886,7 +701,7 @@ gdk_paintable_new_from_filename_scaled (const char *filename,
GdkPaintable *
gdk_paintable_new_from_resource_scaled (const char *path,
double scale)
int scale_factor)
{
GBytes *bytes;
GdkPaintable *paintable;
@@ -895,16 +710,15 @@ gdk_paintable_new_from_resource_scaled (const char *path,
if (!bytes)
return NULL;
paintable = gdk_paintable_new_from_bytes_scaled (bytes, scale);
paintable = gdk_paintable_new_from_bytes_scaled (bytes, scale_factor);
g_bytes_unref (bytes);
return paintable;
}
GdkPaintable *
gdk_paintable_new_from_file_scaled (GFile *file,
double scale)
gdk_paintable_new_from_file_scaled (GFile *file,
int scale_factor)
{
GBytes *bytes;
GdkPaintable *paintable;
@@ -913,7 +727,7 @@ gdk_paintable_new_from_file_scaled (GFile *file,
if (!bytes)
return NULL;
paintable = gdk_paintable_new_from_bytes_scaled (bytes, scale);
paintable = gdk_paintable_new_from_bytes_scaled (bytes, scale_factor);
g_bytes_unref (bytes);
+7 -18
View File
@@ -29,56 +29,45 @@ GdkPixbuf *gtk_make_symbolic_pixbuf_from_data (const char *data,
const char *debug_output_to,
GError **error);
GdkTexture *gdk_texture_new_from_filename_with_fg (const char *filename,
gboolean *only_fg,
GError **error);
GdkTexture *gdk_texture_new_from_resource_with_fg (const char *path,
gboolean *only_fg);
GdkTexture *gdk_texture_new_from_stream_with_fg (GInputStream *stream,
gboolean *only_fg,
GdkTexture *gdk_texture_new_from_stream (GInputStream *stream,
GCancellable *cancellable,
GError **error);
GdkTexture *gdk_texture_new_from_stream_at_scale (GInputStream *stream,
int width,
int height,
gboolean aspect,
gboolean *only_fg,
GCancellable *cancellable,
GError **error);
GdkTexture *gdk_texture_new_from_resource_at_scale (const char *path,
int width,
int height,
gboolean aspect,
gboolean *only_fg,
GError **error);
GdkTexture *gdk_texture_new_from_filename_symbolic (const char *path,
GdkTexture *gdk_texture_new_from_path_symbolic (const char *path,
int width,
int height,
double scale,
gboolean *only_fg,
GError **error);
GdkTexture *gdk_texture_new_from_file_symbolic (GFile *file,
int width,
int height,
double scale,
gboolean *only_fg,
GError **error);
GdkTexture *gdk_texture_new_from_resource_symbolic (const char *path,
int width,
int height,
double scale,
gboolean *only_fg,
GError **error);
GdkTexture *gtk_load_symbolic_texture_from_file (GFile *file);
GdkTexture *gtk_load_symbolic_texture_from_resource (const char *path);
GdkTexture *gtk_load_symbolic_texture_from_resource (const char *data);
GdkPaintable *gdk_paintable_new_from_filename_scaled (const char *filename,
double scale);
GdkPaintable *gdk_paintable_new_from_path_scaled (const char *path,
int scale_factor);
GdkPaintable *gdk_paintable_new_from_resource_scaled (const char *path,
double scale);
int scale_factor);
GdkPaintable *gdk_paintable_new_from_file_scaled (GFile *file,
double scale);
int scale_factor);
G_END_DECLS
+5 -11
View File
@@ -808,11 +808,6 @@ static const GtkAccessibleCollect collect_props[] = {
.ctype = GTK_ACCESSIBLE_COLLECT_STRING,
.name = "valuetext"
},
[GTK_ACCESSIBLE_PROPERTY_HELP_TEXT] = {
.value = GTK_ACCESSIBLE_PROPERTY_HELP_TEXT,
.ctype = GTK_ACCESSIBLE_COLLECT_STRING,
.name = "helptext"
},
};
/* § 6.6.4 Relationship Attributes */
@@ -1667,7 +1662,7 @@ gtk_accessible_value_get_default_for_property (GtkAccessibleProperty property)
{
const GtkAccessibleCollect *cstate = &collect_props[property];
g_return_val_if_fail (property <= GTK_ACCESSIBLE_PROPERTY_HELP_TEXT, NULL);
g_return_val_if_fail (property <= GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT, NULL);
switch (cstate->value)
{
@@ -1697,7 +1692,6 @@ gtk_accessible_value_get_default_for_property (GtkAccessibleProperty property)
case GTK_ACCESSIBLE_PROPERTY_PLACEHOLDER:
case GTK_ACCESSIBLE_PROPERTY_ROLE_DESCRIPTION:
case GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT:
case GTK_ACCESSIBLE_PROPERTY_HELP_TEXT:
return gtk_undefined_accessible_value_new ();
/* Token properties */
@@ -1738,7 +1732,7 @@ gtk_accessible_value_collect_for_property (GtkAccessibleProperty property,
{
const GtkAccessibleCollect *cstate = &collect_props[property];
g_return_val_if_fail (property <= GTK_ACCESSIBLE_PROPERTY_HELP_TEXT, NULL);
g_return_val_if_fail (property <= GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT, NULL);
return gtk_accessible_value_collect_valist (cstate, error, args);
}
@@ -1766,7 +1760,7 @@ gtk_accessible_value_collect_for_property_value (GtkAccessibleProperty propert
{
const GtkAccessibleCollect *cstate = &collect_props[property];
g_return_val_if_fail (property <= GTK_ACCESSIBLE_PROPERTY_HELP_TEXT, NULL);
g_return_val_if_fail (property <= GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT, NULL);
return gtk_accessible_value_collect_value (cstate, value, error);
}
@@ -1779,7 +1773,7 @@ gtk_accessible_value_parse_for_property (GtkAccessibleProperty property,
{
const GtkAccessibleCollect *cstate = &collect_props[property];
g_return_val_if_fail (property <= GTK_ACCESSIBLE_PROPERTY_HELP_TEXT, NULL);
g_return_val_if_fail (property <= GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT, NULL);
return gtk_accessible_value_parse (cstate, str, len, error);
}
@@ -1800,7 +1794,7 @@ gtk_accessible_property_init_value (GtkAccessibleProperty property,
{
const GtkAccessibleCollect *cstate = &collect_props[property];
g_return_if_fail (property <= GTK_ACCESSIBLE_PROPERTY_HELP_TEXT);
g_return_if_fail (property <= GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT);
gtk_accessible_attribute_init_value (cstate, value);
}
+1 -2
View File
@@ -328,7 +328,6 @@ static const char *property_attrs[] = {
[GTK_ACCESSIBLE_PROPERTY_VALUE_MIN] = "valuemin",
[GTK_ACCESSIBLE_PROPERTY_VALUE_NOW] = "valuenow",
[GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT] = "valuetext",
[GTK_ACCESSIBLE_PROPERTY_HELP_TEXT] = "helptext",
};
/*< private >
@@ -343,7 +342,7 @@ const char *
gtk_accessible_property_get_attribute_name (GtkAccessibleProperty property)
{
g_return_val_if_fail (property >= GTK_ACCESSIBLE_PROPERTY_AUTOCOMPLETE &&
property <= GTK_ACCESSIBLE_PROPERTY_HELP_TEXT,
property <= GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT,
"<none>");
return property_attrs[property];
+1 -2
View File
@@ -47,8 +47,7 @@ typedef enum {
GTK_ACCESSIBLE_PROPERTY_CHANGE_VALUE_MAX = 1 << GTK_ACCESSIBLE_PROPERTY_VALUE_MAX,
GTK_ACCESSIBLE_PROPERTY_CHANGE_VALUE_MIN = 1 << GTK_ACCESSIBLE_PROPERTY_VALUE_MIN,
GTK_ACCESSIBLE_PROPERTY_CHANGE_VALUE_NOW = 1 << GTK_ACCESSIBLE_PROPERTY_VALUE_NOW,
GTK_ACCESSIBLE_PROPERTY_CHANGE_VALUE_TEXT = 1 << GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT,
GTK_ACCESSIBLE_PROPERTY_CHANGE_HELP_TEXT = 1 << GTK_ACCESSIBLE_PROPERTY_HELP_TEXT,
GTK_ACCESSIBLE_PROPERTY_CHANGE_VALUE_TEXT = 1 << GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT
} GtkAccessiblePropertyChange;
typedef enum {
+3 -7
View File
@@ -32,12 +32,8 @@
* `GtkBuilderListItemFactory` is a `GtkListItemFactory` that creates
* widgets by instantiating `GtkBuilder` UI templates.
*
* The templates must extend the class that the parent widget expects.
* For example, a factory provided to [property@Gtk.ListView:factory] must have
* a template that extends [class@Gtk.ListItem].
*
* Templates typically use `GtkExpression`s to obtain data from the items
* in the model.
* The templates must be extending `GtkListItem`, and typically use
* `GtkExpression`s to obtain data from the items in the model.
*
* Example:
* ```xml
@@ -207,7 +203,7 @@ gtk_builder_list_item_factory_set_property (GObject *object,
case PROP_RESOURCE:
{
GError *error = NULL;
GBytes *bytes;
GBytes *bytes;
const char *resource;
resource = g_value_get_string (value);
-4
View File
@@ -861,8 +861,6 @@ gtk_column_view_class_init (GtkColumnViewClass *klass)
*
* The factory used for configuring rows.
*
* The factory must be for configuring [class@Gtk.ColumnViewRow] objects.
*
* Since: 4.12
*/
properties[PROP_ROW_FACTORY] =
@@ -928,8 +926,6 @@ gtk_column_view_class_init (GtkColumnViewClass *klass)
*
* Factory for creating header widgets.
*
* The factory must be for configuring [class@Gtk.ListHeader] objects.
*
* Since: 4.12
*/
properties[PROP_HEADER_FACTORY] =
+1 -3
View File
@@ -255,8 +255,6 @@ gtk_column_view_column_class_init (GtkColumnViewColumnClass *klass)
* GtkColumnViewColumn:factory: (attributes org.gtk.Property.get=gtk_column_view_column_get_factory org.gtk.Property.set=gtk_column_view_column_set_factory)
*
* Factory for populating list items.
*
* The factory must be for configuring [class@Gtk.ColumnViewCell] objects.
*/
properties[PROP_FACTORY] =
g_param_spec_object ("factory", NULL, NULL,
@@ -763,7 +761,7 @@ gtk_column_view_column_remove_from_sorter (GtkColumnViewColumn *self)
{
if (self->view == NULL)
return;
gtk_column_view_sorter_remove_column (GTK_COLUMN_VIEW_SORTER (gtk_column_view_get_sorter (self->view)), self);
}
+6 -144
View File
@@ -33,59 +33,13 @@
#include "gtkcssstringvalueprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtkcsstransitionprivate.h"
#include "gtkcssvaluesprivate.h"
#include "gtkprivate.h"
#include "gtkstyleanimationprivate.h"
#include "gtkstylepropertyprivate.h"
#include "gtkstyleproviderprivate.h"
#include "gtkcsscustompropertypoolprivate.h"
G_DEFINE_TYPE (GtkCssAnimatedStyle, gtk_css_animated_style, GTK_TYPE_CSS_STYLE)
#define DEFINE_VALUES(ENUM, TYPE, NAME) \
static inline void \
gtk_css_ ## NAME ## _values_recompute (GtkCssAnimatedStyle *animated) \
{ \
GtkCssStyle *style = (GtkCssStyle *)animated; \
GtkCssValue **values = (GtkCssValue **)((guint8*)(animated->style->NAME) + sizeof (GtkCssValues)); \
int i; \
\
for (i = 0; i < G_N_ELEMENTS (NAME ## _props); i++) \
{ \
guint id = NAME ## _props[i]; \
GtkCssValue *original, *computed; \
\
if (values[i] == NULL) \
continue; \
\
original = gtk_css_style_get_original_value (style, id); \
if (original == NULL) \
continue; \
\
computed = _gtk_css_value_compute (original, \
id, \
animated->provider, \
style, \
animated->parent_style, \
NULL); \
if (computed == NULL) \
continue; \
\
gtk_css_animated_style_set_animated_value (animated, id, computed); \
} \
}
DEFINE_VALUES (CORE, Core, core)
DEFINE_VALUES (BACKGROUND, Background, background)
DEFINE_VALUES (BORDER, Border, border)
DEFINE_VALUES (ICON, Icon, icon)
DEFINE_VALUES (OUTLINE, Outline, outline)
DEFINE_VALUES (FONT, Font, font)
DEFINE_VALUES (FONT_VARIANT, FontVariant, font_variant)
DEFINE_VALUES (ANIMATION, Animation, animation)
DEFINE_VALUES (TRANSITION, Transition, transition)
DEFINE_VALUES (SIZE, Size, size)
DEFINE_VALUES (OTHER, Other, other)
static GtkCssSection *
gtk_css_animated_style_get_section (GtkCssStyle *style,
@@ -120,15 +74,6 @@ gtk_css_animated_style_get_static_style (GtkCssStyle *style)
return (GtkCssStaticStyle *)animated->style;
}
static GtkCssValue *
gtk_css_animated_style_get_original_value (GtkCssStyle *style,
guint id)
{
GtkCssAnimatedStyle *animated = GTK_CSS_ANIMATED_STYLE (style);
return gtk_css_style_get_original_value (animated->style, id);
}
static void
gtk_css_animated_style_dispose (GObject *object)
{
@@ -151,9 +96,6 @@ gtk_css_animated_style_finalize (GObject *object)
GtkCssAnimatedStyle *style = GTK_CSS_ANIMATED_STYLE (object);
g_object_unref (style->style);
if (style->parent_style)
g_object_unref (style->parent_style);
g_object_unref (style->provider);
G_OBJECT_CLASS (gtk_css_animated_style_parent_class)->finalize (object);
}
@@ -170,7 +112,6 @@ gtk_css_animated_style_class_init (GtkCssAnimatedStyleClass *klass)
style_class->get_section = gtk_css_animated_style_get_section;
style_class->is_static = gtk_css_animated_style_is_static;
style_class->get_static_style = gtk_css_animated_style_get_static_style;
style_class->get_original_value = gtk_css_animated_style_get_original_value;
}
static void
@@ -605,51 +546,6 @@ gtk_css_animated_style_get_intrinsic_value (GtkCssAnimatedStyle *style,
return gtk_css_style_get_value (style->style, id);
}
void
gtk_css_animated_style_set_animated_custom_value (GtkCssAnimatedStyle *animated,
int id,
GtkCssVariableValue *value)
{
GtkCssStyle *style = (GtkCssStyle *)animated;
gtk_internal_return_if_fail (GTK_IS_CSS_ANIMATED_STYLE (style));
gtk_internal_return_if_fail (value != NULL);
if (style->variables == NULL)
{
style->variables = gtk_css_variable_set_new ();
if (animated->parent_style)
gtk_css_variable_set_set_parent (style->variables,
animated->parent_style->variables);
}
else if (style->variables == animated->style->variables)
{
gtk_css_variable_set_unref (style->variables);
style->variables = gtk_css_variable_set_copy (animated->style->variables);
}
gtk_css_variable_set_add (style->variables, id, value);
gtk_css_core_values_recompute (animated);
gtk_css_background_values_recompute (animated);
gtk_css_border_values_recompute (animated);
gtk_css_icon_values_recompute (animated);
gtk_css_outline_values_recompute (animated);
gtk_css_font_values_recompute (animated);
gtk_css_font_variant_values_recompute (animated);
gtk_css_animation_values_recompute (animated);
gtk_css_transition_values_recompute (animated);
gtk_css_size_values_recompute (animated);
gtk_css_other_values_recompute (animated);
}
GtkCssVariableValue *
gtk_css_animated_style_get_intrinsic_custom_value (GtkCssAnimatedStyle *style,
int id)
{
return gtk_css_style_get_custom_property (style->style, id);
}
static GPtrArray *
gtk_css_animated_style_create_dynamic (GPtrArray *animations,
GtkCssStyle *style,
@@ -874,6 +770,7 @@ gtk_css_animated_style_find_animation (GtkStyleAnimation **animations,
static GPtrArray *
gtk_css_animated_style_create_css_animations (GPtrArray *animations,
GtkCssStyle *base_style,
GtkCssStyle *parent_style,
gint64 timestamp,
GtkStyleProvider *provider,
GtkCssStyle *source)
@@ -935,6 +832,8 @@ gtk_css_animated_style_create_css_animations (GPtrArray *animations,
if (keyframes == NULL)
continue;
keyframes = _gtk_css_keyframes_compute (keyframes, provider, base_style, parent_style);
animation = _gtk_css_animation_new (name,
keyframes,
timestamp,
@@ -945,6 +844,7 @@ gtk_css_animated_style_create_css_animations (GPtrArray *animations,
_gtk_css_play_state_value_get (_gtk_css_array_value_get_nth (play_states, i)),
_gtk_css_fill_mode_value_get (_gtk_css_array_value_get_nth (fill_modes, i)),
_gtk_css_number_value_get (_gtk_css_array_value_get_nth (iteration_counts, i), 100));
_gtk_css_keyframes_unref (keyframes);
}
if (!animations)
@@ -993,7 +893,7 @@ gtk_css_animated_style_new (GtkCssStyle *base_style,
if (previous_style != NULL)
animations = gtk_css_animated_style_create_css_transitions (animations, base_style, timestamp, previous_style);
animations = gtk_css_animated_style_create_css_animations (animations, base_style, timestamp, provider, previous_style);
animations = gtk_css_animated_style_create_css_animations (animations, base_style, parent_style, timestamp, provider, previous_style);
animations = gtk_css_animated_style_create_dynamic (animations, base_style, timestamp);
if (animations == NULL)
@@ -1002,9 +902,6 @@ gtk_css_animated_style_new (GtkCssStyle *base_style,
result = g_object_new (GTK_TYPE_CSS_ANIMATED_STYLE, NULL);
result->style = g_object_ref (base_style);
if (parent_style)
result->parent_style = g_object_ref (parent_style);
result->provider = g_object_ref (provider);
result->current_time = timestamp;
result->n_animations = animations->len;
result->animations = g_ptr_array_free (animations, FALSE);
@@ -1021,8 +918,6 @@ gtk_css_animated_style_new (GtkCssStyle *base_style,
style->transition = (GtkCssTransitionValues *)gtk_css_values_ref ((GtkCssValues *)base_style->transition);
style->size = (GtkCssSizeValues *)gtk_css_values_ref ((GtkCssValues *)base_style->size);
style->other = (GtkCssOtherValues *)gtk_css_values_ref ((GtkCssValues *)base_style->other);
if (base_style->variables)
style->variables = gtk_css_variable_set_ref (base_style->variables);
gtk_css_animated_style_apply_animations (result);
@@ -1032,9 +927,7 @@ gtk_css_animated_style_new (GtkCssStyle *base_style,
GtkCssStyle *
gtk_css_animated_style_new_advance (GtkCssAnimatedStyle *source,
GtkCssStyle *base_style,
GtkCssStyle *parent_style,
gint64 timestamp,
GtkStyleProvider *provider)
gint64 timestamp)
{
GtkCssAnimatedStyle *result;
GtkCssStyle *style;
@@ -1043,8 +936,6 @@ gtk_css_animated_style_new_advance (GtkCssAnimatedStyle *source,
gtk_internal_return_val_if_fail (GTK_IS_CSS_ANIMATED_STYLE (source), NULL);
gtk_internal_return_val_if_fail (GTK_IS_CSS_STYLE (base_style), NULL);
gtk_internal_return_val_if_fail (parent_style == NULL || GTK_IS_CSS_STYLE (parent_style), NULL);
gtk_internal_return_val_if_fail (GTK_IS_STYLE_PROVIDER (provider), NULL);
if (timestamp == 0)
return g_object_ref (source->style);
@@ -1075,9 +966,6 @@ gtk_css_animated_style_new_advance (GtkCssAnimatedStyle *source,
result = g_object_new (GTK_TYPE_CSS_ANIMATED_STYLE, NULL);
result->style = g_object_ref (base_style);
if (parent_style)
result->parent_style = g_object_ref (parent_style);
result->provider = g_object_ref (provider);
result->current_time = timestamp;
result->n_animations = animations->len;
result->animations = g_ptr_array_free (animations, FALSE);
@@ -1094,34 +982,8 @@ gtk_css_animated_style_new_advance (GtkCssAnimatedStyle *source,
style->transition = (GtkCssTransitionValues *)gtk_css_values_ref ((GtkCssValues *)base_style->transition);
style->size = (GtkCssSizeValues *)gtk_css_values_ref ((GtkCssValues *)base_style->size);
style->other = (GtkCssOtherValues *)gtk_css_values_ref ((GtkCssValues *)base_style->other);
if (base_style->variables)
style->variables = gtk_css_variable_set_ref (base_style->variables);
gtk_css_animated_style_apply_animations (result);
return GTK_CSS_STYLE (result);
}
GtkCssStyle *
gtk_css_animated_style_get_base_style (GtkCssAnimatedStyle *style)
{
gtk_internal_return_val_if_fail (GTK_IS_CSS_ANIMATED_STYLE (style), NULL);
return style->style;
}
GtkCssStyle *
gtk_css_animated_style_get_parent_style (GtkCssAnimatedStyle *style)
{
gtk_internal_return_val_if_fail (GTK_IS_CSS_ANIMATED_STYLE (style), NULL);
return style->parent_style;
}
GtkStyleProvider *
gtk_css_animated_style_get_provider (GtkCssAnimatedStyle *style)
{
gtk_internal_return_val_if_fail (GTK_IS_CSS_ANIMATED_STYLE (style), NULL);
return style->provider;
}
+3 -16
View File
@@ -38,8 +38,6 @@ struct _GtkCssAnimatedStyle
GtkCssStyle parent;
GtkCssStyle *style; /* the style if we weren't animating */
GtkCssStyle *parent_style;
GtkStyleProvider *provider;
gint64 current_time; /* the current time in our world */
gpointer *animations; /* GtkStyleAnimation**, least important one first */
@@ -59,26 +57,15 @@ GtkCssStyle * gtk_css_animated_style_new (GtkCssStyle
GtkStyleProvider *provider,
GtkCssStyle *previous_style);
GtkCssStyle * gtk_css_animated_style_new_advance (GtkCssAnimatedStyle *source,
GtkCssStyle *base_style,
GtkCssStyle *parent_style,
gint64 timestamp,
GtkStyleProvider *provider);
GtkCssStyle *base,
gint64 timestamp);
void gtk_css_animated_style_set_animated_value(GtkCssAnimatedStyle *style,
guint id,
GtkCssValue *value);
GtkCssValue * gtk_css_animated_style_get_intrinsic_value (GtkCssAnimatedStyle *style,
guint id);
void gtk_css_animated_style_set_animated_custom_value (GtkCssAnimatedStyle *animated,
int id,
GtkCssVariableValue *value);
GtkCssVariableValue * gtk_css_animated_style_get_intrinsic_custom_value (GtkCssAnimatedStyle *style,
int id);
GtkCssStyle * gtk_css_animated_style_get_base_style (GtkCssAnimatedStyle *style);
GtkCssStyle * gtk_css_animated_style_get_parent_style (GtkCssAnimatedStyle *style);
GtkStyleProvider * gtk_css_animated_style_get_provider (GtkCssAnimatedStyle *style);
G_END_DECLS
+3 -36
View File
@@ -90,9 +90,6 @@ gtk_css_animation_apply_values (GtkStyleAnimation *style_animation,
GtkCssAnimatedStyle *style)
{
GtkCssAnimation *animation = (GtkCssAnimation *)style_animation;
GtkCssStyle *base_style, *parent_style;
GtkStyleProvider *provider;
GtkCssKeyframes *resolved_keyframes;
double progress;
guint i;
@@ -102,49 +99,19 @@ gtk_css_animation_apply_values (GtkStyleAnimation *style_animation,
progress = gtk_css_animation_get_progress (animation);
progress = _gtk_css_ease_value_transform (animation->ease, progress);
base_style = gtk_css_animated_style_get_base_style (style);
parent_style = gtk_css_animated_style_get_parent_style (style);
provider = gtk_css_animated_style_get_provider (style);
resolved_keyframes = _gtk_css_keyframes_compute (animation->keyframes,
provider,
base_style,
parent_style);
for (i = 0; i < _gtk_css_keyframes_get_n_variables (resolved_keyframes); i++)
{
GtkCssVariableValue *value;
int variable_id;
variable_id = _gtk_css_keyframes_get_variable_id (resolved_keyframes, i);
value = _gtk_css_keyframes_get_variable (resolved_keyframes,
i,
progress,
gtk_css_animated_style_get_intrinsic_custom_value (style, variable_id));
if (!value)
continue;
gtk_css_animated_style_set_animated_custom_value (style, variable_id, value);
gtk_css_variable_value_unref (value);
}
for (i = 0; i < _gtk_css_keyframes_get_n_properties (resolved_keyframes); i++)
for (i = 0; i < _gtk_css_keyframes_get_n_properties (animation->keyframes); i++)
{
GtkCssValue *value;
guint property_id;
property_id = _gtk_css_keyframes_get_property_id (resolved_keyframes, i);
property_id = _gtk_css_keyframes_get_property_id (animation->keyframes, i);
value = _gtk_css_keyframes_get_value (resolved_keyframes,
value = _gtk_css_keyframes_get_value (animation->keyframes,
i,
progress,
gtk_css_animated_style_get_intrinsic_value (style, property_id));
gtk_css_animated_style_set_animated_value (style, property_id, value);
}
_gtk_css_keyframes_unref (resolved_keyframes);
}
static gboolean
+10 -15
View File
@@ -41,12 +41,11 @@ gtk_css_value_array_free (GtkCssValue *value)
}
static GtkCssValue *
gtk_css_value_array_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssVariableSet *variables)
gtk_css_value_array_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
GtkCssValue *result;
GtkCssValue *i_value;
@@ -55,7 +54,7 @@ gtk_css_value_array_compute (GtkCssValue *value,
result = NULL;
for (i = 0; i < value->n_values; i++)
{
i_value = _gtk_css_value_compute (value->values[i], property_id, provider, style, parent_style, variables);
i_value = _gtk_css_value_compute (value->values[i], property_id, provider, style, parent_style);
if (result == NULL &&
i_value != value->values[i])
@@ -403,13 +402,10 @@ _gtk_css_array_value_new_from_array (GtkCssValue **values,
for (i = 0; i < n_values; i ++)
{
if (!gtk_css_value_is_computed (values[i]))
result->is_computed = FALSE;
if (gtk_css_value_contains_variables (values[i]))
result->contains_variables = TRUE;
if (!result->is_computed && result->contains_variables)
break;
{
result->is_computed = FALSE;
break;
}
}
return result;
@@ -471,4 +467,3 @@ _gtk_css_array_value_get_n_values (const GtkCssValue *value)
return value->n_values;
}
+10 -11
View File
@@ -41,12 +41,11 @@ gtk_css_value_bg_size_free (GtkCssValue *value)
}
static GtkCssValue *
gtk_css_value_bg_size_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssVariableSet *variables)
gtk_css_value_bg_size_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
GtkCssValue *x, *y;
@@ -56,10 +55,10 @@ gtk_css_value_bg_size_compute (GtkCssValue *value,
x = y = NULL;
if (value->x)
x = _gtk_css_value_compute (value->x, property_id, provider, style, parent_style, variables);
x = _gtk_css_value_compute (value->x, property_id, provider, style, parent_style);
if (value->y)
y = _gtk_css_value_compute (value->y, property_id, provider, style, parent_style, variables);
y = _gtk_css_value_compute (value->y, property_id, provider, style, parent_style);
if (x == value->x && y == value->y)
{
@@ -164,9 +163,9 @@ static const GtkCssValueClass GTK_CSS_VALUE_BG_SIZE = {
gtk_css_value_bg_size_print
};
static GtkCssValue auto_singleton = { &GTK_CSS_VALUE_BG_SIZE, 1, TRUE, FALSE, FALSE, FALSE, NULL, NULL };
static GtkCssValue cover_singleton = { &GTK_CSS_VALUE_BG_SIZE, 1, TRUE, FALSE, TRUE, FALSE, NULL, NULL };
static GtkCssValue contain_singleton = { &GTK_CSS_VALUE_BG_SIZE, 1, TRUE, FALSE, FALSE, TRUE, NULL, NULL };
static GtkCssValue auto_singleton = { &GTK_CSS_VALUE_BG_SIZE, 1, TRUE, FALSE, FALSE, NULL, NULL };
static GtkCssValue cover_singleton = { &GTK_CSS_VALUE_BG_SIZE, 1, TRUE, TRUE, FALSE, NULL, NULL };
static GtkCssValue contain_singleton = { &GTK_CSS_VALUE_BG_SIZE, 1, TRUE, FALSE, TRUE, NULL, NULL };
GtkCssValue *
_gtk_css_bg_size_value_new (GtkCssValue *x,
+6 -8
View File
@@ -42,12 +42,11 @@ gtk_css_value_border_free (GtkCssValue *value)
}
static GtkCssValue *
gtk_css_value_border_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssVariableSet *variables)
gtk_css_value_border_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
GtkCssValue *values[4];
GtkCssValue *computed;
@@ -58,7 +57,7 @@ gtk_css_value_border_compute (GtkCssValue *value,
{
if (value->values[i])
{
values[i] = _gtk_css_value_compute (value->values[i], property_id, provider, style, parent_style, variables);
values[i] = _gtk_css_value_compute (value->values[i], property_id, provider, style, parent_style);
changed |= (values[i] != value->values[i]);
}
else
@@ -261,4 +260,3 @@ _gtk_css_border_value_get_left (const GtkCssValue *value)
return value->values[GTK_CSS_LEFT];
}
+14 -17
View File
@@ -94,11 +94,10 @@ gtk_css_value_color_free (GtkCssValue *color)
}
static GtkCssValue *
gtk_css_value_color_get_fallback (guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssVariableSet *variables)
gtk_css_value_color_get_fallback (guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
switch (property_id)
{
@@ -121,8 +120,7 @@ gtk_css_value_color_get_fallback (guint property_id,
property_id,
provider,
style,
parent_style,
variables);
parent_style);
case GTK_CSS_PROPERTY_ICON_PALETTE:
return _gtk_css_value_ref (style->core->color);
default:
@@ -134,12 +132,11 @@ gtk_css_value_color_get_fallback (guint property_id,
}
static GtkCssValue *
gtk_css_value_color_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssVariableSet *variables)
gtk_css_value_color_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
GtkCssValue *resolved;
@@ -176,7 +173,7 @@ gtk_css_value_color_compute (GtkCssValue *value,
}
if (resolved == NULL)
return gtk_css_value_color_get_fallback (property_id, provider, style, parent_style, variables);
return gtk_css_value_color_get_fallback (property_id, provider, style, parent_style);
return resolved;
}
@@ -487,9 +484,9 @@ _gtk_css_color_value_resolve (GtkCssValue *color,
return value;
}
static GtkCssValue transparent_black_singleton = { &GTK_CSS_VALUE_COLOR, 1, TRUE, FALSE, COLOR_TYPE_LITERAL, NULL,
static GtkCssValue transparent_black_singleton = { &GTK_CSS_VALUE_COLOR, 1, TRUE, COLOR_TYPE_LITERAL, NULL,
.sym_col.rgba = {0, 0, 0, 0} };
static GtkCssValue white_singleton = { &GTK_CSS_VALUE_COLOR, 1, TRUE, FALSE, COLOR_TYPE_LITERAL, NULL,
static GtkCssValue white_singleton = { &GTK_CSS_VALUE_COLOR, 1, TRUE, COLOR_TYPE_LITERAL, NULL,
.sym_col.rgba = {1, 1, 1, 1} };
@@ -623,7 +620,7 @@ _gtk_css_color_value_new_mix (GtkCssValue *color1,
GtkCssValue *
_gtk_css_color_value_new_current_color (void)
{
static GtkCssValue current_color = { &GTK_CSS_VALUE_COLOR, 1, FALSE, FALSE, COLOR_TYPE_CURRENT_COLOR, NULL, };
static GtkCssValue current_color = { &GTK_CSS_VALUE_COLOR, 1, FALSE, COLOR_TYPE_CURRENT_COLOR, NULL, };
return _gtk_css_value_ref (&current_color);
}
+15 -17
View File
@@ -37,17 +37,16 @@ gtk_css_value_corner_free (GtkCssValue *value)
}
static GtkCssValue *
gtk_css_value_corner_compute (GtkCssValue *corner,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssVariableSet *variables)
gtk_css_value_corner_compute (GtkCssValue *corner,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
GtkCssValue *x, *y;
x = _gtk_css_value_compute (corner->x, property_id, provider, style, parent_style, variables);
y = _gtk_css_value_compute (corner->y, property_id, provider, style, parent_style, variables);
x = _gtk_css_value_compute (corner->x, property_id, provider, style, parent_style);
y = _gtk_css_value_compute (corner->y, property_id, provider, style, parent_style);
if (x == corner->x && y == corner->y)
{
_gtk_css_value_unref (x);
@@ -111,14 +110,14 @@ static const GtkCssValueClass GTK_CSS_VALUE_CORNER = {
};
static GtkCssValue corner_singletons[] = {
{ &GTK_CSS_VALUE_CORNER, 1, TRUE, FALSE, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, TRUE, FALSE, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, TRUE, FALSE, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, TRUE, FALSE, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, TRUE, FALSE, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, TRUE, FALSE, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, TRUE, FALSE, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, TRUE, FALSE, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, TRUE, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, TRUE, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, TRUE, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, TRUE, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, TRUE, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, TRUE, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, TRUE, NULL, NULL },
{ &GTK_CSS_VALUE_CORNER, 1, TRUE, NULL, NULL },
};
static inline void
@@ -227,4 +226,3 @@ gtk_css_corner_value_is_zero (const GtkCssValue *corner)
return gtk_css_dimension_value_is_zero (corner->x) &&
gtk_css_dimension_value_is_zero (corner->y);
}
-161
View File
@@ -1,161 +0,0 @@
/*
* Copyright (C) 2023 GNOME Foundation Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Alice Mikhaylenko <alicem@gnome.org>
*/
#include "gtkcsscustompropertypoolprivate.h"
struct _GtkCssCustomPropertyPool
{
GObject parent_instance;
GArray *names;
GHashTable *name_mappings;
};
struct _GtkCssCustomPropertyName
{
int ref_count;
char *name;
};
typedef struct _GtkCssCustomPropertyName GtkCssCustomPropertyName;
static GtkCssCustomPropertyPool *instance = NULL;
G_DEFINE_FINAL_TYPE (GtkCssCustomPropertyPool, gtk_css_custom_property_pool, G_TYPE_OBJECT)
static void
clear_custom_property_name (GtkCssCustomPropertyName *name)
{
g_clear_pointer (&name->name, g_free);
}
static void
gtk_css_custom_property_pool_finalize (GObject *object)
{
GtkCssCustomPropertyPool *self = (GtkCssCustomPropertyPool *)object;
g_hash_table_unref (self->name_mappings);
g_array_unref (self->names);
G_OBJECT_CLASS (gtk_css_custom_property_pool_parent_class)->finalize (object);
}
static void
gtk_css_custom_property_pool_class_init (GtkCssCustomPropertyPoolClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = gtk_css_custom_property_pool_finalize;
}
static void
gtk_css_custom_property_pool_init (GtkCssCustomPropertyPool *self)
{
self->name_mappings = g_hash_table_new (g_str_hash, g_str_equal);
self->names = g_array_new (FALSE, FALSE, sizeof (GtkCssCustomPropertyName));
g_array_set_clear_func (self->names, (GDestroyNotify) clear_custom_property_name);
}
GtkCssCustomPropertyPool *
gtk_css_custom_property_pool_get (void)
{
if (instance == NULL)
instance = g_object_new (GTK_TYPE_CSS_CUSTOM_PROPERTY_POOL, NULL);
return instance;
}
int
gtk_css_custom_property_pool_add (GtkCssCustomPropertyPool *self,
const char *str)
{
GtkCssCustomPropertyName name;
int id;
id = gtk_css_custom_property_pool_lookup (self, str);
if (id > 0)
return gtk_css_custom_property_pool_ref (self, id);
name.ref_count = 1;
name.name = g_strdup (str);
// TODO reuse slots after they're gone
g_array_append_val (self->names, name);
id = self->names->len;
g_hash_table_insert (self->name_mappings, (char *) name.name, GINT_TO_POINTER (id));
return id;
}
int
gtk_css_custom_property_pool_lookup (GtkCssCustomPropertyPool *self,
const char *str)
{
gpointer id;
id = g_hash_table_lookup (self->name_mappings, str);
return GPOINTER_TO_INT (id);
}
int
gtk_css_custom_property_pool_ref (GtkCssCustomPropertyPool *self,
int id)
{
GtkCssCustomPropertyName *name;
name = &g_array_index (self->names, GtkCssCustomPropertyName, id - 1);
name->ref_count++;
return id;
}
void
gtk_css_custom_property_pool_unref (GtkCssCustomPropertyPool *self,
int id)
{
GtkCssCustomPropertyName *name;
name = &g_array_index (self->names, GtkCssCustomPropertyName, id - 1);
g_assert (name->ref_count > 0);
name->ref_count--;
if (name->ref_count == 0)
{
g_hash_table_remove (self->name_mappings, name->name);
clear_custom_property_name (name);
}
}
const char *
gtk_css_custom_property_pool_get_name (GtkCssCustomPropertyPool *self,
int id)
{
GtkCssCustomPropertyName *name;
name = &g_array_index (self->names, GtkCssCustomPropertyName, id - 1);
return name->name;
}
-43
View File
@@ -1,43 +0,0 @@
/*
* Copyright (C) 2023 GNOME Foundation Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Alice Mikhaylenko <alicem@gnome.org>
*/
#pragma once
#include <glib-object.h>
G_BEGIN_DECLS
#define GTK_TYPE_CSS_CUSTOM_PROPERTY_POOL (gtk_css_custom_property_pool_get_type())
G_DECLARE_FINAL_TYPE (GtkCssCustomPropertyPool, gtk_css_custom_property_pool, GTK, CSS_CUSTOM_PROPERTY_POOL, GObject)
GtkCssCustomPropertyPool *gtk_css_custom_property_pool_get (void);
int gtk_css_custom_property_pool_add (GtkCssCustomPropertyPool *self,
const char *str);
int gtk_css_custom_property_pool_lookup (GtkCssCustomPropertyPool *self,
const char *str);
const char * gtk_css_custom_property_pool_get_name (GtkCssCustomPropertyPool *self,
int id);
int gtk_css_custom_property_pool_ref (GtkCssCustomPropertyPool *self,
int id);
void gtk_css_custom_property_pool_unref (GtkCssCustomPropertyPool *self,
int id);
G_END_DECLS
+5 -7
View File
@@ -50,12 +50,11 @@ gtk_css_value_ease_free (GtkCssValue *value)
}
static GtkCssValue *
gtk_css_value_ease_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssVariableSet *variables)
gtk_css_value_ease_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
return _gtk_css_value_ref (value);
}
@@ -408,4 +407,3 @@ _gtk_css_ease_value_transform (const GtkCssValue *ease,
}
+102 -105
View File
@@ -41,12 +41,11 @@ gtk_css_value_enum_free (GtkCssValue *value)
}
static GtkCssValue *
gtk_css_value_enum_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssVariableSet *variables)
gtk_css_value_enum_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
return _gtk_css_value_ref (value);
}
@@ -88,16 +87,16 @@ static const GtkCssValueClass GTK_CSS_VALUE_BORDER_STYLE = {
};
static GtkCssValue border_style_values[] = {
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, FALSE, GTK_BORDER_STYLE_NONE, "none" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, FALSE, GTK_BORDER_STYLE_SOLID, "solid" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, FALSE, GTK_BORDER_STYLE_INSET, "inset" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, FALSE, GTK_BORDER_STYLE_OUTSET, "outset" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, FALSE, GTK_BORDER_STYLE_HIDDEN, "hidden" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, FALSE, GTK_BORDER_STYLE_DOTTED, "dotted" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, FALSE, GTK_BORDER_STYLE_DASHED, "dashed" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, FALSE, GTK_BORDER_STYLE_DOUBLE, "double" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, FALSE, GTK_BORDER_STYLE_GROOVE, "groove" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, FALSE, GTK_BORDER_STYLE_RIDGE, "ridge" }
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, GTK_BORDER_STYLE_NONE, "none" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, GTK_BORDER_STYLE_SOLID, "solid" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, GTK_BORDER_STYLE_INSET, "inset" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, GTK_BORDER_STYLE_OUTSET, "outset" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, GTK_BORDER_STYLE_HIDDEN, "hidden" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, GTK_BORDER_STYLE_DOTTED, "dotted" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, GTK_BORDER_STYLE_DASHED, "dashed" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, GTK_BORDER_STYLE_DOUBLE, "double" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, GTK_BORDER_STYLE_GROOVE, "groove" },
{ &GTK_CSS_VALUE_BORDER_STYLE, 1, TRUE, GTK_BORDER_STYLE_RIDGE, "ridge" }
};
GtkCssValue *
@@ -146,22 +145,22 @@ static const GtkCssValueClass GTK_CSS_VALUE_BLEND_MODE = {
};
static GtkCssValue blend_mode_values[] = {
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_DEFAULT, "normal" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_MULTIPLY, "multiply" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_SCREEN, "screen" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_OVERLAY, "overlay" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_DARKEN, "darken" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_LIGHTEN, "lighten" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_COLOR_DODGE, "color-dodge" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_COLOR_BURN, "color-burn" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_HARD_LIGHT, "hard-light" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_SOFT_LIGHT, "soft-light" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_DIFFERENCE, "difference" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_EXCLUSION, "exclusion" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_COLOR, "color" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_HUE, "hue" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_SATURATION, "saturation" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_LUMINOSITY, "luminosity" }
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_DEFAULT, "normal" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_MULTIPLY, "multiply" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_SCREEN, "screen" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_OVERLAY, "overlay" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_DARKEN, "darken" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_LIGHTEN, "lighten" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_COLOR_DODGE, "color-dodge" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_COLOR_BURN, "color-burn" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_HARD_LIGHT, "hard-light" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_SOFT_LIGHT, "soft-light" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_DIFFERENCE, "difference" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_EXCLUSION, "exclusion" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_COLOR, "color" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_HUE, "hue" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_SATURATION, "saturation" },
{ &GTK_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_LUMINOSITY, "luminosity" }
};
GtkCssValue *
@@ -230,12 +229,11 @@ gtk_css_font_size_get_default_px (GtkStyleProvider *provider,
}
static GtkCssValue *
gtk_css_value_font_size_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssVariableSet *variables)
gtk_css_value_font_size_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
double font_size;
@@ -298,15 +296,15 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_SIZE = {
};
static GtkCssValue font_size_values[] = {
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, FALSE, GTK_CSS_FONT_SIZE_SMALLER, "smaller" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, FALSE, GTK_CSS_FONT_SIZE_LARGER, "larger" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, FALSE, GTK_CSS_FONT_SIZE_XX_SMALL, "xx-small" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, FALSE, GTK_CSS_FONT_SIZE_X_SMALL, "x-small" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, FALSE, GTK_CSS_FONT_SIZE_SMALL, "small" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, FALSE, GTK_CSS_FONT_SIZE_MEDIUM, "medium" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, FALSE, GTK_CSS_FONT_SIZE_LARGE, "large" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, FALSE, GTK_CSS_FONT_SIZE_X_LARGE, "x-large" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, FALSE, GTK_CSS_FONT_SIZE_XX_LARGE, "xx-large" }
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, GTK_CSS_FONT_SIZE_SMALLER, "smaller" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, GTK_CSS_FONT_SIZE_LARGER, "larger" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, GTK_CSS_FONT_SIZE_XX_SMALL, "xx-small" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, GTK_CSS_FONT_SIZE_X_SMALL, "x-small" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, GTK_CSS_FONT_SIZE_SMALL, "small" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, GTK_CSS_FONT_SIZE_MEDIUM, "medium" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, GTK_CSS_FONT_SIZE_LARGE, "large" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, GTK_CSS_FONT_SIZE_X_LARGE, "x-large" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, FALSE, GTK_CSS_FONT_SIZE_XX_LARGE, "xx-large" }
};
GtkCssValue *
@@ -355,9 +353,9 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_STYLE = {
};
static GtkCssValue font_style_values[] = {
{ &GTK_CSS_VALUE_FONT_STYLE, 1, TRUE, FALSE, PANGO_STYLE_NORMAL, "normal" },
{ &GTK_CSS_VALUE_FONT_STYLE, 1, TRUE, FALSE, PANGO_STYLE_OBLIQUE, "oblique" },
{ &GTK_CSS_VALUE_FONT_STYLE, 1, TRUE, FALSE, PANGO_STYLE_ITALIC, "italic" }
{ &GTK_CSS_VALUE_FONT_STYLE, 1, TRUE, PANGO_STYLE_NORMAL, "normal" },
{ &GTK_CSS_VALUE_FONT_STYLE, 1, TRUE, PANGO_STYLE_OBLIQUE, "oblique" },
{ &GTK_CSS_VALUE_FONT_STYLE, 1, TRUE, PANGO_STYLE_ITALIC, "italic" }
};
GtkCssValue *
@@ -398,12 +396,11 @@ _gtk_css_font_style_value_get (const GtkCssValue *value)
#define LIGHTER -2
static GtkCssValue *
gtk_css_value_font_weight_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssVariableSet *variables)
gtk_css_value_font_weight_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
PangoWeight new_weight;
int parent_value;
@@ -455,8 +452,8 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_WEIGHT = {
};
static GtkCssValue font_weight_values[] = {
{ &GTK_CSS_VALUE_FONT_WEIGHT, 1, FALSE, FALSE, BOLDER, "bolder" },
{ &GTK_CSS_VALUE_FONT_WEIGHT, 1, FALSE, FALSE, LIGHTER, "lighter" },
{ &GTK_CSS_VALUE_FONT_WEIGHT, 1, FALSE, BOLDER, "bolder" },
{ &GTK_CSS_VALUE_FONT_WEIGHT, 1, FALSE, LIGHTER, "lighter" },
};
GtkCssValue *
@@ -505,15 +502,15 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_STRETCH = {
};
static GtkCssValue font_stretch_values[] = {
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, FALSE, PANGO_STRETCH_ULTRA_CONDENSED, "ultra-condensed" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, FALSE, PANGO_STRETCH_EXTRA_CONDENSED, "extra-condensed" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, FALSE, PANGO_STRETCH_CONDENSED, "condensed" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, FALSE, PANGO_STRETCH_SEMI_CONDENSED, "semi-condensed" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, FALSE, PANGO_STRETCH_NORMAL, "normal" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, FALSE, PANGO_STRETCH_SEMI_EXPANDED, "semi-expanded" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, FALSE, PANGO_STRETCH_EXPANDED, "expanded" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, FALSE, PANGO_STRETCH_EXTRA_EXPANDED, "extra-expanded" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, FALSE, PANGO_STRETCH_ULTRA_EXPANDED, "ultra-expanded" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, PANGO_STRETCH_ULTRA_CONDENSED, "ultra-condensed" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, PANGO_STRETCH_EXTRA_CONDENSED, "extra-condensed" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, PANGO_STRETCH_CONDENSED, "condensed" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, PANGO_STRETCH_SEMI_CONDENSED, "semi-condensed" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, PANGO_STRETCH_NORMAL, "normal" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, PANGO_STRETCH_SEMI_EXPANDED, "semi-expanded" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, PANGO_STRETCH_EXPANDED, "expanded" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, PANGO_STRETCH_EXTRA_EXPANDED, "extra-expanded" },
{ &GTK_CSS_VALUE_FONT_STRETCH, 1, TRUE, PANGO_STRETCH_ULTRA_EXPANDED, "ultra-expanded" },
};
GtkCssValue *
@@ -562,9 +559,9 @@ static const GtkCssValueClass GTK_CSS_VALUE_TEXT_DECORATION_STYLE = {
};
static GtkCssValue text_decoration_style_values[] = {
{ &GTK_CSS_VALUE_TEXT_DECORATION_STYLE, 1, TRUE, FALSE, GTK_CSS_TEXT_DECORATION_STYLE_SOLID, "solid" },
{ &GTK_CSS_VALUE_TEXT_DECORATION_STYLE, 1, TRUE, FALSE, GTK_CSS_TEXT_DECORATION_STYLE_DOUBLE, "double" },
{ &GTK_CSS_VALUE_TEXT_DECORATION_STYLE, 1, TRUE, FALSE, GTK_CSS_TEXT_DECORATION_STYLE_WAVY, "wavy" },
{ &GTK_CSS_VALUE_TEXT_DECORATION_STYLE, 1, TRUE, GTK_CSS_TEXT_DECORATION_STYLE_SOLID, "solid" },
{ &GTK_CSS_VALUE_TEXT_DECORATION_STYLE, 1, TRUE, GTK_CSS_TEXT_DECORATION_STYLE_DOUBLE, "double" },
{ &GTK_CSS_VALUE_TEXT_DECORATION_STYLE, 1, TRUE, GTK_CSS_TEXT_DECORATION_STYLE_WAVY, "wavy" },
};
GtkCssValue *
@@ -613,9 +610,9 @@ static const GtkCssValueClass GTK_CSS_VALUE_AREA = {
};
static GtkCssValue area_values[] = {
{ &GTK_CSS_VALUE_AREA, 1, TRUE, FALSE, GTK_CSS_AREA_BORDER_BOX, "border-box" },
{ &GTK_CSS_VALUE_AREA, 1, TRUE, FALSE, GTK_CSS_AREA_PADDING_BOX, "padding-box" },
{ &GTK_CSS_VALUE_AREA, 1, TRUE, FALSE, GTK_CSS_AREA_CONTENT_BOX, "content-box" }
{ &GTK_CSS_VALUE_AREA, 1, TRUE, GTK_CSS_AREA_BORDER_BOX, "border-box" },
{ &GTK_CSS_VALUE_AREA, 1, TRUE, GTK_CSS_AREA_PADDING_BOX, "padding-box" },
{ &GTK_CSS_VALUE_AREA, 1, TRUE, GTK_CSS_AREA_CONTENT_BOX, "content-box" }
};
GtkCssValue *
@@ -670,10 +667,10 @@ static const GtkCssValueClass GTK_CSS_VALUE_DIRECTION = {
};
static GtkCssValue direction_values[] = {
{ &GTK_CSS_VALUE_DIRECTION, 1, TRUE, FALSE, GTK_CSS_DIRECTION_NORMAL, "normal" },
{ &GTK_CSS_VALUE_DIRECTION, 1, TRUE, FALSE, GTK_CSS_DIRECTION_REVERSE, "reverse" },
{ &GTK_CSS_VALUE_DIRECTION, 1, TRUE, FALSE, GTK_CSS_DIRECTION_ALTERNATE, "alternate" },
{ &GTK_CSS_VALUE_DIRECTION, 1, TRUE, FALSE, GTK_CSS_DIRECTION_ALTERNATE_REVERSE, "alternate-reverse" }
{ &GTK_CSS_VALUE_DIRECTION, 1, TRUE, GTK_CSS_DIRECTION_NORMAL, "normal" },
{ &GTK_CSS_VALUE_DIRECTION, 1, TRUE, GTK_CSS_DIRECTION_REVERSE, "reverse" },
{ &GTK_CSS_VALUE_DIRECTION, 1, TRUE, GTK_CSS_DIRECTION_ALTERNATE, "alternate" },
{ &GTK_CSS_VALUE_DIRECTION, 1, TRUE, GTK_CSS_DIRECTION_ALTERNATE_REVERSE, "alternate-reverse" }
};
GtkCssValue *
@@ -731,8 +728,8 @@ static const GtkCssValueClass GTK_CSS_VALUE_PLAY_STATE = {
};
static GtkCssValue play_state_values[] = {
{ &GTK_CSS_VALUE_PLAY_STATE, 1, TRUE, FALSE, GTK_CSS_PLAY_STATE_RUNNING, "running" },
{ &GTK_CSS_VALUE_PLAY_STATE, 1, TRUE, FALSE, GTK_CSS_PLAY_STATE_PAUSED, "paused" }
{ &GTK_CSS_VALUE_PLAY_STATE, 1, TRUE, GTK_CSS_PLAY_STATE_RUNNING, "running" },
{ &GTK_CSS_VALUE_PLAY_STATE, 1, TRUE, GTK_CSS_PLAY_STATE_PAUSED, "paused" }
};
GtkCssValue *
@@ -787,10 +784,10 @@ static const GtkCssValueClass GTK_CSS_VALUE_FILL_MODE = {
};
static GtkCssValue fill_mode_values[] = {
{ &GTK_CSS_VALUE_FILL_MODE, 1, TRUE, FALSE, GTK_CSS_FILL_NONE, "none" },
{ &GTK_CSS_VALUE_FILL_MODE, 1, TRUE, FALSE, GTK_CSS_FILL_FORWARDS, "forwards" },
{ &GTK_CSS_VALUE_FILL_MODE, 1, TRUE, FALSE, GTK_CSS_FILL_BACKWARDS, "backwards" },
{ &GTK_CSS_VALUE_FILL_MODE, 1, TRUE, FALSE, GTK_CSS_FILL_BOTH, "both" }
{ &GTK_CSS_VALUE_FILL_MODE, 1, TRUE, GTK_CSS_FILL_NONE, "none" },
{ &GTK_CSS_VALUE_FILL_MODE, 1, TRUE, GTK_CSS_FILL_FORWARDS, "forwards" },
{ &GTK_CSS_VALUE_FILL_MODE, 1, TRUE, GTK_CSS_FILL_BACKWARDS, "backwards" },
{ &GTK_CSS_VALUE_FILL_MODE, 1, TRUE, GTK_CSS_FILL_BOTH, "both" }
};
GtkCssValue *
@@ -845,9 +842,9 @@ static const GtkCssValueClass GTK_CSS_VALUE_ICON_STYLE = {
};
static GtkCssValue icon_style_values[] = {
{ &GTK_CSS_VALUE_ICON_STYLE, 1, TRUE, FALSE, GTK_CSS_ICON_STYLE_REQUESTED, "requested" },
{ &GTK_CSS_VALUE_ICON_STYLE, 1, TRUE, FALSE, GTK_CSS_ICON_STYLE_REGULAR, "regular" },
{ &GTK_CSS_VALUE_ICON_STYLE, 1, TRUE, FALSE, GTK_CSS_ICON_STYLE_SYMBOLIC, "symbolic" }
{ &GTK_CSS_VALUE_ICON_STYLE, 1, TRUE, GTK_CSS_ICON_STYLE_REQUESTED, "requested" },
{ &GTK_CSS_VALUE_ICON_STYLE, 1, TRUE, GTK_CSS_ICON_STYLE_REGULAR, "regular" },
{ &GTK_CSS_VALUE_ICON_STYLE, 1, TRUE, GTK_CSS_ICON_STYLE_SYMBOLIC, "symbolic" }
};
GtkCssValue *
@@ -902,9 +899,9 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_KERNING = {
};
static GtkCssValue font_kerning_values[] = {
{ &GTK_CSS_VALUE_FONT_KERNING, 1, TRUE, FALSE, GTK_CSS_FONT_KERNING_AUTO, "auto" },
{ &GTK_CSS_VALUE_FONT_KERNING, 1, TRUE, FALSE, GTK_CSS_FONT_KERNING_NORMAL, "normal" },
{ &GTK_CSS_VALUE_FONT_KERNING, 1, TRUE, FALSE, GTK_CSS_FONT_KERNING_NONE, "none" }
{ &GTK_CSS_VALUE_FONT_KERNING, 1, TRUE, GTK_CSS_FONT_KERNING_AUTO, "auto" },
{ &GTK_CSS_VALUE_FONT_KERNING, 1, TRUE, GTK_CSS_FONT_KERNING_NORMAL, "normal" },
{ &GTK_CSS_VALUE_FONT_KERNING, 1, TRUE, GTK_CSS_FONT_KERNING_NONE, "none" }
};
GtkCssValue *
@@ -959,9 +956,9 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_VARIANT_POSITION = {
};
static GtkCssValue font_variant_position_values[] = {
{ &GTK_CSS_VALUE_FONT_VARIANT_POSITION, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_POSITION_NORMAL, "normal" },
{ &GTK_CSS_VALUE_FONT_VARIANT_POSITION, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_POSITION_SUB, "sub" },
{ &GTK_CSS_VALUE_FONT_VARIANT_POSITION, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_POSITION_SUPER, "super" }
{ &GTK_CSS_VALUE_FONT_VARIANT_POSITION, 1, TRUE, GTK_CSS_FONT_VARIANT_POSITION_NORMAL, "normal" },
{ &GTK_CSS_VALUE_FONT_VARIANT_POSITION, 1, TRUE, GTK_CSS_FONT_VARIANT_POSITION_SUB, "sub" },
{ &GTK_CSS_VALUE_FONT_VARIANT_POSITION, 1, TRUE, GTK_CSS_FONT_VARIANT_POSITION_SUPER, "super" }
};
GtkCssValue *
@@ -1016,13 +1013,13 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_VARIANT_CAPS = {
};
static GtkCssValue font_variant_caps_values[] = {
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_CAPS_NORMAL, "normal" },
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_CAPS_SMALL_CAPS, "small-caps" },
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_CAPS_ALL_SMALL_CAPS, "all-small-caps" },
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_CAPS_PETITE_CAPS, "petite-caps" },
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_CAPS_ALL_PETITE_CAPS, "all-petite-caps" },
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_CAPS_UNICASE, "unicase" },
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_CAPS_TITLING_CAPS, "titling-caps" }
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, GTK_CSS_FONT_VARIANT_CAPS_NORMAL, "normal" },
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, GTK_CSS_FONT_VARIANT_CAPS_SMALL_CAPS, "small-caps" },
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, GTK_CSS_FONT_VARIANT_CAPS_ALL_SMALL_CAPS, "all-small-caps" },
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, GTK_CSS_FONT_VARIANT_CAPS_PETITE_CAPS, "petite-caps" },
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, GTK_CSS_FONT_VARIANT_CAPS_ALL_PETITE_CAPS, "all-petite-caps" },
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, GTK_CSS_FONT_VARIANT_CAPS_UNICASE, "unicase" },
{ &GTK_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, GTK_CSS_FONT_VARIANT_CAPS_TITLING_CAPS, "titling-caps" }
};
GtkCssValue *
@@ -1077,8 +1074,8 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_VARIANT_ALTERNATE = {
};
static GtkCssValue font_variant_alternate_values[] = {
{ &GTK_CSS_VALUE_FONT_VARIANT_ALTERNATE, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_ALTERNATE_NORMAL, "normal" },
{ &GTK_CSS_VALUE_FONT_VARIANT_ALTERNATE, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_ALTERNATE_HISTORICAL_FORMS, "historical-forms" }
{ &GTK_CSS_VALUE_FONT_VARIANT_ALTERNATE, 1, TRUE, GTK_CSS_FONT_VARIANT_ALTERNATE_NORMAL, "normal" },
{ &GTK_CSS_VALUE_FONT_VARIANT_ALTERNATE, 1, TRUE, GTK_CSS_FONT_VARIANT_ALTERNATE_HISTORICAL_FORMS, "historical-forms" }
};
GtkCssValue *
@@ -1586,10 +1583,10 @@ static const GtkCssValueClass GTK_CSS_VALUE_TEXT_TRANSFORM = {
};
static GtkCssValue text_transform_values[] = {
{ &GTK_CSS_VALUE_TEXT_TRANSFORM, 1, TRUE, FALSE, GTK_CSS_TEXT_TRANSFORM_NONE, "none" },
{ &GTK_CSS_VALUE_TEXT_TRANSFORM, 1, TRUE, FALSE, GTK_CSS_TEXT_TRANSFORM_LOWERCASE, "lowercase" },
{ &GTK_CSS_VALUE_TEXT_TRANSFORM, 1, TRUE, FALSE, GTK_CSS_TEXT_TRANSFORM_UPPERCASE, "uppercase" },
{ &GTK_CSS_VALUE_TEXT_TRANSFORM, 1, TRUE, FALSE, GTK_CSS_TEXT_TRANSFORM_CAPITALIZE, "capitalize" },
{ &GTK_CSS_VALUE_TEXT_TRANSFORM, 1, TRUE, GTK_CSS_TEXT_TRANSFORM_NONE, "none" },
{ &GTK_CSS_VALUE_TEXT_TRANSFORM, 1, TRUE, GTK_CSS_TEXT_TRANSFORM_LOWERCASE, "lowercase" },
{ &GTK_CSS_VALUE_TEXT_TRANSFORM, 1, TRUE, GTK_CSS_TEXT_TRANSFORM_UPPERCASE, "uppercase" },
{ &GTK_CSS_VALUE_TEXT_TRANSFORM, 1, TRUE, GTK_CSS_TEXT_TRANSFORM_CAPITALIZE, "capitalize" },
};
GtkCssValue *
+23 -26
View File
@@ -307,56 +307,55 @@ gtk_css_value_filter_free (GtkCssValue *value)
/* returns TRUE if dest == src */
static gboolean
gtk_css_filter_compute (GtkCssFilter *dest,
GtkCssFilter *src,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssVariableSet *variables)
gtk_css_filter_compute (GtkCssFilter *dest,
GtkCssFilter *src,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
dest->type = src->type;
switch (src->type)
{
case GTK_CSS_FILTER_BRIGHTNESS:
dest->brightness.value = _gtk_css_value_compute (src->brightness.value, property_id, provider, style, parent_style, variables);
dest->brightness.value = _gtk_css_value_compute (src->brightness.value, property_id, provider, style, parent_style);
return dest->brightness.value == src->brightness.value;
case GTK_CSS_FILTER_CONTRAST:
dest->contrast.value = _gtk_css_value_compute (src->contrast.value, property_id, provider, style, parent_style, variables);
dest->contrast.value = _gtk_css_value_compute (src->contrast.value, property_id, provider, style, parent_style);
return dest->contrast.value == src->contrast.value;
case GTK_CSS_FILTER_GRAYSCALE:
dest->grayscale.value = _gtk_css_value_compute (src->grayscale.value, property_id, provider, style, parent_style, variables);
dest->grayscale.value = _gtk_css_value_compute (src->grayscale.value, property_id, provider, style, parent_style);
return dest->grayscale.value == src->grayscale.value;
case GTK_CSS_FILTER_HUE_ROTATE:
dest->hue_rotate.value = _gtk_css_value_compute (src->hue_rotate.value, property_id, provider, style, parent_style, variables);
dest->hue_rotate.value = _gtk_css_value_compute (src->hue_rotate.value, property_id, provider, style, parent_style);
return dest->hue_rotate.value == src->hue_rotate.value;
case GTK_CSS_FILTER_INVERT:
dest->invert.value = _gtk_css_value_compute (src->invert.value, property_id, provider, style, parent_style, variables);
dest->invert.value = _gtk_css_value_compute (src->invert.value, property_id, provider, style, parent_style);
return dest->invert.value == src->invert.value;
case GTK_CSS_FILTER_OPACITY:
dest->opacity.value = _gtk_css_value_compute (src->opacity.value, property_id, provider, style, parent_style, variables);
dest->opacity.value = _gtk_css_value_compute (src->opacity.value, property_id, provider, style, parent_style);
return dest->opacity.value == src->opacity.value;
case GTK_CSS_FILTER_SATURATE:
dest->saturate.value = _gtk_css_value_compute (src->saturate.value, property_id, provider, style, parent_style, variables);
dest->saturate.value = _gtk_css_value_compute (src->saturate.value, property_id, provider, style, parent_style);
return dest->saturate.value == src->saturate.value;
case GTK_CSS_FILTER_SEPIA:
dest->sepia.value = _gtk_css_value_compute (src->sepia.value, property_id, provider, style, parent_style, variables);
dest->sepia.value = _gtk_css_value_compute (src->sepia.value, property_id, provider, style, parent_style);
return dest->sepia.value == src->sepia.value;
case GTK_CSS_FILTER_BLUR:
dest->blur.value = _gtk_css_value_compute (src->blur.value, property_id, provider, style, parent_style, variables);
dest->blur.value = _gtk_css_value_compute (src->blur.value, property_id, provider, style, parent_style);
return dest->blur.value == src->blur.value;
case GTK_CSS_FILTER_DROP_SHADOW:
dest->drop_shadow.value = _gtk_css_value_compute (src->drop_shadow.value, property_id, provider, style, parent_style, variables);
dest->drop_shadow.value = _gtk_css_value_compute (src->drop_shadow.value, property_id, provider, style, parent_style);
return dest->drop_shadow.value == src->drop_shadow.value;
case GTK_CSS_FILTER_NONE:
@@ -367,12 +366,11 @@ gtk_css_filter_compute (GtkCssFilter *dest,
}
static GtkCssValue *
gtk_css_value_filter_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssVariableSet *variables)
gtk_css_value_filter_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
GtkCssValue *result;
gboolean changes;
@@ -392,8 +390,7 @@ gtk_css_value_filter_compute (GtkCssValue *value,
property_id,
provider,
style,
parent_style,
variables);
parent_style);
}
if (!changes)
@@ -726,7 +723,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_FILTER = {
gtk_css_value_filter_print
};
static GtkCssValue filter_none_singleton = { &GTK_CSS_VALUE_FILTER, 1, TRUE, FALSE, 0, { { GTK_CSS_FILTER_NONE } } };
static GtkCssValue filter_none_singleton = { &GTK_CSS_VALUE_FILTER, 1, TRUE, 0, { { GTK_CSS_FILTER_NONE } } };
static GtkCssValue *
gtk_css_filter_value_alloc (guint n_filters)
+5 -6
View File
@@ -53,12 +53,11 @@ gtk_css_value_font_features_free (GtkCssValue *value)
}
static GtkCssValue *
gtk_css_value_font_features_compute (GtkCssValue *specified,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssVariableSet *variables)
gtk_css_value_font_features_compute (GtkCssValue *specified,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
return _gtk_css_value_ref (specified);
}
+5 -6
View File
@@ -52,12 +52,11 @@ gtk_css_value_font_variations_free (GtkCssValue *value)
}
static GtkCssValue *
gtk_css_value_font_variations_compute (GtkCssValue *specified,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssVariableSet *variables)
gtk_css_value_font_variations_compute (GtkCssValue *specified,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
return _gtk_css_value_ref (specified);
}
+11 -13
View File
@@ -65,12 +65,11 @@ gtk_css_image_real_get_aspect_ratio (GtkCssImage *image)
}
static GtkCssImage *
gtk_css_image_real_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssVariableSet *variables)
gtk_css_image_real_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
return g_object_ref (image);
}
@@ -174,12 +173,11 @@ _gtk_css_image_get_aspect_ratio (GtkCssImage *image)
}
GtkCssImage *
_gtk_css_image_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssVariableSet *variables)
_gtk_css_image_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
GtkCssImageClass *klass;
@@ -189,7 +187,7 @@ _gtk_css_image_compute (GtkCssImage *image,
klass = GTK_CSS_IMAGE_GET_CLASS (image);
return klass->compute (image, property_id, provider, style, parent_style, variables);
return klass->compute (image, property_id, provider, style, parent_style);
}
GtkCssImage *
+9 -10
View File
@@ -313,12 +313,11 @@ gtk_css_image_conic_print (GtkCssImage *image,
}
static GtkCssImage *
gtk_css_image_conic_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssVariableSet *variables)
gtk_css_image_conic_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
GtkCssImageConic *self = GTK_CSS_IMAGE_CONIC (image);
GtkCssImageConic *copy;
@@ -326,8 +325,8 @@ gtk_css_image_conic_compute (GtkCssImage *image,
copy = g_object_new (GTK_TYPE_CSS_IMAGE_CONIC, NULL);
copy->center = _gtk_css_value_compute (self->center, property_id, provider, style, parent_style, variables);
copy->rotation = _gtk_css_value_compute (self->rotation, property_id, provider, style, parent_style, variables);
copy->center = _gtk_css_value_compute (self->center, property_id, provider, style, parent_style);
copy->rotation = _gtk_css_value_compute (self->rotation, property_id, provider, style, parent_style);
copy->n_stops = self->n_stops;
copy->color_stops = g_malloc (sizeof (GtkCssImageConicColorStop) * copy->n_stops);
@@ -336,11 +335,11 @@ gtk_css_image_conic_compute (GtkCssImage *image,
const GtkCssImageConicColorStop *stop = &self->color_stops[i];
GtkCssImageConicColorStop *scopy = &copy->color_stops[i];
scopy->color = _gtk_css_value_compute (stop->color, property_id, provider, style, parent_style, variables);
scopy->color = _gtk_css_value_compute (stop->color, property_id, provider, style, parent_style);
if (stop->offset)
{
scopy->offset = _gtk_css_value_compute (stop->offset, property_id, provider, style, parent_style, variables);
scopy->offset = _gtk_css_value_compute (stop->offset, property_id, provider, style, parent_style);
}
else
{
+6 -7
View File
@@ -399,12 +399,11 @@ gtk_css_image_cross_fade_print (GtkCssImage *image,
}
static GtkCssImage *
gtk_css_image_cross_fade_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssVariableSet *variables)
gtk_css_image_cross_fade_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
GtkCssImageCrossFade *self = GTK_CSS_IMAGE_CROSS_FADE (image);
GtkCssImageCrossFade *result;
@@ -419,7 +418,7 @@ gtk_css_image_cross_fade_compute (GtkCssImage *image,
gtk_css_image_cross_fade_add (result,
entry->has_progress,
entry->progress,
_gtk_css_image_compute (entry->image, property_id, provider, style, parent_style, variables));
_gtk_css_image_compute (entry->image, property_id, provider, style, parent_style));
}
return GTK_CSS_IMAGE (result);
+7 -10
View File
@@ -133,12 +133,11 @@ gtk_css_image_fallback_dispose (GObject *object)
static GtkCssImage *
gtk_css_image_fallback_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssVariableSet *variables)
gtk_css_image_fallback_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
GtkCssImageFallback *fallback = GTK_CSS_IMAGE_FALLBACK (image);
GtkCssImageFallback *copy;
@@ -153,8 +152,7 @@ gtk_css_image_fallback_compute (GtkCssImage *image,
property_id,
provider,
style,
parent_style,
variables);
parent_style);
/* image($color) that didn't change */
if (computed_color && !fallback->images &&
@@ -170,8 +168,7 @@ gtk_css_image_fallback_compute (GtkCssImage *image,
property_id,
provider,
style,
parent_style,
variables);
parent_style);
if (gtk_css_image_is_invalid (copy->images[i]))
continue;
+6 -7
View File
@@ -138,12 +138,11 @@ gtk_css_image_icon_theme_print (GtkCssImage *image,
}
static GtkCssImage *
gtk_css_image_icon_theme_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssVariableSet *variables)
gtk_css_image_icon_theme_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
GtkCssImageIconTheme *icon_theme = GTK_CSS_IMAGE_ICON_THEME (image);
GtkCssImageIconTheme *copy;
@@ -157,7 +156,7 @@ gtk_css_image_icon_theme_compute (GtkCssImage *image,
copy->icon_theme = gtk_icon_theme_get_for_display (display);
copy->serial = gtk_icon_theme_get_serial (copy->icon_theme);
copy->scale = gtk_style_provider_get_scale (provider);
gtk_css_style_lookup_symbolic_colors (style, copy->colors);
gtk_icon_theme_lookup_symbolic_colors (style, copy->colors);
return GTK_CSS_IMAGE (copy);
}
+8 -9
View File
@@ -488,12 +488,11 @@ gtk_css_image_linear_print (GtkCssImage *image,
}
static GtkCssImage *
gtk_css_image_linear_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssVariableSet *variables)
gtk_css_image_linear_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
GtkCssImageLinear *linear = GTK_CSS_IMAGE_LINEAR (image);
GtkCssImageLinear *copy;
@@ -504,7 +503,7 @@ gtk_css_image_linear_compute (GtkCssImage *image,
copy->side = linear->side;
if (linear->angle)
copy->angle = _gtk_css_value_compute (linear->angle, property_id, provider, style, parent_style, variables);
copy->angle = _gtk_css_value_compute (linear->angle, property_id, provider, style, parent_style);
copy->n_stops = linear->n_stops;
copy->color_stops = g_malloc (sizeof (GtkCssImageLinearColorStop) * copy->n_stops);
@@ -513,11 +512,11 @@ gtk_css_image_linear_compute (GtkCssImage *image,
const GtkCssImageLinearColorStop *stop = &linear->color_stops[i];
GtkCssImageLinearColorStop *scopy = &copy->color_stops[i];
scopy->color = _gtk_css_value_compute (stop->color, property_id, provider, style, parent_style, variables);
scopy->color = _gtk_css_value_compute (stop->color, property_id, provider, style, parent_style);
if (stop->offset)
{
scopy->offset = _gtk_css_value_compute (stop->offset, property_id, provider, style, parent_style, variables);
scopy->offset = _gtk_css_value_compute (stop->offset, property_id, provider, style, parent_style);
}
else
{
+5 -6
View File
@@ -96,12 +96,11 @@ gtk_css_image_paintable_get_static_image (GtkCssImage *image)
}
static GtkCssImage *
gtk_css_image_paintable_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssVariableSet *variables)
gtk_css_image_paintable_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
return gtk_css_image_paintable_get_static_image (image);
}
+2 -5
View File
@@ -26,7 +26,6 @@
#include "gtk/css/gtkcsstokenizerprivate.h"
#include "gtk/css/gtkcssparserprivate.h"
#include "gtk/gtkcsstypesprivate.h"
#include "gtk/gtkcssvariablesetprivate.h"
#include "gtk/gtksnapshot.h"
#include "gtk/gtkstyleprovider.h"
@@ -63,8 +62,7 @@ struct _GtkCssImageClass
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssVariableSet *variables);
GtkCssStyle *parent_style);
/* compare two images for equality */
gboolean (* equal) (GtkCssImage *image1,
GtkCssImage *image2);
@@ -108,8 +106,7 @@ GtkCssImage * _gtk_css_image_compute (GtkCssImage *
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssVariableSet *variables);
GtkCssStyle *parent_style);
gboolean _gtk_css_image_equal (GtkCssImage *image1,
GtkCssImage *image2) G_GNUC_PURE;
GtkCssImage * _gtk_css_image_transition (GtkCssImage *start,
+10 -11
View File
@@ -489,12 +489,11 @@ gtk_css_image_radial_print (GtkCssImage *image,
}
static GtkCssImage *
gtk_css_image_radial_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssVariableSet *variables)
gtk_css_image_radial_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
GtkCssImageRadial *radial = GTK_CSS_IMAGE_RADIAL (image);
GtkCssImageRadial *copy;
@@ -505,13 +504,13 @@ gtk_css_image_radial_compute (GtkCssImage *image,
copy->circle = radial->circle;
copy->size = radial->size;
copy->position = _gtk_css_value_compute (radial->position, property_id, provider, style, parent_style, variables);
copy->position = _gtk_css_value_compute (radial->position, property_id, provider, style, parent_style);
if (radial->sizes[0])
copy->sizes[0] = _gtk_css_value_compute (radial->sizes[0], property_id, provider, style, parent_style, variables);
copy->sizes[0] = _gtk_css_value_compute (radial->sizes[0], property_id, provider, style, parent_style);
if (radial->sizes[1])
copy->sizes[1] = _gtk_css_value_compute (radial->sizes[1], property_id, provider, style, parent_style, variables);
copy->sizes[1] = _gtk_css_value_compute (radial->sizes[1], property_id, provider, style, parent_style);
copy->n_stops = radial->n_stops;
copy->color_stops = g_malloc (sizeof (GtkCssImageRadialColorStop) * copy->n_stops);
@@ -520,11 +519,11 @@ gtk_css_image_radial_compute (GtkCssImage *image,
const GtkCssImageRadialColorStop *stop = &radial->color_stops[i];
GtkCssImageRadialColorStop *scopy = &copy->color_stops[i];
scopy->color = _gtk_css_value_compute (stop->color, property_id, provider, style, parent_style, variables);
scopy->color = _gtk_css_value_compute (stop->color, property_id, provider, style, parent_style);
if (stop->offset)
{
scopy->offset = _gtk_css_value_compute (stop->offset, property_id, provider, style, parent_style, variables);
scopy->offset = _gtk_css_value_compute (stop->offset, property_id, provider, style, parent_style);
}
else
{
+8 -10
View File
@@ -97,7 +97,6 @@ gtk_css_image_recolor_load_texture (GtkCssImageRecolor *recolor,
GError **error)
{
char *uri;
gboolean only_fg;
if (recolor->texture)
return;
@@ -111,7 +110,7 @@ gtk_css_image_recolor_load_texture (GtkCssImageRecolor *recolor,
if (g_str_has_suffix (uri, ".symbolic.png"))
recolor->texture = gtk_load_symbolic_texture_from_resource (resource_path);
else
recolor->texture = gdk_texture_new_from_resource_symbolic (resource_path, 0, 0, 1.0, &only_fg, NULL);
recolor->texture = gdk_texture_new_from_resource_symbolic (resource_path, 0, 0, 1.0, NULL);
g_free (resource_path);
}
@@ -120,7 +119,7 @@ gtk_css_image_recolor_load_texture (GtkCssImageRecolor *recolor,
if (g_str_has_suffix (uri, ".symbolic.png"))
recolor->texture = gtk_load_symbolic_texture_from_file (recolor->file);
else
recolor->texture = gdk_texture_new_from_file_symbolic (recolor->file, 0, 0, 1.0, &only_fg, NULL);
recolor->texture = gdk_texture_new_from_file_symbolic (recolor->file, 0, 0, 1.0, NULL);
}
g_free (uri);
@@ -201,12 +200,11 @@ gtk_css_image_recolor_snapshot (GtkCssImage *image,
}
static GtkCssImage *
gtk_css_image_recolor_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssVariableSet *variables)
gtk_css_image_recolor_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
GtkCssImageRecolor *recolor = GTK_CSS_IMAGE_RECOLOR (image);
GtkCssValue *palette;
@@ -217,7 +215,7 @@ gtk_css_image_recolor_compute (GtkCssImage *image,
scale = gtk_style_provider_get_scale (provider);
if (recolor->palette)
palette = _gtk_css_value_compute (recolor->palette, property_id, provider, style, parent_style, variables);
palette = _gtk_css_value_compute (recolor->palette, property_id, provider, style, parent_style);
else
palette = _gtk_css_value_ref (style->core->icon_palette);
+6 -8
View File
@@ -97,12 +97,11 @@ gtk_css_image_scaled_dispose (GObject *object)
static GtkCssImage *
gtk_css_image_scaled_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssVariableSet *variables)
gtk_css_image_scaled_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
GtkCssImageScaled *scaled = GTK_CSS_IMAGE_SCALED (image);
int scale;
@@ -138,8 +137,7 @@ gtk_css_image_scaled_compute (GtkCssImage *image,
property_id,
provider,
style,
parent_style,
variables);
parent_style);
res->scales[0] = scaled->scales[best];
return GTK_CSS_IMAGE (res);
+5 -6
View File
@@ -112,12 +112,11 @@ gtk_css_image_url_snapshot (GtkCssImage *image,
}
static GtkCssImage *
gtk_css_image_url_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssVariableSet *variables)
gtk_css_image_url_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
GtkCssImageUrl *url = GTK_CSS_IMAGE_URL (image);
GtkCssImage *copy;
+7 -8
View File
@@ -34,12 +34,11 @@ gtk_css_value_image_free (GtkCssValue *value)
}
static GtkCssValue *
gtk_css_value_image_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssVariableSet *variables)
gtk_css_value_image_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
GtkCssImage *image, *computed;
@@ -48,7 +47,7 @@ gtk_css_value_image_compute (GtkCssValue *value,
if (image == NULL)
return _gtk_css_value_ref (value);
computed = _gtk_css_image_compute (image, property_id, provider, style, parent_style, variables);
computed = _gtk_css_image_compute (image, property_id, provider, style, parent_style);
if (computed == image)
{
@@ -137,7 +136,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_IMAGE = {
GtkCssValue *
_gtk_css_image_value_new (GtkCssImage *image)
{
static GtkCssValue image_none_singleton = { &GTK_CSS_VALUE_IMAGE, 1, TRUE, FALSE, NULL };
static GtkCssValue image_none_singleton = { &GTK_CSS_VALUE_IMAGE, 1, TRUE, NULL };
GtkCssValue *value;
if (image == NULL)
+6 -8
View File
@@ -34,12 +34,11 @@ gtk_css_value_inherit_free (GtkCssValue *value)
}
static GtkCssValue *
gtk_css_value_inherit_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssVariableSet *variables)
gtk_css_value_inherit_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
if (parent_style)
{
@@ -51,8 +50,7 @@ gtk_css_value_inherit_compute (GtkCssValue *value,
property_id,
provider,
style,
parent_style,
variables);
parent_style);
}
}
+7 -10
View File
@@ -38,12 +38,11 @@ gtk_css_value_initial_free (GtkCssValue *value)
}
static GtkCssValue *
gtk_css_value_initial_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style,
GtkCssVariableSet *variables)
gtk_css_value_initial_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
GtkSettings *settings;
@@ -76,8 +75,7 @@ gtk_css_value_initial_compute (GtkCssValue *value,
property_id,
provider,
style,
parent_style,
variables);
parent_style);
}
static gboolean
@@ -137,6 +135,5 @@ _gtk_css_initial_value_new_compute (guint property_id,
property_id,
provider,
style,
parent_style,
NULL);
parent_style);
}

Some files were not shown because too many files have changed in this diff Show More