Compare commits

..

3 Commits

Author SHA1 Message Date
Matthias Clasen e04cdce680 css: Implement light-dark()
This function returns one of two colors, depending on the
colorscheme that is in use.
2024-06-05 07:24:02 -04:00
Matthias Clasen 812b30eb54 Recompute styles when color-scheme changes
Treat a color-scheme change like reloading the theme.
2024-06-05 07:23:34 -04:00
Matthias Clasen 2b5ec9e879 Add a color-scheme setting
This is the desktop-wide prefer-dark/prefer-light setting.
2024-06-05 07:23:34 -04:00
151 changed files with 2435 additions and 6480 deletions
+1 -1
View File
@@ -299,7 +299,7 @@ node_editor_application_new (void)
app = g_object_new (NODE_EDITOR_APPLICATION_TYPE,
"application-id", "org.gtk.gtk4.NodeEditor",
"flags", G_APPLICATION_HANDLES_OPEN | G_APPLICATION_NON_UNIQUE,
"flags", G_APPLICATION_HANDLES_OPEN,
NULL);
g_application_add_main_option (G_APPLICATION (app), "version", 0, 0,G_OPTION_ARG_NONE, "Show program version", NULL);
+6 -5
View File
@@ -99,15 +99,16 @@ reaches the requested phase. However, in practice most things
happen at higher levels:
- If you are doing an animation, you can use
[method@Gtk.Widget.add_tick_callback] which will cause a regular
gtk_widget_add_tick_callback() which will cause a regular
beating of the clock with a callback in the Update phase
until you stop the tick.
- If some state changes that causes the size of your widget to
change you call [method@Gtk.Widget.queue_resize] which will request
change you call gtk_widget_queue_resize() which will request
a Layout phase and mark your widget as needing relayout.
- If some state changes so you need to redraw your widget you
use [method@Gtk.Widget.queue_draw] to request a Paint phase for
your widget.
- If some state changes so you need to redraw some area of
your widget you use the normal gtk_widget_queue_draw()
set of functions. These will request a Paint phase and
mark the region as needing redraw.
There are also a lot of implicit triggers of these from the
CSS layer (which does animations, resizes and repaints as needed).
-1
View File
@@ -30,7 +30,6 @@
#include <gdk/gdkcairo.h>
#include <gdk/gdkcairocontext.h>
#include <gdk/gdkclipboard.h>
#include <gdk/gdkcolorstate.h>
#include <gdk/gdkconfig.h>
#include <gdk/gdkcontentdeserializer.h>
#include <gdk/gdkcontentformats.h>
-183
View File
@@ -1,183 +0,0 @@
/* gdkcolorstate.c
*
* Copyright 2024 Matthias Clasen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gdkcolorstateprivate.h"
#include <glib/gi18n-lib.h>
/**
* GdkColorState:
*
* A `GdkColorState` object provides the information to interpret
* colors and pixels in a variety of ways.
*
* They are also known as
* [*color spaces*](https://en.wikipedia.org/wiki/Color_space).
*
* Crucially, GTK knows how to convert colors from one color
* state to another.
*
* `GdkColorState objects are immutable and therefore threadsafe.
*
* Since 4.16
*/
G_DEFINE_BOXED_TYPE (GdkColorState, gdk_color_state,
gdk_color_state_ref, gdk_color_state_unref);
/* {{{ Public API */
/**
* gdk_color_state_ref:
* @self: a `GdkColorState`
*
* Increase the reference count of @self.
*
* Returns: the object that was passed in
*
* Since: 4.16
*/
GdkColorState *
(gdk_color_state_ref) (GdkColorState *self)
{
return _gdk_color_state_ref (self);
}
/**
* gdk_color_state_unref:
* @self:a `GdkColorState`
*
* Decrease the reference count of @self.
*
* Unless @self is static, it will be freed
* when the reference count reaches zero.
*
* Since: 4.16
*/
void
(gdk_color_state_unref) (GdkColorState *self)
{
_gdk_color_state_unref (self);
}
/**
* gdk_color_state_get_srgb:
*
* Returns the color state object representing the sRGB color space.
*
* Since: 4.16
*/
GdkColorState *
gdk_color_state_get_srgb (void)
{
return GDK_COLOR_STATE_SRGB;
}
/**
* gdk_color_state_get_srgb_linear:
*
* Returns the color state object representing the linearized sRGB color space.
*
* Since: 4.16
*/
GdkColorState *
gdk_color_state_get_srgb_linear (void)
{
return GDK_COLOR_STATE_SRGB_LINEAR;
}
/**
* gdk_color_state_equal:
* @self: a `GdkColorState`
* @other: another `GdkColorStatee`
*
* Compares two `GdkColorStates` for equality.
*
* Note that this function is not guaranteed to be perfect and two objects
* describing the same color state may compare not equal. However, different
* color states will never compare equal.
*
* Returns: %TRUE if the two color states compare equal
*
* Since: 4.16
*/
gboolean
(gdk_color_state_equal) (GdkColorState *self,
GdkColorState *other)
{
return _gdk_color_state_equal (self, other);
}
/* }}} */
/* {{{ Default implementation */
const char *
gdk_color_state_get_name_from_id (GdkColorStateId id)
{
const char *names[] = {
"srgb", "srgb-linear",
};
return names[id];
}
GdkColorState gdk_default_color_states[] = {
{ NULL, 0 },
{ NULL, 0 },
};
/* }}} */
/* {{{ Private API */
const char *
gdk_color_state_get_name (GdkColorState *self)
{
if (GDK_IS_DEFAULT_COLOR_STATE (self))
{
switch (GDK_DEFAULT_COLOR_STATE_ID (self))
{
case GDK_COLOR_STATE_ID_SRGB: return "srgb";
case GDK_COLOR_STATE_ID_SRGB_LINEAR: return "srgb-linear";
default: g_assert_not_reached ();
}
}
return self->klass->get_name (self);
}
void
gdk_color_state_print (GdkColorState *self,
GString *string)
{
g_string_append (string, gdk_color_state_get_name (self));
}
GdkMemoryDepth
gdk_color_state_get_min_depth (GdkColorState *self)
{
if (self == GDK_COLOR_STATE_SRGB || self == GDK_COLOR_STATE_SRGB_LINEAR)
return GDK_MEMORY_U8;
return GDK_MEMORY_FLOAT16;
}
/* }}} */
/* vim:set foldmethod=marker expandtab: */
-50
View File
@@ -1,50 +0,0 @@
/* gdkcolorstate.h
*
* Copyright 2024 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#if !defined (__GDK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gdk/gdk.h> can be included directly."
#endif
#include <gdk/gdktypes.h>
G_BEGIN_DECLS
#define GDK_TYPE_COLOR_STATE (gdk_color_state_get_type ())
GDK_AVAILABLE_IN_4_16
GType gdk_color_state_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_4_16
GdkColorState * gdk_color_state_ref (GdkColorState *self);
GDK_AVAILABLE_IN_4_16
void gdk_color_state_unref (GdkColorState *self);
GDK_AVAILABLE_IN_4_16
GdkColorState * gdk_color_state_get_srgb (void);
GDK_AVAILABLE_IN_4_16
GdkColorState * gdk_color_state_get_srgb_linear (void);
GDK_AVAILABLE_IN_4_16
gboolean gdk_color_state_equal (GdkColorState *self,
GdkColorState *other);
G_END_DECLS
-84
View File
@@ -1,84 +0,0 @@
#pragma once
#include "gdkcolorstate.h"
#include "gdkmemoryformatprivate.h"
typedef enum
{
GDK_COLOR_STATE_ID_SRGB,
GDK_COLOR_STATE_ID_SRGB_LINEAR,
} GdkColorStateId;
typedef struct _GdkColorStateClass GdkColorStateClass;
struct _GdkColorState
{
GdkColorStateClass *klass;
int ref_count;
};
struct _GdkColorStateClass
{
void (* free) (GdkColorState *self);
gboolean (* equal) (GdkColorState *self,
GdkColorState *other);
const char * (* get_name) (GdkColorState *self);
};
extern GdkColorState gdk_default_color_states[];
#define GDK_COLOR_STATE_SRGB (&gdk_default_color_states[GDK_COLOR_STATE_ID_SRGB])
#define GDK_COLOR_STATE_SRGB_LINEAR (&gdk_default_color_states[GDK_COLOR_STATE_ID_SRGB_LINEAR])
#define GDK_IS_DEFAULT_COLOR_STATE(c) (GDK_COLOR_STATE_SRGB <= (c) && (c) <= GDK_COLOR_STATE_SRGB_LINEAR)
#define GDK_DEFAULT_COLOR_STATE_ID(c) ((GdkColorStateId) (c - gdk_default_color_states))
const char * gdk_color_state_get_name (GdkColorState *color_state);
const char * gdk_color_state_get_name_from_id (GdkColorStateId id);
void gdk_color_state_print (GdkColorState *color_state,
GString *string);
GdkMemoryDepth gdk_color_state_get_min_depth (GdkColorState *color_state);
#define gdk_color_state_ref(self) _gdk_color_state_ref (self)
static inline GdkColorState *
_gdk_color_state_ref (GdkColorState *self)
{
if (GDK_IS_DEFAULT_COLOR_STATE (self))
return self;
self->ref_count++;
return self;
}
#define gdk_color_state_unref(self) _gdk_color_state_unref (self)
static inline void
_gdk_color_state_unref (GdkColorState *self)
{
if (GDK_IS_DEFAULT_COLOR_STATE (self))
return;
self->ref_count--;
if (self->ref_count == 0)
self->klass->free (self);
}
#define gdk_color_state_equal(a,b) _gdk_color_state_equal ((a), (b))
static inline gboolean
_gdk_color_state_equal (GdkColorState *self,
GdkColorState *other)
{
if (self == other)
return TRUE;
if (GDK_IS_DEFAULT_COLOR_STATE (self) || GDK_IS_DEFAULT_COLOR_STATE (other))
return FALSE;
if (self->klass != other->klass)
return FALSE;
return self->klass->equal (self, other);
}
-2
View File
@@ -1874,8 +1874,6 @@ gdk_display_init_egl (GdkDisplay *self,
epoxy_has_egl_extension (priv->egl_display, "EGL_EXT_image_dma_buf_import_modifiers");
self->have_egl_dma_buf_export =
epoxy_has_egl_extension (priv->egl_display, "EGL_MESA_image_dma_buf_export");
self->have_egl_gl_colorspace =
epoxy_has_egl_extension (priv->egl_display, "EGL_KHR_gl_colorspace");
if (self->have_egl_no_config_context)
priv->egl_config_high_depth = gdk_display_create_egl_config (self,
-1
View File
@@ -130,7 +130,6 @@ struct _GdkDisplay
guint have_egl_pixel_format_float : 1;
guint have_egl_dma_buf_import : 1;
guint have_egl_dma_buf_export : 1;
guint have_egl_gl_colorspace : 1;
GdkDmabufFormats *dmabuf_formats;
GdkDmabufDownloader *dmabuf_downloaders[4];
-2
View File
@@ -1758,8 +1758,6 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
priv->features = supported_features & ~disabled_features;
glEnable (GL_FRAMEBUFFER_SRGB);
gdk_gl_context_init_memory_flags (context);
if ((priv->features & GDK_GL_FEATURE_DEBUG) && gl_debug)
+7 -7
View File
@@ -151,7 +151,7 @@ gdk_gl_texture_find_format (GdkGLContext *context,
for (format = 0; format < GDK_MEMORY_N_FORMATS; format++)
{
GLint q_internal_format, q_internal_srgb_format;
GLint q_internal_format;
GLenum q_format, q_type;
GLint q_swizzle[4];
@@ -164,7 +164,6 @@ gdk_gl_texture_find_format (GdkGLContext *context,
gdk_memory_format_gl_format (format,
gdk_gl_context_get_use_es (context),
&q_internal_format,
&q_internal_srgb_format,
&q_format,
&q_type,
q_swizzle);
@@ -188,7 +187,7 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
GdkMemoryFormat format;
gsize expected_stride;
Download *download = download_;
GLint gl_internal_format, gl_internal_srgb_format;
GLint gl_internal_format;
GLenum gl_format, gl_type;
GLint gl_swizzle[4];
@@ -200,7 +199,7 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
{
gdk_memory_format_gl_format (format,
gdk_gl_context_get_use_es (context),
&gl_internal_format, &gl_internal_srgb_format,
&gl_internal_format,
&gl_format, &gl_type, gl_swizzle);
if (download->stride == expected_stride &&
download->format == format)
@@ -263,7 +262,7 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
gdk_memory_format_gl_format (actual_format,
gdk_gl_context_get_use_es (context),
&gl_internal_format, &gl_internal_srgb_format,
&gl_internal_format,
&gl_read_format, &gl_read_type, gl_swizzle);
}
}
@@ -275,7 +274,7 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
gdk_memory_format_gl_format (actual_format,
gdk_gl_context_get_use_es (context),
&gl_internal_format, &gl_internal_srgb_format,
&gl_internal_format,
&gl_read_format, &gl_read_type, gl_swizzle);
}
@@ -472,7 +471,8 @@ gdk_gl_texture_release (GdkGLTexture *self)
g_return_if_fail (self->saved == NULL);
texture = GDK_TEXTURE (self);
self->saved = GDK_TEXTURE (gdk_memory_texture_from_texture (texture));
self->saved = GDK_TEXTURE (gdk_memory_texture_from_texture (texture,
gdk_texture_get_format (texture)));
drop_gl_resources (self);
}
-327
View File
@@ -23,8 +23,6 @@
#include "gdkdmabuffourccprivate.h"
#include "gdkglcontextprivate.h"
#include "gdkcolorstateprivate.h"
#include "gtk/gtkcolorutilsprivate.h"
#include "gsk/gl/fp16private.h"
@@ -329,7 +327,6 @@ ADD_ALPHA_FUNC(r8g8b8_to_a8b8g8r8, 0, 1, 2, 3, 2, 1, 0)
struct _GdkMemoryFormatDescription
{
const char *name;
GdkMemoryAlpha alpha;
GdkMemoryFormat premultiplied;
GdkMemoryFormat straight;
@@ -340,9 +337,7 @@ struct _GdkMemoryFormatDescription
struct {
GLint internal_gl_format;
GLint internal_gles_format;
GLint internal_srgb_format;
GLenum format;
GLenum srgb_format;
GLenum type;
GLint swizzle[4];
/* -1 if none exists, ie the format is already RGBA
@@ -352,7 +347,6 @@ struct _GdkMemoryFormatDescription
} gl;
#ifdef GDK_RENDERING_VULKAN
VkFormat vk_format;
VkFormat vk_srgb_format;
#endif
#ifdef HAVE_DMABUF
guint32 dmabuf_fourcc;
@@ -372,7 +366,6 @@ struct _GdkMemoryFormatDescription
static const GdkMemoryFormatDescription memory_formats[] = {
[GDK_MEMORY_B8G8R8A8_PREMULTIPLIED] = {
.name = "*BGRA8",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_B8G8R8A8_PREMULTIPLIED,
.straight = GDK_MEMORY_B8G8R8A8,
@@ -385,7 +378,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_BGRA,
.internal_srgb_format = -1,
.format = GL_BGRA,
.type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -394,7 +386,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_B8G8R8A8_UNORM,
.vk_srgb_format = VK_FORMAT_B8G8R8A8_SRGB,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_ARGB8888,
@@ -403,7 +394,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = b8g8r8a8_premultiplied_from_float,
},
[GDK_MEMORY_A8R8G8B8_PREMULTIPLIED] = {
.name = "*ARGB8",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_A8R8G8B8_PREMULTIPLIED,
.straight = GDK_MEMORY_A8R8G8B8,
@@ -416,7 +406,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_RGBA8,
.internal_srgb_format = GL_SRGB8_ALPHA8,
.format = GL_BGRA,
.type = GDK_GL_UNSIGNED_BYTE_FLIPPED,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -425,7 +414,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_UNDEFINED,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_BGRA8888,
@@ -434,7 +422,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = a8r8g8b8_premultiplied_from_float,
},
[GDK_MEMORY_R8G8B8A8_PREMULTIPLIED] = {
.name = "*RGBA8",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED,
.straight = GDK_MEMORY_R8G8B8A8,
@@ -447,7 +434,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_RGBA8,
.internal_srgb_format = GL_SRGB8_ALPHA8,
.format = GL_RGBA,
.type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -455,7 +441,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R8G8B8A8_UNORM,
.vk_srgb_format = VK_FORMAT_R8G8B8A8_SRGB,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_ABGR8888,
@@ -464,7 +449,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r8g8b8a8_premultiplied_from_float,
},
[GDK_MEMORY_A8B8G8R8_PREMULTIPLIED] = {
.name = "*ABGR8",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_A8B8G8R8_PREMULTIPLIED,
.straight = GDK_MEMORY_A8B8G8R8,
@@ -477,7 +461,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_RGBA8,
.internal_srgb_format = GL_SRGB8_ALPHA8,
.format = GL_RGBA,
.type = GDK_GL_UNSIGNED_BYTE_FLIPPED,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -486,7 +469,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_UNDEFINED,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_RGBA8888,
@@ -495,7 +477,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = a8b8g8r8_premultiplied_from_float,
},
[GDK_MEMORY_B8G8R8A8] = {
.name = "BGRA8",
.alpha = GDK_MEMORY_ALPHA_STRAIGHT,
.premultiplied = GDK_MEMORY_B8G8R8A8_PREMULTIPLIED,
.straight = GDK_MEMORY_B8G8R8A8,
@@ -508,7 +489,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_BGRA,
.internal_srgb_format = -1,
.format = GL_BGRA,
.type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -517,7 +497,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_B8G8R8A8_UNORM,
.vk_srgb_format = VK_FORMAT_B8G8R8A8_SRGB,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_ARGB8888,
@@ -526,7 +505,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = b8g8r8a8_from_float,
},
[GDK_MEMORY_A8R8G8B8] = {
.name = "ARGB8",
.alpha = GDK_MEMORY_ALPHA_STRAIGHT,
.premultiplied = GDK_MEMORY_A8R8G8B8_PREMULTIPLIED,
.straight = GDK_MEMORY_A8R8G8B8,
@@ -539,7 +517,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_RGBA8,
.internal_srgb_format = GL_SRGB8_ALPHA8,
.format = GL_BGRA,
.type = GDK_GL_UNSIGNED_BYTE_FLIPPED,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -548,7 +525,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_UNDEFINED,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_BGRA8888,
@@ -557,7 +533,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = a8r8g8b8_from_float,
},
[GDK_MEMORY_R8G8B8A8] = {
.name = "RGBA8",
.alpha = GDK_MEMORY_ALPHA_STRAIGHT,
.premultiplied = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED,
.straight = GDK_MEMORY_R8G8B8A8,
@@ -570,7 +545,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_RGBA8,
.internal_srgb_format = GL_SRGB8_ALPHA8,
.format = GL_RGBA,
.type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -578,7 +552,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R8G8B8A8_UNORM,
.vk_srgb_format = VK_FORMAT_R8G8B8A8_SRGB,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_ABGR8888,
@@ -587,7 +560,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r8g8b8a8_from_float,
},
[GDK_MEMORY_A8B8G8R8] = {
.name = "ABGR8",
.alpha = GDK_MEMORY_ALPHA_STRAIGHT,
.premultiplied = GDK_MEMORY_A8B8G8R8_PREMULTIPLIED,
.straight = GDK_MEMORY_A8B8G8R8,
@@ -600,7 +572,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_RGBA8,
.internal_srgb_format = GL_SRGB8_ALPHA8,
.format = GL_RGBA,
.type = GDK_GL_UNSIGNED_BYTE_FLIPPED,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -609,7 +580,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_UNDEFINED,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_RGBA8888,
@@ -618,7 +588,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = a8b8g8r8_from_float,
},
[GDK_MEMORY_B8G8R8X8] = {
.name = "BGRX8",
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_B8G8R8X8,
.straight = GDK_MEMORY_B8G8R8X8,
@@ -632,7 +601,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_BGRA,
.internal_srgb_format = -1,
.format = GL_BGRA,
.type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ONE },
@@ -641,7 +609,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_B8G8R8A8_UNORM,
.vk_srgb_format = VK_FORMAT_B8G8R8A8_SRGB,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_XRGB8888,
@@ -650,7 +617,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = b8g8r8x8_from_float,
},
[GDK_MEMORY_X8R8G8B8] = {
.name = "XRGB8",
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_X8R8G8B8,
.straight = GDK_MEMORY_X8R8G8B8,
@@ -664,7 +630,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_RGBA8,
.internal_srgb_format = GL_SRGB8_ALPHA8,
.format = GL_BGRA,
.type = GDK_GL_UNSIGNED_BYTE_FLIPPED,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ONE },
@@ -673,7 +638,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_UNDEFINED,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_BGRX8888,
@@ -682,7 +646,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = x8r8g8b8_from_float,
},
[GDK_MEMORY_R8G8B8X8] = {
.name = "RGBX8",
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_R8G8B8X8,
.straight = GDK_MEMORY_R8G8B8X8,
@@ -696,7 +659,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_RGBA8,
.internal_srgb_format = GL_SRGB8_ALPHA8,
.format = GL_RGBA,
.type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ONE },
@@ -704,7 +666,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R8G8B8A8_UNORM,
.vk_srgb_format = VK_FORMAT_R8G8B8A8_SRGB,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_XBGR8888,
@@ -713,7 +674,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r8g8b8x8_from_float,
},
[GDK_MEMORY_X8B8G8R8] = {
.name = "XBGR8",
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_X8B8G8R8,
.straight = GDK_MEMORY_X8B8G8R8,
@@ -727,7 +687,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_RGBA8,
.internal_srgb_format = GL_SRGB8_ALPHA8,
.format = GL_RGBA,
.type = GDK_GL_UNSIGNED_BYTE_FLIPPED,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ONE },
@@ -736,7 +695,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_UNDEFINED,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_RGBX8888,
@@ -745,7 +703,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = x8b8g8r8_from_float,
},
[GDK_MEMORY_R8G8B8] = {
.name = "RGB8",
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_R8G8B8,
.straight = GDK_MEMORY_R8G8B8,
@@ -759,7 +716,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGB8,
.internal_gles_format = GL_RGB8,
.internal_srgb_format = GL_SRGB8,
.format = GL_RGB,
.type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -767,7 +723,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R8G8B8_UNORM,
.vk_srgb_format = VK_FORMAT_R8G8B8_SRGB,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_BGR888,
@@ -776,7 +731,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r8g8b8_from_float,
},
[GDK_MEMORY_B8G8R8] = {
.name = "BGR8",
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_B8G8R8,
.straight = GDK_MEMORY_B8G8R8,
@@ -790,7 +744,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGB8,
.internal_gles_format = GL_RGB8,
.internal_srgb_format = GL_SRGB8,
.format = GL_BGR,
.type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -799,7 +752,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_B8G8R8_UNORM,
.vk_srgb_format = VK_FORMAT_B8G8R8_SRGB,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_RGB888,
@@ -808,7 +760,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = b8g8r8_from_float,
},
[GDK_MEMORY_R16G16B16] = {
.name = "RGB16",
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_R16G16B16,
.straight = GDK_MEMORY_R16G16B16,
@@ -825,7 +776,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGB16,
.internal_gles_format = GL_RGB16,
.internal_srgb_format = -1,
.format = GL_RGB,
.type = GL_UNSIGNED_SHORT,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -833,7 +783,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16G16B16_UNORM,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = 0,
@@ -842,7 +791,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r16g16b16_from_float,
},
[GDK_MEMORY_R16G16B16A16_PREMULTIPLIED] = {
.name = "*RGBA16",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_R16G16B16A16_PREMULTIPLIED,
.straight = GDK_MEMORY_R16G16B16A16,
@@ -858,7 +806,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA16,
.internal_gles_format = GL_RGBA16,
.internal_srgb_format = -1,
.format = GL_RGBA,
.type = GL_UNSIGNED_SHORT,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -866,7 +813,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16G16B16A16_UNORM,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_ABGR16161616,
@@ -875,7 +821,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r16g16b16a16_from_float,
},
[GDK_MEMORY_R16G16B16A16] = {
.name = "RGBA16",
.alpha = GDK_MEMORY_ALPHA_STRAIGHT,
.premultiplied = GDK_MEMORY_R16G16B16A16_PREMULTIPLIED,
.straight = GDK_MEMORY_R16G16B16A16,
@@ -891,7 +836,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA16,
.internal_gles_format = GL_RGBA16,
.internal_srgb_format = -1,
.format = GL_RGBA,
.type = GL_UNSIGNED_SHORT,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -899,7 +843,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16G16B16A16_UNORM,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_ABGR16161616,
@@ -908,7 +851,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r16g16b16a16_from_float,
},
[GDK_MEMORY_R16G16B16_FLOAT] = {
.name = "RGBA16f",
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_R16G16B16_FLOAT,
.straight = GDK_MEMORY_R16G16B16_FLOAT,
@@ -924,7 +866,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGB16F,
.internal_gles_format = GL_RGB16F,
.internal_srgb_format = -1,
.format = GL_RGB,
.type = GL_HALF_FLOAT,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -932,7 +873,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16G16B16_SFLOAT,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = 0,
@@ -941,7 +881,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r16g16b16_float_from_float,
},
[GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED] = {
.name = "*RGBA16f",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED,
.straight = GDK_MEMORY_R16G16B16A16_FLOAT,
@@ -956,7 +895,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA16F,
.internal_gles_format = GL_RGBA16F,
.internal_srgb_format = -1,
.format = GL_RGBA,
.type = GL_HALF_FLOAT,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -964,7 +902,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16G16B16A16_SFLOAT,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_ABGR16161616F,
@@ -973,7 +910,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r16g16b16a16_float_from_float,
},
[GDK_MEMORY_R16G16B16A16_FLOAT] = {
.name = "RGBA16f",
.alpha = GDK_MEMORY_ALPHA_STRAIGHT,
.premultiplied = GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED,
.straight = GDK_MEMORY_R16G16B16A16_FLOAT,
@@ -988,7 +924,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA16F,
.internal_gles_format = GL_RGBA16F,
.internal_srgb_format = -1,
.format = GL_RGBA,
.type = GL_HALF_FLOAT,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -996,7 +931,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16G16B16A16_SFLOAT,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_ABGR16161616F,
@@ -1005,7 +939,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r16g16b16a16_float_from_float,
},
[GDK_MEMORY_R32G32B32_FLOAT] = {
.name = "RGB32f",
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_R32G32B32_FLOAT,
.straight = GDK_MEMORY_R32G32B32_FLOAT,
@@ -1021,7 +954,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGB32F,
.internal_gles_format = GL_RGB32F,
.internal_srgb_format = -1,
.format = GL_RGB,
.type = GL_FLOAT,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -1029,7 +961,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R32G32B32_SFLOAT,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = 0,
@@ -1038,7 +969,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r32g32b32_float_from_float,
},
[GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED] = {
.name = "*RGBA32f",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED,
.straight = GDK_MEMORY_R32G32B32A32_FLOAT,
@@ -1053,7 +983,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA32F,
.internal_gles_format = GL_RGBA32F,
.internal_srgb_format = -1,
.format = GL_RGBA,
.type = GL_FLOAT,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -1061,7 +990,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R32G32B32A32_SFLOAT,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = 0,
@@ -1070,7 +998,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r32g32b32a32_float_from_float,
},
[GDK_MEMORY_R32G32B32A32_FLOAT] = {
.name = "RGBA32f",
.alpha = GDK_MEMORY_ALPHA_STRAIGHT,
.premultiplied = GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED,
.straight = GDK_MEMORY_R32G32B32A32_FLOAT,
@@ -1085,7 +1012,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RGBA32F,
.internal_gles_format = GL_RGBA32F,
.internal_srgb_format = -1,
.format = GL_RGBA,
.type = GL_FLOAT,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -1093,7 +1019,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R32G32B32A32_SFLOAT,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = 0,
@@ -1102,7 +1027,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r32g32b32a32_float_from_float,
},
[GDK_MEMORY_G8A8_PREMULTIPLIED] = {
.name = "*GA8",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_G8A8_PREMULTIPLIED,
.straight = GDK_MEMORY_G8A8,
@@ -1116,7 +1040,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RG8,
.internal_gles_format = GL_RG8,
.internal_srgb_format = -1,
.format = GL_RG,
.type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_RED, GL_RED, GL_GREEN },
@@ -1124,7 +1047,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R8G8_UNORM,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = 0,
@@ -1133,7 +1055,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = g8a8_premultiplied_from_float,
},
[GDK_MEMORY_G8A8] = {
.name = "GA8",
.alpha = GDK_MEMORY_ALPHA_STRAIGHT,
.premultiplied = GDK_MEMORY_G8A8_PREMULTIPLIED,
.straight = GDK_MEMORY_G8A8,
@@ -1147,7 +1068,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RG8,
.internal_gles_format = GL_RG8,
.internal_srgb_format = -1,
.format = GL_RG,
.type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_RED, GL_RED, GL_GREEN },
@@ -1155,7 +1075,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R8G8_UNORM,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = 0,
@@ -1164,7 +1083,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = g8a8_from_float,
},
[GDK_MEMORY_G8] = {
.name = "G8",
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_G8,
.straight = GDK_MEMORY_G8,
@@ -1178,7 +1096,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_R8,
.internal_gles_format = GL_R8,
.internal_srgb_format = -1,
.format = GL_RED,
.type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_RED, GL_RED, GL_ONE },
@@ -1186,7 +1103,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R8_UNORM,
.vk_srgb_format = VK_FORMAT_R8_SRGB,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_R8,
@@ -1195,7 +1111,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = g8_from_float,
},
[GDK_MEMORY_G16A16_PREMULTIPLIED] = {
.name = "*GA16",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_G16A16_PREMULTIPLIED,
.straight = GDK_MEMORY_G16A16,
@@ -1212,7 +1127,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RG16,
.internal_gles_format = GL_RG16,
.internal_srgb_format = -1,
.format = GL_RG,
.type = GL_UNSIGNED_SHORT,
.swizzle = { GL_RED, GL_RED, GL_RED, GL_GREEN },
@@ -1220,7 +1134,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16G16_UNORM,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = 0,
@@ -1229,7 +1142,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = g16a16_premultiplied_from_float,
},
[GDK_MEMORY_G16A16] = {
.name = "GA16",
.alpha = GDK_MEMORY_ALPHA_STRAIGHT,
.premultiplied = GDK_MEMORY_G16A16_PREMULTIPLIED,
.straight = GDK_MEMORY_G16A16,
@@ -1246,7 +1158,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_RG16,
.internal_gles_format = GL_RG16,
.internal_srgb_format = -1,
.format = GL_RG,
.type = GL_UNSIGNED_SHORT,
.swizzle = { GL_RED, GL_RED, GL_RED, GL_GREEN },
@@ -1254,7 +1165,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16G16_UNORM,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = 0,
@@ -1263,7 +1173,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = g16a16_from_float,
},
[GDK_MEMORY_G16] = {
.name = "G16",
.alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_G16,
.straight = GDK_MEMORY_G16,
@@ -1280,7 +1189,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_R16,
.internal_gles_format = GL_R16,
.internal_srgb_format = -1,
.format = GL_RED,
.type = GL_UNSIGNED_SHORT,
.swizzle = { GL_RED, GL_RED, GL_RED, GL_ONE },
@@ -1288,7 +1196,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16_UNORM,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_R16,
@@ -1297,7 +1204,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = g16_from_float,
},
[GDK_MEMORY_A8] = {
.name = "A8",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_A8,
.straight = GDK_MEMORY_A8,
@@ -1311,7 +1217,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_R8,
.internal_gles_format = GL_R8,
.internal_srgb_format = -1,
.format = GL_RED,
.type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_RED, GL_RED, GL_RED },
@@ -1319,7 +1224,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R8_UNORM,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = 0,
@@ -1328,7 +1232,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = a8_from_float,
},
[GDK_MEMORY_A16] = {
.name = "A16",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_A16,
.straight = GDK_MEMORY_A16,
@@ -1345,7 +1248,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_R16,
.internal_gles_format = GL_R16,
.internal_srgb_format = -1,
.format = GL_RED,
.type = GL_UNSIGNED_SHORT,
.swizzle = { GL_RED, GL_RED, GL_RED, GL_RED },
@@ -1353,7 +1255,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16_UNORM,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = 0,
@@ -1362,7 +1263,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = a16_from_float,
},
[GDK_MEMORY_A16_FLOAT] = {
.name = "A16f",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_A16_FLOAT,
.straight = GDK_MEMORY_A16_FLOAT,
@@ -1378,7 +1278,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_R16F,
.internal_gles_format = GL_R16F,
.internal_srgb_format = -1,
.format = GL_RED,
.type = GL_HALF_FLOAT,
.swizzle = { GL_RED, GL_RED, GL_RED, GL_RED },
@@ -1386,7 +1285,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16_SFLOAT,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = 0,
@@ -1395,7 +1293,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = a16_float_from_float,
},
[GDK_MEMORY_A32_FLOAT] = {
.name = "A32f",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_A32_FLOAT,
.straight = GDK_MEMORY_A32_FLOAT,
@@ -1411,7 +1308,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = {
.internal_gl_format = GL_R32F,
.internal_gles_format = GL_R32F,
.internal_srgb_format = -1,
.format = GL_RED,
.type = GL_FLOAT,
.swizzle = { GL_RED, GL_RED, GL_RED, GL_RED },
@@ -1419,7 +1315,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
},
#ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R32_SFLOAT,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif
#ifdef HAVE_DMABUF
.dmabuf_fourcc = 0,
@@ -1614,7 +1509,6 @@ void
gdk_memory_format_gl_format (GdkMemoryFormat format,
gboolean gles,
GLint *out_internal_format,
GLint *out_internal_srgb_format,
GLenum *out_format,
GLenum *out_type,
GLint out_swizzle[4])
@@ -1623,7 +1517,6 @@ gdk_memory_format_gl_format (GdkMemoryFormat format,
*out_internal_format = memory_formats[format].gl.internal_gles_format;
else
*out_internal_format = memory_formats[format].gl.internal_gl_format;
*out_internal_srgb_format = memory_formats[format].gl.internal_srgb_format;
*out_format = memory_formats[format].gl.format;
*out_type = memory_formats[format].gl.type;
memcpy (out_swizzle, memory_formats[format].gl.swizzle, sizeof(GLint) * 4);
@@ -1635,8 +1528,6 @@ gdk_memory_format_gl_format (GdkMemoryFormat format,
* @gles: TRUE for GLES, FALSE for GL
* @out_actual_format: The actual RGBA format
* @out_internal_format: the GL internal format
* @out_internal_srgb_format: the GL internal format to use for automatic
* sRGB<=>linear conversion
* @out_format: the GL format
* @out_type: the GL type
* @out_swizzle: The swizzle to use
@@ -1655,7 +1546,6 @@ gdk_memory_format_gl_rgba_format (GdkMemoryFormat format,
gboolean gles,
GdkMemoryFormat *out_actual_format,
GLint *out_internal_format,
GLint *out_internal_srgb_format,
GLenum *out_format,
GLenum *out_type,
GLint out_swizzle[4])
@@ -1670,7 +1560,6 @@ gdk_memory_format_gl_rgba_format (GdkMemoryFormat format,
*out_internal_format = memory_formats[actual].gl.internal_gles_format;
else
*out_internal_format = memory_formats[actual].gl.internal_gl_format;
*out_internal_srgb_format = memory_formats[actual].gl.internal_srgb_format;
*out_format = memory_formats[actual].gl.format;
*out_type = memory_formats[actual].gl.type;
memcpy (out_swizzle, memory_formats[format].gl.rgba_swizzle, sizeof(GLint) * 4);
@@ -1724,14 +1613,6 @@ gdk_memory_format_vk_format (GdkMemoryFormat format,
return memory_formats[format].vk_format;
}
/* Gets the matching SRGB version of a VkFormat
* Returns VK_FORMAT_UNDEFINED if none exists */
VkFormat
gdk_memory_format_vk_srgb_format (GdkMemoryFormat format)
{
return memory_formats[format].vk_srgb_format;
}
/* Vulkan version of gdk_memory_format_gl_rgba_format()
* Returns VK_FORMAT_UNDEFINED on failure */
VkFormat
@@ -1780,12 +1661,6 @@ gdk_memory_format_get_dmabuf_fourcc (GdkMemoryFormat format)
#endif
}
const char *
gdk_memory_format_get_name (GdkMemoryFormat format)
{
return memory_formats[format].name;
}
static void
premultiply (float *rgba,
gsize n)
@@ -1833,10 +1708,6 @@ gdk_memory_convert (guchar *dest_data,
g_assert (dest_format < GDK_MEMORY_N_FORMATS);
g_assert (src_format < GDK_MEMORY_N_FORMATS);
/* We don't allow overlap here. If you want to do in-place color state conversions,
* use gdk_memory_convert_color_state.
*/
g_assert (dest_data + height * dest_stride < src_data || src_data + height * src_stride < dest_data);
if (src_format == dest_format)
{
@@ -1922,201 +1793,3 @@ gdk_memory_convert (guchar *dest_data,
g_free (tmp);
}
static const guchar srgb_lookup[] = {
0, 12, 21, 28, 33, 38, 42, 46, 49, 52, 55, 58, 61, 63, 66, 68,
70, 73, 75, 77, 79, 81, 82, 84, 86, 88, 89, 91, 93, 94, 96, 97,
99, 100, 102, 103, 104, 106, 107, 109, 110, 111, 112, 114, 115, 116, 117, 118,
120, 121, 122, 123, 124, 125, 126, 127, 129, 130, 131, 132, 133, 134, 135, 136,
137, 138, 139, 140, 141, 142, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151,
151, 152, 153, 154, 155, 156, 157, 157, 158, 159, 160, 161, 161, 162, 163, 164,
165, 165, 166, 167, 168, 168, 169, 170, 171, 171, 172, 173, 174, 174, 175, 176,
176, 177, 178, 179, 179, 180, 181, 181, 182, 183, 183, 184, 185, 185, 186, 187,
187, 188, 189, 189, 190, 191, 191, 192, 193, 193, 194, 194, 195, 196, 196, 197,
197, 198, 199, 199, 200, 201, 201, 202, 202, 203, 204, 204, 205, 205, 206, 206,
207, 208, 208, 209, 209, 210, 210, 211, 212, 212, 213, 213, 214, 214, 215, 215,
216, 217, 217, 218, 218, 219, 219, 220, 220, 221, 221, 222, 222, 223, 223, 224,
224, 225, 226, 226, 227, 227, 228, 228, 229, 229, 230, 230, 231, 231, 232, 232,
233, 233, 234, 234, 235, 235, 236, 236, 237, 237, 237, 238, 238, 239, 239, 240,
240, 241, 241, 242, 242, 243, 243, 244, 244, 245, 245, 245, 246, 246, 247, 247,
248, 248, 249, 249, 250, 250, 251, 251, 251, 252, 252, 253, 253, 254, 254, 255
};
static const guchar srgb_inverse_lookup[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1,
1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3,
3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7,
7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12,
13, 13, 13, 14, 14, 15, 15, 16, 16, 16, 17, 17, 18, 18, 19, 19,
20, 20, 21, 22, 22, 23, 23, 24, 24, 25, 26, 26, 27, 27, 28, 29,
29, 30, 31, 31, 32, 33, 33, 34, 35, 36, 36, 37, 38, 38, 39, 40,
41, 42, 42, 43, 44, 45, 46, 47, 47, 48, 49, 50, 51, 52, 53, 54,
55, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 70,
71, 72, 73, 74, 75, 76, 77, 78, 80, 81, 82, 83, 84, 85, 87, 88,
89, 90, 92, 93, 94, 95, 97, 98, 99, 101, 102, 103, 105, 106, 107, 109,
110, 112, 113, 114, 116, 117, 119, 120, 122, 123, 125, 126, 128, 129, 131, 132,
134, 135, 137, 139, 140, 142, 144, 145, 147, 148, 150, 152, 153, 155, 157, 159,
160, 162, 164, 166, 167, 169, 171, 173, 175, 176, 178, 180, 182, 184, 186, 188,
190, 192, 193, 195, 197, 199, 201, 203, 205, 207, 209, 211, 213, 215, 218, 220,
222, 224, 226, 228, 230, 232, 235, 237, 239, 241, 243, 245, 248, 250, 252, 255
};
static void
convert_srgb_to_srgb_linear (guchar *data,
gsize n)
{
for (gsize i = 0; i < n; i++)
{
guint8 r = data[0];
guint8 g = data[1];
guint8 b = data[2];
guchar a = data[3];
float f = a / 255.0;
if (a < 255)
{
r = r / f;
g = g / f;
b = b / f;
}
r = srgb_inverse_lookup[r];
g = srgb_inverse_lookup[g];
b = srgb_inverse_lookup[b];
data[0] = r * f;
data[1] = g * f;
data[2] = b * f;
data += 4;
}
}
static void
convert_srgb_linear_to_srgb (guchar *data,
gsize n)
{
for (gsize i = 0; i < n; i++)
{
guint8 r = data[0];
guint8 g = data[1];
guint8 b = data[2];
guchar a = data[3];
float f = a / 255.0;
if (a < 255)
{
r = r / f;
g = g / f;
b = b / f;
}
r = srgb_lookup[r];
g = srgb_lookup[g];
b = srgb_lookup[b];
data[0] = r * f;
data[1] = g * f;
data[2] = b * f;
data += 4;
}
}
static void
convert_srgb_to_srgb_linear_in_place (guchar *data,
gsize stride,
gsize width,
gsize height)
{
if (stride == width * 4)
{
convert_srgb_to_srgb_linear (data, height * width);
}
else
{
for (gsize y = 0; y < height; y++)
{
convert_srgb_to_srgb_linear (data, width);
data += stride;
}
}
}
static void
convert_srgb_linear_to_srgb_in_place (guchar *data,
gsize stride,
gsize width,
gsize height)
{
if (stride == width * 4)
{
convert_srgb_linear_to_srgb (data, height * width);
}
else
{
for (gsize y = 0; y < height; y++)
{
convert_srgb_linear_to_srgb (data, width);
data += stride;
}
}
}
typedef void (* StepFunc) (float s0, float s1, float s2,
float *d0, float *d1, float *d2);
void
gdk_memory_convert_color_state (guchar *data,
gsize stride,
GdkMemoryFormat format,
GdkColorState *src_color_state,
GdkColorState *dest_color_state,
gsize width,
gsize height)
{
if (format == GDK_MEMORY_B8G8R8A8_PREMULTIPLIED &&
src_color_state == GDK_COLOR_STATE_SRGB &&
dest_color_state == GDK_COLOR_STATE_SRGB_LINEAR)
{
convert_srgb_to_srgb_linear_in_place (data, stride, width, height);
}
else if (format == GDK_MEMORY_B8G8R8A8_PREMULTIPLIED &&
src_color_state == GDK_COLOR_STATE_SRGB_LINEAR &&
dest_color_state == GDK_COLOR_STATE_SRGB)
{
convert_srgb_linear_to_srgb_in_place (data, stride, width, height);
}
else
{
/* General case, treat it just like gdk_memory_convert */
const GdkMemoryFormatDescription *desc = &memory_formats[format];
StepFunc func;
float *tmp;
if (src_color_state == GDK_COLOR_STATE_SRGB &&
dest_color_state == GDK_COLOR_STATE_SRGB_LINEAR)
func = gtk_rgb_to_linear_srgb;
else if (src_color_state == GDK_COLOR_STATE_SRGB_LINEAR &&
dest_color_state == GDK_COLOR_STATE_SRGB)
func = gtk_linear_srgb_to_rgb;
else
return;
tmp = g_new (float, width * 4);
for (gsize y = 0; y < height; y++)
{
desc->to_float (tmp, data, width);
if (desc->alpha == GDK_MEMORY_ALPHA_PREMULTIPLIED)
unpremultiply (tmp, width);
for (gsize x = 0; x < 4 * width; x += 4)
func (tmp[x], tmp[x+1], tmp[x+2], &tmp[x], &tmp[x+1], &tmp[x+2]);
if (desc->alpha != GDK_MEMORY_ALPHA_STRAIGHT)
premultiply (tmp, width);
desc->from_float (data, tmp, width);
data += stride;
}
g_free (tmp);
}
}
+1 -11
View File
@@ -57,7 +57,6 @@ GdkMemoryFormat gdk_memory_depth_get_alpha_format (GdkMemoryDepth
void gdk_memory_format_gl_format (GdkMemoryFormat format,
gboolean gles,
GLint *out_internal_format,
GLint *out_internal_srgb_format,
GLenum *out_format,
GLenum *out_type,
GLint out_swizzle[4]);
@@ -65,20 +64,18 @@ gboolean gdk_memory_format_gl_rgba_format (GdkMemoryFormat
gboolean gles,
GdkMemoryFormat *out_actual_format,
GLint *out_internal_format,
GLint *out_internal_srgb_format,
GLenum *out_format,
GLenum *out_type,
GLint out_swizzle[4]);
#ifdef GDK_RENDERING_VULKAN
VkFormat gdk_memory_format_vk_format (GdkMemoryFormat format,
VkComponentMapping *out_swizzle);
VkFormat gdk_memory_format_vk_srgb_format (GdkMemoryFormat format);
VkFormat gdk_memory_format_vk_rgba_format (GdkMemoryFormat format,
GdkMemoryFormat *out_rgba_format,
VkComponentMapping *out_swizzle);
#endif
guint32 gdk_memory_format_get_dmabuf_fourcc (GdkMemoryFormat format);
const char * gdk_memory_format_get_name (GdkMemoryFormat format);
void gdk_memory_convert (guchar *dest_data,
gsize dest_stride,
@@ -88,13 +85,6 @@ void gdk_memory_convert (guchar
GdkMemoryFormat src_format,
gsize width,
gsize height);
void gdk_memory_convert_color_state (guchar *data,
gsize stride,
GdkMemoryFormat format,
GdkColorState *src_color_state,
GdkColorState *dest_color_state,
gsize width,
gsize height);
G_END_DECLS
+11 -5
View File
@@ -202,7 +202,8 @@ gdk_memory_texture_new_subtexture (GdkMemoryTexture *source,
}
GdkMemoryTexture *
gdk_memory_texture_from_texture (GdkTexture *texture)
gdk_memory_texture_from_texture (GdkTexture *texture,
GdkMemoryFormat format)
{
GdkTexture *result;
GBytes *bytes;
@@ -212,16 +213,21 @@ gdk_memory_texture_from_texture (GdkTexture *texture)
g_return_val_if_fail (GDK_IS_TEXTURE (texture), NULL);
if (GDK_IS_MEMORY_TEXTURE (texture))
return g_object_ref (GDK_MEMORY_TEXTURE (texture));
{
GdkMemoryTexture *memtex = GDK_MEMORY_TEXTURE (texture);
stride = texture->width * gdk_memory_format_bytes_per_pixel (texture->format);
if (gdk_texture_get_format (texture) == format)
return g_object_ref (memtex);
}
stride = texture->width * gdk_memory_format_bytes_per_pixel (format);
data = g_malloc_n (stride, texture->height);
gdk_texture_do_download (texture, texture->format, data, stride);
gdk_texture_do_download (texture, format, data, stride);
bytes = g_bytes_new_take (data, stride * texture->height);
result = gdk_memory_texture_new (texture->width,
texture->height,
texture->format,
format,
bytes,
stride);
g_bytes_unref (bytes);
+2 -1
View File
@@ -28,7 +28,8 @@ G_BEGIN_DECLS
#define GDK_MEMORY_GDK_PIXBUF_OPAQUE GDK_MEMORY_R8G8B8
#define GDK_MEMORY_GDK_PIXBUF_ALPHA GDK_MEMORY_R8G8B8A8
GdkMemoryTexture * gdk_memory_texture_from_texture (GdkTexture *texture);
GdkMemoryTexture * gdk_memory_texture_from_texture (GdkTexture *texture,
GdkMemoryFormat format);
GdkTexture * gdk_memory_texture_new_subtexture (GdkMemoryTexture *texture,
int x,
int y,
+3 -24
View File
@@ -1148,11 +1148,9 @@ gdk_surface_ensure_egl_surface (GdkSurface *self,
g_return_if_fail (priv->egl_native_window != NULL);
if (gdk_display_get_egl_config_high_depth (display) == gdk_display_get_egl_config (display))
high_depth = FALSE;
if (priv->egl_surface_high_depth != high_depth &&
priv->egl_surface != NULL)
priv->egl_surface != NULL &&
gdk_display_get_egl_config_high_depth (display) != gdk_display_get_egl_config (display))
{
gdk_gl_context_clear_current_if_surface (self);
eglDestroySurface (gdk_display_get_egl_display (display), priv->egl_surface);
@@ -1161,35 +1159,16 @@ gdk_surface_ensure_egl_surface (GdkSurface *self,
if (priv->egl_surface == NULL)
{
EGLint attribs[4];
int i;
i = 0;
if (!high_depth && display->have_egl_gl_colorspace)
{
attribs[i++] = EGL_GL_COLORSPACE_KHR;
attribs[i++] = EGL_GL_COLORSPACE_SRGB_KHR;
}
g_assert (i < G_N_ELEMENTS (attribs));
attribs[i++] = EGL_NONE;
priv->egl_surface = eglCreateWindowSurface (gdk_display_get_egl_display (display),
high_depth ? gdk_display_get_egl_config_high_depth (display)
: gdk_display_get_egl_config (display),
(EGLNativeWindowType) priv->egl_native_window,
attribs);
NULL);
priv->egl_surface_high_depth = high_depth;
self->is_srgb = !high_depth && display->have_egl_gl_colorspace;
}
#endif
}
gboolean
gdk_surface_get_gl_is_srgb (GdkSurface *self)
{
return self->is_srgb;
}
GdkGLContext *
gdk_surface_get_paint_gl_context (GdkSurface *surface,
GError **error)
-3
View File
@@ -70,7 +70,6 @@ struct _GdkSurface
guint shortcuts_inhibited : 1;
guint request_motion : 1;
guint has_pointer : 1;
guint is_srgb : 1;
guint request_motion_id;
@@ -303,8 +302,6 @@ void gdk_surface_ensure_egl_surface (GdkSurface
gboolean hdr);
gpointer /*EGLSurface*/ gdk_surface_get_egl_surface (GdkSurface *self);
gboolean gdk_surface_get_gl_is_srgb (GdkSurface *self);
void gdk_surface_set_widget (GdkSurface *self,
gpointer widget);
gpointer gdk_surface_get_widget (GdkSurface *self);
-50
View File
@@ -44,7 +44,6 @@
#include "gdkmemorytextureprivate.h"
#include "gdkpaintable.h"
#include "gdksnapshot.h"
#include "gdkcolorstateprivate.h"
#include <graphene.h>
#include "loaders/gdkpngprivate.h"
@@ -70,7 +69,6 @@ enum {
PROP_0,
PROP_WIDTH,
PROP_HEIGHT,
PROP_COLOR_STATE,
N_PROPS
};
@@ -284,15 +282,6 @@ gdk_texture_set_property (GObject *gobject,
self->height = g_value_get_int (value);
break;
case PROP_COLOR_STATE:
if (self->color_state)
gdk_color_state_unref (self->color_state);
if (g_value_get_boxed (value))
self->color_state = gdk_color_state_ref (g_value_get_boxed (value));
else
self->color_state = GDK_COLOR_STATE_SRGB;
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
break;
@@ -317,10 +306,6 @@ gdk_texture_get_property (GObject *gobject,
g_value_set_int (value, self->height);
break;
case PROP_COLOR_STATE:
g_value_set_boxed (value, self->color_state);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
break;
@@ -359,8 +344,6 @@ gdk_texture_dispose (GObject *object)
gdk_texture_clear_render_data (self);
g_clear_pointer (&self->color_state, gdk_color_state_unref);
G_OBJECT_CLASS (gdk_texture_parent_class)->dispose (object);
}
@@ -405,28 +388,12 @@ gdk_texture_class_init (GdkTextureClass *klass)
G_PARAM_STATIC_STRINGS |
G_PARAM_EXPLICIT_NOTIFY);
/**
* GdkTexture:color-state: (attributes org.gtk.Property.get=gdk_texture_get_color_state)
*
* The color state of the texture.
*
* Since: 4.16
*/
properties[PROP_COLOR_STATE] =
g_param_spec_boxed ("color-state", NULL, NULL,
GDK_TYPE_COLOR_STATE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS |
G_PARAM_EXPLICIT_NOTIFY);
g_object_class_install_properties (gobject_class, N_PROPS, properties);
}
static void
gdk_texture_init (GdkTexture *self)
{
self->color_state = GDK_COLOR_STATE_SRGB;
}
/**
@@ -760,23 +727,6 @@ gdk_texture_get_height (GdkTexture *texture)
return texture->height;
}
/**
* gdk_texture_get_color_state: (attributes org.gtk.Method.get_property=color-state)
* @texture: a `GdkTexture`
*
* Returns the color state associsated with @texture.
*
* Returns: (transfer none): the color state of the `GdkTexture`
*
* Since: 4.16
*/
GdkColorState *
gdk_texture_get_color_state (GdkTexture *texture)
{
g_return_val_if_fail (GDK_IS_TEXTURE (texture), NULL);
return texture->color_state;
}
void
gdk_texture_do_download (GdkTexture *texture,
GdkMemoryFormat format,
-3
View File
@@ -83,9 +83,6 @@ int gdk_texture_get_height (GdkTexture
GDK_AVAILABLE_IN_4_10
GdkMemoryFormat gdk_texture_get_format (GdkTexture *self) G_GNUC_PURE;
GDK_AVAILABLE_IN_4_16
GdkColorState * gdk_texture_get_color_state (GdkTexture *self);
GDK_AVAILABLE_IN_ALL
void gdk_texture_download (GdkTexture *texture,
guchar *data,
-2
View File
@@ -26,8 +26,6 @@ struct _GdkTexture
int width;
int height;
GdkColorState *color_state;
gpointer render_key;
gpointer render_data;
GDestroyNotify render_notify;
-1
View File
@@ -74,7 +74,6 @@ typedef cairo_rectangle_int_t GdkRectangle;
/* Forward declarations of commonly used types */
typedef struct _GdkRGBA GdkRGBA;
typedef struct _GdkColorState GdkColorState;
typedef struct _GdkContentFormats GdkContentFormats;
typedef struct _GdkContentProvider GdkContentProvider;
typedef struct _GdkCursor GdkCursor;
+3 -20
View File
@@ -30,7 +30,6 @@
#include "gdkdmabuftextureprivate.h"
#include "gdkdisplayprivate.h"
#include "gdkprofilerprivate.h"
#include "gdkmemorytexture.h"
#include <glib/gi18n-lib.h>
#include <math.h>
@@ -648,18 +647,15 @@ gdk_vulkan_context_begin_frame (GdkDrawContext *draw_context,
{
if (priv->formats[depth].gdk_format != priv->formats[priv->current_format].gdk_format)
{
GdkMemoryDepth old_format = priv->current_format;
GError *error = NULL;
priv->current_format = depth;
if (!gdk_vulkan_context_check_swapchain (context, &error))
{
g_warning ("%s", error->message);
g_error_free (error);
priv->current_format = old_format;
return;
}
}
priv->current_format = depth;
}
for (i = 0; i < priv->n_images; i++)
{
@@ -884,9 +880,7 @@ gdk_vulkan_context_real_init (GInitable *initable,
switch ((int) formats[i].format)
{
case VK_FORMAT_B8G8R8A8_UNORM:
case VK_FORMAT_B8G8R8A8_SRGB:
if (priv->formats[GDK_MEMORY_U8].vk_format.format == VK_FORMAT_UNDEFINED ||
priv->formats[GDK_MEMORY_U8].vk_format.format == VK_FORMAT_B8G8R8A8_UNORM)
if (priv->formats[GDK_MEMORY_U8].vk_format.format == VK_FORMAT_UNDEFINED)
{
priv->formats[GDK_MEMORY_U8].vk_format = formats[i];
priv->formats[GDK_MEMORY_U8].gdk_format = GDK_MEMORY_B8G8R8A8_PREMULTIPLIED;
@@ -895,9 +889,7 @@ gdk_vulkan_context_real_init (GInitable *initable,
break;
case VK_FORMAT_R8G8B8A8_UNORM:
case VK_FORMAT_R8G8B8A8_SRGB:
if (priv->formats[GDK_MEMORY_U8].vk_format.format == VK_FORMAT_UNDEFINED ||
priv->formats[GDK_MEMORY_U8].vk_format.format == VK_FORMAT_R8G8B8A8_UNORM)
if (priv->formats[GDK_MEMORY_U8].vk_format.format == VK_FORMAT_UNDEFINED)
{
priv->formats[GDK_MEMORY_U8].vk_format = formats[i];
priv->formats[GDK_MEMORY_U8].gdk_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED;
@@ -1302,15 +1294,6 @@ gdk_vulkan_context_get_image_format (GdkVulkanContext *context)
return priv->formats[priv->current_format].vk_format.format;
}
GdkMemoryFormat
gdk_vulkan_context_get_memory_format (GdkVulkanContext *context)
{
GdkVulkanContextPrivate *priv = gdk_vulkan_context_get_instance_private (context);
g_return_val_if_fail (GDK_IS_VULKAN_CONTEXT (context), GDK_MEMORY_DEFAULT);
return priv->formats[priv->current_format].gdk_format;
}
/**
* gdk_vulkan_context_get_n_images:
* @context: a `GdkVulkanContext`
-1
View File
@@ -94,7 +94,6 @@ VkDevice gdk_vulkan_context_get_device (GdkVulk
VkQueue gdk_vulkan_context_get_queue (GdkVulkanContext *context);
uint32_t gdk_vulkan_context_get_queue_family_index (GdkVulkanContext *context);
VkFormat gdk_vulkan_context_get_image_format (GdkVulkanContext *context);
GdkMemoryFormat gdk_vulkan_context_get_memory_format (GdkVulkanContext *context);
uint32_t gdk_vulkan_context_get_n_images (GdkVulkanContext *context);
VkImage gdk_vulkan_context_get_image (GdkVulkanContext *context,
guint id);
-2
View File
@@ -6,7 +6,6 @@ gdk_public_sources = files([
'gdkcairo.c',
'gdkcairocontext.c',
'gdkclipboard.c',
'gdkcolorstate.c',
'gdkcontentdeserializer.c',
'gdkcontentformats.c',
'gdkcontentprovider.c',
@@ -76,7 +75,6 @@ gdk_public_headers = files([
'gdkcairo.h',
'gdkcairocontext.h',
'gdkclipboard.h',
'gdkcolorstate.h',
'gdkcontentdeserializer.h',
'gdkcontentformats.h',
'gdkcontentprovider.h',
-35
View File
@@ -24,7 +24,6 @@
#include "gdkprofilerprivate.h"
#include <glib/gi18n-lib.h>
#include "gdksurfaceprivate.h"
#include <cairo-xlib.h>
@@ -54,9 +53,6 @@ gdk_x11_surface_get_glx_drawable (GdkSurface *surface)
GdkX11Surface *self = GDK_X11_SURFACE (surface);
GdkDisplay *display = gdk_surface_get_display (GDK_SURFACE (self));
GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
Display *dpy = gdk_x11_display_get_xdisplay (display);
XVisualInfo *visinfo;
int value;
if (self->glx_drawable)
return self->glx_drawable;
@@ -66,11 +62,6 @@ gdk_x11_surface_get_glx_drawable (GdkSurface *surface)
gdk_x11_surface_get_xid (surface),
NULL);
visinfo = glXGetVisualFromFBConfig (dpy, display_x11->glx_config);
glXGetConfig (dpy, visinfo, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB, &value);
surface->is_srgb = value != 0;
XFree (visinfo);
return self->glx_drawable;
}
@@ -767,17 +758,6 @@ visual_is_rgba (XVisualInfo *visinfo)
visinfo->visual->blue_mask == 0x0000ff;
}
static gboolean
visual_is_srgb (Display *display,
XVisualInfo *visinfo)
{
int value;
glXGetConfig (display, visinfo, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB, &value);
return value != 0;
}
#define MAX_GLX_ATTRS 30
static gboolean
@@ -797,7 +777,6 @@ gdk_x11_display_create_glx_config (GdkX11Display *self,
WITH_STENCIL_AND_DEPTH_BUFFER,
NO_ALPHA,
NO_ALPHA_VISUAL,
NO_SRGB,
PERFECT
} best_features;
int i = 0;
@@ -886,20 +865,6 @@ gdk_x11_display_create_glx_config (GdkX11Display *self,
continue;
}
if (!visual_is_srgb (dpy, visinfo))
{
if (best_features < NO_SRGB)
{
GDK_DISPLAY_DEBUG (display, OPENGL, "Best GLX config is %u for visual 0x%lX with no SRGB", i, visinfo->visualid);
best_features = NO_SRGB;
*out_visual = visinfo->visual;
*out_depth = visinfo->depth;
self->glx_config = configs[i];
}
XFree (visinfo);
continue;
}
GDK_DISPLAY_DEBUG (display, OPENGL, "GLX config %u for visual 0x%lX is the perfect choice", i, visinfo->visualid);
best_features = PERFECT;
*out_visual = visinfo->visual;
+1 -7
View File
@@ -1483,7 +1483,6 @@ memory_format_gl_format (GskGLCommandQueue *self,
gboolean ensure_mipmap,
gboolean *out_can_mipmap,
GLint *gl_internalformat,
GLint *gl_internalsrgbformat,
GLenum *gl_format,
GLenum *gl_type,
GLint gl_swizzle[4])
@@ -1508,7 +1507,6 @@ memory_format_gl_format (GskGLCommandQueue *self,
gdk_memory_format_gl_format (data_format,
gdk_gl_context_get_use_es (self->context),
gl_internalformat,
gl_internalsrgbformat,
gl_format,
gl_type,
gl_swizzle);
@@ -1521,7 +1519,6 @@ memory_format_gl_format (GskGLCommandQueue *self,
gdk_gl_context_get_use_es (self->context),
&alt_format,
gl_internalformat,
gl_internalsrgbformat,
gl_format,
gl_type,
gl_swizzle))
@@ -1537,7 +1534,6 @@ memory_format_gl_format (GskGLCommandQueue *self,
gdk_memory_format_gl_format (alt_format,
gdk_gl_context_get_use_es (self->context),
gl_internalformat,
gl_internalsrgbformat,
gl_format,
gl_type,
gl_swizzle);
@@ -1556,7 +1552,6 @@ memory_format_gl_format (GskGLCommandQueue *self,
gdk_memory_format_gl_format (fallbacks[i],
gdk_gl_context_get_use_es (self->context),
gl_internalformat,
gl_internalsrgbformat,
gl_format,
gl_type,
gl_swizzle);
@@ -1675,7 +1670,7 @@ gsk_gl_command_queue_upload_texture_chunks (GskGLCommandQueue *self,
G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
int width, height;
GdkMemoryFormat data_format;
GLint gl_internalformat, gl_internalsrgbformat;
GLint gl_internalformat;
GLenum gl_format;
GLenum gl_type;
GLint gl_swizzle[4];
@@ -1718,7 +1713,6 @@ gsk_gl_command_queue_upload_texture_chunks (GskGLCommandQueue *self,
ensure_mipmap,
out_can_mipmap,
&gl_internalformat,
&gl_internalsrgbformat,
&gl_format,
&gl_type,
gl_swizzle);
+3 -2
View File
@@ -972,7 +972,7 @@ gsk_gl_driver_load_texture (GskGLDriver *self,
if (texture_id == 0)
{
downloaded_texture = gdk_memory_texture_from_texture (texture);
downloaded_texture = gdk_memory_texture_from_texture (texture, gdk_texture_get_format (texture));
/* The download_texture() call may have switched the GL context. Make sure
* the right context is at work again.
@@ -1471,7 +1471,8 @@ gsk_gl_driver_add_texture_slices (GskGLDriver *self,
}
slices = g_new0 (GskGLTextureSlice, n_slices);
memtex = gdk_memory_texture_from_texture (texture);
memtex = gdk_memory_texture_from_texture (texture,
gdk_texture_get_format (texture));
if (ensure_mipmap)
{
-23
View File
@@ -30,13 +30,6 @@
#include "gskdebugprivate.h"
#ifdef HAVE_PANGOFT
#include <pango/pangofc-font.h>
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_PARAMETER_TAGS_H
#endif
#define MAX_GLYPH_SIZE 128
G_DEFINE_TYPE (GskGLGlyphLibrary, gsk_gl_glyph_library, GSK_TYPE_GL_TEXTURE_LIBRARY)
@@ -225,16 +218,6 @@ render_glyph (cairo_surface_t *surface,
cairo_t *cr;
PangoGlyphString glyph_string;
PangoGlyphInfo glyph_info;
#ifdef HAVE_PANGOFT
FT_Face face;
FT_Bool darken = 1;
FT_Parameter property = { FT_PARAM_TAG_STEM_DARKENING, &darken };
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
face = pango_fc_font_lock_face (PANGO_FC_FONT (key->font));
G_GNUC_END_IGNORE_DEPRECATIONS
FT_Face_Properties (face, 1, &property);
#endif
g_assert (surface != NULL);
@@ -253,12 +236,6 @@ G_GNUC_END_IGNORE_DEPRECATIONS
cairo_destroy (cr);
cairo_surface_flush (surface);
#ifdef HAVE_PANGOFT
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
pango_fc_font_unlock_face (PANGO_FC_FONT (key->font));
G_GNUC_END_IGNORE_DEPRECATIONS
#endif
}
static void
-5
View File
@@ -102,8 +102,3 @@ GSK_GL_DEFINE_PROGRAM_NO_CLIP (external,
GSK_GL_DEFINE_PROGRAM_NO_CLIP (premultiply,
GSK_GL_SHADER_SINGLE (GSK_GL_SHADER_RESOURCE ("premultiply.glsl")),
GSK_GL_NO_UNIFORMS)
GSK_GL_DEFINE_PROGRAM (colorconvert,
GSK_GL_SHADER_SINGLE (GSK_GL_SHADER_RESOURCE ("colorconvert.glsl")),
GSK_GL_ADD_UNIFORM (1, TO_LINEAR, u_to_linear))
+2 -15
View File
@@ -34,7 +34,6 @@
#include <gdk/gdkglcontextprivate.h>
#include <gdk/gdksurfaceprivate.h>
#include <gdk/gdksubsurfaceprivate.h>
#include <gdk/gdkcolorstateprivate.h>
#include <glib/gi18n-lib.h>
#include <gsk/gskdebugprivate.h>
#include <gsk/gskrendererprivate.h>
@@ -363,7 +362,6 @@ gsk_gl_renderer_render (GskRenderer *renderer,
GdkSurface *surface;
gboolean clear_framebuffer;
float scale;
GdkColorState *target_color_state;
g_assert (GSK_IS_GL_RENDERER (renderer));
g_assert (root != NULL);
@@ -386,17 +384,6 @@ gsk_gl_renderer_render (GskRenderer *renderer,
gsk_render_node_get_preferred_depth (root),
update_area);
if (gdk_surface_get_gl_is_srgb (surface))
{
g_debug ("Relying on GL to do srgb-linear->srgb conversion");
target_color_state = GDK_COLOR_STATE_SRGB_LINEAR;
}
else
{
g_debug ("Using an offscreen for srgb-linear->srgb conversion");
target_color_state = GDK_COLOR_STATE_SRGB;
}
gdk_gl_context_make_current (self->context);
/* Must be called *AFTER* gdk_draw_context_begin_frame() */
@@ -405,7 +392,7 @@ gsk_gl_renderer_render (GskRenderer *renderer,
gsk_gl_driver_begin_frame (self->driver, self->command_queue);
job = gsk_gl_render_job_new (self->driver, &viewport, scale, render_region, 0, clear_framebuffer);
gsk_gl_render_job_render (job, root, target_color_state);
gsk_gl_render_job_render (job, root);
gsk_gl_driver_end_frame (self->driver);
gsk_gl_render_job_free (job);
@@ -489,7 +476,7 @@ gsk_gl_renderer_render_texture (GskRenderer *renderer,
{
gsk_gl_driver_begin_frame (self->driver, self->command_queue);
job = gsk_gl_render_job_new (self->driver, viewport, 1, NULL, render_target->framebuffer_id, TRUE);
gsk_gl_render_job_render_flipped (job, root, GDK_COLOR_STATE_SRGB);
gsk_gl_render_job_render_flipped (job, root);
texture_id = gsk_gl_driver_release_render_target (self->driver, render_target, FALSE);
texture = gsk_gl_driver_create_gdk_texture (self->driver, texture_id, gdk_format);
gsk_gl_driver_end_frame (self->driver);
+10 -85
View File
@@ -33,7 +33,6 @@
#include <gdk/gdkdmabuftexture.h>
#include <gdk/gdksurfaceprivate.h>
#include <gdk/gdksubsurfaceprivate.h>
#include <gdk/gdkcolorstateprivate.h>
#include <gsk/gsktransformprivate.h>
#include <gsk/gskroundedrectprivate.h>
#include <gsk/gskrectprivate.h>
@@ -973,28 +972,11 @@ gsk_gl_render_job_update_clip (GskGLRenderJob *job,
return TRUE;
}
static inline float
srgb_inverse_transfer_function (float v)
{
if (v >= 0.04045)
return powf (((v + 0.055)/(1 + 0.055)), 2.4);
else
return v / 12.92;
}
static inline void
rgba_to_half (const GdkRGBA *rgba,
guint16 h[4])
{
float v[4];
v[0] = srgb_inverse_transfer_function (rgba->red);
v[1] = srgb_inverse_transfer_function (rgba->green);
v[2] = srgb_inverse_transfer_function (rgba->blue);
v[3] = rgba->alpha;
float_to_half4 (v, h);
float_to_half4 ((const float *)rgba, h);
}
/* fill_vertex_data */
@@ -3695,11 +3677,8 @@ gsk_gl_render_job_visit_texture (GskGLRenderJob *job,
g_assert (offscreen.texture_id);
g_assert (offscreen.was_offscreen == FALSE);
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, colorconvert)))
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit)))
{
gsk_gl_program_set_uniform1i (job->current_program,
UNIFORM_TO_LINEAR, 0,
1);
gsk_gl_program_set_uniform_texture_with_sync (job->current_program,
UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D,
@@ -3725,7 +3704,7 @@ gsk_gl_render_job_visit_texture (GskGLRenderJob *job,
g_assert (slices != NULL);
g_assert (n_slices > 0);
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, colorconvert)))
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit)))
{
for (unsigned int i = 0; i < n_slices; i++)
{
@@ -3739,9 +3718,6 @@ gsk_gl_render_job_visit_texture (GskGLRenderJob *job,
if (i > 0)
gsk_gl_render_job_split_draw (job);
gsk_gl_program_set_uniform1i (job->current_program,
UNIFORM_TO_LINEAR, 0,
1);
gsk_gl_program_set_uniform_texture_with_filter (job->current_program,
UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D,
@@ -3856,11 +3832,8 @@ gsk_gl_render_job_visit_texture_scale_node (GskGLRenderJob *job,
u1 = (clip_rect.origin.x + clip_rect.size.width - bounds->origin.x) / bounds->size.width;
v1 = (clip_rect.origin.y + clip_rect.size.height - bounds->origin.y) / bounds->size.height;
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, colorconvert)))
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit)))
{
gsk_gl_program_set_uniform1i (job->current_program,
UNIFORM_TO_LINEAR, 0,
1);
gsk_gl_program_set_uniform_texture_with_sync (job->current_program,
UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D,
@@ -3886,7 +3859,7 @@ gsk_gl_render_job_visit_texture_scale_node (GskGLRenderJob *job,
gsk_gl_driver_slice_texture (job->driver, texture, need_mipmap, &slices, &n_slices);
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, colorconvert)))
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit)))
{
for (guint i = 0; i < n_slices; i++)
{
@@ -3904,9 +3877,6 @@ gsk_gl_render_job_visit_texture_scale_node (GskGLRenderJob *job,
if (i > 0)
gsk_gl_render_job_split_draw (job);
gsk_gl_program_set_uniform1i (job->current_program,
UNIFORM_TO_LINEAR, 0,
1);
gsk_gl_program_set_uniform_texture_with_filter (job->current_program,
UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D,
@@ -3940,11 +3910,8 @@ gsk_gl_render_job_visit_texture_scale_node (GskGLRenderJob *job,
gsk_gl_driver_cache_texture (job->driver, &key, texture_id);
render_texture:
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, colorconvert)))
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit)))
{
gsk_gl_program_set_uniform1i (job->current_program,
UNIFORM_TO_LINEAR, 0,
1);
gsk_gl_program_set_uniform_texture (job->current_program,
UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D,
@@ -4497,8 +4464,7 @@ gsk_gl_render_job_visit_node_with_offscreen (GskGLRenderJob *job,
void
gsk_gl_render_job_render_flipped (GskGLRenderJob *job,
GskRenderNode *root,
GdkColorState *target_color_state)
GskRenderNode *root)
{
graphene_matrix_t proj;
guint framebuffer_id;
@@ -4540,17 +4506,8 @@ gsk_gl_render_job_render_flipped (GskGLRenderJob *job,
gsk_gl_render_job_set_alpha (job, 1.0f);
gsk_gl_command_queue_bind_framebuffer (job->command_queue, job->framebuffer);
gsk_gl_command_queue_clear (job->command_queue, 0, &job->viewport);
GskGLProgram *program;
if (target_color_state == GDK_COLOR_STATE_SRGB)
program = CHOOSE_PROGRAM (job, colorconvert);
else
program = CHOOSE_PROGRAM (job, blit);
if (gsk_gl_render_job_begin_draw (job, program))
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit)))
{
if (target_color_state == GDK_COLOR_STATE_SRGB)
gsk_gl_program_set_uniform1i (job->current_program, UNIFORM_TO_LINEAR, 0, 0);
gsk_gl_program_set_uniform_texture (job->current_program,
UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D,
@@ -4571,8 +4528,7 @@ gsk_gl_render_job_render_flipped (GskGLRenderJob *job,
void
gsk_gl_render_job_render (GskGLRenderJob *job,
GskRenderNode *root,
GdkColorState *target_color_state)
GskRenderNode *root)
{
G_GNUC_UNUSED gint64 start_time;
float scale;
@@ -4595,38 +4551,7 @@ gsk_gl_render_job_render (GskGLRenderJob *job,
gsk_gl_command_queue_bind_framebuffer (job->command_queue, job->framebuffer);
if (job->clear_framebuffer)
gsk_gl_command_queue_clear (job->command_queue, 0, &job->viewport);
if (target_color_state == GDK_COLOR_STATE_SRGB_LINEAR)
{
gsk_gl_render_job_visit_node (job, root);
}
else
{
GskGLRenderOffscreen offscreen = {0};
offscreen.bounds = &root->bounds;
offscreen.force_offscreen = TRUE;
offscreen.reset_clip = TRUE;
offscreen.do_not_cache = TRUE;
gsk_gl_render_job_visit_node_with_offscreen (job, root, &offscreen);
g_assert (offscreen.texture_id);
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, colorconvert)))
{
gsk_gl_program_set_uniform1i (job->current_program, UNIFORM_TO_LINEAR, 0, 0);
gsk_gl_program_set_uniform_texture (job->current_program,
UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D,
GL_TEXTURE0,
offscreen.texture_id);
job->source_is_glyph_atlas = FALSE;
gsk_gl_render_job_draw_offscreen_rect (job, &root->bounds);
gsk_gl_render_job_end_draw (job);
}
}
gsk_gl_render_job_visit_node (job, root);
gdk_gl_context_pop_debug_group (job->command_queue->context);
gdk_profiler_end_mark (start_time, "Build GL command queue", "");
+2 -4
View File
@@ -30,9 +30,7 @@ GskGLRenderJob *gsk_gl_render_job_new (GskGLDriver *dri
gboolean clear_framebuffer);
void gsk_gl_render_job_free (GskGLRenderJob *job);
void gsk_gl_render_job_render (GskGLRenderJob *job,
GskRenderNode *root,
GdkColorState *color_state);
GskRenderNode *root);
void gsk_gl_render_job_render_flipped (GskGLRenderJob *job,
GskRenderNode *root,
GdkColorState *color_state);
GskRenderNode *root);
-63
View File
@@ -1,63 +0,0 @@
// VERTEX_SHADER:
// colorconvert.glsl
void main() {
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
vUv = vec2(aUv.x, aUv.y);
}
// FRAGMENT_SHADER:
// colorconvert.glsl
uniform int u_to_linear;
float
srgb_transfer_function (float v)
{
if (v >= 0.04045)
return pow (((v + 0.055)/(1.0 + 0.055)), 2.4);
else
return v / 12.92;
}
float
srgb_inverse_transfer_function (float v)
{
if (v > 0.0031308)
return 1.055 * pow (v, 1.0/2.4) - 0.055;
else
return 12.92 * v;
}
vec4
srgb_to_linear_srgb (vec4 color)
{
return vec4 (srgb_transfer_function (color.r),
srgb_transfer_function (color.g),
srgb_transfer_function (color.b),
color.a);
}
vec4
linear_srgb_to_srgb (vec4 color)
{
return vec4 (srgb_inverse_transfer_function (color.r),
srgb_inverse_transfer_function (color.g),
srgb_inverse_transfer_function (color.b),
color.a);
}
void main() {
vec4 color = GskTexture(u_source, vUv);
if (color.a != 0.0)
color.rgb /= color.a;
if (u_to_linear != 0)
color = srgb_to_linear_srgb (color);
else
color = linear_srgb_to_srgb (color);
gskSetOutputColor(gsk_scaled_premultiply(color, u_alpha));
}
-10
View File
@@ -10,7 +10,6 @@
#include "gdk/gdkdisplayprivate.h"
#include "gdk/gdkglcontextprivate.h"
#include "gdk/gdkprofilerprivate.h"
#include "gdk/gdkcolorstateprivate.h"
#include <glib/gi18n-lib.h>
@@ -77,7 +76,6 @@ gsk_gl_device_create_offscreen_image (GskGpuDevice *device,
return gsk_gl_image_new (self,
gdk_memory_depth_get_format (depth),
GDK_COLOR_STATE_SRGB_LINEAR,
GSK_GPU_IMAGE_RENDERABLE | GSK_GPU_IMAGE_FILTERABLE,
width,
height);
@@ -87,7 +85,6 @@ static GskGpuImage *
gsk_gl_device_create_upload_image (GskGpuDevice *device,
gboolean with_mipmap,
GdkMemoryFormat format,
GdkColorState *color_state,
gsize width,
gsize height)
{
@@ -95,7 +92,6 @@ gsk_gl_device_create_upload_image (GskGpuDevice *device,
return gsk_gl_image_new (self,
format,
color_state,
0,
width,
height);
@@ -111,7 +107,6 @@ gsk_gl_device_create_download_image (GskGpuDevice *device,
return gsk_gl_image_new (self,
gdk_memory_depth_get_format (depth),
GDK_COLOR_STATE_SRGB_LINEAR,
GSK_GPU_IMAGE_RENDERABLE,
width,
height);
@@ -126,7 +121,6 @@ gsk_gl_device_create_atlas_image (GskGpuDevice *device,
return gsk_gl_image_new (self,
GDK_MEMORY_DEFAULT,
GDK_COLOR_STATE_SRGB_LINEAR,
GSK_GPU_IMAGE_RENDERABLE,
width,
height);
@@ -641,7 +635,6 @@ gsk_gl_device_find_gl_format (GskGLDevice *self,
GdkMemoryFormat *out_format,
GskGpuImageFlags *out_flags,
GLint *out_gl_internal_format,
GLint *out_gl_internal_srgb_format,
GLenum *out_gl_format,
GLenum *out_gl_type,
GLint out_swizzle[4])
@@ -661,7 +654,6 @@ gsk_gl_device_find_gl_format (GskGLDevice *self,
gdk_memory_format_gl_format (format,
gdk_gl_context_get_use_es (context),
out_gl_internal_format,
out_gl_internal_srgb_format,
out_gl_format,
out_gl_type,
out_swizzle);
@@ -673,7 +665,6 @@ gsk_gl_device_find_gl_format (GskGLDevice *self,
gdk_gl_context_get_use_es (context),
&alt_format,
out_gl_internal_format,
out_gl_internal_srgb_format,
out_gl_format,
out_gl_type,
out_swizzle) &&
@@ -697,7 +688,6 @@ gsk_gl_device_find_gl_format (GskGLDevice *self,
gdk_memory_format_gl_format (fallbacks[i],
gdk_gl_context_get_use_es (context),
out_gl_internal_format,
out_gl_internal_srgb_format,
out_gl_format,
out_gl_type,
out_swizzle);
-1
View File
@@ -26,7 +26,6 @@ void gsk_gl_device_find_gl_format (GskGLDe
GdkMemoryFormat *out_format,
GskGpuImageFlags *out_flags,
GLint *out_gl_internal_format,
GLint *out_gl_internal_srgb_format,
GLenum *out_gl_format,
GLenum *out_gl_type,
GLint out_swizzle[4]);
+7 -43
View File
@@ -1,10 +1,9 @@
#include "config.h"
#include "config.h"
#include "gskglimageprivate.h"
#include "gdk/gdkdisplayprivate.h"
#include "gdk/gdkglcontextprivate.h"
#include "gdk/gdkcolorstateprivate.h"
struct _GskGLImage
{
@@ -74,13 +73,11 @@ gsk_gl_image_new_backbuffer (GskGLDevice *device,
GdkGLContext *context,
GdkMemoryFormat format,
gsize width,
gsize height,
gboolean is_srgb)
gsize height)
{
GskGLImage *self;
GskGpuImageFlags flags;
GLint swizzle[4];
GLint gl_internal_format, gl_internal_srgb_format;
self = g_object_new (GSK_TYPE_GL_IMAGE, NULL);
@@ -90,25 +87,11 @@ gsk_gl_image_new_backbuffer (GskGLDevice *device,
0,
&format,
&flags,
&gl_internal_format,
&gl_internal_srgb_format,
&self->gl_internal_format,
&self->gl_format,
&self->gl_type,
swizzle);
if (is_srgb)
{
if (gl_internal_srgb_format != -1)
self->gl_internal_format = gl_internal_srgb_format;
else /* FIXME: not really correct */
self->gl_internal_format = gl_internal_format;
flags |= GSK_GPU_IMAGE_SRGB;
}
else
{
self->gl_internal_format = gl_internal_format;
}
gsk_gpu_image_setup (GSK_GPU_IMAGE (self), flags, format, width, height);
/* texture_id == 0 means backbuffer */
@@ -126,7 +109,6 @@ gsk_gl_image_new_backbuffer (GskGLDevice *device,
GskGpuImage *
gsk_gl_image_new (GskGLDevice *device,
GdkMemoryFormat format,
GdkColorState *color_state,
GskGpuImageFlags required_flags,
gsize width,
gsize height)
@@ -134,7 +116,6 @@ gsk_gl_image_new (GskGLDevice *device,
GskGLImage *self;
GLint swizzle[4];
GskGpuImageFlags flags;
GLint gl_internal_format, gl_internal_srgb_format;
gsize max_size;
max_size = gsk_gpu_device_get_max_image_size (GSK_GPU_DEVICE (device));
@@ -148,23 +129,11 @@ gsk_gl_image_new (GskGLDevice *device,
required_flags,
&format,
&flags,
&gl_internal_format,
&gl_internal_srgb_format,
&self->gl_internal_format,
&self->gl_format,
&self->gl_type,
swizzle);
if (gl_internal_srgb_format != -1 &&
gdk_color_state_equal (color_state, GDK_COLOR_STATE_SRGB))
{
self->gl_internal_format = gl_internal_srgb_format;
flags |= GSK_GPU_IMAGE_SRGB;
}
else
{
self->gl_internal_format = gl_internal_format;
}
gsk_gpu_image_setup (GSK_GPU_IMAGE (self),
flags,
format,
@@ -208,7 +177,6 @@ gsk_gl_image_new_for_texture (GskGLDevice *device,
GdkMemoryFormat format, real_format;
GskGpuImageFlags flags;
GskGLImage *self;
GLint gl_internal_format, gl_internal_srgb_format;
GLint swizzle[4];
format = gdk_texture_get_format (owner);
@@ -220,14 +188,10 @@ gsk_gl_image_new_for_texture (GskGLDevice *device,
0,
&real_format,
&flags,
&gl_internal_format,
&gl_internal_srgb_format,
&self->gl_internal_format,
&self->gl_format,
&self->gl_type,
swizzle);
self->gl_internal_format = gl_internal_format;
if (format != real_format)
flags = GSK_GPU_IMAGE_NO_BLIT |
(gdk_memory_format_alpha (format) == GDK_MEMORY_ALPHA_STRAIGHT ? GSK_GPU_IMAGE_STRAIGHT_ALPHA : 0);
+1 -3
View File
@@ -14,11 +14,9 @@ GskGpuImage * gsk_gl_image_new_backbuffer (GskGLDe
GdkGLContext *context,
GdkMemoryFormat format,
gsize width,
gsize height,
gboolean converts_srgb);
gsize height);
GskGpuImage * gsk_gl_image_new (GskGLDevice *device,
GdkMemoryFormat format,
GdkColorState *color_state,
GskGpuImageFlags required_flags,
gsize width,
gsize height);
-1
View File
@@ -23,7 +23,6 @@ gsk_gpu_blend_mode_op_print_instance (GskGpuShaderOp *shader,
{
GskGpuBlendmodeInstance *instance = (GskGpuBlendmodeInstance *) instance_;
gsk_gpu_print_enum (string, GSK_TYPE_BLEND_MODE, shader->variation);
gsk_gpu_print_rect (string, instance->rect);
gsk_gpu_print_image_descriptor (string, shader->desc, instance->bottom_id);
gsk_gpu_print_enum (string, GSK_TYPE_BLEND_MODE, shader->variation);
+1 -1
View File
@@ -21,7 +21,7 @@ color_equal (const float *color1,
const float *color2)
{
return gdk_rgba_equal (&(GdkRGBA) { color1[0], color1[1], color1[2], color1[3] },
&(GdkRGBA) { color2[0], color2[1], color2[2], color2[3] });
&(GdkRGBA) { color1[0], color1[1], color1[2], color1[3] });
}
static void
+14 -5
View File
@@ -14,7 +14,7 @@ struct _GskGpuClearOp
GskGpuOp op;
cairo_rectangle_int_t rect;
float color[4];
GdkRGBA color;
};
static void
@@ -29,14 +29,23 @@ gsk_gpu_clear_op_print (GskGpuOp *op,
guint indent)
{
GskGpuClearOp *self = (GskGpuClearOp *) op;
float rgba[4];
gsk_gpu_print_op (string, indent, "clear");
gsk_gpu_print_int_rect (string, &self->rect);
gsk_gpu_print_rgba (string, self->color);
gsk_gpu_rgba_to_float (&self->color, rgba);
gsk_gpu_print_rgba (string, rgba);
gsk_gpu_print_newline (string);
}
#ifdef GDK_RENDERING_VULKAN
static void
gsk_gpu_init_clear_value (VkClearValue *value,
const GdkRGBA *rgba)
{
gsk_gpu_rgba_to_float (rgba, value->color.float32);
}
static GskGpuOp *
gsk_gpu_clear_op_vk_command (GskGpuOp *op,
GskGpuFrame *frame,
@@ -45,7 +54,7 @@ gsk_gpu_clear_op_vk_command (GskGpuOp *op,
GskGpuClearOp *self = (GskGpuClearOp *) op;
VkClearValue clear_value;
memcpy (clear_value.color.float32, self->color, sizeof (float) * 4);
gsk_gpu_init_clear_value (&clear_value, &self->color);
vkCmdClearAttachments (state->vk_command_buffer,
1,
@@ -83,7 +92,7 @@ gsk_gpu_clear_op_gl_command (GskGpuOp *op,
else
glScissor (self->rect.x, self->rect.y, self->rect.width, self->rect.height);
glClearColor (self->color[0], self->color[1], self->color[2], self->color[3]);
glClearColor (self->color.red, self->color.green, self->color.blue, self->color.alpha);
glClear (GL_COLOR_BUFFER_BIT);
glScissor (scissor[0], scissor[1], scissor[2], scissor[3]);
@@ -112,5 +121,5 @@ gsk_gpu_clear_op (GskGpuFrame *frame,
self = (GskGpuClearOp *) gsk_gpu_op_alloc (frame, &GSK_GPU_CLEAR_OP_CLASS);
self->rect = *rect;
gsk_gpu_rgba_to_float (color, self->color);
self->color = *color;
}
-86
View File
@@ -1,86 +0,0 @@
#include "config.h"
#include "gskgpucolorconvertopprivate.h"
#include "gskgpuframeprivate.h"
#include "gskgpuprintprivate.h"
#include "gskrectprivate.h"
#include "gdk/gdkcolorstateprivate.h"
#include "gpu/shaders/gskgpucolorconvertinstance.h"
typedef struct _GskGpuColorConvertOp GskGpuColorConvertOp;
struct _GskGpuColorConvertOp
{
GskGpuShaderOp op;
};
static guint
gsk_gpu_color_conversion (GdkColorState *from,
GdkColorState *to)
{
if (from == to)
return 0;
return GDK_DEFAULT_COLOR_STATE_ID (from) | (GDK_DEFAULT_COLOR_STATE_ID (to) << 16);
}
static void
gsk_gpu_color_convert_op_print_instance (GskGpuShaderOp *shader,
gpointer instance_,
GString *string)
{
GskGpuColorconvertInstance *instance = (GskGpuColorconvertInstance *) instance_;
gsk_gpu_print_rect (string, instance->rect);
gsk_gpu_print_image_descriptor (string, shader->desc, instance->tex_id);
gsk_gpu_print_color_conversion (string, shader->variation);
}
static const GskGpuShaderOpClass GSK_GPU_COLOR_CONVERT_OP_CLASS = {
{
GSK_GPU_OP_SIZE (GskGpuColorConvertOp),
GSK_GPU_STAGE_SHADER,
gsk_gpu_shader_op_finish,
gsk_gpu_shader_op_print,
#ifdef GDK_RENDERING_VULKAN
gsk_gpu_shader_op_vk_command,
#endif
gsk_gpu_shader_op_gl_command
},
"gskgpucolorconvert",
sizeof (GskGpuColorconvertInstance),
#ifdef GDK_RENDERING_VULKAN
&gsk_gpu_colorconvert_info,
#endif
gsk_gpu_color_convert_op_print_instance,
gsk_gpu_colorconvert_setup_attrib_locations,
gsk_gpu_colorconvert_setup_vao
};
void
gsk_gpu_color_convert_op (GskGpuFrame *frame,
GskGpuShaderClip clip,
GdkColorState *from,
GdkColorState *to,
GskGpuDescriptors *desc,
guint32 descriptor,
const graphene_rect_t *rect,
const graphene_point_t *offset,
const graphene_rect_t *tex_rect)
{
GskGpuColorconvertInstance *instance;
gsk_gpu_shader_op_alloc (frame,
&GSK_GPU_COLOR_CONVERT_OP_CLASS,
gsk_gpu_color_conversion (from, to),
clip,
desc,
&instance);
gsk_gpu_rect_to_float (rect, offset, instance->rect);
gsk_gpu_rect_to_float (tex_rect, offset, instance->tex_rect);
instance->tex_id = descriptor;
}
-21
View File
@@ -1,21 +0,0 @@
#pragma once
#include "gskgpushaderopprivate.h"
#include <graphene.h>
G_BEGIN_DECLS
void gsk_gpu_color_convert_op (GskGpuFrame *frame,
GskGpuShaderClip clip,
GdkColorState *from,
GdkColorState *to,
GskGpuDescriptors *desc,
guint32 descriptor,
const graphene_rect_t *rect,
const graphene_point_t *offset,
const graphene_rect_t *tex_rect);
G_END_DECLS
+20 -63
View File
@@ -12,7 +12,6 @@
#include "gsk/gskdebugprivate.h"
#include "gsk/gskprivate.h"
#include "gdk/gdkcolorstateprivate.h"
#define MAX_SLICES_PER_ATLAS 64
@@ -253,9 +252,6 @@ struct _GskGpuCachedTexture
GdkTexture *texture;
GskGpuImage *image;
GdkColorState *color_state;
GskGpuImage *image2;
GdkColorState *color_state2;
};
static void
@@ -267,9 +263,6 @@ gsk_gpu_cached_texture_free (GskGpuDevice *device,
gpointer key, value;
g_clear_object (&self->image);
g_clear_pointer (&self->color_state, gdk_color_state_unref);
g_clear_object (&self->image2);
g_clear_pointer (&self->color_state2, gdk_color_state_unref);
if (g_hash_table_steal_extended (priv->texture_cache, self->texture, &key, &value))
{
@@ -332,10 +325,9 @@ gsk_gpu_cached_texture_destroy_cb (gpointer data)
}
static GskGpuCachedTexture *
gsk_gpu_cached_texture_new (GskGpuDevice *device,
GdkTexture *texture,
GskGpuImage *image,
GdkColorState *color_state)
gsk_gpu_cached_texture_new (GskGpuDevice *device,
GdkTexture *texture,
GskGpuImage *image)
{
GskGpuDevicePrivate *priv = gsk_gpu_device_get_instance_private (device);
GskGpuCachedTexture *self;
@@ -348,9 +340,6 @@ gsk_gpu_cached_texture_new (GskGpuDevice *device,
self = gsk_gpu_cached_new (device, &GSK_GPU_CACHED_TEXTURE_CLASS, NULL);
self->texture = texture;
self->image = g_object_ref (image);
self->color_state = gdk_color_state_ref (color_state);
self->image2 = NULL;
self->color_state2 = NULL;
((GskGpuCached *)self)->pixels = gsk_gpu_image_get_width (image) * gsk_gpu_image_get_height (image);
self->dead_pixels_counter = &priv->dead_texture_pixels;
self->use_count = 2;
@@ -707,14 +696,13 @@ gsk_gpu_device_create_offscreen_image (GskGpuDevice *self,
}
GskGpuImage *
gsk_gpu_device_create_upload_image (GskGpuDevice *self,
gboolean with_mipmap,
GdkMemoryFormat format,
GdkColorState *color_state,
gsize width,
gsize height)
gsk_gpu_device_create_upload_image (GskGpuDevice *self,
gboolean with_mipmap,
GdkMemoryFormat format,
gsize width,
gsize height)
{
return GSK_GPU_DEVICE_GET_CLASS (self)->create_upload_image (self, with_mipmap, format, color_state, width, height);
return GSK_GPU_DEVICE_GET_CLASS (self)->create_upload_image (self, with_mipmap, format, width, height);
}
void
@@ -862,65 +850,34 @@ gsk_gpu_device_add_atlas_image (GskGpuDevice *self,
}
GskGpuImage *
gsk_gpu_device_lookup_texture_image (GskGpuDevice *self,
GdkTexture *texture,
GdkColorState *color_state,
gint64 timestamp)
gsk_gpu_device_lookup_texture_image (GskGpuDevice *self,
GdkTexture *texture,
gint64 timestamp)
{
GskGpuDevicePrivate *priv = gsk_gpu_device_get_instance_private (self);
GskGpuCachedTexture *cache;
GskGpuImage *image;
cache = gdk_texture_get_render_data (texture, self);
if (cache == NULL)
cache = g_hash_table_lookup (priv->texture_cache, texture);
if (!cache || gsk_gpu_cached_texture_is_invalid (cache))
return NULL;
if (gdk_color_state_equal (color_state, cache->color_state))
image = cache->image;
else if (cache->color_state2 && gdk_color_state_equal (color_state, cache->color_state2))
image = cache->image2;
else
if (!cache || !cache->image || gsk_gpu_cached_texture_is_invalid (cache))
return NULL;
gsk_gpu_cached_use (self, (GskGpuCached *) cache, timestamp);
return g_object_ref (image);
return g_object_ref (cache->image);
}
void
gsk_gpu_device_cache_texture_image (GskGpuDevice *self,
GdkTexture *texture,
gint64 timestamp,
GskGpuImage *image,
GdkColorState *color_state)
gsk_gpu_device_cache_texture_image (GskGpuDevice *self,
GdkTexture *texture,
gint64 timestamp,
GskGpuImage *image)
{
GskGpuCachedTexture *cache;
cache = gdk_texture_get_render_data (texture, self);
if (cache)
{
if (gdk_color_state_equal (color_state, gdk_texture_get_color_state (texture)))
{
g_clear_pointer (&cache->color_state, gdk_color_state_unref);
g_clear_object (&cache->image);
cache->color_state = gdk_color_state_ref (color_state);
cache->image = g_object_ref (image);
}
else
{
g_clear_pointer (&cache->color_state2, gdk_color_state_unref);
g_clear_object (&cache->image2);
cache->color_state2 = gdk_color_state_ref (color_state);
cache->image2 = g_object_ref (image);
}
}
else
{
cache = gsk_gpu_cached_texture_new (self, texture, image, color_state);
}
cache = gsk_gpu_cached_texture_new (self, texture, image);
gsk_gpu_cached_use (self, (GskGpuCached *) cache, timestamp);
}
@@ -993,7 +950,7 @@ gsk_gpu_device_lookup_glyph_image (GskGpuDevice *self,
}
else
{
image = gsk_gpu_device_create_upload_image (self, FALSE, GDK_MEMORY_DEFAULT, GDK_COLOR_STATE_SRGB, rect.size.width, rect.size.height),
image = gsk_gpu_device_create_upload_image (self, FALSE, GDK_MEMORY_DEFAULT, rect.size.width, rect.size.height),
rect.origin.x = 0;
rect.origin.y = 0;
padding = 0;
+1 -5
View File
@@ -35,7 +35,6 @@ struct _GskGpuDeviceClass
GskGpuImage * (* create_upload_image) (GskGpuDevice *self,
gboolean with_mipmap,
GdkMemoryFormat format,
GdkColorState *color_state,
gsize width,
gsize height);
GskGpuImage * (* create_download_image) (GskGpuDevice *self,
@@ -65,7 +64,6 @@ GskGpuImage * gsk_gpu_device_create_offscreen_image (GskGpuD
GskGpuImage * gsk_gpu_device_create_upload_image (GskGpuDevice *self,
gboolean with_mipmap,
GdkMemoryFormat format,
GdkColorState *color_state,
gsize width,
gsize height);
GskGpuImage * gsk_gpu_device_create_download_image (GskGpuDevice *self,
@@ -75,13 +73,11 @@ GskGpuImage * gsk_gpu_device_create_download_image (GskGpuD
void gsk_gpu_device_make_current (GskGpuDevice *self);
GskGpuImage * gsk_gpu_device_lookup_texture_image (GskGpuDevice *self,
GdkTexture *texture,
GdkColorState *color_state,
gint64 timestamp);
void gsk_gpu_device_cache_texture_image (GskGpuDevice *self,
GdkTexture *texture,
gint64 timestamp,
GskGpuImage *image,
GdkColorState *color_state);
GskGpuImage *image);
typedef enum
{
+2 -52
View File
@@ -12,7 +12,6 @@
#include "gskvulkanimageprivate.h"
#endif
#include "gdk/gdkdmabuftexturebuilderprivate.h"
#include "gdk/gdkdmabuftextureprivate.h"
#include "gdk/gdkglcontextprivate.h"
@@ -146,7 +145,7 @@ gsk_gpu_download_op_vk_command (GskGpuOp *op,
GskVulkanDevice *device = GSK_VULKAN_DEVICE (gsk_gpu_frame_get_device (frame));
VkDevice vk_device = gsk_vulkan_device_get_vk_device (device);
gsk_gpu_device_cache_texture_image (GSK_GPU_DEVICE (device), self->texture, gsk_gpu_frame_get_timestamp (frame), self->image, gdk_texture_get_color_state (self->texture));
gsk_gpu_device_cache_texture_image (GSK_GPU_DEVICE (device), self->texture, gsk_gpu_frame_get_timestamp (frame), self->image);
if (gsk_vulkan_device_has_feature (device, GDK_VULKAN_FEATURE_SEMAPHORE_EXPORT))
{
@@ -263,23 +262,6 @@ gsk_gl_texture_data_free (gpointer user_data)
g_free (data);
}
#ifdef HAVE_DMABUF
typedef struct
{
GdkDmabuf dmabuf;
} Texture;
static void
release_dmabuf_texture (gpointer data)
{
Texture *texture = data;
for (unsigned int i = 0; i < texture->dmabuf.n_planes; i++)
g_close (texture->dmabuf.planes[i].fd, NULL);
g_free (texture);
}
#endif
static GskGpuOp *
gsk_gpu_download_op_gl_command (GskGpuOp *op,
GskGpuFrame *frame,
@@ -289,44 +271,12 @@ gsk_gpu_download_op_gl_command (GskGpuOp *op,
GdkGLTextureBuilder *builder;
GskGLTextureData *data;
GdkGLContext *context;
guint texture_id;
context = GDK_GL_CONTEXT (gsk_gpu_frame_get_context (frame));
texture_id = gsk_gl_image_steal_texture (GSK_GL_IMAGE (self->image));
#ifdef HAVE_DMABUF
if (self->allow_dmabuf)
{
Texture *texture;
texture = g_new0 (Texture, 1);
if (gdk_gl_context_export_dmabuf (context, texture_id, &texture->dmabuf))
{
GdkDmabufTextureBuilder *db;
db = gdk_dmabuf_texture_builder_new ();
gdk_dmabuf_texture_builder_set_display (db, gdk_gl_context_get_display (context));
gdk_dmabuf_texture_builder_set_dmabuf (db, &texture->dmabuf);
gdk_dmabuf_texture_builder_set_premultiplied (db, gdk_memory_format_get_premultiplied (gsk_gpu_image_get_format (self->image)));
gdk_dmabuf_texture_builder_set_width (db, gsk_gpu_image_get_width (self->image));
gdk_dmabuf_texture_builder_set_height (db, gsk_gpu_image_get_height (self->image));
self->texture = gdk_dmabuf_texture_builder_build (db, release_dmabuf_texture, texture, NULL);
g_object_unref (db);
if (self->texture)
return op->next;
}
g_free (texture);
}
#endif
data = g_new (GskGLTextureData, 1);
data->context = g_object_ref (context);
data->texture_id = texture_id;
data->texture_id = gsk_gl_image_steal_texture (GSK_GL_IMAGE (self->image));
if (gdk_gl_context_has_feature (context, GDK_GL_FEATURE_SYNC))
data->sync = glFenceSync (GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
+8 -24
View File
@@ -17,7 +17,6 @@
#include "gdk/gdkdmabufdownloaderprivate.h"
#include "gdk/gdktexturedownloaderprivate.h"
#include "gdk/gdkcolorstateprivate.h"
#define DEFAULT_VERTEX_BUFFER_SIZE 128 * 1024
@@ -403,26 +402,17 @@ gsk_gpu_frame_get_last_op (GskGpuFrame *self)
}
GskGpuImage *
gsk_gpu_frame_upload_texture (GskGpuFrame *self,
gboolean with_mipmap,
GdkTexture *texture,
GdkColorState **out_color_state)
gsk_gpu_frame_upload_texture (GskGpuFrame *self,
gboolean with_mipmap,
GdkTexture *texture)
{
GskGpuFramePrivate *priv = gsk_gpu_frame_get_instance_private (self);
GskGpuImage *image;
GdkColorState *color_state;
image = GSK_GPU_FRAME_GET_CLASS (self)->upload_texture (self, with_mipmap, texture);
if (gsk_gpu_image_get_flags (image) & GSK_GPU_IMAGE_SRGB)
color_state = GDK_COLOR_STATE_SRGB_LINEAR;
else
color_state = gdk_texture_get_color_state (texture);
if (image)
gsk_gpu_device_cache_texture_image (priv->device, texture, priv->timestamp, image, color_state);
*out_color_state = color_state;
gsk_gpu_device_cache_texture_image (priv->device, texture, priv->timestamp, image);
return image;
}
@@ -571,7 +561,6 @@ copy_texture (gpointer user_data,
static void
gsk_gpu_frame_record_rect (GskGpuFrame *self,
GskGpuImage *target,
GdkColorState *target_color_state,
const cairo_rectangle_int_t *clip,
GskRenderNode *node,
const graphene_rect_t *viewport)
@@ -583,7 +572,6 @@ gsk_gpu_frame_record_rect (GskGpuFrame *self,
gsk_gpu_node_processor_process (self,
target,
target_color_state,
clip,
node,
viewport);
@@ -597,7 +585,6 @@ static void
gsk_gpu_frame_record (GskGpuFrame *self,
gint64 timestamp,
GskGpuImage *target,
GdkColorState *target_color_state,
const cairo_region_t *clip,
GskRenderNode *node,
const graphene_rect_t *viewport,
@@ -616,14 +603,13 @@ gsk_gpu_frame_record (GskGpuFrame *self,
cairo_rectangle_int_t rect;
cairo_region_get_rectangle (clip, i, &rect);
gsk_gpu_frame_record_rect (self, target, target_color_state, &rect, node, viewport);
gsk_gpu_frame_record_rect (self, target, &rect, node, viewport);
}
}
else
{
gsk_gpu_frame_record_rect (self,
target,
target_color_state,
&(cairo_rectangle_int_t) {
0, 0,
gsk_gpu_image_get_width (target),
@@ -670,7 +656,6 @@ void
gsk_gpu_frame_render (GskGpuFrame *self,
gint64 timestamp,
GskGpuImage *target,
GdkColorState *target_color_state,
const cairo_region_t *region,
GskRenderNode *node,
const graphene_rect_t *viewport,
@@ -678,7 +663,7 @@ gsk_gpu_frame_render (GskGpuFrame *self,
{
gsk_gpu_frame_cleanup (self);
gsk_gpu_frame_record (self, timestamp, target, target_color_state, region, node, viewport, texture);
gsk_gpu_frame_record (self, timestamp, target, region, node, viewport, texture);
gsk_gpu_frame_submit (self);
}
@@ -717,11 +702,10 @@ gsk_gpu_frame_download_texture (GskGpuFrame *self,
{
GskGpuFramePrivate *priv = gsk_gpu_frame_get_instance_private (self);
GskGpuImage *image;
GdkColorState *color_state;
image = gsk_gpu_device_lookup_texture_image (priv->device, texture, GDK_COLOR_STATE_SRGB, timestamp);
image = gsk_gpu_device_lookup_texture_image (priv->device, texture, timestamp);
if (image == NULL)
image = gsk_gpu_frame_upload_texture (self, FALSE, texture, &color_state);
image = gsk_gpu_frame_upload_texture (self, FALSE, texture);
if (image == NULL)
{
g_critical ("Could not upload texture");
+1 -3
View File
@@ -58,8 +58,7 @@ gpointer gsk_gpu_frame_alloc_op (GskGpuF
gsize size);
GskGpuImage * gsk_gpu_frame_upload_texture (GskGpuFrame *self,
gboolean with_mipmap,
GdkTexture *texture,
GdkColorState **out_color_state);
GdkTexture *texture);
GskGpuDescriptors * gsk_gpu_frame_create_descriptors (GskGpuFrame *self);
gsize gsk_gpu_frame_reserve_vertex_data (GskGpuFrame *self,
gsize size);
@@ -76,7 +75,6 @@ void gsk_gpu_frame_wait (GskGpuF
void gsk_gpu_frame_render (GskGpuFrame *self,
gint64 timestamp,
GskGpuImage *target,
GdkColorState *target_color_state,
const cairo_region_t *region,
GskRenderNode *node,
const graphene_rect_t *viewport,
+1 -1
View File
@@ -114,7 +114,7 @@ gsk_gpu_image_toggle_ref_texture (GskGpuImage *self,
g_object_add_toggle_ref (G_OBJECT (self), gsk_gpu_image_texture_toggle_ref_cb, texture);
g_object_unref (self);
}
GdkMemoryFormat
gsk_gpu_image_get_format (GskGpuImage *self)
{
-2
View File
@@ -5,7 +5,6 @@
#include "gskgpuframeprivate.h"
#include "gskgpuprintprivate.h"
#include "gskrectprivate.h"
#include "gskenumtypes.h"
#include "gpu/shaders/gskgpumaskinstance.h"
@@ -23,7 +22,6 @@ gsk_gpu_mask_op_print_instance (GskGpuShaderOp *shader,
{
GskGpuMaskInstance *instance = (GskGpuMaskInstance *) instance_;
gsk_gpu_print_enum (string, GSK_TYPE_MASK_MODE, shader->variation);
gsk_gpu_print_rect (string, instance->rect);
gsk_gpu_print_image_descriptor (string, shader->desc, instance->source_id);
gsk_gpu_print_image_descriptor (string, shader->desc, instance->mask_id);
+24 -201
View File
@@ -10,7 +10,6 @@
#include "gskgpubluropprivate.h"
#include "gskgpuclearopprivate.h"
#include "gskgpuclipprivate.h"
#include "gskgpucolorconvertopprivate.h"
#include "gskgpucolorizeopprivate.h"
#include "gskgpucolormatrixopprivate.h"
#include "gskgpucoloropprivate.h"
@@ -45,7 +44,6 @@
#include "gdk/gdkrgbaprivate.h"
#include "gdk/gdksubsurfaceprivate.h"
#include "gdk/gdkcolorstateprivate.h"
/* the epsilon we allow pixels to be off due to rounding errors.
* Chosen rather randomly.
@@ -122,7 +120,6 @@ struct _GskGpuNodeProcessor
float opacity;
GskGpuGlobals pending_globals;
GdkColorState *color_state;
};
#define GDK_ARRAY_NAME pattern_buffer
@@ -144,7 +141,6 @@ struct _GskGpuPatternWriter
guint stack;
PatternBuffer buffer;
GdkColorState *color_state;
};
static void gsk_gpu_node_processor_add_node (GskGpuNodeProcessor *self,
@@ -157,7 +153,6 @@ gsk_gpu_node_processor_finish (GskGpuNodeProcessor *self)
{
g_clear_pointer (&self->modelview, gsk_transform_unref);
g_clear_object (&self->desc);
g_clear_pointer (&self->color_state, gdk_color_state_unref);
}
static void
@@ -165,7 +160,6 @@ gsk_gpu_node_processor_init (GskGpuNodeProcessor *self,
GskGpuFrame *frame,
GskGpuDescriptors *desc,
GskGpuImage *target,
GdkColorState *color_state,
const cairo_rectangle_int_t *clip,
const graphene_rect_t *viewport)
{
@@ -208,8 +202,6 @@ gsk_gpu_node_processor_init (GskGpuNodeProcessor *self,
-viewport->origin.y);
self->opacity = 1.0;
self->pending_globals = GSK_GPU_GLOBAL_MATRIX | GSK_GPU_GLOBAL_SCALE | GSK_GPU_GLOBAL_CLIP | GSK_GPU_GLOBAL_SCISSOR | GSK_GPU_GLOBAL_BLEND;
self->color_state = gdk_color_state_ref (color_state);
}
static void
@@ -346,7 +338,6 @@ gsk_gpu_node_processor_init_draw (GskGpuNodeProcessor *self,
GskGpuFrame *frame,
GdkMemoryDepth depth,
const graphene_vec2_t *scale,
GdkColorState *color_state,
const graphene_rect_t *viewport)
{
GskGpuImage *image;
@@ -368,7 +359,6 @@ gsk_gpu_node_processor_init_draw (GskGpuNodeProcessor *self,
frame,
NULL,
image,
color_state,
&area,
viewport);
@@ -391,97 +381,9 @@ gsk_gpu_node_processor_finish_draw (GskGpuNodeProcessor *self,
gsk_gpu_node_processor_finish (self);
}
static GskGpuImage *
gsk_gpu_color_convert (GskGpuFrame *frame,
GskGpuImage *image,
GdkColorState *from,
GdkColorState *to)
{
GskGpuNodeProcessor other;
int width, height;
GdkMemoryDepth depth;
GskGpuImage *copy;
guint32 descriptor;
graphene_rect_t rect;
if (gdk_color_state_equal (from, to))
return image;
width = gsk_gpu_image_get_width (image);
height = gsk_gpu_image_get_height (image);
depth = gdk_memory_format_get_depth (gsk_gpu_image_get_format (image));
depth = gdk_memory_depth_merge (depth, gdk_color_state_get_min_depth (from));
depth = gdk_memory_depth_merge (depth, gdk_color_state_get_min_depth (to));
rect = GRAPHENE_RECT_INIT (0, 0, width, height);
copy = gsk_gpu_device_create_offscreen_image (gsk_gpu_frame_get_device (frame),
FALSE,
depth,
width, height);
gsk_gpu_node_processor_init (&other,
frame,
NULL,
copy,
to,
&(cairo_rectangle_int_t) { 0, 0, width, height },
&rect);
gsk_gpu_render_pass_begin_op (other.frame,
copy,
&(cairo_rectangle_int_t) { 0, 0, width, height },
GSK_RENDER_PASS_OFFSCREEN);
descriptor = gsk_gpu_node_processor_add_image (&other, image, GSK_GPU_SAMPLER_DEFAULT);
gsk_gpu_node_processor_sync_globals (&other, 0);
gsk_gpu_color_convert_op (frame,
GSK_GPU_SHADER_CLIP_NONE,
from,
to,
other.desc,
descriptor,
&rect,
&other.offset,
&rect);
gsk_gpu_render_pass_end_op (other.frame,
copy,
GSK_RENDER_PASS_OFFSCREEN);
gsk_gpu_node_processor_finish (&other);
g_object_unref (image);
return copy;
}
static void
gsk_gpu_node_processor_get_clip_bounds (GskGpuNodeProcessor *self,
graphene_rect_t *out_bounds)
{
graphene_rect_offset_r (&self->clip.rect.bounds,
- self->offset.x,
- self->offset.y,
out_bounds);
/* FIXME: We could try the scissor rect here.
* But how often is that smaller than the clip bounds?
*/
}
static GskGpuImage * gsk_gpu_get_node_as_image (GskGpuFrame *frame,
const graphene_rect_t *clip_bounds,
const graphene_vec2_t *scale,
GdkColorState *color_state,
GskRenderNode *node,
graphene_rect_t *out_bounds);
void
gsk_gpu_node_processor_process (GskGpuFrame *frame,
GskGpuImage *target,
GdkColorState *target_color_state,
const cairo_rectangle_int_t *clip,
GskRenderNode *node,
const graphene_rect_t *viewport)
@@ -492,46 +394,10 @@ gsk_gpu_node_processor_process (GskGpuFrame *frame,
frame,
NULL,
target,
GDK_COLOR_STATE_SRGB_LINEAR,
clip,
viewport);
if (gdk_color_state_equal (target_color_state, GDK_COLOR_STATE_SRGB_LINEAR))
{
gsk_gpu_node_processor_add_node (&self, node);
}
else
{
GskGpuImage *image;
graphene_rect_t clip_bounds;
graphene_rect_t bounds;
guint32 descriptor;
gsk_gpu_node_processor_sync_globals (&self, 0);
gsk_gpu_node_processor_get_clip_bounds (&self, &clip_bounds);
image = gsk_gpu_get_node_as_image (frame,
&clip_bounds,
&self.scale,
GDK_COLOR_STATE_SRGB_LINEAR,
node,
&bounds);
descriptor = gsk_gpu_node_processor_add_image (&self, image, GSK_GPU_SAMPLER_DEFAULT);
gsk_gpu_color_convert_op (frame,
GSK_GPU_SHADER_CLIP_NONE,
GDK_COLOR_STATE_SRGB_LINEAR,
target_color_state,
self.desc,
descriptor,
&bounds,
&self.offset,
&bounds);
g_object_unref (image);
}
gsk_gpu_node_processor_add_node (&self, node);
gsk_gpu_node_processor_finish (&self);
}
@@ -540,7 +406,6 @@ static void
gsk_gpu_pattern_writer_init (GskGpuPatternWriter *self,
GskGpuFrame *frame,
const graphene_vec2_t *scale,
GdkColorState *color_state,
const graphene_point_t *offset,
const graphene_rect_t *bounds)
{
@@ -554,8 +419,6 @@ gsk_gpu_pattern_writer_init (GskGpuPatternWriter *self,
self->scale = *scale;
self->stack = 0;
self->color_state = gdk_color_state_ref (color_state);
pattern_buffer_init (&self->buffer);
}
@@ -683,7 +546,6 @@ gsk_gpu_pattern_writer_finish (GskGpuPatternWriter *self)
pattern_buffer_clear (&self->buffer);
g_assert (self->stack == 0);
g_clear_object (&self->desc);
g_clear_pointer (&self->color_state, gdk_color_state_unref);
}
static gboolean
@@ -802,6 +664,20 @@ gsk_gpu_node_processor_rect_is_integer (GskGpuNodeProcessor *self,
&& int_rect->height == rect->size.height * scale_y;
}
static void
gsk_gpu_node_processor_get_clip_bounds (GskGpuNodeProcessor *self,
graphene_rect_t *out_bounds)
{
graphene_rect_offset_r (&self->clip.rect.bounds,
- self->offset.x,
- self->offset.y,
out_bounds);
/* FIXME: We could try the scissor rect here.
* But how often is that smaller than the clip bounds?
*/
}
static gboolean G_GNUC_WARN_UNUSED_RESULT
gsk_gpu_node_processor_clip_node_bounds (GskGpuNodeProcessor *self,
GskRenderNode *node,
@@ -866,7 +742,6 @@ gsk_gpu_node_processor_image_op (GskGpuNodeProcessor *self,
static GskGpuImage *
gsk_gpu_node_processor_create_offscreen (GskGpuFrame *frame,
const graphene_vec2_t *scale,
GdkColorState *color_state,
const graphene_rect_t *viewport,
GskRenderNode *node)
{
@@ -877,7 +752,6 @@ gsk_gpu_node_processor_create_offscreen (GskGpuFrame *frame,
frame,
gsk_render_node_get_preferred_depth (node),
scale,
color_state,
viewport);
if (image == NULL)
return NULL;
@@ -894,7 +768,6 @@ gsk_gpu_node_processor_create_offscreen (GskGpuFrame *frame,
* @frame: frame to render in
* @clip_bounds: region of node that must be included in image
* @scale: scale factor to use for the image
* @color_state: the color state to composite in
* @node: the node to render
* @out_bounds: the actual bounds of the result
*
@@ -916,12 +789,10 @@ static GskGpuImage *
gsk_gpu_get_node_as_image (GskGpuFrame *frame,
const graphene_rect_t *clip_bounds,
const graphene_vec2_t *scale,
GdkColorState *color_state,
GskRenderNode *node,
graphene_rect_t *out_bounds)
{
GskGpuImage *result;
GdkColorState *image_color_state;
switch ((guint) gsk_render_node_get_node_type (node))
{
@@ -930,19 +801,9 @@ gsk_gpu_get_node_as_image (GskGpuFrame *frame,
GdkTexture *texture = gsk_texture_node_get_texture (node);
GskGpuDevice *device = gsk_gpu_frame_get_device (frame);
gint64 timestamp = gsk_gpu_frame_get_timestamp (frame);
result = gsk_gpu_device_lookup_texture_image (device, texture, color_state, timestamp);
result = gsk_gpu_device_lookup_texture_image (device, texture, timestamp);
if (result == NULL)
{
result = gsk_gpu_frame_upload_texture (frame, FALSE, texture, &image_color_state);
if (result &&
!gdk_color_state_equal (image_color_state, color_state))
{
result = gsk_gpu_color_convert (frame, result, image_color_state, color_state);
gsk_gpu_device_cache_texture_image (device, texture, timestamp, result, color_state);
}
}
result = gsk_gpu_frame_upload_texture (frame, FALSE, texture);
if (result)
{
@@ -960,8 +821,6 @@ gsk_gpu_get_node_as_image (GskGpuFrame *frame,
gsk_render_node_ref (node),
(GDestroyNotify) gsk_render_node_unref);
result = gsk_gpu_color_convert (frame, result, GDK_COLOR_STATE_SRGB, color_state);
g_object_ref (result);
*out_bounds = *clip_bounds;
@@ -974,7 +833,6 @@ gsk_gpu_get_node_as_image (GskGpuFrame *frame,
GSK_DEBUG (FALLBACK, "Offscreening node '%s'", g_type_name_from_instance ((GTypeInstance *) node));
result = gsk_gpu_node_processor_create_offscreen (frame,
scale,
color_state,
clip_bounds,
node);
@@ -985,7 +843,6 @@ gsk_gpu_get_node_as_image (GskGpuFrame *frame,
static GskGpuImage *
gsk_gpu_node_processor_ensure_image (GskGpuFrame *frame,
GskGpuImage *image,
GdkColorState *color_state,
GskGpuImageFlags required_flags,
GskGpuImageFlags disallowed_flags)
{
@@ -1038,7 +895,6 @@ gsk_gpu_node_processor_ensure_image (GskGpuFrame *frame,
frame,
NULL,
copy,
color_state,
&(cairo_rectangle_int_t) { 0, 0, width, height },
&rect);
@@ -1112,7 +968,6 @@ gsk_gpu_node_processor_get_node_as_image (GskGpuNodeProcessor *self,
image = gsk_gpu_get_node_as_image (self->frame,
&clip,
&self->scale,
self->color_state,
node,
out_bounds);
if (image == NULL)
@@ -1120,7 +975,6 @@ gsk_gpu_node_processor_get_node_as_image (GskGpuNodeProcessor *self,
ensure = gsk_gpu_node_processor_ensure_image (self->frame,
image,
self->color_state,
required_flags,
disallowed_flags);
@@ -1131,8 +985,7 @@ gsk_gpu_node_processor_get_node_as_image (GskGpuNodeProcessor *self,
gsk_gpu_device_cache_texture_image (gsk_gpu_frame_get_device (self->frame),
gsk_texture_node_get_texture (node),
gsk_gpu_frame_get_timestamp (self->frame),
ensure,
self->color_state);
ensure);
}
return ensure;
@@ -1173,7 +1026,6 @@ gsk_gpu_node_processor_blur_op (GskGpuNodeProcessor *self,
self->frame,
source_depth,
&self->scale,
self->color_state,
&intermediate_rect);
gsk_gpu_node_processor_sync_globals (&other, 0);
@@ -1353,7 +1205,6 @@ gsk_gpu_node_processor_try_node_as_pattern (GskGpuNodeProcessor *self,
gsk_gpu_pattern_writer_init (&writer,
self->frame,
&self->scale,
self->color_state,
&self->offset,
&clipped);
@@ -1603,7 +1454,6 @@ gsk_gpu_node_processor_add_rounded_clip_node_with_mask (GskGpuNodeProcessor *sel
self->frame,
gsk_render_node_get_preferred_depth (node),
&self->scale,
self->color_state,
&clip_bounds);
gsk_gpu_node_processor_sync_globals (&other, 0);
gsk_gpu_rounded_color_op (other.frame,
@@ -2077,16 +1927,15 @@ gsk_gpu_node_processor_add_texture_node (GskGpuNodeProcessor *self,
GskGpuImage *image;
GdkTexture *texture;
gint64 timestamp;
GdkColorState *image_color_state;
device = gsk_gpu_frame_get_device (self->frame);
texture = gsk_texture_node_get_texture (node);
timestamp = gsk_gpu_frame_get_timestamp (self->frame);
image = gsk_gpu_device_lookup_texture_image (device, texture, self->color_state, timestamp);
image = gsk_gpu_device_lookup_texture_image (device, texture, timestamp);
if (image == NULL)
{
image = gsk_gpu_frame_upload_texture (self->frame, FALSE, texture, &image_color_state);
image = gsk_gpu_frame_upload_texture (self->frame, FALSE, texture);
if (image == NULL)
{
GSK_DEBUG (FALLBACK, "Unsupported texture format %u for size %dx%d",
@@ -2096,12 +1945,6 @@ gsk_gpu_node_processor_add_texture_node (GskGpuNodeProcessor *self,
gsk_gpu_node_processor_add_fallback_node (self, node);
return;
}
if (!gdk_color_state_equal (image_color_state, self->color_state))
{
image = gsk_gpu_color_convert (self->frame, image, image_color_state, self->color_state);
gsk_gpu_device_cache_texture_image (device, texture, timestamp, image, self->color_state);
}
}
if (gsk_gpu_frame_should_optimize (self->frame, GSK_GPU_OPTIMIZE_MIPMAP) &&
@@ -2112,7 +1955,6 @@ gsk_gpu_node_processor_add_texture_node (GskGpuNodeProcessor *self,
image = gsk_gpu_node_processor_ensure_image (self->frame,
image,
self->color_state,
GSK_GPU_IMAGE_MIPMAP,
GSK_GPU_IMAGE_STRAIGHT_ALPHA);
descriptor = gsk_gpu_node_processor_add_image (self, image, GSK_GPU_SAMPLER_MIPMAP_DEFAULT);
@@ -2159,24 +2001,17 @@ gsk_gpu_node_processor_create_texture_pattern (GskGpuPatternWriter *self,
guint32 descriptor;
GskGpuImage *image;
GskGpuSampler sampler;
GdkColorState *image_color_state;
device = gsk_gpu_frame_get_device (self->frame);
texture = gsk_texture_node_get_texture (node);
timestamp = gsk_gpu_frame_get_timestamp (self->frame);
image = gsk_gpu_device_lookup_texture_image (device, texture, self->color_state, timestamp);
image = gsk_gpu_device_lookup_texture_image (device, texture, timestamp);
if (image == NULL)
{
image = gsk_gpu_frame_upload_texture (self->frame, FALSE, texture, &image_color_state);
image = gsk_gpu_frame_upload_texture (self->frame, FALSE, texture);
if (image == NULL)
return FALSE;
if (!gdk_color_state_equal (image_color_state, self->color_state))
{
image = gsk_gpu_color_convert (self->frame, image, image_color_state, self->color_state);
gsk_gpu_device_cache_texture_image (device, texture, timestamp, image, self->color_state);
}
}
if (gsk_gpu_frame_should_optimize (self->frame, GSK_GPU_OPTIMIZE_MIPMAP) &&
@@ -2185,7 +2020,6 @@ gsk_gpu_node_processor_create_texture_pattern (GskGpuPatternWriter *self,
{
image = gsk_gpu_node_processor_ensure_image (self->frame,
image,
self->color_state,
GSK_GPU_IMAGE_MIPMAP,
GSK_GPU_IMAGE_STRAIGHT_ALPHA);
sampler = GSK_GPU_SAMPLER_MIPMAP_DEFAULT;
@@ -2224,7 +2058,6 @@ gsk_gpu_node_processor_add_texture_scale_node (GskGpuNodeProcessor *self,
gint64 timestamp;
guint32 descriptor;
gboolean need_mipmap, need_offscreen;
GdkColorState *image_color_state;
need_offscreen = self->modelview != NULL ||
!graphene_vec2_equal (&self->scale, graphene_vec2_one ());
@@ -2248,7 +2081,6 @@ gsk_gpu_node_processor_add_texture_scale_node (GskGpuNodeProcessor *self,
clip_bounds.size.height = ceilf (clip_bounds.size.height);
offscreen = gsk_gpu_node_processor_create_offscreen (self->frame,
graphene_vec2_one (),
self->color_state,
&clip_bounds,
node);
descriptor = gsk_gpu_node_processor_add_image (self, offscreen, GSK_GPU_SAMPLER_DEFAULT);
@@ -2269,10 +2101,10 @@ gsk_gpu_node_processor_add_texture_scale_node (GskGpuNodeProcessor *self,
timestamp = gsk_gpu_frame_get_timestamp (self->frame);
need_mipmap = scaling_filter == GSK_SCALING_FILTER_TRILINEAR;
image = gsk_gpu_device_lookup_texture_image (device, texture, self->color_state, timestamp);
image = gsk_gpu_device_lookup_texture_image (device, texture, timestamp);
if (image == NULL)
{
image = gsk_gpu_frame_upload_texture (self->frame, need_mipmap, texture, &image_color_state);
image = gsk_gpu_frame_upload_texture (self->frame, need_mipmap, texture);
if (image == NULL)
{
GSK_DEBUG (FALLBACK, "Unsupported texture format %u for size %dx%d",
@@ -2282,16 +2114,10 @@ gsk_gpu_node_processor_add_texture_scale_node (GskGpuNodeProcessor *self,
gsk_gpu_node_processor_add_fallback_node (self, node);
return;
}
if (!gdk_color_state_equal (image_color_state, self->color_state))
{
image = gsk_gpu_color_convert (self->frame, image, image_color_state, self->color_state);
gsk_gpu_device_cache_texture_image (device, texture, timestamp, image, self->color_state);
}
}
image = gsk_gpu_node_processor_ensure_image (self->frame,
image,
self->color_state,
need_mipmap ? (GSK_GPU_IMAGE_CAN_MIPMAP | GSK_GPU_IMAGE_MIPMAP) : 0,
GSK_GPU_IMAGE_STRAIGHT_ALPHA);
@@ -2456,7 +2282,6 @@ gsk_gpu_node_processor_add_gradient_node (GskGpuNodeProcessor *self,
self->frame,
gsk_render_node_get_preferred_depth (node),
&self->scale,
self->color_state,
&bounds);
other.blend = GSK_GPU_BLEND_ADD;
@@ -3506,7 +3331,6 @@ gsk_gpu_node_processor_repeat_tile (GskGpuNodeProcessor *self,
GSK_DEBUG (FALLBACK, "Offscreening node '%s' for tiling", g_type_name_from_instance ((GTypeInstance *) child));
image = gsk_gpu_node_processor_create_offscreen (self->frame,
&self->scale,
self->color_state,
&clipped_child_bounds,
child);
@@ -4299,7 +4123,6 @@ gsk_gpu_node_processor_create_node_pattern (GskGpuPatternWriter *self,
image = gsk_gpu_get_node_as_image (self->frame,
&bounds,
&self->scale,
self->color_state,
node,
&bounds);
if (image == NULL)
-1
View File
@@ -7,7 +7,6 @@ G_BEGIN_DECLS
void gsk_gpu_node_processor_process (GskGpuFrame *frame,
GskGpuImage *target,
GdkColorState *target_color_state,
const cairo_rectangle_int_t *clip,
GskRenderNode *node,
const graphene_rect_t *viewport);
+2 -13
View File
@@ -2,8 +2,6 @@
#include "gskgpuprintprivate.h"
#include "gdk/gdkrgbaprivate.h"
#include "gdk/gdkcolorstateprivate.h"
#include "gskgpudescriptorsprivate.h"
#include "gskgpuimageprivate.h"
@@ -142,10 +140,9 @@ void
gsk_gpu_print_image (GString *string,
GskGpuImage *image)
{
g_string_append_printf (string, "%zux%zu %s ",
g_string_append_printf (string, "%zux%zu ",
gsk_gpu_image_get_width (image),
gsk_gpu_image_get_height (image),
gdk_memory_format_get_name (gsk_gpu_image_get_format (image)));
gsk_gpu_image_get_height (image));
}
void
@@ -157,11 +154,3 @@ gsk_gpu_print_image_descriptor (GString *string,
gsk_gpu_print_image (string, gsk_gpu_descriptors_get_image (desc, id));
}
void
gsk_gpu_print_color_conversion (GString *string,
guint conversion)
{
g_string_append_printf (string, "%s->%s ",
gdk_color_state_get_name_from_id (conversion & 0xffff),
gdk_color_state_get_name_from_id (conversion >> 16));
}
-2
View File
@@ -35,5 +35,3 @@ void gsk_gpu_print_image (GString
void gsk_gpu_print_image_descriptor (GString *string,
GskGpuDescriptors *desc,
guint32 descriptor);
void gsk_gpu_print_color_conversion (GString *string,
guint conversion);
+3 -20
View File
@@ -18,7 +18,6 @@
#include "gdk/gdktextureprivate.h"
#include "gdk/gdktexturedownloaderprivate.h"
#include "gdk/gdkdrawcontextprivate.h"
#include "gdk/gdkcolorstateprivate.h"
#include <graphene.h>
@@ -299,7 +298,6 @@ gsk_gpu_renderer_fallback_render_texture (GskGpuRenderer *self,
gsk_gpu_frame_render (frame,
g_get_monotonic_time (),
image,
GDK_COLOR_STATE_SRGB,
NULL,
root,
&GRAPHENE_RECT_INIT (rounded_viewport->origin.x + x,
@@ -362,7 +360,6 @@ gsk_gpu_renderer_render_texture (GskRenderer *renderer,
gsk_gpu_frame_render (frame,
g_get_monotonic_time (),
image,
GDK_COLOR_STATE_SRGB,
NULL,
root,
&rounded_viewport,
@@ -390,8 +387,6 @@ gsk_gpu_renderer_render (GskRenderer *renderer,
GskGpuImage *backbuffer;
cairo_region_t *render_region;
double scale;
GdkMemoryDepth depth;
GdkColorState *target_color_state;
if (cairo_region_is_empty (region))
{
@@ -399,9 +394,9 @@ gsk_gpu_renderer_render (GskRenderer *renderer,
return;
}
depth = gsk_render_node_get_preferred_depth (root);
gdk_draw_context_begin_frame_full (priv->context, depth, region);
gdk_draw_context_begin_frame_full (priv->context,
gsk_render_node_get_preferred_depth (root),
region);
gsk_gpu_device_maybe_gc (priv->device);
@@ -413,21 +408,9 @@ gsk_gpu_renderer_render (GskRenderer *renderer,
render_region = get_render_region (self);
scale = gsk_gpu_renderer_get_scale (self);
if (gsk_gpu_image_get_flags (backbuffer) & GSK_GPU_IMAGE_SRGB)
{
g_debug ("Relying on GL/Vulkan to do srgb-linear->srgb conversion");
target_color_state = GDK_COLOR_STATE_SRGB_LINEAR;
}
else
{
g_debug ("Using an offscreen for srgb-linear->srgb conversion");
target_color_state = GDK_COLOR_STATE_SRGB;
}
gsk_gpu_frame_render (frame,
g_get_monotonic_time (),
backbuffer,
target_color_state,
render_region,
root,
&GRAPHENE_RECT_INIT (
+3 -15
View File
@@ -4,8 +4,6 @@
#include "gskgputypesprivate.h"
#include <math.h>
G_BEGIN_DECLS
struct _GskGpuShaderOp
@@ -65,23 +63,13 @@ GskGpuOp * gsk_gpu_shader_op_gl_command (GskGpuO
GskGpuFrame *frame,
GskGLCommandState *state);
static inline float
srgb_inverse_transfer_function (float v)
{
if (v >= 0.04045)
return powf (((v + 0.055)/(1 + 0.055)), 2.4);
else
return v / 12.92;
}
static inline void
gsk_gpu_rgba_to_float (const GdkRGBA *rgba,
float values[4])
{
values[0] = srgb_inverse_transfer_function (rgba->red);
values[1] = srgb_inverse_transfer_function (rgba->green);
values[2] = srgb_inverse_transfer_function (rgba->blue);
values[0] = rgba->red;
values[1] = rgba->green;
values[2] = rgba->blue;
values[3] = rgba->alpha;
}
-1
View File
@@ -29,7 +29,6 @@ typedef enum {
GSK_GPU_IMAGE_MIPMAP = (1 << 5),
GSK_GPU_IMAGE_FILTERABLE = (1 << 6),
GSK_GPU_IMAGE_RENDERABLE = (1 << 7),
GSK_GPU_IMAGE_SRGB = (1 << 8),
} GskGpuImageFlags;
typedef enum {
-27
View File
@@ -14,15 +14,6 @@
#include "gdk/gdkglcontextprivate.h"
#include "gsk/gskdebugprivate.h"
#include "gdk/gdkcolorstateprivate.h"
#ifdef HAVE_PANGOFT
#include <pango/pangofc-font.h>
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_PARAMETER_TAGS_H
#endif
static GskGpuOp *
gsk_gpu_upload_op_gl_command_with_area (GskGpuOp *op,
@@ -313,7 +304,6 @@ gsk_gpu_upload_texture_op_try (GskGpuFrame *frame,
image = gsk_gpu_device_create_upload_image (gsk_gpu_frame_get_device (frame),
with_mipmap,
gdk_texture_get_format (texture),
gdk_texture_get_color_state (texture),
gdk_texture_get_width (texture),
gdk_texture_get_height (texture));
if (image == NULL)
@@ -480,7 +470,6 @@ gsk_gpu_upload_cairo_op (GskGpuFrame *frame,
self->image = gsk_gpu_device_create_upload_image (gsk_gpu_frame_get_device (frame),
FALSE,
GDK_MEMORY_DEFAULT,
GDK_COLOR_STATE_SRGB,
ceil (graphene_vec2_get_x (scale) * viewport->size.width),
ceil (graphene_vec2_get_y (scale) * viewport->size.height));
self->viewport = *viewport;
@@ -548,16 +537,6 @@ gsk_gpu_upload_glyph_op_draw (GskGpuOp *op,
cairo_surface_t *surface;
cairo_t *cr;
PangoRectangle ink_rect = { 0, };
#ifdef HAVE_PANGOFT
FT_Face face;
FT_Bool darken = 1;
FT_Parameter property = { FT_PARAM_TAG_STEM_DARKENING, &darken };
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
face = pango_fc_font_lock_face (PANGO_FC_FONT (self->font));
G_GNUC_END_IGNORE_DEPRECATIONS
FT_Face_Properties (face, 1, &property);
#endif
surface = cairo_image_surface_create_for_data (data,
CAIRO_FORMAT_ARGB32,
@@ -599,12 +578,6 @@ G_GNUC_END_IGNORE_DEPRECATIONS
cairo_surface_finish (surface);
cairo_surface_destroy (surface);
#ifdef HAVE_PANGOFT
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
pango_fc_font_unlock_face (PANGO_FC_FONT (self->font));
G_GNUC_END_IGNORE_DEPRECATIONS
#endif
}
#ifdef GDK_RENDERING_VULKAN
+1 -2
View File
@@ -117,8 +117,7 @@ gsk_ngl_renderer_get_backbuffer (GskGpuRenderer *renderer)
GDK_GL_CONTEXT (context),
GDK_MEMORY_DEFAULT /* FIXME */,
ceil (gdk_surface_get_width (surface) * scale),
ceil (gdk_surface_get_height (surface) * scale),
gdk_surface_get_gl_is_srgb (surface));
ceil (gdk_surface_get_height (surface) * scale));
}
return self->backbuffer;
-2
View File
@@ -391,7 +391,6 @@ static GskGpuImage *
gsk_vulkan_device_create_upload_image (GskGpuDevice *device,
gboolean with_mipmap,
GdkMemoryFormat format,
GdkColorState *color_state,
gsize width,
gsize height)
{
@@ -400,7 +399,6 @@ gsk_vulkan_device_create_upload_image (GskGpuDevice *device,
return gsk_vulkan_image_new_for_upload (self,
with_mipmap,
format,
color_state,
width,
height);
}
+8 -25
View File
@@ -11,7 +11,6 @@
#include "gdk/gdkvulkancontextprivate.h"
#include "gdk/gdkmemoryformatprivate.h"
#include "gdk/gdkvulkancontextprivate.h"
#include "gdk/gdkcolorstateprivate.h"
#include <fcntl.h>
#include <string.h>
@@ -203,9 +202,6 @@ gsk_vulkan_device_check_format (GskVulkanDevice *device,
#define CHECK_FLAGS (GSK_GPU_IMAGE_NO_BLIT | GSK_GPU_IMAGE_FILTERABLE | GSK_GPU_IMAGE_RENDERABLE)
GskGpuImageFlags flags;
if (vk_format == VK_FORMAT_UNDEFINED)
return FALSE;
if (vk_usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT &&
!gsk_component_mapping_is_framebuffer_compatible (vk_components))
return FALSE;
@@ -244,7 +240,6 @@ gsk_vulkan_device_check_format (GskVulkanDevice *device,
static GskVulkanImage *
gsk_vulkan_image_new (GskVulkanDevice *device,
GdkMemoryFormat format,
GdkColorState *color_state,
GskGpuImageFlags required_flags,
gsize width,
gsize height,
@@ -266,13 +261,15 @@ gsk_vulkan_image_new (GskVulkanDevice *device,
/* First, try the actual format */
vk_format = gdk_memory_format_vk_format (format, &vk_components);
if (!gsk_vulkan_device_check_format (device, vk_format, &vk_components, required_flags,
if (vk_format == VK_FORMAT_UNDEFINED ||
!gsk_vulkan_device_check_format (device, vk_format, &vk_components, required_flags,
tiling, usage, width, height,
&tiling, &flags))
{
/* Second, try the potential RGBA format */
vk_format = gdk_memory_format_vk_rgba_format (format, NULL, &vk_components);
if (!gsk_vulkan_device_check_format (device, vk_format, &vk_components, required_flags,
if (vk_format == VK_FORMAT_UNDEFINED ||
!gsk_vulkan_device_check_format (device, vk_format, &vk_components, required_flags,
tiling, usage, width, height,
&tiling, &flags))
{
@@ -284,7 +281,8 @@ gsk_vulkan_image_new (GskVulkanDevice *device,
for (i = 0; fallbacks[i] != -1; i++)
{
vk_format = gdk_memory_format_vk_format (fallbacks[i], &vk_components);
if (gsk_vulkan_device_check_format (device, vk_format, &vk_components, required_flags,
if (vk_format != VK_FORMAT_UNDEFINED &&
gsk_vulkan_device_check_format (device, vk_format, &vk_components, required_flags,
tiling, usage, width, height,
&tiling, &flags))
{
@@ -307,13 +305,6 @@ gsk_vulkan_image_new (GskVulkanDevice *device,
(required_flags & GSK_GPU_IMAGE_CAN_MIPMAP))
flags |= GSK_GPU_IMAGE_CAN_MIPMAP;
if (gdk_memory_format_vk_srgb_format (format) != VK_FORMAT_UNDEFINED &&
gdk_color_state_equal (color_state, GDK_COLOR_STATE_SRGB))
{
vk_format = gdk_memory_format_vk_srgb_format (format);
flags |= GSK_GPU_IMAGE_SRGB;
}
vk_device = gsk_vulkan_device_get_vk_device (device);
self = g_object_new (GSK_TYPE_VULKAN_IMAGE, NULL);
@@ -375,7 +366,6 @@ GskGpuImage *
gsk_vulkan_image_new_for_upload (GskVulkanDevice *device,
gboolean with_mipmap,
GdkMemoryFormat format,
GdkColorState *color_state,
gsize width,
gsize height)
{
@@ -383,7 +373,6 @@ gsk_vulkan_image_new_for_upload (GskVulkanDevice *device,
self = gsk_vulkan_image_new (device,
format,
color_state,
with_mipmap ? (GSK_GPU_IMAGE_CAN_MIPMAP | GSK_GPU_IMAGE_RENDERABLE | GSK_GPU_IMAGE_FILTERABLE) : 0,
width,
height,
@@ -444,12 +433,10 @@ GskGpuImage *
gsk_vulkan_image_new_for_swapchain (GskVulkanDevice *device,
VkImage image,
VkFormat format,
GdkMemoryFormat memory_format,
gsize width,
gsize height)
{
GskVulkanImage *self;
GskGpuImageFlags flags = 0;
self = g_object_new (GSK_TYPE_VULKAN_IMAGE, NULL);
@@ -462,11 +449,9 @@ gsk_vulkan_image_new_for_swapchain (GskVulkanDevice *device,
self->vk_image_layout = VK_IMAGE_LAYOUT_UNDEFINED;
self->vk_access = 0;
if (format == gdk_memory_format_vk_srgb_format (memory_format))
flags |= GSK_GPU_IMAGE_SRGB;
/* FIXME: The memory format and flags here are very suboptimal */
gsk_gpu_image_setup (GSK_GPU_IMAGE (self), 0, GDK_MEMORY_DEFAULT, width, height);
/* FIXME: The flags here are very suboptimal */
gsk_gpu_image_setup (GSK_GPU_IMAGE (self), flags, memory_format, width, height);
gsk_vulkan_image_create_view (self,
format,
&(VkComponentMapping) {
@@ -489,7 +474,6 @@ gsk_vulkan_image_new_for_atlas (GskVulkanDevice *device,
self = gsk_vulkan_image_new (device,
GDK_MEMORY_DEFAULT,
GDK_COLOR_STATE_SRGB_LINEAR,
GSK_GPU_IMAGE_FILTERABLE | GSK_GPU_IMAGE_RENDERABLE,
width,
height,
@@ -514,7 +498,6 @@ gsk_vulkan_image_new_for_offscreen (GskVulkanDevice *device,
self = gsk_vulkan_image_new (device,
preferred_format,
GDK_COLOR_STATE_SRGB_LINEAR,
GSK_GPU_IMAGE_RENDERABLE |
(with_mipmap ? GSK_GPU_IMAGE_CAN_MIPMAP | GSK_GPU_IMAGE_FILTERABLE : 0),
width,
-2
View File
@@ -14,7 +14,6 @@ G_DECLARE_FINAL_TYPE (GskVulkanImage, gsk_vulkan_image, GSK, VULKAN_IMAGE, GskGp
GskGpuImage * gsk_vulkan_image_new_for_swapchain (GskVulkanDevice *device,
VkImage image,
VkFormat format,
GdkMemoryFormat memory_format,
gsize width,
gsize height);
@@ -29,7 +28,6 @@ GskGpuImage * gsk_vulkan_image_new_for_offscreen (GskVulk
GskGpuImage * gsk_vulkan_image_new_for_upload (GskVulkanDevice *device,
gboolean with_mipmap,
GdkMemoryFormat format,
GdkColorState *color_state,
gsize width,
gsize height);
#ifdef HAVE_DMABUF
-1
View File
@@ -75,7 +75,6 @@ gsk_vulkan_renderer_update_images_cb (GdkVulkanContext *context,
self->targets[i] = gsk_vulkan_image_new_for_swapchain (device,
gdk_vulkan_context_get_image (context, i),
gdk_vulkan_context_get_image_format (context),
gdk_vulkan_context_get_memory_format (context),
width, height);
}
}
+1 -1
View File
@@ -19,4 +19,4 @@ luminance (vec3 color)
return dot (vec3 (0.2126, 0.7152, 0.0722), color);
}
#endif
#endif /* _COLOR_ */
-116
View File
@@ -1,116 +0,0 @@
#include "common.glsl"
PASS(0) vec2 _pos;
PASS_FLAT(1) Rect _rect;
PASS(2) vec2 _tex_coord;
PASS_FLAT(3) uint _tex_id;
#ifdef GSK_VERTEX_SHADER
IN(0) vec4 in_rect;
IN(1) vec4 in_tex_rect;
IN(2) uint in_tex_id;
void
run (out vec2 pos)
{
Rect r = rect_from_gsk (in_rect);
pos = rect_get_position (r);
_pos = pos;
_rect = r;
_tex_coord = rect_get_coord (rect_from_gsk (in_tex_rect), pos);
_tex_id = in_tex_id;
}
#endif
#ifdef GSK_FRAGMENT_SHADER
float
srgb_transfer_function (float v)
{
if (v >= 0.04045)
return pow (((v + 0.055)/(1.0 + 0.055)), 2.4);
else
return v / 12.92;
}
float
srgb_inverse_transfer_function (float v)
{
if (v > 0.0031308)
return 1.055 * pow (v, 1.0/2.4) - 0.055;
else
return 12.92 * v;
}
vec4
srgb_to_linear_srgb (vec4 color)
{
return vec4 (srgb_transfer_function (color.r),
srgb_transfer_function (color.g),
srgb_transfer_function (color.b),
color.a);
}
vec4
linear_srgb_to_srgb (vec4 color)
{
return vec4 (srgb_inverse_transfer_function (color.r),
srgb_inverse_transfer_function (color.g),
srgb_inverse_transfer_function (color.b),
color.a);
}
#define RGB 0u
#define LINRGB 1u
#define pair(u,v) ((u)|((v) << 16))
#define first(p) ((p) & 0xffffu)
#define second(p) ((p) >> 16)
bool
do_conversion (in vec4 color, in uint f, out vec4 result)
{
switch (f)
{
case pair (RGB, LINRGB): result = srgb_to_linear_srgb (color); break;
case pair (LINRGB, RGB): result = linear_srgb_to_srgb (color); break;
default: return false;
}
return true;
}
vec4
color_convert (in vec4 color, in uint f)
{
vec4 result;
if (f == 0u)
return color;
do_conversion (color, f, result);
return result;
}
void
run (out vec4 color,
out vec2 position)
{
vec4 pixel = gsk_texture (_tex_id, _tex_coord);
pixel = color_unpremultiply (pixel);
pixel = color_convert (pixel, GSK_VARIATION);
color = color_premultiply (pixel) * rect_coverage (_rect, _pos);
position = _pos;
}
#endif
-1
View File
@@ -18,7 +18,6 @@ gsk_private_gpu_shaders = files([
'gskgpuborder.glsl',
'gskgpuboxshadow.glsl',
'gskgpucolor.glsl',
'gskgpucolorconvert.glsl',
'gskgpucolorize.glsl',
'gskgpucolormatrix.glsl',
'gskgpuconicgradient.glsl',
+6 -33
View File
@@ -26,7 +26,6 @@
#include "gskrendererprivate.h"
#include "gskrendernodeprivate.h"
#include "gdk/gdktextureprivate.h"
#include "gdk/gdkcolorstateprivate.h"
typedef struct {
GQuark cpu_time;
@@ -91,19 +90,6 @@ gsk_cairo_renderer_do_render (GskRenderer *renderer,
gsk_profiler_push_samples (profiler);
}
static void
surface_linear_srgb_to_srgb (cairo_surface_t *s)
{
gdk_memory_convert_color_state (cairo_image_surface_get_data (s),
cairo_image_surface_get_stride (s),
GDK_MEMORY_DEFAULT,
GDK_COLOR_STATE_SRGB_LINEAR,
GDK_COLOR_STATE_SRGB,
cairo_image_surface_get_width (s),
cairo_image_surface_get_height (s));
cairo_surface_mark_dirty (s);
}
static GdkTexture *
gsk_cairo_renderer_render_texture (GskRenderer *renderer,
GskRenderNode *root,
@@ -158,7 +144,6 @@ gsk_cairo_renderer_render_texture (GskRenderer *renderer,
cairo_destroy (cr);
surface_linear_srgb_to_srgb (surface);
texture = gdk_texture_new_for_surface (surface);
cairo_surface_destroy (surface);
@@ -171,17 +156,18 @@ gsk_cairo_renderer_render (GskRenderer *renderer,
const cairo_region_t *region)
{
GskCairoRenderer *self = GSK_CAIRO_RENDERER (renderer);
cairo_t *cr, *cr2;
GdkSurface *surface = gsk_renderer_get_surface (renderer);
cairo_surface_t *s;
cairo_t *cr;
gdk_draw_context_begin_frame (GDK_DRAW_CONTEXT (self->cairo_context), region);
gdk_draw_context_begin_frame (GDK_DRAW_CONTEXT (self->cairo_context),
region);
cr = gdk_cairo_context_cairo_create (self->cairo_context);
g_return_if_fail (cr != NULL);
if (GSK_RENDERER_DEBUG_CHECK (renderer, GEOMETRY))
{
GdkSurface *surface = gsk_renderer_get_surface (renderer);
cairo_save (cr);
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
cairo_rectangle (cr,
@@ -192,21 +178,8 @@ gsk_cairo_renderer_render (GskRenderer *renderer,
cairo_restore (cr);
}
s = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
gdk_surface_get_width (surface),
gdk_surface_get_height (surface));
gsk_cairo_renderer_do_render (renderer, cr, root);
cr2 = cairo_create (s);
gdk_cairo_region (cr2, gdk_draw_context_get_frame_region (GDK_DRAW_CONTEXT (self->cairo_context)));
cairo_clip (cr2);
gsk_cairo_renderer_do_render (renderer, cr2, root);
surface_linear_srgb_to_srgb (s);
cairo_set_source_surface (cr, s, 0, 0);
cairo_paint (cr);
cairo_destroy (cr2);
cairo_surface_destroy (s);
cairo_destroy (cr);
gdk_draw_context_end_frame (GDK_DRAW_CONTEXT (self->cairo_context));
+27 -91
View File
@@ -40,7 +40,6 @@
#include "gdk/gdktextureprivate.h"
#include "gdk/gdktexturedownloaderprivate.h"
#include "gdk/gdkrgbaprivate.h"
#include "gdk/gdkcolorstateprivate.h"
#include <cairo.h>
#ifdef CAIRO_HAS_SVG_SURFACE
@@ -48,13 +47,6 @@
#endif
#include <hb-ot.h>
#ifdef HAVE_PANGOFT
#include <pango/pangofc-font.h>
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_PARAMETER_TAGS_H
#endif
/* for oversized image fallback - we use a smaller size than Cairo actually
* allows to avoid rounding errors in Cairo */
#define MAX_CAIRO_IMAGE_WIDTH 16384
@@ -147,39 +139,6 @@ region_union_region_affine (cairo_region_t *region,
}
}
static inline float
srgb_inverse_transfer_function (float v)
{
if (v >= 0.04045)
return powf (((v + 0.055)/(1 + 0.055)), 2.4);
else
return v / 12.92;
}
static void
gsk_cairo_set_source_rgba (cairo_t *cr,
const GdkRGBA *rgba)
{
cairo_set_source_rgba (cr,
srgb_inverse_transfer_function (rgba->red),
srgb_inverse_transfer_function (rgba->green),
srgb_inverse_transfer_function (rgba->blue),
rgba->alpha);
}
static void
surface_srgb_to_linear_srgb (cairo_surface_t *s)
{
gdk_memory_convert_color_state (cairo_image_surface_get_data (s),
cairo_image_surface_get_stride (s),
GDK_MEMORY_DEFAULT,
GDK_COLOR_STATE_SRGB,
GDK_COLOR_STATE_SRGB_LINEAR,
cairo_image_surface_get_width (s),
cairo_image_surface_get_height (s));
cairo_surface_mark_dirty (s);
}
/* {{{ GSK_COLOR_NODE */
/**
@@ -200,7 +159,7 @@ gsk_color_node_draw (GskRenderNode *node,
{
GskColorNode *self = (GskColorNode *) node;
gsk_cairo_set_source_rgba (cr, &self->color);
gdk_cairo_set_source_rgba (cr, &self->color);
gsk_cairo_rectangle (cr, &node->bounds);
cairo_fill (cr);
@@ -335,25 +294,25 @@ gsk_linear_gradient_node_draw (GskRenderNode *node,
if (self->stops[0].offset > 0.0)
cairo_pattern_add_color_stop_rgba (pattern,
0.0,
srgb_inverse_transfer_function (self->stops[0].color.red),
srgb_inverse_transfer_function (self->stops[0].color.green),
srgb_inverse_transfer_function (self->stops[0].color.blue),
self->stops[0].color.red,
self->stops[0].color.green,
self->stops[0].color.blue,
self->stops[0].color.alpha);
for (i = 0; i < self->n_stops; i++)
{
cairo_pattern_add_color_stop_rgba (pattern,
self->stops[i].offset,
srgb_inverse_transfer_function (self->stops[i].color.red),
srgb_inverse_transfer_function (self->stops[i].color.green),
srgb_inverse_transfer_function (self->stops[i].color.blue),
self->stops[i].color.red,
self->stops[i].color.green,
self->stops[i].color.blue,
self->stops[i].color.alpha);
}
if (self->stops[self->n_stops-1].offset < 1.0)
cairo_pattern_add_color_stop_rgba (pattern,
1.0,
srgb_inverse_transfer_function (self->stops[self->n_stops-1].color.red),
srgb_inverse_transfer_function (self->stops[self->n_stops-1].color.green),
srgb_inverse_transfer_function (self->stops[self->n_stops-1].color.blue),
self->stops[self->n_stops-1].color.red,
self->stops[self->n_stops-1].color.green,
self->stops[self->n_stops-1].color.blue,
self->stops[self->n_stops-1].color.alpha);
cairo_set_source (cr, pattern);
@@ -665,25 +624,25 @@ gsk_radial_gradient_node_draw (GskRenderNode *node,
if (self->stops[0].offset > 0.0)
cairo_pattern_add_color_stop_rgba (pattern,
0.0,
srgb_inverse_transfer_function (self->stops[0].color.red),
srgb_inverse_transfer_function (self->stops[0].color.green),
srgb_inverse_transfer_function (self->stops[0].color.blue),
self->stops[0].color.red,
self->stops[0].color.green,
self->stops[0].color.blue,
self->stops[0].color.alpha);
for (i = 0; i < self->n_stops; i++)
{
cairo_pattern_add_color_stop_rgba (pattern,
self->stops[i].offset,
srgb_inverse_transfer_function (self->stops[i].color.red),
srgb_inverse_transfer_function (self->stops[i].color.green),
srgb_inverse_transfer_function (self->stops[i].color.blue),
self->stops[i].color.red,
self->stops[i].color.green,
self->stops[i].color.blue,
self->stops[i].color.alpha);
}
if (self->stops[self->n_stops-1].offset < 1.0)
cairo_pattern_add_color_stop_rgba (pattern,
1.0,
srgb_inverse_transfer_function (self->stops[self->n_stops-1].color.red),
srgb_inverse_transfer_function (self->stops[self->n_stops-1].color.green),
srgb_inverse_transfer_function (self->stops[self->n_stops-1].color.blue),
self->stops[self->n_stops-1].color.red,
self->stops[self->n_stops-1].color.green,
self->stops[self->n_stops-1].color.blue,
self->stops[self->n_stops-1].color.alpha);
gsk_cairo_rectangle (cr, &node->bounds);
@@ -1052,12 +1011,7 @@ _cairo_mesh_pattern_set_corner_rgba (cairo_pattern_t *pattern,
guint corner_num,
const GdkRGBA *rgba)
{
cairo_mesh_pattern_set_corner_color_rgba (pattern,
corner_num,
srgb_inverse_transfer_function (rgba->red),
srgb_inverse_transfer_function (rgba->green),
srgb_inverse_transfer_function (rgba->blue),
rgba->alpha);
cairo_mesh_pattern_set_corner_color_rgba (pattern, corner_num, rgba->red, rgba->green, rgba->blue, rgba->alpha);
}
static void
@@ -1455,7 +1409,7 @@ gsk_border_node_draw (GskRenderNode *node,
gdk_rgba_equal (&self->border_color[0], &self->border_color[2]) &&
gdk_rgba_equal (&self->border_color[0], &self->border_color[3]))
{
gsk_cairo_set_source_rgba (cr, &self->border_color[0]);
gdk_cairo_set_source_rgba (cr, &self->border_color[0]);
}
else
{
@@ -1817,7 +1771,6 @@ gsk_texture_node_draw (GskRenderNode *node,
}
surface = gdk_texture_download_surface (self->texture);
surface_srgb_to_linear_srgb (surface);
pattern = cairo_pattern_create_for_surface (surface);
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_PAD);
@@ -1994,7 +1947,6 @@ gsk_texture_scale_node_draw (GskRenderNode *node,
cr2 = cairo_create (surface2);
surface = gdk_texture_download_surface (self->texture);
surface_srgb_to_linear_srgb (surface);
pattern = cairo_pattern_create_for_surface (surface);
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_PAD);
@@ -2197,7 +2149,7 @@ draw_shadow (cairo_t *cr,
if (has_empty_clip (cr))
return;
gsk_cairo_set_source_rgba (cr, color);
gdk_cairo_set_source_rgba (cr, color);
shadow_cr = gsk_cairo_blur_start_drawing (cr, radius, blur_flags);
cairo_set_fill_rule (shadow_cr, CAIRO_FILL_RULE_EVEN_ODD);
@@ -2370,7 +2322,7 @@ draw_shadow_corner (cairo_t *cr,
g_hash_table_insert (corner_mask_cache, g_memdup2 (&key, sizeof (key)), mask);
}
gsk_cairo_set_source_rgba (cr, color);
gdk_cairo_set_source_rgba (cr, color);
pattern = cairo_pattern_create_for_surface (mask);
cairo_matrix_init_identity (&matrix);
cairo_matrix_scale (&matrix, sx, sy);
@@ -4741,7 +4693,7 @@ gsk_fill_node_draw (GskRenderNode *node,
if (gsk_render_node_get_node_type (self->child) == GSK_COLOR_NODE &&
gsk_rect_contains_rect (&self->child->bounds, &node->bounds))
{
gsk_cairo_set_source_rgba (cr, gsk_color_node_get_color (self->child));
gdk_cairo_set_source_rgba (cr, gsk_color_node_get_color (self->child));
cairo_fill (cr);
}
else
@@ -4934,7 +4886,7 @@ gsk_stroke_node_draw (GskRenderNode *node,
if (gsk_render_node_get_node_type (self->child) == GSK_COLOR_NODE &&
gsk_rect_contains_rect (&self->child->bounds, &node->bounds))
{
gsk_cairo_set_source_rgba (cr, gsk_color_node_get_color (self->child));
gdk_cairo_set_source_rgba (cr, gsk_color_node_get_color (self->child));
}
else
{
@@ -5159,7 +5111,7 @@ gsk_shadow_node_draw (GskRenderNode *node,
gsk_render_node_draw (self->child, cr);
pattern = cairo_pop_group (cr);
cairo_reset_clip (cr);
gsk_cairo_set_source_rgba (cr, &shadow->color);
gdk_cairo_set_source_rgba (cr, &shadow->color);
cairo_mask (cr, pattern);
cairo_pattern_destroy (pattern);
cairo_restore (cr);
@@ -5776,16 +5728,6 @@ gsk_text_node_draw (GskRenderNode *node,
{
GskTextNode *self = (GskTextNode *) node;
PangoGlyphString glyphs;
#ifdef HAVE_PANGOFT
FT_Face face;
FT_Bool darken = 1;
FT_Parameter property = { FT_PARAM_TAG_STEM_DARKENING, &darken };
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
face = pango_fc_font_lock_face (PANGO_FC_FONT (self->font));
G_GNUC_END_IGNORE_DEPRECATIONS
FT_Face_Properties (face, 1, &property);
#endif
glyphs.num_glyphs = self->num_glyphs;
glyphs.glyphs = self->glyphs;
@@ -5793,17 +5735,11 @@ G_GNUC_END_IGNORE_DEPRECATIONS
cairo_save (cr);
gsk_cairo_set_source_rgba (cr, &self->color);
gdk_cairo_set_source_rgba (cr, &self->color);
cairo_translate (cr, self->offset.x, self->offset.y);
pango_cairo_show_glyph_string (cr, self->font, &glyphs);
cairo_restore (cr);
#ifdef HAVE_PANGOFT
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
pango_fc_font_unlock_face (PANGO_FC_FONT (self->font));
G_GNUC_END_IGNORE_DEPRECATIONS
#endif
}
static void
+33 -9
View File
@@ -1005,7 +1005,7 @@ ensure_fontmap (Context *context)
context->fontmap = pango_cairo_font_map_new ();
config = FcConfigCreate ();
config = FcInitLoadConfig ();
pango_fc_font_map_set_config (PANGO_FC_FONT_MAP (context->fontmap), config);
FcConfigDestroy (config);
@@ -2990,13 +2990,8 @@ printer_init_collect_font_info (Printer *printer,
info->face = hb_face_reference (hb_font_get_face (pango_font_get_hb_font (font)));
if (!g_object_get_data (G_OBJECT (pango_font_get_font_map (font)), "font-files"))
{
if (g_strcmp0 (g_getenv ("GSK_SUBSET_FONTS"), "1") == 0)
{
info->input = hb_subset_input_create_or_fail ();
hb_subset_input_set_flags (info->input, HB_SUBSET_FLAGS_RETAIN_GIDS);
}
else
info->serialized = TRUE; /* Don't subset (or serialize) system fonts */
info->input = hb_subset_input_create_or_fail ();
hb_subset_input_set_flags (info->input, HB_SUBSET_FLAGS_RETAIN_GIDS);
}
g_hash_table_insert (printer->fonts, info->face, info);
@@ -3027,11 +3022,11 @@ printer_init_duplicates_for_node (Printer *printer,
switch (gsk_render_node_get_node_type (node))
{
case GSK_CAIRO_NODE:
case GSK_TEXT_NODE:
printer_init_collect_font_info (printer, node);
break;
case GSK_CAIRO_NODE:
case GSK_COLOR_NODE:
case GSK_LINEAR_GRADIENT_NODE:
case GSK_REPEATING_LINEAR_GRADIENT_NODE:
@@ -3627,6 +3622,33 @@ append_texture_param (Printer *p,
g_bytes_unref (bytes);
}
static void
print_font (PangoFont *font)
{
PangoFontDescription *desc;
char *s;
hb_face_t *face;
hb_blob_t *blob;
const char *data;
unsigned int length;
char *csum;
desc = pango_font_describe_with_absolute_size (font);
s = pango_font_description_to_string (desc);
face = hb_font_get_face (pango_font_get_hb_font (font));
blob = hb_face_reference_blob (face);
data = hb_blob_get_data (blob, &length);
csum = g_compute_checksum_for_data (G_CHECKSUM_SHA256, (const guchar *)data, length);
g_print ("%s, face %p, sha %s\n", s, face, csum);
g_free (csum);
hb_blob_destroy (blob);
g_free (s);
}
static void
gsk_text_node_serialize_font (GskRenderNode *node,
Printer *p)
@@ -3647,6 +3669,8 @@ gsk_text_node_serialize_font (GskRenderNode *node,
g_free (s);
pango_font_description_free (desc);
g_print ("serializing ");
print_font (font);
info = g_hash_table_lookup (p->fonts, hb_font_get_face (pango_font_get_hb_font (font)));
if (info->serialized)
return;
-33
View File
@@ -489,9 +489,6 @@ gsk_transform_matrix_with_category (GskTransform *next,
*
* Multiplies @next with the given @matrix.
*
* This function consumes @next. Use [method@Gsk.Transform.ref] first
* if you want to keep it around.
*
* Returns: The new transform
**/
GskTransform *
@@ -646,9 +643,6 @@ static const GskTransformClass GSK_TRANSLATE_TRANSFORM_CLASS =
*
* Translates @next in 2-dimensional space by @point.
*
* This function consumes @next. Use [method@Gsk.Transform.ref] first
* if you want to keep it around.
*
* Returns: (nullable): The new transform
**/
GskTransform *
@@ -669,9 +663,6 @@ gsk_transform_translate (GskTransform *next,
*
* Translates @next by @point.
*
* This function consumes @next. Use [method@Gsk.Transform.ref] first
* if you want to keep it around.
*
* Returns: (nullable): The new transform
**/
GskTransform *
@@ -889,9 +880,6 @@ normalize_angle (float angle)
* Rotates @next @angle degrees in 2D - or in 3D-speak, around the Z axis.
* The rotation happens around the origin point of (0, 0).
*
* This function consumes @next. Use [method@Gsk.Transform.ref] first
* if you want to keep it around.
*
* Returns: (nullable): The new transform
*/
GskTransform *
@@ -1020,9 +1008,6 @@ static const GskTransformClass GSK_ROTATE3D_TRANSFORM_CLASS =
*
* For a rotation in 2D space, use [method@Gsk.Transform.rotate]
*
* This function consumes @next. Use [method@Gsk.Transform.ref] first
* if you want to keep it around.
*
* Returns: (nullable): The new transform
*/
GskTransform *
@@ -1199,9 +1184,6 @@ static const GskTransformClass GSK_SKEW_TRANSFORM_CLASS =
*
* Applies a skew transform.
*
* This function consumes @next. Use [method@Gsk.Transform.ref] first
* if you want to keep it around.
*
* Returns: (nullable): The new transform
*
* Since: 4.6
@@ -1374,9 +1356,6 @@ static const GskTransformClass GSK_SCALE_TRANSFORM_CLASS =
*
* Use [method@Gsk.Transform.scale_3d] to scale in all 3 dimensions.
*
* This function consumes @next. Use [method@Gsk.Transform.ref] first
* if you want to keep it around.
*
* Returns: (nullable): The new transform
**/
GskTransform *
@@ -1396,9 +1375,6 @@ gsk_transform_scale (GskTransform *next,
*
* Scales @next by the given factors.
*
* This function consumes @next. Use [method@Gsk.Transform.ref] first
* if you want to keep it around.
*
* Returns: (nullable): The new transform
**/
GskTransform *
@@ -1534,9 +1510,6 @@ static const GskTransformClass GSK_PERSPECTIVE_TRANSFORM_CLASS =
* those with negative Z values towards the origin. Points
* on the z=0 plane are unchanged.
*
* This function consumes @next. Use [method@Gsk.Transform.ref] first
* if you want to keep it around.
*
* Returns: The new transform
*/
GskTransform *
@@ -1946,9 +1919,6 @@ gsk_transform_to_translate (GskTransform *self,
*
* Applies all the operations from @other to @next.
*
* This function consumes @next. Use [method@Gsk.Transform.ref] first
* if you want to keep it around.
*
* Returns: (nullable): The new transform
*/
GskTransform *
@@ -1985,9 +1955,6 @@ gsk_transform_transform (GskTransform *next,
* between those cases, you should check @self is not %NULL
* before calling this function.
*
* This function consumes @self. Use [method@Gsk.Transform.ref] first
* if you want to keep it around.
*
* Returns: (nullable): The inverted transform
*/
GskTransform *
-2
View File
@@ -4,7 +4,6 @@ gsk_private_gl_shaders = [
'gl/resources/preamble.vs.glsl',
'gl/resources/border.glsl',
'gl/resources/blit.glsl',
'gl/resources/colorconvert.glsl',
'gl/resources/coloring.glsl',
'gl/resources/color.glsl',
'gl/resources/linear_gradient.glsl',
@@ -106,7 +105,6 @@ gsk_private_sources = files([
'gpu/gskgpushaderop.c',
'gpu/gskgpuscissorop.c',
'gpu/gskgpustraightalphaop.c',
'gpu/gskgpucolorconvertop.c',
'gpu/gskgputextureop.c',
'gpu/gskgpuuberop.c',
'gpu/gskgpuuploadop.c',
+16 -16
View File
@@ -4197,20 +4197,20 @@ gtk_tree_view_snapshot_grid_line (GtkTreeView *tree_view,
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 2, 1);
data = cairo_image_surface_get_data (surface);
/* just color the first pixel... */
data[0] = round (CLAMP (grid_line_color->blue, 0, 1) * 255);
data[1] = round (CLAMP (grid_line_color->green, 0, 1) * 255);
data[2] = round (CLAMP (grid_line_color->red, 0, 1) * 255);
data[3] = round (CLAMP (grid_line_color->alpha, 0, 1) * 255);
data[0] = round (grid_line_color->blue * 255);
data[1] = round (grid_line_color->green * 255);
data[2] = round (grid_line_color->red * 255);
data[3] = round (grid_line_color->alpha * 255);
priv->horizontal_grid_line_texture = gdk_texture_new_for_surface (surface);
cairo_surface_destroy (surface);
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 2);
data = cairo_image_surface_get_data (surface);
data[0] = round (CLAMP (grid_line_color->blue, 0, 1) * 255);
data[1] = round (CLAMP (grid_line_color->green, 0, 1) * 255);
data[2] = round (CLAMP (grid_line_color->red, 0, 1) * 255);
data[3] = round (CLAMP (grid_line_color->alpha, 0, 1) * 255);
data[0] = round (grid_line_color->blue * 255);
data[1] = round (grid_line_color->green * 255);
data[2] = round (grid_line_color->red * 255);
data[3] = round (grid_line_color->alpha * 255);
priv->vertical_grid_line_texture = gdk_texture_new_for_surface (surface);
cairo_surface_destroy (surface);
@@ -4272,20 +4272,20 @@ gtk_tree_view_snapshot_tree_line (GtkTreeView *tree_view,
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 2, 1);
data = cairo_image_surface_get_data (surface);
/* just color the first pixel... */
data[0] = round (CLAMP (tree_line_color->blue, 0, 1) * 255);
data[1] = round (CLAMP (tree_line_color->green, 0, 1) * 255);
data[2] = round (CLAMP (tree_line_color->red, 0, 1) * 255);
data[3] = round (CLAMP (tree_line_color->alpha, 0, 1) * 255);
data[0] = round (tree_line_color->blue * 255);
data[1] = round (tree_line_color->green * 255);
data[2] = round (tree_line_color->red * 255);
data[3] = round (tree_line_color->alpha * 255);
priv->horizontal_tree_line_texture = gdk_texture_new_for_surface (surface);
cairo_surface_destroy (surface);
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 2);
data = cairo_image_surface_get_data (surface);
data[0] = round (CLAMP (tree_line_color->blue, 0, 1) * 255);
data[1] = round (CLAMP (tree_line_color->green, 0, 1) * 255);
data[2] = round (CLAMP (tree_line_color->red, 0, 1) * 255);
data[3] = round (CLAMP (tree_line_color->alpha, 0, 1) * 255);
data[0] = round (tree_line_color->blue * 255);
data[1] = round (tree_line_color->green * 255);
data[2] = round (tree_line_color->red * 255);
data[3] = round (tree_line_color->alpha * 255);
priv->vertical_tree_line_texture = gdk_texture_new_for_surface (surface);
cairo_surface_destroy (surface);
+1 -62
View File
@@ -201,10 +201,6 @@ struct _GtkAboutDialog
guint hovering_over_link : 1;
guint wrap_license : 1;
guint in_child_changed : 1;
GSList *link_tags;
guint update_links_cb_id;
};
struct _GtkAboutDialogClass
@@ -710,52 +706,6 @@ update_credits_button_visibility (GtkAboutDialog *about)
update_stack_switcher_visibility (about);
}
static void
update_links_cb (GtkAboutDialog *about)
{
GtkCssStyle *style;
GdkRGBA link_color, visited_link_color;
GSList *l;
style = gtk_css_node_get_style (about->link_node);
link_color = *gtk_css_color_value_get_rgba (style->core->color);
style = gtk_css_node_get_style (about->visited_link_node);
visited_link_color = *gtk_css_color_value_get_rgba (style->core->color);
for (l = about->link_tags; l != NULL; l = l->next)
{
GtkTextTag *tag = l->data;
GdkRGBA color;
const char *uri = g_object_get_data (G_OBJECT (tag), "uri");
if (uri && g_ptr_array_find_with_equal_func (about->visited_links, uri, (GCompareFunc)strcmp, NULL))
color = visited_link_color;
else
color = link_color;
g_object_set (G_OBJECT (tag), "foreground-rgba", &color, NULL);
}
about->update_links_cb_id = 0;
}
static void
link_style_changed_cb (GtkCssNode *node,
GtkCssStyleChange *change,
GtkAboutDialog *about)
{
if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_REDRAW))
{
/* If we access the node right here, we'll end up with infinite recursion */
if (about->link_tags && !about->update_links_cb_id)
{
about->update_links_cb_id =
g_idle_add_once ((GSourceOnceFunc) update_links_cb, about);
}
}
}
static void
gtk_about_dialog_init (GtkAboutDialog *about)
{
@@ -798,16 +748,12 @@ gtk_about_dialog_init (GtkAboutDialog *about)
gtk_css_node_set_name (about->link_node, g_quark_from_static_string ("link"));
gtk_css_node_set_parent (about->link_node, node);
gtk_css_node_set_state (about->link_node, state | GTK_STATE_FLAG_LINK);
g_signal_connect (about->link_node, "style-changed",
G_CALLBACK (link_style_changed_cb), about);
g_object_unref (about->link_node);
about->visited_link_node = gtk_css_node_new ();
gtk_css_node_set_name (about->visited_link_node, g_quark_from_static_string ("link"));
gtk_css_node_set_parent (about->visited_link_node, node);
gtk_css_node_set_state (about->visited_link_node, state | GTK_STATE_FLAG_LINK);
g_signal_connect (about->visited_link_node, "style-changed",
G_CALLBACK (link_style_changed_cb), about);
gtk_css_node_set_state (about->visited_link_node, state | GTK_STATE_FLAG_VISITED);
g_object_unref (about->visited_link_node);
}
@@ -842,10 +788,6 @@ gtk_about_dialog_finalize (GObject *object)
g_slist_free_full (about->credit_sections, destroy_credit_section);
g_ptr_array_unref (about->visited_links);
g_slist_free (about->link_tags);
g_clear_handle_id (&about->update_links_cb_id, g_source_remove);
G_OBJECT_CLASS (gtk_about_dialog_parent_class)->finalize (object);
}
@@ -1968,9 +1910,6 @@ text_buffer_new (GtkAboutDialog *about,
"foreground-rgba", &color,
"underline", PANGO_UNDERLINE_SINGLE,
NULL);
about->link_tags = g_slist_prepend (about->link_tags, tag);
if (strcmp (link_type, "email") == 0)
{
char *escaped;
-206
View File
@@ -423,209 +423,3 @@ gtk_linear_srgb_to_rgb (float linear_red, float linear_green, float linear_bl
*green = apply_gamma (linear_green);
*blue = apply_gamma (linear_blue);
}
void
gtk_linear_srgb_to_xyz (float r, float g, float b,
float *x, float *y, float *z)
{
*x = (506752.0 / 1228815.0) * r + (87881.0 / 245763.0) * g + (12673.0 / 70218.0) * b;
*y = (87098.0 / 409605.0) * r + (175762.0 / 245763.0) * g + (12673.0 / 175545.0) * b;
*z = ( 7918.0 / 409605.0) * r + (87881.0 / 737289.0) * g + (1001167.0 / 1053270.0) * b;
}
void
gtk_xyz_to_linear_srgb (float x, float y, float z,
float *r, float *g, float *b)
{
*r = (12831.0 / 3959.0) * x - (329.0 / 214.0) * y - (1974.0 / 3959.0) * z;
*g = - (851781.0 / 878810.0) * x + (1648619.0 / 878810.0) * y + (36519.0 / 878810.0) * z;
*b = (705.0 / 12673.0) * x - (2585.0 / 12673.0) * y + (705.0 / 667.0) * z;
}
static void
gtk_lin_p3_to_xyz (float r, float g, float b,
float *x, float *y, float *z)
{
*x = (608311.0 / 1250200.0) * r + (189793.0 / 714400.0) * g + (198249.0 / 1000160.0) * b;
*y = (35783.0 / 156275.0) * r + (247089.0 / 357200.0) * g + (198249.0 / 2500400.0) * b;
*z = ( 0 / 1) * r + (32229.0 / 714400.0) * g + (5220557.0 / 5000800.0) * b;
}
static void
gtk_xyz_to_lin_p3 (float x, float y, float z,
float *r, float *g, float *b)
{
*r = (446124.0 / 178915.0) * x - (333277.0 / 357830.0) * y - (72051.0 / 178915.0) * z;
*g = - (14852.0 / 17905.0) * x + (63121.0 / 35810.0) * y + (423.0 / 17905.0) * z;
*b = (11844.0 / 330415.0) * x - (50337.0 / 660830.0) * y + (316169.0 / 330415.0) * z;
}
void gtk_rgb_to_p3 (float red, float green, float blue,
float *pr, float *pg, float *pb)
{
float r, g, b;
float x, y, z;
gtk_rgb_to_linear_srgb (red, green, blue, &r, &g, &b);
gtk_linear_srgb_to_xyz (r, g, b, &x, &y, &z);
gtk_xyz_to_lin_p3 (x, y, z, &r, &g, &b);
gtk_linear_srgb_to_rgb (r, g, b, pr, pg, pb);
}
void
gtk_p3_to_rgb (float pr, float pg, float pb,
float *red, float *green, float *blue)
{
float r, g, b;
float x, y, z;
gtk_rgb_to_linear_srgb (pr, pg, pb, &r, &g, &b);
gtk_lin_p3_to_xyz (r, g, b, &x, &y, &z);
gtk_xyz_to_linear_srgb (x, y, z, &r, &g, &b);
gtk_linear_srgb_to_rgb (r, g, b, red, green, blue);
}
static inline float
linearize_one (float val)
{
float alpha = 1.09929682680944 ;
float beta = 0.018053968510807;
int sign = val < 0 ? -1 : 1;
float abs = fabs (val);
if (abs < beta * 4.5 )
return val / 4.5;
else
return sign * powf ((abs + alpha - 1) / alpha, 1.0 / 0.45);
}
void
gtk_rec2020_to_rec2020_linear (float r, float g , float b,
float *rr, float *gg, float *bb)
{
*rr = linearize_one (r);
*gg = linearize_one (g);
*bb = linearize_one (b);
}
void
gtk_rec2020_linear_to_xyz (float r, float g, float b,
float *x, float *y, float *z)
{
*x = (63426534.0 / 99577255.0) * r + (20160776.0 / 139408157.0) * g + (47086771.0 / 278816314.0) * b;
*y = (26158966.0 / 99577255.0) * r + (472592308.0 / 697040785.0) * g + (8267143.0 / 139408157.0) * b;
*z = ( 0 / 1) * r + (19567812.0 / 697040785.0) * g + (295819943.0 / 278816314.0) * b;
}
void
gtk_rec2020_to_xyz (float r, float g, float b,
float *x, float *y, float *z)
{
gtk_rec2020_to_rec2020_linear (r, g, b, &r, &g, &b);
gtk_rec2020_linear_to_xyz (r, g, b, x, y, z);
}
static inline float
delinearize_one (float val)
{
float alpha = 1.09929682680944;
float beta = 0.018053968510807;
int sign = val < 0 ? -1 : 1;
float abs = fabsf (val);
if (abs > beta)
return sign * (alpha * powf (abs, 0.45) - (alpha - 1));
else
return 4.5 * val;
}
void
gtk_rec2020_linear_to_rec2020 (float r, float g, float b,
float *rr, float *gg, float *bb)
{
*rr = delinearize_one (r);
*gg = delinearize_one (g);
*bb = delinearize_one (b);
}
void
gtk_xyz_to_rec2020_linear (float x, float y, float z,
float *r, float *g, float *b)
{
*r = (30757411.0 / 17917100.0) * x - (6372589.0 / 17917100.0) * y - (4539589.0 / 17917100.0) * z;
*g = - (19765991.0 / 29648200.0) * x + (47925759.0 / 29648200.0) * y + (467509.0 / 29648200.0) *z;
*b = (792561.0 / 44930125.0) * x - (1921689.0 / 44930125.0) * y + (42328811.0 / 44930125.0) * z;
}
void
gtk_xyz_to_rec2020 (float x, float y, float z,
float *r, float *g, float *b)
{
gtk_xyz_to_rec2020_linear (x, y, z, r, g, b);
gtk_rec2020_linear_to_rec2020 (*r, *g, *b, r, g, b);
}
/* maps [0, 1] to [0, 70] */
static inline float
pq_to_linear (float v)
{
float ninv = (1 << 14) / 2610.0;
float minv = (1 << 5) / 2523.0;
float c1 = 3424.0 / (1 << 12);
float c2 = 2413.0 / (1 << 7);
float c3 = 2392.0 / (1 << 7);
float x = powf (MAX ((powf (v, minv) - c1), 0) / (c2 - (c3 * (powf (v, minv)))), ninv);
return x * 10000 / 203.0;
}
/* maps [0, 70] to [0, 1] */
void
gtk_rec2100_pq_to_rec2100_linear (float r, float g, float b,
float *rr, float *gg, float *bb)
{
*rr = pq_to_linear (r);
*gg = pq_to_linear (g);
*bb = pq_to_linear (b);
}
static inline float
linear_to_pq (float v)
{
float x = v * 203.0 / 10000.0;
float n = 2610.0 / (1 << 14);
float m = 2523.0 / (1 << 5);
float c1 = 3424.0 / (1 << 12);
float c2 = 2413.0 / (1 << 7);
float c3 = 2392.0 / (1 << 7);
return powf (((c1 + (c2 * powf (x, n))) / (1 + (c3 * powf (x, n)))), m);
}
void
gtk_rec2100_linear_to_rec2100_pq (float r, float g, float b,
float *rr, float *gg, float *bb)
{
*rr = linear_to_pq (r);
*gg = linear_to_pq (g);
*bb = linear_to_pq (b);
}
void
gtk_rec2100_linear_to_rec2020_linear (float r, float g, float b,
float *rr, float *gg, float *bb)
{
*rr = r;
*gg = g;
*bb = b;
}
void
gtk_rec2020_linear_to_rec2100_linear (float r, float g, float b,
float *rr, float *gg, float *bb)
{
*rr = r;
*gg = g;
*bb = b;
}
-34
View File
@@ -51,39 +51,5 @@ void gtk_rgb_to_linear_srgb (float red, float green, float blue
void gtk_linear_srgb_to_rgb (float linear_red, float linear_green, float linear_blue,
float *red, float *green, float *blue);
void gtk_rgb_to_p3 (float red, float green, float blue,
float *pr, float *pg, float *pb);
void gtk_p3_to_rgb (float pr, float pg, float pb,
float *red, float *green, float *blue);
void gtk_xyz_to_linear_srgb (float x, float y, float z,
float *r, float *g, float *b);
void gtk_linear_srgb_to_xyz (float r, float g, float b,
float *x, float *y, float *z);
void gtk_rec2020_to_xyz (float r, float g, float b,
float *x, float *y, float *z);
void gtk_xyz_to_rec2020 (float x, float y, float z,
float *r, float *g, float *b);
void gtk_rec2020_to_rec2020_linear (float r, float g , float b,
float *rr, float *gg, float *bb);
void gtk_rec2020_linear_to_rec2020 (float r, float g, float b,
float *rr, float *gg, float *bb);
void gtk_rec2020_linear_to_xyz (float r, float g, float b,
float *x, float *y, float *z);
void gtk_xyz_to_rec2020_linear (float x, float y, float z,
float *r, float *g, float *b);
void gtk_rec2100_pq_to_rec2100_linear (float r, float g, float b,
float *rr, float *gg, float *bb);
void gtk_rec2100_linear_to_rec2100_pq (float r, float g, float b,
float *rr, float *gg, float *bb);
void gtk_rec2100_linear_to_rec2020_linear (float r, float g, float b,
float *rr, float *gg, float *bb);
void gtk_rec2020_linear_to_rec2100_linear (float r, float g, float b,
float *rr, float *gg, float *bb);
G_END_DECLS
+5 -266
View File
@@ -35,10 +35,6 @@ gtk_css_color_init (GtkCssColor *color,
case GTK_CSS_COLOR_SPACE_SRGB:
case GTK_CSS_COLOR_SPACE_SRGB_LINEAR:
case GTK_CSS_COLOR_SPACE_OKLAB:
case GTK_CSS_COLOR_SPACE_DISPLAY_P3:
case GTK_CSS_COLOR_SPACE_XYZ:
case GTK_CSS_COLOR_SPACE_REC2020:
case GTK_CSS_COLOR_SPACE_REC2100_PQ:
break;
case GTK_CSS_COLOR_SPACE_HSL:
@@ -140,22 +136,6 @@ gtk_css_color_print (const GtkCssColor *color,
g_string_append (string, "oklch(");
break;
case GTK_CSS_COLOR_SPACE_DISPLAY_P3:
g_string_append (string, "color(display-p3 ");
break;
case GTK_CSS_COLOR_SPACE_XYZ:
g_string_append (string, "color(xyz ");
break;
case GTK_CSS_COLOR_SPACE_REC2020:
g_string_append (string, "color(rec2020 ");
break;
case GTK_CSS_COLOR_SPACE_REC2100_PQ:
g_string_append (string, "color(rec2100-pq ");
break;
default:
g_assert_not_reached ();
}
@@ -201,9 +181,6 @@ gtk_css_color_space_get_coord_name (GtkCssColorSpace color_space,
{
case GTK_CSS_COLOR_SPACE_SRGB:
case GTK_CSS_COLOR_SPACE_SRGB_LINEAR:
case GTK_CSS_COLOR_SPACE_DISPLAY_P3:
case GTK_CSS_COLOR_SPACE_REC2020:
case GTK_CSS_COLOR_SPACE_REC2100_PQ:
switch (coord)
{
case 0: return "r";
@@ -211,14 +188,6 @@ gtk_css_color_space_get_coord_name (GtkCssColorSpace color_space,
case 2: return "b";
default: g_assert_not_reached ();
}
case GTK_CSS_COLOR_SPACE_XYZ:
switch (coord)
{
case 0: return "x";
case 1: return "y";
case 2: return "z";
default: g_assert_not_reached ();
}
case GTK_CSS_COLOR_SPACE_HSL:
switch (coord)
{
@@ -256,64 +225,6 @@ gtk_css_color_space_get_coord_name (GtkCssColorSpace color_space,
}
}
void
gtk_css_color_space_get_coord_range (GtkCssColorSpace color_space,
gboolean legacy_rgb_scale,
guint coord,
float *lower,
float *upper)
{
if (coord == 3)
{
*lower = 0;
*upper = 1;
return;
}
switch (color_space)
{
case GTK_CSS_COLOR_SPACE_SRGB:
*lower = 0;
*upper = legacy_rgb_scale ? 255 : 1;
return;
case GTK_CSS_COLOR_SPACE_SRGB_LINEAR:
case GTK_CSS_COLOR_SPACE_DISPLAY_P3:
case GTK_CSS_COLOR_SPACE_XYZ:
case GTK_CSS_COLOR_SPACE_REC2020:
case GTK_CSS_COLOR_SPACE_REC2100_PQ:
*lower = 0;
*upper = 1;
return;
case GTK_CSS_COLOR_SPACE_HSL:
case GTK_CSS_COLOR_SPACE_HWB:
switch (coord)
{
case 0: *lower = *upper = NAN; return;
case 1:
case 2: *lower = 0; *upper = 100; return;
default: g_assert_not_reached ();
}
case GTK_CSS_COLOR_SPACE_OKLAB:
switch (coord)
{
case 0: *lower = 0; *upper = 1; return;
case 1:
case 2: *lower = -0.4; *upper = 0.4; return;
default: g_assert_not_reached ();
}
case GTK_CSS_COLOR_SPACE_OKLCH:
switch (coord)
{
case 0: *lower = 0; *upper = 1; return;
case 1: *lower = 0; *upper = 0.4; return;
case 2: *lower = *upper = NAN; return;
default: g_assert_not_reached ();
}
default:
g_assert_not_reached ();
}
}
static gboolean
color_space_is_polar (GtkCssColorSpace color_space)
{
@@ -322,17 +233,11 @@ color_space_is_polar (GtkCssColorSpace color_space)
case GTK_CSS_COLOR_SPACE_SRGB:
case GTK_CSS_COLOR_SPACE_SRGB_LINEAR:
case GTK_CSS_COLOR_SPACE_OKLAB:
case GTK_CSS_COLOR_SPACE_DISPLAY_P3:
case GTK_CSS_COLOR_SPACE_XYZ:
case GTK_CSS_COLOR_SPACE_REC2020:
case GTK_CSS_COLOR_SPACE_REC2100_PQ:
return FALSE;
case GTK_CSS_COLOR_SPACE_HSL:
case GTK_CSS_COLOR_SPACE_HWB:
case GTK_CSS_COLOR_SPACE_OKLCH:
return TRUE;
default:
g_assert_not_reached ();
}
@@ -352,10 +257,6 @@ convert_to_rectangular (GtkCssColor *output)
case GTK_CSS_COLOR_SPACE_SRGB:
case GTK_CSS_COLOR_SPACE_SRGB_LINEAR:
case GTK_CSS_COLOR_SPACE_OKLAB:
case GTK_CSS_COLOR_SPACE_DISPLAY_P3:
case GTK_CSS_COLOR_SPACE_XYZ:
case GTK_CSS_COLOR_SPACE_REC2020:
case GTK_CSS_COLOR_SPACE_REC2100_PQ:
break;
case GTK_CSS_COLOR_SPACE_HSL:
@@ -397,11 +298,7 @@ convert_to_linear (GtkCssColor *output)
g_assert (output->color_space == GTK_CSS_COLOR_SPACE_SRGB ||
output->color_space == GTK_CSS_COLOR_SPACE_SRGB_LINEAR ||
output->color_space == GTK_CSS_COLOR_SPACE_OKLAB ||
output->color_space == GTK_CSS_COLOR_SPACE_DISPLAY_P3 ||
output->color_space == GTK_CSS_COLOR_SPACE_XYZ ||
output->color_space == GTK_CSS_COLOR_SPACE_REC2020 ||
output->color_space == GTK_CSS_COLOR_SPACE_REC2100_PQ);
output->color_space == GTK_CSS_COLOR_SPACE_OKLAB);
if (output->color_space == GTK_CSS_COLOR_SPACE_SRGB)
{
@@ -412,52 +309,6 @@ convert_to_linear (GtkCssColor *output)
v[3] = output->values[3];
gtk_css_color_init (output, GTK_CSS_COLOR_SPACE_SRGB_LINEAR, v);
}
else if (output->color_space == GTK_CSS_COLOR_SPACE_DISPLAY_P3)
{
gtk_p3_to_rgb (output->values[0],
output->values[1],
output->values[2],
&v[0], &v[1], &v[2]);
gtk_rgb_to_linear_srgb (v[0], v[1], v[2],
&v[0], &v[1], &v[2]);
v[3] = output->values[3];
gtk_css_color_init (output, GTK_CSS_COLOR_SPACE_SRGB_LINEAR, v);
}
else if (output->color_space == GTK_CSS_COLOR_SPACE_XYZ)
{
gtk_xyz_to_linear_srgb (output->values[0],
output->values[1],
output->values[2],
&v[0], &v[1], &v[2]);
v[3] = output->values[3];
gtk_css_color_init (output, GTK_CSS_COLOR_SPACE_SRGB_LINEAR, v);
}
else if (output->color_space == GTK_CSS_COLOR_SPACE_REC2020)
{
gtk_rec2020_to_xyz (output->values[0],
output->values[1],
output->values[2],
&v[0], &v[1], &v[2]);
gtk_xyz_to_linear_srgb (v[0], v[1], v[2],
&v[0], &v[1], &v[2]);
v[3] = output->values[3];
gtk_css_color_init (output, GTK_CSS_COLOR_SPACE_SRGB_LINEAR, v);
}
else if (output->color_space == GTK_CSS_COLOR_SPACE_REC2100_PQ)
{
gtk_rec2100_pq_to_rec2100_linear (output->values[0],
output->values[1],
output->values[2],
&v[0], &v[1], &v[2]);
gtk_rec2100_linear_to_rec2020_linear (v[0], v[1], v[2],
&v[0], &v[1], &v[2]);
gtk_rec2020_linear_to_xyz (v[0], v[1], v[2],
&v[0], &v[1], &v[2]);
gtk_xyz_to_linear_srgb (v[0], v[1], v[2],
&v[0], &v[1], &v[2]);
v[3] = output->values[3];
gtk_css_color_init (output, GTK_CSS_COLOR_SPACE_SRGB_LINEAR, v);
}
}
static void
@@ -482,52 +333,6 @@ convert_from_linear (GtkCssColor *output,
gtk_css_color_init (output, GTK_CSS_COLOR_SPACE_SRGB, v);
break;
case GTK_CSS_COLOR_SPACE_DISPLAY_P3:
gtk_linear_srgb_to_rgb (output->values[0],
output->values[1],
output->values[2],
&v[0], &v[1], &v[2]);
gtk_rgb_to_p3 (v[0], v[1], v[2],
&v[0], &v[1], &v[2]);
v[3] = output->values[3];
gtk_css_color_init (output, GTK_CSS_COLOR_SPACE_DISPLAY_P3, v);
break;
case GTK_CSS_COLOR_SPACE_XYZ:
gtk_linear_srgb_to_xyz (output->values[0],
output->values[1],
output->values[2],
&v[0], &v[1], &v[2]);
v[3] = output->values[3];
gtk_css_color_init (output, GTK_CSS_COLOR_SPACE_XYZ, v);
break;
case GTK_CSS_COLOR_SPACE_REC2020:
gtk_linear_srgb_to_xyz (output->values[0],
output->values[1],
output->values[2],
&v[0], &v[1], &v[2]);
gtk_xyz_to_rec2020 (v[0], v[1], v[2],
&v[0], &v[1], &v[2]);
v[3] = output->values[3];
gtk_css_color_init (output, GTK_CSS_COLOR_SPACE_REC2020, v);
break;
case GTK_CSS_COLOR_SPACE_REC2100_PQ:
gtk_linear_srgb_to_xyz (output->values[0],
output->values[1],
output->values[2],
&v[0], &v[1], &v[2]);
gtk_xyz_to_rec2020_linear (v[0], v[1], v[2],
&v[0], &v[1], &v[2]);
gtk_rec2020_linear_to_rec2100_linear (v[0], v[1], v[2],
&v[0], &v[1], &v[2]);
gtk_rec2100_linear_to_rec2100_pq (v[0], v[1], v[2],
&v[0], &v[1], &v[2]);
v[3] = output->values[3];
gtk_css_color_init (output, GTK_CSS_COLOR_SPACE_REC2100_PQ, v);
break;
case GTK_CSS_COLOR_SPACE_SRGB_LINEAR:
case GTK_CSS_COLOR_SPACE_OKLAB:
case GTK_CSS_COLOR_SPACE_OKLCH:
@@ -549,10 +354,6 @@ convert_from_rectangular (GtkCssColor *output,
case GTK_CSS_COLOR_SPACE_SRGB:
case GTK_CSS_COLOR_SPACE_SRGB_LINEAR:
case GTK_CSS_COLOR_SPACE_OKLAB:
case GTK_CSS_COLOR_SPACE_DISPLAY_P3:
case GTK_CSS_COLOR_SPACE_XYZ:
case GTK_CSS_COLOR_SPACE_REC2020:
case GTK_CSS_COLOR_SPACE_REC2100_PQ:
g_assert (output->color_space == dest);
break;
@@ -719,10 +520,6 @@ apply_hue_interpolation (GtkCssColor *from,
case GTK_CSS_COLOR_SPACE_SRGB:
case GTK_CSS_COLOR_SPACE_SRGB_LINEAR:
case GTK_CSS_COLOR_SPACE_OKLAB:
case GTK_CSS_COLOR_SPACE_DISPLAY_P3:
case GTK_CSS_COLOR_SPACE_XYZ:
case GTK_CSS_COLOR_SPACE_REC2020:
case GTK_CSS_COLOR_SPACE_REC2100_PQ:
break;
case GTK_CSS_COLOR_SPACE_HSL:
@@ -755,10 +552,6 @@ normalize_hue (GtkCssColor *color)
case GTK_CSS_COLOR_SPACE_SRGB:
case GTK_CSS_COLOR_SPACE_SRGB_LINEAR:
case GTK_CSS_COLOR_SPACE_OKLAB:
case GTK_CSS_COLOR_SPACE_DISPLAY_P3:
case GTK_CSS_COLOR_SPACE_XYZ:
case GTK_CSS_COLOR_SPACE_REC2020:
case GTK_CSS_COLOR_SPACE_REC2100_PQ:
break;
case GTK_CSS_COLOR_SPACE_HSL:
@@ -796,10 +589,6 @@ premultiply (GtkCssColor *color)
case GTK_CSS_COLOR_SPACE_SRGB:
case GTK_CSS_COLOR_SPACE_SRGB_LINEAR:
case GTK_CSS_COLOR_SPACE_OKLAB:
case GTK_CSS_COLOR_SPACE_DISPLAY_P3:
case GTK_CSS_COLOR_SPACE_XYZ:
case GTK_CSS_COLOR_SPACE_REC2020:
case GTK_CSS_COLOR_SPACE_REC2100_PQ:
premultiply_component (color, 0);
premultiply_component (color, 1);
premultiply_component (color, 2);
@@ -842,10 +631,6 @@ unpremultiply (GtkCssColor *color)
case GTK_CSS_COLOR_SPACE_SRGB:
case GTK_CSS_COLOR_SPACE_SRGB_LINEAR:
case GTK_CSS_COLOR_SPACE_OKLAB:
case GTK_CSS_COLOR_SPACE_DISPLAY_P3:
case GTK_CSS_COLOR_SPACE_XYZ:
case GTK_CSS_COLOR_SPACE_REC2020:
case GTK_CSS_COLOR_SPACE_REC2100_PQ:
unpremultiply_component (color, 0);
unpremultiply_component (color, 1);
unpremultiply_component (color, 2);
@@ -882,10 +667,7 @@ collect_analogous_missing (const GtkCssColor *color,
{ -1, -1, -1, -1, -1, 0, -1, -1, 3 }, /* hwb */
{ -1, -1, -1, 0, -1, -1, 1, 2, 3 }, /* oklab */
{ -1, -1, -1, 0, 1, 2, -1, -1, 3 }, /* oklch */
{ 0, 1, 2, -1, -1, -1, -1, -1, 3 }, /* display-p3 */
{ 0, 1, 2, -1, -1, -1, -1, -1, 3 }, /* xyz */
{ 0, 1, 2, -1, -1, -1, -1, -1, 3 }, /* rec2020 */
{ 0, 1, 2, -1, -1, -1, -1, -1, 3 }, /* rec2100-pq */
};
int *src = analogous[color->color_space];
@@ -994,11 +776,6 @@ parse_hue_interpolation (GtkCssParser *parser,
gtk_css_parser_consume_token (parser);
*interp = GTK_CSS_HUE_INTERPOLATION_DECREASING;
}
else if (gtk_css_token_is_ident (token, "hue"))
{
gtk_css_parser_error_syntax (parser, "'hue' goes after the interpolation method");
return FALSE;
}
else
{
*interp = GTK_CSS_HUE_INTERPOLATION_SHORTER;
@@ -1014,12 +791,6 @@ parse_hue_interpolation (GtkCssParser *parser,
return TRUE;
}
gboolean
gtk_css_color_interpolation_method_can_parse (GtkCssParser *parser)
{
return gtk_css_token_is_ident (gtk_css_parser_get_token (parser), "in");
}
gboolean
gtk_css_color_interpolation_method_parse (GtkCssParser *parser,
GtkCssColorSpace *in,
@@ -1055,39 +826,19 @@ gtk_css_color_interpolation_method_parse (GtkCssParser *parser,
gtk_css_parser_consume_token (parser);
*in = GTK_CSS_COLOR_SPACE_HWB;
}
else if (gtk_css_token_is_ident (token, "oklab"))
{
gtk_css_parser_consume_token (parser);
*in = GTK_CSS_COLOR_SPACE_OKLAB;
}
else if (gtk_css_token_is_ident (token, "oklch"))
{
gtk_css_parser_consume_token (parser);
*in = GTK_CSS_COLOR_SPACE_OKLCH;
}
else if (gtk_css_token_is_ident (token, "display-p3"))
else if (gtk_css_token_is_ident (token, "oklab"))
{
gtk_css_parser_consume_token (parser);
*in = GTK_CSS_COLOR_SPACE_DISPLAY_P3;
}
else if (gtk_css_token_is_ident (token, "xyz"))
{
gtk_css_parser_consume_token (parser);
*in = GTK_CSS_COLOR_SPACE_XYZ;
}
else if (gtk_css_token_is_ident (token, "rec2020"))
{
gtk_css_parser_consume_token (parser);
*in = GTK_CSS_COLOR_SPACE_REC2020;
}
else if (gtk_css_token_is_ident (token, "rec2100-pq"))
{
gtk_css_parser_consume_token (parser);
*in = GTK_CSS_COLOR_SPACE_REC2100_PQ;
*in = GTK_CSS_COLOR_SPACE_OKLAB;
}
else
{
gtk_css_parser_error_syntax (parser, "Invalid color space: %s", gtk_css_token_to_string (token));
gtk_css_parser_error_syntax (parser, "Invalid color space");
return FALSE;
}
@@ -1125,18 +876,6 @@ gtk_css_color_interpolation_method_print (GtkCssColorSpace in,
case GTK_CSS_COLOR_SPACE_OKLAB:
g_string_append (string, "oklab");
break;
case GTK_CSS_COLOR_SPACE_DISPLAY_P3:
g_string_append (string, "display-p3");
break;
case GTK_CSS_COLOR_SPACE_XYZ:
g_string_append (string, "xyz");
break;
case GTK_CSS_COLOR_SPACE_REC2020:
g_string_append (string, "rec2020");
break;
case GTK_CSS_COLOR_SPACE_REC2100_PQ:
g_string_append (string, "rec2100-pq");
break;
default:
g_assert_not_reached ();
}
+16 -9
View File
@@ -21,10 +21,17 @@
#include <math.h>
#include "gtk/css/gtkcssparserprivate.h"
#include "gtkcsstypesprivate.h"
G_BEGIN_DECLS
typedef enum {
GTK_CSS_COLOR_SPACE_SRGB,
GTK_CSS_COLOR_SPACE_SRGB_LINEAR,
GTK_CSS_COLOR_SPACE_HSL,
GTK_CSS_COLOR_SPACE_HWB,
GTK_CSS_COLOR_SPACE_OKLAB,
GTK_CSS_COLOR_SPACE_OKLCH,
} GtkCssColorSpace;
typedef struct
{
@@ -89,6 +96,14 @@ void gtk_css_color_convert (const GtkCssColor *input,
GtkCssColorSpace dest,
GtkCssColor *output);
typedef enum
{
GTK_CSS_HUE_INTERPOLATION_SHORTER,
GTK_CSS_HUE_INTERPOLATION_LONGER,
GTK_CSS_HUE_INTERPOLATION_INCREASING,
GTK_CSS_HUE_INTERPOLATION_DECREASING,
} GtkCssHueInterpolation;
void gtk_css_color_interpolate (const GtkCssColor *from,
const GtkCssColor *to,
float progress,
@@ -99,14 +114,6 @@ void gtk_css_color_interpolate (const GtkCssColor *from,
const char * gtk_css_color_space_get_coord_name (GtkCssColorSpace color_space,
guint coord);
void gtk_css_color_space_get_coord_range (GtkCssColorSpace color_space,
gboolean legacy_rgb_scale,
guint coord,
float *lower,
float *upper);
gboolean gtk_css_color_interpolation_method_can_parse (GtkCssParser *parser);
gboolean gtk_css_color_interpolation_method_parse (GtkCssParser *parser,
GtkCssColorSpace *in,
GtkCssHueInterpolation *interp);
+138 -132
View File
@@ -46,6 +46,7 @@ typedef enum {
COLOR_TYPE_ALPHA,
COLOR_TYPE_MIX,
COLOR_TYPE_CURRENT_COLOR,
COLOR_TYPE_LIGHT_DARK,
} ColorType;
struct _GtkCssValue
@@ -90,6 +91,12 @@ struct _GtkCssValue
gboolean legacy_srgb;
GtkCssValue *values[1];
} relative;
struct
{
GtkCssValue *color1;
GtkCssValue *color2;
} light_dark;
};
};
@@ -129,7 +136,11 @@ gtk_css_value_color_free (GtkCssValue *color)
if (color->relative.values[i])
gtk_css_value_unref (color->relative.values[i]);
}
break;
case COLOR_TYPE_LIGHT_DARK:
gtk_css_value_unref (color->light_dark.color1);
gtk_css_value_unref (color->light_dark.color2);
break;
case COLOR_TYPE_COLOR:
@@ -270,6 +281,12 @@ gtk_css_value_color_equal (const GtkCssValue *value1,
case COLOR_TYPE_CURRENT_COLOR:
return TRUE;
case COLOR_TYPE_LIGHT_DARK:
return gtk_css_value_equal (value1->light_dark.color1,
value2->light_dark.color1) &&
gtk_css_value_equal (value1->light_dark.color2,
value2->light_dark.color2);
default:
g_assert_not_reached ();
return FALSE;
@@ -357,30 +374,6 @@ gtk_css_value_color_print (const GtkCssValue *value,
g_string_append (string, " srgb-linear");
break;
case GTK_CSS_COLOR_SPACE_DISPLAY_P3:
g_string_append (string, "color(from ");
gtk_css_value_print (value->relative.origin, string);
g_string_append (string, " display-p3");
break;
case GTK_CSS_COLOR_SPACE_XYZ:
g_string_append (string, "color(from ");
gtk_css_value_print (value->relative.origin, string);
g_string_append (string, " xyz");
break;
case GTK_CSS_COLOR_SPACE_REC2020:
g_string_append (string, "color(from ");
gtk_css_value_print (value->relative.origin, string);
g_string_append (string, " rec2020");
break;
case GTK_CSS_COLOR_SPACE_REC2100_PQ:
g_string_append (string, "color(from ");
gtk_css_value_print (value->relative.origin, string);
g_string_append (string, " rec2100-pq");
break;
case GTK_CSS_COLOR_SPACE_HSL:
g_string_append (string, "hsl(from ");
gtk_css_value_print (value->relative.origin, string);
@@ -518,6 +511,14 @@ gtk_css_value_color_print (const GtkCssValue *value,
g_string_append (string, "currentcolor");
break;
case COLOR_TYPE_LIGHT_DARK:
g_string_append (string, "light-dark(");
gtk_css_value_print (value->light_dark.color1, string);
g_string_append (string, ", ");
gtk_css_value_print (value->light_dark.color2, string);
g_string_append_c (string, ')');
break;
default:
g_assert_not_reached ();
}
@@ -617,49 +618,6 @@ apply_color_mix (GtkCssColorSpace in,
missing);
}
static GtkCssValue *
resolve_relative (GtkCssValue *values[4],
GtkCssColorSpace color_space,
gboolean legacy_rgb_scale)
{
float v[4];
gboolean m[4];
for (guint i = 0; i < 4; i++)
{
if (values[i])
{
float lower, upper;
gtk_css_color_space_get_coord_range (color_space, legacy_rgb_scale,
i, &lower, &upper);
m[i] = FALSE;
v[i] = gtk_css_number_value_get_canonical (values[i], upper - lower);
if (gtk_css_number_value_has_percent (values[i]))
v[i] += lower;
}
else
{
m[i] = TRUE;
v[i] = 0;
}
}
if (color_space == GTK_CSS_COLOR_SPACE_SRGB &&
legacy_rgb_scale)
{
v[0] /= 255.;
v[1] /= 255.;
v[2] /= 255.;
}
v[3] = CLAMP (v[3], 0, 1); /* clamp alpha */
return gtk_css_color_value_new_color (color_space, FALSE, v, m);
}
static GtkCssValue *
gtk_css_color_value_do_resolve (GtkCssValue *color,
guint property_id,
@@ -680,23 +638,39 @@ gtk_css_color_value_do_resolve (GtkCssValue *color,
case COLOR_TYPE_RELATIVE:
{
GtkCssValue *vals[4];
float v[4];
gboolean m[4];
for (guint i = 0; i < 4; i++)
{
if (color->relative.values[i])
vals[i] = gtk_css_value_compute (color->relative.values[i], property_id, context);
{
GtkCssValue *val;
m[i] = FALSE;
val = gtk_css_value_compute (color->relative.values[i], property_id, context);
v[i] = gtk_css_number_value_get_canonical (val, 1);
gtk_css_value_unref (val);
}
else
vals[i] = NULL;
{
m[i] = TRUE;
v[i] = 0;
}
}
value = resolve_relative (vals, color->relative.color_space, color->relative.legacy_srgb);
for (guint i = 0; i < 4; i++)
if (color->relative.color_space == GTK_CSS_COLOR_SPACE_SRGB &&
color->relative.legacy_srgb)
{
if (vals[i])
gtk_css_value_unref (vals[i]);
v[0] /= 255.;
v[1] /= 255.;
v[2] /= 255.;
}
v[3] = CLAMP (v[3], 0, 1); /* clamp alpha */
value = gtk_css_color_value_new_color (color->relative.color_space, FALSE, v, m);
}
break;
@@ -803,6 +777,30 @@ gtk_css_color_value_do_resolve (GtkCssValue *color,
value = gtk_css_value_ref (current);
break;
case COLOR_TYPE_LIGHT_DARK:
{
GtkSettings *settings = gtk_style_provider_get_settings (provider);
int color_scheme;
g_object_get (settings, "gtk-color-scheme", &color_scheme, NULL);
switch (color_scheme)
{
case GTK_COLOR_SCHEME_LIGHT:
value = gtk_css_color_value_do_resolve (color->light_dark.color1, property_id, context, current, cycle_list);
break;
case GTK_COLOR_SCHEME_DARK:
value = gtk_css_color_value_do_resolve (color->light_dark.color2, property_id, context, current, cycle_list);
break;
default:
g_assert_not_reached ();
}
}
break;
default:
value = NULL;
g_assert_not_reached ();
@@ -903,25 +901,6 @@ gtk_css_color_value_new_relative (GtkCssValue *origin,
GtkCssValue *values[4])
{
GtkCssValue *value;
gboolean computed = TRUE;
if (!gtk_css_value_is_computed (origin))
computed = FALSE;
if (!computed)
{
for (guint i = 0; i < 4; i++)
{
if (values[i] && !gtk_css_value_is_computed (values[i]))
{
computed = FALSE;
break;
}
}
}
if (computed)
return resolve_relative (values, color_space, legacy_srgb);
value = gtk_css_value_alloc (&GTK_CSS_VALUE_COLOR,
sizeof (GtkCssValue) + sizeof (GtkCssValue *) * 3);
@@ -1077,6 +1056,20 @@ gtk_css_color_value_new_current_color (void)
return gtk_css_value_ref (&current_color);
}
static GtkCssValue *
gtk_css_color_value_new_light_dark (GtkCssValue *color1,
GtkCssValue *color2)
{
GtkCssValue *value;
value = gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_COLOR);
value->type = COLOR_TYPE_LIGHT_DARK;
value->light_dark.color1 = gtk_css_value_ref (color1);
value->light_dark.color2 = gtk_css_value_ref (color2);
return value;
}
/* }}} */
/* {{{ Parsing */
@@ -1101,7 +1094,8 @@ gtk_css_color_value_can_parse (GtkCssParser *parser)
|| gtk_css_parser_has_function (parser, "oklab")
|| gtk_css_parser_has_function (parser, "oklch")
|| gtk_css_parser_has_function (parser, "color")
|| gtk_css_parser_has_function (parser, "color-mix");
|| gtk_css_parser_has_function (parser, "color-mix")
|| gtk_css_parser_has_function (parser, "light-dark");
}
typedef struct
@@ -1249,6 +1243,39 @@ parse_color_number (GtkCssParser *parser,
}
}
static guint
parse_color_color (GtkCssParser *parser,
guint arg,
gpointer data_)
{
ColorFunctionData *data = data_;
switch (arg)
{
case 0:
data->color = gtk_css_color_value_parse (parser);
if (data->color == NULL)
return 0;
return 1;
case 1:
data->color2 = gtk_css_color_value_parse (parser);
if (data->color2 == NULL)
return 0;
return 1;
default:
g_return_val_if_reached (0);
}
}
typedef struct
{
GdkRGBA *rgba;
gboolean use_percentages;
gboolean missing[4];
} ParseRGBAData;
typedef enum
{
COLOR_SYNTAX_DETECTING,
@@ -1502,11 +1529,7 @@ parse_ok_ab_value (GtkCssParser *parser,
if (data->values[idx] == NULL)
return FALSE;
data->v[idx] = gtk_css_number_value_get_canonical (data->values[idx], 0.8);
/* gtk_css_number_value_get_canonical() doesn't let us specify what 0% is */
if (gtk_css_number_value_has_percent (data->values[idx]))
data->v[idx] -= 0.4;
data->v[idx] = gtk_css_number_value_get_canonical (data->values[idx], 0.4);
}
return TRUE;
@@ -1651,8 +1674,6 @@ parse_color_color_channel (GtkCssParser *parser,
ParseData *data,
guint arg)
{
const GtkCssToken *token;
switch (arg)
{
case 0:
@@ -1668,35 +1689,7 @@ parse_color_color_channel (GtkCssParser *parser,
return 1;
}
if (gtk_css_parser_try_ident (parser, "display-p3"))
{
data->ctx.color_space = GTK_CSS_COLOR_SPACE_DISPLAY_P3;
return 1;
}
if (gtk_css_parser_try_ident (parser, "xyz"))
{
data->ctx.color_space = GTK_CSS_COLOR_SPACE_XYZ;
return 1;
}
if (gtk_css_parser_try_ident (parser, "rec2020"))
{
data->ctx.color_space = GTK_CSS_COLOR_SPACE_REC2020;
return 1;
}
if (gtk_css_parser_try_ident (parser, "rec2100-pq"))
{
data->ctx.color_space = GTK_CSS_COLOR_SPACE_REC2100_PQ;
return 1;
}
token = gtk_css_parser_get_token (parser);
gtk_css_parser_error_syntax (parser,
"Invalid color space in color(): %s",
gtk_css_token_to_string (token));
gtk_css_parser_error_syntax (parser, "Invalid color space in color()");
return 0;
case 1:
@@ -1743,7 +1736,6 @@ parse_color_function (GtkCssParser *self,
{
data->ctx.color = gtk_css_color_value_parse (self);
data->syntax = COLOR_SYNTAX_MODERN;
data->serialize_as_rgb = FALSE;
}
arg = 0;
@@ -2021,6 +2013,20 @@ gtk_css_color_value_parse (GtkCssParser *parser)
g_clear_pointer (&data.color1, gtk_css_value_unref);
g_clear_pointer (&data.color2, gtk_css_value_unref);
return value;
}
else if (gtk_css_parser_has_function (parser, "light-dark"))
{
ColorFunctionData data = { NULL, };
if (gtk_css_parser_consume_function (parser, 2, 2, parse_color_color, &data))
value = gtk_css_color_value_new_light_dark (data.color, data.color2);
else
value = NULL;
g_clear_pointer (&data.color, gtk_css_value_unref);
g_clear_pointer (&data.color2, gtk_css_value_unref);
return value;
}
else if (gtk_css_parser_has_function (parser, "lighter"))
+30 -71
View File
@@ -81,10 +81,7 @@ gtk_css_image_conic_snapshot (GtkCssImage *image,
last = i;
}
if (self->color_space != GTK_CSS_COLOR_SPACE_SRGB)
g_warning_once ("Gradient interpolation color spaces are not supported yet");
gtk_snapshot_append_conic_gradient (
gtk_snapshot_append_conic_gradient (
snapshot,
&GRAPHENE_RECT_INIT (0, 0, width, height),
&GRAPHENE_POINT_INIT (_gtk_css_position_value_get_x (self->center, width),
@@ -175,57 +172,37 @@ gtk_css_image_conic_parse_first_arg (GtkCssImageConic *self,
GtkCssParser *parser,
GArray *stop_array)
{
gboolean has_rotation = FALSE;
gboolean has_center = FALSE;
gboolean has_colorspace = FALSE;
int retval = 1;
gboolean nothing_parsed = TRUE;
do
if (gtk_css_parser_try_ident (parser, "from"))
{
if (!has_colorspace && gtk_css_color_interpolation_method_can_parse (parser))
{
if (!gtk_css_color_interpolation_method_parse (parser, &self->color_space, &self->hue_interp))
return 0;
has_colorspace = TRUE;
}
else if (!has_rotation && gtk_css_parser_try_ident (parser, "from"))
{
self->rotation = gtk_css_number_value_parse (parser, GTK_CSS_PARSE_ANGLE);
if (self->rotation == NULL)
return 0;
has_rotation = TRUE;
}
else if (!has_center && gtk_css_parser_try_ident (parser, "at"))
{
self->center = _gtk_css_position_value_parse (parser);
if (self->center == NULL)
return 0;
has_center = TRUE;
}
else if (gtk_css_token_is (gtk_css_parser_get_token (parser), GTK_CSS_TOKEN_COMMA))
{
retval = 1;
break;
}
else
{
if (gtk_css_image_conic_parse_color_stop (self, parser, stop_array))
{
retval = 2;
break;
}
}
self->rotation = gtk_css_number_value_parse (parser, GTK_CSS_PARSE_ANGLE);
if (self->rotation == NULL)
return 0;
nothing_parsed = FALSE;
}
else
{
self->rotation = gtk_css_number_value_new (0, GTK_CSS_DEG);
}
while (!(has_colorspace && has_rotation && has_center));
if (!has_rotation)
self->rotation = gtk_css_number_value_new (0, GTK_CSS_DEG);
if (gtk_css_parser_try_ident (parser, "at"))
{
self->center = _gtk_css_position_value_parse (parser);
if (self->center == NULL)
return 0;
nothing_parsed = FALSE;
}
else
{
self->center = _gtk_css_position_value_new (gtk_css_number_value_new (50, GTK_CSS_PERCENT),
gtk_css_number_value_new (50, GTK_CSS_PERCENT));
}
if (!has_center)
self->center = _gtk_css_position_value_new (gtk_css_number_value_new (50, GTK_CSS_PERCENT),
gtk_css_number_value_new (50, GTK_CSS_PERCENT));
if (!nothing_parsed)
return 1;
return retval;
return 1 + gtk_css_image_conic_parse_color_stop (self, parser, stop_array);
}
typedef struct
@@ -288,7 +265,7 @@ gtk_css_image_conic_print (GtkCssImage *image,
gboolean written = FALSE;
guint i;
g_string_append (string, "conic-gradient(");
g_string_append (string, "self-gradient(");
if (self->center)
{
@@ -297,7 +274,7 @@ gtk_css_image_conic_print (GtkCssImage *image,
if (!gtk_css_value_equal (self->center, compare))
{
g_string_append (string, "at ");
g_string_append (string, "from ");
gtk_css_value_print (self->center, string);
written = TRUE;
}
@@ -309,19 +286,8 @@ gtk_css_image_conic_print (GtkCssImage *image,
{
if (written)
g_string_append_c (string, ' ');
g_string_append (string, "from ");
g_string_append (string, "at ");
gtk_css_value_print (self->rotation, string);
written = TRUE;
}
if (self->color_space != GTK_CSS_COLOR_SPACE_SRGB)
{
if (written)
g_string_append_c (string, ' ');
gtk_css_color_interpolation_method_print (self->color_space,
self->hue_interp,
string);
written = TRUE;
}
if (written)
@@ -359,8 +325,6 @@ gtk_css_image_conic_compute (GtkCssImage *image,
copy->center = gtk_css_value_compute (self->center, property_id, context);
copy->rotation = gtk_css_value_compute (self->rotation, property_id, context);
copy->color_space = self->color_space;
copy->hue_interp = self->hue_interp;
copy->n_stops = self->n_stops;
copy->color_stops = g_malloc (sizeof (GtkCssImageConicColorStop) * copy->n_stops);
@@ -416,9 +380,6 @@ gtk_css_image_conic_transition (GtkCssImage *start_image,
if (result->rotation == NULL)
goto fail;
result->color_space = start->color_space;
result->hue_interp = start->hue_interp;
result->color_stops = g_malloc (sizeof (GtkCssImageConicColorStop) * start->n_stops);
result->n_stops = 0;
for (i = 0; i < start->n_stops; i++)
@@ -474,9 +435,7 @@ gtk_css_image_conic_equal (GtkCssImage *image1,
guint i;
if (!gtk_css_value_equal (conic1->center, conic2->center) ||
!gtk_css_value_equal (conic1->rotation, conic2->rotation) ||
conic1->color_space != conic2->color_space ||
conic1->hue_interp != conic2->hue_interp)
!gtk_css_value_equal (conic1->rotation, conic2->rotation))
return FALSE;
for (i = 0; i < conic1->n_stops; i++)
-3
View File
@@ -47,9 +47,6 @@ struct _GtkCssImageConic
GtkCssValue *center;
GtkCssValue *rotation;
GtkCssColorSpace color_space;
GtkCssHueInterpolation hue_interp;
guint n_stops;
GtkCssImageConicColorStop *color_stops;
};
+56 -109
View File
@@ -244,9 +244,6 @@ gtk_css_image_linear_snapshot (GtkCssImage *image,
last = i;
}
if (linear->color_space != GTK_CSS_COLOR_SPACE_SRGB)
g_warning_once ("Gradient interpolation color spaces are not supported yet");
if (linear->repeating)
{
gtk_snapshot_append_repeating_linear_gradient (
@@ -307,102 +304,75 @@ gtk_css_image_linear_parse_first_arg (GtkCssImageLinear *linear,
GArray *stop_array)
{
guint i;
gboolean has_colorspace = FALSE;
gboolean has_side_or_angle = FALSE;
guint retval = 1;
do
if (gtk_css_parser_try_ident (parser, "to"))
{
if (!has_colorspace &&gtk_css_color_interpolation_method_can_parse (parser))
for (i = 0; i < 2; i++)
{
if (!gtk_css_color_interpolation_method_parse (parser, &linear->color_space, &linear->hue_interp))
return 0;
has_colorspace = TRUE;
}
else if (!has_side_or_angle && gtk_css_parser_try_ident (parser, "to"))
{
gtk_css_parser_consume_token (parser);
for (i = 0; i < 2; i++)
if (gtk_css_parser_try_ident (parser, "left"))
{
if (gtk_css_parser_try_ident (parser, "left"))
if (linear->side & ((1 << GTK_CSS_LEFT) | (1 << GTK_CSS_RIGHT)))
{
if (linear->side & ((1 << GTK_CSS_LEFT) | (1 << GTK_CSS_RIGHT)))
{
gtk_css_parser_error_syntax (parser, "Expected 'top', 'bottom' or comma");
return 0;
}
linear->side |= (1 << GTK_CSS_LEFT);
gtk_css_parser_error_syntax (parser, "Expected 'top', 'bottom' or comma");
return 0;
}
else if (gtk_css_parser_try_ident (parser, "right"))
{
if (linear->side & ((1 << GTK_CSS_LEFT) | (1 << GTK_CSS_RIGHT)))
{
gtk_css_parser_error_syntax (parser, "Expected 'top', 'bottom' or comma");
return 0;
}
linear->side |= (1 << GTK_CSS_RIGHT);
}
else if (gtk_css_parser_try_ident (parser, "top"))
{
if (linear->side & ((1 << GTK_CSS_TOP) | (1 << GTK_CSS_BOTTOM)))
{
gtk_css_parser_error_syntax (parser, "Expected 'left', 'right' or comma");
return 0;
}
linear->side |= (1 << GTK_CSS_TOP);
}
else if (gtk_css_parser_try_ident (parser, "bottom"))
{
if (linear->side & ((1 << GTK_CSS_TOP) | (1 << GTK_CSS_BOTTOM)))
{
gtk_css_parser_error_syntax (parser, "Expected 'left', 'right' or comma");
return 0;
}
linear->side |= (1 << GTK_CSS_BOTTOM);
}
else
break;
linear->side |= (1 << GTK_CSS_LEFT);
}
if (linear->side == 0)
else if (gtk_css_parser_try_ident (parser, "right"))
{
gtk_css_parser_error_syntax (parser, "Expected side that gradient should go to");
return 0;
if (linear->side & ((1 << GTK_CSS_LEFT) | (1 << GTK_CSS_RIGHT)))
{
gtk_css_parser_error_syntax (parser, "Expected 'top', 'bottom' or comma");
return 0;
}
linear->side |= (1 << GTK_CSS_RIGHT);
}
has_side_or_angle = TRUE;
}
else if (!has_side_or_angle && gtk_css_number_value_can_parse (parser))
{
linear->angle = gtk_css_number_value_parse (parser, GTK_CSS_PARSE_ANGLE);
if (linear->angle == NULL)
return 0;
has_side_or_angle = TRUE;
}
else if (gtk_css_token_is (gtk_css_parser_get_token (parser), GTK_CSS_TOKEN_COMMA))
{
retval = 1;
break;
}
else
{
if (gtk_css_image_linear_parse_color_stop (linear, parser, stop_array))
else if (gtk_css_parser_try_ident (parser, "top"))
{
retval = 2;
break;
if (linear->side & ((1 << GTK_CSS_TOP) | (1 << GTK_CSS_BOTTOM)))
{
gtk_css_parser_error_syntax (parser, "Expected 'left', 'right' or comma");
return 0;
}
linear->side |= (1 << GTK_CSS_TOP);
}
else if (gtk_css_parser_try_ident (parser, "bottom"))
{
if (linear->side & ((1 << GTK_CSS_TOP) | (1 << GTK_CSS_BOTTOM)))
{
gtk_css_parser_error_syntax (parser, "Expected 'left', 'right' or comma");
return 0;
}
linear->side |= (1 << GTK_CSS_BOTTOM);
}
else
break;
}
if (linear->side == 0)
{
gtk_css_parser_error_syntax (parser, "Expected side that gradient should go to");
return 0;
}
return 1;
}
while (!(has_colorspace && has_side_or_angle));
else if (gtk_css_number_value_can_parse (parser))
{
linear->angle = gtk_css_number_value_parse (parser, GTK_CSS_PARSE_ANGLE);
if (linear->angle == NULL)
return 0;
if (linear->angle == NULL && linear->side == 0)
linear->side = (1 << GTK_CSS_BOTTOM);
return 1;
}
else
{
linear->side = 1 << GTK_CSS_BOTTOM;
if (!gtk_css_image_linear_parse_color_stop (linear, parser, stop_array))
return 0;
return retval;
return 2;
}
}
typedef struct
@@ -467,7 +437,6 @@ gtk_css_image_linear_print (GtkCssImage *image,
{
GtkCssImageLinear *linear = GTK_CSS_IMAGE_LINEAR (image);
guint i;
gboolean has_printed = FALSE;
if (linear->repeating)
g_string_append (string, "repeating-linear-gradient(");
@@ -490,29 +459,15 @@ gtk_css_image_linear_print (GtkCssImage *image,
else if (linear->side & (1 << GTK_CSS_RIGHT))
g_string_append (string, " right");
has_printed = TRUE;
g_string_append (string, ", ");
}
}
else
{
gtk_css_value_print (linear->angle, string);
has_printed = TRUE;
g_string_append (string, ", ");
}
if (linear->color_space != GTK_CSS_COLOR_SPACE_SRGB)
{
if (has_printed)
g_string_append_c (string, ' ');
gtk_css_color_interpolation_method_print (linear->color_space,
linear->hue_interp,
string);
has_printed = TRUE;
}
if (has_printed)
g_string_append (string, ", ");
for (i = 0; i < linear->n_stops; i++)
{
const GtkCssImageLinearColorStop *stop = &linear->color_stops[i];
@@ -544,8 +499,6 @@ gtk_css_image_linear_compute (GtkCssImage *image,
copy = g_object_new (GTK_TYPE_CSS_IMAGE_LINEAR, NULL);
copy->repeating = linear->repeating;
copy->side = linear->side;
copy->color_space = linear->color_space;
copy->hue_interp = linear->hue_interp;
if (linear->angle)
copy->angle = gtk_css_value_compute (linear->angle, property_id, context);
@@ -592,15 +545,11 @@ gtk_css_image_linear_transition (GtkCssImage *start_image,
end = GTK_CSS_IMAGE_LINEAR (end_image);
if ((start->repeating != end->repeating)
|| (start->n_stops != end->n_stops)
|| (start->color_space != end->color_space)
|| (start->hue_interp != end->hue_interp))
|| (start->n_stops != end->n_stops))
return GTK_CSS_IMAGE_CLASS (_gtk_css_image_linear_parent_class)->transition (start_image, end_image, property_id, progress);
result = g_object_new (GTK_TYPE_CSS_IMAGE_LINEAR, NULL);
result->repeating = start->repeating;
result->color_space = start->color_space;
result->hue_interp = start->hue_interp;
if (start->side != end->side)
goto fail;
@@ -669,9 +618,7 @@ gtk_css_image_linear_equal (GtkCssImage *image1,
if (linear1->repeating != linear2->repeating ||
linear1->side != linear2->side ||
(linear1->side == 0 && !gtk_css_value_equal (linear1->angle, linear2->angle)) ||
linear1->n_stops != linear2->n_stops ||
linear1->color_space != linear2->color_space ||
linear1->hue_interp != linear2->hue_interp)
linear1->n_stops != linear2->n_stops)
return FALSE;
for (i = 0; i < linear1->n_stops; i++)
-3
View File
@@ -48,9 +48,6 @@ struct _GtkCssImageLinear
guint repeating :1;
GtkCssValue *angle;
GtkCssColorSpace color_space;
GtkCssHueInterpolation hue_interp;
guint n_stops;
GtkCssImageLinearColorStop *color_stops;
};
+3 -27
View File
@@ -194,9 +194,6 @@ gtk_css_image_radial_snapshot (GtkCssImage *image,
last = i;
}
if (radial->color_space != GTK_CSS_COLOR_SPACE_SRGB)
g_warning_once ("Gradient interpolation color spaces are not supported yet");
if (radial->repeating)
gtk_snapshot_append_repeating_radial_gradient (snapshot,
&GRAPHENE_RECT_INIT (0, 0, width, height),
@@ -258,7 +255,6 @@ gtk_css_image_radial_parse_first_arg (GtkCssImageRadial *radial,
{
gboolean has_shape = FALSE;
gboolean has_size = FALSE;
gboolean has_colorspace = FALSE;
gboolean found_one = FALSE;
guint i;
static struct {
@@ -274,13 +270,7 @@ gtk_css_image_radial_parse_first_arg (GtkCssImageRadial *radial,
found_one = FALSE;
do {
if (!has_colorspace && gtk_css_color_interpolation_method_can_parse (parser))
{
if (!gtk_css_color_interpolation_method_parse (parser, &radial->color_space, &radial->hue_interp))
return 0;
has_colorspace = TRUE;
}
else if (!has_shape && gtk_css_parser_try_ident (parser, "circle"))
if (!has_shape && gtk_css_parser_try_ident (parser, "circle"))
{
radial->circle = TRUE;
found_one = has_shape = TRUE;
@@ -477,14 +467,6 @@ gtk_css_image_radial_print (GtkCssImage *image,
g_string_append (string, " at ");
gtk_css_value_print (radial->position, string);
if (radial->color_space != GTK_CSS_COLOR_SPACE_SRGB)
{
g_string_append_c (string, ' ');
gtk_css_color_interpolation_method_print (radial->color_space,
radial->hue_interp,
string);
}
g_string_append (string, ", ");
for (i = 0; i < radial->n_stops; i++)
@@ -519,8 +501,6 @@ gtk_css_image_radial_compute (GtkCssImage *image,
copy->repeating = radial->repeating;
copy->circle = radial->circle;
copy->size = radial->size;
copy->color_space = radial->color_space;
copy->hue_interp = radial->hue_interp;
copy->position = gtk_css_value_compute (radial->position, property_id, context);
@@ -574,9 +554,7 @@ gtk_css_image_radial_transition (GtkCssImage *start_image,
if (start->repeating != end->repeating ||
start->n_stops != end->n_stops ||
start->size != end->size ||
start->circle != end->circle ||
start->color_space != end->color_space ||
start->hue_interp != end->hue_interp)
start->circle != end->circle)
return GTK_CSS_IMAGE_CLASS (_gtk_css_image_radial_parent_class)->transition (start_image, end_image, property_id, progress);
result = g_object_new (GTK_TYPE_CSS_IMAGE_RADIAL, NULL);
@@ -667,9 +645,7 @@ gtk_css_image_radial_equal (GtkCssImage *image1,
(radial1->sizes[0] && radial2->sizes[0] && !gtk_css_value_equal (radial1->sizes[0], radial2->sizes[0])) ||
((radial1->sizes[1] == NULL) != (radial2->sizes[1] == NULL)) ||
(radial1->sizes[1] && radial2->sizes[1] && !gtk_css_value_equal (radial1->sizes[1], radial2->sizes[1])) ||
radial1->n_stops != radial2->n_stops ||
radial1->color_space != radial2->color_space ||
radial1->hue_interp != radial2->hue_interp)
radial1->n_stops != radial2->n_stops)
return FALSE;
for (i = 0; i < radial1->n_stops; i++)
-5
View File
@@ -54,13 +54,8 @@ struct _GtkCssImageRadial
GtkCssValue *position;
GtkCssValue *sizes[2];
GtkCssColorSpace color_space;
GtkCssHueInterpolation hue_interp;
guint n_stops;
GtkCssImageRadialColorStop *color_stops;
GtkCssRadialSize size;
guint circle : 1;
guint repeating :1;
+2 -3
View File
@@ -240,10 +240,9 @@ parse_css_direction (GtkCssStyleProperty *property,
static GtkCssValue *
opacity_parse (GtkCssStyleProperty *property,
GtkCssParser *parser)
GtkCssParser *parser)
{
return gtk_css_number_value_parse (parser, GTK_CSS_PARSE_NUMBER
| GTK_CSS_PARSE_PERCENT);
return gtk_css_number_value_parse (parser, GTK_CSS_PARSE_NUMBER);
}
static GtkCssValue *
+1 -22
View File
@@ -573,26 +573,5 @@ gtk_css_hash_id (GQuark id)
return id * 11;
}
typedef enum {
GTK_CSS_COLOR_SPACE_SRGB,
GTK_CSS_COLOR_SPACE_SRGB_LINEAR,
GTK_CSS_COLOR_SPACE_HSL,
GTK_CSS_COLOR_SPACE_HWB,
GTK_CSS_COLOR_SPACE_OKLAB,
GTK_CSS_COLOR_SPACE_OKLCH,
GTK_CSS_COLOR_SPACE_DISPLAY_P3,
GTK_CSS_COLOR_SPACE_XYZ,
GTK_CSS_COLOR_SPACE_REC2020,
GTK_CSS_COLOR_SPACE_REC2100_PQ,
} GtkCssColorSpace;
typedef enum
{
GTK_CSS_HUE_INTERPOLATION_SHORTER,
GTK_CSS_HUE_INTERPOLATION_LONGER,
GTK_CSS_HUE_INTERPOLATION_INCREASING,
GTK_CSS_HUE_INTERPOLATION_DECREASING,
} GtkCssHueInterpolation;
G_END_DECLS
+1 -1
View File
@@ -47,7 +47,7 @@
* and is destroyed when the drag ends.
*
* To set up a drag icon and associate it with an ongoing drag operation,
* use [ctor@Gtk.DragIcon.get_for_drag] to get the icon for a drag. You can
* use [func@Gtk.DragIcon.get_for_drag] to get the icon for a drag. You can
* then use it like any other widget and use [method@Gtk.DragIcon.set_child]
* to set whatever widget should be used for the drag icon.
*
+20 -1
View File
@@ -1245,7 +1245,8 @@ typedef enum {
GTK_SYSTEM_SETTING_FONT_NAME,
GTK_SYSTEM_SETTING_FONT_CONFIG,
GTK_SYSTEM_SETTING_DISPLAY,
GTK_SYSTEM_SETTING_ICON_THEME
GTK_SYSTEM_SETTING_ICON_THEME,
GTK_SYSTEM_SETTING_COLOR_SCHEME,
} GtkSystemSetting;
/**
@@ -1880,4 +1881,22 @@ typedef enum {
GTK_FONT_RENDERING_MANUAL,
} GtkFontRendering;
/**
* GtkColorScheme:
* @GTK_COLOR_SCHEME_LIGHT: A light color scheme is used
* @GTK_COLOR_SCHEME_DARK: A dark color scheme is used
*
* Values for the [property@Gtk.Settings:gtk-color-scheme] property
* that indicate what color scheme is used.
*
* This information can be used inside CSS to select appropriate colors
* with the light-dark() function.
*
* Since: 4.16
*/
typedef enum {
GTK_COLOR_SCHEME_LIGHT,
GTK_COLOR_SCHEME_DARK
} GtkColorScheme;
G_END_DECLS
+3 -41
View File
@@ -840,24 +840,13 @@ gtk_label_update_layout_attributes (GtkLabel *self,
}
link_color = gtk_css_color_value_get_rgba (style->core->color);
attr = pango_attr_foreground_new (CLAMP (link_color->red * 65535. + 0.5, 0, 65535),
CLAMP (link_color->green * 65535. + 0.5, 0, 65535),
CLAMP (link_color->blue * 65535. + 0.5, 0, 65535));
attr = pango_attr_foreground_new (link_color->red * 65535,
link_color->green * 65535,
link_color->blue * 65535);
attr->start_index = link->start;
attr->end_index = link->end;
pango_attr_list_insert (attrs, attr);
if (link_color->alpha < 0.999)
{
attr = pango_attr_foreground_alpha_new (CLAMP (link_color->alpha * 65535. + 0.5, 0, 65535));
attr->start_index = link->start;
attr->end_index = link->end;
pango_attr_list_insert (attrs, attr);
}
pango_attr_list_unref (link_attrs);
}
}
@@ -3434,29 +3423,6 @@ finish_text (UriParserData *pdata)
}
}
static void
link_style_changed_cb (GtkCssNode *node,
GtkCssStyleChange *change,
GtkLabel *self)
{
if (gtk_css_style_change_affects (change,
GTK_CSS_AFFECTS_CONTENT |
GTK_CSS_AFFECTS_TEXT_ATTRS))
{
gtk_label_ensure_layout (self);
gtk_widget_queue_draw (GTK_WIDGET (self));
}
}
static void
selection_style_changed_cb (GtkCssNode *node,
GtkCssStyleChange *change,
GtkLabel *self)
{
if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_REDRAW))
gtk_widget_queue_draw (GTK_WIDGET (self));
}
static void
start_element_handler (GMarkupParseContext *context,
const char *element_name,
@@ -3545,7 +3511,6 @@ start_element_handler (GMarkupParseContext *context,
gtk_css_node_set_parent (link.cssnode, widget_node);
if (class)
gtk_css_node_add_class (link.cssnode, g_quark_from_string (class));
g_signal_connect (link.cssnode, "style-changed", G_CALLBACK (link_style_changed_cb), self);
state = gtk_css_node_get_state (widget_node);
if (visited)
@@ -5164,8 +5129,6 @@ gtk_label_select_region_index (GtkLabel *self,
gtk_css_node_set_name (self->select_info->selection_node, g_quark_from_static_string ("selection"));
gtk_css_node_set_parent (self->select_info->selection_node, widget_node);
gtk_css_node_set_state (self->select_info->selection_node, gtk_css_node_get_state (widget_node));
g_signal_connect (self->select_info->selection_node, "style-changed",
G_CALLBACK (selection_style_changed_cb), self);
g_object_unref (self->select_info->selection_node);
}
}
@@ -6314,4 +6277,3 @@ gtk_label_accessible_text_init (GtkAccessibleTextInterface *iface)
/* }}} */
/* vim:set foldmethod=marker expandtab: */
+21
View File
@@ -203,6 +203,7 @@ enum {
PROP_KEYNAV_USE_CARET,
PROP_OVERLAY_SCROLLING,
PROP_FONT_RENDERING,
PROP_COLOR_SCHEME,
NUM_PROPERTIES
};
@@ -977,6 +978,24 @@ gtk_settings_class_init (GtkSettingsClass *class)
GTK_FONT_RENDERING_AUTOMATIC,
GTK_PARAM_READWRITE);
/**
* GtkSettings:gtk-color-scheme:
*
* The used color scheme.
*
* GTK can not determine this on its own and relies on application or
* platform libraries to set this property appropriately.
*
* The used color scheme can affect color selection inside CSS with
* the light-dark() function.
*
* Since: 4.16
*/
pspecs[PROP_COLOR_SCHEME] = g_param_spec_enum ("gtk-color-scheme", NULL, NULL,
GTK_TYPE_COLOR_SCHEME,
GTK_COLOR_SCHEME_LIGHT,
GTK_PARAM_READWRITE);
g_object_class_install_properties (gobject_class, NUM_PROPERTIES, pspecs);
}
@@ -1292,6 +1311,8 @@ gtk_settings_notify (GObject *object,
case PROP_CURSOR_THEME_SIZE:
settings_update_cursor_theme (settings);
break;
case PROP_COLOR_SCHEME:
gtk_system_setting_changed (settings->display, GTK_SYSTEM_SETTING_COLOR_SCHEME);
default:
break;
}
-11
View File
@@ -3858,15 +3858,6 @@ get_better_cursor_x (GtkText *self,
return (direction == priv->resolved_dir) ? strong_pos.x / PANGO_SCALE : weak_pos.x / PANGO_SCALE;
}
static void
selection_style_changed_cb (GtkCssNode *node,
GtkCssStyleChange *change,
GtkText *self)
{
if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_REDRAW))
gtk_widget_queue_draw (GTK_WIDGET (self));
}
static void
gtk_text_move_cursor (GtkText *self,
GtkMovementStep step,
@@ -4519,8 +4510,6 @@ gtk_text_set_positions (GtkText *self,
gtk_css_node_set_name (priv->selection_node, g_quark_from_static_string ("selection"));
gtk_css_node_set_parent (priv->selection_node, widget_node);
gtk_css_node_set_state (priv->selection_node, gtk_css_node_get_state (widget_node));
g_signal_connect (priv->selection_node, "style-changed",
G_CALLBACK (selection_style_changed_cb), self);
g_object_unref (priv->selection_node);
}
}
+5 -22
View File
@@ -1407,16 +1407,6 @@ gtk_text_attr_appearance_compare (const PangoAttribute *attr1,
overline_equal (appearance1, appearance2);
}
static inline GdkRGBA *
clamp_rgba (GdkRGBA *rgba)
{
rgba->red = CLAMP (rgba->red, 0, 1);
rgba->green = CLAMP (rgba->green, 0, 1);
rgba->blue = CLAMP (rgba->blue, 0, 1);
rgba->alpha = CLAMP (rgba->alpha, 0, 1);
return rgba;
}
/*
* gtk_text_attr_appearance_new:
* @desc:
@@ -1449,19 +1439,19 @@ gtk_text_attr_appearance_new (const GtkTextAppearance *appearance)
result->appearance = *appearance;
if (appearance->fg_rgba)
result->appearance.fg_rgba = clamp_rgba (gdk_rgba_copy (appearance->fg_rgba));
result->appearance.fg_rgba = gdk_rgba_copy (appearance->fg_rgba);
if (appearance->bg_rgba)
result->appearance.bg_rgba = clamp_rgba (gdk_rgba_copy (appearance->bg_rgba));
result->appearance.bg_rgba = gdk_rgba_copy (appearance->bg_rgba);
if (appearance->underline_rgba)
result->appearance.underline_rgba = clamp_rgba (gdk_rgba_copy (appearance->underline_rgba));
result->appearance.underline_rgba = gdk_rgba_copy (appearance->underline_rgba);
if (appearance->overline_rgba)
result->appearance.overline_rgba = clamp_rgba (gdk_rgba_copy (appearance->overline_rgba));
result->appearance.overline_rgba = gdk_rgba_copy (appearance->overline_rgba);
if (appearance->strikethrough_rgba)
result->appearance.strikethrough_rgba = clamp_rgba (gdk_rgba_copy (appearance->strikethrough_rgba));
result->appearance.strikethrough_rgba = gdk_rgba_copy (appearance->strikethrough_rgba);
return (PangoAttribute *)result;
}
@@ -4100,7 +4090,6 @@ gtk_text_layout_snapshot (GtkTextLayout *layout,
GtkWidget *widget,
GtkSnapshot *snapshot,
const GdkRectangle *clip,
gboolean selection_style_changed,
float cursor_alpha)
{
GtkTextLayoutPrivate *priv;
@@ -4238,12 +4227,6 @@ gtk_text_layout_snapshot (GtkTextLayout *layout,
{
if (line_display->has_block_cursor && gtk_widget_has_focus (widget))
g_clear_pointer (&line_display->node, gsk_render_node_unref);
if (selection_style_changed &&
(selection_start_index != -1 || selection_end_index != -1))
{
g_clear_pointer (&line_display->node, gsk_render_node_unref);
}
}
if (line_display->node == NULL &&
-1
View File
@@ -376,7 +376,6 @@ void gtk_text_layout_snapshot (GtkTextLayout *layout,
GtkWidget *widget,
GtkSnapshot *snapshot,
const GdkRectangle *clip,
gboolean selection_style_changed,
float cursor_alpha);
void gtk_text_layout_set_mru_size (GtkTextLayout *layout,
+1 -1
View File
@@ -286,7 +286,7 @@ gtk_text_util_create_rich_drag_icon (GtkWidget *widget,
gtk_css_style_snapshot_background (&boxes, snapshot);
}
gtk_text_layout_snapshot (layout, widget, snapshot, &(GdkRectangle) { 0, 0, layout_width, layout_height }, FALSE, 1.0);
gtk_text_layout_snapshot (layout, widget, snapshot, &(GdkRectangle) { 0, 0, layout_width, layout_height }, 1.0);
g_object_unref (layout);
g_object_unref (new_buffer);
-20
View File
@@ -303,8 +303,6 @@ struct _GtkTextViewPrivate
guint vscroll_policy : 1;
guint cursor_handle_dragged : 1;
guint selection_handle_dragged : 1;
guint selection_style_changed : 1;
};
struct _GtkTextPendingScroll
@@ -842,19 +840,6 @@ gtk_text_view_notify (GObject *object,
G_OBJECT_CLASS (gtk_text_view_parent_class)->notify (object, pspec);
}
static void
selection_style_changed_cb (GtkCssNode *node,
GtkCssStyleChange *change,
GtkTextView *self)
{
if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_REDRAW))
{
GtkTextViewPrivate *priv = self->priv;
priv->selection_style_changed = TRUE;
gtk_widget_queue_draw (GTK_WIDGET (self));
}
}
static void
gtk_text_view_class_init (GtkTextViewClass *klass)
{
@@ -2056,8 +2041,6 @@ gtk_text_view_init (GtkTextView *text_view)
gtk_css_node_set_state (priv->selection_node,
gtk_css_node_get_state (priv->text_window->css_node) & ~GTK_STATE_FLAG_DROP_ACTIVE);
gtk_css_node_set_visible (priv->selection_node, FALSE);
g_signal_connect (priv->selection_node, "style-changed",
G_CALLBACK (selection_style_changed_cb), text_view);
g_object_unref (priv->selection_node);
gtk_widget_action_set_enabled (GTK_WIDGET (text_view), "text.can-redo", FALSE);
@@ -5939,12 +5922,9 @@ gtk_text_view_paint (GtkWidget *widget,
gtk_widget_get_width (widget),
gtk_widget_get_height (widget)
},
priv->selection_style_changed,
priv->cursor_alpha);
gtk_snapshot_restore (snapshot);
priv->selection_style_changed = FALSE;
}
static void
+7 -1
View File
@@ -5018,6 +5018,7 @@ static void
gtk_widget_real_system_setting_changed (GtkWidget *widget,
GtkSystemSetting setting)
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
GtkWidget *child;
if (setting == GTK_SYSTEM_SETTING_DPI ||
@@ -5029,6 +5030,11 @@ gtk_widget_real_system_setting_changed (GtkWidget *widget,
gtk_widget_queue_resize (widget);
}
if (setting == GTK_SYSTEM_SETTING_COLOR_SCHEME)
{
gtk_css_node_invalidate (priv->cssnode, GTK_CSS_CHANGE_SOURCE);
}
for (child = _gtk_widget_get_first_child (widget);
child != NULL;
child = _gtk_widget_get_next_sibling (child))
@@ -11857,7 +11863,7 @@ gtk_widget_create_render_node (GtkWidget *widget,
style = gtk_css_node_get_style (priv->cssnode);
css_opacity = gtk_css_number_value_get (style->other->opacity, 1);
css_opacity = gtk_css_number_value_get (style->other->opacity, 100);
opacity = CLAMP (css_opacity, 0.0, 1.0) * priv->user_alpha / 255.0;
if (opacity <= 0.0)
+285 -307
View File
File diff suppressed because it is too large Load Diff
+1550 -2374
View File
File diff suppressed because it is too large Load Diff
-2
View File
@@ -7,5 +7,3 @@ depth = 1
[provide]
harfbuzz = libharfbuzz_dep
harfbuzz-subset = libharfbuzz_subset_dep
+1 -2
View File
@@ -189,8 +189,7 @@ allocate_memfd (gsize size)
if (fd == -1)
g_error ("memfd allocation failed");
if (ftruncate (fd, size) != 0)
g_error ("ftruncate failed");
ftruncate (fd, size);
return fd;
}
+2 -9
View File
@@ -27,7 +27,7 @@
#include "gtk/gtkcssstylepropertyprivate.h"
#include "gtk/gtkcssstaticstyleprivate.h"
#define EPSILON 0.005
#define EPSILON 0.001
static gboolean
color_is_near (const GtkCssColor *color1,
@@ -116,15 +116,8 @@ static ColorConversionTest conversion_tests[] = {
{ "oklch(0.66016 0.15546 134.231)", GTK_CSS_COLOR_SPACE_SRGB, "rgb(40.73% 65.12% 22.35%)" },
{ "oklch(72.322% 0.12403 247.996)", GTK_CSS_COLOR_SPACE_SRGB, "rgb(38.29% 67.27% 93.85%)" },
{ "oklch(42.1% 48.25% 328.4)", GTK_CSS_COLOR_SPACE_SRGB, "color(srgb 0.501808 0.00257216 0.501403)" },
/* some self-conversions */
{ "oklch(0.392 0.4 none)", GTK_CSS_COLOR_SPACE_OKLCH, "oklch(0.392 0.4 0)" },
{ "color(display-p3 1 1 1)", GTK_CSS_COLOR_SPACE_DISPLAY_P3, "color(display-p3 1 1 1)" },
{ "color(rec2020 1 1 1)", GTK_CSS_COLOR_SPACE_REC2020, "color(rec2020 1 1 1)" },
{ "color(rec2100-pq 0.58 0.58 0.58)", GTK_CSS_COLOR_SPACE_REC2100_PQ, "color(rec2100-pq 0.58 0.58 0.58)" },
/* more random tests */
{ "color(rec2100-pq 0.58 0.58 0.58)", GTK_CSS_COLOR_SPACE_REC2020, "color(rec2020 1 1 1)" },
{ "color(xyz 0.5 0.7 99%)", GTK_CSS_COLOR_SPACE_DISPLAY_P3, "color(display-p3 0.48 0.93 0.96)" },
{ "hsl(250 100 20)", GTK_CSS_COLOR_SPACE_REC2020, "color(rec2020 0.042 0.008 0.3226)" },
{ "oklch(0.392 0.4 none)", GTK_CSS_COLOR_SPACE_OKLCH, "oklch(0.392 0.4 0)" },
};
static void
@@ -1,4 +1,3 @@
at-invalid-12.css:1:21-25: error: GTK_CSS_PARSER_WARNING_DEPRECATED
at-invalid-12.css:1:25-29: error: GTK_CSS_PARSER_WARNING_DEPRECATED
at-invalid-12.css:1:31-36: error: GTK_CSS_PARSER_WARNING_DEPRECATED
at-invalid-12.css:1:38-44: error: GTK_CSS_PARSER_ERROR_SYNTAX

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