aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2021-09-20 18:19:05 +0200
committerSimon Zeni <simon@bl4ckb0ne.ca>2021-09-22 10:45:39 -0600
commit3c26244340fe09fb99368a1c2326335db86fbf5f (patch)
treee9f4b01b5091a5c6741272887e269b6549255747
parent43833fba642bd7c63c6010965f1009a72dbe3e74 (diff)
scene: add wlr_scene_buffer_set_transform
-rw-r--r--include/wlr/types/wlr_scene.h7
-rw-r--r--types/scene/wlr_scene.c27
2 files changed, 29 insertions, 5 deletions
diff --git a/include/wlr/types/wlr_scene.h b/include/wlr/types/wlr_scene.h
index 6c5194f8..3b3035d0 100644
--- a/include/wlr/types/wlr_scene.h
+++ b/include/wlr/types/wlr_scene.h
@@ -96,6 +96,7 @@ struct wlr_scene_buffer {
struct wlr_texture *texture;
struct wlr_fbox src_box;
int dst_width, dst_height;
+ enum wl_output_transform transform;
};
/** A viewport for an output in the scene-graph */
@@ -233,6 +234,12 @@ void wlr_scene_buffer_set_dest_size(struct wlr_scene_buffer *scene_buffer,
int width, int height);
/**
+ * Set a transform which will be applied to the buffer.
+ */
+void wlr_scene_buffer_set_transform(struct wlr_scene_buffer *scene_buffer,
+ enum wl_output_transform transform);
+
+/**
* Add a viewport for the specified output to the scene-graph.
*
* An output can only be added once to the scene-graph.
diff --git a/types/scene/wlr_scene.c b/types/scene/wlr_scene.c
index f4aec1d8..9ba283ef 100644
--- a/types/scene/wlr_scene.c
+++ b/types/scene/wlr_scene.c
@@ -295,6 +295,17 @@ void wlr_scene_buffer_set_dest_size(struct wlr_scene_buffer *scene_buffer,
scene_node_damage_whole(&scene_buffer->node);
}
+void wlr_scene_buffer_set_transform(struct wlr_scene_buffer *scene_buffer,
+ enum wl_output_transform transform) {
+ if (scene_buffer->transform == transform) {
+ return;
+ }
+
+ scene_node_damage_whole(&scene_buffer->node);
+ scene_buffer->transform = transform;
+ scene_node_damage_whole(&scene_buffer->node);
+}
+
static struct wlr_texture *scene_buffer_get_texture(
struct wlr_scene_buffer *scene_buffer, struct wlr_renderer *renderer) {
struct wlr_client_buffer *client_buffer =
@@ -338,8 +349,13 @@ static void scene_node_get_size(struct wlr_scene_node *node,
*width = scene_buffer->dst_width;
*height = scene_buffer->dst_height;
} else {
- *width = scene_buffer->buffer->width;
- *height = scene_buffer->buffer->height;
+ if (scene_buffer->transform & WL_OUTPUT_TRANSFORM_90) {
+ *height = scene_buffer->buffer->width;
+ *width = scene_buffer->buffer->height;
+ } else {
+ *width = scene_buffer->buffer->width;
+ *height = scene_buffer->buffer->height;
+ }
}
break;
}
@@ -658,6 +674,7 @@ static void render_node_iterator(struct wlr_scene_node *node,
struct wlr_texture *texture;
float matrix[9];
+ enum wl_output_transform transform;
switch (node->type) {
case WLR_SCENE_NODE_ROOT:
case WLR_SCENE_NODE_TREE:
@@ -672,8 +689,7 @@ static void render_node_iterator(struct wlr_scene_node *node,
return;
}
- enum wl_output_transform transform =
- wlr_output_transform_invert(surface->current.transform);
+ transform = wlr_output_transform_invert(surface->current.transform);
wlr_matrix_project_box(matrix, &dst_box, transform, 0.0,
output->transform_matrix);
@@ -694,7 +710,8 @@ static void render_node_iterator(struct wlr_scene_node *node,
return;
}
- wlr_matrix_project_box(matrix, &dst_box, WL_OUTPUT_TRANSFORM_NORMAL, 0.0,
+ transform = wlr_output_transform_invert(scene_buffer->transform);
+ wlr_matrix_project_box(matrix, &dst_box, transform, 0.0,
output->transform_matrix);
render_texture(output, output_damage, texture, &scene_buffer->src_box,