Commit Graph

1185 Commits

Author SHA1 Message Date
Matthias Clasen
222b6c2b58 glyph cache: Go back to memcmp
Be careful to avoid padding data, and only
compare the relevant parts, leaving out the
hash key.
2019-10-17 07:59:34 -05:00
Matthias Clasen
5ab5ff7677 Cosmetics 2019-10-17 07:59:34 -05:00
Matthias Clasen
6c92b824f3 Merge branch 'wip/chergert/opbuffer' into 'master'
Add OpBuffer helper for building op buffer

See merge request GNOME/gtk!1131
2019-10-17 11:37:07 +00:00
Matthias Clasen
d777300d4e Fix a crash with glyph caching
We need to treat atlas-less cached glyphs like
atlases, when it comes to invalidating text node
render data.
2019-10-15 22:52:28 -04:00
Matthias Clasen
173bb2e1e8 gsk: Fix uninitialized memory
This was causing crashes in some circumstances.
2019-10-15 20:54:24 -04:00
Matthias Clasen
dd5ee87b5b gl: Speed up icon cache lookups
Use gdk_texture_set_render_data to avoid
hash table lookups when we can.
2019-10-15 19:44:26 -04:00
Matthias Clasen
e34d1b8a26 gl: Slightly rework the icon cache api
Return a pointer to the IconData struct. This is
closer to the glyph cache api, and will allow us
to add similar shortcuts. For now, just store
texture coords in the form we need, avoiding
converting them over and over.
2019-10-15 19:44:26 -04:00
Matthias Clasen
c5af463843 Cache glyph textures in render nodes
This is a quick implementation that avoids many
glyph cache lookups. We keep an array of direct
pointers in the text render node, and throw those
cached pointers away whenever any atlases have
been dropped (since that may invalidate the cached
glyphs).
2019-10-15 19:44:26 -04:00
Matthias Clasen
49748c9c23 Some more vertex data reshuffling
In some cases, the vertex data is just a trivial
modification of the default data, so do that instead
of recalculating it.
2019-10-15 19:44:26 -04:00
Matthias Clasen
b53fa48794 Fix load_vertex_data
There was a copy-paste error that set all
uv coordinates to 0,0.
2019-10-15 19:44:26 -04:00
Christian Hergert
97f3371709 gl: avoid calculating vertex_data until necessary
In many cases of the switch, we do not need the vertex data. This moves
the creation of the vertex_data array into a secondary function and only
calculates it the cases for which it is required.
2019-10-15 19:44:26 -04:00
Matthias Clasen
58d57e1087 gl: Drop buffer_size
No need to maintain buffer_size separately.
It is always vertices->len * sizeof (GskQuadVertex).
2019-10-15 19:44:26 -04:00
Matthias Clasen
571068af12 Drop OP_CHANGE_VAO
Instead, we accumulate vertices in a separate
array, which simplifies various things and lets
us avoid the extra copying step for the vao.
2019-10-15 19:44:26 -04:00
Christian Hergert
a00d12c62a prototype OpBuffer helper for building op buffer 2019-10-15 19:44:26 -04:00
Timm Bäder
5ea21f7910 gl renderer: Fix an out of bounds read
Fixes #2200
2019-10-15 07:13:14 +02:00
Matthias Clasen
7bff3abe8e glyph cache: Fix handling of big glyphs
We were putting big glyphs in the cache, in their
own texture, but forgetting to mark the texture
as permanent, so it could be reused, leading to
occasional misrendering. Fix this by marking these
textures as permanent, and explicitly freeing them
when the cache entry gets old.
2019-10-12 18:53:22 -04:00
Matthias Clasen
e46a7ca706 shadow cache: Remove outdated comments
No comments are better than outdated comments.
2019-10-12 17:06:39 -04:00
Matthias Clasen
e9ba7eda47 gl: Increate the cache check frequency
Otherwise, we spread the cache over more atlases
than necessary, increasing the amount of texture
changes in each frame.
2019-10-12 12:37:11 -04:00
Matthias Clasen
88649b6aae gl: Interleave cache aging
Every few frames, we do extra work for the
cache aging. Arrange for the glyph and icon
caches to not cause extra work on the same
frame, to smooth things out.
2019-10-12 12:37:11 -04:00
Matthias Clasen
60d63bbada gl: Improve debug spew for caches
Dump similar information for both caches,
and correct the unused percentage for
the atlases.
2019-10-12 12:37:11 -04:00
Matthias Clasen
123cbd42bb gl: Make icon cache work like glyph cache
Replace timestamp tracking with an accessed bit
here too, to keep the glyph and icon cache code
similar.
2019-10-12 11:46:10 -04:00
Matthias Clasen
977ac2b31f gl: Do less work on glyph caching
There is no need for us to be very precise about
aging the glyph entries. It is enough to check
occasionally and mark old entries. This reduces
the overhead of work we do every frame on the
caches, at the cost of letting glyphs linger
a bit longer in the cache.
2019-10-12 11:35:46 -04:00
Timm Bäder
bcdc3b706c iconcache: Fix icon padding 2019-10-12 09:17:24 +02:00
Matthias Clasen
61db797f29 gl: Simplify glyph cache lookup
Make this function more similar to the icon
cache equivalent, and simplify it a bit. We
don't use the boolean return, and we don't need
to look at the age of entry when marking it
used.
2019-10-12 01:35:13 -04:00
Matthias Clasen
0a876f11a0 gl: Don't use memcmp for comparing cache keys
Some innocent change made us use a stack-allocated
key, and things broke. Lets go back to comparing
cache keys field by field.
2019-10-12 01:00:08 -04:00
Matthias Clasen
1c17316f9c gl: Handle row stride for icon cache upload
Same as the previous commit: Downloading a texture
may in theory give us data with a stride, so handle
that.
2019-10-11 21:17:30 -04:00
Matthias Clasen
646c5f369f gl: Handle row stride for glyph cache upload
In theory, we can have data with a stride here,
so set the necessary parameters to tell GL about
it.
2019-10-11 21:16:40 -04:00
Matthias Clasen
8839e10d44 gl: Do less work to maintain caches
Remember which atlases were removed, and only
check those when looking for icons or glyphs
to remove. For most frames, we don't have to
check at all since no atlases were removed.
2019-10-11 20:42:24 -04:00
Matthias Clasen
9b61bfb3c8 gl: Speed up icon caching
Avoid expensive padding, and just upload the
image in several slices.
2019-10-11 19:36:26 -04:00
Timm Bäder
4f5a9be465 gl renderer: Get blur node child only once 2019-10-11 22:31:33 +02:00
Timm Bäder
6a4c778791 gl renderer: Shorten function 2019-10-11 22:31:33 +02:00
Timm Bäder
1caa95b814 gl renderer: Avoid copying a rect 2019-10-11 22:31:33 +02:00
Matthias Clasen
cf44ba7847 gl: Avoid stray use of doubles
Everything else in this code is floats,
so stick to that and avoid unnecessary
precision.
2019-10-11 16:16:09 -04:00
Matthias Clasen
30433d7659 Cosmetics 2019-10-11 16:16:09 -04:00
Matthias Clasen
849b950763 gl: glyph cache tweaks
Reduce the cost of lookups by storing
the hash value directly.
2019-10-11 16:15:15 -04:00
Matthias Clasen
8937cd992d gl: Shrink CachedGlyph structs slightly
Plug a hole in this struct.
2019-10-11 16:15:14 -04:00
Matthias Clasen
e296c6a356 gsk: Store color bit info in text nodes
Keep the 'has color glyphs' info in text nodes,
instead of determining it over and over in both
the vulkan and gl backends.
2019-10-11 16:15:14 -04:00
Timm Bäder
136400e8a2 gl renderer: Remove unused modelview matrix 2019-10-11 16:56:24 +02:00
Timm Bäder
90199534e0 gl renderer: Don't copy outset shadow node outline 2019-10-11 16:38:58 +02:00
Timm Bäder
f7c64b4ebb gl renderer: Don't copy colors into render ops 2019-10-11 15:06:51 +02:00
Timm Bäder
2977e91aed gl renderer: Grow unblurred outset shadow outline on the gpu 2019-10-11 10:16:39 +02:00
Timm Bäder
0b999c73d1 gl renderer: Fix glsl rounded rect shrinking
Previous code would add rounded corners to a rect with all 0 corners
when growing.
2019-10-11 10:15:58 +02:00
Timm Bäder
9b1e0dd4a3 gl renderer: Cosmetics 2019-10-11 09:32:24 +02:00
Timm Bäder
a29826bb71 gl renderer: Only add outset shadow center piece if dx/dy != 0 2019-10-11 08:46:33 +02:00
Christian Hergert
528297f5e5 gl: avoid copying RenderOp to GArray
Instead of copying the (rather large) RenderOp to the GArray, we can
simply set the fields directly in the allocated space for the struct.
In most cases, there wont be any allocations to make as the array size
is kept in tact across frame renderings.
2019-10-09 15:41:53 -07:00
Christian Hergert
b29feb193e gl: use memcmp to compare glyph cache keys
We can just use memcmp here because even in the use of lookup keys with
C99 initializers, we can rely on any space between fields added by the
compiler to be zeroed. So we might as well use wider memory cmopares.
2019-10-09 14:47:23 -07:00
Christian Hergert
e32c992886 gl: avoid copying GskGLCachedGlyph in lookup
This saves a minor amount of CPU time by avoiding the copy of structure
on each lookup (which is short-lived).
2019-10-09 14:37:08 -07:00
Christian Hergert
c9ca60c201 gl: short-circuit on NULL program
The NULL check is a more inclusive check than each of the individual
op->op checks.
2019-10-09 11:51:32 -07:00
Timm Bäder
329f7c1c40 gl renderer: Remove rounded rect intersection code
Caused correctness issues.

Fixes #1917
2019-10-09 16:57:22 +02:00
Timm Bäder
e838ea3bc8 gl renderer: Fix scaled fallback node drawing 2019-10-09 16:57:22 +02:00
Christian Hergert
47ef5af778 gl: remove stray + 2019-10-08 10:58:29 -07:00
Christian Hergert
76ea157f17 rendernode: remove unused macros 2019-10-08 10:57:45 -07:00
Georges Basile Stavracas Neto
a2b49322fb vulkan/renderpass: Use GENERAL for initial layout
UNDEFINED initial layouts may not preserve the contents
of the attachment after transitioning the layout. We want
them to be preserved because we do partial rendering.

Use GENERAL as the initial layout for render passes.
2019-10-05 12:13:22 -03:00
Georges Basile Stavracas Neto
0b2006b74f vulkan/image: Set HOST and TRANSFER bits for before barriers
Multiple images in the before barrier array are defined with
VK_ACCESS_TRANSFER_WRITE_BIT and VK_ACCESS_TRANSFER_READ_BIT,
which requires passing VK_PIPELINE_STAGE_TRANSFER_BIT and
VK_PIPELINE_STAGE_HOST_BIT to vkCmdPipelineBarrier().

Pass these flags correctly.
2019-10-05 12:13:22 -03:00
Timm Bäder
e05b87c8d0 gl renderer: Fix rounded rect intersection 2019-09-25 17:51:52 +02:00
Timm Bäder
c9241e83dd gl renderer: Remove unused matrix 2019-09-09 17:36:25 +02:00
Timm Bäder
6c90d3a1b6 gsktransform: Fix documentation comment
There is no @m.
2019-09-09 17:36:23 +02:00
Rico Tzschichholz
5504c62af9 gsk: Add missing 'transfer full' annotations of instance parameters
Fixes https://gitlab.gnome.org/GNOME/gtk/issues/2107
2019-08-26 18:05:17 +02:00
Дилян Палаузов
6ded38de2b Minor typos in the Documentation (a/an) 2019-08-25 12:52:46 +00:00
Timm Bäder
251bf45cf2 iconcache: ref textures
We can't just assume that the pointer we'se using as a cache key will
stay unique forever. The texture might be freed, and a later allocated
texture might have the same addres now, causing the cache to return
incorrect results.
2019-08-11 09:05:31 +02:00
Timm Bäder
13c0a9e27b iconcache: Replace broken debugging code 2019-08-11 09:05:31 +02:00
Timm Bäder
2914c360a9 gl renderer: Implement a subset of repeat nodes 2019-08-11 09:05:31 +02:00
Matthias Clasen
660f46fcb1 Merge branch 'glsl-switch' into 'master'
glsl: don't use switch statements

See merge request GNOME/gtk!1036
2019-08-02 16:59:27 +00:00
Matthias Clasen
b576aef2b1 Revert "gl: Simplify glyph cache rendering"
This reverts commit 7a3eaad193.

The reason we want to keep using pango here
is that we get hex boxes and similar drawing
features that way.
2019-08-01 00:18:19 -04:00
Elias Aebi
a357995484 glsl: don't use switch statements 2019-07-31 18:48:54 +02:00
Matthias Clasen
d276d2629a gl: Glyph cache fixes
Pass the full location to the glyph cache lookup,
and use the same rounding as cairo does. This makes
the output much closer to the cairo renderer.
2019-07-31 00:03:13 -04:00
Matthias Clasen
5dd8801ee5 gl: implement subpixel positioning
Pass the glyph position into the glyph caching functions,
not just the glyph index. This allows us to cache different
images for different subpixel positions.
2019-07-28 16:42:52 -04:00
Matthias Clasen
5c9643b6eb vulkan: implement subpixel positioning
Pass the glyph position into the glyph caching functions,
not just the glyph index. This allows us to cache different
images for different subpixel positions.
2019-07-28 16:42:52 -04:00
Matthias Clasen
7a3eaad193 gl: Simplify glyph cache rendering
We are currently using a weird mix of pango and cairo,
but there is no need for us to go through a pango
renderer here; we can just use cairo directly.
2019-07-28 09:54:17 -04:00
Timm Bäder
2c38b71ca5 glyph cache: Upload large glyphs in lookup () directly
Instead of relying on a texture id of 0, which can happen for other
reasons, e.g. when the glyph is being scaled too small.

Fixes part of #2046
2019-07-28 12:00:15 +02:00
Timm Bäder
1c93bef0d5 glyph cache: check glyphs for scaled size
We can't rely on just the ink_rect, since that might be without the
scaled applied, which is what ends up on the texture.

Fixes #2046
2019-07-28 10:58:10 +02:00
Timm Bäder
58e8dd1c0d gl renderer: Fix dx/dy handling on hidpi
Fixes misplaced error squiggles in the node editor.
2019-07-26 16:27:39 +02:00
Timm Bäder
b8bbf7b63b gl renderer: Rework transform handling
Fix all the ref counting mishaps. Makes hidpi work again and without
memory leaks.
2019-07-26 15:35:06 +02:00
Matthias Clasen
2803bd93ce gsk: Fix a crash in gsk_render_node_diff
The only thing worse than freeing the same
cairo region twice is freeing it three times.
2019-07-21 13:18:58 -07:00
Timm Bäder
731613d70b gl renderer: Remove leftover modelview matrix
We use a GskTransform there nowadays.
2019-07-21 12:45:10 +02:00
Timm Bäder
5f21c45f75 Revert "gl renderer: ops_set_modelview is (transfer full)"
This reverts commit e904c49e8a.

This breaks HiDPI setups, i.e. setups where the call to
ops_set_modelview does not end up with a NULL transform.
2019-07-21 12:45:10 +02:00
Timm Bäder
6e47ebe030 rendernodeparser: Fix a memory leak when parsing glyphs 2019-07-21 09:06:50 +02:00
Timm Bäder
9728dabf12 rendernodeparser: Fix a memory leak when parsing textures 2019-07-21 09:06:29 +02:00
Timm Bäder
e904c49e8a gl renderer: ops_set_modelview is (transfer full)
regarding the passed modelview matrix
2019-07-21 09:06:10 +02:00
Timm Bäder
27ddd39d69 gl renderer: Pull out code from a loop
Does not not actually depend on anything done inside the loop.
2019-07-21 08:39:25 +02:00
Timm Bäder
5910a28aa5 gl renderer: Replace a redundant function call
We're already getting the radius from the node above.
2019-07-19 18:14:50 +02:00
Timm Bäder
b9b5072668 gl renderer: Fix opacity nodes with overlapping child nodes 2019-07-14 10:08:04 +02:00
Timm Bäder
984dff54ab rendernodeparser: fix typo 2019-07-13 11:12:47 +02:00
Matthias Clasen
bda3c6c084 Merge branch 'wip/baedert/for-master' into 'master'
Improve the valgrind experience

See merge request GNOME/gtk!984
2019-07-09 19:39:13 +00:00
Timm Bäder
f286c99338 Merge branch 'gltexsubimage2d' into 'master'
use glTexSubImage2D instead of glTextureSubImage2D

Closes #2005

See merge request GNOME/gtk!986
2019-07-08 07:14:13 +00:00
Timm Bäder
b062594ae6 gl renderer: Properly clean up program state transforms 2019-07-07 07:24:00 +02:00
Timm Bäder
dbc49e7742 transform: Fix identity transform fast paths
Returning an extra ref will cause leaks later.
2019-07-07 07:24:00 +02:00
Elias Aebi
ea6d3f589f use glTexSubImage2D instead of glTextureSubImage2D 2019-07-06 16:23:21 +02:00
Elias Aebi
1e6120e776 glsl: use float literals 2019-07-06 14:42:08 +02:00
Timm Bäder
3bc3e140dd transform: Add transform_bounds fast path for 2D_AFFINE transforms
E.g. anything involving a scale. This is important when e.g. scrolling
in the node list in the recorder, which scales every recorded node down
to fit in the list.
2019-06-29 09:49:38 +02:00
Timm Bäder
6b42e5b433 gl renderer: Fix push/pop modelview behavior 2019-06-29 08:57:27 +02:00
Timm Bäder
99c01607f1 gl renderer: Remove some dead code 2019-06-29 08:53:36 +02:00
Timm Bäder
071748592d gl renderer: Don't upload GL textures into the icon cache 2019-06-29 07:15:43 +02:00
Timm Bäder
8dd74eac2e transform: Add skew parsing 2019-06-29 07:15:43 +02:00
Benjamin Otte
4a19bab5b3 gsk: Fix annotations for ref()/unref() 2019-06-18 15:58:49 -04:00
Matthias Clasen
c168116e64 Merge branch 'wip/matthiasc/shared-glyph-cache' into 'master'
Share the glyph cache

See merge request GNOME/gtk!912
2019-06-05 12:10:24 +00:00
Matthias Clasen
0dcb71722a Cosmetics
Rename some arguments, since atlases->atlases is awful.
2019-06-05 12:03:39 +00:00
Matthias Clasen
d90143d09c texture atlas: Add a missing initialization
Pointed out by Timm.
2019-06-05 12:00:53 +00:00
Matthias Clasen
69016825aa render node: Optimize type checks
The GSK_IS_RENDER_NODE macro is a bit silly,
and not worth having in g_return_if_fail checks
in trivial getters.
2019-06-05 04:25:43 +00:00
Matthias Clasen
e961943508 Fix a refcounting mishap
We were missing a ref, causing caches to go missing
when a window is opened twice.
2019-06-05 02:49:07 +00:00
Matthias Clasen
054b5216a1 Remove debug spew 2019-06-04 23:11:18 +00:00
Timm Bäder
ecb353f4af Consider all offscreen drawings for the icon cache 2019-06-04 23:00:02 +00:00
Matthias Clasen
259bbdcb09 Share glyph and icon caches
Use the same texture atlases to back both
the glyph and icon caches, and unify their
sizes and management. Store big glyphs
in separate textures, so all atlases have
the same size. Tweak some of the eviction
parameters.

We share the caches across all GL contexts
on a display, unless the GSK_NO_SHARED_CACHES
env var is set.
2019-06-04 23:00:02 +00:00
Matthias Clasen
7293fd517e glyph cache: Stop storing driver and render
This is the first step towards sharing glyph
caches across renderers.
2019-06-04 23:00:02 +00:00
Matthias Clasen
c9cea36b37 gl: Use pad-extend for icon cache
Repeat the border pixels to avoid artifacts from
linear scaling.
2019-06-04 23:00:02 +00:00
Matthias Clasen
4020399439 gl: Use linear scaling for atlases 2019-06-04 23:00:01 +00:00
Matthias Clasen
efc31161f0 gl: Allow setting min/mag filter on textures
This will be used in the future.
Adapt all callers to pass GL_NEAREST for now.
2019-06-04 23:00:01 +00:00
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