-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
structure: moved fx_renderer and related fuctions to a folder
- Loading branch information
1 parent
c24fccd
commit 420364d
Showing
18 changed files
with
88 additions
and
73 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#ifndef _MATRIX_H | ||
#define _MATRIX_H | ||
|
||
#include <wlr/types/wlr_output.h> | ||
|
||
void matrix_projection(float mat[static 9], int width, int height, | ||
enum wl_output_transform transform); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#include <math.h> | ||
#include <string.h> | ||
#include <wlr/types/wlr_output.h> | ||
|
||
#include "sway/desktop/fx_renderer/matrix.h" | ||
|
||
static const float transforms[][9] = { | ||
[WL_OUTPUT_TRANSFORM_NORMAL] = { | ||
1.0f, 0.0f, 0.0f, | ||
0.0f, 1.0f, 0.0f, | ||
0.0f, 0.0f, 1.0f, | ||
}, | ||
[WL_OUTPUT_TRANSFORM_90] = { | ||
0.0f, 1.0f, 0.0f, | ||
-1.0f, 0.0f, 0.0f, | ||
0.0f, 0.0f, 1.0f, | ||
}, | ||
[WL_OUTPUT_TRANSFORM_180] = { | ||
-1.0f, 0.0f, 0.0f, | ||
0.0f, -1.0f, 0.0f, | ||
0.0f, 0.0f, 1.0f, | ||
}, | ||
[WL_OUTPUT_TRANSFORM_270] = { | ||
0.0f, -1.0f, 0.0f, | ||
1.0f, 0.0f, 0.0f, | ||
0.0f, 0.0f, 1.0f, | ||
}, | ||
[WL_OUTPUT_TRANSFORM_FLIPPED] = { | ||
-1.0f, 0.0f, 0.0f, | ||
0.0f, 1.0f, 0.0f, | ||
0.0f, 0.0f, 1.0f, | ||
}, | ||
[WL_OUTPUT_TRANSFORM_FLIPPED_90] = { | ||
0.0f, 1.0f, 0.0f, | ||
1.0f, 0.0f, 0.0f, | ||
0.0f, 0.0f, 1.0f, | ||
}, | ||
[WL_OUTPUT_TRANSFORM_FLIPPED_180] = { | ||
1.0f, 0.0f, 0.0f, | ||
0.0f, -1.0f, 0.0f, | ||
0.0f, 0.0f, 1.0f, | ||
}, | ||
[WL_OUTPUT_TRANSFORM_FLIPPED_270] = { | ||
0.0f, -1.0f, 0.0f, | ||
-1.0f, 0.0f, 0.0f, | ||
0.0f, 0.0f, 1.0f, | ||
}, | ||
}; | ||
|
||
void matrix_projection(float mat[static 9], int width, int height, | ||
enum wl_output_transform transform) { | ||
memset(mat, 0, sizeof(*mat) * 9); | ||
|
||
const float *t = transforms[transform]; | ||
float x = 2.0f / width; | ||
float y = 2.0f / height; | ||
|
||
// Rotation + reflection | ||
mat[0] = x * t[0]; | ||
mat[1] = x * t[1]; | ||
mat[3] = y * -t[3]; | ||
mat[4] = y * -t[4]; | ||
|
||
// Translation | ||
mat[2] = -copysign(1.0f, mat[0] + mat[1]); | ||
mat[5] = -copysign(1.0f, mat[3] + mat[4]); | ||
|
||
// Identity | ||
mat[8] = 1.0f; | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters