From a3cb1cabd3eee4e7bb75f1cffb442b5360b17fbd Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Fri, 11 Sep 2020 19:40:00 -0300 Subject: [PATCH] texture-tower: Use graphene APIs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A boring one, with the exception that row and column needed to be swapped. For the sake of consistency, the variable names were also synchronized with the values they hold, so e.g. xy → yx, etc. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439 --- src/compositor/meta-texture-tower.c | 42 ++++++++++++++--------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/compositor/meta-texture-tower.c b/src/compositor/meta-texture-tower.c index 87c9ff3de..cb7b99726 100644 --- a/src/compositor/meta-texture-tower.c +++ b/src/compositor/meta-texture-tower.c @@ -281,17 +281,17 @@ get_paint_level (ClutterPaintContext *paint_context, cogl_framebuffer_get_projection_matrix (framebuffer, &projection); cogl_framebuffer_get_modelview_matrix (framebuffer, &modelview); - cogl_matrix_multiply (&pm, &projection, &modelview); + graphene_matrix_multiply (&modelview, &projection, &pm); - xx = cogl_matrix_get_value (&pm, 0, 0); - xy = cogl_matrix_get_value (&pm, 0, 1); - xw = cogl_matrix_get_value (&pm, 0, 3); - yx = cogl_matrix_get_value (&pm, 1, 0); - yy = cogl_matrix_get_value (&pm, 1, 1); - yw = cogl_matrix_get_value (&pm, 1, 3); - wx = cogl_matrix_get_value (&pm, 3, 0); - wy = cogl_matrix_get_value (&pm, 3, 1); - ww = cogl_matrix_get_value (&pm, 3, 3); + xx = graphene_matrix_get_value (&pm, 0, 0); + xy = graphene_matrix_get_value (&pm, 0, 1); + xw = graphene_matrix_get_value (&pm, 0, 3); + yx = graphene_matrix_get_value (&pm, 1, 0); + yy = graphene_matrix_get_value (&pm, 1, 1); + yw = graphene_matrix_get_value (&pm, 1, 3); + wx = graphene_matrix_get_value (&pm, 3, 0); + wy = graphene_matrix_get_value (&pm, 3, 1); + ww = graphene_matrix_get_value (&pm, 3, 3); cogl_framebuffer_get_viewport4fv (framebuffer, v); viewport_width = v[2]; @@ -300,9 +300,9 @@ get_paint_level (ClutterPaintContext *paint_context, u0 = width / 2.; v0 = height / 2.; - xc = xx * u0 + xy * v0 + xw; - yc = yx * u0 + yy * v0 + yw; - wc = wx * u0 + wy * v0 + ww; + xc = xx * u0 + yx * v0 + wx; + yc = xy * u0 + yy * v0 + wy; + wc = xw * u0 + yw * v0 + ww; /* We'll simplify the equations below for a bit of micro-optimization. * The commented out code is the unsimplified version. @@ -315,10 +315,10 @@ get_paint_level (ClutterPaintContext *paint_context, // with respect to u, v, using // d(a/b)/dx = da/dx * (1/b) - a * db/dx / (b^2) - dxdu = 0.5 * viewport_width * (xx - wx * (xc/wc)) / wc; - dxdv = 0.5 * viewport_width * (xy - wy * (xc/wc)) / wc; - dydu = 0.5 * viewport_height * (yx - wx * (yc/wc)) / wc; - dydv = 0.5 * viewport_height * (yy - wy * (yc/wc)) / wc; + dxdu = 0.5 * viewport_width * (xx - xw * (xc/wc)) / wc; + dxdv = 0.5 * viewport_width * (yx - yw * (xc/wc)) / wc; + dydu = 0.5 * viewport_height * (xy - xw * (yc/wc)) / wc; + dydv = 0.5 * viewport_height * (yy - yw * (yc/wc)) / wc; // Compute the inverse partials as the matrix inverse det = dxdu * dydv - dxdv * dydu; @@ -337,10 +337,10 @@ get_paint_level (ClutterPaintContext *paint_context, */ /* dxdu * wc, etc */ - dxdu_ = 0.5 * viewport_width * (xx - wx * (xc/wc)); - dxdv_ = 0.5 * viewport_width * (xy - wy * (xc/wc)); - dydu_ = 0.5 * viewport_height * (yx - wx * (yc/wc)); - dydv_ = 0.5 * viewport_height * (yy - wy * (yc/wc)); + dxdu_ = 0.5 * viewport_width * (xx - xw * (xc/wc)); + dxdv_ = 0.5 * viewport_width * (yx - yw * (xc/wc)); + dydu_ = 0.5 * viewport_height * (xy - xw * (yc/wc)); + dydv_ = 0.5 * viewport_height * (yy - yw * (yc/wc)); /* det * wc^2 */ det_ = dxdu_ * dydv_ - dxdv_ * dydu_;