Compare commits

...

14 Commits

Author SHA1 Message Date
Emmanuele Bassi 0fa41887f1 Snapshot/WIP: Add shaderc to the manifest 2024-01-12 23:19:10 +00:00
Matthias Clasen c146f225ff Merge branch 'big-glyph-test' into 'main'
gsk: Fix big glyphs getting clipped

See merge request GNOME/gtk!6744
2024-01-12 21:31:35 +00:00
Matthias Clasen 9f4f65be4a gsk: Add test for clipped big glyphs
Tests the fix in the previous commit 93715b963e.

Sadly, the flipped variant of this test fails with the cairo
renderer, so it is marked as -nocairo. All the other renderers
pass it.
2024-01-12 16:02:05 -05:00
Matthias Clasen 93715b963e gsk: Fix big glyphs getting clipped
We were inadvertedly shifting the rendering by one pixel.
2024-01-12 15:55:27 -05:00
Benjamin Otte c1407f2ca6 Merge branch 'wip/otte/for-main' into 'main'
gpu: Remove unnecessary optimization

Closes #6322

See merge request GNOME/gtk!6743
2024-01-12 19:23:46 +00:00
Benjamin Otte 3b299f574d testsuite: Add a test for contained clips
Related: #6322
2024-01-12 20:06:04 +01:00
Benjamin Otte a51c6aed47 gpu: Introduce "contained" clip
This clip is different from "none" in that the bounds rect cannot be
ignored and that potential drawing outside the clip must be avoided.

In particular it means that clip nodes cannot be discarded if they
encompass the full clip region.

Fixes #6322
2024-01-12 20:06:04 +01:00
Benjamin Otte b552cf74dd gpu: Remove unnecessary optimization
Every branch in the switch is so optimized that it does this check
early anyway, so there's no need to have it as an extra step.
2024-01-12 20:06:04 +01:00
Matthias Clasen 0be0265751 Merge branch 'ebassi/doc-since-fix' into 'main'
docs: Add missing Since to gtk-show-status-shapes setting

See merge request GNOME/gtk!6741
2024-01-12 15:04:05 +00:00
Matthias Clasen 207dd6fe0d Merge branch 'matthiasc/for-main' into 'main'
gsk: Fix up test names to include 'compare'

See merge request GNOME/gtk!6739
2024-01-12 14:38:46 +00:00
Emmanuele Bassi a87ff8d556 docs: Add missing Since to gtk-show-status-shapes setting 2024-01-12 12:54:54 +00:00
Matthias Clasen 153cb8316e gsk: Fix up test names to include 'compare' 2024-01-11 23:19:29 -05:00
Matthias Clasen 7ad7c0d8c1 Merge branch 'switch-shapes' into 'main'
switch: Follow "switch-shapes" setting

Closes #5354

See merge request GNOME/gtk!6731
2024-01-11 19:19:58 +00:00
Florian Müllner bf0120f73d switch: Follow "show-status-shapes" setting
Whether or not switches include shapes to indicate their ON/OFF
state is currently controlled by the stylesheet (in particular
the HighContrast style).

However there are use cases for both using the HighContrast style
without shapes, and for using shapes with the regular stylesheet,
so follow the newly added "show-status-shapes" setting instead.

https://gitlab.gnome.org/GNOME/gtk/-/issues/5354
2024-01-11 01:33:16 +01:00
18 changed files with 159 additions and 26 deletions
+32
View File
@@ -63,6 +63,38 @@
}
]
},
{
"name": "shaderc",
"buildsystem": "cmake-ninja",
"builddir": true,
"config-opts": [
"-DSHADERC_SKIP_COPYRIGHT_CHECK=ON",
"-DSHADERC_SKIP_EXAMPLES=ON",
"-DSHADERC_SKIP_TESTS=ON"
],
"cleanup": [ "/bin", "/lib/cmake", "/lib/pkgconfig", "/include" ],
"post-install": [
"install -D /lib/$(gcc --print-multiarch)/libSPIRV*.so /app/lib"
],
"sources": [
{
"type": "archive",
"archive-type": "tar",
"url": "https://api.github.com/repos/google/shaderc/tarball/refs/tags/v2021.3",
"sha256": "b7e54b23a83343d5e2da836d8833ae0db11926141955edf845e35d4dc1eb88d1"
},
{
"type": "shell",
"commands": [
"sed -i 's|SPIRV/GlslangToSpv.h|glslang/SPIRV/GlslangToSpv.h|' libshaderc_util/src/compiler.cc",
"sed -i 's|add_subdirectory(third_party)||' CMakeLists.txt",
"sed -i 's|add_custom_target(build-version|set(NOT_USE|' CMakeLists.txt",
"LIB=/lib/$(gcc --print-multiarch)\nVER_MATCH=\"[0-9]+\\.[^\\. ]+\"\nSHADERC=$(grep -m1 -oP \"^v$VER_MATCH\" CHANGES)\nSPIRV=v$(grep -oP \"(?<=Version:.)$VER_MATCH\" $LIB/pkgconfig/SPIRV-Tools-shared.pc)\nGLSLANG=v$(realpath $LIB/libglslang.so | grep -oP \"(?<=so.)$VER_MATCH\")\ncat <<- EOF > glslc/src/build-version.inc\n \"shaderc $SHADERC\"\n \"spirv-tools $SPIRV\"\n \"glslang $GLSLANG\"\nEOF",
"cat glslc/src/build-version.inc"
]
}
]
},
{
"name" : "libsass",
"buildsystem" : "meson",
+1
View File
@@ -1796,6 +1796,7 @@ static TranslationEntry translations[] = {
{ FALSE, "org.gnome.desktop.wm.preferences", "action-right-click-titlebar", "gtk-titlebar-right-click", G_TYPE_STRING, { .s = "menu" } },
{ FALSE, "org.gnome.desktop.a11y", "always-show-text-caret", "gtk-keynav-use-caret", G_TYPE_BOOLEAN, { .b = FALSE } },
{ FALSE, "org.gnome.desktop.a11y.interface", "high-contrast", "high-contast", G_TYPE_NONE, { .b = FALSE } },
{ FALSE, "org.gnome.desktop.a11y.interface", "show-status-shapes", "gtk-show-status-shapes", G_TYPE_BOOLEAN, { .b = FALSE } },
/* Note, this setting doesn't exist, the portal and gsd fake it */
{ FALSE, "org.gnome.fontconfig", "serial", "gtk-fontconfig-timestamp", G_TYPE_NONE, { .i = 0 } },
};
+1
View File
@@ -39,6 +39,7 @@ static const struct {
{"Gtk/CursorThemeSize", "gtk-cursor-theme-size"},
{"Gtk/ColorScheme", "gtk-color-scheme"},
{"Gtk/EnableAnimations", "gtk-enable-animations"},
{"Gtk/ShowStatusStates", "gtk-show-status-shapes"},
{"Xft/Antialias", "gtk-xft-antialias"},
{"Xft/Hinting", "gtk-xft-hinting"},
{"Xft/HintStyle", "gtk-xft-hintstyle"},
+21 -11
View File
@@ -14,6 +14,14 @@ gsk_gpu_clip_init_empty (GskGpuClip *clip,
gsk_rounded_rect_init_from_rect (&clip->rect, rect, 0);
}
void
gsk_gpu_clip_init_contained (GskGpuClip *clip,
const graphene_rect_t *rect)
{
clip->type = GSK_GPU_CLIP_CONTAINED;
gsk_rounded_rect_init_from_rect (&clip->rect, rect, 0);
}
void
gsk_gpu_clip_init_rect (GskGpuClip *clip,
const graphene_rect_t *rect)
@@ -54,17 +62,6 @@ gsk_gpu_clip_intersect_rect (GskGpuClip *dest,
{
GskRoundedRectIntersection res;
if (gsk_rect_contains_rect (rect, &src->rect.bounds))
{
gsk_gpu_clip_init_copy (dest, src);
return TRUE;
}
if (!gsk_rect_intersects (rect, &src->rect.bounds))
{
dest->type = GSK_GPU_CLIP_ALL_CLIPPED;
return TRUE;
}
switch (src->type)
{
case GSK_GPU_CLIP_ALL_CLIPPED:
@@ -72,6 +69,14 @@ gsk_gpu_clip_intersect_rect (GskGpuClip *dest,
break;
case GSK_GPU_CLIP_NONE:
if (gsk_rect_contains_rect (rect, &src->rect.bounds))
{
gsk_gpu_clip_init_copy (dest, src);
return TRUE;
}
G_GNUC_FALLTHROUGH;
case GSK_GPU_CLIP_CONTAINED:
gsk_gpu_clip_init_copy (dest, src);
if (gsk_rect_intersection (&dest->rect.bounds, rect, &dest->rect.bounds))
dest->type = GSK_GPU_CLIP_RECT;
@@ -124,6 +129,7 @@ gsk_gpu_clip_intersect_rounded_rect (GskGpuClip *dest,
break;
case GSK_GPU_CLIP_NONE:
case GSK_GPU_CLIP_CONTAINED:
case GSK_GPU_CLIP_RECT:
res = gsk_rounded_rect_intersect_with_rect (rounded, &src->rect.bounds, &dest->rect);
if (!gsk_gpu_clip_init_after_intersection (dest, res))
@@ -174,6 +180,7 @@ gsk_gpu_clip_transform (GskGpuClip *dest,
return TRUE;
case GSK_GPU_CLIP_NONE:
case GSK_GPU_CLIP_CONTAINED:
case GSK_GPU_CLIP_RECT:
case GSK_GPU_CLIP_ROUNDED:
switch (gsk_transform_get_category (transform))
@@ -246,6 +253,7 @@ gsk_gpu_clip_may_intersect_rect (const GskGpuClip *self,
return FALSE;
case GSK_GPU_CLIP_NONE:
case GSK_GPU_CLIP_CONTAINED:
case GSK_GPU_CLIP_RECT:
case GSK_GPU_CLIP_ROUNDED:
return gsk_rect_intersects (&self->rect.bounds, &r);
@@ -269,6 +277,7 @@ gsk_gpu_clip_contains_rect (const GskGpuClip *self,
return FALSE;
case GSK_GPU_CLIP_NONE:
case GSK_GPU_CLIP_CONTAINED:
case GSK_GPU_CLIP_RECT:
return gsk_rect_contains_rect (&self->rect.bounds, &r);
@@ -283,6 +292,7 @@ gsk_gpu_clip_get_shader_clip (const GskGpuClip *self,
const graphene_rect_t *rect)
{
if (self->type == GSK_GPU_CLIP_NONE ||
self->type == GSK_GPU_CLIP_CONTAINED ||
gsk_gpu_clip_contains_rect (self, offset, rect))
return GSK_GPU_SHADER_CLIP_NONE;
else if (self->type == GSK_GPU_CLIP_RECT)
+5
View File
@@ -18,6 +18,9 @@ typedef enum {
* to the actual bounds of the underlying framebuffer
*/
GSK_GPU_CLIP_NONE,
/* The clip exists outside the rect, so clipping must
* happen if rendering can't be proven to stay in the rect */
GSK_GPU_CLIP_CONTAINED,
/* The clip is a rectangular area */
GSK_GPU_CLIP_RECT,
/* The clip is a rounded rectangle */
@@ -34,6 +37,8 @@ struct _GskGpuClip
void gsk_gpu_clip_init_empty (GskGpuClip *clip,
const graphene_rect_t *rect);
void gsk_gpu_clip_init_contained (GskGpuClip *clip,
const graphene_rect_t *rect);
void gsk_gpu_clip_init_copy (GskGpuClip *self,
const GskGpuClip *src);
void gsk_gpu_clip_init_rect (GskGpuClip *clip,
+2 -2
View File
@@ -709,8 +709,8 @@ gsk_gpu_device_lookup_glyph_image (GskGpuDevice *self,
.height = rect.size.height + 2 * padding,
},
scale,
&GRAPHENE_POINT_INIT (cache->origin.x + 1,
cache->origin.y + 1));
&GRAPHENE_POINT_INIT (cache->origin.x + padding,
cache->origin.y + padding));
g_hash_table_insert (priv->glyph_cache, cache, cache);
gsk_gpu_cached_use (self, (GskGpuCached *) cache, gsk_gpu_frame_get_timestamp (frame));
+2 -2
View File
@@ -1591,7 +1591,7 @@ gsk_gpu_node_processor_add_transform_node (GskGpuNodeProcessor *self,
if (gsk_gpu_clip_contains_rect (&self->clip, &self->offset, &node->bounds))
{
gsk_gpu_clip_init_empty (&self->clip, &child->bounds);
gsk_gpu_clip_init_contained (&self->clip, &child->bounds);
}
else if (old_clip.type == GSK_GPU_CLIP_NONE)
{
@@ -1600,7 +1600,7 @@ gsk_gpu_node_processor_add_transform_node (GskGpuNodeProcessor *self,
inverse = gsk_transform_invert (gsk_transform_ref (clip_transform));
gsk_transform_transform_bounds (inverse, &old_clip.rect.bounds, &new_bounds);
gsk_transform_unref (inverse);
gsk_gpu_clip_init_empty (&self->clip, &new_bounds);
gsk_gpu_clip_init_contained (&self->clip, &new_bounds);
}
else if (!gsk_gpu_clip_transform (&self->clip, &old_clip, clip_transform, &child->bounds))
{
+12
View File
@@ -172,6 +172,7 @@ enum {
PROP_ALTERNATIVE_SORT_ARROWS,
PROP_ENABLE_ANIMATIONS,
PROP_ERROR_BELL,
PROP_STATUS_SHAPES,
PROP_PRINT_BACKENDS,
PROP_PRINT_PREVIEW_COMMAND,
PROP_ENABLE_ACCELS,
@@ -571,6 +572,17 @@ gtk_settings_class_init (GtkSettingsClass *class)
TRUE,
GTK_PARAM_READWRITE);
/**
* GtkSettings:gtk-show-status-shapes:
*
* When %TRUE, widgets like switches include shapes to indicate their on/off state.
*
* Since: 4.14
*/
pspecs[PROP_STATUS_SHAPES] = g_param_spec_boolean ("gtk-show-status-shapes", NULL, NULL,
FALSE,
GTK_PARAM_READWRITE);
/**
* GtkSettings:gtk-print-backends:
*
+27
View File
@@ -549,6 +549,18 @@ state_set (GtkSwitch *self,
return TRUE;
}
static gboolean
translate_switch_shapes_to_opacity (GBinding *binding,
const GValue *from_value,
GValue *to_value,
gpointer user_data)
{
gboolean visible = g_value_get_boolean (from_value);
g_value_set_double (to_value, visible ? 1.0 : 0.0);
return TRUE;
}
static void
gtk_switch_class_init (GtkSwitchClass *klass)
{
@@ -658,6 +670,7 @@ gtk_switch_init (GtkSwitch *self)
{
GtkLayoutManager *layout;
GtkGesture *gesture;
GtkSettings *gtk_settings;
gtk_widget_set_focusable (GTK_WIDGET (self), TRUE);
@@ -690,18 +703,32 @@ gtk_switch_init (GtkSwitch *self)
gtk_switch_allocate);
gtk_widget_set_layout_manager (GTK_WIDGET (self), layout);
gtk_settings = gtk_settings_get_default ();
self->on_image = g_object_new (GTK_TYPE_IMAGE,
"accessible-role", GTK_ACCESSIBLE_ROLE_NONE,
"icon-name", "switch-on-symbolic",
NULL);
gtk_widget_set_parent (self->on_image, GTK_WIDGET (self));
g_object_bind_property_full (gtk_settings, "gtk-show-status-shapes",
self->on_image, "opacity",
G_BINDING_SYNC_CREATE,
translate_switch_shapes_to_opacity,
NULL, NULL, NULL);
self->off_image = g_object_new (GTK_TYPE_IMAGE,
"accessible-role", GTK_ACCESSIBLE_ROLE_NONE,
"icon-name", "switch-off-symbolic",
NULL);
gtk_widget_set_parent (self->off_image, GTK_WIDGET (self));
g_object_bind_property_full (gtk_settings, "gtk-show-status-shapes",
self->off_image, "opacity",
G_BINDING_SYNC_CREATE,
translate_switch_shapes_to_opacity,
NULL, NULL, NULL);
self->slider = gtk_gizmo_new_with_role ("slider",
GTK_ACCESSIBLE_ROLE_NONE,
NULL, NULL, NULL, NULL, NULL, NULL);
-4
View File
@@ -2482,10 +2482,6 @@ switch {
transition: $button_transition;
}
@if $contrast != 'high' {
> image { color: transparent; } /* only show i / o for the accessible theme */
}
&:hover > slider {
@include button(hover);
}
@@ -0,0 +1,7 @@
transform {
transform: scale(30);
child: text {
font: "text-mixed-color 7.5";
glyphs: 7 10;
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1002 B

+22
View File
@@ -0,0 +1,22 @@
transform {
transform: rotate(45);
child: clip {
clip: -10 -2.5 20 5;
child: color {
bounds: -25 -25 50 50;
color: rgb(255,0,0);
}
}
}
color {
bounds: -16 -16 16 16;
color: rgb(0,0,0);
}
color {
bounds: -8 -8 16 16;
color: rgb(0,0,0);
}
color {
bounds: 0 0 16 16;
color: rgb(0,0,0);
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 136 B

Binary file not shown.
+18
View File
@@ -10,6 +10,7 @@
<GlyphID id="4" name="D"/>
<GlyphID id="5" name="E"/>
<GlyphID id="6" name="F"/>
<GlyphID id="7" name="G"/>
</GlyphOrder>
<head>
@@ -80,6 +81,7 @@
<mtx name="D" width="1024" lsb="0"/>
<mtx name="E" width="1024" lsb="0"/>
<mtx name="F" width="1024" lsb="0"/>
<mtx name="G" width="1024" lsb="0"/>
</hmtx>
<loca>
@@ -141,6 +143,21 @@
</contour>
<instructions><assembly></assembly></instructions>
</TTGlyph>
<TTGlyph name="G">
<contour>
<pt x="0" y="0" on="1"/>
<pt x="1024" y="0" on="1"/>
<pt x="1024" y="2048" on="1"/>
<pt x="0" y="2048" on="1"/>
</contour>
<contour>
<pt x="5" y="5" on="1"/>
<pt x="5" y="2043" on="1"/>
<pt x="1019" y="2043" on="1"/>
<pt x="1019" y="5" on="1"/>
</contour>
<instructions><assembly></assembly></instructions>
</TTGlyph>
</glyf>
<COLR>
@@ -182,6 +199,7 @@
<map code="0x44" name="D"/>
<map code="0x45" name="E"/>
<map code="0x46" name="F"/>
<map code="0x47" name="G"/>
</cmap_format_4>
</cmap>
+8 -6
View File
@@ -10,6 +10,7 @@ node_parser = executable('node-parser', 'node-parser.c',
)
compare_render_tests = [
'big-box-glyph-nocairo',
'big-checkerboard',
'big-checkerboard-scaled-down',
'big-checkerboard-scaled-down-nearest',
@@ -28,6 +29,7 @@ compare_render_tests = [
'border-opacity',
'borders-rotated',
'borders-scaled',
'clip-contained',
'clip-coordinates-2d',
'clip-coordinates-nocairo',
'clip-in-rounded-clip1',
@@ -210,7 +212,7 @@ foreach renderer : renderers
if ((not testname.contains(exclude_term)) and
(renderer_name != 'broadway' or broadway_enabled) and
(renderer_name != 'vulkan' or have_vulkan))
test(renderer_name + ' ' + testname, compare_render,
test('compare ' + renderer_name + ' ' + testname, compare_render,
args: [
'--output', join_paths(meson.current_build_dir(), 'compare', renderer_name),
join_paths(meson.current_source_dir(), 'compare', testname + '.node'),
@@ -219,7 +221,7 @@ foreach renderer : renderers
env: test_env,
suite: suites,
)
test(renderer_name + ' ' + testname + ' flipped', compare_render,
test('compare ' + renderer_name + ' ' + testname + ' flipped', compare_render,
args: [
'--flip',
'--output', join_paths(meson.current_build_dir(), 'compare', renderer_name),
@@ -229,7 +231,7 @@ foreach renderer : renderers
env: test_env,
suite: suites + [ 'gsk-compare-flipped-' + renderer_name ],
)
test(renderer_name + ' ' + testname + ' repeated', compare_render,
test('compare ' + renderer_name + ' ' + testname + ' repeated', compare_render,
args: [
'--repeat',
'--output', join_paths(meson.current_build_dir(), 'compare', renderer_name),
@@ -239,7 +241,7 @@ foreach renderer : renderers
env: test_env,
suite: suites + [ 'gsk-compare-repeated-' + renderer_name ],
)
test(renderer_name + ' ' + testname + ' rotated', compare_render,
test('compare ' + renderer_name + ' ' + testname + ' rotated', compare_render,
args: [
'--rotate',
'--output', join_paths(meson.current_build_dir(), 'compare', renderer_name),
@@ -249,7 +251,7 @@ foreach renderer : renderers
env: test_env,
suite: suites + [ 'gsk-compare-rotated-' + renderer_name ],
)
test(renderer_name + ' ' + testname + ' masked', compare_render,
test('compare ' + renderer_name + ' ' + testname + ' masked', compare_render,
args: [
'--mask',
'--output', join_paths(meson.current_build_dir(), 'compare', renderer_name),
@@ -259,7 +261,7 @@ foreach renderer : renderers
env: test_env,
suite: suites + [ 'gsk-compare-masked-' + renderer_name ],
)
test(renderer_name + ' ' + testname + ' replayed', compare_render,
test('compare ' + renderer_name + ' ' + testname + ' replayed', compare_render,
args: [
'--replay',
'--output', join_paths(meson.current_build_dir(), 'compare', renderer_name),
+1 -1
View File
@@ -10,7 +10,7 @@ echo "1..1"
name=gtk-query-settings
result=$TEST_RESULT_DIR/$name.out
$GTK_QUERY_SETTINGS 2>/dev/null >$result
EXPECTED=50
EXPECTED=51
SEEN=$(wc -l $result | cut -f1 -d' ')
if [ $SEEN -eq $EXPECTED ]; then