Commit Graph

62 Commits

Author SHA1 Message Date
Matthias Clasen
dd16d7c4c8 gsk: Serialize float textures as tiff
Otherwise, we lose precision when converting them
to 16bit integers.
2022-05-13 12:34:24 -04:00
Benjamin Otte
c97a758aa7 cssparser: Remove unused argument
The base_directory argument is never used. So don't have it.
2021-10-28 03:19:08 +02:00
Matthias Clasen
c77b5c46a3 rendernodeparser: Avoid gdk_texture_new_for_pixbuf
We can just use gdk_texture_new_from_bytes here now.

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

Update affected test output.
2021-09-17 00:25:22 +02:00
Benjamin Otte
56b31c3923 rendernodeparser: Handle is_color attribute for glyphs 2021-09-16 23:59:37 +02:00
Benjamin Otte
ca3d942b9b rendernodeparser: Remove leftover debug prints 2021-07-14 20:19:40 +02:00
Benjamin Otte
5470a1344d rendernodeparser: Don't use %g when writing file
%g is locale dependent and can add "," where "." should be. Use
string_append_double() instead.
2021-07-14 20:18:44 +02:00
Matthias Clasen
2d266d107b gsk: Clean up docs syntax
Replace leftover gtk-doc syntax (#Type) with backquotes.
2021-05-22 17:25:26 -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
124f60593b nodeparser: Print debug message before child
This puts the message up top, where it can be seen,
and not at the other end of an endless tree of children.

Update tests to match.
2021-03-09 12:15:25 -05:00
Matthias Clasen
96ac85038b rendernode: Fix glyph serialization
We serializing to a string of ASCII, we need to
escape some chars, such as '\' and '"'.

Fixes: #3710
2021-03-02 11:32:29 -05:00
Matthias Clasen
20fb155e8c gsk: Fix render node serialization
When looking for ascii glyphs, we must match
the pango shape flags that GTK is using.
2021-01-28 18:19:42 -05:00
Matthias Clasen
9cec9e4ce2 gsk: Export the glyph serialization privately
We want to use the same serialization in the inspector,
so export this function.
2020-12-21 13:11:08 -05:00
Matthias Clasen
26119af7a6 gsk: Improve glyph serialization
The special case for ASCII glyphs is unfortunately not
working very well, because of an oversight in pango:
When I added subpixel positioning, I made pango_shape()
default to not rounding, and make PangoLayout call
pango_shape_with_flags() and pass the rounding information
down. The upshot is that we need to use the _with_flags
variant here and tell it to round position, so it matches
what the text node contains.
2020-12-21 13:08:34 -05:00
Matthias Clasen
aa95ae774f gsk: Fix serialization of glyphs
We were forgetting to put a space between two numbers
in some cases, confusing the parser.

Test included.

Fixes: #3496
2020-12-21 10:49:56 -05:00
Benjamin Otte
55a242bd81 gsk: Add GskConicGradientNode 2020-12-03 00:47:54 +01:00
Benjamin Otte
71cb7c2063 rendernodeparser: Split out a function 2020-12-02 21:48:35 +01:00
Benjamin Otte
1c7daece7a Merge branch 'wip/otte/for-master' into 'master'
Wip/otte/for master

See merge request GNOME/gtk!2855
2020-11-17 19:08:01 +00:00
Benjamin Otte
f2284ff40f rendernode: Rename all gsk_render_node_peek_*() functions
Those are getters, they should be gsk_render_node_get_*() functions.
2020-11-17 19:04:39 +01:00
Matthias Clasen
121e61cf01 gsk: Avoid using gtk css types in public api
Using GtkCssSection in public headers here may be
ok from the C perspective, since it all ends up in
the same library anyway. But it causes circular
dependency problems for our gir files that are still
split by namespace.

To avoid this problem, copy the GtkCssLocation struct
struct as GskParseLocation, and pass take two of them
instead of a GtkCssSection in the error callback.

Update all users.

Fixes: #2454
2020-11-16 23:27:44 -05:00
Matthias Clasen
cef1cd19ff gsk: Avoid long lines in serialized nodes
When encoding big blobs of data in base64, insert newlines.
Base64 allows it, CSS allows it, so not need to make GtkTextView
struggle with multi-megabyte lines.

Update nodeparser tests to reflect this change.
2020-10-03 13:10:55 -04:00
Matthias Clasen
a9809b0f67 Allow inserting newlines in css strings
Rename _gtk_css_print_string to strip the _ and add
an insert_newlines argument to it. Update all callers,
and make the render node serializer insert newlines.
2020-10-02 23:40:16 -04:00
Matthias Clasen
9033336a23 css: Move _gtk_css_print_string around
Move this to a separate header, since it is not
parser functionality, and kill the duplicate
gtkcssparserprivate.h header.
2020-10-02 23:40:16 -04:00
Alexander Larsson
7ea755e206 Add GskGLShaderNode and GskGLShader
A GskGLShader is an abstraction of a GLSL fragment shader that
can produce pixel values given inputs:
 * N (currently max 4) textures
 * Current arguments for the shader uniform
Uniform types are: float,(u)int,bool,vec234)
There is also a builder for the uniform arguments which are
passed around as immutable GBytes in the built form.

A GskGLShaderNode is a render node that renders a GskGLShader inside a
specified rectangular bounds. It renders its child nodes as textures
and passes those as texture arguments to the shader. You also pass it
a uniform arguments object.
2020-09-29 09:51:16 +02:00
Timm Bäder
dbfc172f6a radial gradients: Allow 0 start/end values 2020-09-18 15:39:07 +02:00
Timm Bäder
6a089816fc gsk: Parse radial gradient nodes 2020-09-18 15:39:07 +02:00
Matthias Clasen
ebfb3e771d rendernode: switch to h/vradius 2020-09-18 15:39:04 +02:00
Matthias Clasen
0c6226c20b gsk: Add a radial gradient node
Only a fallback implementation for now.

Fixes #2262
2020-09-18 15:38:55 +02:00
Matthias Clasen
929a56e53c Clean up lots of GTK+ -> GTK
Replace most remaining uses of GTK+ in the docs and
user-visible strings by GTK. Also remove some leftover
"Was added in 3.x" sentences from the docs.
2020-09-12 12:01:04 -04:00
Matthias Clasen
d83df5a928 gsk: Fix a typo
We were checking x_offset twice, when we meant to check
x_offset and y_offset. Pointed out by Rafał Mikrut.

Fixes: #2726
2020-05-09 19:40:06 -04:00
Emmanuele Bassi
d701a89281 Turn GskRenderNode into a derivable type
Language bindings—especially ones based on introspection—cannot deal
with custom type hiearchies. Luckily for us, GType has a derivable type
with low overhead: GTypeInstance.

By turning GskRenderNode into a GTypeInstance, and creating derived
types for each class of node, we can provide an introspectable API to
our non-C API consumers, with no functional change to the C API itself.
2020-04-08 15:40:15 +01:00
Timm Bäder
d7df56b6cb gsk: Make GskColorStop.offset a float
Doesn't make sense for this to be double if everything else is float.
Also makes it possible to 'easily' pass this to the GPU.
2020-01-07 17:27:16 +01:00
Timm Bäder
ecc40cf115 rendernodeparser: Only report a GError* if we have one 2019-11-19 09:37:26 +01:00
Timm Bäder
3d7817154c rendernodeparser: Handle resolving NULL urls 2019-11-19 09:37:03 +01:00
Matthias Clasen
8ccf2a722a gsk: Stop using deprecated pango api
Shape engines are not used anymore.
2019-11-01 13:01:54 -04:00
Timm Bäder
6e47ebe030 rendernodeparser: Fix a memory leak when parsing glyphs 2019-07-21 09:06:50 +02:00
Timm Bäder
9728dabf12 rendernodeparser: Fix a memory leak when parsing textures 2019-07-21 09:06:29 +02:00
Timm Bäder
984dff54ab rendernodeparser: fix typo 2019-07-13 11:12:47 +02:00
Benjamin Otte
d81cf5a443 rendernodeparser: Handle Cairo being stupid
Cairo writes to finished streams, so we have to make sure to keep the
stream around to allow it to do that.
2019-06-03 17:22:11 +02:00
Benjamin Otte
53f23f8ae9 rendernodeparser: Handle empty Cairo nodes
Cairo nodes can contain a NULL surface if they have never been drawn to.
Make this the default Cairo node.
2019-05-30 15:32:36 +02:00
Benjamin Otte
1e0c0c0ba7 rendernodeparser: Parse cairo script
Use cairo-script-interpreter to parse the scripts that generate cairo
nodes.

This requires libcairoscriptinterpreter.so to work properly, but if
it isn't found we disable this (unimportant for normal functioning)
code and just emits a parser warning.
The testsuite requires it however or it will fail.

A new test is included that tests all of this.
2019-05-30 15:32:36 +02:00
Benjamin Otte
89fb752a8f css: Use %f, not %.17f
The testusite failures explain why:
We don't want to print "1.00000000000000000", but "1".
2019-05-29 14:30:13 +02:00
Benjamin Otte
9ee2b23176 rendernodeparser: Handle repeating linear gradients
Just handle them like regular gradients, only name them differently.
2019-05-29 07:14:31 +02:00
Benjamin Otte
d71c196c5c css: Don't print numbers with exponent
CSS does not do exponents, so printing numbers close to 0 as 1.234e-15
does not work.

Also up the accuracy to 17 digits because that's what everyone else
uses.
2019-05-29 07:14:31 +02:00
Benjamin Otte
928c85ccc3 rendernodeparser: Parse Cairo nodes
We also print the script, but we don't parse it yet.
2019-05-26 00:50:13 +02:00
Benjamin Otte
b90a66cab5 rendernodeparser: Allow parsing strings
Instead of only allowing for glyph indexes, allow ASCII characters as
replacements. So this glyph sequence
  glyphs: 65 8, 66 8, 67 8
Can be replaced by
  glyphs: "ABC"
provided that the glyph for "A", "B" and "C" are 65, 66 and 67
respectively and their advance is exactly 8.
x offset and y offset must always be 0 and every glyph must start a
cluster.
2019-05-21 06:43:59 +02:00
Benjamin Otte
1a65a6ce76 rendernodeparser: Update to new rules
Update to the docs outlined in #1887.

In particular, the changes do:

1. Require no property, have a working default for everything
2. Be clear about what gets printed and how.

Tests ahve been adapted to still pass.
2019-05-21 06:43:59 +02:00
Benjamin Otte
678aa8088f rgba: Add GDK_RGBA() macro
So far it's private, but it's a pretty cute way to use hex colors, so we
might conside making it public.
2019-05-21 06:43:59 +02:00
Benjamin Otte
a1d08b4b52 rendernode: Take a graphene_point_t for the offset
... instead of 2 floats.
2019-05-21 06:43:59 +02:00
Benjamin Otte
20d1bc2ccc rendernodeparser: Skip root node when it's a container
When printing, behave the same way as when parsing:
Magically skip a container node if there is one - just like the
parser magically creates a container node to hold all the nodes
it parses.
2019-05-21 06:43:59 +02:00