Skip to content

Commit

Permalink
render: Don't pass matrix into render_texture
Browse files Browse the repository at this point in the history
  • Loading branch information
Nefsen402 committed Apr 27, 2023
1 parent cfe2209 commit 5ac2a9e
Showing 1 changed file with 13 additions and 26 deletions.
39 changes: 13 additions & 26 deletions sway/desktop/render.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,18 @@ static void set_scale_filter(struct wlr_output *wlr_output,

static void render_texture(struct render_context *ctx, struct wlr_texture *texture,
const struct wlr_fbox *src_box, const struct wlr_box *dst_box,
const float matrix[static 9], float alpha) {
enum wl_output_transform transform, float alpha) {
struct wlr_renderer *renderer = ctx->renderer;
struct sway_output *output = ctx->output;

struct wlr_box proj_box = *dst_box;
scale_box(&proj_box, output->wlr_output->scale);

float matrix[9];
enum wl_output_transform inv_transform = wlr_output_transform_invert(transform);
wlr_matrix_project_box(matrix, &proj_box, inv_transform, 0,
output->wlr_output->transform_matrix);

pixman_region32_t damage;
pixman_region32_init(&damage);
pixman_region32_union_rect(&damage, &damage, dst_box->x, dst_box->y,
Expand Down Expand Up @@ -152,12 +160,6 @@ static void render_surface_iterator(struct sway_output *output,
struct wlr_box proj_box = *_box;
scale_box(&proj_box, wlr_output->scale);

float matrix[9];
enum wl_output_transform transform =
wlr_output_transform_invert(surface->current.transform);
wlr_matrix_project_box(matrix, &proj_box, transform, 0.0,
wlr_output->transform_matrix);

struct wlr_box dst_box = *_box;
struct wlr_box *clip_box = data->clip_box;
if (clip_box != NULL) {
Expand All @@ -167,7 +169,7 @@ static void render_surface_iterator(struct sway_output *output,
scale_box(&dst_box, wlr_output->scale);

render_texture(data->ctx, texture,
&src_box, &dst_box, matrix, alpha);
&src_box, &dst_box, surface->current.transform, alpha);

wlr_presentation_surface_sampled_on_output(server.presentation, surface,
wlr_output);
Expand Down Expand Up @@ -323,11 +325,6 @@ static void render_saved_view(struct render_context *ctx, struct sway_view *view
struct wlr_box dst_box = proj_box;
scale_box(&proj_box, wlr_output->scale);

float matrix[9];
enum wl_output_transform transform = wlr_output_transform_invert(saved_buf->transform);
wlr_matrix_project_box(matrix, &proj_box, transform, 0,
wlr_output->transform_matrix);

if (!floating) {
dst_box.width = fmin(dst_box.width,
view->container->current.content_width -
Expand All @@ -339,7 +336,7 @@ static void render_saved_view(struct render_context *ctx, struct sway_view *view
scale_box(&dst_box, wlr_output->scale);

render_texture(ctx, saved_buf->buffer->texture,
&saved_buf->source_box, &dst_box, matrix, alpha);
&saved_buf->source_box, &dst_box, saved_buf->transform, alpha);
}

// FIXME: we should set the surface that this saved buffer originates from
Expand Down Expand Up @@ -511,16 +508,11 @@ static void render_titlebar(struct render_context *ctx, struct sway_container *c
texture_box.y = round((bg_y - output_y) * output_scale) +
ob_padding_above;

float matrix[9];
wlr_matrix_project_box(matrix, &texture_box,
WL_OUTPUT_TRANSFORM_NORMAL,
0.0, output->wlr_output->transform_matrix);

if (ob_inner_width < texture_box.width) {
texture_box.width = ob_inner_width;
}
render_texture(ctx, marks_texture,
NULL, &texture_box, matrix, con->alpha);
NULL, &texture_box, WL_OUTPUT_TRANSFORM_NORMAL, con->alpha);

// Padding above
memcpy(&color, colors->background, sizeof(float) * 4);
Expand Down Expand Up @@ -586,17 +578,12 @@ static void render_titlebar(struct render_context *ctx, struct sway_container *c
texture_box.y =
round((bg_y - output_y) * output_scale) + ob_padding_above;

float matrix[9];
wlr_matrix_project_box(matrix, &texture_box,
WL_OUTPUT_TRANSFORM_NORMAL,
0.0, output->wlr_output->transform_matrix);

if (ob_inner_width - ob_marks_width < texture_box.width) {
texture_box.width = ob_inner_width - ob_marks_width;
}

render_texture(ctx, title_texture,
NULL, &texture_box, matrix, con->alpha);
NULL, &texture_box, WL_OUTPUT_TRANSFORM_NORMAL, con->alpha);

// Padding above
memcpy(&color, colors->background, sizeof(float) * 4);
Expand Down

0 comments on commit 5ac2a9e

Please sign in to comment.