Commit Graph

51 Commits

Author SHA1 Message Date
Timm Bäder
ec1133d6e1 renderbackground: Only query number of layers once
We did it once in snapshot_background and then again in snapshot_color.
2020-06-27 10:51:06 +02:00
Timm Bäder
8fcf1b78a4 renderbackground: Only query h/vrepeat if we need to 2020-06-27 10:51:06 +02:00
Christoph Reiter
2d5cf2b4c4 Drop fallback-c89.c
We require a C compiler supporting C99 now. The main purpose of
these fallbacks was for MSVC. From what I can see this is now all supported
by MSVC 2015+ anyway.

The only other change this includes is to replace isnanf() with the
(type infering) C99 isnan() macro, because MSVC doesn't provide isnanf().
2020-05-31 17:09:23 +02:00
Timm Bäder
b75d408d6d css: Make some local variables const 2020-02-05 04:03:43 +01:00
Matthias Clasen
7fbb37a09f background: Don't render initial backgrounds
Add a fast exit for the common case that the background
values are unset.
2020-02-01 09:11:39 +01:00
Matthias Clasen
10e4c04e61 Use style values directly
Replace uses of gtk_css_style_get_value with direct access,
throughout the tree. We don't replace all uses, just those
where we are dealing with a fixed property. Be careful to
handle the currentColor special case for color properties.
2020-01-29 11:07:32 +01:00
Timm Bäder
2e256986c3 renderbackground: Avoid unnecessary work in snapshot_background() 2020-01-26 18:21:07 +01:00
Timm Bäder
45455f1bdb Remove GtkCssShadowsValue
Previously, we wrapped all GtkCssShadowValues in a GtkCssShadowsValue,
even if it was just one shadow. This causes an unnecessary bloat in
css values.

Make each GtkCssShadowValue able to handle multiple shadows instead, and
use gtk_css_shadow_value* API everywhere.
2020-01-18 08:49:52 +01:00
Timm Bäder
67991ed0f4 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-18 08:49:51 +01:00
Timm Bäder
d490d8f1f3 renderbackground: Try to omit a save/restore pair 2020-01-07 17:27:16 +01:00
Timm Bäder
075a0ccb5e renderbackground: Save a snapshot_translate() call
Just add the values manually when really using the snapshot later. Also
unifies the two if branches by pulling out getting the x/y values.
2020-01-07 17:27:16 +01:00
Benjamin Otte
b0eceb65d7 renderbackground: Use new snapshot transforms 2019-02-21 19:47:28 +01:00
Benjamin Otte
c44c44ee25 css: Pass boxes to the render functions
Instead of style + rect_of_one_box, pass the new GtkCssBoxes object.
This has the nice side effect that when drawing background + border +
outline, we only compute all the boxes we need once.
2019-02-15 06:53:22 +01:00
Benjamin Otte
19ffb40b27 cssboxes: Introduce
Split out the code for computing CSS boxes from given variables from the
background render code. This way, it can be shared between different
codebases.

Also, make that code completely be contained of static inline functions.
That ensures that it can be 100% inlined in cases where only parts of
the rectangle are needed (like in gtk_widget_get_width() in the future).

This will require some more patches to actually work, but those will
follow.
2019-02-15 06:53:22 +01:00
Benjamin Otte
14408b7485 render: Make gtk_render_background() use the snapshot API
This removes a lot of duplicated code.
2018-07-24 20:55:45 +02:00
Benjamin Otte
73b4a62f51 snapshot: Redo debug messages
Instead of every snapshot function having debug messages, have an
explicit gtk_snapshot_push_debug() function that appends a debug node.
2018-04-24 04:06:58 +02:00
Timm Bäder
31974e02ca renderbackground: Avoid excess css value lookups
We iterate over all background layers twice, so only lookup blend mode
vlaues once.
2018-01-10 08:46:22 +01:00
Timm Bäder
5e39f3c23b renderbackground: Add some constness 2018-01-10 08:46:22 +01:00
Timm Bäder
c9e6fcd5fa renderbackground: Pull out a gdk_rgba_is_clear check
We only call snapshot_color once, and this way it's clearer that nothing
will happen for a clear color from the caller side.
2018-01-10 08:46:22 +01:00
Timm Bäder
99026d2df8 renderbackground: Minimize style lookups
Move the early returns up so we don't look up all those css values for
no reason.
2017-10-20 14:56:29 +02:00
Benjamin Otte
87497ca2e1 snapshot: Rename gtk_snapshot_translate_2d()
It's now called gtk_snapshot_offset().
2017-01-13 14:37:48 +01:00
Benjamin Otte
6055028c96 snapshot: Rename append APIs
Instead of having gtk_snapshot_append_foo_node(), just have
gtk_snapshot_append_foo(). Nobody needs to know that this internally
uses nodes.
2017-01-13 04:46:09 +01:00
Benjamin Otte
b58de2d16c snapshot: Redo pop() API
gtk_snapshot_pop() => removed
gtk_snapshot_pop_and_append() => gtk_snapshot_pop()

So now there is no way to get a rendernode out of the snapshotting API
until you gtk_snapshot_finish().
2017-01-13 03:38:36 +01:00
Benjamin Otte
bc3ba68641 snapshot: Add gtk_snapshot_push_blend()
and use it for backgrounds.
2017-01-13 03:38:36 +01:00
Alexander Larsson
65ad2541d7 Snapshot: Only record names if inspector is recording
Otherwise we do a lot of allocations and vprintf calls which are
not used.
2017-01-11 10:22:40 +01:00
Benjamin Otte
b993acfe2c gsk: Add GskRepeatNode
Also add gtk_snapshot_push_repeat() and use that to draw backgrounds.

With that change, CSS background snapshots are created without Cairo
nodes.
2017-01-01 19:53:36 +01:00
Benjamin Otte
4d9eedafcd roundedbox: Add gtk_rounded_boxes_init_for_style()
Instead of making people intiialize a rectangle and then applying border
radius manually, provide a constructor that does it for them.
While doing that, also allow people to instead request the padding box
or the content box.

Refactor all relevant code to use this new constructor.
2016-12-20 18:01:12 +01:00
Benjamin Otte
95a2a5c54c gtk: Remove GtkJunctionSides 2016-12-20 18:01:12 +01:00
Benjamin Otte
071c9a8221 API: gdk: Add gdk_rgba_is_clear() and gdk_rgba_is_opaque()
I want to use these inside GSK, and I'm not a fan of putting GdkRGBA
APIs into it or duplicating it into GTK.

So public API it is.
2016-12-20 18:01:12 +01:00
Benjamin Otte
a9809e5d30 gsk: Add gsk_rounded_rect_shrink()
... and replace _gtk_rounded_box_grow() and _gtk_rounded_box_shrink()
with it.
2016-12-20 18:01:11 +01:00
Benjamin Otte
cf520b7a1f gsk: Add blend nodes
Implement blend mode support in GTK background compositing with it.
2016-12-20 18:01:11 +01:00
Benjamin Otte
3e26fadb24 css: Replace custom blend modes with GskBlendMode 2016-12-20 18:01:11 +01:00
Benjamin Otte
cd68c93b4c render: Fall back later when rendering backgrounds
We can now render most backgrounds fine.
2016-12-20 18:01:10 +01:00
Benjamin Otte
dd1cf1ac0f css: An opaque background does not allow omitting push_group
When the background-clip of the background is smaller than the
background-clip of blended images, not pushing a group is wrong.

Test testing exactly that included.
2016-12-20 18:01:10 +01:00
Benjamin Otte
f96f16899d roundedbox: Remove _gtk_rounded_box_path()
Use gsk_rounded_rect_path() instead.

That's a private GSK function, be we can just include its header.
2016-12-20 18:01:10 +01:00
Benjamin Otte
e26f84fca0 gtk: Remove GtkRoundedBox struct
Use GskRoundedRect instead.
2016-12-20 18:01:10 +01:00
Benjamin Otte
a2dfb1e93f roundedbox: typedef to GskRoundedRect 2016-12-20 18:01:10 +01:00
Emmanuele Bassi
4cbe079767 Use Graphene init macros for compound literals
The Graphene init macros can now be used for compound literals, which
means we need to update our mixed uses.
2016-11-21 16:21:38 +00:00
Benjamin Otte
b93c26f559 render: Refactor background drawing code
We can query the blend mode inside the paint function.
2016-11-19 21:28:18 +01:00
Benjamin Otte
38f226b5ce render: Propagate snapshot drawing to box shadows
This decouples actual background drawing from shadow drawing in the
snapshot case.

We also now create seperate nodes for shadows vs for backgrounds.
2016-11-19 20:58:36 +01:00
Benjamin Otte
c22a9a03f9 renderbackground: Remove unused functions 2016-11-16 19:31:47 +01:00
Benjamin Otte
79d2d0e40d snapshot: Add gtk_snapshot_render_background()
and gtk_snapshot_render_frame() to be direct replacements for the
old gtk_render_*() functions.

Use them to replace Cairo usage completely in gtk_window_snapshot().
2016-11-15 17:48:45 +01:00
Benjamin Otte
a54db5adcd render: Draw shadows outside of potential push_group() call
Before, the shadows were clipped.
2016-11-08 02:32:29 +01:00
Benjamin Otte
f9da4f0270 render: Clip the correct rectangle
We translated before.
2016-11-08 02:32:29 +01:00
Benjamin Otte
a0e63b8a07 rendernode: Require passing a renderer to get_draw_context()
This is in preparation of making render nodes independent of the
renderer, so that they can be rendered multiple times with different
renderers.
2016-11-01 16:32:26 +01:00
Matthias Clasen
39c1aa5e27 Split css background into individual render nodes
Use separate render nodes for each layer in a multi-image
background. WARNING: blend modes don't work right yet.
2016-10-18 11:49:15 +01:00
Matthias Clasen
b660361fb7 Don't create render nodes for empty backgrounds 2016-10-18 11:49:14 +01:00
Matthias Clasen
cffb8ae4b5 Break out the css background render node in a function
This is in preparation for creating separate render nodes
for individual backgrounds.
2016-10-18 11:49:14 +01:00
Georges Basile Stavracas Neto
369db4a406 css: add background-blend-mode support
CSS supports blend modes, in which a series of layers are
merged together according to the given operation or set of
operations.

Support for blend modes landed on Cairo, which exposes all
the commons and also the exquisites blend modes available.
Adding support for blend modes, then, is just a matter of
using the available Cairo operations.

This patch adds the background-blend-mode CSS enum property,
and adapts the background rendering code to blend the backgrounds
using the available blend modes when they're set.

https://bugzilla.gnome.org/show_bug.cgi?id=768305
2016-07-03 17:24:47 -04:00
Benjamin Otte
71a9fd9d83 stylecontext: Move background_is_opaque() function
The new way, it no longer depends on the style context, but on the
CssStyle. This will become relevant in the next commit.
2016-02-25 16:52:58 +01:00