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
128 changed files with 2678 additions and 3944 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 -36
View File
@@ -1,41 +1,6 @@
Overview of Changes in 4.15.5, 11-08-2024
Overview of Changes in 4.15.5, xx-xx-xxxx
=========================================
* 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.
+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;
}
+1 -1
View File
@@ -38,7 +38,7 @@
* 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
*/
+8 -1
View File
@@ -78,8 +78,15 @@ GdkColorState * gdk_color_state_new_for_cicp (const GdkCicp
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;
+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))
+14 -44
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,8 +378,6 @@ 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;
@@ -430,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));
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;
}
/**
* gdk_draw_context_end_frame:
* @context: a `GdkDrawContext`
@@ -457,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)
@@ -487,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;
}
/**
@@ -504,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);
+8 -30
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;
@@ -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);
+3 -4
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;
}
@@ -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)
{
+10 -36
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,
@@ -427,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;
@@ -462,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)
@@ -482,21 +480,6 @@ gdk_color_state_from_image_description_bits (ImageDescription *desc)
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;
}
static void
image_desc_info_done (void *data,
struct xx_image_description_info_v4 *info)
@@ -505,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)
{
@@ -517,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)
@@ -525,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
@@ -681,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
@@ -697,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;
}
@@ -729,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);
@@ -773,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
+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,
+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,
+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));
+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
+5
View File
@@ -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));
}
}
+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);
}
-32
View File
@@ -30,16 +30,6 @@ void gtk_snapshot_append_text (GtkSnapshot
const GdkRGBA *color,
float x,
float y);
void gtk_snapshot_append_text2 (GtkSnapshot *snapshot,
PangoFont *font,
PangoGlyphString *glyphs,
const GdkColor *color,
float x,
float y);
void gtk_snapshot_append_layout2 (GtkSnapshot *snapshot,
PangoLayout *layout,
const GdkColor *color);
void gtk_snapshot_push_collect (GtkSnapshot *snapshot);
GskRenderNode * gtk_snapshot_pop_collect (GtkSnapshot *snapshot);
@@ -50,28 +40,6 @@ void gtk_snapshot_push_subsurface (GtkSnapshot
void gtk_snapshot_append_color2 (GtkSnapshot *snapshot,
const GdkColor *color,
const graphene_rect_t *bounds);
void gtk_snapshot_append_border2 (GtkSnapshot *snapshot,
const GskRoundedRect *outline,
const float border_width[4],
const GdkColor border_color[4]);
void gtk_snapshot_append_inset_shadow2 (GtkSnapshot *snapshot,
const GskRoundedRect *outline,
const GdkColor *color,
const graphene_point_t *offset,
float spread,
float blur_radius);
void gtk_snapshot_append_outset_shadow2 (GtkSnapshot *snapshot,
const GskRoundedRect *outline,
const GdkColor *color,
const graphene_point_t *offset,
float spread,
float blur_radius);
void gtk_snapshot_push_shadow2 (GtkSnapshot *snapshot,
const GskShadow2 *shadow,
gsize n_shadows);
G_END_DECLS
-2
View File
@@ -28,8 +28,6 @@
G_BEGIN_DECLS
#define GTK_STYLE_PROVIDER_PRIORITY_INSPECTOR 1000
#define GTK_STYLE_PROVIDER_GET_INTERFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), GTK_TYPE_STYLE_PROVIDER, GtkStyleProviderInterface))
typedef struct _GtkStyleProviderInterface GtkStyleProviderInterface;
+29 -29
View File
@@ -3867,7 +3867,7 @@ render_para (GskPangoRenderer *crenderer,
GtkTextLineDisplay *line_display,
int selection_start_index,
int selection_end_index,
const GdkColor *selection_color,
const GdkRGBA *selection,
gboolean draw_selection_text,
float cursor_alpha)
{
@@ -3921,11 +3921,11 @@ render_para (GskPangoRenderer *crenderer,
*/
if (selection_start_index < byte_offset &&
selection_end_index > pango_layout_line_get_length (line) + byte_offset &&
gdk_color_is_opaque (selection_color))
selection->alpha >= 1)
{
gtk_snapshot_append_color2 (crenderer->snapshot,
selection_color,
&GRAPHENE_RECT_INIT (line_display->left_margin,
gtk_snapshot_append_color (crenderer->snapshot,
selection,
&GRAPHENE_RECT_INIT (line_display->left_margin,
selection_y,
screen_width,
selection_height));
@@ -3990,7 +3990,7 @@ render_para (GskPangoRenderer *crenderer,
PANGO_PIXELS (line_rect.width) -
bounds.origin.x);
gtk_snapshot_append_color2 (crenderer->snapshot, selection_color, &bounds);
gtk_snapshot_append_color (crenderer->snapshot, selection, &bounds);
if (draw_selection_text)
{
@@ -4009,12 +4009,12 @@ render_para (GskPangoRenderer *crenderer,
if (line_rect.x > line_display->left_margin * PANGO_SCALE &&
((line_display->direction == GTK_TEXT_DIR_LTR && selection_start_index < byte_offset) ||
(line_display->direction == GTK_TEXT_DIR_RTL && selection_end_index > byte_offset + pango_layout_line_get_length (line))))
gtk_snapshot_append_color2 (crenderer->snapshot,
selection_color,
&GRAPHENE_RECT_INIT (line_display->left_margin,
selection_y,
PANGO_PIXELS (line_rect.x) - line_display->left_margin,
selection_height));
gtk_snapshot_append_color (crenderer->snapshot,
selection,
&GRAPHENE_RECT_INIT (line_display->left_margin,
selection_y,
PANGO_PIXELS (line_rect.x) - line_display->left_margin,
selection_height));
if (line_rect.x + line_rect.width <
(screen_width + line_display->left_margin) * PANGO_SCALE &&
@@ -4025,9 +4025,9 @@ render_para (GskPangoRenderer *crenderer,
+ screen_width
- PANGO_PIXELS (line_rect.x)
- PANGO_PIXELS (line_rect.width);
gtk_snapshot_append_color2 (crenderer->snapshot,
selection_color,
&GRAPHENE_RECT_INIT (PANGO_PIXELS (line_rect.x) + PANGO_PIXELS (line_rect.width),
gtk_snapshot_append_color (crenderer->snapshot,
selection,
&GRAPHENE_RECT_INIT (PANGO_PIXELS (line_rect.x) + PANGO_PIXELS (line_rect.width),
selection_y,
nonlayout_width,
selection_height));
@@ -4042,7 +4042,7 @@ render_para (GskPangoRenderer *crenderer,
{
GtkCssNode *node;
GtkCssStyle *style;
GdkColor cursor_color;
const GdkRGBA *cursor_color;
graphene_rect_t bounds = {
.origin.x = line_display->x_offset + line_display->block_cursor.x,
.origin.y = line_display->block_cursor.y + line_display->top_margin,
@@ -4056,11 +4056,10 @@ render_para (GskPangoRenderer *crenderer,
node = gtk_widget_get_css_node (crenderer->widget);
style = gtk_css_node_get_style (node);
gtk_css_color_to_color (gtk_css_color_value_get_color (style->used->caret_color),
&cursor_color);
cursor_color = gtk_css_color_value_get_rgba (style->used->caret_color);
gtk_snapshot_push_opacity (crenderer->snapshot, cursor_alpha);
gtk_snapshot_append_color2 (crenderer->snapshot, &cursor_color, &bounds);
gtk_snapshot_append_color (crenderer->snapshot, cursor_color, &bounds);
/* draw text under the cursor if any */
if (!line_display->cursor_at_line_end)
@@ -4115,7 +4114,8 @@ gtk_text_layout_snapshot (GtkTextLayout *layout,
int selection_end_line;
gboolean have_selection;
gboolean draw_selection_text;
GdkColor selection_color;
const GdkRGBA *selection;
const GdkRGBA *color;
GtkSnapshot *cursor_snapshot;
GtkTextBTree *btree;
GtkTextLine *first_line;
@@ -4146,6 +4146,8 @@ gtk_text_layout_snapshot (GtkTextLayout *layout,
node = gtk_widget_get_css_node (widget);
style = gtk_css_node_get_style (node);
color = gtk_css_color_value_get_rgba (style->used->color);
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (0, offset_y));
offset_y = 0;
@@ -4157,8 +4159,7 @@ gtk_text_layout_snapshot (GtkTextLayout *layout,
crenderer->widget = widget;
crenderer->snapshot = snapshot;
gtk_css_color_to_color (gtk_css_color_value_get_color (style->used->color),
&crenderer->fg_color);
crenderer->fg_color = color;
have_selection = gtk_text_buffer_get_selection_bounds (layout->buffer,
&selection_start,
@@ -4166,6 +4167,7 @@ gtk_text_layout_snapshot (GtkTextLayout *layout,
if (have_selection)
{
GtkCssNode *selection_node;
const GdkRGBA *text_color;
selection_start_line = gtk_text_iter_get_line (&selection_start);
selection_end_line = gtk_text_iter_get_line (&selection_end);
@@ -4173,16 +4175,16 @@ gtk_text_layout_snapshot (GtkTextLayout *layout,
selection_node = gtk_text_view_get_selection_node ((GtkTextView*)widget);
style = gtk_css_node_get_style (selection_node);
gtk_css_color_to_color (gtk_css_color_value_get_color (style->used->background_color),
&selection_color);
selection = gtk_css_color_value_get_rgba (style->used->background_color);
text_color = gtk_css_color_value_get_rgba (style->used->color);
draw_selection_text = !gdk_color_is_clear (&crenderer->fg_color);
draw_selection_text = text_color->alpha > 0;
}
else
{
selection_start_line = -1;
selection_end_line = -1;
gdk_color_init (&selection_color, GDK_COLOR_STATE_SRGB, (float[]) { 0, 0, 0, 0 });
selection = NULL;
draw_selection_text = FALSE;
}
@@ -4258,7 +4260,7 @@ gtk_text_layout_snapshot (GtkTextLayout *layout,
gtk_snapshot_push_collect (snapshot);
render_para (crenderer, line_display,
selection_start_index, selection_end_index,
&selection_color,
selection,
draw_selection_text,
cursor_alpha);
line_display->node = gtk_snapshot_pop_collect (snapshot);
@@ -4333,8 +4335,6 @@ gtk_text_layout_snapshot (GtkTextLayout *layout,
/* Only update eviction source once per snapshot */
gtk_text_line_display_cache_delay_eviction (priv->cache);
gdk_color_finish (&crenderer->fg_color);
gsk_pango_renderer_release (crenderer);
}
+42
View File
@@ -470,6 +470,8 @@ static void gtk_window_activate_close (GtkWidget *widget,
const char *action_name,
GVariant *parameter);
static void gtk_window_css_changed (GtkWidget *widget,
GtkCssStyleChange *change);
static void _gtk_window_set_is_active (GtkWindow *window,
gboolean is_active);
static void gtk_window_present_toplevel (GtkWindow *window);
@@ -780,6 +782,7 @@ gtk_window_class_init (GtkWindowClass *klass)
widget_class->focus = gtk_window_focus;
widget_class->move_focus = gtk_window_move_focus;
widget_class->measure = gtk_window_measure;
widget_class->css_changed = gtk_window_css_changed;
klass->activate_default = gtk_window_real_activate_default;
klass->activate_focus = gtk_window_real_activate_focus;
@@ -4056,6 +4059,30 @@ out:
*shadow_width = (GtkBorder) {0, 0, 0, 0};
}
static void
update_opaque_region (GtkWindow *window)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
gboolean subtract_decoration_corners;
gboolean subtract_shadow;
subtract_decoration_corners = (priv->client_decorated &&
priv->decorated &&
!priv->fullscreen &&
!priv->maximized);
subtract_shadow = (priv->client_decorated &&
priv->decorated &&
priv->use_client_shadow &&
!priv->maximized &&
!priv->fullscreen);
gtk_native_update_opaque_region (GTK_NATIVE (window),
NULL,
subtract_decoration_corners,
subtract_shadow,
RESIZE_HANDLE_SIZE);
}
static void
update_realized_window_properties (GtkWindow *window)
{
@@ -4065,6 +4092,8 @@ update_realized_window_properties (GtkWindow *window)
const graphene_rect_t *border_rect;
double native_x, native_y;
update_opaque_region (window);
if (!priv->client_decorated || !priv->use_client_shadow)
return;
@@ -5171,6 +5200,19 @@ gtk_window_set_focus (GtkWindow *window,
gtk_window_root_set_focus (GTK_ROOT (window), NULL);
}
static void
gtk_window_css_changed (GtkWidget *widget,
GtkCssStyleChange *change)
{
GtkWindow *window = GTK_WINDOW (widget);
GTK_WIDGET_CLASS (gtk_window_parent_class)->css_changed (widget, change);
if (!_gtk_widget_get_alloc_needed (widget) &&
(change == NULL || gtk_css_style_change_changes_property (change, GTK_CSS_PROPERTY_BACKGROUND_COLOR)))
update_opaque_region (window);
}
/*
* _gtk_window_unset_focus_and_default:
* @window: a `GtkWindow`
+6 -6
View File
@@ -26,15 +26,15 @@
#include "window.h"
#include "css-editor.h"
#include "gtkalertdialog.h"
#include "gtkcssprovider.h"
#include "gtkfiledialog.h"
#include "gtklabel.h"
#include "gtkstyleproviderprivate.h"
#include "gtktextiter.h"
#include "gtkstyleprovider.h"
#include "gtktextview.h"
#include "gtkalertdialog.h"
#include "gtkfiledialog.h"
#include "gtktogglebutton.h"
#include "gtklabel.h"
#include "gtktooltip.h"
#include "gtktextiter.h"
#include "gtk/css/gtkcss.h"
@@ -174,7 +174,7 @@ disable_toggled (GtkToggleButton *button,
else
gtk_style_context_add_provider_for_display (ce->priv->display,
GTK_STYLE_PROVIDER (ce->priv->provider),
GTK_STYLE_PROVIDER_PRIORITY_INSPECTOR);
GTK_STYLE_PROVIDER_PRIORITY_USER);
}
static void
+78 -79
View File
@@ -236,15 +236,9 @@ static GParamSpec *props[LAST_PROP] = { NULL, };
G_DEFINE_TYPE (GtkInspectorRecorder, gtk_inspector_recorder, GTK_TYPE_WIDGET)
typedef struct
{
GskRenderNode *node;
const char *role;
} RenderNode;
static GListModel *
create_render_node_list_model (RenderNode *nodes,
guint n_nodes)
create_render_node_list_model (GskRenderNode **nodes,
guint n_nodes)
{
GListStore *store;
guint i;
@@ -255,11 +249,9 @@ create_render_node_list_model (RenderNode *nodes,
for (i = 0; i < n_nodes; i++)
{
graphene_rect_t bounds;
GdkPaintable *paintable;
gsk_render_node_get_bounds (nodes[i].node, &bounds);
paintable = gtk_render_node_paintable_new (nodes[i].node, &bounds);
g_object_set_data (G_OBJECT (paintable), "role", (gpointer) nodes[i].role);
gsk_render_node_get_bounds (nodes[i], &bounds);
GdkPaintable *paintable = gtk_render_node_paintable_new (nodes[i], &bounds);
g_list_store_append (store, paintable);
g_object_unref (paintable);
}
@@ -294,46 +286,46 @@ create_list_model_for_render_node (GskRenderNode *node)
return NULL;
case GSK_TRANSFORM_NODE:
return create_render_node_list_model (&(RenderNode) { gsk_transform_node_get_child (node), NULL }, 1);
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_transform_node_get_child (node) }, 1);
case GSK_OPACITY_NODE:
return create_render_node_list_model (&(RenderNode) { gsk_opacity_node_get_child (node), NULL }, 1);
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_opacity_node_get_child (node) }, 1);
case GSK_COLOR_MATRIX_NODE:
return create_render_node_list_model (&(RenderNode) { gsk_color_matrix_node_get_child (node), NULL }, 1);
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_color_matrix_node_get_child (node) }, 1);
case GSK_BLUR_NODE:
return create_render_node_list_model (&(RenderNode) { gsk_blur_node_get_child (node), NULL }, 1);
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_blur_node_get_child (node) }, 1);
case GSK_REPEAT_NODE:
return create_render_node_list_model (&(RenderNode) { gsk_repeat_node_get_child (node), NULL }, 1);
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_repeat_node_get_child (node) }, 1);
case GSK_CLIP_NODE:
return create_render_node_list_model (&(RenderNode) { gsk_clip_node_get_child (node), NULL }, 1);
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_clip_node_get_child (node) }, 1);
case GSK_ROUNDED_CLIP_NODE:
return create_render_node_list_model (&(RenderNode) { gsk_rounded_clip_node_get_child (node), NULL }, 1);
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_rounded_clip_node_get_child (node) }, 1);
case GSK_FILL_NODE:
return create_render_node_list_model (&(RenderNode) { gsk_fill_node_get_child (node), NULL }, 1);
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_fill_node_get_child (node) }, 1);
case GSK_STROKE_NODE:
return create_render_node_list_model (&(RenderNode) { gsk_stroke_node_get_child (node), NULL }, 1);
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_stroke_node_get_child (node) }, 1);
case GSK_SHADOW_NODE:
return create_render_node_list_model (&(RenderNode) { gsk_shadow_node_get_child (node), NULL }, 1);
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_shadow_node_get_child (node) }, 1);
case GSK_BLEND_NODE:
return create_render_node_list_model ((RenderNode[2]) { { gsk_blend_node_get_bottom_child (node), "Bottom" },
{ gsk_blend_node_get_top_child (node), "Top" } }, 2);
return create_render_node_list_model ((GskRenderNode *[2]) { gsk_blend_node_get_bottom_child (node),
gsk_blend_node_get_top_child (node) }, 2);
case GSK_MASK_NODE:
return create_render_node_list_model ((RenderNode[2]) { { gsk_mask_node_get_source (node), "Source" },
{ gsk_mask_node_get_mask (node), "Mask" } }, 2);
return create_render_node_list_model ((GskRenderNode *[2]) { gsk_mask_node_get_source (node),
gsk_mask_node_get_mask (node) }, 2);
case GSK_CROSS_FADE_NODE:
return create_render_node_list_model ((RenderNode[2]) { { gsk_cross_fade_node_get_start_child (node), "Start" },
{ gsk_cross_fade_node_get_end_child (node), "End" } }, 2);
return create_render_node_list_model ((GskRenderNode *[2]) { gsk_cross_fade_node_get_start_child (node),
gsk_cross_fade_node_get_end_child (node) }, 2);
case GSK_GL_SHADER_NODE:
{
@@ -380,10 +372,10 @@ G_GNUC_END_IGNORE_DEPRECATIONS
}
case GSK_DEBUG_NODE:
return create_render_node_list_model (&(RenderNode) { gsk_debug_node_get_child (node), NULL }, 1);
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_debug_node_get_child (node) }, 1);
case GSK_SUBSURFACE_NODE:
return create_render_node_list_model (&(RenderNode) { gsk_subsurface_node_get_child (node), NULL }, 1);
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_subsurface_node_get_child (node) }, 1);
}
}
@@ -834,6 +826,19 @@ get_color2_texture (const GdkColor *color)
return texture;
}
static GdkTexture *
get_color_texture (const GdkRGBA *rgba)
{
GdkColor color;
GdkTexture *texture;
gdk_color_init_from_rgba (&color, rgba);
texture = get_color2_texture (&color);
gdk_color_finish (&color);
return texture;
}
static GdkTexture *
get_linear_gradient_texture (gsize n_stops, const GskColorStop *stops)
{
@@ -902,9 +907,24 @@ add_text_row (GListStore *store,
}
static void
add_color_row (GListStore *store,
const char *name,
const GdkColor *color)
add_color_row (GListStore *store,
const char *name,
const GdkRGBA *color)
{
char *text;
GdkTexture *texture;
text = gdk_rgba_to_string (color);
texture = get_color_texture (color);
list_store_add_object_property (store, name, text, texture);
g_free (text);
g_object_unref (texture);
}
static void
add_color2_row (GListStore *store,
const char *name,
const GdkColor *color)
{
char *text;
GdkTexture *texture;
@@ -1011,40 +1031,22 @@ add_texture_rows (GListStore *store,
static void
populate_render_node_properties (GListStore *store,
GskRenderNode *node,
const char *role)
GskRenderNode *node)
{
graphene_rect_t bounds, opaque;
graphene_rect_t bounds;
g_list_store_remove_all (store);
gsk_render_node_get_bounds (node, &bounds);
if (role)
add_text_row (store, "Role", "%s", role);
add_text_row (store, "Type", "%s", node_type_name (gsk_render_node_get_node_type (node)));
add_text_row (store, "Bounds",
"(%.2f, %.2f) to (%.2f, %.2f) - %.2f x %.2f",
bounds.origin.x,
bounds.origin.y,
bounds.origin.x + bounds.size.width,
bounds.origin.y + bounds.size.height,
"%.2f x %.2f + %.2f + %.2f",
bounds.size.width,
bounds.size.height);
if (gsk_render_node_get_opaque_rect (node, &opaque))
add_text_row (store, "Opaque",
"(%.2f, %.2f) to (%.2f, %.2f) - %.2f x %.2f",
opaque.origin.x,
opaque.origin.y,
opaque.origin.x + opaque.size.width,
opaque.origin.y + opaque.size.height,
opaque.size.width,
opaque.size.height);
else
add_text_row (store, "Opaque", "no");
bounds.size.height,
bounds.origin.x,
bounds.origin.y);
switch (gsk_render_node_get_node_type (node))
{
@@ -1096,7 +1098,7 @@ populate_render_node_properties (GListStore *store,
break;
case GSK_COLOR_NODE:
add_color_row (store, "Color", gsk_color_node_get_color2 (node));
add_color2_row (store, "Color", gsk_color_node_get_color2 (node));
break;
case GSK_LINEAR_GRADIENT_NODE:
@@ -1194,6 +1196,7 @@ populate_render_node_properties (GListStore *store,
case GSK_TEXT_NODE:
{
const PangoFont *font = gsk_text_node_get_font (node);
const GdkRGBA *color = gsk_text_node_get_color (node);
const graphene_point_t *offset = gsk_text_node_get_offset (node);
PangoFontDescription *desc;
GString *s;
@@ -1212,7 +1215,7 @@ populate_render_node_properties (GListStore *store,
add_text_row (store, "Position", "%.2f %.2f", offset->x, offset->y);
add_color_row (store, "Color", gsk_text_node_get_color2 (node));
add_color_row (store, "Color", color);
}
break;
@@ -1220,7 +1223,7 @@ populate_render_node_properties (GListStore *store,
{
const char *name[4] = { "Top", "Right", "Bottom", "Left" };
const float *widths = gsk_border_node_get_widths (node);
const GdkColor *colors = gsk_border_node_get_colors2 (node);
const GdkRGBA *colors = gsk_border_node_get_colors (node);
int i;
for (i = 0; i < 4; i++)
@@ -1228,9 +1231,9 @@ populate_render_node_properties (GListStore *store,
GdkTexture *texture;
char *text, *tmp;
text = gdk_color_to_string (&colors[i]);
text = gdk_rgba_to_string (&colors[i]);
tmp = g_strdup_printf ("%.2f, %s", widths[i], text);
texture = get_color2_texture (&colors[i]);
texture = get_color_texture (&colors[i]);
list_store_add_object_property (store, name[i], tmp, texture);
g_object_unref (texture);
@@ -1352,7 +1355,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
case GSK_INSET_SHADOW_NODE:
{
const GdkColor *color = gsk_inset_shadow_node_get_color2 (node);
const GdkRGBA *color = gsk_inset_shadow_node_get_color (node);
float dx = gsk_inset_shadow_node_get_dx (node);
float dy = gsk_inset_shadow_node_get_dy (node);
float spread = gsk_inset_shadow_node_get_spread (node);
@@ -1370,7 +1373,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
case GSK_OUTSET_SHADOW_NODE:
{
const GskRoundedRect *outline = gsk_outset_shadow_node_get_outline (node);
const GdkColor *color = gsk_outset_shadow_node_get_color2 (node);
const GdkRGBA *color = gsk_outset_shadow_node_get_color (node);
float dx = gsk_outset_shadow_node_get_dx (node);
float dy = gsk_outset_shadow_node_get_dy (node);
float spread = gsk_outset_shadow_node_get_spread (node);
@@ -1515,14 +1518,14 @@ G_GNUC_END_IGNORE_DEPRECATIONS
for (i = 0; i < gsk_shadow_node_get_n_shadows (node); i++)
{
char *label;
const GskShadow2 *shadow = gsk_shadow_node_get_shadow2 (node, i);
const GskShadow *shadow = gsk_shadow_node_get_shadow (node, i);
label = g_strdup_printf ("Color %d", i);
add_color_row (store, label, &shadow->color);
g_free (label);
label = g_strdup_printf ("Offset %d", i);
add_text_row (store, label, "%.2f %.2f", shadow->offset.x, shadow->offset.y);
add_text_row (store, label, "%.2f %.2f", shadow->dx, shadow->dy);
g_free (label);
label = g_strdup_printf ("Radius %d", i);
@@ -1535,15 +1538,13 @@ G_GNUC_END_IGNORE_DEPRECATIONS
case GSK_TRANSFORM_NODE:
{
static const char * category_names[] = {
[GSK_FINE_TRANSFORM_CATEGORY_UNKNOWN] = "unknown",
[GSK_FINE_TRANSFORM_CATEGORY_ANY] = "any",
[GSK_FINE_TRANSFORM_CATEGORY_3D] = "3D",
[GSK_FINE_TRANSFORM_CATEGORY_2D] = "2D",
[GSK_FINE_TRANSFORM_CATEGORY_2D_DIHEDRAL] = "2D dihedral",
[GSK_FINE_TRANSFORM_CATEGORY_2D_NEGATIVE_AFFINE] = "2D negative affine",
[GSK_FINE_TRANSFORM_CATEGORY_2D_AFFINE] = "2D affine",
[GSK_FINE_TRANSFORM_CATEGORY_2D_TRANSLATE] = "2D translate",
[GSK_FINE_TRANSFORM_CATEGORY_IDENTITY] = "identity"
[GSK_TRANSFORM_CATEGORY_UNKNOWN] = "unknown",
[GSK_TRANSFORM_CATEGORY_ANY] = "any",
[GSK_TRANSFORM_CATEGORY_3D] = "3D",
[GSK_TRANSFORM_CATEGORY_2D] = "2D",
[GSK_TRANSFORM_CATEGORY_2D_AFFINE] = "2D affine",
[GSK_TRANSFORM_CATEGORY_2D_TRANSLATE] = "2D translate",
[GSK_TRANSFORM_CATEGORY_IDENTITY] = "identity"
};
GskTransform *transform;
char *s;
@@ -1552,7 +1553,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
s = gsk_transform_to_string (transform);
add_text_row (store, "Matrix", "%s", s);
g_free (s);
add_text_row (store, "Category", "%s", category_names[gsk_transform_get_fine_category (transform)]);
add_text_row (store, "Category", "%s", category_names[gsk_transform_get_category (transform)]);
}
break;
@@ -1937,7 +1938,6 @@ render_node_list_selection_changed (GtkListBox *list,
GskRenderNode *node;
GdkPaintable *paintable;
GtkTreeListRow *row_item;
const char *role;
row_item = gtk_single_selection_get_selected_item (recorder->render_node_selection);
@@ -1951,8 +1951,7 @@ render_node_list_selection_changed (GtkListBox *list,
gtk_picture_set_paintable (GTK_PICTURE (recorder->render_node_view), paintable);
node = gtk_render_node_paintable_get_render_node (GTK_RENDER_NODE_PAINTABLE (paintable));
role = g_object_get_data (G_OBJECT (paintable), "role");
populate_render_node_properties (recorder->render_node_properties, node, role);
populate_render_node_properties (recorder->render_node_properties, node);
g_object_unref (paintable);
}
+14 -21
View File
@@ -26,7 +26,6 @@ cloudproviders_req = '>= 0.3.1'
xkbcommon_req = '>= 0.2.0'
sysprof_req = '>= 3.38.0'
vulkan_req = '>= 1.3'
gstreamer_req = '>= 1.24.0'
fs = import('fs')
gnome = import('gnome')
@@ -411,27 +410,21 @@ if win32_enabled
pangowin32_dep = dependency('pangowin32')
endif
pangocairo_dep = dependency('pangocairo', version: pango_req)
pixbuf_dep = dependency('gdk-pixbuf-2.0', version: gdk_pixbuf_req,
default_options: ['png=enabled', 'jpeg=enabled', 'builtin_loaders=png,jpeg', 'man=false'])
png_dep = dependency('libpng', 'png')
tiff_dep = dependency('libtiff-4', 'tiff')
jpeg_dep = dependency('libjpeg', 'jpeg')
pangocairo_dep = dependency('pangocairo', version: pango_req)
pixbuf_dep = dependency('gdk-pixbuf-2.0', version: gdk_pixbuf_req,
default_options: ['png=enabled', 'jpeg=enabled', 'builtin_loaders=png,jpeg', 'man=false'])
png_dep = dependency('libpng', 'png')
tiff_dep = dependency('libtiff-4', 'tiff')
jpeg_dep = dependency('libjpeg', 'jpeg')
epoxy_dep = dependency('epoxy', version: epoxy_req)
xkbdep = dependency('xkbcommon', version: xkbcommon_req, required: wayland_enabled)
graphene_dep = dependency('graphene-gobject-1.0', version: graphene_req,
default_options: ['tests=false', 'gobject_types=true'])
iso_codes_dep = dependency('iso-codes', required: false)
gi_dep = dependency('gobject-introspection-1.0', version: introspection_req,
required: get_option('introspection').enabled() and
get_option('build-tests'))
gstplayer_dep = dependency('gstreamer-player-1.0', version: gstreamer_req,
required: get_option('media-gstreamer'))
gstgl_dep = dependency('gstreamer-gl-1.0', version: gstreamer_req,
required: get_option('media-gstreamer'))
gstallocators_dep = dependency('gstreamer-allocators-1.0', version: gstreamer_req,
required: get_option('media-gstreamer'))
epoxy_dep = dependency('epoxy', version: epoxy_req)
xkbdep = dependency('xkbcommon', version: xkbcommon_req, required: wayland_enabled)
graphene_dep = dependency('graphene-gobject-1.0', version: graphene_req,
default_options: ['tests=false', 'gobject_types=true'])
iso_codes_dep = dependency('iso-codes', required: false)
gi_dep = dependency('gobject-introspection-1.0', version: introspection_req,
required: get_option('introspection').enabled() and
get_option('build-tests'))
fontconfig_dep = [] # only used in x11 backend
+54 -22
View File
@@ -52,8 +52,10 @@
#include <gst/gl/gstglfuncs.h>
#ifdef HAVE_GSTREAMER_DRM
#include <gdk/gdkdmabuffourccprivate.h>
#include <gst/allocators/gstdmabuf.h>
#endif
enum {
PROP_0,
@@ -70,11 +72,17 @@ GST_DEBUG_CATEGORY (gtk_debug_gst_sink);
#define NOGL_CAPS GST_VIDEO_CAPS_MAKE (FORMATS)
#ifdef HAVE_GSTREAMER_DRM
# define GST_VIDEO_DMA_DRM_CAPS_MAKE_STR GST_VIDEO_DMA_DRM_CAPS_MAKE "; "
#else
# define GST_VIDEO_DMA_DRM_CAPS_MAKE_STR
#endif
static GstStaticPadTemplate gtk_gst_sink_template =
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_VIDEO_DMA_DRM_CAPS_MAKE "; "
GST_STATIC_CAPS (GST_VIDEO_DMA_DRM_CAPS_MAKE_STR
"video/x-raw(" GST_CAPS_FEATURE_MEMORY_GL_MEMORY "), "
"format = (string) RGBA, "
"width = " GST_VIDEO_SIZE_RANGE ", "
@@ -122,6 +130,7 @@ gtk_gst_sink_get_times (GstBaseSink *bsink,
}
}
#ifdef HAVE_GSTREAMER_DRM
static void
add_drm_formats_and_modifiers (GstCaps *caps,
GdkDmabufFormats *dmabuf_formats)
@@ -155,6 +164,7 @@ add_drm_formats_and_modifiers (GstCaps *caps,
gst_structure_take_value (gst_caps_get_structure (caps, 0), "drm-format",
&dmabuf_list);
}
#endif
static GdkColorState *
gtk_gst_color_state_from_colorimetry (GtkGstSink *self,
@@ -209,12 +219,16 @@ gtk_gst_sink_get_caps (GstBaseSink *bsink,
if (self->gst_context)
{
GdkDisplay *display = gdk_gl_context_get_display (self->gdk_context);
GdkDmabufFormats *formats = gdk_display_get_dmabuf_formats (display);
tmp = gst_pad_get_pad_template_caps (GST_BASE_SINK_PAD (bsink));
tmp = gst_caps_make_writable (tmp);
add_drm_formats_and_modifiers (tmp, formats);
#ifdef HAVE_GSTREAMER_DRM
{
GdkDisplay *display = gdk_gl_context_get_display (self->gdk_context);
GdkDmabufFormats *formats = gdk_display_get_dmabuf_formats (display);
tmp = gst_caps_make_writable (tmp);
add_drm_formats_and_modifiers (tmp, formats);
}
#endif
}
else
{
@@ -247,23 +261,24 @@ gtk_gst_sink_set_caps (GstBaseSink *bsink,
GST_DEBUG_OBJECT (self, "set caps with %" GST_PTR_FORMAT, caps);
if (gst_video_is_dma_drm_caps (caps))
{
if (!gst_video_info_dma_drm_from_caps (&self->drm_info, caps))
return FALSE;
#ifdef HAVE_GSTREAMER_DRM
if (gst_video_is_dma_drm_caps (caps)) {
if (!gst_video_info_dma_drm_from_caps (&self->drm_info, caps))
return FALSE;
if (!gst_video_info_dma_drm_to_video_info (&self->drm_info, &self->v_info))
return FALSE;
if (!gst_video_info_dma_drm_to_video_info (&self->drm_info, &self->v_info))
return FALSE;
GST_INFO_OBJECT (self, "using DMABuf, passthrough possible");
}
else
{
gst_video_info_dma_drm_init (&self->drm_info);
GST_INFO_OBJECT (self, "using DMABuf, passthrough possible");
} else {
gst_video_info_dma_drm_init (&self->drm_info);
#endif
if (!gst_video_info_from_caps (&self->v_info, caps))
return FALSE;
}
if (!gst_video_info_from_caps (&self->v_info, caps))
return FALSE;
#ifdef HAVE_GSTREAMER_DRM
}
#endif
g_clear_pointer (&self->color_state, gdk_color_state_unref);
self->color_state = gtk_gst_color_state_from_colorimetry (self, &self->v_info.colorimetry);
@@ -310,11 +325,13 @@ gtk_gst_sink_propose_allocation (GstBaseSink *bsink,
return FALSE;
}
#ifdef HAVE_GSTREAMER_DRM
if (gst_caps_features_contains (gst_caps_get_features (caps, 0), GST_CAPS_FEATURE_MEMORY_DMABUF))
{
gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE, 0);
return TRUE;
}
#endif
if (!gst_caps_features_contains (gst_caps_get_features (caps, 0), GST_CAPS_FEATURE_MEMORY_GL_MEMORY))
return FALSE;
@@ -407,6 +424,7 @@ gtk_gst_sink_texture_from_buffer (GtkGstSink *self,
viewport->size.width = GST_VIDEO_INFO_WIDTH (&self->v_info);
viewport->size.height = GST_VIDEO_INFO_HEIGHT (&self->v_info);
#ifdef HAVE_GSTREAMER_DRM
if (gst_is_dmabuf_memory (gst_buffer_peek_memory (buffer, 0)))
{
GdkDmabufTextureBuilder *builder = NULL;
@@ -465,8 +483,10 @@ gtk_gst_sink_texture_from_buffer (GtkGstSink *self,
*pixel_aspect_ratio = ((double) GST_VIDEO_INFO_PAR_N (&self->v_info) /
(double) GST_VIDEO_INFO_PAR_D (&self->v_info));
}
else if (self->gdk_context &&
gst_video_frame_map (frame, &self->v_info, buffer, GST_MAP_READ | GST_MAP_GL))
else
#endif
if (self->gdk_context &&
gst_video_frame_map (frame, &self->v_info, buffer, GST_MAP_READ | GST_MAP_GL))
{
GstGLSyncMeta *sync_meta;
GdkGLTextureBuilder *builder;
@@ -685,8 +705,20 @@ gtk_gst_sink_initialize_gl (GtkGstSink *self)
if (gl_api & (GST_GL_API_OPENGL3 | GST_GL_API_OPENGL))
{
#ifdef HAVE_GST_GL_DISPLAY_NEW_WITH_TYPE
self->gst_display = gst_gl_display_new_with_type (GST_GL_DISPLAY_TYPE_WIN32);
#else
#if GST_GL_HAVE_PLATFORM_EGL
g_message ("If media fails to play, set the envvar `GST_DEBUG=1`, and if GstGL context creation fails");
g_message ("due to \"Couldn't create GL context: Cannot share context with non-EGL context\",");
g_message ("set in the environment `GST_GL_PLATFORM=wgl` and `GST_GL_WINDOW=win32`,");
g_message ("and restart the GTK application");
#endif
self->gst_display = gst_gl_display_new ();
#endif
}
#if GST_GL_HAVE_PLATFORM_EGL
else
{
+2
View File
@@ -47,7 +47,9 @@ struct _GtkGstSink
GstVideoSink parent;
GstVideoInfo v_info;
#ifdef HAVE_GSTREAMER_DRM
GstVideoInfoDmaDrm drm_info;
#endif
GtkGstPaintable * paintable;
GdkGLContext * gdk_context;
+22 -3
View File
@@ -5,10 +5,29 @@ media_backends = []
extra_c_args = ['-DGTK_COMPILATION']
extra_c_args += common_cflags
if gstplayer_dep.found() and gstgl_dep.found() and gstallocators_dep.found()
gstplayer_dep = dependency('gstreamer-player-1.0', version: '>= 1.12.3',
required: get_option('media-gstreamer'))
gstgl_dep = dependency('gstreamer-gl-1.0', version: '>= 1.12.3',
required: get_option('media-gstreamer'))
gstdrm_dep = dependency('gstreamer-allocators-1.0', version: '>= 1.23.1',
required: false)
if gstplayer_dep.found() and gstgl_dep.found()
extra_win_cflags = []
if host_machine.system() == 'windows' and gstgl_dep.version().version_compare('>=1.19.1')
message('libgstgl has gst_gl_display_new_with_type()')
extra_win_cflags += '-DHAVE_GST_GL_DISPLAY_NEW_WITH_TYPE'
endif
media_backends += 'gstreamer'
cdata.set('HAVE_GSTREAMER', 1)
media_gst_deps = [ libm, libgtk_dep, gstplayer_dep, gstgl_dep, gstallocators_dep ]
media_gst_deps = [ libm, libgtk_dep, gstplayer_dep, gstgl_dep ]
if libdrm_dep.found() and gstdrm_dep.found()
cdata.set('HAVE_GSTREAMER_DRM', 1)
media_gst_deps += [ gstdrm_dep ]
endif
shared_module('media-gstreamer',
sources: [
@@ -16,7 +35,7 @@ if gstplayer_dep.found() and gstgl_dep.found() and gstallocators_dep.found()
'gtkgstpaintable.c',
'gtkgstsink.c',
],
c_args: extra_c_args,
c_args: extra_c_args + extra_win_cflags,
dependencies: media_gst_deps,
name_suffix: module_suffix,
install_dir: media_install_dir,
+590 -1094
View File
File diff suppressed because it is too large Load Diff

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