Compare commits

..

14 Commits

Author SHA1 Message Date
Matthias Clasen ec271b47fb wip 2024-08-07 19:18:35 -04:00
Matthias Clasen 80bee35ab7 download op: wip 2024-08-07 18:13:34 -04:00
Matthias Clasen 4be4e53bdd memory convert: debug spew 2024-08-07 18:13:34 -04:00
Matthias Clasen d10c55c748 node processor: spew 2024-08-07 18:13:34 -04:00
Matthias Clasen 60d9d79bcc renderer: debug spew 2024-08-07 18:13:33 -04:00
Matthias Clasen d0fbe1db5a download op: debug spew 2024-08-07 18:13:33 -04:00
Matthias Clasen 44aca0cecf Add a test for render_texture 2024-08-07 18:13:33 -04:00
Matthias Clasen f8afc60c9b Some more color tests 2024-08-07 18:11:35 -04:00
Matthias Clasen 2f26bd9842 colorstate: Change the rendering color state api
Pass an extra boolean that tells whether the target image is GL_SRGB,
in which case, the rendering color state must be srgb-linear.

Update all callers to pass FALSE, except for the one call in
the node processor, where we want to take GL_LINEAR into account.
2024-08-07 18:11:35 -04:00
Matthias Clasen 449fc749e6 Add a compare test for handling of pq colors
The node file here has a pq color that is far out of range for
sRGB, and will produce widely different result if we don't clamp
things properly.
2024-08-07 13:34:45 -04:00
Matthias Clasen 56ea1754bf gsk: Pass color state to download op
This lets us create a texture in the desired color state.
2024-08-07 13:34:45 -04:00
Matthias Clasen cd18bb9fd1 renderer: Make hdr textures if necessary
Take the preferred color state of the content into account
when deciding what color state to use for the texture we
generate.
2024-08-07 13:34:45 -04:00
Matthias Clasen 9f3927e7a7 gsk: Adapt to new rendering colorstate api
Since we now handle the GL_SRGB case when the  node processor calls
get_rendering_color_state, we can just pass SRGB as input here.
2024-08-07 13:34:45 -04:00
Matthias Clasen df18749d6d colorstate: Change the rendering color state api
Pass an extra boolean that tells whether the target image is GL_SRGB,
in which case, the rendering color state must be srgb-linear.

Update all callers to pass FALSE, except for the one call in
the node processor, where we want to take GL_LINEAR into account.
2024-08-07 13:34:45 -04:00
145 changed files with 3171 additions and 5432 deletions
+1 -1
View File
@@ -26,7 +26,7 @@ variables:
BACKEND_FLAGS: "-Dx11-backend=true -Dwayland-backend=true -Dbroadway-backend=true"
FEATURE_FLAGS: "-Dvulkan=enabled -Dcloudproviders=enabled -Dbuild-testsuite=true -Dintrospection=enabled"
MESON_TEST_TIMEOUT_MULTIPLIER: 3
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v52"
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v49"
workflow:
rules:
+1 -4
View File
@@ -1,4 +1,4 @@
FROM fedora:40
FROM fedora:39
RUN dnf -y install \
adwaita-icon-theme \
@@ -99,11 +99,8 @@ RUN dnf -y install \
which \
wireplumber \
xorg-x11-server-Xvfb \
&& dnf -y update \
&& dnf clean all
RUN rm /usr/share/vulkan/icd.d/powervr_mesa_icd.x86_64.json
# Enable sudo for wheel users
RUN sed -i -e 's/# %wheel/%wheel/' -e '0,/%wheel/{s/%wheel/# %wheel/}' /etc/sudoers
+1
View File
@@ -11,6 +11,7 @@ multiplier=${MESON_TEST_TIMEOUT_MULTIPLIER:-1}
# Ignore memory leaks lower in dependencies
export LSAN_OPTIONS=suppressions=$srcdir/lsan.supp:print_suppressions=0:detect_leaks=0:allocator_may_return_null=1
export G_SLICE=always-malloc
case "${setup}" in
x11*)
+1 -39
View File
@@ -1,44 +1,6 @@
Overview of Changes in 4.15.6, xx-xx-xxxx
Overview of Changes in 4.15.5, xx-xx-xxxx
=========================================
Overview of Changes in 4.15.5, 11-08-2024
=========================================
* GtkTextView:
- ADd GtkTextBufferCommitNotify
* CSS:
- Propagate color state information to GSK for many features:
colors, borders, shadows, text
* Gdk:
- Fix an fd leak in the Vulkan code
- Fix a leak of EGLSurfaces and DMA buffers
- Set the opaque region of surfaces automatically based on their content
* Gsk:
- Fix Emoji rendering in Vulkan
- Rework color handling to take color states into account
- Implement more powerful occlusion culling
- Minimize our use of renderpasses
* Macos:
- Fix window transparency
* Debugging:
- The inspector shows details about color states
* Deprecations:
- gdk_draw_context_begin/end_frame
- gdk_surface_set_opaque_region
* Build:
- Require gstreamer 1.24
* Translation updates
Romanian
Overview of Changes in 4.15.4, 30-07-2024
=========================================
+1 -1
View File
@@ -38,7 +38,7 @@ if get_option('documentation')
gdk_gir[0],
],
depends: gdk_gir[0],
suite: ['docs', 'failing'],
suite: ['docs'],
)
if x11_enabled
+1 -1
View File
@@ -260,4 +260,4 @@ name = "StyleProvider"
hidden = true
[check]
ignore_deprecated = true
skip_deprecated = true
+1 -1
View File
@@ -74,7 +74,7 @@ if get_option('documentation')
gtk_gir[0],
],
depends: gtk_gir[0],
suite: ['docs', 'failing'],
suite: ['docs'],
)
endif
+15 -61
View File
@@ -6,7 +6,7 @@ The format is a text format that follows the [CSS syntax rules](https://drafts.c
The grammar of a node text representation using [the CSS value definition syntax](https://drafts.csswg.org/css-values-3/#value-defs) looks like this:
document: <@-rule>*<node>
document: <@-rule>*<node>*
@-rule: @cicp "name" { <property>* }
node: container [ "name" ] { <document> } | <node-type> [ "name" ] { <property>* } | "name"
property: <property-name>: <node> | <value> ;
@@ -49,16 +49,12 @@ The following properties can be set for custom color states:
| primaries | `<integer>` | 2 | always |
| transfer | `<integer>` | 2 | always |
| matrix | `<integer>` | 2 | always |
| range | `<range>` | full | non-default |
| range | `narrow | full` | full | non-default |
Note that the primaries, transfer and matrix properties always need
to be specified, since GTK does not allow creating color state objects
with these being set to 2 (== unspecified).
Range can have the following values:
range: narrow | full
# Colors
Colors can be specified with a variation of the modern CSS color syntax:
@@ -70,16 +66,6 @@ The traditional syntax for sRGB colors still works as well:
rgba(<number>, <number>, <number>, <number)
rgb(<number, <number>, <number>)
# Rectangles
Rectangles can be specified just as four integers for x, y, width and height:
rect: <number> <number> <number> <number>
Rounded rectangles use a CSS-like syntax:
rounded-rect: <rect> [ "/" <number>{1,4} [ "/" <number>{1,4} ] ]
# Nodes
### container
@@ -96,13 +82,6 @@ The **container** node is a special node that allows specifying a list of child
Creates a node like `gsk_blend_node_new()` with the given properties.
Possible values for the mode property are:
blend-mode: normal | multiply | screen | overlay | darken |
lighten | color-dodge | color-burn | hard-light |
soft-light | difference | exclusion | color |
hue | saturation | luminosity
### blur
| property | syntax | default | printed |
@@ -222,10 +201,6 @@ Creates a node like `gsk_fill_node_new()` with the given properties.
The default child node is the default color node, but created with the
bounds of the path.
Possible values for the fill-rule property are:
fill-rule: winding | even-odd
### glshader
| property | syntax | default | printed |
@@ -277,10 +252,6 @@ Creates a node like `gsk_linear_gradient_node_new()` with the given properties.
Creates a node like `gsk_mask_node_new()` with the given properties.
Possible values for the mode property are:
mask-mode: alpha | inverted-alpha | luminance | inverted-luminance
### opacity
| property | syntax | default | printed |
@@ -319,11 +290,11 @@ Creates a node like `gsk_radial_gradient_node_new()` with the given properties.
### repeat
| property | syntax | default | printed |
| ------------ | ---------- | ---------------------- | ----------- |
| bounds | `<rect>` | *bounds of child node* | non-default |
| child | `<node>` | color { } | always |
| child-bounds | `<rect>` | *bounds of child node* | non-default |
| property | syntax | default | printed |
| ----------- | ---------------- | ---------------------- | ----------- |
| bounds | `<rect>` | *bounds of child node* | non-default |
| child | `<node>` | color { } | always |
| child-bounds| `<rect>` | *bounds of child node* | non-default |
Creates a node like `gsk_repeat_node_new()` with the given properties.
@@ -390,14 +361,6 @@ Creates a node like `gsk_stroke_node_new()` with the given properties.
The default child node is the default color node, but created with the
stroke bounds of the path.
Possible values for the line-cap property are:
line-cap: butt | round | square
Possible values for the line-join property are:
line-join: miter | round | bevel
### text
| property | syntax | default | printed |
@@ -406,9 +369,9 @@ Possible values for the line-join property are:
| font | `<string>` `<url>`? | "Cantarell 15px" | always |
| glyphs | `<glyphs>` | "Hello" | always |
| offset | `<point>` | 0 0 | non-default |
| hint-style | `<hint-style>` | slight | non-default |
| hint-style | `<hint style>` | slight | non-default |
| antialias | `<antialias>` | gray | non-default |
| hint-metrics | `<hint-metrics>` | off | non-default |
| hint-metrics | `<hint metrics>` | off | non-default |
Creates a node like `gsk_text_node_new()` with the given properties.
@@ -423,17 +386,9 @@ be specified as well, like this: 40 10 0 0 color.
If the given font does not exist or the given glyphs are invalid for the given
font, an error node will be returned.
Possible values for the hint-style property are:
hint-style: none | slight | full
Possible value for the antialias property are:
antialias: none | gray
Possible value for hint-metrics are:
hint-metrics: on | off
Possible values for hint-style are none, slight or full.
Possible value for antialias are none or gray.
Possible value for hint-metrics are on or off.
### texture
@@ -459,15 +414,14 @@ representation for this texture is `url("data:image/png;base64,iVBORw0KGgoAAAANS
| -------- | ---------------- | ---------------------- | ----------- |
| bounds | `<rect>` | 50 | always |
| texture | `<url>` | *see below* | always |
| filter | `filter` | linear | non-default |
| filter | `filter` | *see below* | non-default |
Creates a node like `gsk_texture_scale_node_new()` with the given properties.
The default texture is a 10x10 checkerboard, just like for texture.
Possible values for the filter property are:
filter: linear | nearest | trilinear
The possible filter values are `linear`, `nearest` and `trilinear`, with
`linear` being the default.
### transform
+6 -19
View File
@@ -262,12 +262,6 @@ A number of options affect behavior instead of logging:
`high-depth`
: Use high bit depth rendering if possible
`linear`
: Enable linear rendering
`hdr`
: Force HDR rendering
`no-vsync`
: Repaint instantly (uses 100% CPU with animations)
@@ -286,6 +280,9 @@ are only available when GTK has been configured with `-Ddebug=true`.
`renderer`
: General renderer information
`opengl`
: OpenGL renderer information
`vulkan`
: Check Vulkan errors
@@ -318,9 +315,6 @@ A number of options affect behavior instead of logging:
`cairo`
: Overlay error pattern over cairo drawing (finds fallbacks)
`occlusion`
: Overlay highlight over areas optimized via occlusion culling
The special value `all` can be used to turn on all debug options. The special
value `help` can be used to obtain a list of all supported debug options.
@@ -467,12 +461,12 @@ using and the GDK backend supports them:
This variable can be set to a list of values, which cause GSK to
disable certain optimizations of the "ngl" and "vulkan" renderer.
`uber`
: Don't use the uber shader
`clear`
: Use shaders instead of vkCmdClearAttachment()/glClear()
`merge`
: USe one vkCmdDraw()/glDrawArrays() per operation
`blit`
: Use shaders instead of vkCmdBlit()/glBlitFramebuffer()
@@ -482,13 +476,6 @@ disable certain optimizations of the "ngl" and "vulkan" renderer.
`mipmap`
: Avoid creating mipmaps
`to-image`
: Don't fast-path creation of images for nodes
`occlusion`
: Disable occlusion culling via opacity tracking
The special value `all` can be used to turn on all values. The special
value `help` can be used to obtain a list of all supported values.
-1
View File
@@ -9,7 +9,6 @@ documentation in the form of man pages.
- [gtk4-demo-application](gtk4-demo-application.html)
- [gtk4-encode-symbolic-svg](gtk4-encode-symbolic-svg.html)
- [gtk4-icon-browser](gtk4-icon-browser.html)
- [gtk4-image-tool](gtk4-image-tool.html)
- [gtk4-launch](gtk4-launch.html)
- [gtk4-node-editor](gtk4-node-editor.html)
- [gtk4-path-tool](gtk4-path-tool.html)
-2
View File
@@ -82,10 +82,8 @@ gdk_cairo_context_cairo_create (GdkCairoContext *self)
draw_context = GDK_DRAW_CONTEXT (self);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
if (!gdk_draw_context_is_in_frame (draw_context))
return NULL;
G_GNUC_END_IGNORE_DEPRECATIONS
cr = GDK_CAIRO_CONTEXT_GET_CLASS (self)->cairo_create (self);
+1 -1
View File
@@ -58,7 +58,7 @@ void gdk_cicp_params_set_matrix_coefficients (GdkCicpParams *self,
/**
* GdkCicpRange:
* @GDK_CICP_RANGE_NARROW: The values use the range of 16-235 (for Y) and 16-240 for u and v.
* @GDK_CICP_RANGE_FULL: The values use the full range.
* @GDK_CICO_RANGE_FULL: The values use the full range.
*
* The values of this enumeration describe whether image data uses
* the full range of 8-bit values.
-42
View File
@@ -298,46 +298,4 @@ gdk_color_to_string (const GdkColor *self)
return g_string_free (string, FALSE);
}
gboolean
gdk_color_in_gamut (const GdkColor *self,
GdkColorState *color_state)
{
float values[4];
const float *range;
gdk_color_to_float (self, color_state, values);
range = gdk_color_state_get_range (color_state);
return range[0] <= values[0] && values[0] <= range[1] &&
range[2] <= values[1] && values[1] <= range[3] &&
range[4] <= values[2] && values[2] <= range[5] &&
range[6] <= values[3] && values[3] <= range[7];
}
void
gdk_color_clamp_to_gamut (GdkColor *self,
GdkColorState *color_state)
{
GdkColor tmp;
const float *range;
gdk_color_to_float (self, color_state, tmp.values);
range = gdk_color_state_get_range (color_state);
if (range[0] > tmp.values[0] || tmp.values[0] > range[1] ||
range[2] > tmp.values[1] || tmp.values[1] > range[3] ||
range[4] > tmp.values[2] || tmp.values[2] > range[5] ||
range[6] > tmp.values[3] || tmp.values[3] > range[7])
{
tmp.color_state = color_state;
tmp.values[0] = CLAMP (tmp.values[0], range[0], range[1]);
tmp.values[1] = CLAMP (tmp.values[1], range[2], range[3]);
tmp.values[2] = CLAMP (tmp.values[2], range[4], range[5]);
tmp.values[3] = CLAMP (tmp.values[3], range[6], range[7]);
gdk_color_to_float (&tmp, self->color_state, self->values);
}
}
+21 -82
View File
@@ -20,17 +20,11 @@
* and tests, and must not include other headers.
*/
static inline int
sign (float v)
{
return v < 0 ? -1 : 1;
}
static inline float
srgb_oetf (float v)
{
if (fabsf (v) > 0.0031308f)
return 1.055f * sign (v) * powf (fabsf (v), 1.f / 2.4f) - 0.055f;
if (v > 0.0031308f)
return 1.055f * powf (v, 1.f / 2.4f) - 0.055f;
else
return 12.92f * v;
}
@@ -38,8 +32,8 @@ srgb_oetf (float v)
static inline float
srgb_eotf (float v)
{
if (fabsf (v) >= 0.04045f)
return sign (v) * powf (((fabsf (v) + 0.055f) / (1.f + 0.055f)), 2.4f);
if (v >= 0.04045f)
return powf (((v + 0.055f) / (1.f + 0.055f)), 2.4f);
else
return v / 12.92f;
}
@@ -47,25 +41,25 @@ srgb_eotf (float v)
static inline float
gamma22_oetf (float v)
{
return sign (v) * powf (fabsf (v), 1.f / 2.2f);
return powf (v, 1.f / 2.2f);
}
static inline float
gamma22_eotf (float v)
{
return sign (v) * powf (fabsf (v), 2.2f);
return powf (v, 2.2f);
}
static inline float
gamma28_oetf (float v)
{
return sign (v) * powf (fabsf (v), 1.f / 2.8f);
return powf (v, 1.f / 2.8f);
}
static inline float
gamma28_eotf (float v)
{
return sign (v) * powf (fabsf (v), 2.8f);
return powf (v, 2.8f);
}
static inline float
@@ -77,10 +71,9 @@ pq_eotf (float v)
float c2 = 2413.0 / (1 << 7);
float c3 = 2392.0 / (1 << 7);
float x = powf (fabsf (v), minv);
x = powf (MAX ((x - c1), 0) / (c2 - (c3 * x)), ninv);
float x = powf (MAX ((powf (v, minv) - c1), 0) / (c2 - (c3 * (powf (v, minv)))), ninv);
return sign (v) * x * 10000 / 203.0;
return x * 10000 / 203.0;
}
static inline float
@@ -93,8 +86,7 @@ pq_oetf (float v)
float c2 = 2413.0 / (1 << 7);
float c3 = 2392.0 / (1 << 7);
x = powf (fabsf (x), n);
return sign (v) * powf (((c1 + (c2 * x)) / (1 + (c3 * x))), m);
return powf (((c1 + (c2 * powf (x, n))) / (1 + (c3 * powf (x, n)))), m);
}
static inline float
@@ -103,10 +95,10 @@ bt709_eotf (float v)
const float a = 1.099;
const float d = 0.0812;
if (fabsf (v) < d)
if (v < d)
return v / 4.5f;
else
return sign (v) * powf ((fabsf (v) + (a - 1)) / a, 1 / 0.45f);
return powf ((v + (a - 1)) / a, 1 / 0.45f);
}
static inline float
@@ -115,10 +107,10 @@ bt709_oetf (float v)
const float a = 1.099;
const float b = 0.018;
if (fabsf (v) < b)
if (v < b)
return v * 4.5f;
else
return a * sign (v) * powf (fabsf (v), 0.45f) - (a - 1);
return a * powf (v, 0.45f) - (a - 1);
}
static inline float
@@ -158,15 +150,15 @@ static const float identity[9] = {
};
static const float srgb_to_xyz[9] = {
0.412391, 0.357584, 0.180481,
0.212639, 0.715169, 0.072192,
0.019331, 0.119195, 0.950532
0.4124564, 0.3575761, 0.1804375,
0.2126729, 0.7151522, 0.0721750,
0.0193339, 0.1191920, 0.9503041,
};
static const float xyz_to_srgb[9] = {
3.240970, -1.537383, -0.498611,
-0.969244, 1.875968, 0.041555,
0.055630, -0.203977, 1.056972
3.2404542, -1.5371385, -0.4985314,
-0.9692660, 1.8760108, 0.0415560,
0.0556434, -0.2040259, 1.0572252,
};
static const float rec2020_to_xyz[9] = {
@@ -230,56 +222,3 @@ static const float srgb_to_rec2020[9] = {
0.069108, 0.919519, 0.011360,
0.016394, 0.088011, 0.895380,
};
/* primaries */
static const float srgb_primaries[8] = {
0.640, 0.330,
0.300, 0.600,
0.150, 0.060,
0.3127, 0.3290
};
static const float pal_primaries[8] = {
0.64, 0.33,
0.29, 0.60,
0.15, 0.06,
0.3127, 0.3290
};
static const float ntsc_primaries[8] = {
0.630, 0.340,
0.310, 0.595,
0.155, 0.070,
0.3127, 0.3290
};
static const float rec2020_primaries[8] = {
0.708, 0.292,
0.170, 0.797,
0.131, 0.046,
0.3127, 0.3290
};
static const float p3_primaries[8] = {
0.680, 0.320,
0.265, 0.690,
0.150, 0.060,
0.3127, 0.3290
};
/* ranges */
static const float default_range[8] = {
0, 1,
0, 1,
0, 1,
0, 1
};
static const float rec2100_linear_range[8] = {
0, 49.2610855,
0, 49.2610855,
0, 49.2610855,
0, 1,
};
+1 -4
View File
@@ -116,10 +116,7 @@ _gdk_color_to_float (const GdkColor *self,
{
if (gdk_color_state_equal (self->color_state, color_state))
{
values[0] = self->values[0];
values[1] = self->values[1];
values[2] = self->values[2];
values[3] = self->values[3];
memcpy (values, self->values, sizeof (float) * 4);
return;
}
-6
View File
@@ -102,12 +102,6 @@ void gdk_color_print (const GdkColor *self,
char * gdk_color_to_string (const GdkColor *self);
gboolean gdk_color_in_gamut (const GdkColor *self,
GdkColorState *color_state);
void gdk_color_clamp_to_gamut (GdkColor *self,
GdkColorState *color_state);
#include "gdkcolorimpl.h"
G_END_DECLS
+4 -368
View File
@@ -24,8 +24,6 @@
#include "gdkcolordefs.h"
#include <graphene.h>
#include <glib/gi18n-lib.h>
/**
@@ -40,9 +38,9 @@
* Crucially, GTK knows how to convert colors from one color
* state to another.
*
* `GdkColorState` objects are immutable and therefore threadsafe.
* `GdkColorState objects are immutable and therefore threadsafe.
*
* Since: 4.16
* Since 4.16
*/
G_DEFINE_BOXED_TYPE (GdkColorState, gdk_color_state,
@@ -333,22 +331,6 @@ gdk_default_color_state_get_cicp (GdkColorState *color_state)
return &self->cicp;
}
static const float *
gdk_default_color_state_get_primaries (GdkColorState *color_state)
{
GdkDefaultColorState *self = (GdkDefaultColorState *) color_state;
return self->primaries;
}
static const float *
gdk_default_color_state_get_range (GdkColorState *color_state)
{
GdkDefaultColorState *self = (GdkDefaultColorState *) color_state;
return self->range;
}
/* }}} */
static const
@@ -360,8 +342,6 @@ GdkColorStateClass GDK_DEFAULT_COLOR_STATE_CLASS = {
.get_convert_to = gdk_default_color_state_get_convert_to,
.get_convert_from = gdk_default_color_state_get_convert_from,
.get_cicp = gdk_default_color_state_get_cicp,
.get_primaries = gdk_default_color_state_get_primaries,
.get_range = gdk_default_color_state_get_range,
};
GdkDefaultColorState gdk_default_color_states[] = {
@@ -379,8 +359,6 @@ GdkDefaultColorState gdk_default_color_states[] = {
[GDK_COLOR_STATE_ID_REC2100_PQ] = gdk_default_srgb_to_rec2100_pq,
[GDK_COLOR_STATE_ID_REC2100_LINEAR] = gdk_default_srgb_to_rec2100_linear,
},
.primaries = srgb_primaries,
.range = default_range,
.cicp = { 1, 13, 0, 1 },
},
[GDK_COLOR_STATE_ID_SRGB_LINEAR] = {
@@ -397,8 +375,6 @@ GdkDefaultColorState gdk_default_color_states[] = {
[GDK_COLOR_STATE_ID_REC2100_PQ] = gdk_default_srgb_linear_to_rec2100_pq,
[GDK_COLOR_STATE_ID_REC2100_LINEAR] = gdk_default_srgb_linear_to_rec2100_linear,
},
.primaries = srgb_primaries,
.range = default_range,
.cicp = { 1, 8, 0, 1 },
},
[GDK_COLOR_STATE_ID_REC2100_PQ] = {
@@ -415,8 +391,6 @@ GdkDefaultColorState gdk_default_color_states[] = {
[GDK_COLOR_STATE_ID_SRGB_LINEAR] = gdk_default_rec2100_pq_to_srgb_linear,
[GDK_COLOR_STATE_ID_REC2100_LINEAR] = gdk_default_rec2100_pq_to_rec2100_linear,
},
.primaries = rec2020_primaries,
.range = default_range,
.cicp = { 9, 16, 0, 1 },
},
[GDK_COLOR_STATE_ID_REC2100_LINEAR] = {
@@ -433,13 +407,11 @@ GdkDefaultColorState gdk_default_color_states[] = {
[GDK_COLOR_STATE_ID_SRGB_LINEAR] = gdk_default_rec2100_linear_to_srgb_linear,
[GDK_COLOR_STATE_ID_REC2100_PQ] = gdk_default_rec2100_linear_to_rec2100_pq,
},
.primaries = rec2020_primaries,
.range = rec2100_linear_range,
.cicp = { 9, 8, 0, 1 },
},
};
/* }}} */
/* }}} */
/* {{{ Cicp implementation */
typedef struct _GdkCicpColorState GdkCicpColorState;
@@ -460,9 +432,6 @@ struct _GdkCicpColorState
float *from_rec2020;
GdkCicp cicp;
const float *primaries;
const float *range;
};
/* {{{ Conversion functions */
@@ -480,6 +449,7 @@ TRANSFORM(gdk_cicp_from_rec2100_linear, NONE, cicp->from_rec2020, cicp->o
#undef cicp
/* }}} */
/* }}} */
/* {{{ Vfuncs */
@@ -585,22 +555,6 @@ gdk_cicp_color_state_get_cicp (GdkColorState *color_state)
return &self->cicp;
}
static const float *
gdk_cicp_color_state_get_primaries (GdkColorState *color_state)
{
GdkCicpColorState *self = (GdkCicpColorState *) color_state;
return self->primaries;
}
static const float *
gdk_cicp_color_state_get_range (GdkColorState *color_state)
{
GdkCicpColorState *self = (GdkCicpColorState *) color_state;
return self->range;
}
/* }}} */
static const
@@ -612,8 +566,6 @@ GdkColorStateClass GDK_CICP_COLOR_STATE_CLASS = {
.get_convert_to = gdk_cicp_color_state_get_convert_to,
.get_convert_from = gdk_cicp_color_state_get_convert_from,
.get_cicp = gdk_cicp_color_state_get_cicp,
.get_primaries = gdk_cicp_color_state_get_primaries,
.get_range = gdk_cicp_color_state_get_range,
};
static inline float *
@@ -640,7 +592,6 @@ gdk_color_state_new_for_cicp (const GdkCicp *cicp,
GdkTransferFunc oetf;
gconstpointer to_xyz;
gconstpointer from_xyz;
const float *primaries;
if (cicp->range == GDK_CICP_RANGE_NARROW || cicp->matrix_coefficients != 0)
{
@@ -710,27 +661,22 @@ gdk_color_state_new_for_cicp (const GdkCicp *cicp,
switch (cicp->color_primaries)
{
case 1:
primaries = srgb_primaries;
to_xyz = srgb_to_xyz;
from_xyz = xyz_to_srgb;
break;
case 5:
primaries = pal_primaries;
to_xyz = pal_to_xyz;
from_xyz = xyz_to_pal;
break;
case 6:
primaries = ntsc_primaries;
to_xyz = ntsc_to_xyz;
from_xyz = xyz_to_ntsc;
break;
case 9:
primaries = rec2020_primaries;
to_xyz = rec2020_to_xyz;
from_xyz = xyz_to_rec2020;
break;
case 12:
primaries = p3_primaries;
to_xyz = p3_to_xyz;
from_xyz = xyz_to_p3;
break;
@@ -757,9 +703,6 @@ gdk_color_state_new_for_cicp (const GdkCicp *cicp,
self->eotf = eotf;
self->oetf = oetf;
self->primaries = primaries;
self->range = default_range;
self->to_srgb = multiply (g_new (float, 9), xyz_to_srgb, to_xyz);
self->to_rec2020 = multiply (g_new (float, 9), xyz_to_rec2020, to_xyz);
self->from_srgb = multiply (g_new (float, 9), from_xyz, srgb_to_xyz);
@@ -784,313 +727,6 @@ gdk_color_state_new_for_cicp (const GdkCicp *cicp,
return (GdkColorState *) self;
}
/* }}} */
/* {{{ Primaries implementation */
typedef struct _GdkPrimariesColorState GdkPrimariesColorState;
struct _GdkPrimariesColorState
{
GdkColorState parent;
char *name;
GdkTransferFunc eotf;
GdkTransferFunc oetf;
float primaries[8];
float to_srgb[9];
float to_rec2020[9];
float from_srgb[9];
float from_rec2020[9];
GdkCicp cicp;
};
/* {{{ Conversion functions */
#define prim ((GdkPrimariesColorState *)self)
TRANSFORM(gdk_primaries_to_srgb, prim->eotf, prim->to_srgb, srgb_oetf)
TRANSFORM(gdk_primaries_to_srgb_linear, prim->eotf, prim->to_srgb, NONE)
TRANSFORM(gdk_primaries_to_rec2100_pq, prim->eotf, prim->to_rec2020, pq_oetf)
TRANSFORM(gdk_primaries_to_rec2100_linear, prim->eotf, prim->to_rec2020, NONE)
TRANSFORM(gdk_primaries_from_srgb, srgb_eotf, prim->from_srgb, prim->oetf)
TRANSFORM(gdk_primaries_from_srgb_linear, NONE, prim->from_srgb, prim->oetf)
TRANSFORM(gdk_primaries_from_rec2100_pq, pq_eotf, prim->from_rec2020, prim->oetf)
TRANSFORM(gdk_primaries_from_rec2100_linear, NONE, prim->from_rec2020, prim->oetf)
#undef prim
/* }}} */
/* {{{ Vfuncs */
static void
gdk_primaries_color_state_free (GdkColorState *cs)
{
GdkPrimariesColorState *self = (GdkPrimariesColorState *) cs;
g_free (self->name);
g_free (self);
}
static gboolean
gdk_primaries_color_state_equal (GdkColorState *self,
GdkColorState *other)
{
GdkPrimariesColorState *cs1 = (GdkPrimariesColorState *) self;
GdkPrimariesColorState *cs2 = (GdkPrimariesColorState *) other;
return memcmp (cs1->primaries, cs2->primaries, sizeof (float) * 8) == 0 &&
cs1->eotf == cs2->eotf;
}
static const char *
gdk_primaries_color_state_get_name (GdkColorState *self)
{
GdkPrimariesColorState *cs = (GdkPrimariesColorState *) self;
return cs->name;
}
static GdkColorState *
gdk_primaries_color_state_get_no_srgb_tf (GdkColorState *self)
{
return NULL;
}
static GdkFloatColorConvert
gdk_primaries_color_state_get_convert_to (GdkColorState *self,
GdkColorState *target)
{
if (!GDK_IS_DEFAULT_COLOR_STATE (target))
return NULL;
switch (GDK_DEFAULT_COLOR_STATE_ID (target))
{
case GDK_COLOR_STATE_ID_SRGB:
return gdk_primaries_to_srgb;
case GDK_COLOR_STATE_ID_SRGB_LINEAR:
return gdk_primaries_to_srgb_linear;
case GDK_COLOR_STATE_ID_REC2100_PQ:
return gdk_primaries_to_rec2100_pq;
case GDK_COLOR_STATE_ID_REC2100_LINEAR:
return gdk_primaries_to_rec2100_linear;
case GDK_COLOR_STATE_N_IDS:
default:
g_assert_not_reached ();
}
return NULL;
}
static GdkFloatColorConvert
gdk_primaries_color_state_get_convert_from (GdkColorState *self,
GdkColorState *source)
{
if (!GDK_IS_DEFAULT_COLOR_STATE (source))
return NULL;
switch (GDK_DEFAULT_COLOR_STATE_ID (source))
{
case GDK_COLOR_STATE_ID_SRGB:
return gdk_primaries_from_srgb;
case GDK_COLOR_STATE_ID_SRGB_LINEAR:
return gdk_primaries_from_srgb_linear;
case GDK_COLOR_STATE_ID_REC2100_PQ:
return gdk_primaries_from_rec2100_pq;
case GDK_COLOR_STATE_ID_REC2100_LINEAR:
return gdk_primaries_from_rec2100_linear;
case GDK_COLOR_STATE_N_IDS:
default:
g_assert_not_reached ();
}
return NULL;
}
static const GdkCicp *
gdk_primaries_color_state_get_cicp (GdkColorState *color_state)
{
GdkPrimariesColorState *self = (GdkPrimariesColorState *) color_state;
return &self->cicp;
}
static const float *
gdk_primaries_color_state_get_primaries (GdkColorState *color_state)
{
GdkPrimariesColorState *self = (GdkPrimariesColorState *) color_state;
return self->primaries;
}
/* }}} */
static const
GdkColorStateClass GDK_PRIMARIES_COLOR_STATE_CLASS = {
.free = gdk_primaries_color_state_free,
.equal = gdk_primaries_color_state_equal,
.get_name = gdk_primaries_color_state_get_name,
.get_no_srgb_tf = gdk_primaries_color_state_get_no_srgb_tf,
.get_convert_to = gdk_primaries_color_state_get_convert_to,
.get_convert_from = gdk_primaries_color_state_get_convert_from,
.get_cicp = gdk_primaries_color_state_get_cicp,
.get_primaries = gdk_primaries_color_state_get_primaries,
};
static void
compute_to_xyz_from_primaries (float to_xyz[9],
const float primaries[8])
{
float rx, ry, gx, gy, bx, by, wx, wy;
float rY, bY, gY;
rx = primaries[0]; ry = primaries[1];
gx = primaries[2]; gy = primaries[3];
bx = primaries[4]; by = primaries[5];
wx = primaries[6]; wy = primaries[7];
bY = (((1 - wx)/wy - (1 - rx)/ry)*(gx/gy - rx/ry) - (wx/wy - rx/ry)*((1 - gx)/gy - (1 - rx)/ry)) /
(((1 - bx)/by - (1 - rx)/ry)*(gx/gy - rx/ry) - (bx/by - rx/ry)*((1 - gx)/gy - (1 - rx)/ry));
gY = (wx/wy - rx/ry - bY*(bx/by - rx/ry)) / (gx/gy - rx/ry);
rY = 1 - gY - bY;
to_xyz[0] = rY/ry * rx; to_xyz[1] = gY/gy * gx; to_xyz[2] = bY/by * bx;
to_xyz[3] = rY; to_xyz[4] = gY; to_xyz[5] = bY;
to_xyz[6] = rY/ry * (1-rx-ry); to_xyz[7] = gY/gy * (1-gx-gy); to_xyz[8] = bY/by * (1-bx-by);
}
static void
invert (float res[9],
const float a[9])
{
graphene_matrix_t m, m2;
float v[16];
graphene_matrix_init_from_float (&m,
(const float *)&(float[]) {
a[0], a[1], a[2], 0,
a[3], a[4], a[5], 0,
a[6], a[7], a[8], 0,
0, 0, 0, 1
});
graphene_matrix_inverse (&m, &m2);
graphene_matrix_to_float (&m2, v);
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++)
res[3 * i + j] = v[4 * i + j];
}
GdkColorState *
gdk_color_state_new_for_primaries (const float primaries[8],
guint transfer_function,
GError **error)
{
GdkPrimariesColorState *self;
float to_xyz[9];
float from_xyz[9];
GdkTransferFunc eotf;
GdkTransferFunc oetf;
if (memcmp (primaries, srgb_primaries, sizeof (float) * 8) == 0)
return gdk_color_state_new_for_cicp (&(GdkCicp) { 1, transfer_function, 0, GDK_CICP_RANGE_FULL },
error);
else if (memcmp (primaries, pal_primaries, sizeof (float) * 8) == 0)
return gdk_color_state_new_for_cicp (&(GdkCicp) { 5, transfer_function, 0, GDK_CICP_RANGE_FULL },
error);
else if (memcmp (primaries, ntsc_primaries, sizeof (float) * 8) == 0)
return gdk_color_state_new_for_cicp (&(GdkCicp) { 6, transfer_function, 0, GDK_CICP_RANGE_FULL },
error);
else if (memcmp (primaries, rec2020_primaries, sizeof (float) * 8) == 0)
return gdk_color_state_new_for_cicp (&(GdkCicp) { 9, transfer_function, 0, GDK_CICP_RANGE_FULL },
error);
else if (memcmp (primaries, p3_primaries, sizeof (float) * 8) == 0)
return gdk_color_state_new_for_cicp (&(GdkCicp) { 12, transfer_function, 0, GDK_CICP_RANGE_FULL },
error);
compute_to_xyz_from_primaries (to_xyz, primaries);
invert (from_xyz, to_xyz);
switch (transfer_function)
{
case 1:
case 6:
case 14:
case 15:
eotf = bt709_eotf;
oetf = bt709_oetf;
break;
case 4:
eotf = gamma22_eotf;
oetf = gamma22_oetf;
break;
case 5:
eotf = gamma28_eotf;
oetf = gamma28_oetf;
break;
case 8:
eotf = NONE;
oetf = NONE;
break;
case 13:
eotf = srgb_eotf;
oetf = srgb_oetf;
break;
case 16:
eotf = pq_eotf;
oetf = pq_oetf;
break;
case 18:
eotf = hlg_eotf;
oetf = hlg_oetf;
break;
default:
g_set_error (error,
G_IO_ERROR, G_IO_ERROR_FAILED,
_("primaries: Transfer function %u not supported"),
transfer_function);
return NULL;
}
self = g_new0 (GdkPrimariesColorState, 1);
self->parent.klass = &GDK_PRIMARIES_COLOR_STATE_CLASS;
self->parent.ref_count = 1;
self->parent.rendering_color_state = GDK_COLOR_STATE_REC2100_LINEAR;
self->parent.depth = GDK_MEMORY_FLOAT16;
self->eotf = eotf;
self->oetf = oetf;
self->cicp.color_primaries = 2;
self->cicp.transfer_function = transfer_function;
self->cicp.matrix_coefficients = 0;
self->cicp.range = GDK_CICP_RANGE_FULL;
memcpy (self->primaries, primaries, sizeof (float) * 8);
multiply (self->to_srgb, xyz_to_srgb, to_xyz);
multiply (self->to_rec2020, xyz_to_rec2020, to_xyz);
multiply (self->from_srgb, from_xyz, srgb_to_xyz);
multiply (self->from_rec2020, from_xyz, rec2020_to_xyz);
self->name = g_strdup_printf ("primaries(%f,%f,%f,%f,%f,%f,%f,%f)",
primaries[0], primaries[1], primaries[2],
primaries[3], primaries[4], primaries[5],
primaries[6], primaries[7]);
return (GdkColorState *) self;
}
/* }}} */
/* {{{ Private API */
+10 -26
View File
@@ -45,8 +45,6 @@ struct _GdkColorStateClass
GdkFloatColorConvert (* get_convert_from) (GdkColorState *self,
GdkColorState *source);
const GdkCicp * (* get_cicp) (GdkColorState *self);
const float * (* get_primaries) (GdkColorState *self);
const float * (* get_range) (GdkColorState *self);
};
typedef struct _GdkDefaultColorState GdkDefaultColorState;
@@ -60,9 +58,6 @@ struct _GdkDefaultColorState
GdkFloatColorConvert convert_to[GDK_COLOR_STATE_N_IDS];
GdkCicp cicp;
const float *primaries;
const float *range;
};
extern GdkDefaultColorState gdk_default_color_states[GDK_COLOR_STATE_N_IDS];
@@ -82,13 +77,16 @@ GdkColorState * gdk_color_state_get_no_srgb_tf (GdkColorState
GdkColorState * gdk_color_state_new_for_cicp (const GdkCicp *cicp,
GError **error);
GdkColorState * gdk_color_state_new_for_primaries (const float primaries[8],
guint transfer_function,
GError **error);
static inline GdkColorState *
gdk_color_state_get_rendering_color_state (GdkColorState *self)
gdk_color_state_get_rendering_color_state (GdkColorState *self,
gboolean srgb)
{
if (srgb)
{
self = gdk_color_state_get_no_srgb_tf (self);
g_assert (self);
}
if (GDK_DEBUG_CHECK (HDR))
self = GDK_COLOR_STATE_REC2100_PQ;
@@ -176,18 +174,6 @@ gdk_color_state_get_cicp (GdkColorState *self)
return self->klass->get_cicp (self);
}
static inline const float *
gdk_color_state_get_primaries (GdkColorState *self)
{
return self->klass->get_primaries (self);
}
static inline const float *
gdk_color_state_get_range (GdkColorState *self)
{
return self->klass->get_range (self);
}
static inline void
gdk_color_state_convert_color (GdkColorState *src_cs,
const float src[4],
@@ -197,10 +183,7 @@ gdk_color_state_convert_color (GdkColorState *src_cs,
GdkFloatColorConvert convert = NULL;
GdkFloatColorConvert convert2 = NULL;
dest[0] = src[0];
dest[1] = src[1];
dest[2] = src[2];
dest[3] = src[3];
memcpy (dest, src, sizeof (float) * 4);
if (gdk_color_state_equal (src_cs, dest_cs))
return;
@@ -234,3 +217,4 @@ gdk_color_state_from_rgba (GdkColorState *self,
self,
out_color);
}
+1 -1
View File
@@ -1477,7 +1477,7 @@ gdk_display_create_gl_context (GdkDisplay *self,
if (!gdk_display_prepare_gl (self, error))
return NULL;
return gdk_gl_context_new (self, NULL, FALSE);
return gdk_gl_context_new (self, NULL);
}
/*< private >
+1 -1
View File
@@ -71,7 +71,7 @@ download_memcpy (guchar *dst_data,
bpp = gdk_memory_format_bytes_per_pixel (dst_format);
src_stride = dmabuf->planes[0].stride;
src_data = src_datas[0] + dmabuf->planes[0].offset;
g_return_if_fail (sizes[0] >= dmabuf->planes[0].offset + gdk_memory_format_min_buffer_size (dst_format, src_stride, width, height));
g_return_if_fail (sizes[0] >= dmabuf->planes[0].offset + gdk_memory_format_min_buffer_size (dst_format, dst_stride, width, height));
if (dst_stride == src_stride)
memcpy (dst_data, src_data, (height - 1) * dst_stride + width * bpp);
-4
View File
@@ -5,10 +5,6 @@
#include <drm_fourcc.h>
#endif
#ifndef DRM_FORMAT_MOD_INVALID
#define DRM_FORMAT_MOD_INVALID ((1ULL << 56) - 1)
#endif
#ifndef fourcc_code
#define fourcc_code(a, b, c, d) ((__u32)(a) | ((__u32)(b) << 8) | \
((__u32)(c) << 16) | ((__u32)(d) << 24))
+15 -47
View File
@@ -223,9 +223,6 @@ gdk_draw_context_init (GdkDrawContext *self)
*
* Returns: %TRUE if the context is between [method@Gdk.DrawContext.begin_frame]
* and [method@Gdk.DrawContext.end_frame] calls.
*
* Deprecated: 4.16: Drawing directly to the surface is no longer recommended.
* Use `GskRenderNode` and `GskRenderer`.
*/
gboolean
gdk_draw_context_is_in_frame (GdkDrawContext *context)
@@ -316,9 +313,6 @@ gdk_draw_context_get_surface (GdkDrawContext *context)
* gdk_draw_context_begin_frame() and gdk_draw_context_end_frame() via the
* use of [GskRenderer](../gsk4/class.Renderer.html)s, so application code
* does not need to call these functions explicitly.
*
* Deprecated: 4.16: Drawing directly to the surface is no longer recommended.
* Use `GskRenderNode` and `GskRenderer`.
*/
void
gdk_draw_context_begin_frame (GdkDrawContext *context,
@@ -330,12 +324,11 @@ gdk_draw_context_begin_frame (GdkDrawContext *context,
g_return_if_fail (priv->surface != NULL);
g_return_if_fail (region != NULL);
gdk_draw_context_begin_frame_full (context, GDK_MEMORY_U8, region, NULL);
gdk_draw_context_begin_frame_full (context, GDK_MEMORY_U8, region);
}
/*
* @depth: best depth to render in
* @opaque: (nullable): opaque region of the rendering
*
* If the given depth is not `GDK_MEMORY_U8`, GDK will see about providing a
* rendering target that supports a higher bit depth than 8 bits per channel.
@@ -358,10 +351,9 @@ gdk_draw_context_begin_frame (GdkDrawContext *context,
* to choose.
*/
void
gdk_draw_context_begin_frame_full (GdkDrawContext *context,
GdkMemoryDepth depth,
const cairo_region_t *region,
const graphene_rect_t *opaque)
gdk_draw_context_begin_frame_full (GdkDrawContext *context,
GdkMemoryDepth depth,
const cairo_region_t *region)
{
GdkDrawContextPrivate *priv = gdk_draw_context_get_instance_private (context);
@@ -386,23 +378,19 @@ gdk_draw_context_begin_frame_full (GdkDrawContext *context,
return;
}
gdk_surface_set_opaque_rect (priv->surface, opaque);
if (gdk_display_get_debug_flags (priv->display) & GDK_DEBUG_HIGH_DEPTH)
depth = GDK_MEMORY_FLOAT32;
priv->frame_region = cairo_region_copy (region);
priv->surface->paint_context = g_object_ref (context);
g_assert (priv->color_state == NULL);
GDK_DRAW_CONTEXT_GET_CLASS (context)->begin_frame (context,
depth,
priv->frame_region,
&priv->color_state,
&priv->depth);
/* The callback is meant to set them. Note that it does not return a ref */
/* the callback is meant to set them */
g_assert (priv->color_state != NULL);
g_assert (priv->depth < GDK_N_DEPTHS);
@@ -432,21 +420,6 @@ region_get_pixels (cairo_region_t *region)
}
#endif
void
gdk_draw_context_end_frame_full (GdkDrawContext *context)
{
GdkDrawContextPrivate *priv = gdk_draw_context_get_instance_private (context);
GDK_DRAW_CONTEXT_GET_CLASS (context)->end_frame (context, priv->frame_region);
gdk_profiler_set_int_counter (pixels_counter, region_get_pixels (priv->frame_region));
priv->color_state = NULL;
g_clear_pointer (&priv->frame_region, cairo_region_destroy);
g_clear_object (&priv->surface->paint_context);
priv->depth = GDK_N_DEPTHS;
}
/**
* gdk_draw_context_end_frame:
* @context: a `GdkDrawContext`
@@ -459,9 +432,6 @@ gdk_draw_context_end_frame_full (GdkDrawContext *context)
* When using a [class@Gdk.GLContext], this function may call `glFlush()`
* implicitly before returning; it is not recommended to call `glFlush()`
* explicitly before calling this function.
*
* Deprecated: 4.16: Drawing directly to the surface is no longer recommended.
* Use `GskRenderNode` and `GskRenderer`.
*/
void
gdk_draw_context_end_frame (GdkDrawContext *context)
@@ -489,7 +459,14 @@ gdk_draw_context_end_frame (GdkDrawContext *context)
return;
}
gdk_draw_context_end_frame_full (context);
GDK_DRAW_CONTEXT_GET_CLASS (context)->end_frame (context, priv->frame_region);
gdk_profiler_set_int_counter (pixels_counter, region_get_pixels (priv->frame_region));
g_clear_pointer (&priv->color_state, gdk_color_state_unref);
g_clear_pointer (&priv->frame_region, cairo_region_destroy);
g_clear_object (&priv->surface->paint_context);
priv->depth = GDK_N_DEPTHS;
}
/**
@@ -506,24 +483,15 @@ gdk_draw_context_end_frame (GdkDrawContext *context)
* and [method@Gdk.DrawContext.end_frame], %NULL will be returned.
*
* Returns: (transfer none) (nullable): a Cairo region
*
* Deprecated: 4.16: Drawing directly to the surface is no longer recommended.
* Use `GskRenderNode` and `GskRenderer`.
*/
const cairo_region_t *
_gdk_draw_context_get_frame_region (GdkDrawContext *context)
gdk_draw_context_get_frame_region (GdkDrawContext *context)
{
GdkDrawContextPrivate *priv = gdk_draw_context_get_instance_private (context);
return priv->frame_region;
}
const cairo_region_t *
(gdk_draw_context_get_frame_region) (GdkDrawContext *context)
{
g_return_val_if_fail (GDK_IS_DRAW_CONTEXT (context), NULL);
return _gdk_draw_context_get_frame_region (context);
return priv->frame_region;
}
/*<private>
+4 -4
View File
@@ -40,15 +40,15 @@ GdkDisplay * gdk_draw_context_get_display (GdkDrawContext
GDK_AVAILABLE_IN_ALL
GdkSurface * gdk_draw_context_get_surface (GdkDrawContext *context);
GDK_DEPRECATED_IN_4_16
GDK_AVAILABLE_IN_ALL
void gdk_draw_context_begin_frame (GdkDrawContext *context,
const cairo_region_t *region);
GDK_DEPRECATED_IN_4_16
GDK_AVAILABLE_IN_ALL
void gdk_draw_context_end_frame (GdkDrawContext *context);
GDK_DEPRECATED_IN_4_16
GDK_AVAILABLE_IN_ALL
gboolean gdk_draw_context_is_in_frame (GdkDrawContext *context);
GDK_DEPRECATED_IN_4_16
GDK_AVAILABLE_IN_ALL
const cairo_region_t * gdk_draw_context_get_frame_region (GdkDrawContext *context);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkDrawContext, g_object_unref)
+1 -7
View File
@@ -25,8 +25,6 @@
#include "gdkcolorstateprivate.h"
#include "gdkmemoryformatprivate.h"
#include <graphene.h>
G_BEGIN_DECLS
#define GDK_DRAW_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DRAW_CONTEXT, GdkDrawContextClass))
@@ -59,14 +57,10 @@ void gdk_draw_context_surface_resized (GdkDrawContext
void gdk_draw_context_begin_frame_full (GdkDrawContext *context,
GdkMemoryDepth depth,
const cairo_region_t *region,
const graphene_rect_t *opaque);
void gdk_draw_context_end_frame_full (GdkDrawContext *context);
const cairo_region_t *region);
void gdk_draw_context_empty_frame (GdkDrawContext *context);
#define gdk_draw_context_get_frame_region(...) _gdk_draw_context_get_frame_region(__VA_ARGS__)
const cairo_region_t * _gdk_draw_context_get_frame_region (GdkDrawContext *self);
GdkColorState * gdk_draw_context_get_color_state (GdkDrawContext *self);
GdkMemoryDepth gdk_draw_context_get_depth (GdkDrawContext *self);
+10 -32
View File
@@ -122,7 +122,6 @@ struct _GdkGLContextPrivate
GdkGLMemoryFlags memory_flags[GDK_MEMORY_N_FORMATS];
GdkGLFeatures features;
guint surface_attached : 1;
guint use_khr_debug : 1;
guint has_debug_output : 1;
guint extensions_checked : 1;
@@ -638,10 +637,7 @@ gdk_gl_context_real_begin_frame (GdkDrawContext *draw_context,
else
*out_depth = GDK_MEMORY_U8;
if (*out_depth == GDK_MEMORY_U8_SRGB)
*out_color_state = gdk_color_state_get_no_srgb_tf (color_state);
else
*out_color_state = color_state;
*out_color_state = color_state;
#else
*out_color_state = gdk_color_state_get_srgb ();
*out_depth = GDK_MEMORY_U8;
@@ -718,8 +714,8 @@ gdk_gl_context_real_end_frame (GdkDrawContext *draw_context,
cairo_region_get_rectangle (painted, i, &rect);
rects[j++] = (int) floor (rect.x * scale);
rects[j++] = (int) floor ((surface_height - rect.height - rect.y) * scale);
rects[j++] = (int) ceil ((rect.x + rect.width) * scale) - floor (rect.x * scale);
rects[j++] = (int) ceil ((surface_height - rect.y) * scale) - floor ((surface_height - rect.height - rect.y) * scale);
rects[j++] = (int) ceil (rect.width * scale);
rects[j++] = (int) ceil (rect.height * scale);
}
priv->eglSwapBuffersWithDamage (gdk_display_get_egl_display (display), egl_surface, rects, n_rects);
g_free (heap_rects);
@@ -830,28 +826,20 @@ gdk_gl_context_init (GdkGLContext *self)
/* Must have called gdk_display_prepare_gl() before */
GdkGLContext *
gdk_gl_context_new (GdkDisplay *display,
GdkSurface *surface,
gboolean surface_attached)
GdkSurface *surface)
{
GdkGLContextPrivate *priv;
GdkGLContext *shared, *result;
GdkGLContext *shared;
g_assert (surface == NULL || display == gdk_surface_get_display (surface));
g_assert (!surface_attached || surface != NULL);
/* assert gdk_display_prepare_gl() had been called */
shared = gdk_display_get_gl_context (display);
g_assert (shared);
result = g_object_new (G_OBJECT_TYPE (shared),
"display", display,
"surface", surface,
NULL);
priv = gdk_gl_context_get_instance_private (result);
priv->surface_attached = surface_attached;
return result;
return g_object_new (G_OBJECT_TYPE (shared),
"display", display,
"surface", surface,
NULL);
}
void
@@ -1834,22 +1822,12 @@ gdk_gl_context_check_is_current (GdkGLContext *context)
void
gdk_gl_context_make_current (GdkGLContext *context)
{
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
MaskedContext *current, *masked_context;
gboolean surfaceless;
g_return_if_fail (GDK_IS_GL_CONTEXT (context));
if (priv->surface_attached)
{
surfaceless = FALSE;
}
else
{
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
surfaceless = !gdk_draw_context_is_in_frame (GDK_DRAW_CONTEXT (context));
G_GNUC_END_IGNORE_DEPRECATIONS
}
surfaceless = !gdk_draw_context_is_in_frame (GDK_DRAW_CONTEXT (context));
masked_context = mask_context (context, surfaceless);
current = g_private_get (&thread_current_context);
+2 -3
View File
@@ -122,9 +122,8 @@ void gdk_gl_backend_use (GdkGLBackend
void gdk_gl_context_clear_current_if_surface (GdkSurface *surface);
GdkGLContext * gdk_gl_context_new (GdkDisplay *display,
GdkSurface *surface,
gboolean surface_attached);
GdkGLContext * gdk_gl_context_new (GdkDisplay *display,
GdkSurface *surface);
gboolean gdk_gl_context_is_api_allowed (GdkGLContext *self,
GdkGLAPI api,
+14
View File
@@ -1879,6 +1879,12 @@ gdk_memory_convert (guchar *dest_data,
g_assert (dest_data + gdk_memory_format_min_buffer_size (dest_format, dest_stride, width, height) <= src_data ||
src_data + gdk_memory_format_min_buffer_size (src_format, src_stride, width, height) <= dest_data);
g_print ("memory convert %s %s -> %s %s\n",
gdk_memory_format_get_name (src_format),
gdk_color_state_get_name (src_cs),
gdk_memory_format_get_name (dest_format),
gdk_color_state_get_name (dest_cs));
if (src_format == dest_format && gdk_color_state_equal (dest_cs, src_cs))
{
gsize bytes_per_row = src_desc->bytes_per_pixel * width;
@@ -1952,6 +1958,7 @@ gdk_memory_convert (guchar *dest_data,
if (func != NULL)
{
g_print ("convert format\n");
for (y = 0; y < height; y++)
{
func (dest_data, src_data, width);
@@ -1974,10 +1981,13 @@ gdk_memory_convert (guchar *dest_data,
needs_premultiply = src_desc->alpha == GDK_MEMORY_ALPHA_STRAIGHT && dest_desc->alpha != GDK_MEMORY_ALPHA_STRAIGHT;
}
g_print ("convert color %lu %lu\n", width, height);
for (y = 0; y < height; y++)
{
src_desc->to_float (tmp, src_data, width);
g_print ("after to_float: %f %f %f %f\n", tmp[0][0], tmp[0][1], tmp[0][2], tmp[0][3]);
if (needs_unpremultiply)
unpremultiply (tmp, width);
@@ -2159,6 +2169,10 @@ gdk_memory_convert_color_state (guchar *data,
if (gdk_color_state_equal (src_cs, dest_cs))
return;
g_print ("memory convert color state %s -> %s\n",
gdk_color_state_get_name (src_cs),
gdk_color_state_get_name (dest_cs));
if (format == GDK_MEMORY_B8G8R8A8_PREMULTIPLIED &&
src_cs == GDK_COLOR_STATE_SRGB &&
dest_cs == GDK_COLOR_STATE_SRGB_LINEAR)
+2 -4
View File
@@ -111,7 +111,7 @@ gdk_memory_sanitize (GBytes *bytes,
stride % align == 0)
{
*out_stride = stride;
return bytes;
return g_bytes_ref (bytes);
}
bpp = gdk_memory_format_bytes_per_pixel (format);
@@ -122,8 +122,6 @@ gdk_memory_sanitize (GBytes *bytes,
for (y = 0; y < height; y++)
memcpy (copy + y * copy_stride, data + y * stride, bpp * width);
g_bytes_unref (bytes);
*out_stride = copy_stride;
return g_bytes_new_take (copy, copy_stride * height);
}
@@ -199,7 +197,7 @@ gdk_memory_texture_new (int width,
/* needs to be this complex to support subtexture of the bottom right part */
g_return_val_if_fail (g_bytes_get_size (bytes) >= gdk_memory_format_min_buffer_size (format, stride, width, height), NULL);
bytes = gdk_memory_sanitize (g_bytes_ref (bytes), width, height, format, stride, &stride);
bytes = gdk_memory_sanitize (bytes, width, height, format, stride, &stride);
self = g_object_new (GDK_TYPE_MEMORY_TEXTURE,
"width", width,
-10
View File
@@ -52,16 +52,6 @@ gdk_rectangle_transform_affine (const GdkRectangle *src,
dest->height = ceilf (MAX (y1, y2)) - dest->y;
}
static inline gboolean
gdk_rectangle_contains (const GdkRectangle *rect,
const GdkRectangle *contained)
{
return contained->x >= rect->x
&& contained->y >= rect->y
&& contained->x + contained->width <= rect->x + rect->width
&& contained->y + contained->height <= rect->y + rect->height;
}
G_END_DECLS
+11 -102
View File
@@ -40,13 +40,11 @@
#include <glib/gi18n-lib.h>
#include "gdkmarshalers.h"
#include "gdkpopupprivate.h"
#include "gdkrectangleprivate.h"
#include "gdkrectangle.h"
#include "gdktoplevelprivate.h"
#include "gdkvulkancontext.h"
#include "gdksubsurfaceprivate.h"
#include "gsk/gskrectprivate.h"
#include <math.h>
#ifdef HAVE_EGL
@@ -77,9 +75,6 @@ struct _GdkSurfacePrivate
GdkMemoryDepth egl_surface_depth;
#endif
cairo_region_t *opaque_region;
cairo_rectangle_int_t opaque_rect; /* This is different from the region */
gpointer widget;
GdkColorState *color_state;
@@ -515,12 +510,6 @@ gdk_surface_real_create_subsurface (GdkSurface *surface)
return NULL;
}
static void
gdk_surface_default_set_opaque_region (GdkSurface *surface,
cairo_region_t *region)
{
}
static void
gdk_surface_constructed (GObject *object)
{
@@ -544,7 +533,6 @@ gdk_surface_class_init (GdkSurfaceClass *klass)
klass->beep = gdk_surface_real_beep;
klass->get_scale = gdk_surface_real_get_scale;
klass->create_subsurface = gdk_surface_real_create_subsurface;
klass->set_opaque_region = gdk_surface_default_set_opaque_region;
/**
* GdkSurface:cursor: (attributes org.gtk.Property.get=gdk_surface_get_cursor org.gtk.Property.set=gdk_surface_set_cursor)
@@ -783,7 +771,7 @@ gdk_surface_finalize (GObject *object)
g_clear_object (&surface->display);
g_clear_pointer (&priv->opaque_region, cairo_region_destroy);
g_clear_pointer (&surface->opaque_region, cairo_region_destroy);
if (surface->parent)
surface->parent->children = g_list_remove (surface->parent->children, surface);
@@ -1146,12 +1134,11 @@ gdk_surface_set_egl_native_window (GdkSurface *self,
{
GdkDisplay *display = gdk_surface_get_display (self);
gdk_gl_context_clear_current_if_surface (self);
eglDestroySurface (gdk_display_get_egl_display (display), priv->egl_surface);
priv->egl_surface = NULL;
}
gdk_gl_context_clear_current_if_surface (self);
priv->egl_native_window = native_window;
}
@@ -1269,7 +1256,7 @@ gdk_surface_create_gl_context (GdkSurface *surface,
if (!gdk_display_prepare_gl (surface->display, error))
return NULL;
return gdk_gl_context_new (surface->display, surface, FALSE);
return gdk_gl_context_new (surface->display, surface);
}
/**
@@ -2646,35 +2633,6 @@ gdk_surface_get_scale (GdkSurface *surface)
return GDK_SURFACE_GET_CLASS (surface)->get_scale (surface);
}
static void
gdk_surface_update_opaque_region (GdkSurface *self)
{
GdkSurfacePrivate *priv = gdk_surface_get_instance_private (self);
cairo_region_t *region;
if (priv->opaque_region == NULL)
{
if (priv->opaque_rect.width <= 0)
region = NULL;
else
region = cairo_region_create_rectangle (&priv->opaque_rect);
}
else
{
if (priv->opaque_rect.width <= 0)
region = cairo_region_reference (priv->opaque_region);
else
{
region = cairo_region_copy (priv->opaque_region);
cairo_region_union_rectangle (region, &priv->opaque_rect);
}
}
GDK_SURFACE_GET_CLASS (self)->set_opaque_region (self, region);
g_clear_pointer (&region, cairo_region_destroy);
}
/**
* gdk_surface_set_opaque_region:
* @surface: a top-level `GdkSurface`
@@ -2696,76 +2654,27 @@ gdk_surface_update_opaque_region (GdkSurface *self)
* is opaque, as we know where the opaque regions are. If your surface
* background is not opaque, please update this property in your
* [GtkWidgetClass.css_changed](../gtk4/vfunc.Widget.css_changed.html) handler.
*
* Deprecated: 4.16: GDK can figure out the opaque parts of a window itself
* by inspecting the contents that are drawn.
*/
void
gdk_surface_set_opaque_region (GdkSurface *surface,
cairo_region_t *region)
{
GdkSurfacePrivate *priv = gdk_surface_get_instance_private (surface);
GdkSurfaceClass *class;
g_return_if_fail (GDK_IS_SURFACE (surface));
g_return_if_fail (!GDK_SURFACE_DESTROYED (surface));
if (cairo_region_equal (priv->opaque_region, region))
if (cairo_region_equal (surface->opaque_region, region))
return;
g_clear_pointer (&priv->opaque_region, cairo_region_destroy);
g_clear_pointer (&surface->opaque_region, cairo_region_destroy);
if (region != NULL)
priv->opaque_region = cairo_region_reference (region);
surface->opaque_region = cairo_region_reference (region);
gdk_surface_update_opaque_region (surface);
}
/* Sets the opaque rect from the rendernode via end_frame() */
void
gdk_surface_set_opaque_rect (GdkSurface *self,
const graphene_rect_t *rect)
{
GdkSurfacePrivate *priv = gdk_surface_get_instance_private (self);
cairo_rectangle_int_t opaque;
if (rect)
gsk_rect_to_cairo_shrink (rect, &opaque);
else
opaque = (cairo_rectangle_int_t) { 0, 0, 0, 0 };
if (gdk_rectangle_equal (&priv->opaque_rect, &opaque))
return;
priv->opaque_rect = opaque;
gdk_surface_update_opaque_region (self);
}
/*
* gdk_surface_is_opaque:
* @self: a surface
*
* Checks if the whole surface is known to be opaque.
* This allows using an RGBx buffer instead of RGBA.
*
* This function works for the currently rendered frame inside
* begin_frame() implementations.
*
* Returns: %TRUE if the whole surface is provably opaque
**/
gboolean
gdk_surface_is_opaque (GdkSurface *self)
{
GdkSurfacePrivate *priv = gdk_surface_get_instance_private (self);
cairo_rectangle_int_t whole = { 0, 0, self->width, self->height };
if (gdk_rectangle_contains (&priv->opaque_rect, &whole))
return TRUE;
if (cairo_region_contains_rectangle (priv->opaque_region, &whole) == CAIRO_REGION_OVERLAP_IN)
return TRUE;
return FALSE;
class = GDK_SURFACE_GET_CLASS (surface);
if (class->set_opaque_region)
class->set_opaque_region (surface, region);
}
void
+1 -1
View File
@@ -125,7 +125,7 @@ void gdk_surface_request_layout (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
GdkFrameClock* gdk_surface_get_frame_clock (GdkSurface *surface);
GDK_DEPRECATED_IN_4_16
GDK_AVAILABLE_IN_ALL
void gdk_surface_set_opaque_region (GdkSurface *surface,
cairo_region_t *region);
+10 -11
View File
@@ -96,6 +96,8 @@ struct _GdkSurface
GSList *draw_contexts;
GdkDrawContext *paint_context;
cairo_region_t *opaque_region;
GdkSeat *current_shortcuts_inhibited_seat;
GPtrArray *subsurfaces;
@@ -251,17 +253,14 @@ gdk_gravity_flip_vertically (GdkGravity anchor)
g_assert_not_reached ();
}
void _gdk_surface_destroy (GdkSurface *surface,
gboolean foreign_destroy);
void gdk_surface_invalidate_rect (GdkSurface *surface,
const GdkRectangle *rect);
void gdk_surface_invalidate_region (GdkSurface *surface,
const cairo_region_t *region);
void _gdk_surface_clear_update_area (GdkSurface *surface);
void _gdk_surface_update_size (GdkSurface *surface);
void gdk_surface_set_opaque_rect (GdkSurface *self,
const graphene_rect_t *rect);
gboolean gdk_surface_is_opaque (GdkSurface *self);
void _gdk_surface_destroy (GdkSurface *surface,
gboolean foreign_destroy);
void gdk_surface_invalidate_rect (GdkSurface *surface,
const GdkRectangle *rect);
void gdk_surface_invalidate_region (GdkSurface *surface,
const cairo_region_t *region);
void _gdk_surface_clear_update_area (GdkSurface *surface);
void _gdk_surface_update_size (GdkSurface *surface);
GdkGLContext * gdk_surface_get_paint_gl_context (GdkSurface *surface,
GError **error);
+5 -6
View File
@@ -678,10 +678,7 @@ gdk_vulkan_context_begin_frame (GdkDrawContext *draw_context,
cairo_region_union (region, priv->regions[priv->draw_index]);
if (priv->current_depth == GDK_MEMORY_U8_SRGB)
*out_color_state = gdk_color_state_get_no_srgb_tf (color_state);
else
*out_color_state = color_state;
*out_color_state = color_state;
*out_depth = priv->current_depth;
}
@@ -714,8 +711,8 @@ gdk_vulkan_context_end_frame (GdkDrawContext *draw_context,
.layer = 0,
.offset.x = (int) floor (r.x * scale),
.offset.y = (int) floor (r.y * scale),
.extent.width = (int) ceil ((r.x + r.width) * scale) - floor (r.x * scale),
.extent.height = (int) ceil ((r.y + r.height) * scale) - floor (r.y * scale),
.extent.width = (int) ceil (r.width * scale),
.extent.height = (int) ceil (r.height * scale),
};
}
}
@@ -1348,6 +1345,7 @@ gdk_vulkan_context_get_draw_index (GdkVulkanContext *context)
GdkVulkanContextPrivate *priv = gdk_vulkan_context_get_instance_private (context);
g_return_val_if_fail (GDK_IS_VULKAN_CONTEXT (context), 0);
g_return_val_if_fail (gdk_draw_context_is_in_frame (GDK_DRAW_CONTEXT (context)), 0);
return priv->draw_index;
}
@@ -1371,6 +1369,7 @@ gdk_vulkan_context_set_draw_semaphore (GdkVulkanContext *context,
GdkVulkanContextPrivate *priv = gdk_vulkan_context_get_instance_private (context);
g_return_if_fail (GDK_IS_VULKAN_CONTEXT (context));
g_return_if_fail (!gdk_draw_context_is_in_frame (GDK_DRAW_CONTEXT (context)));
g_return_if_fail (priv->draw_semaphore == VK_NULL_HANDLE);
priv->draw_semaphore = semaphore;
+1 -1
View File
@@ -65,7 +65,7 @@ gdk_vulkan_handle_result (VkResult res,
{
if (res != VK_SUCCESS)
{
g_warning ("%s(): %s (%d)", called_function, gdk_vulkan_strerror (res), res);
GDK_DEBUG (VULKAN, "%s(): %s (%d)", called_function, gdk_vulkan_strerror (res), res);
}
return res;
+21 -2
View File
@@ -107,13 +107,32 @@ _gdk_macos_cairo_context_cairo_create (GdkCairoContext *cairo_context)
cairo_clip (cr);
}
/* If we have some exposed transparent area in the damage region,
* we need to clear the existing content first to leave an transparent
* area for cairo. We use (surface_bounds or damage)-(opaque) to get
* the smallest set of rectangles we need to clear as it's expensive.
*/
if (!opaque)
{
cairo_region_t *transparent;
cairo_rectangle_int_t r = { 0, 0, width/scale, height/scale };
cairo_save (cr);
cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
cairo_paint (cr);
if (damage != NULL)
cairo_region_get_extents (damage, &r);
transparent = cairo_region_create_rectangle (&r);
if (surface->opaque_region)
cairo_region_subtract (transparent, surface->opaque_region);
if (!cairo_region_is_empty (transparent))
{
gdk_cairo_region (cr, transparent);
cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
cairo_fill (cr);
}
cairo_region_destroy (transparent);
cairo_restore (cr);
}
+1 -1
View File
@@ -242,7 +242,7 @@ gdk_macos_gl_context_allocate (GdkMacosGLContext *self)
return;
/* Alter to an opaque surface if necessary */
opaque = gdk_surface_is_opaque (surface);
opaque = _gdk_macos_surface_is_opaque (GDK_MACOS_SURFACE (surface));
if (opaque != self->last_opaque)
{
self->last_opaque = !!opaque;
+1
View File
@@ -86,6 +86,7 @@ CGDirectDisplayID _gdk_macos_surface_get_screen_id (GdkMacosSurface
const char *_gdk_macos_surface_get_title (GdkMacosSurface *self);
void _gdk_macos_surface_set_title (GdkMacosSurface *self,
const char *title);
gboolean _gdk_macos_surface_is_opaque (GdkMacosSurface *self);
NSView *_gdk_macos_surface_get_view (GdkMacosSurface *self);
gboolean _gdk_macos_surface_get_modal_hint (GdkMacosSurface *self);
void _gdk_macos_surface_set_modal_hint (GdkMacosSurface *self,
+23
View File
@@ -553,6 +553,29 @@ gdk_macos_surface_init (GdkMacosSurface *self)
self->monitors = g_ptr_array_new_with_free_func (g_object_unref);
}
gboolean
_gdk_macos_surface_is_opaque (GdkMacosSurface *self)
{
GdkSurface *surface = (GdkSurface *)self;
g_return_val_if_fail (GDK_IS_MACOS_SURFACE (self), FALSE);
if (surface->opaque_region != NULL &&
cairo_region_num_rectangles (surface->opaque_region) == 1)
{
cairo_rectangle_int_t extents;
cairo_region_get_extents (surface->opaque_region, &extents);
return (extents.x == 0 &&
extents.y == 0 &&
extents.width == GDK_SURFACE (self)->width &&
extents.height == GDK_SURFACE (self)->height);
}
return FALSE;
}
const char *
_gdk_macos_surface_get_title (GdkMacosSurface *self)
{
+37 -125
View File
@@ -1,10 +1,9 @@
#include "config.h"
#include "gdkwaylandcolor-private.h"
#include "gdksurface-wayland-private.h"
#include <gdk/wayland/xx-color-management-v4-client-protocol.h>
typedef struct _ImageDescription ImageDescription;
static uint primaries_map[] = {
[XX_COLOR_MANAGER_V4_PRIMARIES_SRGB] = 1,
[XX_COLOR_MANAGER_V4_PRIMARIES_PAL_M] = 4,
@@ -67,18 +66,6 @@ cicp_to_wl_transfer (uint tf)
return 0;
}
static inline float
wl_to_primary_coord (uint p)
{
return p / 10000.0;
}
static inline uint
wl_from_primary_coord (float p)
{
return p * 10000;
}
struct _GdkWaylandColor
{
GdkWaylandDisplay *display;
@@ -293,85 +280,50 @@ create_image_desc (GdkWaylandColor *color,
gboolean sync)
{
CsImageDescListenerData data;
struct xx_image_description_creator_params_v4 *creator = NULL;
struct xx_image_description_creator_params_v4 *creator;
struct xx_image_description_v4 *desc;
const GdkCicp *cicp;
GdkCicp norm;
uint32_t primaries, tf;
cicp = gdk_color_state_get_cicp (cs);
if (cicp && cicp->color_primaries != 2)
if (!cicp)
{
GdkCicp norm;
uint32_t primaries_named;
uint32_t tf_named;
gdk_cicp_normalize (cicp, &norm);
primaries_named = cicp_to_wl_primaries (norm.color_primaries);
tf_named = cicp_to_wl_transfer (norm.transfer_function);
if ((color->color_manager_supported.primaries & (1 << primaries_named)) == 0 ||
(color->color_manager_supported.transfers & (1 << tf_named)) == 0)
{
GDK_DEBUG (MISC, "Unsupported color state %s: Primaries or transfer function unsupported",
gdk_color_state_get_name (cs));
g_hash_table_insert (color->cs_to_desc, gdk_color_state_ref (cs), NULL);
return;
}
creator = xx_color_manager_v4_new_parametric_creator (color->color_manager);
xx_image_description_creator_params_v4_set_primaries_named (creator, primaries_named);
xx_image_description_creator_params_v4_set_tf_named (creator, tf_named);
}
else if (cicp && cicp->color_primaries == 2)
{
const float *primaries = gdk_color_state_get_primaries (cs);
GdkCicp norm;
uint32_t tf_named;
gdk_cicp_normalize (cicp, &norm);
tf_named = cicp_to_wl_transfer (norm.transfer_function);
if ((color->color_manager_supported.features & (1 << XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_SET_PRIMARIES)) == 0 ||
(color->color_manager_supported.transfers & (1 << tf_named)) == 0)
{
GDK_DEBUG (MISC, "Unsupported color state %s: Primaries or transfer function unsupported",
gdk_color_state_get_name (cs));
g_hash_table_insert (color->cs_to_desc, gdk_color_state_ref (cs), NULL);
return;
}
creator = xx_color_manager_v4_new_parametric_creator (color->color_manager);
xx_image_description_creator_params_v4_set_primaries (creator,
wl_from_primary_coord (primaries[0]),
wl_from_primary_coord (primaries[1]),
wl_from_primary_coord (primaries[2]),
wl_from_primary_coord (primaries[3]),
wl_from_primary_coord (primaries[4]),
wl_from_primary_coord (primaries[5]),
wl_from_primary_coord (primaries[6]),
wl_from_primary_coord (primaries[7]));
xx_image_description_creator_params_v4_set_tf_named (creator, tf_named);
}
else
{
GDK_DEBUG (MISC, "Unsupported color state %s: Not a CICP colorstate and no primaries",
GDK_DEBUG (MISC, "Unsupported color state %s: Not a CICP colorstate",
gdk_color_state_get_name (cs));
g_hash_table_insert (color->cs_to_desc, gdk_color_state_ref (cs), NULL);
return;
}
gdk_cicp_normalize (cicp, &norm);
primaries = cicp_to_wl_primaries (norm.color_primaries);
tf = cicp_to_wl_transfer (norm.transfer_function);
desc = xx_image_description_creator_params_v4_create (creator);
if ((color->color_manager_supported.primaries & (1 << primaries)) == 0 ||
(color->color_manager_supported.transfers & (1 << tf)) == 0)
{
GDK_DEBUG (MISC, "Unsupported color state %s: Primaries or transfer function unsupported",
gdk_color_state_get_name (cs));
g_hash_table_insert (color->cs_to_desc, gdk_color_state_ref (cs), NULL);
return;
}
data.color = color;
data.color_state = cs;
data.sync = sync;
data.done = FALSE;
creator = xx_color_manager_v4_new_parametric_creator (color->color_manager);
xx_image_description_creator_params_v4_set_primaries_named (creator, primaries);
xx_image_description_creator_params_v4_set_tf_named (creator, tf);
desc = xx_image_description_creator_params_v4_create (creator);
if (sync)
{
struct wl_event_queue *event_queue;
event_queue = wl_display_create_queue (color->display->wl_display);
wl_proxy_set_queue ((struct wl_proxy *) desc, event_queue);
xx_image_description_v4_add_listener (desc, &cs_image_desc_listener, &data);
@@ -474,12 +426,11 @@ struct _GdkWaylandColorSurface
GdkWaylandColor *color;
struct xx_color_management_surface_v4 *surface;
struct xx_color_management_feedback_surface_v4 *feedback;
ImageDescription *current_desc;
GdkColorStateChanged callback;
gpointer data;
};
struct _ImageDescription
typedef struct
{
GdkWaylandColorSurface *surface;
@@ -509,7 +460,7 @@ struct _ImageDescription
unsigned int has_target_luminance : 1;
unsigned int has_target_max_cll : 1;
unsigned int has_target_max_fall : 1;
};
} ImageDescription;
static GdkColorState *
gdk_color_state_from_image_description_bits (ImageDescription *desc)
@@ -525,38 +476,8 @@ gdk_color_state_from_image_description_bits (ImageDescription *desc)
return gdk_color_state_new_for_cicp (&cicp, NULL);
}
else if (desc->has_primaries && desc->has_tf_named)
{
float primaries[8];
primaries[0] = wl_to_primary_coord (desc->r_x);
primaries[1] = wl_to_primary_coord (desc->r_y);
primaries[2] = wl_to_primary_coord (desc->g_x);
primaries[3] = wl_to_primary_coord (desc->g_y);
primaries[4] = wl_to_primary_coord (desc->b_x);
primaries[5] = wl_to_primary_coord (desc->b_y);
primaries[6] = wl_to_primary_coord (desc->w_x);
primaries[7] = wl_to_primary_coord (desc->w_y);
return gdk_color_state_new_for_primaries (primaries, desc->tf_named, NULL);
}
return NULL;
}
static void
gdk_wayland_color_surface_clear_image_desc (GdkWaylandColorSurface *self)
{
ImageDescription *desc = self->current_desc;
if (desc == NULL)
return;
g_clear_pointer (&desc->image_desc, xx_image_description_v4_destroy);
g_clear_pointer (&desc->info, xx_image_description_info_v4_destroy);
g_free (desc);
self->current_desc = NULL;
else
return NULL;
}
static void
@@ -567,8 +488,6 @@ image_desc_info_done (void *data,
GdkWaylandColorSurface *self = desc->surface;
GdkColorState *cs;
g_assert (self->current_desc == desc);
cs = gdk_color_state_from_image_description_bits (desc);
if (cs)
{
@@ -579,7 +498,7 @@ image_desc_info_done (void *data,
else
{
cs = GDK_COLOR_STATE_SRGB;
g_clear_pointer (&desc->image_desc, xx_image_description_v4_destroy);
xx_image_description_v4_destroy (desc->image_desc);
}
if (self->callback)
@@ -587,7 +506,8 @@ image_desc_info_done (void *data,
gdk_color_state_unref (cs);
gdk_wayland_color_surface_clear_image_desc (self);
xx_image_description_info_v4_destroy (desc->info);
g_free (desc);
}
static void
@@ -743,11 +663,10 @@ image_desc_failed (void *data,
ImageDescription *desc = data;
GdkWaylandColorSurface *self = desc->surface;
g_assert (self->current_desc == desc);
self->callback (self, GDK_COLOR_STATE_SRGB, self->data);
gdk_wayland_color_surface_clear_image_desc (self);
xx_image_description_v4_destroy (desc->image_desc);
g_free (desc);
}
static void
@@ -759,14 +678,13 @@ image_desc_ready (void *data,
GdkWaylandColorSurface *self = desc->surface;
GdkColorState *cs;
g_assert (self->current_desc == desc);
cs = g_hash_table_lookup (self->color->id_to_cs, GUINT_TO_POINTER (identity));
if (cs)
{
self->callback (self, cs, self->data);
gdk_wayland_color_surface_clear_image_desc (self);
xx_image_description_v4_destroy (desc->image_desc);
g_free (desc);
return;
}
@@ -791,13 +709,9 @@ preferred_changed (void *data,
if (!self->callback)
return;
/* If there's still an ongoing query, cancel it. It's outdated. */
gdk_wayland_color_surface_clear_image_desc (self);
desc = g_new0 (ImageDescription, 1);
desc->surface = self;
self->current_desc = desc;
desc->image_desc = xx_color_management_feedback_surface_v4_get_preferred (self->feedback);
@@ -835,8 +749,6 @@ gdk_wayland_color_surface_new (GdkWaylandColor *color,
void
gdk_wayland_color_surface_free (GdkWaylandColorSurface *self)
{
gdk_wayland_color_surface_clear_image_desc (self);
xx_color_management_surface_v4_destroy (self->surface);
xx_color_management_feedback_surface_v4_destroy (self->feedback);
+16 -3
View File
@@ -120,6 +120,20 @@ maybe_wait_for_vblank (GdkDisplay *display,
}
}
static GLXDrawable
gdk_x11_gl_context_glx_get_drawable (GdkX11GLContextGLX *self)
{
GdkDrawContext *draw_context = GDK_DRAW_CONTEXT (self);
GdkSurface *surface;
if (gdk_draw_context_is_in_frame (draw_context))
surface = gdk_draw_context_get_surface (draw_context);
else
surface = GDK_X11_DISPLAY (gdk_draw_context_get_display (draw_context))->leader_gdk_surface;
return gdk_x11_surface_get_glx_drawable (surface);
}
static void
gdk_x11_gl_context_glx_end_frame (GdkDrawContext *draw_context,
cairo_region_t *painted)
@@ -304,11 +318,10 @@ gdk_x11_gl_context_glx_get_damage (GdkGLContext *context)
if (display_x11->has_glx_buffer_age)
{
GdkSurface *surface = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (context));
GdkX11GLContextGLX *self = GDK_X11_GL_CONTEXT_GLX (context);
gdk_gl_context_make_current (context);
glXQueryDrawable (dpy,
gdk_x11_surface_get_glx_drawable (surface),
glXQueryDrawable (dpy, gdk_x11_gl_context_glx_get_drawable (self),
GLX_BACK_BUFFER_AGE_EXT, &buffer_age);
if (buffer_age > 0 && buffer_age <= GDK_GL_MAX_TRACKED_BUFFERS)
+2 -2
View File
@@ -934,7 +934,7 @@ gsk_broadway_renderer_render (GskRenderer *renderer,
self->node_lookup = g_hash_table_new (g_direct_hash, g_direct_equal);
gdk_draw_context_begin_frame_full (GDK_DRAW_CONTEXT (self->draw_context), GDK_MEMORY_U8, update_area, NULL);
gdk_draw_context_begin_frame (GDK_DRAW_CONTEXT (self->draw_context), update_area);
/* These are owned by the draw context between begin and end, but
cache them here for easier access during the render */
@@ -946,7 +946,7 @@ gsk_broadway_renderer_render (GskRenderer *renderer,
self->nodes = NULL;
self->node_textures = NULL;
gdk_draw_context_end_frame_full (GDK_DRAW_CONTEXT (self->draw_context));
gdk_draw_context_end_frame (GDK_DRAW_CONTEXT (self->draw_context));
if (self->last_node_lookup)
g_hash_table_unref (self->last_node_lookup);
+4 -4
View File
@@ -133,7 +133,7 @@ void half_to_float4 (const guint16 h[4], float f[4]) __attribute__((ifunc ("reso
void float_to_half (const float *f, guint16 *h, int n) __attribute__((ifunc ("resolve_float_to_half")));
void half_to_float (const guint16 *h, float *f, int n) __attribute__((ifunc ("resolve_half_to_float")));
static void * __attribute__ ((no_sanitize_address)) G_GNUC_UNUSED
static void * __attribute__ ((no_sanitize_address))
resolve_float_to_half4 (void)
{
__builtin_cpu_init ();
@@ -143,7 +143,7 @@ resolve_float_to_half4 (void)
return float_to_half4_c;
}
static void * __attribute__ ((no_sanitize_address)) G_GNUC_UNUSED
static void * __attribute__ ((no_sanitize_address))
resolve_half_to_float4 (void)
{
__builtin_cpu_init ();
@@ -153,7 +153,7 @@ resolve_half_to_float4 (void)
return half_to_float4_c;
}
static void * __attribute__ ((no_sanitize_address)) G_GNUC_UNUSED
static void * __attribute__ ((no_sanitize_address))
resolve_float_to_half (void)
{
__builtin_cpu_init ();
@@ -163,7 +163,7 @@ resolve_float_to_half (void)
return float_to_half_c;
}
static void * __attribute__ ((no_sanitize_address)) G_GNUC_UNUSED
static void * __attribute__ ((no_sanitize_address))
resolve_half_to_float (void)
{
__builtin_cpu_init ();
-3
View File
@@ -217,9 +217,6 @@ gsk_gl_driver_dispose (GObject *object)
g_assert (GSK_IS_GL_DRIVER (self));
g_assert (self->in_frame == FALSE);
if (self->shared_command_queue)
gsk_gl_command_queue_make_current (self->shared_command_queue);
#define GSK_GL_NO_UNIFORMS
#define GSK_GL_SHADER_RESOURCE(name)
#define GSK_GL_SHADER_STRING(str)
+69 -17
View File
@@ -192,12 +192,12 @@ gsk_gl_renderer_realize (GskRenderer *renderer,
g_assert (self->context == NULL);
g_assert (self->command_queue == NULL);
if (!gdk_display_prepare_gl (display, error))
goto failure;
if (surface == NULL)
context = gdk_display_create_gl_context (display, error);
else
context = gdk_surface_create_gl_context (surface, error);
context = gdk_gl_context_new (display, surface, surface != NULL);
if (!gdk_gl_context_realize (context, error))
if (!context || !gdk_gl_context_realize (context, error))
goto failure;
api = gdk_gl_context_get_api (context);
@@ -258,8 +258,6 @@ gsk_gl_renderer_unrealize (GskRenderer *renderer)
g_clear_object (&self->driver);
g_clear_object (&self->command_queue);
g_clear_object (&self->context);
gdk_gl_context_clear_current ();
}
static cairo_region_t *
@@ -295,6 +293,65 @@ get_render_region (GdkSurface *surface,
return cairo_region_create_rectangle (&extents);
}
static gboolean
update_area_requires_clear (GdkSurface *surface,
const cairo_region_t *update_area)
{
cairo_rectangle_int_t rect;
guint n_rects;
g_assert (GDK_IS_SURFACE (surface));
/* No opaque region, assume we have to clear */
if (surface->opaque_region == NULL)
return TRUE;
/* If the update_area is the whole surface, then clear it
* because many drivers optimize for this by avoiding extra
* work to reload any contents.
*/
if (update_area == NULL)
return TRUE;
if (cairo_region_num_rectangles (update_area) == 1)
{
cairo_region_get_rectangle (update_area, 0, &rect);
if (rect.x == 0 &&
rect.y == 0 &&
rect.width == surface->width &&
rect.height == surface->height)
return TRUE;
}
/* If the entire surface is opaque, then we can skip clearing
* (with the exception of full surface clearing above).
*/
if (cairo_region_num_rectangles (surface->opaque_region) == 1)
{
cairo_region_get_rectangle (surface->opaque_region, 0, &rect);
if (rect.x == 0 &&
rect.y == 0 &&
rect.width == surface->width &&
rect.height == surface->height)
return FALSE;
}
/* If any update_area rectangle overlaps our transparent
* regions, then we need to clear the area.
*/
n_rects = cairo_region_num_rectangles (update_area);
for (guint i = 0; i < n_rects; i++)
{
cairo_region_get_rectangle (update_area, i, &rect);
if (cairo_region_contains_rectangle (surface->opaque_region, &rect) != CAIRO_REGION_OVERLAP_IN)
return TRUE;
}
return FALSE;
}
static void
gsk_gl_renderer_render (GskRenderer *renderer,
GskRenderNode *root,
@@ -305,8 +362,7 @@ gsk_gl_renderer_render (GskRenderer *renderer,
graphene_rect_t viewport;
GskGLRenderJob *job;
GdkSurface *surface;
graphene_rect_t opaque_tmp;
const graphene_rect_t *opaque;
gboolean clear_framebuffer;
float scale;
g_assert (GSK_IS_GL_RENDERER (renderer));
@@ -326,27 +382,23 @@ gsk_gl_renderer_render (GskRenderer *renderer,
viewport.size.width = gdk_surface_get_width (surface) * scale;
viewport.size.height = gdk_surface_get_height (surface) * scale;
if (gsk_render_node_get_opaque_rect (root, &opaque_tmp))
opaque = &opaque_tmp;
else
opaque = NULL;
gdk_draw_context_begin_frame_full (GDK_DRAW_CONTEXT (self->context),
gsk_render_node_get_preferred_depth (root),
update_area,
opaque);
update_area);
gdk_gl_context_make_current (self->context);
/* Must be called *AFTER* gdk_draw_context_begin_frame() */
render_region = get_render_region (surface, self->context);
clear_framebuffer = update_area_requires_clear (surface, render_region);
gsk_gl_driver_begin_frame (self->driver, self->command_queue);
job = gsk_gl_render_job_new (self->driver, &viewport, scale, render_region, 0, TRUE);
job = gsk_gl_render_job_new (self->driver, &viewport, scale, render_region, 0, clear_framebuffer);
gsk_gl_render_job_render (job, root);
gsk_gl_driver_end_frame (self->driver);
gsk_gl_render_job_free (job);
gdk_draw_context_end_frame_full (GDK_DRAW_CONTEXT (self->context));
gdk_draw_context_end_frame (GDK_DRAW_CONTEXT (self->context));
gsk_gl_driver_after_frame (self->driver);
+8 -22
View File
@@ -2182,10 +2182,6 @@ gsk_gl_render_job_visit_unblurred_inset_shadow_node (GskGLRenderJob *job,
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, inset_shadow)))
{
const GdkRGBA rgba;
gdk_color_to_float (gsk_inset_shadow_node_get_color2 (node), GDK_COLOR_STATE_SRGB, (float *) &rgba);
gsk_gl_program_set_uniform_rounded_rect (job->current_program,
UNIFORM_INSET_SHADOW_OUTLINE_RECT, 0,
&transformed_outline);
@@ -2196,7 +2192,7 @@ gsk_gl_render_job_visit_unblurred_inset_shadow_node (GskGLRenderJob *job,
UNIFORM_INSET_SHADOW_OFFSET, 0,
gsk_inset_shadow_node_get_dx (node),
gsk_inset_shadow_node_get_dy (node));
rgba_to_half (&rgba, color);
rgba_to_half (gsk_inset_shadow_node_get_color (node), color);
gsk_gl_render_job_draw_rect_with_color (job, &node->bounds, color);
gsk_gl_render_job_end_draw (job);
}
@@ -2289,10 +2285,6 @@ gsk_gl_render_job_visit_blurred_inset_shadow_node (GskGLRenderJob *job,
/* Actual inset shadow outline drawing */
if (gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, inset_shadow)))
{
const GdkRGBA rgba;
gdk_color_to_float (gsk_inset_shadow_node_get_color2 (node), GDK_COLOR_STATE_SRGB, (float *) &rgba);
gsk_gl_program_set_uniform_rounded_rect (job->current_program,
UNIFORM_INSET_SHADOW_OUTLINE_RECT, 0,
&transformed_outline);
@@ -2303,7 +2295,7 @@ gsk_gl_render_job_visit_blurred_inset_shadow_node (GskGLRenderJob *job,
UNIFORM_INSET_SHADOW_OFFSET, 0,
offset_x * scale_x,
offset_y * scale_y);
rgba_to_half (&rgba, color);
rgba_to_half (gsk_inset_shadow_node_get_color (node), color);
gsk_gl_render_job_draw_with_color (job,
0, 0, texture_width, texture_height,
color);
@@ -2386,7 +2378,6 @@ gsk_gl_render_job_visit_unblurred_outset_shadow_node (GskGLRenderJob *job,
float spread = gsk_outset_shadow_node_get_spread (node);
float dx = gsk_outset_shadow_node_get_dx (node);
float dy = gsk_outset_shadow_node_get_dy (node);
GdkRGBA rgba;
guint16 color[4];
const float edge_sizes[] = { // Top, right, bottom, left
spread - dy, spread + dx, spread + dy, spread - dx
@@ -2398,8 +2389,7 @@ gsk_gl_render_job_visit_unblurred_outset_shadow_node (GskGLRenderJob *job,
{ outline->corner[3].width + spread - dx, outline->corner[3].height + spread + dy },
};
gdk_color_to_float (gsk_outset_shadow_node_get_color2 (node), GDK_COLOR_STATE_SRGB, (float *) &rgba);
rgba_to_half (&rgba, color);
rgba_to_half (gsk_outset_shadow_node_get_color (node), color);
gsk_gl_render_job_translate_rounded_rect (job, outline, &transformed_outline);
@@ -2483,13 +2473,11 @@ gsk_gl_render_job_visit_blurred_outset_shadow_node (GskGLRenderJob *job,
int blurred_texture_id;
int cached_tid;
gboolean do_slicing;
GdkRGBA rgba;
guint16 color[4];
float half_width = outline->bounds.size.width / 2;
float half_height = outline->bounds.size.height / 2;
gdk_color_to_float (gsk_outset_shadow_node_get_color2 (node), GDK_COLOR_STATE_SRGB, (float *) &rgba);
rgba_to_half (&rgba, color);
rgba_to_half (gsk_outset_shadow_node_get_color (node), color);
/* scaled_outline is the minimal outline we need to draw the given drop shadow,
* enlarged by the spread and offset by the blur radius. */
@@ -4221,12 +4209,10 @@ gsk_gl_render_job_visit_node (GskGLRenderJob *job,
break;
case GSK_TEXT_NODE:
{
GdkRGBA rgba;
gdk_color_to_float (gsk_text_node_get_color2 (node), GDK_COLOR_STATE_SRGB, (float *) &rgba);
gsk_gl_render_job_visit_text_node (job, node, &rgba, FALSE);
}
gsk_gl_render_job_visit_text_node (job,
node,
gsk_text_node_get_color (node),
FALSE);
break;
case GSK_TEXTURE_NODE:
+3 -3
View File
@@ -75,10 +75,10 @@ void main() {
if (offset < next_offset) {
float f = (offset - curr_offset) / (next_offset - curr_offset);
vec4 curr_color = gsk_scaled_premultiply (get_color(i), u_alpha);
vec4 next_color = gsk_scaled_premultiply (get_color(i + 1), u_alpha);
vec4 curr_color = get_color(i);
vec4 next_color = get_color(i + 1);
vec4 color = mix(curr_color, next_color, f);
gskSetOutputColor(color);
gskSetScaledOutputColor(gsk_premultiply(color), u_alpha);
return;
}
}
+3 -3
View File
@@ -97,10 +97,10 @@ void main() {
if (offset < next_offset) {
float f = (offset - curr_offset) / (next_offset - curr_offset);
vec4 curr_color = gsk_scaled_premultiply (get_color(i), u_alpha);
vec4 next_color = gsk_scaled_premultiply (get_color(i + 1), u_alpha);
vec4 curr_color = get_color(i);
vec4 next_color = get_color(i + 1);
vec4 color = mix(curr_color, next_color, f);
gskSetOutputColor(color);
gskSetScaledOutputColor(gsk_premultiply (color), u_alpha);
return;
}
}
+3 -3
View File
@@ -77,10 +77,10 @@ void main() {
if (offset < next_offset) {
float f = (offset - curr_offset) / (next_offset - curr_offset);
vec4 curr_color = gsk_scaled_premultiply (get_color(i), u_alpha);
vec4 next_color = gsk_scaled_premultiply (get_color(i + 1), u_alpha);
vec4 curr_color = get_color(i);
vec4 next_color = get_color(i + 1);
vec4 color = mix(curr_color, next_color, f);
gskSetOutputColor(color);
gskSetScaledOutputColor(gsk_premultiply(color), u_alpha);
return;
}
}
+13 -25
View File
@@ -56,22 +56,18 @@ static const GskGpuShaderOpClass GSK_GPU_BLUR_OP_CLASS = {
static void
gsk_gpu_blur_op_full (GskGpuFrame *frame,
GskGpuShaderClip clip,
GdkColorState *ccs,
float opacity,
const graphene_point_t *offset,
GskGpuColorStates color_states,
guint32 variation,
const graphene_point_t *offset,
const GskGpuShaderImage *image,
const graphene_vec2_t *blur_direction,
const GdkColor *blur_color)
float blur_color[4])
{
GskGpuBlurInstance *instance;
GdkColorState *alt;
alt = gsk_gpu_color_states_find (ccs, blur_color);
gsk_gpu_shader_op_alloc (frame,
&GSK_GPU_BLUR_OP_CLASS,
gsk_gpu_color_states_create (ccs, TRUE, alt, variation & VARIATION_COLORIZE ? FALSE : TRUE),
color_states,
variation,
clip,
(GskGpuImage *[1]) { image->image },
@@ -81,49 +77,41 @@ gsk_gpu_blur_op_full (GskGpuFrame *frame,
gsk_gpu_rect_to_float (image->coverage, offset, instance->rect);
gsk_gpu_rect_to_float (image->bounds, offset, instance->tex_rect);
graphene_vec2_to_float (blur_direction, instance->blur_direction);
gsk_gpu_color_to_float (blur_color, alt, opacity, instance->blur_color);
gsk_gpu_vec4_to_float (blur_color, instance->blur_color);
}
void
gsk_gpu_blur_op (GskGpuFrame *frame,
GskGpuShaderClip clip,
GdkColorState *ccs,
float opacity,
GskGpuColorStates color_states,
const graphene_point_t *offset,
const GskGpuShaderImage *image,
const graphene_vec2_t *blur_direction)
{
GdkColor blur_color;
gdk_color_init (&blur_color, ccs, (float[]) { 1, 1, 1, 1 });
gsk_gpu_blur_op_full (frame,
clip,
ccs,
opacity,
offset,
color_states,
0,
offset,
image,
blur_direction,
&blur_color);
gdk_color_finish (&blur_color);
(float[4]) { 1, 1, 1, 1 });
}
void
gsk_gpu_blur_shadow_op (GskGpuFrame *frame,
GskGpuShaderClip clip,
GdkColorState *ccs,
float opacity,
GskGpuColorStates color_states,
const graphene_point_t *offset,
const GskGpuShaderImage *image,
const graphene_vec2_t *blur_direction,
const GdkColor *shadow_color)
float shadow_color[4])
{
gsk_gpu_blur_op_full (frame,
clip,
ccs,
opacity,
offset,
color_states,
VARIATION_COLORIZE,
offset,
image,
blur_direction,
shadow_color);
+3 -5
View File
@@ -8,20 +8,18 @@ G_BEGIN_DECLS
void gsk_gpu_blur_op (GskGpuFrame *frame,
GskGpuShaderClip clip,
GdkColorState *ccs,
float opacity,
GskGpuColorStates color_states,
const graphene_point_t *offset,
const GskGpuShaderImage *image,
const graphene_vec2_t *blur_direction);
void gsk_gpu_blur_shadow_op (GskGpuFrame *frame,
GskGpuShaderClip clip,
GdkColorState *ccs,
float opacity,
GskGpuColorStates color_states,
const graphene_point_t *offset,
const GskGpuShaderImage *image,
const graphene_vec2_t *blur_direction,
const GdkColor *shadow_color);
float shadow_color[4]);
G_END_DECLS
+5 -15
View File
@@ -97,29 +97,19 @@ static const GskGpuShaderOpClass GSK_GPU_BORDER_OP_CLASS = {
void
gsk_gpu_border_op (GskGpuFrame *frame,
GskGpuShaderClip clip,
GdkColorState *ccs,
float opacity,
const graphene_point_t *offset,
GskGpuColorStates color_states,
const GskRoundedRect *outline,
const graphene_point_t *offset,
const graphene_point_t *inside_offset,
const float widths[4],
const GdkColor colors[4])
const float colors[4][4])
{
GskGpuBorderInstance *instance;
guint i;
GdkColorState *alt;
if (GDK_IS_DEFAULT_COLOR_STATE (colors[0].color_state) &&
gdk_color_state_equal (colors[0].color_state, colors[1].color_state) &&
gdk_color_state_equal (colors[0].color_state, colors[2].color_state) &&
gdk_color_state_equal (colors[0].color_state, colors[3].color_state))
alt = colors[0].color_state;
else
alt = ccs;
gsk_gpu_shader_op_alloc (frame,
&GSK_GPU_BORDER_OP_CLASS,
gsk_gpu_color_states_create (ccs, TRUE, alt, FALSE),
color_states,
0,
clip,
NULL,
@@ -131,7 +121,7 @@ gsk_gpu_border_op (GskGpuFrame *frame,
for (i = 0; i < 4; i++)
{
instance->border_widths[i] = widths[i];
gsk_gpu_color_to_float (&colors[i], alt, opacity, &instance->border_colors[4 * i]);
gsk_gpu_vec4_to_float (colors[i], &instance->border_colors[4 * i]);
}
instance->offset[0] = inside_offset->x;
instance->offset[1] = inside_offset->y;
+3 -5
View File
@@ -2,7 +2,6 @@
#include "gskgputypesprivate.h"
#include "gsktypes.h"
#include "gdkcolorprivate.h"
#include <graphene.h>
@@ -10,13 +9,12 @@ G_BEGIN_DECLS
void gsk_gpu_border_op (GskGpuFrame *frame,
GskGpuShaderClip clip,
GdkColorState *ccs,
float opacity,
const graphene_point_t *offset,
GskGpuColorStates color_states,
const GskRoundedRect *outline,
const graphene_point_t *offset,
const graphene_point_t *inside_offset,
const float widths[4],
const GdkColor colors[4]);
const float colors[4][4]);
G_END_DECLS
+5 -9
View File
@@ -76,28 +76,24 @@ static const GskGpuShaderOpClass GSK_GPU_BOX_SHADOW_OP_CLASS = {
void
gsk_gpu_box_shadow_op (GskGpuFrame *frame,
GskGpuShaderClip clip,
GdkColorState *ccs,
float opacity,
const graphene_point_t *offset,
GskGpuColorStates color_states,
gboolean inset,
const graphene_rect_t *bounds,
const GskRoundedRect *outline,
const graphene_point_t *shadow_offset,
float spread,
float blur_radius,
const GdkColor *color)
const graphene_point_t *offset,
const float color[4])
{
GskGpuBoxshadowInstance *instance;
GdkColorState *alt;
/* Use border shader for no blurring */
g_return_if_fail (blur_radius > 0.0f);
alt = gsk_gpu_color_states_find (ccs, color);
gsk_gpu_shader_op_alloc (frame,
&GSK_GPU_BOX_SHADOW_OP_CLASS,
gsk_gpu_color_states_create (ccs, TRUE, alt, FALSE),
color_states,
inset ? VARIATION_INSET : 0,
clip,
NULL,
@@ -106,7 +102,7 @@ gsk_gpu_box_shadow_op (GskGpuFrame *frame,
gsk_gpu_rect_to_float (bounds, offset, instance->bounds);
gsk_rounded_rect_to_float (outline, offset, instance->outline);
gsk_gpu_color_to_float (color, alt, opacity, instance->color);
gsk_gpu_vec4_to_float (color, instance->color);
instance->shadow_offset[0] = shadow_offset->x;
instance->shadow_offset[1] = shadow_offset->y;
instance->shadow_spread = spread;
+3 -5
View File
@@ -2,7 +2,6 @@
#include "gskgputypesprivate.h"
#include "gsktypes.h"
#include "gdkcolorprivate.h"
#include <graphene.h>
@@ -10,16 +9,15 @@ G_BEGIN_DECLS
void gsk_gpu_box_shadow_op (GskGpuFrame *frame,
GskGpuShaderClip clip,
GdkColorState *ccs,
float opacity,
const graphene_point_t *offset,
GskGpuColorStates color_states,
gboolean inset,
const graphene_rect_t *bounds,
const GskRoundedRect *outline,
const graphene_point_t *shadow_offset,
float spread,
float blur_radius,
const GdkColor *color);
const graphene_point_t *offset,
const float color[4]);
G_END_DECLS
+4 -8
View File
@@ -52,20 +52,16 @@ static const GskGpuShaderOpClass GSK_GPU_COLORIZE_OP_CLASS = {
void
gsk_gpu_colorize_op (GskGpuFrame *frame,
GskGpuShaderClip clip,
GdkColorState *ccs,
float opacity,
GskGpuColorStates color_states,
const graphene_point_t *offset,
const GskGpuShaderImage *image,
const GdkColor *color)
const float color[4])
{
GskGpuColorizeInstance *instance;
GdkColorState *alt;
alt = gsk_gpu_color_states_find (ccs, color);
gsk_gpu_shader_op_alloc (frame,
&GSK_GPU_COLORIZE_OP_CLASS,
gsk_gpu_color_states_create (ccs, TRUE, alt, FALSE),
color_states,
0,
clip,
(GskGpuImage *[1]) { image->image },
@@ -74,5 +70,5 @@ gsk_gpu_colorize_op (GskGpuFrame *frame,
gsk_gpu_rect_to_float (image->coverage ? image->coverage : image->bounds, offset, instance->rect);
gsk_gpu_rect_to_float (image->bounds, offset, instance->tex_rect);
gsk_gpu_color_to_float (color, alt, opacity, instance->color);
gsk_gpu_vec4_to_float (color, instance->color);
}
+2 -3
View File
@@ -8,11 +8,10 @@ G_BEGIN_DECLS
void gsk_gpu_colorize_op (GskGpuFrame *frame,
GskGpuShaderClip clip,
GdkColorState *ccs,
float opacity,
GskGpuColorStates color_states,
const graphene_point_t *offset,
const GskGpuShaderImage *image,
const GdkColor *color);
const float color[4]);
G_END_DECLS
-4
View File
@@ -74,10 +74,6 @@ gsk_gpu_color_states_is_alt_premultiplied (GskGpuColorStates self)
return !!(self & COLOR_SPACE_ALT_PREMULTIPLIED);
}
/* Note: this function should only return a colorstate other than
* color->color_state *only* if the shaders can't handle the conversion
* from color->color_state to ccs.
*/
static inline GdkColorState *
gsk_gpu_color_states_find (GdkColorState *ccs,
const GdkColor *color)
+101 -7
View File
@@ -33,6 +33,8 @@ struct _GskGpuDownloadOp
GskGpuOp op;
GskGpuImage *image;
GdkColorState *image_cs;
GdkColorState *download_cs;
gboolean allow_dmabuf;
GdkGpuDownloadOpCreateFunc create_func;
GskGpuDownloadFunc func;
@@ -53,8 +55,60 @@ gsk_gpu_download_op_finish (GskGpuOp *op)
if (self->create_func)
self->create_func (self);
g_print ("downloaded texture: %s %.4s depth %s format %s color state %s\n",
GDK_IS_DMABUF_TEXTURE (self->texture)
? "dmabuf"
: (GDK_IS_GL_TEXTURE (self->texture)
? "gl"
: "memory"),
GDK_IS_DMABUF_TEXTURE (self->texture)
? (char *) &gdk_dmabuf_texture_get_dmabuf (GDK_DMABUF_TEXTURE (self->texture))->fourcc
: "",
gdk_memory_depth_get_name (gdk_memory_format_get_depth (gdk_texture_get_format (self->texture), FALSE)),
gdk_memory_format_get_name (gdk_texture_get_format (self->texture)),
gdk_color_state_get_name (gdk_texture_get_color_state (self->texture)));
if (!gdk_color_state_equal (gdk_texture_get_color_state (self->texture), self->download_cs))
{
GdkTextureDownloader *downloader;
GdkMemoryTextureBuilder *builder;
GBytes *bytes;
gsize stride;
GdkTexture *texture;
g_print ("converting rendered %s texture after download: %s -> %s\n",
GDK_IS_DMABUF_TEXTURE (self->texture) ? "dmabuf" :
(GDK_IS_GL_TEXTURE (self->texture) ? "gl" : "memory"),
gdk_color_state_get_name (gdk_texture_get_color_state (self->texture)),
gdk_color_state_get_name (self->download_cs));
downloader = gdk_texture_downloader_new (self->texture);
gdk_texture_downloader_set_format (downloader, gdk_texture_get_format (self->texture));
gdk_texture_downloader_set_color_state (downloader, self->download_cs);
bytes = gdk_texture_downloader_download_bytes (downloader, &stride);
gdk_texture_downloader_free (downloader);
builder = gdk_memory_texture_builder_new ();
gdk_memory_texture_builder_set_bytes (builder, bytes);
gdk_memory_texture_builder_set_stride (builder, stride);
gdk_memory_texture_builder_set_width (builder, gdk_texture_get_width (self->texture));
gdk_memory_texture_builder_set_height (builder, gdk_texture_get_height (self->texture));
gdk_memory_texture_builder_set_format (builder, gdk_texture_get_format (self->texture));
gdk_memory_texture_builder_set_color_state (builder, self->download_cs);
texture = gdk_memory_texture_builder_build (builder);
g_object_unref (builder);
g_set_object (&self->texture, texture);
g_bytes_unref (bytes);
g_object_unref (texture);
}
self->func (self->user_data, self->texture);
gdk_color_state_unref (self->image_cs);
gdk_color_state_unref (self->download_cs);
g_object_unref (self->texture);
g_object_unref (self->image);
g_clear_object (&self->buffer);
@@ -70,6 +124,7 @@ gsk_gpu_download_op_print (GskGpuOp *op,
gsk_gpu_print_op (string, indent, "download");
gsk_gpu_print_image (string, self->image);
gsk_gpu_print_string (string, gdk_color_state_get_name (self->download_cs));
gsk_gpu_print_newline (string);
}
@@ -118,6 +173,7 @@ gsk_gpu_download_op_vk_create (GskGpuDownloadOp *self)
guchar *data;
gsize width, height, stride;
GdkMemoryFormat format;
GdkMemoryTextureBuilder *builder;
data = gsk_gpu_buffer_map (self->buffer);
width = gsk_gpu_image_get_width (self->image);
@@ -125,11 +181,18 @@ gsk_gpu_download_op_vk_create (GskGpuDownloadOp *self)
format = gsk_gpu_image_get_format (self->image);
stride = width * gdk_memory_format_bytes_per_pixel (format);
bytes = g_bytes_new (data, stride * height);
self->texture = gdk_memory_texture_new (width,
height,
format,
bytes,
stride);
builder = gdk_memory_texture_builder_new ();
gdk_memory_texture_builder_set_bytes (builder, bytes);
gdk_memory_texture_builder_set_stride (builder, stride);
gdk_memory_texture_builder_set_width (builder, width);
gdk_memory_texture_builder_set_height (builder, height);
gdk_memory_texture_builder_set_format (builder, format);
gdk_memory_texture_builder_set_color_state (builder, self->image_cs);
self->texture = gdk_memory_texture_builder_build (builder);
g_object_unref (builder);
g_bytes_unref (bytes);
gsk_gpu_buffer_unmap (self->buffer, 0);
}
@@ -144,7 +207,17 @@ gsk_gpu_download_op_vk_command (GskGpuOp *op,
#ifdef HAVE_DMABUF
if (self->allow_dmabuf)
self->texture = gsk_vulkan_image_to_dmabuf_texture (GSK_VULKAN_IMAGE (self->image));
{
GdkColorState *cs;
if (gsk_gpu_image_get_flags (self->image) & GSK_GPU_IMAGE_SRGB)
cs = GDK_COLOR_STATE_SRGB;
else
cs = self->image_cs;
self->texture = gsk_vulkan_image_to_dmabuf_texture (GSK_VULKAN_IMAGE (self->image), cs);
}
if (self->texture)
{
GskGpuDevice *device = gsk_gpu_frame_get_device (frame);
@@ -295,10 +368,16 @@ gsk_gpu_download_op_gl_command (GskGpuOp *op,
GskGLTextureData *data;
GdkGLContext *context;
guint texture_id;
GdkColorState *cs;
context = GDK_GL_CONTEXT (gsk_gpu_frame_get_context (frame));
texture_id = gsk_gl_image_steal_texture (GSK_GL_IMAGE (self->image));
if (gsk_gpu_image_get_flags (self->image) & GSK_GPU_IMAGE_SRGB)
cs = GDK_COLOR_STATE_SRGB_LINEAR;
else
cs = self->image_cs;
#ifdef HAVE_DMABUF
if (self->allow_dmabuf)
{
@@ -317,12 +396,20 @@ gsk_gpu_download_op_gl_command (GskGpuOp *op,
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);
gdk_dmabuf_texture_builder_set_color_state (db, cs);
g_print ("dmabuf downloader color state: %s\n", gdk_color_state_get_name (gdk_dmabuf_texture_builder_get_color_state (db)));
self->texture = gdk_dmabuf_texture_builder_build (db,
release_dmabuf_texture,
texture,
NULL);
g_object_unref (db);
if (self->texture)
return op->next;
else
g_print ("failed to build dmabuf texture\n");
}
g_free (texture);
@@ -343,6 +430,7 @@ gsk_gpu_download_op_gl_command (GskGpuOp *op,
gdk_gl_texture_builder_set_width (builder, gsk_gpu_image_get_width (self->image));
gdk_gl_texture_builder_set_height (builder, gsk_gpu_image_get_height (self->image));
gdk_gl_texture_builder_set_sync (builder, data->sync);
gdk_gl_texture_builder_set_color_state (builder, cs);
self->texture = gdk_gl_texture_builder_build (builder,
gsk_gl_texture_data_free,
@@ -367,6 +455,8 @@ static const GskGpuOpClass GSK_GPU_DOWNLOAD_OP_CLASS = {
void
gsk_gpu_download_op (GskGpuFrame *frame,
GskGpuImage *image,
GdkColorState *image_cs,
GdkColorState *download_cs,
gboolean allow_dmabuf,
GskGpuDownloadFunc func,
gpointer user_data)
@@ -377,6 +467,10 @@ gsk_gpu_download_op (GskGpuFrame *frame,
self->image = g_object_ref (image);
self->allow_dmabuf = allow_dmabuf;
self->image_cs = gdk_color_state_ref (image_cs);
self->download_cs = gdk_color_state_ref (download_cs);
self->func = func,
self->user_data = user_data;
}
+2
View File
@@ -9,6 +9,8 @@ typedef void (* GskGpuDownloadFunc) (gpointe
void gsk_gpu_download_op (GskGpuFrame *frame,
GskGpuImage *image,
GdkColorState *image_cs,
GdkColorState *download_cs,
gboolean allow_dmabuf,
GskGpuDownloadFunc func,
gpointer user_data);
+53 -15
View File
@@ -78,20 +78,19 @@ gsk_gpu_frame_default_cleanup (GskGpuFrame *self)
}
static void
gsk_gpu_frame_default_begin (GskGpuFrame *self,
GdkDrawContext *context,
GdkMemoryDepth depth,
const cairo_region_t *region,
const graphene_rect_t *opaque)
gsk_gpu_frame_default_begin (GskGpuFrame *self,
GdkDrawContext *context,
GdkMemoryDepth depth,
const cairo_region_t *region)
{
gdk_draw_context_begin_frame_full (context, depth, region, opaque);
gdk_draw_context_begin_frame_full (context, depth, region);
}
static void
gsk_gpu_frame_default_end (GskGpuFrame *self,
GdkDrawContext *context)
{
gdk_draw_context_end_frame_full (context);
gdk_draw_context_end_frame (context);
}
static void
@@ -203,10 +202,9 @@ void
gsk_gpu_frame_begin (GskGpuFrame *self,
GdkDrawContext *context,
GdkMemoryDepth depth,
const cairo_region_t *region,
const graphene_rect_t *opaque)
const cairo_region_t *region)
{
GSK_GPU_FRAME_GET_CLASS (self)->begin (self, context, depth, region, opaque);
GSK_GPU_FRAME_GET_CLASS (self)->begin (self, context, depth, region);
}
void
@@ -634,7 +632,7 @@ gsk_gpu_frame_record (GskGpuFrame *self,
gint64 timestamp,
GskGpuImage *target,
GdkColorState *target_color_state,
cairo_region_t *clip,
const cairo_region_t *clip,
GskRenderNode *node,
const graphene_rect_t *viewport,
GdkTexture **texture)
@@ -645,10 +643,48 @@ gsk_gpu_frame_record (GskGpuFrame *self,
priv->timestamp = timestamp;
gsk_gpu_cache_set_time (gsk_gpu_device_get_cache (priv->device), timestamp);
gsk_gpu_node_processor_process (self, target, target_color_state, clip, node, viewport, pass_type);
if (clip)
{
int i;
for (i = 0; i < cairo_region_num_rectangles (clip); i++)
{
cairo_rectangle_int_t rect;
cairo_region_get_rectangle (clip, i, &rect);
gsk_gpu_node_processor_process (self, target, target_color_state, &rect, node, viewport, pass_type);
}
}
else
{
gsk_gpu_node_processor_process (self,
target,
target_color_state,
&(cairo_rectangle_int_t) {
0, 0,
gsk_gpu_image_get_width (target),
gsk_gpu_image_get_height (target)
},
node,
viewport,
pass_type);
}
if (texture)
gsk_gpu_download_op (self, target, TRUE, copy_texture, texture);
{
GdkColorState *image_cs;
GdkColorState *download_cs;
image_cs = gdk_color_state_get_rendering_color_state (target_color_state,
gsk_gpu_image_get_flags (target) & GSK_GPU_IMAGE_SRGB);
if (image_cs == GDK_COLOR_STATE_SRGB_LINEAR)
download_cs = GDK_COLOR_STATE_SRGB;
else
download_cs = image_cs;
gsk_gpu_download_op (self, target, target_color_state, download_cs, TRUE, copy_texture, texture);
}
}
static void
@@ -687,7 +723,7 @@ gsk_gpu_frame_render (GskGpuFrame *self,
gint64 timestamp,
GskGpuImage *target,
GdkColorState *target_color_state,
cairo_region_t *clip,
const cairo_region_t *region,
GskRenderNode *node,
const graphene_rect_t *viewport,
GdkTexture **texture)
@@ -696,7 +732,7 @@ gsk_gpu_frame_render (GskGpuFrame *self,
gsk_gpu_frame_cleanup (self);
gsk_gpu_frame_record (self, timestamp, target, target_color_state, clip, node, viewport, texture);
gsk_gpu_frame_record (self, timestamp, target, target_color_state, region, node, viewport, texture);
gsk_gpu_frame_submit (self, pass_type);
}
@@ -755,6 +791,8 @@ gsk_gpu_frame_download_texture (GskGpuFrame *self,
gsk_gpu_download_op (self,
image,
gdk_texture_get_color_state (texture),
color_state,
FALSE,
do_download,
g_memdup (&(Download) {
+3 -5
View File
@@ -30,8 +30,7 @@ struct _GskGpuFrameClass
void (* begin) (GskGpuFrame *self,
GdkDrawContext *context,
GdkMemoryDepth depth,
const cairo_region_t *region,
const graphene_rect_t *opaque);
const cairo_region_t *region);
void (* end) (GskGpuFrame *self,
GdkDrawContext *context);
GskGpuImage * (* upload_texture) (GskGpuFrame *self,
@@ -67,8 +66,7 @@ gsize gsk_gpu_frame_get_texture_vertex_size (GskGpuF
void gsk_gpu_frame_begin (GskGpuFrame *self,
GdkDrawContext *context,
GdkMemoryDepth depth,
const cairo_region_t *region,
const graphene_rect_t *opaque);
const cairo_region_t *region);
void gsk_gpu_frame_end (GskGpuFrame *self,
GdkDrawContext *context);
@@ -104,7 +102,7 @@ void gsk_gpu_frame_render (GskGpuF
gint64 timestamp,
GskGpuImage *target,
GdkColorState *target_color_state,
cairo_region_t *clip,
const cairo_region_t *region,
GskRenderNode *node,
const graphene_rect_t *viewport,
GdkTexture **texture);
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -8,7 +8,7 @@ G_BEGIN_DECLS
void gsk_gpu_node_processor_process (GskGpuFrame *frame,
GskGpuImage *target,
GdkColorState *target_color_state,
cairo_region_t *clip,
const cairo_rectangle_int_t *clip,
GskRenderNode *node,
const graphene_rect_t *viewport,
GskRenderPassType pass_type);
+21 -33
View File
@@ -264,7 +264,6 @@ gsk_gpu_renderer_fallback_render_texture (GskGpuRenderer *self,
guchar *data;
GdkTexture *texture;
GdkTextureDownloader downloader;
cairo_region_t *clip_region;
GskGpuFrame *frame;
max_size = gsk_gpu_device_get_max_image_size (priv->device);
@@ -300,22 +299,14 @@ gsk_gpu_renderer_fallback_render_texture (GskGpuRenderer *self,
MIN (image_width, width - x),
MIN (image_height, height - y));
if (gsk_gpu_image_get_flags (image) & GSK_GPU_IMAGE_SRGB)
color_state = GDK_COLOR_STATE_SRGB_LINEAR;
else
color_state = GDK_COLOR_STATE_SRGB;
color_state = GDK_COLOR_STATE_SRGB;
clip_region = cairo_region_create_rectangle (&(cairo_rectangle_int_t) {
0, 0,
gsk_gpu_image_get_width (image),
gsk_gpu_image_get_height (image)
});
frame = gsk_gpu_renderer_create_frame (self);
gsk_gpu_frame_render (frame,
g_get_monotonic_time (),
image,
color_state,
clip_region,
NULL,
root,
&GRAPHENE_RECT_INIT (rounded_viewport->origin.x + x,
rounded_viewport->origin.y + y,
@@ -358,7 +349,7 @@ gsk_gpu_renderer_render_texture (GskRenderer *renderer,
GdkTexture *texture;
graphene_rect_t rounded_viewport;
GdkColorState *color_state;
cairo_region_t *clip_region;
GdkMemoryDepth depth;
gsk_gpu_device_maybe_gc (priv->device);
@@ -368,33 +359,34 @@ gsk_gpu_renderer_render_texture (GskRenderer *renderer,
viewport->origin.y,
ceil (viewport->size.width),
ceil (viewport->size.height));
if (gsk_render_node_is_hdr (root))
color_state = GDK_COLOR_STATE_REC2100_PQ;
else
color_state = GDK_COLOR_STATE_SRGB;
depth = gdk_memory_depth_merge (gsk_render_node_get_preferred_depth (root),
gdk_color_state_get_depth (color_state));
image = gsk_gpu_device_create_download_image (priv->device,
gsk_render_node_get_preferred_depth (root),
depth,
rounded_viewport.size.width,
rounded_viewport.size.height);
if (image == NULL)
return gsk_gpu_renderer_fallback_render_texture (self, root, &rounded_viewport);
if (gsk_gpu_image_get_flags (image) & GSK_GPU_IMAGE_SRGB)
color_state = GDK_COLOR_STATE_SRGB_LINEAR;
else
color_state = GDK_COLOR_STATE_SRGB;
g_print ("render_texture: image depth %s, target color state %s\n",
gdk_memory_depth_get_name (depth), gdk_color_state_get_name (color_state));
frame = gsk_gpu_renderer_create_frame (self);
clip_region = cairo_region_create_rectangle (&(cairo_rectangle_int_t) {
0, 0,
gsk_gpu_image_get_width (image),
gsk_gpu_image_get_height (image)
});
texture = NULL;
gsk_gpu_frame_render (frame,
g_get_monotonic_time (),
image,
color_state,
clip_region,
NULL,
root,
&rounded_viewport,
&texture);
@@ -420,8 +412,6 @@ gsk_gpu_renderer_render (GskRenderer *renderer,
GskGpuFrame *frame;
GskGpuImage *backbuffer;
cairo_region_t *render_region;
graphene_rect_t opaque_tmp;
const graphene_rect_t *opaque;
double scale;
GdkMemoryDepth depth;
@@ -433,17 +423,13 @@ gsk_gpu_renderer_render (GskRenderer *renderer,
gsk_gpu_device_maybe_gc (priv->device);
gsk_gpu_renderer_make_current (self);
depth = gsk_render_node_get_preferred_depth (root);
frame = gsk_gpu_renderer_get_frame (self);
scale = gsk_gpu_renderer_get_scale (self);
if (gsk_render_node_get_opaque_rect (root, &opaque_tmp))
opaque = &opaque_tmp;
else
opaque = NULL;
gsk_gpu_frame_begin (frame, priv->context, depth, region, opaque);
gsk_gpu_frame_begin (frame, priv->context, depth, region);
gsk_gpu_renderer_make_current (self);
backbuffer = GSK_GPU_RENDERER_GET_CLASS (self)->get_backbuffer (self);
@@ -465,6 +451,8 @@ gsk_gpu_renderer_render (GskRenderer *renderer,
gsk_gpu_frame_end (frame, priv->context);
gsk_gpu_device_queue_gc (priv->device);
g_clear_pointer (&render_region, cairo_region_destroy);
}
static double
+6 -5
View File
@@ -45,10 +45,13 @@ gsk_ngl_renderer_create_context (GskGpuRenderer *renderer,
{
GdkGLContext *context;
if (!gdk_display_prepare_gl (display, error))
return NULL;
if (surface)
context = gdk_surface_create_gl_context (surface, error);
else
context = gdk_display_create_gl_context (display, error);
context = gdk_gl_context_new (display, surface, surface != NULL);
if (context == NULL)
return NULL;
/* GLES 2 is not supported */
gdk_gl_context_set_required_version (context, 3, 0);
@@ -139,8 +142,6 @@ gsk_ngl_renderer_unrealize (GskRenderer *renderer)
gsk_ngl_renderer_free_backbuffer (self);
gdk_gl_context_clear_current ();
GSK_RENDERER_CLASS (gsk_ngl_renderer_parent_class)->unrealize (renderer);
}
+1 -1
View File
@@ -76,7 +76,7 @@ gsk_vulkan_handle_result (VkResult res,
{
if (res != VK_SUCCESS)
{
g_warning ("%s(): %s (%d)", called_function, gdk_vulkan_strerror (res), res);
GSK_DEBUG (VULKAN, "%s(): %s (%d)", called_function, gdk_vulkan_strerror (res), res);
}
return res;
}
+5 -6
View File
@@ -148,16 +148,15 @@ gsk_vulkan_frame_cleanup (GskGpuFrame *frame)
}
static void
gsk_vulkan_frame_begin (GskGpuFrame *frame,
GdkDrawContext *context,
GdkMemoryDepth depth,
const cairo_region_t *region,
const graphene_rect_t *opaque)
gsk_vulkan_frame_begin (GskGpuFrame *frame,
GdkDrawContext *context,
GdkMemoryDepth depth,
const cairo_region_t *region)
{
GskVulkanFrame *self = GSK_VULKAN_FRAME (frame);
gdk_vulkan_context_set_draw_semaphore (GDK_VULKAN_CONTEXT (context), self->vk_acquire_semaphore);
GSK_GPU_FRAME_CLASS (gsk_vulkan_frame_parent_class)->begin (frame, context, depth, region, opaque);
GSK_GPU_FRAME_CLASS (gsk_vulkan_frame_parent_class)->begin (frame, context, depth, region);
}
static GskGpuImage *
+3 -1
View File
@@ -1176,7 +1176,8 @@ gsk_vulkan_image_get_n_planes (GskVulkanImage *self,
}
GdkTexture *
gsk_vulkan_image_to_dmabuf_texture (GskVulkanImage *self)
gsk_vulkan_image_to_dmabuf_texture (GskVulkanImage *self,
GdkColorState *color_state)
{
GskGpuImage *image = GSK_GPU_IMAGE (self);
GdkDmabufTextureBuilder *builder;
@@ -1226,6 +1227,7 @@ gsk_vulkan_image_to_dmabuf_texture (GskVulkanImage *self)
gdk_dmabuf_texture_builder_set_display (builder, gsk_gpu_device_get_display (GSK_GPU_DEVICE (self->device)));
gdk_dmabuf_texture_builder_set_width (builder, gsk_gpu_image_get_width (image));
gdk_dmabuf_texture_builder_set_height (builder, gsk_gpu_image_get_height (image));
gdk_dmabuf_texture_builder_set_color_state (builder, color_state);
gdk_dmabuf_texture_builder_set_fourcc (builder, fourcc);
gdk_dmabuf_texture_builder_set_modifier (builder, properties.drmFormatModifier);
gdk_dmabuf_texture_builder_set_premultiplied (builder, !(gsk_gpu_image_get_flags (image) & GSK_GPU_IMAGE_STRAIGHT_ALPHA));
+2 -1
View File
@@ -44,7 +44,8 @@ GskGpuImage * gsk_vulkan_image_new_for_dmabuf (GskVulk
gsize height,
const GdkDmabuf *dmabuf,
gboolean premultiplied);
GdkTexture * gsk_vulkan_image_to_dmabuf_texture (GskVulkanImage *self);
GdkTexture * gsk_vulkan_image_to_dmabuf_texture (GskVulkanImage *self,
GdkColorState *color_state);
#endif
guchar * gsk_vulkan_image_get_data (GskVulkanImage *self,
+8 -9
View File
@@ -53,8 +53,8 @@ output_color_alpha (vec4 color,
float
srgb_eotf (float v)
{
if (abs (v) >= 0.04045)
return sign (v) * pow (((abs (v) + 0.055) / (1.0 + 0.055)), 2.4);
if (v >= 0.04045)
return pow (((v + 0.055) / (1.0 + 0.055)), 2.4);
else
return v / 12.92;
}
@@ -62,8 +62,8 @@ srgb_eotf (float v)
float
srgb_oetf (float v)
{
if (abs (v) > 0.0031308)
return 1.055 * sign (v) * pow (abs (v), 1.0 / 2.4) - 0.055;
if (v > 0.0031308)
return 1.055 * pow (v, 1.0 / 2.4) - 0.055;
else
return 12.92 * v;
}
@@ -77,10 +77,9 @@ pq_eotf (float v)
const float c2 = 2413.0 / 128.0;
const float c3 = 2392.0 / 128.0;
float x = pow (abs (v), minv);
x = pow (max (x - c1, 0.0) / (c2 - (c3 * x)), ninv);
float x = pow (max ((pow (v, minv) - c1), 0.0) / (c2 - (c3 * (pow (v, minv)))), ninv);
return sign (v) * x * 10000.0 / 203.0;
return x * 10000.0 / 203.0;
}
float
@@ -92,9 +91,9 @@ pq_oetf (float v)
const float c2 = 2413.0 / 128.0;
const float c3 = 2392.0 / 128.0;
float x = pow (abs (v) * 203.0 / 10000.0, n);
float x = v * 203.0 / 10000.0;
return sign (v) * pow (((c1 + (c2 * x)) / (1.0 + (c3 * x))), m);
return pow (((c1 + (c2 * pow (x, n))) / (1.0 + (c3 * pow (x, n)))), m);
}
/* Note that these matrices are transposed from the C version */
+8 -8
View File
@@ -161,43 +161,43 @@ run (out vec2 pos)
float
bt709_eotf (float v)
{
if (abs (v) < 0.081)
if (v < 0.081)
return v / 4.5;
else
return sign (v) * pow ((abs (v) + 0.099) / 1.099, 1.0/0.45);
return pow ((v + 0.099) / 1.099, 1.0/0.45);
}
float
bt709_oetf (float v)
{
if (abs (v) < 0.081)
if (v < 0.081)
return v * 4.5;
else
return 1.099 * sign (v) * pow (abs (v), 0.45) - 0.099;
return 1.099 * pow (v, 0.45) - 0.099;
}
float
gamma22_oetf (float v)
{
return sign (v) * pow (abs (v), 1.0 / 2.2);
return pow (v, 1.0 / 2.2);
}
float
gamma22_eotf (float v)
{
return sign (v) * pow (abs (v), 2.2);
return pow (v, 2.2);
}
float
gamma28_oetf (float v)
{
return sign (v) * pow (abs (v), 1.0 / 2.8);
return pow (v, 1.0 / 2.8);
}
float
gamma28_eotf (float v)
{
return sign (v) * pow (abs (v), 2.8);
return pow (v, 2.8);
}
float
+2 -3
View File
@@ -23,7 +23,6 @@
#include "config.h"
#include "gskcairoblurprivate.h"
#include "gdkcairoprivate.h"
#include "gdkcairoprivate.h"
@@ -378,7 +377,7 @@ cairo_t *
gsk_cairo_blur_finish_drawing (cairo_t *cr,
GdkColorState *ccs,
float radius,
const GdkColor *color,
const GdkRGBA *color,
GskBlurFlags blur_flags)
{
cairo_t *original_cr;
@@ -398,7 +397,7 @@ gsk_cairo_blur_finish_drawing (cairo_t *cr,
gsk_cairo_blur_surface (surface, x_scale * radius, blur_flags);
gdk_cairo_set_source_color (original_cr, ccs, color);
gdk_cairo_set_source_rgba_ccs (original_cr, ccs, color);
if (blur_flags & GSK_BLUR_REPEAT)
mask_surface_repeat (original_cr, surface);
else
+2 -3
View File
@@ -25,7 +25,6 @@
#include <gdk/gdk.h>
#include <cairo.h>
#include "gdkcolorprivate.h"
G_BEGIN_DECLS
@@ -38,7 +37,7 @@ typedef enum {
void gsk_cairo_blur_surface (cairo_surface_t *surface,
double radius,
GskBlurFlags flags);
GskBlurFlags flags);
int gsk_cairo_blur_compute_pixels (double radius) G_GNUC_CONST;
cairo_t * gsk_cairo_blur_start_drawing (cairo_t *cr,
@@ -47,7 +46,7 @@ cairo_t * gsk_cairo_blur_start_drawing (cairo_t *cr,
cairo_t * gsk_cairo_blur_finish_drawing (cairo_t *cr,
GdkColorState *ccs,
float radius,
const GdkColor *color,
const GdkRGBA *color,
GskBlurFlags blur_flags);
G_END_DECLS
+3 -11
View File
@@ -159,18 +159,10 @@ gsk_cairo_renderer_render (GskRenderer *renderer,
const cairo_region_t *region)
{
GskCairoRenderer *self = GSK_CAIRO_RENDERER (renderer);
graphene_rect_t opaque_tmp;
const graphene_rect_t *opaque;
cairo_t *cr;
if (gsk_render_node_get_opaque_rect (root, &opaque_tmp))
opaque = &opaque_tmp;
else
opaque = NULL;
gdk_draw_context_begin_frame_full (GDK_DRAW_CONTEXT (self->cairo_context),
GDK_MEMORY_U8,
region,
opaque);
gdk_draw_context_begin_frame (GDK_DRAW_CONTEXT (self->cairo_context),
region);
cr = gdk_cairo_context_cairo_create (self->cairo_context);
g_return_if_fail (cr != NULL);
@@ -196,7 +188,7 @@ gsk_cairo_renderer_render (GskRenderer *renderer,
cairo_destroy (cr);
gdk_draw_context_end_frame_full (GDK_DRAW_CONTEXT (self->cairo_context));
gdk_draw_context_end_frame (GDK_DRAW_CONTEXT (self->cairo_context));
}
static void
-1
View File
@@ -15,7 +15,6 @@ static const GdkDebugKey gsk_debug_keys[] = {
{ "staging", GSK_DEBUG_STAGING, "Use a staging image for texture upload (Vulkan only)" },
{ "offload-disable", GSK_DEBUG_OFFLOAD_DISABLE, "Disable graphics offload" },
{ "cairo", GSK_DEBUG_CAIRO, "Overlay error pattern over Cairo drawing (finds fallbacks)" },
{ "occlusion", GSK_DEBUG_OCCLUSION, "Overlay highlight over areas optimized via occlusion culling" },
};
static guint gsk_debug_flags;
-1
View File
@@ -18,7 +18,6 @@ typedef enum {
GSK_DEBUG_STAGING = 1 << 10,
GSK_DEBUG_OFFLOAD_DISABLE = 1 << 11,
GSK_DEBUG_CAIRO = 1 << 12,
GSK_DEBUG_OCCLUSION = 1 << 13,
} GskDebugFlags;
#define GSK_DEBUG_ANY ((1 << 13) - 1)
-12
View File
@@ -5,8 +5,6 @@
#include <graphene.h>
#include <math.h>
#define GSK_RECT_INIT_CAIRO(cairo_rect) GRAPHENE_RECT_INIT((cairo_rect)->x, (cairo_rect)->y, (cairo_rect)->width, (cairo_rect)->height)
static inline void
gsk_rect_init (graphene_rect_t *r,
float x,
@@ -187,16 +185,6 @@ gsk_rect_to_cairo_grow (const graphene_rect_t *graphene,
cairo->height = ceilf (graphene->origin.y + graphene->size.height) - cairo->y;
}
static inline void
gsk_rect_to_cairo_shrink (const graphene_rect_t *graphene,
cairo_rectangle_int_t *cairo)
{
cairo->x = ceilf (graphene->origin.x);
cairo->y = ceilf (graphene->origin.y);
cairo->width = floorf (graphene->origin.x + graphene->size.width) - cairo->x;
cairo->height = floorf (graphene->origin.y + graphene->size.height) - cairo->y;
}
static inline gboolean
gsk_rect_equal (const graphene_rect_t *r1,
const graphene_rect_t *r2)
+3 -3
View File
@@ -380,7 +380,7 @@ gsk_render_node_draw_ccs (GskRenderNode *node,
GdkColorState *ccs)
{
/* Check that the calling function did pass a correct color state */
g_assert (ccs == gdk_color_state_get_rendering_color_state (ccs));
g_assert (ccs == gdk_color_state_get_rendering_color_state (ccs, FALSE));
cairo_save (cr);
@@ -413,7 +413,7 @@ gsk_render_node_draw_with_color_state (GskRenderNode *node,
{
GdkColorState *ccs;
ccs = gdk_color_state_get_rendering_color_state (color_state);
ccs = gdk_color_state_get_rendering_color_state (color_state, FALSE);
if (gdk_color_state_equal (color_state, ccs))
{
@@ -615,7 +615,7 @@ gsk_render_node_diff (GskRenderNode *node1,
/**
* gsk_render_node_get_opaque_rect:
* @self: a `GskRenderNode`
* @out_opaque: (out): return location for the opaque rect
* @out_opaque: (out):
*
* Gets an opaque rectangle inside the node that GTK can determine to
* be fully opaque.
+1 -1
View File
@@ -124,7 +124,7 @@ void gsk_render_node_get_bounds (GskRenderNode
GDK_AVAILABLE_IN_4_16
gboolean gsk_render_node_get_opaque_rect (GskRenderNode *self,
graphene_rect_t *out_opaque) G_GNUC_WARN_UNUSED_RESULT;
graphene_rect_t *out_opaque);
GDK_AVAILABLE_IN_ALL
void gsk_render_node_draw (GskRenderNode *node,
+107 -492
View File
File diff suppressed because it is too large Load Diff
+133 -159
View File
@@ -493,6 +493,14 @@ parse_rounded_rect (GtkCssParser *parser,
return TRUE;
}
static gboolean
parse_color (GtkCssParser *parser,
Context *context,
gpointer out_color)
{
return gdk_rgba_parser_parse (parser, out_color);
}
static gboolean
parse_double (GtkCssParser *parser,
Context *context,
@@ -516,33 +524,6 @@ parse_positive_double (GtkCssParser *parser,
return gtk_css_parser_consume_number (parser, out_double);
}
static gboolean
parse_strictly_positive_double (GtkCssParser *parser,
Context *context,
gpointer out_double)
{
double tmp;
if (gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_SIGNED_NUMBER)
|| gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_SIGNED_INTEGER))
{
gtk_css_parser_error_syntax (parser, "Expected a strictly positive number");
return FALSE;
}
if (!gtk_css_parser_consume_number (parser, &tmp))
return FALSE;
if (tmp == 0)
{
gtk_css_parser_error_syntax (parser, "Expected a strictly positive number");
return FALSE;
}
*(double *) out_double = tmp;
return TRUE;
}
static gboolean
parse_point (GtkCssParser *parser,
Context *context,
@@ -712,9 +693,33 @@ parse_float4 (GtkCssParser *parser,
return TRUE;
}
static gboolean parse_color2 (GtkCssParser *parser,
Context *context,
gpointer color);
static gboolean
parse_colors4 (GtkCssParser *parser,
Context *context,
gpointer out_colors)
{
GdkRGBA colors[4];
int i;
for (i = 0; i < 4 && !gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_EOF); i ++)
{
if (!gdk_rgba_parser_parse (parser, &colors[i]))
return FALSE;
}
if (i == 0)
{
gtk_css_parser_error_syntax (parser, "Expected a color");
return FALSE;
}
for (; i < 4; i++)
{
colors[i] = colors[(i - 1) >> 1];
}
memcpy (out_colors, colors, sizeof (GdkRGBA) * 4);
return TRUE;
}
static gboolean
parse_shadows (GtkCssParser *parser,
@@ -725,11 +730,10 @@ parse_shadows (GtkCssParser *parser,
do
{
GskShadow2 shadow;
GdkColor color = GDK_COLOR_SRGB (0, 0, 0, 1);
GskShadow shadow = { GDK_RGBA("000000"), 0, 0, 0 };
double dx = 0, dy = 0, radius = 0;
if (!parse_color2 (parser, context, &color))
if (!gdk_rgba_parser_parse (parser, &shadow.color))
gtk_css_parser_error_value (parser, "Expected shadow color");
if (!gtk_css_parser_consume_number (parser, &dx))
@@ -744,13 +748,11 @@ parse_shadows (GtkCssParser *parser,
gtk_css_parser_error_value (parser, "Expected shadow blur radius");
}
gdk_color_init_copy (&shadow.color, &color);
graphene_point_init (&shadow.offset, dx, dy);
shadow.dx = dx;
shadow.dy = dy;
shadow.radius = radius;
g_array_append_val (shadows, shadow);
gdk_color_finish (&color);
}
while (gtk_css_parser_try_token (parser, GTK_CSS_TOKEN_COMMA));
@@ -760,15 +762,7 @@ parse_shadows (GtkCssParser *parser,
static void
clear_shadows (gpointer inout_shadows)
{
GArray *shadows = inout_shadows;
for (gsize i = 0; i < shadows->len; i++)
{
GskShadow2 *shadow = &g_array_index (shadows, GskShadow2, i);
gdk_color_finish (&shadow->color);
}
g_array_set_size (shadows, 0);
g_array_set_size (inout_shadows, 0);
}
static const struct
@@ -1471,6 +1465,12 @@ create_default_path (void)
return gsk_path_builder_free_to_path (builder);
}
typedef struct
{
GdkColorState *color_state;
float values[4];
} Color;
static gboolean
parse_cicp_range (GtkCssParser *parser,
Context *context,
@@ -1606,6 +1606,35 @@ parse_color_state (GtkCssParser *parser,
return TRUE;
}
static gboolean
gtk_css_parser_consume_number_or_percentage (GtkCssParser *parser,
double min,
double max,
double *value)
{
if (gtk_css_parser_has_percentage (parser))
{
double number;
gtk_css_parser_consume_percentage (parser, &number);
*value = min + (number / 100.0) * (max - min);
return TRUE;
}
else if (gtk_css_parser_has_number (parser))
{
double number;
gtk_css_parser_consume_number (parser, &number);
*value = number;
return TRUE;
}
else
{
gtk_css_parser_error_syntax (parser, "Expected a number or percentage");
return FALSE;
}
}
typedef struct {
Context *context;
GdkColor *color;
@@ -1676,34 +1705,6 @@ parse_color2 (GtkCssParser *parser,
return FALSE;
}
static gboolean
parse_colors4 (GtkCssParser *parser,
Context *context,
gpointer out_colors)
{
GdkColor colors[4];
int i;
for (i = 0; i < 4 && !gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_EOF); i ++)
{
if (!parse_color2 (parser, context, &colors[i]))
return FALSE;
}
if (i == 0)
{
gtk_css_parser_error_syntax (parser, "Expected a color");
return FALSE;
}
for (; i < 4; i++)
{
colors[i] = colors[(i - 1) >> 1];
}
memcpy (out_colors, colors, sizeof (GdkColor) * 4);
return TRUE;
}
static GskRenderNode *
parse_color_node (GtkCssParser *parser,
Context *context)
@@ -1792,8 +1793,8 @@ parse_radial_gradient_node_internal (GtkCssParser *parser,
const Declaration declarations[] = {
{ "bounds", parse_rect, NULL, &bounds },
{ "center", parse_point, NULL, &center },
{ "hradius", parse_strictly_positive_double, NULL, &hradius },
{ "vradius", parse_strictly_positive_double, NULL, &vradius },
{ "hradius", parse_positive_double, NULL, &hradius },
{ "vradius", parse_positive_double, NULL, &vradius },
{ "start", parse_positive_double, NULL, &start },
{ "end", parse_positive_double, NULL, &end },
{ "stops", parse_stops, clear_stops, &stops },
@@ -1811,16 +1812,7 @@ parse_radial_gradient_node_internal (GtkCssParser *parser,
g_array_append_val (stops, to);
}
if (end <= start)
{
gtk_css_parser_error (parser,
GTK_CSS_PARSER_ERROR_UNKNOWN_VALUE,
gtk_css_parser_get_block_location (parser),
gtk_css_parser_get_end_location (parser),
"\"start\" must be larger than \"end\"");
result = NULL;
}
else if (repeating)
if (repeating)
result = gsk_repeating_radial_gradient_node_new (&bounds, &center, hradius, vradius, start, end,
(GskColorStop *) stops->data, stops->len);
else
@@ -1886,25 +1878,20 @@ parse_inset_shadow_node (GtkCssParser *parser,
Context *context)
{
GskRoundedRect outline = GSK_ROUNDED_RECT_INIT (0, 0, 50, 50);
GdkColor color = GDK_COLOR_SRGB (0, 0, 0, 1);
GdkRGBA color = GDK_RGBA("000000");
double dx = 1, dy = 1, blur = 0, spread = 0;
const Declaration declarations[] = {
{ "outline", parse_rounded_rect, NULL, &outline },
{ "color", parse_color2, NULL, &color },
{ "color", parse_color, NULL, &color },
{ "dx", parse_double, NULL, &dx },
{ "dy", parse_double, NULL, &dy },
{ "spread", parse_double, NULL, &spread },
{ "blur", parse_positive_double, NULL, &blur }
};
GskRenderNode *node;
parse_declarations (parser, context, declarations, G_N_ELEMENTS (declarations));
node = gsk_inset_shadow_node_new2 (&outline, &color, &GRAPHENE_POINT_INIT (dx, dy), spread, blur);
gdk_color_finish (&color);
return node;
return gsk_inset_shadow_node_new (&outline, &color, dx, dy, spread, blur);
}
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
@@ -2186,21 +2173,16 @@ parse_border_node (GtkCssParser *parser,
{
GskRoundedRect outline = GSK_ROUNDED_RECT_INIT (0, 0, 50, 50);
float widths[4] = { 1, 1, 1, 1 };
GdkColor colors[4] = {
GDK_COLOR_SRGB (0, 0, 0, 1),
GDK_COLOR_SRGB (0, 0, 0, 1),
GDK_COLOR_SRGB (0, 0, 0, 1),
GDK_COLOR_SRGB (0, 0, 0, 1),
};
GdkRGBA colors[4] = { GDK_RGBA("000"), GDK_RGBA("000"), GDK_RGBA("000"), GDK_RGBA("000") };
const Declaration declarations[] = {
{ "outline", parse_rounded_rect, NULL, &outline },
{ "widths", parse_float4, NULL, &widths },
{ "colors", parse_colors4, NULL, &colors },
{ "colors", parse_colors4, NULL, &colors }
};
parse_declarations (parser, context, declarations, G_N_ELEMENTS (declarations));
return gsk_border_node_new2 (&outline, widths, colors);
return gsk_border_node_new (&outline, widths, colors);
}
static GskRenderNode *
@@ -2300,25 +2282,20 @@ parse_outset_shadow_node (GtkCssParser *parser,
Context *context)
{
GskRoundedRect outline = GSK_ROUNDED_RECT_INIT (0, 0, 50, 50);
GdkColor color = GDK_COLOR_SRGB (0, 0, 0, 1);
GdkRGBA color = GDK_RGBA("000000");
double dx = 1, dy = 1, blur = 0, spread = 0;
const Declaration declarations[] = {
{ "outline", parse_rounded_rect, NULL, &outline },
{ "color", parse_color2, NULL, &color },
{ "color", parse_color, NULL, &color },
{ "dx", parse_double, NULL, &dx },
{ "dy", parse_double, NULL, &dy },
{ "spread", parse_double, NULL, &spread },
{ "blur", parse_positive_double, NULL, &blur }
};
GskRenderNode *node;
parse_declarations (parser, context, declarations, G_N_ELEMENTS (declarations));
node = gsk_outset_shadow_node_new2 (&outline, &color, &GRAPHENE_POINT_INIT (dx, dy), spread, blur);
gdk_color_finish (&color);
return node;
return gsk_outset_shadow_node_new (&outline, &color, dx, dy, spread, blur);
}
static GskRenderNode *
@@ -2606,7 +2583,7 @@ parse_text_node (GtkCssParser *parser,
{
PangoFont *font = NULL;
graphene_point_t offset = GRAPHENE_POINT_INIT (0, 0);
GdkColor color = GDK_COLOR_SRGB (0, 0, 0, 1);
GdkRGBA color = GDK_RGBA("000000");
PangoGlyphString *glyphs = NULL;
cairo_hint_style_t hint_style = CAIRO_HINT_STYLE_SLIGHT;
cairo_antialias_t antialias = CAIRO_ANTIALIAS_GRAY;
@@ -2615,7 +2592,7 @@ parse_text_node (GtkCssParser *parser,
const Declaration declarations[] = {
{ "font", parse_font, clear_font, &font },
{ "offset", parse_point, NULL, &offset },
{ "color", parse_color2, NULL, &color },
{ "color", parse_color, NULL, &color },
{ "glyphs", parse_glyphs, clear_glyphs, &glyphs },
{ "hint-style", parse_hint_style, NULL, &hint_style },
{ "antialias", parse_antialias, NULL, &antialias },
@@ -2658,7 +2635,7 @@ parse_text_node (GtkCssParser *parser,
}
else
{
result = gsk_text_node_new2 (font, glyphs, &color, &offset);
result = gsk_text_node_new (font, glyphs, &color, &offset);
if (result == NULL)
{
gtk_css_parser_error_value (parser, "Glyphs result in empty text");
@@ -2672,8 +2649,6 @@ parse_text_node (GtkCssParser *parser,
if (result == NULL)
result = create_default_render_node ();
gdk_color_finish (&color);
return result;
}
@@ -2945,10 +2920,10 @@ parse_shadow_node (GtkCssParser *parser,
Context *context)
{
GskRenderNode *child = NULL;
GArray *shadows = g_array_new (FALSE, TRUE, sizeof (GskShadow2));
GArray *shadows = g_array_new (FALSE, TRUE, sizeof (GskShadow));
const Declaration declarations[] = {
{ "child", parse_node, clear_node, &child },
{ "shadows", parse_shadows, clear_shadows, shadows },
{ "shadows", parse_shadows, clear_shadows, shadows }
};
GskRenderNode *result;
@@ -2958,13 +2933,12 @@ parse_shadow_node (GtkCssParser *parser,
if (shadows->len == 0)
{
GskShadow2 default_shadow = { GDK_COLOR_SRGB (0, 0, 0, 1), GRAPHENE_POINT_INIT (1, 1), 0 };
GskShadow default_shadow = { GDK_RGBA("000000"), 1, 1, 0 };
g_array_append_val (shadows, default_shadow);
}
result = gsk_shadow_node_new2 (child, (GskShadow2 *)shadows->data, shadows->len);
result = gsk_shadow_node_new (child, (GskShadow *)shadows->data, shadows->len);
clear_shadows (shadows);
g_array_free (shadows, TRUE);
gsk_render_node_unref (child);
@@ -3331,35 +3305,21 @@ printer_init_duplicates_for_node (Printer *printer,
{
case GSK_TEXT_NODE:
printer_init_collect_font_info (printer, node);
printer_init_check_color_state (printer, gsk_text_node_get_color2 (node)->color_state);
break;
case GSK_COLOR_NODE:
printer_init_check_color_state (printer, gsk_color_node_get_color2 (node)->color_state);
break;
case GSK_BORDER_NODE:
{
const GdkColor *colors = gsk_border_node_get_colors2 (node);
for (int i = 0; i < 4; i++)
printer_init_check_color_state (printer, colors[i].color_state);
}
break;
case GSK_INSET_SHADOW_NODE:
printer_init_check_color_state (printer, gsk_inset_shadow_node_get_color2 (node)->color_state);
break;
case GSK_OUTSET_SHADOW_NODE:
printer_init_check_color_state (printer, gsk_outset_shadow_node_get_color2 (node)->color_state);
break;
case GSK_CAIRO_NODE:
case GSK_LINEAR_GRADIENT_NODE:
case GSK_REPEATING_LINEAR_GRADIENT_NODE:
case GSK_RADIAL_GRADIENT_NODE:
case GSK_REPEATING_RADIAL_GRADIENT_NODE:
case GSK_CONIC_GRADIENT_NODE:
case GSK_BORDER_NODE:
case GSK_INSET_SHADOW_NODE:
case GSK_OUTSET_SHADOW_NODE:
/* no children */
break;
@@ -3401,11 +3361,6 @@ printer_init_duplicates_for_node (Printer *printer,
case GSK_SHADOW_NODE:
printer_init_duplicates_for_node (printer, gsk_shadow_node_get_child (node));
for (int i = 0; i < gsk_shadow_node_get_n_shadows (node); i++)
{
const GskShadow2 * shadow = gsk_shadow_node_get_shadow2 (node, i);
printer_init_check_color_state (printer, shadow->color.color_state);
}
break;
case GSK_DEBUG_NODE:
@@ -3664,6 +3619,18 @@ append_unsigned_param (Printer *p,
g_string_append_printf (p->str, "%s: %u;\n", param_name, value);
}
static void
append_rgba_param (Printer *p,
const char *param_name,
const GdkRGBA *value)
{
_indent (p);
g_string_append_printf (p->str, "%s: ", param_name);
gdk_rgba_print (value, p->str);
g_string_append_c (p->str, ';');
g_string_append_c (p->str, '\n');
}
static void
print_color (Printer *p,
const GdkColor *color)
@@ -4355,11 +4322,13 @@ render_node_print (Printer *p,
case GSK_OUTSET_SHADOW_NODE:
{
const GdkRGBA *color = gsk_outset_shadow_node_get_color (node);
start_node (p, "outset-shadow", node_name);
append_float_param (p, "blur", gsk_outset_shadow_node_get_blur_radius (node), 0.0f);
if (!gdk_color_equal (gsk_outset_shadow_node_get_color2 (node), &GDK_COLOR_SRGB (0, 0, 0, 1)))
append_color_param (p, "color", gsk_outset_shadow_node_get_color2 (node));
if (!gdk_rgba_equal (color, &GDK_RGBA("000")))
append_rgba_param (p, "color", color);
append_float_param (p, "dx", gsk_outset_shadow_node_get_dx (node), 1.0f);
append_float_param (p, "dy", gsk_outset_shadow_node_get_dy (node), 1.0f);
append_rounded_rect_param (p, "outline", gsk_outset_shadow_node_get_outline (node));
@@ -4457,18 +4426,18 @@ render_node_print (Printer *p,
case GSK_BORDER_NODE:
{
const GdkColor *colors = gsk_border_node_get_colors2 (node);
const GdkRGBA *colors = gsk_border_node_get_colors (node);
const float *widths = gsk_border_node_get_widths (node);
guint i, n;
start_node (p, "border", node_name);
if (!gdk_color_equal (&colors[3], &colors[1]))
if (!gdk_rgba_equal (&colors[3], &colors[1]))
n = 4;
else if (!gdk_color_equal (&colors[2], &colors[0]))
else if (!gdk_rgba_equal (&colors[2], &colors[0]))
n = 3;
else if (!gdk_color_equal (&colors[1], &colors[0]))
else if (!gdk_rgba_equal (&colors[1], &colors[0]))
n = 2;
else if (!gdk_color_equal (&colors[0], (&(GdkColor) { .color_state = GDK_COLOR_STATE_SRGB, .values = { 0, 0, 0, 1 } })))
else if (!gdk_rgba_equal (&colors[0], &GDK_RGBA("000000")))
n = 1;
else
n = 0;
@@ -4481,7 +4450,7 @@ render_node_print (Printer *p,
{
if (i > 0)
g_string_append_c (p->str, ' ');
print_color (p, &colors[i]);
gdk_rgba_print (&colors[i], p->str);
}
g_string_append (p->str, ";\n");
}
@@ -4527,21 +4496,25 @@ render_node_print (Printer *p,
g_string_append (p->str, "shadows: ");
for (i = 0; i < n_shadows; i ++)
{
const GskShadow2 *s = gsk_shadow_node_get_shadow2 (node, i);
const GskShadow *s = gsk_shadow_node_get_shadow (node, i);
char *color;
if (i > 0)
g_string_append (p->str, ", ");
print_color (p, &s->color);
color = gdk_rgba_to_string (&s->color);
g_string_append (p->str, color);
g_string_append_c (p->str, ' ');
string_append_double (p->str, s->offset.x);
string_append_double (p->str, s->dx);
g_string_append_c (p->str, ' ');
string_append_double (p->str, s->offset.y);
string_append_double (p->str, s->dy);
if (s->radius > 0)
{
g_string_append_c (p->str, ' ');
string_append_double (p->str, s->radius);
}
g_free (color);
}
g_string_append_c (p->str, ';');
@@ -4554,11 +4527,12 @@ render_node_print (Printer *p,
case GSK_INSET_SHADOW_NODE:
{
const GdkRGBA *color = gsk_inset_shadow_node_get_color (node);
start_node (p, "inset-shadow", node_name);
append_float_param (p, "blur", gsk_inset_shadow_node_get_blur_radius (node), 0.0f);
if (!gdk_color_equal (gsk_inset_shadow_node_get_color2 (node), &GDK_COLOR_SRGB (0, 0, 0, 1)))
append_color_param (p, "color", gsk_inset_shadow_node_get_color2 (node));
if (!gdk_rgba_equal (color, &GDK_RGBA("000")))
append_rgba_param (p, "color", color);
append_float_param (p, "dx", gsk_inset_shadow_node_get_dx (node), 1.0f);
append_float_param (p, "dy", gsk_inset_shadow_node_get_dy (node), 1.0f);
append_rounded_rect_param (p, "outline", gsk_inset_shadow_node_get_outline (node));
@@ -4607,12 +4581,12 @@ render_node_print (Printer *p,
case GSK_TEXT_NODE:
{
const graphene_point_t *offset = gsk_text_node_get_offset (node);
const GdkColor *color = gsk_text_node_get_color2 (node);
const GdkRGBA *color = gsk_text_node_get_color (node);
start_node (p, "text", node_name);
if (!gdk_color_equal (color, &GDK_COLOR_SRGB (0, 0, 0, 1)))
append_color_param (p, "color", color);
if (!gdk_rgba_equal (color, &GDK_RGBA ("000000")))
append_rgba_param (p, "color", color);
_indent (p);
g_string_append (p->str, "font: ");
+3 -45
View File
@@ -123,52 +123,10 @@ _gsk_render_node_ref (GskRenderNode *node)
return node;
}
GskRenderNode * gsk_color_node_new2 (const GdkColor *color,
const graphene_rect_t *bounds);
GskRenderNode * gsk_color_node_new2 (const GdkColor *color,
const graphene_rect_t *bounds);
const GdkColor * gsk_color_node_get_color2 (const GskRenderNode *node);
GskRenderNode * gsk_border_node_new2 (const GskRoundedRect *outline,
const float border_width[4],
const GdkColor border_color[4]);
const GdkColor * gsk_border_node_get_colors2 (const GskRenderNode *node);
GskRenderNode * gsk_inset_shadow_node_new2 (const GskRoundedRect *outline,
const GdkColor *color,
const graphene_point_t *offset,
float spread,
float blur_radius);
const GdkColor * gsk_inset_shadow_node_get_color2 (const GskRenderNode *node);
const graphene_point_t *gsk_inset_shadow_node_get_offset (const GskRenderNode *node);
GskRenderNode * gsk_outset_shadow_node_new2 (const GskRoundedRect *outline,
const GdkColor *color,
const graphene_point_t *offset,
float spread,
float blur_radius);
const GdkColor * gsk_outset_shadow_node_get_color2 (const GskRenderNode *node);
const graphene_point_t *gsk_outset_shadow_node_get_offset (const GskRenderNode *node);
typedef struct _GskShadow2 GskShadow2;
struct _GskShadow2
{
GdkColor color;
graphene_point_t offset;
float radius;
};
GskRenderNode * gsk_shadow_node_new2 (GskRenderNode *child,
const GskShadow2 *shadows,
gsize n_shadows);
const GskShadow2 *gsk_shadow_node_get_shadow2 (const GskRenderNode *node,
gsize i);
GskRenderNode * gsk_text_node_new2 (PangoFont *font,
PangoGlyphString *glyphs,
const GdkColor *color,
const graphene_point_t *offset);
const GdkColor *gsk_text_node_get_color2 (const GskRenderNode *node);
const GdkColor* gsk_color_node_get_color2 (const GskRenderNode *node);
G_END_DECLS
-29
View File
@@ -1290,35 +1290,6 @@ gtk_css_parser_consume_percentage (GtkCssParser *self,
return FALSE;
}
gboolean
gtk_css_parser_consume_number_or_percentage (GtkCssParser *parser,
double min,
double max,
double *value)
{
double number = 0;
if (gtk_css_parser_has_percentage (parser))
{
if (gtk_css_parser_consume_percentage (parser, &number))
{
*value = min + (number / 100.0) * (max - min);
return TRUE;
}
}
else if (gtk_css_parser_has_number (parser))
{
if (gtk_css_parser_consume_number (parser, &number))
{
*value = number;
return TRUE;
}
}
gtk_css_parser_error_syntax (parser, "Expected a number or percentage");
return FALSE;
}
gsize
gtk_css_parser_consume_any (GtkCssParser *parser,
const GtkCssParseOption *options,
-5
View File
@@ -154,11 +154,6 @@ gboolean gtk_css_parser_consume_integer (GtkCssParser
int *number);
gboolean gtk_css_parser_consume_percentage (GtkCssParser *self,
double *number);
gboolean gtk_css_parser_consume_number_or_percentage
(GtkCssParser *parser,
double min,
double max,
double *value);
gboolean gtk_css_parser_consume_function (GtkCssParser *self,
guint min_args,
guint max_args,
-35
View File
@@ -27,13 +27,8 @@
#include "gtkalertdialog.h"
#include <glib/gi18n-lib.h>
#ifdef G_OS_WIN32
#include "gtkshowwin32.h"
#endif
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
#ifndef G_OS_WIN32
typedef struct {
GtkWindow *parent;
char *handle;
@@ -91,24 +86,6 @@ window_handle_exported (GtkWindow *window,
data);
}
#else /* G_OS_WIN32 */
static void
show_win32_done (GObject *source,
GAsyncResult *result,
gpointer user_data)
{
GTask *task = user_data;
GError *error = NULL;
if (gtk_show_uri_win32_finish (GTK_WINDOW (source), result, &error))
g_task_return_boolean (task, TRUE);
else
g_task_return_error (task, error);
g_object_unref (task);
}
#endif
/**
* gtk_show_uri_full:
* @parent: (nullable): parent window
@@ -137,7 +114,6 @@ gtk_show_uri_full (GtkWindow *parent,
GAsyncReadyCallback callback,
gpointer user_data)
{
#ifndef G_OS_WIN32
GtkShowUriData *data;
GdkAppLaunchContext *context;
GdkDisplay *display;
@@ -162,17 +138,6 @@ gtk_show_uri_full (GtkWindow *parent,
if (!parent || !gtk_window_export_handle (parent, window_handle_exported, data))
window_handle_exported (parent, NULL, data);
#else /* G_OS_WIN32 */
GTask *task;
g_return_if_fail (parent == NULL || GTK_IS_WINDOW (parent));
g_return_if_fail (uri != NULL);
task = g_task_new (parent, cancellable, callback, user_data);
g_task_set_source_tag (task, gtk_show_uri_full);
gtk_show_uri_win32 (parent, uri, FALSE, cancellable, show_win32_done, task);
#endif
}
/**
+32 -72
View File
@@ -28,8 +28,6 @@
#include "gtkwidgetprivate.h"
#include "gtkcsscolorvalueprivate.h"
#include "gdk/gdkrgbaprivate.h"
#include "gdk/gdkcolorprivate.h"
#include "gdk/gdkcairoprivate.h"
#include "gtkcssshadowvalueprivate.h"
#include <math.h>
@@ -60,26 +58,23 @@ gsk_pango_renderer_set_shape_handler (GskPangoRenderer *crenderer,
static void
get_color (GskPangoRenderer *crenderer,
PangoRenderPart part,
GdkColor *out_color)
GdkRGBA *rgba)
{
const PangoColor *color = pango_renderer_get_color ((PangoRenderer *) (crenderer), part);
const guint16 a = pango_renderer_get_alpha ((PangoRenderer *) (crenderer), part);
if (color)
{
gdk_color_init (out_color, GDK_COLOR_STATE_SRGB,
(float[]) {
color->red / 65535.,
color->green / 65535.,
color->blue / 65535.,
a ? a / 65535. : crenderer->fg_color.alpha,
});
rgba->red = color->red / 65535.;
rgba->green = color->green / 65535.;
rgba->blue = color->blue / 65535.;
rgba->alpha = a ? a / 65535. : crenderer->fg_color->alpha;
}
else
{
gdk_color_init_copy (out_color, &crenderer->fg_color);
*rgba = *crenderer->fg_color;
if (a)
out_color->alpha = a / 65535.;
rgba->alpha = a / 65535.;
}
}
@@ -88,11 +83,10 @@ set_color (GskPangoRenderer *crenderer,
PangoRenderPart part,
cairo_t *cr)
{
GdkColor color;
GdkRGBA rgba = { 0, 0, 0, 1 };
get_color (crenderer, part, &color);
gdk_cairo_set_source_color (cr, GDK_COLOR_STATE_SRGB, &color);
gdk_color_finish (&color);
get_color (crenderer, part, &rgba);
gdk_cairo_set_source_rgba (cr, &rgba);
}
static void
@@ -103,7 +97,7 @@ gsk_pango_renderer_draw_glyph_item (PangoRenderer *renderer,
int y)
{
GskPangoRenderer *crenderer = (GskPangoRenderer *) (renderer);
GdkColor color;
GdkRGBA color;
gboolean has_shadow = FALSE;
if (crenderer->shadow_style)
@@ -112,14 +106,12 @@ gsk_pango_renderer_draw_glyph_item (PangoRenderer *renderer,
get_color (crenderer, PANGO_RENDER_PART_FOREGROUND, &color);
gtk_snapshot_append_text2 (crenderer->snapshot,
glyph_item->item->analysis.font,
glyph_item->glyphs,
&color,
(float) x / PANGO_SCALE,
(float) y / PANGO_SCALE);
gdk_color_finish (&color);
gtk_snapshot_append_text (crenderer->snapshot,
glyph_item->item->analysis.font,
glyph_item->glyphs,
&color,
(float) x / PANGO_SCALE,
(float) y / PANGO_SCALE);
if (has_shadow)
gtk_snapshot_pop (crenderer->snapshot);
@@ -134,18 +126,16 @@ gsk_pango_renderer_draw_rectangle (PangoRenderer *renderer,
int height)
{
GskPangoRenderer *crenderer = (GskPangoRenderer *) (renderer);
GdkColor color;
GdkRGBA rgba;
get_color (crenderer, part, &color);
get_color (crenderer, part, &rgba);
gtk_snapshot_append_color2 (crenderer->snapshot,
&color,
&GRAPHENE_RECT_INIT ((double)x / PANGO_SCALE,
(double)y / PANGO_SCALE,
(double)width / PANGO_SCALE,
(double)height / PANGO_SCALE));
gdk_color_finish (&color);
gtk_snapshot_append_color (crenderer->snapshot,
&rgba,
&GRAPHENE_RECT_INIT ((double)x / PANGO_SCALE,
(double)y / PANGO_SCALE,
(double)width / PANGO_SCALE,
(double)height / PANGO_SCALE));
}
static void
@@ -199,7 +189,7 @@ gsk_pango_renderer_draw_error_underline (PangoRenderer *renderer,
{
GskPangoRenderer *crenderer = (GskPangoRenderer *) (renderer);
double xx, yy, ww, hh;
GdkColor color;
GdkRGBA rgba;
GskRoundedRect dot;
xx = (double)x / PANGO_SCALE;
@@ -207,7 +197,7 @@ gsk_pango_renderer_draw_error_underline (PangoRenderer *renderer,
ww = (double)width / PANGO_SCALE;
hh = (double)height / PANGO_SCALE;
get_color (crenderer, PANGO_RENDER_PART_UNDERLINE, &color);
get_color (crenderer, PANGO_RENDER_PART_UNDERLINE, &rgba);
gtk_snapshot_push_repeat (crenderer->snapshot,
&GRAPHENE_RECT_INIT (xx, yy, ww, hh),
@@ -218,13 +208,11 @@ gsk_pango_renderer_draw_error_underline (PangoRenderer *renderer,
hh / 2);
gtk_snapshot_push_rounded_clip (crenderer->snapshot, &dot);
gtk_snapshot_append_color2 (crenderer->snapshot, &color, &dot.bounds);
gtk_snapshot_append_color (crenderer->snapshot, &rgba, &dot.bounds);
gtk_snapshot_pop (crenderer->snapshot);
gtk_snapshot_append_color2 (crenderer->snapshot,
&GDK_COLOR_SRGB (0, 0, 0, 0),
&GRAPHENE_RECT_INIT (xx, yy, 1.5 * hh, hh));
gdk_color_finish (&color);
gtk_snapshot_append_color (crenderer->snapshot,
&GDK_RGBA_TRANSPARENT,
&GRAPHENE_RECT_INIT (xx, yy, 1.5 * hh, hh));
gtk_snapshot_pop (crenderer->snapshot);
}
@@ -501,32 +489,6 @@ void
gtk_snapshot_append_layout (GtkSnapshot *snapshot,
PangoLayout *layout,
const GdkRGBA *color)
{
GdkColor color2;
gdk_color_init_from_rgba (&color2, color);
gtk_snapshot_append_layout2 (snapshot, layout, &color2);
gdk_color_finish (&color2);
}
/* < private >
* gtk_snapshot_append_layout2:
* @snapshot: a `GtkSnapshot`
* @layout: the `PangoLayout` to render
* @color: the foreground color to render the layout in
*
* Creates render nodes for rendering @layout in the given foregound @color
* and appends them to the current node of @snapshot without changing the
* current node. The current theme's foreground color for a widget can be
* obtained with [method@Gtk.Widget.get_color].
*
* Note that if the layout does not produce any visible output, then nodes
* may not be added to the @snapshot.
**/
void
gtk_snapshot_append_layout2 (GtkSnapshot *snapshot,
PangoLayout *layout,
const GdkColor *color)
{
GskPangoRenderer *crenderer;
@@ -536,11 +498,9 @@ gtk_snapshot_append_layout2 (GtkSnapshot *snapshot,
crenderer = gsk_pango_renderer_acquire ();
crenderer->snapshot = snapshot;
gdk_color_init_copy (&crenderer->fg_color, color);
crenderer->fg_color = color;
pango_renderer_draw_layout (PANGO_RENDERER (crenderer), layout, 0, 0);
gdk_color_finish (&crenderer->fg_color);
gsk_pango_renderer_release (crenderer);
}
+1 -1
View File
@@ -58,7 +58,7 @@ struct _GskPangoRenderer
GtkWidget *widget;
GtkSnapshot *snapshot;
GdkColor fg_color;
const GdkRGBA *fg_color;
GtkCssStyle *shadow_style;
/* Error underline color for this widget */
+48 -64
View File
@@ -594,7 +594,7 @@ gtk_css_shadow_value_snapshot_outset (const GtkCssValue *value,
{
guint i;
double dx, dy, spread, radius;
GdkColor color;
const GdkRGBA *color;
g_return_if_fail (value->class == &GTK_CSS_VALUE_SHADOW);
@@ -605,14 +605,11 @@ gtk_css_shadow_value_snapshot_outset (const GtkCssValue *value,
if (shadow->inset)
continue;
gtk_css_color_to_color (gtk_css_color_value_get_color (shadow->color), &color);
color = gtk_css_color_value_get_rgba (shadow->color);
/* We don't need to draw invisible shadows */
if (gdk_color_is_clear (&color))
{
gdk_color_finish (&color);
continue;
}
if (gdk_rgba_is_clear (color))
continue;
dx = gtk_css_number_value_get (shadow->hoffset, 0);
dy = gtk_css_number_value_get (shadow->voffset, 0);
@@ -621,11 +618,7 @@ gtk_css_shadow_value_snapshot_outset (const GtkCssValue *value,
if (value->is_filter)
radius = 2 * radius;
gtk_snapshot_append_outset_shadow2 (snapshot, border_box,
&color,
&GRAPHENE_POINT_INIT (dx, dy),
spread, radius);
gdk_color_finish (&color);
gtk_snapshot_append_outset_shadow (snapshot, border_box, color, dx, dy, spread, radius);
}
}
@@ -636,7 +629,7 @@ gtk_css_shadow_value_snapshot_inset (const GtkCssValue *value,
{
guint i;
double dx, dy, spread, radius;
GdkColor color;
const GdkRGBA *color;
g_return_if_fail (value->class == &GTK_CSS_VALUE_SHADOW);
@@ -647,14 +640,11 @@ gtk_css_shadow_value_snapshot_inset (const GtkCssValue *value,
if (!shadow->inset)
continue;
gtk_css_color_to_color (gtk_css_color_value_get_color (shadow->color), &color);
color = gtk_css_color_value_get_rgba (shadow->color);
/* We don't need to draw invisible shadows */
if (gdk_color_is_clear (&color))
{
gdk_color_finish (&color);
continue;
}
if (gdk_rgba_is_clear (color))
continue;
dx = gtk_css_number_value_get (shadow->hoffset, 0);
dy = gtk_css_number_value_get (shadow->voffset, 0);
@@ -673,58 +663,55 @@ gtk_css_shadow_value_snapshot_inset (const GtkCssValue *value,
{
const float y = dy > 0 ? dy : 0;
gtk_snapshot_append_color2 (snapshot, &color,
&GRAPHENE_RECT_INIT (
padding_bounds->origin.x,
padding_bounds->origin.y + y,
dx,
padding_bounds->size.height - ABS (dy)
));
gtk_snapshot_append_color (snapshot, color,
&GRAPHENE_RECT_INIT (
padding_bounds->origin.x,
padding_bounds->origin.y + y,
dx,
padding_bounds->size.height - ABS (dy)
));
}
else if (dx < 0)
{
const float y = dy > 0 ? dy : 0;
gtk_snapshot_append_color2 (snapshot, &color,
&GRAPHENE_RECT_INIT (
padding_bounds->origin.x + padding_bounds->size.width + dx,
padding_bounds->origin.y + y,
- dx,
padding_bounds->size.height - ABS (dy)
));
gtk_snapshot_append_color (snapshot, color,
&GRAPHENE_RECT_INIT (
padding_bounds->origin.x + padding_bounds->size.width + dx,
padding_bounds->origin.y + y,
- dx,
padding_bounds->size.height - ABS (dy)
));
}
if (dy > 0)
{
gtk_snapshot_append_color2 (snapshot, &color,
&GRAPHENE_RECT_INIT (
padding_bounds->origin.x,
padding_bounds->origin.y,
padding_bounds->size.width,
dy
));
gtk_snapshot_append_color (snapshot, color,
&GRAPHENE_RECT_INIT (
padding_bounds->origin.x,
padding_bounds->origin.y,
padding_bounds->size.width,
dy
));
}
else if (dy < 0)
{
gtk_snapshot_append_color2 (snapshot, &color,
&GRAPHENE_RECT_INIT (
padding_bounds->origin.x,
padding_bounds->origin.y + padding_bounds->size.height + dy,
padding_bounds->size.width,
- dy
));
gtk_snapshot_append_color (snapshot, color,
&GRAPHENE_RECT_INIT (
padding_bounds->origin.x,
padding_bounds->origin.y + padding_bounds->size.height + dy,
padding_bounds->size.width,
- dy
));
}
}
else
{
gtk_snapshot_append_inset_shadow2 (snapshot,
padding_box,
&color,
&GRAPHENE_POINT_INIT (dx, dy),
spread, radius);
gtk_snapshot_append_inset_shadow (snapshot,
padding_box,
color,
dx, dy, spread, radius);
}
gdk_color_finish (&color);
}
}
@@ -757,31 +744,28 @@ gboolean
gtk_css_shadow_value_push_snapshot (const GtkCssValue *value,
GtkSnapshot *snapshot)
{
GskShadow2 *shadows;
GskShadow *shadows;
guint i;
if (gtk_css_shadow_value_is_clear (value))
return FALSE;
shadows = g_newa (GskShadow2, value->n_shadows);
shadows = g_newa (GskShadow, value->n_shadows);
for (i = 0; i < value->n_shadows; i++)
{
const ShadowValue *shadow = &value->shadows[i];
gtk_css_color_to_color (gtk_css_color_value_get_color (shadow->color), &shadows[i].color);
graphene_point_init (&shadows[i].offset,
gtk_css_number_value_get (shadow->hoffset, 0),
gtk_css_number_value_get (shadow->voffset, 0));
shadows[i].color = *gtk_css_color_value_get_rgba (shadow->color);
shadows[i].dx = gtk_css_number_value_get (shadow->hoffset, 0);
shadows[i].dy = gtk_css_number_value_get (shadow->voffset, 0);
shadows[i].radius = gtk_css_number_value_get (shadow->radius, 0);
if (value->is_filter)
shadows[i].radius *= 2;
}
gtk_snapshot_push_shadow2 (snapshot, shadows, value->n_shadows);
for (i = 0; i < value->n_shadows; i++)
gdk_color_finish (&shadows[i].color);
gtk_snapshot_push_shadow (snapshot, shadows, value->n_shadows);
return TRUE;
}
+1 -1
View File
@@ -742,7 +742,7 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style)
if (decoration_line & GTK_CSS_TEXT_DECORATION_LINE_LINE_THROUGH)
{
attrs = add_pango_attr (attrs, pango_attr_strikethrough_new (TRUE));
if (has_decoration_color)
if (!has_decoration_color)
attrs = add_pango_attr (attrs, pango_attr_strikethrough_color_new (decoration_color->red * 65535. + 0.5,
decoration_color->green * 65535. + 0.5,
decoration_color->blue * 65535. + 0.5));
+1 -13
View File
@@ -26,10 +26,6 @@
#include "deprecated/gtkshow.h"
#include <glib/gi18n-lib.h>
#ifdef G_OS_WIN32
#include "gtkshowwin32.h"
#endif
/**
* GtkFileLauncher:
*
@@ -436,11 +432,7 @@ show_uri_done (GObject *source,
GTask *task = G_TASK (data);
GError *error = NULL;
#ifndef G_OS_WIN32
if (!gtk_show_uri_full_finish (parent, result, &error))
#else
if (!gtk_show_uri_win32_finish (parent, result, &error))
#endif
{
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
g_task_return_new_error (task, GTK_DIALOG_ERROR, GTK_DIALOG_ERROR_CANCELLED, "Cancelled by user");
@@ -511,6 +503,7 @@ gtk_file_launcher_launch (GtkFileLauncher *self,
gtk_openuri_portal_open_async (self->file, FALSE, flags, parent, cancellable, open_done, task);
}
else
#endif
{
char *uri = g_file_get_uri (self->file);
@@ -520,11 +513,6 @@ G_GNUC_END_IGNORE_DEPRECATIONS
g_free (uri);
}
#else /* G_OS_WIN32 */
char *path = g_file_get_path (self->file);
gtk_show_uri_win32 (parent, path, self->always_ask, cancellable, show_uri_done, task);
g_free (path);
#endif
}
/**
+2 -3
View File
@@ -83,8 +83,8 @@ get_icon_lookup_flags (GtkIconHelper *self,
static GdkPaintable *
ensure_paintable_for_gicon (GtkIconHelper *self,
GtkCssStyle *style,
int scale,
GtkTextDirection dir,
int scale,
gboolean preload,
GIcon *gicon,
gboolean *symbolic)
@@ -104,9 +104,8 @@ ensure_paintable_for_gicon (GtkIconHelper *self,
icon = gtk_icon_theme_lookup_by_gicon (icon_theme,
gicon,
MIN (width, height),
scale,
dir,
flags);
scale, flags);
*symbolic = gtk_icon_paintable_is_symbolic (icon);
return GDK_PAINTABLE (icon);
+182
View File
@@ -304,3 +304,185 @@ gtk_native_queue_relayout (GtkNative *self)
gdk_surface_request_layout (surface);
}
static void
corner_rect (const GtkCssValue *value,
cairo_rectangle_int_t *rect)
{
rect->width = _gtk_css_corner_value_get_x (value, 100);
rect->height = _gtk_css_corner_value_get_y (value, 100);
}
static void
subtract_decoration_corners_from_region (cairo_region_t *region,
cairo_rectangle_int_t *extents,
const GtkCssStyle *style)
{
cairo_rectangle_int_t rect;
corner_rect (style->border->border_top_left_radius, &rect);
rect.x = extents->x;
rect.y = extents->y;
cairo_region_subtract_rectangle (region, &rect);
corner_rect (style->border->border_top_right_radius, &rect);
rect.x = extents->x + extents->width - rect.width;
rect.y = extents->y;
cairo_region_subtract_rectangle (region, &rect);
corner_rect (style->border->border_bottom_left_radius, &rect);
rect.x = extents->x;
rect.y = extents->y + extents->height - rect.height;
cairo_region_subtract_rectangle (region, &rect);
corner_rect (style->border->border_bottom_right_radius, &rect);
rect.x = extents->x + extents->width - rect.width;
rect.y = extents->y + extents->height - rect.height;
cairo_region_subtract_rectangle (region, &rect);
}
static int
get_translucent_border_edge (GtkCssValue *border_color,
GtkCssValue *border_width)
{
if (!gdk_rgba_is_opaque (gtk_css_color_value_get_rgba (border_color)))
return round (gtk_css_number_value_get (border_width, 100));
return 0;
}
static void
get_translucent_border_width (GtkWidget *widget,
GtkBorder *border)
{
GtkCssNode *css_node = gtk_widget_get_css_node (widget);
GtkCssStyle *style = gtk_css_node_get_style (css_node);
border->top = get_translucent_border_edge (style->used->border_top_color,
style->border->border_top_width);
border->bottom = get_translucent_border_edge (style->used->border_bottom_color,
style->border->border_bottom_width);
border->left = get_translucent_border_edge (style->used->border_left_color,
style->border->border_left_width);
border->right = get_translucent_border_edge (style->used->border_right_color,
style->border->border_right_width);
}
static gboolean
get_opaque_rect (GtkWidget *widget,
cairo_rectangle_int_t *rect)
{
gboolean is_opaque;
if (gtk_widget_get_opacity (widget) < 1)
is_opaque = FALSE;
else
{
GtkCssNode *node;
GtkCssStyle *style;
const GdkRGBA *color;
node = gtk_widget_get_css_node (widget);
style = gtk_css_node_get_style (node);
color = gtk_css_color_value_get_rgba (style->used->background_color);
is_opaque = gdk_rgba_is_opaque (color);
}
if (is_opaque)
{
const graphene_rect_t *border_rect;
GtkCssBoxes css_boxes;
GtkBorder border;
gtk_css_boxes_init (&css_boxes, widget);
border_rect = gtk_css_boxes_get_border_rect (&css_boxes);
get_translucent_border_width (widget, &border);
rect->x = border_rect->origin.x + border.left;
rect->y = border_rect->origin.y + border.top;
rect->width = border_rect->size.width - border.left - border.right;
rect->height = border_rect->size.height - border.top - border.bottom;
}
return is_opaque;
}
static void
get_shadow_width (GtkWidget *widget,
GtkBorder *shadow_width,
int resize_handle_size)
{
GtkCssNode *css_node = gtk_widget_get_css_node (widget);
const GtkCssStyle *style = gtk_css_node_get_style (css_node);
gtk_css_shadow_value_get_extents (style->used->box_shadow, shadow_width);
shadow_width->left = MAX (shadow_width->left, resize_handle_size);
shadow_width->top = MAX (shadow_width->top, resize_handle_size);
shadow_width->bottom = MAX (shadow_width->bottom, resize_handle_size);
shadow_width->right = MAX (shadow_width->right, resize_handle_size);
}
void
gtk_native_update_opaque_region (GtkNative *native,
GtkWidget *contents,
gboolean subtract_decoration_corners,
gboolean subtract_shadow,
int resize_handle_size)
{
cairo_rectangle_int_t rect;
cairo_region_t *opaque_region = NULL;
GdkSurface *surface;
GtkBorder shadow;
g_return_if_fail (GTK_IS_NATIVE (native));
g_return_if_fail (!contents || GTK_IS_WIDGET (contents));
if (contents == NULL)
contents = GTK_WIDGET (native);
if (!_gtk_widget_get_realized (GTK_WIDGET (native)) ||
!_gtk_widget_get_realized (contents))
return;
if (subtract_shadow)
get_shadow_width (contents, &shadow, resize_handle_size);
else
shadow = (GtkBorder) {0, 0, 0, 0};
surface = gtk_native_get_surface (native);
if (get_opaque_rect (contents, &rect))
{
double native_x, native_y;
gtk_native_get_surface_transform (native, &native_x, &native_y);
rect.x += native_x;
rect.y += native_y;
if (contents != GTK_WIDGET (native))
{
graphene_point_t p;
if (!gtk_widget_compute_point (contents, GTK_WIDGET (native),
&GRAPHENE_POINT_INIT (0, 0), &p))
graphene_point_init (&p, 0, 0);
rect.x += p.x;
rect.y += p.y;
}
opaque_region = cairo_region_create_rectangle (&rect);
if (subtract_decoration_corners)
{
GtkCssStyle *style;
style = gtk_css_node_get_style (gtk_widget_get_css_node (contents));
subtract_decoration_corners_from_region (opaque_region, &rect, style);
}
}
gdk_surface_set_opaque_region (surface, opaque_region);
cairo_region_destroy (opaque_region);
}
+5
View File
@@ -28,6 +28,11 @@ struct _GtkNativeInterface
};
void gtk_native_queue_relayout (GtkNative *native);
void gtk_native_update_opaque_region (GtkNative *native,
GtkWidget *contents,
gboolean subtract_decoration_corners,
gboolean subtract_shadow,
int resize_handle_size);
G_END_DECLS
+6 -1
View File
@@ -42,7 +42,7 @@
*
* ## GtkPopover as menu replacement
*
* `GtkPopover` is often used to replace menus. The best way to do this
* `GtkPopover` is often used to replace menus. The best was to do this
* is to use the [class@Gtk.PopoverMenu] subclass which supports being
* populated from a `GMenuModel` with [ctor@Gtk.PopoverMenu.new_from_model].
*
@@ -1029,6 +1029,8 @@ gtk_popover_realize (GtkWidget *widget)
priv->renderer = gsk_renderer_new_for_surface (priv->surface);
gtk_native_realize (GTK_NATIVE (popover));
gtk_native_update_opaque_region (GTK_NATIVE (popover), priv->contents_widget, TRUE, TRUE, 0);
}
static void
@@ -1465,6 +1467,9 @@ gtk_popover_update_shape (GtkPopover *popover)
gdk_surface_set_input_region (priv->surface, region);
cairo_region_destroy (region);
}
if (_gtk_widget_get_realized (GTK_WIDGET (popover)))
gtk_native_update_opaque_region (GTK_NATIVE (popover), priv->contents_widget, TRUE, TRUE, 0);
}
static int
+1 -3
View File
@@ -188,7 +188,6 @@ gtk_print_setup_set_page_setup (GtkPrintSetup *setup,
static GtkPrinter *
gtk_print_setup_get_printer (GtkPrintSetup *setup)
{
#ifdef HAVE_GIO_UNIX
if (!setup->printer)
{
const char *name = NULL;
@@ -199,7 +198,6 @@ gtk_print_setup_get_printer (GtkPrintSetup *setup)
if (name)
setup->printer = gtk_printer_find (name);
}
#endif
return setup->printer;
}
@@ -1676,8 +1674,8 @@ gtk_print_dialog_print_file (GtkPrintDialog *self,
#ifdef HAVE_GIO_UNIX
PrintTaskData *ptd;
GFileInputStream *content;
GError *error = NULL;
#endif
GError *error = NULL;
g_return_if_fail (GTK_IS_PRINT_DIALOG (self));
g_return_if_fail (parent == NULL || GTK_IS_WINDOW (parent));
+73 -94
View File
@@ -37,9 +37,6 @@
#include "gtksnapshotprivate.h"
#include "gdk/gdkhslaprivate.h"
#include "gdk/gdkrgbaprivate.h"
#include "gdk/gdkcolorprivate.h"
#include "gdk/gdkcairoprivate.h"
#include "gsk/gskroundedrectprivate.h"
#include "gsk/gskrectprivate.h"
@@ -338,30 +335,27 @@ static void
snapshot_frame_fill (GtkSnapshot *snapshot,
const GskRoundedRect *outline,
const float border_width[4],
const GdkColor colors[4],
const GdkRGBA colors[4],
guint hidden_side)
{
if (hidden_side)
{
GdkColor real_colors[4];
GdkRGBA real_colors[4];
guint i;
for (i = 0; i < 4; i++)
{
if (hidden_side & (1 << i))
gdk_color_init_from_rgba (&real_colors[i], &GDK_RGBA_TRANSPARENT);
real_colors[i] = (GdkRGBA) { 0, 0, 0, 0 };
else
gdk_color_init_copy (&real_colors[i], &colors[i]);
real_colors[i] = colors[i];
}
snapshot_frame_fill (snapshot, outline, border_width, real_colors, 0);
for (i = 0; i < 4; i++)
gdk_color_finish (&real_colors[i]);
return;
}
gtk_snapshot_append_border2 (snapshot, outline, border_width, colors);
gtk_snapshot_append_border (snapshot, outline, border_width, colors);
}
static void
@@ -415,7 +409,7 @@ static void
render_frame_stroke (cairo_t *cr,
const GskRoundedRect *border_box,
const double border_width[4],
const GdkColor colors[4],
GdkRGBA colors[4],
guint hidden_side,
GtkBorderStyle stroke_style)
{
@@ -423,9 +417,9 @@ render_frame_stroke (cairo_t *cr,
GskRoundedRect stroke_box;
guint i;
different_colors = !gdk_color_equal (&colors[0], &colors[1]) ||
!gdk_color_equal (&colors[0], &colors[2]) ||
!gdk_color_equal (&colors[0], &colors[3]);
different_colors = !gdk_rgba_equal (&colors[0], &colors[1]) ||
!gdk_rgba_equal (&colors[0], &colors[2]) ||
!gdk_rgba_equal (&colors[0], &colors[3]);
different_borders = border_width[0] != border_width[1] ||
border_width[0] != border_width[2] ||
border_width[0] != border_width[3] ;
@@ -442,15 +436,14 @@ render_frame_stroke (cairo_t *cr,
double length = 0;
/* FAST PATH:
* Mostly expected to trigger for focus rectangles
*/
for (i = 0; i < 4; i++)
* Mostly expected to trigger for focus rectangles */
for (i = 0; i < 4; i++)
{
length += _gtk_rounded_box_guess_length (&stroke_box, i);
}
gsk_rounded_rect_path (&stroke_box, cr);
gdk_cairo_set_source_color (cr, GDK_COLOR_STATE_SRGB, &colors[0]);
gdk_cairo_set_source_rgba (cr, &colors[0]);
set_stroke_style (cr, border_width[0], stroke_style, length);
cairo_stroke (cr);
}
@@ -487,7 +480,7 @@ render_frame_stroke (cairo_t *cr,
_gtk_rounded_box_path_side (&stroke_box, cr, i);
gdk_cairo_set_source_color (cr, GDK_COLOR_STATE_SRGB, &colors[i]);
gdk_cairo_set_source_rgba (cr, &colors[i]);
set_stroke_style (cr,
border_width[i],
stroke_style,
@@ -503,38 +496,36 @@ static void
snapshot_frame_stroke (GtkSnapshot *snapshot,
const GskRoundedRect *outline,
const float border_width[4],
const GdkColor colors[4],
GdkRGBA colors[4],
guint hidden_side,
GtkBorderStyle stroke_style)
{
double double_width[4] = { border_width[0], border_width[1], border_width[2], border_width[3] };
cairo_t *cr;
cr = gtk_snapshot_append_cairo (snapshot, &outline->bounds);
cr = gtk_snapshot_append_cairo (snapshot,
&outline->bounds);
render_frame_stroke (cr, outline, double_width, colors, hidden_side, stroke_style);
cairo_destroy (cr);
}
static void
color_shade (const GdkColor *color,
double factor,
GdkColor *color_return)
color_shade (const GdkRGBA *color,
double factor,
GdkRGBA *color_return)
{
GdkRGBA rgba;
GdkHSLA hsla;
gdk_color_to_float (color, GDK_COLOR_STATE_SRGB, (float *) &rgba);
_gdk_hsla_init_from_rgba (&hsla, &rgba);
_gdk_hsla_init_from_rgba (&hsla, color);
_gdk_hsla_shade (&hsla, &hsla, factor);
_gdk_rgba_init_from_hsla (&rgba, &hsla);
gdk_color_from_rgba (color_return, color->color_state, &rgba);
_gdk_rgba_init_from_hsla (color_return, &hsla);
}
static void
snapshot_border (GtkSnapshot *snapshot,
const GskRoundedRect *border_box,
const float border_width[4],
GdkColor colors[4],
GdkRGBA colors[4],
GtkBorderStyle border_style[4])
{
guint hidden_side = 0;
@@ -594,12 +585,12 @@ snapshot_border (GtkSnapshot *snapshot,
hidden_side |= (1 << j);
else
dont_draw |= (1 << j);
other_border[j] = border_width[j] / 3;
}
snapshot_frame_fill (snapshot, border_box, other_border, colors, dont_draw);
other_box = *border_box;
gsk_rounded_rect_shrink (&other_box,
2 * other_border[GTK_CSS_TOP],
@@ -613,7 +604,7 @@ snapshot_border (GtkSnapshot *snapshot,
case GTK_BORDER_STYLE_RIDGE:
{
GskRoundedRect other_box;
GdkColor other_colors[4];
GdkRGBA other_colors[4];
guint dont_draw = hidden_side;
float other_border[4];
@@ -631,9 +622,9 @@ snapshot_border (GtkSnapshot *snapshot,
dont_draw |= (1 << j);
other_border[j] = border_width[j] / 2;
}
snapshot_frame_fill (snapshot, border_box, other_border, colors, dont_draw);
other_box = *border_box;
gsk_rounded_rect_shrink (&other_box,
other_border[GTK_CSS_TOP],
@@ -648,7 +639,7 @@ snapshot_border (GtkSnapshot *snapshot,
break;
}
}
snapshot_frame_fill (snapshot, border_box, border_width, colors, hidden_side);
}
@@ -684,7 +675,7 @@ gtk_css_style_snapshot_border (GtkCssBoxes *boxes,
else
{
GtkBorderStyle border_style[4];
GdkColor colors[4];
GdkRGBA colors[4];
graphene_simd4f_t alpha_test_vector;
/* Optimize the most common case of "This widget has no border" */
@@ -692,54 +683,46 @@ gtk_css_style_snapshot_border (GtkCssBoxes *boxes,
gtk_css_boxes_get_padding_rect (boxes)))
return;
gtk_css_color_to_color (gtk_css_color_value_get_color (style->used->border_top_color), &colors[0]);
gtk_css_color_to_color (gtk_css_color_value_get_color (style->used->border_right_color), &colors[1]);
gtk_css_color_to_color (gtk_css_color_value_get_color (style->used->border_bottom_color), &colors[2]);
gtk_css_color_to_color (gtk_css_color_value_get_color (style->used->border_left_color), &colors[3]);
colors[0] = *gtk_css_color_value_get_rgba (style->used->border_top_color);
colors[1] = *gtk_css_color_value_get_rgba (style->used->border_right_color);
colors[2] = *gtk_css_color_value_get_rgba (style->used->border_bottom_color);
colors[3] = *gtk_css_color_value_get_rgba (style->used->border_left_color);
alpha_test_vector = graphene_simd4f_init (colors[0].alpha,
colors[1].alpha,
colors[2].alpha,
colors[3].alpha);
if (!graphene_simd4f_is_zero4 (alpha_test_vector))
alpha_test_vector = graphene_simd4f_init (colors[0].alpha, colors[1].alpha, colors[2].alpha, colors[3].alpha);
if (graphene_simd4f_is_zero4 (alpha_test_vector))
return;
border_style[0] = _gtk_css_border_style_value_get (style->border->border_top_style);
border_style[1] = _gtk_css_border_style_value_get (style->border->border_right_style);
border_style[2] = _gtk_css_border_style_value_get (style->border->border_bottom_style);
border_style[3] = _gtk_css_border_style_value_get (style->border->border_left_style);
border_width[0] = gtk_css_number_value_get (style->border->border_top_width, 100);
border_width[1] = gtk_css_number_value_get (style->border->border_right_width, 100);
border_width[2] = gtk_css_number_value_get (style->border->border_bottom_width, 100);
border_width[3] = gtk_css_number_value_get (style->border->border_left_width, 100);
gtk_snapshot_push_debug (snapshot, "CSS border");
if (border_style[0] <= GTK_BORDER_STYLE_SOLID &&
border_style[1] <= GTK_BORDER_STYLE_SOLID &&
border_style[2] <= GTK_BORDER_STYLE_SOLID &&
border_style[3] <= GTK_BORDER_STYLE_SOLID)
{
border_style[0] = _gtk_css_border_style_value_get (style->border->border_top_style);
border_style[1] = _gtk_css_border_style_value_get (style->border->border_right_style);
border_style[2] = _gtk_css_border_style_value_get (style->border->border_bottom_style);
border_style[3] = _gtk_css_border_style_value_get (style->border->border_left_style);
border_width[0] = gtk_css_number_value_get (style->border->border_top_width, 100);
border_width[1] = gtk_css_number_value_get (style->border->border_right_width, 100);
border_width[2] = gtk_css_number_value_get (style->border->border_bottom_width, 100);
border_width[3] = gtk_css_number_value_get (style->border->border_left_width, 100);
gtk_snapshot_push_debug (snapshot, "CSS border");
if (border_style[0] <= GTK_BORDER_STYLE_SOLID &&
border_style[1] <= GTK_BORDER_STYLE_SOLID &&
border_style[2] <= GTK_BORDER_STYLE_SOLID &&
border_style[3] <= GTK_BORDER_STYLE_SOLID)
{
/* The most common case of a solid border */
gtk_snapshot_append_border2 (snapshot,
gtk_css_boxes_get_border_box (boxes),
border_width,
colors);
}
else
{
snapshot_border (snapshot,
gtk_css_boxes_get_border_box (boxes),
border_width,
colors,
border_style);
}
gtk_snapshot_pop (snapshot);
/* The most common case of a solid border */
gtk_snapshot_append_border (snapshot,
gtk_css_boxes_get_border_box (boxes),
border_width,
colors);
}
gdk_color_finish (&colors[0]);
gdk_color_finish (&colors[1]);
gdk_color_finish (&colors[2]);
gdk_color_finish (&colors[3]);
else
{
snapshot_border (snapshot,
gtk_css_boxes_get_border_box (boxes),
border_width,
colors,
border_style);
}
gtk_snapshot_pop (snapshot);
}
}
@@ -750,20 +733,17 @@ gtk_css_style_snapshot_outline (GtkCssBoxes *boxes,
GtkCssStyle *style = boxes->style;
GtkBorderStyle border_style[4];
float border_width[4];
GdkColor colors[4];
GdkRGBA colors[4];
border_style[0] = _gtk_css_border_style_value_get (style->outline->outline_style);
if (border_style[0] != GTK_BORDER_STYLE_NONE)
{
GdkColor color;
const GdkRGBA *color;
gtk_css_color_to_color (gtk_css_color_value_get_color (style->used->outline_color), &color);
color = gtk_css_color_value_get_rgba (style->used->outline_color);
if (gdk_color_is_clear (&color))
{
gdk_color_finish (&color);
return;
}
if (gdk_rgba_is_clear (color))
return;
border_width[0] = gtk_css_number_value_get (style->outline->outline_width, 100);
@@ -772,7 +752,7 @@ gtk_css_style_snapshot_outline (GtkCssBoxes *boxes,
border_style[1] = border_style[2] = border_style[3] = border_style[0];
border_width[3] = border_width[2] = border_width[1] = border_width[0];
colors[0] = colors[1] = colors[2] = colors[3] = color;
colors[0] = colors[1] = colors[2] = colors[3] = *color;
gtk_snapshot_push_debug (snapshot, "CSS outline");
snapshot_border (snapshot,
@@ -781,6 +761,5 @@ gtk_css_style_snapshot_outline (GtkCssBoxes *boxes,
colors,
border_style);
gtk_snapshot_pop (snapshot);
gdk_color_finish (&color);
}
}
+15 -18
View File
@@ -22,10 +22,9 @@
#include "gtkcsscolorvalueprivate.h"
#include "gtkcssshadowvalueprivate.h"
#include "gtkpangoprivate.h"
#include "gtksnapshotprivate.h"
#include "gtksnapshot.h"
#include "gtktypebuiltins.h"
#include "gtksettings.h"
#include "gdkcairoprivate.h"
void
@@ -36,7 +35,7 @@ gtk_css_style_snapshot_layout (GtkCssBoxes *boxes,
PangoLayout *layout)
{
GtkCssStyle *style;
GdkColor color;
const GdkRGBA *color;
gboolean has_shadow;
gtk_snapshot_push_debug (snapshot, "Layout");
@@ -48,11 +47,11 @@ gtk_css_style_snapshot_layout (GtkCssBoxes *boxes,
}
style = boxes->style;
gtk_css_color_to_color (gtk_css_color_value_get_color (style->used->color), &color);
color = gtk_css_color_value_get_rgba (style->used->color);
has_shadow = gtk_css_shadow_value_push_snapshot (style->used->text_shadow, snapshot);
gtk_snapshot_append_layout2 (snapshot, layout, &color);
gtk_snapshot_append_layout (snapshot, layout, color);
if (has_shadow)
gtk_snapshot_pop (snapshot);
@@ -60,8 +59,6 @@ gtk_css_style_snapshot_layout (GtkCssBoxes *boxes,
if (x != 0 || y != 0)
gtk_snapshot_restore (snapshot);
gdk_color_finish (&color);
gtk_snapshot_pop (snapshot);
}
@@ -72,7 +69,7 @@ draw_insertion_cursor (cairo_t *cr,
double width,
double height,
double aspect_ratio,
const GdkColor *color,
const GdkRGBA *color,
PangoDirection direction,
gboolean draw_arrow)
{
@@ -84,7 +81,7 @@ draw_insertion_cursor (cairo_t *cr,
cairo_save (cr);
cairo_new_path (cr);
gdk_cairo_set_source_color (cr, GDK_COLOR_STATE_SRGB, color);
gdk_cairo_set_source_rgba (cr, color);
stem_width = height * aspect_ratio + 1;
@@ -191,12 +188,12 @@ snapshot_insertion_cursor (GtkSnapshot *snapshot,
PangoDirection direction,
gboolean draw_arrow)
{
GdkColor color;
const GdkRGBA *color;
gtk_css_color_to_color (is_primary
? gtk_css_color_value_get_color (style->used->caret_color)
: gtk_css_color_value_get_color (style->used->secondary_caret_color),
&color);
if (is_primary)
color = gtk_css_color_value_get_rgba (style->used->caret_color);
else
color = gtk_css_color_value_get_rgba (style->used->secondary_caret_color);
if (width != 0 || draw_arrow)
{
@@ -206,7 +203,7 @@ snapshot_insertion_cursor (GtkSnapshot *snapshot,
get_insertion_cursor_bounds (width, height, aspect_ratio, direction, draw_arrow, &bounds);
cr = gtk_snapshot_append_cairo (snapshot, &bounds);
draw_insertion_cursor (cr, 0, 0, width, height, aspect_ratio, &color, direction, draw_arrow);
draw_insertion_cursor (cr, 0, 0, width, height, aspect_ratio, color, direction, draw_arrow);
cairo_destroy (cr);
}
@@ -223,9 +220,9 @@ snapshot_insertion_cursor (GtkSnapshot *snapshot,
else
offset = stem_width - stem_width / 2;
gtk_snapshot_append_color2 (snapshot,
&color,
&GRAPHENE_RECT_INIT (- offset, 0, stem_width, height));
gtk_snapshot_append_color (snapshot,
color,
&GRAPHENE_RECT_INIT (- offset, 0, stem_width, height));
}
}
-185
View File
@@ -1,185 +0,0 @@
/*
* GTK - The GIMP Toolkit
* Copyright (C) 2024 Sergey Bugaev
* All rights reserved.
*
* This Library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This Library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gtkshowwin32.h"
#include <gtk/gtknative.h>
#include <gdk/win32/gdkwin32misc.h>
#include <shellapi.h>
#include <shlobj.h>
typedef struct {
gunichar2 *uri_or_path;
gboolean always_ask;
} ShowData;
static void
show_data_free (ShowData *data)
{
g_free (data->uri_or_path);
g_slice_free (ShowData, data);
}
static void
show_uri_win32_in_thread (GTask *task,
gpointer source_object,
gpointer task_data,
GCancellable *cancellable)
{
ShowData *data = task_data;
GdkSurface *parent_surface;
HWND parent_hwnd;
HMONITOR monitor;
HRESULT hr;
if (source_object)
{
parent_surface = gtk_native_get_surface (GTK_NATIVE (source_object));
parent_hwnd = GDK_SURFACE_HWND (parent_surface);
monitor = MonitorFromWindow (parent_hwnd, MONITOR_DEFAULTTONULL);
}
else
{
parent_hwnd = 0;
monitor = (HMONITOR) NULL;
}
if (!data->always_ask)
{
BOOL res;
SHELLEXECUTEINFOW shex_info;
/* Attempt to initialize COM, in the off chance that there
* are ShellExecute hooks. */
hr = CoInitializeEx (NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
memset (&shex_info, 0, sizeof (shex_info));
shex_info.cbSize = sizeof (shex_info);
shex_info.fMask = SEE_MASK_NOASYNC | SEE_MASK_HMONITOR;
shex_info.hwnd = parent_hwnd;
shex_info.lpVerb = NULL;
shex_info.lpFile = data->uri_or_path;
shex_info.lpParameters = NULL;
shex_info.lpDirectory = NULL;
shex_info.nShow = SW_SHOWNORMAL;
shex_info.hMonitor = monitor;
/* Us passing the monitor derived from the parent window shouldn't
* break any custom window positioning logic in the app being
* launched, since the passed monitor is only used as a fallback
* for apps that use CW_USEDEFAULT. */
res = ShellExecuteExW (&shex_info);
/* Un-initialize COM if we have successfully initialized it earlier. */
if (SUCCEEDED (hr))
CoUninitialize ();
if (res)
g_task_return_boolean (task, TRUE);
else
{
int errsv = GetLastError ();
gchar *emsg = g_win32_error_message (errsv);
g_task_return_new_error (task, G_IO_ERROR,
g_io_error_from_win32_error (errsv),
"%s", emsg);
g_free (emsg);
}
}
else
{
OPENASINFO openas_info;
memset (&openas_info, 0, sizeof (openas_info));
openas_info.pcszFile = data->uri_or_path;
openas_info.pcszClass = NULL;
openas_info.oaifInFlags = OAIF_ALLOW_REGISTRATION | OAIF_REGISTER_EXT | OAIF_EXEC;
hr = SHOpenWithDialog (parent_hwnd, &openas_info);
if (SUCCEEDED (hr))
g_task_return_boolean (task, TRUE);
else
g_task_return_new_error (task, G_IO_ERROR,
G_IO_ERROR_FAILED,
"Failed to display Open With dialog: 0x%lx", hr);
}
}
void
gtk_show_uri_win32 (GtkWindow *parent,
const char *uri_or_path,
gboolean always_ask,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
ShowData *show_data;
GTask *task;
GError *error = NULL;
char *owned_path = NULL;
g_return_if_fail (uri_or_path != NULL);
task = g_task_new (parent, cancellable, callback, user_data);
g_task_set_source_tag (task, gtk_show_uri_win32);
/* ShellExecute doesn't quite like file:// URLs, so convert
* those to file paths now. */
if (g_str_has_prefix (uri_or_path, "file://"))
{
GFile *file = g_file_new_for_uri (uri_or_path);
uri_or_path = owned_path = g_file_get_path (file);
g_object_unref (file);
}
show_data = g_slice_new (ShowData);
show_data->always_ask = always_ask;
/* Note: uri_or_path is UTF-8 encoded here. */
show_data->uri_or_path = g_utf8_to_utf16 (uri_or_path, -1, NULL, NULL, &error);
g_clear_pointer(&owned_path, g_free);
if (G_UNLIKELY (error))
{
g_task_return_error (task, error);
g_slice_free (ShowData, show_data);
g_object_unref (task);
return;
}
g_task_set_task_data (task, show_data, (GDestroyNotify) show_data_free);
g_task_run_in_thread (task, show_uri_win32_in_thread);
g_object_unref (task);
}
gboolean
gtk_show_uri_win32_finish (GtkWindow *parent,
GAsyncResult *result,
GError **error)
{
g_return_val_if_fail (g_task_is_valid (result, parent), FALSE);
return g_task_propagate_boolean (G_TASK (result), error);
}
-39
View File
@@ -1,39 +0,0 @@
/*
* GTK - The GIMP Toolkit
* Copyright (C) 2024 Sergey Bugaev
* All rights reserved.
*
* This Library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This Library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <gio/gio.h>
typedef struct _GtkWindow GtkWindow;
G_BEGIN_DECLS
void gtk_show_uri_win32 (GtkWindow *parent,
const char *uri_or_path,
gboolean always_ask,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean gtk_show_uri_win32_finish (GtkWindow *parent,
GAsyncResult *result,
GError **error);
G_END_DECLS
+41 -191
View File
@@ -119,8 +119,8 @@ G_GNUC_END_IGNORE_DEPRECATIONS
} stroke;
struct {
gsize n_shadows;
GskShadow2 *shadows;
GskShadow2 a_shadow; /* Used if n_shadows == 1 */
GskShadow *shadows;
GskShadow a_shadow; /* Used if n_shadows == 1 */
} shadow;
struct {
GskBlendMode blend_mode;
@@ -1348,11 +1348,11 @@ gtk_snapshot_collect_shadow (GtkSnapshot *snapshot,
if (node == NULL)
return NULL;
shadow_node = gsk_shadow_node_new2 (node,
state->data.shadow.shadows != NULL
? state->data.shadow.shadows
: &state->data.shadow.a_shadow,
state->data.shadow.n_shadows);
shadow_node = gsk_shadow_node_new (node,
state->data.shadow.shadows != NULL ?
state->data.shadow.shadows :
&state->data.shadow.a_shadow,
state->data.shadow.n_shadows);
gsk_render_node_unref (node);
@@ -1391,12 +1391,6 @@ gtk_snapshot_append_stroke (GtkSnapshot *snapshot,
static void
gtk_snapshot_clear_shadow (GtkSnapshotState *state)
{
if (state->data.shadow.shadows != 0)
for (gsize i = 0; i < state->data.shadow.n_shadows; i++)
gdk_color_finish (&state->data.shadow.shadows[i].color);
else
gdk_color_finish (&state->data.shadow.a_shadow.color);
g_free (state->data.shadow.shadows);
}
@@ -1414,41 +1408,6 @@ void
gtk_snapshot_push_shadow (GtkSnapshot *snapshot,
const GskShadow *shadow,
gsize n_shadows)
{
GskShadow2 *shadow2;
g_return_if_fail (n_shadows > 0);
shadow2 = g_new (GskShadow2, n_shadows);
for (gsize i = 0; i < n_shadows; i++)
{
gdk_color_init_from_rgba (&shadow2[i].color, &shadow[i].color);
graphene_point_init (&shadow2[i].offset, shadow[i].dx,shadow[i].dy);
shadow2[i].radius = shadow[i].radius;
}
gtk_snapshot_push_shadow2 (snapshot, shadow2, n_shadows);
for (gsize i = 0; i < n_shadows; i++)
gdk_color_finish (&shadow2[i].color);
g_free (shadow2);
}
/*< private >
* gtk_snapshot_push_shadow2:
* @snapshot: a `GtkSnapshot`
* @shadow: (array length=n_shadows): the first shadow specification
* @n_shadows: number of shadow specifications
*
* Applies a shadow to an image.
*
* The image is recorded until the next call to [method@Gtk.Snapshot.pop].
*/
void
gtk_snapshot_push_shadow2 (GtkSnapshot *snapshot,
const GskShadow2 *shadow,
gsize n_shadows)
{
GtkSnapshotState *state;
GskTransform *transform;
@@ -1470,23 +1429,20 @@ gtk_snapshot_push_shadow2 (GtkSnapshot *snapshot,
if (n_shadows == 1)
{
state->data.shadow.shadows = NULL;
gdk_color_init_copy (&state->data.shadow.a_shadow.color, &shadow->color);
graphene_point_init (&state->data.shadow.a_shadow.offset,
shadow->offset.x * scale_x,
shadow->offset.y * scale_y);
state->data.shadow.a_shadow.radius = shadow->radius * scale_x;
memcpy (&state->data.shadow.a_shadow, shadow, sizeof (GskShadow));
state->data.shadow.a_shadow.dx *= scale_x;
state->data.shadow.a_shadow.dy *= scale_y;
state->data.shadow.a_shadow.radius *= scale_x;
}
else
{
state->data.shadow.shadows = g_malloc (sizeof (GskShadow2) * n_shadows);
memcpy (state->data.shadow.shadows, shadow, sizeof (GskShadow2) * n_shadows);
state->data.shadow.shadows = g_malloc (sizeof (GskShadow) * n_shadows);
memcpy (state->data.shadow.shadows, shadow, sizeof (GskShadow) * n_shadows);
for (i = 0; i < n_shadows; i++)
{
gdk_color_init_copy (&state->data.shadow.shadows[i].color, &shadow[i].color);
graphene_point_init (&state->data.shadow.shadows[i].offset,
shadow[i].offset.x * scale_x,
shadow[i].offset.y * scale_y);
state->data.shadow.shadows[i].radius = shadow[i].radius * scale_x;
state->data.shadow.shadows[i].dx *= scale_x;
state->data.shadow.shadows[i].dy *= scale_y;
state->data.shadow.shadows[i].radius *= scale_x;
}
}
@@ -2473,31 +2429,16 @@ gtk_snapshot_append_text (GtkSnapshot *snapshot,
const GdkRGBA *color,
float x,
float y)
{
GdkColor color2;
gdk_color_init_from_rgba (&color2, color);
gtk_snapshot_append_text2 (snapshot, font, glyphs, &color2, x, y);
gdk_color_finish (&color2);
}
void
gtk_snapshot_append_text2 (GtkSnapshot *snapshot,
PangoFont *font,
PangoGlyphString *glyphs,
const GdkColor *color,
float x,
float y)
{
GskRenderNode *node;
float dx, dy;
gtk_snapshot_ensure_translate (snapshot, &dx, &dy);
node = gsk_text_node_new2 (font,
glyphs,
color,
&GRAPHENE_POINT_INIT (x + dx, y + dy));
node = gsk_text_node_new (font,
glyphs,
color,
&GRAPHENE_POINT_INIT (x + dx, y + dy));
if (node == NULL)
return;
@@ -2864,36 +2805,6 @@ gtk_snapshot_append_border (GtkSnapshot *snapshot,
const GskRoundedRect *outline,
const float border_width[4],
const GdkRGBA border_color[4])
{
GdkColor color[4];
for (int i = 0; i < 4; i++)
gdk_color_init_from_rgba (&color[i], &border_color[i]);
gtk_snapshot_append_border2 (snapshot, outline, border_width, color);
for (int i = 0; i < 4; i++)
gdk_color_finish (&color[i]);
}
/*< private >
* gtk_snapshot_append_border2:
* @snapshot: a `GtkSnapshot`
* @outline: the outline of the border
* @border_width: (array fixed-size=4): the stroke width of the border on
* the top, right, bottom and left side respectively.
* @border_color: (array fixed-size=4): the color used on the top, right,
* bottom and left side.
*
* Appends a stroked border rectangle inside the given @outline.
*
* The four sides of the border can have different widths and colors.
*/
void
gtk_snapshot_append_border2 (GtkSnapshot *snapshot,
const GskRoundedRect *outline,
const float border_width[4],
const GdkColor border_color[4])
{
GskRenderNode *node;
GskRoundedRect real_outline;
@@ -2907,14 +2818,14 @@ gtk_snapshot_append_border2 (GtkSnapshot *snapshot,
gtk_snapshot_ensure_affine (snapshot, &scale_x, &scale_y, &dx, &dy);
gsk_rounded_rect_scale_affine (&real_outline, outline, scale_x, scale_y, dx, dy);
node = gsk_border_node_new2 (&real_outline,
(float[4]) {
border_width[0] * scale_y,
border_width[1] * scale_x,
border_width[2] * scale_y,
border_width[3] * scale_x,
},
border_color);
node = gsk_border_node_new (&real_outline,
(float[4]) {
border_width[0] * scale_y,
border_width[1] * scale_x,
border_width[2] * scale_y,
border_width[3] * scale_x,
},
border_color);
gtk_snapshot_append_node_internal (snapshot, node);
}
@@ -2939,36 +2850,6 @@ gtk_snapshot_append_inset_shadow (GtkSnapshot *snapshot,
float dy,
float spread,
float blur_radius)
{
GdkColor color2;
gdk_color_init_from_rgba (&color2, color);
gtk_snapshot_append_inset_shadow2 (snapshot,
outline,
&color2,
&GRAPHENE_POINT_INIT (dx, dy),
spread, blur_radius);
gdk_color_finish (&color2);
}
/*< private >
* gtk_snapshot_append_inset_shadow2:
* @snapshot: a `GtkSnapshot`
* @outline: outline of the region surrounded by shadow
* @color: color of the shadow
* @offset: offset of shadow
* @spread: how far the shadow spreads towards the inside
* @blur_radius: how much blur to apply to the shadow
*
* Appends an inset shadow into the box given by @outline.
*/
void
gtk_snapshot_append_inset_shadow2 (GtkSnapshot *snapshot,
const GskRoundedRect *outline,
const GdkColor *color,
const graphene_point_t *offset,
float spread,
float blur_radius)
{
GskRenderNode *node;
GskRoundedRect real_outline;
@@ -2977,17 +2858,16 @@ gtk_snapshot_append_inset_shadow2 (GtkSnapshot *snapshot,
g_return_if_fail (snapshot != NULL);
g_return_if_fail (outline != NULL);
g_return_if_fail (color != NULL);
g_return_if_fail (offset != NULL);
gtk_snapshot_ensure_affine (snapshot, &scale_x, &scale_y, &x, &y);
gsk_rounded_rect_scale_affine (&real_outline, outline, scale_x, scale_y, x, y);
node = gsk_inset_shadow_node_new2 (&real_outline,
color,
&GRAPHENE_POINT_INIT (scale_x * offset->x,
scale_y * offset->y),
spread,
blur_radius);
node = gsk_inset_shadow_node_new (&real_outline,
color,
scale_x * dx,
scale_y * dy,
spread,
blur_radius);
gtk_snapshot_append_node_internal (snapshot, node);
}
@@ -3012,36 +2892,6 @@ gtk_snapshot_append_outset_shadow (GtkSnapshot *snapshot,
float dy,
float spread,
float blur_radius)
{
GdkColor color2;
gdk_color_init_from_rgba (&color2, color);
gtk_snapshot_append_outset_shadow2 (snapshot,
outline,
&color2,
&GRAPHENE_POINT_INIT (dx, dy),
spread, blur_radius);
gdk_color_finish (&color2);
}
/*< private >
* gtk_snapshot_append_outset_shadow2:
* @snapshot: a `GtkSnapshot`
* @outline: outline of the region surrounded by shadow
* @color: color of the shadow
* @offset: offset of shadow
* @spread: how far the shadow spreads towards the outside
* @blur_radius: how much blur to apply to the shadow
*
* Appends an outset shadow node around the box given by @outline.
*/
void
gtk_snapshot_append_outset_shadow2 (GtkSnapshot *snapshot,
const GskRoundedRect *outline,
const GdkColor *color,
const graphene_point_t *offset,
float spread,
float blur_radius)
{
GskRenderNode *node;
GskRoundedRect real_outline;
@@ -3050,17 +2900,17 @@ gtk_snapshot_append_outset_shadow2 (GtkSnapshot *snapshot,
g_return_if_fail (snapshot != NULL);
g_return_if_fail (outline != NULL);
g_return_if_fail (color != NULL);
g_return_if_fail (offset != NULL);
gtk_snapshot_ensure_affine (snapshot, &scale_x, &scale_y, &x, &y);
gsk_rounded_rect_scale_affine (&real_outline, outline, scale_x, scale_y, x, y);
node = gsk_outset_shadow_node_new2 (&real_outline,
color,
&GRAPHENE_POINT_INIT (scale_x * offset->x,
scale_y * offset->y),
spread,
blur_radius);
node = gsk_outset_shadow_node_new (&real_outline,
color,
scale_x * dx,
scale_y * dy,
spread,
blur_radius);
gtk_snapshot_append_node_internal (snapshot, node);
}

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