Compare commits

...

143 Commits

Author SHA1 Message Date
Emmanuele Bassi
6d3beaf955 gsk/ngl: Build with G_DISABLE_ASSERT enabled 2021-04-12 12:27:55 +01:00
Emmanuele Bassi
1968a18edb gsk/gl: Build with G_DISABLE_ASSERT enabled 2021-04-12 12:27:33 +01:00
Emmanuele Bassi
cfe688f27e wayland: Build with G_DISABLE_ASSERT 2021-04-12 11:59:56 +01:00
Emmanuele Bassi
d37e9f708b build: Don't append multiple flags as a string
The gtk_debug_cflags variable is an array, with each argument stored in
a separate string; if we add multiple arguments inside the same string
we break the escaping rules.

Fixes: #3864
2021-04-12 11:29:53 +01:00
Emmanuele Bassi
fe66225189 Disable G_DISABLE_ASSERT in gtk_test_init()
If G_DISABLE_ASSERT is set when calling g_test_init(), the function will
warn and break every test.
2021-04-12 11:29:53 +01: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
3ad56a762f Merge branch 'grouped-toggle-fix' into 'master'
togglebutton: Fix expected group behavior

See merge request GNOME/gtk!3425
2021-04-12 02:40:43 +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
2a7b5a5156 Merge branch 'matthiasc/for-master' into 'master'
menubutton: Propagate focus-on-click

See merge request GNOME/gtk!3424
2021-04-11 22:41:26 +00:00
Matthias Clasen
233e662294 togglebutton: Fix expected group behavior
The expectation is that a grouped button stays
active when you click it. Grouped check buttons
behave this way, and grouped toggle buttons should
too.
2021-04-11 18:29:53 -04:00
Matthias Clasen
ae41697d83 node-editor: Make header buttons not steal focus
This is rarely useful, and is confusing when it
happens as side-effect of dragging the window.
2021-04-11 15:32:15 -04:00
Matthias Clasen
e2fb59798e icon browser: Make header buttons not steal focus
This is rarely useful, and is confusing when it
happens as side-effect of dragging the window.
2021-04-11 15:32:15 -04:00
Matthias Clasen
d0fc3e166d widget-factory: Make header buttons not steal focus
This is rarely useful, and is confusing when it
happens as side-effect of dragging the window.
2021-04-11 15:32:15 -04:00
Matthias Clasen
e4ce46e75f gtk-demo: Make header buttons not steal focus
This is rarely useful, and is confusing when it
happens as side-effect of dragging the window.
2021-04-11 15:32:15 -04:00
Matthias Clasen
e2420f62fe menubutton: Propagate focus-on-click
Propagate the focus-on-click setting to the button
inside, so that setting menubuttons as !focus-on-click
works as expected. This helps for menubuttons in
header bars, where dragging on the button will otherwise
steal focus from the content.
2021-04-11 15:32:15 -04:00
Yuri Chornoivan
6712106c25 Update Ukrainian translation 2021-04-11 18:39:40 +00:00
Matthias Clasen
5b55138729 Merge branch 'matthiasc/for-master' into 'master'
some small optimizations

See merge request GNOME/gtk!3423
2021-04-11 18:23:54 +00: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
678e6fc6d6 nodeeditor: Make the help window wide enough
Make the help window wide enough to show the
tables without wrapping.
2021-04-11 12:50:34 -04:00
Matthias Clasen
fcf39170e1 Merge branch 'media-memory-leak' into 'master'
media: Fix a memory leak

See merge request GNOME/gtk!3420
2021-04-10 13:42:41 +00:00
Matthias Clasen
187072c3fa media: Fix a memory leak
This was introduced in e7dc82fa32.
2021-04-10 09:02:59 -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
87a8ff90d6 Merge branch 'popover-list-lockup' into 'master'
window: Defer focus setting until after paint

Closes #3725

See merge request GNOME/gtk!3417
2021-04-10 00:34:24 +00:00
Matthias Clasen
4a76abffd4 window: Defer focus setting until after paint
Commit 3dbf5038fa tried to defer focus changes
until after rendering is done. But it failed to do so, since
the toplevel ::render handler is still before rendering of
popups that are attached to that toplevel. To do this
properly, we need to do it in the AFTER_PAINT frame clock
phase.

Fixes: #3725
2021-04-09 19:44:10 -04:00
Matthias Clasen
715449695c Merge branch 'ngl-coloring-underlines' into 'master'
Optimize underlines in text

See merge request GNOME/gtk!3414
2021-04-09 15:36:21 +00:00
Matthias Clasen
d15b0afca9 Merge branch 'no-scroll-cursor' into 'master'
scrolledwindow: Stop using scroll cursors

See merge request GNOME/gtk!3416
2021-04-09 13:30:36 +00:00
Matthias Clasen
0d6bbc035d Merge branch 'ebassi/ci-docs' into 'master'
ci: Drop the split Fedora images

See merge request GNOME/gtk!3415
2021-04-09 12:35:49 +00:00
Matthias Clasen
9313d4b6b4 scrolledwindow: Stop using scroll cursors
We used to override cursor to use all-scroll while the
content is being scrolled. Unfortunately, there is several
problems with this:
- It is really only expected certain devices, and we don't
  have the device information on Wayland
- With the way cursor setting works in GTK4, non-NULL cursors
  of the content (eg the text views ibeam) win, making the
  scroll cursor not show up
- Under X11, we seem to miss scroll end events and then
  the scroll cursor gets stuck
Therefore, just remove this feature.
2021-04-09 08:26:09 -04:00
Emmanuele Bassi
ed412f43d1 ci: Drop the split Fedora images
Now that we don't need the whole of Pandoc to build our documentation,
we can go back to a single Fedora image for our CI.
2021-04-09 12:28:08 +01: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
e4a6101ae0 gtk-demo: Make one text scroll benchmark harder
Add underlines into the mix with the Emoji heavy
text, to see if we can optimize lines.
2021-04-08 23:34:36 -04:00
Matthias Clasen
5d0a3bd4cb Merge branch 'half-float' into 'master'
ngl: Use fp16 for colors

See merge request GNOME/gtk!3405
2021-04-09 03:34:05 +00:00
Matthias Clasen
1c2238cc2a Merge branch 'font-fallback-fix' into 'master'
wayland: Improve font setting fallback more

Closes #3838

See merge request GNOME/gtk!3412
2021-04-08 11:24:09 +00: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
cce36ae701 wayland: Improve font setting fallback more
We may get a response from the portal that contains
no useful settings at all. In that case, we should
fallback as well.

Fixes: #3838
2021-04-07 19:24:09 -04:00
Matthias Clasen
2f0a02eecb Merge branch 'wip/carlosg/stuck-frames' into 'master'
surface: Always set PHASE_PAINT as pending when updates are scheduled

Closes #3750

See merge request GNOME/gtk!3411
2021-04-07 23:18:25 +00:00
Carlos Garnacho
07167fdf22 surface: Always set PHASE_PAINT as pending when updates are scheduled
At times (most often when closing subsurfaces that are scheduling
relayouts) the PHASE_PAINT handling gets broken with the following
sequence:

1. Surface receives wl_callback.done for the previous frame.
   Surface is thawed.
2. A new update on the surface is scheduled. PHASE_PAINT is
   requested directly on the frame clock. priv->pending_phase is
   left unset in the surface.
3. Surface gets frozen
4. Frame clock processes the update scheduled at 2. The surface
   is frozen, so paint is prevented. PHASE_PAINT is considered
   handled.
5. Compositor emits wl_callback.done again. Surface is thawed.
6. At this point the machinery is off
   - The surface didn't paint but has pending update regions
   - priv->draw_needed is set in the toplevel and other portions
     of the widget tree
   - So queueing redraws is ineffective at eventually calling
     gdk_surface_schedule_update() again on the toplevel surface.
   - We don't paint anymore, so this broken state is not flushed
     until other subsurface changes manage to schedule the missing
     update.

To fix this, always set PHASE_PAINT in priv->pending_phase when
doing gdk_surface_schedule_update(). If the frame clock turns
around before the surface is thawed, it will still be waiting to
be processed the next iteration.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/3750
2021-04-07 23:06:06 +02:00
Matthias Clasen
5710df685b Merge branch 'font-settings-fallback-4' into 'master'
wayland: Improve font setting fallback

See merge request GNOME/gtk!3407
2021-04-07 13:21:38 +00:00
Matthias Clasen
62f10b1b8f wayland: Improve font setting fallback
When we don't get stettings from the portal, the current
fallback is 'awful fonts'. There is no need for that. Instead,
set the fallback values to grayscale antialiasing with slight
hinting.
2021-04-07 08:50:14 -04:00
Matthias Clasen
d50d55228b Merge branch 'textview-last-line' into 'master'
textview: Fix a problem with the last line

Closes #3835

See merge request GNOME/gtk!3403
2021-04-06 16:15:55 +00:00
Matthias Clasen
288a5d4151 textview: Fix a problem with the last line
Sometimes, we missed the last line for display.

Fixes: #3835
2021-04-06 11:09:05 -04:00
Matthias Clasen
748b8497c9 Merge branch 'matthiasc/for-master' into 'master'
window: Actually enable the inspector by default

Closes #3831

See merge request GNOME/gtk!3401
2021-04-05 19:05:15 +00:00
Matthias Clasen
303ff60d5e modelbutton: Avoid a crash
We may not have a popover menu ancestor. The check for
this was forgotten in one of the branches here.

Fixes: #3831
2021-04-05 14:06:42 -04:00
Matthias Clasen
b79eb55b34 window: Actually enable the inspector by default
427d216081 changed the default in the schema,
but didn't handle cases where the schema isn't found.
2021-04-05 11:54:37 -04:00
Matthias Clasen
0ca573142a Merge branch 'matthiasc/for-master' into 'master'
textlayout: Remove some unnecessary code

See merge request GNOME/gtk!3400
2021-04-05 13:19:29 +00: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
2e18f1b6e3 textlayout: Remove an unused function 2021-04-05 08:47:53 -04:00
Matthias Clasen
6cf712591f textlayout: Avoid allocations for line iteration
No need to collect the lines firs, and allocate memory
for that. We can just iterate over them right away.
2021-04-04 23:42:58 -04:00
Matthias Clasen
b32cd5d328 textlayout: Introduce some locals
No need to call _gtk_text_buffer_get_btree over and over.
2021-04-04 22:44:09 -04:00
Matthias Clasen
2af99bd65e textlayout: Create the cursor snapshot on demand
We don't need it all the time.
2021-04-04 22:27:53 -04:00
Matthias Clasen
5b0ea70d1c textattributes: Small docs fix 2021-04-04 22:27:53 -04:00
Matthias Clasen
d719a3d877 textbtree: Return tags in a GPtrArray
One of the callers prefers that, it lets us avoid
copying the array in one place, and generally makes
for better code.
2021-04-04 22:27:53 -04:00
Matthias Clasen
b0df8910ba textlayout: Only get selection color once
No need to do this for every paragraph that is
inside the selection.
2021-04-04 14:20:25 -04:00
Matthias Clasen
5b8bf04035 texttag: Just use qsort
No point in trying to optimize this.
2021-04-04 14:20:25 -04:00
Matthias Clasen
58e44e296f textbtree: Inline node data handling 2021-04-04 14:20:25 -04:00
Matthias Clasen
0334d002c0 textbtree: Speed up _gtk_text_btree_find_line_top
Another place where we can avoid allocating a stack
piecemeal.
2021-04-04 14:20:25 -04:00
Matthias Clasen
d731ce49ad textbtree: Don't opencode realloc
We can just use g_realloc here.
2021-04-04 14:20:25 -04:00
Matthias Clasen
a93614409e textbtree: Speed up _gtk_text_line_char_index
No need to allocate a stack piecemeal here.
2021-04-04 14:20:25 -04:00
Matthias Clasen
214e2d14be textbtree: Avoid malloc in one place 2021-04-04 14:20:25 -04:00
Matthias Clasen
67ee6b2740 textlayout: Don't call render_para too much
render_para produces no nodes for an empty paragraph.
Don't call it over and over for those.
2021-04-04 14:20:25 -04:00
Matthias Clasen
07a3fb833c textlayout: Remove some unnecessary code
The same field is set again 2 lines down.
2021-04-04 14:20:25 -04:00
Chao-Hsiung Liao
1c419f762b Update Chinese (Taiwan) translation
(cherry picked from commit 3d3912d7f4)
2021-04-03 23:54:29 +00:00
Matthias Clasen
8d6c7b81e9 Merge branch 'matthiasc/for-master' into 'master'
gsk: Rename resource paths

See merge request GNOME/gtk!3399
2021-04-03 20:14:29 +00:00
Matthias Clasen
fcaadf6724 Merge branch 'dotted-lines3' into 'master'
Modernize error underlines

See merge request GNOME/gtk!3398
2021-04-03 20:14:13 +00:00
Matthias Clasen
ff38d8cdc0 Modernize error underlines
Implement PANGO_UNDERLINE_ERROR as a dotted line, instead of
squiggly, which looks quite dated.
2021-04-03 13:52:56 -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
2f1ff307da Merge branch 'matthiasc/for-master' into 'master'
node test: Improve --generate

See merge request GNOME/gtk!3397
2021-04-03 03:20:17 +00:00
Matthias Clasen
a8e8e04496 settings: Make font-size changes apply immediately
We need to invalidate the style when font-size changes,
because we propagate this value through the initial
value of the CSS font-size property, and it will not
be recomputed otherwise.
2021-04-02 23:04:09 -04:00
Matthias Clasen
91bcf6f0ba immulticontext: Unset client widget on delegate change
Forgetting to do so was causing the Wayland im context
to leave behind a dead event controller. This was showing
up as a crash when closing the inspector after changing
the im-module property of a GtkText widget. The crash
was delayed until closing the inspector because the
inspector keeps a ref on the event controllers of the
currently shown widget.
2021-04-02 22:24:19 -04:00
Matthias Clasen
a228b2de64 imwayland: Name event controllers
This helps with debugging.
2021-04-02 22:24:00 -04:00
Matthias Clasen
cb18437908 widget-factory: Name an event controller
This helps with debugging.
2021-04-02 22:23:34 -04:00
Matthias Clasen
23dab885cd text: Name all event controllers
This helps with debugging.
2021-04-02 22:23:03 -04:00
Matthias Clasen
e7284c23da inspector: Support copying nodes to clipboard
Add a button that copies the serialization of the
selected node to the clipboard.
2021-04-02 21:38:14 -04:00
Matthias Clasen
1e1f199b56 node-editor: Support pasting the image
Add a button that copies the image to the clipboard.
2021-04-02 21:24:59 -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
f2edf40e48 node test: Improve --generate
This is a pet peeve of mine: When we call
g_test_init() before handling --generate,
the random seed spew pollutes the output.
Highly annoying. I've fixes many test binaries
over the years, but more keep popping up.
2021-04-02 20:35:39 -04:00
Matthias Clasen
7cb99a0866 Merge branch 'fix-downscaled-textures' into 'master'
ngl: Fix downscaled textures

See merge request GNOME/gtk!3395
2021-04-03 00:18:48 +00:00
Matthias Clasen
36da7c3075 Merge branch 'matthiasc/for-master' into 'master'
comboboxtext: Remove misleading docs

Closes #3824

See merge request GNOME/gtk!3396
2021-04-03 00:04:36 +00:00
Matthias Clasen
a3b69f1101 Merge branch 'fix-initial-font-selection' into 'master'
fontchooser: Fix initial font selection

Closes #3687

See merge request GNOME/gtk!3392
2021-04-02 23:45:59 +00:00
Matthias Clasen
9f2d1ff264 comboboxtext: Remove misleading docs
The entry is no longer accessible.
The docs were outdated.

Fixes: #3824
2021-04-02 19:44:30 -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
0d135d90f0 Merge branch 'flat-button-activating' into 'master'
button: Style .keyboard-activating on frameless buttons

See merge request GNOME/gtk!3394
2021-04-02 18:50:16 +00:00
Chris Mayo
ffa9814dd0 button: Style .keyboard-activating on frameless buttons
The use of the keyboard-activating CSS class for buttons was added
in [1], but the style did not apply to buttons with has-frame=FALSE.

[1] 00923615f4 ("button: Add back visual feedback for keynav", 2021-04-01)
2021-04-02 19:24:51 +01:00
Nathan Follens
a2fec9134b Update Dutch translation
(cherry picked from commit a356bf6fac)
2021-04-02 18:09:34 +00:00
Matthias Clasen
8caadaf404 fontchooser: Fix initial font selection
The change in 740559a54f to populate the list incrementally
broke initial font selection. Fix that, by trying to select
until the incremental filling is done.

Fixes: #3687
2021-04-02 01:06:23 -04:00
Matthias Clasen
469228fcd7 Merge branch 'theme-reorg' into 'master'
Reorganize our themes

See merge request GNOME/gtk!3079
2021-04-02 03:02:49 +00:00
Matthias Clasen
fd329e0ec5 Make theme fallback working with the new names
Since we are likely going to see theme names like
Adwaita and HighContrast, make fallback work as follows:

Adwaita -> Default
Adwaita:dark -> Default:dark
HighContrast -> Default:hc
HighContrast:dark -> Default:hc-dark
HighContrastInverse -> Default:hc-dark

Other themes will fall back to Default, as before.
2021-04-01 22:02:38 -04:00
Matthias Clasen
7f4041ec30 Merge branch 'matthiasc/for-master' into 'master'
testsuite: Sort gsk compare tests

See merge request GNOME/gtk!3389
2021-04-02 00:38:55 +00:00
Matthias Clasen
5cb5bdc4eb testsuite: Sort gsk compare tests
Easier to find things that way.
2021-04-01 20:07:13 -04:00
Matthias Clasen
08913deba5 Add some more gsk tests
The css-background test contains a node pattern that
is optimized in the ngl renderer.
2021-04-01 20:06:40 -04:00
Matthias Clasen
aceeef47f4 Add one more compose test 2021-04-01 20:06:40 -04:00
Matthias Clasen
ddda0ca1db Merge branch 'button-activate-feedback' into 'master'
button: Add back visual feedback for keynav

Closes #3813

See merge request GNOME/gtk!3390
2021-04-01 23:36:32 +00:00
Matthias Clasen
00923615f4 button: Add back visual feedback for keynav
We lost the visual feedback for activating a button
via Space or Enter when the :active pseudo-state became
managed. Bring it back with a style class.

Fixes: #3813
2021-04-01 18:38:11 -04:00
Matthias Clasen
63945bc408 Merge branch 'matthiasc/for-master' into 'master'
Add one more compose test

See merge request GNOME/gtk!3388
2021-04-01 20:50:04 +00:00
Matthias Clasen
076f79745b Add one more compose test 2021-04-01 16:32:30 -04:00
Matthias Clasen
8e9effcc1e Merge branch 'us-intl-compose' into 'master'
Revert Compose sequence changes

Closes #3807

See merge request GNOME/gtk!3386
2021-04-01 20:01:06 +00:00
Matthias Clasen
7f4522a3f1 Add more compose tests
Test the sequences whose demise made people
unhappy.
2021-04-01 15:32:32 -04:00
Matthias Clasen
f98abe4400 Revert Compose sequence changes
This was breaking muscle memory of people with
the us intl keyboard layout, for important keys
such as '. The unfortunate side-effect is that
our handling of <dead_acute> is a bit hampered
by sequences that don't fit the pattern. But
such is life.

Fixes: #3807
2021-04-01 15:31:21 -04:00
Emmanuele Bassi
2ee8f676c3 Merge branch 'builder-tag' into 'master'
docs: Escape tags in GtkBuilder description

See merge request GNOME/gtk!3385
2021-04-01 18:49:38 +00:00
Chris Mayo
7216f71825 docs: Escape tags in GtkBuilder description
Fixes the tags and the rest of the gi-docgen created HTML page not being
visible in a browser.
2021-04-01 19:21:57 +01:00
Matthias Clasen
0bf3e4c25b Drop Adwaita and HighContrast themes
These themes will reappear in libadwaita in due course.
2021-04-01 12:39:30 -04:00
Matthias Clasen
e964e176f9 widget-factory: Use the new themes
Update the Style menu to switch between the variants
of the Default theme.
2021-04-01 12:27:35 -04:00
Matthias Clasen
8938b09bc9 Change the default theme to "Default"
We are not shipping Adwaita anymore.
2021-04-01 12:27:35 -04:00
Matthias Clasen
3654bcfbe8 Make the theme variants available as themes
This makes it easier to implement the theme switching
in widget-factory, since we don't have a variant setting.
2021-04-01 12:27:26 -04:00
Matthias Clasen
0dcf95b898 Reorganize our themes
Rename the included theme to Default, with 4 variants:
light, dark, hc, hc-dark. This replaces Adwaita,
Adwaita:dark, HighContrast and HighContrastInverse.
We still make the themes available under these names,
and we still set up Adwaita-dark and HighContrastInverse
as the dark variants of Adwaita and HighContrast.

The unification of the theme variants under Default
is not quite perfect; it would be nice to merge
the assets/ and assets-hc/ subdirectories and render
all assets from a single svg file.
2021-04-01 11:42:17 -04:00
Benjamin Otte
405fab8b36 Merge branch 'wip/otte/for-master' into 'master'
snapshot: scale border widths when appending border nodes

Closes #3819

See merge request GNOME/gtk!3384
2021-04-01 15:10:50 +00:00
Benjamin Otte
ef455f5c85 snapshot: Move sanity checks to a better place
Fixes cases where the sanity checks would reject valid code, like when
using GL shaders on a scaled transform.

Fixes #3819
2021-04-01 16:53:33 +02:00
Benjamin Otte
05e4cd1579 snapshot: scale border widths when appending border nodes
Found by Matthias on IRC while arguing about GtkSnapshot being too
complicated.
2021-04-01 16:37:43 +02:00
Matthias Clasen
0ea96e3b0c Merge branch 'filechooser-signal-disconnect' into 'master'
filechooserwidget: Disconnect settings signal on dispose

See merge request GNOME/gtk!3383
2021-04-01 14:25:08 +00:00
Carlos Garnacho
1e9e7bf0d9 Merge branch 'wip/exalm/overshoot-changes' into 'master'
scrolledwindow: Cancel overshoot on dimension changes

Closes #3752

See merge request GNOME/gtk!3300
2021-04-01 12:11:15 +00:00
Alexander Mikhaylenko
d7a5dedd4f scrolledwindow: Cancel overshoot on dimension changes
If we scroll down in a list that's still being filled, we hit the edge and
initiate overshoot, and then the adjustment's upper value increases. This
leads to an unwanted bounce back.

Additionally, if in a similar situation the upper value decreases, the
overscroll glow gets stuck.

Update kinetic scrolling upper and lower value on changes, and immediately
cancel it if dimensions on that side change.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3752
2021-04-01 16:37:30 +05:00
Rafał Dzięgiel
2e65416270 filechooserwidget: Reduce code duplication for disconnecting settings signal
Instead of getting current display before calling settings signal removal,
do it inside remove function and only if there is a signal connection to remove.
2021-04-01 09:36:23 +02:00
Rafał Dzięgiel
13c22e4e2f filechooserwidget: Disconnect settings signal on dispose
Settings signal was not being disconnected on dispose causing
application crash when user changed icon theme after dialog disposal.
2021-04-01 09:28:37 +02:00
Matthias Clasen
65a061f3c2 Merge branch 'ebassi/broadway-docs' into 'master'
docs: Update the Broadway instructions

See merge request GNOME/gtk!3380
2021-03-31 21:42:59 +00:00
Matthias Clasen
fc63e6856f Merge branch 'ebassi/docs-links' into 'master'
docs: Update the links to the docs of GTK dependencies

Closes #3817

See merge request GNOME/gtk!3381
2021-03-31 21:42:49 +00:00
Matthias Clasen
94747d53eb Merge branch 'offscreen-fixes' into 'master'
Offscreen fixes

See merge request GNOME/gtk!3379
2021-03-31 21:27:18 +00:00
Emmanuele Bassi
7bfff6c51e docs: Update the links to the docs of GTK dependencies
Use docs.gtk.org where appropriate.

Fixes: #3817
2021-03-31 20:51:27 +01:00
Emmanuele Bassi
3fdedce8f6 docs: Update the Broadway instructions
The Broadway server binary is now versioned, and it's not compatible
with the GTK3 server.
2021-03-31 20:06:54 +01:00
Matthias Clasen
5f0fe09423 Merge branch 'ebassi/for-master' into 'master'
Update the gi-docgen repository

See merge request GNOME/gtk!3352
2021-03-31 11:34:56 +00:00
Benjamin Otte
9e402fa064 Merge branch 'wip/otte/for-master' into 'master'
gstmedia: Properly detect stream metadata when preparing

See merge request GNOME/gtk!3377
2021-03-30 21:54:57 +00:00
Emmanuele Bassi
d84440969a Merge branch 'ebassi/docs-ci' into 'master'
ci: Add missing graphviz dependency

See merge request GNOME/gtk!3376
2021-03-30 20:44:51 +00:00
Benjamin Otte
e7dc82fa32 gstmedia: Properly detect stream metadata when preparing
We can look at the GstPlayerMediaInfo to get all the info we care about.
2021-03-30 22:26:26 +02:00
Emmanuele Bassi
f1b3492700 ci: Add missing graphviz dependency
We generate the hierarchy graph for GTK types, and in order to do so, we
need the dot utility from graphviz in the CI image.
2021-03-30 21:08:43 +01:00
Emmanuele Bassi
70e26d12fb Update the gi-docgen repository
Do not use my personal workspace.
2021-03-26 17:41:58 +00:00
441 changed files with 10712 additions and 5521 deletions

View File

@@ -24,9 +24,9 @@ variables:
BACKEND_FLAGS: "-Dx11-backend=true -Dwayland-backend=true -Dbroadway-backend=true"
FEATURE_FLAGS: "-Dvulkan=enabled -Dcloudproviders=enabled"
MESON_TEST_TIMEOUT_MULTIPLIER: 3
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v28"
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v29"
FLATPAK_IMAGE: "registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master"
DOCS_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora-docs:v26"
DOCS_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v29"
.only-default:
only:

View File

@@ -1,89 +0,0 @@
FROM fedora:33
RUN dnf -y install \
adwaita-icon-theme \
atk-devel \
at-spi2-atk-devel \
avahi-gobject-devel \
cairo-devel \
cairo-gobject-devel \
ccache \
clang \
clang-analyzer \
colord-devel \
cups-devel \
dbus-daemon \
dbus-x11 \
dejavu-sans-mono-fonts \
desktop-file-utils \
diffutils \
elfutils-libelf-devel \
fribidi-devel \
gcc \
gcc-c++ \
gdk-pixbuf2-devel \
gdk-pixbuf2-modules \
gettext \
git \
glib2-devel \
glib2-static \
glibc-devel \
glibc-headers \
gnome-desktop-testing \
gobject-introspection-devel \
graphene-devel \
gstreamer1-devel \
gstreamer1-plugins-good \
gstreamer1-plugins-bad-free-devel \
gstreamer1-plugins-base-devel \
gtk-doc \
hicolor-icon-theme \
iso-codes \
itstool \
json-glib-devel \
lcov \
libasan \
libattr-devel \
libcloudproviders-devel \
libepoxy-devel \
libffi-devel \
libmount-devel \
librsvg2 \
libselinux-devel \
libubsan \
libXcomposite-devel \
libXcursor-devel \
libXcursor-devel \
libXdamage-devel \
libXfixes-devel \
libXi-devel \
libXinerama-devel \
libxkbcommon-devel \
libXrandr-devel \
libXrender-devel \
libXtst-devel \
libxslt \
mesa-dri-drivers \
mesa-libEGL-devel \
mesa-libGLES-devel \
meson \
ninja-build \
pango-devel \
pcre-devel \
pcre-static \
python3 \
python3-jinja2 \
python3-pip \
python3-pygments \
python3-wheel \
redhat-rpm-config \
sassc \
systemtap-sdt-devel \
vulkan-devel \
wayland-devel \
wayland-protocols-devel \
weston \
weston-libs \
which \
xorg-x11-server-Xvfb \
&& dnf clean all

View File

@@ -1,17 +0,0 @@
FROM registry.gitlab.gnome.org/gnome/gtk/fedora-base:v28
RUN dnf -y install \
python3-jinja2 \
python3-markdown \
python3-pygments \
python3-toml \
python3-typogrify
ARG HOST_USER_ID=5555
ENV HOST_USER_ID ${HOST_USER_ID}
RUN useradd -u $HOST_USER_ID -ms /bin/bash user
USER user
WORKDIR /home/user
ENV LANG C.UTF-8

View File

@@ -1,4 +1,96 @@
FROM registry.gitlab.gnome.org/gnome/gtk/fedora-base:v28
FROM fedora:33
RUN dnf -y install \
adwaita-icon-theme \
atk-devel \
at-spi2-atk-devel \
avahi-gobject-devel \
cairo-devel \
cairo-gobject-devel \
ccache \
clang \
clang-analyzer \
colord-devel \
cups-devel \
dbus-daemon \
dbus-x11 \
dejavu-sans-mono-fonts \
desktop-file-utils \
diffutils \
elfutils-libelf-devel \
fribidi-devel \
gcc \
gcc-c++ \
gdk-pixbuf2-devel \
gdk-pixbuf2-modules \
gettext \
git \
glib2-devel \
glib2-static \
glibc-devel \
glibc-headers \
gnome-desktop-testing \
gobject-introspection-devel \
graphene-devel \
graphviz \
gstreamer1-devel \
gstreamer1-plugins-good \
gstreamer1-plugins-bad-free-devel \
gstreamer1-plugins-base-devel \
gtk-doc \
hicolor-icon-theme \
iso-codes \
itstool \
json-glib-devel \
lcov \
libasan \
libattr-devel \
libcloudproviders-devel \
libepoxy-devel \
libffi-devel \
libmount-devel \
librsvg2 \
libselinux-devel \
libubsan \
libXcomposite-devel \
libXcursor-devel \
libXcursor-devel \
libXdamage-devel \
libXfixes-devel \
libXi-devel \
libXinerama-devel \
libxkbcommon-devel \
libXrandr-devel \
libXrender-devel \
libXtst-devel \
libxslt \
mesa-dri-drivers \
mesa-libEGL-devel \
mesa-libGLES-devel \
meson \
ninja-build \
pango-devel \
pcre-devel \
pcre-static \
python3 \
python3-jinja2 \
python3-markdown \
python3-pip \
python3-pygments \
python3-toml \
python3-typogrify \
python3-wheel \
redhat-rpm-config \
sassc \
systemtap-sdt-devel \
vulkan-devel \
wayland-devel \
wayland-protocols-devel \
weston \
weston-libs \
which \
xorg-x11-server-Xvfb \
&& dnf clean all
# Enable sudo for wheel users
RUN sed -i -e 's/# %wheel/%wheel/' -e '0,/%wheel/{s/%wheel/# %wheel/}' /etc/sudoers

View File

@@ -279,3 +279,5 @@
/* Define if tracker3 is available */
#mesondefine HAVE_TRACKER3
#mesondefine HAVE_F16C

View File

@@ -116,20 +116,25 @@ populate_emoji_text (void)
GtkWidget *textview;
GtkTextBuffer *buffer;
GString *s;
GtkTextIter iter;
s = g_string_sized_new (1000 * 30 * 4);
s = g_string_sized_new (500 * 30 * 4);
for (int i = 0; i < 1000; i++)
for (int i = 0; i < 500; i++)
{
if (i % 2)
g_string_append (s, "x");
g_string_append (s, "<span underline=\"single\" underline_color=\"red\">x</span>");
for (int j = 0; j < 30; j++)
g_string_append (s, "💓x");
{
g_string_append (s, "💓");
g_string_append (s, "<span underline=\"single\" underline_color=\"red\">x</span>");
}
g_string_append (s, "\n");
}
buffer = gtk_text_buffer_new (NULL);
gtk_text_buffer_set_text (buffer, s->str, s->len);
gtk_text_buffer_get_start_iter (buffer, &iter);
gtk_text_buffer_insert_markup (buffer, &iter, s->str, s->len);
g_string_free (s, TRUE);

View File

@@ -25,6 +25,7 @@
<object class="GtkButton">
<property name="valign">center</property>
<property name="action-name">win.run</property>
<property name="focus-on-click">0</property>
<property name="label" translatable="yes">Run</property>
</object>
</child>
@@ -32,6 +33,7 @@
<object class="GtkToggleButton">
<property name="icon-name">edit-find-symbolic</property>
<property name="valign">center</property>
<property name="focus-on-click">0</property>
<property name="active" bind-source="searchbar" bind-property="search-mode-enabled" bind-flags="bidirectional|sync-create"/>
<accessibility>
<property name="label" translatable="yes">Search</property>
@@ -41,6 +43,7 @@
<child type="end">
<object class="GtkMenuButton" id="gear_menu_button">
<property name="valign">center</property>
<property name="focus-on-click">0</property>
<property name="menu-model">gear_menu</property>
<property name="icon-name">open-menu-symbolic</property>
<accessibility>

View File

@@ -25,12 +25,14 @@
</style>
<child>
<object class="GtkToggleButton" id="normal_radio">
<property name="focus-on-click">0</property>
<property name="label" translatable="yes">Normal</property>
<property name="active">1</property>
</object>
</child>
<child>
<object class="GtkToggleButton" id="symbolic_radio">
<property name="focus-on-click">0</property>
<property name="label" translatable="yes">Symbolic</property>
<property name="group">normal_radio</property>
<signal name="notify::active" handler="symbolic_toggled" swapped="yes" after="yes"/>
@@ -40,6 +42,7 @@
</child>
<child type="end">
<object class="GtkMenuButton" id="gear_menu_button">
<property name="focus-on-click">0</property>
<property name="valign">center</property>
<property name="menu-model">gear_menu</property>
<property name="icon-name">open-menu-symbolic</property>
@@ -47,6 +50,7 @@
</child>
<child type="end">
<object class="GtkToggleButton" id="search">
<property name="focus-on-click">0</property>
<style>
<class name="image-button"/>
</style>

View File

@@ -2,8 +2,8 @@
<interface>
<object class="GtkWindow" id="window">
<property name="title" translatable="yes">Help</property>
<property name="default-width">720</property>
<property name="default-height">520</property>
<property name="default-width">920</property>
<property name="default-height">600</property>
<child>
<object class="GtkScrolledWindow">
<child>

View File

@@ -635,6 +635,24 @@ export_image_cb (GtkWidget *button,
gtk_widget_show (dialog);
}
static void
clip_image_cb (GtkWidget *button,
NodeEditorWindow *self)
{
GdkTexture *texture;
GdkClipboard *clipboard;
texture = create_texture (self);
if (texture == NULL)
return;
clipboard = gtk_widget_get_clipboard (GTK_WIDGET (self));
gdk_clipboard_set_texture (clipboard, texture);
g_object_unref (texture);
}
static void
testcase_name_entry_changed_cb (GtkWidget *button,
GParamSpec *pspec,
@@ -826,6 +844,7 @@ node_editor_window_class_init (NodeEditorWindowClass *class)
gtk_widget_class_bind_template_callback (widget_class, open_cb);
gtk_widget_class_bind_template_callback (widget_class, save_cb);
gtk_widget_class_bind_template_callback (widget_class, export_image_cb);
gtk_widget_class_bind_template_callback (widget_class, clip_image_cb);
gtk_widget_class_bind_template_callback (widget_class, testcase_save_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, testcase_name_entry_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, dark_mode_cb);

View File

@@ -102,6 +102,7 @@
<object class="GtkHeaderBar" id="header">
<child type="start">
<object class="GtkButton">
<property name="focus-on-click">0</property>
<property name="icon-name">document-open-symbolic</property>
<property name="tooltip-text">Open node file</property>
<signal name="clicked" handler="open_cb"/>
@@ -109,6 +110,7 @@
</child>
<child type="start">
<object class="GtkButton">
<property name="focus-on-click">0</property>
<property name="icon-name">document-save-symbolic</property>
<property name="tooltip-text">Save to node file</property>
<signal name="clicked" handler="save_cb"/>
@@ -116,24 +118,30 @@
</child>
<child type="start">
<object class="GtkButton">
<property name="focus-on-click">0</property>
<property name="icon-name">insert-image-symbolic</property>
<property name="tooltip-text">Export to image</property>
<signal name="clicked" handler="export_image_cb"/>
</object>
</child>
<child type="start">
<object class="GtkSeparator">
<property name="orientation">vertical</property>
<object class="GtkButton">
<property name="focus-on-click">0</property>
<property name="icon-name">edit-copy-symbolic</property>
<property name="tooltip-text">Copy image to clipboard</property>
<signal name="clicked" handler="clip_image_cb"/>
</object>
</child>
<child type="start">
<object class="GtkMenuButton">
<property name="focus-on-click">0</property>
<property name="label">Save Testcase</property>
<property name="popover">testcase_popover</property>
</object>
</child>
<child type="end">
<object class="GtkMenuButton" id="gear_menu_button">
<property name="focus-on-click">0</property>
<property name="valign">center</property>
<property name="menu-model">gear_menu</property>
<property name="icon-name">open-menu-symbolic</property>
@@ -141,6 +149,7 @@
</child>
<child type="end">
<object class="GtkToggleButton" id="dark_bg_button">
<property name="focus-on-click">0</property>
<property name="valign">center</property>
<property name="has-frame">0</property>
<property name="icon-name">display-brightness-symbolic</property>

View File

@@ -50,32 +50,19 @@ change_theme_state (GSimpleAction *action,
GtkSettings *settings = gtk_settings_get_default ();
const char *s;
const char *theme;
gboolean prefer_dark = FALSE;
g_simple_action_set_state (action, state);
s = g_variant_get_string (state, NULL);
if (strcmp (s, "adwaita") == 0)
{
theme = "Adwaita";
prefer_dark = FALSE;
}
else if (strcmp (s, "adwaita-dark") == 0)
{
theme = "Adwaita";
prefer_dark = TRUE;
}
else if (strcmp (s, "highcontrast") == 0)
{
theme = "HighContrast";
prefer_dark = FALSE;
}
else if (strcmp (s, "highcontrast-inverse") == 0)
{
theme = "HighContrastInverse";
prefer_dark = FALSE;
}
if (strcmp (s, "default") == 0)
theme = "Default";
else if (strcmp (s, "dark") == 0)
theme = "Default-dark";
else if (strcmp (s, "hc") == 0)
theme = "Default-hc";
else if (strcmp (s, "hc-dark") == 0)
theme = "Default-hc-dark";
else if (strcmp (s, "current") == 0)
{
gtk_settings_reset_property (settings, "gtk-theme-name");
@@ -87,7 +74,7 @@ change_theme_state (GSimpleAction *action,
g_object_set (G_OBJECT (settings),
"gtk-theme-name", theme,
"gtk-application-prefer-dark-theme", prefer_dark,
"gtk-application-prefer-dark-theme", FALSE,
NULL);
}
@@ -1886,6 +1873,7 @@ set_up_context_popover (GtkWidget *widget,
gtk_widget_set_parent (popover, widget);
gtk_popover_set_has_arrow (GTK_POPOVER (popover), FALSE);
gesture = gtk_gesture_click_new ();
gtk_event_controller_set_name (GTK_EVENT_CONTROLLER (gesture), "widget-factory-context-click");
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), GDK_BUTTON_SECONDARY);
g_signal_connect (gesture, "pressed", G_CALLBACK (clicked_cb), popover);
gtk_widget_add_controller (widget, GTK_EVENT_CONTROLLER (gesture));

View File

@@ -15,24 +15,24 @@
<attribute name="target">current</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Adwaita</attribute>
<attribute name="label" translatable="yes">Default</attribute>
<attribute name="action">win.theme</attribute>
<attribute name="target">adwaita</attribute>
<attribute name="target">default</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Adwaita dark</attribute>
<attribute name="label" translatable="yes">Dark</attribute>
<attribute name="action">win.theme</attribute>
<attribute name="target">adwaita-dark</attribute>
<attribute name="target">dark</attribute>
</item>
<item>
<attribute name="label" translatable="yes">High contrast</attribute>
<attribute name="label" translatable="yes">Highcontrast</attribute>
<attribute name="action">win.theme</attribute>
<attribute name="target">highcontrast</attribute>
<attribute name="target">hc</attribute>
</item>
<item>
<attribute name="label" translatable="yes">High contrast inverse</attribute>
<attribute name="label" translatable="yes">Highcontrast inverse</attribute>
<attribute name="action">win.theme</attribute>
<attribute name="target">highcontrast-inverse</attribute>
<attribute name="target">hc-dark</attribute>
</item>
</section>
</submenu>
@@ -438,6 +438,7 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<child type="end">
<object class="GtkMenuButton" id="gear_menu_button">
<property name="valign">center</property>
<property name="focus-on-click">0</property>
<property name="popover">
<object class="GtkPopoverMenu" id="gear_menu">
<property name="menu-model">gear_menu_model</property>

View File

@@ -24,17 +24,17 @@ search_index = true
[dependencies."Pango-1.0"]
name = "Pango"
description = "Text shaping and rendering"
docs_url = "https://developer.gnome.org/pango/stable"
docs_url = "https://docs.gtk.org/Pango/"
[dependencies."GdkWayland-4.0"]
name = "GdkWayland"
description = "GDK Wayland Backend"
docs_url = "https://gnome.pages.gitlab.gnome.org/gtk/gdk4-wayland/"
docs_url = "https://docs.gtk.org/gdk4-wayland/"
[dependencies."GdkX11-4.0"]
name = "GdkX11"
description = "GDK X11 Backend"
docs_url = "https://gnome.pages.gitlab.gnome.org/gtk/gdk4-x11/"
docs_url = "https://docs.gtk.org/gdk4-x11/"
[theme]
name = "basic"

View File

@@ -14,22 +14,22 @@ search_index = true
[dependencies."GObject-2.0"]
name = "GObject"
description = "The base type system library"
docs_url = "https://developer.gnome.org/gobject/stable"
docs_url = "https://developer.gnome.org/gobject/stable/"
[dependencies."Graphene-1.0"]
name = "Graphene"
description = "A thin layer of mathematical types for 3D libraries"
docs_url = "https://ebassi.github.io/graphene/docs"
docs_url = "https://ebassi.github.io/graphene/docs/"
[dependencies."Pango-1.0"]
name = "Pango"
description = "Text shaping and rendering"
docs_url = "https://developer.gnome.org/pango/stable"
docs_url = "https://docs.gtk.org/Pango/"
[dependencies."Gdk-4.0"]
name = "GDK"
description = "The GTK windowing system abstraction"
docs_url = "https://gnome.pages.gitlab.gnome.org/gtk/gdk4/"
docs_url = "https://docs.gtk.org/gdk4/"
[theme]
name = "basic"

View File

@@ -3,27 +3,29 @@ Slug: broadway
## Using GTK with Broadway
The GDK Broadway backend provides support for displaying GTK
applications in a web browser, using HTML5 and web sockets. To run
your application in this way, select the Broadway backend by setting
`GDK_BACKEND=broadway`. Then you can make your application appear in
a web browser by pointing it at `http://127.0.0.1:8080`. Note that
you need to enable web sockets in your web browser.
The GDK Broadway backend provides support for displaying GTK applications in
a web browser, using HTML5 and web sockets.
You can choose a different port from the default 8080 by setting
the `BROADWAY_DISPLAY` environment variable to the port that you
want to use.
To run your application in this way, select the Broadway backend by setting
`GDK_BACKEND=broadway`. Then you can make your application appear in a web
browser by pointing it at `http://127.0.0.1:8080`. Note that you need to
enable web sockets in your web browser.
It is also possible to use multiple GTK applications in the same
web browser window, by using the Broadway server, `broadwayd`, that
ships with GTK. To use broadwayd, start it like this:
You can choose a different port from the default 8080 by setting the
`BROADWAY_DISPLAY` environment variable to the port that you want to use.
It is also possible to use multiple GTK applications in the same web browser
window, by using the Broadway server, `gtk4-broadwayd`, that ships with GTK.
To start the Broadway server use:
```
broadwayd :5
gtk4-broadwayd :5
```
Then point your web browser at `http://127.0.0.1:8085`.
Start your applications like this:
Once the Broadway server is running, you can start your applications like
this:
```
GDK_BACKEND=broadway BROADWAY_DISPLAY=:5 gtk4-demo
@@ -31,9 +33,13 @@ GDK_BACKEND=broadway BROADWAY_DISPLAY=:5 gtk4-demo
## Broadway-specific environment variables
### BROADWAY\_DISPLAY
### `BROADWAY_DISPLAY`
Specifies the Broadway display number. The default display is 0.
The display number determines the port to use when connecting
to a Broadway application via the following formula:
`port = 8080 + display`
The display number determines the port to use when connecting to a Broadway
application via the following formula:
```
port = 8080 + display
```

View File

@@ -24,17 +24,17 @@ search_index = true
[dependencies."Pango-1.0"]
name = "Pango"
description = "Text shaping and rendering"
docs_url = "https://developer.gnome.org/pango/stable"
docs_url = "https://docs.gtk.org/Pango/"
[dependencies."Gdk-4.0"]
name = "GDK"
description = "The GTK windowing system abstraction"
docs_url = "https://gnome.pages.gitlab.gnome.org/gtk/gdk4/"
docs_url = "https://docs.gtk.org/gdk4/"
[dependencies."Gsk-4.0"]
name = "GSK"
description = "The GTK rendering abstraction"
docs_url = "https://gnome.pages.gitlab.gnome.org/gtk/gsk4/"
docs_url = "https://docs.gtk.org/gsk4/"
[theme]
name = "basic"

View File

@@ -1299,12 +1299,11 @@ gdk_surface_schedule_update (GdkSurface *surface)
g_return_if_fail (surface);
surface->pending_phases |= GDK_FRAME_CLOCK_PHASE_PAINT;
if (surface->update_freeze_count ||
gdk_surface_is_toplevel_frozen (surface))
{
surface->pending_phases |= GDK_FRAME_CLOCK_PHASE_PAINT;
return;
}
return;
/* If there's no frame clock (a foreign surface), then the invalid
* region will just stick around unless gdk_surface_process_updates()

View File

@@ -848,7 +848,12 @@ gdk_wayland_device_pad_get_n_groups (GdkDevicePad *pad)
data = gdk_wayland_seat_find_pad (GDK_WAYLAND_SEAT (seat),
GDK_DEVICE (pad));
#ifdef G_DISABLE_ASSERT
if (data == NULL)
return 0;
#else
g_assert (data != NULL);
#endif
return g_list_length (data->mode_groups);
}
@@ -863,7 +868,12 @@ gdk_wayland_device_pad_get_group_n_modes (GdkDevicePad *pad,
data = gdk_wayland_seat_find_pad (GDK_WAYLAND_SEAT (seat),
GDK_DEVICE (pad));
#ifdef G_DISABLE_ASSERT
if (data == NULL)
return 0;
#else
g_assert (data != NULL);
#endif
group = g_list_nth_data (data->mode_groups, n_group);
if (!group)
@@ -909,7 +919,12 @@ gdk_wayland_device_pad_get_feature_group (GdkDevicePad *pad,
data = gdk_wayland_seat_find_pad (GDK_WAYLAND_SEAT (seat),
GDK_DEVICE (pad));
#ifdef G_DISABLE_ASSERT
if (data == NULL)
return -1;
#else
g_assert (data != NULL);
#endif
for (l = data->mode_groups, i = 0; l; l = l->next, i++)
{
@@ -4236,7 +4251,14 @@ tablet_pad_handle_button (void *data,
wp_tablet_pad, button, state));
group = tablet_pad_lookup_button_group (pad, button);
#ifdef G_DISABLE_ASSERT
if (group == NULL)
return;
#else
g_assert (group != NULL);
#endif
n_group = g_list_index (pad->mode_groups, group);
event = gdk_pad_event_new_button (state == ZWP_TABLET_PAD_V2_BUTTON_STATE_PRESSED

View File

@@ -58,6 +58,19 @@
#include "gdk/gdk-private.h"
/* Keep g_assert() defined even if we disable it globally,
* as we use it in many places as a handy mechanism to check
* for non-NULL
*/
#ifdef G_DISABLE_ASSERT
# undef g_assert
# define g_assert(expr) G_STMT_START { \
if G_LIKELY (expr) ; else \
g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
#expr); \
} G_STMT_END
#endif
/**
* GdkWaylandDisplay:
*
@@ -1708,13 +1721,13 @@ static TranslationEntry translations[] = {
{ FALSE, "org.gnome.desktop.privacy", "recent-files-max-age", "gtk-recent-files-max-age", G_TYPE_INT, { .i = 30 } },
{ FALSE, "org.gnome.desktop.privacy", "remember-recent-files", "gtk-recent-files-enabled", G_TYPE_BOOLEAN, { .b = TRUE } },
{ FALSE, "org.gnome.desktop.wm.preferences", "button-layout", "gtk-decoration-layout", G_TYPE_STRING, { .s = "menu:close" } },
{ FALSE, "org.gnome.desktop.interface", "font-antialiasing", "gtk-xft-antialias", G_TYPE_NONE, { .i = 0 } },
{ FALSE, "org.gnome.desktop.interface", "font-hinting", "gtk-xft-hinting", G_TYPE_NONE, { .i = 0 } },
{ FALSE, "org.gnome.desktop.interface", "font-hinting", "gtk-xft-hintstyle", G_TYPE_NONE, { .i = 0 } },
{ FALSE, "org.gnome.desktop.interface", "font-antialiasing", "gtk-xft-antialias", G_TYPE_NONE, { .i = 1 } },
{ FALSE, "org.gnome.desktop.interface", "font-hinting", "gtk-xft-hinting", G_TYPE_NONE, { .i = 1 } },
{ FALSE, "org.gnome.desktop.interface", "font-hinting", "gtk-xft-hintstyle", G_TYPE_NONE, { .i = 1 } },
{ FALSE, "org.gnome.desktop.interface", "font-rgba-order", "gtk-xft-rgba", G_TYPE_NONE, { .i = 0 } },
{ FALSE, "org.gnome.settings-daemon.plugins.xsettings", "antialiasing", "gtk-xft-antialias", G_TYPE_NONE, { .i = 0 } },
{ FALSE, "org.gnome.settings-daemon.plugins.xsettings", "hinting", "gtk-xft-hinting", G_TYPE_NONE, { .i = 0 } },
{ FALSE, "org.gnome.settings-daemon.plugins.xsettings", "hinting", "gtk-xft-hintstyle", G_TYPE_NONE, { .i = 0 } },
{ FALSE, "org.gnome.settings-daemon.plugins.xsettings", "antialiasing", "gtk-xft-antialias", G_TYPE_NONE, { .i = 1 } },
{ FALSE, "org.gnome.settings-daemon.plugins.xsettings", "hinting", "gtk-xft-hinting", G_TYPE_NONE, { .i = 1 } },
{ FALSE, "org.gnome.settings-daemon.plugins.xsettings", "hinting", "gtk-xft-hintstyle", G_TYPE_NONE, { .i = 1 } },
{ FALSE, "org.gnome.settings-daemon.plugins.xsettings", "rgba-order", "gtk-xft-rgba", G_TYPE_NONE, { .i = 0 } },
{ FALSE, "org.gnome.desktop.interface", "text-scaling-factor", "gtk-xft-dpi" , G_TYPE_NONE, { .i = 0 } }, /* We store the factor as 16.16 */
{ FALSE, "org.gnome.desktop.wm.preferences", "action-double-click-titlebar", "gtk-titlebar-double-click", G_TYPE_STRING, { .s = "toggle-maximize" } },
@@ -1917,6 +1930,14 @@ init_settings (GdkDisplay *display)
g_variant_get (ret, "(a{sa{sv}})", &iter);
if (g_variant_n_children (ret) == 0)
{
g_debug ("Received no portal settings");
g_clear_pointer (&ret, g_variant_unref);
goto fallback;
}
while (g_variant_iter_loop (iter, "{s@a{sv}}", &schema_str, &val))
{
GVariantIter *iter2 = g_variant_iter_new (val);

View File

@@ -45,7 +45,7 @@ xml = '''<?xml version='1.0' encoding='UTF-8'?>
'''
for f in gl_source_shaders:
xml += ' <file alias=\'glsl/{0}\'>resources/glsl/{0}</file>\n'.format(os.path.basename(f))
xml += ' <file alias=\'gl/{0}\'>gl/resources/{0}</file>\n'.format(os.path.basename(f))
xml += '\n'
@@ -55,12 +55,12 @@ for f in ngl_source_shaders:
xml += '\n'
for f in vulkan_compiled_shaders:
xml += ' <file alias=\'vulkan/{0}\'>resources/vulkan/{0}</file>\n'.format(os.path.basename(f))
xml += ' <file alias=\'vulkan/{0}\'>vulkan/resources/{0}</file>\n'.format(os.path.basename(f))
xml += '\n'
for f in vulkan_shaders:
xml += ' <file alias=\'vulkan/{0}\'>resources/vulkan/{0}</file>\n'.format(os.path.basename(f))
xml += ' <file alias=\'vulkan/{0}\'>vulkan/resources/{0}</file>\n'.format(os.path.basename(f))
xml += '''
</gresource>

View File

@@ -433,8 +433,6 @@ gsk_gl_driver_slice_texture (GskGLDriver *self,
guint *out_n_slices)
{
const int max_texture_size = gsk_gl_driver_get_max_texture_size (self) / 4; // XXX Too much?
const int tex_width = texture->width;
const int tex_height = texture->height;
const int cols = (texture->width / max_texture_size) + 1;
const int rows = (texture->height / max_texture_size) + 1;
int col, row;
@@ -442,8 +440,7 @@ gsk_gl_driver_slice_texture (GskGLDriver *self,
TextureSlice *slices;
Texture *tex;
g_assert (tex_width > max_texture_size || tex_height > max_texture_size);
g_assert (texture->width > max_texture_size || texture->height > max_texture_size);
tex = gdk_texture_get_render_data (texture, self);
@@ -730,7 +727,12 @@ gsk_gl_driver_mark_texture_permanent (GskGLDriver *self,
{
Texture *t = gsk_gl_driver_get_texture (self, texture_id);
#ifdef G_DISABLE_ASSERT
if (t == NULL)
return;
#else
g_assert (t != NULL);
#endif
t->permanent = TRUE;
}

View File

@@ -2002,7 +2002,12 @@ render_unblurred_inset_shadow_node (GskGLRenderer *self,
const float dy = gsk_inset_shadow_node_get_dy (node);
const float spread = gsk_inset_shadow_node_get_spread (node);
#if G_DISABLE_ASSERT
if (blur_radius == 0)
return;
#else
g_assert (blur_radius == 0);
#endif
ops_set_program (builder, &self->programs->inset_shadow_program);
ops_set_inset_shadow (builder, transform_rect (self, builder, gsk_inset_shadow_node_get_outline (node)),
@@ -3313,27 +3318,27 @@ gsk_gl_renderer_create_programs (GskGLRenderer *self,
const char *resource_path;
const char *name;
} program_definitions[] = {
{ "/org/gtk/libgsk/glsl/blend.glsl", "blend" },
{ "/org/gtk/libgsk/glsl/blit.glsl", "blit" },
{ "/org/gtk/libgsk/glsl/blur.glsl", "blur" },
{ "/org/gtk/libgsk/glsl/border.glsl", "border" },
{ "/org/gtk/libgsk/glsl/color_matrix.glsl", "color matrix" },
{ "/org/gtk/libgsk/glsl/color.glsl", "color" },
{ "/org/gtk/libgsk/glsl/coloring.glsl", "coloring" },
{ "/org/gtk/libgsk/glsl/cross_fade.glsl", "cross fade" },
{ "/org/gtk/libgsk/glsl/inset_shadow.glsl", "inset shadow" },
{ "/org/gtk/libgsk/glsl/linear_gradient.glsl", "linear gradient" },
{ "/org/gtk/libgsk/glsl/radial_gradient.glsl", "radial gradient" },
{ "/org/gtk/libgsk/glsl/conic_gradient.glsl", "conic gradient" },
{ "/org/gtk/libgsk/glsl/outset_shadow.glsl", "outset shadow" },
{ "/org/gtk/libgsk/glsl/repeat.glsl", "repeat" },
{ "/org/gtk/libgsk/glsl/unblurred_outset_shadow.glsl", "unblurred_outset shadow" },
{ "/org/gtk/libgsk/gl/blend.glsl", "blend" },
{ "/org/gtk/libgsk/gl/blit.glsl", "blit" },
{ "/org/gtk/libgsk/gl/blur.glsl", "blur" },
{ "/org/gtk/libgsk/gl/border.glsl", "border" },
{ "/org/gtk/libgsk/gl/color_matrix.glsl", "color matrix" },
{ "/org/gtk/libgsk/gl/color.glsl", "color" },
{ "/org/gtk/libgsk/gl/coloring.glsl", "coloring" },
{ "/org/gtk/libgsk/gl/cross_fade.glsl", "cross fade" },
{ "/org/gtk/libgsk/gl/inset_shadow.glsl", "inset shadow" },
{ "/org/gtk/libgsk/gl/linear_gradient.glsl", "linear gradient" },
{ "/org/gtk/libgsk/gl/radial_gradient.glsl", "radial gradient" },
{ "/org/gtk/libgsk/gl/conic_gradient.glsl", "conic gradient" },
{ "/org/gtk/libgsk/gl/outset_shadow.glsl", "outset shadow" },
{ "/org/gtk/libgsk/gl/repeat.glsl", "repeat" },
{ "/org/gtk/libgsk/gl/unblurred_outset_shadow.glsl", "unblurred_outset shadow" },
};
gsk_gl_shader_builder_init (&shader_builder,
"/org/gtk/libgsk/glsl/preamble.glsl",
"/org/gtk/libgsk/glsl/preamble.vs.glsl",
"/org/gtk/libgsk/glsl/preamble.fs.glsl");
"/org/gtk/libgsk/gl/preamble.glsl",
"/org/gtk/libgsk/gl/preamble.vs.glsl",
"/org/gtk/libgsk/gl/preamble.fs.glsl");
g_assert (G_N_ELEMENTS (program_definitions) == GL_N_PROGRAMS);

View File

@@ -19,9 +19,9 @@ rounded_rect_equal (const GskRoundedRect *r1,
const GskRoundedRect *r2)
{
if (r1 == r2)
return true;
return true;
if (!r1)
if (r1 == NULL || r2 == NULL)
return false;
if (r1->bounds.origin.x != r2->bounds.origin.x ||
@@ -626,6 +626,9 @@ ops_draw (RenderOpBuilder *builder,
ProgramState *program_state = get_current_program_state (builder);
OpDraw *op;
if (program_state == NULL)
return NULL;
if (memcmp (&builder->current_projection, &program_state->projection, sizeof (graphene_matrix_t)) != 0)
{
OpMatrix *opm;
@@ -739,7 +742,12 @@ ops_set_inset_shadow (RenderOpBuilder *self,
ProgramState *current_program_state = get_current_program_state (self);
OpShadow *op;
#ifdef G_DISABLE_ASSERT
if (current_program_state == NULL)
return;
#else
g_assert (current_program_state);
#endif
op = ops_begin (self, OP_CHANGE_INSET_SHADOW);
@@ -806,7 +814,12 @@ ops_set_unblurred_outset_shadow (RenderOpBuilder *self,
ProgramState *current_program_state = get_current_program_state (self);
OpShadow *op;
#ifdef G_DISABLE_ASSERT
if (current_program_state == NULL)
return;
#else
g_assert (current_program_state);
#endif
op = ops_begin (self, OP_CHANGE_UNBLURRED_OUTSET_SHADOW);
@@ -869,7 +882,12 @@ ops_set_linear_gradient (RenderOpBuilder *self,
OpLinearGradient *op;
const guint real_n_color_stops = MIN (GL_MAX_GRADIENT_STOPS, n_color_stops);
#ifdef G_DISABLE_ASSERT
if (current_program_state == NULL)
return;
#else
g_assert (current_program_state);
#endif
op = ops_begin (self, OP_CHANGE_LINEAR_GRADIENT);

View File

@@ -1867,6 +1867,7 @@ gsk_inset_shadow_node_draw (GskRenderNode *node,
GskRoundedRect box, clip_box;
int clip_radius;
double x1c, y1c, x2c, y2c;
double blur_radius;
/* We don't need to draw invisible shadows */
if (gdk_rgba_is_clear (&self->color))
@@ -1876,7 +1877,9 @@ gsk_inset_shadow_node_draw (GskRenderNode *node,
if (!gsk_rounded_rect_intersects_rect (&self->outline, &GRAPHENE_RECT_INIT (x1c, y1c, x2c - x1c, y2c - y1c)))
return;
clip_radius = gsk_cairo_blur_compute_pixels (self->blur_radius);
blur_radius = self->blur_radius / 2;
clip_radius = gsk_cairo_blur_compute_pixels (blur_radius);
cairo_save (cr);
@@ -1890,8 +1893,8 @@ gsk_inset_shadow_node_draw (GskRenderNode *node,
gsk_rounded_rect_init_copy (&clip_box, &self->outline);
gsk_rounded_rect_shrink (&clip_box, -clip_radius, -clip_radius, -clip_radius, -clip_radius);
if (!needs_blur (self->blur_radius))
draw_shadow (cr, TRUE, &box, &clip_box, self->blur_radius, &self->color, GSK_BLUR_NONE);
if (!needs_blur (blur_radius))
draw_shadow (cr, TRUE, &box, &clip_box, blur_radius, &self->color, GSK_BLUR_NONE);
else
{
cairo_region_t *remaining;
@@ -1922,7 +1925,7 @@ gsk_inset_shadow_node_draw (GskRenderNode *node,
/* Always clip with remaining to ensure we never draw any area twice */
gdk_cairo_region (cr, remaining);
cairo_clip (cr);
draw_shadow_corner (cr, TRUE, &box, &clip_box, self->blur_radius, &self->color, i, &r);
draw_shadow_corner (cr, TRUE, &box, &clip_box, blur_radius, &self->color, i, &r);
cairo_restore (cr);
/* We drew the region, remove it from remaining */
@@ -1936,7 +1939,7 @@ gsk_inset_shadow_node_draw (GskRenderNode *node,
/* Always clip with remaining to ensure we never draw any area twice */
gdk_cairo_region (cr, remaining);
cairo_clip (cr);
draw_shadow_side (cr, TRUE, &box, &clip_box, self->blur_radius, &self->color, i, &r);
draw_shadow_side (cr, TRUE, &box, &clip_box, blur_radius, &self->color, i, &r);
cairo_restore (cr);
/* We drew the region, remove it from remaining */
@@ -1948,7 +1951,7 @@ gsk_inset_shadow_node_draw (GskRenderNode *node,
cairo_save (cr);
gdk_cairo_region (cr, remaining);
cairo_clip (cr);
draw_shadow (cr, TRUE, &box, &clip_box, self->blur_radius, &self->color, GSK_BLUR_NONE);
draw_shadow (cr, TRUE, &box, &clip_box, blur_radius, &self->color, GSK_BLUR_NONE);
cairo_restore (cr);
cairo_region_destroy (remaining);
@@ -2159,6 +2162,7 @@ gsk_outset_shadow_node_draw (GskRenderNode *node,
int clip_radius;
double x1c, y1c, x2c, y2c;
float top, right, bottom, left;
double blur_radius;
/* We don't need to draw invisible shadows */
if (gdk_rgba_is_clear (&self->color))
@@ -2168,7 +2172,9 @@ gsk_outset_shadow_node_draw (GskRenderNode *node,
if (gsk_rounded_rect_contains_rect (&self->outline, &GRAPHENE_RECT_INIT (x1c, y1c, x2c - x1c, y2c - y1c)))
return;
clip_radius = gsk_cairo_blur_compute_pixels (self->blur_radius);
blur_radius = self->blur_radius / 2;
clip_radius = gsk_cairo_blur_compute_pixels (blur_radius);
cairo_save (cr);
@@ -2186,8 +2192,8 @@ gsk_outset_shadow_node_draw (GskRenderNode *node,
gsk_rounded_rect_offset (&box, self->dx, self->dy);
gsk_rounded_rect_shrink (&box, -self->spread, -self->spread, -self->spread, -self->spread);
if (!needs_blur (self->blur_radius))
draw_shadow (cr, FALSE, &box, &clip_box, self->blur_radius, &self->color, GSK_BLUR_NONE);
if (!needs_blur (blur_radius))
draw_shadow (cr, FALSE, &box, &clip_box, blur_radius, &self->color, GSK_BLUR_NONE);
else
{
int i;
@@ -2217,7 +2223,7 @@ gsk_outset_shadow_node_draw (GskRenderNode *node,
/* Always clip with remaining to ensure we never draw any area twice */
gdk_cairo_region (cr, remaining);
cairo_clip (cr);
draw_shadow_corner (cr, FALSE, &box, &clip_box, self->blur_radius, &self->color, i, &r);
draw_shadow_corner (cr, FALSE, &box, &clip_box, blur_radius, &self->color, i, &r);
cairo_restore (cr);
/* We drew the region, remove it from remaining */
@@ -2231,7 +2237,7 @@ gsk_outset_shadow_node_draw (GskRenderNode *node,
/* Always clip with remaining to ensure we never draw any area twice */
gdk_cairo_region (cr, remaining);
cairo_clip (cr);
draw_shadow_side (cr, FALSE, &box, &clip_box, self->blur_radius, &self->color, i, &r);
draw_shadow_side (cr, FALSE, &box, &clip_box, blur_radius, &self->color, i, &r);
cairo_restore (cr);
/* We drew the region, remove it from remaining */
@@ -2243,7 +2249,7 @@ gsk_outset_shadow_node_draw (GskRenderNode *node,
cairo_save (cr);
gdk_cairo_region (cr, remaining);
cairo_clip (cr);
draw_shadow (cr, FALSE, &box, &clip_box, self->blur_radius, &self->color, GSK_BLUR_NONE);
draw_shadow (cr, FALSE, &box, &clip_box, blur_radius, &self->color, GSK_BLUR_NONE);
cairo_restore (cr);
cairo_region_destroy (remaining);

View File

@@ -2439,9 +2439,9 @@ render_node_print (Printer *p,
{
start_node (p, "cross-fade");
append_node_param (p, "end", gsk_cross_fade_node_get_end_child (node));
append_float_param (p, "progress", gsk_cross_fade_node_get_progress (node), 0.5f);
append_node_param (p, "start", gsk_cross_fade_node_get_start_child (node));
append_node_param (p, "end", gsk_cross_fade_node_get_end_child (node));
end_node (p);
}
@@ -2456,8 +2456,8 @@ render_node_print (Printer *p,
start_node (p, "linear-gradient");
append_rect_param (p, "bounds", &node->bounds);
append_point_param (p, "end", gsk_linear_gradient_node_get_end (node));
append_point_param (p, "start", gsk_linear_gradient_node_get_start (node));
append_point_param (p, "end", gsk_linear_gradient_node_get_end (node));
append_stops_param (p, "stops", gsk_linear_gradient_node_get_color_stops (node, NULL),
gsk_linear_gradient_node_get_n_color_stops (node));
@@ -2506,8 +2506,8 @@ render_node_print (Printer *p,
{
start_node (p, "opacity");
append_node_param (p, "child", gsk_opacity_node_get_child (node));
append_float_param (p, "opacity", gsk_opacity_node_get_opacity (node), 0.5f);
append_node_param (p, "child", gsk_opacity_node_get_child (node));
end_node (p);
}
@@ -2535,8 +2535,8 @@ render_node_print (Printer *p,
{
start_node (p, "clip");
append_node_param (p, "child", gsk_clip_node_get_child (node));
append_rect_param (p, "clip", gsk_clip_node_get_clip (node));
append_node_param (p, "child", gsk_clip_node_get_child (node));
end_node (p);
}
@@ -2546,8 +2546,8 @@ render_node_print (Printer *p,
{
start_node (p, "rounded-clip");
append_node_param (p, "child", gsk_rounded_clip_node_get_child (node));
append_rounded_rect_param (p, "clip", gsk_rounded_clip_node_get_clip (node));
append_node_param (p, "child", gsk_rounded_clip_node_get_child (node));
end_node (p);
@@ -2559,9 +2559,9 @@ render_node_print (Printer *p,
GskTransform *transform = gsk_transform_node_get_transform (node);
start_node (p, "transform");
append_node_param (p, "child", gsk_transform_node_get_child (node));
if (gsk_transform_get_category (transform) != GSK_TRANSFORM_CATEGORY_IDENTITY)
append_transform_param (p, "transform", transform);
append_node_param (p, "child", gsk_transform_node_get_child (node));
end_node (p);
}
@@ -2571,11 +2571,11 @@ render_node_print (Printer *p,
{
start_node (p, "color-matrix");
append_node_param (p, "child", gsk_color_matrix_node_get_child (node));
if (!graphene_matrix_is_identity (gsk_color_matrix_node_get_color_matrix (node)))
append_matrix_param (p, "matrix", gsk_color_matrix_node_get_color_matrix (node));
if (!graphene_vec4_equal (gsk_color_matrix_node_get_color_offset (node), graphene_vec4_zero ()))
append_vec4_param (p, "offset", gsk_color_matrix_node_get_color_offset (node));
append_node_param (p, "child", gsk_color_matrix_node_get_child (node));
end_node (p);
}
@@ -2649,8 +2649,6 @@ render_node_print (Printer *p,
start_node (p, "shadow");
append_node_param (p, "child", gsk_shadow_node_get_child (node));
_indent (p);
g_string_append (p->str, "shadows: ");
for (i = 0; i < n_shadows; i ++)
@@ -2678,6 +2676,7 @@ render_node_print (Printer *p,
g_string_append_c (p->str, ';');
g_string_append_c (p->str, '\n');
append_node_param (p, "child", gsk_shadow_node_get_child (node));
end_node (p);
}
@@ -2917,9 +2916,9 @@ render_node_print (Printer *p,
if (!graphene_rect_equal (&node->bounds, &child->bounds))
append_rect_param (p, "bounds", &node->bounds);
append_node_param (p, "child", gsk_repeat_node_get_child (node));
if (!graphene_rect_equal (child_bounds, &child->bounds))
append_rect_param (p, "child-bounds", child_bounds);
append_node_param (p, "child", gsk_repeat_node_get_child (node));
end_node (p);
}
@@ -2932,8 +2931,6 @@ render_node_print (Printer *p,
start_node (p, "blend");
append_node_param (p, "bottom", gsk_blend_node_get_bottom_child (node));
if (mode != GSK_BLEND_MODE_DEFAULT)
{
_indent (p);
@@ -2946,6 +2943,7 @@ render_node_print (Printer *p,
}
}
}
append_node_param (p, "bottom", gsk_blend_node_get_bottom_child (node));
append_node_param (p, "top", gsk_blend_node_get_top_child (node));
end_node (p);

View File

@@ -203,7 +203,7 @@ gsk_rounded_rect_offset (GskRoundedRect *self,
return self;
}
static void
static inline void
border_radius_shrink (graphene_size_t *corner,
double width,
double height,
@@ -252,26 +252,29 @@ gsk_rounded_rect_shrink (GskRoundedRect *self,
float bottom,
float left)
{
if (self->bounds.size.width - left - right < 0)
float width = left + right;
float height = top + bottom;
if (self->bounds.size.width - width < 0)
{
self->bounds.origin.x += left * self->bounds.size.width / (left + right);
self->bounds.origin.x += left * self->bounds.size.width / width;
self->bounds.size.width = 0;
}
else
{
self->bounds.origin.x += left;
self->bounds.size.width -= left + right;
self->bounds.size.width -= width;
}
if (self->bounds.size.height - bottom - top < 0)
if (self->bounds.size.height - height < 0)
{
self->bounds.origin.y += top * self->bounds.size.height / (top + bottom);
self->bounds.origin.y += top * self->bounds.size.height / height;
self->bounds.size.height = 0;
}
else
{
self->bounds.origin.y += top;
self->bounds.size.height -= top + bottom;
self->bounds.size.height -= height;
}
border_radius_shrink (&self->corner[GSK_CORNER_TOP_LEFT], left, top, &self->bounds.size);
@@ -311,9 +314,7 @@ gsk_rounded_rect_scale_affine (GskRoundedRect *dest,
gboolean
gsk_rounded_rect_is_circular (const GskRoundedRect *self)
{
guint i;
for (i = 0; i < 4; i++)
for (guint i = 0; i < 4; i++)
{
if (self->corner[i].width != self->corner[i].height)
return FALSE;
@@ -337,9 +338,7 @@ gsk_rounded_rect_is_circular (const GskRoundedRect *self)
gboolean
gsk_rounded_rect_is_rectilinear (const GskRoundedRect *self)
{
guint i;
for (i = 0; i < 4; i++)
for (guint i = 0; i < 4; i++)
{
if (self->corner[i].width > 0 ||
self->corner[i].height > 0)
@@ -349,8 +348,8 @@ gsk_rounded_rect_is_rectilinear (const GskRoundedRect *self)
return TRUE;
}
static gboolean
ellipsis_contains_point (const graphene_size_t *ellipsis,
static inline gboolean
ellipsis_contains_point (const graphene_size_t *ellipsis,
const graphene_point_t *point)
{
return (point->x * point->x) / (ellipsis->width * ellipsis->width)
@@ -371,46 +370,42 @@ static Location
gsk_rounded_rect_locate_point (const GskRoundedRect *self,
const graphene_point_t *point)
{
float px, py;
float ox, oy;
ox = self->bounds.origin.x + self->bounds.size.width;
oy = self->bounds.origin.y + self->bounds.size.height;
if (point->x < self->bounds.origin.x ||
point->y < self->bounds.origin.y ||
point->x > self->bounds.origin.x + self->bounds.size.width ||
point->y > self->bounds.origin.y + self->bounds.size.height)
point->x > ox ||
point->y > oy)
return OUTSIDE;
if (self->bounds.origin.x + self->corner[GSK_CORNER_TOP_LEFT].width > point->x &&
self->bounds.origin.y + self->corner[GSK_CORNER_TOP_LEFT].height > point->y &&
!ellipsis_contains_point (&self->corner[GSK_CORNER_TOP_LEFT],
&GRAPHENE_POINT_INIT (
self->bounds.origin.x + self->corner[GSK_CORNER_TOP_LEFT].width - point->x,
self->bounds.origin.y + self->corner[GSK_CORNER_TOP_LEFT].height- point->y
)))
px = self->bounds.origin.x + self->corner[GSK_CORNER_TOP_LEFT].width - point->x;
py = self->bounds.origin.y + self->corner[GSK_CORNER_TOP_LEFT].height - point->y;
if (px > 0 && py > 0 &&
!ellipsis_contains_point (&self->corner[GSK_CORNER_TOP_LEFT], &GRAPHENE_POINT_INIT (px, py)))
return OUTSIDE_TOP_LEFT;
if (self->bounds.origin.x + self->bounds.size.width - self->corner[GSK_CORNER_TOP_RIGHT].width < point->x &&
self->bounds.origin.y + self->corner[GSK_CORNER_TOP_RIGHT].height > point->y &&
!ellipsis_contains_point (&self->corner[GSK_CORNER_TOP_RIGHT],
&GRAPHENE_POINT_INIT (
self->bounds.origin.x + self->bounds.size.width - self->corner[GSK_CORNER_TOP_RIGHT].width - point->x,
self->bounds.origin.y + self->corner[GSK_CORNER_TOP_RIGHT].height- point->y
)))
px = ox - self->corner[GSK_CORNER_TOP_RIGHT].width - point->x;
py = self->bounds.origin.y + self->corner[GSK_CORNER_TOP_RIGHT].height - point->y;
if (px < 0 && py > 0 &&
!ellipsis_contains_point (&self->corner[GSK_CORNER_TOP_RIGHT], &GRAPHENE_POINT_INIT (px, py)))
return OUTSIDE_TOP_RIGHT;
if (self->bounds.origin.x + self->corner[GSK_CORNER_BOTTOM_LEFT].width > point->x &&
self->bounds.origin.y + self->bounds.size.height - self->corner[GSK_CORNER_BOTTOM_LEFT].height < point->y &&
px = self->bounds.origin.x + self->corner[GSK_CORNER_BOTTOM_LEFT].width - point->x;
py = oy - self->corner[GSK_CORNER_BOTTOM_LEFT].height - point->y;
if (px > 0 && py < 0 &&
!ellipsis_contains_point (&self->corner[GSK_CORNER_BOTTOM_LEFT],
&GRAPHENE_POINT_INIT (
self->bounds.origin.x + self->corner[GSK_CORNER_BOTTOM_LEFT].width - point->x,
self->bounds.origin.y + self->bounds.size.height - self->corner[GSK_CORNER_BOTTOM_LEFT].height- point->y
)))
&GRAPHENE_POINT_INIT (px, py)))
return OUTSIDE_BOTTOM_LEFT;
if (self->bounds.origin.x + self->bounds.size.width - self->corner[GSK_CORNER_BOTTOM_RIGHT].width < point->x &&
self->bounds.origin.y + self->bounds.size.height - self->corner[GSK_CORNER_BOTTOM_RIGHT].height < point->y &&
px = ox - self->corner[GSK_CORNER_BOTTOM_RIGHT].width - point->x;
py = oy - self->corner[GSK_CORNER_BOTTOM_RIGHT].height - point->y;
if (px < 0 && py < 0 &&
!ellipsis_contains_point (&self->corner[GSK_CORNER_BOTTOM_RIGHT],
&GRAPHENE_POINT_INIT (
self->bounds.origin.x + self->bounds.size.width - self->corner[GSK_CORNER_BOTTOM_RIGHT].width - point->x,
self->bounds.origin.y + self->bounds.size.height - self->corner[GSK_CORNER_BOTTOM_RIGHT].height- point->y
)))
&GRAPHENE_POINT_INIT (px, py)))
return OUTSIDE_BOTTOM_RIGHT;
return INSIDE;
@@ -445,16 +440,45 @@ gboolean
gsk_rounded_rect_contains_rect (const GskRoundedRect *self,
const graphene_rect_t *rect)
{
float tx, ty;
float px, py;
float ox, oy;
tx = rect->origin.x + rect->size.width;
ty = rect->origin.y + rect->size.height;
ox = self->bounds.origin.x + self->bounds.size.width;
oy = self->bounds.origin.y + self->bounds.size.height;
if (rect->origin.x < self->bounds.origin.x ||
rect->origin.y < self->bounds.origin.y ||
rect->origin.x + rect->size.width > self->bounds.origin.x + self->bounds.size.width ||
rect->origin.y + rect->size.height > self->bounds.origin.y + self->bounds.size.height)
tx > ox ||
ty > oy)
return FALSE;
if (!gsk_rounded_rect_contains_point (self, &rect->origin) ||
!gsk_rounded_rect_contains_point (self, &GRAPHENE_POINT_INIT (rect->origin.x + rect->size.width, rect->origin.y)) ||
!gsk_rounded_rect_contains_point (self, &GRAPHENE_POINT_INIT (rect->origin.x, rect->origin.y + rect->size.height)) ||
!gsk_rounded_rect_contains_point (self, &GRAPHENE_POINT_INIT (rect->origin.x + rect->size.width, rect->origin.y + rect->size.height)))
px = self->bounds.origin.x + self->corner[GSK_CORNER_TOP_LEFT].width - rect->origin.x;
py = self->bounds.origin.y + self->corner[GSK_CORNER_TOP_LEFT].height - rect->origin.y;
if (px > 0 && py > 0 &&
!ellipsis_contains_point (&self->corner[GSK_CORNER_TOP_LEFT], &GRAPHENE_POINT_INIT (px, py)))
return FALSE;
px = ox - self->corner[GSK_CORNER_TOP_RIGHT].width - tx;
py = self->bounds.origin.y + self->corner[GSK_CORNER_TOP_RIGHT].height - rect->origin.y;
if (px < 0 && py > 0 &&
!ellipsis_contains_point (&self->corner[GSK_CORNER_TOP_RIGHT], &GRAPHENE_POINT_INIT (px, py)))
return FALSE;
px = self->bounds.origin.x + self->corner[GSK_CORNER_BOTTOM_LEFT].width - rect->origin.x;
py = oy - self->corner[GSK_CORNER_BOTTOM_LEFT].height - ty;
if (px > 0 && py < 0 &&
!ellipsis_contains_point (&self->corner[GSK_CORNER_BOTTOM_LEFT],
&GRAPHENE_POINT_INIT (px, py)))
return FALSE;
px = ox - self->corner[GSK_CORNER_BOTTOM_RIGHT].width - tx;
py = oy - self->corner[GSK_CORNER_BOTTOM_RIGHT].height - ty;
if (px < 0 && py < 0 &&
!ellipsis_contains_point (&self->corner[GSK_CORNER_BOTTOM_RIGHT],
&GRAPHENE_POINT_INIT (px, py)))
return FALSE;
return TRUE;
@@ -476,8 +500,10 @@ gsk_rounded_rect_intersects_rect (const GskRoundedRect *self,
if (!graphene_rect_intersection (&self->bounds, rect, NULL))
return FALSE;
/* If the bounding boxes intersect but the rectangles don't, one of the rect's corners
* must be in the opposite corner's outside region */
/* If the bounding boxes intersect but the rectangles don't,
* one of the rect's corners must be in the opposite corner's
* outside region
*/
if (gsk_rounded_rect_locate_point (self, &rect->origin) == OUTSIDE_BOTTOM_RIGHT ||
gsk_rounded_rect_locate_point (self, &GRAPHENE_POINT_INIT (rect->origin.x + rect->size.width, rect->origin.y)) == OUTSIDE_BOTTOM_LEFT ||
gsk_rounded_rect_locate_point (self, &GRAPHENE_POINT_INIT (rect->origin.x, rect->origin.y + rect->size.height)) == OUTSIDE_TOP_RIGHT ||

View File

@@ -1,23 +1,23 @@
gsk_private_gl_shaders = [
'resources/glsl/preamble.glsl',
'resources/glsl/preamble.fs.glsl',
'resources/glsl/preamble.vs.glsl',
'resources/glsl/border.glsl',
'resources/glsl/blit.glsl',
'resources/glsl/coloring.glsl',
'resources/glsl/color.glsl',
'resources/glsl/linear_gradient.glsl',
'resources/glsl/radial_gradient.glsl',
'resources/glsl/conic_gradient.glsl',
'resources/glsl/color_matrix.glsl',
'resources/glsl/blur.glsl',
'resources/glsl/inset_shadow.glsl',
'resources/glsl/outset_shadow.glsl',
'resources/glsl/unblurred_outset_shadow.glsl',
'resources/glsl/cross_fade.glsl',
'resources/glsl/blend.glsl',
'resources/glsl/repeat.glsl',
'resources/glsl/custom.glsl',
'gl/resources/preamble.glsl',
'gl/resources/preamble.fs.glsl',
'gl/resources/preamble.vs.glsl',
'gl/resources/border.glsl',
'gl/resources/blit.glsl',
'gl/resources/coloring.glsl',
'gl/resources/color.glsl',
'gl/resources/linear_gradient.glsl',
'gl/resources/radial_gradient.glsl',
'gl/resources/conic_gradient.glsl',
'gl/resources/color_matrix.glsl',
'gl/resources/blur.glsl',
'gl/resources/inset_shadow.glsl',
'gl/resources/outset_shadow.glsl',
'gl/resources/unblurred_outset_shadow.glsl',
'gl/resources/cross_fade.glsl',
'gl/resources/blend.glsl',
'gl/resources/repeat.glsl',
'gl/resources/custom.glsl',
]
gsk_private_ngl_shaders = [
@@ -85,6 +85,7 @@ gsk_private_sources = files([
'ngl/gskngltexturelibrary.c',
'ngl/gskngluniformstate.c',
'ngl/gskngltexturepool.c',
'ngl/fp16.c',
])
gsk_public_headers = files([
@@ -158,7 +159,7 @@ if have_vulkan
'vulkan/gskvulkanshader.c',
])
subdir('resources/vulkan')
subdir('vulkan/resources')
endif # have_vulkan
if get_variable('broadway_enabled')

150
gsk/ngl/fp16.c Normal file
View File

@@ -0,0 +1,150 @@
/* fp16.c
*
* Copyright 2021 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include <config.h>
#include "fp16private.h"
#ifdef HAVE_F16C
#include <immintrin.h>
#endif
static inline guint
as_uint (const float x)
{
return *(guint*)&x;
}
static inline float
as_float (const guint x)
{
return *(float*)&x;
}
// IEEE-754 16-bit floating-point format (without infinity): 1-5-10
static inline float
half_to_float (const guint16 x)
{
const guint e = (x&0x7C00)>>10; // exponent
const guint m = (x&0x03FF)<<13; // mantissa
const guint v = as_uint((float)m)>>23;
return as_float((x&0x8000)<<16 | (e!=0)*((e+112)<<23|m) | ((e==0)&(m!=0))*((v-37)<<23|((m<<(150-v))&0x007FE000)));
}
static inline guint16
float_to_half (const float x)
{
const guint b = as_uint(x)+0x00001000; // round-to-nearest-even
const guint e = (b&0x7F800000)>>23; // exponent
const guint m = b&0x007FFFFF; // mantissa
return (b&0x80000000)>>16 | (e>112)*((((e-112)<<10)&0x7C00)|m>>13) | ((e<113)&(e>101))*((((0x007FF000+m)>>(125-e))+1)>>1) | (e>143)*0x7FFF; // sign : normalized : denormalized : saturate
}
static void
float_to_half4_c (const float f[4],
guint16 h[4])
{
h[0] = float_to_half (f[0]);
h[1] = float_to_half (f[1]);
h[2] = float_to_half (f[2]);
h[3] = float_to_half (f[3]);
}
static void
half_to_float4_c (const guint16 h[4],
float f[4])
{
f[0] = half_to_float (h[0]);
f[1] = half_to_float (h[1]);
f[2] = half_to_float (h[2]);
f[3] = half_to_float (h[3]);
}
#ifdef HAVE_F16C
static void
float_to_half4_f16c (const float f[4],
guint16 h[4])
{
__m128 s = _mm_loadu_ps (f);
__m128i i = _mm_cvtps_ph (s, 0);
_mm_storel_epi64 ((__m128i*)h, i);
}
static void
half_to_float4_f16c (const guint16 h[4],
float f[4])
{
__m128i i = _mm_loadl_epi64 ((__m128i_u const *)h);
__m128 s = _mm_cvtph_ps (i);
_mm_store_ps (f, s);
}
void float_to_half4 (const float f[4], guint16 h[4]) __attribute__((ifunc ("resolve_float_to_half4")));
void half_to_float4 (const guint16 h[4], float f[4]) __attribute__((ifunc ("resolve_half_to_float4")));
static void *
resolve_float_to_half4 (void)
{
__builtin_cpu_init ();
if (__builtin_cpu_supports ("f16c"))
return float_to_half4_f16c;
else
return float_to_half4_c;
}
static void *
resolve_half_to_float4 (void)
{
__builtin_cpu_init ();
if (__builtin_cpu_supports ("f16c"))
return half_to_float4_f16c;
else
return half_to_float4_c;
}
#else
#ifdef __APPLE__
// turns out aliases don't work on Darwin
void
float_to_half4 (const float f[4],
guint16 h[4])
{
float_to_half4_c (f, h);
}
void
half_to_float4 (const guint16 h[4],
float f[4])
{
half_to_float4_c (h, f);
}
#else
void float_to_half4 (const float f[4], guint16 h[4]) __attribute__((alias ("float_to_half4_c")));
void half_to_float4 (const guint16 h[4], float f[4]) __attribute__((alias ("half_to_float4_c")));
#endif
#endif /* GTK_HAS_F16C */

40
gsk/ngl/fp16private.h Normal file
View File

@@ -0,0 +1,40 @@
/* fp16private.h
*
* Copyright 2021 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#ifndef __FP16_PRIVATE_H__
#define __FP16_PRIVATE_H__
#include <glib.h>
G_BEGIN_DECLS
#define FP16_ZERO ((guint16)0)
#define FP16_ONE ((guint16)15360)
#define FP16_MINUS_ONE ((guint16)48128)
void float_to_half4 (const float f[4],
guint16 h[4]);
void half_to_float4 (const guint16 h[4],
float f[4]);
G_END_DECLS
#endif

View File

@@ -169,7 +169,7 @@ gsk_ngl_command_queue_print_batch (GskNglCommandQueue *self,
for (guint i = 0; i < batch->draw.bind_count; i++)
{
const GskNglCommandBind *bind = &self->batch_binds.items[batch->draw.bind_offset + i];
g_print (" Bind[%d]: %u\n", bind->texture, bind->id);
g_printerr (" Bind[%d]: %u\n", bind->texture, bind->id);
}
for (guint i = 0; i < batch->draw.uniform_count; i++)
@@ -951,6 +951,7 @@ gsk_ngl_command_queue_execute (GskNglCommandQueue *self,
guint n_binds = 0;
guint n_fbos = 0;
guint n_uniforms = 0;
guint n_programs = 0;
guint vao_id;
guint vbo_id;
int textures[4];
@@ -1003,13 +1004,13 @@ gsk_ngl_command_queue_execute (GskNglCommandQueue *self,
/* 2 = color location */
glEnableVertexAttribArray (2);
glVertexAttribPointer (2, 4, GL_FLOAT, GL_FALSE,
glVertexAttribPointer (2, 4, GL_HALF_FLOAT, GL_FALSE,
sizeof (GskNglDrawVertex),
(void *) G_STRUCT_OFFSET (GskNglDrawVertex, color));
/* 3 = color2 location */
glEnableVertexAttribArray (3);
glVertexAttribPointer (3, 4, GL_FLOAT, GL_FALSE,
glVertexAttribPointer (3, 4, GL_HALF_FLOAT, GL_FALSE,
sizeof (GskNglDrawVertex),
(void *) G_STRUCT_OFFSET (GskNglDrawVertex, color2));
@@ -1062,6 +1063,8 @@ gsk_ngl_command_queue_execute (GskNglCommandQueue *self,
{
program = batch->any.program;
glUseProgram (program);
n_programs++;
}
if (apply_framebuffer (&framebuffer, batch->draw.framebuffer))
@@ -1144,6 +1147,7 @@ gsk_ngl_command_queue_execute (GskNglCommandQueue *self,
gdk_profiler_set_int_counter (self->metrics.n_binds, n_binds);
gdk_profiler_set_int_counter (self->metrics.n_uniforms, n_uniforms);
gdk_profiler_set_int_counter (self->metrics.n_fbos, n_fbos);
gdk_profiler_set_int_counter (self->metrics.n_programs, n_programs);
gdk_profiler_set_int_counter (self->metrics.n_uploads, self->n_uploads);
gdk_profiler_set_int_counter (self->metrics.queue_depth, self->batches.len);
@@ -1415,6 +1419,7 @@ gsk_ngl_command_queue_set_profiler (GskNglCommandQueue *self,
self->metrics.n_fbos = gdk_profiler_define_int_counter ("fbos", "Number of framebuffers attached");
self->metrics.n_uniforms = gdk_profiler_define_int_counter ("uniforms", "Number of uniforms changed");
self->metrics.n_uploads = gdk_profiler_define_int_counter ("uploads", "Number of texture uploads");
self->metrics.n_programs = gdk_profiler_define_int_counter ("programs", "Number of program changes");
self->metrics.queue_depth = gdk_profiler_define_int_counter ("gl-queue-depth", "Depth of GL command batches");
}
#endif

View File

@@ -250,6 +250,7 @@ struct _GskNglCommandQueue
guint n_fbos;
guint n_uniforms;
guint n_uploads;
guint n_programs;
guint queue_depth;
} metrics;

View File

@@ -43,6 +43,7 @@
#include "gsknglshadowlibraryprivate.h"
#include "ninesliceprivate.h"
#include "fp16private.h"
#define ORTHO_NEAR_PLANE -10000
#define ORTHO_FAR_PLANE 10000
@@ -211,6 +212,13 @@ node_is_invisible (const GskRenderNode *node)
node->bounds.size.height == 0.0f;
}
static inline gboolean G_GNUC_PURE
rounded_rect_equal (const GskRoundedRect *r1,
const GskRoundedRect *r2)
{
return memcmp (r1, r2, sizeof (GskRoundedRect)) == 0;
}
static inline void
gsk_rounded_rect_shrink_to_minimum (GskRoundedRect *self)
{
@@ -726,7 +734,7 @@ gsk_ngl_render_job_transform_bounds (GskNglRenderJob *job,
/* Our most common transform is 2d-affine, so inline it.
* Both identity and 2d-translate are virtually unseen here.
*/
if G_LIKELY (category == GSK_TRANSFORM_CATEGORY_2D_AFFINE)
if G_LIKELY (category >= GSK_TRANSFORM_CATEGORY_2D_AFFINE)
{
float dx, dy, scale_x, scale_y;
@@ -810,9 +818,9 @@ interval_contains (float p1, float w1,
}
static inline gboolean
gsk_ngl_render_job_update_clip (GskNglRenderJob *job,
const GskRenderNode *node,
gboolean *pushed_clip)
gsk_ngl_render_job_update_clip (GskNglRenderJob *job,
const graphene_rect_t *bounds,
gboolean *pushed_clip)
{
graphene_rect_t transformed_bounds;
gboolean no_clip = FALSE;
@@ -826,7 +834,7 @@ gsk_ngl_render_job_update_clip (GskNglRenderJob *job,
return TRUE;
}
gsk_ngl_render_job_transform_bounds (job, &node->bounds, &transformed_bounds);
gsk_ngl_render_job_transform_bounds (job, bounds, &transformed_bounds);
if (!rect_intersects (&job->current_clip->rect.bounds, &transformed_bounds))
{
@@ -884,6 +892,13 @@ gsk_ngl_render_job_update_clip (GskNglRenderJob *job,
return TRUE;
}
static inline void
rgba_to_half (const GdkRGBA *rgba,
guint16 h[4])
{
float_to_half4 ((const float *)rgba, h);
}
/* fill_vertex_data */
static void
gsk_ngl_render_job_draw_coords (GskNglRenderJob *job,
@@ -895,16 +910,16 @@ gsk_ngl_render_job_draw_coords (GskNglRenderJob *job,
float min_v,
float max_u,
float max_v,
const GdkRGBA *color)
guint16 c[4])
{
GskNglDrawVertex *vertices = gsk_ngl_command_queue_add_vertices (job->command_queue);
vertices[0] = (GskNglDrawVertex) { { min_x, min_y }, { min_u, min_v }, { color->red, color->green, color->blue, color->alpha } };
vertices[1] = (GskNglDrawVertex) { { min_x, max_y }, { min_u, max_v }, { color->red, color->green, color->blue, color->alpha } };
vertices[2] = (GskNglDrawVertex) { { max_x, min_y }, { max_u, min_v }, { color->red, color->green, color->blue, color->alpha } };
vertices[3] = (GskNglDrawVertex) { { max_x, max_y }, { max_u, max_v }, { color->red, color->green, color->blue, color->alpha } };
vertices[4] = (GskNglDrawVertex) { { min_x, max_y }, { min_u, max_v }, { color->red, color->green, color->blue, color->alpha } };
vertices[5] = (GskNglDrawVertex) { { max_x, min_y }, { max_u, min_v }, { color->red, color->green, color->blue, color->alpha } };
vertices[0] = (GskNglDrawVertex) { .position = { min_x, min_y }, .uv = { min_u, min_v }, .color = { c[0], c[1], c[2], c[3] } };
vertices[1] = (GskNglDrawVertex) { .position = { min_x, max_y }, .uv = { min_u, max_v }, .color = { c[0], c[1], c[2], c[3] } };
vertices[2] = (GskNglDrawVertex) { .position = { max_x, min_y }, .uv = { max_u, min_v }, .color = { c[0], c[1], c[2], c[3] } };
vertices[3] = (GskNglDrawVertex) { .position = { max_x, max_y }, .uv = { max_u, max_v }, .color = { c[0], c[1], c[2], c[3] } };
vertices[4] = (GskNglDrawVertex) { .position = { min_x, max_y }, .uv = { min_u, max_v }, .color = { c[0], c[1], c[2], c[3] } };
vertices[5] = (GskNglDrawVertex) { .position = { max_x, min_y }, .uv = { max_u, min_v }, .color = { c[0], c[1], c[2], c[3] } };
}
/* load_vertex_data_with_region */
@@ -912,7 +927,7 @@ static inline void
gsk_ngl_render_job_draw_offscreen_with_color (GskNglRenderJob *job,
const graphene_rect_t *bounds,
const GskNglRenderOffscreen *offscreen,
const GdkRGBA *color)
guint16 color[4])
{
float min_x = job->offset_x + bounds->origin.x;
float min_y = job->offset_y + bounds->origin.y;
@@ -932,7 +947,8 @@ gsk_ngl_render_job_draw_offscreen (GskNglRenderJob *job,
const graphene_rect_t *bounds,
const GskNglRenderOffscreen *offscreen)
{
gsk_ngl_render_job_draw_offscreen_with_color (job, bounds, offscreen, &(GdkRGBA) { 0.f, 0.f, 0.f, 0.f });
gsk_ngl_render_job_draw_offscreen_with_color (job, bounds, offscreen,
(guint16[]) { FP16_ZERO, FP16_ZERO, FP16_ZERO, FP16_ZERO });
}
/* load_float_vertex_data */
@@ -942,7 +958,7 @@ gsk_ngl_render_job_draw_with_color (GskNglRenderJob *job,
float y,
float width,
float height,
const GdkRGBA *color)
guint16 color[4])
{
float min_x = job->offset_x + x;
float min_y = job->offset_y + y;
@@ -959,14 +975,15 @@ gsk_ngl_render_job_draw (GskNglRenderJob *job,
float width,
float height)
{
gsk_ngl_render_job_draw_with_color (job, x, y, width, height, &(GdkRGBA) { 0.f, 0.f, 0.f, 0.f });
gsk_ngl_render_job_draw_with_color (job, x, y, width, height,
(guint16[]) { FP_ZERO, FP_ZERO, FP_ZERO, FP_ZERO });
}
/* load_vertex_data */
static inline void
gsk_ngl_render_job_draw_rect_with_color (GskNglRenderJob *job,
const graphene_rect_t *bounds,
const GdkRGBA *color)
guint16 color[4])
{
gsk_ngl_render_job_draw_with_color (job,
bounds->origin.x,
@@ -995,11 +1012,12 @@ gsk_ngl_render_job_draw_offscreen_rect (GskNglRenderJob *job,
float min_y = job->offset_y + bounds->origin.y;
float max_x = min_x + bounds->size.width;
float max_y = min_y + bounds->size.height;
guint16 color[4] = { FP16_ZERO, FP16_ZERO, FP16_ZERO, FP16_ZERO };
gsk_ngl_render_job_draw_coords (job,
min_x, min_y, max_x, max_y,
0, 1, 1, 0,
&(GdkRGBA) { 0.f, 0.f, 0.f, 0.f } );
color);
}
static inline void
@@ -1253,7 +1271,7 @@ blur_offscreen (GskNglRenderJob *job,
gsk_ngl_render_job_draw_coords (job,
0, 0, texture_to_blur_width, texture_to_blur_height,
0, 1, 1, 0,
&(GdkRGBA) { 0.f, 0.f, 0.f, 0.f });
(guint16[]) { FP16_ZERO, FP16_ZERO, FP16_ZERO, FP16_ZERO });
gsk_ngl_render_job_end_draw (job);
/* Bind second pass framebuffer and clear it */
@@ -1280,7 +1298,7 @@ blur_offscreen (GskNglRenderJob *job,
gsk_ngl_render_job_draw_coords (job,
0, 0, texture_to_blur_width, texture_to_blur_height,
0, 1, 1, 0,
&(GdkRGBA) { 0.f, 0.f, 0.f, 0.f });
(guint16[]) { FP16_ZERO, FP16_ZERO, FP16_ZERO, FP16_ZERO });
gsk_ngl_render_job_end_draw (job);
gsk_ngl_render_job_pop_modelview (job);
@@ -1349,15 +1367,54 @@ blur_node (GskNglRenderJob *job,
*max_y = job->offset_y + node->bounds.origin.y + node->bounds.size.height + half_blur_extra;
}
#define ATLAS_SIZE 512
static inline void
gsk_ngl_render_job_visit_color_node (GskNglRenderJob *job,
const GskRenderNode *node)
{
gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, color));
gsk_ngl_render_job_draw_rect_with_color (job,
&node->bounds,
gsk_color_node_get_color (node));
gsk_ngl_render_job_end_draw (job);
guint16 color[4];
GskNglProgram *program;
GskNglCommandBatch *batch;
rgba_to_half (gsk_color_node_get_color (node), color);
/* Avoid switching away from the coloring program for
* rendering a solid color.
*/
program = CHOOSE_PROGRAM (job, coloring);
batch = gsk_ngl_command_queue_get_batch (job->command_queue);
if (batch->any.kind == GSK_NGL_COMMAND_KIND_DRAW &&
batch->any.program == program->id)
{
GskNglRenderOffscreen offscreen = {0};
gsk_ngl_render_job_begin_draw (job, program);
/* The top left few pixels in our atlases are always
* solid white, so we can use it here, without
* having to choose any particular atlas texture.
*/
offscreen.was_offscreen = FALSE;
offscreen.area.x = 1.f / ATLAS_SIZE;
offscreen.area.y = 1.f / ATLAS_SIZE;
offscreen.area.x2 = 2.f / ATLAS_SIZE;
offscreen.area.y2 = 2.f / ATLAS_SIZE;
gsk_ngl_render_job_draw_offscreen_with_color (job,
&node->bounds,
&offscreen,
color);
gsk_ngl_render_job_end_draw (job);
}
else
{
gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, color));
gsk_ngl_render_job_draw_rect_with_color (job, &node->bounds, color);
gsk_ngl_render_job_end_draw (job);
}
}
static inline void
@@ -1498,20 +1555,14 @@ gsk_ngl_render_job_visit_clipped_child (GskNglRenderJob *job,
}
else
{
GskRoundedRect scaled_clip;
GskNglRenderOffscreen offscreen = {0};
offscreen.bounds = &child->bounds;
offscreen.bounds = clip;
offscreen.force_offscreen = TRUE;
offscreen.reset_clip = TRUE;
offscreen.do_not_cache = TRUE;
scaled_clip = GSK_ROUNDED_RECT_INIT ((job->offset_x + clip->origin.x) * job->scale_x,
(job->offset_y + clip->origin.y) * job->scale_y,
clip->size.width * job->scale_x,
clip->size.height * job->scale_y);
gsk_ngl_render_job_push_clip (job, &scaled_clip);
gsk_ngl_render_job_visit_node_with_offscreen (job, child, &offscreen);
gsk_ngl_render_job_pop_clip (job);
g_assert (offscreen.texture_id);
@@ -1521,7 +1572,7 @@ gsk_ngl_render_job_visit_clipped_child (GskNglRenderJob *job,
GL_TEXTURE_2D,
GL_TEXTURE0,
offscreen.texture_id);
gsk_ngl_render_job_draw_offscreen_rect (job, &child->bounds);
gsk_ngl_render_job_draw_offscreen_rect (job, clip);
gsk_ngl_render_job_end_draw (job);
}
}
@@ -1633,28 +1684,41 @@ gsk_ngl_render_job_visit_rect_border_node (GskNglRenderJob *job,
const float *widths = gsk_border_node_get_widths (node);
const graphene_point_t *origin = &node->bounds.origin;
const graphene_size_t *size = &node->bounds.size;
guint16 color[4];
gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, color));
if (widths[0] > 0)
gsk_ngl_render_job_draw_rect_with_color (job,
&GRAPHENE_RECT_INIT (origin->x, origin->y, size->width - widths[1], widths[0]),
&colors[0]);
{
rgba_to_half (&colors[0], color);
gsk_ngl_render_job_draw_rect_with_color (job,
&GRAPHENE_RECT_INIT (origin->x, origin->y, size->width - widths[1], widths[0]),
color);
}
if (widths[1] > 0)
gsk_ngl_render_job_draw_rect_with_color (job,
&GRAPHENE_RECT_INIT (origin->x + size->width - widths[1], origin->y, widths[1], size->height - widths[2]),
&colors[0]);
{
rgba_to_half (&colors[1], color);
gsk_ngl_render_job_draw_rect_with_color (job,
&GRAPHENE_RECT_INIT (origin->x + size->width - widths[1], origin->y, widths[1], size->height - widths[2]),
color);
}
if (widths[2] > 0)
gsk_ngl_render_job_draw_rect_with_color (job,
&GRAPHENE_RECT_INIT (origin->x + widths[3], origin->y + size->height - widths[2], size->width - widths[1], widths[2]),
&colors[0]);
{
rgba_to_half (&colors[2], color);
gsk_ngl_render_job_draw_rect_with_color (job,
&GRAPHENE_RECT_INIT (origin->x + widths[3], origin->y + size->height - widths[2], size->width - widths[1], widths[2]),
color);
}
if (widths[3] > 0)
gsk_ngl_render_job_draw_rect_with_color (job,
&GRAPHENE_RECT_INIT (origin->x, origin->y + widths[0], widths[3], size->height - widths[0]),
&colors[0]);
{
rgba_to_half (&colors[3], color);
gsk_ngl_render_job_draw_rect_with_color (job,
&GRAPHENE_RECT_INIT (origin->x, origin->y + widths[0], widths[3], size->height - widths[0]),
color);
}
gsk_ngl_render_job_end_draw (job);
}
@@ -1664,7 +1728,7 @@ gsk_ngl_render_job_visit_border_node (GskNglRenderJob *job,
const GskRenderNode *node)
{
const GskRoundedRect *rounded_outline = gsk_border_node_get_outline (node);
const GdkRGBA *c = gsk_border_node_get_colors (node);
const GdkRGBA *colors = gsk_border_node_get_colors (node);
const float *widths = gsk_border_node_get_widths (node);
struct {
float w;
@@ -1675,6 +1739,7 @@ gsk_ngl_render_job_visit_border_node (GskNglRenderJob *job,
float max_x = min_x + node->bounds.size.width;
float max_y = min_y + node->bounds.size.height;
GskRoundedRect outline;
guint16 color[4];
memset (sizes, 0, sizeof sizes);
@@ -1718,52 +1783,60 @@ gsk_ngl_render_job_visit_border_node (GskNglRenderJob *job,
{
GskNglDrawVertex *vertices = gsk_ngl_command_queue_add_vertices (job->command_queue);
vertices[0] = (GskNglDrawVertex) { { min_x, min_y }, { 0, 1 }, { c[0].red, c[0].green, c[0].blue, c[0].alpha } };
vertices[1] = (GskNglDrawVertex) { { min_x + sizes[0].w, min_y + sizes[0].h }, { 0, 0 }, { c[0].red, c[0].green, c[0].blue, c[0].alpha } };
vertices[2] = (GskNglDrawVertex) { { max_x, min_y }, { 1, 1 }, { c[0].red, c[0].green, c[0].blue, c[0].alpha } };
rgba_to_half (&colors[0], color);
vertices[3] = (GskNglDrawVertex) { { max_x - sizes[1].w, min_y + sizes[1].h }, { 1, 0 }, { c[0].red, c[0].green, c[0].blue, c[0].alpha } };
vertices[4] = (GskNglDrawVertex) { { min_x + sizes[0].w, min_y + sizes[0].h }, { 0, 0 }, { c[0].red, c[0].green, c[0].blue, c[0].alpha } };
vertices[5] = (GskNglDrawVertex) { { max_x, min_y }, { 1, 1 }, { c[0].red, c[0].green, c[0].blue, c[0].alpha } };
vertices[0] = (GskNglDrawVertex) { .position = { min_x, min_y }, .uv = { 0, 1 }, .color = { color[0], color[1], color[2], color[3] } };
vertices[1] = (GskNglDrawVertex) { .position = { min_x + sizes[0].w, min_y + sizes[0].h }, .uv = { 0, 0 }, .color = { color[0], color[1], color[2], color[3] } };
vertices[2] = (GskNglDrawVertex) { .position = { max_x, min_y }, .uv = { 1, 1 }, .color = { color[0], color[1], color[2], color[3] } };
vertices[3] = (GskNglDrawVertex) { .position = { max_x - sizes[1].w, min_y + sizes[1].h }, .uv = { 1, 0 }, .color = { color[0], color[1], color[2], color[3] } };
vertices[4] = (GskNglDrawVertex) { .position = { min_x + sizes[0].w, min_y + sizes[0].h }, .uv = { 0, 0 }, .color = { color[0], color[1], color[2], color[3] } };
vertices[5] = (GskNglDrawVertex) { .position = { max_x, min_y }, .uv = { 1, 1 }, .color = { color[0], color[1], color[2], color[3] } };
}
if (widths[1] > 0)
{
GskNglDrawVertex *vertices = gsk_ngl_command_queue_add_vertices (job->command_queue);
vertices[0] = (GskNglDrawVertex) { { max_x - sizes[1].w, min_y + sizes[1].h }, { 0, 1 }, { c[1].red, c[1].green, c[1].blue, c[1].alpha } };
vertices[1] = (GskNglDrawVertex) { { max_x - sizes[2].w, max_y - sizes[2].h }, { 0, 0 }, { c[1].red, c[1].green, c[1].blue, c[1].alpha } };
vertices[2] = (GskNglDrawVertex) { { max_x, min_y }, { 1, 1 }, { c[1].red, c[1].green, c[1].blue, c[1].alpha } };
rgba_to_half (&colors[1], color);
vertices[3] = (GskNglDrawVertex) { { max_x, max_y }, { 1, 0 }, { c[1].red, c[1].green, c[1].blue, c[1].alpha } };
vertices[4] = (GskNglDrawVertex) { { max_x - sizes[2].w, max_y - sizes[2].h }, { 0, 0 }, { c[1].red, c[1].green, c[1].blue, c[1].alpha } };
vertices[5] = (GskNglDrawVertex) { { max_x, min_y }, { 1, 1 }, { c[1].red, c[1].green, c[1].blue, c[1].alpha } };
vertices[0] = (GskNglDrawVertex) { .position = { max_x - sizes[1].w, min_y + sizes[1].h }, .uv = { 0, 1 }, .color = { color[0], color[1], color[2], color[3] } };
vertices[1] = (GskNglDrawVertex) { .position = { max_x - sizes[2].w, max_y - sizes[2].h }, .uv = { 0, 0 }, .color = { color[0], color[1], color[2], color[3] } };
vertices[2] = (GskNglDrawVertex) { .position = { max_x, min_y }, .uv = { 1, 1 }, .color = { color[0], color[1], color[2], color[3] } };
vertices[3] = (GskNglDrawVertex) { .position = { max_x, max_y }, .uv = { 1, 0 }, .color = { color[0], color[1], color[2], color[3] } };
vertices[4] = (GskNglDrawVertex) { .position = { max_x - sizes[2].w, max_y - sizes[2].h }, .uv = { 0, 0 }, .color = { color[0], color[1], color[2], color[3] } };
vertices[5] = (GskNglDrawVertex) { .position = { max_x, min_y }, .uv = { 1, 1 }, .color = { color[0], color[1], color[2], color[3] } };
}
if (widths[2] > 0)
{
GskNglDrawVertex *vertices = gsk_ngl_command_queue_add_vertices (job->command_queue);
vertices[0] = (GskNglDrawVertex) { { min_x + sizes[3].w, max_y - sizes[3].h }, { 0, 1 }, { c[2].red, c[2].green, c[2].blue, c[2].alpha } };
vertices[1] = (GskNglDrawVertex) { { min_x, max_y }, { 0, 0 }, { c[2].red, c[2].green, c[2].blue, c[2].alpha } };
vertices[2] = (GskNglDrawVertex) { { max_x - sizes[2].w, max_y - sizes[2].h }, { 1, 1 }, { c[2].red, c[2].green, c[2].blue, c[2].alpha } };
rgba_to_half (&colors[2], color);
vertices[3] = (GskNglDrawVertex) { { max_x, max_y }, { 1, 0 }, { c[2].red, c[2].green, c[2].blue, c[2].alpha } };
vertices[4] = (GskNglDrawVertex) { { min_x , max_y }, { 0, 0 }, { c[2].red, c[2].green, c[2].blue, c[2].alpha } };
vertices[5] = (GskNglDrawVertex) { { max_x - sizes[2].w, max_y - sizes[2].h }, { 1, 1 }, { c[2].red, c[2].green, c[2].blue, c[2].alpha } };
vertices[0] = (GskNglDrawVertex) { .position = { min_x + sizes[3].w, max_y - sizes[3].h }, .uv = { 0, 1 }, .color = { color[0], color[1], color[2], color[3] } };
vertices[1] = (GskNglDrawVertex) { .position = { min_x, max_y }, .uv = { 0, 0 }, .color = { color[0], color[1], color[2], color[3] } };
vertices[2] = (GskNglDrawVertex) { .position = { max_x - sizes[2].w, max_y - sizes[2].h }, .uv = { 1, 1 }, .color = { color[0], color[1], color[2], color[3] } };
vertices[3] = (GskNglDrawVertex) { .position = { max_x, max_y }, .uv = { 1, 0 }, .color = { color[0], color[1], color[2], color[3] } };
vertices[4] = (GskNglDrawVertex) { .position = { min_x , max_y }, .uv = { 0, 0 }, .color = { color[0], color[1], color[2], color[3] } };
vertices[5] = (GskNglDrawVertex) { .position = { max_x - sizes[2].w, max_y - sizes[2].h }, .uv = { 1, 1 }, .color = { color[0], color[1], color[2], color[3] } };
}
if (widths[3] > 0)
{
GskNglDrawVertex *vertices = gsk_ngl_command_queue_add_vertices (job->command_queue);
vertices[0] = (GskNglDrawVertex) { { min_x, min_y }, { 0, 1 }, { c[3].red, c[3].green, c[3].blue, c[3].alpha } };
vertices[1] = (GskNglDrawVertex) { { min_x, max_y }, { 0, 0 }, { c[3].red, c[3].green, c[3].blue, c[3].alpha } };
vertices[2] = (GskNglDrawVertex) { { min_x + sizes[0].w, min_y + sizes[0].h }, { 1, 1 }, { c[3].red, c[3].green, c[3].blue, c[3].alpha } };
rgba_to_half (&colors[3], color);
vertices[3] = (GskNglDrawVertex) { { min_x + sizes[3].w, max_y - sizes[3].h }, { 1, 0 }, { c[3].red, c[3].green, c[3].blue, c[3].alpha } };
vertices[4] = (GskNglDrawVertex) { { min_x, max_y }, { 0, 0 }, { c[3].red, c[3].green, c[3].blue, c[3].alpha } };
vertices[5] = (GskNglDrawVertex) { { min_x + sizes[0].w, min_y + sizes[0].h }, { 1, 1 }, { c[3].red, c[3].green, c[3].blue, c[3].alpha } };
vertices[0] = (GskNglDrawVertex) { .position = { min_x, min_y }, .uv = { 0, 1 }, .color = { color[0], color[1], color[2], color[3] } };
vertices[1] = (GskNglDrawVertex) { .position = { min_x, max_y }, .uv = { 0, 0 }, .color = { color[0], color[1], color[2], color[3] } };
vertices[2] = (GskNglDrawVertex) { .position = { min_x + sizes[0].w, min_y + sizes[0].h }, .uv = { 1, 1 }, .color = { color[0], color[1], color[2], color[3] } };
vertices[3] = (GskNglDrawVertex) { .position = { min_x + sizes[3].w, max_y - sizes[3].h }, .uv = { 1, 0 }, .color = { color[0], color[1], color[2], color[3] } };
vertices[4] = (GskNglDrawVertex) { .position = { min_x, max_y }, .uv = { 0, 0 }, .color = { color[0], color[1], color[2], color[3] } };
vertices[5] = (GskNglDrawVertex) { .position = { min_x + sizes[0].w, min_y + sizes[0].h }, .uv = { 1, 1 }, .color = { color[0], color[1], color[2], color[3] } };
}
gsk_ngl_render_job_end_draw (job);
@@ -1781,8 +1854,6 @@ gsk_ngl_render_job_visit_css_background (GskNglRenderJob *job,
const GskRenderNode *node2)
{
const GskRenderNode *child = gsk_rounded_clip_node_get_child (node);
const GdkRGBA *c2 = gsk_color_node_get_color (child);
const GdkRGBA *c = gsk_border_node_get_colors (node2);
const GskRoundedRect *rounded_outline = gsk_border_node_get_outline (node2);
const float *widths = gsk_border_node_get_widths (node2);
float min_x = job->offset_x + node2->bounds.origin.x;
@@ -1791,10 +1862,15 @@ gsk_ngl_render_job_visit_css_background (GskNglRenderJob *job,
float max_y = min_y + node2->bounds.size.height;
GskRoundedRect outline;
GskNglDrawVertex *vertices;
guint16 color[4];
guint16 color2[4];
if (node_is_invisible (node2))
return;
rgba_to_half (&gsk_border_node_get_colors (node2)[0], color);
rgba_to_half (gsk_color_node_get_color (child), color2);
gsk_ngl_render_job_transform_rounded_rect (job, rounded_outline, &outline);
gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, filled_border));
@@ -1809,12 +1885,12 @@ gsk_ngl_render_job_visit_css_background (GskNglRenderJob *job,
vertices = gsk_ngl_command_queue_add_vertices (job->command_queue);
vertices[0] = (GskNglDrawVertex) { { min_x, min_y }, { 0, 0 }, { c[0].red, c[0].green, c[0].blue, c[0].alpha }, { c2->red, c2->green, c2->blue, c2->alpha } };
vertices[1] = (GskNglDrawVertex) { { min_x, max_y }, { 0, 0 }, { c[0].red, c[0].green, c[0].blue, c[0].alpha }, { c2->red, c2->green, c2->blue, c2->alpha } };
vertices[2] = (GskNglDrawVertex) { { max_x, min_y }, { 0, 0 }, { c[0].red, c[0].green, c[0].blue, c[0].alpha }, { c2->red, c2->green, c2->blue, c2->alpha } };
vertices[3] = (GskNglDrawVertex) { { max_x, max_y }, { 0, 0 }, { c[0].red, c[0].green, c[0].blue, c[0].alpha }, { c2->red, c2->green, c2->blue, c2->alpha } };
vertices[4] = (GskNglDrawVertex) { { min_x, max_y }, { 0, 0 }, { c[0].red, c[0].green, c[0].blue, c[0].alpha }, { c2->red, c2->green, c2->blue, c2->alpha } };
vertices[5] = (GskNglDrawVertex) { { max_x, min_y }, { 0, 0 }, { c[0].red, c[0].green, c[0].blue, c[0].alpha }, { c2->red, c2->green, c2->blue, c2->alpha } };
vertices[0] = (GskNglDrawVertex) { .position = { min_x, min_y }, .color = { color[0], color[1], color[2], color[3] }, .color2 = { color2[0], color2[1], color2[2], color2[3] } };
vertices[1] = (GskNglDrawVertex) { .position = { min_x, max_y }, .color = { color[0], color[1], color[2], color[3] }, .color2 = { color2[0], color2[1], color2[2], color2[3] } };
vertices[2] = (GskNglDrawVertex) { .position = { max_x, min_y }, .color = { color[0], color[1], color[2], color[3] }, .color2 = { color2[0], color2[1], color2[2], color2[3] } };
vertices[3] = (GskNglDrawVertex) { .position = { max_x, max_y }, .color = { color[0], color[1], color[2], color[3] }, .color2 = { color2[0], color2[1], color2[2], color2[3] } };
vertices[4] = (GskNglDrawVertex) { .position = { min_x, max_y }, .color = { color[0], color[1], color[2], color[3] }, .color2 = { color2[0], color2[1], color2[2], color2[3] } };
vertices[5] = (GskNglDrawVertex) { .position = { max_x, min_y }, .color = { color[0], color[1], color[2], color[3] }, .color2 = { color2[0], color2[1], color2[2], color2[3] } };
gsk_ngl_render_job_end_draw (job);
}
@@ -1898,6 +1974,7 @@ gsk_ngl_render_job_visit_transform_node (GskNglRenderJob *job,
GskNglRenderOffscreen offscreen = {0};
offscreen.bounds = &child->bounds;
offscreen.force_offscreen = FALSE;
offscreen.reset_clip = TRUE;
if (!result_is_axis_aligned (transform, &child->bounds))
@@ -1938,6 +2015,7 @@ gsk_ngl_render_job_visit_unblurred_inset_shadow_node (GskNglRenderJob *job,
{
const GskRoundedRect *outline = gsk_inset_shadow_node_get_outline (node);
GskRoundedRect transformed_outline;
guint16 color[4];
gsk_ngl_render_job_transform_rounded_rect (job, outline, &transformed_outline);
@@ -1952,7 +2030,8 @@ gsk_ngl_render_job_visit_unblurred_inset_shadow_node (GskNglRenderJob *job,
UNIFORM_INSET_SHADOW_OFFSET, 0,
gsk_inset_shadow_node_get_dx (node),
gsk_inset_shadow_node_get_dy (node));
gsk_ngl_render_job_draw_rect_with_color (job, &node->bounds, gsk_inset_shadow_node_get_color (node));
rgba_to_half (gsk_inset_shadow_node_get_color (node), color);
gsk_ngl_render_job_draw_rect_with_color (job, &node->bounds, color);
gsk_ngl_render_job_end_draw (job);
}
@@ -1973,6 +2052,7 @@ gsk_ngl_render_job_visit_blurred_inset_shadow_node (GskNglRenderJob *job,
int blurred_texture_id;
GskTextureKey key;
GskNglRenderOffscreen offscreen = {0};
guint16 color[4];
g_assert (blur_radius > 0);
@@ -2052,9 +2132,10 @@ gsk_ngl_render_job_visit_blurred_inset_shadow_node (GskNglRenderJob *job,
UNIFORM_INSET_SHADOW_OFFSET, 0,
offset_x * scale_x,
offset_y * scale_y);
rgba_to_half (gsk_inset_shadow_node_get_color (node), color);
gsk_ngl_render_job_draw_with_color (job,
0, 0, texture_width, texture_height,
gsk_inset_shadow_node_get_color (node));
color);
gsk_ngl_render_job_end_draw (job);
gsk_ngl_render_job_pop_modelview (job);
@@ -2137,7 +2218,7 @@ gsk_ngl_render_job_visit_unblurred_outset_shadow_node (GskNglRenderJob *job,
float spread = gsk_outset_shadow_node_get_spread (node);
float dx = gsk_outset_shadow_node_get_dx (node);
float dy = gsk_outset_shadow_node_get_dy (node);
const GdkRGBA *color = gsk_outset_shadow_node_get_color (node);
guint16 color[4];
const float edge_sizes[] = { // Top, right, bottom, left
spread - dy, spread + dx, spread + dy, spread - dx
};
@@ -2148,6 +2229,8 @@ gsk_ngl_render_job_visit_unblurred_outset_shadow_node (GskNglRenderJob *job,
{ outline->corner[3].width + spread - dx, outline->corner[3].height + spread + dy },
};
rgba_to_half (gsk_outset_shadow_node_get_color (node), color);
gsk_ngl_render_job_transform_rounded_rect (job, outline, &transformed_outline);
gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, unblurred_outset_shadow));
@@ -2210,16 +2293,14 @@ static inline void
gsk_ngl_render_job_visit_blurred_outset_shadow_node (GskNglRenderJob *job,
const GskRenderNode *node)
{
static const GdkRGBA white = { 1, 1, 1, 1 };
const GskRoundedRect *outline = gsk_outset_shadow_node_get_outline (node);
const GdkRGBA *color = gsk_outset_shadow_node_get_color (node);
float scale_x = job->scale_x;
float scale_y = job->scale_y;
float blur_radius = gsk_outset_shadow_node_get_blur_radius (node);
float blur_extra = blur_radius * 2.0f; /* 2.0 = shader radius_multiplier */
float half_blur_extra = blur_extra / 2.0f;
int extra_blur_pixels = ceilf (half_blur_extra * scale_x);
int extra_blur_pixels_x = ceilf (half_blur_extra * scale_x);
int extra_blur_pixels_y = ceilf (half_blur_extra * scale_y);
float spread = gsk_outset_shadow_node_get_spread (node);
float dx = gsk_outset_shadow_node_get_dx (node);
float dy = gsk_outset_shadow_node_get_dy (node);
@@ -2230,13 +2311,26 @@ gsk_ngl_render_job_visit_blurred_outset_shadow_node (GskNglRenderJob *job,
int blurred_texture_id;
int cached_tid;
gboolean do_slicing;
guint16 color[4];
float half_width = outline->bounds.size.width / 2;
float half_height = outline->bounds.size.height / 2;
rgba_to_half (gsk_outset_shadow_node_get_color (node), color);
/* scaled_outline is the minimal outline we need to draw the given drop shadow,
* enlarged by the spread and offset by the blur radius. */
scaled_outline = *outline;
if (outline->bounds.size.width < blur_extra ||
outline->bounds.size.height < blur_extra)
outline->bounds.size.height < blur_extra ||
outline->corner[0].width >= half_width ||
outline->corner[1].width >= half_width ||
outline->corner[2].width >= half_width ||
outline->corner[3].width >= half_width ||
outline->corner[0].height >= half_height ||
outline->corner[1].height >= half_height ||
outline->corner[2].height >= half_height ||
outline->corner[3].height >= half_height)
{
do_slicing = FALSE;
gsk_rounded_rect_shrink (&scaled_outline, -spread, -spread, -spread, -spread);
@@ -2259,10 +2353,10 @@ gsk_ngl_render_job_visit_blurred_outset_shadow_node (GskNglRenderJob *job,
texture_width = (int)ceil ((scaled_outline.bounds.size.width + blur_extra) * scale_x);
texture_height = (int)ceil ((scaled_outline.bounds.size.height + blur_extra) * scale_y);
scaled_outline.bounds.origin.x = extra_blur_pixels;
scaled_outline.bounds.origin.y = extra_blur_pixels;
scaled_outline.bounds.size.width = texture_width - (extra_blur_pixels * 2);
scaled_outline.bounds.size.height = texture_height - (extra_blur_pixels * 2);
scaled_outline.bounds.origin.x = extra_blur_pixels_x;
scaled_outline.bounds.origin.y = extra_blur_pixels_y;
scaled_outline.bounds.size.width = texture_width - (extra_blur_pixels_x * 2);
scaled_outline.bounds.size.height = texture_height - (extra_blur_pixels_y * 2);
for (guint i = 0; i < G_N_ELEMENTS (scaled_outline.corner); i++)
{
@@ -2311,7 +2405,8 @@ gsk_ngl_render_job_visit_blurred_outset_shadow_node (GskNglRenderJob *job,
/* Draw the outline using color program */
gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, color));
gsk_ngl_render_job_draw_with_color (job, 0, 0, texture_width, texture_height, &white);
gsk_ngl_render_job_draw_with_color (job, 0, 0, texture_width, texture_height,
(guint16[]){ FP16_ONE, FP16_ONE, FP16_ONE, FP16_ONE });
gsk_ngl_render_job_end_draw (job);
/* Reset state from offscreen */
@@ -2349,7 +2444,7 @@ gsk_ngl_render_job_visit_blurred_outset_shadow_node (GskNglRenderJob *job,
float min_x = floorf (outline->bounds.origin.x - spread - half_blur_extra + dx);
float min_y = floorf (outline->bounds.origin.y - spread - half_blur_extra + dy);
offscreen.was_offscreen = FALSE;
offscreen.was_offscreen = TRUE;
offscreen.texture_id = blurred_texture_id;
init_full_texture_region (&offscreen);
@@ -2374,6 +2469,8 @@ gsk_ngl_render_job_visit_blurred_outset_shadow_node (GskNglRenderJob *job,
return;
}
/* slicing */
gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, outset_shadow));
gsk_ngl_program_set_uniform_texture (job->current_program,
UNIFORM_SHARED_SOURCE, 0,
@@ -2392,24 +2489,36 @@ gsk_ngl_render_job_visit_blurred_outset_shadow_node (GskNglRenderJob *job,
float max_y = ceilf (outline->bounds.origin.y + outline->bounds.size.height +
half_blur_extra + dy + spread);
const GskNglTextureNineSlice *slices;
float left_width, center_width, right_width;
float top_height, center_height, bottom_height;
GskNglTexture *texture;
texture = gsk_ngl_driver_get_texture_by_id (job->driver, blurred_texture_id);
slices = gsk_ngl_texture_get_nine_slice (texture, &scaled_outline, extra_blur_pixels);
slices = gsk_ngl_texture_get_nine_slice (texture, &scaled_outline, extra_blur_pixels_x, extra_blur_pixels_y);
offscreen.was_offscreen = TRUE;
/* Our texture coordinates MUST be scaled, while the actual vertex coords
* MUST NOT be scaled. */
* MUST NOT be scaled.
*/
left_width = slices[NINE_SLICE_TOP_LEFT].rect.width / scale_x;
right_width = slices[NINE_SLICE_TOP_RIGHT].rect.width / scale_x;
center_width = (max_x - min_x) - (left_width + right_width);
top_height = slices[NINE_SLICE_TOP_LEFT].rect.height / scale_y;
bottom_height = slices[NINE_SLICE_BOTTOM_LEFT].rect.height / scale_y;
center_height = (max_y - min_y) - (top_height + bottom_height);
/* Top left */
if (nine_slice_is_visible (&slices[NINE_SLICE_TOP_LEFT]))
{
memcpy (&offscreen.area, &slices[NINE_SLICE_TOP_LEFT].area, sizeof offscreen.area);
gsk_ngl_render_job_draw_offscreen_with_color (job,
&GRAPHENE_RECT_INIT (min_x, min_y,
slices[NINE_SLICE_TOP_LEFT].rect.width / scale_x,
slices[NINE_SLICE_TOP_LEFT].rect.height / scale_y),
&GRAPHENE_RECT_INIT (min_x,
min_y,
left_width,
top_height),
&offscreen,
color);
}
@@ -2418,13 +2527,11 @@ gsk_ngl_render_job_visit_blurred_outset_shadow_node (GskNglRenderJob *job,
if (nine_slice_is_visible (&slices[NINE_SLICE_TOP_CENTER]))
{
memcpy (&offscreen.area, &slices[NINE_SLICE_TOP_CENTER].area, sizeof offscreen.area);
float width = (max_x - min_x) - (slices[NINE_SLICE_TOP_LEFT].rect.width / scale_x +
slices[NINE_SLICE_TOP_RIGHT].rect.width / scale_x);
gsk_ngl_render_job_draw_offscreen_with_color (job,
&GRAPHENE_RECT_INIT (min_x + (slices[NINE_SLICE_TOP_LEFT].rect.width / scale_x),
&GRAPHENE_RECT_INIT (min_x + left_width,
min_y,
width,
slices[NINE_SLICE_TOP_CENTER].rect.height / scale_y),
center_width,
top_height),
&offscreen,
color);
}
@@ -2434,10 +2541,10 @@ gsk_ngl_render_job_visit_blurred_outset_shadow_node (GskNglRenderJob *job,
{
memcpy (&offscreen.area, &slices[NINE_SLICE_TOP_RIGHT].area, sizeof offscreen.area);
gsk_ngl_render_job_draw_offscreen_with_color (job,
&GRAPHENE_RECT_INIT (max_x - (slices[NINE_SLICE_TOP_RIGHT].rect.width / scale_x),
&GRAPHENE_RECT_INIT (max_x - right_width,
min_y,
slices[NINE_SLICE_TOP_RIGHT].rect.width / scale_x,
slices[NINE_SLICE_TOP_RIGHT].rect.height / scale_y),
right_width,
top_height),
&offscreen,
color);
}
@@ -2447,10 +2554,10 @@ gsk_ngl_render_job_visit_blurred_outset_shadow_node (GskNglRenderJob *job,
{
memcpy (&offscreen.area, &slices[NINE_SLICE_BOTTOM_RIGHT].area, sizeof offscreen.area);
gsk_ngl_render_job_draw_offscreen_with_color (job,
&GRAPHENE_RECT_INIT (max_x - (slices[NINE_SLICE_BOTTOM_RIGHT].rect.width / scale_x),
max_y - (slices[NINE_SLICE_BOTTOM_RIGHT].rect.height / scale_y),
slices[NINE_SLICE_BOTTOM_RIGHT].rect.width / scale_x,
slices[NINE_SLICE_BOTTOM_RIGHT].rect.height / scale_y),
&GRAPHENE_RECT_INIT (max_x - right_width,
max_y - bottom_height,
right_width,
bottom_height),
&offscreen,
color);
}
@@ -2461,9 +2568,9 @@ gsk_ngl_render_job_visit_blurred_outset_shadow_node (GskNglRenderJob *job,
memcpy (&offscreen.area, &slices[NINE_SLICE_BOTTOM_LEFT].area, sizeof offscreen.area);
gsk_ngl_render_job_draw_offscreen_with_color (job,
&GRAPHENE_RECT_INIT (min_x,
max_y - (slices[NINE_SLICE_BOTTOM_LEFT].rect.height / scale_y),
slices[NINE_SLICE_BOTTOM_LEFT].rect.width / scale_x,
slices[NINE_SLICE_BOTTOM_LEFT].rect.height / scale_y),
max_y - bottom_height,
left_width,
bottom_height),
&offscreen,
color);
}
@@ -2472,13 +2579,11 @@ gsk_ngl_render_job_visit_blurred_outset_shadow_node (GskNglRenderJob *job,
if (nine_slice_is_visible (&slices[NINE_SLICE_LEFT_CENTER]))
{
memcpy (&offscreen.area, &slices[NINE_SLICE_LEFT_CENTER].area, sizeof offscreen.area);
float height = (max_y - min_y) - (slices[NINE_SLICE_TOP_LEFT].rect.height / scale_y +
slices[NINE_SLICE_BOTTOM_LEFT].rect.height / scale_y);
gsk_ngl_render_job_draw_offscreen_with_color (job,
&GRAPHENE_RECT_INIT (min_x,
min_y + (slices[NINE_SLICE_TOP_LEFT].rect.height / scale_y),
slices[NINE_SLICE_LEFT_CENTER].rect.width / scale_x,
height),
min_y + top_height,
left_width,
center_height),
&offscreen,
color);
}
@@ -2487,13 +2592,11 @@ gsk_ngl_render_job_visit_blurred_outset_shadow_node (GskNglRenderJob *job,
if (nine_slice_is_visible (&slices[NINE_SLICE_RIGHT_CENTER]))
{
memcpy (&offscreen.area, &slices[NINE_SLICE_RIGHT_CENTER].area, sizeof offscreen.area);
float height = (max_y - min_y) - (slices[NINE_SLICE_TOP_RIGHT].rect.height / scale_y +
slices[NINE_SLICE_BOTTOM_RIGHT].rect.height / scale_y);
gsk_ngl_render_job_draw_offscreen_with_color (job,
&GRAPHENE_RECT_INIT (max_x - (slices[NINE_SLICE_RIGHT_CENTER].rect.width / scale_x),
min_y + (slices[NINE_SLICE_TOP_LEFT].rect.height / scale_y),
slices[NINE_SLICE_RIGHT_CENTER].rect.width / scale_x,
height),
&GRAPHENE_RECT_INIT (max_x - right_width,
min_y + top_height,
right_width,
center_height),
&offscreen,
color);
}
@@ -2502,13 +2605,11 @@ gsk_ngl_render_job_visit_blurred_outset_shadow_node (GskNglRenderJob *job,
if (nine_slice_is_visible (&slices[NINE_SLICE_BOTTOM_CENTER]))
{
memcpy (&offscreen.area, &slices[NINE_SLICE_BOTTOM_CENTER].area, sizeof offscreen.area);
float width = (max_x - min_x) - (slices[NINE_SLICE_BOTTOM_LEFT].rect.width / scale_x +
slices[NINE_SLICE_BOTTOM_RIGHT].rect.width / scale_x);
gsk_ngl_render_job_draw_offscreen_with_color (job,
&GRAPHENE_RECT_INIT (min_x + (slices[NINE_SLICE_BOTTOM_LEFT].rect.width / scale_x),
max_y - (slices[NINE_SLICE_BOTTOM_CENTER].rect.height / scale_y),
width,
slices[NINE_SLICE_BOTTOM_CENTER].rect.height / scale_y),
&GRAPHENE_RECT_INIT (min_x + left_width,
max_y - bottom_height,
center_width,
bottom_height),
&offscreen,
color);
}
@@ -2516,17 +2617,20 @@ gsk_ngl_render_job_visit_blurred_outset_shadow_node (GskNglRenderJob *job,
/* Middle */
if (nine_slice_is_visible (&slices[NINE_SLICE_CENTER]))
{
memcpy (&offscreen.area, &slices[NINE_SLICE_CENTER].area, sizeof offscreen.area);
float width = (max_x - min_x) - (slices[NINE_SLICE_LEFT_CENTER].rect.width / scale_x +
slices[NINE_SLICE_RIGHT_CENTER].rect.width / scale_x);
float height = (max_y - min_y) - (slices[NINE_SLICE_TOP_CENTER].rect.height / scale_y +
slices[NINE_SLICE_BOTTOM_CENTER].rect.height / scale_y);
gsk_ngl_render_job_draw_offscreen_with_color (job,
&GRAPHENE_RECT_INIT (min_x + (slices[NINE_SLICE_LEFT_CENTER].rect.width / scale_x),
min_y + (slices[NINE_SLICE_TOP_CENTER].rect.height / scale_y),
width, height),
&offscreen,
color);
if (!gsk_rounded_rect_contains_rect (outline, &GRAPHENE_RECT_INIT (min_x + left_width,
min_y + top_height,
center_width,
center_height)))
{
memcpy (&offscreen.area, &slices[NINE_SLICE_CENTER].area, sizeof offscreen.area);
gsk_ngl_render_job_draw_offscreen_with_color (job,
&GRAPHENE_RECT_INIT (min_x + left_width,
min_y + top_height,
center_width,
center_height),
&offscreen,
color);
}
}
}
@@ -2695,7 +2799,7 @@ gsk_ngl_render_job_visit_text_node (GskNglRenderJob *job,
guint last_texture = 0;
GskNglDrawVertex *vertices;
guint used = 0;
GdkRGBA c;
guint16 c[4] = { FP16_MINUS_ONE, FP16_MINUS_ONE, FP16_MINUS_ONE, FP16_MINUS_ONE };
const PangoGlyphInfo *gi;
guint i;
int yshift;
@@ -2707,10 +2811,8 @@ gsk_ngl_render_job_visit_text_node (GskNglRenderJob *job,
/* If the font has color glyphs, we don't need to recolor anything.
* We tell the shader by setting the color to vec4(-1).
*/
if (!force_color && gsk_text_node_has_color_glyphs (node))
c = (GdkRGBA) { -1.f, -1.f, -1.f, -1.f };
else
c = *color;
if (force_color || !gsk_text_node_has_color_glyphs (node))
rgba_to_half (color, c);
lookup.font = (PangoFont *)font;
lookup.scale = (guint) (text_scale * 1024);
@@ -2788,13 +2890,13 @@ gsk_ngl_render_job_visit_text_node (GskNglRenderJob *job,
glyph_x2 = glyph_x + glyph->ink_rect.width;
glyph_y2 = glyph_y + glyph->ink_rect.height;
*(vertices++) = (GskNglDrawVertex) { { glyph_x, glyph_y }, { tx, ty }, { c.red, c.green, c.blue, c.alpha } };
*(vertices++) = (GskNglDrawVertex) { { glyph_x, glyph_y2 }, { tx, ty2 }, { c.red, c.green, c.blue, c.alpha } };
*(vertices++) = (GskNglDrawVertex) { { glyph_x2, glyph_y }, { tx2, ty }, { c.red, c.green, c.blue, c.alpha } };
*(vertices++) = (GskNglDrawVertex) { .position = { glyph_x, glyph_y }, .uv = { tx, ty }, .color = { c[0], c[1], c[2], c[3] } };
*(vertices++) = (GskNglDrawVertex) { .position = { glyph_x, glyph_y2 }, .uv = { tx, ty2 }, .color = { c[0], c[1], c[2], c[3] } };
*(vertices++) = (GskNglDrawVertex) { .position = { glyph_x2, glyph_y }, .uv = { tx2, ty }, .color = { c[0], c[1], c[2], c[3] } };
*(vertices++) = (GskNglDrawVertex) { { glyph_x2, glyph_y2 }, { tx2, ty2 }, { c.red, c.green, c.blue, c.alpha } };
*(vertices++) = (GskNglDrawVertex) { { glyph_x, glyph_y2 }, { tx, ty2 }, { c.red, c.green, c.blue, c.alpha } };
*(vertices++) = (GskNglDrawVertex) { { glyph_x2, glyph_y }, { tx2, ty }, { c.red, c.green, c.blue, c.alpha } };
*(vertices++) = (GskNglDrawVertex) { .position = { glyph_x2, glyph_y2 }, .uv = { tx2, ty2 }, .color = { c[0], c[1], c[2], c[3] } };
*(vertices++) = (GskNglDrawVertex) { .position = { glyph_x, glyph_y2 }, .uv = { tx, ty2 }, .color = { c[0], c[1], c[2], c[3] } };
*(vertices++) = (GskNglDrawVertex) { .position = { glyph_x2, glyph_y }, .uv = { tx2, ty }, .color = { c[0], c[1], c[2], c[3] } };
batch->draw.vbo_count += GSK_NGL_N_VERTICES;
used++;
@@ -2827,6 +2929,7 @@ gsk_ngl_render_job_visit_shadow_node (GskNglRenderJob *job,
const float dy = shadow->dy;
GskNglRenderOffscreen offscreen = {0};
graphene_rect_t bounds;
guint16 color[4];
if (shadow->radius == 0 &&
gsk_render_node_get_node_type (shadow_child) == GSK_TEXT_NODE)
@@ -2889,7 +2992,8 @@ gsk_ngl_render_job_visit_shadow_node (GskNglRenderJob *job,
GL_TEXTURE_2D,
GL_TEXTURE0,
offscreen.texture_id);
gsk_ngl_render_job_draw_offscreen_with_color (job, &bounds, &offscreen, &shadow->color);
rgba_to_half (&shadow->color, color);
gsk_ngl_render_job_draw_offscreen_with_color (job, &bounds, &offscreen, color);
gsk_ngl_render_job_end_draw (job);
gsk_ngl_render_job_offset (job, -dx, -dy);
}
@@ -2946,7 +3050,7 @@ gsk_ngl_render_job_visit_blur_node (GskNglRenderJob *job,
gsk_ngl_render_job_draw_coords (job,
min_x, min_y, max_x, max_y,
0, 1, 1, 0,
&(GdkRGBA) { 0.f, 0.f, 0.f, 0.f } );
(guint16[]) { FP16_ZERO, FP16_ZERO, FP16_ZERO, FP16_ZERO } );
gsk_ngl_render_job_end_draw (job);
}
@@ -3052,10 +3156,10 @@ static inline void
gsk_ngl_render_job_visit_gl_shader_node_fallback (GskNglRenderJob *job,
const GskRenderNode *node)
{
static const GdkRGBA pink = { 255 / 255., 105 / 255., 180 / 255., 1.0 };
guint16 pink[4] = { 15360, 13975, 14758, 15360 }; /* 255 105 180 */
gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, color));
gsk_ngl_render_job_draw_rect_with_color (job, &node->bounds, &pink);
gsk_ngl_render_job_draw_rect_with_color (job, &node->bounds, pink);
gsk_ngl_render_job_end_draw (job);
}
@@ -3261,7 +3365,7 @@ gsk_ngl_render_job_visit_texture_node (GskNglRenderJob *job,
gsk_ngl_render_job_draw_coords (job,
x1, y1, x2, y2,
0, 0, 1, 1,
&(GdkRGBA) { 0.f, 0.f, 0.f, 0.f });
(guint16[]) { FP16_ZERO, FP16_ZERO, FP16_ZERO, FP16_ZERO });
}
gsk_ngl_render_job_end_draw (job);
@@ -3337,7 +3441,7 @@ gsk_ngl_render_job_visit_node (GskNglRenderJob *job,
if (node_is_invisible (node))
return;
if (!gsk_ngl_render_job_update_clip (job, node, &has_clip))
if (!gsk_ngl_render_job_update_clip (job, &node->bounds, &has_clip))
return;
switch (gsk_render_node_get_node_type (node))
@@ -3397,8 +3501,8 @@ gsk_ngl_render_job_visit_node (GskNglRenderJob *job,
if (gsk_render_node_get_node_type (grandchild) == GSK_COLOR_NODE &&
gsk_render_node_get_node_type (child2) == GSK_BORDER_NODE &&
gsk_border_node_get_uniform_color (child2) &&
gsk_rounded_rect_equal (gsk_rounded_clip_node_get_clip (child),
gsk_border_node_get_outline (child2)))
rounded_rect_equal (gsk_rounded_clip_node_get_clip (child),
gsk_border_node_get_outline (child2)))
{
gsk_ngl_render_job_visit_css_background (job, child, child2);
i++; /* skip the border node */
@@ -3624,6 +3728,13 @@ gsk_ngl_render_job_visit_node_with_offscreen (GskNglRenderJob *job,
render_target->framebuffer_id);
}
if (downscale_x != 1 || downscale_y != 1)
{
GskTransform *transform = gsk_transform_scale (NULL, downscale_x, downscale_y);
gsk_ngl_render_job_push_modelview (job, transform);
gsk_transform_unref (transform);
}
gsk_ngl_render_job_transform_bounds (job, offscreen->bounds, &viewport);
/* Code above will scale the size with the scale we use in the render ops,
* but for the viewport size, we need our own size limited by the texture size */
@@ -3632,8 +3743,6 @@ gsk_ngl_render_job_visit_node_with_offscreen (GskNglRenderJob *job,
gsk_ngl_render_job_set_viewport (job, &viewport, &prev_viewport);
gsk_ngl_render_job_set_projection_from_rect (job, &job->viewport, &prev_projection);
if (downscale_x != 1 || downscale_y != 1)
gsk_ngl_render_job_push_modelview (job, gsk_transform_scale (NULL, downscale_x, downscale_y));
prev_alpha = gsk_ngl_render_job_set_alpha (job, 1.0f);
prev_fbo = gsk_ngl_command_queue_bind_framebuffer (job->command_queue, render_target->framebuffer_id);

View File

@@ -202,6 +202,31 @@ gsk_ngl_shadow_library_lookup (GskNglShadowLibrary *self,
return ret->texture_id;
}
#if 0
static void
write_shadow_to_png (const Shadow *shadow)
{
int width = shadow->outline.bounds.size.width + (shadow->outline.bounds.origin.x * 2);
int height = shadow->outline.bounds.size.height + (shadow->outline.bounds.origin.y * 2);
int stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, width);
guchar *data = g_malloc (height * stride);
cairo_surface_t *s;
char *filename = g_strdup_printf ("shadow_cache_%d_%d_%d.png",
width, height, shadow->texture_id);
glBindTexture (GL_TEXTURE_2D, shadow->texture_id);
glGetTexImage (GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
s = cairo_image_surface_create_for_data (data, CAIRO_FORMAT_ARGB32,
width, height,
stride);
cairo_surface_write_to_png (s, filename);
cairo_surface_destroy (s);
g_free (data);
g_free (filename);
}
#endif
void
gsk_ngl_shadow_library_begin_frame (GskNglShadowLibrary *self)
{
@@ -211,6 +236,14 @@ gsk_ngl_shadow_library_begin_frame (GskNglShadowLibrary *self)
g_return_if_fail (GSK_IS_NGL_SHADOW_LIBRARY (self));
#if 0
for (i = 0, p = self->shadows->len; i < p; i++)
{
const Shadow *shadow = &g_array_index (self->shadows, Shadow, i);
write_shadow_to_png (shadow);
}
#endif
watermark = self->driver->current_frame_id - MAX_UNUSED_FRAMES;
for (i = 0, p = self->shadows->len; i < p; i++)

View File

@@ -20,6 +20,7 @@
#include "config.h"
#include <gdk/gdkglcontextprivate.h>
#include <gsk/gskdebugprivate.h>
#include "gsknglcommandqueueprivate.h"
@@ -239,6 +240,51 @@ gsk_ngl_texture_atlas_pack (GskNglTextureAtlas *self,
return rect.was_packed;
}
static void
gsk_ngl_texture_atlas_initialize (GskNglDriver *driver,
GskNglTextureAtlas *atlas)
{
/* Insert a single pixel at 0,0 for use in coloring */
gboolean packed G_GNUC_UNUSED;
int x, y;
guint gl_format;
guint gl_type;
guint8 pixel_data[4 * 3 * 3];
gdk_gl_context_push_debug_group_printf (gdk_gl_context_get_current (),
"Initializing Atlas");
packed = gsk_ngl_texture_atlas_pack (atlas, 3, 3, &x, &y);
g_assert (packed);
g_assert (x == 0 && y == 0);
memset (pixel_data, 255, sizeof pixel_data);
if (gdk_gl_context_get_use_es (gdk_gl_context_get_current ()))
{
gl_format = GL_RGBA;
gl_type = GL_UNSIGNED_BYTE;
}
else
{
gl_format = GL_BGRA;
gl_type = GL_UNSIGNED_INT_8_8_8_8_REV;
}
glBindTexture (GL_TEXTURE_2D, atlas->texture_id);
glTexSubImage2D (GL_TEXTURE_2D, 0,
0, 0,
3, 3,
gl_format, gl_type,
pixel_data);
gdk_gl_context_pop_debug_group (gdk_gl_context_get_current ());
driver->command_queue->n_uploads++;
}
static void
gsk_ngl_texture_atlases_pack (GskNglDriver *driver,
int width,
@@ -265,6 +311,8 @@ gsk_ngl_texture_atlases_pack (GskNglDriver *driver,
/* No atlas has enough space, so create a new one... */
atlas = gsk_ngl_driver_create_atlas (driver);
gsk_ngl_texture_atlas_initialize (driver, atlas);
/* Pack it onto that one, which surely has enough space... */
if (!gsk_ngl_texture_atlas_pack (atlas, width, height, &x, &y))
g_assert_not_reached ();

View File

@@ -170,7 +170,8 @@ gsk_ngl_texture_new (guint texture_id,
const GskNglTextureNineSlice *
gsk_ngl_texture_get_nine_slice (GskNglTexture *texture,
const GskRoundedRect *outline,
float extra_pixels)
float extra_pixels_x,
float extra_pixels_y)
{
g_assert (texture != NULL);
g_assert (outline != NULL);
@@ -180,7 +181,7 @@ gsk_ngl_texture_get_nine_slice (GskNglTexture *texture,
texture->nine_slice = g_new0 (GskNglTextureNineSlice, 9);
nine_slice_rounded_rect (texture->nine_slice, outline);
nine_slice_grow (texture->nine_slice, extra_pixels);
nine_slice_grow (texture->nine_slice, extra_pixels_x, extra_pixels_y);
nine_slice_to_texture_coords (texture->nine_slice, texture->width, texture->height);
}

View File

@@ -94,7 +94,8 @@ GskNglTexture *gsk_ngl_texture_new (guint
gint64 frame_id);
const GskNglTextureNineSlice *gsk_ngl_texture_get_nine_slice (GskNglTexture *texture,
const GskRoundedRect *outline,
float extra_pixels);
float extra_pixels_x,
float extra_pixels_y);
void gsk_ngl_texture_free (GskNglTexture *texture);
G_END_DECLS

View File

@@ -54,9 +54,11 @@ typedef struct _GskNglDriver GskNglDriver;
struct _GskNglDrawVertex
{
float position[2];
float uv[2];
float color[4];
float color2[4];
union {
float uv[2];
guint16 color2[4];
};
guint16 color[4];
};
G_END_DECLS

View File

@@ -159,121 +159,122 @@ nine_slice_to_texture_coords (GskNglTextureNineSlice *slices,
static inline void
nine_slice_grow (GskNglTextureNineSlice *slices,
int amount)
int amount_x,
int amount_y)
{
if (amount == 0)
if (amount_x == 0 && amount_y == 0)
return;
/* top left */
slices[0].rect.x -= amount;
slices[0].rect.y -= amount;
if (amount > slices[0].rect.width)
slices[0].rect.width += amount * 2;
slices[0].rect.x -= amount_x;
slices[0].rect.y -= amount_y;
if (amount_x > slices[0].rect.width)
slices[0].rect.width += amount_x * 2;
else
slices[0].rect.width += amount;
slices[0].rect.width += amount_x;
if (amount > slices[0].rect.height)
slices[0].rect.height += amount * 2;
if (amount_y > slices[0].rect.height)
slices[0].rect.height += amount_y * 2;
else
slices[0].rect.height += amount;
slices[0].rect.height += amount_y;
/* Top center */
slices[1].rect.y -= amount;
if (amount > slices[1].rect.height)
slices[1].rect.height += amount * 2;
slices[1].rect.y -= amount_y;
if (amount_y > slices[1].rect.height)
slices[1].rect.height += amount_y * 2;
else
slices[1].rect.height += amount;
slices[1].rect.height += amount_y;
/* top right */
slices[2].rect.y -= amount;
if (amount > slices[2].rect.width)
slices[2].rect.y -= amount_y;
if (amount_x > slices[2].rect.width)
{
slices[2].rect.x -= amount;
slices[2].rect.width += amount * 2;
slices[2].rect.x -= amount_x;
slices[2].rect.width += amount_x * 2;
}
else
{
slices[2].rect.width += amount;
slices[2].rect.width += amount_x;
}
if (amount > slices[2].rect.height)
slices[2].rect.height += amount * 2;
if (amount_y > slices[2].rect.height)
slices[2].rect.height += amount_y * 2;
else
slices[2].rect.height += amount;
slices[2].rect.height += amount_y;
slices[3].rect.x -= amount;
if (amount > slices[3].rect.width)
slices[3].rect.width += amount * 2;
slices[3].rect.x -= amount_x;
if (amount_x > slices[3].rect.width)
slices[3].rect.width += amount_x * 2;
else
slices[3].rect.width += amount;
slices[3].rect.width += amount_x;
/* Leave center alone */
if (amount > slices[5].rect.width)
if (amount_x > slices[5].rect.width)
{
slices[5].rect.x -= amount;
slices[5].rect.width += amount * 2;
slices[5].rect.x -= amount_x;
slices[5].rect.width += amount_x * 2;
}
else
{
slices[5].rect.width += amount;
slices[5].rect.width += amount_x;
}
/* Bottom left */
slices[6].rect.x -= amount;
if (amount > slices[6].rect.width)
slices[6].rect.x -= amount_x;
if (amount_x > slices[6].rect.width)
{
slices[6].rect.width += amount * 2;
slices[6].rect.width += amount_x * 2;
}
else
{
slices[6].rect.width += amount;
slices[6].rect.width += amount_x;
}
if (amount > slices[6].rect.height)
if (amount_y > slices[6].rect.height)
{
slices[6].rect.y -= amount;
slices[6].rect.height += amount * 2;
slices[6].rect.y -= amount_y;
slices[6].rect.height += amount_y * 2;
}
else
{
slices[6].rect.height += amount;
slices[6].rect.height += amount_y;
}
/* Bottom center */
if (amount > slices[7].rect.height)
if (amount_y > slices[7].rect.height)
{
slices[7].rect.y -= amount;
slices[7].rect.height += amount * 2;
slices[7].rect.y -= amount_y;
slices[7].rect.height += amount_y * 2;
}
else
{
slices[7].rect.height += amount;
slices[7].rect.height += amount_y;
}
if (amount > slices[8].rect.width)
if (amount_x > slices[8].rect.width)
{
slices[8].rect.x -= amount;
slices[8].rect.width += amount * 2;
slices[8].rect.x -= amount_x;
slices[8].rect.width += amount_x * 2;
}
else
{
slices[8].rect.width += amount;
slices[8].rect.width += amount_x;
}
if (amount > slices[8].rect.height)
if (amount_y > slices[8].rect.height)
{
slices[8].rect.y -= amount;
slices[8].rect.height += amount * 2;
slices[8].rect.y -= amount_y;
slices[8].rect.height += amount_y * 2;
}
else
{
slices[8].rect.height += amount;
slices[8].rect.height += amount_y;
}
#ifdef DEBUG_NINE_SLICE

Some files were not shown because too many files have changed in this diff Show More