Commit Graph

91 Commits

Author SHA1 Message Date
Marco Trevisan (Treviño)
29f36fed08 cssshadowvalue: don't apply the y_scale offset twice to the shadow
As per commit 942e904 this changed causing a regression that
seems to be visible only when scale > 2.

https://bugzilla.gnome.org/show_bug.cgi?id=791363
2017-12-08 18:23:10 -05:00
Benjamin Otte
83fb7a649f css: Merge GtkStyleProviderPrivate into GtkStyleProvider
This is just lots of renaming.

The interface remains private, so the public API does not change, apart
from removing the definition of the Interface object to avoid
subclassing.
2017-10-31 04:33:54 +01:00
Matthias Clasen
598d22d194 Avoid creating trivial shadow nodes
The Vulkan renderer creates a fallback surface for each shadow
node, even if we end up not rendering anything to it. Avoiding
this is a nice optimization.
2017-10-28 16:10:46 -04:00
Benjamin Otte
fb47a8d714 css: Remove deprecated number-as-pixels compatibility
Previously, for compatibility with GTK 3.0, we allowed specifying
numbers without units and interpreted them as pixels, even when the CSS
specification didn't.

Remove that now that we can break API.
2017-01-18 04:13:56 +01:00
Alexander Larsson
c00f8dce9f GtkSnapshot: Always use int for the translation
We already take ints when setting the translation, so it can't
currently take any other values. Additionally, I was seeing large
costs in int -> double -> int for the rects in
gtk_snapshot_clips_rect(), as all callers really are ints (widget
allocations) and the clip region is int-based.

This change completely cleared a 2% rectangle_init_from_graphene from
the profile and is likely to have nice performance effects elsewhere
too.
2017-01-11 16:14:03 +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
3a38bc9bf7 gsk: Remove spread member from GskShadow
I had originally thought I'd use GskShadow for box-shadow, but didn't in
the end.

So now it's only used for text-shadow and icon-shadow, and those don't
have a spread.
2016-12-23 08:11:00 +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
2034e83a20 gsk: Add GskOutsetShadowNode 2016-12-20 18:01:12 +01:00
Benjamin Otte
fcc1f554d6 gsk: Add GskInsetShadowNode
And again lots of shadow code gets copied to GSK. But we're now almost
at a stage where widget-factory does not use cairo nodes anymore.
2016-12-20 18:01:12 +01:00
Benjamin Otte
4fc64ae3dd gsk: Add contains/intersect functions for GskRoundedRect
... and use them.
2016-12-20 18:01:12 +01:00
Benjamin Otte
2480e0d575 gsk: Add GskShadowNode
... and make the icon rendering code use it.

This requires moving even more shadow renering code into GSK, but so be
it. At least the "shadows not implemented" warning is now gone!
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
15e8a22f08 gsk: Move gtk/gtkcairoblur.c to gsk/gskcairoblur.c 2016-12-20 18:01:11 +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
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
fa9b0f9965 roundedbox: Remove _gtk_rounded_box_move()
Use gsk_rounded_rect_offset() instead.
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
Benjamin Otte
c04bece131 roundedbox: Use a graphene_size_t for the corners
Obviously, I'm trying to port GtkRoundedBox to GskRoundedRect.

This is the second step on that path.
2016-12-20 18:01:10 +01:00
Benjamin Otte
6d012fb4ea gtk: Get rid of GtkCssCorner
We have GskCorner now which is identical.
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
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
c45f8b1a25 cssshadows: Reengineer API
This way we have an API to query extents per shadow and I want that in
the next patch.
2016-11-19 20:58:36 +01:00
Gustavo Noronha Silva
942e904bcc cssshadowvalue: scale the blur surface by the same factor as the target
Making sure the surfaces are using the same scale factor makes it more
likely a fast path will be used when pixman gets involved, as pointed
out by Benjamin Otte.

https://bugzilla.gnome.org/show_bug.cgi?id=772075
2016-11-10 16:47:13 -02:00
Emmanuele Bassi
9557364216 gtk: Mark internal functions as static
These functions are only used within their compilation unit.
2016-10-17 11:44:10 +01:00
Timm Bäder
38181bc3d2 shadowsvalue: Don't draw invisible box shadows 2016-05-02 19:28:33 +02:00
Benjamin Otte
c081ca2d4c cssshadowsvalue: Avoid allocating new value if not needed 2016-04-21 23:01:31 +02:00
Benjamin Otte
58b7512b53 cssshadowvalue: Fix copy/paste issue
http://www.viva64.com/en/b/0383/
2016-03-20 05:26:39 +01:00
Benjamin Otte
a52ecd2be6 css: Add gtk_css_number_value_can_parse()
Use it instead of _gtk_css_parser_has_number().

We need that once we introduce calc() support.
2016-02-13 04:49:08 +01:00
Alexander Larsson
d8d0188e86 css shadows: Cache blured masks for the corners of outset shadows
A lot of time was spend rendering the shadows on windows with CSD, in
particular the corner pieces, since they are the largest parts. This
patch catches this particular case and caches the pre-rendered blur
masks.

This makes the shadow code go from 25% to 8% of the time when resizing
gtk3-demo.
2015-09-15 16:05:50 +02:00
Alexander Larsson
f31e20247f css shadows: Break out side & corner shadows into helper functions
This changes nothing, but makes the code a bit easier to read
2015-09-15 16:05:50 +02:00
Matthias Clasen
29ab70b801 css: Fix compiler warnings
Fix warnings due to -Wdeclaration-after-statement and -Wshadow.
2015-06-02 09:08:15 -04:00
Alexander Larsson
8e032622c8 box-shadow: For top/bottom and left/right parts, repeat a single line
Since these part really are the same in all of the x or y direction
and we don't blur in that direction we can just blur one line and
repeat it during drawing.

https://bugzilla.gnome.org/show_bug.cgi?id=746468
2015-03-21 21:39:15 +01:00
Alexander Larsson
967cb56275 shadow-box: Blur only horizontally/vertically for the non-corner parts
There is no need to e.g. blur in the x-direction for the top part
of a box shadow. Also, there is no need to extend the mask in the
non-blurred direction.

https://bugzilla.gnome.org/show_bug.cgi?id=746468
2015-03-21 21:31:49 +01:00
Alexander Larsson
9c2a16fb3b shadow-box: Bail out blur early if radius is 1px
For radius 1px the current implementation rounds down to a 1 px box
filter which is a no-op. Rather than creating useless shadow masks
in this case we bail out blurring early.

Another alternative would be to make radius 1px round up to a 2 px box
filter, but that would change the rendering of Adwaita which is probably
not a great idea this late in the cycle.

https://bugzilla.gnome.org/show_bug.cgi?id=746468
2015-03-21 21:07:26 +01:00
Benjamin Otte
da25771e58 cssvalue: Remove GtkCssDependencies
They are not used anymore.
2015-03-18 15:23:31 +01:00
Benjamin Otte
1116914ea0 css: Move scale to GtkStyleProviderPrivate
This way, we can remove it as a separate argument from
gtk_css_value_compute() and allow computation to only depend on one
thing: the style provider.
2015-02-06 11:26:31 +01:00
Benjamin Otte
e697213b35 render: Remove spinner special-cases
The spinner is a regular builtin image now. There is no need to go
through the shadows code manually anymore as regular items do get
shadows automatically.

This also allows simplifying the actual spinner drawing code so that it
actually works.
2015-01-20 06:30:19 +01:00
Benjamin Otte
572f46067f cssstyle: Rename GtkCssComputedValues => GtkCssStyle
This is literally just renaming of the object (and the associated source
files). No other changes are in there.
2015-01-07 14:26:46 +01:00
Matthias Clasen
cb3393f001 css: Avoid excessive shadow rendering
The shadow rendering code had code to exit early if we determine
that the shadow is entirely clipped away. Unfortunately, the check
based on cairo clip extents fails for any clip regions that are
more complicated than axis-aligned rectangles, and we are using
a hollow rounded rectangle here. So, instead, do the check manually,
using the just-introduced API in GtkRoundedBox.
2014-12-02 08:29:24 -05:00
Javier Jardón
710f332082 configure.ac: Depend on cairo 1.14.0
This is needed for cairo_set_device_scale()
2014-11-10 15:12:17 +00:00
Benjamin Otte
3f4bd447f8 shadows: Respect scaled factors for cached surface 2014-10-10 01:02:34 +02:00
Jasper St. Pierre
dadc37e64d cssshadowvalue: Add a cache for blurred Pango layouts
Drawing text with Pango is quite expensive, and drawing text and also
blurring it is *really* expensive. To prevent us from drawing a lot of
text and then blurring it a lot is *really* expensive.

We now cache the blurred pixels for the last layout and shadow we made,
which means we can repeatedly draw labels with a blurred text-shadow
extremely fast.

To detect whether the shadow is up-to-date, we track the serial of the
PangoLayout alongside the radius of the box shadow. We don't support
inset shadows nor spread on text-shadow, so we don't need to track
these.
2014-10-06 01:58:31 +02:00
Benjamin Otte
23948d6a3a themingengine: Move actual render functions to gtkrender.c
GtkThemingEngine just always calls
  gtk_do_render_foo(engine->priv->context, ...)
now. Other than that, the code is unchanged.
2014-10-03 06:18:05 +02:00
Jasper St. Pierre
763aa4db94 cssshadowvalue: Move the check for blurring into its own function
This makes it easier to update the check later.
2014-10-03 06:18:04 +02:00
Jasper St. Pierre
6556e7e08d cssshadowvalue: Rename shadow_key to original_cr_key
shadow_key is a poor name for this, and we're going to add more user
data keys, so rename it to something more indicative of what it's used
for.
2014-10-03 06:18:04 +02:00
Jasper St. Pierre
e6a0378289 gtkcssshadowvalue: Use cairo_surface_create_similar_image
Calling this on an Xlib surface allows us to keep this in SHM memory,
giving it a potential speedup so we don't have to copy it to SHM memory
for the Composite when we mask later.
2014-09-02 11:26:55 -07:00
Jasper St. Pierre
f33eb7a373 cssshadowvalue: Fix whitespace 2014-08-31 19:50:37 -07:00
Matthias Clasen
e014b89310 Move gtkthemingengine to deprecated directory
This is the place for wholly-deprecated sources.
2014-08-29 16:35:37 -04:00