aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2023-05-03 11:34:28 +0200
committerAlexander Orzechowski <alex@ozal.ski>2023-05-30 16:18:19 +0000
commit5bcd537ff465b36bf5f587bc99ce04b2ec18aec2 (patch)
tree4f42005776544ee35f518e026662726007de2af1
parent8e81b4bb4237fe846e3f9eb997404aef2c396da5 (diff)
output/cursor: use new rendering API
-rw-r--r--types/output/cursor.c42
1 files changed, 20 insertions, 22 deletions
diff --git a/types/output/cursor.c b/types/output/cursor.c
index 12baa5f8..efd6b32f 100644
--- a/types/output/cursor.c
+++ b/types/output/cursor.c
@@ -312,40 +312,38 @@ static struct wlr_buffer *render_cursor_buffer(struct wlr_output_cursor *cursor)
return NULL;
}
- struct wlr_box cursor_box = {
+ struct wlr_box dst_box = {
.width = texture->width * output->scale / scale,
.height = texture->height * output->scale / scale,
};
- float output_matrix[9];
- wlr_matrix_identity(output_matrix);
- if (output->transform != WL_OUTPUT_TRANSFORM_NORMAL) {
- struct wlr_box tr_size = {
- .width = buffer->width,
- .height = buffer->height,
- };
- wlr_box_transform(&tr_size, &tr_size, output->transform, 0, 0);
+ wlr_box_transform(&dst_box, &dst_box, wlr_output_transform_invert(output->transform),
+ buffer->width, buffer->height);
- wlr_matrix_translate(output_matrix, buffer->width / 2.0,
- buffer->height / 2.0);
- wlr_matrix_transform(output_matrix, output->transform);
- wlr_matrix_translate(output_matrix, - tr_size.width / 2.0,
- - tr_size.height / 2.0);
+ struct wlr_render_pass *pass = wlr_renderer_begin_buffer_pass(renderer, buffer);
+ if (pass == NULL) {
+ wlr_buffer_unlock(buffer);
+ return NULL;
}
- float matrix[9];
- wlr_matrix_project_box(matrix, &cursor_box, transform, 0, output_matrix);
+ transform = wlr_output_transform_invert(transform);
+ transform = wlr_output_transform_compose(transform, output->transform);
- if (!wlr_renderer_begin_with_buffer(renderer, buffer)) {
+ wlr_render_pass_add_rect(pass, &(struct wlr_render_rect_options){
+ .box = { .width = buffer->width, .height = buffer->height },
+ .blend_mode = WLR_RENDER_BLEND_MODE_NONE,
+ });
+ wlr_render_pass_add_texture(pass, &(struct wlr_render_texture_options){
+ .texture = texture,
+ .dst_box = dst_box,
+ .transform = transform,
+ });
+
+ if (!wlr_render_pass_submit(pass)) {
wlr_buffer_unlock(buffer);
return NULL;
}
- wlr_renderer_clear(renderer, (float[]){ 0.0, 0.0, 0.0, 0.0 });
- wlr_render_texture_with_matrix(renderer, texture, matrix, 1.0);
-
- wlr_renderer_end(renderer);
-
return buffer;
}