Commit Graph

34 Commits

Author SHA1 Message Date
Timm Bäder
ca4ae81170 transform: Compare class before ->next 2020-01-07 17:27:18 +01:00
Timm Bäder
766d4dff76 GskTransform: Compute sin/deg of 90deg rotations manually
Otherwise we might end up with inaccuracies, e.g. when
gsk_transform_transform_bounds()'ing bounds.
2020-01-07 17:27:17 +01:00
Timm Bäder
e62f135c6a GskTransform: Normalize angles
Make sure all angles are in the [0..365) range
2020-01-07 17:27:17 +01:00
Timm Bäder
6c90d3a1b6 gsktransform: Fix documentation comment
There is no @m.
2019-09-09 17:36:23 +02:00
Rico Tzschichholz
5504c62af9 gsk: Add missing 'transfer full' annotations of instance parameters
Fixes https://gitlab.gnome.org/GNOME/gtk/issues/2107
2019-08-26 18:05:17 +02:00
Timm Bäder
dbc49e7742 transform: Fix identity transform fast paths
Returning an extra ref will cause leaks later.
2019-07-07 07:24:00 +02:00
Timm Bäder
3bc3e140dd transform: Add transform_bounds fast path for 2D_AFFINE transforms
E.g. anything involving a scale. This is important when e.g. scrolling
in the node list in the recorder, which scales every recorded node down
to fit in the list.
2019-06-29 09:49:38 +02:00
Timm Bäder
8dd74eac2e transform: Add skew parsing 2019-06-29 07:15:43 +02:00
Matthias Clasen
206970c1e8 Merge branch 'transform-tests' into 'master'
Transform tests

See merge request GNOME/gtk!910
2019-06-03 16:41:17 +00:00
Matthias Clasen
4ed57449ba gsk: Fix printing of identity transforms
These need to print as "none", otherwise
the parser does not accept them.
2019-06-03 16:20:38 +00:00
Matthias Clasen
d93fb5a3fa Cosmetics
Fix up a variable name mismatch in GskTransform docs.
2019-06-03 16:15:16 +00:00
Timm Bäder
a1161456ff GskTransform: NULL is a valid transform 2019-06-03 17:36:31 +02:00
Timm Bäder
05ca772631 GskTransform: Ignore identity transforms
We often end up with e.g. a scale of 1 or a translation by 0/0. Ignore
those transforms since they don't do anything.
2019-06-03 17:03:02 +02:00
Benjamin Otte
5a0c8805fc transform: Coalesce similar transforms
If somebody does a transform like
  scale(5) scale(10) translate(1,1) translate(5,0)
store it instead as
  scale(50) translate(6,1)
This way, less memory is consumed and transforms are easier to read.

In particular, this simplifies the typical transforms we do in GTK,
which are just one translation after another.
2019-06-02 21:18:56 +02:00
Benjamin Otte
69629ebb1a transform: Treat 0 perspective transforms as identity
This happens if you apply a perspective transform and its inverse, which
is the negative version of the perspective.
2019-06-02 15:12:37 +02:00
Matthias Clasen
3f940715e4 gsk: Documentation tweaks
Add some missing symbols.
2019-05-01 23:24:14 -04:00
Emmanuele Bassi
cf9deb7cf5 Use getters for translation and scaling components
Instead of accessing the matrix cells directly.
2019-04-29 02:26:31 +02:00
Emmanuele Bassi
40beb69487 Never compare floats for equality
Floating point values cannot ever be compared for equality. GLib has a
G_APPROX_VALUE macro that lets us compare two value within a provided
precision, so we should use that instead.
2019-04-29 02:26:31 +02:00
Emmanuele Bassi
f1cadee196 Use matrix equality in GskTransform
Graphene has new API to check for equality, so we should use it instead
of doing a byte-by-byte comparison.
2019-04-29 02:26:31 +02:00
Emmanuele Bassi
478fdaa632 Use atomic boxing instead of manual refcounting
Artisanal, homegrown, locally sourced, vegan reference counting has been
replaced by the appropriate API in GLib, which does small things like
saturation and type checking.
2019-04-29 02:25:18 +02:00
Benjamin Otte
8001c7d972 transform: Add gsk_transform_parse()
It uses the new CSS parser.
2019-04-12 19:34:29 +02:00
Bastien Nocera
884088f649 gsk: API docs fixes
gsk/gskenums.h:181: Error: Gsk: multiple "@GSK_TRANSFORM_CATEGORY_2D" parameters for identifier "GskTransformCategory":
 * @GSK_TRANSFORM_CATEGORY_2D: The matrix is a 2D matrix. This is equivalent
    ^
gsk/gsktransform.c:1342: Warning: Gsk: gsk_transform_to_2d: unknown parameter 'm' in documentation comment, should be 'self'
gsk/gsktransform.c:1368: Warning: Gsk: gsk_transform_to_2d: invalid return annotation
gsk/gsktransform.c:1461: Warning: Gsk: gsk_transform_to_translate: unknown parameter 'm' in documentation comment, should be 'self'
2019-03-07 16:29:28 +01:00
Benjamin Otte
3a3b325f8e transform: Add perspective()
This commit adds gsk_transform_perspective(), gtk_snapshot_perspective()
and support for perspective() in the CSS syntax.
2019-03-05 20:46:00 +01:00
Benjamin Otte
a8bf5eee0f transform: Readd optimization
This is the optimization from bbd4e2f60d
2019-03-04 23:41:51 +01:00
Benjamin Otte
bd113aa85c transform: Redo querying API
Make the API expect a tranform of the proper category instead of
doing the check ourselves and returning TRUE/FALSE.

The benefit is that the mai use case is switch (transform->category)
statements and in those we know the category and don't need to check
TRUE/FALSE.

Using the wrong matrix will now cause a g_warning().
2019-03-04 23:41:51 +01:00
Benjamin Otte
1fecbd4241 transform: Store the category in the transform
... instead of computing it every time we need it.

This should be faster and we want to use it a lot more prominently.

Also, we have the struct memory available anyway.
2019-03-04 23:41:51 +01:00
Benjamin Otte
3545abc7a1 transform: Implement gsk_transform_invert()
And use it.

And test it.
2019-03-04 23:41:51 +01:00
Benjamin Otte
70b341139b transform: Remove gsk_transform_identity()
This used to be a good idea back when GskTransform was intended to be
used for transitions, but without it, it's not anymore.
2019-03-04 23:41:51 +01:00
Benjamin Otte
e737b42113 trasnform: Fix print statement
We were printing the wrong variable.
2019-03-04 23:15:24 +01:00
Benjamin Otte
cf00c36c85 transform: Split rotate() and rotate3d() class
This is mainly for accuracy: We can guarantee the math we do for 2D
rotations results in a 2D matrix.
2019-03-04 23:15:24 +01:00
Benjamin Otte
3cc84d2860 transform: Make category public API
Also rename it from GskMatrixCategory to GskTransformCategory.
2019-03-04 23:15:24 +01:00
Benjamin Otte
791bf0c2eb transform: Remove API to poke internals
It is not interesting to users of GskTransform how it is made up
internally. Users should just use the gsk_transform_to_*() APIs.
2019-03-04 23:15:24 +01:00
Benjamin Otte
4916280883 transform: Add more API
In particular, add a per-category querying API for the matrix:
- gsk_transform_to_translate()
- gsk_transform_to_affine()
- gsk_transform_to_2d()
- gsk_transform_to_matrix()

This way, code can use the relevant one for the given category.
2019-03-04 23:15:06 +01:00
Benjamin Otte
0e1a50366a transform: Move to GSK
The renaming of the prefix makes this a large patch.
2019-03-04 23:09:02 +01:00