Commit Graph

1715 Commits

Author SHA1 Message Date
Matthias Clasen
060f2d5f65 Annotate pango_glyph_string_num_glyphs as pure 2021-09-14 16:38:08 -04:00
Benjamin Otte
193b383739 ngl: Simplify and unbug texture download
If we can't handle the texture, always just download_texture() it,
that way we are sure it's a memory texture.
2021-09-13 01:56:47 +02:00
Benjamin Otte
9c8e464b04 texture: Add GdkMemoryConversion private enum
Now gdk_memory_convert() converts to one of these conversions instead of
re(ab)using parts of the GdkMemoryFormat enum.
2021-09-12 05:22:21 +02:00
Benjamin Otte
140976a670 Merge branch 'wip/otte/for-master' into 'master'
rendernode: Write the whole node

See merge request GNOME/gtk!3938
2021-09-11 20:56:39 +00:00
Benjamin Otte
9f2b847835 rendernode: Write the whole node
It turns out g_output_stream_write_bytes() does not write the bytes.
It should be renamed to g_output_stream_write_some_of_the_bytes() maybe.
2021-09-11 22:28:40 +02:00
Matthias Clasen
155a4fac5c Add vectorized half-float conversion
We can't make the -4 versions inline, since
we use ifuncs for them, so make vectorized
versions.

Test included.
2021-09-10 22:17:31 -04:00
Matthias Clasen
65ce3eb207 Avoid hand-rolled color glyph information
Followup to b244f31337. Pango provides color glyph
information for us now, so we don't need to steal a
bit anymore.
2021-09-05 10:58:50 -04:00
Matthias Clasen
ce2b2128bb Revert "gsk: Add font options to text nodes"
This reverts commit f1347f5841.
2021-09-04 15:42:05 -04:00
Matthias Clasen
41c25b8809 Revert "gsk: Add font options to the glyph cache"
This reverts commit 6599cb001f.
2021-09-04 15:42:05 -04:00
Matthias Clasen
b5ff35ff3e Revert "gsk: Pass font options along"
This reverts commit 299c7c3514.
2021-09-04 15:42:05 -04:00
Matthias Clasen
299c7c3514 gsk: Pass font options along
Use the font options from the text node when
looking up glyphs.
2021-09-03 12:52:05 -04:00
Matthias Clasen
6599cb001f gsk: Add font options to the glyph cache
The cairo_t that we create to render glyphs for
the glyph cache needs to match the font options
that are supposedly governing how glyphs are
drawn.

Since we allow font options to be different per
widget in gtk, we need to have them at least at
the level of individual render nodes. Adding them
to the lookup key for the glyph cache has the
side effect of solving another problem: We are
not flushing the cache when font options change.
2021-09-03 12:52:05 -04:00
Matthias Clasen
f1347f5841 gsk: Add font options to text nodes
Since font options affect how the glyphs get rendered,
we need to pass the font options down from the gtk level
to where the glyph cache is populated.

Add a new gsk_text_node_new_full api that takes a
cairo_font_options_t in addition to the other parameters.
2021-09-03 12:43:35 -04:00
Matthias Clasen
b244f31337 Use color glyph information from Pango
Pango now sets a bit in PangoGlyphVisAttr for
color glyphs, so we don't need to do that
ourselves anymore.
2021-09-01 01:47:06 -04:00
Benjamin Otte
0b7a36ce33 rendernode: Add (de)serialization support for render nodes
This includes our own new mime type for render nodes, too.
2021-08-30 06:02:15 +02:00
Benjamin Otte
1957915940 rendernode: Add GValue functions for render nodes
This is needed as GskRenderNode is its own fundamental type and has its
own GValue infrastructure. And I want to put render nodes into the
clipboard which uses GValues.
2021-08-30 06:02:15 +02:00
Matthias Clasen
1cfd340cae ngl: Avoid a coordinate overflow
This was showing up as big text selections going
missing sporadically.

Fixes: #4214
2021-08-28 15:42:30 -04:00
Matthias Clasen
e9e373913e gsk: Drop the gl renderer
ngl supports all the same platforms as gl
now, and has seen more improvements in the
last cycle.
2021-08-20 22:58:30 -04:00
Benjamin Otte
ea07bf7536 Merge branch 'wip/otte/for-master' into 'master'
ngl: Make current when unrealizing

See merge request GNOME/gtk!3835
2021-08-08 01:09:31 +00:00
Benjamin Otte
80e6f1ca8c ngl: Make current when unrealizing
The profiler (at least) discards GL objects and we want to discard them
on the right context.
2021-08-08 02:17:08 +02:00
Matthias Clasen
916886312a Merge branch 'wip/exalm/shadow-extents' into 'master'
Shrink shadow extents

See merge request GNOME/gtk!3825
2021-08-05 16:39:52 +00:00
Alexander Mikhaylenko
46a9538b6a Shrink shadow extents
Long time ago, Cairo shadows in both GTK3 and 4 were drawn at a size about
twice their radius. Eventually this was fixed but the shadow extents are
still calculated for the previous size and appear unreasonably large: for
example, 141px for a 50px radius shadow. This can get very noticeable in
places such as invisible window frame which gets included into screenshots.

https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/3419 just divides the
radius by 2 when drawing a shadow with Cairo, do the same when calculating
extents.

See https://gitlab.gnome.org/GNOME/gtk/-/issues/3841
2021-08-04 14:47:17 +05:00
Matthias Clasen
e1606ce8eb Merge branch 'color-glyph-fixes' into 'master'
gsk: Make color glyphs

Closes #4141

See merge request GNOME/gtk!3812
2021-07-31 20:54:39 +00:00
Matthias Clasen
915c229396 gsk: Use harfbuzz for color fonts
harfbuzz has all the information we need, so we
can avoid poking directly at freetype apis. Also
drop the caching of color glyph information until
it turns out to be a problem.
2021-07-31 16:34:38 -04:00
Matthias Clasen
a7a2dbc3ea gsk: Cache per-glyph color information
We don't really want to load the bitmaps every time
we create a render node, so do it once and cache the
information on the PangoFont.
2021-07-31 16:34:38 -04:00
Matthias Clasen
7e8f586859 ngl: Use per-glyph color information
Decide per-glyph whether we need color nor not.

Fixes: #4141
2021-07-31 16:34:24 -04:00
Matthias Clasen
bb9dccd773 gsk: Mark color glyphs
Steal a bit from PangoGlyphVisAttr to mark glyphs
that have color.
2021-07-31 16:34:24 -04:00
Matthias Clasen
ed41c46926 ngl: Bypass pango for glyph cache rendering
We can just use cairo directly here,
and cut out some layers of pango in the middle.
2021-07-30 19:46:07 -04:00
Matthias Clasen
09deb1d757 ngl: Cosmetics
Use the macro we already have to check that colors
are fully transparent.
2021-07-26 13:42:10 -04:00
Matthias Clasen
0ef12193f9 gsk: Optimize gsk_transform_to...
Optimize these functions for the common cases.
2021-07-24 18:48:10 -04:00
Matthias Clasen
b695ef9168 gsk: Add a shortcut for a common transform case
Add a private getter for the translation part of a
transform node, to avoid pulling it out of the transform
over and over.
2021-07-24 18:48:09 -04:00
Matthias Clasen
7fb1389648 gsk: Add a private getter for container children
No need to get them one-by-one, in our inner loop.
2021-07-24 18:48:09 -04:00
Matthias Clasen
f88efb811b ngl: Reduce type checking overhead
No need to be very careful here, these are entirely
internal types.
2021-07-24 18:48:09 -04:00
Matthias Clasen
466d33ca69 ngl: Speed up clipping calculations a bit
Exit as early as possible from intersect_rounded_rectilinear.
2021-07-24 18:48:09 -04:00
Matthias Clasen
7bdda15b86 Cosmetics
Fix a comment typo.
2021-07-22 17:03:08 -04:00
Matthias Clasen
a10b1b7341 Add more sysprof marks
Add a few more marks during gtk_init to figure out where
our startup time goes, and avoid the sysprof initialization
from distorting the first mark.
2021-07-22 12:51:32 -04:00
Benjamin Otte
c7320df0c9 gdk: Add gdk_gl_context_is_shared()
... and use it in the GL renderers.
2021-07-22 16:27:31 +02:00
Benjamin Otte
dd666e4fe4 ngl: Store the shared driver in the display
... instead of some random GL context.
2021-07-22 16:23:56 +02:00
Benjamin Otte
430b6f8fb1 gdk: Add GdkDisplay::init_gl vfunc
The vfunc is called to initialize GL and it returns a "base" context
that GDK then uses as the context all others are shared with. So the GL
context share tree now looks like:

+ context from init_gl
  - context1
  - context2
  ...

So this is a flat tree now, the complexity is gone.

The only caveat is that backends now need to create a GL context when
initializing GL so some refactoring was needed.

Two new functions have been added:

* gdk_display_prepare_gl()
  This is public API and can be used to ensure that GL has been
  initialized or if not, retrieve an error to display (or debug-print).
* gdk_display_get_gl_context()
  This is a private function to retrieve the base context from
  init_gl(). It replaces gdk_surface_get_shared_data_context().
2021-07-22 16:23:56 +02:00
Matthias Clasen
1c90bb522e ngl: Handle negative scales
Scale factors can be negative, but we were not
looking out for that, triggering an assertion when
trying to create a render target with negative
width of height. Avoid that.

Fixes: #4096
2021-07-15 16:40:13 -04:00
Matthias Clasen
c799452973 ngl: Do nothing for transparent text nodes
Like the previous commit - a transparent text node
will not produce any visible pixels, so bail out early.
2021-07-15 13:18:23 -04:00
Matthias Clasen
fd48afb77d ngl: Do nothing for transparent color nodes
No need to send commands to the GPU to render transparency.
2021-07-15 13:18:23 -04:00
Benjamin Otte
ca3d942b9b rendernodeparser: Remove leftover debug prints 2021-07-14 20:19:40 +02:00
Benjamin Otte
5470a1344d rendernodeparser: Don't use %g when writing file
%g is locale dependent and can add "," where "." should be. Use
string_append_double() instead.
2021-07-14 20:18:44 +02:00
Matthias Clasen
fc9c34897a ngl: Make the C half-float implementation accessible
Make this accessible for tests.
2021-07-13 09:03:49 -04:00
Matthias Clasen
f45c0b9609 gsk: Another vbo_size overflow fix
We can overflow vbo_size not just by batching
too much, but also by producing humongous text
nodes. Split them up.
2021-06-29 15:22:40 -04:00
Matthias Clasen
9ea162034a gsk: Use the right limit for batch size
We use 16 bits, so G_MAXINT16 is one bit short.
Just make it explicit as 0xffff.
2021-06-29 15:21:45 -04:00
Matthias Clasen
bd5e5beee0 gsk: Don't overflow vbo_count
We use 16 bits to store vbo_count, so we can't create
batches that have more than 65535 vertices. Pay attention
to that limit when merging batches.
2021-06-28 15:00:41 -04:00
Matthias Clasen
7a493f151d Revert "gsk: Respect max element vertices limitation"
This reverts commit f58fc6b22e.
2021-06-28 14:50:58 -04:00
Matthias Clasen
f58fc6b22e gsk: Respect max element vertices limitation
We are pretty good at batching commands now, and we can easily
produce batches that exceed the maximum number of elements per
draw call that the hw can handle. Query that number, and respect
it when merging batches.

This fixes the rendering of the overview map in GtkSourceView.
2021-06-18 06:50:59 -07:00
Matthias Clasen
938bfff3dd Add type annotations for filename arguments
Add missing "(type filename)" annotations for string
arguments that are filenames.

Fixes: #633
2021-06-12 11:12:06 -04:00
Matthias Clasen
e437c55142 Add a doc comment for gsk_rounded_rect_is_circular 2021-06-04 09:49:05 -04:00
Matthias Clasen
da9cd4659e Merge branch 'bilelmoussaoui/markdown-links' into 'master'
docs: use markdown syntax for hyperlinks

See merge request GNOME/gtk!3589
2021-06-04 02:45:25 +00:00
Matthias Clasen
578db92973 Cosmetics: Eradicate gint
Remove a handful of errant uses of gint.
2021-06-03 17:41:28 -04:00
Bilal Elmoussaoui
02672a521a docs: use markdown syntax for hyperlinks 2021-05-25 13:14:01 +00:00
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
Matthias Clasen
3add99a9a8 ngl: Speed up glyph loop
Move some work out of the loop in visit_text_node.
This takes advantage of the fact that the yoffset
of most glyphs is zero, so yphase generally does
not change in a line of text.
2021-03-30 00:19:28 -04:00
Matthias Clasen
d4ea2e848d ngl: We only need two bits for phases
We use 4 phases, so 2 bits are enough.
2021-03-30 00:19:28 -04:00
Matthias Clasen
5847f75c57 ngl: Cosmetics
Remove a local variable in gsk_render_job_visit_text_node.
2021-03-29 15:17:20 -04:00
Matthias Clasen
ce2c3efc91 ngl: Improve packing
Pack texture cache entries slightly better.

There was a 4 byte hole here.
2021-03-29 15:17:10 -04:00
Matthias Clasen
2599c5aed3 gsk: Typo fix 2021-03-29 15:16:44 -04:00
Matthias Clasen
bca39e2605 ngl: Typo fix 2021-03-29 15:16:25 -04:00
Matthias Clasen
2d5dd7b3d7 gsk: Make rendernode diffing smarter
Allow comparing container nodes to any other
node, by pretending the other node is a single
child container (if it isn't one already).

This fixes a glitch where we redraw the full
entry text when the blinking cursor goes to
opacity 0, since GskSnapshot then optimizes
away first the opacity node, and then the
single-child container.
2021-03-28 10:26:06 -04:00
Matthias Clasen
0904dd29c2 gsk: Use floorf for floats 2021-03-28 10:26:06 -04:00
Matthias Clasen
279b9347fd gsk: Cosmetics 2021-03-28 10:26:02 -04:00
Matthias Clasen
2a2ae16894 ngl: Cosmetics
Remove a commented out line that snuck in with
a recent commit.
2021-03-28 10:26:02 -04:00
Matthias Clasen
e7f9d56da5 ngl: Fix an uninitialized read
We were using the wrong matrix here.
valgrind pointed this point.
2021-03-27 16:23:40 -04:00
Xavier Claessens
086e1ed39f ngl: Fix crash with intel driver on Windows when compiling shaders
Fixes #3783.
2021-03-25 08:20:30 -04:00
Christian Hergert
f8a6a09896 ngl: move uniform key mapping into uniform state
Previously, we translated the uniform key (an enum) into a location within
the shader program in GskNglProgram. A number of performance improvements
were focused around having low nubers for the uniform locations. Generally
this is the case, but some drivers such as old Intel drivers on Windows
may use rather large numbers for those.

To combat this, we can push the translation of uniform keys into locations
at the GskNglUniformState level so that we work with unranslated keys
through the process until applying them.

Fixes #3780
2021-03-23 13:44:26 -07:00
Matthias Clasen
157218c507 Merge branch 'wip/baedert/for-master' into 'master'
ngl: Remove unused function

See merge request GNOME/gtk!3332
2021-03-22 11:17:58 +00:00
Matthias Clasen
7a56aa910e ngl: Fix a rounding error in subpixel positioning
1024 / 4 is 256, not 250.
2021-03-21 16:05:10 -04:00
Matthias Clasen
bd0df03248 gl: Fix a rounding error in subpixel positioning
1024 / 4 is 256, not 250.
2021-03-21 16:05:10 -04:00
Matthias Clasen
2e69273922 ngl: Remove an unused field
We are ignoring the debug nodes, so the
debug_groups string chunk is unused.
2021-03-21 16:05:10 -04:00
Matthias Clasen
1e014f4291 ngl: Always populate the glyph front cache
There is no reason not to do this also in the
case when we upload the glyph.
2021-03-21 16:05:10 -04:00
Matthias Clasen
fbe47106e7 ngl: Use floorf consistently 2021-03-21 16:05:10 -04:00
Timm Bäder
ea93c40644 ngl: Remove unused function 2021-03-21 18:00:10 +01:00
Matthias Clasen
b253aca883 ngl: Improve the glyph front cache
The effectiveness of the front cache is limited by
subpixel positioning making it very likely that we
will meet the same glyph in  different x phases inside
a single line of text.

Factoring the xphase into the front cache key makes things
better. For the string eeeeeeeeeeeeeeeeeee

before: 0% front cache hits
after: >90% front cache hits
2021-03-19 14:32:03 -04:00
Matthias Clasen
5ac7f7c2f6 ngl: Drop an unused struct member
GskNglGlyphLibrary.hash_table wasn't used.
2021-03-19 14:05:15 -04:00
Matthias Clasen
830efa6ce2 Revert "ngl: Remove duplicate check"
This reverts commit 1fd534ef1e.

This change revealed that we are not treating damage regions
correctly, and we regularly end up with
2021-03-19 13:17:02 -04:00
Matthias Clasen
8fdedbd73b Merge branch 'ngl-by-default' into 'master'
gsk: Make ngl the default OpenGL renderer

See merge request GNOME/gtk!3313
2021-03-19 02:01:34 +00:00
Christian Hergert
0f0ee97e1e ngl: clear Glyph front cache at the beginning of a frame
We don't want to be responsible for duplicating the effort of the hash
table, we just want to speed up subsequent lookups. Otherwise, we risk
not marking glyph usage when tracking usage for compaction.
2021-03-18 18:00:04 -07:00
Christian Hergert
af80f3a976 ngl: implement atlas compaction
This required finishing up the begin_frame/end_frame semantics for
GskNglTextureLibraryw which was apparently overlooked.

The driver was changed to provide more information to the library when
beginning frames. We do not need to use end_frame so that was removed.

The frame age is the same as GL (60) but I do wonder if that is based
on seconds if we should be using something longer for situations where
we have higher frame rates.

Fixes #3771
2021-03-18 17:59:56 -07:00
Matthias Clasen
19d9c78514 gsk: Make ngl the default OpenGL renderer
We will keep the original GL renderer around for
a while, to have an alternative. But we want to
get wider testing of the new renderer.
2021-03-18 15:00:39 -04:00
Christian Hergert
56daad9c35 ngl: ensure vertices buffer allocates enough vertices
It's not guaranteed that a single power of two growth will be enough.

Fixes #3770
2021-03-18 10:43:24 -07:00
Andrey Kozlovskiy
6b48fb767d Fix a typo in gsk_border_node_diff
Typo was introduced in !3278 and results in an incorrect handling of different uniformity.
2021-03-17 15:38:01 +00:00
Kjell Ahlstedt
50beae7541 meson: Find libcairo-script-interpreter when cairo is a subproject
If cairo is a subproject, it's not necessarily installed when gtk
is built. In the build tree, libcairo-script-interpreter is not stored
in the same directory as other cairo libraries.
2021-03-16 11:47:28 +01:00
Benjamin Otte
1fd534ef1e ngl: Remove duplicate check
We check the extents, so there's no need to check overlap before.
2021-03-15 01:30:34 +01:00
Matthias Clasen
28de2eecc9 ngl: Special-case css backgrounds
Recognize a common pattern: A rounded clip with
a color node, followed by a border node, with the
same outline. This is what CSS backgrounds frequently
produce, and we can render it more efficiently with
a combined shader.
2021-03-14 16:49:31 -04:00
Matthias Clasen
ed3f0012b1 ngl: Don't bother with uniform border nodes
Now that colors aren't uniforms anymore, we don't
win much by using the inset_shadow shader. The fragment
shaders of inset_shadow and border are identical. And
the regular border setup does nine-slicing.
2021-03-14 16:49:31 -04:00
Matthias Clasen
51074ca5df ngl: Small shader improvements
Add a variant of gskSetOutputColor that saves a
few multiplications, and use it where possible.
2021-03-14 16:49:31 -04:00
Matthias Clasen
8aac574d63 ngl: Improve the coloring shader
Since we are now passing a float anyway, we can avoid
the branch in the fragment shader.
2021-03-14 16:49:31 -04:00
Matthias Clasen
c1f98d6837 ngl: Improve the gradient shaders
Use a define for MAX_COLOR_STOPS, and give the loop
a fixed limit.
2021-03-14 16:49:31 -04:00
Matthias Clasen
3f60c39de4 ngl: Rewrite gsk_ngl_render_job_visit_text_node
Make this more compact, and thus easier to read.
2021-03-14 16:49:31 -04:00
Matthias Clasen
4aa570ba88 ngl: Drop gsk_ngl_render_job_set_color
Colors are not state that we carry across draw ops,
so setting the color on the render job doesn't make
much sense. Instead, pass the color to the various
draw calls. Add a few new ones for that purpose.

Also, shorten the names of some by going from
'load_vertices_from_offscreen' to 'draw_offscreen'.
2021-03-14 16:49:31 -04:00
Matthias Clasen
233969e9e4 ngl: Refactor gsk_ngl_render_job_visit_border_node
With color sorting out of the picture, this can
be much simpler.
2021-03-14 16:49:31 -04:00
Matthias Clasen
19e3a6af5d ngl: Consistently use gsk_scaled_premultiply
Its not going to make much of a difference, but we
can just as well be consistent.
2021-03-14 16:49:31 -04:00
Matthias Clasen
29501f5398 ngl: Fix up uniform enums
This got messed up when color was changed from
a uniform to an attribute in 06d5c8e72d.
2021-03-14 16:49:31 -04:00
Emmanuel Gil Peyrot
064947356a ngl: Fix the coloring shader on GLES 2.0
Integer varyings didn’t exist in GLSL ES 1.00, neither did the flat
attribute.
2021-03-13 22:00:54 +00:00
Matthias Clasen
42dfc21b2d ngl: Fix up some debug printouts 2021-03-12 18:26:15 -05:00
Matthias Clasen
daed57c30e Merge branch 'wip/chergert/fewer-uniforms' into 'master'
ngl: apply fewer uniforms

See merge request GNOME/gtk!3289
2021-03-12 22:55:00 +00:00
Matthias Clasen
ebe30d851b ngl: Identify shaders
Add a comment with a name to each shader. That makes
identifying the shaders in apitrace much easier.
2021-03-12 15:35:40 -05:00