Compare commits
60 Commits
listview-t
...
shader-too
Author | SHA1 | Date | |
---|---|---|---|
|
84c6a1a8cf | ||
|
57f3598b71 | ||
|
422fc3dda4 | ||
|
46866b8a66 | ||
|
9df6f802f2 | ||
|
1bbca0cd25 | ||
|
83784c17a3 | ||
|
3f46d0f2fa | ||
|
ef1ff8313f | ||
|
119a07e055 | ||
|
abfd94d2d9 | ||
|
6022fbcdf8 | ||
|
744016e768 | ||
|
d39f50a4ee | ||
|
c23d3c4406 | ||
|
1e2eae4ddf | ||
|
77eb3df7c0 | ||
|
e540022869 | ||
|
e6700405c9 | ||
|
5bbd8e12fa | ||
|
8b59771cd1 | ||
|
8a0a08e4ce | ||
|
bef6352401 | ||
|
60a43ddce0 | ||
|
90c9e88ee9 | ||
|
d860bf95ab | ||
|
a3bd0a3e17 | ||
|
d274c7df06 | ||
|
9a5f482e1a | ||
|
2f6140c066 | ||
|
9ce4471527 | ||
|
cda4ec48b2 | ||
|
d9582c123e | ||
|
4d30aacb0c | ||
|
4862c3f779 | ||
|
08d1353cde | ||
|
585dadf575 | ||
|
d069eb173a | ||
|
6015560b63 | ||
|
5a776389d7 | ||
|
6c2dfed5a5 | ||
|
7dec24c2cc | ||
|
c20e7a0c5d | ||
|
719021e1f4 | ||
|
4856e115a9 | ||
|
bfb5bbe862 | ||
|
b98c86fb7b | ||
|
e01c3f581e | ||
|
c45199e388 | ||
|
27fb9917d8 | ||
|
b5d6613a3f | ||
|
5dc77edbe3 | ||
|
a3d63b3579 | ||
|
57c12a8661 | ||
|
f1ccb9b81a | ||
|
2711cb8dcd | ||
|
c79925bd4a | ||
|
a1fdf06d80 | ||
|
36d7ca058e | ||
|
6b2b6ceb74 |
@@ -20,6 +20,7 @@
|
||||
#include "config.h"
|
||||
#include <gtk/gtk.h>
|
||||
#include <glib/gstdio.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#include "demos.h"
|
||||
#include "fontify.h"
|
||||
@@ -923,6 +924,34 @@ 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)
|
||||
{
|
||||
@@ -970,6 +999,7 @@ 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);
|
||||
|
@@ -5,8 +5,11 @@ 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; instead it allows to create Cairo
|
||||
drawing contexts which can be used to draw on [class@Gdk.Surface]s.
|
||||
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.
|
||||
|
||||
Additional functions allow use [struct@Gdk.Rectangle]s with Cairo
|
||||
and to use [struct@Gdk.RGBA], `GdkPixbuf`, and [class@Gdk.Surface]
|
||||
|
64
gdk/gdk.c
@@ -143,31 +143,50 @@ static const GdkDebugKey gdk_debug_keys[] = {
|
||||
|
||||
#ifdef G_HAS_CONSTRUCTORS
|
||||
#ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
|
||||
#pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(stash_desktop_startup_notification_id)
|
||||
#pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(stash_and_unset_environment)
|
||||
#endif
|
||||
G_DEFINE_CONSTRUCTOR(stash_desktop_startup_notification_id)
|
||||
G_DEFINE_CONSTRUCTOR(stash_and_unset_environment)
|
||||
#endif
|
||||
|
||||
static char *startup_notification_id = NULL;
|
||||
static char *xdg_activation_token = NULL;
|
||||
|
||||
static void
|
||||
stash_desktop_startup_notification_id (void)
|
||||
stash_and_unset_environment (void)
|
||||
{
|
||||
const char *desktop_startup_id;
|
||||
|
||||
desktop_startup_id = g_getenv ("DESKTOP_STARTUP_ID");
|
||||
if (desktop_startup_id && *desktop_startup_id != '\0')
|
||||
{
|
||||
if (!g_utf8_validate (desktop_startup_id, -1, NULL))
|
||||
g_warning ("DESKTOP_STARTUP_ID contains invalid UTF-8");
|
||||
else
|
||||
startup_notification_id = g_strdup (desktop_startup_id);
|
||||
}
|
||||
|
||||
/* Clear the environment variable so it won't be inherited by
|
||||
/* Copies environment variables and unsets them so they won't be inherited by
|
||||
* child processes and confuse things.
|
||||
*
|
||||
* Changing environment variables can be racy so we try to do this as early as
|
||||
* possible in the program flow and before any printing that might involve
|
||||
* environment variables.
|
||||
*/
|
||||
g_unsetenv ("DESKTOP_STARTUP_ID");
|
||||
struct {
|
||||
const char *key;
|
||||
char **dst;
|
||||
} vars[] = {
|
||||
{ "DESKTOP_STARTUP_ID", &startup_notification_id },
|
||||
{ "XDG_ACTIVATION_TOKEN", &xdg_activation_token },
|
||||
};
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (vars); i++)
|
||||
*vars[i].dst = g_strdup (g_getenv (vars[i].key));
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (vars); i++)
|
||||
g_unsetenv (vars[i].key);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (vars); i++)
|
||||
{
|
||||
if (*vars[i].dst == NULL)
|
||||
continue;
|
||||
|
||||
if (!g_utf8_validate (*vars[i].dst, -1, NULL))
|
||||
{
|
||||
g_warning ("%s contains invalid UTF-8", vars[i].key);
|
||||
g_clear_pointer (vars[i].dst, g_free);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static gpointer
|
||||
@@ -292,7 +311,7 @@ gdk_pre_parse (void)
|
||||
gdk_gl_backend_use (GDK_GL_WGL);
|
||||
|
||||
#ifndef G_HAS_CONSTRUCTORS
|
||||
stash_desktop_startup_notification_id ();
|
||||
stash_and_unset_environment ();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -326,15 +345,20 @@ gdk_display_open_default (void)
|
||||
/*< private >
|
||||
* gdk_get_startup_notification_id:
|
||||
*
|
||||
* Returns the original value of the DESKTOP_STARTUP_ID environment
|
||||
* variable if it was defined and valid, or %NULL otherwise.
|
||||
* Returns the original value of the XDG_ACTIVATION_TOKEN environment
|
||||
* variable if it was defined and valid, otherwise it returns the original
|
||||
* value of the DESKTOP_STARTUP_ID environment variable if it was defined
|
||||
* and valid, or %NULL if neither of them were defined and valid.
|
||||
*
|
||||
* Returns: (nullable) (transfer none): the original value of the
|
||||
* DESKTOP_STARTUP_ID environment variable
|
||||
* XDG_ACTIVATION_TOKEN or DESKTOP_STARTUP_ID environment variable
|
||||
*/
|
||||
const char *
|
||||
gdk_get_startup_notification_id (void)
|
||||
{
|
||||
if (xdg_activation_token)
|
||||
return xdg_activation_token;
|
||||
|
||||
return startup_notification_id;
|
||||
}
|
||||
|
||||
|
@@ -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_wide, uv_data[x / X_SUB * 2 + U], uv_data[x / X_SUB * 2 + V], &r, &g, &b);
|
||||
get_uv_values (&itu601_narrow, 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_wide, u_data[x / X_SUB], v_data[x / X_SUB], &r, &g, &b);
|
||||
get_uv_values (&itu601_narrow, 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_wide, src_data[2 * x + U], src_data[2 * x + V], &r, &g, &b);
|
||||
get_uv_values (&itu601_narrow, 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);
|
||||
|
@@ -239,7 +239,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_FULL_RANGE_EXT;
|
||||
attribs[i++] = EGL_YUV_NARROW_RANGE_EXT;
|
||||
|
||||
#define ADD_PLANE(plane) \
|
||||
{ \
|
||||
@@ -265,6 +265,7 @@ 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,
|
||||
|
@@ -2198,12 +2198,78 @@ gdk_gl_context_import_dmabuf (GdkGLContext *self,
|
||||
|
||||
gdk_display_init_dmabuf (display);
|
||||
|
||||
if (!gdk_dmabuf_formats_contains (display->egl_external_formats, dmabuf->fourcc, dmabuf->modifier))
|
||||
if (gdk_dmabuf_formats_contains (display->egl_dmabuf_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_2D);
|
||||
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);
|
||||
|
||||
if (texture_id == 0)
|
||||
{
|
||||
GDK_DISPLAY_DEBUG (display, DMABUF,
|
||||
@@ -2214,40 +2280,13 @@ gdk_gl_context_import_dmabuf (GdkGLContext *self,
|
||||
}
|
||||
|
||||
GDK_DISPLAY_DEBUG (display, DMABUF,
|
||||
"Imported %dx%d %.4s:%#" G_GINT64_MODIFIER "x dmabuf as GL_TEXTURE_2D texture",
|
||||
"Imported %dx%d %.4s:%#" G_GINT64_MODIFIER "x dmabuf as %s texture",
|
||||
width, height,
|
||||
(char *) &dmabuf->fourcc, dmabuf->modifier);
|
||||
*external = FALSE;
|
||||
(char *) &dmabuf->fourcc, dmabuf->modifier,
|
||||
target == GL_TEXTURE_EXTERNAL_OES ? "GL_TEXTURE_EXTERNAL_OES" : "GL_TEXTURE_2D");
|
||||
*external = target == GL_TEXTURE_EXTERNAL_OES;
|
||||
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
|
||||
|
@@ -563,7 +563,7 @@ gdk_texture_new_from_bytes_internal (GBytes *bytes,
|
||||
{
|
||||
if (gdk_is_png (bytes))
|
||||
{
|
||||
return gdk_load_png (bytes, error);
|
||||
return gdk_load_png (bytes, NULL, error);
|
||||
}
|
||||
else if (gdk_is_jpeg (bytes))
|
||||
{
|
||||
|
@@ -29,6 +29,7 @@
|
||||
#include "gdkdmabuffourccprivate.h"
|
||||
#include "gdkdmabuftextureprivate.h"
|
||||
#include "gdkdisplayprivate.h"
|
||||
#include "gdkprofilerprivate.h"
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include <math.h>
|
||||
|
||||
@@ -1110,6 +1111,7 @@ 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;
|
||||
@@ -1124,14 +1126,13 @@ 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)
|
||||
{
|
||||
@@ -1151,7 +1152,7 @@ gdk_vulkan_save_pipeline_cache (GdkDisplay *display)
|
||||
|
||||
file = gdk_vulkan_get_pipeline_cache_file (display);
|
||||
|
||||
GDK_DEBUG (VULKAN, "Saving pipeline cache to %s", g_file_peek_path (file));
|
||||
GDK_DEBUG (VULKAN, "Saving pipeline cache of size %lu to %s", size, g_file_peek_path (file));
|
||||
|
||||
if (!g_file_replace_contents (file,
|
||||
data,
|
||||
@@ -1166,7 +1167,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)
|
||||
@@ -1193,10 +1194,15 @@ 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;
|
||||
}
|
||||
@@ -1223,6 +1229,18 @@ gdk_display_vulkan_pipeline_cache_updated (GdkDisplay *display)
|
||||
NULL);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_display_vulkan_pipeline_cache_save (GdkDisplay *display)
|
||||
{
|
||||
return gdk_vulkan_save_pipeline_cache (display);
|
||||
}
|
||||
|
||||
GFile *
|
||||
gdk_display_vulkan_pipeline_cache_file (GdkDisplay *display)
|
||||
{
|
||||
return gdk_vulkan_get_pipeline_cache_file (display);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_display_create_pipeline_cache (GdkDisplay *display)
|
||||
{
|
||||
@@ -1236,6 +1254,11 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1345,6 +1368,7 @@ 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;
|
||||
@@ -1553,6 +1577,8 @@ 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;
|
||||
}
|
||||
}
|
||||
@@ -1591,6 +1617,7 @@ 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;
|
||||
@@ -1752,6 +1779,8 @@ 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;
|
||||
}
|
||||
|
||||
|
@@ -87,6 +87,8 @@ VkShaderModule gdk_display_get_vk_shader_module (GdkDisp
|
||||
const char *resource_name);
|
||||
|
||||
void gdk_display_vulkan_pipeline_cache_updated (GdkDisplay *display);
|
||||
gboolean gdk_display_vulkan_pipeline_cache_save (GdkDisplay *display);
|
||||
GFile * gdk_display_vulkan_pipeline_cache_file (GdkDisplay *display);
|
||||
|
||||
VkInstance gdk_vulkan_context_get_instance (GdkVulkanContext *context);
|
||||
VkPhysicalDevice gdk_vulkan_context_get_physical_device (GdkVulkanContext *context);
|
||||
|
@@ -127,15 +127,18 @@ png_simple_warning_callback (png_structp png,
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ Public API */
|
||||
/* {{{ Public API */
|
||||
|
||||
GdkTexture *
|
||||
gdk_load_png (GBytes *bytes,
|
||||
GError **error)
|
||||
gdk_load_png (GBytes *bytes,
|
||||
GHashTable *options,
|
||||
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;
|
||||
@@ -297,6 +300,17 @@ 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);
|
||||
|
||||
|
@@ -23,6 +23,7 @@
|
||||
#define PNG_SIGNATURE "\x89PNG"
|
||||
|
||||
GdkTexture *gdk_load_png (GBytes *bytes,
|
||||
GHashTable *options,
|
||||
GError **error);
|
||||
|
||||
GBytes *gdk_save_png (GdkTexture *texture);
|
||||
|
@@ -287,97 +287,6 @@ static const struct wl_shm_listener wl_shm_listener = {
|
||||
wl_shm_format
|
||||
};
|
||||
|
||||
static void
|
||||
linux_dmabuf_done (void *data,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *zwp_linux_dmabuf_feedback_v1)
|
||||
{
|
||||
GDK_DEBUG (MISC, "dmabuf feedback done");
|
||||
}
|
||||
|
||||
static void
|
||||
linux_dmabuf_format_table (void *data,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *zwp_linux_dmabuf_feedback_v1,
|
||||
int32_t fd,
|
||||
uint32_t size)
|
||||
{
|
||||
GdkWaylandDisplay *display_wayland = data;
|
||||
|
||||
display_wayland->linux_dmabuf_n_formats = size / 16;
|
||||
display_wayland->linux_dmabuf_formats = mmap (NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||
|
||||
GDK_DEBUG (MISC, "got dmabuf format table (%lu entries)", display_wayland->linux_dmabuf_n_formats);
|
||||
}
|
||||
|
||||
static void
|
||||
linux_dmabuf_main_device (void *data,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *zwp_linux_dmabuf_feedback_v1,
|
||||
struct wl_array *device)
|
||||
{
|
||||
dev_t dev G_GNUC_UNUSED;
|
||||
|
||||
memcpy (&dev, device->data, sizeof (dev_t));
|
||||
|
||||
GDK_DEBUG (MISC, "got dmabuf main device: %u %u", major (dev), minor (dev));
|
||||
}
|
||||
|
||||
static void
|
||||
linux_dmabuf_tranche_done (void *data,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *zwp_linux_dmabuf_feedback_v1)
|
||||
{
|
||||
GDK_DEBUG (MISC, "dmabuf feedback tranche done");
|
||||
}
|
||||
|
||||
static void
|
||||
linux_dmabuf_tranche_target_device (void *data,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *zwp_linux_dmabuf_feedback_v1,
|
||||
struct wl_array *device)
|
||||
{
|
||||
dev_t dev G_GNUC_UNUSED;
|
||||
|
||||
memcpy (&dev, device->data, sizeof (dev_t));
|
||||
|
||||
GDK_DEBUG (MISC, "got dmabuf tranche target device: %u %u", major (dev), minor (dev));
|
||||
}
|
||||
|
||||
static void
|
||||
linux_dmabuf_tranche_formats (void *data,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *zwp_linux_dmabuf_feedback_v1,
|
||||
struct wl_array *indices)
|
||||
{
|
||||
GdkWaylandDisplay *display_wayland = data;
|
||||
|
||||
GDK_DEBUG (MISC, "got dmabuf tranche formats (%lu entries):", indices->size / sizeof (guint16));
|
||||
guint16 *pos;
|
||||
|
||||
wl_array_for_each (pos, indices)
|
||||
{
|
||||
LinuxDmabufFormat *fmt G_GNUC_UNUSED = &display_wayland->linux_dmabuf_formats[*pos];
|
||||
uint32_t f G_GNUC_UNUSED = fmt->fourcc;
|
||||
uint64_t m G_GNUC_UNUSED = fmt->modifier;
|
||||
GDK_DEBUG (MISC, " %.4s:%#" G_GINT64_MODIFIER "x", (char *) &f, m);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
linux_dmabuf_tranche_flags (void *data,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *zwp_linux_dmabuf_feedback_v1,
|
||||
uint32_t flags)
|
||||
{
|
||||
GDK_DEBUG (MISC,
|
||||
"got dmabuf tranche flags: %s",
|
||||
flags & ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SCANOUT ? "scanout" : "");
|
||||
}
|
||||
|
||||
static const struct zwp_linux_dmabuf_feedback_v1_listener linux_dmabuf_feedback_listener = {
|
||||
linux_dmabuf_done,
|
||||
linux_dmabuf_format_table,
|
||||
linux_dmabuf_main_device,
|
||||
linux_dmabuf_tranche_done,
|
||||
linux_dmabuf_tranche_target_device,
|
||||
linux_dmabuf_tranche_formats,
|
||||
linux_dmabuf_tranche_flags,
|
||||
};
|
||||
|
||||
static void
|
||||
server_decoration_manager_default_mode (void *data,
|
||||
struct org_kde_kwin_server_decoration_manager *manager,
|
||||
@@ -454,12 +363,14 @@ gdk_registry_handle_global (void *data,
|
||||
}
|
||||
else if (strcmp (interface, "zwp_linux_dmabuf_v1") == 0 && version >= 4)
|
||||
{
|
||||
struct zwp_linux_dmabuf_feedback_v1 *feedback;
|
||||
|
||||
display_wayland->linux_dmabuf =
|
||||
wl_registry_bind (display_wayland->wl_registry, id, &zwp_linux_dmabuf_v1_interface, version);
|
||||
display_wayland->linux_dmabuf_feedback =
|
||||
zwp_linux_dmabuf_v1_get_default_feedback (display_wayland->linux_dmabuf);
|
||||
zwp_linux_dmabuf_feedback_v1_add_listener (display_wayland->linux_dmabuf_feedback,
|
||||
&linux_dmabuf_feedback_listener, display_wayland);
|
||||
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);
|
||||
_gdk_wayland_display_async_roundtrip (display_wayland);
|
||||
}
|
||||
else if (strcmp (interface, "xdg_wm_base") == 0)
|
||||
@@ -832,9 +743,7 @@ gdk_wayland_display_dispose (GObject *object)
|
||||
g_clear_pointer (&display_wayland->presentation, wp_presentation_destroy);
|
||||
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->linux_dmabuf_feedback, zwp_linux_dmabuf_feedback_v1_destroy);
|
||||
if (display_wayland->linux_dmabuf_formats)
|
||||
munmap (display_wayland->linux_dmabuf_formats, display_wayland->linux_dmabuf_n_formats * 16);
|
||||
g_clear_pointer (&display_wayland->dmabuf_formats_info, dmabuf_formats_info_free);
|
||||
|
||||
g_clear_pointer (&display_wayland->shm, wl_shm_destroy);
|
||||
g_clear_pointer (&display_wayland->wl_registry, wl_registry_destroy);
|
||||
|
@@ -49,6 +49,7 @@
|
||||
|
||||
#include "gdkdisplayprivate.h"
|
||||
#include "gdkwaylanddevice.h"
|
||||
#include "gdkdmabuf-wayland-private.h"
|
||||
#include "cursor/wayland-cursor.h"
|
||||
|
||||
#include <epoxy/egl.h>
|
||||
@@ -73,13 +74,6 @@ typedef enum _GdkWaylandShellVariant
|
||||
GDK_WAYLAND_SHELL_VARIANT_ZXDG_SHELL_V6
|
||||
} GdkWaylandShellVariant;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t fourcc;
|
||||
uint32_t padding;
|
||||
uint64_t modifier;
|
||||
} LinuxDmabufFormat;
|
||||
|
||||
struct _GdkWaylandDisplay
|
||||
{
|
||||
GdkDisplay parent_instance;
|
||||
@@ -105,9 +99,7 @@ struct _GdkWaylandDisplay
|
||||
struct wl_compositor *compositor;
|
||||
struct wl_shm *shm;
|
||||
struct zwp_linux_dmabuf_v1 *linux_dmabuf;
|
||||
struct zwp_linux_dmabuf_feedback_v1 *linux_dmabuf_feedback;
|
||||
gsize linux_dmabuf_n_formats;
|
||||
LinuxDmabufFormat *linux_dmabuf_formats;
|
||||
DmabufFormatsInfo *dmabuf_formats_info;
|
||||
struct xdg_wm_base *xdg_wm_base;
|
||||
struct zxdg_shell_v6 *zxdg_shell_v6;
|
||||
struct gtk_shell1 *gtk_shell;
|
||||
|
77
gdk/wayland/gdkdmabuf-wayland-private.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* gdkdmabuf-wayland.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 Library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <wayland-client.h>
|
||||
#include <wayland-egl.h>
|
||||
|
||||
#include <glib.h>
|
||||
#include <gdk/gdkkeys.h>
|
||||
#include <gdk/gdksurface.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t fourcc;
|
||||
uint32_t padding;
|
||||
uint64_t modifier;
|
||||
} DmabufFormat;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
dev_t target_device;
|
||||
guint32 flags;
|
||||
gsize n_formats;
|
||||
DmabufFormat *formats;
|
||||
} DmabufTranche;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
dev_t main_device;
|
||||
GPtrArray *tranches;
|
||||
} DmabufFormats;
|
||||
|
||||
typedef struct DmabufFormatsInfo DmabufFormatsInfo;
|
||||
|
||||
struct DmabufFormatsInfo
|
||||
{
|
||||
GdkDisplay *display;
|
||||
char *name;
|
||||
struct zwp_linux_dmabuf_feedback_v1 *feedback;
|
||||
|
||||
gsize n_dmabuf_formats;
|
||||
DmabufFormat *dmabuf_format_table;
|
||||
|
||||
DmabufFormats *dmabuf_formats;
|
||||
DmabufFormats *pending_dmabuf_formats;
|
||||
DmabufTranche *pending_tranche;
|
||||
};
|
||||
|
||||
DmabufFormatsInfo * dmabuf_formats_info_new (GdkDisplay *display,
|
||||
const char *name,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *feedback);
|
||||
|
||||
void dmabuf_formats_info_free (DmabufFormatsInfo *info);
|
||||
|
||||
G_END_DECLS
|
241
gdk/wayland/gdkdmabuf-wayland.c
Normal file
@@ -0,0 +1,241 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "gdkdmabuf-wayland-private.h"
|
||||
|
||||
#include "gdkdebugprivate.h"
|
||||
#include "gdkdmabufformatsprivate.h"
|
||||
#include "gdkdmabufformatsbuilderprivate.h"
|
||||
#include "gdkdmabufformatsprivate.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/sysmacros.h>
|
||||
|
||||
#include "linux-dmabuf-unstable-v1-client-protocol.h"
|
||||
|
||||
|
||||
static DmabufTranche *
|
||||
dmabuf_tranche_new (void)
|
||||
{
|
||||
return g_new0 (DmabufTranche, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
dmabuf_tranche_free (DmabufTranche *tranche)
|
||||
{
|
||||
g_free (tranche->formats);
|
||||
g_free (tranche);
|
||||
}
|
||||
|
||||
static DmabufFormats *
|
||||
dmabuf_formats_new (void)
|
||||
{
|
||||
DmabufFormats *formats;
|
||||
|
||||
formats = g_new0 (DmabufFormats, 1);
|
||||
formats->tranches = g_ptr_array_new_with_free_func ((GDestroyNotify) dmabuf_tranche_free);
|
||||
|
||||
return formats;
|
||||
}
|
||||
|
||||
static void
|
||||
dmabuf_formats_free (DmabufFormats *formats)
|
||||
{
|
||||
g_ptr_array_unref (formats->tranches);
|
||||
g_free (formats);
|
||||
}
|
||||
|
||||
static void
|
||||
update_dmabuf_formats (DmabufFormatsInfo *info)
|
||||
{
|
||||
DmabufFormats *formats = info->dmabuf_formats;
|
||||
|
||||
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++)
|
||||
{
|
||||
DmabufTranche *tranche = g_ptr_array_index (formats->tranches, i);
|
||||
|
||||
GDK_DISPLAY_DEBUG (info->display, MISC,
|
||||
"dmabuf tranche target device: %u %u",
|
||||
major (tranche->target_device),
|
||||
minor (tranche->target_device));
|
||||
|
||||
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);
|
||||
|
||||
for (gsize j = 0; j < tranche->n_formats; j++)
|
||||
{
|
||||
GDK_DISPLAY_DEBUG (info->display, MISC,
|
||||
" %.4s:%#" G_GINT64_MODIFIER "x",
|
||||
(char *) &(tranche->formats[j].fourcc),
|
||||
tranche->formats[j].modifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
linux_dmabuf_done (void *data,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *feedback)
|
||||
{
|
||||
DmabufFormatsInfo *info = data;
|
||||
|
||||
g_clear_pointer (&info->dmabuf_formats, dmabuf_formats_free);
|
||||
|
||||
info->dmabuf_formats = info->pending_dmabuf_formats;
|
||||
info->pending_dmabuf_formats = NULL;
|
||||
|
||||
update_dmabuf_formats (info);
|
||||
}
|
||||
|
||||
static void
|
||||
linux_dmabuf_format_table (void *data,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *feedback,
|
||||
int32_t fd,
|
||||
uint32_t size)
|
||||
{
|
||||
DmabufFormatsInfo *info = data;
|
||||
|
||||
if (info->dmabuf_formats)
|
||||
munmap (info->dmabuf_formats, sizeof (DmabufFormat) * info->n_dmabuf_formats);
|
||||
|
||||
info->n_dmabuf_formats = size / 16;
|
||||
info->dmabuf_format_table = mmap (NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
linux_dmabuf_main_device (void *data,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *feedback,
|
||||
struct wl_array *device)
|
||||
{
|
||||
DmabufFormatsInfo *info = data;
|
||||
dev_t dev;
|
||||
|
||||
memcpy (&dev, device->data, sizeof (dev_t));
|
||||
|
||||
g_assert (info->pending_dmabuf_formats == NULL);
|
||||
|
||||
info->pending_dmabuf_formats = dmabuf_formats_new ();
|
||||
info->pending_dmabuf_formats->main_device = dev;
|
||||
}
|
||||
|
||||
static void
|
||||
linux_dmabuf_tranche_done (void *data,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *feedback)
|
||||
{
|
||||
DmabufFormatsInfo *info = data;
|
||||
|
||||
g_ptr_array_add (info->pending_dmabuf_formats->tranches,
|
||||
info->pending_tranche);
|
||||
|
||||
info->pending_tranche = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
linux_dmabuf_tranche_target_device (void *data,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *feedback,
|
||||
struct wl_array *device)
|
||||
{
|
||||
DmabufFormatsInfo *info = data;
|
||||
dev_t dev;
|
||||
DmabufTranche *tranche;
|
||||
|
||||
memcpy (&dev, device->data, sizeof (dev_t));
|
||||
|
||||
g_assert (info->pending_tranche == NULL);
|
||||
|
||||
tranche = dmabuf_tranche_new ();
|
||||
tranche->target_device = dev;
|
||||
|
||||
info->pending_tranche = tranche;
|
||||
}
|
||||
|
||||
static void
|
||||
linux_dmabuf_tranche_formats (void *data,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *feedback,
|
||||
struct wl_array *indices)
|
||||
{
|
||||
DmabufFormatsInfo *info = data;
|
||||
DmabufTranche *tranche;
|
||||
int i;
|
||||
guint16 *pos;
|
||||
|
||||
g_assert (info->pending_tranche != NULL);
|
||||
tranche = info->pending_tranche;
|
||||
|
||||
tranche->n_formats = indices->size / sizeof (guint16);
|
||||
tranche->formats = g_new (DmabufFormat, tranche->n_formats);
|
||||
|
||||
i = 0;
|
||||
wl_array_for_each (pos, indices)
|
||||
{
|
||||
tranche->formats[i++] = info->dmabuf_format_table[*pos];
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
linux_dmabuf_tranche_flags (void *data,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *feedback,
|
||||
uint32_t flags)
|
||||
{
|
||||
DmabufFormatsInfo *info = data;
|
||||
DmabufTranche *tranche;
|
||||
|
||||
g_assert (info->pending_tranche != NULL);
|
||||
tranche = info->pending_tranche;
|
||||
tranche->flags = flags;
|
||||
}
|
||||
|
||||
static const struct zwp_linux_dmabuf_feedback_v1_listener feedback_listener = {
|
||||
linux_dmabuf_done,
|
||||
linux_dmabuf_format_table,
|
||||
linux_dmabuf_main_device,
|
||||
linux_dmabuf_tranche_done,
|
||||
linux_dmabuf_tranche_target_device,
|
||||
linux_dmabuf_tranche_formats,
|
||||
linux_dmabuf_tranche_flags,
|
||||
};
|
||||
|
||||
DmabufFormatsInfo *
|
||||
dmabuf_formats_info_new (GdkDisplay *display,
|
||||
const char *name,
|
||||
struct zwp_linux_dmabuf_feedback_v1 *feedback)
|
||||
{
|
||||
DmabufFormatsInfo *info;
|
||||
|
||||
info = g_new0 (DmabufFormatsInfo, 1);
|
||||
|
||||
info->display = display;
|
||||
info->name = g_strdup (name);
|
||||
info->feedback = feedback;
|
||||
|
||||
if (info->feedback)
|
||||
zwp_linux_dmabuf_feedback_v1_add_listener (info->feedback,
|
||||
&feedback_listener, info);
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
void
|
||||
dmabuf_formats_info_free (DmabufFormatsInfo *info)
|
||||
{
|
||||
g_free (info->name);
|
||||
g_clear_pointer (&info->feedback, zwp_linux_dmabuf_feedback_v1_destroy);
|
||||
if (info->dmabuf_format_table)
|
||||
{
|
||||
munmap (info->dmabuf_format_table, info->n_dmabuf_formats * 16);
|
||||
info->dmabuf_format_table = NULL;
|
||||
}
|
||||
g_clear_pointer (&info->dmabuf_formats, dmabuf_formats_free);
|
||||
g_clear_pointer (&info->pending_dmabuf_formats, dmabuf_formats_free);
|
||||
g_clear_pointer (&info->pending_tranche, dmabuf_tranche_free);
|
||||
|
||||
g_free (info);
|
||||
}
|
@@ -8,6 +8,7 @@ gdk_wayland_sources = files([
|
||||
'gdkdevice-wayland.c',
|
||||
'gdkdevicepad-wayland.c',
|
||||
'gdkdisplay-wayland.c',
|
||||
'gdkdmabuf-wayland.c',
|
||||
'gdkdrag-wayland.c',
|
||||
'gdkdragsurface-wayland.c',
|
||||
'gdkdrop-wayland.c',
|
||||
|
@@ -68,6 +68,11 @@ 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)
|
||||
{
|
||||
@@ -75,6 +80,7 @@ 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;
|
||||
}
|
||||
|
@@ -29,7 +29,7 @@ gsk_gpu_blend_mode_op_print_instance (GskGpuShaderOp *shader,
|
||||
gsk_gpu_print_image_descriptor (string, shader->desc, instance->top_id);
|
||||
}
|
||||
|
||||
static const GskGpuShaderOpClass GSK_GPU_BLEND_MODE_OP_CLASS = {
|
||||
const GskGpuShaderOpClass GSK_GPU_BLEND_MODE_OP_CLASS = {
|
||||
{
|
||||
GSK_GPU_OP_SIZE (GskGpuBlendModeOp),
|
||||
GSK_GPU_STAGE_SHADER,
|
||||
|
@@ -31,7 +31,7 @@ gsk_gpu_blur_op_print_instance (GskGpuShaderOp *shader,
|
||||
gsk_gpu_print_image_descriptor (string, shader->desc, instance->tex_id);
|
||||
}
|
||||
|
||||
static const GskGpuShaderOpClass GSK_GPU_BLUR_OP_CLASS = {
|
||||
const GskGpuShaderOpClass GSK_GPU_BLUR_OP_CLASS = {
|
||||
{
|
||||
GSK_GPU_OP_SIZE (GskGpuBlurOp),
|
||||
GSK_GPU_STAGE_SHADER,
|
||||
|
@@ -72,7 +72,7 @@ gsk_gpu_border_op_gl_command (GskGpuOp *op,
|
||||
return gsk_gpu_shader_op_gl_command_n (op, frame, state, 8);
|
||||
}
|
||||
|
||||
static const GskGpuShaderOpClass GSK_GPU_BORDER_OP_CLASS = {
|
||||
const GskGpuShaderOpClass GSK_GPU_BORDER_OP_CLASS = {
|
||||
{
|
||||
GSK_GPU_OP_SIZE (GskGpuBorderOp),
|
||||
GSK_GPU_STAGE_SHADER,
|
||||
|
@@ -51,7 +51,7 @@ gsk_gpu_box_shadow_op_gl_command (GskGpuOp *op,
|
||||
return gsk_gpu_shader_op_gl_command_n (op, frame, state, 8);
|
||||
}
|
||||
|
||||
static const GskGpuShaderOpClass GSK_GPU_BOX_SHADOW_OP_CLASS = {
|
||||
const GskGpuShaderOpClass GSK_GPU_BOX_SHADOW_OP_CLASS = {
|
||||
{
|
||||
GSK_GPU_OP_SIZE (GskGpuBoxShadowOp),
|
||||
GSK_GPU_STAGE_SHADER,
|
||||
|
@@ -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 ("ngl-buffer-uploads", "Number of bytes uploaded to GPU");
|
||||
profiler_buffer_uploads_id = gdk_profiler_define_int_counter ("buffer-uploads", "Number of bytes uploaded to GPU");
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -27,7 +27,7 @@ gsk_gpu_colorize_op_print_instance (GskGpuShaderOp *shader,
|
||||
gsk_gpu_print_rgba (string, instance->color);
|
||||
}
|
||||
|
||||
static const GskGpuShaderOpClass GSK_GPU_COLORIZE_OP_CLASS = {
|
||||
const GskGpuShaderOpClass GSK_GPU_COLORIZE_OP_CLASS = {
|
||||
{
|
||||
GSK_GPU_OP_SIZE (GskGpuColorizeOp),
|
||||
GSK_GPU_STAGE_SHADER,
|
||||
|
@@ -26,7 +26,7 @@ gsk_gpu_color_matrix_op_print_instance (GskGpuShaderOp *shader,
|
||||
gsk_gpu_print_image_descriptor (string, shader->desc, instance->tex_id);
|
||||
}
|
||||
|
||||
static const GskGpuShaderOpClass GSK_GPU_COLOR_MATRIX_OP_CLASS = {
|
||||
const GskGpuShaderOpClass GSK_GPU_COLOR_MATRIX_OP_CLASS = {
|
||||
{
|
||||
GSK_GPU_OP_SIZE (GskGpuColorMatrixOp),
|
||||
GSK_GPU_STAGE_SHADER,
|
||||
|
@@ -27,7 +27,7 @@ gsk_gpu_color_op_print_instance (GskGpuShaderOp *shader,
|
||||
gsk_gpu_print_rgba (string, instance->color);
|
||||
}
|
||||
|
||||
static const GskGpuShaderOpClass GSK_GPU_COLOR_OP_CLASS = {
|
||||
const GskGpuShaderOpClass GSK_GPU_COLOR_OP_CLASS = {
|
||||
{
|
||||
GSK_GPU_OP_SIZE (GskGpuColorOp),
|
||||
GSK_GPU_STAGE_SHADER,
|
||||
|
@@ -27,7 +27,7 @@ gsk_gpu_conic_gradient_op_print_instance (GskGpuShaderOp *shader,
|
||||
gsk_gpu_print_rect (string, instance->rect);
|
||||
}
|
||||
|
||||
static const GskGpuShaderOpClass GSK_GPU_CONIC_GRADIENT_OP_CLASS = {
|
||||
const GskGpuShaderOpClass GSK_GPU_CONIC_GRADIENT_OP_CLASS = {
|
||||
{
|
||||
GSK_GPU_OP_SIZE (GskGpuConicGradientOp),
|
||||
GSK_GPU_STAGE_SHADER,
|
||||
|
@@ -28,7 +28,7 @@ gsk_gpu_cross_fade_op_print_instance (GskGpuShaderOp *shader,
|
||||
g_string_append_printf (string, "%g%%", 100 * instance->opacity_progress[1]);
|
||||
}
|
||||
|
||||
static const GskGpuShaderOpClass GSK_GPU_CROSS_FADE_OP_CLASS = {
|
||||
const GskGpuShaderOpClass GSK_GPU_CROSS_FADE_OP_CLASS = {
|
||||
{
|
||||
GSK_GPU_OP_SIZE (GskGpuCrossFadeOp),
|
||||
GSK_GPU_STAGE_SHADER,
|
||||
|
@@ -30,7 +30,7 @@ gsk_gpu_linear_gradient_op_print_instance (GskGpuShaderOp *shader,
|
||||
gsk_gpu_print_rect (string, instance->rect);
|
||||
}
|
||||
|
||||
static const GskGpuShaderOpClass GSK_GPU_LINEAR_GRADIENT_OP_CLASS = {
|
||||
const GskGpuShaderOpClass GSK_GPU_LINEAR_GRADIENT_OP_CLASS = {
|
||||
{
|
||||
GSK_GPU_OP_SIZE (GskGpuLinearGradientOp),
|
||||
GSK_GPU_STAGE_SHADER,
|
||||
|
@@ -27,7 +27,7 @@ gsk_gpu_mask_op_print_instance (GskGpuShaderOp *shader,
|
||||
gsk_gpu_print_image_descriptor (string, shader->desc, instance->mask_id);
|
||||
}
|
||||
|
||||
static const GskGpuShaderOpClass GSK_GPU_MASK_OP_CLASS = {
|
||||
const GskGpuShaderOpClass GSK_GPU_MASK_OP_CLASS = {
|
||||
{
|
||||
GSK_GPU_OP_SIZE (GskGpuMaskOp),
|
||||
GSK_GPU_STAGE_SHADER,
|
||||
|
@@ -345,8 +345,8 @@ gsk_gpu_node_processor_init_draw (GskGpuNodeProcessor *self,
|
||||
|
||||
area.x = 0;
|
||||
area.y = 0;
|
||||
area.width = ceilf (graphene_vec2_get_x (scale) * viewport->size.width - EPSILON);
|
||||
area.height = ceilf (graphene_vec2_get_y (scale) * viewport->size.height - EPSILON);
|
||||
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));
|
||||
|
||||
image = gsk_gpu_device_create_offscreen_image (gsk_gpu_frame_get_device (frame),
|
||||
FALSE,
|
||||
|
@@ -30,7 +30,7 @@ gsk_gpu_radial_gradient_op_print_instance (GskGpuShaderOp *shader,
|
||||
gsk_gpu_print_rect (string, instance->rect);
|
||||
}
|
||||
|
||||
static const GskGpuShaderOpClass GSK_GPU_RADIAL_GRADIENT_OP_CLASS = {
|
||||
const GskGpuShaderOpClass GSK_GPU_RADIAL_GRADIENT_OP_CLASS = {
|
||||
{
|
||||
GSK_GPU_OP_SIZE (GskGpuRadialGradientOp),
|
||||
GSK_GPU_STAGE_SHADER,
|
||||
|
@@ -27,7 +27,7 @@ gsk_gpu_rounded_color_op_print_instance (GskGpuShaderOp *shader,
|
||||
gsk_gpu_print_rgba (string, instance->color);
|
||||
}
|
||||
|
||||
static const GskGpuShaderOpClass GSK_GPU_ROUNDED_COLOR_OP_CLASS = {
|
||||
const GskGpuShaderOpClass GSK_GPU_ROUNDED_COLOR_OP_CLASS = {
|
||||
{
|
||||
GSK_GPU_OP_SIZE (GskGpuRoundedColorOp),
|
||||
GSK_GPU_STAGE_SHADER,
|
||||
|
@@ -268,3 +268,45 @@ gsk_gpu_shader_op_alloc (GskGpuFrame *frame,
|
||||
*((gpointer *) out_vertex_data) = gsk_gpu_frame_get_vertex_data (frame, vertex_offset);
|
||||
}
|
||||
|
||||
extern const GskGpuShaderOpClass GSK_GPU_BLEND_MODE_OP_CLASS;
|
||||
extern const GskGpuShaderOpClass GSK_GPU_BLUR_OP_CLASS;
|
||||
extern const GskGpuShaderOpClass GSK_GPU_BORDER_OP_CLASS;
|
||||
extern const GskGpuShaderOpClass GSK_GPU_BOX_SHADOW_OP_CLASS;
|
||||
extern const GskGpuShaderOpClass GSK_GPU_COLORIZE_OP_CLASS;
|
||||
extern const GskGpuShaderOpClass GSK_GPU_COLOR_MATRIX_OP_CLASS;
|
||||
extern const GskGpuShaderOpClass GSK_GPU_COLOR_OP_CLASS;
|
||||
extern const GskGpuShaderOpClass GSK_GPU_CONIC_GRADIENT_OP_CLASS;
|
||||
extern const GskGpuShaderOpClass GSK_GPU_CROSS_FADE_OP_CLASS;
|
||||
extern const GskGpuShaderOpClass GSK_GPU_LINEAR_GRADIENT_OP_CLASS;
|
||||
extern const GskGpuShaderOpClass GSK_GPU_MASK_OP_CLASS;
|
||||
extern const GskGpuShaderOpClass GSK_GPU_RADIAL_GRADIENT_OP_CLASS;
|
||||
extern const GskGpuShaderOpClass GSK_GPU_ROUNDED_COLOR_OP_CLASS;
|
||||
extern const GskGpuShaderOpClass GSK_GPU_STRAIGHT_ALPHA_OP_CLASS;
|
||||
extern const GskGpuShaderOpClass GSK_GPU_TEXTURE_OP_CLASS;
|
||||
extern const GskGpuShaderOpClass GSK_GPU_UBER_OP_CLASS;
|
||||
|
||||
#define CHECK_CLASS(class) if (strcmp (name, class.shader_name) == 0) return &class
|
||||
|
||||
const GskGpuShaderOpClass *
|
||||
gsk_gpu_shader_op_class_from_name (const char *name)
|
||||
{
|
||||
CHECK_CLASS (GSK_GPU_BLEND_MODE_OP_CLASS);
|
||||
else CHECK_CLASS (GSK_GPU_BLUR_OP_CLASS);
|
||||
else CHECK_CLASS (GSK_GPU_BORDER_OP_CLASS);
|
||||
else CHECK_CLASS (GSK_GPU_BOX_SHADOW_OP_CLASS);
|
||||
else CHECK_CLASS (GSK_GPU_COLORIZE_OP_CLASS);
|
||||
else CHECK_CLASS (GSK_GPU_COLOR_MATRIX_OP_CLASS);
|
||||
else CHECK_CLASS (GSK_GPU_COLOR_OP_CLASS);
|
||||
else CHECK_CLASS (GSK_GPU_CROSS_FADE_OP_CLASS);
|
||||
else CHECK_CLASS (GSK_GPU_LINEAR_GRADIENT_OP_CLASS);
|
||||
else CHECK_CLASS (GSK_GPU_MASK_OP_CLASS);
|
||||
else CHECK_CLASS (GSK_GPU_RADIAL_GRADIENT_OP_CLASS);
|
||||
else CHECK_CLASS (GSK_GPU_ROUNDED_COLOR_OP_CLASS);
|
||||
else CHECK_CLASS (GSK_GPU_STRAIGHT_ALPHA_OP_CLASS);
|
||||
else CHECK_CLASS (GSK_GPU_TEXTURE_OP_CLASS);
|
||||
else CHECK_CLASS (GSK_GPU_UBER_OP_CLASS);
|
||||
|
||||
g_warning ("No such shader op: %s\n", name);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@@ -84,5 +84,7 @@ gsk_gpu_point_to_float (const graphene_point_t *point,
|
||||
values[1] = point->y + offset->y;
|
||||
}
|
||||
|
||||
const GskGpuShaderOpClass * gsk_gpu_shader_op_class_from_name (const char *name);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@@ -29,7 +29,7 @@ gsk_gpu_straight_alpha_op_print_instance (GskGpuShaderOp *shader,
|
||||
gsk_gpu_print_image_descriptor (string, shader->desc, instance->tex_id);
|
||||
}
|
||||
|
||||
static const GskGpuShaderOpClass GSK_GPU_STRAIGHT_ALPHA_OP_CLASS = {
|
||||
const GskGpuShaderOpClass GSK_GPU_STRAIGHT_ALPHA_OP_CLASS = {
|
||||
{
|
||||
GSK_GPU_OP_SIZE (GskGpuStraightAlphaOp),
|
||||
GSK_GPU_STAGE_SHADER,
|
||||
|
@@ -26,7 +26,7 @@ gsk_gpu_texture_op_print_instance (GskGpuShaderOp *shader,
|
||||
gsk_gpu_print_image_descriptor (string, shader->desc, instance->tex_id);
|
||||
}
|
||||
|
||||
static const GskGpuShaderOpClass GSK_GPU_TEXTURE_OP_CLASS = {
|
||||
const GskGpuShaderOpClass GSK_GPU_TEXTURE_OP_CLASS = {
|
||||
{
|
||||
GSK_GPU_OP_SIZE (GskGpuTextureOp),
|
||||
GSK_GPU_STAGE_SHADER,
|
||||
|
@@ -26,7 +26,7 @@ gsk_gpu_uber_op_print_instance (GskGpuShaderOp *shader,
|
||||
gsk_gpu_print_rect (string, instance->rect);
|
||||
}
|
||||
|
||||
static const GskGpuShaderOpClass GSK_GPU_UBER_OP_CLASS = {
|
||||
const GskGpuShaderOpClass GSK_GPU_UBER_OP_CLASS = {
|
||||
{
|
||||
GSK_GPU_OP_SIZE (GskGpuUberOp),
|
||||
GSK_GPU_STAGE_SHADER,
|
||||
|
@@ -313,6 +313,11 @@ gsk_gpu_upload_texture_op_try (GskGpuFrame *frame,
|
||||
{
|
||||
GEnumClass *enum_class = g_type_class_ref (GDK_TYPE_MEMORY_FORMAT);
|
||||
|
||||
if (!GDK_IS_MEMORY_TEXTURE (texture))
|
||||
{
|
||||
gdk_debug_message ("Unoptimized upload for %s", G_OBJECT_TYPE_NAME (texture));
|
||||
}
|
||||
|
||||
if (gdk_texture_get_format (texture) != gsk_gpu_image_get_format (image))
|
||||
{
|
||||
gdk_debug_message ("Unsupported format %s, converting on CPU to %s",
|
||||
|
@@ -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_FULL,
|
||||
.ycbcrRange = VK_SAMPLER_YCBCR_RANGE_ITU_NARROW,
|
||||
.components = (VkComponentMapping) {
|
||||
VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||
VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||
@@ -951,6 +951,8 @@ 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,
|
||||
@@ -1128,8 +1130,25 @@ gsk_vulkan_device_get_vk_pipeline (GskVulkanDevice *self,
|
||||
&pipeline);
|
||||
|
||||
gdk_profiler_end_markf (begin_time,
|
||||
"Create Vulkan pipeline frag=%s vert=%s",
|
||||
fragment_shader_name, vertex_shader_name);
|
||||
"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 (%lu/%lu/%lu)",
|
||||
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);
|
||||
|
||||
g_free (fragment_shader_name);
|
||||
g_free (vertex_shader_name);
|
||||
|
@@ -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 @x3, @y3
|
||||
* Adds an elliptical arc from the current point to @x2, @y2
|
||||
* with @x1, @y1 determining the tangent directions.
|
||||
*
|
||||
* After this, @x3, @y3 will be the new current point.
|
||||
* After this, @x2, @y2 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 @x3, @y3
|
||||
* Adds an elliptical arc from the current point to @x2, @y2
|
||||
* with @x1, @y1 determining the tangent directions.
|
||||
*
|
||||
* All coordinates are given relative to the current point.
|
||||
|
@@ -28,7 +28,9 @@ G_BEGIN_DECLS
|
||||
|
||||
typedef enum
|
||||
{
|
||||
/* path has only lines */
|
||||
GSK_PATH_FLAT,
|
||||
/* all contours are closed */
|
||||
GSK_PATH_CLOSED
|
||||
} GskPathFlags;
|
||||
|
||||
|
@@ -428,21 +428,6 @@ 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;
|
||||
}
|
||||
|
||||
@@ -509,21 +494,6 @@ 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);
|
||||
@@ -609,12 +579,17 @@ get_renderer_for_display (GdkSurface *surface)
|
||||
static GType
|
||||
get_renderer_for_env_var (GdkSurface *surface)
|
||||
{
|
||||
static GType env_var_type = G_TYPE_NONE;
|
||||
static GType env_var_type = G_TYPE_INVALID;
|
||||
|
||||
if (env_var_type == G_TYPE_NONE)
|
||||
if (env_var_type == G_TYPE_INVALID)
|
||||
{
|
||||
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;
|
||||
@@ -632,83 +607,115 @@ get_renderer_for_backend (GdkSurface *surface)
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gl_software_rendering (GdkSurface *surface)
|
||||
gl_supported_platform (GdkSurface *surface,
|
||||
GType renderer_type,
|
||||
gboolean as_fallback)
|
||||
{
|
||||
GdkDisplay *display = gdk_surface_get_display (surface);
|
||||
GdkGLContext *context;
|
||||
GError *error = NULL;
|
||||
|
||||
if (!gdk_display_prepare_gl (display, NULL))
|
||||
return G_TYPE_INVALID;
|
||||
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;
|
||||
|
||||
context = gdk_display_get_gl_context (display);
|
||||
gdk_gl_context_make_current (context);
|
||||
|
||||
return strstr ((const char *) glGetString (GL_RENDERER), "llvmpipe") != NULL;
|
||||
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;
|
||||
}
|
||||
|
||||
static GType
|
||||
get_renderer_for_gl (GdkSurface *surface)
|
||||
{
|
||||
if (gl_software_rendering (surface))
|
||||
if (!gl_supported_platform (surface, gsk_ngl_renderer_get_type (), FALSE))
|
||||
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_software_rendering (GdkSurface *surface)
|
||||
vulkan_supported_platform (GdkSurface *surface,
|
||||
GType renderer_type,
|
||||
gboolean as_fallback)
|
||||
{
|
||||
GdkDisplay *display = gdk_surface_get_display (surface);
|
||||
VkPhysicalDeviceProperties props;
|
||||
GError *error = NULL;
|
||||
|
||||
if (!gdk_display_init_vulkan (display, NULL))
|
||||
return G_TYPE_INVALID;
|
||||
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;
|
||||
}
|
||||
|
||||
vkGetPhysicalDeviceProperties (display->vk_physical_device, &props);
|
||||
|
||||
return props.deviceType == VK_PHYSICAL_DEVICE_TYPE_CPU;
|
||||
}
|
||||
#endif
|
||||
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;
|
||||
}
|
||||
|
||||
static GType
|
||||
get_renderer_for_vulkan (GdkSurface *surface)
|
||||
{
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
if (vulkan_software_rendering (surface))
|
||||
return G_TYPE_INVALID;
|
||||
if (as_fallback)
|
||||
return TRUE;
|
||||
|
||||
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_friendly_platform (GdkSurface *surface)
|
||||
get_renderer_for_vulkan (GdkSurface *surface)
|
||||
{
|
||||
if (vulkan_friendly_platform (surface))
|
||||
return get_renderer_for_vulkan (surface);
|
||||
if (!vulkan_supported_platform (surface, GSK_TYPE_VULKAN_RENDERER, FALSE))
|
||||
return G_TYPE_INVALID;
|
||||
|
||||
return G_TYPE_INVALID;
|
||||
return GSK_TYPE_VULKAN_RENDERER;
|
||||
}
|
||||
|
||||
static GType
|
||||
get_renderer_for_gles2 (GdkSurface *surface)
|
||||
get_renderer_for_vulkan_fallback (GdkSurface *surface)
|
||||
{
|
||||
return GSK_TYPE_GL_RENDERER;
|
||||
if (!vulkan_supported_platform (surface, GSK_TYPE_VULKAN_RENDERER, TRUE))
|
||||
return G_TYPE_INVALID;
|
||||
|
||||
return GSK_TYPE_VULKAN_RENDERER;
|
||||
}
|
||||
#endif
|
||||
|
||||
static GType
|
||||
get_renderer_fallback (GdkSurface *surface)
|
||||
@@ -722,10 +729,14 @@ static struct {
|
||||
{ get_renderer_for_display },
|
||||
{ get_renderer_for_env_var },
|
||||
{ get_renderer_for_backend },
|
||||
{ get_renderer_for_vulkan_friendly_platform },
|
||||
{ get_renderer_for_gl },
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
{ get_renderer_for_vulkan },
|
||||
{ get_renderer_for_gles2 },
|
||||
#endif
|
||||
{ get_renderer_for_gl },
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
{ get_renderer_for_vulkan_fallback },
|
||||
#endif
|
||||
{ get_renderer_for_gl_fallback },
|
||||
{ get_renderer_fallback },
|
||||
};
|
||||
|
||||
@@ -763,17 +774,19 @@ gsk_renderer_new_for_surface (GdkSurface *surface)
|
||||
|
||||
if (gsk_renderer_realize (renderer, surface, &error))
|
||||
{
|
||||
GSK_RENDERER_DEBUG (renderer, RENDERER,
|
||||
"Using renderer of type '%s' for surface '%s'",
|
||||
G_OBJECT_TYPE_NAME (renderer),
|
||||
G_OBJECT_TYPE_NAME (surface));
|
||||
GSK_DEBUG (RENDERER,
|
||||
"Using renderer '%s' for surface '%s'",
|
||||
G_OBJECT_TYPE_NAME (renderer),
|
||||
G_OBJECT_TYPE_NAME (surface));
|
||||
return renderer;
|
||||
}
|
||||
|
||||
g_message ("Failed to realize renderer of type '%s' for surface '%s': %s\n",
|
||||
GSK_DEBUG (RENDERER,
|
||||
"Failed to realize renderer '%s' for surface '%s': %s",
|
||||
G_OBJECT_TYPE_NAME (renderer),
|
||||
G_OBJECT_TYPE_NAME (surface),
|
||||
error->message);
|
||||
|
||||
g_object_unref (renderer);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
|
@@ -21,9 +21,16 @@
|
||||
#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,
|
||||
@@ -199,6 +206,7 @@ _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,
|
||||
@@ -214,37 +222,38 @@ 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\"\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>",
|
||||
"<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,",
|
||||
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 void
|
||||
static gboolean
|
||||
extract_plane (GdkPixbuf *src,
|
||||
GdkPixbuf *dst,
|
||||
int from_plane,
|
||||
@@ -255,6 +264,7 @@ 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);
|
||||
@@ -274,11 +284,109 @@ 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 *
|
||||
@@ -293,38 +401,46 @@ 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;
|
||||
char *icon_height_str;
|
||||
GdkPixbuf *loaded;
|
||||
char *icon_width_str = NULL;
|
||||
char *icon_height_str = NULL;
|
||||
char *escaped_file_data = NULL;
|
||||
gsize len;
|
||||
GdkPixbuf *pixbuf = NULL;
|
||||
int plane;
|
||||
int icon_width, icon_height;
|
||||
char *escaped_file_data;
|
||||
gboolean has_symbolic_classes;
|
||||
gboolean only_fg = TRUE;
|
||||
|
||||
has_symbolic_classes = svg_has_symbolic_classes (file_data, file_len);
|
||||
|
||||
/* Fetch size from the original icon */
|
||||
GInputStream *stream = g_memory_input_stream_new_from_data (file_data, file_len, NULL);
|
||||
GdkPixbuf *reference = gdk_pixbuf_new_from_stream (stream, NULL, error);
|
||||
|
||||
g_object_unref (stream);
|
||||
|
||||
if (!reference)
|
||||
return NULL;
|
||||
|
||||
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);
|
||||
icon_width_str = g_strdup_printf ("%d", icon_width);
|
||||
icon_height_str = g_strdup_printf ("%d", icon_height);
|
||||
if (has_symbolic_classes || width == 0 || height == 0)
|
||||
svg_find_size_strings (file_data, file_len, &icon_width_str, &icon_height_str);
|
||||
|
||||
if (width == 0)
|
||||
width = icon_width * scale;
|
||||
width = (int) (g_ascii_strtoull (icon_width_str, NULL, 0) * scale);
|
||||
if (height == 0)
|
||||
height = icon_height * scale;
|
||||
height = (int) (g_ascii_strtoull (icon_height_str, NULL, 0) * scale);
|
||||
|
||||
for (plane = 0; plane < 3; plane++)
|
||||
if (!has_symbolic_classes)
|
||||
{
|
||||
GInputStream *stream;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
escaped_file_data = g_base64_encode ((guchar *) file_data, file_len);
|
||||
len = strlen (escaped_file_data);
|
||||
|
||||
for (int 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
|
||||
@@ -337,7 +453,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, width, height,
|
||||
loaded = load_symbolic_svg (escaped_file_data, len, width, height,
|
||||
icon_width_str,
|
||||
icon_height_str,
|
||||
g_string,
|
||||
@@ -358,25 +474,26 @@ gtk_make_symbolic_pixbuf_from_data (const char *file_data,
|
||||
g_free (filename);
|
||||
}
|
||||
|
||||
if (pixbuf == NULL)
|
||||
if (plane == 0)
|
||||
{
|
||||
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8,
|
||||
gdk_pixbuf_get_width (loaded),
|
||||
gdk_pixbuf_get_height (loaded));
|
||||
gdk_pixbuf_fill (pixbuf, 0);
|
||||
memset (gdk_pixbuf_get_pixels (pixbuf), 0, gdk_pixbuf_get_byte_length (pixbuf));
|
||||
|
||||
extract_plane (loaded, pixbuf, 3, 3);
|
||||
}
|
||||
|
||||
if (plane == 0)
|
||||
extract_plane (loaded, pixbuf, 3, 3);
|
||||
|
||||
extract_plane (loaded, pixbuf, 0, plane);
|
||||
only_fg &= extract_plane (loaded, pixbuf, 0, plane);
|
||||
|
||||
g_object_unref (loaded);
|
||||
}
|
||||
|
||||
g_free (escaped_file_data);
|
||||
|
||||
out:
|
||||
if (only_fg && pixbuf)
|
||||
gdk_pixbuf_set_option (pixbuf, "tEXt::only-foreground", "true");
|
||||
|
||||
g_free (escaped_file_data);
|
||||
g_free (icon_width_str);
|
||||
g_free (icon_height_str);
|
||||
|
||||
@@ -409,17 +526,17 @@ make_symbolic_pixbuf_from_resource (const char *path,
|
||||
}
|
||||
|
||||
static GdkPixbuf *
|
||||
make_symbolic_pixbuf_from_path (const char *path,
|
||||
int width,
|
||||
int height,
|
||||
double scale,
|
||||
GError **error)
|
||||
make_symbolic_pixbuf_from_filename (const char *filename,
|
||||
int width,
|
||||
int height,
|
||||
double scale,
|
||||
GError **error)
|
||||
{
|
||||
char *data;
|
||||
gsize size;
|
||||
GdkPixbuf *pixbuf;
|
||||
|
||||
if (!g_file_get_contents (path, &data, &size, error))
|
||||
if (!g_file_get_contents (filename, &data, &size, error))
|
||||
return NULL;
|
||||
|
||||
pixbuf = gtk_make_symbolic_pixbuf_from_data (data, size, width, height, scale, NULL, error);
|
||||
@@ -453,11 +570,85 @@ 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)
|
||||
{
|
||||
@@ -467,24 +658,7 @@ 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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
*only_fg = pixbuf_is_only_fg (pixbuf);
|
||||
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
||||
g_object_unref (pixbuf);
|
||||
}
|
||||
@@ -497,6 +671,7 @@ gdk_texture_new_from_resource_at_scale (const char *path,
|
||||
int width,
|
||||
int height,
|
||||
gboolean preserve_aspect,
|
||||
gboolean *only_fg,
|
||||
GError **error)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
@@ -505,6 +680,7 @@ 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);
|
||||
}
|
||||
@@ -516,18 +692,20 @@ gdk_texture_new_from_resource_at_scale (const char *path,
|
||||
/* {{{ Symbolic texture API */
|
||||
|
||||
GdkTexture *
|
||||
gdk_texture_new_from_path_symbolic (const char *path,
|
||||
int width,
|
||||
int height,
|
||||
double scale,
|
||||
GError **error)
|
||||
gdk_texture_new_from_filename_symbolic (const char *filename,
|
||||
int width,
|
||||
int height,
|
||||
double scale,
|
||||
gboolean *only_fg,
|
||||
GError **error)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
GdkTexture *texture = NULL;
|
||||
|
||||
pixbuf = make_symbolic_pixbuf_from_path (path, width, height, scale, error);
|
||||
pixbuf = make_symbolic_pixbuf_from_filename (filename, width, height, scale, error);
|
||||
if (pixbuf)
|
||||
{
|
||||
*only_fg = pixbuf_is_only_fg (pixbuf);
|
||||
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
||||
g_object_unref (pixbuf);
|
||||
}
|
||||
@@ -546,6 +724,7 @@ gdk_texture_new_from_resource_symbolic (const char *path,
|
||||
int width,
|
||||
int height,
|
||||
double scale,
|
||||
gboolean *only_fg,
|
||||
GError **error)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
@@ -554,6 +733,7 @@ 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);
|
||||
}
|
||||
@@ -588,14 +768,19 @@ gdk_texture_new_from_file_symbolic (GFile *file,
|
||||
int width,
|
||||
int height,
|
||||
double scale,
|
||||
gboolean *only_fg,
|
||||
GError **error)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
GdkTexture *texture;
|
||||
GdkTexture *texture = NULL;
|
||||
|
||||
pixbuf = make_symbolic_pixbuf_from_file (file, width, height, scale, error);
|
||||
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
||||
g_object_unref (pixbuf);
|
||||
if (pixbuf)
|
||||
{
|
||||
*only_fg = pixbuf_is_only_fg (pixbuf);
|
||||
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
||||
g_object_unref (pixbuf);
|
||||
}
|
||||
|
||||
return texture;
|
||||
}
|
||||
@@ -604,7 +789,7 @@ gdk_texture_new_from_file_symbolic (GFile *file,
|
||||
/* {{{ Scaled paintable API */
|
||||
|
||||
typedef struct {
|
||||
int scale_factor;
|
||||
double scale;
|
||||
} LoaderData;
|
||||
|
||||
static void
|
||||
@@ -620,24 +805,24 @@ on_loader_size_prepared (GdkPixbufLoader *loader,
|
||||
format = gdk_pixbuf_loader_get_format (loader);
|
||||
if (!gdk_pixbuf_format_is_scalable (format))
|
||||
{
|
||||
loader_data->scale_factor = 1;
|
||||
loader_data->scale = 1.0;
|
||||
return;
|
||||
}
|
||||
|
||||
gdk_pixbuf_loader_set_size (loader,
|
||||
width * loader_data->scale_factor,
|
||||
height * loader_data->scale_factor);
|
||||
width * loader_data->scale,
|
||||
height * loader_data->scale);
|
||||
}
|
||||
|
||||
static GdkPaintable *
|
||||
gdk_paintable_new_from_bytes_scaled (GBytes *bytes,
|
||||
int scale_factor)
|
||||
double scale)
|
||||
{
|
||||
LoaderData loader_data;
|
||||
GdkTexture *texture;
|
||||
GdkPaintable *paintable;
|
||||
|
||||
loader_data.scale_factor = scale_factor;
|
||||
loader_data.scale = scale;
|
||||
|
||||
if (gdk_texture_can_load (bytes))
|
||||
{
|
||||
@@ -667,8 +852,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_factor != 1)
|
||||
paintable = gtk_scaler_new (GDK_PAINTABLE (texture), loader_data.scale_factor);
|
||||
if (loader_data.scale != 1.0)
|
||||
paintable = gtk_scaler_new (GDK_PAINTABLE (texture), loader_data.scale);
|
||||
else
|
||||
paintable = g_object_ref (GDK_PAINTABLE (texture));
|
||||
|
||||
@@ -679,20 +864,20 @@ gdk_paintable_new_from_bytes_scaled (GBytes *bytes,
|
||||
}
|
||||
|
||||
GdkPaintable *
|
||||
gdk_paintable_new_from_path_scaled (const char *path,
|
||||
int scale_factor)
|
||||
gdk_paintable_new_from_filename_scaled (const char *filename,
|
||||
double scale)
|
||||
{
|
||||
char *contents;
|
||||
gsize length;
|
||||
GBytes *bytes;
|
||||
GdkPaintable *paintable;
|
||||
|
||||
if (!g_file_get_contents (path, &contents, &length, NULL))
|
||||
if (!g_file_get_contents (filename, &contents, &length, NULL))
|
||||
return NULL;
|
||||
|
||||
bytes = g_bytes_new_take (contents, length);
|
||||
|
||||
paintable = gdk_paintable_new_from_bytes_scaled (bytes, scale_factor);
|
||||
paintable = gdk_paintable_new_from_bytes_scaled (bytes, scale);
|
||||
|
||||
g_bytes_unref (bytes);
|
||||
|
||||
@@ -701,7 +886,7 @@ gdk_paintable_new_from_path_scaled (const char *path,
|
||||
|
||||
GdkPaintable *
|
||||
gdk_paintable_new_from_resource_scaled (const char *path,
|
||||
int scale_factor)
|
||||
double scale)
|
||||
{
|
||||
GBytes *bytes;
|
||||
GdkPaintable *paintable;
|
||||
@@ -710,15 +895,16 @@ gdk_paintable_new_from_resource_scaled (const char *path,
|
||||
if (!bytes)
|
||||
return NULL;
|
||||
|
||||
paintable = gdk_paintable_new_from_bytes_scaled (bytes, scale_factor);
|
||||
paintable = gdk_paintable_new_from_bytes_scaled (bytes, scale);
|
||||
|
||||
g_bytes_unref (bytes);
|
||||
|
||||
return paintable;
|
||||
}
|
||||
|
||||
GdkPaintable *
|
||||
gdk_paintable_new_from_file_scaled (GFile *file,
|
||||
int scale_factor)
|
||||
gdk_paintable_new_from_file_scaled (GFile *file,
|
||||
double scale)
|
||||
{
|
||||
GBytes *bytes;
|
||||
GdkPaintable *paintable;
|
||||
@@ -727,7 +913,7 @@ gdk_paintable_new_from_file_scaled (GFile *file,
|
||||
if (!bytes)
|
||||
return NULL;
|
||||
|
||||
paintable = gdk_paintable_new_from_bytes_scaled (bytes, scale_factor);
|
||||
paintable = gdk_paintable_new_from_bytes_scaled (bytes, scale);
|
||||
|
||||
g_bytes_unref (bytes);
|
||||
|
||||
|
@@ -29,45 +29,56 @@ GdkPixbuf *gtk_make_symbolic_pixbuf_from_data (const char *data,
|
||||
const char *debug_output_to,
|
||||
GError **error);
|
||||
|
||||
GdkTexture *gdk_texture_new_from_stream (GInputStream *stream,
|
||||
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,
|
||||
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_path_symbolic (const char *path,
|
||||
GdkTexture *gdk_texture_new_from_filename_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 *data);
|
||||
GdkTexture *gtk_load_symbolic_texture_from_resource (const char *path);
|
||||
|
||||
GdkPaintable *gdk_paintable_new_from_path_scaled (const char *path,
|
||||
int scale_factor);
|
||||
GdkPaintable *gdk_paintable_new_from_filename_scaled (const char *filename,
|
||||
double scale);
|
||||
GdkPaintable *gdk_paintable_new_from_resource_scaled (const char *path,
|
||||
int scale_factor);
|
||||
double scale);
|
||||
GdkPaintable *gdk_paintable_new_from_file_scaled (GFile *file,
|
||||
int scale_factor);
|
||||
double scale);
|
||||
|
||||
G_END_DECLS
|
||||
|
@@ -1055,6 +1055,7 @@ gtk_at_context_get_accessible_relation (GtkATContext *self,
|
||||
static guint8 naming[] = {
|
||||
[GTK_ACCESSIBLE_ROLE_ALERT] = NAME_FROM_AUTHOR,
|
||||
[GTK_ACCESSIBLE_ROLE_ALERT_DIALOG] = NAME_FROM_AUTHOR|GTK_ACCESSIBLE_NAME_REQUIRED,
|
||||
[GTK_ACCESSIBLE_ROLE_APPLICATION] = NAME_FROM_AUTHOR|GTK_ACCESSIBLE_NAME_REQUIRED,
|
||||
[GTK_ACCESSIBLE_ROLE_ARTICLE] = NAME_FROM_AUTHOR,
|
||||
[GTK_ACCESSIBLE_ROLE_BANNER] = GTK_ACCESSIBLE_NAME_PROHIBITED,
|
||||
[GTK_ACCESSIBLE_ROLE_BLOCK_QUOTE] = NAME_FROM_AUTHOR,
|
||||
@@ -1099,6 +1100,7 @@ static guint8 naming[] = {
|
||||
[GTK_ACCESSIBLE_ROLE_NONE] = GTK_ACCESSIBLE_NAME_PROHIBITED,
|
||||
[GTK_ACCESSIBLE_ROLE_NOTE] = NAME_FROM_AUTHOR,
|
||||
[GTK_ACCESSIBLE_ROLE_OPTION] = NAME_FROM_AUTHOR|NAME_FROM_CONTENT|GTK_ACCESSIBLE_NAME_REQUIRED,
|
||||
[GTK_ACCESSIBLE_ROLE_PARAGRAPH] = GTK_ACCESSIBLE_NAME_PROHIBITED,
|
||||
[GTK_ACCESSIBLE_ROLE_PRESENTATION] = GTK_ACCESSIBLE_NAME_PROHIBITED,
|
||||
[GTK_ACCESSIBLE_ROLE_PROGRESS_BAR] = NAME_FROM_AUTHOR|GTK_ACCESSIBLE_NAME_REQUIRED,
|
||||
[GTK_ACCESSIBLE_ROLE_RADIO] = NAME_FROM_AUTHOR|NAME_FROM_CONTENT|GTK_ACCESSIBLE_NAME_REQUIRED,
|
||||
@@ -1124,9 +1126,11 @@ static guint8 naming[] = {
|
||||
[GTK_ACCESSIBLE_ROLE_TABLE] = NAME_FROM_AUTHOR|GTK_ACCESSIBLE_NAME_REQUIRED,
|
||||
[GTK_ACCESSIBLE_ROLE_TAB_LIST] = NAME_FROM_AUTHOR,
|
||||
[GTK_ACCESSIBLE_ROLE_TAB_PANEL] = NAME_FROM_AUTHOR|GTK_ACCESSIBLE_NAME_REQUIRED,
|
||||
[GTK_ACCESSIBLE_ROLE_TERMINAL] = NAME_FROM_AUTHOR|GTK_ACCESSIBLE_NAME_REQUIRED,
|
||||
[GTK_ACCESSIBLE_ROLE_TEXT_BOX] = NAME_FROM_AUTHOR|GTK_ACCESSIBLE_NAME_REQUIRED,
|
||||
[GTK_ACCESSIBLE_ROLE_TIME] = GTK_ACCESSIBLE_NAME_PROHIBITED,
|
||||
[GTK_ACCESSIBLE_ROLE_TIMER] = NAME_FROM_AUTHOR,
|
||||
[GTK_ACCESSIBLE_ROLE_TOGGLE_BUTTON] = NAME_FROM_AUTHOR|GTK_ACCESSIBLE_NAME_REQUIRED,
|
||||
[GTK_ACCESSIBLE_ROLE_TOOLBAR] = NAME_FROM_AUTHOR|GTK_ACCESSIBLE_NAME_RECOMMENDED,
|
||||
[GTK_ACCESSIBLE_ROLE_TOOLTIP] = NAME_FROM_AUTHOR|NAME_FROM_CONTENT,
|
||||
[GTK_ACCESSIBLE_ROLE_TREE] = NAME_FROM_AUTHOR|GTK_ACCESSIBLE_NAME_REQUIRED,
|
||||
@@ -1134,9 +1138,6 @@ static guint8 naming[] = {
|
||||
[GTK_ACCESSIBLE_ROLE_TREE_ITEM] = NAME_FROM_AUTHOR|NAME_FROM_CONTENT|GTK_ACCESSIBLE_NAME_REQUIRED,
|
||||
[GTK_ACCESSIBLE_ROLE_WIDGET] = NAME_FROM_AUTHOR|NAME_FROM_CONTENT,
|
||||
[GTK_ACCESSIBLE_ROLE_WINDOW] = NAME_FROM_AUTHOR,
|
||||
[GTK_ACCESSIBLE_ROLE_TOGGLE_BUTTON] = NAME_FROM_AUTHOR|GTK_ACCESSIBLE_NAME_REQUIRED,
|
||||
[GTK_ACCESSIBLE_ROLE_APPLICATION] = NAME_FROM_AUTHOR|GTK_ACCESSIBLE_NAME_REQUIRED,
|
||||
[GTK_ACCESSIBLE_ROLE_PARAGRAPH] = GTK_ACCESSIBLE_NAME_PROHIBITED,
|
||||
};
|
||||
|
||||
/* < private >
|
||||
|
@@ -97,6 +97,7 @@ gtk_css_image_recolor_load_texture (GtkCssImageRecolor *recolor,
|
||||
GError **error)
|
||||
{
|
||||
char *uri;
|
||||
gboolean only_fg;
|
||||
|
||||
if (recolor->texture)
|
||||
return;
|
||||
@@ -110,7 +111,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, NULL);
|
||||
recolor->texture = gdk_texture_new_from_resource_symbolic (resource_path, 0, 0, 1.0, &only_fg, NULL);
|
||||
|
||||
g_free (resource_path);
|
||||
}
|
||||
@@ -119,7 +120,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, NULL);
|
||||
recolor->texture = gdk_texture_new_from_file_symbolic (recolor->file, 0, 0, 1.0, &only_fg, NULL);
|
||||
}
|
||||
|
||||
g_free (uri);
|
||||
|
@@ -258,9 +258,9 @@ gtk_drop_target_async_handle_event (GtkEventController *controller,
|
||||
|
||||
static void
|
||||
gtk_drop_target_async_handle_crossing (GtkEventController *controller,
|
||||
const GtkCrossingData *crossing,
|
||||
double x,
|
||||
double y)
|
||||
const GtkCrossingData *crossing,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
GtkDropTargetAsync *self = GTK_DROP_TARGET_ASYNC (controller);
|
||||
GtkWidget *widget = gtk_event_controller_get_widget (controller);
|
||||
@@ -340,9 +340,9 @@ gtk_drop_target_async_set_property (GObject *object,
|
||||
|
||||
static void
|
||||
gtk_drop_target_async_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkDropTargetAsync *self = GTK_DROP_TARGET_ASYNC (object);
|
||||
|
||||
|
@@ -414,6 +414,7 @@ struct _GtkIconPaintable
|
||||
guint is_svg : 1;
|
||||
guint is_resource : 1;
|
||||
guint is_symbolic : 1;
|
||||
guint only_fg : 1;
|
||||
|
||||
/* Cached information if we go ahead and try to load the icon.
|
||||
*
|
||||
@@ -3712,6 +3713,7 @@ icon_ensure_texture__locked (GtkIconPaintable *icon,
|
||||
gint64 before;
|
||||
int pixel_size;
|
||||
GError *load_error = NULL;
|
||||
gboolean only_fg = FALSE;
|
||||
|
||||
icon_cache_mark_used_if_cached (icon);
|
||||
|
||||
@@ -3739,28 +3741,32 @@ icon_ensure_texture__locked (GtkIconPaintable *icon,
|
||||
{
|
||||
if (icon->is_svg)
|
||||
{
|
||||
if (gtk_icon_paintable_is_symbolic (icon))
|
||||
if (icon->is_symbolic)
|
||||
icon->texture = gdk_texture_new_from_resource_symbolic (icon->filename,
|
||||
pixel_size, pixel_size,
|
||||
icon->desired_scale,
|
||||
&only_fg,
|
||||
&load_error);
|
||||
else
|
||||
icon->texture = gdk_texture_new_from_resource_at_scale (icon->filename,
|
||||
pixel_size, pixel_size,
|
||||
TRUE, &load_error);
|
||||
TRUE,
|
||||
&only_fg,
|
||||
&load_error);
|
||||
}
|
||||
else
|
||||
icon->texture = gdk_texture_new_from_resource (icon->filename);
|
||||
icon->texture = gdk_texture_new_from_resource_with_fg (icon->filename, &only_fg);
|
||||
}
|
||||
else if (icon->filename)
|
||||
{
|
||||
if (icon->is_svg)
|
||||
{
|
||||
if (gtk_icon_paintable_is_symbolic (icon))
|
||||
icon->texture = gdk_texture_new_from_path_symbolic (icon->filename,
|
||||
pixel_size, pixel_size,
|
||||
icon->desired_scale,
|
||||
&load_error);
|
||||
if (icon->is_symbolic)
|
||||
icon->texture = gdk_texture_new_from_filename_symbolic (icon->filename,
|
||||
pixel_size, pixel_size,
|
||||
icon->desired_scale,
|
||||
&only_fg,
|
||||
&load_error);
|
||||
else
|
||||
{
|
||||
GFile *file = g_file_new_for_path (icon->filename);
|
||||
@@ -3770,7 +3776,9 @@ icon_ensure_texture__locked (GtkIconPaintable *icon,
|
||||
{
|
||||
icon->texture = gdk_texture_new_from_stream_at_scale (stream,
|
||||
pixel_size, pixel_size,
|
||||
TRUE, NULL,
|
||||
TRUE,
|
||||
&only_fg,
|
||||
NULL,
|
||||
&load_error);
|
||||
g_object_unref (stream);
|
||||
}
|
||||
@@ -3780,7 +3788,7 @@ icon_ensure_texture__locked (GtkIconPaintable *icon,
|
||||
}
|
||||
else
|
||||
{
|
||||
icon->texture = gdk_texture_new_from_filename (icon->filename, &load_error);
|
||||
icon->texture = gdk_texture_new_from_filename_with_fg (icon->filename, &only_fg, &load_error);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -3798,15 +3806,19 @@ icon_ensure_texture__locked (GtkIconPaintable *icon,
|
||||
if (icon->is_svg)
|
||||
icon->texture = gdk_texture_new_from_stream_at_scale (stream,
|
||||
pixel_size, pixel_size,
|
||||
TRUE, NULL,
|
||||
TRUE,
|
||||
&only_fg,
|
||||
NULL,
|
||||
&load_error);
|
||||
else
|
||||
icon->texture = gdk_texture_new_from_stream (stream, NULL, &load_error);
|
||||
icon->texture = gdk_texture_new_from_stream_with_fg (stream, &only_fg, NULL, &load_error);
|
||||
|
||||
g_object_unref (stream);
|
||||
}
|
||||
}
|
||||
|
||||
icon->only_fg = only_fg;
|
||||
|
||||
if (!icon->texture)
|
||||
{
|
||||
g_warning ("Failed to load icon %s: %s", icon->filename, load_error ? load_error->message : "");
|
||||
@@ -3814,6 +3826,7 @@ icon_ensure_texture__locked (GtkIconPaintable *icon,
|
||||
icon->texture = gdk_texture_new_from_resource (IMAGE_MISSING_RESOURCE_PATH);
|
||||
icon->icon_name = g_strdup ("image-missing");
|
||||
icon->is_symbolic = FALSE;
|
||||
icon->only_fg = FALSE;
|
||||
}
|
||||
|
||||
if (GDK_PROFILER_IS_RUNNING)
|
||||
@@ -3896,22 +3909,9 @@ gtk_icon_paintable_snapshot_symbolic (GtkSymbolicPaintable *paintable,
|
||||
int texture_width, texture_height;
|
||||
double render_width;
|
||||
double render_height;
|
||||
gboolean symbolic;
|
||||
graphene_rect_t render_rect;
|
||||
|
||||
texture = gtk_icon_paintable_ensure_texture (icon);
|
||||
symbolic = gtk_icon_paintable_is_symbolic (icon);
|
||||
|
||||
if (symbolic)
|
||||
{
|
||||
graphene_matrix_t matrix;
|
||||
graphene_vec4_t offset;
|
||||
|
||||
init_color_matrix (&matrix, &offset,
|
||||
&colors[0], &colors[3],
|
||||
&colors[2], &colors[1]);
|
||||
|
||||
gtk_snapshot_push_color_matrix (snapshot, &matrix, &offset);
|
||||
}
|
||||
|
||||
texture_width = gdk_texture_get_width (texture);
|
||||
texture_height = gdk_texture_get_height (texture);
|
||||
@@ -3928,14 +3928,39 @@ gtk_icon_paintable_snapshot_symbolic (GtkSymbolicPaintable *paintable,
|
||||
render_height = height;
|
||||
}
|
||||
|
||||
gtk_snapshot_append_texture (snapshot, texture,
|
||||
&GRAPHENE_RECT_INIT ((width - render_width) / 2,
|
||||
(height - render_height) / 2,
|
||||
render_width,
|
||||
render_height));
|
||||
graphene_rect_init (&render_rect,
|
||||
(width - render_width) / 2,
|
||||
(height - render_height) / 2,
|
||||
render_width,
|
||||
render_height);
|
||||
|
||||
if (symbolic)
|
||||
gtk_snapshot_pop (snapshot);
|
||||
if (icon->is_symbolic && icon->only_fg)
|
||||
{
|
||||
g_debug ("snapshot symbolic icon using mask");
|
||||
gtk_snapshot_push_mask (snapshot, GSK_MASK_MODE_ALPHA);
|
||||
gtk_snapshot_append_texture (snapshot, texture, &render_rect);
|
||||
gtk_snapshot_pop (snapshot);
|
||||
gtk_snapshot_append_color (snapshot, &colors[0], &render_rect);
|
||||
gtk_snapshot_pop (snapshot);
|
||||
}
|
||||
else if (icon->is_symbolic)
|
||||
{
|
||||
graphene_matrix_t matrix;
|
||||
graphene_vec4_t offset;
|
||||
|
||||
g_debug ("snapshot symbolic icon using color-matrix");
|
||||
init_color_matrix (&matrix, &offset,
|
||||
&colors[0], &colors[3],
|
||||
&colors[2], &colors[1]);
|
||||
|
||||
gtk_snapshot_push_color_matrix (snapshot, &matrix, &offset);
|
||||
gtk_snapshot_append_texture (snapshot, texture, &render_rect);
|
||||
gtk_snapshot_pop (snapshot);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_snapshot_append_texture (snapshot, texture, &render_rect);
|
||||
}
|
||||
}
|
||||
|
||||
static GdkPaintableFlags
|
||||
|
@@ -598,7 +598,7 @@ gtk_image_set_from_file (GtkImage *image,
|
||||
}
|
||||
|
||||
scale_factor = gtk_widget_get_scale_factor (GTK_WIDGET (image));
|
||||
paintable = gdk_paintable_new_from_path_scaled (filename, scale_factor);
|
||||
paintable = gdk_paintable_new_from_filename_scaled (filename, scale_factor);
|
||||
|
||||
if (paintable == NULL)
|
||||
{
|
||||
|
@@ -2113,6 +2113,28 @@ gtk_label_unroot (GtkWidget *widget)
|
||||
GTK_WIDGET_CLASS (gtk_label_parent_class)->unroot (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
launch_done (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer data)
|
||||
{
|
||||
GError *error = NULL;
|
||||
gboolean success;
|
||||
|
||||
if (GTK_IS_FILE_LAUNCHER (source))
|
||||
success = gtk_file_launcher_launch_finish (GTK_FILE_LAUNCHER (source), result, &error);
|
||||
else if (GTK_IS_URI_LAUNCHER (source))
|
||||
success = gtk_uri_launcher_launch_finish (GTK_URI_LAUNCHER (source), result, &error);
|
||||
else
|
||||
g_assert_not_reached ();
|
||||
|
||||
if (!success)
|
||||
{
|
||||
g_warning ("Failed to launch handler: %s", error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_label_activate_link (GtkLabel *self,
|
||||
const char *uri)
|
||||
@@ -2132,7 +2154,7 @@ gtk_label_activate_link (GtkLabel *self,
|
||||
|
||||
file = g_file_new_for_uri (uri);
|
||||
launcher = gtk_file_launcher_new (file);
|
||||
gtk_file_launcher_launch (launcher, GTK_WINDOW (toplevel), NULL, NULL, NULL);
|
||||
gtk_file_launcher_launch (launcher, GTK_WINDOW (toplevel), NULL, launch_done, NULL);
|
||||
g_object_unref (launcher);
|
||||
g_object_unref (file);
|
||||
}
|
||||
@@ -2141,7 +2163,7 @@ gtk_label_activate_link (GtkLabel *self,
|
||||
GtkUriLauncher *launcher;
|
||||
|
||||
launcher = gtk_uri_launcher_new (uri);
|
||||
gtk_uri_launcher_launch (launcher, GTK_WINDOW (toplevel), NULL, NULL, NULL);
|
||||
gtk_uri_launcher_launch (launcher, GTK_WINDOW (toplevel), NULL, launch_done, NULL);
|
||||
g_object_unref (launcher);
|
||||
}
|
||||
|
||||
|
@@ -480,6 +480,28 @@ gtk_link_button_pressed_cb (GtkGestureClick *gesture,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
launch_done (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer data)
|
||||
{
|
||||
GError *error = NULL;
|
||||
gboolean success;
|
||||
|
||||
if (GTK_IS_FILE_LAUNCHER (source))
|
||||
success = gtk_file_launcher_launch_finish (GTK_FILE_LAUNCHER (source), result, &error);
|
||||
else if (GTK_IS_URI_LAUNCHER (source))
|
||||
success = gtk_uri_launcher_launch_finish (GTK_URI_LAUNCHER (source), result, &error);
|
||||
else
|
||||
g_assert_not_reached ();
|
||||
|
||||
if (!success)
|
||||
{
|
||||
g_warning ("Failed to launch handler: %s", error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_link_button_activate_link (GtkLinkButton *link_button)
|
||||
{
|
||||
@@ -496,7 +518,7 @@ gtk_link_button_activate_link (GtkLinkButton *link_button)
|
||||
|
||||
launcher = gtk_file_launcher_new (file);
|
||||
|
||||
gtk_file_launcher_launch (launcher, GTK_WINDOW (toplevel), NULL, NULL, NULL);
|
||||
gtk_file_launcher_launch (launcher, GTK_WINDOW (toplevel), NULL, launch_done, NULL);
|
||||
|
||||
g_object_unref (launcher);
|
||||
g_object_unref (file);
|
||||
@@ -505,7 +527,7 @@ gtk_link_button_activate_link (GtkLinkButton *link_button)
|
||||
{
|
||||
GtkUriLauncher *launcher = gtk_uri_launcher_new (link_button->uri);
|
||||
|
||||
gtk_uri_launcher_launch (launcher, GTK_WINDOW (toplevel), NULL, NULL, NULL);
|
||||
gtk_uri_launcher_launch (launcher, GTK_WINDOW (toplevel), NULL, launch_done, NULL);
|
||||
|
||||
g_object_unref (launcher);
|
||||
}
|
||||
|
@@ -28,7 +28,7 @@ struct _GtkScaler
|
||||
GObject parent_instance;
|
||||
|
||||
GdkPaintable *paintable;
|
||||
double scale_factor;
|
||||
double scale;
|
||||
};
|
||||
|
||||
struct _GtkScalerClass
|
||||
@@ -46,12 +46,12 @@ gtk_scaler_paintable_snapshot (GdkPaintable *paintable,
|
||||
|
||||
gtk_snapshot_save (snapshot);
|
||||
|
||||
gtk_snapshot_scale (snapshot, 1.0 / self->scale_factor, 1.0 / self->scale_factor);
|
||||
gtk_snapshot_scale (snapshot, 1.0 / self->scale, 1.0 / self->scale);
|
||||
|
||||
gdk_paintable_snapshot (self->paintable,
|
||||
snapshot,
|
||||
width * self->scale_factor,
|
||||
height * self->scale_factor);
|
||||
width * self->scale,
|
||||
height * self->scale);
|
||||
|
||||
gtk_snapshot_restore (snapshot);
|
||||
}
|
||||
@@ -63,7 +63,7 @@ gtk_scaler_paintable_get_current_image (GdkPaintable *paintable)
|
||||
GdkPaintable *current_paintable, *current_self;
|
||||
|
||||
current_paintable = gdk_paintable_get_current_image (self->paintable);
|
||||
current_self = gtk_scaler_new (current_paintable, self->scale_factor);
|
||||
current_self = gtk_scaler_new (current_paintable, self->scale);
|
||||
g_object_unref (current_paintable);
|
||||
|
||||
return current_self;
|
||||
@@ -82,7 +82,7 @@ gtk_scaler_paintable_get_intrinsic_width (GdkPaintable *paintable)
|
||||
{
|
||||
GtkScaler *self = GTK_SCALER (paintable);
|
||||
|
||||
return gdk_paintable_get_intrinsic_width (self->paintable) / self->scale_factor;
|
||||
return gdk_paintable_get_intrinsic_width (self->paintable) / self->scale;
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -90,7 +90,7 @@ gtk_scaler_paintable_get_intrinsic_height (GdkPaintable *paintable)
|
||||
{
|
||||
GtkScaler *self = GTK_SCALER (paintable);
|
||||
|
||||
return gdk_paintable_get_intrinsic_height (self->paintable) / self->scale_factor;
|
||||
return gdk_paintable_get_intrinsic_height (self->paintable) / self->scale;
|
||||
}
|
||||
|
||||
static double gtk_scaler_paintable_get_intrinsic_aspect_ratio (GdkPaintable *paintable)
|
||||
@@ -147,18 +147,18 @@ gtk_scaler_class_init (GtkScalerClass *klass)
|
||||
static void
|
||||
gtk_scaler_init (GtkScaler *self)
|
||||
{
|
||||
self->scale_factor = 1.0;
|
||||
self->scale = 1.0;
|
||||
}
|
||||
|
||||
GdkPaintable *
|
||||
gtk_scaler_new (GdkPaintable *paintable,
|
||||
double scale_factor)
|
||||
double scale)
|
||||
{
|
||||
GtkScaler *self;
|
||||
guint flags;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_PAINTABLE (paintable), NULL);
|
||||
g_return_val_if_fail (scale_factor > 0.0, NULL);
|
||||
g_return_val_if_fail (scale > 0.0, NULL);
|
||||
|
||||
self = g_object_new (GTK_TYPE_SCALER, NULL);
|
||||
|
||||
@@ -171,7 +171,7 @@ gtk_scaler_new (GdkPaintable *paintable,
|
||||
if ((flags & GDK_PAINTABLE_STATIC_SIZE) == 0)
|
||||
g_signal_connect_swapped (paintable, "invalidate-size", G_CALLBACK (gdk_paintable_invalidate_size), self);
|
||||
|
||||
self->scale_factor = scale_factor;
|
||||
self->scale = scale;
|
||||
|
||||
return GDK_PAINTABLE (self);
|
||||
}
|
||||
|
@@ -28,7 +28,7 @@ G_BEGIN_DECLS
|
||||
G_DECLARE_FINAL_TYPE (GtkScaler, gtk_scaler, GTK, SCALER, GObject)
|
||||
|
||||
GdkPaintable * gtk_scaler_new (GdkPaintable *paintable,
|
||||
double scale_factor);
|
||||
double scale);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
Before Width: | Height: | Size: 236 B After Width: | Height: | Size: 265 B |
Before Width: | Height: | Size: 231 B After Width: | Height: | Size: 261 B |
Before Width: | Height: | Size: 369 B After Width: | Height: | Size: 396 B |
Before Width: | Height: | Size: 282 B After Width: | Height: | Size: 312 B |
Before Width: | Height: | Size: 186 B After Width: | Height: | Size: 218 B |
Before Width: | Height: | Size: 181 B After Width: | Height: | Size: 211 B |
Before Width: | Height: | Size: 255 B After Width: | Height: | Size: 267 B |
Before Width: | Height: | Size: 226 B After Width: | Height: | Size: 253 B |
Before Width: | Height: | Size: 226 B After Width: | Height: | Size: 257 B |
Before Width: | Height: | Size: 217 B After Width: | Height: | Size: 246 B |
Before Width: | Height: | Size: 295 B After Width: | Height: | Size: 324 B |
Before Width: | Height: | Size: 319 B After Width: | Height: | Size: 348 B |
Before Width: | Height: | Size: 318 B After Width: | Height: | Size: 346 B |
Before Width: | Height: | Size: 195 B After Width: | Height: | Size: 227 B |
Before Width: | Height: | Size: 202 B After Width: | Height: | Size: 234 B |
Before Width: | Height: | Size: 291 B After Width: | Height: | Size: 316 B |
Before Width: | Height: | Size: 209 B After Width: | Height: | Size: 239 B |
Before Width: | Height: | Size: 161 B After Width: | Height: | Size: 190 B |
Before Width: | Height: | Size: 155 B After Width: | Height: | Size: 186 B |
Before Width: | Height: | Size: 155 B After Width: | Height: | Size: 186 B |
Before Width: | Height: | Size: 161 B After Width: | Height: | Size: 190 B |
Before Width: | Height: | Size: 229 B After Width: | Height: | Size: 261 B |
Before Width: | Height: | Size: 283 B After Width: | Height: | Size: 313 B |
Before Width: | Height: | Size: 116 B After Width: | Height: | Size: 148 B |
Before Width: | Height: | Size: 149 B After Width: | Height: | Size: 178 B |
Before Width: | Height: | Size: 100 B After Width: | Height: | Size: 132 B |
Before Width: | Height: | Size: 157 B After Width: | Height: | Size: 209 B |
Before Width: | Height: | Size: 105 B After Width: | Height: | Size: 156 B |
Before Width: | Height: | Size: 195 B After Width: | Height: | Size: 231 B |
Before Width: | Height: | Size: 104 B After Width: | Height: | Size: 178 B |
Before Width: | Height: | Size: 236 B After Width: | Height: | Size: 265 B |
Before Width: | Height: | Size: 186 B After Width: | Height: | Size: 243 B |
Before Width: | Height: | Size: 106 B After Width: | Height: | Size: 138 B |
Before Width: | Height: | Size: 135 B After Width: | Height: | Size: 167 B |
Before Width: | Height: | Size: 143 B After Width: | Height: | Size: 175 B |
Before Width: | Height: | Size: 154 B After Width: | Height: | Size: 186 B |
Before Width: | Height: | Size: 154 B After Width: | Height: | Size: 186 B |
Before Width: | Height: | Size: 143 B After Width: | Height: | Size: 175 B |
Before Width: | Height: | Size: 121 B After Width: | Height: | Size: 153 B |
Before Width: | Height: | Size: 322 B After Width: | Height: | Size: 356 B |
Before Width: | Height: | Size: 316 B After Width: | Height: | Size: 339 B |
Before Width: | Height: | Size: 101 B After Width: | Height: | Size: 133 B |
Before Width: | Height: | Size: 113 B After Width: | Height: | Size: 145 B |
Before Width: | Height: | Size: 320 B After Width: | Height: | Size: 350 B |
Before Width: | Height: | Size: 130 B After Width: | Height: | Size: 161 B |
Before Width: | Height: | Size: 160 B After Width: | Height: | Size: 189 B |
Before Width: | Height: | Size: 139 B After Width: | Height: | Size: 170 B |