[gtk/wip/chergert/glproto] inline most common transform, 2d-affine
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/chergert/glproto] inline most common transform, 2d-affine
- Date: Tue, 9 Feb 2021 20:15:30 +0000 (UTC)
commit 20430380d3d66b02185bb77d8981c6d6a62b7574
Author: Christian Hergert <chergert redhat com>
Date: Tue Feb 9 12:25:44 2021 -0800
inline most common transform, 2d-affine
gsk/next/gskglrenderjob.c | 53 +++++++++++++++++++++++++++++++++++++++++------
1 file changed, 47 insertions(+), 6 deletions(-)
---
diff --git a/gsk/next/gskglrenderjob.c b/gsk/next/gskglrenderjob.c
index b2eca55b10..969a74c0ed 100644
--- a/gsk/next/gskglrenderjob.c
+++ b/gsk/next/gskglrenderjob.c
@@ -691,19 +691,60 @@ gsk_gl_render_job_transform_bounds (GskGLRenderJob *job,
const graphene_rect_t *rect,
graphene_rect_t *out_rect)
{
- graphene_rect_t r;
+ GskTransform *transform;
+ GskTransformCategory category;
g_assert (job != NULL);
g_assert (job->modelview->len > 0);
g_assert (rect != NULL);
g_assert (out_rect != NULL);
- r.origin.x = rect->origin.x + job->offset_x;
- r.origin.y = rect->origin.y + job->offset_y;
- r.size.width = rect->size.width;
- r.size.height = rect->size.height;
+ transform = job->current_modelview->transform;
+ category = gsk_transform_get_category (transform);
+
+ /* Our most common transform is 2d-affine, so inline it.
+ * Both identity and 2d-translate are virtually unseen here.
+ */
+ if G_LIKELY (category == GSK_TRANSFORM_CATEGORY_2D_AFFINE)
+ {
+ float dx, dy, scale_x, scale_y;
+
+ gsk_transform_to_affine (transform, &scale_x, &scale_y, &dx, &dy);
+
+ /* Init directly into out rect */
+ out_rect->origin.x = ((rect->origin.x + job->offset_x) * scale_x) + dx;
+ out_rect->origin.y = ((rect->origin.y + job->offset_y) * scale_y) + dy;
+ out_rect->size.width = rect->size.width * scale_x;
+ out_rect->size.height = rect->size.height * scale_y;
+
+ /* Normaize in place */
+ if (out_rect->size.width < 0.f)
+ {
+ float size = fabsf (out_rect->size.width);
+
+ out_rect->origin.x -= size;
+ out_rect->size.width = size;
+ }
- gsk_transform_transform_bounds (job->current_modelview->transform, &r, out_rect);
+ if (out_rect->size.height < 0.f)
+ {
+ float size = fabsf (out_rect->size.height);
+
+ out_rect->origin.y -= size;
+ out_rect->size.height = size;
+ }
+ }
+ else
+ {
+ graphene_rect_t r;
+
+ r.origin.x = rect->origin.x + job->offset_x;
+ r.origin.y = rect->origin.y + job->offset_y;
+ r.size.width = rect->size.width;
+ r.size.height = rect->size.height;
+
+ gsk_transform_transform_bounds (transform, &r, out_rect);
+ }
}
static inline void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]