Compare commits

..

1 Commits

Author SHA1 Message Date
Matthias Clasen 1050ca63a6 widget: Keep separate nodes for css
Keep separate render nodes for CSS background, border, content
and outline, and only recreate them when needed.
2024-06-02 16:05:58 -04:00
178 changed files with 3018 additions and 8742 deletions
-34
View File
@@ -1,40 +1,6 @@
Overview of Changes in 4.15.2, xx-xx-xxxx Overview of Changes in 4.15.2, xx-xx-xxxx
========================================= =========================================
* GtkFileChooserWidget:
- Plug some memory leaks
- Make Ctrl-Shift-N create a new folder
* CSS:
- Support color(), oklab(), etc (https://www.w3.org/TR/css-color-4/)
- Support color-mix() (https://www.w3.org/TR/css-color-5/)
- Support relative colors (https://www.w3.org/TR/css-color-5/)
* Accessibility:
- Avoid markup when reading labels
* GSK:
- Subset fonts when serializing node trees
* Wayland:
- Use xdg-dialog protocol for attached dialogs
* Windows:
- Build with UNICODE
* Debugging:
- Add GTK_DEBUG=css for warning about deprecated css syntax
* Tools:
- nodeparser: Add an extract command for data urls
* Deprecations:
- CSS Color functions shade(), lighter(), darker(), alpha(), mix()
* Translation updates:
Hebrew
Overview of Changes in 4.15.1, 21-05-2024 Overview of Changes in 4.15.1, 21-05-2024
========================================= =========================================
+1 -1
View File
@@ -299,7 +299,7 @@ node_editor_application_new (void)
app = g_object_new (NODE_EDITOR_APPLICATION_TYPE, app = g_object_new (NODE_EDITOR_APPLICATION_TYPE,
"application-id", "org.gtk.gtk4.NodeEditor", "application-id", "org.gtk.gtk4.NodeEditor",
"flags", G_APPLICATION_HANDLES_OPEN | G_APPLICATION_NON_UNIQUE, "flags", G_APPLICATION_HANDLES_OPEN,
NULL); NULL);
g_application_add_main_option (G_APPLICATION (app), "version", 0, 0,G_OPTION_ARG_NONE, "Show program version", NULL); g_application_add_main_option (G_APPLICATION (app), "version", 0, 0,G_OPTION_ARG_NONE, "Show program version", NULL);
+2 -3
View File
@@ -93,12 +93,11 @@ Colors can be expressed in numerous ways in CSS (see the
many (but not all) of these. many (but not all) of these.
You can use rgb(), rgba(), hsl() with both the legacy or the modern CSS You can use rgb(), rgba(), hsl() with both the legacy or the modern CSS
syntax, and calc() can be used as well in color expressions. hwb(), oklab(), syntax, and calc() can be used as well in color expressions.
oklch(), color(), color-mix() and relative colors are supported as well.
### Non-CSS Colors ### Non-CSS Colors
GTK extends the CSS syntax with several additional ways to specify colors. GTK extends the CSS syntax with several additional ways to specify colors.
These extensions are deprecated and should be replaced by the equivalent These extensions are deprecated and should be replaced by the equivalent
standard CSS notions. standard CSS notions.
+6 -5
View File
@@ -99,15 +99,16 @@ reaches the requested phase. However, in practice most things
happen at higher levels: happen at higher levels:
- If you are doing an animation, you can use - 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 beating of the clock with a callback in the Update phase
until you stop the tick. until you stop the tick.
- If some state changes that causes the size of your widget to - 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. a Layout phase and mark your widget as needing relayout.
- If some state changes so you need to redraw your widget you - If some state changes so you need to redraw some area of
use [method@Gtk.Widget.queue_draw] to request a Paint phase for your widget you use the normal gtk_widget_queue_draw()
your widget. 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 There are also a lot of implicit triggers of these from the
CSS layer (which does animations, resizes and repaints as needed). CSS layer (which does animations, resizes and repaints as needed).
@@ -18,7 +18,6 @@ SYNOPSIS
| |
| **gtk4-rendernode-tool** benchmark [OPTIONS...] <FILE> | **gtk4-rendernode-tool** benchmark [OPTIONS...] <FILE>
| **gtk4-rendernode-tool** compare [OPTIONS...] <FILE1> <FILE2> | **gtk4-rendernode-tool** compare [OPTIONS...] <FILE1> <FILE2>
| **gtk4-rendernode-tool** extract [OPTIONS...] <FILE>
| **gtk4-rendernode-tool** info [OPTIONS...] <FILE> | **gtk4-rendernode-tool** info [OPTIONS...] <FILE>
| **gtk4-rendernode-tool** render [OPTIONS...] <FILE> [<FILE>] | **gtk4-rendernode-tool** render [OPTIONS...] <FILE> [<FILE>]
| **gtk4-rendernode-tool** show [OPTIONS...] <FILE> | **gtk4-rendernode-tool** show [OPTIONS...] <FILE>
@@ -100,15 +99,3 @@ exit code is 1. If the images are identical, it is 0.
``--quiet`` ``--quiet``
Don't write results to stdout. Don't write results to stdout.
Extract
^^^^^^^
The ``extract`` command saves all the data urls found in a node file to a given
directory. The file names for the extracted files are derived from the mimetype
of the url.
``--dir=DIRECTORY``
Save extracted files in ``DIRECTORY`` (defaults to the current directory).
-1
View File
@@ -77,7 +77,6 @@ content_files = [
"section-tree-widget.md", "section-tree-widget.md",
"migrating-2to4.md", "migrating-2to4.md",
"migrating-3to4.md", "migrating-3to4.md",
"migrating-4to5.md",
"broadway.md", "broadway.md",
"osx.md", "osx.md",
"wayland.md", "wayland.md",
-1
View File
@@ -14,7 +14,6 @@ expand_content_md_files = [
'running.md', 'running.md',
'migrating-2to4.md', 'migrating-2to4.md',
'migrating-3to4.md', 'migrating-3to4.md',
'migrating-4to5.md',
'actions.md', 'actions.md',
'input-handling.md', 'input-handling.md',
'drawing-model.md', 'drawing-model.md',
+1 -98
View File
@@ -58,7 +58,7 @@ use a GtkLabel.
If you have a need for custom drawing that fits into the current If you have a need for custom drawing that fits into the current
(dark or light) theme, e.g. for rendering a graph, you can still (dark or light) theme, e.g. for rendering a graph, you can still
get the current style foreground color, using get the current style foreground color, using
[method@Gtk.Widget.get_color]. [method@Gtk.Widget.get_style_color].
## Local stylesheets are going away ## Local stylesheets are going away
@@ -73,103 +73,6 @@ GTK 5 will no longer provide this functionality. The recommendations
is to use a global stylesheet (i.e. gtk_style_context_add_provider_for_display()) is to use a global stylesheet (i.e. gtk_style_context_add_provider_for_display())
and rely on style classes to make your CSS apply only where desired. and rely on style classes to make your CSS apply only where desired.
## Non-standard CSS extensions are going away
GTK's CSS machinery has a some non-standard extensions around colors:
named colors with \@define-color and color functions: lighter(), darker(),
shade(), alpha(), mix().
GTK now implements equivalent functionality from the CSS specs.
### \@define-color is going away
\@define-color should be replaced by custom properties in the :root scope.
Instead of
```
@define-color fg_color #2e3436
...
box {
color: @fg_color;
}
```
use
```
:root {
--fg-color: #2e3436;
}
...
box {
color: var(--fg-color);
}
```
For more information about custom CSS properties and variables, see the
[CSS Custom Properties for Cascading Variables](https://www.w3.org/TR/css-variables-1/)
spec.
### Color expressions are going away
The color functions can all be replaced by combinations of calc() and color-mix().
ligher(c) and darker(c) are just shade(c, 1.3) or shade(c, 0.7), respectively, and
thus can be handled the same way as shade in the examples below.
Replace
```
a {
color: mix(red, green, 0.8);
}
b {
color: alpha(green, 0.6);
}
c {
color: shade(red, 1.3);
}
d {
color: shade(red, 0.7);
}
```
with
```
a {
color: color-mix(in srgb, red, green 80%);
}
b {
color: rgb(from green, r g b / calc(alpha * 0.6));
}
c {
color: hsl(from red, h calc(s * 1.3) calc(l * 1.3));
}
d {
color: hsl(from red, h calc(s * 0.7) calc(l * 0.7));
}
```
Variations of these replacements are possible.
Note that GTK has historically computed mix() and shade() values in the SRGB and HSL
colorspaces, but using OKLAB instead might yield slightly better results.
For more information about color-mix(), see the
[CSS Color](https://drafts.csswg.org/css-color-5) spec.
## Chooser interfaces are going away ## Chooser interfaces are going away
The GtkColorChooser, GtkFontChooser, GtkFileChooser and GtkAppChooser The GtkColorChooser, GtkFontChooser, GtkFileChooser and GtkAppChooser
-1
View File
@@ -30,7 +30,6 @@
#include <gdk/gdkcairo.h> #include <gdk/gdkcairo.h>
#include <gdk/gdkcairocontext.h> #include <gdk/gdkcairocontext.h>
#include <gdk/gdkclipboard.h> #include <gdk/gdkclipboard.h>
#include <gdk/gdkcolorstate.h>
#include <gdk/gdkconfig.h> #include <gdk/gdkconfig.h>
#include <gdk/gdkcontentdeserializer.h> #include <gdk/gdkcontentdeserializer.h>
#include <gdk/gdkcontentformats.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"); epoxy_has_egl_extension (priv->egl_display, "EGL_EXT_image_dma_buf_import_modifiers");
self->have_egl_dma_buf_export = self->have_egl_dma_buf_export =
epoxy_has_egl_extension (priv->egl_display, "EGL_MESA_image_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) if (self->have_egl_no_config_context)
priv->egl_config_high_depth = gdk_display_create_egl_config (self, 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_pixel_format_float : 1;
guint have_egl_dma_buf_import : 1; guint have_egl_dma_buf_import : 1;
guint have_egl_dma_buf_export : 1; guint have_egl_dma_buf_export : 1;
guint have_egl_gl_colorspace : 1;
GdkDmabufFormats *dmabuf_formats; GdkDmabufFormats *dmabuf_formats;
GdkDmabufDownloader *dmabuf_downloaders[4]; GdkDmabufDownloader *dmabuf_downloaders[4];
-2
View File
@@ -1758,8 +1758,6 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
priv->features = supported_features & ~disabled_features; priv->features = supported_features & ~disabled_features;
glEnable (GL_FRAMEBUFFER_SRGB);
gdk_gl_context_init_memory_flags (context); gdk_gl_context_init_memory_flags (context);
if ((priv->features & GDK_GL_FEATURE_DEBUG) && gl_debug) 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++) 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; GLenum q_format, q_type;
GLint q_swizzle[4]; GLint q_swizzle[4];
@@ -164,7 +164,6 @@ gdk_gl_texture_find_format (GdkGLContext *context,
gdk_memory_format_gl_format (format, gdk_memory_format_gl_format (format,
gdk_gl_context_get_use_es (context), gdk_gl_context_get_use_es (context),
&q_internal_format, &q_internal_format,
&q_internal_srgb_format,
&q_format, &q_format,
&q_type, &q_type,
q_swizzle); q_swizzle);
@@ -188,7 +187,7 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
GdkMemoryFormat format; GdkMemoryFormat format;
gsize expected_stride; gsize expected_stride;
Download *download = download_; Download *download = download_;
GLint gl_internal_format, gl_internal_srgb_format; GLint gl_internal_format;
GLenum gl_format, gl_type; GLenum gl_format, gl_type;
GLint gl_swizzle[4]; GLint gl_swizzle[4];
@@ -200,7 +199,7 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
{ {
gdk_memory_format_gl_format (format, gdk_memory_format_gl_format (format,
gdk_gl_context_get_use_es (context), gdk_gl_context_get_use_es (context),
&gl_internal_format, &gl_internal_srgb_format, &gl_internal_format,
&gl_format, &gl_type, gl_swizzle); &gl_format, &gl_type, gl_swizzle);
if (download->stride == expected_stride && if (download->stride == expected_stride &&
download->format == format) download->format == format)
@@ -263,7 +262,7 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
gdk_memory_format_gl_format (actual_format, gdk_memory_format_gl_format (actual_format,
gdk_gl_context_get_use_es (context), 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); &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_memory_format_gl_format (actual_format,
gdk_gl_context_get_use_es (context), 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); &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); g_return_if_fail (self->saved == NULL);
texture = GDK_TEXTURE (self); 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); drop_gl_resources (self);
} }
-327
View File
@@ -23,8 +23,6 @@
#include "gdkdmabuffourccprivate.h" #include "gdkdmabuffourccprivate.h"
#include "gdkglcontextprivate.h" #include "gdkglcontextprivate.h"
#include "gdkcolorstateprivate.h"
#include "gtk/gtkcolorutilsprivate.h"
#include "gsk/gl/fp16private.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 struct _GdkMemoryFormatDescription
{ {
const char *name;
GdkMemoryAlpha alpha; GdkMemoryAlpha alpha;
GdkMemoryFormat premultiplied; GdkMemoryFormat premultiplied;
GdkMemoryFormat straight; GdkMemoryFormat straight;
@@ -340,9 +337,7 @@ struct _GdkMemoryFormatDescription
struct { struct {
GLint internal_gl_format; GLint internal_gl_format;
GLint internal_gles_format; GLint internal_gles_format;
GLint internal_srgb_format;
GLenum format; GLenum format;
GLenum srgb_format;
GLenum type; GLenum type;
GLint swizzle[4]; GLint swizzle[4];
/* -1 if none exists, ie the format is already RGBA /* -1 if none exists, ie the format is already RGBA
@@ -352,7 +347,6 @@ struct _GdkMemoryFormatDescription
} gl; } gl;
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
VkFormat vk_format; VkFormat vk_format;
VkFormat vk_srgb_format;
#endif #endif
#ifdef HAVE_DMABUF #ifdef HAVE_DMABUF
guint32 dmabuf_fourcc; guint32 dmabuf_fourcc;
@@ -372,7 +366,6 @@ struct _GdkMemoryFormatDescription
static const GdkMemoryFormatDescription memory_formats[] = { static const GdkMemoryFormatDescription memory_formats[] = {
[GDK_MEMORY_B8G8R8A8_PREMULTIPLIED] = { [GDK_MEMORY_B8G8R8A8_PREMULTIPLIED] = {
.name = "*BGRA8",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED, .alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_B8G8R8A8_PREMULTIPLIED, .premultiplied = GDK_MEMORY_B8G8R8A8_PREMULTIPLIED,
.straight = GDK_MEMORY_B8G8R8A8, .straight = GDK_MEMORY_B8G8R8A8,
@@ -385,7 +378,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = { .gl = {
.internal_gl_format = GL_RGBA8, .internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_BGRA, .internal_gles_format = GL_BGRA,
.internal_srgb_format = -1,
.format = GL_BGRA, .format = GL_BGRA,
.type = GL_UNSIGNED_BYTE, .type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA }, .swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -394,7 +386,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
}, },
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_B8G8R8A8_UNORM, .vk_format = VK_FORMAT_B8G8R8A8_UNORM,
.vk_srgb_format = VK_FORMAT_B8G8R8A8_SRGB,
#endif #endif
#ifdef HAVE_DMABUF #ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_ARGB8888, .dmabuf_fourcc = DRM_FORMAT_ARGB8888,
@@ -403,7 +394,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = b8g8r8a8_premultiplied_from_float, .from_float = b8g8r8a8_premultiplied_from_float,
}, },
[GDK_MEMORY_A8R8G8B8_PREMULTIPLIED] = { [GDK_MEMORY_A8R8G8B8_PREMULTIPLIED] = {
.name = "*ARGB8",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED, .alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_A8R8G8B8_PREMULTIPLIED, .premultiplied = GDK_MEMORY_A8R8G8B8_PREMULTIPLIED,
.straight = GDK_MEMORY_A8R8G8B8, .straight = GDK_MEMORY_A8R8G8B8,
@@ -416,7 +406,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = { .gl = {
.internal_gl_format = GL_RGBA8, .internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_RGBA8, .internal_gles_format = GL_RGBA8,
.internal_srgb_format = GL_SRGB8_ALPHA8,
.format = GL_BGRA, .format = GL_BGRA,
.type = GDK_GL_UNSIGNED_BYTE_FLIPPED, .type = GDK_GL_UNSIGNED_BYTE_FLIPPED,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA }, .swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -425,7 +414,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
}, },
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_UNDEFINED, .vk_format = VK_FORMAT_UNDEFINED,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif #endif
#ifdef HAVE_DMABUF #ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_BGRA8888, .dmabuf_fourcc = DRM_FORMAT_BGRA8888,
@@ -434,7 +422,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = a8r8g8b8_premultiplied_from_float, .from_float = a8r8g8b8_premultiplied_from_float,
}, },
[GDK_MEMORY_R8G8B8A8_PREMULTIPLIED] = { [GDK_MEMORY_R8G8B8A8_PREMULTIPLIED] = {
.name = "*RGBA8",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED, .alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, .premultiplied = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED,
.straight = GDK_MEMORY_R8G8B8A8, .straight = GDK_MEMORY_R8G8B8A8,
@@ -447,7 +434,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = { .gl = {
.internal_gl_format = GL_RGBA8, .internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_RGBA8, .internal_gles_format = GL_RGBA8,
.internal_srgb_format = GL_SRGB8_ALPHA8,
.format = GL_RGBA, .format = GL_RGBA,
.type = GL_UNSIGNED_BYTE, .type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA }, .swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -455,7 +441,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
}, },
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R8G8B8A8_UNORM, .vk_format = VK_FORMAT_R8G8B8A8_UNORM,
.vk_srgb_format = VK_FORMAT_R8G8B8A8_SRGB,
#endif #endif
#ifdef HAVE_DMABUF #ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_ABGR8888, .dmabuf_fourcc = DRM_FORMAT_ABGR8888,
@@ -464,7 +449,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r8g8b8a8_premultiplied_from_float, .from_float = r8g8b8a8_premultiplied_from_float,
}, },
[GDK_MEMORY_A8B8G8R8_PREMULTIPLIED] = { [GDK_MEMORY_A8B8G8R8_PREMULTIPLIED] = {
.name = "*ABGR8",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED, .alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_A8B8G8R8_PREMULTIPLIED, .premultiplied = GDK_MEMORY_A8B8G8R8_PREMULTIPLIED,
.straight = GDK_MEMORY_A8B8G8R8, .straight = GDK_MEMORY_A8B8G8R8,
@@ -477,7 +461,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = { .gl = {
.internal_gl_format = GL_RGBA8, .internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_RGBA8, .internal_gles_format = GL_RGBA8,
.internal_srgb_format = GL_SRGB8_ALPHA8,
.format = GL_RGBA, .format = GL_RGBA,
.type = GDK_GL_UNSIGNED_BYTE_FLIPPED, .type = GDK_GL_UNSIGNED_BYTE_FLIPPED,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA }, .swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -486,7 +469,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
}, },
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_UNDEFINED, .vk_format = VK_FORMAT_UNDEFINED,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif #endif
#ifdef HAVE_DMABUF #ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_RGBA8888, .dmabuf_fourcc = DRM_FORMAT_RGBA8888,
@@ -495,7 +477,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = a8b8g8r8_premultiplied_from_float, .from_float = a8b8g8r8_premultiplied_from_float,
}, },
[GDK_MEMORY_B8G8R8A8] = { [GDK_MEMORY_B8G8R8A8] = {
.name = "BGRA8",
.alpha = GDK_MEMORY_ALPHA_STRAIGHT, .alpha = GDK_MEMORY_ALPHA_STRAIGHT,
.premultiplied = GDK_MEMORY_B8G8R8A8_PREMULTIPLIED, .premultiplied = GDK_MEMORY_B8G8R8A8_PREMULTIPLIED,
.straight = GDK_MEMORY_B8G8R8A8, .straight = GDK_MEMORY_B8G8R8A8,
@@ -508,7 +489,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = { .gl = {
.internal_gl_format = GL_RGBA8, .internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_BGRA, .internal_gles_format = GL_BGRA,
.internal_srgb_format = -1,
.format = GL_BGRA, .format = GL_BGRA,
.type = GL_UNSIGNED_BYTE, .type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA }, .swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -517,7 +497,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
}, },
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_B8G8R8A8_UNORM, .vk_format = VK_FORMAT_B8G8R8A8_UNORM,
.vk_srgb_format = VK_FORMAT_B8G8R8A8_SRGB,
#endif #endif
#ifdef HAVE_DMABUF #ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_ARGB8888, .dmabuf_fourcc = DRM_FORMAT_ARGB8888,
@@ -526,7 +505,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = b8g8r8a8_from_float, .from_float = b8g8r8a8_from_float,
}, },
[GDK_MEMORY_A8R8G8B8] = { [GDK_MEMORY_A8R8G8B8] = {
.name = "ARGB8",
.alpha = GDK_MEMORY_ALPHA_STRAIGHT, .alpha = GDK_MEMORY_ALPHA_STRAIGHT,
.premultiplied = GDK_MEMORY_A8R8G8B8_PREMULTIPLIED, .premultiplied = GDK_MEMORY_A8R8G8B8_PREMULTIPLIED,
.straight = GDK_MEMORY_A8R8G8B8, .straight = GDK_MEMORY_A8R8G8B8,
@@ -539,7 +517,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = { .gl = {
.internal_gl_format = GL_RGBA8, .internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_RGBA8, .internal_gles_format = GL_RGBA8,
.internal_srgb_format = GL_SRGB8_ALPHA8,
.format = GL_BGRA, .format = GL_BGRA,
.type = GDK_GL_UNSIGNED_BYTE_FLIPPED, .type = GDK_GL_UNSIGNED_BYTE_FLIPPED,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA }, .swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -548,7 +525,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
}, },
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_UNDEFINED, .vk_format = VK_FORMAT_UNDEFINED,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif #endif
#ifdef HAVE_DMABUF #ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_BGRA8888, .dmabuf_fourcc = DRM_FORMAT_BGRA8888,
@@ -557,7 +533,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = a8r8g8b8_from_float, .from_float = a8r8g8b8_from_float,
}, },
[GDK_MEMORY_R8G8B8A8] = { [GDK_MEMORY_R8G8B8A8] = {
.name = "RGBA8",
.alpha = GDK_MEMORY_ALPHA_STRAIGHT, .alpha = GDK_MEMORY_ALPHA_STRAIGHT,
.premultiplied = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, .premultiplied = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED,
.straight = GDK_MEMORY_R8G8B8A8, .straight = GDK_MEMORY_R8G8B8A8,
@@ -570,7 +545,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = { .gl = {
.internal_gl_format = GL_RGBA8, .internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_RGBA8, .internal_gles_format = GL_RGBA8,
.internal_srgb_format = GL_SRGB8_ALPHA8,
.format = GL_RGBA, .format = GL_RGBA,
.type = GL_UNSIGNED_BYTE, .type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA }, .swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -578,7 +552,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
}, },
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R8G8B8A8_UNORM, .vk_format = VK_FORMAT_R8G8B8A8_UNORM,
.vk_srgb_format = VK_FORMAT_R8G8B8A8_SRGB,
#endif #endif
#ifdef HAVE_DMABUF #ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_ABGR8888, .dmabuf_fourcc = DRM_FORMAT_ABGR8888,
@@ -587,7 +560,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r8g8b8a8_from_float, .from_float = r8g8b8a8_from_float,
}, },
[GDK_MEMORY_A8B8G8R8] = { [GDK_MEMORY_A8B8G8R8] = {
.name = "ABGR8",
.alpha = GDK_MEMORY_ALPHA_STRAIGHT, .alpha = GDK_MEMORY_ALPHA_STRAIGHT,
.premultiplied = GDK_MEMORY_A8B8G8R8_PREMULTIPLIED, .premultiplied = GDK_MEMORY_A8B8G8R8_PREMULTIPLIED,
.straight = GDK_MEMORY_A8B8G8R8, .straight = GDK_MEMORY_A8B8G8R8,
@@ -600,7 +572,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = { .gl = {
.internal_gl_format = GL_RGBA8, .internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_RGBA8, .internal_gles_format = GL_RGBA8,
.internal_srgb_format = GL_SRGB8_ALPHA8,
.format = GL_RGBA, .format = GL_RGBA,
.type = GDK_GL_UNSIGNED_BYTE_FLIPPED, .type = GDK_GL_UNSIGNED_BYTE_FLIPPED,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA }, .swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -609,7 +580,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
}, },
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_UNDEFINED, .vk_format = VK_FORMAT_UNDEFINED,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif #endif
#ifdef HAVE_DMABUF #ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_RGBA8888, .dmabuf_fourcc = DRM_FORMAT_RGBA8888,
@@ -618,7 +588,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = a8b8g8r8_from_float, .from_float = a8b8g8r8_from_float,
}, },
[GDK_MEMORY_B8G8R8X8] = { [GDK_MEMORY_B8G8R8X8] = {
.name = "BGRX8",
.alpha = GDK_MEMORY_ALPHA_OPAQUE, .alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_B8G8R8X8, .premultiplied = GDK_MEMORY_B8G8R8X8,
.straight = GDK_MEMORY_B8G8R8X8, .straight = GDK_MEMORY_B8G8R8X8,
@@ -632,7 +601,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = { .gl = {
.internal_gl_format = GL_RGBA8, .internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_BGRA, .internal_gles_format = GL_BGRA,
.internal_srgb_format = -1,
.format = GL_BGRA, .format = GL_BGRA,
.type = GL_UNSIGNED_BYTE, .type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ONE }, .swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ONE },
@@ -641,7 +609,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
}, },
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_B8G8R8A8_UNORM, .vk_format = VK_FORMAT_B8G8R8A8_UNORM,
.vk_srgb_format = VK_FORMAT_B8G8R8A8_SRGB,
#endif #endif
#ifdef HAVE_DMABUF #ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_XRGB8888, .dmabuf_fourcc = DRM_FORMAT_XRGB8888,
@@ -650,7 +617,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = b8g8r8x8_from_float, .from_float = b8g8r8x8_from_float,
}, },
[GDK_MEMORY_X8R8G8B8] = { [GDK_MEMORY_X8R8G8B8] = {
.name = "XRGB8",
.alpha = GDK_MEMORY_ALPHA_OPAQUE, .alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_X8R8G8B8, .premultiplied = GDK_MEMORY_X8R8G8B8,
.straight = GDK_MEMORY_X8R8G8B8, .straight = GDK_MEMORY_X8R8G8B8,
@@ -664,7 +630,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = { .gl = {
.internal_gl_format = GL_RGBA8, .internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_RGBA8, .internal_gles_format = GL_RGBA8,
.internal_srgb_format = GL_SRGB8_ALPHA8,
.format = GL_BGRA, .format = GL_BGRA,
.type = GDK_GL_UNSIGNED_BYTE_FLIPPED, .type = GDK_GL_UNSIGNED_BYTE_FLIPPED,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ONE }, .swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ONE },
@@ -673,7 +638,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
}, },
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_UNDEFINED, .vk_format = VK_FORMAT_UNDEFINED,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif #endif
#ifdef HAVE_DMABUF #ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_BGRX8888, .dmabuf_fourcc = DRM_FORMAT_BGRX8888,
@@ -682,7 +646,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = x8r8g8b8_from_float, .from_float = x8r8g8b8_from_float,
}, },
[GDK_MEMORY_R8G8B8X8] = { [GDK_MEMORY_R8G8B8X8] = {
.name = "RGBX8",
.alpha = GDK_MEMORY_ALPHA_OPAQUE, .alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_R8G8B8X8, .premultiplied = GDK_MEMORY_R8G8B8X8,
.straight = GDK_MEMORY_R8G8B8X8, .straight = GDK_MEMORY_R8G8B8X8,
@@ -696,7 +659,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = { .gl = {
.internal_gl_format = GL_RGBA8, .internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_RGBA8, .internal_gles_format = GL_RGBA8,
.internal_srgb_format = GL_SRGB8_ALPHA8,
.format = GL_RGBA, .format = GL_RGBA,
.type = GL_UNSIGNED_BYTE, .type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ONE }, .swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ONE },
@@ -704,7 +666,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
}, },
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R8G8B8A8_UNORM, .vk_format = VK_FORMAT_R8G8B8A8_UNORM,
.vk_srgb_format = VK_FORMAT_R8G8B8A8_SRGB,
#endif #endif
#ifdef HAVE_DMABUF #ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_XBGR8888, .dmabuf_fourcc = DRM_FORMAT_XBGR8888,
@@ -713,7 +674,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r8g8b8x8_from_float, .from_float = r8g8b8x8_from_float,
}, },
[GDK_MEMORY_X8B8G8R8] = { [GDK_MEMORY_X8B8G8R8] = {
.name = "XBGR8",
.alpha = GDK_MEMORY_ALPHA_OPAQUE, .alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_X8B8G8R8, .premultiplied = GDK_MEMORY_X8B8G8R8,
.straight = GDK_MEMORY_X8B8G8R8, .straight = GDK_MEMORY_X8B8G8R8,
@@ -727,7 +687,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = { .gl = {
.internal_gl_format = GL_RGBA8, .internal_gl_format = GL_RGBA8,
.internal_gles_format = GL_RGBA8, .internal_gles_format = GL_RGBA8,
.internal_srgb_format = GL_SRGB8_ALPHA8,
.format = GL_RGBA, .format = GL_RGBA,
.type = GDK_GL_UNSIGNED_BYTE_FLIPPED, .type = GDK_GL_UNSIGNED_BYTE_FLIPPED,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ONE }, .swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ONE },
@@ -736,7 +695,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
}, },
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_UNDEFINED, .vk_format = VK_FORMAT_UNDEFINED,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif #endif
#ifdef HAVE_DMABUF #ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_RGBX8888, .dmabuf_fourcc = DRM_FORMAT_RGBX8888,
@@ -745,7 +703,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = x8b8g8r8_from_float, .from_float = x8b8g8r8_from_float,
}, },
[GDK_MEMORY_R8G8B8] = { [GDK_MEMORY_R8G8B8] = {
.name = "RGB8",
.alpha = GDK_MEMORY_ALPHA_OPAQUE, .alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_R8G8B8, .premultiplied = GDK_MEMORY_R8G8B8,
.straight = GDK_MEMORY_R8G8B8, .straight = GDK_MEMORY_R8G8B8,
@@ -759,7 +716,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = { .gl = {
.internal_gl_format = GL_RGB8, .internal_gl_format = GL_RGB8,
.internal_gles_format = GL_RGB8, .internal_gles_format = GL_RGB8,
.internal_srgb_format = GL_SRGB8,
.format = GL_RGB, .format = GL_RGB,
.type = GL_UNSIGNED_BYTE, .type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA }, .swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -767,7 +723,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
}, },
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R8G8B8_UNORM, .vk_format = VK_FORMAT_R8G8B8_UNORM,
.vk_srgb_format = VK_FORMAT_R8G8B8_SRGB,
#endif #endif
#ifdef HAVE_DMABUF #ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_BGR888, .dmabuf_fourcc = DRM_FORMAT_BGR888,
@@ -776,7 +731,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r8g8b8_from_float, .from_float = r8g8b8_from_float,
}, },
[GDK_MEMORY_B8G8R8] = { [GDK_MEMORY_B8G8R8] = {
.name = "BGR8",
.alpha = GDK_MEMORY_ALPHA_OPAQUE, .alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_B8G8R8, .premultiplied = GDK_MEMORY_B8G8R8,
.straight = GDK_MEMORY_B8G8R8, .straight = GDK_MEMORY_B8G8R8,
@@ -790,7 +744,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = { .gl = {
.internal_gl_format = GL_RGB8, .internal_gl_format = GL_RGB8,
.internal_gles_format = GL_RGB8, .internal_gles_format = GL_RGB8,
.internal_srgb_format = GL_SRGB8,
.format = GL_BGR, .format = GL_BGR,
.type = GL_UNSIGNED_BYTE, .type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA }, .swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -799,7 +752,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
}, },
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_B8G8R8_UNORM, .vk_format = VK_FORMAT_B8G8R8_UNORM,
.vk_srgb_format = VK_FORMAT_B8G8R8_SRGB,
#endif #endif
#ifdef HAVE_DMABUF #ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_RGB888, .dmabuf_fourcc = DRM_FORMAT_RGB888,
@@ -808,7 +760,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = b8g8r8_from_float, .from_float = b8g8r8_from_float,
}, },
[GDK_MEMORY_R16G16B16] = { [GDK_MEMORY_R16G16B16] = {
.name = "RGB16",
.alpha = GDK_MEMORY_ALPHA_OPAQUE, .alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_R16G16B16, .premultiplied = GDK_MEMORY_R16G16B16,
.straight = GDK_MEMORY_R16G16B16, .straight = GDK_MEMORY_R16G16B16,
@@ -825,7 +776,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = { .gl = {
.internal_gl_format = GL_RGB16, .internal_gl_format = GL_RGB16,
.internal_gles_format = GL_RGB16, .internal_gles_format = GL_RGB16,
.internal_srgb_format = -1,
.format = GL_RGB, .format = GL_RGB,
.type = GL_UNSIGNED_SHORT, .type = GL_UNSIGNED_SHORT,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA }, .swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -833,7 +783,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
}, },
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16G16B16_UNORM, .vk_format = VK_FORMAT_R16G16B16_UNORM,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif #endif
#ifdef HAVE_DMABUF #ifdef HAVE_DMABUF
.dmabuf_fourcc = 0, .dmabuf_fourcc = 0,
@@ -842,7 +791,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r16g16b16_from_float, .from_float = r16g16b16_from_float,
}, },
[GDK_MEMORY_R16G16B16A16_PREMULTIPLIED] = { [GDK_MEMORY_R16G16B16A16_PREMULTIPLIED] = {
.name = "*RGBA16",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED, .alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_R16G16B16A16_PREMULTIPLIED, .premultiplied = GDK_MEMORY_R16G16B16A16_PREMULTIPLIED,
.straight = GDK_MEMORY_R16G16B16A16, .straight = GDK_MEMORY_R16G16B16A16,
@@ -858,7 +806,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = { .gl = {
.internal_gl_format = GL_RGBA16, .internal_gl_format = GL_RGBA16,
.internal_gles_format = GL_RGBA16, .internal_gles_format = GL_RGBA16,
.internal_srgb_format = -1,
.format = GL_RGBA, .format = GL_RGBA,
.type = GL_UNSIGNED_SHORT, .type = GL_UNSIGNED_SHORT,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA }, .swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -866,7 +813,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
}, },
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16G16B16A16_UNORM, .vk_format = VK_FORMAT_R16G16B16A16_UNORM,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif #endif
#ifdef HAVE_DMABUF #ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_ABGR16161616, .dmabuf_fourcc = DRM_FORMAT_ABGR16161616,
@@ -875,7 +821,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r16g16b16a16_from_float, .from_float = r16g16b16a16_from_float,
}, },
[GDK_MEMORY_R16G16B16A16] = { [GDK_MEMORY_R16G16B16A16] = {
.name = "RGBA16",
.alpha = GDK_MEMORY_ALPHA_STRAIGHT, .alpha = GDK_MEMORY_ALPHA_STRAIGHT,
.premultiplied = GDK_MEMORY_R16G16B16A16_PREMULTIPLIED, .premultiplied = GDK_MEMORY_R16G16B16A16_PREMULTIPLIED,
.straight = GDK_MEMORY_R16G16B16A16, .straight = GDK_MEMORY_R16G16B16A16,
@@ -891,7 +836,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = { .gl = {
.internal_gl_format = GL_RGBA16, .internal_gl_format = GL_RGBA16,
.internal_gles_format = GL_RGBA16, .internal_gles_format = GL_RGBA16,
.internal_srgb_format = -1,
.format = GL_RGBA, .format = GL_RGBA,
.type = GL_UNSIGNED_SHORT, .type = GL_UNSIGNED_SHORT,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA }, .swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -899,7 +843,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
}, },
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16G16B16A16_UNORM, .vk_format = VK_FORMAT_R16G16B16A16_UNORM,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif #endif
#ifdef HAVE_DMABUF #ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_ABGR16161616, .dmabuf_fourcc = DRM_FORMAT_ABGR16161616,
@@ -908,7 +851,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r16g16b16a16_from_float, .from_float = r16g16b16a16_from_float,
}, },
[GDK_MEMORY_R16G16B16_FLOAT] = { [GDK_MEMORY_R16G16B16_FLOAT] = {
.name = "RGBA16f",
.alpha = GDK_MEMORY_ALPHA_OPAQUE, .alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_R16G16B16_FLOAT, .premultiplied = GDK_MEMORY_R16G16B16_FLOAT,
.straight = GDK_MEMORY_R16G16B16_FLOAT, .straight = GDK_MEMORY_R16G16B16_FLOAT,
@@ -924,7 +866,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = { .gl = {
.internal_gl_format = GL_RGB16F, .internal_gl_format = GL_RGB16F,
.internal_gles_format = GL_RGB16F, .internal_gles_format = GL_RGB16F,
.internal_srgb_format = -1,
.format = GL_RGB, .format = GL_RGB,
.type = GL_HALF_FLOAT, .type = GL_HALF_FLOAT,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA }, .swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -932,7 +873,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
}, },
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16G16B16_SFLOAT, .vk_format = VK_FORMAT_R16G16B16_SFLOAT,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif #endif
#ifdef HAVE_DMABUF #ifdef HAVE_DMABUF
.dmabuf_fourcc = 0, .dmabuf_fourcc = 0,
@@ -941,7 +881,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r16g16b16_float_from_float, .from_float = r16g16b16_float_from_float,
}, },
[GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED] = { [GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED] = {
.name = "*RGBA16f",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED, .alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED, .premultiplied = GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED,
.straight = GDK_MEMORY_R16G16B16A16_FLOAT, .straight = GDK_MEMORY_R16G16B16A16_FLOAT,
@@ -956,7 +895,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = { .gl = {
.internal_gl_format = GL_RGBA16F, .internal_gl_format = GL_RGBA16F,
.internal_gles_format = GL_RGBA16F, .internal_gles_format = GL_RGBA16F,
.internal_srgb_format = -1,
.format = GL_RGBA, .format = GL_RGBA,
.type = GL_HALF_FLOAT, .type = GL_HALF_FLOAT,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA }, .swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -964,7 +902,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
}, },
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16G16B16A16_SFLOAT, .vk_format = VK_FORMAT_R16G16B16A16_SFLOAT,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif #endif
#ifdef HAVE_DMABUF #ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_ABGR16161616F, .dmabuf_fourcc = DRM_FORMAT_ABGR16161616F,
@@ -973,7 +910,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r16g16b16a16_float_from_float, .from_float = r16g16b16a16_float_from_float,
}, },
[GDK_MEMORY_R16G16B16A16_FLOAT] = { [GDK_MEMORY_R16G16B16A16_FLOAT] = {
.name = "RGBA16f",
.alpha = GDK_MEMORY_ALPHA_STRAIGHT, .alpha = GDK_MEMORY_ALPHA_STRAIGHT,
.premultiplied = GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED, .premultiplied = GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED,
.straight = GDK_MEMORY_R16G16B16A16_FLOAT, .straight = GDK_MEMORY_R16G16B16A16_FLOAT,
@@ -988,7 +924,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = { .gl = {
.internal_gl_format = GL_RGBA16F, .internal_gl_format = GL_RGBA16F,
.internal_gles_format = GL_RGBA16F, .internal_gles_format = GL_RGBA16F,
.internal_srgb_format = -1,
.format = GL_RGBA, .format = GL_RGBA,
.type = GL_HALF_FLOAT, .type = GL_HALF_FLOAT,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA }, .swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -996,7 +931,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
}, },
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16G16B16A16_SFLOAT, .vk_format = VK_FORMAT_R16G16B16A16_SFLOAT,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif #endif
#ifdef HAVE_DMABUF #ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_ABGR16161616F, .dmabuf_fourcc = DRM_FORMAT_ABGR16161616F,
@@ -1005,7 +939,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r16g16b16a16_float_from_float, .from_float = r16g16b16a16_float_from_float,
}, },
[GDK_MEMORY_R32G32B32_FLOAT] = { [GDK_MEMORY_R32G32B32_FLOAT] = {
.name = "RGB32f",
.alpha = GDK_MEMORY_ALPHA_OPAQUE, .alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_R32G32B32_FLOAT, .premultiplied = GDK_MEMORY_R32G32B32_FLOAT,
.straight = GDK_MEMORY_R32G32B32_FLOAT, .straight = GDK_MEMORY_R32G32B32_FLOAT,
@@ -1021,7 +954,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = { .gl = {
.internal_gl_format = GL_RGB32F, .internal_gl_format = GL_RGB32F,
.internal_gles_format = GL_RGB32F, .internal_gles_format = GL_RGB32F,
.internal_srgb_format = -1,
.format = GL_RGB, .format = GL_RGB,
.type = GL_FLOAT, .type = GL_FLOAT,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA }, .swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -1029,7 +961,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
}, },
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R32G32B32_SFLOAT, .vk_format = VK_FORMAT_R32G32B32_SFLOAT,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif #endif
#ifdef HAVE_DMABUF #ifdef HAVE_DMABUF
.dmabuf_fourcc = 0, .dmabuf_fourcc = 0,
@@ -1038,7 +969,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r32g32b32_float_from_float, .from_float = r32g32b32_float_from_float,
}, },
[GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED] = { [GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED] = {
.name = "*RGBA32f",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED, .alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED, .premultiplied = GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED,
.straight = GDK_MEMORY_R32G32B32A32_FLOAT, .straight = GDK_MEMORY_R32G32B32A32_FLOAT,
@@ -1053,7 +983,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = { .gl = {
.internal_gl_format = GL_RGBA32F, .internal_gl_format = GL_RGBA32F,
.internal_gles_format = GL_RGBA32F, .internal_gles_format = GL_RGBA32F,
.internal_srgb_format = -1,
.format = GL_RGBA, .format = GL_RGBA,
.type = GL_FLOAT, .type = GL_FLOAT,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA }, .swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -1061,7 +990,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
}, },
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R32G32B32A32_SFLOAT, .vk_format = VK_FORMAT_R32G32B32A32_SFLOAT,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif #endif
#ifdef HAVE_DMABUF #ifdef HAVE_DMABUF
.dmabuf_fourcc = 0, .dmabuf_fourcc = 0,
@@ -1070,7 +998,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r32g32b32a32_float_from_float, .from_float = r32g32b32a32_float_from_float,
}, },
[GDK_MEMORY_R32G32B32A32_FLOAT] = { [GDK_MEMORY_R32G32B32A32_FLOAT] = {
.name = "RGBA32f",
.alpha = GDK_MEMORY_ALPHA_STRAIGHT, .alpha = GDK_MEMORY_ALPHA_STRAIGHT,
.premultiplied = GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED, .premultiplied = GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED,
.straight = GDK_MEMORY_R32G32B32A32_FLOAT, .straight = GDK_MEMORY_R32G32B32A32_FLOAT,
@@ -1085,7 +1012,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = { .gl = {
.internal_gl_format = GL_RGBA32F, .internal_gl_format = GL_RGBA32F,
.internal_gles_format = GL_RGBA32F, .internal_gles_format = GL_RGBA32F,
.internal_srgb_format = -1,
.format = GL_RGBA, .format = GL_RGBA,
.type = GL_FLOAT, .type = GL_FLOAT,
.swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA }, .swizzle = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
@@ -1093,7 +1019,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
}, },
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R32G32B32A32_SFLOAT, .vk_format = VK_FORMAT_R32G32B32A32_SFLOAT,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif #endif
#ifdef HAVE_DMABUF #ifdef HAVE_DMABUF
.dmabuf_fourcc = 0, .dmabuf_fourcc = 0,
@@ -1102,7 +1027,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = r32g32b32a32_float_from_float, .from_float = r32g32b32a32_float_from_float,
}, },
[GDK_MEMORY_G8A8_PREMULTIPLIED] = { [GDK_MEMORY_G8A8_PREMULTIPLIED] = {
.name = "*GA8",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED, .alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_G8A8_PREMULTIPLIED, .premultiplied = GDK_MEMORY_G8A8_PREMULTIPLIED,
.straight = GDK_MEMORY_G8A8, .straight = GDK_MEMORY_G8A8,
@@ -1116,7 +1040,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = { .gl = {
.internal_gl_format = GL_RG8, .internal_gl_format = GL_RG8,
.internal_gles_format = GL_RG8, .internal_gles_format = GL_RG8,
.internal_srgb_format = -1,
.format = GL_RG, .format = GL_RG,
.type = GL_UNSIGNED_BYTE, .type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_RED, GL_RED, GL_GREEN }, .swizzle = { GL_RED, GL_RED, GL_RED, GL_GREEN },
@@ -1124,7 +1047,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
}, },
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R8G8_UNORM, .vk_format = VK_FORMAT_R8G8_UNORM,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif #endif
#ifdef HAVE_DMABUF #ifdef HAVE_DMABUF
.dmabuf_fourcc = 0, .dmabuf_fourcc = 0,
@@ -1133,7 +1055,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = g8a8_premultiplied_from_float, .from_float = g8a8_premultiplied_from_float,
}, },
[GDK_MEMORY_G8A8] = { [GDK_MEMORY_G8A8] = {
.name = "GA8",
.alpha = GDK_MEMORY_ALPHA_STRAIGHT, .alpha = GDK_MEMORY_ALPHA_STRAIGHT,
.premultiplied = GDK_MEMORY_G8A8_PREMULTIPLIED, .premultiplied = GDK_MEMORY_G8A8_PREMULTIPLIED,
.straight = GDK_MEMORY_G8A8, .straight = GDK_MEMORY_G8A8,
@@ -1147,7 +1068,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = { .gl = {
.internal_gl_format = GL_RG8, .internal_gl_format = GL_RG8,
.internal_gles_format = GL_RG8, .internal_gles_format = GL_RG8,
.internal_srgb_format = -1,
.format = GL_RG, .format = GL_RG,
.type = GL_UNSIGNED_BYTE, .type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_RED, GL_RED, GL_GREEN }, .swizzle = { GL_RED, GL_RED, GL_RED, GL_GREEN },
@@ -1155,7 +1075,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
}, },
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R8G8_UNORM, .vk_format = VK_FORMAT_R8G8_UNORM,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif #endif
#ifdef HAVE_DMABUF #ifdef HAVE_DMABUF
.dmabuf_fourcc = 0, .dmabuf_fourcc = 0,
@@ -1164,7 +1083,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = g8a8_from_float, .from_float = g8a8_from_float,
}, },
[GDK_MEMORY_G8] = { [GDK_MEMORY_G8] = {
.name = "G8",
.alpha = GDK_MEMORY_ALPHA_OPAQUE, .alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_G8, .premultiplied = GDK_MEMORY_G8,
.straight = GDK_MEMORY_G8, .straight = GDK_MEMORY_G8,
@@ -1178,7 +1096,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = { .gl = {
.internal_gl_format = GL_R8, .internal_gl_format = GL_R8,
.internal_gles_format = GL_R8, .internal_gles_format = GL_R8,
.internal_srgb_format = -1,
.format = GL_RED, .format = GL_RED,
.type = GL_UNSIGNED_BYTE, .type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_RED, GL_RED, GL_ONE }, .swizzle = { GL_RED, GL_RED, GL_RED, GL_ONE },
@@ -1186,7 +1103,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
}, },
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R8_UNORM, .vk_format = VK_FORMAT_R8_UNORM,
.vk_srgb_format = VK_FORMAT_R8_SRGB,
#endif #endif
#ifdef HAVE_DMABUF #ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_R8, .dmabuf_fourcc = DRM_FORMAT_R8,
@@ -1195,7 +1111,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = g8_from_float, .from_float = g8_from_float,
}, },
[GDK_MEMORY_G16A16_PREMULTIPLIED] = { [GDK_MEMORY_G16A16_PREMULTIPLIED] = {
.name = "*GA16",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED, .alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_G16A16_PREMULTIPLIED, .premultiplied = GDK_MEMORY_G16A16_PREMULTIPLIED,
.straight = GDK_MEMORY_G16A16, .straight = GDK_MEMORY_G16A16,
@@ -1212,7 +1127,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = { .gl = {
.internal_gl_format = GL_RG16, .internal_gl_format = GL_RG16,
.internal_gles_format = GL_RG16, .internal_gles_format = GL_RG16,
.internal_srgb_format = -1,
.format = GL_RG, .format = GL_RG,
.type = GL_UNSIGNED_SHORT, .type = GL_UNSIGNED_SHORT,
.swizzle = { GL_RED, GL_RED, GL_RED, GL_GREEN }, .swizzle = { GL_RED, GL_RED, GL_RED, GL_GREEN },
@@ -1220,7 +1134,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
}, },
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16G16_UNORM, .vk_format = VK_FORMAT_R16G16_UNORM,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif #endif
#ifdef HAVE_DMABUF #ifdef HAVE_DMABUF
.dmabuf_fourcc = 0, .dmabuf_fourcc = 0,
@@ -1229,7 +1142,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = g16a16_premultiplied_from_float, .from_float = g16a16_premultiplied_from_float,
}, },
[GDK_MEMORY_G16A16] = { [GDK_MEMORY_G16A16] = {
.name = "GA16",
.alpha = GDK_MEMORY_ALPHA_STRAIGHT, .alpha = GDK_MEMORY_ALPHA_STRAIGHT,
.premultiplied = GDK_MEMORY_G16A16_PREMULTIPLIED, .premultiplied = GDK_MEMORY_G16A16_PREMULTIPLIED,
.straight = GDK_MEMORY_G16A16, .straight = GDK_MEMORY_G16A16,
@@ -1246,7 +1158,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = { .gl = {
.internal_gl_format = GL_RG16, .internal_gl_format = GL_RG16,
.internal_gles_format = GL_RG16, .internal_gles_format = GL_RG16,
.internal_srgb_format = -1,
.format = GL_RG, .format = GL_RG,
.type = GL_UNSIGNED_SHORT, .type = GL_UNSIGNED_SHORT,
.swizzle = { GL_RED, GL_RED, GL_RED, GL_GREEN }, .swizzle = { GL_RED, GL_RED, GL_RED, GL_GREEN },
@@ -1254,7 +1165,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
}, },
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16G16_UNORM, .vk_format = VK_FORMAT_R16G16_UNORM,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif #endif
#ifdef HAVE_DMABUF #ifdef HAVE_DMABUF
.dmabuf_fourcc = 0, .dmabuf_fourcc = 0,
@@ -1263,7 +1173,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = g16a16_from_float, .from_float = g16a16_from_float,
}, },
[GDK_MEMORY_G16] = { [GDK_MEMORY_G16] = {
.name = "G16",
.alpha = GDK_MEMORY_ALPHA_OPAQUE, .alpha = GDK_MEMORY_ALPHA_OPAQUE,
.premultiplied = GDK_MEMORY_G16, .premultiplied = GDK_MEMORY_G16,
.straight = GDK_MEMORY_G16, .straight = GDK_MEMORY_G16,
@@ -1280,7 +1189,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = { .gl = {
.internal_gl_format = GL_R16, .internal_gl_format = GL_R16,
.internal_gles_format = GL_R16, .internal_gles_format = GL_R16,
.internal_srgb_format = -1,
.format = GL_RED, .format = GL_RED,
.type = GL_UNSIGNED_SHORT, .type = GL_UNSIGNED_SHORT,
.swizzle = { GL_RED, GL_RED, GL_RED, GL_ONE }, .swizzle = { GL_RED, GL_RED, GL_RED, GL_ONE },
@@ -1288,7 +1196,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
}, },
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16_UNORM, .vk_format = VK_FORMAT_R16_UNORM,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif #endif
#ifdef HAVE_DMABUF #ifdef HAVE_DMABUF
.dmabuf_fourcc = DRM_FORMAT_R16, .dmabuf_fourcc = DRM_FORMAT_R16,
@@ -1297,7 +1204,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = g16_from_float, .from_float = g16_from_float,
}, },
[GDK_MEMORY_A8] = { [GDK_MEMORY_A8] = {
.name = "A8",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED, .alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_A8, .premultiplied = GDK_MEMORY_A8,
.straight = GDK_MEMORY_A8, .straight = GDK_MEMORY_A8,
@@ -1311,7 +1217,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = { .gl = {
.internal_gl_format = GL_R8, .internal_gl_format = GL_R8,
.internal_gles_format = GL_R8, .internal_gles_format = GL_R8,
.internal_srgb_format = -1,
.format = GL_RED, .format = GL_RED,
.type = GL_UNSIGNED_BYTE, .type = GL_UNSIGNED_BYTE,
.swizzle = { GL_RED, GL_RED, GL_RED, GL_RED }, .swizzle = { GL_RED, GL_RED, GL_RED, GL_RED },
@@ -1319,7 +1224,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
}, },
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R8_UNORM, .vk_format = VK_FORMAT_R8_UNORM,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif #endif
#ifdef HAVE_DMABUF #ifdef HAVE_DMABUF
.dmabuf_fourcc = 0, .dmabuf_fourcc = 0,
@@ -1328,7 +1232,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = a8_from_float, .from_float = a8_from_float,
}, },
[GDK_MEMORY_A16] = { [GDK_MEMORY_A16] = {
.name = "A16",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED, .alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_A16, .premultiplied = GDK_MEMORY_A16,
.straight = GDK_MEMORY_A16, .straight = GDK_MEMORY_A16,
@@ -1345,7 +1248,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = { .gl = {
.internal_gl_format = GL_R16, .internal_gl_format = GL_R16,
.internal_gles_format = GL_R16, .internal_gles_format = GL_R16,
.internal_srgb_format = -1,
.format = GL_RED, .format = GL_RED,
.type = GL_UNSIGNED_SHORT, .type = GL_UNSIGNED_SHORT,
.swizzle = { GL_RED, GL_RED, GL_RED, GL_RED }, .swizzle = { GL_RED, GL_RED, GL_RED, GL_RED },
@@ -1353,7 +1255,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
}, },
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16_UNORM, .vk_format = VK_FORMAT_R16_UNORM,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif #endif
#ifdef HAVE_DMABUF #ifdef HAVE_DMABUF
.dmabuf_fourcc = 0, .dmabuf_fourcc = 0,
@@ -1362,7 +1263,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = a16_from_float, .from_float = a16_from_float,
}, },
[GDK_MEMORY_A16_FLOAT] = { [GDK_MEMORY_A16_FLOAT] = {
.name = "A16f",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED, .alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_A16_FLOAT, .premultiplied = GDK_MEMORY_A16_FLOAT,
.straight = GDK_MEMORY_A16_FLOAT, .straight = GDK_MEMORY_A16_FLOAT,
@@ -1378,7 +1278,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = { .gl = {
.internal_gl_format = GL_R16F, .internal_gl_format = GL_R16F,
.internal_gles_format = GL_R16F, .internal_gles_format = GL_R16F,
.internal_srgb_format = -1,
.format = GL_RED, .format = GL_RED,
.type = GL_HALF_FLOAT, .type = GL_HALF_FLOAT,
.swizzle = { GL_RED, GL_RED, GL_RED, GL_RED }, .swizzle = { GL_RED, GL_RED, GL_RED, GL_RED },
@@ -1386,7 +1285,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
}, },
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R16_SFLOAT, .vk_format = VK_FORMAT_R16_SFLOAT,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif #endif
#ifdef HAVE_DMABUF #ifdef HAVE_DMABUF
.dmabuf_fourcc = 0, .dmabuf_fourcc = 0,
@@ -1395,7 +1293,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.from_float = a16_float_from_float, .from_float = a16_float_from_float,
}, },
[GDK_MEMORY_A32_FLOAT] = { [GDK_MEMORY_A32_FLOAT] = {
.name = "A32f",
.alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED, .alpha = GDK_MEMORY_ALPHA_PREMULTIPLIED,
.premultiplied = GDK_MEMORY_A32_FLOAT, .premultiplied = GDK_MEMORY_A32_FLOAT,
.straight = GDK_MEMORY_A32_FLOAT, .straight = GDK_MEMORY_A32_FLOAT,
@@ -1411,7 +1308,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
.gl = { .gl = {
.internal_gl_format = GL_R32F, .internal_gl_format = GL_R32F,
.internal_gles_format = GL_R32F, .internal_gles_format = GL_R32F,
.internal_srgb_format = -1,
.format = GL_RED, .format = GL_RED,
.type = GL_FLOAT, .type = GL_FLOAT,
.swizzle = { GL_RED, GL_RED, GL_RED, GL_RED }, .swizzle = { GL_RED, GL_RED, GL_RED, GL_RED },
@@ -1419,7 +1315,6 @@ static const GdkMemoryFormatDescription memory_formats[] = {
}, },
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
.vk_format = VK_FORMAT_R32_SFLOAT, .vk_format = VK_FORMAT_R32_SFLOAT,
.vk_srgb_format = VK_FORMAT_UNDEFINED,
#endif #endif
#ifdef HAVE_DMABUF #ifdef HAVE_DMABUF
.dmabuf_fourcc = 0, .dmabuf_fourcc = 0,
@@ -1614,7 +1509,6 @@ void
gdk_memory_format_gl_format (GdkMemoryFormat format, gdk_memory_format_gl_format (GdkMemoryFormat format,
gboolean gles, gboolean gles,
GLint *out_internal_format, GLint *out_internal_format,
GLint *out_internal_srgb_format,
GLenum *out_format, GLenum *out_format,
GLenum *out_type, GLenum *out_type,
GLint out_swizzle[4]) 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; *out_internal_format = memory_formats[format].gl.internal_gles_format;
else else
*out_internal_format = memory_formats[format].gl.internal_gl_format; *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_format = memory_formats[format].gl.format;
*out_type = memory_formats[format].gl.type; *out_type = memory_formats[format].gl.type;
memcpy (out_swizzle, memory_formats[format].gl.swizzle, sizeof(GLint) * 4); 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 * @gles: TRUE for GLES, FALSE for GL
* @out_actual_format: The actual RGBA format * @out_actual_format: The actual RGBA format
* @out_internal_format: the GL internal 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_format: the GL format
* @out_type: the GL type * @out_type: the GL type
* @out_swizzle: The swizzle to use * @out_swizzle: The swizzle to use
@@ -1655,7 +1546,6 @@ gdk_memory_format_gl_rgba_format (GdkMemoryFormat format,
gboolean gles, gboolean gles,
GdkMemoryFormat *out_actual_format, GdkMemoryFormat *out_actual_format,
GLint *out_internal_format, GLint *out_internal_format,
GLint *out_internal_srgb_format,
GLenum *out_format, GLenum *out_format,
GLenum *out_type, GLenum *out_type,
GLint out_swizzle[4]) 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; *out_internal_format = memory_formats[actual].gl.internal_gles_format;
else else
*out_internal_format = memory_formats[actual].gl.internal_gl_format; *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_format = memory_formats[actual].gl.format;
*out_type = memory_formats[actual].gl.type; *out_type = memory_formats[actual].gl.type;
memcpy (out_swizzle, memory_formats[format].gl.rgba_swizzle, sizeof(GLint) * 4); 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; 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() /* Vulkan version of gdk_memory_format_gl_rgba_format()
* Returns VK_FORMAT_UNDEFINED on failure */ * Returns VK_FORMAT_UNDEFINED on failure */
VkFormat VkFormat
@@ -1780,12 +1661,6 @@ gdk_memory_format_get_dmabuf_fourcc (GdkMemoryFormat format)
#endif #endif
} }
const char *
gdk_memory_format_get_name (GdkMemoryFormat format)
{
return memory_formats[format].name;
}
static void static void
premultiply (float *rgba, premultiply (float *rgba,
gsize n) gsize n)
@@ -1833,10 +1708,6 @@ gdk_memory_convert (guchar *dest_data,
g_assert (dest_format < GDK_MEMORY_N_FORMATS); g_assert (dest_format < GDK_MEMORY_N_FORMATS);
g_assert (src_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) if (src_format == dest_format)
{ {
@@ -1922,201 +1793,3 @@ gdk_memory_convert (guchar *dest_data,
g_free (tmp); 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, void gdk_memory_format_gl_format (GdkMemoryFormat format,
gboolean gles, gboolean gles,
GLint *out_internal_format, GLint *out_internal_format,
GLint *out_internal_srgb_format,
GLenum *out_format, GLenum *out_format,
GLenum *out_type, GLenum *out_type,
GLint out_swizzle[4]); GLint out_swizzle[4]);
@@ -65,20 +64,18 @@ gboolean gdk_memory_format_gl_rgba_format (GdkMemoryFormat
gboolean gles, gboolean gles,
GdkMemoryFormat *out_actual_format, GdkMemoryFormat *out_actual_format,
GLint *out_internal_format, GLint *out_internal_format,
GLint *out_internal_srgb_format,
GLenum *out_format, GLenum *out_format,
GLenum *out_type, GLenum *out_type,
GLint out_swizzle[4]); GLint out_swizzle[4]);
#ifdef GDK_RENDERING_VULKAN #ifdef GDK_RENDERING_VULKAN
VkFormat gdk_memory_format_vk_format (GdkMemoryFormat format, VkFormat gdk_memory_format_vk_format (GdkMemoryFormat format,
VkComponentMapping *out_swizzle); VkComponentMapping *out_swizzle);
VkFormat gdk_memory_format_vk_srgb_format (GdkMemoryFormat format);
VkFormat gdk_memory_format_vk_rgba_format (GdkMemoryFormat format, VkFormat gdk_memory_format_vk_rgba_format (GdkMemoryFormat format,
GdkMemoryFormat *out_rgba_format, GdkMemoryFormat *out_rgba_format,
VkComponentMapping *out_swizzle); VkComponentMapping *out_swizzle);
#endif #endif
guint32 gdk_memory_format_get_dmabuf_fourcc (GdkMemoryFormat format); 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, void gdk_memory_convert (guchar *dest_data,
gsize dest_stride, gsize dest_stride,
@@ -88,13 +85,6 @@ void gdk_memory_convert (guchar
GdkMemoryFormat src_format, GdkMemoryFormat src_format,
gsize width, gsize width,
gsize height); 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 G_END_DECLS
+11 -5
View File
@@ -202,7 +202,8 @@ gdk_memory_texture_new_subtexture (GdkMemoryTexture *source,
} }
GdkMemoryTexture * GdkMemoryTexture *
gdk_memory_texture_from_texture (GdkTexture *texture) gdk_memory_texture_from_texture (GdkTexture *texture,
GdkMemoryFormat format)
{ {
GdkTexture *result; GdkTexture *result;
GBytes *bytes; GBytes *bytes;
@@ -212,16 +213,21 @@ gdk_memory_texture_from_texture (GdkTexture *texture)
g_return_val_if_fail (GDK_IS_TEXTURE (texture), NULL); g_return_val_if_fail (GDK_IS_TEXTURE (texture), NULL);
if (GDK_IS_MEMORY_TEXTURE (texture)) 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); 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); bytes = g_bytes_new_take (data, stride * texture->height);
result = gdk_memory_texture_new (texture->width, result = gdk_memory_texture_new (texture->width,
texture->height, texture->height,
texture->format, format,
bytes, bytes,
stride); stride);
g_bytes_unref (bytes); 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_OPAQUE GDK_MEMORY_R8G8B8
#define GDK_MEMORY_GDK_PIXBUF_ALPHA GDK_MEMORY_R8G8B8A8 #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, GdkTexture * gdk_memory_texture_new_subtexture (GdkMemoryTexture *texture,
int x, int x,
int y, 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); 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 && 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); gdk_gl_context_clear_current_if_surface (self);
eglDestroySurface (gdk_display_get_egl_display (display), priv->egl_surface); 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) 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), priv->egl_surface = eglCreateWindowSurface (gdk_display_get_egl_display (display),
high_depth ? gdk_display_get_egl_config_high_depth (display) high_depth ? gdk_display_get_egl_config_high_depth (display)
: gdk_display_get_egl_config (display), : gdk_display_get_egl_config (display),
(EGLNativeWindowType) priv->egl_native_window, (EGLNativeWindowType) priv->egl_native_window,
attribs); NULL);
priv->egl_surface_high_depth = high_depth; priv->egl_surface_high_depth = high_depth;
self->is_srgb = !high_depth && display->have_egl_gl_colorspace;
} }
#endif #endif
} }
gboolean
gdk_surface_get_gl_is_srgb (GdkSurface *self)
{
return self->is_srgb;
}
GdkGLContext * GdkGLContext *
gdk_surface_get_paint_gl_context (GdkSurface *surface, gdk_surface_get_paint_gl_context (GdkSurface *surface,
GError **error) GError **error)
-3
View File
@@ -70,7 +70,6 @@ struct _GdkSurface
guint shortcuts_inhibited : 1; guint shortcuts_inhibited : 1;
guint request_motion : 1; guint request_motion : 1;
guint has_pointer : 1; guint has_pointer : 1;
guint is_srgb : 1;
guint request_motion_id; guint request_motion_id;
@@ -303,8 +302,6 @@ void gdk_surface_ensure_egl_surface (GdkSurface
gboolean hdr); gboolean hdr);
gpointer /*EGLSurface*/ gdk_surface_get_egl_surface (GdkSurface *self); 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, void gdk_surface_set_widget (GdkSurface *self,
gpointer widget); gpointer widget);
gpointer gdk_surface_get_widget (GdkSurface *self); gpointer gdk_surface_get_widget (GdkSurface *self);
-50
View File
@@ -44,7 +44,6 @@
#include "gdkmemorytextureprivate.h" #include "gdkmemorytextureprivate.h"
#include "gdkpaintable.h" #include "gdkpaintable.h"
#include "gdksnapshot.h" #include "gdksnapshot.h"
#include "gdkcolorstateprivate.h"
#include <graphene.h> #include <graphene.h>
#include "loaders/gdkpngprivate.h" #include "loaders/gdkpngprivate.h"
@@ -70,7 +69,6 @@ enum {
PROP_0, PROP_0,
PROP_WIDTH, PROP_WIDTH,
PROP_HEIGHT, PROP_HEIGHT,
PROP_COLOR_STATE,
N_PROPS N_PROPS
}; };
@@ -284,15 +282,6 @@ gdk_texture_set_property (GObject *gobject,
self->height = g_value_get_int (value); self->height = g_value_get_int (value);
break; 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: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
break; break;
@@ -317,10 +306,6 @@ gdk_texture_get_property (GObject *gobject,
g_value_set_int (value, self->height); g_value_set_int (value, self->height);
break; break;
case PROP_COLOR_STATE:
g_value_set_boxed (value, self->color_state);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
break; break;
@@ -359,8 +344,6 @@ gdk_texture_dispose (GObject *object)
gdk_texture_clear_render_data (self); 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); 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_STATIC_STRINGS |
G_PARAM_EXPLICIT_NOTIFY); 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); g_object_class_install_properties (gobject_class, N_PROPS, properties);
} }
static void static void
gdk_texture_init (GdkTexture *self) 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; 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 void
gdk_texture_do_download (GdkTexture *texture, gdk_texture_do_download (GdkTexture *texture,
GdkMemoryFormat format, GdkMemoryFormat format,
-3
View File
@@ -83,9 +83,6 @@ int gdk_texture_get_height (GdkTexture
GDK_AVAILABLE_IN_4_10 GDK_AVAILABLE_IN_4_10
GdkMemoryFormat gdk_texture_get_format (GdkTexture *self) G_GNUC_PURE; 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 GDK_AVAILABLE_IN_ALL
void gdk_texture_download (GdkTexture *texture, void gdk_texture_download (GdkTexture *texture,
guchar *data, guchar *data,
-2
View File
@@ -26,8 +26,6 @@ struct _GdkTexture
int width; int width;
int height; int height;
GdkColorState *color_state;
gpointer render_key; gpointer render_key;
gpointer render_data; gpointer render_data;
GDestroyNotify render_notify; GDestroyNotify render_notify;
-1
View File
@@ -74,7 +74,6 @@ typedef cairo_rectangle_int_t GdkRectangle;
/* Forward declarations of commonly used types */ /* Forward declarations of commonly used types */
typedef struct _GdkRGBA GdkRGBA; typedef struct _GdkRGBA GdkRGBA;
typedef struct _GdkColorState GdkColorState;
typedef struct _GdkContentFormats GdkContentFormats; typedef struct _GdkContentFormats GdkContentFormats;
typedef struct _GdkContentProvider GdkContentProvider; typedef struct _GdkContentProvider GdkContentProvider;
typedef struct _GdkCursor GdkCursor; typedef struct _GdkCursor GdkCursor;
+3 -20
View File
@@ -30,7 +30,6 @@
#include "gdkdmabuftextureprivate.h" #include "gdkdmabuftextureprivate.h"
#include "gdkdisplayprivate.h" #include "gdkdisplayprivate.h"
#include "gdkprofilerprivate.h" #include "gdkprofilerprivate.h"
#include "gdkmemorytexture.h"
#include <glib/gi18n-lib.h> #include <glib/gi18n-lib.h>
#include <math.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) if (priv->formats[depth].gdk_format != priv->formats[priv->current_format].gdk_format)
{ {
GdkMemoryDepth old_format = priv->current_format;
GError *error = NULL; GError *error = NULL;
priv->current_format = depth;
if (!gdk_vulkan_context_check_swapchain (context, &error)) if (!gdk_vulkan_context_check_swapchain (context, &error))
{ {
g_warning ("%s", error->message); g_warning ("%s", error->message);
g_error_free (error); g_error_free (error);
priv->current_format = old_format;
return; return;
} }
} }
priv->current_format = depth;
} }
for (i = 0; i < priv->n_images; i++) for (i = 0; i < priv->n_images; i++)
{ {
@@ -884,9 +880,7 @@ gdk_vulkan_context_real_init (GInitable *initable,
switch ((int) formats[i].format) switch ((int) formats[i].format)
{ {
case VK_FORMAT_B8G8R8A8_UNORM: case VK_FORMAT_B8G8R8A8_UNORM:
case VK_FORMAT_B8G8R8A8_SRGB: if (priv->formats[GDK_MEMORY_U8].vk_format.format == VK_FORMAT_UNDEFINED)
if (priv->formats[GDK_MEMORY_U8].vk_format.format == VK_FORMAT_UNDEFINED ||
priv->formats[GDK_MEMORY_U8].vk_format.format == VK_FORMAT_B8G8R8A8_UNORM)
{ {
priv->formats[GDK_MEMORY_U8].vk_format = formats[i]; priv->formats[GDK_MEMORY_U8].vk_format = formats[i];
priv->formats[GDK_MEMORY_U8].gdk_format = GDK_MEMORY_B8G8R8A8_PREMULTIPLIED; priv->formats[GDK_MEMORY_U8].gdk_format = GDK_MEMORY_B8G8R8A8_PREMULTIPLIED;
@@ -895,9 +889,7 @@ gdk_vulkan_context_real_init (GInitable *initable,
break; break;
case VK_FORMAT_R8G8B8A8_UNORM: case VK_FORMAT_R8G8B8A8_UNORM:
case VK_FORMAT_R8G8B8A8_SRGB: if (priv->formats[GDK_MEMORY_U8].vk_format.format == VK_FORMAT_UNDEFINED)
if (priv->formats[GDK_MEMORY_U8].vk_format.format == VK_FORMAT_UNDEFINED ||
priv->formats[GDK_MEMORY_U8].vk_format.format == VK_FORMAT_R8G8B8A8_UNORM)
{ {
priv->formats[GDK_MEMORY_U8].vk_format = formats[i]; priv->formats[GDK_MEMORY_U8].vk_format = formats[i];
priv->formats[GDK_MEMORY_U8].gdk_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED; 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; 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: * gdk_vulkan_context_get_n_images:
* @context: a `GdkVulkanContext` * @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); VkQueue gdk_vulkan_context_get_queue (GdkVulkanContext *context);
uint32_t gdk_vulkan_context_get_queue_family_index (GdkVulkanContext *context); uint32_t gdk_vulkan_context_get_queue_family_index (GdkVulkanContext *context);
VkFormat gdk_vulkan_context_get_image_format (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); uint32_t gdk_vulkan_context_get_n_images (GdkVulkanContext *context);
VkImage gdk_vulkan_context_get_image (GdkVulkanContext *context, VkImage gdk_vulkan_context_get_image (GdkVulkanContext *context,
guint id); guint id);
-2
View File
@@ -6,7 +6,6 @@ gdk_public_sources = files([
'gdkcairo.c', 'gdkcairo.c',
'gdkcairocontext.c', 'gdkcairocontext.c',
'gdkclipboard.c', 'gdkclipboard.c',
'gdkcolorstate.c',
'gdkcontentdeserializer.c', 'gdkcontentdeserializer.c',
'gdkcontentformats.c', 'gdkcontentformats.c',
'gdkcontentprovider.c', 'gdkcontentprovider.c',
@@ -76,7 +75,6 @@ gdk_public_headers = files([
'gdkcairo.h', 'gdkcairo.h',
'gdkcairocontext.h', 'gdkcairocontext.h',
'gdkclipboard.h', 'gdkclipboard.h',
'gdkcolorstate.h',
'gdkcontentdeserializer.h', 'gdkcontentdeserializer.h',
'gdkcontentformats.h', 'gdkcontentformats.h',
'gdkcontentprovider.h', 'gdkcontentprovider.h',
+1 -17
View File
@@ -3866,25 +3866,9 @@ pointer_surface_leave (void *data,
pointer_surface_update_scale (device); pointer_surface_update_scale (device);
} }
static void
pointer_surface_preferred_buffer_scale (void *data,
struct wl_surface *wl_surface,
int32_t factor)
{
}
static void
pointer_surface_preferred_buffer_transform (void *data,
struct wl_surface *wl_surface,
uint32_t transform)
{
}
static const struct wl_surface_listener pointer_surface_listener = { static const struct wl_surface_listener pointer_surface_listener = {
pointer_surface_enter, pointer_surface_enter,
pointer_surface_leave, pointer_surface_leave
pointer_surface_preferred_buffer_scale,
pointer_surface_preferred_buffer_transform,
}; };
static void static void
-35
View File
@@ -24,7 +24,6 @@
#include "gdkprofilerprivate.h" #include "gdkprofilerprivate.h"
#include <glib/gi18n-lib.h> #include <glib/gi18n-lib.h>
#include "gdksurfaceprivate.h"
#include <cairo-xlib.h> #include <cairo-xlib.h>
@@ -54,9 +53,6 @@ gdk_x11_surface_get_glx_drawable (GdkSurface *surface)
GdkX11Surface *self = GDK_X11_SURFACE (surface); GdkX11Surface *self = GDK_X11_SURFACE (surface);
GdkDisplay *display = gdk_surface_get_display (GDK_SURFACE (self)); GdkDisplay *display = gdk_surface_get_display (GDK_SURFACE (self));
GdkX11Display *display_x11 = GDK_X11_DISPLAY (display); GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
Display *dpy = gdk_x11_display_get_xdisplay (display);
XVisualInfo *visinfo;
int value;
if (self->glx_drawable) if (self->glx_drawable)
return 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), gdk_x11_surface_get_xid (surface),
NULL); 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; return self->glx_drawable;
} }
@@ -767,17 +758,6 @@ visual_is_rgba (XVisualInfo *visinfo)
visinfo->visual->blue_mask == 0x0000ff; 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 #define MAX_GLX_ATTRS 30
static gboolean static gboolean
@@ -797,7 +777,6 @@ gdk_x11_display_create_glx_config (GdkX11Display *self,
WITH_STENCIL_AND_DEPTH_BUFFER, WITH_STENCIL_AND_DEPTH_BUFFER,
NO_ALPHA, NO_ALPHA,
NO_ALPHA_VISUAL, NO_ALPHA_VISUAL,
NO_SRGB,
PERFECT PERFECT
} best_features; } best_features;
int i = 0; int i = 0;
@@ -886,20 +865,6 @@ gdk_x11_display_create_glx_config (GdkX11Display *self,
continue; 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); GDK_DISPLAY_DEBUG (display, OPENGL, "GLX config %u for visual 0x%lX is the perfect choice", i, visinfo->visualid);
best_features = PERFECT; best_features = PERFECT;
*out_visual = visinfo->visual; *out_visual = visinfo->visual;
+1 -7
View File
@@ -1483,7 +1483,6 @@ memory_format_gl_format (GskGLCommandQueue *self,
gboolean ensure_mipmap, gboolean ensure_mipmap,
gboolean *out_can_mipmap, gboolean *out_can_mipmap,
GLint *gl_internalformat, GLint *gl_internalformat,
GLint *gl_internalsrgbformat,
GLenum *gl_format, GLenum *gl_format,
GLenum *gl_type, GLenum *gl_type,
GLint gl_swizzle[4]) GLint gl_swizzle[4])
@@ -1508,7 +1507,6 @@ memory_format_gl_format (GskGLCommandQueue *self,
gdk_memory_format_gl_format (data_format, gdk_memory_format_gl_format (data_format,
gdk_gl_context_get_use_es (self->context), gdk_gl_context_get_use_es (self->context),
gl_internalformat, gl_internalformat,
gl_internalsrgbformat,
gl_format, gl_format,
gl_type, gl_type,
gl_swizzle); gl_swizzle);
@@ -1521,7 +1519,6 @@ memory_format_gl_format (GskGLCommandQueue *self,
gdk_gl_context_get_use_es (self->context), gdk_gl_context_get_use_es (self->context),
&alt_format, &alt_format,
gl_internalformat, gl_internalformat,
gl_internalsrgbformat,
gl_format, gl_format,
gl_type, gl_type,
gl_swizzle)) gl_swizzle))
@@ -1537,7 +1534,6 @@ memory_format_gl_format (GskGLCommandQueue *self,
gdk_memory_format_gl_format (alt_format, gdk_memory_format_gl_format (alt_format,
gdk_gl_context_get_use_es (self->context), gdk_gl_context_get_use_es (self->context),
gl_internalformat, gl_internalformat,
gl_internalsrgbformat,
gl_format, gl_format,
gl_type, gl_type,
gl_swizzle); gl_swizzle);
@@ -1556,7 +1552,6 @@ memory_format_gl_format (GskGLCommandQueue *self,
gdk_memory_format_gl_format (fallbacks[i], gdk_memory_format_gl_format (fallbacks[i],
gdk_gl_context_get_use_es (self->context), gdk_gl_context_get_use_es (self->context),
gl_internalformat, gl_internalformat,
gl_internalsrgbformat,
gl_format, gl_format,
gl_type, gl_type,
gl_swizzle); 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; G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
int width, height; int width, height;
GdkMemoryFormat data_format; GdkMemoryFormat data_format;
GLint gl_internalformat, gl_internalsrgbformat; GLint gl_internalformat;
GLenum gl_format; GLenum gl_format;
GLenum gl_type; GLenum gl_type;
GLint gl_swizzle[4]; GLint gl_swizzle[4];
@@ -1718,7 +1713,6 @@ gsk_gl_command_queue_upload_texture_chunks (GskGLCommandQueue *self,
ensure_mipmap, ensure_mipmap,
out_can_mipmap, out_can_mipmap,
&gl_internalformat, &gl_internalformat,
&gl_internalsrgbformat,
&gl_format, &gl_format,
&gl_type, &gl_type,
gl_swizzle); gl_swizzle);
+3 -2
View File
@@ -972,7 +972,7 @@ gsk_gl_driver_load_texture (GskGLDriver *self,
if (texture_id == 0) 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 download_texture() call may have switched the GL context. Make sure
* the right context is at work again. * 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); 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) if (ensure_mipmap)
{ {
-23
View File
@@ -30,13 +30,6 @@
#include "gskdebugprivate.h" #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 #define MAX_GLYPH_SIZE 128
G_DEFINE_TYPE (GskGLGlyphLibrary, gsk_gl_glyph_library, GSK_TYPE_GL_TEXTURE_LIBRARY) 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; cairo_t *cr;
PangoGlyphString glyph_string; PangoGlyphString glyph_string;
PangoGlyphInfo glyph_info; 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); g_assert (surface != NULL);
@@ -253,12 +236,6 @@ G_GNUC_END_IGNORE_DEPRECATIONS
cairo_destroy (cr); cairo_destroy (cr);
cairo_surface_flush (surface); 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 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_DEFINE_PROGRAM_NO_CLIP (premultiply,
GSK_GL_SHADER_SINGLE (GSK_GL_SHADER_RESOURCE ("premultiply.glsl")), GSK_GL_SHADER_SINGLE (GSK_GL_SHADER_RESOURCE ("premultiply.glsl")),
GSK_GL_NO_UNIFORMS) 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/gdkglcontextprivate.h>
#include <gdk/gdksurfaceprivate.h> #include <gdk/gdksurfaceprivate.h>
#include <gdk/gdksubsurfaceprivate.h> #include <gdk/gdksubsurfaceprivate.h>
#include <gdk/gdkcolorstateprivate.h>
#include <glib/gi18n-lib.h> #include <glib/gi18n-lib.h>
#include <gsk/gskdebugprivate.h> #include <gsk/gskdebugprivate.h>
#include <gsk/gskrendererprivate.h> #include <gsk/gskrendererprivate.h>
@@ -363,7 +362,6 @@ gsk_gl_renderer_render (GskRenderer *renderer,
GdkSurface *surface; GdkSurface *surface;
gboolean clear_framebuffer; gboolean clear_framebuffer;
float scale; float scale;
GdkColorState *target_color_state;
g_assert (GSK_IS_GL_RENDERER (renderer)); g_assert (GSK_IS_GL_RENDERER (renderer));
g_assert (root != NULL); g_assert (root != NULL);
@@ -386,17 +384,6 @@ gsk_gl_renderer_render (GskRenderer *renderer,
gsk_render_node_get_preferred_depth (root), gsk_render_node_get_preferred_depth (root),
update_area); 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); gdk_gl_context_make_current (self->context);
/* Must be called *AFTER* gdk_draw_context_begin_frame() */ /* 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); 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); 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_driver_end_frame (self->driver);
gsk_gl_render_job_free (job); 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); 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); 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_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); texture = gsk_gl_driver_create_gdk_texture (self->driver, texture_id, gdk_format);
gsk_gl_driver_end_frame (self->driver); gsk_gl_driver_end_frame (self->driver);
+10 -85
View File
@@ -33,7 +33,6 @@
#include <gdk/gdkdmabuftexture.h> #include <gdk/gdkdmabuftexture.h>
#include <gdk/gdksurfaceprivate.h> #include <gdk/gdksurfaceprivate.h>
#include <gdk/gdksubsurfaceprivate.h> #include <gdk/gdksubsurfaceprivate.h>
#include <gdk/gdkcolorstateprivate.h>
#include <gsk/gsktransformprivate.h> #include <gsk/gsktransformprivate.h>
#include <gsk/gskroundedrectprivate.h> #include <gsk/gskroundedrectprivate.h>
#include <gsk/gskrectprivate.h> #include <gsk/gskrectprivate.h>
@@ -973,28 +972,11 @@ gsk_gl_render_job_update_clip (GskGLRenderJob *job,
return TRUE; 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 static inline void
rgba_to_half (const GdkRGBA *rgba, rgba_to_half (const GdkRGBA *rgba,
guint16 h[4]) guint16 h[4])
{ {
float v[4]; float_to_half4 ((const float *)rgba, h);
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);
} }
/* fill_vertex_data */ /* fill_vertex_data */
@@ -3695,11 +3677,8 @@ gsk_gl_render_job_visit_texture (GskGLRenderJob *job,
g_assert (offscreen.texture_id); g_assert (offscreen.texture_id);
g_assert (offscreen.was_offscreen == FALSE); 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, gsk_gl_program_set_uniform_texture_with_sync (job->current_program,
UNIFORM_SHARED_SOURCE, 0, UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D, GL_TEXTURE_2D,
@@ -3725,7 +3704,7 @@ gsk_gl_render_job_visit_texture (GskGLRenderJob *job,
g_assert (slices != NULL); g_assert (slices != NULL);
g_assert (n_slices > 0); 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++) for (unsigned int i = 0; i < n_slices; i++)
{ {
@@ -3739,9 +3718,6 @@ gsk_gl_render_job_visit_texture (GskGLRenderJob *job,
if (i > 0) if (i > 0)
gsk_gl_render_job_split_draw (job); 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, gsk_gl_program_set_uniform_texture_with_filter (job->current_program,
UNIFORM_SHARED_SOURCE, 0, UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D, 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; 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; 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, gsk_gl_program_set_uniform_texture_with_sync (job->current_program,
UNIFORM_SHARED_SOURCE, 0, UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D, 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); 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++) 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) if (i > 0)
gsk_gl_render_job_split_draw (job); 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, gsk_gl_program_set_uniform_texture_with_filter (job->current_program,
UNIFORM_SHARED_SOURCE, 0, UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D, 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); gsk_gl_driver_cache_texture (job->driver, &key, texture_id);
render_texture: 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, gsk_gl_program_set_uniform_texture (job->current_program,
UNIFORM_SHARED_SOURCE, 0, UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D, GL_TEXTURE_2D,
@@ -4497,8 +4464,7 @@ gsk_gl_render_job_visit_node_with_offscreen (GskGLRenderJob *job,
void void
gsk_gl_render_job_render_flipped (GskGLRenderJob *job, gsk_gl_render_job_render_flipped (GskGLRenderJob *job,
GskRenderNode *root, GskRenderNode *root)
GdkColorState *target_color_state)
{ {
graphene_matrix_t proj; graphene_matrix_t proj;
guint framebuffer_id; 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_render_job_set_alpha (job, 1.0f);
gsk_gl_command_queue_bind_framebuffer (job->command_queue, job->framebuffer); gsk_gl_command_queue_bind_framebuffer (job->command_queue, job->framebuffer);
gsk_gl_command_queue_clear (job->command_queue, 0, &job->viewport); gsk_gl_command_queue_clear (job->command_queue, 0, &job->viewport);
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit)))
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 (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, gsk_gl_program_set_uniform_texture (job->current_program,
UNIFORM_SHARED_SOURCE, 0, UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D, GL_TEXTURE_2D,
@@ -4571,8 +4528,7 @@ gsk_gl_render_job_render_flipped (GskGLRenderJob *job,
void void
gsk_gl_render_job_render (GskGLRenderJob *job, gsk_gl_render_job_render (GskGLRenderJob *job,
GskRenderNode *root, GskRenderNode *root)
GdkColorState *target_color_state)
{ {
G_GNUC_UNUSED gint64 start_time; G_GNUC_UNUSED gint64 start_time;
float scale; float scale;
@@ -4595,38 +4551,7 @@ gsk_gl_render_job_render (GskGLRenderJob *job,
gsk_gl_command_queue_bind_framebuffer (job->command_queue, job->framebuffer); gsk_gl_command_queue_bind_framebuffer (job->command_queue, job->framebuffer);
if (job->clear_framebuffer) if (job->clear_framebuffer)
gsk_gl_command_queue_clear (job->command_queue, 0, &job->viewport); gsk_gl_command_queue_clear (job->command_queue, 0, &job->viewport);
gsk_gl_render_job_visit_node (job, root);
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);
}
}
gdk_gl_context_pop_debug_group (job->command_queue->context); gdk_gl_context_pop_debug_group (job->command_queue->context);
gdk_profiler_end_mark (start_time, "Build GL command queue", ""); 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); gboolean clear_framebuffer);
void gsk_gl_render_job_free (GskGLRenderJob *job); void gsk_gl_render_job_free (GskGLRenderJob *job);
void gsk_gl_render_job_render (GskGLRenderJob *job, void gsk_gl_render_job_render (GskGLRenderJob *job,
GskRenderNode *root, GskRenderNode *root);
GdkColorState *color_state);
void gsk_gl_render_job_render_flipped (GskGLRenderJob *job, void gsk_gl_render_job_render_flipped (GskGLRenderJob *job,
GskRenderNode *root, GskRenderNode *root);
GdkColorState *color_state);
-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/gdkdisplayprivate.h"
#include "gdk/gdkglcontextprivate.h" #include "gdk/gdkglcontextprivate.h"
#include "gdk/gdkprofilerprivate.h" #include "gdk/gdkprofilerprivate.h"
#include "gdk/gdkcolorstateprivate.h"
#include <glib/gi18n-lib.h> #include <glib/gi18n-lib.h>
@@ -77,7 +76,6 @@ gsk_gl_device_create_offscreen_image (GskGpuDevice *device,
return gsk_gl_image_new (self, return gsk_gl_image_new (self,
gdk_memory_depth_get_format (depth), gdk_memory_depth_get_format (depth),
GDK_COLOR_STATE_SRGB_LINEAR,
GSK_GPU_IMAGE_RENDERABLE | GSK_GPU_IMAGE_FILTERABLE, GSK_GPU_IMAGE_RENDERABLE | GSK_GPU_IMAGE_FILTERABLE,
width, width,
height); height);
@@ -87,7 +85,6 @@ static GskGpuImage *
gsk_gl_device_create_upload_image (GskGpuDevice *device, gsk_gl_device_create_upload_image (GskGpuDevice *device,
gboolean with_mipmap, gboolean with_mipmap,
GdkMemoryFormat format, GdkMemoryFormat format,
GdkColorState *color_state,
gsize width, gsize width,
gsize height) gsize height)
{ {
@@ -95,7 +92,6 @@ gsk_gl_device_create_upload_image (GskGpuDevice *device,
return gsk_gl_image_new (self, return gsk_gl_image_new (self,
format, format,
color_state,
0, 0,
width, width,
height); height);
@@ -111,7 +107,6 @@ gsk_gl_device_create_download_image (GskGpuDevice *device,
return gsk_gl_image_new (self, return gsk_gl_image_new (self,
gdk_memory_depth_get_format (depth), gdk_memory_depth_get_format (depth),
GDK_COLOR_STATE_SRGB_LINEAR,
GSK_GPU_IMAGE_RENDERABLE, GSK_GPU_IMAGE_RENDERABLE,
width, width,
height); height);
@@ -126,7 +121,6 @@ gsk_gl_device_create_atlas_image (GskGpuDevice *device,
return gsk_gl_image_new (self, return gsk_gl_image_new (self,
GDK_MEMORY_DEFAULT, GDK_MEMORY_DEFAULT,
GDK_COLOR_STATE_SRGB_LINEAR,
GSK_GPU_IMAGE_RENDERABLE, GSK_GPU_IMAGE_RENDERABLE,
width, width,
height); height);
@@ -641,7 +635,6 @@ gsk_gl_device_find_gl_format (GskGLDevice *self,
GdkMemoryFormat *out_format, GdkMemoryFormat *out_format,
GskGpuImageFlags *out_flags, GskGpuImageFlags *out_flags,
GLint *out_gl_internal_format, GLint *out_gl_internal_format,
GLint *out_gl_internal_srgb_format,
GLenum *out_gl_format, GLenum *out_gl_format,
GLenum *out_gl_type, GLenum *out_gl_type,
GLint out_swizzle[4]) GLint out_swizzle[4])
@@ -661,7 +654,6 @@ gsk_gl_device_find_gl_format (GskGLDevice *self,
gdk_memory_format_gl_format (format, gdk_memory_format_gl_format (format,
gdk_gl_context_get_use_es (context), gdk_gl_context_get_use_es (context),
out_gl_internal_format, out_gl_internal_format,
out_gl_internal_srgb_format,
out_gl_format, out_gl_format,
out_gl_type, out_gl_type,
out_swizzle); out_swizzle);
@@ -673,7 +665,6 @@ gsk_gl_device_find_gl_format (GskGLDevice *self,
gdk_gl_context_get_use_es (context), gdk_gl_context_get_use_es (context),
&alt_format, &alt_format,
out_gl_internal_format, out_gl_internal_format,
out_gl_internal_srgb_format,
out_gl_format, out_gl_format,
out_gl_type, out_gl_type,
out_swizzle) && out_swizzle) &&
@@ -697,7 +688,6 @@ gsk_gl_device_find_gl_format (GskGLDevice *self,
gdk_memory_format_gl_format (fallbacks[i], gdk_memory_format_gl_format (fallbacks[i],
gdk_gl_context_get_use_es (context), gdk_gl_context_get_use_es (context),
out_gl_internal_format, out_gl_internal_format,
out_gl_internal_srgb_format,
out_gl_format, out_gl_format,
out_gl_type, out_gl_type,
out_swizzle); out_swizzle);
-1
View File
@@ -26,7 +26,6 @@ void gsk_gl_device_find_gl_format (GskGLDe
GdkMemoryFormat *out_format, GdkMemoryFormat *out_format,
GskGpuImageFlags *out_flags, GskGpuImageFlags *out_flags,
GLint *out_gl_internal_format, GLint *out_gl_internal_format,
GLint *out_gl_internal_srgb_format,
GLenum *out_gl_format, GLenum *out_gl_format,
GLenum *out_gl_type, GLenum *out_gl_type,
GLint out_swizzle[4]); GLint out_swizzle[4]);
+5 -41
View File
@@ -1,10 +1,9 @@
#include "config.h" #include "config.h"
#include "gskglimageprivate.h" #include "gskglimageprivate.h"
#include "gdk/gdkdisplayprivate.h" #include "gdk/gdkdisplayprivate.h"
#include "gdk/gdkglcontextprivate.h" #include "gdk/gdkglcontextprivate.h"
#include "gdk/gdkcolorstateprivate.h"
struct _GskGLImage struct _GskGLImage
{ {
@@ -74,13 +73,11 @@ gsk_gl_image_new_backbuffer (GskGLDevice *device,
GdkGLContext *context, GdkGLContext *context,
GdkMemoryFormat format, GdkMemoryFormat format,
gsize width, gsize width,
gsize height, gsize height)
gboolean is_srgb)
{ {
GskGLImage *self; GskGLImage *self;
GskGpuImageFlags flags; GskGpuImageFlags flags;
GLint swizzle[4]; GLint swizzle[4];
GLint gl_internal_format, gl_internal_srgb_format;
self = g_object_new (GSK_TYPE_GL_IMAGE, NULL); self = g_object_new (GSK_TYPE_GL_IMAGE, NULL);
@@ -90,25 +87,11 @@ gsk_gl_image_new_backbuffer (GskGLDevice *device,
0, 0,
&format, &format,
&flags, &flags,
&gl_internal_format, &self->gl_internal_format,
&gl_internal_srgb_format,
&self->gl_format, &self->gl_format,
&self->gl_type, &self->gl_type,
swizzle); 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); gsk_gpu_image_setup (GSK_GPU_IMAGE (self), flags, format, width, height);
/* texture_id == 0 means backbuffer */ /* texture_id == 0 means backbuffer */
@@ -126,7 +109,6 @@ gsk_gl_image_new_backbuffer (GskGLDevice *device,
GskGpuImage * GskGpuImage *
gsk_gl_image_new (GskGLDevice *device, gsk_gl_image_new (GskGLDevice *device,
GdkMemoryFormat format, GdkMemoryFormat format,
GdkColorState *color_state,
GskGpuImageFlags required_flags, GskGpuImageFlags required_flags,
gsize width, gsize width,
gsize height) gsize height)
@@ -134,7 +116,6 @@ gsk_gl_image_new (GskGLDevice *device,
GskGLImage *self; GskGLImage *self;
GLint swizzle[4]; GLint swizzle[4];
GskGpuImageFlags flags; GskGpuImageFlags flags;
GLint gl_internal_format, gl_internal_srgb_format;
gsize max_size; gsize max_size;
max_size = gsk_gpu_device_get_max_image_size (GSK_GPU_DEVICE (device)); 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, required_flags,
&format, &format,
&flags, &flags,
&gl_internal_format, &self->gl_internal_format,
&gl_internal_srgb_format,
&self->gl_format, &self->gl_format,
&self->gl_type, &self->gl_type,
swizzle); 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), gsk_gpu_image_setup (GSK_GPU_IMAGE (self),
flags, flags,
format, format,
@@ -208,7 +177,6 @@ gsk_gl_image_new_for_texture (GskGLDevice *device,
GdkMemoryFormat format, real_format; GdkMemoryFormat format, real_format;
GskGpuImageFlags flags; GskGpuImageFlags flags;
GskGLImage *self; GskGLImage *self;
GLint gl_internal_format, gl_internal_srgb_format;
GLint swizzle[4]; GLint swizzle[4];
format = gdk_texture_get_format (owner); format = gdk_texture_get_format (owner);
@@ -220,14 +188,10 @@ gsk_gl_image_new_for_texture (GskGLDevice *device,
0, 0,
&real_format, &real_format,
&flags, &flags,
&gl_internal_format, &self->gl_internal_format,
&gl_internal_srgb_format,
&self->gl_format, &self->gl_format,
&self->gl_type, &self->gl_type,
swizzle); swizzle);
self->gl_internal_format = gl_internal_format;
if (format != real_format) if (format != real_format)
flags = GSK_GPU_IMAGE_NO_BLIT | flags = GSK_GPU_IMAGE_NO_BLIT |
(gdk_memory_format_alpha (format) == GDK_MEMORY_ALPHA_STRAIGHT ? GSK_GPU_IMAGE_STRAIGHT_ALPHA : 0); (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, GdkGLContext *context,
GdkMemoryFormat format, GdkMemoryFormat format,
gsize width, gsize width,
gsize height, gsize height);
gboolean converts_srgb);
GskGpuImage * gsk_gl_image_new (GskGLDevice *device, GskGpuImage * gsk_gl_image_new (GskGLDevice *device,
GdkMemoryFormat format, GdkMemoryFormat format,
GdkColorState *color_state,
GskGpuImageFlags required_flags, GskGpuImageFlags required_flags,
gsize width, gsize width,
gsize height); gsize height);
-1
View File
@@ -23,7 +23,6 @@ gsk_gpu_blend_mode_op_print_instance (GskGpuShaderOp *shader,
{ {
GskGpuBlendmodeInstance *instance = (GskGpuBlendmodeInstance *) instance_; 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_rect (string, instance->rect);
gsk_gpu_print_image_descriptor (string, shader->desc, instance->bottom_id); gsk_gpu_print_image_descriptor (string, shader->desc, instance->bottom_id);
gsk_gpu_print_enum (string, GSK_TYPE_BLEND_MODE, shader->variation); 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) const float *color2)
{ {
return gdk_rgba_equal (&(GdkRGBA) { color1[0], color1[1], color1[2], color1[3] }, 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 static void
+14 -5
View File
@@ -14,7 +14,7 @@ struct _GskGpuClearOp
GskGpuOp op; GskGpuOp op;
cairo_rectangle_int_t rect; cairo_rectangle_int_t rect;
float color[4]; GdkRGBA color;
}; };
static void static void
@@ -29,14 +29,23 @@ gsk_gpu_clear_op_print (GskGpuOp *op,
guint indent) guint indent)
{ {
GskGpuClearOp *self = (GskGpuClearOp *) op; GskGpuClearOp *self = (GskGpuClearOp *) op;
float rgba[4];
gsk_gpu_print_op (string, indent, "clear"); gsk_gpu_print_op (string, indent, "clear");
gsk_gpu_print_int_rect (string, &self->rect); 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); gsk_gpu_print_newline (string);
} }
#ifdef GDK_RENDERING_VULKAN #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 * static GskGpuOp *
gsk_gpu_clear_op_vk_command (GskGpuOp *op, gsk_gpu_clear_op_vk_command (GskGpuOp *op,
GskGpuFrame *frame, GskGpuFrame *frame,
@@ -45,7 +54,7 @@ gsk_gpu_clear_op_vk_command (GskGpuOp *op,
GskGpuClearOp *self = (GskGpuClearOp *) op; GskGpuClearOp *self = (GskGpuClearOp *) op;
VkClearValue clear_value; 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, vkCmdClearAttachments (state->vk_command_buffer,
1, 1,
@@ -83,7 +92,7 @@ gsk_gpu_clear_op_gl_command (GskGpuOp *op,
else else
glScissor (self->rect.x, self->rect.y, self->rect.width, self->rect.height); 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); glClear (GL_COLOR_BUFFER_BIT);
glScissor (scissor[0], scissor[1], scissor[2], scissor[3]); 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 = (GskGpuClearOp *) gsk_gpu_op_alloc (frame, &GSK_GPU_CLEAR_OP_CLASS);
self->rect = *rect; 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/gskdebugprivate.h"
#include "gsk/gskprivate.h" #include "gsk/gskprivate.h"
#include "gdk/gdkcolorstateprivate.h"
#define MAX_SLICES_PER_ATLAS 64 #define MAX_SLICES_PER_ATLAS 64
@@ -253,9 +252,6 @@ struct _GskGpuCachedTexture
GdkTexture *texture; GdkTexture *texture;
GskGpuImage *image; GskGpuImage *image;
GdkColorState *color_state;
GskGpuImage *image2;
GdkColorState *color_state2;
}; };
static void static void
@@ -267,9 +263,6 @@ gsk_gpu_cached_texture_free (GskGpuDevice *device,
gpointer key, value; gpointer key, value;
g_clear_object (&self->image); 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)) 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 * static GskGpuCachedTexture *
gsk_gpu_cached_texture_new (GskGpuDevice *device, gsk_gpu_cached_texture_new (GskGpuDevice *device,
GdkTexture *texture, GdkTexture *texture,
GskGpuImage *image, GskGpuImage *image)
GdkColorState *color_state)
{ {
GskGpuDevicePrivate *priv = gsk_gpu_device_get_instance_private (device); GskGpuDevicePrivate *priv = gsk_gpu_device_get_instance_private (device);
GskGpuCachedTexture *self; 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 = gsk_gpu_cached_new (device, &GSK_GPU_CACHED_TEXTURE_CLASS, NULL);
self->texture = texture; self->texture = texture;
self->image = g_object_ref (image); 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); ((GskGpuCached *)self)->pixels = gsk_gpu_image_get_width (image) * gsk_gpu_image_get_height (image);
self->dead_pixels_counter = &priv->dead_texture_pixels; self->dead_pixels_counter = &priv->dead_texture_pixels;
self->use_count = 2; self->use_count = 2;
@@ -707,14 +696,13 @@ gsk_gpu_device_create_offscreen_image (GskGpuDevice *self,
} }
GskGpuImage * GskGpuImage *
gsk_gpu_device_create_upload_image (GskGpuDevice *self, gsk_gpu_device_create_upload_image (GskGpuDevice *self,
gboolean with_mipmap, gboolean with_mipmap,
GdkMemoryFormat format, GdkMemoryFormat format,
GdkColorState *color_state, gsize width,
gsize width, gsize height)
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 void
@@ -862,65 +850,34 @@ gsk_gpu_device_add_atlas_image (GskGpuDevice *self,
} }
GskGpuImage * GskGpuImage *
gsk_gpu_device_lookup_texture_image (GskGpuDevice *self, gsk_gpu_device_lookup_texture_image (GskGpuDevice *self,
GdkTexture *texture, GdkTexture *texture,
GdkColorState *color_state, gint64 timestamp)
gint64 timestamp)
{ {
GskGpuDevicePrivate *priv = gsk_gpu_device_get_instance_private (self); GskGpuDevicePrivate *priv = gsk_gpu_device_get_instance_private (self);
GskGpuCachedTexture *cache; GskGpuCachedTexture *cache;
GskGpuImage *image;
cache = gdk_texture_get_render_data (texture, self); cache = gdk_texture_get_render_data (texture, self);
if (cache == NULL) if (cache == NULL)
cache = g_hash_table_lookup (priv->texture_cache, texture); cache = g_hash_table_lookup (priv->texture_cache, texture);
if (!cache || gsk_gpu_cached_texture_is_invalid (cache)) if (!cache || !cache->image || 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
return NULL; return NULL;
gsk_gpu_cached_use (self, (GskGpuCached *) cache, timestamp); gsk_gpu_cached_use (self, (GskGpuCached *) cache, timestamp);
return g_object_ref (image); return g_object_ref (cache->image);
} }
void void
gsk_gpu_device_cache_texture_image (GskGpuDevice *self, gsk_gpu_device_cache_texture_image (GskGpuDevice *self,
GdkTexture *texture, GdkTexture *texture,
gint64 timestamp, gint64 timestamp,
GskGpuImage *image, GskGpuImage *image)
GdkColorState *color_state)
{ {
GskGpuCachedTexture *cache; GskGpuCachedTexture *cache;
cache = gdk_texture_get_render_data (texture, self); cache = gsk_gpu_cached_texture_new (self, texture, image);
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);
}
gsk_gpu_cached_use (self, (GskGpuCached *) cache, timestamp); gsk_gpu_cached_use (self, (GskGpuCached *) cache, timestamp);
} }
@@ -993,7 +950,7 @@ gsk_gpu_device_lookup_glyph_image (GskGpuDevice *self,
} }
else 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.x = 0;
rect.origin.y = 0; rect.origin.y = 0;
padding = 0; padding = 0;
+1 -5
View File
@@ -35,7 +35,6 @@ struct _GskGpuDeviceClass
GskGpuImage * (* create_upload_image) (GskGpuDevice *self, GskGpuImage * (* create_upload_image) (GskGpuDevice *self,
gboolean with_mipmap, gboolean with_mipmap,
GdkMemoryFormat format, GdkMemoryFormat format,
GdkColorState *color_state,
gsize width, gsize width,
gsize height); gsize height);
GskGpuImage * (* create_download_image) (GskGpuDevice *self, 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, GskGpuImage * gsk_gpu_device_create_upload_image (GskGpuDevice *self,
gboolean with_mipmap, gboolean with_mipmap,
GdkMemoryFormat format, GdkMemoryFormat format,
GdkColorState *color_state,
gsize width, gsize width,
gsize height); gsize height);
GskGpuImage * gsk_gpu_device_create_download_image (GskGpuDevice *self, 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); void gsk_gpu_device_make_current (GskGpuDevice *self);
GskGpuImage * gsk_gpu_device_lookup_texture_image (GskGpuDevice *self, GskGpuImage * gsk_gpu_device_lookup_texture_image (GskGpuDevice *self,
GdkTexture *texture, GdkTexture *texture,
GdkColorState *color_state,
gint64 timestamp); gint64 timestamp);
void gsk_gpu_device_cache_texture_image (GskGpuDevice *self, void gsk_gpu_device_cache_texture_image (GskGpuDevice *self,
GdkTexture *texture, GdkTexture *texture,
gint64 timestamp, gint64 timestamp,
GskGpuImage *image, GskGpuImage *image);
GdkColorState *color_state);
typedef enum typedef enum
{ {
+2 -52
View File
@@ -12,7 +12,6 @@
#include "gskvulkanimageprivate.h" #include "gskvulkanimageprivate.h"
#endif #endif
#include "gdk/gdkdmabuftexturebuilderprivate.h"
#include "gdk/gdkdmabuftextureprivate.h" #include "gdk/gdkdmabuftextureprivate.h"
#include "gdk/gdkglcontextprivate.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)); GskVulkanDevice *device = GSK_VULKAN_DEVICE (gsk_gpu_frame_get_device (frame));
VkDevice vk_device = gsk_vulkan_device_get_vk_device (device); 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)) 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); 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 * static GskGpuOp *
gsk_gpu_download_op_gl_command (GskGpuOp *op, gsk_gpu_download_op_gl_command (GskGpuOp *op,
GskGpuFrame *frame, GskGpuFrame *frame,
@@ -289,44 +271,12 @@ gsk_gpu_download_op_gl_command (GskGpuOp *op,
GdkGLTextureBuilder *builder; GdkGLTextureBuilder *builder;
GskGLTextureData *data; GskGLTextureData *data;
GdkGLContext *context; GdkGLContext *context;
guint texture_id;
context = GDK_GL_CONTEXT (gsk_gpu_frame_get_context (frame)); 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 = g_new (GskGLTextureData, 1);
data->context = g_object_ref (context); 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)) if (gdk_gl_context_has_feature (context, GDK_GL_FEATURE_SYNC))
data->sync = glFenceSync (GL_SYNC_GPU_COMMANDS_COMPLETE, 0); data->sync = glFenceSync (GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
+8 -24
View File
@@ -17,7 +17,6 @@
#include "gdk/gdkdmabufdownloaderprivate.h" #include "gdk/gdkdmabufdownloaderprivate.h"
#include "gdk/gdktexturedownloaderprivate.h" #include "gdk/gdktexturedownloaderprivate.h"
#include "gdk/gdkcolorstateprivate.h"
#define DEFAULT_VERTEX_BUFFER_SIZE 128 * 1024 #define DEFAULT_VERTEX_BUFFER_SIZE 128 * 1024
@@ -403,26 +402,17 @@ gsk_gpu_frame_get_last_op (GskGpuFrame *self)
} }
GskGpuImage * GskGpuImage *
gsk_gpu_frame_upload_texture (GskGpuFrame *self, gsk_gpu_frame_upload_texture (GskGpuFrame *self,
gboolean with_mipmap, gboolean with_mipmap,
GdkTexture *texture, GdkTexture *texture)
GdkColorState **out_color_state)
{ {
GskGpuFramePrivate *priv = gsk_gpu_frame_get_instance_private (self); GskGpuFramePrivate *priv = gsk_gpu_frame_get_instance_private (self);
GskGpuImage *image; GskGpuImage *image;
GdkColorState *color_state;
image = GSK_GPU_FRAME_GET_CLASS (self)->upload_texture (self, with_mipmap, texture); 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) if (image)
gsk_gpu_device_cache_texture_image (priv->device, texture, priv->timestamp, image, color_state); gsk_gpu_device_cache_texture_image (priv->device, texture, priv->timestamp, image);
*out_color_state = color_state;
return image; return image;
} }
@@ -571,7 +561,6 @@ copy_texture (gpointer user_data,
static void static void
gsk_gpu_frame_record_rect (GskGpuFrame *self, gsk_gpu_frame_record_rect (GskGpuFrame *self,
GskGpuImage *target, GskGpuImage *target,
GdkColorState *target_color_state,
const cairo_rectangle_int_t *clip, const cairo_rectangle_int_t *clip,
GskRenderNode *node, GskRenderNode *node,
const graphene_rect_t *viewport) const graphene_rect_t *viewport)
@@ -583,7 +572,6 @@ gsk_gpu_frame_record_rect (GskGpuFrame *self,
gsk_gpu_node_processor_process (self, gsk_gpu_node_processor_process (self,
target, target,
target_color_state,
clip, clip,
node, node,
viewport); viewport);
@@ -597,7 +585,6 @@ static void
gsk_gpu_frame_record (GskGpuFrame *self, gsk_gpu_frame_record (GskGpuFrame *self,
gint64 timestamp, gint64 timestamp,
GskGpuImage *target, GskGpuImage *target,
GdkColorState *target_color_state,
const cairo_region_t *clip, const cairo_region_t *clip,
GskRenderNode *node, GskRenderNode *node,
const graphene_rect_t *viewport, const graphene_rect_t *viewport,
@@ -616,14 +603,13 @@ gsk_gpu_frame_record (GskGpuFrame *self,
cairo_rectangle_int_t rect; cairo_rectangle_int_t rect;
cairo_region_get_rectangle (clip, i, &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 else
{ {
gsk_gpu_frame_record_rect (self, gsk_gpu_frame_record_rect (self,
target, target,
target_color_state,
&(cairo_rectangle_int_t) { &(cairo_rectangle_int_t) {
0, 0, 0, 0,
gsk_gpu_image_get_width (target), gsk_gpu_image_get_width (target),
@@ -670,7 +656,6 @@ void
gsk_gpu_frame_render (GskGpuFrame *self, gsk_gpu_frame_render (GskGpuFrame *self,
gint64 timestamp, gint64 timestamp,
GskGpuImage *target, GskGpuImage *target,
GdkColorState *target_color_state,
const cairo_region_t *region, const cairo_region_t *region,
GskRenderNode *node, GskRenderNode *node,
const graphene_rect_t *viewport, const graphene_rect_t *viewport,
@@ -678,7 +663,7 @@ gsk_gpu_frame_render (GskGpuFrame *self,
{ {
gsk_gpu_frame_cleanup (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); 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); GskGpuFramePrivate *priv = gsk_gpu_frame_get_instance_private (self);
GskGpuImage *image; 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) 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) if (image == NULL)
{ {
g_critical ("Could not upload texture"); g_critical ("Could not upload texture");
+1 -3
View File
@@ -58,8 +58,7 @@ gpointer gsk_gpu_frame_alloc_op (GskGpuF
gsize size); gsize size);
GskGpuImage * gsk_gpu_frame_upload_texture (GskGpuFrame *self, GskGpuImage * gsk_gpu_frame_upload_texture (GskGpuFrame *self,
gboolean with_mipmap, gboolean with_mipmap,
GdkTexture *texture, GdkTexture *texture);
GdkColorState **out_color_state);
GskGpuDescriptors * gsk_gpu_frame_create_descriptors (GskGpuFrame *self); GskGpuDescriptors * gsk_gpu_frame_create_descriptors (GskGpuFrame *self);
gsize gsk_gpu_frame_reserve_vertex_data (GskGpuFrame *self, gsize gsk_gpu_frame_reserve_vertex_data (GskGpuFrame *self,
gsize size); gsize size);
@@ -76,7 +75,6 @@ void gsk_gpu_frame_wait (GskGpuF
void gsk_gpu_frame_render (GskGpuFrame *self, void gsk_gpu_frame_render (GskGpuFrame *self,
gint64 timestamp, gint64 timestamp,
GskGpuImage *target, GskGpuImage *target,
GdkColorState *target_color_state,
const cairo_region_t *region, const cairo_region_t *region,
GskRenderNode *node, GskRenderNode *node,
const graphene_rect_t *viewport, const graphene_rect_t *viewport,
-2
View File
@@ -5,7 +5,6 @@
#include "gskgpuframeprivate.h" #include "gskgpuframeprivate.h"
#include "gskgpuprintprivate.h" #include "gskgpuprintprivate.h"
#include "gskrectprivate.h" #include "gskrectprivate.h"
#include "gskenumtypes.h"
#include "gpu/shaders/gskgpumaskinstance.h" #include "gpu/shaders/gskgpumaskinstance.h"
@@ -23,7 +22,6 @@ gsk_gpu_mask_op_print_instance (GskGpuShaderOp *shader,
{ {
GskGpuMaskInstance *instance = (GskGpuMaskInstance *) instance_; 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_rect (string, instance->rect);
gsk_gpu_print_image_descriptor (string, shader->desc, instance->source_id); gsk_gpu_print_image_descriptor (string, shader->desc, instance->source_id);
gsk_gpu_print_image_descriptor (string, shader->desc, instance->mask_id); gsk_gpu_print_image_descriptor (string, shader->desc, instance->mask_id);
+24 -201
View File
@@ -10,7 +10,6 @@
#include "gskgpubluropprivate.h" #include "gskgpubluropprivate.h"
#include "gskgpuclearopprivate.h" #include "gskgpuclearopprivate.h"
#include "gskgpuclipprivate.h" #include "gskgpuclipprivate.h"
#include "gskgpucolorconvertopprivate.h"
#include "gskgpucolorizeopprivate.h" #include "gskgpucolorizeopprivate.h"
#include "gskgpucolormatrixopprivate.h" #include "gskgpucolormatrixopprivate.h"
#include "gskgpucoloropprivate.h" #include "gskgpucoloropprivate.h"
@@ -45,7 +44,6 @@
#include "gdk/gdkrgbaprivate.h" #include "gdk/gdkrgbaprivate.h"
#include "gdk/gdksubsurfaceprivate.h" #include "gdk/gdksubsurfaceprivate.h"
#include "gdk/gdkcolorstateprivate.h"
/* the epsilon we allow pixels to be off due to rounding errors. /* the epsilon we allow pixels to be off due to rounding errors.
* Chosen rather randomly. * Chosen rather randomly.
@@ -122,7 +120,6 @@ struct _GskGpuNodeProcessor
float opacity; float opacity;
GskGpuGlobals pending_globals; GskGpuGlobals pending_globals;
GdkColorState *color_state;
}; };
#define GDK_ARRAY_NAME pattern_buffer #define GDK_ARRAY_NAME pattern_buffer
@@ -144,7 +141,6 @@ struct _GskGpuPatternWriter
guint stack; guint stack;
PatternBuffer buffer; PatternBuffer buffer;
GdkColorState *color_state;
}; };
static void gsk_gpu_node_processor_add_node (GskGpuNodeProcessor *self, 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_pointer (&self->modelview, gsk_transform_unref);
g_clear_object (&self->desc); g_clear_object (&self->desc);
g_clear_pointer (&self->color_state, gdk_color_state_unref);
} }
static void static void
@@ -165,7 +160,6 @@ gsk_gpu_node_processor_init (GskGpuNodeProcessor *self,
GskGpuFrame *frame, GskGpuFrame *frame,
GskGpuDescriptors *desc, GskGpuDescriptors *desc,
GskGpuImage *target, GskGpuImage *target,
GdkColorState *color_state,
const cairo_rectangle_int_t *clip, const cairo_rectangle_int_t *clip,
const graphene_rect_t *viewport) const graphene_rect_t *viewport)
{ {
@@ -208,8 +202,6 @@ gsk_gpu_node_processor_init (GskGpuNodeProcessor *self,
-viewport->origin.y); -viewport->origin.y);
self->opacity = 1.0; 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->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 static void
@@ -346,7 +338,6 @@ gsk_gpu_node_processor_init_draw (GskGpuNodeProcessor *self,
GskGpuFrame *frame, GskGpuFrame *frame,
GdkMemoryDepth depth, GdkMemoryDepth depth,
const graphene_vec2_t *scale, const graphene_vec2_t *scale,
GdkColorState *color_state,
const graphene_rect_t *viewport) const graphene_rect_t *viewport)
{ {
GskGpuImage *image; GskGpuImage *image;
@@ -368,7 +359,6 @@ gsk_gpu_node_processor_init_draw (GskGpuNodeProcessor *self,
frame, frame,
NULL, NULL,
image, image,
color_state,
&area, &area,
viewport); viewport);
@@ -391,97 +381,9 @@ gsk_gpu_node_processor_finish_draw (GskGpuNodeProcessor *self,
gsk_gpu_node_processor_finish (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 void
gsk_gpu_node_processor_process (GskGpuFrame *frame, gsk_gpu_node_processor_process (GskGpuFrame *frame,
GskGpuImage *target, GskGpuImage *target,
GdkColorState *target_color_state,
const cairo_rectangle_int_t *clip, const cairo_rectangle_int_t *clip,
GskRenderNode *node, GskRenderNode *node,
const graphene_rect_t *viewport) const graphene_rect_t *viewport)
@@ -492,46 +394,10 @@ gsk_gpu_node_processor_process (GskGpuFrame *frame,
frame, frame,
NULL, NULL,
target, target,
GDK_COLOR_STATE_SRGB_LINEAR,
clip, clip,
viewport); viewport);
if (gdk_color_state_equal (target_color_state, GDK_COLOR_STATE_SRGB_LINEAR)) gsk_gpu_node_processor_add_node (&self, node);
{
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_finish (&self); gsk_gpu_node_processor_finish (&self);
} }
@@ -540,7 +406,6 @@ static void
gsk_gpu_pattern_writer_init (GskGpuPatternWriter *self, gsk_gpu_pattern_writer_init (GskGpuPatternWriter *self,
GskGpuFrame *frame, GskGpuFrame *frame,
const graphene_vec2_t *scale, const graphene_vec2_t *scale,
GdkColorState *color_state,
const graphene_point_t *offset, const graphene_point_t *offset,
const graphene_rect_t *bounds) const graphene_rect_t *bounds)
{ {
@@ -554,8 +419,6 @@ gsk_gpu_pattern_writer_init (GskGpuPatternWriter *self,
self->scale = *scale; self->scale = *scale;
self->stack = 0; self->stack = 0;
self->color_state = gdk_color_state_ref (color_state);
pattern_buffer_init (&self->buffer); pattern_buffer_init (&self->buffer);
} }
@@ -683,7 +546,6 @@ gsk_gpu_pattern_writer_finish (GskGpuPatternWriter *self)
pattern_buffer_clear (&self->buffer); pattern_buffer_clear (&self->buffer);
g_assert (self->stack == 0); g_assert (self->stack == 0);
g_clear_object (&self->desc); g_clear_object (&self->desc);
g_clear_pointer (&self->color_state, gdk_color_state_unref);
} }
static gboolean static gboolean
@@ -802,6 +664,20 @@ gsk_gpu_node_processor_rect_is_integer (GskGpuNodeProcessor *self,
&& int_rect->height == rect->size.height * scale_y; && 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 static gboolean G_GNUC_WARN_UNUSED_RESULT
gsk_gpu_node_processor_clip_node_bounds (GskGpuNodeProcessor *self, gsk_gpu_node_processor_clip_node_bounds (GskGpuNodeProcessor *self,
GskRenderNode *node, GskRenderNode *node,
@@ -866,7 +742,6 @@ gsk_gpu_node_processor_image_op (GskGpuNodeProcessor *self,
static GskGpuImage * static GskGpuImage *
gsk_gpu_node_processor_create_offscreen (GskGpuFrame *frame, gsk_gpu_node_processor_create_offscreen (GskGpuFrame *frame,
const graphene_vec2_t *scale, const graphene_vec2_t *scale,
GdkColorState *color_state,
const graphene_rect_t *viewport, const graphene_rect_t *viewport,
GskRenderNode *node) GskRenderNode *node)
{ {
@@ -877,7 +752,6 @@ gsk_gpu_node_processor_create_offscreen (GskGpuFrame *frame,
frame, frame,
gsk_render_node_get_preferred_depth (node), gsk_render_node_get_preferred_depth (node),
scale, scale,
color_state,
viewport); viewport);
if (image == NULL) if (image == NULL)
return NULL; return NULL;
@@ -894,7 +768,6 @@ gsk_gpu_node_processor_create_offscreen (GskGpuFrame *frame,
* @frame: frame to render in * @frame: frame to render in
* @clip_bounds: region of node that must be included in image * @clip_bounds: region of node that must be included in image
* @scale: scale factor to use for the image * @scale: scale factor to use for the image
* @color_state: the color state to composite in
* @node: the node to render * @node: the node to render
* @out_bounds: the actual bounds of the result * @out_bounds: the actual bounds of the result
* *
@@ -916,12 +789,10 @@ static GskGpuImage *
gsk_gpu_get_node_as_image (GskGpuFrame *frame, gsk_gpu_get_node_as_image (GskGpuFrame *frame,
const graphene_rect_t *clip_bounds, const graphene_rect_t *clip_bounds,
const graphene_vec2_t *scale, const graphene_vec2_t *scale,
GdkColorState *color_state,
GskRenderNode *node, GskRenderNode *node,
graphene_rect_t *out_bounds) graphene_rect_t *out_bounds)
{ {
GskGpuImage *result; GskGpuImage *result;
GdkColorState *image_color_state;
switch ((guint) gsk_render_node_get_node_type (node)) 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); GdkTexture *texture = gsk_texture_node_get_texture (node);
GskGpuDevice *device = gsk_gpu_frame_get_device (frame); GskGpuDevice *device = gsk_gpu_frame_get_device (frame);
gint64 timestamp = gsk_gpu_frame_get_timestamp (frame); gint64 timestamp = gsk_gpu_frame_get_timestamp (frame);
result = gsk_gpu_device_lookup_texture_image (device, texture, timestamp);
result = gsk_gpu_device_lookup_texture_image (device, texture, color_state, timestamp);
if (result == NULL) if (result == NULL)
{ result = gsk_gpu_frame_upload_texture (frame, FALSE, texture);
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);
}
}
if (result) if (result)
{ {
@@ -960,8 +821,6 @@ gsk_gpu_get_node_as_image (GskGpuFrame *frame,
gsk_render_node_ref (node), gsk_render_node_ref (node),
(GDestroyNotify) gsk_render_node_unref); (GDestroyNotify) gsk_render_node_unref);
result = gsk_gpu_color_convert (frame, result, GDK_COLOR_STATE_SRGB, color_state);
g_object_ref (result); g_object_ref (result);
*out_bounds = *clip_bounds; *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)); GSK_DEBUG (FALLBACK, "Offscreening node '%s'", g_type_name_from_instance ((GTypeInstance *) node));
result = gsk_gpu_node_processor_create_offscreen (frame, result = gsk_gpu_node_processor_create_offscreen (frame,
scale, scale,
color_state,
clip_bounds, clip_bounds,
node); node);
@@ -985,7 +843,6 @@ gsk_gpu_get_node_as_image (GskGpuFrame *frame,
static GskGpuImage * static GskGpuImage *
gsk_gpu_node_processor_ensure_image (GskGpuFrame *frame, gsk_gpu_node_processor_ensure_image (GskGpuFrame *frame,
GskGpuImage *image, GskGpuImage *image,
GdkColorState *color_state,
GskGpuImageFlags required_flags, GskGpuImageFlags required_flags,
GskGpuImageFlags disallowed_flags) GskGpuImageFlags disallowed_flags)
{ {
@@ -1038,7 +895,6 @@ gsk_gpu_node_processor_ensure_image (GskGpuFrame *frame,
frame, frame,
NULL, NULL,
copy, copy,
color_state,
&(cairo_rectangle_int_t) { 0, 0, width, height }, &(cairo_rectangle_int_t) { 0, 0, width, height },
&rect); &rect);
@@ -1112,7 +968,6 @@ gsk_gpu_node_processor_get_node_as_image (GskGpuNodeProcessor *self,
image = gsk_gpu_get_node_as_image (self->frame, image = gsk_gpu_get_node_as_image (self->frame,
&clip, &clip,
&self->scale, &self->scale,
self->color_state,
node, node,
out_bounds); out_bounds);
if (image == NULL) 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, ensure = gsk_gpu_node_processor_ensure_image (self->frame,
image, image,
self->color_state,
required_flags, required_flags,
disallowed_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_gpu_device_cache_texture_image (gsk_gpu_frame_get_device (self->frame),
gsk_texture_node_get_texture (node), gsk_texture_node_get_texture (node),
gsk_gpu_frame_get_timestamp (self->frame), gsk_gpu_frame_get_timestamp (self->frame),
ensure, ensure);
self->color_state);
} }
return ensure; return ensure;
@@ -1173,7 +1026,6 @@ gsk_gpu_node_processor_blur_op (GskGpuNodeProcessor *self,
self->frame, self->frame,
source_depth, source_depth,
&self->scale, &self->scale,
self->color_state,
&intermediate_rect); &intermediate_rect);
gsk_gpu_node_processor_sync_globals (&other, 0); 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, gsk_gpu_pattern_writer_init (&writer,
self->frame, self->frame,
&self->scale, &self->scale,
self->color_state,
&self->offset, &self->offset,
&clipped); &clipped);
@@ -1603,7 +1454,6 @@ gsk_gpu_node_processor_add_rounded_clip_node_with_mask (GskGpuNodeProcessor *sel
self->frame, self->frame,
gsk_render_node_get_preferred_depth (node), gsk_render_node_get_preferred_depth (node),
&self->scale, &self->scale,
self->color_state,
&clip_bounds); &clip_bounds);
gsk_gpu_node_processor_sync_globals (&other, 0); gsk_gpu_node_processor_sync_globals (&other, 0);
gsk_gpu_rounded_color_op (other.frame, gsk_gpu_rounded_color_op (other.frame,
@@ -2077,16 +1927,15 @@ gsk_gpu_node_processor_add_texture_node (GskGpuNodeProcessor *self,
GskGpuImage *image; GskGpuImage *image;
GdkTexture *texture; GdkTexture *texture;
gint64 timestamp; gint64 timestamp;
GdkColorState *image_color_state;
device = gsk_gpu_frame_get_device (self->frame); device = gsk_gpu_frame_get_device (self->frame);
texture = gsk_texture_node_get_texture (node); texture = gsk_texture_node_get_texture (node);
timestamp = gsk_gpu_frame_get_timestamp (self->frame); 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) 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) if (image == NULL)
{ {
GSK_DEBUG (FALLBACK, "Unsupported texture format %u for size %dx%d", 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); gsk_gpu_node_processor_add_fallback_node (self, node);
return; 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) && 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 = gsk_gpu_node_processor_ensure_image (self->frame,
image, image,
self->color_state,
GSK_GPU_IMAGE_MIPMAP, GSK_GPU_IMAGE_MIPMAP,
GSK_GPU_IMAGE_STRAIGHT_ALPHA); GSK_GPU_IMAGE_STRAIGHT_ALPHA);
descriptor = gsk_gpu_node_processor_add_image (self, image, GSK_GPU_SAMPLER_MIPMAP_DEFAULT); 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; guint32 descriptor;
GskGpuImage *image; GskGpuImage *image;
GskGpuSampler sampler; GskGpuSampler sampler;
GdkColorState *image_color_state;
device = gsk_gpu_frame_get_device (self->frame); device = gsk_gpu_frame_get_device (self->frame);
texture = gsk_texture_node_get_texture (node); texture = gsk_texture_node_get_texture (node);
timestamp = gsk_gpu_frame_get_timestamp (self->frame); 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) 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) if (image == NULL)
return FALSE; 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) && 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 = gsk_gpu_node_processor_ensure_image (self->frame,
image, image,
self->color_state,
GSK_GPU_IMAGE_MIPMAP, GSK_GPU_IMAGE_MIPMAP,
GSK_GPU_IMAGE_STRAIGHT_ALPHA); GSK_GPU_IMAGE_STRAIGHT_ALPHA);
sampler = GSK_GPU_SAMPLER_MIPMAP_DEFAULT; sampler = GSK_GPU_SAMPLER_MIPMAP_DEFAULT;
@@ -2224,7 +2058,6 @@ gsk_gpu_node_processor_add_texture_scale_node (GskGpuNodeProcessor *self,
gint64 timestamp; gint64 timestamp;
guint32 descriptor; guint32 descriptor;
gboolean need_mipmap, need_offscreen; gboolean need_mipmap, need_offscreen;
GdkColorState *image_color_state;
need_offscreen = self->modelview != NULL || need_offscreen = self->modelview != NULL ||
!graphene_vec2_equal (&self->scale, graphene_vec2_one ()); !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); clip_bounds.size.height = ceilf (clip_bounds.size.height);
offscreen = gsk_gpu_node_processor_create_offscreen (self->frame, offscreen = gsk_gpu_node_processor_create_offscreen (self->frame,
graphene_vec2_one (), graphene_vec2_one (),
self->color_state,
&clip_bounds, &clip_bounds,
node); node);
descriptor = gsk_gpu_node_processor_add_image (self, offscreen, GSK_GPU_SAMPLER_DEFAULT); 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); timestamp = gsk_gpu_frame_get_timestamp (self->frame);
need_mipmap = scaling_filter == GSK_SCALING_FILTER_TRILINEAR; 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) 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) if (image == NULL)
{ {
GSK_DEBUG (FALLBACK, "Unsupported texture format %u for size %dx%d", 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); gsk_gpu_node_processor_add_fallback_node (self, node);
return; 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 = gsk_gpu_node_processor_ensure_image (self->frame,
image, image,
self->color_state,
need_mipmap ? (GSK_GPU_IMAGE_CAN_MIPMAP | GSK_GPU_IMAGE_MIPMAP) : 0, need_mipmap ? (GSK_GPU_IMAGE_CAN_MIPMAP | GSK_GPU_IMAGE_MIPMAP) : 0,
GSK_GPU_IMAGE_STRAIGHT_ALPHA); GSK_GPU_IMAGE_STRAIGHT_ALPHA);
@@ -2456,7 +2282,6 @@ gsk_gpu_node_processor_add_gradient_node (GskGpuNodeProcessor *self,
self->frame, self->frame,
gsk_render_node_get_preferred_depth (node), gsk_render_node_get_preferred_depth (node),
&self->scale, &self->scale,
self->color_state,
&bounds); &bounds);
other.blend = GSK_GPU_BLEND_ADD; 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)); GSK_DEBUG (FALLBACK, "Offscreening node '%s' for tiling", g_type_name_from_instance ((GTypeInstance *) child));
image = gsk_gpu_node_processor_create_offscreen (self->frame, image = gsk_gpu_node_processor_create_offscreen (self->frame,
&self->scale, &self->scale,
self->color_state,
&clipped_child_bounds, &clipped_child_bounds,
child); child);
@@ -4299,7 +4123,6 @@ gsk_gpu_node_processor_create_node_pattern (GskGpuPatternWriter *self,
image = gsk_gpu_get_node_as_image (self->frame, image = gsk_gpu_get_node_as_image (self->frame,
&bounds, &bounds,
&self->scale, &self->scale,
self->color_state,
node, node,
&bounds); &bounds);
if (image == NULL) if (image == NULL)
-1
View File
@@ -7,7 +7,6 @@ G_BEGIN_DECLS
void gsk_gpu_node_processor_process (GskGpuFrame *frame, void gsk_gpu_node_processor_process (GskGpuFrame *frame,
GskGpuImage *target, GskGpuImage *target,
GdkColorState *target_color_state,
const cairo_rectangle_int_t *clip, const cairo_rectangle_int_t *clip,
GskRenderNode *node, GskRenderNode *node,
const graphene_rect_t *viewport); const graphene_rect_t *viewport);
+2 -13
View File
@@ -2,8 +2,6 @@
#include "gskgpuprintprivate.h" #include "gskgpuprintprivate.h"
#include "gdk/gdkrgbaprivate.h"
#include "gdk/gdkcolorstateprivate.h"
#include "gskgpudescriptorsprivate.h" #include "gskgpudescriptorsprivate.h"
#include "gskgpuimageprivate.h" #include "gskgpuimageprivate.h"
@@ -142,10 +140,9 @@ void
gsk_gpu_print_image (GString *string, gsk_gpu_print_image (GString *string,
GskGpuImage *image) 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_width (image),
gsk_gpu_image_get_height (image), gsk_gpu_image_get_height (image));
gdk_memory_format_get_name (gsk_gpu_image_get_format (image)));
} }
void void
@@ -157,11 +154,3 @@ gsk_gpu_print_image_descriptor (GString *string,
gsk_gpu_print_image (string, gsk_gpu_descriptors_get_image (desc, id)); 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, void gsk_gpu_print_image_descriptor (GString *string,
GskGpuDescriptors *desc, GskGpuDescriptors *desc,
guint32 descriptor); 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/gdktextureprivate.h"
#include "gdk/gdktexturedownloaderprivate.h" #include "gdk/gdktexturedownloaderprivate.h"
#include "gdk/gdkdrawcontextprivate.h" #include "gdk/gdkdrawcontextprivate.h"
#include "gdk/gdkcolorstateprivate.h"
#include <graphene.h> #include <graphene.h>
@@ -299,7 +298,6 @@ gsk_gpu_renderer_fallback_render_texture (GskGpuRenderer *self,
gsk_gpu_frame_render (frame, gsk_gpu_frame_render (frame,
g_get_monotonic_time (), g_get_monotonic_time (),
image, image,
GDK_COLOR_STATE_SRGB,
NULL, NULL,
root, root,
&GRAPHENE_RECT_INIT (rounded_viewport->origin.x + x, &GRAPHENE_RECT_INIT (rounded_viewport->origin.x + x,
@@ -362,7 +360,6 @@ gsk_gpu_renderer_render_texture (GskRenderer *renderer,
gsk_gpu_frame_render (frame, gsk_gpu_frame_render (frame,
g_get_monotonic_time (), g_get_monotonic_time (),
image, image,
GDK_COLOR_STATE_SRGB,
NULL, NULL,
root, root,
&rounded_viewport, &rounded_viewport,
@@ -390,8 +387,6 @@ gsk_gpu_renderer_render (GskRenderer *renderer,
GskGpuImage *backbuffer; GskGpuImage *backbuffer;
cairo_region_t *render_region; cairo_region_t *render_region;
double scale; double scale;
GdkMemoryDepth depth;
GdkColorState *target_color_state;
if (cairo_region_is_empty (region)) if (cairo_region_is_empty (region))
{ {
@@ -399,9 +394,9 @@ gsk_gpu_renderer_render (GskRenderer *renderer,
return; return;
} }
depth = gsk_render_node_get_preferred_depth (root); gdk_draw_context_begin_frame_full (priv->context,
gsk_render_node_get_preferred_depth (root),
gdk_draw_context_begin_frame_full (priv->context, depth, region); region);
gsk_gpu_device_maybe_gc (priv->device); gsk_gpu_device_maybe_gc (priv->device);
@@ -413,21 +408,9 @@ gsk_gpu_renderer_render (GskRenderer *renderer,
render_region = get_render_region (self); render_region = get_render_region (self);
scale = gsk_gpu_renderer_get_scale (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, gsk_gpu_frame_render (frame,
g_get_monotonic_time (), g_get_monotonic_time (),
backbuffer, backbuffer,
target_color_state,
render_region, render_region,
root, root,
&GRAPHENE_RECT_INIT ( &GRAPHENE_RECT_INIT (
+3 -15
View File
@@ -4,8 +4,6 @@
#include "gskgputypesprivate.h" #include "gskgputypesprivate.h"
#include <math.h>
G_BEGIN_DECLS G_BEGIN_DECLS
struct _GskGpuShaderOp struct _GskGpuShaderOp
@@ -65,23 +63,13 @@ GskGpuOp * gsk_gpu_shader_op_gl_command (GskGpuO
GskGpuFrame *frame, GskGpuFrame *frame,
GskGLCommandState *state); 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 static inline void
gsk_gpu_rgba_to_float (const GdkRGBA *rgba, gsk_gpu_rgba_to_float (const GdkRGBA *rgba,
float values[4]) float values[4])
{ {
values[0] = srgb_inverse_transfer_function (rgba->red); values[0] = rgba->red;
values[1] = srgb_inverse_transfer_function (rgba->green); values[1] = rgba->green;
values[2] = srgb_inverse_transfer_function (rgba->blue); values[2] = rgba->blue;
values[3] = rgba->alpha; values[3] = rgba->alpha;
} }
-1
View File
@@ -29,7 +29,6 @@ typedef enum {
GSK_GPU_IMAGE_MIPMAP = (1 << 5), GSK_GPU_IMAGE_MIPMAP = (1 << 5),
GSK_GPU_IMAGE_FILTERABLE = (1 << 6), GSK_GPU_IMAGE_FILTERABLE = (1 << 6),
GSK_GPU_IMAGE_RENDERABLE = (1 << 7), GSK_GPU_IMAGE_RENDERABLE = (1 << 7),
GSK_GPU_IMAGE_SRGB = (1 << 8),
} GskGpuImageFlags; } GskGpuImageFlags;
typedef enum { typedef enum {
-27
View File
@@ -14,15 +14,6 @@
#include "gdk/gdkglcontextprivate.h" #include "gdk/gdkglcontextprivate.h"
#include "gsk/gskdebugprivate.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 * static GskGpuOp *
gsk_gpu_upload_op_gl_command_with_area (GskGpuOp *op, 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), image = gsk_gpu_device_create_upload_image (gsk_gpu_frame_get_device (frame),
with_mipmap, with_mipmap,
gdk_texture_get_format (texture), gdk_texture_get_format (texture),
gdk_texture_get_color_state (texture),
gdk_texture_get_width (texture), gdk_texture_get_width (texture),
gdk_texture_get_height (texture)); gdk_texture_get_height (texture));
if (image == NULL) 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), self->image = gsk_gpu_device_create_upload_image (gsk_gpu_frame_get_device (frame),
FALSE, FALSE,
GDK_MEMORY_DEFAULT, GDK_MEMORY_DEFAULT,
GDK_COLOR_STATE_SRGB,
ceil (graphene_vec2_get_x (scale) * viewport->size.width), ceil (graphene_vec2_get_x (scale) * viewport->size.width),
ceil (graphene_vec2_get_y (scale) * viewport->size.height)); ceil (graphene_vec2_get_y (scale) * viewport->size.height));
self->viewport = *viewport; self->viewport = *viewport;
@@ -548,16 +537,6 @@ gsk_gpu_upload_glyph_op_draw (GskGpuOp *op,
cairo_surface_t *surface; cairo_surface_t *surface;
cairo_t *cr; cairo_t *cr;
PangoRectangle ink_rect = { 0, }; 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, surface = cairo_image_surface_create_for_data (data,
CAIRO_FORMAT_ARGB32, CAIRO_FORMAT_ARGB32,
@@ -599,12 +578,6 @@ G_GNUC_END_IGNORE_DEPRECATIONS
cairo_surface_finish (surface); cairo_surface_finish (surface);
cairo_surface_destroy (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 #ifdef GDK_RENDERING_VULKAN
+1 -2
View File
@@ -117,8 +117,7 @@ gsk_ngl_renderer_get_backbuffer (GskGpuRenderer *renderer)
GDK_GL_CONTEXT (context), GDK_GL_CONTEXT (context),
GDK_MEMORY_DEFAULT /* FIXME */, GDK_MEMORY_DEFAULT /* FIXME */,
ceil (gdk_surface_get_width (surface) * scale), ceil (gdk_surface_get_width (surface) * scale),
ceil (gdk_surface_get_height (surface) * scale), ceil (gdk_surface_get_height (surface) * scale));
gdk_surface_get_gl_is_srgb (surface));
} }
return self->backbuffer; return self->backbuffer;
-2
View File
@@ -391,7 +391,6 @@ static GskGpuImage *
gsk_vulkan_device_create_upload_image (GskGpuDevice *device, gsk_vulkan_device_create_upload_image (GskGpuDevice *device,
gboolean with_mipmap, gboolean with_mipmap,
GdkMemoryFormat format, GdkMemoryFormat format,
GdkColorState *color_state,
gsize width, gsize width,
gsize height) gsize height)
{ {
@@ -400,7 +399,6 @@ gsk_vulkan_device_create_upload_image (GskGpuDevice *device,
return gsk_vulkan_image_new_for_upload (self, return gsk_vulkan_image_new_for_upload (self,
with_mipmap, with_mipmap,
format, format,
color_state,
width, width,
height); height);
} }
+8 -25
View File
@@ -11,7 +11,6 @@
#include "gdk/gdkvulkancontextprivate.h" #include "gdk/gdkvulkancontextprivate.h"
#include "gdk/gdkmemoryformatprivate.h" #include "gdk/gdkmemoryformatprivate.h"
#include "gdk/gdkvulkancontextprivate.h" #include "gdk/gdkvulkancontextprivate.h"
#include "gdk/gdkcolorstateprivate.h"
#include <fcntl.h> #include <fcntl.h>
#include <string.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) #define CHECK_FLAGS (GSK_GPU_IMAGE_NO_BLIT | GSK_GPU_IMAGE_FILTERABLE | GSK_GPU_IMAGE_RENDERABLE)
GskGpuImageFlags flags; GskGpuImageFlags flags;
if (vk_format == VK_FORMAT_UNDEFINED)
return FALSE;
if (vk_usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT && if (vk_usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT &&
!gsk_component_mapping_is_framebuffer_compatible (vk_components)) !gsk_component_mapping_is_framebuffer_compatible (vk_components))
return FALSE; return FALSE;
@@ -244,7 +240,6 @@ gsk_vulkan_device_check_format (GskVulkanDevice *device,
static GskVulkanImage * static GskVulkanImage *
gsk_vulkan_image_new (GskVulkanDevice *device, gsk_vulkan_image_new (GskVulkanDevice *device,
GdkMemoryFormat format, GdkMemoryFormat format,
GdkColorState *color_state,
GskGpuImageFlags required_flags, GskGpuImageFlags required_flags,
gsize width, gsize width,
gsize height, gsize height,
@@ -266,13 +261,15 @@ gsk_vulkan_image_new (GskVulkanDevice *device,
/* First, try the actual format */ /* First, try the actual format */
vk_format = gdk_memory_format_vk_format (format, &vk_components); 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, usage, width, height,
&tiling, &flags)) &tiling, &flags))
{ {
/* Second, try the potential RGBA format */ /* Second, try the potential RGBA format */
vk_format = gdk_memory_format_vk_rgba_format (format, NULL, &vk_components); 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, usage, width, height,
&tiling, &flags)) &tiling, &flags))
{ {
@@ -284,7 +281,8 @@ gsk_vulkan_image_new (GskVulkanDevice *device,
for (i = 0; fallbacks[i] != -1; i++) for (i = 0; fallbacks[i] != -1; i++)
{ {
vk_format = gdk_memory_format_vk_format (fallbacks[i], &vk_components); 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, usage, width, height,
&tiling, &flags)) &tiling, &flags))
{ {
@@ -307,13 +305,6 @@ gsk_vulkan_image_new (GskVulkanDevice *device,
(required_flags & GSK_GPU_IMAGE_CAN_MIPMAP)) (required_flags & GSK_GPU_IMAGE_CAN_MIPMAP))
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); vk_device = gsk_vulkan_device_get_vk_device (device);
self = g_object_new (GSK_TYPE_VULKAN_IMAGE, NULL); self = g_object_new (GSK_TYPE_VULKAN_IMAGE, NULL);
@@ -375,7 +366,6 @@ GskGpuImage *
gsk_vulkan_image_new_for_upload (GskVulkanDevice *device, gsk_vulkan_image_new_for_upload (GskVulkanDevice *device,
gboolean with_mipmap, gboolean with_mipmap,
GdkMemoryFormat format, GdkMemoryFormat format,
GdkColorState *color_state,
gsize width, gsize width,
gsize height) gsize height)
{ {
@@ -383,7 +373,6 @@ gsk_vulkan_image_new_for_upload (GskVulkanDevice *device,
self = gsk_vulkan_image_new (device, self = gsk_vulkan_image_new (device,
format, format,
color_state,
with_mipmap ? (GSK_GPU_IMAGE_CAN_MIPMAP | GSK_GPU_IMAGE_RENDERABLE | GSK_GPU_IMAGE_FILTERABLE) : 0, with_mipmap ? (GSK_GPU_IMAGE_CAN_MIPMAP | GSK_GPU_IMAGE_RENDERABLE | GSK_GPU_IMAGE_FILTERABLE) : 0,
width, width,
height, height,
@@ -444,12 +433,10 @@ GskGpuImage *
gsk_vulkan_image_new_for_swapchain (GskVulkanDevice *device, gsk_vulkan_image_new_for_swapchain (GskVulkanDevice *device,
VkImage image, VkImage image,
VkFormat format, VkFormat format,
GdkMemoryFormat memory_format,
gsize width, gsize width,
gsize height) gsize height)
{ {
GskVulkanImage *self; GskVulkanImage *self;
GskGpuImageFlags flags = 0;
self = g_object_new (GSK_TYPE_VULKAN_IMAGE, NULL); 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_image_layout = VK_IMAGE_LAYOUT_UNDEFINED;
self->vk_access = 0; self->vk_access = 0;
if (format == gdk_memory_format_vk_srgb_format (memory_format)) /* FIXME: The memory format and flags here are very suboptimal */
flags |= GSK_GPU_IMAGE_SRGB; 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, gsk_vulkan_image_create_view (self,
format, format,
&(VkComponentMapping) { &(VkComponentMapping) {
@@ -489,7 +474,6 @@ gsk_vulkan_image_new_for_atlas (GskVulkanDevice *device,
self = gsk_vulkan_image_new (device, self = gsk_vulkan_image_new (device,
GDK_MEMORY_DEFAULT, GDK_MEMORY_DEFAULT,
GDK_COLOR_STATE_SRGB_LINEAR,
GSK_GPU_IMAGE_FILTERABLE | GSK_GPU_IMAGE_RENDERABLE, GSK_GPU_IMAGE_FILTERABLE | GSK_GPU_IMAGE_RENDERABLE,
width, width,
height, height,
@@ -514,7 +498,6 @@ gsk_vulkan_image_new_for_offscreen (GskVulkanDevice *device,
self = gsk_vulkan_image_new (device, self = gsk_vulkan_image_new (device,
preferred_format, preferred_format,
GDK_COLOR_STATE_SRGB_LINEAR,
GSK_GPU_IMAGE_RENDERABLE | GSK_GPU_IMAGE_RENDERABLE |
(with_mipmap ? GSK_GPU_IMAGE_CAN_MIPMAP | GSK_GPU_IMAGE_FILTERABLE : 0), (with_mipmap ? GSK_GPU_IMAGE_CAN_MIPMAP | GSK_GPU_IMAGE_FILTERABLE : 0),
width, 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, GskGpuImage * gsk_vulkan_image_new_for_swapchain (GskVulkanDevice *device,
VkImage image, VkImage image,
VkFormat format, VkFormat format,
GdkMemoryFormat memory_format,
gsize width, gsize width,
gsize height); gsize height);
@@ -29,7 +28,6 @@ GskGpuImage * gsk_vulkan_image_new_for_offscreen (GskVulk
GskGpuImage * gsk_vulkan_image_new_for_upload (GskVulkanDevice *device, GskGpuImage * gsk_vulkan_image_new_for_upload (GskVulkanDevice *device,
gboolean with_mipmap, gboolean with_mipmap,
GdkMemoryFormat format, GdkMemoryFormat format,
GdkColorState *color_state,
gsize width, gsize width,
gsize height); gsize height);
#ifdef HAVE_DMABUF #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, self->targets[i] = gsk_vulkan_image_new_for_swapchain (device,
gdk_vulkan_context_get_image (context, i), gdk_vulkan_context_get_image (context, i),
gdk_vulkan_context_get_image_format (context), gdk_vulkan_context_get_image_format (context),
gdk_vulkan_context_get_memory_format (context),
width, height); width, height);
} }
} }
+1 -1
View File
@@ -19,4 +19,4 @@ luminance (vec3 color)
return dot (vec3 (0.2126, 0.7152, 0.0722), 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', 'gskgpuborder.glsl',
'gskgpuboxshadow.glsl', 'gskgpuboxshadow.glsl',
'gskgpucolor.glsl', 'gskgpucolor.glsl',
'gskgpucolorconvert.glsl',
'gskgpucolorize.glsl', 'gskgpucolorize.glsl',
'gskgpucolormatrix.glsl', 'gskgpucolormatrix.glsl',
'gskgpuconicgradient.glsl', 'gskgpuconicgradient.glsl',
+6 -33
View File
@@ -26,7 +26,6 @@
#include "gskrendererprivate.h" #include "gskrendererprivate.h"
#include "gskrendernodeprivate.h" #include "gskrendernodeprivate.h"
#include "gdk/gdktextureprivate.h" #include "gdk/gdktextureprivate.h"
#include "gdk/gdkcolorstateprivate.h"
typedef struct { typedef struct {
GQuark cpu_time; GQuark cpu_time;
@@ -91,19 +90,6 @@ gsk_cairo_renderer_do_render (GskRenderer *renderer,
gsk_profiler_push_samples (profiler); 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 * static GdkTexture *
gsk_cairo_renderer_render_texture (GskRenderer *renderer, gsk_cairo_renderer_render_texture (GskRenderer *renderer,
GskRenderNode *root, GskRenderNode *root,
@@ -158,7 +144,6 @@ gsk_cairo_renderer_render_texture (GskRenderer *renderer,
cairo_destroy (cr); cairo_destroy (cr);
surface_linear_srgb_to_srgb (surface);
texture = gdk_texture_new_for_surface (surface); texture = gdk_texture_new_for_surface (surface);
cairo_surface_destroy (surface); cairo_surface_destroy (surface);
@@ -171,17 +156,18 @@ gsk_cairo_renderer_render (GskRenderer *renderer,
const cairo_region_t *region) const cairo_region_t *region)
{ {
GskCairoRenderer *self = GSK_CAIRO_RENDERER (renderer); GskCairoRenderer *self = GSK_CAIRO_RENDERER (renderer);
cairo_t *cr, *cr2; cairo_t *cr;
GdkSurface *surface = gsk_renderer_get_surface (renderer);
cairo_surface_t *s;
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); cr = gdk_cairo_context_cairo_create (self->cairo_context);
g_return_if_fail (cr != NULL); g_return_if_fail (cr != NULL);
if (GSK_RENDERER_DEBUG_CHECK (renderer, GEOMETRY)) if (GSK_RENDERER_DEBUG_CHECK (renderer, GEOMETRY))
{ {
GdkSurface *surface = gsk_renderer_get_surface (renderer);
cairo_save (cr); cairo_save (cr);
cairo_set_operator (cr, CAIRO_OPERATOR_OVER); cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
cairo_rectangle (cr, cairo_rectangle (cr,
@@ -192,21 +178,8 @@ gsk_cairo_renderer_render (GskRenderer *renderer,
cairo_restore (cr); cairo_restore (cr);
} }
s = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, gsk_cairo_renderer_do_render (renderer, cr, root);
gdk_surface_get_width (surface),
gdk_surface_get_height (surface));
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); cairo_destroy (cr);
gdk_draw_context_end_frame (GDK_DRAW_CONTEXT (self->cairo_context)); gdk_draw_context_end_frame (GDK_DRAW_CONTEXT (self->cairo_context));
+3 -10
View File
@@ -679,16 +679,9 @@ vulkan_supported_platform (GdkSurface *surface,
if (props.deviceType == VK_PHYSICAL_DEVICE_TYPE_CPU) if (props.deviceType == VK_PHYSICAL_DEVICE_TYPE_CPU)
{ {
if (!as_fallback) if (!as_fallback)
GSK_DEBUG (RENDERER, "Not using '%s': device is CPU", g_type_name (renderer_type)); GSK_DEBUG (RENDERER,
return FALSE; "Not using '%s': device is CPU",
} g_type_name (renderer_type));
gdk_display_init_dmabuf (display);
if (!display->vk_dmabuf_formats ||
gdk_dmabuf_formats_get_n_formats (display->vk_dmabuf_formats) == 0)
{
if (!as_fallback)
GSK_DEBUG (RENDERER, "Not using '%s': no dmabuf support", g_type_name (renderer_type));
return FALSE; return FALSE;
} }
+27 -91
View File
@@ -40,7 +40,6 @@
#include "gdk/gdktextureprivate.h" #include "gdk/gdktextureprivate.h"
#include "gdk/gdktexturedownloaderprivate.h" #include "gdk/gdktexturedownloaderprivate.h"
#include "gdk/gdkrgbaprivate.h" #include "gdk/gdkrgbaprivate.h"
#include "gdk/gdkcolorstateprivate.h"
#include <cairo.h> #include <cairo.h>
#ifdef CAIRO_HAS_SVG_SURFACE #ifdef CAIRO_HAS_SVG_SURFACE
@@ -48,13 +47,6 @@
#endif #endif
#include <hb-ot.h> #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 /* for oversized image fallback - we use a smaller size than Cairo actually
* allows to avoid rounding errors in Cairo */ * allows to avoid rounding errors in Cairo */
#define MAX_CAIRO_IMAGE_WIDTH 16384 #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 */ /* {{{ GSK_COLOR_NODE */
/** /**
@@ -200,7 +159,7 @@ gsk_color_node_draw (GskRenderNode *node,
{ {
GskColorNode *self = (GskColorNode *) 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); gsk_cairo_rectangle (cr, &node->bounds);
cairo_fill (cr); cairo_fill (cr);
@@ -335,25 +294,25 @@ gsk_linear_gradient_node_draw (GskRenderNode *node,
if (self->stops[0].offset > 0.0) if (self->stops[0].offset > 0.0)
cairo_pattern_add_color_stop_rgba (pattern, cairo_pattern_add_color_stop_rgba (pattern,
0.0, 0.0,
srgb_inverse_transfer_function (self->stops[0].color.red), self->stops[0].color.red,
srgb_inverse_transfer_function (self->stops[0].color.green), self->stops[0].color.green,
srgb_inverse_transfer_function (self->stops[0].color.blue), self->stops[0].color.blue,
self->stops[0].color.alpha); self->stops[0].color.alpha);
for (i = 0; i < self->n_stops; i++) for (i = 0; i < self->n_stops; i++)
{ {
cairo_pattern_add_color_stop_rgba (pattern, cairo_pattern_add_color_stop_rgba (pattern,
self->stops[i].offset, self->stops[i].offset,
srgb_inverse_transfer_function (self->stops[i].color.red), self->stops[i].color.red,
srgb_inverse_transfer_function (self->stops[i].color.green), self->stops[i].color.green,
srgb_inverse_transfer_function (self->stops[i].color.blue), self->stops[i].color.blue,
self->stops[i].color.alpha); self->stops[i].color.alpha);
} }
if (self->stops[self->n_stops-1].offset < 1.0) if (self->stops[self->n_stops-1].offset < 1.0)
cairo_pattern_add_color_stop_rgba (pattern, cairo_pattern_add_color_stop_rgba (pattern,
1.0, 1.0,
srgb_inverse_transfer_function (self->stops[self->n_stops-1].color.red), self->stops[self->n_stops-1].color.red,
srgb_inverse_transfer_function (self->stops[self->n_stops-1].color.green), 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.blue,
self->stops[self->n_stops-1].color.alpha); self->stops[self->n_stops-1].color.alpha);
cairo_set_source (cr, pattern); cairo_set_source (cr, pattern);
@@ -665,25 +624,25 @@ gsk_radial_gradient_node_draw (GskRenderNode *node,
if (self->stops[0].offset > 0.0) if (self->stops[0].offset > 0.0)
cairo_pattern_add_color_stop_rgba (pattern, cairo_pattern_add_color_stop_rgba (pattern,
0.0, 0.0,
srgb_inverse_transfer_function (self->stops[0].color.red), self->stops[0].color.red,
srgb_inverse_transfer_function (self->stops[0].color.green), self->stops[0].color.green,
srgb_inverse_transfer_function (self->stops[0].color.blue), self->stops[0].color.blue,
self->stops[0].color.alpha); self->stops[0].color.alpha);
for (i = 0; i < self->n_stops; i++) for (i = 0; i < self->n_stops; i++)
{ {
cairo_pattern_add_color_stop_rgba (pattern, cairo_pattern_add_color_stop_rgba (pattern,
self->stops[i].offset, self->stops[i].offset,
srgb_inverse_transfer_function (self->stops[i].color.red), self->stops[i].color.red,
srgb_inverse_transfer_function (self->stops[i].color.green), self->stops[i].color.green,
srgb_inverse_transfer_function (self->stops[i].color.blue), self->stops[i].color.blue,
self->stops[i].color.alpha); self->stops[i].color.alpha);
} }
if (self->stops[self->n_stops-1].offset < 1.0) if (self->stops[self->n_stops-1].offset < 1.0)
cairo_pattern_add_color_stop_rgba (pattern, cairo_pattern_add_color_stop_rgba (pattern,
1.0, 1.0,
srgb_inverse_transfer_function (self->stops[self->n_stops-1].color.red), self->stops[self->n_stops-1].color.red,
srgb_inverse_transfer_function (self->stops[self->n_stops-1].color.green), 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.blue,
self->stops[self->n_stops-1].color.alpha); self->stops[self->n_stops-1].color.alpha);
gsk_cairo_rectangle (cr, &node->bounds); gsk_cairo_rectangle (cr, &node->bounds);
@@ -1052,12 +1011,7 @@ _cairo_mesh_pattern_set_corner_rgba (cairo_pattern_t *pattern,
guint corner_num, guint corner_num,
const GdkRGBA *rgba) const GdkRGBA *rgba)
{ {
cairo_mesh_pattern_set_corner_color_rgba (pattern, cairo_mesh_pattern_set_corner_color_rgba (pattern, corner_num, rgba->red, rgba->green, rgba->blue, rgba->alpha);
corner_num,
srgb_inverse_transfer_function (rgba->red),
srgb_inverse_transfer_function (rgba->green),
srgb_inverse_transfer_function (rgba->blue),
rgba->alpha);
} }
static void 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[2]) &&
gdk_rgba_equal (&self->border_color[0], &self->border_color[3])) 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 else
{ {
@@ -1817,7 +1771,6 @@ gsk_texture_node_draw (GskRenderNode *node,
} }
surface = gdk_texture_download_surface (self->texture); surface = gdk_texture_download_surface (self->texture);
surface_srgb_to_linear_srgb (surface);
pattern = cairo_pattern_create_for_surface (surface); pattern = cairo_pattern_create_for_surface (surface);
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_PAD); cairo_pattern_set_extend (pattern, CAIRO_EXTEND_PAD);
@@ -1994,7 +1947,6 @@ gsk_texture_scale_node_draw (GskRenderNode *node,
cr2 = cairo_create (surface2); cr2 = cairo_create (surface2);
surface = gdk_texture_download_surface (self->texture); surface = gdk_texture_download_surface (self->texture);
surface_srgb_to_linear_srgb (surface);
pattern = cairo_pattern_create_for_surface (surface); pattern = cairo_pattern_create_for_surface (surface);
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_PAD); cairo_pattern_set_extend (pattern, CAIRO_EXTEND_PAD);
@@ -2197,7 +2149,7 @@ draw_shadow (cairo_t *cr,
if (has_empty_clip (cr)) if (has_empty_clip (cr))
return; 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); shadow_cr = gsk_cairo_blur_start_drawing (cr, radius, blur_flags);
cairo_set_fill_rule (shadow_cr, CAIRO_FILL_RULE_EVEN_ODD); 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); 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); pattern = cairo_pattern_create_for_surface (mask);
cairo_matrix_init_identity (&matrix); cairo_matrix_init_identity (&matrix);
cairo_matrix_scale (&matrix, sx, sy); 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 && if (gsk_render_node_get_node_type (self->child) == GSK_COLOR_NODE &&
gsk_rect_contains_rect (&self->child->bounds, &node->bounds)) 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); cairo_fill (cr);
} }
else else
@@ -4934,7 +4886,7 @@ gsk_stroke_node_draw (GskRenderNode *node,
if (gsk_render_node_get_node_type (self->child) == GSK_COLOR_NODE && if (gsk_render_node_get_node_type (self->child) == GSK_COLOR_NODE &&
gsk_rect_contains_rect (&self->child->bounds, &node->bounds)) 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 else
{ {
@@ -5159,7 +5111,7 @@ gsk_shadow_node_draw (GskRenderNode *node,
gsk_render_node_draw (self->child, cr); gsk_render_node_draw (self->child, cr);
pattern = cairo_pop_group (cr); pattern = cairo_pop_group (cr);
cairo_reset_clip (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_mask (cr, pattern);
cairo_pattern_destroy (pattern); cairo_pattern_destroy (pattern);
cairo_restore (cr); cairo_restore (cr);
@@ -5776,16 +5728,6 @@ gsk_text_node_draw (GskRenderNode *node,
{ {
GskTextNode *self = (GskTextNode *) node; GskTextNode *self = (GskTextNode *) node;
PangoGlyphString glyphs; 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.num_glyphs = self->num_glyphs;
glyphs.glyphs = self->glyphs; glyphs.glyphs = self->glyphs;
@@ -5793,17 +5735,11 @@ G_GNUC_END_IGNORE_DEPRECATIONS
cairo_save (cr); 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); cairo_translate (cr, self->offset.x, self->offset.y);
pango_cairo_show_glyph_string (cr, self->font, &glyphs); pango_cairo_show_glyph_string (cr, self->font, &glyphs);
cairo_restore (cr); 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 static void
+111 -159
View File
@@ -54,8 +54,6 @@
#include <pango/pangofc-fontmap.h> #include <pango/pangofc-fontmap.h>
#endif #endif
#include <hb-subset.h>
#include <glib/gstdio.h> #include <glib/gstdio.h>
typedef struct _Context Context; typedef struct _Context Context;
@@ -948,22 +946,23 @@ create_ascii_glyphs (PangoFont *font)
PangoGlyphString *result, *glyph_string; PangoGlyphString *result, *glyph_string;
guint i; guint i;
result = pango_glyph_string_new ();
coverage = pango_font_get_coverage (font, language); coverage = pango_font_get_coverage (font, language);
for (i = MIN_ASCII_GLYPH; i < MAX_ASCII_GLYPH; i++)
{
if (!pango_coverage_get (coverage, i))
break;
}
g_object_unref (coverage);
if (i < MAX_ASCII_GLYPH)
return NULL;
result = pango_glyph_string_new ();
pango_glyph_string_set_size (result, N_ASCII_GLYPHS); pango_glyph_string_set_size (result, N_ASCII_GLYPHS);
glyph_string = pango_glyph_string_new (); glyph_string = pango_glyph_string_new ();
for (i = MIN_ASCII_GLYPH; i < MAX_ASCII_GLYPH; i++) for (i = MIN_ASCII_GLYPH; i < MAX_ASCII_GLYPH; i++)
{ {
const char text[2] = { i, 0 }; const char text[2] = { i, 0 };
if (!pango_coverage_get (coverage, i))
{
result->glyphs[i - MIN_ASCII_GLYPH].glyph = PANGO_GLYPH_INVALID_INPUT;
continue;
}
pango_shape_with_flags (text, 1, pango_shape_with_flags (text, 1,
text, 1, text, 1,
&not_a_hack, &not_a_hack,
@@ -971,13 +970,14 @@ create_ascii_glyphs (PangoFont *font)
PANGO_SHAPE_NONE); PANGO_SHAPE_NONE);
if (glyph_string->num_glyphs != 1) if (glyph_string->num_glyphs != 1)
result->glyphs[i - MIN_ASCII_GLYPH].glyph = PANGO_GLYPH_INVALID_INPUT; {
else pango_glyph_string_free (glyph_string);
result->glyphs[i - MIN_ASCII_GLYPH] = glyph_string->glyphs[0]; pango_glyph_string_free (result);
return NULL;
}
result->glyphs[i - MIN_ASCII_GLYPH] = glyph_string->glyphs[0];
} }
g_object_unref (coverage);
pango_glyph_string_free (glyph_string); pango_glyph_string_free (glyph_string);
return result; return result;
@@ -1005,7 +1005,7 @@ ensure_fontmap (Context *context)
context->fontmap = pango_cairo_font_map_new (); context->fontmap = pango_cairo_font_map_new ();
config = FcConfigCreate (); config = FcInitLoadConfig ();
pango_fc_font_map_set_config (PANGO_FC_FONT_MAP (context->fontmap), config); pango_fc_font_map_set_config (PANGO_FC_FONT_MAP (context->fontmap), config);
FcConfigDestroy (config); FcConfigDestroy (config);
@@ -1113,70 +1113,81 @@ parse_font (GtkCssParser *parser,
if (font_name == NULL) if (font_name == NULL)
return FALSE; return FALSE;
if (context->fontmap)
font = font_from_string (context->fontmap, font_name, FALSE);
if (gtk_css_parser_has_url (parser)) if (gtk_css_parser_has_url (parser))
{ {
char *url; char *url;
char *scheme;
GBytes *bytes;
GError *error = NULL;
GtkCssLocation start_location;
gboolean success = FALSE;
start_location = *gtk_css_parser_get_start_location (parser); if (font != NULL)
url = gtk_css_parser_consume_url (parser);
if (url != NULL)
{ {
scheme = g_uri_parse_scheme (url); gtk_css_parser_error_value (parser, "A font with this name already exists.");
if (scheme && g_ascii_strcasecmp (scheme, "data") == 0) /* consume the url to avoid more errors */
{ url = gtk_css_parser_consume_url (parser);
bytes = gtk_css_data_url_parse (url, NULL, &error);
}
else
{
GFile *file;
file = g_file_new_for_uri (url);
bytes = g_file_load_bytes (file, NULL, NULL, &error);
g_object_unref (file);
}
g_free (scheme);
g_free (url); g_free (url);
if (bytes != NULL)
{
success = add_font_from_bytes (context, bytes, &error);
g_bytes_unref (bytes);
}
if (!success)
{
gtk_css_parser_emit_error (parser,
&start_location,
gtk_css_parser_get_end_location (parser),
error);
}
} }
else
if (success)
{ {
font = font_from_string (context->fontmap, font_name, FALSE); char *scheme;
if (!font) GBytes *bytes;
GError *error = NULL;
GtkCssLocation start_location;
gboolean success = FALSE;
start_location = *gtk_css_parser_get_start_location (parser);
url = gtk_css_parser_consume_url (parser);
if (url != NULL)
{ {
gtk_css_parser_error (parser, scheme = g_uri_parse_scheme (url);
GTK_CSS_PARSER_ERROR_UNKNOWN_VALUE, if (scheme && g_ascii_strcasecmp (scheme, "data") == 0)
&start_location, {
gtk_css_parser_get_end_location (parser), bytes = gtk_css_data_url_parse (url, NULL, &error);
"The given url does not define a font named \"%s\"", }
font_name); else
{
GFile *file;
file = g_file_new_for_uri (url);
bytes = g_file_load_bytes (file, NULL, NULL, &error);
g_object_unref (file);
}
g_free (scheme);
g_free (url);
if (bytes != NULL)
{
success = add_font_from_bytes (context, bytes, &error);
g_bytes_unref (bytes);
}
if (!success)
{
gtk_css_parser_emit_error (parser,
&start_location,
gtk_css_parser_get_end_location (parser),
error);
}
}
if (success)
{
font = font_from_string (context->fontmap, font_name, FALSE);
if (!font)
{
gtk_css_parser_error (parser,
GTK_CSS_PARSER_ERROR_UNKNOWN_VALUE,
&start_location,
gtk_css_parser_get_end_location (parser),
"The given url does not define a font named \"%s\"",
font_name);
}
} }
} }
} }
else else
{ {
if (context->fontmap)
font = font_from_string (context->fontmap, font_name, FALSE);
if (!font) if (!font)
font = font_from_string (pango_cairo_font_map_get_default (), font_name, TRUE); font = font_from_string (pango_cairo_font_map_get_default (), font_name, TRUE);
@@ -2244,12 +2255,6 @@ unpack_glyphs (PangoFont *font,
return FALSE; return FALSE;
} }
if (ascii->glyphs[idx].glyph == PANGO_GLYPH_INVALID_INPUT)
{
g_clear_pointer (&ascii, pango_glyph_string_free);
return FALSE;
}
gi->glyph = ascii->glyphs[idx].glyph; gi->glyph = ascii->glyphs[idx].glyph;
gi->geometry.width = ascii->glyphs[idx].geometry.width; gi->geometry.width = ascii->glyphs[idx].geometry.width;
} }
@@ -2941,7 +2946,7 @@ typedef struct
gsize named_node_counter; gsize named_node_counter;
GHashTable *named_textures; GHashTable *named_textures;
gsize named_texture_counter; gsize named_texture_counter;
GHashTable *fonts; GHashTable *serialized_fonts;
} Printer; } Printer;
static void static void
@@ -2956,64 +2961,6 @@ printer_init_check_texture (Printer *printer,
g_hash_table_insert (printer->named_textures, texture, g_strdup ("")); g_hash_table_insert (printer->named_textures, texture, g_strdup (""));
} }
typedef struct {
hb_face_t *face;
hb_subset_input_t *input;
gboolean serialized;
} FontInfo;
static void
font_info_free (gpointer data)
{
FontInfo *info = (FontInfo *) data;
hb_face_destroy (info->face);
if (info->input)
hb_subset_input_destroy (info->input);
g_free (info);
}
static void
printer_init_collect_font_info (Printer *printer,
GskRenderNode *node)
{
PangoFont *font;
FontInfo *info;
font = gsk_text_node_get_font (node);
info = (FontInfo *) g_hash_table_lookup (printer->fonts, hb_font_get_face (pango_font_get_hb_font (font)));
if (!info)
{
info = g_new0 (FontInfo, 1);
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 */
}
g_hash_table_insert (printer->fonts, info->face, info);
}
if (info->input)
{
const PangoGlyphInfo *glyphs;
guint n_glyphs;
glyphs = gsk_text_node_get_glyphs (node, &n_glyphs);
for (guint i = 0; i < n_glyphs; i++)
hb_set_add (hb_subset_input_glyph_set (info->input), glyphs[i].glyph);
}
}
static void static void
printer_init_duplicates_for_node (Printer *printer, printer_init_duplicates_for_node (Printer *printer,
GskRenderNode *node) GskRenderNode *node)
@@ -3027,11 +2974,8 @@ printer_init_duplicates_for_node (Printer *printer,
switch (gsk_render_node_get_node_type (node)) switch (gsk_render_node_get_node_type (node))
{ {
case GSK_TEXT_NODE:
printer_init_collect_font_info (printer, node);
break;
case GSK_CAIRO_NODE: case GSK_CAIRO_NODE:
case GSK_TEXT_NODE:
case GSK_COLOR_NODE: case GSK_COLOR_NODE:
case GSK_LINEAR_GRADIENT_NODE: case GSK_LINEAR_GRADIENT_NODE:
case GSK_REPEATING_LINEAR_GRADIENT_NODE: case GSK_REPEATING_LINEAR_GRADIENT_NODE:
@@ -3155,7 +3099,7 @@ printer_init (Printer *self,
self->named_node_counter = 0; self->named_node_counter = 0;
self->named_textures = g_hash_table_new_full (NULL, NULL, NULL, g_free); self->named_textures = g_hash_table_new_full (NULL, NULL, NULL, g_free);
self->named_texture_counter = 0; self->named_texture_counter = 0;
self->fonts = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, font_info_free); self->serialized_fonts = g_hash_table_new (g_str_hash, g_str_equal);
printer_init_duplicates_for_node (self, node); printer_init_duplicates_for_node (self, node);
} }
@@ -3167,7 +3111,7 @@ printer_clear (Printer *self)
g_string_free (self->str, TRUE); g_string_free (self->str, TRUE);
g_hash_table_unref (self->named_nodes); g_hash_table_unref (self->named_nodes);
g_hash_table_unref (self->named_textures); g_hash_table_unref (self->named_textures);
g_hash_table_unref (self->fonts); g_hash_table_unref (self->serialized_fonts);
} }
#define IDENT_LEVEL 2 /* Spaces per level */ #define IDENT_LEVEL 2 /* Spaces per level */
@@ -3632,14 +3576,9 @@ gsk_text_node_serialize_font (GskRenderNode *node,
Printer *p) Printer *p)
{ {
PangoFont *font = gsk_text_node_get_font (node); PangoFont *font = gsk_text_node_get_font (node);
PangoFontMap *fontmap = pango_font_get_font_map (font);
PangoFontDescription *desc; PangoFontDescription *desc;
char *s; char *s;
FontInfo *info;
hb_face_t *face;
hb_blob_t *blob;
const char *data;
guint length;
char *b64;
desc = pango_font_describe_with_absolute_size (font); desc = pango_font_describe_with_absolute_size (font);
s = pango_font_description_to_string (desc); s = pango_font_description_to_string (desc);
@@ -3647,29 +3586,42 @@ gsk_text_node_serialize_font (GskRenderNode *node,
g_free (s); g_free (s);
pango_font_description_free (desc); pango_font_description_free (desc);
info = g_hash_table_lookup (p->fonts, hb_font_get_face (pango_font_get_hb_font (font))); /* Check if this is a custom font that we created from a url */
if (info->serialized) if (!g_object_get_data (G_OBJECT (fontmap), "font-files"))
return; return;
if (info->input) #ifdef HAVE_PANGOFT
face = hb_subset_or_fail (info->face, info->input); {
else FcPattern *pat;
face = hb_face_reference (info->face); FcResult res;
const char *file;
char *data;
gsize len;
char *b64;
blob = hb_face_reference_blob (face); pat = pango_fc_font_get_pattern (PANGO_FC_FONT (font));
data = hb_blob_get_data (blob, &length); res = FcPatternGetString (pat, FC_FILE, 0, (FcChar8 **)&file);
if (res != FcResultMatch)
return;
b64 = base64_encode_with_linebreaks ((const guchar *) data, length); if (g_hash_table_contains (p->serialized_fonts, file))
return;
g_string_append (p->str, " url(\"data:font/ttf;base64,\\\n"); if (!g_file_get_contents (file, &data, &len, NULL))
append_escaping_newlines (p->str, b64); return;
g_string_append (p->str, "\")");
g_free (b64); g_hash_table_add (p->serialized_fonts, (gpointer) file);
hb_blob_destroy (blob);
hb_face_destroy (face);
info->serialized = TRUE; b64 = base64_encode_with_linebreaks ((const guchar *) data, len);
g_string_append (p->str, " url(\"data:font/ttf;base64,\\\n");
append_escaping_newlines (p->str, b64);
g_string_append (p->str, "\")");
g_free (b64);
g_free (data);
}
#endif
} }
static void static void
-33
View File
@@ -489,9 +489,6 @@ gsk_transform_matrix_with_category (GskTransform *next,
* *
* Multiplies @next with the given @matrix. * 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 * Returns: The new transform
**/ **/
GskTransform * GskTransform *
@@ -646,9 +643,6 @@ static const GskTransformClass GSK_TRANSLATE_TRANSFORM_CLASS =
* *
* Translates @next in 2-dimensional space by @point. * 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 * Returns: (nullable): The new transform
**/ **/
GskTransform * GskTransform *
@@ -669,9 +663,6 @@ gsk_transform_translate (GskTransform *next,
* *
* Translates @next by @point. * 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 * Returns: (nullable): The new transform
**/ **/
GskTransform * GskTransform *
@@ -889,9 +880,6 @@ normalize_angle (float angle)
* Rotates @next @angle degrees in 2D - or in 3D-speak, around the Z axis. * Rotates @next @angle degrees in 2D - or in 3D-speak, around the Z axis.
* The rotation happens around the origin point of (0, 0). * 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 * Returns: (nullable): The new transform
*/ */
GskTransform * GskTransform *
@@ -1020,9 +1008,6 @@ static const GskTransformClass GSK_ROTATE3D_TRANSFORM_CLASS =
* *
* For a rotation in 2D space, use [method@Gsk.Transform.rotate] * 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 * Returns: (nullable): The new transform
*/ */
GskTransform * GskTransform *
@@ -1199,9 +1184,6 @@ static const GskTransformClass GSK_SKEW_TRANSFORM_CLASS =
* *
* Applies a skew transform. * 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 * Returns: (nullable): The new transform
* *
* Since: 4.6 * 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. * 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 * Returns: (nullable): The new transform
**/ **/
GskTransform * GskTransform *
@@ -1396,9 +1375,6 @@ gsk_transform_scale (GskTransform *next,
* *
* Scales @next by the given factors. * 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 * Returns: (nullable): The new transform
**/ **/
GskTransform * GskTransform *
@@ -1534,9 +1510,6 @@ static const GskTransformClass GSK_PERSPECTIVE_TRANSFORM_CLASS =
* those with negative Z values towards the origin. Points * those with negative Z values towards the origin. Points
* on the z=0 plane are unchanged. * 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 * Returns: The new transform
*/ */
GskTransform * GskTransform *
@@ -1946,9 +1919,6 @@ gsk_transform_to_translate (GskTransform *self,
* *
* Applies all the operations from @other to @next. * 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 * Returns: (nullable): The new transform
*/ */
GskTransform * GskTransform *
@@ -1985,9 +1955,6 @@ gsk_transform_transform (GskTransform *next,
* between those cases, you should check @self is not %NULL * between those cases, you should check @self is not %NULL
* before calling this function. * 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 * Returns: (nullable): The inverted transform
*/ */
GskTransform * GskTransform *
-2
View File
@@ -4,7 +4,6 @@ gsk_private_gl_shaders = [
'gl/resources/preamble.vs.glsl', 'gl/resources/preamble.vs.glsl',
'gl/resources/border.glsl', 'gl/resources/border.glsl',
'gl/resources/blit.glsl', 'gl/resources/blit.glsl',
'gl/resources/colorconvert.glsl',
'gl/resources/coloring.glsl', 'gl/resources/coloring.glsl',
'gl/resources/color.glsl', 'gl/resources/color.glsl',
'gl/resources/linear_gradient.glsl', 'gl/resources/linear_gradient.glsl',
@@ -106,7 +105,6 @@ gsk_private_sources = files([
'gpu/gskgpushaderop.c', 'gpu/gskgpushaderop.c',
'gpu/gskgpuscissorop.c', 'gpu/gskgpuscissorop.c',
'gpu/gskgpustraightalphaop.c', 'gpu/gskgpustraightalphaop.c',
'gpu/gskgpucolorconvertop.c',
'gpu/gskgputextureop.c', 'gpu/gskgputextureop.c',
'gpu/gskgpuuberop.c', 'gpu/gskgpuuberop.c',
'gpu/gskgpuuploadop.c', 'gpu/gskgpuuploadop.c',
+1 -8
View File
@@ -778,20 +778,13 @@ gtk_style_context_resolve_color (GtkStyleContext *context,
{ {
GtkStyleContextPrivate *priv = gtk_style_context_get_instance_private (context); GtkStyleContextPrivate *priv = gtk_style_context_get_instance_private (context);
GtkCssValue *val; GtkCssValue *val;
GtkCssComputeContext ctx = { NULL, };
g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), FALSE); g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), FALSE);
g_return_val_if_fail (color != NULL, FALSE); g_return_val_if_fail (color != NULL, FALSE);
g_return_val_if_fail (result != NULL, FALSE); g_return_val_if_fail (result != NULL, FALSE);
ctx.provider = GTK_STYLE_PROVIDER (priv->cascade);
ctx.style = gtk_css_node_get_style (priv->cssnode);
if (gtk_css_node_get_parent (priv->cssnode))
ctx.parent_style = gtk_css_node_get_style (gtk_css_node_get_parent (priv->cssnode));
val = gtk_css_color_value_resolve (color, val = gtk_css_color_value_resolve (color,
GTK_CSS_PROPERTY_COLOR, GTK_STYLE_PROVIDER (priv->cascade),
&ctx,
_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_COLOR)); _gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_COLOR));
if (val == NULL) if (val == NULL)
+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); surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 2, 1);
data = cairo_image_surface_get_data (surface); data = cairo_image_surface_get_data (surface);
/* just color the first pixel... */ /* just color the first pixel... */
data[0] = round (CLAMP (grid_line_color->blue, 0, 1) * 255); data[0] = round (grid_line_color->blue * 255);
data[1] = round (CLAMP (grid_line_color->green, 0, 1) * 255); data[1] = round (grid_line_color->green * 255);
data[2] = round (CLAMP (grid_line_color->red, 0, 1) * 255); data[2] = round (grid_line_color->red * 255);
data[3] = round (CLAMP (grid_line_color->alpha, 0, 1) * 255); data[3] = round (grid_line_color->alpha * 255);
priv->horizontal_grid_line_texture = gdk_texture_new_for_surface (surface); priv->horizontal_grid_line_texture = gdk_texture_new_for_surface (surface);
cairo_surface_destroy (surface); cairo_surface_destroy (surface);
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 2); surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 2);
data = cairo_image_surface_get_data (surface); data = cairo_image_surface_get_data (surface);
data[0] = round (CLAMP (grid_line_color->blue, 0, 1) * 255); data[0] = round (grid_line_color->blue * 255);
data[1] = round (CLAMP (grid_line_color->green, 0, 1) * 255); data[1] = round (grid_line_color->green * 255);
data[2] = round (CLAMP (grid_line_color->red, 0, 1) * 255); data[2] = round (grid_line_color->red * 255);
data[3] = round (CLAMP (grid_line_color->alpha, 0, 1) * 255); data[3] = round (grid_line_color->alpha * 255);
priv->vertical_grid_line_texture = gdk_texture_new_for_surface (surface); priv->vertical_grid_line_texture = gdk_texture_new_for_surface (surface);
cairo_surface_destroy (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); surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 2, 1);
data = cairo_image_surface_get_data (surface); data = cairo_image_surface_get_data (surface);
/* just color the first pixel... */ /* just color the first pixel... */
data[0] = round (CLAMP (tree_line_color->blue, 0, 1) * 255); data[0] = round (tree_line_color->blue * 255);
data[1] = round (CLAMP (tree_line_color->green, 0, 1) * 255); data[1] = round (tree_line_color->green * 255);
data[2] = round (CLAMP (tree_line_color->red, 0, 1) * 255); data[2] = round (tree_line_color->red * 255);
data[3] = round (CLAMP (tree_line_color->alpha, 0, 1) * 255); data[3] = round (tree_line_color->alpha * 255);
priv->horizontal_tree_line_texture = gdk_texture_new_for_surface (surface); priv->horizontal_tree_line_texture = gdk_texture_new_for_surface (surface);
cairo_surface_destroy (surface); cairo_surface_destroy (surface);
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 2); surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 2);
data = cairo_image_surface_get_data (surface); data = cairo_image_surface_get_data (surface);
data[0] = round (CLAMP (tree_line_color->blue, 0, 1) * 255); data[0] = round (tree_line_color->blue * 255);
data[1] = round (CLAMP (tree_line_color->green, 0, 1) * 255); data[1] = round (tree_line_color->green * 255);
data[2] = round (CLAMP (tree_line_color->red, 0, 1) * 255); data[2] = round (tree_line_color->red * 255);
data[3] = round (CLAMP (tree_line_color->alpha, 0, 1) * 255); data[3] = round (tree_line_color->alpha * 255);
priv->vertical_tree_line_texture = gdk_texture_new_for_surface (surface); priv->vertical_tree_line_texture = gdk_texture_new_for_surface (surface);
cairo_surface_destroy (surface); cairo_surface_destroy (surface);
+1 -62
View File
@@ -201,10 +201,6 @@ struct _GtkAboutDialog
guint hovering_over_link : 1; guint hovering_over_link : 1;
guint wrap_license : 1; guint wrap_license : 1;
guint in_child_changed : 1; guint in_child_changed : 1;
GSList *link_tags;
guint update_links_cb_id;
}; };
struct _GtkAboutDialogClass struct _GtkAboutDialogClass
@@ -710,52 +706,6 @@ update_credits_button_visibility (GtkAboutDialog *about)
update_stack_switcher_visibility (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 static void
gtk_about_dialog_init (GtkAboutDialog *about) 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_name (about->link_node, g_quark_from_static_string ("link"));
gtk_css_node_set_parent (about->link_node, node); gtk_css_node_set_parent (about->link_node, node);
gtk_css_node_set_state (about->link_node, state | GTK_STATE_FLAG_LINK); 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); g_object_unref (about->link_node);
about->visited_link_node = gtk_css_node_new (); 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_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_parent (about->visited_link_node, node);
gtk_css_node_set_state (about->visited_link_node, state | GTK_STATE_FLAG_LINK); gtk_css_node_set_state (about->visited_link_node, state | GTK_STATE_FLAG_VISITED);
g_signal_connect (about->visited_link_node, "style-changed",
G_CALLBACK (link_style_changed_cb), about);
g_object_unref (about->visited_link_node); 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_slist_free_full (about->credit_sections, destroy_credit_section);
g_ptr_array_unref (about->visited_links); 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); G_OBJECT_CLASS (gtk_about_dialog_parent_class)->finalize (object);
} }
@@ -1968,9 +1910,6 @@ text_buffer_new (GtkAboutDialog *about,
"foreground-rgba", &color, "foreground-rgba", &color,
"underline", PANGO_UNDERLINE_SINGLE, "underline", PANGO_UNDERLINE_SINGLE,
NULL); NULL);
about->link_tags = g_slist_prepend (about->link_tags, tag);
if (strcmp (link_type, "email") == 0) if (strcmp (link_type, "email") == 0)
{ {
char *escaped; 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); *green = apply_gamma (linear_green);
*blue = apply_gamma (linear_blue); *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, void gtk_linear_srgb_to_rgb (float linear_red, float linear_green, float linear_blue,
float *red, float *green, float *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 G_END_DECLS
+42 -60
View File
@@ -21,14 +21,12 @@
#include <string.h> #include <string.h>
GtkCssValue * gtk_css_calc_value_parse_sum (GtkCssParser *parser, GtkCssValue * gtk_css_calc_value_parse_sum (GtkCssParser *parser,
GtkCssNumberParseFlags flags, GtkCssNumberParseFlags flags);
GtkCssNumberParseContext *ctx);
static GtkCssValue * static GtkCssValue *
gtk_css_calc_value_parse_value (GtkCssParser *parser, gtk_css_calc_value_parse_value (GtkCssParser *parser,
GtkCssNumberParseFlags flags, GtkCssNumberParseFlags flags)
GtkCssNumberParseContext *ctx)
{ {
if (gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_OPEN_PARENS)) if (gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_OPEN_PARENS))
{ {
@@ -36,7 +34,7 @@ gtk_css_calc_value_parse_value (GtkCssParser *parser,
gtk_css_parser_start_block (parser); gtk_css_parser_start_block (parser);
result = gtk_css_calc_value_parse_sum (parser, flags, ctx); result = gtk_css_calc_value_parse_sum (parser, flags);
if (result == NULL) if (result == NULL)
{ {
gtk_css_parser_end_block (parser); gtk_css_parser_end_block (parser);
@@ -62,7 +60,7 @@ gtk_css_calc_value_parse_value (GtkCssParser *parser,
return result; return result;
} }
return gtk_css_number_value_parse_with_context (parser, flags, ctx); return gtk_css_number_value_parse (parser, flags);
} }
static gboolean static gboolean
@@ -73,9 +71,8 @@ is_number (GtkCssValue *value)
} }
static GtkCssValue * static GtkCssValue *
gtk_css_calc_value_parse_product (GtkCssParser *parser, gtk_css_calc_value_parse_product (GtkCssParser *parser,
GtkCssNumberParseFlags flags, GtkCssNumberParseFlags flags)
GtkCssNumberParseContext *ctx)
{ {
GtkCssValue *result, *value, *temp; GtkCssValue *result, *value, *temp;
GtkCssNumberParseFlags actual_flags; GtkCssNumberParseFlags actual_flags;
@@ -84,7 +81,7 @@ gtk_css_calc_value_parse_product (GtkCssParser *parser,
actual_flags = flags | GTK_CSS_PARSE_NUMBER; actual_flags = flags | GTK_CSS_PARSE_NUMBER;
gtk_css_parser_get_token (parser); gtk_css_parser_get_token (parser);
start = *gtk_css_parser_get_start_location (parser); start = *gtk_css_parser_get_start_location (parser);
result = gtk_css_calc_value_parse_value (parser, actual_flags, ctx); result = gtk_css_calc_value_parse_value (parser, actual_flags);
if (result == NULL) if (result == NULL)
return NULL; return NULL;
@@ -95,7 +92,7 @@ gtk_css_calc_value_parse_product (GtkCssParser *parser,
if (gtk_css_parser_try_delim (parser, '*')) if (gtk_css_parser_try_delim (parser, '*'))
{ {
value = gtk_css_calc_value_parse_product (parser, actual_flags, ctx); value = gtk_css_calc_value_parse_product (parser, actual_flags);
if (value == NULL) if (value == NULL)
goto fail; goto fail;
if (is_number (value)) if (is_number (value))
@@ -108,7 +105,7 @@ gtk_css_calc_value_parse_product (GtkCssParser *parser,
} }
else if (gtk_css_parser_try_delim (parser, '/')) else if (gtk_css_parser_try_delim (parser, '/'))
{ {
value = gtk_css_calc_value_parse_product (parser, GTK_CSS_PARSE_NUMBER, ctx); value = gtk_css_calc_value_parse_product (parser, GTK_CSS_PARSE_NUMBER);
if (value == NULL) if (value == NULL)
goto fail; goto fail;
temp = gtk_css_number_value_multiply (result, 1.0 / gtk_css_number_value_get (value, 100)); temp = gtk_css_number_value_multiply (result, 1.0 / gtk_css_number_value_get (value, 100));
@@ -140,13 +137,12 @@ fail:
} }
GtkCssValue * GtkCssValue *
gtk_css_calc_value_parse_sum (GtkCssParser *parser, gtk_css_calc_value_parse_sum (GtkCssParser *parser,
GtkCssNumberParseFlags flags, GtkCssNumberParseFlags flags)
GtkCssNumberParseContext *ctx)
{ {
GtkCssValue *result; GtkCssValue *result;
result = gtk_css_calc_value_parse_product (parser, flags, ctx); result = gtk_css_calc_value_parse_product (parser, flags);
if (result == NULL) if (result == NULL)
return NULL; return NULL;
@@ -156,13 +152,13 @@ gtk_css_calc_value_parse_sum (GtkCssParser *parser,
if (gtk_css_parser_try_delim (parser, '+')) if (gtk_css_parser_try_delim (parser, '+'))
{ {
next = gtk_css_calc_value_parse_product (parser, flags, ctx); next = gtk_css_calc_value_parse_product (parser, flags);
if (next == NULL) if (next == NULL)
goto fail; goto fail;
} }
else if (gtk_css_parser_try_delim (parser, '-')) else if (gtk_css_parser_try_delim (parser, '-'))
{ {
temp = gtk_css_calc_value_parse_product (parser, flags, ctx); temp = gtk_css_calc_value_parse_product (parser, flags);
if (temp == NULL) if (temp == NULL)
goto fail; goto fail;
next = gtk_css_number_value_multiply (temp, -1); next = gtk_css_number_value_multiply (temp, -1);
@@ -197,7 +193,6 @@ fail:
typedef struct typedef struct
{ {
GtkCssNumberParseFlags flags; GtkCssNumberParseFlags flags;
GtkCssNumberParseContext *ctx;
GtkCssValue *value; GtkCssValue *value;
} ParseCalcData; } ParseCalcData;
@@ -208,7 +203,7 @@ gtk_css_calc_value_parse_arg (GtkCssParser *parser,
{ {
ParseCalcData *data = data_; ParseCalcData *data = data_;
data->value = gtk_css_calc_value_parse_sum (parser, data->flags, data->ctx); data->value = gtk_css_calc_value_parse_sum (parser, data->flags);
if (data->value == NULL) if (data->value == NULL)
return 0; return 0;
@@ -216,16 +211,14 @@ gtk_css_calc_value_parse_arg (GtkCssParser *parser,
} }
GtkCssValue * GtkCssValue *
gtk_css_calc_value_parse (GtkCssParser *parser, gtk_css_calc_value_parse (GtkCssParser *parser,
GtkCssNumberParseFlags flags, GtkCssNumberParseFlags flags)
GtkCssNumberParseContext *ctx)
{ {
ParseCalcData data; ParseCalcData data;
/* This can only be handled at compute time, we allow '-' after all */ /* This can only be handled at compute time, we allow '-' after all */
data.flags = flags & ~GTK_CSS_POSITIVE_ONLY; data.flags = flags & ~GTK_CSS_POSITIVE_ONLY;
data.value = NULL; data.value = NULL;
data.ctx = ctx;
if (!gtk_css_parser_has_function (parser, "calc")) if (!gtk_css_parser_has_function (parser, "calc"))
{ {
@@ -242,7 +235,6 @@ gtk_css_calc_value_parse (GtkCssParser *parser,
typedef struct typedef struct
{ {
GtkCssNumberParseFlags flags; GtkCssNumberParseFlags flags;
GtkCssNumberParseContext *ctx;
GPtrArray *values; GPtrArray *values;
} ParseArgnData; } ParseArgnData;
@@ -254,7 +246,7 @@ gtk_css_argn_value_parse_arg (GtkCssParser *parser,
ParseArgnData *data = data_; ParseArgnData *data = data_;
GtkCssValue *value; GtkCssValue *value;
value = gtk_css_calc_value_parse_sum (parser, data->flags, data->ctx); value = gtk_css_calc_value_parse_sum (parser, data->flags);
if (value == NULL) if (value == NULL)
return 0; return 0;
@@ -266,7 +258,6 @@ gtk_css_argn_value_parse_arg (GtkCssParser *parser,
typedef struct typedef struct
{ {
GtkCssNumberParseFlags flags; GtkCssNumberParseFlags flags;
GtkCssNumberParseContext *ctx;
GtkCssValue *values[3]; GtkCssValue *values[3];
} ParseClampData; } ParseClampData;
@@ -286,7 +277,7 @@ gtk_css_clamp_value_parse_arg (GtkCssParser *parser,
} }
} }
data->values[arg] = gtk_css_calc_value_parse_sum (parser, data->flags, data->ctx); data->values[arg] = gtk_css_calc_value_parse_sum (parser, data->flags);
if (data->values[arg] == NULL) if (data->values[arg] == NULL)
return 0; return 0;
@@ -294,10 +285,9 @@ gtk_css_clamp_value_parse_arg (GtkCssParser *parser,
} }
GtkCssValue * GtkCssValue *
gtk_css_clamp_value_parse (GtkCssParser *parser, gtk_css_clamp_value_parse (GtkCssParser *parser,
GtkCssNumberParseFlags flags, GtkCssNumberParseFlags flags,
GtkCssNumberParseContext *ctx, guint type)
guint type)
{ {
ParseClampData data; ParseClampData data;
GtkCssValue *result = NULL; GtkCssValue *result = NULL;
@@ -310,7 +300,6 @@ gtk_css_clamp_value_parse (GtkCssParser *parser,
/* This can only be handled at compute time, we allow '-' after all */ /* This can only be handled at compute time, we allow '-' after all */
data.flags = flags & ~GTK_CSS_POSITIVE_ONLY; data.flags = flags & ~GTK_CSS_POSITIVE_ONLY;
data.ctx = ctx;
data.values[0] = NULL; data.values[0] = NULL;
data.values[1] = NULL; data.values[1] = NULL;
data.values[2] = NULL; data.values[2] = NULL;
@@ -337,7 +326,6 @@ gtk_css_clamp_value_parse (GtkCssParser *parser,
typedef struct { typedef struct {
GtkCssNumberParseFlags flags; GtkCssNumberParseFlags flags;
GtkCssNumberParseContext *ctx;
guint mode; guint mode;
gboolean has_mode; gboolean has_mode;
GtkCssValue *values[2]; GtkCssValue *values[2];
@@ -364,13 +352,13 @@ gtk_css_round_value_parse_arg (GtkCssParser *parser,
} }
} }
data->values[0] = gtk_css_calc_value_parse_sum (parser, data->flags, data->ctx); data->values[0] = gtk_css_calc_value_parse_sum (parser, data->flags);
if (data->values[0] == NULL) if (data->values[0] == NULL)
return 0; return 0;
} }
else if (arg == 1) else if (arg == 1)
{ {
GtkCssValue *value = gtk_css_calc_value_parse_sum (parser, data->flags, data->ctx); GtkCssValue *value = gtk_css_calc_value_parse_sum (parser, data->flags);
if (value == NULL) if (value == NULL)
return 0; return 0;
@@ -388,7 +376,7 @@ gtk_css_round_value_parse_arg (GtkCssParser *parser,
return 0; return 0;
} }
data->values[1] = gtk_css_calc_value_parse_sum (parser, data->flags, data->ctx); data->values[1] = gtk_css_calc_value_parse_sum (parser, data->flags);
if (data->values[1] == NULL) if (data->values[1] == NULL)
return 0; return 0;
@@ -398,10 +386,9 @@ gtk_css_round_value_parse_arg (GtkCssParser *parser,
} }
GtkCssValue * GtkCssValue *
gtk_css_round_value_parse (GtkCssParser *parser, gtk_css_round_value_parse (GtkCssParser *parser,
GtkCssNumberParseFlags flags, GtkCssNumberParseFlags flags,
GtkCssNumberParseContext *ctx, guint type)
guint type)
{ {
ParseRoundData data; ParseRoundData data;
GtkCssValue *result = NULL; GtkCssValue *result = NULL;
@@ -413,7 +400,6 @@ gtk_css_round_value_parse (GtkCssParser *parser,
} }
data.flags = flags & ~GTK_CSS_POSITIVE_ONLY; data.flags = flags & ~GTK_CSS_POSITIVE_ONLY;
data.ctx = ctx;
data.mode = ROUND_NEAREST; data.mode = ROUND_NEAREST;
data.has_mode = FALSE; data.has_mode = FALSE;
data.values[0] = NULL; data.values[0] = NULL;
@@ -444,7 +430,6 @@ gtk_css_round_value_parse (GtkCssParser *parser,
typedef struct { typedef struct {
GtkCssNumberParseFlags flags; GtkCssNumberParseFlags flags;
GtkCssNumberParseContext *ctx;
GtkCssValue *values[2]; GtkCssValue *values[2];
} ParseArg2Data; } ParseArg2Data;
@@ -455,7 +440,7 @@ gtk_css_arg2_value_parse_arg (GtkCssParser *parser,
{ {
ParseArg2Data *data = data_; ParseArg2Data *data = data_;
data->values[arg] = gtk_css_calc_value_parse_sum (parser, data->flags, data->ctx); data->values[arg] = gtk_css_calc_value_parse_sum (parser, data->flags);
if (data->values[arg] == NULL) if (data->values[arg] == NULL)
return 0; return 0;
@@ -463,13 +448,12 @@ gtk_css_arg2_value_parse_arg (GtkCssParser *parser,
} }
GtkCssValue * GtkCssValue *
gtk_css_arg2_value_parse (GtkCssParser *parser, gtk_css_arg2_value_parse (GtkCssParser *parser,
GtkCssNumberParseFlags flags, GtkCssNumberParseFlags flags,
GtkCssNumberParseContext *ctx, guint min_args,
guint min_args, guint max_args,
guint max_args, const char *function,
const char *function, guint type)
guint type)
{ {
ParseArg2Data data; ParseArg2Data data;
GtkCssValue *result = NULL; GtkCssValue *result = NULL;
@@ -483,7 +467,6 @@ gtk_css_arg2_value_parse (GtkCssParser *parser,
} }
data.flags = flags & ~GTK_CSS_POSITIVE_ONLY; data.flags = flags & ~GTK_CSS_POSITIVE_ONLY;
data.ctx = ctx;
data.values[0] = NULL; data.values[0] = NULL;
data.values[1] = NULL; data.values[1] = NULL;
@@ -507,11 +490,10 @@ gtk_css_arg2_value_parse (GtkCssParser *parser,
} }
GtkCssValue * GtkCssValue *
gtk_css_argn_value_parse (GtkCssParser *parser, gtk_css_argn_value_parse (GtkCssParser *parser,
GtkCssNumberParseFlags flags, GtkCssNumberParseFlags flags,
GtkCssNumberParseContext *ctx, const char *function,
const char *function, guint type)
guint type)
{ {
ParseArgnData data; ParseArgnData data;
GtkCssValue *result = NULL; GtkCssValue *result = NULL;
@@ -525,7 +507,6 @@ gtk_css_argn_value_parse (GtkCssParser *parser,
/* This can only be handled at compute time, we allow '-' after all */ /* This can only be handled at compute time, we allow '-' after all */
data.flags = flags & ~GTK_CSS_POSITIVE_ONLY; data.flags = flags & ~GTK_CSS_POSITIVE_ONLY;
data.values = g_ptr_array_new (); data.values = g_ptr_array_new ();
data.ctx = ctx;
if (gtk_css_parser_consume_function (parser, 1, G_MAXUINT, gtk_css_argn_value_parse_arg, &data)) if (gtk_css_parser_consume_function (parser, 1, G_MAXUINT, gtk_css_argn_value_parse_arg, &data))
{ {
@@ -554,3 +535,4 @@ gtk_css_argn_value_parse (GtkCssParser *parser,
return result; return result;
} }
+1 -6
View File
@@ -22,26 +22,21 @@
G_BEGIN_DECLS G_BEGIN_DECLS
GtkCssValue * gtk_css_calc_value_parse (GtkCssParser *parser, GtkCssValue * gtk_css_calc_value_parse (GtkCssParser *parser,
GtkCssNumberParseFlags flags, GtkCssNumberParseFlags flags);
GtkCssNumberParseContext *ctx);
GtkCssValue * gtk_css_clamp_value_parse (GtkCssParser *parser, GtkCssValue * gtk_css_clamp_value_parse (GtkCssParser *parser,
GtkCssNumberParseFlags flags, GtkCssNumberParseFlags flags,
GtkCssNumberParseContext *ctx,
guint type); guint type);
GtkCssValue * gtk_css_round_value_parse (GtkCssParser *parser, GtkCssValue * gtk_css_round_value_parse (GtkCssParser *parser,
GtkCssNumberParseFlags flags, GtkCssNumberParseFlags flags,
GtkCssNumberParseContext *ctx,
guint type); guint type);
GtkCssValue * gtk_css_arg2_value_parse (GtkCssParser *parser, GtkCssValue * gtk_css_arg2_value_parse (GtkCssParser *parser,
GtkCssNumberParseFlags flags, GtkCssNumberParseFlags flags,
GtkCssNumberParseContext *ctx,
guint min_args, guint min_args,
guint max_args, guint max_args,
const char *function, const char *function,
guint type); guint type);
GtkCssValue * gtk_css_argn_value_parse (GtkCssParser *parser, GtkCssValue * gtk_css_argn_value_parse (GtkCssParser *parser,
GtkCssNumberParseFlags flags, GtkCssNumberParseFlags flags,
GtkCssNumberParseContext *ctx,
const char *function, const char *function,
guint type); guint type);
+36 -480
View File
@@ -35,10 +35,6 @@ gtk_css_color_init (GtkCssColor *color,
case GTK_CSS_COLOR_SPACE_SRGB: case GTK_CSS_COLOR_SPACE_SRGB:
case GTK_CSS_COLOR_SPACE_SRGB_LINEAR: case GTK_CSS_COLOR_SPACE_SRGB_LINEAR:
case GTK_CSS_COLOR_SPACE_OKLAB: 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; break;
case GTK_CSS_COLOR_SPACE_HSL: case GTK_CSS_COLOR_SPACE_HSL:
@@ -77,54 +73,46 @@ append_color_component (GString *string,
g_string_append_printf (string, "%g", gtk_css_color_get_component (color, idx)); g_string_append_printf (string, "%g", gtk_css_color_get_component (color, idx));
} }
static void
print_as_rgb (const GtkCssColor *color,
GString *string)
{
GtkCssColor tmp;
gtk_css_color_convert (color, GTK_CSS_COLOR_SPACE_SRGB, &tmp);
if (tmp.values[3] > 0.999)
{
g_string_append_printf (string, "rgb(%d,%d,%d)",
(int)(0.5 + CLAMP (tmp.values[0], 0., 1.) * 255.),
(int)(0.5 + CLAMP (tmp.values[1], 0., 1.) * 255.),
(int)(0.5 + CLAMP (tmp.values[2], 0., 1.) * 255.));
}
else
{
char alpha[G_ASCII_DTOSTR_BUF_SIZE];
g_ascii_formatd (alpha, G_ASCII_DTOSTR_BUF_SIZE, "%g", CLAMP (tmp.values[3], 0, 1));
g_string_append_printf (string, "rgba(%d,%d,%d,%s)",
(int)(0.5 + CLAMP (tmp.values[0], 0., 1.) * 255.),
(int)(0.5 + CLAMP (tmp.values[1], 0., 1.) * 255.),
(int)(0.5 + CLAMP (tmp.values[2], 0., 1.) * 255.),
alpha);
}
}
GString * GString *
gtk_css_color_print (const GtkCssColor *color, gtk_css_color_print (const GtkCssColor *color,
gboolean serialize_as_rgb, gboolean serialize_as_rgb,
GString *string) GString *string)
{ {
GtkCssColorSpace print_color_space = color->color_space;
GtkCssColor tmp;
switch (color->color_space) switch (color->color_space)
{ {
case GTK_CSS_COLOR_SPACE_SRGB:
case GTK_CSS_COLOR_SPACE_HSL: case GTK_CSS_COLOR_SPACE_HSL:
case GTK_CSS_COLOR_SPACE_HWB: case GTK_CSS_COLOR_SPACE_HWB:
if (serialize_as_rgb) print_rgb:
{ {
print_as_rgb (color, string); GtkCssColor tmp;
return string;
} gtk_css_color_convert (color, GTK_CSS_COLOR_SPACE_SRGB, &tmp);
if (tmp.values[3] > 0.999)
{
g_string_append_printf (string, "rgb(%d,%d,%d)",
(int)(0.5 + CLAMP (tmp.values[0], 0., 1.) * 255.),
(int)(0.5 + CLAMP (tmp.values[1], 0., 1.) * 255.),
(int)(0.5 + CLAMP (tmp.values[2], 0., 1.) * 255.));
}
else
{
char alpha[G_ASCII_DTOSTR_BUF_SIZE];
g_ascii_formatd (alpha, G_ASCII_DTOSTR_BUF_SIZE, "%g", CLAMP (tmp.values[3], 0, 1));
g_string_append_printf (string, "rgba(%d,%d,%d,%s)",
(int)(0.5 + CLAMP (tmp.values[0], 0., 1.) * 255.),
(int)(0.5 + CLAMP (tmp.values[1], 0., 1.) * 255.),
(int)(0.5 + CLAMP (tmp.values[2], 0., 1.) * 255.),
alpha);
}
}
return string;
case GTK_CSS_COLOR_SPACE_SRGB:
if (serialize_as_rgb)
goto print_rgb;
print_color_space = GTK_CSS_COLOR_SPACE_SRGB;
g_string_append (string, "color(srgb "); g_string_append (string, "color(srgb ");
break; break;
@@ -140,43 +128,22 @@ gtk_css_color_print (const GtkCssColor *color,
g_string_append (string, "oklch("); g_string_append (string, "oklch(");
break; 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: default:
g_assert_not_reached (); g_assert_not_reached ();
} }
if (print_color_space != color->color_space)
gtk_css_color_convert (color, print_color_space, &tmp);
else
tmp = *color;
for (guint i = 0; i < 3; i++) for (guint i = 0; i < 3; i++)
{ {
if (i > 0) if (i > 0)
g_string_append_c (string, ' '); g_string_append_c (string, ' ');
append_color_component (string, &tmp, i); append_color_component (string, color, i);
} }
if (gtk_css_color_component_missing (&tmp, 3) || if (gtk_css_color_component_missing (color, 3) ||
tmp.values[3] < 0.999) color->values[3] < 0.999)
{ {
g_string_append (string, " / "); g_string_append (string, " / ");
append_color_component (string, &tmp, 3); append_color_component (string, color, 3);
} }
g_string_append_c (string, ')'); g_string_append_c (string, ')');
@@ -201,9 +168,6 @@ gtk_css_color_space_get_coord_name (GtkCssColorSpace color_space,
{ {
case GTK_CSS_COLOR_SPACE_SRGB: case GTK_CSS_COLOR_SPACE_SRGB:
case GTK_CSS_COLOR_SPACE_SRGB_LINEAR: 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) switch (coord)
{ {
case 0: return "r"; case 0: return "r";
@@ -211,14 +175,6 @@ gtk_css_color_space_get_coord_name (GtkCssColorSpace color_space,
case 2: return "b"; case 2: return "b";
default: g_assert_not_reached (); 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: case GTK_CSS_COLOR_SPACE_HSL:
switch (coord) switch (coord)
{ {
@@ -256,88 +212,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)
{
switch (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 ();
}
}
/* }}} */ /* }}} */
/* {{{ Color conversion */ /* {{{ Color conversion */
@@ -352,10 +226,6 @@ convert_to_rectangular (GtkCssColor *output)
case GTK_CSS_COLOR_SPACE_SRGB: case GTK_CSS_COLOR_SPACE_SRGB:
case GTK_CSS_COLOR_SPACE_SRGB_LINEAR: case GTK_CSS_COLOR_SPACE_SRGB_LINEAR:
case GTK_CSS_COLOR_SPACE_OKLAB: 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; break;
case GTK_CSS_COLOR_SPACE_HSL: case GTK_CSS_COLOR_SPACE_HSL:
@@ -397,11 +267,7 @@ convert_to_linear (GtkCssColor *output)
g_assert (output->color_space == GTK_CSS_COLOR_SPACE_SRGB || 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_SRGB_LINEAR ||
output->color_space == GTK_CSS_COLOR_SPACE_OKLAB || 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);
if (output->color_space == GTK_CSS_COLOR_SPACE_SRGB) if (output->color_space == GTK_CSS_COLOR_SPACE_SRGB)
{ {
@@ -412,52 +278,6 @@ convert_to_linear (GtkCssColor *output)
v[3] = output->values[3]; v[3] = output->values[3];
gtk_css_color_init (output, GTK_CSS_COLOR_SPACE_SRGB_LINEAR, v); 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 static void
@@ -482,52 +302,6 @@ convert_from_linear (GtkCssColor *output,
gtk_css_color_init (output, GTK_CSS_COLOR_SPACE_SRGB, v); gtk_css_color_init (output, GTK_CSS_COLOR_SPACE_SRGB, v);
break; 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_SRGB_LINEAR:
case GTK_CSS_COLOR_SPACE_OKLAB: case GTK_CSS_COLOR_SPACE_OKLAB:
case GTK_CSS_COLOR_SPACE_OKLCH: case GTK_CSS_COLOR_SPACE_OKLCH:
@@ -549,10 +323,6 @@ convert_from_rectangular (GtkCssColor *output,
case GTK_CSS_COLOR_SPACE_SRGB: case GTK_CSS_COLOR_SPACE_SRGB:
case GTK_CSS_COLOR_SPACE_SRGB_LINEAR: case GTK_CSS_COLOR_SPACE_SRGB_LINEAR:
case GTK_CSS_COLOR_SPACE_OKLAB: 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); g_assert (output->color_space == dest);
break; break;
@@ -719,10 +489,6 @@ apply_hue_interpolation (GtkCssColor *from,
case GTK_CSS_COLOR_SPACE_SRGB: case GTK_CSS_COLOR_SPACE_SRGB:
case GTK_CSS_COLOR_SPACE_SRGB_LINEAR: case GTK_CSS_COLOR_SPACE_SRGB_LINEAR:
case GTK_CSS_COLOR_SPACE_OKLAB: 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; break;
case GTK_CSS_COLOR_SPACE_HSL: case GTK_CSS_COLOR_SPACE_HSL:
@@ -755,10 +521,6 @@ normalize_hue (GtkCssColor *color)
case GTK_CSS_COLOR_SPACE_SRGB: case GTK_CSS_COLOR_SPACE_SRGB:
case GTK_CSS_COLOR_SPACE_SRGB_LINEAR: case GTK_CSS_COLOR_SPACE_SRGB_LINEAR:
case GTK_CSS_COLOR_SPACE_OKLAB: 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; break;
case GTK_CSS_COLOR_SPACE_HSL: case GTK_CSS_COLOR_SPACE_HSL:
@@ -796,10 +558,6 @@ premultiply (GtkCssColor *color)
case GTK_CSS_COLOR_SPACE_SRGB: case GTK_CSS_COLOR_SPACE_SRGB:
case GTK_CSS_COLOR_SPACE_SRGB_LINEAR: case GTK_CSS_COLOR_SPACE_SRGB_LINEAR:
case GTK_CSS_COLOR_SPACE_OKLAB: 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, 0);
premultiply_component (color, 1); premultiply_component (color, 1);
premultiply_component (color, 2); premultiply_component (color, 2);
@@ -842,10 +600,6 @@ unpremultiply (GtkCssColor *color)
case GTK_CSS_COLOR_SPACE_SRGB: case GTK_CSS_COLOR_SPACE_SRGB:
case GTK_CSS_COLOR_SPACE_SRGB_LINEAR: case GTK_CSS_COLOR_SPACE_SRGB_LINEAR:
case GTK_CSS_COLOR_SPACE_OKLAB: 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, 0);
unpremultiply_component (color, 1); unpremultiply_component (color, 1);
unpremultiply_component (color, 2); unpremultiply_component (color, 2);
@@ -882,10 +636,7 @@ collect_analogous_missing (const GtkCssColor *color,
{ -1, -1, -1, -1, -1, 0, -1, -1, 3 }, /* hwb */ { -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, -1, 1, 2, 3 }, /* oklab */
{ -1, -1, -1, 0, 1, 2, -1, -1, 3 }, /* oklch */ { -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]; int *src = analogous[color->color_space];
@@ -968,200 +719,5 @@ gtk_css_color_interpolate (const GtkCssColor *from,
unpremultiply (output); unpremultiply (output);
} }
static gboolean
parse_hue_interpolation (GtkCssParser *parser,
GtkCssHueInterpolation *interp)
{
const GtkCssToken *token = gtk_css_parser_get_token (parser);
if (gtk_css_token_is_ident (token, "shorter"))
{
gtk_css_parser_consume_token (parser);
*interp = GTK_CSS_HUE_INTERPOLATION_SHORTER;
}
else if (gtk_css_token_is_ident (token, "longer"))
{
gtk_css_parser_consume_token (parser);
*interp = GTK_CSS_HUE_INTERPOLATION_LONGER;
}
else if (gtk_css_token_is_ident (token, "increasing"))
{
gtk_css_parser_consume_token (parser);
*interp = GTK_CSS_HUE_INTERPOLATION_INCREASING;
}
else if (gtk_css_token_is_ident (token, "decreasing"))
{
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;
return TRUE;
}
if (!gtk_css_parser_try_ident (parser, "hue"))
{
gtk_css_parser_error_syntax (parser, "Expected 'hue'");
return FALSE;
}
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,
GtkCssHueInterpolation *interp)
{
const GtkCssToken *token;
if (!gtk_css_parser_try_ident (parser, "in"))
{
gtk_css_parser_error_syntax (parser, "Expected 'in'");
return FALSE;
}
token = gtk_css_parser_get_token (parser);
if (gtk_css_token_is_ident (token, "srgb"))
{
gtk_css_parser_consume_token (parser);
*in = GTK_CSS_COLOR_SPACE_SRGB;
}
else if (gtk_css_token_is_ident (token, "srgb-linear"))
{
gtk_css_parser_consume_token (parser);
*in = GTK_CSS_COLOR_SPACE_SRGB_LINEAR;
}
else if (gtk_css_token_is_ident (token, "hsl"))
{
gtk_css_parser_consume_token (parser);
*in = GTK_CSS_COLOR_SPACE_HSL;
}
else if (gtk_css_token_is_ident (token, "hwb"))
{
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"))
{
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;
}
else
{
gtk_css_parser_error_syntax (parser, "Invalid color space: %s", gtk_css_token_to_string (token));
return FALSE;
}
if (color_space_is_polar (*in))
return parse_hue_interpolation (parser, interp);
return TRUE;
}
void
gtk_css_color_interpolation_method_print (GtkCssColorSpace in,
GtkCssHueInterpolation interp,
GString *string)
{
g_string_append (string, "in ");
switch (in)
{
case GTK_CSS_COLOR_SPACE_SRGB:
g_string_append (string, "srgb");
break;
case GTK_CSS_COLOR_SPACE_SRGB_LINEAR:
g_string_append (string, "srgb-linear");
break;
case GTK_CSS_COLOR_SPACE_HSL:
g_string_append (string, "hsl");
break;
case GTK_CSS_COLOR_SPACE_HWB:
g_string_append (string, "hwb");
break;
case GTK_CSS_COLOR_SPACE_OKLCH:
g_string_append (string, "oklch");
break;
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 ();
}
if (!color_space_is_polar (in))
return;
switch (interp)
{
case GTK_CSS_HUE_INTERPOLATION_SHORTER:
/* shorter is the default mode, don't print it */
break;
case GTK_CSS_HUE_INTERPOLATION_LONGER:
g_string_append (string, " longer hue");
break;
case GTK_CSS_HUE_INTERPOLATION_INCREASING:
g_string_append (string, " increasing hue");
break;
case GTK_CSS_HUE_INTERPOLATION_DECREASING:
g_string_append (string, " decreasing hue");
break;
default:
g_assert_not_reached ();
}
}
/* }}} */ /* }}} */
/* vim:set foldmethod=marker expandtab: */ /* vim:set foldmethod=marker expandtab: */
+16 -19
View File
@@ -20,11 +20,16 @@
#include <glib.h> #include <glib.h>
#include <math.h> #include <math.h>
#include "gtk/css/gtkcssparserprivate.h"
#include "gtkcsstypesprivate.h"
G_BEGIN_DECLS 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 typedef struct
{ {
@@ -89,6 +94,14 @@ void gtk_css_color_convert (const GtkCssColor *input,
GtkCssColorSpace dest, GtkCssColorSpace dest,
GtkCssColor *output); 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, void gtk_css_color_interpolate (const GtkCssColor *from,
const GtkCssColor *to, const GtkCssColor *to,
float progress, float progress,
@@ -99,20 +112,4 @@ void gtk_css_color_interpolate (const GtkCssColor *from,
const char * gtk_css_color_space_get_coord_name (GtkCssColorSpace color_space, const char * gtk_css_color_space_get_coord_name (GtkCssColorSpace color_space,
guint coord); 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);
void gtk_css_color_interpolation_method_print (GtkCssColorSpace in,
GtkCssHueInterpolation interp,
GString *string);
G_END_DECLS G_END_DECLS
+360 -940
View File
File diff suppressed because it is too large Load Diff
+3 -9
View File
@@ -33,11 +33,9 @@ GtkCssValue * gtk_css_color_value_new_name (const char *name) G
gboolean gtk_css_color_value_can_parse (GtkCssParser *parser); gboolean gtk_css_color_value_can_parse (GtkCssParser *parser);
GtkCssValue * gtk_css_color_value_parse (GtkCssParser *parser); GtkCssValue * gtk_css_color_value_parse (GtkCssParser *parser);
GtkCssValue * gtk_css_color_value_resolve (GtkCssValue *color, GtkCssValue * gtk_css_color_value_resolve (GtkCssValue *color,
guint property_id, GtkStyleProvider *provider,
GtkCssComputeContext *context, GtkCssValue *current);
GtkCssValue *current);
const GdkRGBA * gtk_css_color_value_get_rgba (const GtkCssValue *color) G_GNUC_CONST; const GdkRGBA * gtk_css_color_value_get_rgba (const GtkCssValue *color) G_GNUC_CONST;
GtkCssValue * gtk_css_color_value_new_color (GtkCssColorSpace color_space, GtkCssValue * gtk_css_color_value_new_color (GtkCssColorSpace color_space,
@@ -48,10 +46,6 @@ GtkCssValue * gtk_css_color_value_new_color (GtkCssColorSpace color_
const GtkCssColor * const GtkCssColor *
gtk_css_color_value_get_color (const GtkCssValue *color) G_GNUC_CONST; gtk_css_color_value_get_color (const GtkCssValue *color) G_GNUC_CONST;
float gtk_css_color_value_get_coord (const GtkCssValue *color,
GtkCssColorSpace color_space,
gboolean legacy_srgb,
guint coord);
G_END_DECLS G_END_DECLS
+30 -71
View File
@@ -81,10 +81,7 @@ gtk_css_image_conic_snapshot (GtkCssImage *image,
last = i; last = i;
} }
if (self->color_space != GTK_CSS_COLOR_SPACE_SRGB) gtk_snapshot_append_conic_gradient (
g_warning_once ("Gradient interpolation color spaces are not supported yet");
gtk_snapshot_append_conic_gradient (
snapshot, snapshot,
&GRAPHENE_RECT_INIT (0, 0, width, height), &GRAPHENE_RECT_INIT (0, 0, width, height),
&GRAPHENE_POINT_INIT (_gtk_css_position_value_get_x (self->center, width), &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, GtkCssParser *parser,
GArray *stop_array) GArray *stop_array)
{ {
gboolean has_rotation = FALSE; gboolean nothing_parsed = TRUE;
gboolean has_center = FALSE;
gboolean has_colorspace = FALSE;
int retval = 1;
do if (gtk_css_parser_try_ident (parser, "from"))
{ {
if (!has_colorspace && gtk_css_color_interpolation_method_can_parse (parser)) self->rotation = gtk_css_number_value_parse (parser, GTK_CSS_PARSE_ANGLE);
{ if (self->rotation == NULL)
if (!gtk_css_color_interpolation_method_parse (parser, &self->color_space, &self->hue_interp)) return 0;
return 0; nothing_parsed = FALSE;
has_colorspace = TRUE; }
} else
else if (!has_rotation && gtk_css_parser_try_ident (parser, "from")) {
{ self->rotation = gtk_css_number_value_new (0, GTK_CSS_DEG);
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;
}
}
} }
while (!(has_colorspace && has_rotation && has_center));
if (!has_rotation) if (gtk_css_parser_try_ident (parser, "at"))
self->rotation = gtk_css_number_value_new (0, GTK_CSS_DEG); {
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) if (!nothing_parsed)
self->center = _gtk_css_position_value_new (gtk_css_number_value_new (50, GTK_CSS_PERCENT), return 1;
gtk_css_number_value_new (50, GTK_CSS_PERCENT));
return retval; return 1 + gtk_css_image_conic_parse_color_stop (self, parser, stop_array);
} }
typedef struct typedef struct
@@ -288,7 +265,7 @@ gtk_css_image_conic_print (GtkCssImage *image,
gboolean written = FALSE; gboolean written = FALSE;
guint i; guint i;
g_string_append (string, "conic-gradient("); g_string_append (string, "self-gradient(");
if (self->center) if (self->center)
{ {
@@ -297,7 +274,7 @@ gtk_css_image_conic_print (GtkCssImage *image,
if (!gtk_css_value_equal (self->center, compare)) 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); gtk_css_value_print (self->center, string);
written = TRUE; written = TRUE;
} }
@@ -309,19 +286,8 @@ gtk_css_image_conic_print (GtkCssImage *image,
{ {
if (written) if (written)
g_string_append_c (string, ' '); g_string_append_c (string, ' ');
g_string_append (string, "from "); g_string_append (string, "at ");
gtk_css_value_print (self->rotation, string); 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) 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->center = gtk_css_value_compute (self->center, property_id, context);
copy->rotation = gtk_css_value_compute (self->rotation, 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->n_stops = self->n_stops;
copy->color_stops = g_malloc (sizeof (GtkCssImageConicColorStop) * copy->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) if (result->rotation == NULL)
goto fail; 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->color_stops = g_malloc (sizeof (GtkCssImageConicColorStop) * start->n_stops);
result->n_stops = 0; result->n_stops = 0;
for (i = 0; i < start->n_stops; i++) for (i = 0; i < start->n_stops; i++)
@@ -474,9 +435,7 @@ gtk_css_image_conic_equal (GtkCssImage *image1,
guint i; guint i;
if (!gtk_css_value_equal (conic1->center, conic2->center) || if (!gtk_css_value_equal (conic1->center, conic2->center) ||
!gtk_css_value_equal (conic1->rotation, conic2->rotation) || !gtk_css_value_equal (conic1->rotation, conic2->rotation))
conic1->color_space != conic2->color_space ||
conic1->hue_interp != conic2->hue_interp)
return FALSE; return FALSE;
for (i = 0; i < conic1->n_stops; i++) for (i = 0; i < conic1->n_stops; i++)
-3
View File
@@ -47,9 +47,6 @@ struct _GtkCssImageConic
GtkCssValue *center; GtkCssValue *center;
GtkCssValue *rotation; GtkCssValue *rotation;
GtkCssColorSpace color_space;
GtkCssHueInterpolation hue_interp;
guint n_stops; guint n_stops;
GtkCssImageConicColorStop *color_stops; GtkCssImageConicColorStop *color_stops;
}; };
+56 -109
View File
@@ -244,9 +244,6 @@ gtk_css_image_linear_snapshot (GtkCssImage *image,
last = i; 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) if (linear->repeating)
{ {
gtk_snapshot_append_repeating_linear_gradient ( gtk_snapshot_append_repeating_linear_gradient (
@@ -307,102 +304,75 @@ gtk_css_image_linear_parse_first_arg (GtkCssImageLinear *linear,
GArray *stop_array) GArray *stop_array)
{ {
guint i; 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)) if (gtk_css_parser_try_ident (parser, "left"))
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 (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;
gtk_css_parser_error_syntax (parser, "Expected 'top', 'bottom' or comma");
return 0;
}
linear->side |= (1 << GTK_CSS_LEFT);
} }
else if (gtk_css_parser_try_ident (parser, "right")) linear->side |= (1 << GTK_CSS_LEFT);
{
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;
} }
else if (gtk_css_parser_try_ident (parser, "right"))
if (linear->side == 0)
{ {
gtk_css_parser_error_syntax (parser, "Expected side that gradient should go to"); if (linear->side & ((1 << GTK_CSS_LEFT) | (1 << GTK_CSS_RIGHT)))
return 0; {
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"))
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))
{ {
retval = 2; if (linear->side & ((1 << GTK_CSS_TOP) | (1 << GTK_CSS_BOTTOM)))
break; {
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 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) return 1;
linear->side = (1 << GTK_CSS_BOTTOM); }
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 typedef struct
@@ -467,7 +437,6 @@ gtk_css_image_linear_print (GtkCssImage *image,
{ {
GtkCssImageLinear *linear = GTK_CSS_IMAGE_LINEAR (image); GtkCssImageLinear *linear = GTK_CSS_IMAGE_LINEAR (image);
guint i; guint i;
gboolean has_printed = FALSE;
if (linear->repeating) if (linear->repeating)
g_string_append (string, "repeating-linear-gradient("); 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)) else if (linear->side & (1 << GTK_CSS_RIGHT))
g_string_append (string, " right"); g_string_append (string, " right");
has_printed = TRUE; g_string_append (string, ", ");
} }
} }
else else
{ {
gtk_css_value_print (linear->angle, string); 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++) for (i = 0; i < linear->n_stops; i++)
{ {
const GtkCssImageLinearColorStop *stop = &linear->color_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 = g_object_new (GTK_TYPE_CSS_IMAGE_LINEAR, NULL);
copy->repeating = linear->repeating; copy->repeating = linear->repeating;
copy->side = linear->side; copy->side = linear->side;
copy->color_space = linear->color_space;
copy->hue_interp = linear->hue_interp;
if (linear->angle) if (linear->angle)
copy->angle = gtk_css_value_compute (linear->angle, property_id, context); 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); end = GTK_CSS_IMAGE_LINEAR (end_image);
if ((start->repeating != end->repeating) if ((start->repeating != end->repeating)
|| (start->n_stops != end->n_stops) || (start->n_stops != end->n_stops))
|| (start->color_space != end->color_space)
|| (start->hue_interp != end->hue_interp))
return GTK_CSS_IMAGE_CLASS (_gtk_css_image_linear_parent_class)->transition (start_image, end_image, property_id, progress); 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 = g_object_new (GTK_TYPE_CSS_IMAGE_LINEAR, NULL);
result->repeating = start->repeating; result->repeating = start->repeating;
result->color_space = start->color_space;
result->hue_interp = start->hue_interp;
if (start->side != end->side) if (start->side != end->side)
goto fail; goto fail;
@@ -669,9 +618,7 @@ gtk_css_image_linear_equal (GtkCssImage *image1,
if (linear1->repeating != linear2->repeating || if (linear1->repeating != linear2->repeating ||
linear1->side != linear2->side || linear1->side != linear2->side ||
(linear1->side == 0 && !gtk_css_value_equal (linear1->angle, linear2->angle)) || (linear1->side == 0 && !gtk_css_value_equal (linear1->angle, linear2->angle)) ||
linear1->n_stops != linear2->n_stops || linear1->n_stops != linear2->n_stops)
linear1->color_space != linear2->color_space ||
linear1->hue_interp != linear2->hue_interp)
return FALSE; return FALSE;
for (i = 0; i < linear1->n_stops; i++) for (i = 0; i < linear1->n_stops; i++)
-3
View File
@@ -48,9 +48,6 @@ struct _GtkCssImageLinear
guint repeating :1; guint repeating :1;
GtkCssValue *angle; GtkCssValue *angle;
GtkCssColorSpace color_space;
GtkCssHueInterpolation hue_interp;
guint n_stops; guint n_stops;
GtkCssImageLinearColorStop *color_stops; GtkCssImageLinearColorStop *color_stops;
}; };
+3 -27
View File
@@ -194,9 +194,6 @@ gtk_css_image_radial_snapshot (GtkCssImage *image,
last = i; 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) if (radial->repeating)
gtk_snapshot_append_repeating_radial_gradient (snapshot, gtk_snapshot_append_repeating_radial_gradient (snapshot,
&GRAPHENE_RECT_INIT (0, 0, width, height), &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_shape = FALSE;
gboolean has_size = FALSE; gboolean has_size = FALSE;
gboolean has_colorspace = FALSE;
gboolean found_one = FALSE; gboolean found_one = FALSE;
guint i; guint i;
static struct { static struct {
@@ -274,13 +270,7 @@ gtk_css_image_radial_parse_first_arg (GtkCssImageRadial *radial,
found_one = FALSE; found_one = FALSE;
do { do {
if (!has_colorspace && gtk_css_color_interpolation_method_can_parse (parser)) if (!has_shape && gtk_css_parser_try_ident (parser, "circle"))
{
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"))
{ {
radial->circle = TRUE; radial->circle = TRUE;
found_one = has_shape = TRUE; found_one = has_shape = TRUE;
@@ -477,14 +467,6 @@ gtk_css_image_radial_print (GtkCssImage *image,
g_string_append (string, " at "); g_string_append (string, " at ");
gtk_css_value_print (radial->position, string); 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, ", "); g_string_append (string, ", ");
for (i = 0; i < radial->n_stops; i++) for (i = 0; i < radial->n_stops; i++)
@@ -519,8 +501,6 @@ gtk_css_image_radial_compute (GtkCssImage *image,
copy->repeating = radial->repeating; copy->repeating = radial->repeating;
copy->circle = radial->circle; copy->circle = radial->circle;
copy->size = radial->size; 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); 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 || if (start->repeating != end->repeating ||
start->n_stops != end->n_stops || start->n_stops != end->n_stops ||
start->size != end->size || start->size != end->size ||
start->circle != end->circle || start->circle != end->circle)
start->color_space != end->color_space ||
start->hue_interp != end->hue_interp)
return GTK_CSS_IMAGE_CLASS (_gtk_css_image_radial_parent_class)->transition (start_image, end_image, property_id, progress); 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); 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[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] == NULL) != (radial2->sizes[1] == NULL)) ||
(radial1->sizes[1] && radial2->sizes[1] && !gtk_css_value_equal (radial1->sizes[1], radial2->sizes[1])) || (radial1->sizes[1] && radial2->sizes[1] && !gtk_css_value_equal (radial1->sizes[1], radial2->sizes[1])) ||
radial1->n_stops != radial2->n_stops || radial1->n_stops != radial2->n_stops)
radial1->color_space != radial2->color_space ||
radial1->hue_interp != radial2->hue_interp)
return FALSE; return FALSE;
for (i = 0; i < radial1->n_stops; i++) for (i = 0; i < radial1->n_stops; i++)
-5
View File
@@ -54,13 +54,8 @@ struct _GtkCssImageRadial
GtkCssValue *position; GtkCssValue *position;
GtkCssValue *sizes[2]; GtkCssValue *sizes[2];
GtkCssColorSpace color_space;
GtkCssHueInterpolation hue_interp;
guint n_stops; guint n_stops;
GtkCssImageRadialColorStop *color_stops; GtkCssImageRadialColorStop *color_stops;
GtkCssRadialSize size; GtkCssRadialSize size;
guint circle : 1; guint circle : 1;
guint repeating :1; guint repeating :1;
+24 -118
View File
@@ -22,7 +22,6 @@
#include "gtkcsscalcvalueprivate.h" #include "gtkcsscalcvalueprivate.h"
#include "gtkcssenumvalueprivate.h" #include "gtkcssenumvalueprivate.h"
#include "gtkcssdimensionvalueprivate.h" #include "gtkcssdimensionvalueprivate.h"
#include "gtkcsscolorvalueprivate.h"
#include "gtkcssstyleprivate.h" #include "gtkcssstyleprivate.h"
#include "gtkprivate.h" #include "gtkprivate.h"
@@ -70,7 +69,6 @@ typedef enum {
TYPE_EXP, TYPE_EXP,
TYPE_LOG, TYPE_LOG,
TYPE_HYPOT, TYPE_HYPOT,
TYPE_COLOR_COORD,
} NumberValueType; } NumberValueType;
static const char *function_name[] = { static const char *function_name[] = {
@@ -112,12 +110,6 @@ struct _GtkCssValue {
guint n_terms; guint n_terms;
GtkCssValue *terms[1]; GtkCssValue *terms[1];
} calc; } calc;
struct {
GtkCssValue *color;
GtkCssColorSpace color_space;
guint coord : 16;
guint legacy_rgb_scale : 1;
} color_coord;
}; };
}; };
@@ -148,11 +140,7 @@ gtk_css_calc_value_new (guint type,
static void static void
gtk_css_value_number_free (GtkCssValue *number) gtk_css_value_number_free (GtkCssValue *number)
{ {
if (number->type == TYPE_COLOR_COORD) if (number->type != TYPE_DIMENSION)
{
gtk_css_value_unref (number->color_coord.color);
}
else if (number->type != TYPE_DIMENSION)
{ {
for (guint i = 0; i < number->calc.n_terms; i++) for (guint i = 0; i < number->calc.n_terms; i++)
{ {
@@ -322,21 +310,7 @@ gtk_css_value_number_compute (GtkCssValue *number,
GtkCssStyle *style = context->style; GtkCssStyle *style = context->style;
GtkCssStyle *parent_style = context->parent_style; GtkCssStyle *parent_style = context->parent_style;
if (number->type == TYPE_COLOR_COORD) if (number->type != TYPE_DIMENSION)
{
GtkCssValue *color;
float v;
color = gtk_css_value_compute (number->color_coord.color, property_id, context);
v = gtk_css_color_value_get_coord (color,
number->color_coord.color_space,
number->color_coord.legacy_rgb_scale,
number->color_coord.coord);
gtk_css_value_unref (color);
return gtk_css_number_value_new (v, GTK_CSS_NUMBER);
}
else if (number->type != TYPE_DIMENSION)
{ {
const guint n_terms = number->calc.n_terms; const guint n_terms = number->calc.n_terms;
GtkCssValue *result; GtkCssValue *result;
@@ -546,10 +520,6 @@ gtk_css_value_number_print (const GtkCssValue *value,
g_string_append_c (string, ')'); g_string_append_c (string, ')');
break; break;
case TYPE_COLOR_COORD:
g_string_append (string, gtk_css_color_space_get_coord_name (value->color_coord.color_space, value->color_coord.coord));
break;
default: default:
{ {
const char *sep = value->type == TYPE_CALC ? " + " : (value->type == TYPE_PRODUCT ? " * " : ", "); const char *sep = value->type == TYPE_CALC ? " + " : (value->type == TYPE_PRODUCT ? " * " : ", ");
@@ -901,7 +871,6 @@ gtk_css_number_value_get_dimension (const GtkCssValue *value)
case TYPE_SQRT: case TYPE_SQRT:
case TYPE_POW: case TYPE_POW:
case TYPE_LOG: case TYPE_LOG:
case TYPE_COLOR_COORD:
return GTK_CSS_DIMENSION_NUMBER; return GTK_CSS_DIMENSION_NUMBER;
case TYPE_ASIN: case TYPE_ASIN:
@@ -918,11 +887,7 @@ gtk_css_number_value_get_dimension (const GtkCssValue *value)
gboolean gboolean
gtk_css_number_value_has_percent (const GtkCssValue *value) gtk_css_number_value_has_percent (const GtkCssValue *value)
{ {
if (value->type == TYPE_COLOR_COORD) if (value->type == TYPE_DIMENSION)
{
return FALSE;
}
else if (value->type == TYPE_DIMENSION)
{ {
return gtk_css_unit_get_dimension (value->dimension.unit) == GTK_CSS_DIMENSION_PERCENTAGE; return gtk_css_unit_get_dimension (value->dimension.unit) == GTK_CSS_DIMENSION_PERCENTAGE;
} }
@@ -1361,7 +1326,6 @@ gtk_css_math_value_new (guint type,
switch ((NumberValueType) type) switch ((NumberValueType) type)
{ {
case TYPE_DIMENSION: case TYPE_DIMENSION:
case TYPE_COLOR_COORD:
g_assert_not_reached (); g_assert_not_reached ();
case TYPE_ROUND: case TYPE_ROUND:
@@ -1443,16 +1407,6 @@ gtk_css_number_value_can_parse (GtkCssParser *parser)
GtkCssValue * GtkCssValue *
gtk_css_number_value_parse (GtkCssParser *parser, gtk_css_number_value_parse (GtkCssParser *parser,
GtkCssNumberParseFlags flags) GtkCssNumberParseFlags flags)
{
GtkCssNumberParseContext ctx = { NULL, 0, FALSE };
return gtk_css_number_value_parse_with_context (parser, flags, &ctx);
}
GtkCssValue *
gtk_css_number_value_parse_with_context (GtkCssParser *parser,
GtkCssNumberParseFlags flags,
GtkCssNumberParseContext *ctx)
{ {
const GtkCssToken *token = gtk_css_parser_get_token (parser); const GtkCssToken *token = gtk_css_parser_get_token (parser);
@@ -1461,47 +1415,47 @@ gtk_css_number_value_parse_with_context (GtkCssParser *parser,
const char *name = gtk_css_token_get_string (token); const char *name = gtk_css_token_get_string (token);
if (g_ascii_strcasecmp (name, "calc") == 0) if (g_ascii_strcasecmp (name, "calc") == 0)
return gtk_css_calc_value_parse (parser, flags, ctx); return gtk_css_calc_value_parse (parser, flags);
else if (g_ascii_strcasecmp (name, "min") == 0) else if (g_ascii_strcasecmp (name, "min") == 0)
return gtk_css_argn_value_parse (parser, flags, ctx, "min", TYPE_MIN); return gtk_css_argn_value_parse (parser, flags, "min", TYPE_MIN);
else if (g_ascii_strcasecmp (name, "max") == 0) else if (g_ascii_strcasecmp (name, "max") == 0)
return gtk_css_argn_value_parse (parser, flags, ctx, "max", TYPE_MAX); return gtk_css_argn_value_parse (parser, flags, "max", TYPE_MAX);
else if (g_ascii_strcasecmp (name, "hypot") == 0) else if (g_ascii_strcasecmp (name, "hypot") == 0)
return gtk_css_argn_value_parse (parser, flags, ctx, "hypot", TYPE_HYPOT); return gtk_css_argn_value_parse (parser, flags, "hypot", TYPE_HYPOT);
else if (g_ascii_strcasecmp (name, "clamp") == 0) else if (g_ascii_strcasecmp (name, "clamp") == 0)
return gtk_css_clamp_value_parse (parser, flags, ctx, TYPE_CLAMP); return gtk_css_clamp_value_parse (parser, flags, TYPE_CLAMP);
else if (g_ascii_strcasecmp (name, "round") == 0) else if (g_ascii_strcasecmp (name, "round") == 0)
return gtk_css_round_value_parse (parser, flags, ctx, TYPE_ROUND); return gtk_css_round_value_parse (parser, flags, TYPE_ROUND);
else if (g_ascii_strcasecmp (name, "mod") == 0) else if (g_ascii_strcasecmp (name, "mod") == 0)
return gtk_css_arg2_value_parse (parser, flags, ctx, 2, 2, "mod", TYPE_MOD); return gtk_css_arg2_value_parse (parser, flags, 2, 2, "mod", TYPE_MOD);
else if (g_ascii_strcasecmp (name, "rem") == 0) else if (g_ascii_strcasecmp (name, "rem") == 0)
return gtk_css_arg2_value_parse (parser, flags, ctx, 2, 2, "rem", TYPE_REM); return gtk_css_arg2_value_parse (parser, flags, 2, 2, "rem", TYPE_REM);
else if (g_ascii_strcasecmp (name, "abs") == 0) else if (g_ascii_strcasecmp (name, "abs") == 0)
return gtk_css_arg2_value_parse (parser, flags, ctx, 1, 1, "abs", TYPE_ABS); return gtk_css_arg2_value_parse (parser, flags, 1, 1, "abs", TYPE_ABS);
else if ((flags & GTK_CSS_PARSE_NUMBER) && g_ascii_strcasecmp (name, "sign") == 0) else if ((flags & GTK_CSS_PARSE_NUMBER) && g_ascii_strcasecmp (name, "sign") == 0)
return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER|GTK_CSS_PARSE_DIMENSION|GTK_CSS_PARSE_PERCENT, ctx, 1, 1, "sign", TYPE_SIGN); return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER|GTK_CSS_PARSE_DIMENSION|GTK_CSS_PARSE_PERCENT, 1, 1, "sign", TYPE_SIGN);
else if ((flags & GTK_CSS_PARSE_NUMBER) && g_ascii_strcasecmp (name, "sin") == 0) else if ((flags & GTK_CSS_PARSE_NUMBER) && g_ascii_strcasecmp (name, "sin") == 0)
return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER|GTK_CSS_PARSE_ANGLE, ctx, 1, 1, "sin", TYPE_SIN); return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER|GTK_CSS_PARSE_ANGLE, 1, 1, "sin", TYPE_SIN);
else if ((flags & GTK_CSS_PARSE_NUMBER) && g_ascii_strcasecmp (name, "cos") == 0) else if ((flags & GTK_CSS_PARSE_NUMBER) && g_ascii_strcasecmp (name, "cos") == 0)
return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER|GTK_CSS_PARSE_ANGLE, ctx, 1, 1, "cos", TYPE_COS); return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER|GTK_CSS_PARSE_ANGLE, 1, 1, "cos", TYPE_COS);
else if ((flags & GTK_CSS_PARSE_NUMBER) && g_ascii_strcasecmp (name, "tan") == 0) else if ((flags & GTK_CSS_PARSE_NUMBER) && g_ascii_strcasecmp (name, "tan") == 0)
return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER|GTK_CSS_PARSE_ANGLE, ctx, 1, 1, "tan", TYPE_TAN); return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER|GTK_CSS_PARSE_ANGLE, 1, 1, "tan", TYPE_TAN);
else if ((flags & GTK_CSS_PARSE_ANGLE) && g_ascii_strcasecmp (name, "asin") == 0) else if ((flags & GTK_CSS_PARSE_ANGLE) && g_ascii_strcasecmp (name, "asin") == 0)
return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER, ctx, 1, 1, "asin", TYPE_ASIN); return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER, 1, 1, "asin", TYPE_ASIN);
else if ((flags & GTK_CSS_PARSE_ANGLE) && g_ascii_strcasecmp (name, "acos") == 0) else if ((flags & GTK_CSS_PARSE_ANGLE) && g_ascii_strcasecmp (name, "acos") == 0)
return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER, ctx, 1, 1, "acos", TYPE_ACOS); return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER, 1, 1, "acos", TYPE_ACOS);
else if ((flags & GTK_CSS_PARSE_ANGLE) && g_ascii_strcasecmp (name, "atan") == 0) else if ((flags & GTK_CSS_PARSE_ANGLE) && g_ascii_strcasecmp (name, "atan") == 0)
return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER, ctx, 1, 1, "atan", TYPE_ATAN); return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER, 1, 1, "atan", TYPE_ATAN);
else if ((flags & GTK_CSS_PARSE_ANGLE) && g_ascii_strcasecmp (name, "atan2") == 0) else if ((flags & GTK_CSS_PARSE_ANGLE) && g_ascii_strcasecmp (name, "atan2") == 0)
return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER|GTK_CSS_PARSE_DIMENSION|GTK_CSS_PARSE_PERCENT, ctx, 2, 2, "atan2", TYPE_ATAN2); return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER|GTK_CSS_PARSE_DIMENSION|GTK_CSS_PARSE_PERCENT, 2, 2, "atan2", TYPE_ATAN2);
else if ((flags & GTK_CSS_PARSE_NUMBER) && g_ascii_strcasecmp (name, "pow") == 0) else if ((flags & GTK_CSS_PARSE_NUMBER) && g_ascii_strcasecmp (name, "pow") == 0)
return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER, ctx, 2, 2, "pow", TYPE_POW); return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER, 2, 2, "pow", TYPE_POW);
else if ((flags & GTK_CSS_PARSE_NUMBER) && g_ascii_strcasecmp (name, "sqrt") == 0) else if ((flags & GTK_CSS_PARSE_NUMBER) && g_ascii_strcasecmp (name, "sqrt") == 0)
return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER, ctx, 1, 1, "sqrt", TYPE_SQRT); return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER, 1, 1, "sqrt", TYPE_SQRT);
else if ((flags & GTK_CSS_PARSE_NUMBER) && g_ascii_strcasecmp (name, "exp") == 0) else if ((flags & GTK_CSS_PARSE_NUMBER) && g_ascii_strcasecmp (name, "exp") == 0)
return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER, ctx, 1, 1, "exp", TYPE_EXP); return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER, 1, 1, "exp", TYPE_EXP);
else if ((flags & GTK_CSS_PARSE_NUMBER) && g_ascii_strcasecmp (name, "log") == 0) else if ((flags & GTK_CSS_PARSE_NUMBER) && g_ascii_strcasecmp (name, "log") == 0)
return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER, ctx, 1, 2, "log", TYPE_LOG); return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER, 1, 2, "log", TYPE_LOG);
} }
else if (gtk_css_token_is (token, GTK_CSS_TOKEN_IDENT)) else if (gtk_css_token_is (token, GTK_CSS_TOKEN_IDENT))
{ {
@@ -1525,18 +1479,6 @@ gtk_css_number_value_parse_with_context (GtkCssParser *parser,
return gtk_css_number_value_new (constants[i].value, GTK_CSS_NUMBER); return gtk_css_number_value_new (constants[i].value, GTK_CSS_NUMBER);
} }
} }
if (ctx->color)
{
for (guint i = 0; i < 4; i++)
{
if (g_ascii_strcasecmp (name, gtk_css_color_space_get_coord_name (ctx->color_space, i)) == 0)
{
gtk_css_parser_consume_token (parser);
return gtk_css_number_value_new_color_component (ctx->color, ctx->color_space, ctx->legacy_rgb_scale, i);
}
}
}
} }
return gtk_css_dimension_value_parse (parser, flags); return gtk_css_dimension_value_parse (parser, flags);
@@ -1768,12 +1710,6 @@ gtk_css_number_value_get (const GtkCssValue *value,
return sqrt (acc); return sqrt (acc);
} }
case TYPE_COLOR_COORD:
return gtk_css_color_value_get_coord (value->color_coord.color,
value->color_coord.color_space,
value->color_coord.legacy_rgb_scale,
value->color_coord.coord);
default: default:
g_assert_not_reached (); g_assert_not_reached ();
} }
@@ -1885,33 +1821,3 @@ _sign (double a)
else else
return 0; return 0;
} }
GtkCssValue *
gtk_css_number_value_new_color_component (GtkCssValue *color,
GtkCssColorSpace color_space,
gboolean legacy_rgb_scale,
guint coord)
{
if (gtk_css_value_is_computed (color))
{
float v;
v = gtk_css_color_value_get_coord (color, color_space, legacy_rgb_scale, coord);
return gtk_css_number_value_new (v, GTK_CSS_NUMBER);
}
else
{
GtkCssValue *result;
result = gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_NUMBER);
result->type = TYPE_COLOR_COORD;
result->color_coord.color_space = color_space;
result->color_coord.color = gtk_css_value_ref (color);
result->color_coord.coord = coord;
result->color_coord.legacy_rgb_scale = legacy_rgb_scale;
result->is_computed = FALSE;
return result;
}
}
-18
View File
@@ -24,7 +24,6 @@
#include "gtk/css/gtkcssparserprivate.h" #include "gtk/css/gtkcssparserprivate.h"
#include "gtkcsstypesprivate.h" #include "gtkcsstypesprivate.h"
#include "gtkcssvalueprivate.h" #include "gtkcssvalueprivate.h"
#include "gtkcsscolorprivate.h"
G_BEGIN_DECLS G_BEGIN_DECLS
@@ -37,14 +36,6 @@ typedef enum /*< skip >*/ {
GTK_CSS_PARSE_TIME = (1 << 5) GTK_CSS_PARSE_TIME = (1 << 5)
} GtkCssNumberParseFlags; } GtkCssNumberParseFlags;
typedef struct
{
/* Context needed when parsing numbers */
GtkCssValue *color;
GtkCssColorSpace color_space;
gboolean legacy_rgb_scale; /* r, g, b must be scaled to 255 */
} GtkCssNumberParseContext;
#define GTK_CSS_PARSE_DIMENSION (GTK_CSS_PARSE_LENGTH|GTK_CSS_PARSE_ANGLE|GTK_CSS_PARSE_TIME) #define GTK_CSS_PARSE_DIMENSION (GTK_CSS_PARSE_LENGTH|GTK_CSS_PARSE_ANGLE|GTK_CSS_PARSE_TIME)
GtkCssValue * gtk_css_dimension_value_new (double value, GtkCssValue * gtk_css_dimension_value_new (double value,
@@ -56,10 +47,6 @@ gboolean gtk_css_number_value_can_parse (GtkCssParser *par
GtkCssValue * gtk_css_number_value_parse (GtkCssParser *parser, GtkCssValue * gtk_css_number_value_parse (GtkCssParser *parser,
GtkCssNumberParseFlags flags); GtkCssNumberParseFlags flags);
GtkCssValue * gtk_css_number_value_parse_with_context (GtkCssParser *parser,
GtkCssNumberParseFlags flags,
GtkCssNumberParseContext *context);
GtkCssDimension gtk_css_number_value_get_dimension (const GtkCssValue *value) G_GNUC_PURE; GtkCssDimension gtk_css_number_value_get_dimension (const GtkCssValue *value) G_GNUC_PURE;
gboolean gtk_css_number_value_has_percent (const GtkCssValue *value) G_GNUC_PURE; gboolean gtk_css_number_value_has_percent (const GtkCssValue *value) G_GNUC_PURE;
GtkCssValue * gtk_css_number_value_multiply (GtkCssValue *value, GtkCssValue * gtk_css_number_value_multiply (GtkCssValue *value,
@@ -75,11 +62,6 @@ double gtk_css_number_value_get_canonical (GtkCssValue *num
gboolean gtk_css_dimension_value_is_zero (const GtkCssValue *value) G_GNUC_PURE; gboolean gtk_css_dimension_value_is_zero (const GtkCssValue *value) G_GNUC_PURE;
GtkCssValue * gtk_css_number_value_new_color_component (GtkCssValue *color,
GtkCssColorSpace color_space,
gboolean legacy_srgb,
guint coord);
enum { enum {
ROUND_NEAREST, ROUND_NEAREST,
ROUND_UP, ROUND_UP,
+2 -3
View File
@@ -240,10 +240,9 @@ parse_css_direction (GtkCssStyleProperty *property,
static GtkCssValue * static GtkCssValue *
opacity_parse (GtkCssStyleProperty *property, opacity_parse (GtkCssStyleProperty *property,
GtkCssParser *parser) GtkCssParser *parser)
{ {
return gtk_css_number_value_parse (parser, GTK_CSS_PARSE_NUMBER return gtk_css_number_value_parse (parser, GTK_CSS_PARSE_NUMBER);
| GTK_CSS_PARSE_PERCENT);
} }
static GtkCssValue * static GtkCssValue *
+1 -22
View File
@@ -573,26 +573,5 @@ gtk_css_hash_id (GQuark id)
return id * 11; 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 G_END_DECLS
+1 -1
View File
@@ -47,7 +47,7 @@
* and is destroyed when the drag ends. * and is destroyed when the drag ends.
* *
* To set up a drag icon and associate it with an ongoing drag operation, * 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] * 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. * to set whatever widget should be used for the drag icon.
* *
+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); link_color = gtk_css_color_value_get_rgba (style->core->color);
attr = pango_attr_foreground_new (link_color->red * 65535,
attr = pango_attr_foreground_new (CLAMP (link_color->red * 65535. + 0.5, 0, 65535), link_color->green * 65535,
CLAMP (link_color->green * 65535. + 0.5, 0, 65535), link_color->blue * 65535);
CLAMP (link_color->blue * 65535. + 0.5, 0, 65535));
attr->start_index = link->start; attr->start_index = link->start;
attr->end_index = link->end; attr->end_index = link->end;
pango_attr_list_insert (attrs, attr); 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); 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 static void
start_element_handler (GMarkupParseContext *context, start_element_handler (GMarkupParseContext *context,
const char *element_name, const char *element_name,
@@ -3545,7 +3511,6 @@ start_element_handler (GMarkupParseContext *context,
gtk_css_node_set_parent (link.cssnode, widget_node); gtk_css_node_set_parent (link.cssnode, widget_node);
if (class) if (class)
gtk_css_node_add_class (link.cssnode, g_quark_from_string (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); state = gtk_css_node_get_state (widget_node);
if (visited) 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_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_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)); 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); g_object_unref (self->select_info->selection_node);
} }
} }
@@ -6314,4 +6277,3 @@ gtk_label_accessible_text_init (GtkAccessibleTextInterface *iface)
/* }}} */ /* }}} */
/* vim:set foldmethod=marker expandtab: */ /* vim:set foldmethod=marker expandtab: */
-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; 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 static void
gtk_text_move_cursor (GtkText *self, gtk_text_move_cursor (GtkText *self,
GtkMovementStep step, 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_name (priv->selection_node, g_quark_from_static_string ("selection"));
gtk_css_node_set_parent (priv->selection_node, widget_node); 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)); 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); g_object_unref (priv->selection_node);
} }
} }

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