mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-04-17 06:46:39 -04:00
util/matrix: Rotate around (.5, .5) with wlr_matrix_transform
Before we would rotate around 0,0 which means that the content needed to be scaled to -1, 1 to be transformed properly when we're usually working in the 0, 1 range. Switch it around. These matrices were precomputed by simply adding a -.5 -.5 translate and back again with old transform in between.
This commit is contained in:
parent
c9d6339b60
commit
3a4bc44688
2 changed files with 8 additions and 12 deletions
|
|
@ -139,7 +139,6 @@ static void set_tex_matrix(GLint loc, enum wl_output_transform trans,
|
||||||
wlr_matrix_identity(tex_matrix);
|
wlr_matrix_identity(tex_matrix);
|
||||||
wlr_matrix_translate(tex_matrix, box->x, box->y);
|
wlr_matrix_translate(tex_matrix, box->x, box->y);
|
||||||
wlr_matrix_scale(tex_matrix, box->width, box->height);
|
wlr_matrix_scale(tex_matrix, box->width, box->height);
|
||||||
wlr_matrix_translate(tex_matrix, .5, .5);
|
|
||||||
|
|
||||||
// since textures have a different origin point we have to transform
|
// since textures have a different origin point we have to transform
|
||||||
// differently if we are rotating
|
// differently if we are rotating
|
||||||
|
|
@ -148,7 +147,6 @@ static void set_tex_matrix(GLint loc, enum wl_output_transform trans,
|
||||||
} else {
|
} else {
|
||||||
wlr_matrix_transform(tex_matrix, trans);
|
wlr_matrix_transform(tex_matrix, trans);
|
||||||
}
|
}
|
||||||
wlr_matrix_translate(tex_matrix, -.5, -.5);
|
|
||||||
|
|
||||||
glUniformMatrix3fv(loc, 1, GL_FALSE, tex_matrix);
|
glUniformMatrix3fv(loc, 1, GL_FALSE, tex_matrix);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,21 +57,21 @@ static const float transforms[][9] = {
|
||||||
},
|
},
|
||||||
[WL_OUTPUT_TRANSFORM_90] = {
|
[WL_OUTPUT_TRANSFORM_90] = {
|
||||||
0.0f, 1.0f, 0.0f,
|
0.0f, 1.0f, 0.0f,
|
||||||
-1.0f, 0.0f, 0.0f,
|
-1.0f, 0.0f, 1.0f,
|
||||||
0.0f, 0.0f, 1.0f,
|
0.0f, 0.0f, 1.0f,
|
||||||
},
|
},
|
||||||
[WL_OUTPUT_TRANSFORM_180] = {
|
[WL_OUTPUT_TRANSFORM_180] = {
|
||||||
-1.0f, 0.0f, 0.0f,
|
-1.0f, 0.0f, 1.0f,
|
||||||
0.0f, -1.0f, 0.0f,
|
0.0f, -1.0f, 1.0f,
|
||||||
0.0f, 0.0f, 1.0f,
|
0.0f, 0.0f, 1.0f,
|
||||||
},
|
},
|
||||||
[WL_OUTPUT_TRANSFORM_270] = {
|
[WL_OUTPUT_TRANSFORM_270] = {
|
||||||
0.0f, -1.0f, 0.0f,
|
0.0f, -1.0f, 1.0f,
|
||||||
1.0f, 0.0f, 0.0f,
|
1.0f, 0.0f, 0.0f,
|
||||||
0.0f, 0.0f, 1.0f,
|
0.0f, 0.0f, 1.0f,
|
||||||
},
|
},
|
||||||
[WL_OUTPUT_TRANSFORM_FLIPPED] = {
|
[WL_OUTPUT_TRANSFORM_FLIPPED] = {
|
||||||
-1.0f, 0.0f, 0.0f,
|
-1.0f, 0.0f, 1.0f,
|
||||||
0.0f, 1.0f, 0.0f,
|
0.0f, 1.0f, 0.0f,
|
||||||
0.0f, 0.0f, 1.0f,
|
0.0f, 0.0f, 1.0f,
|
||||||
},
|
},
|
||||||
|
|
@ -82,12 +82,12 @@ static const float transforms[][9] = {
|
||||||
},
|
},
|
||||||
[WL_OUTPUT_TRANSFORM_FLIPPED_180] = {
|
[WL_OUTPUT_TRANSFORM_FLIPPED_180] = {
|
||||||
1.0f, 0.0f, 0.0f,
|
1.0f, 0.0f, 0.0f,
|
||||||
0.0f, -1.0f, 0.0f,
|
0.0f, -1.0f, 1.0f,
|
||||||
0.0f, 0.0f, 1.0f,
|
0.0f, 0.0f, 1.0f,
|
||||||
},
|
},
|
||||||
[WL_OUTPUT_TRANSFORM_FLIPPED_270] = {
|
[WL_OUTPUT_TRANSFORM_FLIPPED_270] = {
|
||||||
0.0f, -1.0f, 0.0f,
|
0.0f, -1.0f, 1.0f,
|
||||||
-1.0f, 0.0f, 0.0f,
|
-1.0f, 0.0f, 1.0f,
|
||||||
0.0f, 0.0f, 1.0f,
|
0.0f, 0.0f, 1.0f,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
@ -132,9 +132,7 @@ void wlr_matrix_project_box(float mat[static 9], const struct wlr_box *box,
|
||||||
wlr_matrix_scale(mat, width, height);
|
wlr_matrix_scale(mat, width, height);
|
||||||
|
|
||||||
if (transform != WL_OUTPUT_TRANSFORM_NORMAL) {
|
if (transform != WL_OUTPUT_TRANSFORM_NORMAL) {
|
||||||
wlr_matrix_translate(mat, 0.5, 0.5);
|
|
||||||
wlr_matrix_transform(mat, transform);
|
wlr_matrix_transform(mat, transform);
|
||||||
wlr_matrix_translate(mat, -0.5, -0.5);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_matrix_multiply(mat, projection, mat);
|
wlr_matrix_multiply(mat, projection, mat);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue