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

Commit

Permalink
squash pixman
Browse files Browse the repository at this point in the history
  • Loading branch information
bl4ckb0ne committed Apr 16, 2021
1 parent 653589a commit 5c4acc9
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions render/pixman/renderer.c
Expand Up @@ -196,9 +196,12 @@ static bool pixman_render_subtexture_with_matrix(
mask_colour.alpha = 0xFFFF * alpha;
pixman_image_t *mask = pixman_image_create_solid_fill(&mask_colour);

float m[9];
memcpy(m, matrix, sizeof(m));
wlr_matrix_scale(m, 1.0 / fbox->width, 1.0 / fbox->height);

struct pixman_transform transform = {0};
wlr_matrix_scale((float *)matrix, 1.0 / fbox->width, 1.0 / fbox->height);
matrix_to_pixman_transform(&transform, matrix);
matrix_to_pixman_transform(&transform, m);
pixman_transform_invert(&transform, &transform);

pixman_image_set_transform(texture->image, &transform);
Expand Down Expand Up @@ -226,15 +229,25 @@ static void pixman_render_quad_with_matrix(struct wlr_renderer *wlr_renderer,
};

pixman_image_t *fill = pixman_image_create_solid_fill(&colour);
pixman_image_t *image = pixman_image_create_bits(PIXMAN_a8r8g8b8,
matrix[0], matrix[4], NULL, 0);

float m[9];
memcpy(m, matrix, sizeof(m));

float width = sqrt(matrix[0] * matrix[0] + matrix[1] * matrix[1]);
float height = sqrt(matrix[4] * matrix[4] + matrix[1] * matrix[1]);

wlr_matrix_scale(m, 1.0 / width, 1.0 / height);

pixman_image_t *image = pixman_image_create_bits(PIXMAN_a8r8g8b8, width,
height, NULL, 0);
pixman_image_unref(fill);

pixman_image_composite32 (PIXMAN_OP_SRC, fill, NULL, image,
0, 0, 0, 0, 0, 0, matrix[0], matrix[4]);
0, 0, 0, 0, 0, 0, width, height);
pixman_image_unref(fill);

struct pixman_transform transform = {0};
wlr_matrix_scale((float*)matrix, 1.0 / matrix[0], 1.0 / matrix[4]);
matrix_to_pixman_transform(&transform, matrix);
matrix_to_pixman_transform(&transform, m);
pixman_transform_invert(&transform, &transform);

pixman_image_set_transform(image, &transform);
Expand Down

0 comments on commit 5c4acc9

Please sign in to comment.