Commit Graph

1776 Commits

Author SHA1 Message Date
Benjamin Otte
ade7509b97 GL renderer: Remove noperspective usage
It causes issues with compilation of GLES shaders and isn't in any
way correct.
2021-11-30 14:12:10 +01:00
Benjamin Otte
291c50202a rendernode: Simplify conic gradient code 2021-11-30 14:12:10 +01:00
Matthias Clasen
5b1cd335bb Go back to using pango for glyph rendering
Using just cairo makes us lose hexboxes. So, until
we implement that ourselves, go back to using pango.
2021-11-20 11:13:52 -05:00
Bilal Elmoussaoui
40c08954db g-i: add missing since annotations 2021-11-13 17:50:53 +01:00
Benjamin Otte
95574f98c4 gl: Use GL_BACK_LEFT
The spec doesn't allow GL_BACK, but many drivers do. Use the
spec-accepted equivalent instead.

Fixed #4402
2021-11-03 22:53:59 +01:00
Benjamin Otte
c97a758aa7 cssparser: Remove unused argument
The base_directory argument is never used. So don't have it.
2021-10-28 03:19:08 +02:00
Matthias Clasen
4ea84d3144 Merge branch 'bilelmoussaoui/missing-since-annotations' into 'master'
since annotations cleanup

See merge request GNOME/gtk!4086
2021-10-26 17:53:06 +00:00
Benjamin Otte
2b2fd23815 Merge branch 'wip/otte/center-center-center' into 'master'
Add a bunch of reftests and fix their failures

Closes #4285

See merge request GNOME/gtk!4085
2021-10-22 16:35:41 +00:00
Benjamin Otte
b912e84df7 gl: Call make_current() before doing any GL work
But don't call it too early, we only want to call it once we have
prepared the target.

This way, we guarantee that a GL context is always available and that it
is bound to the correct target.
2021-10-22 17:51:40 +02:00
Bilal Elmoussaoui
cb3eae1042 g-i: add missing since 4.6 annotations 2021-10-21 15:34:39 +01:00
Benjamin Otte
cb03fe8f31 gsk: Allow gsk_renderer_realize (renderer, NULL, NULL)
That way, we can use renderers without surfaces.
2021-10-20 21:49:32 +02:00
Matthias Clasen
5dec1b0cc0 Merge branch 'wip/baedert/for-master' into 'master'
Some fixes, hmm yes

See merge request GNOME/gtk!4068
2021-10-18 20:58:46 +00:00
Matthias Clasen
bddf9f9ca3 docs: Cosmetics
Do a round of "the the" removal.
2021-10-18 08:35:54 -04:00
Timm Bäder
085f0171c1 Ensure blur nodes have a positive blur radius 2021-10-17 12:15:34 +02:00
Benjamin Otte
9a2e9c5be4 gl: Use gdk_memory_texture_new_from_texture()
Way less code to prepare the texture in a proper format.
2021-10-13 14:33:44 +02:00
Benjamin Otte
ddc4a40c33 gl: Refactor texture uploading
Don't pass texture + rect, but instead have
  gdk_memory_texture_new_subtexture()
and use it to generate subtextures and pass them.

This has the advantage of downloading the a too large texture only once
instead of N times.
2021-10-13 14:33:44 +02:00
Benjamin Otte
5199bebdb5 gl: Move texture uploading to the renderer
It does not belong in GdkGLContext, it's a renderer thing.
It's also the only user of that API.

Introduce gdk_gl_context_check_version() private API to make version
checks simpler.
2021-10-13 14:33:44 +02:00
Benjamin Otte
31e9072906 gl: Fix downloading textures *again*
It turns out glReadPixels() cannot convert pixels and you are only
allowed to pass a single value into the function arguments. You need to
know which ones or things will explode.

GL is great.
2021-10-13 14:33:44 +02:00
Benjamin Otte
b65b64628d texture: Refactor downloading
Pass a format do GdkTextureClass::download(). That way we can download
data in any format.

Also replace gdk_texture_download_texture() with
gdk_memory_texture_from_texture() which again takes a format.

The old functionality is still there for code that wants it: Just pass
gdk_texture_get_format (texture) as the format argument.
2021-10-12 02:06:43 +02:00
Matthias Clasen
49a64da7ec Merge branch 'ngl-is-the-new-gl' into 'master'
Rename ngl to gl

Closes #4318

See merge request GNOME/gtk!4037
2021-10-11 06:43:41 +00:00
Benjamin Otte
e371bd09c1 ngl: Use the right value
It's GL_RGBA, not GL_BGRA, or GLES will complain.
2021-10-09 04:44:30 +02:00
Benjamin Otte
76420d7146 ngl: Fix glTexImage2D() usage on GLES
GLES is very adamant about the format and type matching the internal
format, even if the data is NULL.
2021-10-08 03:31:07 +02:00
Benjamin Otte
3b9967db48 ngl: Compute correct renderformat
We want to round up, not down.
2021-10-08 03:31:06 +02:00
Benjamin Otte
4f53645e5d ngl: fbo 0 has no color attachment
Query the backbuffer instead.
2021-10-08 03:31:06 +02:00
Matthias Clasen
b7eb1d3310 gsk: provide an ngl renderer
Provide a minimal renderer implementation that fails
in realize. This avoids reusing the same type, which
might give bindings trouble.
2021-10-07 16:46:29 -04:00
Matthias Clasen
7a1644bc97 Maintain abi
Keep gsk_ngl_renderer_new and gsk_ngl_renderer_get_type,
since they were part of the abi in 4.2, and in an
installed header.

Fixes: #4318
2021-10-07 13:05:53 -04:00
Matthias Clasen
144f727d5a Rename ngl to gl
We have only one gl renderer now, and it is
a bit odd for it not be called gl.
2021-10-07 13:05:53 -04:00
Matthias Clasen
6f1742970d ngl: Make render_texture high depth aware
Make a deep texture, if the render nodes have
high depth content.

For now, we use 32F here for the deep format,
since using 16F causes small rounding errors
that break the memorytexture roundtrip tests.
2021-10-06 21:45:54 -04:00
Matthias Clasen
8a24deff97 ngl: Update framebuffer format for each frame
Look at whether the render nodes are high depth and
if so, request a high depth framebuffer.
Whether we actually get one is up to the backend.
2021-10-06 21:35:25 -04:00
Matthias Clasen
985d2d221c ngl: Determine intermediate formats
Look at the framebuffer and the rendernode to
determine what format to use for intermediate
textures.

Our preference here is to use fp16, if we have it
and it makes sense for the framebuffer we're given.
2021-10-06 21:35:25 -04:00
Matthias Clasen
9174814686 ngl: Allow specifying texture formats
Allow passing a format when creating textures or render targets.

Update all callers to pass GL_RGBA8, which is the format we
have always used so far.
2021-10-06 21:35:25 -04:00
Matthias Clasen
2a08641f59 gsk: Add high depth rendernode api
Add private api to find out if the content
of a render node should be considered 'deep'.

The information is collected at creation time,
so there is no tree-walking involved when we
are using this information in the renderer.

Currently, this comes down to whether there are
any texture nodes with high depth textures in the subtree.
In the future, we may want to allow marking gradient
nodes in this way as well.
2021-10-06 21:35:25 -04:00
Benjamin Otte
8950c0dc96 texture: Make format a property of GdkTexture
For MemoryTexture, this is a simple change.

For GLTexture, we need to query the format at texture creation. This
sounds like a bad idea and extra work until one realizes that we'd
need to do that anyway when using the texure the first time - either
when downloading, or when trying to use it in a rendernode, where we
will soon need that information to determine if the texture prefers high
depth.
2021-10-07 02:41:30 +02:00
Benjamin Otte
48781cf7f7 memorytexture: Split out GdkMemoryFormat handling
Also, now make gdk_memory_convert() the only conversion functions
and allow conversions between any 2 formats by going via a float[4].

This could be optimized via fast-paths, but so far it isn't.
2021-10-06 22:50:07 +02:00
Matthias Clasen
f7df384ee1 ngl: Don't cache large glyphs forever
We never put large icons into the icon cache,
so all its items are always atlased, but we do
put large glyphs in to the glyph cache, and we
were never freeing those items, even when they
go unused. Fix that.
2021-10-03 13:43:15 -04:00
Matthias Clasen
8c227622d7 ngl: Small docs updates
Don't refer to nonexisting functions.
2021-10-03 11:08:46 -04:00
Matthias Clasen
c93264868b ngl: Plug a memory leak
When creating a GdkTexture from the texture
stored in the driver, we must free the GskNglTexture
struct.
2021-10-03 02:33:01 -04:00
Matthias Clasen
5bf1196bd4 ngl: Drop the texture pool object
This wasn't serving any clear purpose.
2021-10-03 02:32:40 -04:00
Matthias Clasen
bfcc2da2ce ngl: Cosmetics
Move _GskNglTextureState to the one place it is used.
2021-10-03 01:20:06 -04:00
Chun-wei Fan
a45e1a01fc fp16.c: Fix float_to_half() function call
Correct the function being called.
2021-09-30 16:21:38 +08:00
Matthias Clasen
7b22e37371 Merge branch 'transform-work' into 'master'
transform: Add sections

See merge request GNOME/gtk!3974
2021-09-18 06:35:08 +00:00
Matthias Clasen
41b810da7f Add gsk_transform_to_2d_components
This function decomposes a general 2D transform
into skew, scale, rotation and translation.

Tests included.
2021-09-18 02:06:51 -04:00
Matthias Clasen
1289e68931 gsk: Add skew transforms
Add gsk_transform_skew() to make our transform
api more complete wrt to what you would expect
for a graphics api.
2021-09-17 22:07:26 -04:00
Matthias Clasen
9e6adaa913 transform: Add sections
This makes the code easier to navigate (for me).
2021-09-17 22:07:26 -04:00
Matthias Clasen
7e4b2b971f Revert "gsk: Stop enlarging text bounding boxes"
This reverts commit 87af45403a.

I've found that this change is needed to ensure that the
bounding boxes of text nodes encompass all the glyphd drawing.
Without it, we overdraw the widget boundaries and cut off
glyphs.
2021-09-17 19:11:06 -04:00
Matthias Clasen
c6cacd2b2d ngl: Use exact device scales for glyphs
We are rendering the glyphs on a larger surface,
and we should avoid introducing unnecessary
rounding errors here. Also, I've found that
we always need to enlarge the surface by one
pixels in each direction to avoid cutting off
the tops of large glyphs.
2021-09-17 19:07:55 -04:00
Matthias Clasen
d962360fa0 Fix glyph cache entry sizing
The subpixel-positioned glyph extends on both sides.
2021-09-17 13:38:29 -04:00
Matthias Clasen
87af45403a gsk: Stop enlarging text bounding boxes
This should not be necessary and only serves
to make the actual bugs harder to find.
2021-09-17 12:37:36 -04:00
Matthias Clasen
bef54a382d transform: Improve docs
Add an example for reconstructing transforms.
2021-09-17 10:28:49 -04:00
Matthias Clasen
6a60214e8c gsk: Handle 2D transforms better
For 2D transforms, we can read the scale
factors more directly off the matrix.

This should eventually be moved out into a
function to decompose a 2D transform into
scale + rotation + skew + translation.
2021-09-17 10:28:49 -04:00
Matthias Clasen
c77b5c46a3 rendernodeparser: Avoid gdk_texture_new_for_pixbuf
We can just use gdk_texture_new_from_bytes here now.

Update affected test output.
2021-09-17 00:25:22 +02:00
Matthias Clasen
5b82cf1145 rendernodeparser: Use gdk_texture_save_to_png_bytes
Avoid cairo, and use our own api for saving png data.

Update affected test output.
2021-09-17 00:25:22 +02:00
Benjamin Otte
56b31c3923 rendernodeparser: Handle is_color attribute for glyphs 2021-09-16 23:59:37 +02:00
Matthias Clasen
93323be22a ngl: Avoid offscreens in more cases
We avoid an offscreen if we know the child node
can 'handle' the transform. Shadow nodes can if their
child node does - either the child node is a text node
in which case the shortcuts we take for shadow nodes
will work fine with the transform (we just render the
text node offset), or the child is not a text node,
in which case we render the shadow to an offscreen
anyway.

This change makes the label-shadows reftest pass with
the GL renderer, not by fixing the issue but by avoiding
it.
2021-09-16 23:59:37 +02:00
Matthias Clasen
9e14de2534 ngl: Improve shortcuts for shadow nodes
For shadow nodes, we try pretty hard to avoid
rendering shadows, and and we have a shortcut
that just renders text offset, but we can try
harder to do nothing - if the text is offset
by zero, we don't need to draw it at all.
2021-09-16 23:59:37 +02:00
Benjamin Otte
62954a0338 ngl Fix bottom-right border render failure
The wrong index was used for offsetting the bottom border rect.

Test included.
2021-09-16 23:59:37 +02:00
Matthias Clasen
390a0b2f2a ngl: Fix opacity handling
We need to use an offscreen whenever there is overlapping
children somewhere in the tree below, just checking the
direct child of the opacity node is not enough.

Fixes: #4261
2021-09-16 23:59:37 +02:00
Matthias Clasen
eb23e23b03 ngl: Avoid cairo_to_png in debug output
Just use a GL texture and gdk_texture_save_to_png,
it was made for this.
2021-09-15 21:18:34 -04:00
Matthias Clasen
423a4d4c3e Annotate gsk_cairo_blur_compute_pixels as const 2021-09-14 16:38:08 -04:00
Matthias Clasen
6faef4416f Annotate gsk_ngl_uniform_state_align as pure 2021-09-14 16:38:08 -04:00
Matthias Clasen
5f452a5e6c Annotate gsk_rounded_rect_is_circular as pure
And also mark gsk_rounded_rect_to_string as malloc.
2021-09-14 16:38:08 -04:00
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