Compare commits

..

27 Commits

Author SHA1 Message Date
Benjamin Otte 3a8db343b8 wip: Add a cube stack transition 2019-03-05 20:44:45 +01:00
Benjamin Otte 08d904a732 transform: Add perspective()
This commit adds gsk_transform_perspective() as well ass support for
perspective() in the CSS syntax.
2019-03-05 20:44:41 +01:00
Benjamin Otte dbe58452d7 rendernode: Implement diffing of transform nodes
This reinstates diffing in the same way that it worked for offset nodes.

It would be possible to add diffing for affine transforms or even all
transforms, but I think this is unnecessary right now - and also quite
expensive to compute.
2019-03-04 23:41:51 +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 b391aea2b3 widget: Make transform a GskTransform
This concludes pushing transforms down into GskTransform.

What's remaining is potentially pushing it further into the renderers.
2019-03-04 23:41:51 +01:00
Benjamin Otte 979e9bec27 testsuite: Add a transforms test
In particular, check that to_matrix() and to_2d(), to_affine() and
to_translate() return the same values.

This also requires a recent Graphene version or the tests will fail.
2019-03-04 23:41:27 +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 3a3c2d14ab rendernode: Make the transform node take a GskTransform
This is an attempt to push GskTransform deeper into the stack.
2019-03-04 23:15:07 +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
Matthias Clasen 20f7588a84 Merge branch 'adwaita-typo-fix-master' into 'master'
Adwaita: Fix typo (missing comma)

Closes #1713

See merge request GNOME/gtk!618
2019-03-04 17:36:10 +00:00
Christoph Reiter 348912dff4 treeview: make sure separator nodes have a height > 0
In case the theme doesn't set a height/min-height for the treeview
separator the treeview drawing gets confused and draws rows on top of each
other depending on the redraw area.

This is due to gtk_tree_view_get_row_height() assuming that a node with a
height <= 0 is not set and not a separator and it will default to the
expander size.

Ideally gtk_tree_view_get_row_height() would know if it operates on a separator,
but there are too many calls/levels, so just make sure the separator height
is at least 1 (Adwaita already sets "min-height: 2px", so no change there)

Cherry-picked from !614 to master
2019-03-04 17:07:13 +01:00
Alex Monday 610692d07b Adwaita: Fix typo (missing comma)
Closes https://gitlab.gnome.org/GNOME/gtk/issues/1713


(cherry picked from commit 0b61d6f6ae)
2019-03-04 15:58:15 +00:00
Emmanuele Bassi 45ea288ba2 Merge branch 'notebook-notify-page-not-child' into 'master'
notebook: Notify the notebook page, not the child

See merge request GNOME/gtk!616
2019-03-04 11:35:18 +00:00
Matthias Clasen b79545e83c search entry: Fix a copy-paste error 2019-03-03 22:56:02 -05:00
Matthias Clasen 02318dbda7 entries: Fix mnemonic activation
Since entries are no longer can-focus, the default
mnemonic_activate handler refuses to act on them.
2019-03-03 22:25:52 -05:00
Peter Bloomfield afbfccb89e notebook: Notify the notebook page, not the child
Call g_object_notify() on the GtkNotebookPage, not the child GtkWidget.
Fixes some issues in !594.
2019-03-03 18:21:10 -05:00
Benjamin Otte bed4c68041 widget: Fix gtk_widget_pick() on 3d-transformed widgets
Picking is done by drawing a line along the parent's z axis and picking
at the intersection with the child's z=0 plane.

However, the previous code was casting a ray along the child's z axis.

This patch actually transforms the line to pick into the target's
coordinate system and then computes the corrrect intersection with the
z=0 plane.

Using graphene_point3d_interpolate() to compute the final intersection
point is a bit of abuse of that function, but I found no better way in
Graphene to achieve the same thing.
2019-03-03 19:50:59 +01:00
Matthias Clasen 8ceff21497 gtk-demo: Minimally fix the sarch entry demo
This was broken by the entry refactoring.
2019-03-03 12:43:00 -05:00
Matej Urbančič 4fe67310fb Updated Slovenian translation 2019-03-02 20:57:57 +01:00
100 changed files with 2903 additions and 3314 deletions
+4 -1
View File
@@ -246,7 +246,10 @@ do_search_entry (GtkWidget *do_widget)
gtk_container_add (GTK_CONTAINER (vbox), hbox);
/* Create our entry */
entry = gtk_search_entry_new ();
entry = gtk_entry_new ();
gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
GTK_ENTRY_ICON_PRIMARY,
"edit-find-symbolic");
gtk_container_add (GTK_CONTAINER (hbox), entry);
/* Create the find and cancel buttons */
+1 -1
View File
@@ -48,7 +48,7 @@ change_transition_state (GSimpleAction *action,
GtkStackTransitionType transition;
if (g_variant_get_boolean (state))
transition = GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT;
transition = GTK_STACK_TRANSITION_TYPE_CUBE;
else
transition = GTK_STACK_TRANSITION_TYPE_NONE;
+1 -1
View File
@@ -429,7 +429,7 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<property name="margin">10</property>
<child>
<object class="GtkStack" id="toplevel_stack">
<property name="transition-duration">30000</property>
<property name="transition-duration">3000</property>
<child>
<object class="GtkStackPage">
<property name="name">page1</property>
+1
View File
@@ -18,6 +18,7 @@
<title>API Reference</title>
<xi:include href="xml/GskRenderer.xml" />
<xi:include href="xml/GskRenderNode.xml" />
<xi:include href="xml/GskTransform.xml" />
</reference>
<index id="api-index-full">
+38
View File
@@ -144,3 +144,41 @@ gsk_rounded_rect_contains_point
gsk_rounded_rect_contains_rect
gsk_rounded_rect_intersects_rect
</SECTION>
<SECTION>
<FILE>GskTransform</FILE>
<TITLE>3D transformations</TITLE>
GskTransform
gsk_transform_ref
gsk_transform_unref
<SUBSECTION>
GskTransformCategory
gsk_transform_get_category
<SUBSECTION>
gsk_transform_print
gsk_transform_to_string
gsk_transform_to_matrix
gsk_transform_to_2d
gsk_transform_to_affine
gsk_transform_to_translate
<SUBSECTION>
gsk_transform_transform
gsk_transform_invert
gsk_transform_matrix
gsk_transform_translate
gsk_transform_translate_3d
gsk_transform_rotate
gsk_transform_rotate_3d
gsk_transform_scale
gsk_transform_scale_3d
gsk_transform_perspective
<SUBSECTION>
gsk_transform_equal
<SUBSECTION>
gsk_transform_transform_bounds
<SUBSECTION Private>
GSK_TYPE_TRANSFORM
gsk_transform_get_type
gsk_transform_new
</SECTION>
-1
View File
@@ -345,7 +345,6 @@
<xi:include href="xml/gtkselection.xml" />
<xi:include href="xml/gtktesting.xml" />
<xi:include href="xml/filesystem.xml" />
<xi:include href="xml/gtktransform.xml" />
</part>
<part id="theming">
+1 -32
View File
@@ -4388,6 +4388,7 @@ gtk_snapshot_rotate
gtk_snapshot_rotate_3d
gtk_snapshot_scale
gtk_snapshot_scale_3d
gtk_snapshot_perspective
gtk_snapshot_append_node
gtk_snapshot_append_cairo
gtk_snapshot_append_texture
@@ -5867,38 +5868,6 @@ gtk_mount_operation_get_type
GtkMountOperationPrivate
</SECTION>
<SECTION>
<FILE>gtktransform</FILE>
<TITLE>3D transformations</TITLE>
GtkTransformType
GtkTransform
gtk_transform_ref
gtk_transform_unref
<SUBSECTION>
gtk_transform_print
gtk_transform_to_string
gtk_transform_to_matrix
<SUBSECTION>
gtk_transform_identity
gtk_transform_transform
gtk_transform_matrix
gtk_transform_translate
gtk_transform_translate_3d
gtk_transform_rotate
gtk_transform_rotate_3d
gtk_transform_scale
gtk_transform_scale_3d
<SUBSECTION>
gtk_transform_equal
<SUBSECTION>
gtk_transform_get_transform_type
gtk_transform_get_next
<SUBSECTION Private>
GTK_TYPE_TRANSFORM
gdk_transform_get_type
gtk_transform_new
</SECTION>
<SECTION>
<FILE>gtkorientable</FILE>
<TITLE>Orientable</TITLE>
+24 -16
View File
@@ -8,13 +8,14 @@
#include "gskglprofilerprivate.h"
#include "gskprofilerprivate.h"
#include "gskrendererprivate.h"
#include "gskrendernodeprivate.h"
#include "gsktransformprivate.h"
#include "gskshaderbuilderprivate.h"
#include "gskglglyphcacheprivate.h"
#include "gskglrenderopsprivate.h"
#include "gskcairoblurprivate.h"
#include "gskglshadowcacheprivate.h"
#include "gskglnodesampleprivate.h"
#include "gsktransform.h"
#include "gskprivate.h"
@@ -794,20 +795,21 @@ render_transform_node (GskGLRenderer *self,
GskRenderNode *node,
RenderOpBuilder *builder)
{
const GskMatrixCategory category = gsk_transform_node_get_category (node);
const graphene_matrix_t *node_transform = gsk_transform_node_peek_transform (node);
GskTransform *node_transform = gsk_transform_node_get_transform (node);
const GskTransformCategory category = gsk_transform_get_category (node_transform);
GskRenderNode *child = gsk_transform_node_get_child (node);
switch (category)
{
case GSK_MATRIX_CATEGORY_IDENTITY:
case GSK_TRANSFORM_CATEGORY_IDENTITY:
gsk_gl_renderer_add_render_ops (self, child, builder);
break;
case GSK_MATRIX_CATEGORY_2D_TRANSLATE:
case GSK_TRANSFORM_CATEGORY_2D_TRANSLATE:
{
const float dx = graphene_matrix_get_value (node_transform, 3, 0);
const float dy = graphene_matrix_get_value (node_transform, 3, 1);
float dx, dy;
gsk_transform_to_translate (node_transform, &dx, &dy);
ops_offset (builder, dx, dy);
gsk_gl_renderer_add_render_ops (self, child, builder);
@@ -815,17 +817,21 @@ render_transform_node (GskGLRenderer *self,
}
break;
case GSK_MATRIX_CATEGORY_2D_AFFINE:
case GSK_TRANSFORM_CATEGORY_2D_AFFINE:
{
ops_push_modelview (builder, node_transform, category);
graphene_matrix_t mat;
gsk_transform_to_matrix (node_transform, &mat);
ops_push_modelview (builder, &mat, category);
gsk_gl_renderer_add_render_ops (self, child, builder);
ops_pop_modelview (builder);
}
break;
case GSK_MATRIX_CATEGORY_UNKNOWN:
case GSK_MATRIX_CATEGORY_ANY:
case GSK_MATRIX_CATEGORY_INVERTIBLE:
case GSK_TRANSFORM_CATEGORY_UNKNOWN:
case GSK_TRANSFORM_CATEGORY_ANY:
case GSK_TRANSFORM_CATEGORY_3D:
case GSK_TRANSFORM_CATEGORY_2D:
default:
{
const float min_x = child->bounds.origin.x;
@@ -834,8 +840,10 @@ render_transform_node (GskGLRenderer *self,
const float max_y = min_y + child->bounds.size.height;
int texture_id;
gboolean is_offscreen;
graphene_matrix_t mat;
ops_push_modelview (builder, node_transform, category);
gsk_transform_to_matrix (node_transform, &mat);
ops_push_modelview (builder, &mat, category);
if (node_supports_transform (child))
{
@@ -1416,7 +1424,7 @@ render_outset_shadow_node (GskGLRenderer *self,
op.op = OP_CLEAR;
ops_add (builder, &op);
prev_projection = ops_set_projection (builder, &item_proj);
ops_set_modelview (builder, &identity, GSK_MATRIX_CATEGORY_IDENTITY);
ops_set_modelview (builder, &identity, GSK_TRANSFORM_CATEGORY_IDENTITY);
prev_viewport = ops_set_viewport (builder, &GRAPHENE_RECT_INIT (0, 0, texture_width, texture_height));
/* Draw outline */
@@ -2634,7 +2642,7 @@ add_offscreen_ops (GskGLRenderer *self,
op.op = OP_CLEAR;
ops_add (builder, &op);
prev_projection = ops_set_projection (builder, &item_proj);
ops_set_modelview (builder, &identity, GSK_MATRIX_CATEGORY_IDENTITY);
ops_set_modelview (builder, &identity, GSK_TRANSFORM_CATEGORY_IDENTITY);
prev_viewport = ops_set_viewport (builder,
&GRAPHENE_RECT_INIT (bounds->origin.x * scale,
bounds->origin.y * scale,
@@ -2895,7 +2903,7 @@ gsk_gl_renderer_do_render (GskRenderer *renderer,
render_op_builder.current_opacity = 1.0f;
render_op_builder.render_ops = self->render_ops;
ops_set_modelview (&render_op_builder, &modelview,
scale_factor == 1 ? GSK_MATRIX_CATEGORY_IDENTITY : GSK_MATRIX_CATEGORY_2D_AFFINE);
scale_factor == 1 ? GSK_TRANSFORM_CATEGORY_IDENTITY : GSK_TRANSFORM_CATEGORY_2D_AFFINE);
/* Initial clip is self->render_region! */
if (self->render_region != NULL)
+16 -14
View File
@@ -65,22 +65,23 @@ extract_matrix_metadata (const graphene_matrix_t *m,
{
switch (md->category)
{
case GSK_MATRIX_CATEGORY_IDENTITY:
case GSK_TRANSFORM_CATEGORY_IDENTITY:
md->scale_x = 1;
md->scale_y = 1;
break;
case GSK_MATRIX_CATEGORY_2D_TRANSLATE:
case GSK_TRANSFORM_CATEGORY_2D_TRANSLATE:
md->translate_x = graphene_matrix_get_value (m, 3, 0);
md->translate_y = graphene_matrix_get_value (m, 3, 1);
md->scale_x = 1;
md->scale_y = 1;
break;
case GSK_MATRIX_CATEGORY_UNKNOWN:
case GSK_MATRIX_CATEGORY_ANY:
case GSK_MATRIX_CATEGORY_INVERTIBLE:
case GSK_MATRIX_CATEGORY_2D_AFFINE:
case GSK_TRANSFORM_CATEGORY_UNKNOWN:
case GSK_TRANSFORM_CATEGORY_ANY:
case GSK_TRANSFORM_CATEGORY_3D:
case GSK_TRANSFORM_CATEGORY_2D:
case GSK_TRANSFORM_CATEGORY_2D_AFFINE:
{
graphene_vec3_t col1;
graphene_vec3_t col2;
@@ -121,21 +122,22 @@ ops_transform_bounds_modelview (const RenderOpBuilder *builder,
switch (head->metadata.category)
{
case GSK_MATRIX_CATEGORY_IDENTITY:
case GSK_TRANSFORM_CATEGORY_IDENTITY:
*dst = *src;
break;
case GSK_MATRIX_CATEGORY_2D_TRANSLATE:
case GSK_TRANSFORM_CATEGORY_2D_TRANSLATE:
*dst = *src;
dst->origin.x += head->metadata.translate_x;
dst->origin.y += head->metadata.translate_y;
break;
/* TODO: Handle scale */
case GSK_MATRIX_CATEGORY_2D_AFFINE:
case GSK_MATRIX_CATEGORY_UNKNOWN:
case GSK_MATRIX_CATEGORY_ANY:
case GSK_MATRIX_CATEGORY_INVERTIBLE:
case GSK_TRANSFORM_CATEGORY_UNKNOWN:
case GSK_TRANSFORM_CATEGORY_ANY:
case GSK_TRANSFORM_CATEGORY_3D:
case GSK_TRANSFORM_CATEGORY_2D:
case GSK_TRANSFORM_CATEGORY_2D_AFFINE:
default:
graphene_matrix_transform_bounds (builder->current_modelview,
src,
@@ -333,7 +335,7 @@ ops_set_modelview_internal (RenderOpBuilder *builder,
void
ops_set_modelview (RenderOpBuilder *builder,
const graphene_matrix_t *mv,
GskMatrixCategory mv_category)
GskTransformCategory mv_category)
{
MatrixStackEntry *entry;
@@ -363,7 +365,7 @@ ops_set_modelview (RenderOpBuilder *builder,
void
ops_push_modelview (RenderOpBuilder *builder,
const graphene_matrix_t *mv,
GskMatrixCategory mv_category)
GskTransformCategory mv_category)
{
float scale = ops_get_scale (builder);
MatrixStackEntry *entry;
+3 -3
View File
@@ -25,7 +25,7 @@ typedef struct
float dx_before;
float dy_before;
GskMatrixCategory category;
GskTransformCategory category;
} OpsMatrixMetadata;
typedef struct
@@ -281,10 +281,10 @@ void ops_dump_framebuffer (RenderOpBuilder *builder,
void ops_finish (RenderOpBuilder *builder);
void ops_push_modelview (RenderOpBuilder *builder,
const graphene_matrix_t *mv,
GskMatrixCategory mv_category);
GskTransformCategory mv_category);
void ops_set_modelview (RenderOpBuilder *builder,
const graphene_matrix_t *mv,
GskMatrixCategory mv_category);
GskTransformCategory mv_category);
void ops_pop_modelview (RenderOpBuilder *builder);
float ops_get_scale (const RenderOpBuilder *builder);
+1
View File
@@ -24,6 +24,7 @@
#include <gsk/gskrenderer.h>
#include <gsk/gskrendernode.h>
#include <gsk/gskroundedrect.h>
#include <gsk/gsktransform.h>
#include <gsk/gsktypes.h>
#include <gsk/gskenumtypes.h>
+38
View File
@@ -170,4 +170,42 @@ typedef enum {
GSK_SERIALIZATION_INVALID_DATA
} GskSerializationError;
/**
* GskTransformCategory:
* @GSK_TRANSFORM_CATEGORY_UNKNOWN: The category of the matrix has not been
* determined.
* @GSK_TRANSFORM_CATEGORY_ANY: Analyzing the matrix concluded that it does
* not fit in any other category.
* @GSK_TRANSFORM_CATEGORY_2D: The matrix is a 3D matrix. This means that
* the w column (the last column) has the values (0, 0, 0, 1).
* @GSK_TRANSFORM_CATEGORY_2D: The matrix is a 2D matrix. This is equivalent
* to graphene_matrix_is_2d() returning %TRUE. In particular, this
* means that Cairo can deal with the matrix.
* @GSK_TRANSFORM_CATEGORY_2D_AFFINE: The matrix is a combination of 2D scale
* and 2D translation operations. In particular, this means that any
* rectangle can be transformed exactly using this matrix.
* @GSK_TRANSFORM_CATEGORY_2D_TRANSLATE: The matrix is a 2D translation.
* @GSK_TRANSFORM_CATEGORY_IDENTITY: The matrix is the identity matrix.
*
* The categories of matrices relevant for GSK and GTK. Note that any
* category includes matrices of all later categories. So if you want
* to for example check if a matrix is a 2D matrix,
* `category >= GSK_TRANSFORM_CATEGORY_2D` is the way to do this.
*
* Also keep in mind that rounding errors may cause matrices to not
* conform to their categories. Otherwise, matrix operations done via
* mutliplication will not worsen categories. So for the matrix
* multiplication `C = A * B`, `category(C) = MIN (category(A), category(B))`.
*/
typedef enum
{
GSK_TRANSFORM_CATEGORY_UNKNOWN,
GSK_TRANSFORM_CATEGORY_ANY,
GSK_TRANSFORM_CATEGORY_3D,
GSK_TRANSFORM_CATEGORY_2D,
GSK_TRANSFORM_CATEGORY_2D_AFFINE,
GSK_TRANSFORM_CATEGORY_2D_TRANSLATE,
GSK_TRANSFORM_CATEGORY_IDENTITY
} GskTransformCategory;
#endif /* __GSK_TYPES_H__ */
+39 -5
View File
@@ -42,7 +42,6 @@
#include "gskdebugprivate.h"
#include "gskrendererprivate.h"
#include "gskrendernodeparserprivate.h"
#include <graphene-gobject.h>
@@ -329,11 +328,19 @@ gsk_render_node_diff (GskRenderNode *node1,
GBytes *
gsk_render_node_serialize (GskRenderNode *node)
{
GVariant *node_variant, *variant;
GBytes *result;
char *str;
str = gsk_render_node_serialize_to_string (node);
result = g_bytes_new_take (str, strlen (str));
node_variant = gsk_render_node_serialize_node (node);
variant = g_variant_new ("(suuv)",
GSK_RENDER_NODE_SERIALIZATION_ID,
(guint32) GSK_RENDER_NODE_SERIALIZATION_VERSION,
(guint32) gsk_render_node_get_node_type (node),
node_variant);
result = g_variant_get_data_as_bytes (variant);
g_variant_unref (variant);
return result;
}
@@ -390,9 +397,36 @@ GskRenderNode *
gsk_render_node_deserialize (GBytes *bytes,
GError **error)
{
char *id_string;
guint32 version, node_type;
GVariant *variant, *node_variant;
GskRenderNode *node = NULL;
node = gsk_render_node_deserialize_from_string ((const char *)g_bytes_get_data (bytes, NULL));
variant = g_variant_new_from_bytes (G_VARIANT_TYPE ("(suuv)"), bytes, FALSE);
g_variant_get (variant, "(suuv)", &id_string, &version, &node_type, &node_variant);
if (!g_str_equal (id_string, GSK_RENDER_NODE_SERIALIZATION_ID))
{
g_set_error (error, GSK_SERIALIZATION_ERROR, GSK_SERIALIZATION_UNSUPPORTED_FORMAT,
"Data not in GskRenderNode serialization format.");
goto out;
}
if (version != GSK_RENDER_NODE_SERIALIZATION_VERSION)
{
g_set_error (error, GSK_SERIALIZATION_ERROR, GSK_SERIALIZATION_UNSUPPORTED_VERSION,
"Format version %u not supported.", version);
goto out;
}
node = gsk_render_node_deserialize_node (node_type, node_variant, error);
out:
g_free (id_string);
g_variant_unref (node_variant);
g_variant_unref (variant);
return node;
}
+2 -3
View File
@@ -196,12 +196,11 @@ GskRenderNode * gsk_container_node_get_child (GskRenderNode
GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_transform_node_new (GskRenderNode *child,
const graphene_matrix_t *transform);
GskTransform *transform);
GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_transform_node_get_child (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
const graphene_matrix_t *
gsk_transform_node_peek_transform (GskRenderNode *node);
GskTransform * gsk_transform_node_get_transform (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_opacity_node_new (GskRenderNode *child,
+103 -87
View File
@@ -25,6 +25,7 @@
#include "gskdiffprivate.h"
#include "gskrendererprivate.h"
#include "gskroundedrectprivate.h"
#include "gsktransformprivate.h"
#include "gdk/gdktextureprivate.h"
@@ -2387,8 +2388,7 @@ struct _GskTransformNode
GskRenderNode render_node;
GskRenderNode *child;
graphene_matrix_t transform;
GskMatrixCategory category;
GskTransform *transform;
};
static void
@@ -2397,6 +2397,7 @@ gsk_transform_node_finalize (GskRenderNode *node)
GskTransformNode *self = (GskTransformNode *) node;
gsk_render_node_unref (self->child);
gsk_transform_unref (self->transform);
}
static void
@@ -2404,23 +2405,87 @@ gsk_transform_node_draw (GskRenderNode *node,
cairo_t *cr)
{
GskTransformNode *self = (GskTransformNode *) node;
float xx, yx, xy, yy, dx, dy;
cairo_matrix_t ctm;
if (graphene_matrix_to_2d (&self->transform, &ctm.xx, &ctm.yx, &ctm.xy, &ctm.yy, &ctm.x0, &ctm.y0))
{
GSK_NOTE (CAIRO, g_message ("CTM = { .xx = %g, .yx = %g, .xy = %g, .yy = %g, .x0 = %g, .y0 = %g }",
ctm.xx, ctm.yx,
ctm.xy, ctm.yy,
ctm.x0, ctm.y0));
cairo_transform (cr, &ctm);
gsk_render_node_draw (self->child, cr);
}
else
if (gsk_transform_get_category (self->transform) < GSK_TRANSFORM_CATEGORY_2D)
{
cairo_set_source_rgb (cr, 255 / 255., 105 / 255., 180 / 255.);
cairo_rectangle (cr, node->bounds.origin.x, node->bounds.origin.y, node->bounds.size.width, node->bounds.size.height);
cairo_fill (cr);
return;
}
gsk_transform_to_2d (self->transform, &xx, &yx, &xy, &yy, &dx, &dy);
cairo_matrix_init (&ctm, xx, yx, xy, yy, dx, dy);
GSK_NOTE (CAIRO, g_message ("CTM = { .xx = %g, .yx = %g, .xy = %g, .yy = %g, .x0 = %g, .y0 = %g }",
ctm.xx, ctm.yx,
ctm.xy, ctm.yy,
ctm.x0, ctm.y0));
cairo_transform (cr, &ctm);
gsk_render_node_draw (self->child, cr);
}
static void
gsk_transform_node_diff (GskRenderNode *node1,
GskRenderNode *node2,
cairo_region_t *region)
{
GskTransformNode *self1 = (GskTransformNode *) node1;
GskTransformNode *self2 = (GskTransformNode *) node2;
if (!gsk_transform_equal (self1->transform, self2->transform))
{
gsk_render_node_diff_impossible (node1, node2, region);
return;
}
if (self1->child == self2->child)
return;
switch (gsk_transform_get_category (self1->transform))
{
case GSK_TRANSFORM_CATEGORY_IDENTITY:
gsk_render_node_diff (self1->child, self2->child, region);
break;
case GSK_TRANSFORM_CATEGORY_2D_TRANSLATE:
{
cairo_region_t *sub;
float dx, dy;
gsk_transform_to_translate (self1->transform, &dx, &dy);
sub = cairo_region_create ();
gsk_render_node_diff (self1->child, self2->child, sub);
cairo_region_translate (sub, floor (dx), floor (dy));
if (floor (dx) != dx)
{
cairo_region_t *tmp = cairo_region_copy (sub);
cairo_region_translate (tmp, 1, 0);
cairo_region_union (sub, tmp);
cairo_region_destroy (sub);
}
if (floor (dy) != dy)
{
cairo_region_t *tmp = cairo_region_copy (sub);
cairo_region_translate (tmp, 0, 1);
cairo_region_union (sub, tmp);
cairo_region_destroy (sub);
}
cairo_region_union (region, sub);
cairo_region_destroy (sub);
}
break;
case GSK_TRANSFORM_CATEGORY_UNKNOWN:
case GSK_TRANSFORM_CATEGORY_ANY:
case GSK_TRANSFORM_CATEGORY_3D:
case GSK_TRANSFORM_CATEGORY_2D:
case GSK_TRANSFORM_CATEGORY_2D_AFFINE:
default:
gsk_render_node_diff_impossible (node1, node2, region);
break;
}
}
@@ -2430,12 +2495,15 @@ static GVariant *
gsk_transform_node_serialize (GskRenderNode *node)
{
GskTransformNode *self = (GskTransformNode *) node;
graphene_matrix_t matrix;
float mat[16];
graphene_matrix_to_float (&self->transform, mat);
/* XXX: serialize transforms properly */
gsk_transform_to_matrix (self->transform, &matrix);
graphene_matrix_to_float (&matrix, mat);
return g_variant_new (GSK_TRANSFORM_NODE_VARIANT_TYPE,
self->category,
gsk_transform_get_category (self->transform),
(double) mat[0], (double) mat[1], (double) mat[2], (double) mat[3],
(double) mat[4], (double) mat[5], (double) mat[6], (double) mat[7],
(double) mat[8], (double) mat[9], (double) mat[10], (double) mat[11],
@@ -2448,7 +2516,8 @@ static GskRenderNode *
gsk_transform_node_deserialize (GVariant *variant,
GError **error)
{
graphene_matrix_t transform;
graphene_matrix_t matrix;
GskTransform *transform;
double mat[16];
guint32 child_type;
gint32 category;
@@ -2472,15 +2541,16 @@ gsk_transform_node_deserialize (GVariant *variant,
if (child == NULL)
return NULL;
graphene_matrix_init_from_float (&transform,
graphene_matrix_init_from_float (&matrix,
(float[16]) {
mat[0], mat[1], mat[2], mat[3],
mat[4], mat[5], mat[6], mat[7],
mat[8], mat[9], mat[10], mat[11],
mat[12], mat[13], mat[14], mat[15]
});
result = gsk_transform_node_new_with_category (child, &transform, category);
transform = gsk_transform_matrix_with_category (NULL, &matrix, category);
result = gsk_transform_node_new (child, transform);
gsk_transform_unref (transform);
gsk_render_node_unref (child);
@@ -2494,7 +2564,7 @@ static const GskRenderNodeClass GSK_TRANSFORM_NODE_CLASS = {
gsk_transform_node_finalize,
gsk_transform_node_draw,
gsk_render_node_can_diff_true,
gsk_render_node_diff_impossible,
gsk_transform_node_diff,
gsk_transform_node_serialize,
gsk_transform_node_deserialize
};
@@ -2502,7 +2572,7 @@ static const GskRenderNodeClass GSK_TRANSFORM_NODE_CLASS = {
/**
* gsk_transform_node_new:
* @child: The node to transform
* @transform: The transform to apply
* @transform: (transfer none): The transform to apply
*
* Creates a #GskRenderNode that will transform the given @child
* with the given @transform.
@@ -2510,66 +2580,22 @@ static const GskRenderNodeClass GSK_TRANSFORM_NODE_CLASS = {
* Returns: A new #GskRenderNode
*/
GskRenderNode *
gsk_transform_node_new (GskRenderNode *child,
const graphene_matrix_t *transform)
{
g_return_val_if_fail (GSK_IS_RENDER_NODE (child), NULL);
g_return_val_if_fail (transform != NULL, NULL);
return gsk_transform_node_new_with_category (child, transform, GSK_MATRIX_CATEGORY_UNKNOWN);
}
/*<private>
* gsk_transform_node_new_with_category:
* @child: The node to transform
* @transform: The transform to apply
* @category: The category @transform belongs to
*
* Creates a #GskRenderNode that will transform the given @child
* with the given @transform.
*
* The given @category will be used by renderers for optimizations and must
* be correct. If you do not know the category of @transform, use
* %GSK_MATRIX_CATEGORY_UNKNOWN.
*
* Returns: A new #GskRenderNode
**/
GskRenderNode *
gsk_transform_node_new_with_category (GskRenderNode *child,
const graphene_matrix_t *transform,
GskMatrixCategory category)
gsk_transform_node_new (GskRenderNode *child,
GskTransform *transform)
{
GskTransformNode *self;
g_return_val_if_fail (GSK_IS_RENDER_NODE (child), NULL);
g_return_val_if_fail (transform != NULL, NULL);
self = (GskTransformNode *) gsk_render_node_new (&GSK_TRANSFORM_NODE_CLASS, 0);
self->child = gsk_render_node_ref (child);
graphene_matrix_init_from_matrix (&self->transform, transform);
self->category = category;
self->transform = gsk_transform_ref (transform);
switch (category)
{
case GSK_MATRIX_CATEGORY_IDENTITY:
graphene_rect_init_from_rect (&self->render_node.bounds, &child->bounds);
break;
case GSK_MATRIX_CATEGORY_2D_TRANSLATE:
{
graphene_rect_init_from_rect (&self->render_node.bounds, &child->bounds);
self->render_node.bounds.origin.x += graphene_matrix_get_value (transform, 3, 0);
self->render_node.bounds.origin.y += graphene_matrix_get_value (transform, 3, 1);
}
break;
case GSK_MATRIX_CATEGORY_2D_AFFINE:
case GSK_MATRIX_CATEGORY_ANY:
case GSK_MATRIX_CATEGORY_UNKNOWN:
case GSK_MATRIX_CATEGORY_INVERTIBLE:
default:
graphene_matrix_transform_bounds (&self->transform,
&child->bounds,
&self->render_node.bounds);
}
gsk_transform_transform_bounds (self->transform,
&child->bounds,
&self->render_node.bounds);
return &self->render_node;
}
@@ -2592,24 +2618,14 @@ gsk_transform_node_get_child (GskRenderNode *node)
return self->child;
}
const graphene_matrix_t *
gsk_transform_node_peek_transform (GskRenderNode *node)
GskTransform *
gsk_transform_node_get_transform (GskRenderNode *node)
{
GskTransformNode *self = (GskTransformNode *) node;
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_TRANSFORM_NODE), NULL);
return &self->transform;
}
GskMatrixCategory
gsk_transform_node_get_category (GskRenderNode *node)
{
GskTransformNode *self = (GskTransformNode *) node;
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_TRANSFORM_NODE), GSK_MATRIX_CATEGORY_UNKNOWN);
return self->category;
return self->transform;
}
/*** GSK_DEBUG_NODE ***/
File diff suppressed because it is too large Load Diff
-10
View File
@@ -1,10 +0,0 @@
#ifndef __GSK_RENDER_NODE_PARSER_PRIVATE_H__
#define __GSK_RENDER_NODE_PARSER_PRIVATE_H__
#include "gskrendernode.h"
GskRenderNode * gsk_render_node_deserialize_from_string (const char *string);
char * gsk_render_node_serialize_to_string (GskRenderNode *root);
#endif
-43
View File
@@ -6,44 +6,6 @@
G_BEGIN_DECLS
/*<private>
* GskMatrixCategory:
* @GSK_MATRIX_CATEGORY_UNKNOWN: The category of the matrix has not been
* determined.
* @GSK_MATRIX_CATEGORY_ANY: Analyzing the matrix concluded that it does
* not fit in any other category.
* @GSK_MATRIX_CATEGORY_INVERTIBLE: The matrix is linear independant and
* should therefor be invertible. Note that this is not guaranteed
* to actually be true due to rounding errors when inverting.
* @GSK_MATRIX_CATEGORY_2D: The matrix is a 2D matrix. This is equivalent
* to graphene_matrix_is_2d() returning %TRUE. In particular, this
* means that Cairo can deal with the matrix.
* @GSK_MATRIX_CATEGORY_2D_AFFINE: The matrix is a combination of 2D scale
* and 2D translation operations. In particular, this means that any
* rectangle can be transformed exactly using this matrix.
* @GSK_MATRIX_CATEGORY_2D_TRANSLATE: The matrix is a 2D translation.
* @GSK_MATRIX_CATEGORY_IDENTITY: The matrix is the identity matrix.
*
* The categories of matrices relevant for GSK and GTK. Note that any
* category includes matrices of all later categories. So if you want
* to for example check if a matrix is a 2D matrix,
* `category >= GSK_MATRIX_CATEGORY_2D` is the way to do this.
*
* Also keep in mind that rounding errors may cause matrices to not
* conform to their categories. Otherwise, matrix operations done via
* mutliplication will not worsen categories. So for the matrix
* multiplication `C = A * B`, `category(C) = MIN (category(A), category(B))`.
*/
typedef enum
{
GSK_MATRIX_CATEGORY_UNKNOWN,
GSK_MATRIX_CATEGORY_ANY,
GSK_MATRIX_CATEGORY_INVERTIBLE,
GSK_MATRIX_CATEGORY_2D_AFFINE,
GSK_MATRIX_CATEGORY_2D_TRANSLATE,
GSK_MATRIX_CATEGORY_IDENTITY
} GskMatrixCategory;
typedef struct _GskRenderNodeClass GskRenderNodeClass;
#define GSK_IS_RENDER_NODE_TYPE(node,type) (GSK_IS_RENDER_NODE (node) && (node)->node_class->node_type == (type))
@@ -96,11 +58,6 @@ GskRenderNode * gsk_render_node_deserialize_node (GskRenderNodeType typ
GskRenderNode * gsk_cairo_node_new_for_surface (const graphene_rect_t *bounds,
cairo_surface_t *surface);
GskRenderNode * gsk_transform_node_new_with_category (GskRenderNode *child,
const graphene_matrix_t *transform,
GskMatrixCategory category);
GskMatrixCategory gsk_transform_node_get_category (GskRenderNode *node);
G_END_DECLS
+1656
View File
File diff suppressed because it is too large Load Diff
+119
View File
@@ -0,0 +1,119 @@
/*
* Copyright © 2019 Benjamin Otte
*
* 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 library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Benjamin Otte <otte@gnome.org>
*/
#ifndef __GSK_TRANSFORM_H__
#define __GSK_TRANSFORM_H__
#if !defined (__GSK_H_INSIDE__) && !defined (GSK_COMPILATION)
#error "Only <gsk/gsk.h> can be included directly."
#endif
#include <gsk/gskenums.h>
#include <gsk/gsktypes.h>
G_BEGIN_DECLS
#define GSK_TYPE_TRANSFORM (gsk_transform_get_type ())
GDK_AVAILABLE_IN_ALL
GType gsk_transform_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GskTransform * gsk_transform_ref (GskTransform *self);
GDK_AVAILABLE_IN_ALL
void gsk_transform_unref (GskTransform *self);
GDK_AVAILABLE_IN_ALL
void gsk_transform_print (GskTransform *self,
GString *string);
GDK_AVAILABLE_IN_ALL
char * gsk_transform_to_string (GskTransform *self);
GDK_AVAILABLE_IN_ALL
void gsk_transform_to_matrix (GskTransform *self,
graphene_matrix_t *out_matrix);
GDK_AVAILABLE_IN_ALL
void gsk_transform_to_2d (GskTransform *self,
float *out_xx,
float *out_yx,
float *out_xy,
float *out_yy,
float *out_dx,
float *out_dy);
GDK_AVAILABLE_IN_ALL
void gsk_transform_to_affine (GskTransform *self,
float *out_scale_x,
float *out_scale_y,
float *out_dx,
float *out_dy);
GDK_AVAILABLE_IN_ALL
void gsk_transform_to_translate (GskTransform *self,
float *out_dx,
float *out_dy);
GDK_AVAILABLE_IN_ALL
GskTransformCategory gsk_transform_get_category (GskTransform *self) G_GNUC_PURE;
GDK_AVAILABLE_IN_ALL
gboolean gsk_transform_equal (GskTransform *first,
GskTransform *second) G_GNUC_PURE;
GDK_AVAILABLE_IN_ALL
GskTransform * gsk_transform_new (void);
GDK_AVAILABLE_IN_ALL
GskTransform * gsk_transform_transform (GskTransform *next,
GskTransform *other);
GDK_AVAILABLE_IN_ALL
GskTransform * gsk_transform_invert (GskTransform *self);
GDK_AVAILABLE_IN_ALL
GskTransform * gsk_transform_matrix (GskTransform *next,
const graphene_matrix_t *matrix);
GDK_AVAILABLE_IN_ALL
GskTransform * gsk_transform_translate (GskTransform *next,
const graphene_point_t *point);
GDK_AVAILABLE_IN_ALL
GskTransform * gsk_transform_translate_3d (GskTransform *next,
const graphene_point3d_t *point);
GDK_AVAILABLE_IN_ALL
GskTransform * gsk_transform_rotate (GskTransform *next,
float angle);
GDK_AVAILABLE_IN_ALL
GskTransform * gsk_transform_rotate_3d (GskTransform *next,
float angle,
const graphene_vec3_t *axis);
GDK_AVAILABLE_IN_ALL
GskTransform * gsk_transform_scale (GskTransform *next,
float factor_x,
float factor_y);
GDK_AVAILABLE_IN_ALL
GskTransform * gsk_transform_scale_3d (GskTransform *next,
float factor_x,
float factor_y,
float factor_z);
GDK_AVAILABLE_IN_ALL
GskTransform * gsk_transform_perspective (GskTransform *next,
float depth);
GDK_AVAILABLE_IN_ALL
void gsk_transform_transform_bounds (GskTransform *self,
const graphene_rect_t *rect,
graphene_rect_t *out_rect);
G_END_DECLS
#endif /* __GSK_TRANSFORM_H__ */
@@ -18,29 +18,21 @@
*/
#ifndef __GTK_TRANSFORM_PRIVATE_H__
#define __GTK_TRANSFORM_PRIVATE_H__
#ifndef __GSK_TRANSFORM_PRIVATE_H__
#define __GSK_TRANSFORM_PRIVATE_H__
#include "gtktransform.h"
#include "gsktransform.h"
#include <gsk/gsk.h>
#include "gsk/gskrendernodeprivate.h"
G_BEGIN_DECLS
GskMatrixCategory gtk_transform_categorize (GtkTransform *self);
gboolean gtk_transform_to_affine (GtkTransform *self,
float *scale_x,
float *scale_y,
float *dx,
float *dy) G_GNUC_WARN_UNUSED_RESULT;
GtkTransform * gtk_transform_matrix_with_category (GtkTransform *next,
GskTransform * gsk_transform_matrix_with_category (GskTransform *next,
const graphene_matrix_t*matrix,
GskMatrixCategory category);
GskTransformCategory category);
G_END_DECLS
#endif /* __GTK_TRANSFORM_PRIVATE_H__ */
#endif /* __GSK_TRANSFORM_PRIVATE_H__ */
+1
View File
@@ -27,5 +27,6 @@
#include <gsk/gskenums.h>
typedef struct _GskRenderer GskRenderer;
typedef struct _GskTransform GskTransform;
#endif /* __GSK_TYPES_H__ */
+3 -2
View File
@@ -24,7 +24,8 @@ gsk_public_sources = files([
'gskrenderer.c',
'gskrendernode.c',
'gskrendernodeimpl.c',
'gskroundedrect.c'
'gskroundedrect.c',
'gsktransform.c',
])
gsk_private_sources = files([
@@ -33,7 +34,6 @@ gsk_private_sources = files([
'gskdebug.c',
'gskprivate.c',
'gskprofiler.c',
'gskrendernodeparser.c',
'gl/gskshaderbuilder.c',
'gl/gskglprofiler.c',
'gl/gskglrenderer.c',
@@ -50,6 +50,7 @@ gsk_public_headers = files([
'gskrenderer.h',
'gskrendernode.h',
'gskroundedrect.h',
'gsktransform.h',
'gsktypes.h',
'gsk-autocleanup.h'
])
+2 -1
View File
@@ -8,6 +8,7 @@
#include "gskrenderer.h"
#include "gskrendererprivate.h"
#include "gskroundedrectprivate.h"
#include "gsktransform.h"
#include "gskvulkanblendmodepipelineprivate.h"
#include "gskvulkanblurpipelineprivate.h"
#include "gskvulkanborderpipelineprivate.h"
@@ -560,7 +561,7 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self,
#endif
child = gsk_transform_node_get_child (node);
graphene_matrix_init_from_matrix (&transform, gsk_transform_node_peek_transform (node));
gsk_transform_to_matrix (gsk_transform_node_get_transform (node), &transform);
graphene_matrix_init_from_matrix (&mv, &self->mv);
graphene_matrix_multiply (&transform, &mv, &self->mv);
if (!gsk_vulkan_push_constants_transform (&op.constants.constants, constants, &transform, &child->bounds))
-1
View File
@@ -228,7 +228,6 @@
#include <gtk/gtktoolshell.h>
#include <gtk/gtktooltip.h>
#include <gtk/gtktestutils.h>
#include <gtk/gtktransform.h>
#include <gtk/gtktreednd.h>
#include <gtk/gtktreelistmodel.h>
#include <gtk/gtktreemodel.h>
+128 -37
View File
@@ -23,7 +23,7 @@
#include <string.h>
#include "gtkcssnumbervalueprivate.h"
#include "gtktransform.h"
#include "gsktransform.h"
typedef union _GtkCssTransform GtkCssTransform;
@@ -35,7 +35,8 @@ typedef enum {
GTK_CSS_TRANSFORM_SCALE,
GTK_CSS_TRANSFORM_SKEW,
GTK_CSS_TRANSFORM_SKEW_X,
GTK_CSS_TRANSFORM_SKEW_Y
GTK_CSS_TRANSFORM_SKEW_Y,
GTK_CSS_TRANSFORM_PERSPECTIVE
} GtkCssTransformType;
union _GtkCssTransform {
@@ -66,6 +67,10 @@ union _GtkCssTransform {
GtkCssTransformType type;
GtkCssValue *skew;
} skew_x, skew_y;
struct {
GtkCssTransformType type;
GtkCssValue *depth;
} perspective;
};
struct _GtkCssValue {
@@ -110,6 +115,9 @@ gtk_css_transform_clear (GtkCssTransform *transform)
case GTK_CSS_TRANSFORM_SKEW_Y:
_gtk_css_value_unref (transform->skew_y.skew);
break;
case GTK_CSS_TRANSFORM_PERSPECTIVE:
_gtk_css_value_unref (transform->perspective.depth);
break;
case GTK_CSS_TRANSFORM_NONE:
default:
g_assert_not_reached ();
@@ -117,7 +125,7 @@ gtk_css_transform_clear (GtkCssTransform *transform)
}
}
static void
static gboolean
gtk_css_transform_init_identity (GtkCssTransform *transform,
GtkCssTransformType type)
{
@@ -152,28 +160,33 @@ gtk_css_transform_init_identity (GtkCssTransform *transform,
case GTK_CSS_TRANSFORM_SKEW_Y:
transform->skew_y.skew = _gtk_css_number_value_new (0, GTK_CSS_DEG);
break;
case GTK_CSS_TRANSFORM_PERSPECTIVE:
return FALSE;
case GTK_CSS_TRANSFORM_NONE:
default:
g_assert_not_reached ();
break;
return FALSE;
}
transform->type = type;
return TRUE;
}
static GtkTransform *
static GskTransform *
gtk_css_transform_apply (const GtkCssTransform *transform,
GtkTransform *next)
GskTransform *next)
{
graphene_matrix_t skew;
switch (transform->type)
{
case GTK_CSS_TRANSFORM_MATRIX:
return gtk_transform_matrix (next, &transform->matrix.matrix);
return gsk_transform_matrix (next, &transform->matrix.matrix);
case GTK_CSS_TRANSFORM_TRANSLATE:
return gtk_transform_translate_3d (next,
return gsk_transform_translate_3d (next,
&GRAPHENE_POINT3D_INIT (
_gtk_css_number_value_get (transform->translate.x, 100),
_gtk_css_number_value_get (transform->translate.y, 100),
@@ -188,34 +201,38 @@ gtk_css_transform_apply (const GtkCssTransform *transform,
_gtk_css_number_value_get (transform->rotate.x, 1),
_gtk_css_number_value_get (transform->rotate.y, 1),
_gtk_css_number_value_get (transform->rotate.z, 1));
return gtk_transform_rotate_3d (next,
return gsk_transform_rotate_3d (next,
_gtk_css_number_value_get (transform->rotate.angle, 100),
&axis);
}
case GTK_CSS_TRANSFORM_SCALE:
return gtk_transform_scale_3d (next,
return gsk_transform_scale_3d (next,
_gtk_css_number_value_get (transform->scale.x, 1),
_gtk_css_number_value_get (transform->scale.y, 1),
_gtk_css_number_value_get (transform->scale.z, 1));
break;
case GTK_CSS_TRANSFORM_SKEW:
graphene_matrix_init_skew (&skew,
_gtk_css_number_value_get (transform->skew.x, 100) / 180.0f * G_PI,
_gtk_css_number_value_get (transform->skew.y, 100) / 180.0f * G_PI);
return gtk_transform_matrix (next, &skew);
return gsk_transform_matrix (next, &skew);
case GTK_CSS_TRANSFORM_SKEW_X:
graphene_matrix_init_skew (&skew,
_gtk_css_number_value_get (transform->skew_x.skew, 100) / 180.0f * G_PI,
0);
return gtk_transform_matrix (next, &skew);
return gsk_transform_matrix (next, &skew);
case GTK_CSS_TRANSFORM_SKEW_Y:
graphene_matrix_init_skew (&skew,
0,
_gtk_css_number_value_get (transform->skew_y.skew, 100) / 180.0f * G_PI);
return gtk_transform_matrix (next, &skew);
return gsk_transform_matrix (next, &skew);
case GTK_CSS_TRANSFORM_PERSPECTIVE:
return gsk_transform_perspective (next,
_gtk_css_number_value_get (transform->perspective.depth, 100));
case GTK_CSS_TRANSFORM_NONE:
default:
@@ -225,10 +242,10 @@ gtk_css_transform_apply (const GtkCssTransform *transform,
}
/* NB: The returned matrix may be invalid */
static GtkTransform *
static GskTransform *
gtk_css_transform_value_compute_transform (const GtkCssValue *value)
{
GtkTransform *transform;
GskTransform *transform;
guint i;
transform = NULL;
@@ -303,6 +320,9 @@ gtk_css_transform_compute (GtkCssTransform *dest,
case GTK_CSS_TRANSFORM_SKEW_Y:
dest->skew_y.skew = _gtk_css_value_compute (src->skew_y.skew, property_id, provider, style, parent_style);
return dest->skew_y.skew == src->skew_y.skew;
case GTK_CSS_TRANSFORM_PERSPECTIVE:
dest->perspective.depth = _gtk_css_value_compute (src->perspective.depth, property_id, provider, style, parent_style);
return dest->perspective.depth == src->perspective.depth;
case GTK_CSS_TRANSFORM_NONE:
default:
g_assert_not_reached ();
@@ -389,6 +409,8 @@ gtk_css_transform_equal (const GtkCssTransform *transform1,
return _gtk_css_value_equal (transform1->skew_x.skew, transform2->skew_x.skew);
case GTK_CSS_TRANSFORM_SKEW_Y:
return _gtk_css_value_equal (transform1->skew_y.skew, transform2->skew_y.skew);
case GTK_CSS_TRANSFORM_PERSPECTIVE:
return _gtk_css_value_equal (transform1->perspective.depth, transform2->perspective.depth);
case GTK_CSS_TRANSFORM_NONE:
default:
g_assert_not_reached ();
@@ -416,7 +438,8 @@ gtk_css_value_transform_equal (const GtkCssValue *value1,
{
GtkCssTransform transform;
gtk_css_transform_init_identity (&transform, larger->transforms[i].type);
if (!gtk_css_transform_init_identity (&transform, larger->transforms[i].type))
return FALSE;
if (!gtk_css_transform_equal (&larger->transforms[i], &transform))
{
@@ -430,6 +453,38 @@ gtk_css_value_transform_equal (const GtkCssValue *value1,
return TRUE;
}
static void
gtk_css_transform_transition_default (GtkCssTransform *result,
const GtkCssTransform *start,
const GtkCssTransform *end,
guint property_id,
double progress)
{
graphene_matrix_t start_mat, end_mat;
GskTransform *trans;
result->type = GTK_CSS_TRANSFORM_MATRIX;
if (start)
trans = gtk_css_transform_apply (start, NULL);
else
trans = NULL;
gsk_transform_to_matrix (trans, &start_mat);
gsk_transform_unref (trans);
if (end)
trans = gtk_css_transform_apply (end, NULL);
else
trans = NULL;
gsk_transform_to_matrix (trans, &end_mat);
gsk_transform_unref (trans);
graphene_matrix_interpolate (&start_mat,
&end_mat,
progress,
&result->matrix.matrix);
}
static void
gtk_css_transform_transition (GtkCssTransform *result,
const GtkCssTransform *start,
@@ -473,6 +528,9 @@ gtk_css_transform_transition (GtkCssTransform *result,
case GTK_CSS_TRANSFORM_SKEW_Y:
result->skew_y.skew = _gtk_css_value_transition (start->skew_y.skew, end->skew_y.skew, property_id, progress);
break;
case GTK_CSS_TRANSFORM_PERSPECTIVE:
gtk_css_transform_transition_default (result, start, end, property_id, progress);
break;
case GTK_CSS_TRANSFORM_NONE:
default:
g_assert_not_reached ();
@@ -512,16 +570,16 @@ gtk_css_value_transform_transition (GtkCssValue *start,
{
if (start->transforms[i].type != end->transforms[i].type)
{
GtkTransform *transform;
GskTransform *transform;
graphene_matrix_t start_matrix, end_matrix;
transform = gtk_css_transform_value_compute_transform (start);
gtk_transform_to_matrix (transform, &start_matrix);
gtk_transform_unref (transform);
gsk_transform_to_matrix (transform, &start_matrix);
gsk_transform_unref (transform);
transform = gtk_css_transform_value_compute_transform (end);
gtk_transform_to_matrix (transform, &end_matrix);
gtk_transform_unref (transform);
gsk_transform_to_matrix (transform, &end_matrix);
gsk_transform_unref (transform);
result = gtk_css_transform_value_alloc (1);
result->transforms[0].type = GTK_CSS_TRANSFORM_MATRIX;
@@ -546,25 +604,45 @@ gtk_css_value_transform_transition (GtkCssValue *start,
{
GtkCssTransform transform;
gtk_css_transform_init_identity (&transform, start->transforms[i].type);
gtk_css_transform_transition (&result->transforms[i],
&start->transforms[i],
&transform,
property_id,
progress);
gtk_css_transform_clear (&transform);
if (gtk_css_transform_init_identity (&transform, start->transforms[i].type))
{
gtk_css_transform_transition (&result->transforms[i],
&start->transforms[i],
&transform,
property_id,
progress);
gtk_css_transform_clear (&transform);
}
else
{
gtk_css_transform_transition_default (&result->transforms[i],
&start->transforms[i],
NULL,
property_id,
progress);
}
}
for (; i < end->n_transforms; i++)
{
GtkCssTransform transform;
gtk_css_transform_init_identity (&transform, end->transforms[i].type);
gtk_css_transform_transition (&result->transforms[i],
&transform,
&end->transforms[i],
property_id,
progress);
gtk_css_transform_clear (&transform);
if (gtk_css_transform_init_identity (&transform, end->transforms[i].type))
{
gtk_css_transform_transition (&result->transforms[i],
&transform,
&end->transforms[i],
property_id,
progress);
gtk_css_transform_clear (&transform);
}
else
{
gtk_css_transform_transition_default (&result->transforms[i],
NULL,
&end->transforms[i],
property_id,
progress);
}
}
g_assert (i == MAX (start->n_transforms, end->n_transforms));
@@ -678,6 +756,11 @@ gtk_css_transform_print (const GtkCssTransform *transform,
_gtk_css_value_print (transform->skew_y.skew, string);
g_string_append (string, ")");
break;
case GTK_CSS_TRANSFORM_PERSPECTIVE:
g_string_append (string, "perspective(");
_gtk_css_value_print (transform->perspective.depth, string);
g_string_append (string, ")");
break;
case GTK_CSS_TRANSFORM_NONE:
default:
g_assert_not_reached ();
@@ -1046,6 +1129,14 @@ gtk_css_transform_parse (GtkCssTransform *transform,
if (transform->skew_y.skew == NULL)
return FALSE;
}
else if (_gtk_css_parser_try (parser, "perspective(", TRUE))
{
transform->type = GTK_CSS_TRANSFORM_PERSPECTIVE;
transform->perspective.depth = _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_LENGTH);
if (transform->perspective.depth == NULL)
return FALSE;
}
else
{
_gtk_css_parser_error (parser, "unknown syntax for transform");
@@ -1098,7 +1189,7 @@ _gtk_css_transform_value_parse (GtkCssParser *parser)
return value;
}
GtkTransform *
GskTransform *
gtk_css_transform_value_get_transform (const GtkCssValue *transform)
{
g_return_val_if_fail (transform->class == &GTK_CSS_VALUE_TRANSFORM, FALSE);
+1 -1
View File
@@ -28,7 +28,7 @@ G_BEGIN_DECLS
GtkCssValue * _gtk_css_transform_value_new_none (void);
GtkCssValue * _gtk_css_transform_value_parse (GtkCssParser *parser);
GtkTransform * gtk_css_transform_value_get_transform (const GtkCssValue *transform);
GskTransform * gtk_css_transform_value_get_transform (const GtkCssValue *transform);
G_END_DECLS
+13
View File
@@ -332,6 +332,18 @@ gtk_entry_grab_focus (GtkWidget *widget)
gtk_widget_grab_focus (priv->text);
}
static gboolean
gtk_entry_mnemonic_activate (GtkWidget *widget,
gboolean group_cycling)
{
GtkEntry *entry = GTK_ENTRY (widget);
GtkEntryPrivate *priv = gtk_entry_get_instance_private (entry);
gtk_widget_grab_focus (priv->text);
return TRUE;
}
static void
gtk_entry_class_init (GtkEntryClass *class)
{
@@ -351,6 +363,7 @@ gtk_entry_class_init (GtkEntryClass *class)
widget_class->query_tooltip = gtk_entry_query_tooltip;
widget_class->direction_changed = gtk_entry_direction_changed;
widget_class->grab_focus = gtk_entry_grab_focus;
widget_class->mnemonic_activate = gtk_entry_mnemonic_activate;
quark_entry_completion = g_quark_from_static_string ("gtk-entry-completion-key");
+8 -7
View File
@@ -6634,7 +6634,7 @@ gtk_notebook_set_tab_label (GtkNotebook *notebook,
if (priv->menu)
gtk_notebook_menu_item_recreate (notebook, list);
g_object_notify (G_OBJECT (child), "tab-label");
g_object_notify (G_OBJECT (page), "tab-label");
}
/**
@@ -6764,7 +6764,7 @@ gtk_notebook_set_menu_label (GtkNotebook *notebook,
if (priv->menu)
gtk_notebook_menu_item_create (notebook, page);
g_object_notify (G_OBJECT (child), "menu-label");
g_object_notify (G_OBJECT (page), "menu-label");
}
/**
@@ -6791,7 +6791,6 @@ gtk_notebook_set_menu_label_text (GtkNotebook *notebook,
gtk_widget_set_valign (menu_label, GTK_ALIGN_CENTER);
}
gtk_notebook_set_menu_label (notebook, child, menu_label);
g_object_notify (G_OBJECT (child), "menu-label");
}
/**
@@ -7031,7 +7030,7 @@ gtk_notebook_set_tab_reorderable (GtkNotebook *notebook,
else
gtk_style_context_remove_class (gtk_widget_get_style_context (page->tab_widget),
"reorderable-page");
g_object_notify (G_OBJECT (child), "reorderable");
g_object_notify (G_OBJECT (page), "reorderable");
}
}
@@ -7114,6 +7113,7 @@ gtk_notebook_set_tab_detachable (GtkNotebook *notebook,
gboolean detachable)
{
GList *list;
GtkNotebookPage *page;
g_return_if_fail (GTK_IS_NOTEBOOK (notebook));
g_return_if_fail (GTK_IS_WIDGET (child));
@@ -7121,12 +7121,13 @@ gtk_notebook_set_tab_detachable (GtkNotebook *notebook,
list = gtk_notebook_find_child (notebook, child);
g_return_if_fail (list != NULL);
page = GTK_NOTEBOOK_PAGE_FROM_LIST (list);
detachable = detachable != FALSE;
if (GTK_NOTEBOOK_PAGE_FROM_LIST (list)->detachable != detachable)
if (page->detachable != detachable)
{
GTK_NOTEBOOK_PAGE_FROM_LIST (list)->detachable = detachable;
g_object_notify (G_OBJECT (child), "detachable");
page->detachable = detachable;
g_object_notify (G_OBJECT (page), "detachable");
}
}
+13
View File
@@ -226,6 +226,18 @@ gtk_password_entry_grab_focus (GtkWidget *widget)
gtk_widget_grab_focus (priv->entry);
}
static gboolean
gtk_password_entry_mnemonic_activate (GtkWidget *widget,
gboolean group_cycling)
{
GtkPasswordEntry *entry = GTK_PASSWORD_ENTRY (widget);
GtkPasswordEntryPrivate *priv = gtk_password_entry_get_instance_private (entry);
gtk_widget_grab_focus (priv->entry);
return TRUE;
}
static void
gtk_password_entry_class_init (GtkPasswordEntryClass *klass)
{
@@ -242,6 +254,7 @@ gtk_password_entry_class_init (GtkPasswordEntryClass *klass)
widget_class->size_allocate = gtk_password_entry_size_allocate;
widget_class->get_accessible = gtk_password_entry_get_accessible;
widget_class->grab_focus = gtk_password_entry_grab_focus;
widget_class->mnemonic_activate = gtk_password_entry_mnemonic_activate;
gtk_editable_install_properties (object_class, 1);
+5 -5
View File
@@ -29,7 +29,7 @@
#include "gtkcsstransformvalueprivate.h"
#include "gtkiconthemeprivate.h"
#include "gtksnapshot.h"
#include "gtktransform.h"
#include "gsktransform.h"
#include <math.h>
@@ -41,7 +41,7 @@ gtk_css_style_snapshot_icon (GtkCssStyle *style,
GtkCssImageBuiltinType builtin_type)
{
const GtkCssValue *shadows_value, *transform_value, *filter_value;
GtkTransform *transform;
GskTransform *transform;
GtkCssImage *image;
gboolean has_shadow;
@@ -92,7 +92,7 @@ gtk_css_style_snapshot_icon (GtkCssStyle *style,
gtk_snapshot_pop (snapshot);
gtk_transform_unref (transform);
gsk_transform_unref (transform);
}
void
@@ -104,7 +104,7 @@ gtk_css_style_snapshot_icon_paintable (GtkCssStyle *style,
gboolean recolor)
{
const GtkCssValue *shadows_value, *transform_value, *filter_value;
GtkTransform *transform;
GskTransform *transform;
gboolean has_shadow;
g_return_if_fail (GTK_IS_CSS_STYLE (style));
@@ -172,5 +172,5 @@ gtk_css_style_snapshot_icon_paintable (GtkCssStyle *style,
transparent:
gtk_css_filter_value_pop_snapshot (filter_value, snapshot);
gtk_transform_unref (transform);
gsk_transform_unref (transform);
}
+13
View File
@@ -258,6 +258,18 @@ gtk_search_entry_grab_focus (GtkWidget *widget)
gtk_text_grab_focus_without_selecting (GTK_TEXT (priv->entry));
}
static gboolean
gtk_search_entry_mnemonic_activate (GtkWidget *widget,
gboolean group_cycling)
{
GtkSearchEntry *entry = GTK_SEARCH_ENTRY (widget);
GtkSearchEntryPrivate *priv = gtk_search_entry_get_instance_private (entry);
gtk_widget_grab_focus (priv->entry);
return TRUE;
}
static void
gtk_search_entry_class_init (GtkSearchEntryClass *klass)
{
@@ -273,6 +285,7 @@ gtk_search_entry_class_init (GtkSearchEntryClass *klass)
widget_class->size_allocate = gtk_search_entry_size_allocate;
widget_class->get_accessible = gtk_search_entry_get_accessible;
widget_class->grab_focus = gtk_search_entry_grab_focus;
widget_class->mnemonic_activate = gtk_search_entry_mnemonic_activate;
klass->stop_search = gtk_search_entry_stop_search;
+62 -65
View File
@@ -28,7 +28,7 @@
#include "gtkrendericonprivate.h"
#include "gtkrendernodepaintableprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtktransformprivate.h"
#include "gsktransformprivate.h"
#include "gsk/gskrendernodeprivate.h"
@@ -109,7 +109,7 @@ gtk_snapshot_collect_default (GtkSnapshot *snapshot,
static GtkSnapshotState *
gtk_snapshot_push_state (GtkSnapshot *snapshot,
GtkTransform *transform,
GskTransform *transform,
GtkSnapshotCollectFunc collect_func)
{
const gsize n_states = snapshot->state_stack->len;
@@ -118,7 +118,7 @@ gtk_snapshot_push_state (GtkSnapshot *snapshot,
g_array_set_size (snapshot->state_stack, n_states + 1);
state = &g_array_index (snapshot->state_stack, GtkSnapshotState, n_states);
state->transform = gtk_transform_ref (transform);
state->transform = gsk_transform_ref (transform);
state->collect_func = collect_func;
state->start_node_index = snapshot->nodes->len;
state->n_nodes = 0;
@@ -145,7 +145,7 @@ gtk_snapshot_get_previous_state (const GtkSnapshot *snapshot)
static void
gtk_snapshot_state_clear (GtkSnapshotState *state)
{
gtk_transform_unref (state->transform);
gsk_transform_unref (state->transform);
}
/**
@@ -242,14 +242,15 @@ gtk_snapshot_collect_autopush_transform (GtkSnapshot *snapshot,
guint n_nodes)
{
GskRenderNode *node, *transform_node;
GtkSnapshotState *previous_state;
previous_state = gtk_snapshot_get_previous_state (snapshot);
node = gtk_snapshot_collect_default (snapshot, state, nodes, n_nodes);
if (node == NULL)
return NULL;
transform_node = gsk_transform_node_new_with_category (node,
&state->data.transform.transform,
state->data.transform.category);
transform_node = gsk_transform_node_new (node, previous_state->transform);
gsk_render_node_unref (node);
@@ -259,17 +260,9 @@ gtk_snapshot_collect_autopush_transform (GtkSnapshot *snapshot,
static void
gtk_snapshot_autopush_transform (GtkSnapshot *snapshot)
{
GtkSnapshotState *previous_state;
GtkSnapshotState *state;
state = gtk_snapshot_push_state (snapshot,
NULL,
gtk_snapshot_collect_autopush_transform);
previous_state = gtk_snapshot_get_previous_state (snapshot);
gtk_transform_to_matrix (previous_state->transform, &state->data.transform.transform);
state->data.transform.category = gtk_transform_categorize (previous_state->transform);
gtk_snapshot_push_state (snapshot,
NULL,
gtk_snapshot_collect_autopush_transform);
}
static gboolean
@@ -582,15 +575,15 @@ gtk_snapshot_ensure_affine (GtkSnapshot *snapshot,
float *dx,
float *dy)
{
const GtkSnapshotState *current_state = gtk_snapshot_get_current_state (snapshot);
const GtkSnapshotState *state = gtk_snapshot_get_current_state (snapshot);
if (gtk_transform_to_affine (current_state->transform, scale_x, scale_y, dx, dy))
return;
gtk_snapshot_autopush_transform (snapshot);
*scale_x = *scale_y = 1;
*dx = *dy = 0;
if (gsk_transform_get_category (state->transform) < GSK_TRANSFORM_CATEGORY_2D_AFFINE)
{
gtk_snapshot_autopush_transform (snapshot);
state = gtk_snapshot_get_current_state (snapshot);
}
gsk_transform_to_affine (state->transform, scale_x, scale_y, dx, dy);
}
static void
@@ -598,16 +591,15 @@ gtk_snapshot_ensure_translate (GtkSnapshot *snapshot,
float *dx,
float *dy)
{
const GtkSnapshotState *current_state = gtk_snapshot_get_current_state (snapshot);
float scale_x, scale_y;
const GtkSnapshotState *state = gtk_snapshot_get_current_state (snapshot);
if (gtk_transform_to_affine (current_state->transform, &scale_x, &scale_y, dx, dy) &&
scale_x == 1.0f && scale_y == 1.0f)
return;
gtk_snapshot_autopush_transform (snapshot);
*dx = *dy = 0;
if (gsk_transform_get_category (state->transform) < GSK_TRANSFORM_CATEGORY_2D_TRANSLATE)
{
gtk_snapshot_autopush_transform (snapshot);
state = gtk_snapshot_get_current_state (snapshot);
}
gsk_transform_to_translate (state->transform, dx, dy);
}
static void
@@ -615,10 +607,8 @@ gtk_snapshot_ensure_identity (GtkSnapshot *snapshot)
{
const GtkSnapshotState *state = gtk_snapshot_get_current_state (snapshot);
if (state->transform == NULL)
return;
gtk_snapshot_autopush_transform (snapshot);
if (gsk_transform_get_category (state->transform) < GSK_TRANSFORM_CATEGORY_IDENTITY)
gtk_snapshot_autopush_transform (snapshot);
}
void
@@ -1244,14 +1234,14 @@ gtk_snapshot_restore (GtkSnapshot *snapshot)
**/
void
gtk_snapshot_transform (GtkSnapshot *snapshot,
GtkTransform *transform)
GskTransform *transform)
{
GtkSnapshotState *state;
g_return_if_fail (GTK_IS_SNAPSHOT (snapshot));
state = gtk_snapshot_get_current_state (snapshot);
state->transform = gtk_transform_transform (state->transform, transform);
state->transform = gsk_transform_transform (state->transform, transform);
}
/**
@@ -1271,21 +1261,7 @@ gtk_snapshot_transform_matrix (GtkSnapshot *snapshot,
g_return_if_fail (matrix != NULL);
state = gtk_snapshot_get_current_state (snapshot);
state->transform = gtk_transform_matrix (state->transform, matrix);
}
void
gtk_snapshot_transform_matrix_with_category (GtkSnapshot *snapshot,
const graphene_matrix_t *matrix,
GskMatrixCategory category)
{
GtkSnapshotState *state;
g_return_if_fail (GTK_IS_SNAPSHOT (snapshot));
g_return_if_fail (matrix != NULL);
state = gtk_snapshot_get_current_state (snapshot);
state->transform = gtk_transform_matrix_with_category (state->transform, matrix, category);
state->transform = gsk_transform_matrix (state->transform, matrix);
}
/**
@@ -1305,7 +1281,7 @@ gtk_snapshot_translate (GtkSnapshot *snapshot,
g_return_if_fail (point != NULL);
state = gtk_snapshot_get_current_state (snapshot);
state->transform = gtk_transform_translate (state->transform, point);
state->transform = gsk_transform_translate (state->transform, point);
}
/**
@@ -1325,7 +1301,7 @@ gtk_snapshot_translate_3d (GtkSnapshot *snapshot,
g_return_if_fail (point != NULL);
state = gtk_snapshot_get_current_state (snapshot);
state->transform = gtk_transform_translate_3d (state->transform, point);
state->transform = gsk_transform_translate_3d (state->transform, point);
}
/**
@@ -1345,7 +1321,7 @@ gtk_snapshot_rotate (GtkSnapshot *snapshot,
g_return_if_fail (GTK_IS_SNAPSHOT (snapshot));
state = gtk_snapshot_get_current_state (snapshot);
state->transform = gtk_transform_rotate (state->transform, angle);
state->transform = gsk_transform_rotate (state->transform, angle);
}
/**
@@ -1356,7 +1332,7 @@ gtk_snapshot_rotate (GtkSnapshot *snapshot,
*
* Rotates @snapshot's coordinate system by @angle degrees around @axis.
*
* For a rotation in 2D space, use gtk_transform_rotate().
* For a rotation in 2D space, use gsk_transform_rotate().
*/
void
gtk_snapshot_rotate_3d (GtkSnapshot *snapshot,
@@ -1369,7 +1345,7 @@ gtk_snapshot_rotate_3d (GtkSnapshot *snapshot,
g_return_if_fail (axis != NULL);
state = gtk_snapshot_get_current_state (snapshot);
state->transform = gtk_transform_rotate_3d (state->transform, angle, axis);
state->transform = gsk_transform_rotate_3d (state->transform, angle, axis);
}
/**
@@ -1378,7 +1354,7 @@ gtk_snapshot_rotate_3d (GtkSnapshot *snapshot,
* @factor_x: scaling factor on the X axis
* @factor_y: scaling factor on the Y axis
*
* Scales @@snapshot's coordinate system in 2-dimensional space by
* Scales @snapshot's coordinate system in 2-dimensional space by
* the given factors.
*
* Use gtk_snapshot_scale_3d() to scale in all 3 dimensions.
@@ -1393,7 +1369,7 @@ gtk_snapshot_scale (GtkSnapshot *snapshot,
g_return_if_fail (GTK_IS_SNAPSHOT (snapshot));
state = gtk_snapshot_get_current_state (snapshot);
state->transform = gtk_transform_scale (state->transform, factor_x, factor_y);
state->transform = gsk_transform_scale (state->transform, factor_x, factor_y);
}
/**
@@ -1403,7 +1379,7 @@ gtk_snapshot_scale (GtkSnapshot *snapshot,
* @factor_y: scaling factor on the Y axis
* @factor_z: scaling factor on the Z axis
*
* Scales @@snapshot's coordinate system by the given factors.
* Scales @snapshot's coordinate system by the given factors.
*/
void
gtk_snapshot_scale_3d (GtkSnapshot *snapshot,
@@ -1416,7 +1392,28 @@ gtk_snapshot_scale_3d (GtkSnapshot *snapshot,
g_return_if_fail (GTK_IS_SNAPSHOT (snapshot));
state = gtk_snapshot_get_current_state (snapshot);
state->transform = gtk_transform_scale_3d (state->transform, factor_x, factor_y, factor_z);
state->transform = gsk_transform_scale_3d (state->transform, factor_x, factor_y, factor_z);
}
/**
* gtk_snapshot_perspective:
* @snapshot: a #GtkSnapshot
* @depth: distance of the z=0 plane
*
* Applies a perspective projection transform.
*
* See gsk_transform_perspective() for a discussion on the details.
*/
void
gtk_snapshot_perspective (GtkSnapshot *snapshot,
float depth)
{
GtkSnapshotState *state;
g_return_if_fail (GTK_IS_SNAPSHOT (snapshot));
state = gtk_snapshot_get_current_state (snapshot);
state->transform = gsk_transform_perspective (state->transform, depth);
}
void
+4 -1
View File
@@ -107,7 +107,7 @@ GDK_AVAILABLE_IN_ALL
void gtk_snapshot_restore (GtkSnapshot *snapshot);
GDK_AVAILABLE_IN_ALL
void gtk_snapshot_transform (GtkSnapshot *snapshot,
GtkTransform *transform);
GskTransform *transform);
GDK_AVAILABLE_IN_ALL
void gtk_snapshot_transform_matrix (GtkSnapshot *snapshot,
const graphene_matrix_t*matrix);
@@ -134,6 +134,9 @@ void gtk_snapshot_scale_3d (GtkSnapshot
float factor_y,
float factor_z);
GDK_AVAILABLE_IN_ALL
void gtk_snapshot_perspective (GtkSnapshot *snapshot,
float depth);
GDK_AVAILABLE_IN_ALL
void gtk_snapshot_append_node (GtkSnapshot *snapshot,
GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
+3 -11
View File
@@ -35,19 +35,15 @@ struct _GtkSnapshotState {
guint start_node_index;
guint n_nodes;
GtkTransform * transform;
GskTransform * transform;
GtkSnapshotCollectFunc collect_func;
union {
struct {
graphene_matrix_t transform;
GskMatrixCategory category;
} transform;
struct {
double opacity;
double opacity;
} opacity;
struct {
double radius;
double radius;
} blur;
struct {
graphene_matrix_t matrix;
@@ -105,10 +101,6 @@ void gtk_snapshot_append_node_internal (GtkSnapshot
GtkSnapshot * gtk_snapshot_new_with_parent (GtkSnapshot *parent_snapshot);
void gtk_snapshot_transform_matrix_with_category
(GtkSnapshot *snapshot,
const graphene_matrix_t*matrix,
GskMatrixCategory category);
void gtk_snapshot_append_text (GtkSnapshot *snapshot,
PangoFont *font,
PangoGlyphString *glyphs,
+24
View File
@@ -304,6 +304,28 @@ G_DEFINE_TYPE_WITH_CODE (GtkSpinButton, gtk_spin_button, GTK_TYPE_WIDGET,
"change-value", 1, \
GTK_TYPE_SCROLL_TYPE, scroll)
static void
gtk_spin_button_grab_focus (GtkWidget *widget)
{
GtkSpinButton *spin_button = GTK_SPIN_BUTTON (widget);
GtkSpinButtonPrivate *priv = gtk_spin_button_get_instance_private (spin_button);
gtk_widget_grab_focus (priv->entry);
}
static gboolean
gtk_spin_button_mnemonic_activate (GtkWidget *widget,
gboolean group_cycling)
{
GtkSpinButton *spin_button = GTK_SPIN_BUTTON (widget);
GtkSpinButtonPrivate *priv = gtk_spin_button_get_instance_private (spin_button);
gtk_widget_grab_focus (priv->entry);
return TRUE;
}
static void
gtk_spin_button_class_init (GtkSpinButtonClass *class)
{
@@ -321,6 +343,8 @@ gtk_spin_button_class_init (GtkSpinButtonClass *class)
widget_class->size_allocate = gtk_spin_button_size_allocate;
widget_class->grab_notify = gtk_spin_button_grab_notify;
widget_class->state_flags_changed = gtk_spin_button_state_flags_changed;
widget_class->grab_focus = gtk_spin_button_grab_focus;
widget_class->mnemonic_activate = gtk_spin_button_mnemonic_activate;
class->input = NULL;
class->output = NULL;
+84 -1
View File
@@ -104,6 +104,7 @@
* @GTK_STACK_TRANSITION_TYPE_OVER_DOWN_UP: Cover the old page sliding down or uncover the new page sliding up, according to order
* @GTK_STACK_TRANSITION_TYPE_OVER_LEFT_RIGHT: Cover the old page sliding left or uncover the new page sliding right, according to order
* @GTK_STACK_TRANSITION_TYPE_OVER_RIGHT_LEFT: Cover the old page sliding right or uncover the new page sliding left, according to order
* @GTK_STACK_TRANSITION_TYPE_CUBE: Pretend the pages are sides of a cube and rotate that cube
*
* These enumeration values describe the possible transitions
* between pages in a #GtkStack widget.
@@ -911,6 +912,7 @@ get_simple_transition_type (gboolean new_child_first,
case GTK_STACK_TRANSITION_TYPE_UNDER_LEFT:
case GTK_STACK_TRANSITION_TYPE_UNDER_RIGHT:
case GTK_STACK_TRANSITION_TYPE_CROSSFADE:
case GTK_STACK_TRANSITION_TYPE_CUBE:
default:
return transition_type;
}
@@ -1071,6 +1073,7 @@ effective_transition_type (GtkStack *stack,
case GTK_STACK_TRANSITION_TYPE_OVER_LEFT_RIGHT:
case GTK_STACK_TRANSITION_TYPE_OVER_RIGHT_LEFT:
case GTK_STACK_TRANSITION_TYPE_CROSSFADE:
case GTK_STACK_TRANSITION_TYPE_CUBE:
default:
return transition_type;
}
@@ -2047,7 +2050,6 @@ gtk_stack_forall (GtkContainer *container,
}
}
#include <gsk/gskrendernodeprivate.h>
static void
gtk_stack_compute_expand (GtkWidget *widget,
gboolean *hexpand_p,
@@ -2169,6 +2171,84 @@ gtk_stack_snapshot_under (GtkWidget *widget,
}
}
static void
gtk_stack_snapshot_cube (GtkWidget *widget,
GtkSnapshot *snapshot)
{
GtkStack *stack = GTK_STACK (widget);
GtkStackPrivate *priv = gtk_stack_get_instance_private (stack);
double progress = gtk_progress_tracker_get_progress (&priv->tracker, FALSE);
if (priv->last_visible_node && progress > 0.5)
{
gtk_snapshot_save (snapshot);
gtk_snapshot_translate_3d (snapshot, &GRAPHENE_POINT3D_INIT (
gtk_widget_get_width (widget) / 2.f,
gtk_widget_get_height (widget) / 2.f,
0));
gtk_snapshot_perspective (snapshot, 2 * gtk_widget_get_width (widget) / 1.f);
gtk_snapshot_translate_3d (snapshot, &GRAPHENE_POINT3D_INIT (
0, 0,
- gtk_widget_get_width (widget) / 2.f));
gtk_snapshot_rotate_3d (snapshot, -90 * progress, graphene_vec3_y_axis());
gtk_snapshot_translate_3d (snapshot, &GRAPHENE_POINT3D_INIT (
- gtk_widget_get_width (widget) / 2.f,
- gtk_widget_get_height (widget) / 2.f,
gtk_widget_get_width (widget) / 2.f));
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (
priv->last_visible_surface_allocation.x,
priv->last_visible_surface_allocation.y));
gtk_snapshot_append_node (snapshot, priv->last_visible_node);
gtk_snapshot_restore (snapshot);
}
gtk_snapshot_save (snapshot);
gtk_snapshot_translate_3d (snapshot, &GRAPHENE_POINT3D_INIT (
gtk_widget_get_width (widget) / 2.f,
gtk_widget_get_height (widget) / 2.f,
0));
gtk_snapshot_perspective (snapshot, 2 * gtk_widget_get_width (widget) / 1.f);
gtk_snapshot_translate_3d (snapshot, &GRAPHENE_POINT3D_INIT (
0, 0,
- gtk_widget_get_width (widget) / 2.f));
gtk_snapshot_rotate_3d (snapshot, 90 * (1.0 - progress), graphene_vec3_y_axis());
gtk_snapshot_translate_3d (snapshot, &GRAPHENE_POINT3D_INIT (
- gtk_widget_get_width (widget) / 2.f,
- gtk_widget_get_height (widget) / 2.f,
gtk_widget_get_width (widget) / 2.f));
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (
priv->last_visible_surface_allocation.x,
priv->last_visible_surface_allocation.y));
gtk_widget_snapshot_child (widget,
priv->visible_child->widget,
snapshot);
gtk_snapshot_restore (snapshot);
if (priv->last_visible_node && progress <= 0.5)
{
gtk_snapshot_save (snapshot);
gtk_snapshot_translate_3d (snapshot, &GRAPHENE_POINT3D_INIT (
gtk_widget_get_width (widget) / 2.f,
gtk_widget_get_height (widget) / 2.f,
0));
gtk_snapshot_perspective (snapshot, 2 * gtk_widget_get_width (widget) / 1.f);
gtk_snapshot_translate_3d (snapshot, &GRAPHENE_POINT3D_INIT (
0, 0,
- gtk_widget_get_width (widget) / 2.f));
gtk_snapshot_rotate_3d (snapshot, -90 * progress, graphene_vec3_y_axis());
gtk_snapshot_translate_3d (snapshot, &GRAPHENE_POINT3D_INIT (
- gtk_widget_get_width (widget) / 2.f,
- gtk_widget_get_height (widget) / 2.f,
gtk_widget_get_width (widget) / 2.f));
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (
priv->last_visible_surface_allocation.x,
priv->last_visible_surface_allocation.y));
gtk_snapshot_append_node (snapshot, priv->last_visible_node);
gtk_snapshot_restore (snapshot);
}
}
static void
gtk_stack_snapshot_slide (GtkWidget *widget,
GtkSnapshot *snapshot)
@@ -2285,6 +2365,9 @@ gtk_stack_snapshot (GtkWidget *widget,
case GTK_STACK_TRANSITION_TYPE_UNDER_RIGHT:
gtk_stack_snapshot_under (widget, snapshot);
break;
case GTK_STACK_TRANSITION_TYPE_CUBE:
gtk_stack_snapshot_cube (widget, snapshot);
break;
case GTK_STACK_TRANSITION_TYPE_NONE:
case GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT:
case GTK_STACK_TRANSITION_TYPE_SLIDE_UP_DOWN:
+2 -1
View File
@@ -72,7 +72,8 @@ typedef enum {
GTK_STACK_TRANSITION_TYPE_OVER_UP_DOWN,
GTK_STACK_TRANSITION_TYPE_OVER_DOWN_UP,
GTK_STACK_TRANSITION_TYPE_OVER_LEFT_RIGHT,
GTK_STACK_TRANSITION_TYPE_OVER_RIGHT_LEFT
GTK_STACK_TRANSITION_TYPE_OVER_RIGHT_LEFT,
GTK_STACK_TRANSITION_TYPE_CUBE
} GtkStackTransitionType;
struct _GtkStack {
-1113
View File
File diff suppressed because it is too large Load Diff
-104
View File
@@ -1,104 +0,0 @@
/*
* Copyright © 2019 Benjamin Otte
*
* 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 library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Benjamin Otte <otte@gnome.org>
*/
#ifndef __GTK_TRANSFORM_H__
#define __GTK_TRANSFORM_H__
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk.h> can be included directly."
#endif
#include <graphene.h>
#include <gtk/gtktypes.h>
G_BEGIN_DECLS
#define GTK_TYPE_MATRIX (gtk_transform_get_type ())
typedef enum
{
GTK_TRANSFORM_TYPE_IDENTITY,
GTK_TRANSFORM_TYPE_TRANSFORM,
GTK_TRANSFORM_TYPE_TRANSLATE,
GTK_TRANSFORM_TYPE_ROTATE,
GTK_TRANSFORM_TYPE_SCALE
} GtkTransformType;
GDK_AVAILABLE_IN_ALL
GType gtk_transform_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GtkTransform * gtk_transform_ref (GtkTransform *self);
GDK_AVAILABLE_IN_ALL
void gtk_transform_unref (GtkTransform *self);
GDK_AVAILABLE_IN_ALL
void gtk_transform_print (GtkTransform *self,
GString *string);
GDK_AVAILABLE_IN_ALL
char * gtk_transform_to_string (GtkTransform *self);
GDK_AVAILABLE_IN_ALL
void gtk_transform_to_matrix (GtkTransform *self,
graphene_matrix_t *out_matrix);
GDK_AVAILABLE_IN_ALL
gboolean gtk_transform_equal (GtkTransform *first,
GtkTransform *second) G_GNUC_PURE;
GDK_AVAILABLE_IN_ALL
GtkTransform * gtk_transform_new (void);
GDK_AVAILABLE_IN_ALL
GtkTransform * gtk_transform_identity (GtkTransform *next);
GDK_AVAILABLE_IN_ALL
GtkTransform * gtk_transform_transform (GtkTransform *next,
GtkTransform *other);
GDK_AVAILABLE_IN_ALL
GtkTransform * gtk_transform_matrix (GtkTransform *next,
const graphene_matrix_t *matrix);
GDK_AVAILABLE_IN_ALL
GtkTransform * gtk_transform_translate (GtkTransform *next,
const graphene_point_t *point);
GDK_AVAILABLE_IN_ALL
GtkTransform * gtk_transform_translate_3d (GtkTransform *next,
const graphene_point3d_t *point);
GDK_AVAILABLE_IN_ALL
GtkTransform * gtk_transform_rotate (GtkTransform *next,
float angle);
GDK_AVAILABLE_IN_ALL
GtkTransform * gtk_transform_rotate_3d (GtkTransform *next,
float angle,
const graphene_vec3_t *axis);
GDK_AVAILABLE_IN_ALL
GtkTransform * gtk_transform_scale (GtkTransform *next,
float factor_x,
float factor_y);
GDK_AVAILABLE_IN_ALL
GtkTransform * gtk_transform_scale_3d (GtkTransform *next,
float factor_x,
float factor_y,
float factor_z);
GDK_AVAILABLE_IN_ALL
GtkTransformType gtk_transform_get_transform_type (GtkTransform *self) G_GNUC_PURE;
GDK_AVAILABLE_IN_ALL
GtkTransform * gtk_transform_get_next (GtkTransform *self) G_GNUC_PURE;
G_END_DECLS
#endif /* __GTK_TRANSFORM_H__ */
+2
View File
@@ -5614,6 +5614,8 @@ validate_row (GtkTreeView *tree_view,
if (is_separator)
{
height = separator_height;
/* gtk_tree_view_get_row_height() assumes separator nodes are > 0 */
height = MAX (height, 1);
}
else
{
-1
View File
@@ -45,7 +45,6 @@ typedef struct _GtkSettings GtkSettings;
typedef GdkSnapshot GtkSnapshot;
typedef struct _GtkStyleContext GtkStyleContext;
typedef struct _GtkTooltip GtkTooltip;
typedef struct _GtkTransform GtkTransform;
typedef struct _GtkWidget GtkWidget;
typedef struct _GtkWidgetPath GtkWidgetPath;
typedef struct _GtkWindow GtkWindow;
+56 -38
View File
@@ -62,7 +62,7 @@
#include "gtksnapshotprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtktooltipprivate.h"
#include "gtktransformprivate.h"
#include "gsktransformprivate.h"
#include "gtktypebuiltins.h"
#include "gtkversion.h"
#include "gtkwidgetpaintableprivate.h"
@@ -820,15 +820,33 @@ gtk_widget_real_pick (GtkWidget *widget,
child = _gtk_widget_get_prev_sibling (child))
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (child);
GskTransform *transform;
graphene_matrix_t inv;
GtkWidget *picked;
graphene_point_t p;
graphene_point3d_t p0, p1, res;
graphene_matrix_inverse (&priv->transform, &inv);
graphene_point_init (&p, x, y);
graphene_matrix_transform_point (&inv, &p, &p);
if (priv->transform)
{
transform = gsk_transform_invert (gsk_transform_ref (priv->transform));
if (transform == NULL)
continue;
}
else
{
transform = NULL;
}
gsk_transform_to_matrix (transform, &inv);
gsk_transform_unref (transform);
graphene_point3d_init (&p0, x, y, 0);
graphene_point3d_init (&p1, x, y, 1);
graphene_matrix_transform_point3d (&inv, &p0, &p0);
graphene_matrix_transform_point3d (&inv, &p1, &p1);
if (fabs (p0.z - p1.z) < 1.f / 4096)
continue;
picked = gtk_widget_pick (child, p.x, p.y);
graphene_point3d_interpolate (&p0, &p1, p0.z / (p0.z - p1.z), &res);
picked = gtk_widget_pick (child, res.x, res.y);
if (picked)
return picked;
}
@@ -2878,8 +2896,6 @@ gtk_widget_init (GTypeInstance *instance, gpointer g_class)
priv->width_request = -1;
priv->height_request = -1;
graphene_matrix_init_identity (&priv->transform);
_gtk_size_request_cache_init (&priv->requests);
priv->cssnode = gtk_css_widget_node_new (widget);
@@ -4129,10 +4145,10 @@ gtk_widget_size_allocate (GtkWidget *widget,
const GtkAllocation *allocation,
int baseline)
{
GtkTransform *transform;
GskTransform *transform;
if (allocation->x || allocation->y)
transform = gtk_transform_translate (NULL, &GRAPHENE_POINT_INIT (allocation->x, allocation->y));
transform = gsk_transform_translate (NULL, &GRAPHENE_POINT_INIT (allocation->x, allocation->y));
else
transform = NULL;
@@ -4142,7 +4158,7 @@ gtk_widget_size_allocate (GtkWidget *widget,
baseline,
transform);
gtk_transform_unref (transform);
gsk_transform_unref (transform);
}
/**
@@ -4167,7 +4183,7 @@ gtk_widget_allocate (GtkWidget *widget,
int width,
int height,
int baseline,
GtkTransform *transform)
GskTransform *transform)
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
GdkRectangle adjusted;
@@ -4179,8 +4195,7 @@ gtk_widget_allocate (GtkWidget *widget,
gint min_width, min_height;
GtkCssStyle *style;
GtkBorder margin, border, padding;
graphene_matrix_t transform_matrix;
GtkTransform *css_transform;
GskTransform *css_transform;
#ifdef G_ENABLE_DEBUG
GdkDisplay *display;
#endif
@@ -4216,11 +4231,11 @@ gtk_widget_allocate (GtkWidget *widget,
baseline_changed = priv->allocated_size_baseline != baseline;
size_changed = (priv->allocated_width != width ||
priv->allocated_height != height);
transform_changed = !gtk_transform_equal (priv->allocated_transform, transform);
transform_changed = !gsk_transform_equal (priv->allocated_transform, transform);
/* order is important, sometimes priv->allocated_transform == transform */
gtk_transform_ref (transform);
gtk_transform_unref (priv->allocated_transform);
gsk_transform_ref (transform);
gsk_transform_unref (priv->allocated_transform);
priv->allocated_transform = transform;
priv->allocated_width = width;
priv->allocated_height = height;
@@ -4301,12 +4316,12 @@ gtk_widget_allocate (GtkWidget *widget,
if (css_transform)
{
transform = gtk_transform_translate (transform, &GRAPHENE_POINT_INIT (adjusted.x, adjusted.y));
transform = gsk_transform_translate (transform, &GRAPHENE_POINT_INIT (adjusted.x, adjusted.y));
adjusted.x = adjusted.y = 0;
transform = gtk_transform_translate (transform, &GRAPHENE_POINT_INIT (adjusted.width / 2, adjusted.height / 2));
transform = gtk_transform_transform (transform, css_transform);
transform = gtk_transform_translate (transform, &GRAPHENE_POINT_INIT (- adjusted.width / 2, - adjusted.height / 2));
transform = gsk_transform_translate (transform, &GRAPHENE_POINT_INIT (adjusted.width / 2, adjusted.height / 2));
transform = gsk_transform_transform (transform, css_transform);
transform = gsk_transform_translate (transform, &GRAPHENE_POINT_INIT (- adjusted.width / 2, - adjusted.height / 2));
}
get_box_margin (style, &margin);
@@ -4323,13 +4338,10 @@ gtk_widget_allocate (GtkWidget *widget,
margin.bottom + border.bottom + padding.bottom;
if (baseline >= 0)
baseline -= margin.top + border.top + padding.top;
graphene_matrix_init_translate (&priv->transform, &GRAPHENE_POINT3D_INIT (adjusted.x, adjusted.y, 0));
gtk_transform_to_matrix (transform, &transform_matrix);
graphene_matrix_multiply (&priv->transform, &transform_matrix, &priv->transform);
priv->transform_category = gtk_transform_categorize (transform);
if (adjusted.x || adjusted.y)
priv->transform_category = MIN (priv->transform_category, GSK_MATRIX_CATEGORY_2D_TRANSLATE);
transform = gsk_transform_translate (transform, &GRAPHENE_POINT_INIT (adjusted.x, adjusted.y));
priv->transform = transform;
if (!alloc_needed && !size_changed && !baseline_changed)
{
@@ -6213,11 +6225,11 @@ _gtk_widget_set_visible_flag (GtkWidget *widget,
if (!visible)
{
g_clear_pointer (&priv->allocated_transform, gtk_transform_unref);
g_clear_pointer (&priv->allocated_transform, gsk_transform_unref);
priv->allocated_width = 0;
priv->allocated_height = 0;
priv->allocated_size_baseline = 0;
graphene_matrix_init_identity (&priv->transform);
g_clear_pointer (&priv->transform, gsk_transform_unref);
priv->width = 0;
priv->height = 0;
gtk_widget_update_paintables (widget);
@@ -11068,6 +11080,7 @@ gtk_widget_get_allocation (GtkWidget *widget,
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
const graphene_rect_t *margin_rect;
float dx, dy;
GtkCssBoxes boxes;
g_return_if_fail (GTK_IS_WIDGET (widget));
@@ -11076,10 +11089,13 @@ gtk_widget_get_allocation (GtkWidget *widget,
gtk_css_boxes_init (&boxes, widget);
margin_rect = gtk_css_boxes_get_margin_rect (&boxes);
allocation->x = graphene_matrix_get_value (&priv->transform, 3, 0) +
ceil (margin_rect->origin.x);
allocation->y = graphene_matrix_get_value (&priv->transform, 3, 1) +
ceil (margin_rect->origin.y);
if (gsk_transform_get_category (priv->transform) >= GSK_TRANSFORM_CATEGORY_2D_TRANSLATE)
gsk_transform_to_translate (priv->transform, &dx, &dy);
else
dx = dy = 0;
allocation->x = dx + ceil (margin_rect->origin.x);
allocation->y = dy + ceil (margin_rect->origin.y);
allocation->width = ceil (margin_rect->size.width);
allocation->height = ceil (margin_rect->size.height);
}
@@ -11198,7 +11214,7 @@ gtk_widget_compute_transform (GtkWidget *widget,
graphene_matrix_t *out_transform)
{
GtkWidget *ancestor, *iter;
graphene_matrix_t transform, inverse;
graphene_matrix_t transform, inverse, tmp;
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
g_return_val_if_fail (GTK_IS_WIDGET (target), FALSE);
@@ -11207,7 +11223,7 @@ gtk_widget_compute_transform (GtkWidget *widget,
/* optimization for common case: parent wants coordinates of a direct child */
if (target == widget->priv->parent)
{
graphene_matrix_init_from_matrix (out_transform, &widget->priv->transform);
gsk_transform_to_matrix (widget->priv->transform, out_transform);
return TRUE;
}
@@ -11222,8 +11238,9 @@ gtk_widget_compute_transform (GtkWidget *widget,
for (iter = widget; iter != ancestor; iter = iter->priv->parent)
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (iter);
gsk_transform_to_matrix (priv->transform, &tmp);
graphene_matrix_multiply (&transform, &priv->transform, &transform);
graphene_matrix_multiply (&transform, &tmp, &transform);
}
/* optimization for common case: parent wants coordinates of a non-direct child */
@@ -11237,8 +11254,9 @@ gtk_widget_compute_transform (GtkWidget *widget,
for (iter = target; iter != ancestor; iter = iter->priv->parent)
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (iter);
gsk_transform_to_matrix (priv->transform, &tmp);
graphene_matrix_multiply (&inverse, &priv->transform, &inverse);
graphene_matrix_multiply (&inverse, &tmp, &inverse);
}
if (!graphene_matrix_inverse (&inverse, &inverse))
{
@@ -13418,7 +13436,7 @@ gtk_widget_snapshot_child (GtkWidget *widget,
g_return_if_fail (snapshot != NULL);
gtk_snapshot_save (snapshot);
gtk_snapshot_transform_matrix_with_category (snapshot, &priv->transform, priv->transform_category);
gtk_snapshot_transform (snapshot, priv->transform);
gtk_widget_snapshot (child, snapshot);
+1 -1
View File
@@ -407,7 +407,7 @@ void gtk_widget_allocate (GtkWidget *widget,
int width,
int height,
int baseline,
GtkTransform *transform);
GskTransform *transform);
GDK_AVAILABLE_IN_ALL
GtkSizeRequestMode gtk_widget_get_request_mode (GtkWidget *widget);
+2 -3
View File
@@ -144,13 +144,12 @@ struct _GtkWidgetPrivate
GtkStyleContext *context;
/* The widget's allocated size */
GtkTransform *allocated_transform;
GskTransform *allocated_transform;
int allocated_width;
int allocated_height;
gint allocated_size_baseline;
graphene_matrix_t transform;
GskMatrixCategory transform_category;
GskTransform *transform;
int width;
int height;
int baseline;
+15 -18
View File
@@ -33,6 +33,7 @@
#include <gsk/gskrendererprivate.h>
#include <gsk/gskrendernodeprivate.h>
#include <gsk/gskroundedrectprivate.h>
#include <gsk/gsktransformprivate.h>
#include <glib/gi18n-lib.h>
#include <gdk/gdktextureprivate.h>
@@ -889,26 +890,22 @@ populate_render_node_properties (GtkListStore *store,
case GSK_TRANSFORM_NODE:
{
static const char * category_names[] = {
[GSK_MATRIX_CATEGORY_UNKNOWN] = "unknown",
[GSK_MATRIX_CATEGORY_ANY] = "any",
[GSK_MATRIX_CATEGORY_INVERTIBLE] = "invertible",
[GSK_MATRIX_CATEGORY_2D_AFFINE] = "2D affine",
[GSK_MATRIX_CATEGORY_2D_TRANSLATE] = "2D transform",
[GSK_MATRIX_CATEGORY_IDENTITY] = "identity"
[GSK_TRANSFORM_CATEGORY_UNKNOWN] = "unknown",
[GSK_TRANSFORM_CATEGORY_ANY] = "any",
[GSK_TRANSFORM_CATEGORY_3D] = "3D",
[GSK_TRANSFORM_CATEGORY_2D] = "2D",
[GSK_TRANSFORM_CATEGORY_2D_AFFINE] = "2D affine",
[GSK_TRANSFORM_CATEGORY_2D_TRANSLATE] = "2D translate",
[GSK_TRANSFORM_CATEGORY_IDENTITY] = "identity"
};
float f[16];
guint i;
GskTransform *transform;
char *s;
graphene_matrix_to_float (gsk_transform_node_peek_transform (node), f);
for (i = 0; i < 4; i++)
{
char *row_string = g_strdup_printf ("%.2f, %.2f, %.2f, %.2f",
f[4 * i], f[4 * i + 1],
f[4 * i + 2], f[4 * i + 3]);
add_text_row (store, i == 0 ? "Matrix" : "", row_string);
g_free (row_string);
}
add_text_row (store, "Category", category_names[gsk_transform_node_get_category (node)]);
transform = gsk_transform_node_get_transform (node);
s = gsk_transform_to_string (transform);
add_text_row (store, "Matrix", s);
g_free (s);
add_text_row (store, "Category", category_names[gsk_transform_get_category (transform)]);
}
break;
-2
View File
@@ -375,7 +375,6 @@ gtk_public_sources = files([
'gtktoolshell.c',
'gtktooltip.c',
'gtktooltipwindow.c',
'gtktransform.c',
'gtktreednd.c',
'gtktreelistmodel.c',
'gtktreemenu.c',
@@ -606,7 +605,6 @@ gtk_public_headers = files([
'gtktoolitem.h',
'gtktoolshell.h',
'gtktooltip.h',
'gtktransform.h',
'gtktreednd.h',
'gtktreelistmodel.h',
'gtktreemodel.h',
+1 -1
View File
@@ -3907,7 +3907,7 @@ filechooserbutton:drop(active) {
border-left-style: none;
}
@at-root %sidebar_right
@at-root %sidebar_right,
&:dir(rtl),
&.right {
border-left: 1px solid $borders_color;
+1 -1
View File
@@ -1693,7 +1693,7 @@ filechooserbutton:drop(active) { box-shadow: none; border-color: transparent; }
stacksidebar.sidebar:dir(ltr) list, stacksidebar.sidebar.left list, stacksidebar.sidebar.left:dir(rtl) list, .sidebar:not(separator):dir(ltr), .sidebar:not(separator).left, .sidebar:not(separator).left:dir(rtl) { border-right: 1px solid #1b1b1b; border-left-style: none; }
stacksidebar.sidebar:dir(rtl) list .sidebar:not(separator):dir(rtl), stacksidebar.sidebar.right list .sidebar:not(separator):dir(rtl), .sidebar:not(separator).right { border-left: 1px solid #1b1b1b; border-right-style: none; }
stacksidebar.sidebar:dir(rtl) list, stacksidebar.sidebar.right list, .sidebar:not(separator):dir(rtl), .sidebar:not(separator).right { border-left: 1px solid #1b1b1b; border-right-style: none; }
.sidebar:backdrop { background-color: #323232; border-color: #202020; transition: 200ms ease-out; }
+1 -1
View File
@@ -1713,7 +1713,7 @@ filechooserbutton:drop(active) { box-shadow: none; border-color: transparent; }
stacksidebar.sidebar:dir(ltr) list, stacksidebar.sidebar.left list, stacksidebar.sidebar.left:dir(rtl) list, .sidebar:not(separator):dir(ltr), .sidebar:not(separator).left, .sidebar:not(separator).left:dir(rtl) { border-right: 1px solid #cdc7c2; border-left-style: none; }
stacksidebar.sidebar:dir(rtl) list .sidebar:not(separator):dir(rtl), stacksidebar.sidebar.right list .sidebar:not(separator):dir(rtl), .sidebar:not(separator).right { border-left: 1px solid #cdc7c2; border-right-style: none; }
stacksidebar.sidebar:dir(rtl) list, stacksidebar.sidebar.right list, .sidebar:not(separator):dir(rtl), .sidebar:not(separator).right { border-left: 1px solid #cdc7c2; border-right-style: none; }
.sidebar:backdrop { background-color: #f9f9f8; border-color: #d5d0cc; transition: 200ms ease-out; }
+1 -1
View File
@@ -35,7 +35,7 @@ gdk_pixbuf_req = '>= 2.30.0'
introspection_req = '>= 1.39.0'
wayland_proto_req = '>= 1.12'
wayland_req = '>= 1.14.91'
graphene_req = '>= 1.5.1'
graphene_req = '>= 1.8.5'
epoxy_req = '>= 1.4'
cloudproviders_req = '>= 0.2.5'
xkbcommon_req = '>= 0.2.0'
+31 -53
View File
@@ -11,8 +11,8 @@ msgid ""
msgstr ""
"Project-Id-Version: gtk+ master\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-02-14 17:14+0000\n"
"PO-Revision-Date: 2019-02-14 18:28+0100\n"
"POT-Creation-Date: 2019-03-02 16:48+0000\n"
"PO-Revision-Date: 2019-03-02 20:56+0100\n"
"Last-Translator: Matej Urbančič <mateju@svn.gnome.org>\n"
"Language-Team: Slovenian GNOME Translation Team <gnome-si@googlegroups.com>\n"
"Language: sl_SI\n"
@@ -22,7 +22,7 @@ msgstr ""
"Plural-Forms: nplurals=4; plural=(n%100==1 ? 1 : n%100==2 ? 2 : n%100==3 || n"
"%100==4 ? 3 : 0);\n"
"X-Poedit-SourceCharset: utf-8\n"
"X-Generator: Poedit 2.1.1\n"
"X-Generator: Poedit 2.0.6\n"
#: gdk/broadway/gdkbroadway-server.c:144
#, c-format
@@ -1242,7 +1242,7 @@ msgstr ""
#: gtk/gtkmountoperation.c:545 gtk/gtkpagesetupunixdialog.c:196
#: gtk/gtkprintbackend.c:781 gtk/gtkprinteroptionwidget.c:545
#: gtk/gtkprintunixdialog.c:673 gtk/gtkprintunixdialog.c:746
#: gtk/gtkwindow.c:12779 gtk/inspector/css-editor.c:201
#: gtk/gtkwindow.c:12792 gtk/inspector/css-editor.c:201
#: gtk/ui/gtkappchooserdialog.ui:61 gtk/ui/gtkassistant.ui:125
#: gtk/ui/gtkcolorchooserdialog.ui:34 gtk/ui/gtkfontchooserdialog.ui:31
msgid "_Cancel"
@@ -1291,7 +1291,7 @@ msgid "_Apply"
msgstr "_Uveljavi"
#: gtk/deprecated/gtkfontsel.c:1698 gtk/gtkmessagedialog.c:944
#: gtk/gtkmessagedialog.c:966 gtk/gtkprintbackend.c:782 gtk/gtkwindow.c:12780
#: gtk/gtkmessagedialog.c:966 gtk/gtkprintbackend.c:782 gtk/gtkwindow.c:12793
msgid "_OK"
msgstr "_V redu"
@@ -1532,36 +1532,36 @@ msgstr "_Zapri"
msgid "Could not show link"
msgstr "Povezave ni mogoče pokazati"
#: gtk/gtkaboutdialog.c:1035
#: gtk/gtkaboutdialog.c:1037
msgid "Website"
msgstr "Spletišče"
#. used for the application menu on MacOS. %s is replaced with the application name.
#: gtk/gtkaboutdialog.c:1085 gtk/ui/gtkapplication-quartz.ui:7
#: gtk/gtkaboutdialog.c:1087 gtk/ui/gtkapplication-quartz.ui:7
#, c-format
msgid "About %s"
msgstr "O programu %s"
#: gtk/gtkaboutdialog.c:2312
#: gtk/gtkaboutdialog.c:2314
msgid "Created by"
msgstr "Ustvarili:"
#: gtk/gtkaboutdialog.c:2315
#: gtk/gtkaboutdialog.c:2317
msgid "Documented by"
msgstr "Dokumentacija:"
#: gtk/gtkaboutdialog.c:2325
#: gtk/gtkaboutdialog.c:2327
msgid "Translated by"
msgstr "Prevod:"
#: gtk/gtkaboutdialog.c:2330
#: gtk/gtkaboutdialog.c:2332
msgid "Artwork by"
msgstr "Grafična podoba:"
#. Translators: this is the license preamble; the string at the end
#. * contains the name of the license as link text.
#.
#: gtk/gtkaboutdialog.c:2490
#: gtk/gtkaboutdialog.c:2494
#, c-format
msgid ""
"This program comes with absolutely no warranty.\n"
@@ -1761,7 +1761,7 @@ msgstr "Ni mogoče razčleniti vrednosti za %s::%s: %s\n"
msgid "Can't parse file: %s\n"
msgstr "Ni mogoče razčleniti datoteke: %s\n"
#: gtk/gtk-builder-tool.c:1056
#: gtk/gtk-builder-tool.c:1058
#, c-format
msgid ""
"Usage:\n"
@@ -2159,11 +2159,11 @@ msgstr "default:mm"
msgid "Manage Custom Sizes"
msgstr "Upravljanje poljubnih velikosti"
#: gtk/gtkcustompaperunixdialog.c:567 gtk/gtkpagesetupunixdialog.c:811
#: gtk/gtkcustompaperunixdialog.c:567 gtk/gtkpagesetupunixdialog.c:813
msgid "inch"
msgstr "palec"
#: gtk/gtkcustompaperunixdialog.c:569 gtk/gtkpagesetupunixdialog.c:809
#: gtk/gtkcustompaperunixdialog.c:569 gtk/gtkpagesetupunixdialog.c:811
msgid "mm"
msgstr "mm"
@@ -2594,7 +2594,7 @@ msgstr "Sans 12"
msgid "Pick a Font"
msgstr "Izberite pisavo"
#: gtk/gtkfontbutton.c:1393
#: gtk/gtkfontbutton.c:1395
msgctxt "font"
msgid "None"
msgstr "Brez"
@@ -2720,8 +2720,6 @@ msgid "Show program version"
msgstr "Pokaži različico programa"
#: gtk/gtk-launch.c:74
#, fuzzy
#| msgid "APPLICATION [URI...] — launch an APPLICATION"
msgid "APPLICATION [URI...] — launch an APPLICATION"
msgstr "PROGRAM [URI ...] zagon PROGRAMA z naslovom URI"
@@ -2970,7 +2968,7 @@ msgstr "Katerikoli tiskalnik"
msgid "For portable documents"
msgstr "Za prenosljive dokumente"
#: gtk/gtkpagesetupunixdialog.c:829
#: gtk/gtkpagesetupunixdialog.c:831
#, c-format
msgid ""
"Margins:\n"
@@ -2985,11 +2983,11 @@ msgstr ""
" Zgoraj: %s %s\n"
" Spodaj: %s %s"
#: gtk/gtkpagesetupunixdialog.c:878 gtk/gtkprintunixdialog.c:3390
#: gtk/gtkpagesetupunixdialog.c:880 gtk/gtkprintunixdialog.c:3392
msgid "Manage Custom Sizes…"
msgstr "Upravljanje poljubnih velikosti ..."
#: gtk/gtkpagesetupunixdialog.c:900 gtk/ui/gtkpagesetupunixdialog.ui:31
#: gtk/gtkpagesetupunixdialog.c:902 gtk/ui/gtkpagesetupunixdialog.ui:31
#: gtk/ui/gtkprintunixdialog.ui:854
msgid "Page Setup"
msgstr "Nastavitev strani"
@@ -3335,7 +3333,7 @@ msgstr "Zapomni si _geslo"
msgid "Select a filename"
msgstr "Izbor imena datoteke"
#: gtk/gtkprinteroptionwidget.c:767
#: gtk/gtkprinteroptionwidget.c:769
msgid "Not available"
msgstr "Ni na voljo"
@@ -3398,7 +3396,7 @@ msgstr "Končano z napako"
msgid "Preparing %d"
msgstr "Pripravljanje %d"
#: gtk/gtkprintoperation.c:2376 gtk/gtkprintoperation.c:3005
#: gtk/gtkprintoperation.c:2376 gtk/gtkprintoperation.c:3007
#, c-format
msgid "Preparing"
msgstr "Pripravljanje"
@@ -3408,19 +3406,19 @@ msgstr "Pripravljanje"
msgid "Printing %d"
msgstr "Tiskanje %d"
#: gtk/gtkprintoperation.c:3036
#: gtk/gtkprintoperation.c:3038
#, c-format
msgid "Error creating print preview"
msgstr "Napaka med ustvarjanjem predogleda tiskanja"
#: gtk/gtkprintoperation.c:3039
#: gtk/gtkprintoperation.c:3041
#, c-format
msgid "The most probable reason is that a temporary file could not be created."
msgstr "Najverjetnejši razlog je, da začasne datoteke ni mogoče ustvariti"
#. window
#: gtk/gtkprintoperation-portal.c:231 gtk/gtkprintoperation-portal.c:542
#: gtk/gtkprintoperation-portal.c:611 gtk/gtkprintunixdialog.c:3412
#: gtk/gtkprintoperation-portal.c:611 gtk/gtkprintunixdialog.c:3414
msgid "Print"
msgstr "Natisni"
@@ -3661,9 +3659,7 @@ msgid "Unable to move the item with URI '%s' to '%s'"
msgstr "Predmeta z naslovom URI »%s« ni mogoče premakniti v »%s«."
#: gtk/gtkrecentmanager.c:2507
#, fuzzy, c-format
#| msgid ""
#| "No registered application with name '%s' for item with URI '%s' found"
#, c-format
msgid "No registered application with name '%s' for item with URI '%s' found"
msgstr ""
"Ni mogoče najti programa z imenom »%s« za odpiranje predmetov z naslovom URI "
@@ -3936,12 +3932,12 @@ msgstr "Spremeni velikost"
msgid "Always on Top"
msgstr "Vedno na vrhu"
#: gtk/gtkwindow.c:12767
#: gtk/gtkwindow.c:12780
#, c-format
msgid "Do you want to use GTK+ Inspector?"
msgstr "Ali želite uporabljati nadzorni program GTK+?"
#: gtk/gtkwindow.c:12769
#: gtk/gtkwindow.c:12782
#, c-format
msgid ""
"GTK+ Inspector is an interactive debugger that lets you explore and modify "
@@ -3951,9 +3947,7 @@ msgstr ""
"Nadzornik GTK+ je razhroščevalnik, ki omogoča raziskovanje in spreminjanje "
"nastavitev GTK+. Neustrezna raba lahko povzroči nedelovanje okolja."
#: gtk/gtkwindow.c:12774
#, fuzzy
#| msgid "Don't show this message again"
#: gtk/gtkwindow.c:12787
msgid "Don't show this message again"
msgstr "Sporočila ne pokaži več"
@@ -4158,8 +4152,6 @@ msgid "Frame Clock"
msgstr "Okvir ure"
#: gtk/inspector/misc-info.ui:475
#, fuzzy
#| msgid "Tick callback"
msgid "Tick callback"
msgstr "Označi povratni sklic"
@@ -4416,10 +4408,6 @@ msgid "Setting is hardcoded by GTK_TEST_TOUCHSCREEN"
msgstr "Nastavitev je vključena v privzeto vrednost GTK_TEST_TOUCHSCREEN"
#: gtk/inspector/visual.c:791
#, fuzzy
#| msgid ""
#| "Not settable at runtime.\n"
#| "Use GDK_GL=always or GDK_GL=disable instead"
msgid ""
"Not settable at runtime.\n"
"Use GDK_GL=always or GDK_GL=disable instead"
@@ -4521,8 +4509,6 @@ msgid "Show Widget Resizes"
msgstr "Pokaži prilagajanje velikosti gradnika"
#: gtk/inspector/visual.ui:683
#, fuzzy
#| msgid "Simulate touchscreen"
msgid "Simulate touchscreen"
msgstr "Simuliraj zaslon na dotik"
@@ -4531,8 +4517,6 @@ msgid "GL Rendering"
msgstr "Izrisovanje GL"
#: gtk/inspector/visual.ui:740
#, fuzzy
#| msgid "When Needed"
msgid "When needed"
msgstr "Ko je zahtevano"
@@ -5011,12 +4995,9 @@ msgid "NLC Kanji Forms"
msgstr ""
#: gtk/open-type-layout.h:79
#, fuzzy
#| msgctxt "print operation status"
#| msgid "Initial state"
msgctxt "OpenType layout"
msgid "Nukta Forms"
msgstr "Začetno stanje"
msgstr "Oblike nukta"
#: gtk/open-type-layout.h:80
msgctxt "OpenType layout"
@@ -5311,10 +5292,9 @@ msgid "Trailing Jamo Forms"
msgstr "Pozivnik terminala"
#: gtk/open-type-layout.h:137
#, fuzzy
msgctxt "OpenType layout"
msgid "Traditional Name Forms"
msgstr "Pozivnik terminala"
msgstr "Tradicionalne imenske oblike"
#: gtk/open-type-layout.h:138
#, fuzzy
@@ -5325,11 +5305,9 @@ msgid "Tabular Figures"
msgstr "Zaupno"
#: gtk/open-type-layout.h:139
#, fuzzy
#| msgid "Terminal Pager"
msgctxt "OpenType layout"
msgid "Traditional Forms"
msgstr "Pozivnik terminala"
msgstr "Tradicionalne oblike"
#: gtk/open-type-layout.h:140
msgctxt "OpenType layout"
+5 -5
View File
@@ -104,7 +104,7 @@ gtk_transform_tester_size_allocate (GtkWidget *widget,
int baseline)
{
GtkTransformTester *self = (GtkTransformTester *)widget;
GtkTransform *global_transform;
GskTransform *global_transform;
int w, h;
if (!self->test_widget)
@@ -121,16 +121,16 @@ gtk_transform_tester_size_allocate (GtkWidget *widget,
global_transform = NULL;
global_transform = gtk_transform_translate (global_transform, &GRAPHENE_POINT_INIT (width / 2.0f, height / 2.0f));
global_transform = gtk_transform_rotate (global_transform, scale);
global_transform = gtk_transform_translate (global_transform, &GRAPHENE_POINT_INIT (-w / 2.0f, -h / 2.0f));
global_transform = gsk_transform_translate (global_transform, &GRAPHENE_POINT_INIT (width / 2.0f, height / 2.0f));
global_transform = gsk_transform_rotate (global_transform, scale);
global_transform = gsk_transform_translate (global_transform, &GRAPHENE_POINT_INIT (-w / 2.0f, -h / 2.0f));
gtk_widget_allocate (self->test_widget,
w, h,
-1,
global_transform);
gtk_transform_unref (global_transform);
gsk_transform_unref (global_transform);
}
static void
Binary file not shown.

After

Width:  |  Height:  |  Size: 157 B

Binary file not shown.
Binary file not shown.
-10
View File
@@ -1,10 +0,0 @@
clip {
clip = (60, 80, 60, 70)
rounded_clip {
clip = (20, 50, 100, 100) 50
color {
bounds = (20, 50, 100, 100)
color = (1, 0, 0, 1)
}
}
}
Binary file not shown.
-13
View File
@@ -1,13 +0,0 @@
cross_fade {
progress = 0.5
color {
bounds = (0, 0, 200, 200)
color = (1, 1, 1, 1)
}
linear_gradient {
bounds = (100, 100, 200, 200)
start = (200, 100)
end = (200, 300)
stops = (0, (1, 0, 0, 1)) (1, (0, 1, 0, 1))
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.
Binary file not shown.
-9
View File
@@ -1,9 +0,0 @@
rounded_clip {
clip = (0, 0, 50, 100) 25
linear_gradient {
bounds = (0, 0, 50, 100)
start = (0, 0)
end = (0, 100)
stops = (0, (1, 0, 0, 1)) (1, (0, 0, 1, 1))
}
}
Binary file not shown.
-14
View File
@@ -1,14 +0,0 @@
container {
linear_gradient {
bounds = (0, 0, 50, 100)
start = (0, 0)
end = (0, 100)
stops = (0, (1, 0, 0, 1)) (1, (0, 0, 1, 1))
}
linear_gradient {
bounds = (50, 0, 50, 100)
start = (50, 0)
end = (100, 0)
stops = (0, (1, 0, 0, 1)) (1, (0, 0, 1, 1))
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 744 B

Binary file not shown.
Binary file not shown.
-13
View File
@@ -1,13 +0,0 @@
clip {
clip = (50, 50, 50, 50)
opacity {
opacity = 0.4
rounded_clip {
clip = (50, 50, 100, 100) 50
color {
bounds = (50, 50, 100, 100)
color = (1, 0, 0, 1)
}
}
}
}
Binary file not shown.
@@ -1,8 +0,0 @@
outset_shadow {
outline = (100, 100, 40, 40) (5.714286, 5.714286) (2.857143, 2.857143) (17.142859, 17.142859) (22.857143, 22.857143)
color = (0, 0, 0, 0.5)
dx = 20
dy = 20
spread = 1
blur_radius = 4
}
Binary file not shown.
@@ -1,8 +0,0 @@
outset_shadow {
outline = (100, 100, 200, 200)
color = (0, 0, 0, 1)
dx = 0
dy = 0
spread = 0
blur_radius = 40
}
Binary file not shown.
Binary file not shown.
@@ -1,8 +0,0 @@
outset_shadow {
outline = (100, 100, 40, 40) (5.714286, 5.714286) (2.857143, 2.857143) (17.142859, 17.142859) (22.857143, 22.857143)
color = (0, 0, 0, 0.5)
dx = 0
dy = 0
spread = 1
blur_radius = 4
}
Binary file not shown.
@@ -1,8 +0,0 @@
outset_shadow {
outline = (100, 100, 100, 100)
color = (0, 0, 0, 1)
dx = -100
dy = 100
spread = 10
blur_radius = 0
}
Binary file not shown.
@@ -1,8 +0,0 @@
outset_shadow {
outline = (100, 100, 100, 100)
color = (0, 0, 0, 1)
dx = 10
dy = 0
spread = 10
blur_radius = 0
}
Binary file not shown.
@@ -1,8 +0,0 @@
outset_shadow {
outline = (100, 100, 100, 100)
color = (0, 0, 0, 1)
dx = 0
dy = 10
spread = 10
blur_radius = 0
}
Binary file not shown.
@@ -1,8 +0,0 @@
outset_shadow {
outline = (100, 100, 200, 200) 50 0 50 0
color = (0, 0, 0, 0.5)
dx = 10
dy = 10
spread = 30
blur_radius = 0
}
Binary file not shown.
@@ -1,8 +0,0 @@
outset_shadow {
outline = (100, 100, 200, 200) 0 100 0 100
color = (0, 0, 0, 0.5)
dx = 10
dy = 10
spread = 30
blur_radius = 0
}
Binary file not shown.
@@ -1,8 +0,0 @@
outset_shadow {
outline = (100, 100, 200, 200) 7 7 0 0
color = (0, 0, 0, 1)
dx = 0
dy = 0
spread = 1
blur_radius = 0
}
Binary file not shown.
@@ -1,8 +0,0 @@
outset_shadow {
outline = (100, 100, 100, 100)
color = (0, 0, 0, 1)
dx = 0
dy = 0
spread = 10
blur_radius = 0
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 790 B

Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 1011 B

Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 613 B

+7 -1
View File
@@ -42,16 +42,22 @@ gl_tests = [
['outset shadow blurred simple', 'outset_shadow_blurred_simple'],
['outset shadow blurred small', 'outset_shadow_blurred_small'],
['outset shadow blurred offset', 'outset_shadow_blurred_offset'],
['outset shadow transformed', 'outset_shadow_translated'],
['Transform in Shadow', 'shadow_transform1'],
['Crossfade simple', 'cross_fade'],
['Crossfade transformed', 'cross_fade_transformed'],
['Clipped crossfade', 'clipped_cross_fade'],
['Clipped rounded clip', 'clipped_rounded_clip'],
['clipped rounded clip2', 'transformed_clipped_rounded_clip'],
['gradient simple', 'gradient_simple'],
['gradient transformed', 'gradient_transformed'],
['gradient clipped', 'gradient_clipped'],
['offscreen opacity', 'opacity_clip'],
]
foreach gl_test : gl_tests
test('GL ' + gl_test[0], compare_render,
args: [join_paths(meson.current_source_dir(), 'gl', gl_test[1] + '.txt'),
args: [join_paths(meson.current_source_dir(), 'gl', gl_test[1] + '.node'),
join_paths(meson.current_source_dir(), 'gl', gl_test[1] + '.gl.png')],
env: [ 'GIO_USE_VOLUME_MONITOR=unix',
'GSETTINGS_BACKEND=memory',
+67 -60
View File
@@ -183,7 +183,7 @@ repeat (void)
GskRenderNode *child;
GskRenderNode *transform;
GskRenderNode *container;
graphene_matrix_t matrix;
GskTransform *matrix;
child = cairo ();
@@ -202,18 +202,21 @@ repeat (void)
gsk_render_node_unref (child);
graphene_matrix_init_translate (&matrix, &(const graphene_point3d_t) { 0, 20, 0 });
transform = gsk_transform_node_new (repeat[1], &matrix);
matrix = gsk_transform_translate (NULL, &(const graphene_point_t) { 0, 20 });
transform = gsk_transform_node_new (repeat[1], matrix);
gsk_transform_unref (matrix);
gsk_render_node_unref (repeat[1]);
repeat[1] = transform;
graphene_matrix_init_translate (&matrix, &(const graphene_point3d_t) { 0, 40, 0 });
transform = gsk_transform_node_new (repeat[2], &matrix);
matrix = gsk_transform_translate (NULL, &(const graphene_point_t) { 0, 40 });
transform = gsk_transform_node_new (repeat[2], matrix);
gsk_transform_unref (matrix);
gsk_render_node_unref (repeat[2]);
repeat[2] = transform;
graphene_matrix_init_translate (&matrix, &(const graphene_point3d_t) { 220, -100, 0 });
transform = gsk_transform_node_new (repeat[3], &matrix);
matrix = gsk_transform_translate (NULL, &(const graphene_point_t) { 220, -100 });
transform = gsk_transform_node_new (repeat[3], matrix);
gsk_transform_unref (matrix);
gsk_render_node_unref (repeat[3]);
repeat[3] = transform;
@@ -234,13 +237,14 @@ blendmode (void)
GskRenderNode *child2;
GskRenderNode *transform;
GskRenderNode *container;
graphene_matrix_t matrix;
GskTransform *matrix;
child1 = cairo ();
child2 = cairo2 ();
graphene_matrix_init_translate (&matrix, &(const graphene_point3d_t) { 50, 50, 0 });
transform = gsk_transform_node_new (child2, &matrix);
matrix = gsk_transform_translate (NULL, &(const graphene_point_t) { 50, 50 });
transform = gsk_transform_node_new (child2, matrix);
gsk_transform_unref (matrix);
gsk_render_node_unref (child2);
child2 = transform;
@@ -303,11 +307,12 @@ blendmodes (void)
for (j = 0; j < 4; j++, mode++)
{
GskRenderNode *b;
graphene_matrix_t matrix;
GskTransform *transform;
b = gsk_blend_node_new (child1, child2, mode);
graphene_matrix_init_translate (&matrix, &(const graphene_point3d_t) { i * 110, j * 110, 0 });
blend[mode] = gsk_transform_node_new (b, &matrix);
transform = gsk_transform_translate (NULL, &(const graphene_point_t) { i * 110, j * 110 });
blend[mode] = gsk_transform_node_new (b, transform);
gsk_transform_unref (transform);
gsk_render_node_unref (b);
}
@@ -329,13 +334,14 @@ cross_fade (void)
GskRenderNode *child2;
GskRenderNode *transform;
GskRenderNode *container;
graphene_matrix_t matrix;
GskTransform *matrix;
child1 = cairo ();
child2 = cairo2 ();
graphene_matrix_init_translate (&matrix, &(const graphene_point3d_t) { 50, 50, 0 });
transform = gsk_transform_node_new (child2, &matrix);
matrix = gsk_transform_translate (NULL, &(const graphene_point_t) { 50, 50 });
transform = gsk_transform_node_new (child2, matrix);
gsk_transform_unref (matrix);
gsk_render_node_unref (child2);
child2 = transform;
@@ -355,7 +361,7 @@ cross_fades (void)
GskRenderNode *node;
GskRenderNode *nodes[5];
GskRenderNode *container;
graphene_matrix_t matrix;
GskTransform *transform;
int i;
child1 = cairo2 ();
@@ -364,8 +370,9 @@ cross_fades (void)
for (i = 0; i < 5; i++)
{
node = gsk_cross_fade_node_new (child1, child2, i / 4.0);
graphene_matrix_init_translate (&matrix, &(const graphene_point3d_t) { i* 210, 0, 0 });
nodes[i] = gsk_transform_node_new (node, &matrix);
transform = gsk_transform_translate (NULL, &(const graphene_point_t) { i* 210, 0 });
nodes[i] = gsk_transform_node_new (node, transform);
gsk_transform_unref (transform);
gsk_render_node_unref (node);
}
@@ -386,21 +393,17 @@ transform (void)
GskRenderNode *node;
GskRenderNode *nodes[10];
GskRenderNode *container;
graphene_matrix_t scale;
graphene_matrix_t translate;
graphene_matrix_t matrix;
graphene_vec3_t axis;
graphene_vec3_init (&axis, 0.0, 0.0, 1.0);
GskTransform *transform;
int i;
node = ducky ();
for (i = 0; i < 10; i++)
{
graphene_matrix_init_rotate (&scale, 20.0 * i, &axis);
graphene_matrix_init_translate (&translate, &(const graphene_point3d_t) { i* 110, 0, 0 });
graphene_matrix_multiply (&scale, &translate, &matrix);
nodes[i] = gsk_transform_node_new (node, &matrix);
transform = gsk_transform_rotate (NULL, 20.0 * i);
transform = gsk_transform_translate (transform, &(const graphene_point_t) { i* 110, 0 });
nodes[i] = gsk_transform_node_new (node, transform);
gsk_transform_unref (transform);
}
container = gsk_container_node_new (nodes, 5);
@@ -420,7 +423,7 @@ opacity (void)
GskRenderNode *node;
GskRenderNode *nodes[5];
GskRenderNode *container;
graphene_matrix_t matrix;
GskTransform *transform;
int i;
child = ducky ();
@@ -428,8 +431,9 @@ opacity (void)
for (i = 0; i < 5; i++)
{
node = gsk_opacity_node_new (child, i / 4.0);
graphene_matrix_init_translate (&matrix, &(const graphene_point3d_t) { i* 210, 0, 0 });
nodes[i] = gsk_transform_node_new (node, &matrix);
transform = gsk_transform_translate (NULL, &(const graphene_point_t) { i* 210, 0 });
nodes[i] = gsk_transform_node_new (node, transform);
gsk_transform_unref (transform);
gsk_render_node_unref (node);
}
@@ -454,7 +458,7 @@ color_matrix1 (void)
GskRenderNode *child_nodes[N];
graphene_matrix_t matrix;
graphene_vec4_t offset;
graphene_matrix_t transform;
GskTransform *transform;
float cairo_width = 150;
graphene_rect_t bounds;
@@ -470,14 +474,16 @@ color_matrix1 (void)
offset = *graphene_vec4_zero ();
graphene_matrix_init_scale (&matrix, 0.3, 0.3, 0.3); /* Should make the node darker */
n = gsk_color_matrix_node_new (cairo_node, &matrix, &offset);
graphene_matrix_init_translate (&transform, &GRAPHENE_POINT3D_INIT (cairo_width, 0, 0));
child_nodes[1] = gsk_transform_node_new (n, &transform);
transform = gsk_transform_translate (NULL, &GRAPHENE_POINT_INIT (cairo_width, 0));
child_nodes[1] = gsk_transform_node_new (n, transform);
gsk_transform_unref (transform);
/* Same as above, but this time we stuff the transform node in the color matrix node, and not vice versa */
offset = *graphene_vec4_zero ();
graphene_matrix_init_scale (&matrix, 0.3, 0.3, 0.3);
graphene_matrix_init_translate (&transform, &GRAPHENE_POINT3D_INIT (2 * cairo_width, 0, 0));
n = gsk_transform_node_new (cairo_node, &transform);
transform = gsk_transform_translate (NULL, &GRAPHENE_POINT_INIT (2 * cairo_width, 0));
n = gsk_transform_node_new (cairo_node, transform);
gsk_transform_unref (transform);
child_nodes[2] = gsk_color_matrix_node_new (n, &matrix, &offset);
/* Color matrix inside color matrix, one reversing the other's effect */
@@ -491,8 +497,9 @@ color_matrix1 (void)
graphene_matrix_init_scale (&matrix, 2, 2, 2);
n = gsk_color_matrix_node_new (inner_color_matrix_node, &matrix, &offset);
graphene_matrix_init_translate (&transform, &GRAPHENE_POINT3D_INIT (3 * cairo_width, 0, 0));
child_nodes[3] = gsk_transform_node_new (n, &transform);
transform = gsk_transform_translate (NULL, &GRAPHENE_POINT_INIT (3 * cairo_width, 0));
child_nodes[3] = gsk_transform_node_new (n, transform);
gsk_transform_unref (transform);
}
/* Color matrix in color matrix in transform */
@@ -507,11 +514,12 @@ color_matrix1 (void)
graphene_matrix_init_scale (&matrix, 2, 2, 2);
offset = *graphene_vec4_zero ();
n = gsk_color_matrix_node_new (inner_color_matrix_node, &matrix, &offset);
graphene_matrix_init_scale (&transform, 1, 1, 1);
graphene_matrix_rotate_z (&transform, 350);
graphene_matrix_translate (&transform, &GRAPHENE_POINT3D_INIT (4 * cairo_width, 0, 0));
transform = gsk_transform_scale (NULL, 1, 1);
transform = gsk_transform_rotate (transform, 350);
transform = gsk_transform_translate (transform, &GRAPHENE_POINT_INIT (4 * cairo_width, 0));
child_nodes[4] = gsk_transform_node_new (n, &transform);
child_nodes[4] = gsk_transform_node_new (n, transform);
gsk_transform_unref (transform);
}
container_node = gsk_container_node_new (child_nodes, N);
@@ -528,36 +536,37 @@ transformed_clip (void)
GskRenderNode *transform_node;
GskRenderNode *clip_node;
GskRenderNode *nodes[4];
graphene_matrix_t transform;
GskTransform *transform;
{
clip_node = gsk_clip_node_new (ducky (),
&GRAPHENE_RECT_INIT (0, 0, 200, 500));
graphene_matrix_init_translate (&transform, &GRAPHENE_POINT3D_INIT (180, 0, 0));
nodes[0] = gsk_transform_node_new (clip_node, &transform);
transform = gsk_transform_translate (NULL, &GRAPHENE_POINT_INIT (180, 0));
nodes[0] = gsk_transform_node_new (clip_node, transform);
gsk_transform_unref (transform);
}
{
graphene_matrix_init_translate (&transform, &GRAPHENE_POINT3D_INIT (0, 200, 0));
transform_node = gsk_transform_node_new (ducky (), &transform);
transform = gsk_transform_translate (NULL, &GRAPHENE_POINT_INIT (0, 200));
transform_node = gsk_transform_node_new (ducky (), transform);
gsk_transform_unref (transform);
nodes[1] = gsk_clip_node_new (transform_node,
&GRAPHENE_RECT_INIT (0, 0, 500, 250));
}
{
graphene_vec3_t axis_vec;
graphene_matrix_init_translate (&transform, &GRAPHENE_POINT3D_INIT (150, 200, 0));
transform_node = gsk_transform_node_new (ducky (), &transform);
transform = gsk_transform_translate (NULL, &GRAPHENE_POINT_INIT (150, 200));
transform_node = gsk_transform_node_new (ducky (), transform);
gsk_transform_unref (transform);
clip_node = gsk_clip_node_new (transform_node,
&GRAPHENE_RECT_INIT (150, 200, 91, 100));
graphene_vec3_init (&axis_vec, 0, 0, 1);
graphene_matrix_init_rotate (&transform, 20, &axis_vec);
transform = gsk_transform_rotate (NULL, 20);
/*graphene_matrix_init_identity (&transform);*/
nodes[2] = gsk_transform_node_new (clip_node, &transform);
nodes[2] = gsk_transform_node_new (clip_node, transform);
gsk_transform_unref (transform);
@@ -576,12 +585,10 @@ transformed_clip (void)
}
{
graphene_vec3_t axis_vec;
graphene_vec3_init (&axis_vec, 0, 0, 1);
graphene_matrix_init_rotate (&transform, 20, &axis_vec);
graphene_matrix_translate (&transform, &GRAPHENE_POINT3D_INIT (350, 200, 0));
transform_node = gsk_transform_node_new (ducky (), &transform);
transform = gsk_transform_rotate (NULL, 20);
transform = gsk_transform_translate (transform, &GRAPHENE_POINT_INIT (350, 200));
transform_node = gsk_transform_node_new (ducky (), transform);
gsk_transform_unref (transform);
nodes[3] = gsk_clip_node_new (transform_node,
&GRAPHENE_RECT_INIT (350, 200, 91, 100));
}
+1
View File
@@ -52,6 +52,7 @@ tests = [
['templates'],
['textbuffer'],
['textiter'],
['transform'],
['treelistmodel'],
['treemodel', ['treemodel.c', 'liststore.c', 'treestore.c', 'filtermodel.c',
'modelrefcount.c', 'sortmodel.c', 'gtktreemodelrefcount.c']],
+293
View File
@@ -0,0 +1,293 @@
/*
* Copyright © 2019 Benjamin Otte
*
* 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 library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Benjamin Otte <otte@gnome.org>
*/
#include "config.h"
#include <gtk/gtk.h>
#define EPSILON (1.f / 1024 / 32) /* 2^-15 */
/* macros stolen from graphene testsuite, so they get to keep their names */
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9))
/* Use typeof on GCC */
# define graphene_fuzzy_equals(n1,n2,epsilon) \
G_GNUC_EXTENSION({ \
__auto_type _n1 = (n1); \
__auto_type _n2 = (n2); \
__auto_type _epsilon = (epsilon); \
((_n1 > _n2 ? (_n1 - _n2 ) : (_n2 - _n1)) <= _epsilon); \
})
#else
/* fallback for Visual Studio, typeof not supported */
# define graphene_fuzzy_equals(n1,n2,epsilon) \
(((n1) > (n2) ? ((n1) - (n2)) : ((n2) - (n1))) <= (epsilon))
#endif /* __GNUC__ */
#define graphene_assert_fuzzy_matrix_cell_equal(row,col,n1,n2,epsilon) \
G_STMT_START { \
if (graphene_fuzzy_equals (n1, n2, epsilon)) ; else { \
char *s = g_strdup_printf ("[%d][%d]: " #n1 " == " #n2 " (+/- " #epsilon "): (%.7g == %.7g)", \
row, col, n1, n2); \
g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, s); \
g_free (s); \
} \
} G_STMT_END
#define graphene_assert_fuzzy_matrix_equal(m1,m2,epsilon) \
G_STMT_START { \
unsigned int __i, __j; \
float __m1[16], __m2[16]; \
graphene_matrix_to_float ((m1), __m1); \
graphene_matrix_to_float ((m2), __m2); \
for (__i = 0; __i < 4; __i++) { \
for (__j = 0; __j < 4; __j++) { \
unsigned int __idx = __i * 4 + __j; \
graphene_assert_fuzzy_matrix_cell_equal (__i, __j, __m1[__idx], __m2[__idx], epsilon); \
} \
} \
} G_STMT_END
#define graphene_assert_fuzzy_transform_equal(t1,t2,epsilon) \
G_STMT_START { \
graphene_matrix_t __mat1, __mat2; \
gsk_transform_to_matrix ((t1), &__mat1); \
gsk_transform_to_matrix ((t2), &__mat2); \
graphene_assert_fuzzy_matrix_equal (&__mat1, &__mat2, (epsilon)); \
} G_STMT_END
static struct {
GskTransformCategory category;
} test_transforms[] = {
{ GSK_TRANSFORM_CATEGORY_IDENTITY },
{ GSK_TRANSFORM_CATEGORY_IDENTITY },
{ GSK_TRANSFORM_CATEGORY_2D_TRANSLATE },
{ GSK_TRANSFORM_CATEGORY_3D },
{ GSK_TRANSFORM_CATEGORY_2D },
{ GSK_TRANSFORM_CATEGORY_3D },
{ GSK_TRANSFORM_CATEGORY_2D_AFFINE },
{ GSK_TRANSFORM_CATEGORY_3D },
{ GSK_TRANSFORM_CATEGORY_ANY },
};
static GskTransform *
apply_test_transform (GskTransform *transform,
guint i)
{
switch (i)
{
case 0:
return transform ? transform : gsk_transform_new ();
case 1:
return gsk_transform_transform (transform, NULL);
case 2:
return gsk_transform_translate (transform, &GRAPHENE_POINT_INIT (3, 5));
case 3:
return gsk_transform_translate_3d (transform, &GRAPHENE_POINT3D_INIT (3, 5, 7));
case 4:
return gsk_transform_rotate (transform, 90);
case 5:
return gsk_transform_rotate_3d (transform, 90, graphene_vec3_y_axis ());
case 6:
return gsk_transform_scale (transform, 2, 3);
case 7:
return gsk_transform_scale_3d (transform, 2, 3, 5);
case 8:
return gsk_transform_perspective (transform, 5);
default:
g_assert_not_reached ();
return NULL;
}
}
static GskTransformCategory
categorize_matrix (const graphene_matrix_t *matrix)
{
if (!graphene_fuzzy_equals (graphene_matrix_get_value (matrix, 0, 3), 0, EPSILON) ||
!graphene_fuzzy_equals (graphene_matrix_get_value (matrix, 1, 3), 0, EPSILON) ||
!graphene_fuzzy_equals (graphene_matrix_get_value (matrix, 2, 3), 0, EPSILON) ||
!graphene_fuzzy_equals (graphene_matrix_get_value (matrix, 3, 3), 1, EPSILON))
return GSK_TRANSFORM_CATEGORY_ANY;
if (!graphene_fuzzy_equals (graphene_matrix_get_value (matrix, 0, 2), 0, EPSILON) ||
!graphene_fuzzy_equals (graphene_matrix_get_value (matrix, 1, 2), 0, EPSILON) ||
!graphene_fuzzy_equals (graphene_matrix_get_value (matrix, 2, 2), 1, EPSILON) ||
!graphene_fuzzy_equals (graphene_matrix_get_value (matrix, 3, 2), 0, EPSILON) ||
!graphene_fuzzy_equals (graphene_matrix_get_value (matrix, 2, 0), 0, EPSILON) ||
!graphene_fuzzy_equals (graphene_matrix_get_value (matrix, 2, 1), 0, EPSILON))
return GSK_TRANSFORM_CATEGORY_3D;
if (!graphene_fuzzy_equals (graphene_matrix_get_value (matrix, 0, 1), 0, EPSILON) ||
!graphene_fuzzy_equals (graphene_matrix_get_value (matrix, 1, 0), 0, EPSILON))
return GSK_TRANSFORM_CATEGORY_2D;
if (!graphene_fuzzy_equals (graphene_matrix_get_value (matrix, 0, 0), 1, EPSILON) ||
!graphene_fuzzy_equals (graphene_matrix_get_value (matrix, 1, 1), 1, EPSILON))
return GSK_TRANSFORM_CATEGORY_2D_AFFINE;
if (!graphene_fuzzy_equals (graphene_matrix_get_value (matrix, 3, 0), 0, EPSILON) ||
!graphene_fuzzy_equals (graphene_matrix_get_value (matrix, 3, 1), 0, EPSILON))
return GSK_TRANSFORM_CATEGORY_2D_TRANSLATE;
return GSK_TRANSFORM_CATEGORY_IDENTITY;
}
static void
check_conversions (GskTransform *transform,
GskTransformCategory expected_category)
{
graphene_matrix_t matrix, test;
float f[16] = { 1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1 };
g_assert_cmpint (gsk_transform_get_category (transform), ==, expected_category);
gsk_transform_to_matrix (transform, &matrix);
/* we don't insist on getting simplifications right.
* The matrix "scale(2) scale(0.5)" would be categorized as identity,
* but the transform might not do that.
*/
g_assert_cmpint (gsk_transform_get_category (transform), <=, categorize_matrix (&matrix));
switch (expected_category)
{
case GSK_TRANSFORM_CATEGORY_UNKNOWN:
case GSK_TRANSFORM_CATEGORY_ANY:
case GSK_TRANSFORM_CATEGORY_3D:
break;
case GSK_TRANSFORM_CATEGORY_IDENTITY:
case GSK_TRANSFORM_CATEGORY_2D_TRANSLATE:
gsk_transform_to_translate (transform,
&f[4 * 3 + 0], &f[4 * 3 + 1]);
graphene_matrix_init_from_float (&test, f);
graphene_assert_fuzzy_matrix_equal (&matrix, &test, EPSILON);
/* fallthrough */
case GSK_TRANSFORM_CATEGORY_2D_AFFINE:
gsk_transform_to_affine (transform,
&f[4 * 0 + 0], &f[4 * 1 + 1],
&f[4 * 3 + 0], &f[4 * 3 + 1]);
graphene_matrix_init_from_float (&test, f);
graphene_assert_fuzzy_matrix_equal (&matrix, &test, EPSILON);
/* fallthrough */
case GSK_TRANSFORM_CATEGORY_2D:
gsk_transform_to_2d (transform,
&f[4 * 0 + 0], &f[4 * 0 + 1],
&f[4 * 1 + 0], &f[4 * 1 + 1],
&f[4 * 3 + 0], &f[4 * 3 + 1]);
graphene_matrix_init_from_float (&test, f);
graphene_assert_fuzzy_matrix_equal (&matrix, &test, EPSILON);
break;
}
}
static void
test_conversions_simple (void)
{
GskTransform *transform;
guint i;
for (i = 0; i < G_N_ELEMENTS (test_transforms); i++)
{
transform = apply_test_transform (NULL, i);
check_conversions (transform, test_transforms[i].category);
gsk_transform_unref (transform);
}
}
static void
test_conversions_transformed (void)
{
GskTransform *transform;
guint i, j, k;
for (i = 0; i < G_N_ELEMENTS (test_transforms); i++)
{
for (j = 0; j < G_N_ELEMENTS (test_transforms); j++)
{
for (k = 0; k < G_N_ELEMENTS (test_transforms); k++)
{
transform = apply_test_transform (NULL, i);
transform = apply_test_transform (transform, j);
transform = apply_test_transform (transform, k);
check_conversions (transform, MIN (test_transforms[i].category, MIN (test_transforms[j].category, test_transforms[k].category)));
gsk_transform_unref (transform);
}
}
}
}
static void
test_invert (void)
{
GskTransform *transform, *inverse, *identity;
guint i, j, k;
for (i = 0; i < G_N_ELEMENTS (test_transforms); i++)
{
for (j = 0; j < G_N_ELEMENTS (test_transforms); j++)
{
for (k = 0; k < G_N_ELEMENTS (test_transforms); k++)
{
transform = apply_test_transform (NULL, i);
transform = apply_test_transform (transform, j);
transform = apply_test_transform (transform, k);
inverse = gsk_transform_invert (gsk_transform_ref (transform));
g_assert (inverse != NULL || transform == NULL);
identity = gsk_transform_transform (gsk_transform_ref (transform), inverse);
graphene_assert_fuzzy_transform_equal (identity, NULL, EPSILON);
gsk_transform_unref (identity);
inverse = gsk_transform_invert (inverse);
graphene_assert_fuzzy_transform_equal (transform, inverse, EPSILON);
gsk_transform_unref (transform);
gsk_transform_unref (inverse);
}
}
}
}
int
main (int argc,
char *argv[])
{
gtk_test_init (&argc, &argv, NULL);
g_test_add_func ("/transform/conversions/simple", test_conversions_simple);
g_test_add_func ("/transform/conversions/transformed", test_conversions_transformed);
g_test_add_func ("/transform/invert", test_invert);
return g_test_run ();
}