Commit Graph

946 Commits

Author SHA1 Message Date
Benjamin Otte
69629ebb1a transform: Treat 0 perspective transforms as identity
This happens if you apply a perspective transform and its inverse, which
is the negative version of the perspective.
2019-06-02 15:12:37 +02:00
Timm Bäder
a51b694314 gl renderer: Remove homegrown transform_bounds code
GskTransform can do this for us now.
2019-06-02 11:43:06 +02:00
Timm Bäder
b6cc774312 transform: Add G_GNUC_WARN_UNUSED_RESULT annotations
These functions return the new transform so their return value should
really never be ignored.
2019-06-02 10:33:30 +02:00
Timm Bäder
db548ee2a0 gl renderer: Fix scale computation
We don't need to just look at the scale of the new modelview matrix, but
at the one we get when multiplying the new one with the current one.

Test case attached.
2019-06-02 10:25:39 +02:00
Timm Bäder
f999572e8f gl renderer: Use GskTransform in render ops builder
for the modelview matrix. We need this later.
2019-06-02 10:12:09 +02:00
Timm Bäder
f1996783ec gl renderer: Fix rounded rect intersection code
Test case attached.

Fixes #1920
2019-06-02 08:31:44 +02:00
Niels De Graef
df9aed6c61 Fix some GObject introspection annotations
Fixes several warnings by the GIR compiler.
2019-05-30 20:34:43 +02:00
Benjamin Otte
53f23f8ae9 rendernodeparser: Handle empty Cairo nodes
Cairo nodes can contain a NULL surface if they have never been drawn to.
Make this the default Cairo node.
2019-05-30 15:32:36 +02:00
Benjamin Otte
1e0c0c0ba7 rendernodeparser: Parse cairo script
Use cairo-script-interpreter to parse the scripts that generate cairo
nodes.

This requires libcairoscriptinterpreter.so to work properly, but if
it isn't found we disable this (unimportant for normal functioning)
code and just emits a parser warning.
The testsuite requires it however or it will fail.

A new test is included that tests all of this.
2019-05-30 15:32:36 +02:00
Timm Bäder
78ee4c0677 gl renderer: Properly flip scaled fallback nodes
Fixes cairo nodes in hidpi setups
2019-05-30 09:12:45 +02:00
Benjamin Otte
89fb752a8f css: Use %f, not %.17f
The testusite failures explain why:
We don't want to print "1.00000000000000000", but "1".
2019-05-29 14:30:13 +02:00
Benjamin Otte
9ee2b23176 rendernodeparser: Handle repeating linear gradients
Just handle them like regular gradients, only name them differently.
2019-05-29 07:14:31 +02:00
Benjamin Otte
d71c196c5c css: Don't print numbers with exponent
CSS does not do exponents, so printing numbers close to 0 as 1.234e-15
does not work.

Also up the accuracy to 17 digits because that's what everyone else
uses.
2019-05-29 07:14:31 +02:00
Benjamin Otte
6e15538328 broadway: Handle Cairo nodes with NULL surfaces 2019-05-29 07:14:31 +02:00
Matthias Clasen
848f658b32 Trivial 2019-05-26 00:08:39 -04:00
Benjamin Otte
928c85ccc3 rendernodeparser: Parse Cairo nodes
We also print the script, but we don't parse it yet.
2019-05-26 00:50:13 +02:00
Benjamin Otte
fda643952d rendernode: Remove unused function 2019-05-25 23:50:46 +02:00
Timm Bäder
fb86fd900e gl renderer: Make creating render targets easier 2019-05-23 18:42:00 +02:00
Timm Bäder
f32756e705 gl renderer: Remove some unused api form the GLDriver 2019-05-23 18:42:00 +02:00
Timm Bäder
fcfc2ca518 gl renderer: Render recording surface untransformed
Cairo can't handle the y flip apparently.

Fixes #1906
2019-05-21 08:38:11 +02:00
Timm Bäder
3f1afd6040 gl glyphcache: Don't choke on huge glyphs
We blindly assume everywhere that a single glyph will definitely fit on
one atlas, but that's not always the case.
For now, don't crash or produce GL errors.
2019-05-21 08:17:13 +02:00
Benjamin Otte
29cb9230bf rendernode: Blur alpha channel for cairo blur node
The blur node still doesn't properly blur with a transform, but at least
it now doesn't turn semi-transparent stuff black.
2019-05-21 06:43:59 +02:00
Benjamin Otte
b90a66cab5 rendernodeparser: Allow parsing strings
Instead of only allowing for glyph indexes, allow ASCII characters as
replacements. So this glyph sequence
  glyphs: 65 8, 66 8, 67 8
Can be replaced by
  glyphs: "ABC"
provided that the glyph for "A", "B" and "C" are 65, 66 and 67
respectively and their advance is exactly 8.
x offset and y offset must always be 0 and every glyph must start a
cluster.
2019-05-21 06:43:59 +02:00
Benjamin Otte
1a65a6ce76 rendernodeparser: Update to new rules
Update to the docs outlined in #1887.

In particular, the changes do:

1. Require no property, have a working default for everything
2. Be clear about what gets printed and how.

Tests ahve been adapted to still pass.
2019-05-21 06:43:59 +02:00
Benjamin Otte
678aa8088f rgba: Add GDK_RGBA() macro
So far it's private, but it's a pretty cute way to use hex colors, so we
might conside making it public.
2019-05-21 06:43:59 +02:00
Benjamin Otte
a1d08b4b52 rendernode: Take a graphene_point_t for the offset
... instead of 2 floats.
2019-05-21 06:43:59 +02:00
Benjamin Otte
0fd0be4f9a testsuite: Redo node-parser
Base the rewrite on testsuite/css/parser/test-css-parser - we now
require the node file to match a reference node and track the errors it
triggers.
We also no longer use gtester.
2019-05-21 06:43:59 +02:00
Benjamin Otte
20d1bc2ccc rendernodeparser: Skip root node when it's a container
When printing, behave the same way as when parsing:
Magically skip a container node if there is one - just like the
parser magically creates a container node to hold all the nodes
it parses.
2019-05-21 06:43:59 +02:00
Benjamin Otte
ed0ecf0ff0 rendernodeparser: Allow single values instead of 4
This allows writing:
  colors: red;
instead of
  colors: red red red red;
to draw a red border.
2019-05-21 06:43:59 +02:00
Benjamin Otte
c8fc40e793 rendernodeparser: Print properties alphabetically
Because now we have a rule.

Also update some tests to the new order.
2019-05-21 06:43:59 +02:00
Benjamin Otte
6c473d5ff7 glrenderer: Handle NULL debug messages 2019-05-21 06:43:59 +02:00
Timm Bäder
aa922f0779 gl renderer: Pass correct matrix category when rendering offscreen
We can't just pretend we have an identity matrix when we are actually
scaling. This fixes the node editor sometimes not drawing things when
rendering to a texture. We were mistakenly discaring render nodes
because the bounds transformation was wrong.
2019-05-20 12:10:12 +02:00
Timm Bäder
7e502d0752 gl renderer: Delete render_texture framebuffer 2019-05-20 11:08:50 +02:00
Timm Bäder
6a69dc6e5d gl renderer: A GdkGLTexture's context might be NULL
gdk_gl_texture_download ought to still work, but we can't make a NULL
context current obviously.
2019-05-20 09:33:55 +02:00
Timm Bäder
5aa531674e gl renderer: Really fix gl debugging code
Properly label an object and make sure we have the right gl context even
after a gdk_gl_context_end_frame call.
2019-05-20 08:47:41 +02:00
Timm Bäder
63267a2f70 gl renderer: Render fallback nodes upside down
We stuff both gl-drawn and cairo-drawn textures into the same cache, so
we can't really assume that we need to draw any of them flipped or not.
Fix this by drawing fallback stuff upside down and then using
upside-down vertex data for everything.

Fixes #1897
2019-05-18 13:47:59 +02:00
Timm Bäder
a9fb528a60 gl renderer: Remove an outdated comment 2019-05-18 13:47:59 +02:00
Timm Bäder
a2518493a2 gl renderer: Fix color matrix shader
We *just* computed a un-premultiplied color, maybe we should also use
it.
2019-05-18 13:47:59 +02:00
Timm Bäder
ccb9877534 gl renderer: Skip invisible shadows 2019-05-18 13:47:59 +02:00
Timm Bäder
dc7bf31b6e gl renderer: Remove useless ops_offset calls
We add the shadow offset manually.
2019-05-18 13:47:59 +02:00
Benjamin Otte
57061ea7df rendernodeparser: Move EOF test into parse_declarations()
This way, we don't have to duplicate code.

Plus, we can ensure to clear the erroneously parsed value that should
not be used.
2019-05-13 00:59:15 +02:00
Benjamin Otte
ed4af4e777 rendernodeparser: Introduce clear_func
We want to be able to clear the already parsed contents, because we need
to do that when somebody parses the same property twice.
2019-05-13 00:49:18 +02:00
Benjamin Otte
a04ea72ca1 rendernodeparser: Default color to black
Nobody wants to render transparent text.
2019-05-12 17:28:19 +02:00
Benjamin Otte
0886ade182 cssparser: Make gsk_renderer_consume_url() return a string
We don't want to return a GFile because GFile can't handle can't deal
with data: urls.
That makes the code a bit more complicated that doesn't deal with those
URLs, but it makes the other code actually work.

GtkCssImageUrl also now decodes data urls immediately instead of only at
the first load. So don't use data urls if you care about performance.
2019-05-12 17:28:19 +02:00
Benjamin Otte
0103704171 rendernodeparser: Use parser blocks
Instead of trying to do error handling manually, use the semicolon
blocks feature provided by GtkCssParser.
2019-05-12 17:28:19 +02:00
Benjamin Otte
3a373b9b33 rendernodeparser: Parse images differently
Instead of encoding the raw data, encode the full image to a PNG.
And instead of stuffing that encoding into a string, use a full
data: url.
And then remove the width and height properties, because they're now
implicitly included in the data.
And then change the parser to match.
And because the parser now parses regular urls on top of data: urls, we
can now load any random file.
2019-05-12 17:27:01 +02:00
Benjamin Otte
4505f4f17b rendernode: Set EXTEND_PAD when drawing textures 2019-05-12 15:41:53 +02:00
Benjamin Otte
777beb0d0a glrenderer: Ensure current context for debug stuff 2019-05-08 19:47:40 +02:00
Benjamin Otte
1fa4b9f58c rendernode: Parse repeat nodes 2019-05-08 19:47:40 +02:00
Matthias Clasen
64454a7e47 gsk: Add tracing to the vulkan renderer
Emit the equivalent of the cpu-time counter, as well
as pixel numbers i the inspector.
2019-05-07 09:37:59 -07:00
Matthias Clasen
b09a0958a0 gsk: Add tracing to the gl renderer
Emit the equivalent of the cpu-time counter in the inspector.
2019-05-07 09:37:59 -07:00
Matthias Clasen
c541fa9555 gsk: Add some more profiler apis
Add a way to extract the start time of timers.
This will let us reuse the profiler timers for tracing.
2019-05-07 09:37:59 -07:00
Timm Bäder
e847c030bd gl renderer: Fix blur nodes with radius 0 2019-05-07 17:21:16 +02:00
Timm Bäder
4869013a8d gl renderer: Fix coloring shader
We *just* pre-multiplied u_color but then didn't use its rgb values.
This fixes backdrop scale marks in Adwaita to not be white.
2019-05-06 17:58:55 +02:00
Timm Bäder
3e2107846d gl renderer: Fix blend shader 2019-05-06 17:34:48 +02:00
Timm Bäder
d5d48af7f7 gl renderer: Reset opacity when offscreen-rendering crossfade nodes
A pattern emerges...
2019-05-05 07:18:39 +02:00
Benjamin Otte
3f24ad741a gsk: Export gsk_vulkan_renderer_new() 2019-05-05 07:18:39 +02:00
Benjamin Otte
cc5f2f8995 gsk: Export gsk_broadway_renderer_new()
... when broadway is enabled.
2019-05-05 07:18:39 +02:00
Benjamin Otte
6594ccf716 gsk: Export gsk_gl_renderer_new() 2019-05-05 07:18:39 +02:00
Benjamin Otte
559ae8b326 gsk: Export Cairo renderer 2019-05-05 07:18:39 +02:00
Benjamin Otte
b4f5baf4fa rendernode: Parse and print blend nodes properly 2019-05-05 07:18:39 +02:00
Timm Bäder
dde69802cd Add error func to node deserialization 2019-05-05 07:18:39 +02:00
Timm Bäder
fb63364f30 rendernode: Remove old GVariant (de)serialization code
We're doing the CSS thing now.
2019-05-05 07:18:39 +02:00
Timm Bäder
01a7c7a8b2 Parse render nodes from text files
Instead of the previous approach using GVariant, this new approach uses
human-readable text files as the serialization format for render nodes.

The format is a custom one, but it is inspired by QML and conforms to
the CSS syntax. Because of that, we can use the CSS machinery from GTK
to parse it, and in particular share code to parse properties that GTK's
CSS machinery also supports, such as colors.

This commit breaks all existing usages of node files - such as the
testsuite and various test tools - they will be fixed in further
commits.
2019-05-05 07:18:39 +02:00
Benjamin Otte
19227d9789 rendernode: Compute border node colors properly
Change the way we compute border color cutoffs to the same method that
browsers use. This method does not consider the corner sizes at all and
only looks at border-width.
2019-05-02 19:35:45 +02:00
Benjamin Otte
8915d60900 roundedrect: Mke sure shrinking borders works
Previously, when borders were too big - ie when a 100x100 rect had only
one 100x100 border, like the black part of ◔ - and then shrinking this
rect by 25px on either side, we'd end up with a 50x50 rect with a 75x75
border, and that's obviously not correct.
2019-05-02 19:35:45 +02:00
Matthias Clasen
3f940715e4 gsk: Documentation tweaks
Add some missing symbols.
2019-05-01 23:24:14 -04:00
Alexander Larsson
484e330e4a Merge branch 'wip/baedert/fix-gl-debug' into 'master'
Fix GL debugging

See merge request GNOME/gtk!778
2019-04-29 11:42:04 +00:00
Benjamin Otte
c06d1a69ae Merge branch 'transform-fixes' into 'master'
Small fixes to GskTransform

See merge request GNOME/gtk!660
2019-04-29 00:42:28 +00:00
Emmanuele Bassi
cf9deb7cf5 Use getters for translation and scaling components
Instead of accessing the matrix cells directly.
2019-04-29 02:26:31 +02:00
Emmanuele Bassi
40beb69487 Never compare floats for equality
Floating point values cannot ever be compared for equality. GLib has a
G_APPROX_VALUE macro that lets us compare two value within a provided
precision, so we should use that instead.
2019-04-29 02:26:31 +02:00
Emmanuele Bassi
f1cadee196 Use matrix equality in GskTransform
Graphene has new API to check for equality, so we should use it instead
of doing a byte-by-byte comparison.
2019-04-29 02:26:31 +02:00
Emmanuele Bassi
478fdaa632 Use atomic boxing instead of manual refcounting
Artisanal, homegrown, locally sourced, vegan reference counting has been
replaced by the appropriate API in GLib, which does small things like
saturation and type checking.
2019-04-29 02:25:18 +02:00
Timm Bäder
c848b9014b gl renderer: Add simple blend node implementation 2019-04-28 07:58:31 +02:00
Timm Bäder
931b0b3752 gl renderer: Move texture labeling below initialization
Apparently genTextures and friends only "reserves names", initializing
them will actually create them. Using glObjectLabel on textures before
initializing them will throw a GL_INVALID_VALUE error.
2019-04-27 10:44:37 +02:00
Timm Bäder
1a7c280ebb gl renderer: bind the texture framebuffer before rendering
When rendering to a texture, collecting the render ops might bind a
different framebuffer, so bind the one we want again before doing the
actual rendering.
2019-04-26 18:05:32 +02:00
Alexander Larsson
32edf29c0a GskGLRenderer: Add debug groups
This adds debug groups in various places, including the debug
nodes if those are in use. This makes the traces in tools like
renderdoc much easier to read.
2019-04-25 11:36:21 +02:00
Alexander Larsson
4f7171885f GskGLRenderer: Label various gl objects
This means the names are more useful in tools like renderdoc.
2019-04-25 11:35:00 +02:00
Timm Bäder
e13d242320 gl renderer: Keep op builder around
GL keeps the unoform state per-program, but not per-frame. So, we can't
pretend that this works for us. Keep the RenderOpBuilder around for the
entire lifetime of the renderer instead.
2019-04-24 17:55:14 +02:00
Timm Bäder
91bbe6ef95 gl renderer: Sync gpu and cpu default alpha value
Otherwise we might end up not passing the new value to the GPU.
2019-04-24 13:29:45 +02:00
Timm Bäder
34fcfb154a gl renderer: Properly apply opacity in cross-fade shader 2019-04-24 13:29:45 +02:00
Timm Bäder
cc878ec00f gl renderer: begin/end_frame around do_render
This fixes rendering to a texture on intel hardware. The glClear calls
would throw a GL_FRAMEBUFFER_INCOMPLETE error here, because the
gsk_gl_driver_begin_frame() call in do_render() reset the framebuffer
object in use.
2019-04-23 17:09:14 +02:00
Benjamin Otte
9b6f822f15 rendernode: Fix border rendering
This fixed the reftest introduced in the previous commit.

I'm using a mesh gradient here instead of drawing 4 individual sides to
avoid artifacts when those sides overlap in rounded corners.
2019-04-19 03:39:57 +02:00
Benjamin Otte
3f9b8f25d8 vulkan: Add missing break statement 2019-04-15 14:38:23 +02:00
Timm Bäder
3569348f9c gl renderer: Declare color matrix child separately
Otherwise I'm doing this all the time when debugging.
2019-04-13 06:00:02 +02:00
Benjamin Otte
8001c7d972 transform: Add gsk_transform_parse()
It uses the new CSS parser.
2019-04-12 19:34:29 +02:00
Benjamin Otte
96f9cbcabf cssimage: Make cross-fade() an array
The new spec at https://drafts.csswg.org/css-images-4/#cross-fade-function
allows infinite images to cross-fade and we want to, too.
2019-04-12 19:34:28 +02:00
Timm Bäder
0245ac2106 gl renderer: Apply transform only for final texture drawing
We don't want the new transform while drawing things on a texture.
Instead, only apply the new transform matrix when adding the final
texture drawing ops.

This fixes the stack cube rotation transition to at least look somewhat
better.
2019-03-31 06:16:16 +02:00
Timm Bäder
b2089b89cc gl renderer: Add debug code to dump framebuffer
This way we can specify it on specific add_offscreen_ops callsites.
2019-03-31 06:14:41 +02:00
Alexander Larsson
43778bef4d broadway: Add minor comment 2019-03-29 14:30:13 +01:00
Alexander Larsson
f1ba94843e broadway: Move gsk files to a subdirectory 2019-03-29 14:30:13 +01:00
Alexander Larsson
f932d35c95 broadway: Optimize color matrix + texture nodes to pre-colorized texture 2019-03-29 14:30:13 +01:00
Benjamin Otte
c04190e761 rendernode: Round pixel colors in color matrix drawing
Fixes symbolic-icon-translucent-color.ui reftest
2019-03-29 09:56:52 +01:00
Alexander Larsson
9212727f53 broadway: Use css transforms
This allows generic transforms nodes to work.
2019-03-27 19:27:16 +01:00
Alexander Larsson
fbefec52a5 Broadway: Add id for nodes and reuse old ones
When sending render nodes from the client to the daemon we add an id,
and whenever we're about to re-send the entire tree node we instead
send the old id. We track all the nodes for the previous frame
of the surface this way.

Having the id on the daemon side will allow us do to much better deltas.
2019-03-26 17:07:47 +01:00
Alexander Larsson
d59d8b5dd4 Disable accidental debug spew 2019-03-26 17:07:47 +01:00
Alexander Larsson
311aa01e01 broadway: Simplify fallback node cache
Since nodes are now cached we just store the fallback as a
texture in a hashtable indexed by the node. If its unused for
5 frames we drop it.
2019-03-26 17:07:47 +01:00
Alexander Larsson
890b759091 broadway: Send actual float32, not some hack 2019-03-26 17:07:47 +01:00
Alexander Larsson
b097f0a7d8 Broadway: Add node for debug nodes
This can be helpful when debugging broadway.
2019-03-26 17:07:47 +01:00
Alexander Larsson
1b5b1bfd0e broadway: Don't fall back for translation transform nodes
These are trivial anyway
2019-03-26 17:07:47 +01:00