Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

Commit

Permalink
wip update output transform matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
bl4ckb0ne committed Mar 4, 2021
1 parent c5dad8b commit 8624124
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
11 changes: 10 additions & 1 deletion render/gles2/renderer.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ static const float flip_180[9] = {

static bool gles2_render_subtexture_with_matrix(
struct wlr_renderer *wlr_renderer, struct wlr_texture *wlr_texture,
const struct wlr_fbox *box, const float matrix[static 9],
const struct wlr_fbox *box, const float mat[static 9],
float alpha) {
struct wlr_gles2_renderer *renderer =
gles2_get_renderer_in_context(wlr_renderer);
Expand Down Expand Up @@ -270,6 +270,15 @@ static bool gles2_render_subtexture_with_matrix(
abort();
}

float proj[9];
wlr_matrix_projection(proj, box->width, box->height,
WL_OUTPUT_TRANSFORM_NORMAL);

float matrix[9];
wlr_matrix_multiply(matrix, proj, mat);

wlr_matrix_scale(matrix, 1.f/box->width, 1.f/box->height);

float gl_matrix[9];
wlr_matrix_multiply(gl_matrix, flip_180, matrix);

Expand Down
9 changes: 7 additions & 2 deletions types/wlr_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,13 @@ void wlr_output_update_enabled(struct wlr_output *output, bool enabled) {
}

static void output_update_matrix(struct wlr_output *output) {
wlr_matrix_projection(output->transform_matrix, output->width,
output->height, output->transform);
float width = output->width / 2.f;
float height = output->height / 2.f;

wlr_matrix_identity(output->transform_matrix);
wlr_matrix_translate(output->transform_matrix, width, height);
wlr_matrix_transform(output->transform_matrix, output->transform);
wlr_matrix_translate(output->transform_matrix, -width, -height);
}

void wlr_output_enable(struct wlr_output *output, bool enable) {
Expand Down

0 comments on commit 8624124

Please sign in to comment.