Commit Graph

60206 Commits

Author SHA1 Message Date
Matthias Clasen
3e9960e06f css: Add gtk_css_style_get_static_style
This lets us avoid poking directly at the GtkCssAnimatedStyle
struct in gtkcssnode.c.
2020-01-14 21:43:23 -05:00
Matthias Clasen
4cf2b87654 Speed up gtk_widget_pick
Add early exits, and avoid as much work as
possible.
2020-01-14 21:43:23 -05:00
Matthias Clasen
a5dc2caa13 Revert "css: Faster matching for simple selectors"
This reverts commit 05f7d68e29.
2020-01-14 16:59:27 -05:00
Matthias Clasen
05f7d68e29 css: Faster matching for simple selectors
Inline simple selectors for node matchers.
A bit ugly, but works.
2020-01-14 15:47:30 -05:00
Matthias Clasen
e9eacdeded css: Implement the superset matcher smarter
Instead of wrapping the individual vfuncs, and having
a branch in the inner loop, rewrite the matcher class.
2020-01-14 15:47:30 -05:00
Matthias Clasen
616c0ab8c5 css: Compute selector tree changes ahead of time
These only depend on the selector tree, so we can
compute them while constructing the tree.
2020-01-14 15:47:30 -05:00
Matthias Clasen
792130437e css: Handle initial values more efficiently
Instead of creating a new values every time we
resolve the initial values for dpi and font family,
keep a css value around for the settings.
2020-01-14 15:47:30 -05:00
Matthias Clasen
0afa486d41 css: Mark transform value as computed
This is not very useful, since transitions generate
a ton of transforms anyway.
2020-01-14 15:47:30 -05:00
Matthias Clasen
6e5f56684d css: Simplify default values
We no longer need to create one-element arrays or
corners with two identical values.
2020-01-14 15:47:30 -05:00
Matthias Clasen
52c7a3672e css: Re-add a lost special case
When the border-style special cases were moved in
c687f485fd, the one for outline-width was lost.

Make the code more compact, and bring the special
case back.
2020-01-14 15:47:30 -05:00
Timm Bäder
cfc7540c3b gl renderer: Render simple border nodes in a simple way
Roughly 80% of the border nodes are just one color and have the same
width on all sides, so we can draw them by uploading just one rect and
not four.
2020-01-14 17:32:59 +01:00
Timm Bäder
0d15eb7d01 numbervalue: Add early-out to multiply()
If the factor is 1, we already know what the result is going to be.
2020-01-14 17:32:59 +01:00
Timm Bäder
6d4cecb0c6 cssnumbervalue: Move early-out code to GtkCssValue
These checks make sense for all css values.
2020-01-14 17:32:59 +01:00
Timm Bäder
ada5ff8a91 cssdimensionvalue: Implement transition()
Instead of falling back to the generic gtk_css_number_value_transition
(which can allocate multiple new css values), just implement this here.
2020-01-14 17:32:59 +01:00
Timm Bäder
940910770a testsuite: Remove an invalid test case 2020-01-14 17:32:59 +01:00
Timm Bäder
3a2d6c58ba Remove GtkCssShadowsValue
Previously, we wrapped all GtkCssShadowValues in a GtkCssShadowsValue,
even if it was just one shadow.
2020-01-14 17:32:55 +01:00
Timm Bäder
bac51a05db cssshadowvalue: Only create 2 shadows values for transitions
This is for cases where we want to transition from "no shadow" to
"shadow", which we need quite a lot.
2020-01-14 15:28:19 +01:00
Timm Bäder
9d3704c62a cssdimensionvalue: Allow transitioning between different units...
... as long as one of the two values is 0.
2020-01-14 15:28:17 +01:00
Timm Bäder
5cdeca2e25 cssvalue: Improve css value accounting output
And make it fully optional behind an #ifdef.
2020-01-14 15:28:15 +01:00
Timm Bäder
d3ad97073b csscolorvalue: check for singletons in new_literal
Gets rid of another ~400 GtkCssValue instances in the widget-factory.
2020-01-12 15:53:26 +01:00
Timm Bäder
c2e680f4f0 cssimage: Add is_computed vfunc
Same semantics as the is_computed field of GtkCssValue
2020-01-11 17:17:27 +01:00
Timm Bäder
ab868a3207 css: Set the is_computed flag for more values
With these changes, we skip roughly 85% of compute() calls during
widget-factory startup
2020-01-11 17:17:27 +01:00
Timm Bäder
ab78c19236 cssvalue: Don't call compute() for already computed css values
As per the previous commit, this is unnecessary.

Even with the small amount of css values we mark as is_computed, we
already skip computing over 60% of them like this during the startup of
the widget factory.
2020-01-11 17:17:27 +01:00
Timm Bäder
a3a71c149e cssvalue: Add is_computed flag
When a css value has "child" css values (e.g. a linear gradient has
several color stop css values) which are all computed (won't change when
compute() is called on them), we want to skip computing the entire
subtree.

Since css values are immutable, we can set the is_computed flag at
construct time.

Since GtkCssValue instances are 0-initialized in _gtk_css_value_alloc,
the default for is_computed it FALSE. This commit only sets it to TRUE
in a few cases, such as various "none" singleton values which will never
change. Later commits will refine this and set it for more values.
2020-01-11 17:17:27 +01:00
Timm Bäder
6b6f0856f0 testsuite: Update css color output 2020-01-11 17:17:27 +01:00
Timm Bäder
c687f485fd css: Move border-width special cases out of GtkCssDimensionValue
Move them to style computation instead, so we don't have them in such a
generic place.
2020-01-11 17:17:25 +01:00
Timm Bäder
a5b2ac73c8 csscolorvalue: Don't copy rgbas when applying function
We get const pointers to the colors, so just use those and unref the
values later.
2020-01-11 12:49:00 +01:00
Timm Bäder
b544f7c6bb gl renderer: Look at shadow color in the outset shadow cache
It would probably be better to not do this and always render the outline
in plain white, then later recolor it but do this for no, just for
correctness.
2020-01-11 12:49:00 +01:00
Timm Bäder
a10c5b74a1 cssimageradial: Avoid computing a new image if it didn't change 2020-01-11 12:49:00 +01:00
Timm Bäder
8af3a86dda cssimageradial: Use array + length instead of GArray
This makes sense since we're not going to change the (amount of) colors
after parsing.
2020-01-11 12:49:00 +01:00
Timm Bäder
11a78a0736 cssimagelinear: Don't compute new image if it didn't change 2020-01-11 12:49:00 +01:00
Timm Bäder
b7d9ec73ec cssimagelinear: Use count+array for the color stops, not GArray
This makse sense but will also make later changes to GtkCssImageLinear
simpler.
2020-01-11 12:48:59 +01:00
Timm Bäder
c1a5221941 cssimagefallback: Don't compute new image if only a color is set
Themes might use e.g. image(red), which is a constant value and will
never change. In that case, the fallback image has ->color set, but not
->images. If that's the case and the computed color is the same as
the one we already have, just return the already existing image.
2020-01-11 12:48:59 +01:00
Timm Bäder
7b40541889 Remove GtkCssRgbaValue
The differenciation between a literal color value and an RGBA value
caused problems in various situations. Just treat the two the same but
don't allow access to the rgba value of a non-literal color value.

This gets rid of around 1.6k rgba values in the widget-factory.
2020-01-11 12:48:59 +01:00
Matthias Clasen
2b9e5bdb4b dump css value stats 2020-01-11 12:48:59 +01:00
Timm Bäder
439238c502 csssshadwovalue: Remove unused function prototype 2020-01-11 12:48:59 +01:00
Timm Bäder
e90c499f2c cssnumbervalue: Add early-outs to transition code
we don't need to do the calculation at all if the progress is 0 or 1
anyway.

We also sometimes transition from 0 to 0 etc., so we can short-circuit
that as well by doing the fast pointer-equality check and relying on the
singletons.
2020-01-11 12:48:59 +01:00
Timm Bäder
a3a31d229b csscornervalue: Accept other values if x == y
Most corners are square, so x == y. In that case, just accept either of
them. This makes the corner value unnecessary.

In fact none of the corner values in the widget-factory are needed, so
this spares us around 500 corner value allocations.

css value stats before:

GtkCssBgSizeValue: 23
GtkCssIdentValue: 25
GtkCssPositionValue: 81
GtkCssCornerValue: 556
GtkCssArrayValue: 143
GtkCssStringValue: 33
GtkCssPaletteValue: 29
GtkCssImageValue: 2765
GtkCssColorValue: 1452
GtkCssFilterValue: 3
GtkCssRgbaValue: 1092
GtkCssShadowValue: 708
GtkCssEaseValue: 33
GtkCssBorderValue: 2
GtkCssTransformValue: 11
GtkCssDimensionValue: 882
GtkCssShadowsValue: 584
SUM: 8428

and after:

GtkCssColorValue: 1452
GtkCssFilterValue: 3
GtkCssRgbaValue: 1092
GtkCssShadowValue: 708
GtkCssEaseValue: 33
GtkCssBorderValue: 2
GtkCssTransformValue: 11
GtkCssDimensionValue: 882
GtkCssShadowsValue: 584
GtkCssBgSizeValue: 23
GtkCssIdentValue: 25
GtkCssPositionValue: 81
GtkCssArrayValue: 143
GtkCssStringValue: 33
GtkCssPaletteValue: 29
GtkCssImageValue: 2765
SUM: 7872

8428 to 7872 is a 556 reduction (6.5%)

asdf
2020-01-11 12:48:59 +01:00
Timm Bäder
65344cc3cf cssarrayvalue: Don't allocate memory when parsing array values
We probably won't find CSS with more than 128 values in array.
2020-01-11 12:48:55 +01:00
Timm Bäder
a26c615305 cssarrayvalue: Allow calling array API on non-arrays
Just allow calling _get_nth() and _get_n_values() on every kind of css
value. This way we can allow all values in places where only array
values would be allowed before.

This spares us around 1000 array values in the widget factory.

css value stats before:

GtkCssFilterValue: 3
GtkCssRgbaValue: 1092
GtkCssShadowValue: 708
GtkCssEaseValue: 33
GtkCssBorderValue: 2
GtkCssTransformValue: 11
GtkCssDimensionValue: 882
GtkCssShadowsValue: 584
GtkCssBgSizeValue: 23
GtkCssIdentValue: 25
GtkCssPositionValue: 81
GtkCssCornerValue: 556
GtkCssArrayValue: 1130
GtkCssStringValue: 33
GtkCssPaletteValue: 29
GtkCssImageValue: 2765
GtkCssColorValue: 1452
SUM: 9415

and after:

GtkCssBgSizeValue: 23
GtkCssIdentValue: 25
GtkCssPositionValue: 81
GtkCssCornerValue: 556
GtkCssArrayValue: 143
GtkCssStringValue: 33
GtkCssPaletteValue: 29
GtkCssImageValue: 2765
GtkCssColorValue: 1452
GtkCssFilterValue: 3
GtkCssRgbaValue: 1092
GtkCssShadowValue: 708
GtkCssEaseValue: 33
GtkCssBorderValue: 2
GtkCssTransformValue: 11
GtkCssDimensionValue: 882
GtkCssShadowsValue: 584
SUM: 8428

9415 to 8428 is a 987 reduction (10.4%)
2020-01-11 08:09:17 +01:00
Timm Bäder
37a559ffe5 cssvalue: Add type names for all classes
This is important to have for debugging and e.g. to print statistics for
the individual css value types
2020-01-11 08:09:17 +01:00
Timm Bäder
5a12448f9a csscolorvalue: Compute alpha/shade/mix of color literals directly
The values of these are never gonna change so we can as well create
literal color values from the resulting colors instead.
2020-01-11 08:09:17 +01:00
Timm Bäder
6b19f493ab csscolorvalue: Don't resolve literal color values 2020-01-11 08:09:16 +01:00
Matthias Clasen
f5daecf353 Merge branch 'dnd-gestures-2' into 'master'
Add new dnd api

See merge request GNOME/gtk!1278
2020-01-11 06:09:58 +00:00
Matthias Clasen
b76940bab5 dragdest: More documentation 2020-01-11 00:50:22 -05:00
Matthias Clasen
ec255f9bb1 Update all callers 2020-01-11 00:50:22 -05:00
Matthias Clasen
9dc6be4fb0 Reshuffle droptarget api a little bit
Add a ::drag-motion signal back, remove x,y from
the ::accept signal, and only emit ::accept once.
2020-01-11 00:49:59 -05:00
Matthias Clasen
186b783f9d Merge branch 'wip/chergert/gtk4-gtk-main-sync' into 'master'
Rubustness fixes for gtk_main_sync()

See merge request GNOME/gtk!1299
2020-01-11 04:41:46 +00:00
Christian Hergert
2f3518c80d gtkmain: be deterministic in source removal
Fixes gtk_main_sync() to only remove a source if it has not
already executed (and been removed). The previous code was
using gtk_main_quit() directly which would be non-determinstic
based on the previous value in the return register.
2020-01-10 15:04:44 -08:00
Christian Hergert
4a7f68e79e gtkmain: short-circuit gtk_main_sync() where no display
If there is no display, we will hit the slow path here which
can introduce long latencies in unit tests. This checks for
a NULL list of displays and simply short-circuits.
2020-01-10 15:00:10 -08:00