Commit Graph

822 Commits

Author SHA1 Message Date
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