Commit Graph

1178 Commits

Author SHA1 Message Date
Matthias Clasen
102cc1c8d3 gl: Add 1 pixel of padding in the icon cache 2019-06-04 23:00:01 +00:00
Matthias Clasen
2529385fe4 glyph cache: Reinstate 1 pixel padding
This is necessary to prevent bleeding.
2019-06-04 23:00:01 +00:00
Matthias Clasen
f37274dbb0 gl: Don't leak texture atlases
We need to free the texture atlases, and the
textures backing them.
2019-06-04 23:00:01 +00:00
Matthias Clasen
a3757936c1 gl: Free icon data 2019-06-04 23:00:01 +00:00
Matthias Clasen
adb5df020c glyph cache: Clarify message
We have different kinds of caches now.
2019-06-04 23:00:01 +00:00
Timm Bäder
cf4ff56ca5 gl renderer: Add & use icon cache
Upload small icons all to the same texture atlas.
2019-06-04 23:00:01 +00:00
Timm Bäder
e2ffad7b07 glimage: Only support uploading one region 2019-06-04 23:00:01 +00:00
Timm Bäder
b74bb90c7d gl renderer: Move texture atlas into its own file
We want to reuse the code later.
2019-06-04 23:00:01 +00:00
Timm Bäder
66b081dc9c glglyphcache: Use stb_rect_pack for better glyph packing 2019-06-04 22:42:00 +00:00
Timm Bäder
4b3986ae1f rendernodeimpl: Inline container_node_get_bounds into _new
It's the only caller of the function and we can avoid a second loop over
all child nodes this way.
2019-06-04 16:48:08 +02:00
Matthias Clasen
206970c1e8 Merge branch 'transform-tests' into 'master'
Transform tests

See merge request GNOME/gtk!910
2019-06-03 16:41:17 +00:00
Matthias Clasen
4ed57449ba gsk: Fix printing of identity transforms
These need to print as "none", otherwise
the parser does not accept them.
2019-06-03 16:20:38 +00:00
Matthias Clasen
d93fb5a3fa Cosmetics
Fix up a variable name mismatch in GskTransform docs.
2019-06-03 16:15:16 +00:00
Benjamin Otte
4efa457a63 Merge branch 'for-master' into 'master'
rendernodeparser: Handle Cairo being stupid

See merge request GNOME/gtk!909
2019-06-03 15:45:20 +00:00
Timm Bäder
a1161456ff GskTransform: NULL is a valid transform 2019-06-03 17:36:31 +02:00
Benjamin Otte
d81cf5a443 rendernodeparser: Handle Cairo being stupid
Cairo writes to finished streams, so we have to make sure to keep the
stream around to allow it to do that.
2019-06-03 17:22:11 +02:00
Timm Bäder
a0cb68283d gl renderer: Dont' memcmp() a GskTransform 2019-06-03 17:07:26 +02:00
Timm Bäder
d228f4bb76 gl renderer: Don't ref transform twice
That's gonna leak it otherwise.
2019-06-03 17:03:02 +02:00
Timm Bäder
3a49c0eb2f glyphcache: Don't leak hashtables 2019-06-03 17:03:02 +02:00
Timm Bäder
05ca772631 GskTransform: Ignore identity transforms
We often end up with e.g. a scale of 1 or a translation by 0/0. Ignore
those transforms since they don't do anything.
2019-06-03 17:03:02 +02:00
Timm Bäder
efe9bba343 gl renderer: Ref transform before using it
Fixes #1929
2019-06-03 17:03:02 +02:00
Timm Bäder
fb1f929c38 gl renderer: Dont' unnecessarily to_matrix transforms 2019-06-03 17:03:02 +02:00
Matthias Clasen
3c6c07e94d gl: Avoid a memdup in glyph upload
We don't need to dup the memory here if we
set up the image surface properly. This won't
matter for most glyphs, but some of them can
be big.
2019-06-03 02:47:52 +00:00
Matthias Clasen
e0803f039f gl: Fix glyph cache aging
The logic here seems faulty. We want to keep
a timestamp that tells us when the glyph was
last used, so always update the timestamp.

And whenever we use a glyph, it turns 'young'
again, so remove it from the old pixels
accounting.

The (MAX_AGE, MAX_AGE+CHECK_INTERVAL) interval
is only relevant to prevent us from turning
a cached glyph old more than once, and that
is already taken care of.
2019-06-03 02:09:04 +00:00
Matthias Clasen
3059d76b4c Add code to dump out the glyph caches 2019-06-03 02:09:04 +00:00
Matthias Clasen
0a09b8dca7 gl: Improve cache dropping code
There was a TODO here to avoid iterating the
glyphs multiple times, so avoid that. And
actually log the number of glyphs that was dropped.
2019-06-03 02:09:04 +00:00
Matthias Clasen
ad2a1c92ce gl: Improve glyph cache logging
Use g_message to be consistent, and make the
message fit a line.
2019-06-03 02:09:04 +00:00
Matthias Clasen
fd4182f5c5 gl: Log creation of glyph caches
Now that they can be of different sizes, this
is somewhat interesting.
2019-06-03 02:09:04 +00:00
Matthias Clasen
a64dfb1dfc gl: Make the glyph cache survive big glyphs
Create an extra atlas of just the right size for
each huge glyph. Not pretty, but works.
2019-06-03 02:08:36 +00:00
Benjamin Otte
7e9cb07a92 Merge branch 'for-master' into 'master'
For master

See merge request GNOME/gtk!903
2019-06-03 00:22:40 +00:00
Benjamin Otte
5a0c8805fc transform: Coalesce similar transforms
If somebody does a transform like
  scale(5) scale(10) translate(1,1) translate(5,0)
store it instead as
  scale(50) translate(6,1)
This way, less memory is consumed and transforms are easier to read.

In particular, this simplifies the typical transforms we do in GTK,
which are just one translation after another.
2019-06-02 21:18:56 +02:00
Matthias Clasen
1a4e360c2c Don't generate mipmaps needlessly
GL_LINEAR doesn't use mipmaps, so don't generate them.
2019-06-02 18:29:11 +00:00
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
Benjamin Otte
658588dfe7 renderer: Make gsk_renderer_is_realized() public
... and add a property for it.
2019-03-19 08:47:54 +01:00
Benjamin Otte
480d8aec06 renderer: Remove display property
Renderers don't need a display until they get realized. And once they
get realized, they can look up the display from the surface.
2019-03-19 08:47:54 +01:00
Bastien Nocera
884088f649 gsk: API docs fixes
gsk/gskenums.h:181: Error: Gsk: multiple "@GSK_TRANSFORM_CATEGORY_2D" parameters for identifier "GskTransformCategory":
 * @GSK_TRANSFORM_CATEGORY_2D: The matrix is a 2D matrix. This is equivalent
    ^
gsk/gsktransform.c:1342: Warning: Gsk: gsk_transform_to_2d: unknown parameter 'm' in documentation comment, should be 'self'
gsk/gsktransform.c:1368: Warning: Gsk: gsk_transform_to_2d: invalid return annotation
gsk/gsktransform.c:1461: Warning: Gsk: gsk_transform_to_translate: unknown parameter 'm' in documentation comment, should be 'self'
2019-03-07 16:29:28 +01:00
Benjamin Otte
18da852e15 rendernode: Add can_diff implementation for transform nodes
That one was missing and killing performance in the fishbowl.
2019-03-06 12:40:58 +01:00
Timm Bäder
9105de9170 gl renderer: Cache rendered fallback nodes 2019-03-06 06:31:25 +01:00
Timm Bäder
eeed55d45c gl renderer: Mark pointer textures as used
Otherwise we remove them, causing additional texture uploads.
2019-03-06 06:31:25 +01:00
Benjamin Otte
3a3b325f8e transform: Add perspective()
This commit adds gsk_transform_perspective(), gtk_snapshot_perspective()
and support for perspective() in the CSS syntax.
2019-03-05 20:46:00 +01:00
Benjamin Otte
dbe58452d7 rendernode: Implement diffing of transform nodes
This reinstates diffing in the same way that it worked for offset nodes.

It would be possible to add diffing for affine transforms or even all
transforms, but I think this is unnecessary right now - and also quite
expensive to compute.
2019-03-04 23:41:51 +01:00
Benjamin Otte
a8bf5eee0f transform: Readd optimization
This is the optimization from bbd4e2f60d
2019-03-04 23:41:51 +01:00
Benjamin Otte
bd113aa85c transform: Redo querying API
Make the API expect a tranform of the proper category instead of
doing the check ourselves and returning TRUE/FALSE.

The benefit is that the mai use case is switch (transform->category)
statements and in those we know the category and don't need to check
TRUE/FALSE.

Using the wrong matrix will now cause a g_warning().
2019-03-04 23:41:51 +01:00
Benjamin Otte
1fecbd4241 transform: Store the category in the transform
... instead of computing it every time we need it.

This should be faster and we want to use it a lot more prominently.

Also, we have the struct memory available anyway.
2019-03-04 23:41:51 +01:00
Benjamin Otte
3545abc7a1 transform: Implement gsk_transform_invert()
And use it.

And test it.
2019-03-04 23:41:51 +01:00
Benjamin Otte
70b341139b transform: Remove gsk_transform_identity()
This used to be a good idea back when GskTransform was intended to be
used for transitions, but without it, it's not anymore.
2019-03-04 23:41:51 +01:00
Benjamin Otte
e737b42113 trasnform: Fix print statement
We were printing the wrong variable.
2019-03-04 23:15:24 +01:00
Benjamin Otte
cf00c36c85 transform: Split rotate() and rotate3d() class
This is mainly for accuracy: We can guarantee the math we do for 2D
rotations results in a 2D matrix.
2019-03-04 23:15:24 +01:00
Benjamin Otte
3cc84d2860 transform: Make category public API
Also rename it from GskMatrixCategory to GskTransformCategory.
2019-03-04 23:15:24 +01:00
Benjamin Otte
791bf0c2eb transform: Remove API to poke internals
It is not interesting to users of GskTransform how it is made up
internally. Users should just use the gsk_transform_to_*() APIs.
2019-03-04 23:15:24 +01:00
Benjamin Otte
3a3c2d14ab rendernode: Make the transform node take a GskTransform
This is an attempt to push GskTransform deeper into the stack.
2019-03-04 23:15:07 +01:00
Benjamin Otte
4916280883 transform: Add more API
In particular, add a per-category querying API for the matrix:
- gsk_transform_to_translate()
- gsk_transform_to_affine()
- gsk_transform_to_2d()
- gsk_transform_to_matrix()

This way, code can use the relevant one for the given category.
2019-03-04 23:15:06 +01:00
Benjamin Otte
0e1a50366a transform: Move to GSK
The renaming of the prefix makes this a large patch.
2019-03-04 23:09:02 +01:00
Timm Bäder
dc282991c6 roundedrect: Add gsk_rounded_rect_to_string
Keep it private for now, but it's very useful when debugging.
2019-02-28 10:33:18 +01:00
Timm Bäder
7931ab5f33 gl renderer: Change shadow cache eviction strategy
Since we can do partial redraws, dropping every shadow that's been
unused for one frame happens too fast. This is also a problem when a
shadow gets drawn on a texture for a few frames.
2019-02-28 10:33:18 +01:00
Timm Bäder
416a4cf5ea gl renderer: Ignore nodes with nan bounds
This can happen for certain transform nodes. The transform node's
child's bounds are fine, but the transform node bounds are all nan.
Just ignore those bounds since we can't meaningfully render them anyway.
2019-02-28 07:22:34 +01:00
Timm Bäder
bbd4e2f60d transformnode: Avoid matrix multiplication if we can
If the given matrix is explicitly of category IDENTITY, we don't need to
do anything, and in the 2D_TRANSLATE case, just offset the child bounds.
Those are the two most common cases.
2019-02-28 07:22:34 +01:00
Timm Bäder
5577e30ad4 gl renderer: Add more nodes that support transforms 2019-02-28 07:22:34 +01:00
Timm Bäder
e836c575ce gl renderer: Remove GskRoundedRect initializaion 2019-02-25 08:46:27 +01:00
Timm Bäder
47fb1ec4c4 gl renderer: Partially implement rounded rect intersection
Some rounded rect intersections can actually be done and even expressed
as a single rounded rectangle.
2019-02-25 08:46:27 +01:00
Timm Bäder
f0624266dc gl renderer: Add debug function to dump render node 2019-02-25 08:46:27 +01:00
Timm Bäder
58c2bea959 gl renderer: Stop determining the matrix category ourselves
Use the category we get from transform nodes and add ops_ API to supply
one when we set a graphene_matrix_t directly.
2019-02-25 08:37:06 +01:00
Timm Bäder
f9041230c6 gl renderer: Round size up when rendering to a texture
Both the clip we use and the viewport we set should contain the entire
texture size and not potentially clip the last pixel.
2019-02-23 04:50:25 +01:00
Timm Bäder
da0bd697b8 gl renderer: Use the matrix node category 2019-02-22 19:08:43 +01:00
Benjamin Otte
0d119f81c8 snapshot: Refactor text rendering
The code didn't change, it was just shuffled around to make the
with_bounds() versions of the text rendering unnecessary and instead
pass through the generic append_node() path.
2019-02-21 19:47:28 +01:00
Benjamin Otte
e1570e9ebc snapshot: Add gtk_snapshot_append_border()
This is adding functions for the remaining render nodes.
2019-02-21 19:47:28 +01:00
Benjamin Otte
6a4bf2b993 gsk: Remove offset nodes
They were a neat idea while they lasted. But now, it's time for
categorized transform nodes, where matrices with
GSK_MATRIX_CATEGORY_2D_TRANSLATE are the exact replacement.

Renderers have not been adapted for this purpose, so they (continue to)
run slow paths.
2019-02-21 19:47:28 +01:00
Benjamin Otte
70a1233a28 gsk: Add GskMatrixCategory
We'll use that soon.
2019-02-21 19:47:27 +01:00
Timm Bäder
a872c41f79 glglyphcache: Fix dropping caches unnecessarily
The first set of glyphs is created with a timestamp of 1. Later we
subtract the glyph timestamp from the cache timestamp, meaning we end up
with numbers ending in 9, e.g. 59. Now unfortunately !(60 <= 59), so we
do not end up incrasing the old_pixels count of the cache. Later we then
call lookup() and DEcrease the old_pixels count, which makes the
unsigned int wrap and cause a huge old_pixels value, which causes us to
drop the cache.
2019-02-10 10:31:27 +01:00
Timm Bäder
ea554580c7 glglyphcache: Remove surface member from dirty glyph
We don't use it after we've rendered to it, just its size and data.
2019-02-10 10:31:27 +01:00
Emmanuele Bassi
4040f76529 Use @basename@ in enumeration type templates
The @filename@ directive will use the full path of the file being parsed
for enumeration types; we should use @basename@, instead, as it improves
the reproducibility of the build by using only the file name.
2019-02-04 14:02:45 +01:00
Benjamin Otte
359bc7695c build: Reintroduce warning flags from autotools
Some of the flags got lost in the meson transition or were demoted from
error flags to warning flags.
This commit reintroduces them.

It also includes fixes for the code that had warnings with those flags.
The big one being -Wshadow.
2019-01-22 04:33:12 +01:00
Timm Bäder
8e0cbc1c3d gl renderer: Support (not) resetting the opacity for offscreen nodes
We usually want to do that, but it's wrong for e.g. crossfade nodes.
2019-01-18 19:43:54 +01:00
Timm Bäder
e14fe222e8 gl renderer: Don't add clip ops if the clip didn't change 2019-01-18 19:40:49 +01:00
Timm Bäder
59bf76dce1 gl renderer: Force blur shadow node children offscreen
This broke the overlay blur demoe when resizing the window to a size
that would completely move the image below a button, causing the
GtkSnapshot code to remove the clip node below the blur node.
2019-01-13 08:41:37 +01:00
Timm Bäder
d55fc8b7b1 gl renderer: Dont't try to draw glyphs at scale 0
Fixes #1475
2019-01-10 17:14:48 +01:00
Timm Bäder
e72d0a9118 gl glyphcache: Only support one dirty glyph per atlas 2019-01-10 16:49:19 +01:00
Timm Bäder
fb7d033953 gl renderer: Remove debug code 2019-01-10 16:49:19 +01:00
Timm Bäder
cfa440bbae gl renderer: Fix hidpi transform nodes 2019-01-10 16:49:19 +01:00
Timm Bäder
b0a8b7da63 gl renderer: Only compile the vertex shader once
All our programs use the same vertex shader, so don't compile it over
and over again. This improves startup times by at least 0.001%, I swear.
2019-01-10 16:49:19 +01:00
Timm Bäder
b2ff6e91cd gl renderer: Don't forget the offset when rendering blur nodes 2019-01-10 16:49:19 +01:00
Timm Bäder
1d3aa9207c gl renderer: Add a clip stack
So we can check that the currently set clip is the first one and now
intersect with it. This first clip is always the entire viewport or the
entire render_area and we don't want to end up drawing things to a
texture because of it.
2018-12-31 12:44:02 +01:00
Timm Bäder
3ce45508e1 gl renderer: Track border width state separately 2018-12-07 16:36:10 +01:00
Timm Bäder
57efdcfbbe gl renderer: Ignore subsequent render target ops 2018-12-07 16:36:10 +01:00
Timm Bäder
df817bd118 gl renderer: Ignore viewport ops to the same viewport 2018-12-07 16:36:10 +01:00
Timm Bäder
4b3a94f382 gl renderer: Fix remaining TODO about offset nodes
All of the nodes should now support offsets.
2018-12-04 06:30:47 +01:00
Timm Bäder
d67dacedba gl renderer: transform nodes: offset 2018-12-04 06:30:47 +01:00
Timm Bäder
e1feb1b712 gl renderer: Clip nodes: offset 2018-12-04 06:30:47 +01:00
Timm Bäder
e8670c89ae gl renderer: Linear gradients: offset 2018-12-04 06:30:47 +01:00
Timm Bäder
b4f918904c gl renderer: Outset shadow nodes: offset 2018-12-04 06:30:47 +01:00
Timm Bäder
aead150ce2 gl renderer: Care about offset when rendering border nodes 2018-12-04 06:30:47 +01:00
Timm Bäder
fd47e57e4b gl renderer: care about offset when rendering shadow nodes 2018-12-04 06:30:47 +01:00
Timm Bäder
2b95a5daee gl renderer: Remove blend shader
It's unused.
2018-12-02 16:04:40 +01:00
Timm Bäder
0681c5d5bc gl renderer: Reset opacity when rendering to a texture
The opacity will already be applied when rendering the final texture.
2018-12-02 16:03:08 +01:00
Timm Bäder
b19926c079 gl renderer: Add function to draw debug rectangle 2018-12-02 14:31:57 +01:00
Timm Bäder
692ed4f994 gl renderer: Refactor render op builder 2018-12-02 14:17:18 +01:00
Timm Bäder
ad759307f8 gl renderer: Add more node types to print_render_node_tree
debugging ++
2018-12-02 13:39:55 +01:00
Timm Bäder
58a4ae94e9 gl renderer: Use ops_transform_bounds_modelview in more places 2018-12-02 13:25:43 +01:00
Timm Bäder
9df9087a13 gl renderer: Add NodeSample
As a quick way of checking what a particular sample of nodes (e.g. all
offset node children) are made up of.
2018-12-02 13:25:43 +01:00
Timm Bäder
71512cf9ad gl renderer: Move geometry calculation further down
We don't need it above, so move it to where it belongs.
2018-12-02 13:25:43 +01:00
Timm Bäder
79cc8fb261 gl renderer: Apply offset with scale 2018-12-02 13:25:43 +01:00
Timm Bäder
2831dbb110 gl renderer: Refactor add_offscreen_ops
Use a graphene_rect_t for the node bounds instead of 4 floats.
This makes it simpler to pass the size in without the offset applied.
2018-12-02 13:25:43 +01:00
Timm Bäder
933acb3682 gl renderer: Add offscreen ops without offset applied
When doing color matrix nodes. This fixes color matrix node with scale =
2.
2018-12-02 13:25:43 +01:00
Timm Bäder
574ebafa46 gl renderer: Reset offset when rendering offscreen
We want to apply the offset to the rendered texture, not to the
offscreen-rendered content.
2018-12-02 13:25:43 +01:00
Timm Bäder
74dd05b45e gl renderer: add render ops for dumping the framebuffer
So offscreen rendering can be properly debugged.
2018-12-02 13:25:43 +01:00
Timm Bäder
3eb2cef421 gl renderer: Set the render region as initial clip
So we avoid creating render ops for things outside of it.
2018-12-02 13:25:43 +01:00
Timm Bäder
538491efa1 gl renderer: Fix only_translation check 2018-12-02 13:25:43 +01:00
Timm Bäder
5907ff694f gl renderer: Render non-trivial transforms to a texture
This way we can e.g. render rotated clips, borders, etc.
2018-11-29 08:50:18 +01:00
Timm Bäder
c0cf592336 gl renderer: Cache offscreen textures per node, not size 2018-11-29 08:50:16 +01:00
Timm Bäder
12378f0afa gl renderer: Expand matrix metadata extraction
Instead of getting the translation x/y everytime we use the modelview,
get it once, when extracting the metadata. Do the same with the scale.
And save if the matrix is "simple" at all, i.e. if it only consists of a
translation and/or scale. This will be helpful later when we start
drawing transformed nodes on textures.
2018-11-29 08:23:42 +01:00
Timm Bäder
5ea211bbb1 Revert "gldriver: Don't create surfaces to upload textures"
This reverts commit 6466e53bfc.

This breaks GtkGLArea.
2018-11-29 07:39:11 +01:00
Timm Bäder
ef751bc809 gl renderer: Use stack to keep track of modelview matrix
So we can avoid calculating metadata for matrices all the time.
2018-11-27 05:39:27 +01:00
Timm Bäder
6466e53bfc gldriver: Don't create surfaces to upload textures 2018-11-27 05:37:38 +01:00
Timm Bäder
5936d7f8f2 gl renderer: Properly retrieve matrix scale
So rotating offscreen nodes works.
2018-11-08 05:13:50 +01:00
Timm Bäder
d15df65a9d gl renderer: Save some matrix multiplications
We do this for every single node, which is a little costly, especially
since the common case for the modelview matrix these days is a simple
translation. So, check whether the new modelview matrix is only a
translation matrix and if so, don't do a full matrix multiplication per
node.
2018-10-11 12:27:56 +02:00
Christian Hergert
87d33470ed vulkan: fix warning from g_clear_pointer() changes 2018-07-28 10:54:14 -07:00
Timm Bäder
392b4d9ac5 gl renderer: Pull a few declarations into the closest scope 2018-07-17 17:33:47 +02:00
Timm Bäder
5386cf89f2 GskRoundedRect: Typo 2018-07-17 17:33:47 +02:00
Timm Bäder
b7d948af69 gl renderer: Use a GArray for the shadow cache
It's very small usually, in default Adwaita the only blurred outset
shadow we have is the one for the CSD'd toplevel window.
2018-07-17 17:33:46 +02:00
Elias Aebi
19873e549a gl: implement clipping for legacy contexts 2018-07-14 14:31:50 +02:00
Elias Aebi
05ca6bc189 gl: fix compilation errors for legacy context shaders 2018-07-14 14:24:21 +02:00
Benjamin Otte
3ce3867403 gl: Don't accidentally use ints for float variables
The int was floor()ing the x/y coordinates of glyphs, which could cause
significant repositioning of glyphs when text was scaled via the MVP.
2018-07-13 14:56:04 +02:00
Timm Bäder
3dd188fe7e gl renderer: Cache blurred outset shadow nodes
Since these are particularly expensive to render and we have a pretty
big one used in every client-side decorated window.
2018-07-08 21:50:59 +02:00
Timm Bäder
a0b8e32462 rendernodes: Fix unconditionally impossible diffs
Some of the _diff implementations did a whole bunch of work just to
throw it away afterwards and invalidate the entire union of the two
render nodes, most notably the two clip nodes. Fix this to only call
gsk_render_node_diff_impossible if the previous if-condition is FALSE
and not always.
2018-07-08 21:50:59 +02:00
Timm Bäder
50f76eb8cc GskRenderer: Add missing nullable annotation 2018-07-08 21:50:59 +02:00
Benjamin Otte
9fb3b84253 rendernode: Make offset nodes use floats
It's OpenGL stuff, use floats.
2018-07-04 15:05:37 +02:00
Timm Bäder
165dab8265 gl renderer: Ignore 0-sized fallback nodes 2018-06-26 21:41:29 +02:00
Matthias Clasen
8755d884f3 Remove a lot of Since annotations
4.0 will represent a clean epoch. We don't want to have
lots of noise in the docs about 2.x or 3.x.
2018-06-25 19:55:04 -04:00
Benjamin Otte
c48be6ef96 Revert "Add aligned allocator functions to GSK"
This reverts commit 8e74eb382f.

This code is not necessary. It worked around a bug in graphene where
graphene was requiring stricter alignment than glib allocators could
guarantee.
2018-06-19 20:00:53 +02:00
Benjamin Otte
0b1f0984f5 Revert "Use aligned allocators for GtkSnapshot"
This reverts commit c02bc22cc5.

This code is not necessary.
The bug causing this problem ws prsent in the graphene library.
2018-06-19 19:52:52 +02:00
Timm Bäder
7f8106f2a9 gl renderer: call glViewport directly 2018-06-16 10:09:12 +02:00
Matthias Clasen
4f632296a5 Merge branch 'lrn/gtk4warnings' into 'master'
Fix a lot of warnings in GTK4

See merge request GNOME/gtk!188
2018-06-10 23:14:42 +00:00
Руслан Ижбулатов
10b2f6540a Fix wrong format strings in various places 2018-06-10 21:20:59 +00:00
Руслан Ижбулатов
c02bc22cc5 Use aligned allocators for GtkSnapshot
Any data that is later fed to graphene must be
allocated with proper alignment, if graphene
uses SSE2 or GCC vector instructions.

This adds custom array code (a streamlined copy
of GArray with all unnecessary bells and whistles removed),
which is then used for the state_stack instead of GArray.

There's also a runtime check for the size of GtkSnapshotState
itself being a multiple of 16. If that is not so, any array
elements past the 0th element will lose alignment.
There are probably struct attributes that can
make GtkSnapshotState always have size that is a multiple
of 16, but we'll burn that bridge if we cross it.
2018-06-10 20:35:54 +00:00
Руслан Ижбулатов
a394a86151 Use aligned allocators for GskRenderNode
Any data that is later fed to graphene must be
allocated with proper alignment, if graphene
uses SSE2 or GCC vector instructions.
2018-06-09 14:05:49 +00:00
Руслан Ижбулатов
8e74eb382f Add aligned allocator functions to GSK
The code is mostly stolen from graphene.
Allocators support any alignment, but their implementation
only calls system aligned allocator functions if malloc()
is not aligned to 16-byte boundaries. If it is aligned,
the implementation just calls malloc() regardless of which
alignment is requested by the caller.

This can be fixed by saving the result of meson malloc()
alignment check and adding a few conditions to the implementation,
but right now GSK and GTK only need 16-byte alignment either way.
2018-06-09 14:01:03 +00:00
Timm Bäder
4ab3aada3f gl renderer: use w axis vector from graphene
Instead of initializing our own one every time.
2018-06-04 21:58:44 +02:00
Timm Bäder
719b2b0525 gl renderer: Remove an outdated comment 2018-05-27 17:51:51 +02:00
Timm Bäder
251913c80e gl renderer: Use offsets for more node types 2018-05-27 16:20:55 +02:00
Timm Bäder
c8aa5b8b4e gl renderer: Add helper for printing a render node tree 2018-05-19 10:18:50 +02:00
Benjamin Otte
69644993f6 gsk: Improve GSK_RENDERER behavior
1. Include the broadway renderer (so we can test it properly fails on
   Wayland or X11)
2. List all potential renderers, print useful information when Vulkan
   is not compiled in instea dof omitting it
3. Improve docs
2018-05-07 16:45:32 +02:00
Timm Bäder
31e0aaf6b0 gl renderer: Remove ops debug message
Without a node name, this doesn't make much sense anymore.
2018-05-02 19:48:34 +02:00
Timm Bäder
d506799e72 gl renderer: Ignore nodes outside of the clip
Pretty sure this will bite me later but for now we avoid rendering nodes
that we are not going to see anyway.
2018-05-01 15:13:11 +02:00
Timm Bäder
3a5a9d9233 gl renderer: Use simple offset for selected offset node children 2018-05-01 15:13:11 +02:00
Alexander Larsson
8c5d31d11d broadway: Handle offset nodes 2018-04-24 23:24:55 +02:00
Alexander Larsson
b554f4be20 broadway: Handle cairo nodes of type recording surface 2018-04-24 23:24:55 +02:00
Alexander Larsson
a329de63ea broadway: Add and use GdkBroadwayDrawContext 2018-04-24 23:24:55 +02:00
Benjamin Otte
a865621519 gdk: Move begin/end_frame() functions
As they require a draw context and the draw context is already bound to
the surface, it makes much more sense and reduces abiguity by moving
these APIs to the draw context.

As a side effect, we simplify GdkSurface APIs to a point where
GdkSurface now does not concern itself with drawing anymore at all,
apart from being the object that creates draw contexts.
2018-04-24 23:16:58 +02:00
Benjamin Otte
48fc18c37b gdk: Get rid of GdkDrawingContext
All information is kept in GdkDrawContext these days, so use that one.
2018-04-24 23:16:58 +02:00
Benjamin Otte
c6ae0ff2d1 gdk: Get rid of gdk_drawing_context_get_clip()
Use the identical gdk_draw_context_get_frame_region() instead.
2018-04-24 23:16:58 +02:00
Benjamin Otte
4d481ecb95 gsk: Refactor damage computation for GL renderer
Previously, we got the damage, then computed the changed area, then
started a frame with that changed area.

But starting a frame computes the damage for us.

So now we start a frame, then get the damage area from that, then
compute the change area.
2018-04-24 23:16:58 +02:00
Benjamin Otte
a83487a0c4 cairocontext: Move a function
A function of GdkDrawingContext is only used when drawing with Cairo, so
move it to GdkCairoContext.
2018-04-24 23:16:12 +02:00
Benjamin Otte
f396786051 gdk: Add GdkCairoContext
This does nothing but disallow passing NULL to gdk_surface_begin_paint()
and instead require this context.

The ultimate goal is to split out Cairo drawing into its own source file
so it doesn't clutter up the generic rendering path.
2018-04-24 23:16:12 +02:00
Benjamin Otte
b49dccb86d rendernode: Remove gsk_render_node_set_name()
And of course, gsk_render_node_get_name() is gone, too.
The replacement is of course debug nodes.

As a side effect, GskRenderNode is now *really* immutable.
2018-04-24 04:06:58 +02:00
Benjamin Otte
49f9d2108d gsk: Add GskDebugNode 2018-04-24 04:06:58 +02:00
Timm Bäder
4f3c7cd48a gsk: Make gsk_text_node_new_with_bounds private
We pulled out the bounds calculation for performance reasons, but the
caller can't know how to properly compute them. Inside gtk+, we can do
that but it's not good enough for public API.
2018-04-21 11:20:15 +02:00
Timm Bäder
d74be1fcf0 gl renderer: Rename texture_id parameter to fbo_id
So this makes sense again.
2018-04-21 10:13:16 +02:00
Timm Bäder
29f38056a9 gl renderer: Fix fallback node scaling 2018-04-21 10:06:57 +02:00
Timm Bäder
4336c6412a gl renderer: Remove unused viewport member 2018-04-15 17:12:01 +02:00
Timm Bäder
0a0c909e14 GskRenderer: Plug a memory leak 2018-04-14 12:50:17 +02:00
Timm Bäder
add82735bb gl renderer: Don't use texture ids in glBindFramebuffer calls 2018-04-14 11:47:02 +02:00
Timm Bäder
fdfdada362 gl renderer: Increase GArray size by 2 up front
Since we know we will add two elements anyway.
2018-04-14 11:47:02 +02:00
Timm Bäder
5e81761ad0 gl renderer: Slightly change ops_offset behavior
Add the given delta to the current one instead of replacing it.
2018-04-11 19:14:54 +02:00
Timm Bäder
0336825537 gl renderer: Don't draw all rounded clip nodes to a texture
We only need to do that if the rounde clip node intersects with the
outer one.
2018-04-11 19:14:54 +02:00
Timm Bäder
d7af16c8e4 gl renderer: Render everyhing according to MV scale
And not the surface's scale factor. This way the magnifier works.
2018-04-11 15:31:22 +02:00
Timm Bäder
cc66b50dcd gl renderer: Remove unused field 2018-04-11 15:31:22 +02:00
Benjamin Otte
1792f3b21e rendernode: Add missing return
Don't to extra work when not needed.
2018-04-05 18:40:54 +02:00
Benjamin Otte
200bbe8fda diff: Allow aborting a diff
When the max cost for finding a path gets to high, the diff can now be
aborted.

Because render nodes have a fallback method (by just marking the whole
bounds of the nodes as different), we use this to improve performance
of diffs.

This brings fishbowl (which is basically a container node with N images
that change every frame) back to close to previous performance.
2018-04-05 14:56:38 +02:00
Benjamin Otte
4b72ea33ac diff: Introduce GskDiffSettings
We can put lots of settings there to allow tuning the diff algorithm
used.
2018-04-05 14:56:38 +02:00
Benjamin Otte
0f184d3270 vulkan: Always render clip extents
Now that we have the full render nodes available, there is not much
benefit in fine-grained control over multiple rectangles.
In particular, it's causing pain with complex regions.

There might be a benefit in clipping to the region's rectangles in cases
like widget-factory where the whole diff is made up of the 2 rectangles
of spinner and the pulsing progress bar, but it needs a good heuristic
for where this is useful.
2018-04-05 14:56:38 +02:00
Benjamin Otte
925cbeaadf renderer: Track the previous node
... and diff the previous node with the current one to determine the
clip region.

This doubles the work necessary to track clip regions, but the following
commits will clean that up.
2018-04-05 14:56:38 +02:00
Benjamin Otte
7c313c7b25 gsk: move begin/end_frame vfuncs into the renderers 2018-04-05 14:56:38 +02:00
Benjamin Otte
d0873c7dec gsk: Fold gsk_renderer_begin_draw_frame() into renderer
It doesn't need to be exported anymore.

As a side effect, the inspector no longer has any information about the
render region, so remove the code that was taking care of that.
2018-04-05 14:56:38 +02:00
Benjamin Otte
a6079b9b7b gsk: Implement gsk_render_node_diff()
This includes a copy of the diff(1) algorithm used by git diff by Davide
Libenzi.

It's used for the common case ofcontainer nodes having only very few
changes for the few nodes of child widgets that changed (like a button
lighting up when hilighted or a spinning spinner).
2018-04-05 14:56:38 +02:00
Benjamin Otte
271820b677 rendernode: Add gsk_render_node_diff()
... and gsk_render_node_can_diff(). Those are vfuncs to compute a region
containing all the pixels that differ between the two nodes.

This is just the plumbing that chains into node classes. No node
implements it yet.
2018-04-05 14:56:38 +02:00
Rico Tzschichholz
f2937f8c45 Fix some g-i annotation warnings 2018-04-01 09:15:08 +02:00
Timm Bäder
0f28f0ee39 GskRenderer: Remove outdated documentation comment
All render node trees are immutable
2018-03-31 14:45:03 +02:00
Timm Bäder
08296b8aee gl renderer: Don't highlight cairo nodes as fallback 2018-03-31 14:45:01 +02:00
Timm Bäder
809fdaa3e4 shaderbuilder: Insert newlines directly after defines
Instead of doing that in the loop in the last interation, we can just do
it after the loop.
2018-03-30 23:15:04 +02:00
Timm Bäder
f6330846c9 gl renderer: Remover unused mask uniform 2018-03-30 23:15:04 +02:00
Timm Bäder
badada9cf8 shader builder: Remove unused members 2018-03-30 23:15:04 +02:00
Timm Bäder
be3a42b7b1 shader builder: Reuse GString for shader code 2018-03-30 23:15:04 +02:00
Benjamin Otte
4fc072925c gsk: Remove gsk_renderer_create_cairo_surface()
It's not used anymore.
2018-03-29 05:02:15 +02:00
Benjamin Otte
69101a11b5 renderer: Get rid of unused member variable 2018-03-29 05:02:15 +02:00
Chun-wei Fan
dfb06e1c7a gsk/gl: Include cairo.h consistently
Follow the other sources that include cairo.h, by just doing #include
<cairo.h>, not <cairo/cairo.h>.

https://bugzilla.gnome.org/show_bug.cgi?id=773299
2018-03-28 22:05:17 +08:00
Timm Bäder
cc0a69e101 gl renderer: Fix some crashes
When the first op is a modelview or projection change.
2018-03-27 18:20:52 +02:00
Timm Bäder
b26e584e29 gl renderer: Rename everything called window to surface 2018-03-26 21:13:52 +02:00
Benjamin Otte
353ad30b12 rendernode: Fix serializing
Adding the offset node broke serialization in 2 ways:

1. We store the enum value in the node, so make sure to not change it
   for existing values
2. The offset node was missing in the deserialization lookup table
2018-03-26 19:43:06 +02:00
Benjamin Otte
ce743f28a1 rendernode: Add an offset node
This is a special case of the transform node that does a 2D translation.

The implementation in the Vulkan and GL renderers is crude and just does
the same as the transform node.

Nothing uses that node yet.
2018-03-26 18:16:36 +02:00
Timm Bäder
433517fdc9 gl renderer: Skip all 0-sized nodes
These will cause problems later on.
2018-03-25 11:47:57 +02:00
Timm Bäder
7240178988 gl renderer: Remove cairo node special case 2018-03-25 11:47:57 +02:00
Benjamin Otte
e84c6acc4f rendernode: Remove renderer argument
It's not needed to create Cairo nodes anymore.
2018-03-24 21:57:20 +01:00
Benjamin Otte
df600669a2 rendernode: Create Cairo surfaces as recording surfaces
This way, we can postpone the actual rendeing of the node until the
renderer. This allows the renderer to choose the right scale to
render at, so it can decide to use 2x scale for hidpi on its own.

Last but not least, it makes all nodes independent of the context they
are created in, because they do not need to know at snapshot time what
they will ultimately be rendered into.
2018-03-24 21:57:20 +01:00
Benjamin Otte
f680d5d130 vulkan: Remove special case for Cairo surfaces
This is in preparation for the next commits which switch Cairo nodes to
recording surfaces.
2018-03-24 21:57:20 +01:00
Alexander Larsson
39851fbdbf Continue renaming window to surface
This renames a lot of arguments, local variables and functions.
2018-03-21 11:49:14 +01:00
Alexander Larsson
695d141f32 Merge branch 'rename-window-to-surface' into 'master'
Rename window to surface

See merge request GNOME/gtk!72
2018-03-20 16:16:57 +00:00
Alexander Larsson
9a7e721181 GdkSurface: Rename various functions and variables
This is an automatic rename of various things related
to the window->surface rename.

Public symbols changed by this is:
 GDK_MODE_WINDOW
 gdk_device_get_window_at_position
 gdk_device_get_window_at_position_double
 gdk_device_get_last_event_window
 gdk_display_get_monitor_at_window
 gdk_drag_context_get_source_window
 gdk_drag_context_get_dest_window
 gdk_drag_context_get_drag_window
 gdk_draw_context_get_window
 gdk_drawing_context_get_window
 gdk_gl_context_get_window
 gdk_synthesize_window_state
 gdk_surface_get_window_type
 gdk_x11_display_set_window_scale
 gsk_renderer_new_for_window
 gsk_renderer_get_window
 gtk_text_view_buffer_to_window_coords
 gtk_tree_view_convert_widget_to_bin_window_coords
 gtk_tree_view_convert_tree_to_bin_window_coords

The commands that generated this are:

git sed -f g "GDK window" "GDK surface"
git sed -f g window_impl surface_impl
(cd gdk; git sed -f g impl_window impl_surface)
git sed -f g WINDOW_IMPL SURFACE_IMPL
git sed -f g GDK_MODE_WINDOW GDK_MODE_SURFACE
git sed -f g gdk_draw_context_get_window gdk_draw_context_get_surface
git sed -f g gdk_drawing_context_get_window gdk_drawing_context_get_surface
git sed -f g gdk_gl_context_get_window gdk_gl_context_get_surface
git sed -f g gsk_renderer_get_window gsk_renderer_get_surface
git sed -f g gsk_renderer_new_for_window gsk_renderer_new_for_surface

(cd gdk; git sed -f g window_type surface_type)
git sed -f g gdk_surface_get_window_type gdk_surface_get_surface_type

git sed -f g window_at_position surface_at_position
git sed -f g event_window event_surface
git sed -f g window_coord surface_coord
git sed -f g window_state surface_state
git sed -f g window_cursor surface_cursor
git sed -f g window_scale surface_scale
git sed -f g window_events surface_events
git sed -f g monitor_at_window monitor_at_surface
git sed -f g window_under_pointer surface_under_pointer
(cd gdk; git sed -f g for_window for_surface)
git sed -f g window_anchor surface_anchor
git sed -f g WINDOW_IS_TOPLEVEL SURFACE_IS_TOPLEVEL
git sed -f g native_window native_surface
git sed -f g source_window source_surface
git sed -f g dest_window dest_surface
git sed -f g drag_window drag_surface
git sed -f g input_window input_surface

git checkout NEWS* po-properties po docs/reference/gtk/migrating-3to4.xml
2018-03-20 12:05:26 +01:00
Alexander Larsson
391727bd0d GdkWindow -> GdkSurface initial type rename
This renames the GdkWindow class and related classes (impl, backend
subclasses) to surface. Additionally it renames related types:
GdkWindowAttr, GdkWindowPaint, GdkWindowWindowClass, GdkWindowType,
GdkWindowTypeHint, GdkWindowHints, GdkWindowState, GdkWindowEdge

This is an automatic conversion using the below commands:

git sed -f g GdkWindowWindowClass GdkSurfaceSurfaceClass

git sed -f g GdkWindow GdkSurface
git sed -f g "gdk_window\([ _\(\),;]\|$\)" "gdk_surface\1" # Avoid hitting gdk_windowing
git sed -f g "GDK_WINDOW\([ _\(]\|$\)" "GDK_SURFACE\1" # Avoid hitting GDK_WINDOWING
git sed "GDK_\([A-Z]*\)IS_WINDOW\([_ (]\|$\)" "GDK_\1IS_SURFACE\2"
git sed GDK_TYPE_WINDOW GDK_TYPE_SURFACE
git sed -f g GdkPointerWindowInfo GdkPointerSurfaceInfo

git sed -f g "BROADWAY_WINDOW" "BROADWAY_SURFACE"
git sed -f g "broadway_window" "broadway_surface"
git sed -f g "BroadwayWindow" "BroadwaySurface"
git sed -f g "WAYLAND_WINDOW" "WAYLAND_SURFACE"
git sed -f g "wayland_window" "wayland_surface"
git sed -f g "WaylandWindow" "WaylandSurface"
git sed -f g "X11_WINDOW" "X11_SURFACE"
git sed -f g "x11_window" "x11_surface"
git sed -f g "X11Window" "X11Surface"
git sed -f g "WIN32_WINDOW" "WIN32_SURFACE"
git sed -f g "win32_window" "win32_surface"
git sed -f g "Win32Window" "Win32Surface"
git sed -f g "QUARTZ_WINDOW" "QUARTZ_SURFACE"
git sed -f g "quartz_window" "quartz_surface"
git sed -f g "QuartzWindow" "QuartzSurface"

git checkout NEWS* po-properties
2018-03-20 11:40:08 +01:00
Timm Bäder
0124740fa0 gl renderer: Support large textures
By tiling them.
2018-03-20 09:40:10 +01:00
Timm Bäder
4240119d64 gl renderer: add basic code to support texture tiling 2018-03-20 09:40:10 +01:00
Timm Bäder
a9fec38680 rendernode: Don't use gdk_texture_download_surface
It can't handle the texture sizes we'd like to support
2018-03-20 09:40:10 +01:00