diff options
author | Simon Ser <contact@emersion.fr> | 2021-05-19 11:00:30 +0200 |
---|---|---|
committer | Simon Zeni <simon@bl4ckb0ne.ca> | 2021-05-19 09:57:37 -0400 |
commit | f73c04b8019522e445a19a5b5760faacfa91c0f0 (patch) | |
tree | acfe78117343cd30b7274632827ad4aeda3fa73e /render/pixman | |
parent | 66e100ffbffbb70b64b973a4606d7c7b857c19ce (diff) |
render/pixman: avoid sqrt() in render_quad without rotation
When the matrix doesn't have a rotation, we can avoid a sqrt() call.
Tested with Sway's tabbed containers.
Diffstat (limited to 'render/pixman')
-rw-r--r-- | render/pixman/renderer.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/render/pixman/renderer.c b/render/pixman/renderer.c index 7680e171..a5a402f2 100644 --- a/render/pixman/renderer.c +++ b/render/pixman/renderer.c @@ -230,10 +230,14 @@ static void pixman_render_quad_with_matrix(struct wlr_renderer *wlr_renderer, memcpy(m, matrix, sizeof(m)); // TODO get the width/height from the caller instead of extracting them - // TODO detect non rotation with matrix[1] == 0 and matrix[4] == 0 to avoid - // doing the calculation - float width = sqrt(matrix[0] * matrix[0] + matrix[1] * matrix[1]); - float height = sqrt(matrix[3] * matrix[3] + matrix[4] * matrix[4]); + float width, height; + if (matrix[1] == 0.0 && matrix[3] == 0.0) { + width = fabs(matrix[0]); + height = fabs(matrix[4]); + } else { + width = sqrt(matrix[0] * matrix[0] + matrix[1] * matrix[1]); + height = sqrt(matrix[3] * matrix[3] + matrix[4] * matrix[4]); + } wlr_matrix_scale(m, 1.0 / width, 1.0 / height); |