Commit Graph

38 Commits

Author SHA1 Message Date
Matthias Clasen
06423d807f Revert "gtk: Pass font options along"
This reverts commit 062a15310a.
2021-09-04 15:42:05 -04:00
Matthias Clasen
062a15310a gtk: Pass font options along
Pass the widget's font options along when we
are creating text nodes.
2021-09-03 12:52:05 -04:00
Matthias Clasen
91f7b9663f gtk: Clean up docs syntax
Replace leftover gtk-doc syntax (#Type) with backquotes.
2021-05-22 17:25:26 -04: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
Timm Bäder
e90f5e8a20 gskpango: Don't copy fg color
No need to do that here, we copy it in to the individual render nodes
anyway.
2020-12-21 15:23:25 +01:00
Timm Bäder
98b99201b0 gskpango: Remove bounds rect
We only need this to render shapes and trapezoids, i.e. only when
falling back to cairo. Remove code to measure the layout and convert the
ink_rect to a graphene_rect_t from gtk_snapshot_append_layout() and do
it when drawing shapes and trapezoids instead.
2020-12-21 12:56:38 +01:00
Timm Bäder
bce4d669ee gskpango: Fix a potential cairo_t leak
The previous early return did not cairo_destroy() it.
2020-12-21 12:49:06 +01:00
Benjamin Otte
8dad615f04 gtk: Remove unused header include
gtkcssnodeprivate.h was mainly used for repositioning CSS nodes in
gadgets, and gadgets are gone now.
2020-10-20 04:50:12 +02:00
Benjamin Otte
3078b180fe Replace "gdouble" with "double" 2020-07-25 00:47:36 +02:00
Timm Bäder
34976a791c gskpango: Make get_color a bit shorter
Don't copy from crenderer->fg_color just to override from the local
color again.
2020-05-05 08:20:09 +02:00
Alexander Larsson
7c73f2fb02 GskPango: Allow specifying a custom shape snapshot handler
We will need this for GtkTextView to render the textures in it.
2020-02-06 17:47:56 +01:00
Matthias Clasen
10e4c04e61 Use style values directly
Replace uses of gtk_css_style_get_value with direct access,
throughout the tree. We don't replace all uses, just those
where we are dealing with a fixed property. Be careful to
handle the currentColor special case for color properties.
2020-01-29 11:07:32 +01:00
Matthias Clasen
4b63523b1f gskpango: Don't free rgba's we don't own
We don't copy them anymore, so don't free them.
2020-01-27 13:35:04 -05:00
Matthias Clasen
731ae8f39e gskpango: Stop using style context getters
Just go to the css nodes directly.
2020-01-25 14:18:22 -05:00
Matthias Clasen
30f55c4d07 Remove a redundant vfunc
PangoRenderer has a perfectly adequate default
implementation of draw_glyphs, no need to duplicate that.
2019-07-23 23:28:24 -04:00
Matthias Clasen
3278e9ab6c Render error underlines as render nodes
Use a sequence of transformed squares,
instead of a cairo node. The drawing is not
identical to the previous code, but reasonably
close.
2019-07-23 18:31:39 -04:00
Christian Hergert
4ff9163c47 textview: port GtkTextView to GskPangoRenderer
This removes the use of GtkTextDisplay (a PangoRenderer) to use
the GskPangoRender which generates render nodes. Part of this means
improving the GskPangoRenderer to support the necessary features for
displaying a GtkTextView.

Primarily, this is a merging of GtkTextDisplay features into
GskPangoRender. Additionally, GtkTextDisplay was removed to allow for
gtk_text_layout_snapshot() to be implemented elsewhere.
2019-07-21 16:03:45 -07:00
Benjamin Otte
0d119f81c8 snapshot: Refactor text rendering
The code didn't change, it was just shuffled around to make the
with_bounds() versions of the text rendering unnecessary and instead
pass through the generic append_node() path.
2019-02-21 19:47:28 +01:00
Benjamin Otte
fba0b359d4 css: Report sizes as absolute
All PangoFontDescriptions that GTK creates now use
pango_font_description_set_absolute_size().
2018-07-04 06:15:33 +02:00
Benjamin Otte
73b4a62f51 snapshot: Redo debug messages
Instead of every snapshot function having debug messages, have an
explicit gtk_snapshot_push_debug() function that appends a debug node.
2018-04-24 04:06:58 +02:00
Timm Bäder
4f3c7cd48a gsk: Make gsk_text_node_new_with_bounds private
We pulled out the bounds calculation for performance reasons, but the
caller can't know how to properly compute them. Inside gtk+, we can do
that but it's not good enough for public API.
2018-04-21 11:20:15 +02:00
Benjamin Otte
2db43edbd6 snapshot: Don't handle clip anymore
If widgets want to clip things, they now need to do it themselves.

By not taking care of clip, we avoid the need to track clip. And by not
tracking clip, we can avoid all unnecessary cache invalidations that we
were doing for render nodes whenever the clip changed.

And when you are scrolling, the clip changes *a lot*.
2018-04-17 23:21:37 +02:00
Benjamin Otte
278ab3c4de snapshot: Track clip as a rect only 2018-04-05 14:56:38 +02:00
Benjamin Otte
9b83116fcb snapshot: Export gtk_snapshot_append_layout()
This is the equivalent snapshot function to pango_cairo_show_layout().

Not to be confused with gtk_snapshot_render_layout(), which is the
equivalent to gtk_render_layout().
2018-03-26 18:16:36 +02:00
Benjamin Otte
e6d24f4c15 snapshot: Make gtk_snapshot_append_node() take care of offset
Push an offset node when append_node is called. That resets the offset.
2018-03-26 18:16:36 +02:00
Matthias Clasen
d55da3fd44 Use GtkSnapshot getters
We can avoid direct struct access and gtksnapshotprivate.h
everywhere.
2018-03-11 00:31:44 -05:00
Timm Bäder
8a062f4f9a gskpango: Don't create text nodes for clipped text
Measure the text here directly and check if the created node bounds will
be clipped away before even creating the text node.
2018-03-04 19:15:03 +01:00
Chun-wei Fan
a687fd9aeb gtk/gskpango.c: Use g_snprintf()
This fixes the build of GTK+ master on Visual Studio 2013 (and possibly
others) as snprintf() may not be supported even if the required C99
features are supported by the compiler.

https://bugzilla.gnome.org/show_bug.cgi?id=773299
2017-11-21 14:22:23 +08:00
Matthias Clasen
b0e8d8483d More work on text nodes
This commit takes several steps towards rendering text
like we want to.

The creation of the cairo surface and texture is moved
to the backend (in GskVulkanRenderer). We add a mask
shader that is used in the next text pipeline to use
the texture as a mask, like cairo_mask_surface does.
There is a separate color text pipeline that uses the
already existing blend shaders to use the texture as
a source, like cairo_paint does.

The text node api is simplified to have just a single
offset, which determines the left end of the text baseline,
like all our other text drawing APIs.
2017-09-10 14:36:26 -04:00
Chun-wei Fan
1b7f08171a gskpango.c: Include cairo.h consistently
The other source files use "#include <cairo.h>", so we should do
likewise.

https://bugzilla.gnome.org/show_bug.cgi?id=773299
2017-09-06 10:42:32 +08:00
Matthias Clasen
d281cd7498 Fix a compiler warning 2017-09-03 19:53:29 -04:00
Matthias Clasen
59b1206468 Avoid empty nodes another way
Make gsk_text_node_new return NULL if the extents are empty.
2017-09-03 19:35:02 -04:00
Matthias Clasen
7bb202e4a2 Add a workaround for vulkan crashes
I see 'out of memory' errors and crashes inside libvulkan when
creating nodes that have empty bounds and end up in the fallback
paths, like a shadow around an empty text node. Prevent this
by not creating text nodes in that case.
2017-09-03 11:57:21 -04:00
Matthias Clasen
eab50246e1 Only record node names when we should
This is the same thing we do for render nodes elsewhere.
2017-09-03 10:30:32 -04:00
Matthias Clasen
1440bb25de Fix text colors
This was lost in some reshuffling of the gskpango branch.
2017-09-01 14:12:20 -04:00
Matthias Clasen
f199f7b87b Fix the build 2017-09-01 13:42:43 -04:00
Matthias Clasen
a367d34949 Use a text render node in GskPangoRenderer
This pushes the rendering closer to the place where we can
insert a texture atlas for glyph caching.
2017-09-01 13:30:03 -04:00
Matthias Clasen
82e8f3a542 Add a Pango renderer
Copy the PangoCairoRenderer into GTK+, rename it to GskPangoRenderer,
and strip it down far enough to build without private pango apis.
This means we currently don't support hexboxes or shapes.

Currently, this lives in gtk, but it might be nicer to put it
in gsk eventually.
2017-09-01 13:30:03 -04:00