Commit Graph

1560 Commits

Author SHA1 Message Date
Matthias Clasen
2d266d107b gsk: Clean up docs syntax
Replace leftover gtk-doc syntax (#Type) with backquotes.
2021-05-22 17:25:26 -04:00
Matthias Clasen
4a0d3d7acc docs: Reduce redundancy
Remove a boatload of "or %NULL" from nullable parameters
and return values. gi-docgen generates suitable text from
the annotation that we don't need to duplicate.

This adds a few missing nullable annotations too.
2021-05-20 20:45:06 -04:00
Matthias Clasen
7fe0610b68 introspection: Stop using allow-none
allow-none has been deprecated for a long time
already. Instead use optional and nullable everywhere.
2021-05-20 19:17:49 -04:00
Matthias Clasen
8ba16eb4f1 Documentation fixes
Mostly fixing up indentation of continuation lines,
and other small cleanups.
2021-05-20 19:17:49 -04:00
Matthias Clasen
66b4f0cac4 ngl: Reuse texture coordinates
When uploading glyphs, reuse the position that
we get from gsk_ngl_texture_library_pack, instead
of recomputing it.
2021-05-15 22:23:14 -04:00
Matthias Clasen
81e0206465 ngl: Be consistent about padding
Make gsk_ngl_texture_library_pack always return
the position including the padding. And compute
texture coordinates accurately in all cases (we
were fudging the padding for standalone textures.
2021-05-15 22:21:26 -04:00
Matthias Clasen
cb1babeeba ngl: Add padding between cached glyphs
Without this, adjacent items in the cache sometimes
bleed into the texture for a glyph.
2021-05-15 22:15:05 -04:00
Matthias Clasen
8e7bc8d742 Improve transformed offscreen rendering
Preserve the scale for 2D transforms to
avoid a pixellated appearance.
2021-05-13 19:37:16 -04:00
Matthias Clasen
930ff499ee Confine -mf16c to a single source file
We can't use this flag for any code that may get run
outside the __builtin_cpu_supports() check, and meson
doesn't allow per-file cflags. So we have to split this
code off into its own static library.
2021-05-05 18:58:23 -04:00
Alexander Mikhaylenko
ae7f380396 gsk: Fix shader gresource paths
They were never updated after having been moved.
2021-04-19 20:01:33 +05:00
Chun-wei Fan
8df32e93be GSK: Fix builds against latest stable GLib with MSVC
GLib-2.68.x now considers warning C4098 ('void' function returning a value) as
an error, so avoid doing that.
2021-04-16 11:39:17 +08:00
Matthias Clasen
4465ee5414 Merge branch 'ngl-crash' into 'master'
ngl: Fix a rare assertion violation

Closes #3853

See merge request GNOME/gtk!3434
2021-04-13 22:02:44 +00:00
Matthias Clasen
c66b030427 ngl: Fix a rare assertion violation
When we clean up the uniform allocations after a frame,
it can happen that our space requirements actually increase,
due to padding that depends on the order of allocations.

Instead of asserting that it doesn't happen, just make
it work by growing our allocation.

Fixes: #3853
2021-04-12 22:53:48 -04:00
Emmanuele Bassi
31e08d4629 gsk/ngl: Build with G_DISABLE_ASSERT enabled 2021-04-12 21:23:18 -04:00
Matthias Clasen
9d3aa2cfce gsk: Avoid compiler warnings without assertions
Disabling assertions was provoking some unused variable
warnings from the compiler. Avoid these.
2021-04-12 21:22:46 -04:00
Chun-wei Fan
d5ced21264 gsk/ngl/fp16.c: Implement runtime F16C detection on MSVC
We need to use __cpuid() to check for the presence of F16C instructions on
Visual Studio builds, and call the half_to_float4() or float_to_half4()
implementation accordingly, as the __builtin_cpu...() functions are strictly
for GCC or CLang only.

Also, since __m128i_u is not a standard intrisics type across the board, just
use __m128i on Visual Studio as it is safe to do so there for use for
_mm_loadl_epi64().

Like running on Darwin, we cannot use the alias __attribute__ as __attribute__
is also for GCC and CLang only.
2021-04-12 18:13:42 +08:00
Matthias Clasen
46ed7540b2 Merge branch 'ngl-shadow-fixes' into 'master'
ngl: Fix outset blurred shadows

See merge request GNOME/gtk!3427
2021-04-12 05:07:29 +00:00
Matthias Clasen
21a1a40555 Merge branch 'shadow-reduction' into 'master'
gsk: Don't overshadow

See merge request GNOME/gtk!3419
2021-04-12 02:39:55 +00:00
Matthias Clasen
849692b24b ngl: Fix unevenly scaled shadows
Ensure that we don't cut them off at the edges.
2021-04-11 22:35:02 -04:00
Matthias Clasen
f3bf4e4876 ngl: Don't slice unsliceable shadows
When the corners are too big to make slicing work,
don't do it, since it leads to broken results.
2021-04-11 22:10:33 -04:00
Matthias Clasen
46270d3dcd ngl: Fix a case of flipped shadow
In the non-sliced case, we were rendering the shadow
upside down.
2021-04-11 22:10:33 -04:00
Matthias Clasen
da6096faaf ngl: Add code to dump shadows
This can be helpful in understanding shadow bugs.
2021-04-11 21:13:47 -04:00
Matthias Clasen
1d9c581f10 ngl: Allow passing bounds to update_clip
update_clip only uses the bounds of the node that
we are currently passing. This opens the door to
updating the clip while handling a single node.
2021-04-11 12:54:17 -04:00
Matthias Clasen
6bfb57db16 ngl: Small optimization for shadows
When 9-slicing shadows, omit the center tile when it is
entirely contained in the outline (that is not always
the case, depending on corners and offsets).
2021-04-11 12:54:07 -04:00
Matthias Clasen
f8f2f2944f roundedrect: Speed up contains_rect and friends
gsk_rounded_rect_contains_rect was calling
gsk_rounded_rect_contains_point, which potentially
checks all four corners, for a total of up to 16
corner/point checks. But there is no need to do
more than 4 such checks to answer the question.
2021-04-11 12:52:30 -04:00
Matthias Clasen
aaf17fd3d0 ngl: Small optimization
We really want equality here.
2021-04-11 12:50:50 -04:00
Matthias Clasen
e6599c6c4f gsk: Don't overshadow
Reduce the cairo shadows to the same size as their GL brethren.
2021-04-09 21:47:55 -04:00
Matthias Clasen
bfe4aea981 ngl: Add a program change counter
Count how often we change programs during a frame.
2021-04-09 00:52:18 -04:00
Matthias Clasen
0caa28c1de ngl: Optimize underlines in text
Opportunistically use the coloring program for
drawing underlines instead of the color program.
This avoids program changes in the middle of
text.

For the Emoji text scrolling benchmark, this reduces
the program changes per frame from > 1000 to around 100.
2021-04-08 23:37:51 -04:00
Matthias Clasen
d8ba4b4114 ngl: Reserve a pixel in texture atlases
This will be used for coloring from the texture.
2021-04-08 23:34:37 -04:00
Matthias Clasen
e7963945bb ngl: Fix an oversight
All the rest of debug spew goes to stderr here.
2021-04-08 23:34:37 -04:00
Matthias Clasen
2d7169fd5f Work around compiler shortcomings on macOS
alias attributes don't work on Darwin, so
do without.
2021-04-07 22:38:47 -04:00
Matthias Clasen
885a6b8ebc gsk: Add runtime checks for F16C
Use an IFUNC resolver to determine whether we can use
intrinsics for FP16 conversion. This requires the functions
to be no longer inline.

Sadly, it turns out that __builtin_cpu_supports ("f16c")
doesn't compile on the systems where we want it to prevent
us from getting a SIGILL at runtime.
2021-04-07 22:21:23 -04:00
Matthias Clasen
9d81c129fc Add an option to disable F16C
And add a compile time check for the presence of this
CPU feature.
2021-04-07 22:21:23 -04:00
Matthias Clasen
38c6fe2ce4 Move color conversion up
Doing the color conversion early lets us reuse
the results whenever we do more than one draw
per node.
2021-04-07 21:30:43 -04:00
Matthias Clasen
7fe7b7ac7d ngl: Use a constant for (fp16)-1
No need to convert that again for every glyph.
2021-04-07 21:30:43 -04:00
Matthias Clasen
ae7f52d301 ngl: Reduce vertex storage
We only have one shader that uses the color2 attribute,
and it doesn't use the uv attribute, so save vertex
memory by putting those in the same space.

This reduce the per vertex space from 32 to 24 bytes.
2021-04-07 21:30:43 -04:00
Matthias Clasen
8b1fcb58e8 ngl: Use fp16 for colors
This reduces the size of our Vertex struct from
48 to 32 bytes. It would be nicer if we could store
the colors in fp16 format in the rendernodes, and
avoid conversion here. But this is still good.
2021-04-07 21:30:43 -04:00
Matthias Clasen
a1ece16143 ngl: Fix an oversight
We were special-casing 2D affine transforms,
but overlooked even simpler transforms.
2021-04-05 08:47:53 -04:00
Matthias Clasen
900a4e4d31 gsk: Move shader resources
Move the resources of each renderer to its subdirectory.
We've previously done that for the ngl renderer, but it
is better to be consistent and do it for all the renderers.
2021-04-03 08:24:58 -04:00
Matthias Clasen
ee63b84b6a gsk: Rename resource paths
Make the shaders of the gl renderer live under
/org/gtk/libgsk/gl. This is purely cosmetic.
2021-04-03 08:10:58 -04:00
Matthias Clasen
efb5e793a4 nodeparser: Change the serialization
Arrange things so that non-child parameters
are always printed before the children. This
greatly helps with readability, which really
suffers when there's hundreds of lines of indented
children between the node start and its parameters.

Update all affected tests.
2021-04-02 20:38:32 -04:00
Matthias Clasen
8d603dfe99 ngl: Avoid huge intermediate textures
Instead of rendering the unclipped child to a texture
(and risking blowing the texture size limit, and bad
downscaling), just render the clipped region, and live
with the fact that we can't cache the rendered texture.

This avoid bad artifacts when scrolling long textviews
in rounded clips.
2021-04-02 19:33:44 -04:00
Matthias Clasen
3ff04976e3 ngl: Plug a memory leak
This was introduced in f9457af128.
2021-04-02 18:41:53 -04:00
Matthias Clasen
54ff4fd45f ngl: Fix downscaled textures
It is not pretty, but at least it works now.
2021-04-02 18:33:01 -04:00
Matthias Clasen
f9457af128 ngl: Fix offscreen rendering with transforms
There was confusion here about the handling of the
modelview transform. The modelview transform we are
getting is already set up for rendering the node
we are given, so keep it - except for possible adding
an extra scale on top when the texture would otherwise
be too big.
2021-03-31 14:36:24 -04:00
Matthias Clasen
94f0a4ef2c ngl: Be explicit about offscreen clipping
Explicitly set all the input arguments.
This makes it clearer what is going on.
2021-03-31 14:34:16 -04:00
Matthias Clasen
53e75936cb ngl: Add sonme comments
The GskNglRenderOffscreen struct is a mix of in and
out arguments. Better annotate that a little bit.
2021-03-31 14:32:47 -04:00
Matthias Clasen
ba4e66d189 ngl: Avoid a goto
Reshuffle the code slightly, so we can use a continue
instead.
2021-03-30 00:34:52 -04:00
Matthias Clasen
2c33550048 gsk: Avoid empty glyphs early
Strip out PANGO_GLYPH_EMPTY when text nodes are
constructed. Then we don't have to check this special
case in the inner loop in visit_text_node.
2021-03-30 00:34:52 -04:00