mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-24 13:45:58 +01:00
util/transform: add wlr_output_transform_coords()
We hand-roll this in multiple places.
This commit is contained in:
parent
9e702e9cfe
commit
2eb225236e
5 changed files with 30 additions and 36 deletions
|
@ -25,4 +25,9 @@ enum wl_output_transform wlr_output_transform_invert(
|
|||
enum wl_output_transform wlr_output_transform_compose(
|
||||
enum wl_output_transform tr_a, enum wl_output_transform tr_b);
|
||||
|
||||
/**
|
||||
* Applies a transform to coordinates.
|
||||
*/
|
||||
void wlr_output_transform_coords(enum wl_output_transform tr, int *x, int *y);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -130,12 +130,7 @@ static void surface_reconfigure(struct wlr_scene_surface *scene_surface) {
|
|||
|
||||
wlr_fbox_transform(&src_box, &src_box, state->transform,
|
||||
buffer_width, buffer_height);
|
||||
|
||||
if (state->transform & WL_OUTPUT_TRANSFORM_90) {
|
||||
int tmp = buffer_width;
|
||||
buffer_width = buffer_height;
|
||||
buffer_height = tmp;
|
||||
}
|
||||
wlr_output_transform_coords(state->transform, &buffer_width, &buffer_height);
|
||||
|
||||
src_box.x += (double)(clip->x * buffer_width) / state->width;
|
||||
src_box.y += (double)(clip->y * buffer_height) / state->height;
|
||||
|
|
|
@ -879,13 +879,9 @@ static void scene_node_get_size(struct wlr_scene_node *node,
|
|||
*width = scene_buffer->dst_width;
|
||||
*height = scene_buffer->dst_height;
|
||||
} else if (scene_buffer->buffer) {
|
||||
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;
|
||||
}
|
||||
*width = scene_buffer->buffer->width;
|
||||
*height = scene_buffer->buffer->height;
|
||||
wlr_output_transform_coords(scene_buffer->transform, width, height);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1544,14 +1540,13 @@ static bool scene_entry_try_direct_scanout(struct render_list_entry *entry,
|
|||
|
||||
struct wlr_scene_buffer *buffer = wlr_scene_buffer_from_node(node);
|
||||
|
||||
struct wlr_fbox default_box = {0};
|
||||
if (buffer->transform & WL_OUTPUT_TRANSFORM_90) {
|
||||
default_box.width = buffer->buffer->height;
|
||||
default_box.height = buffer->buffer->width;
|
||||
} else {
|
||||
default_box.width = buffer->buffer->width;
|
||||
default_box.height = buffer->buffer->height;
|
||||
}
|
||||
int default_width = buffer->buffer->width;
|
||||
int default_height = buffer->buffer->height;
|
||||
wlr_output_transform_coords(buffer->transform, &default_width, &default_height);
|
||||
struct wlr_fbox default_box = {
|
||||
.width = default_width,
|
||||
.height = default_height,
|
||||
};
|
||||
|
||||
if (!wlr_fbox_empty(&buffer->src_box) &&
|
||||
!wlr_fbox_equal(&buffer->src_box, &default_box)) {
|
||||
|
@ -1679,11 +1674,8 @@ bool wlr_scene_output_build_state(struct wlr_scene_output *scene_output,
|
|||
render_data.scale = state->scale;
|
||||
}
|
||||
|
||||
if (render_data.transform & WL_OUTPUT_TRANSFORM_90) {
|
||||
int tmp = render_data.trans_width;
|
||||
render_data.trans_width = render_data.trans_height;
|
||||
render_data.trans_height = tmp;
|
||||
}
|
||||
wlr_output_transform_coords(render_data.transform,
|
||||
&render_data.trans_width, &render_data.trans_height);
|
||||
|
||||
render_data.logical.width = render_data.trans_width / render_data.scale;
|
||||
render_data.logical.height = render_data.trans_height / render_data.scale;
|
||||
|
|
|
@ -146,16 +146,10 @@ static void surface_handle_set_input_region(struct wl_client *client,
|
|||
}
|
||||
|
||||
static void surface_state_transformed_buffer_size(struct wlr_surface_state *state,
|
||||
int *out_width, int *out_height) {
|
||||
int width = state->buffer_width;
|
||||
int height = state->buffer_height;
|
||||
if ((state->transform & WL_OUTPUT_TRANSFORM_90) != 0) {
|
||||
int tmp = width;
|
||||
width = height;
|
||||
height = tmp;
|
||||
}
|
||||
*out_width = width;
|
||||
*out_height = height;
|
||||
int *width, int *height) {
|
||||
*width = state->buffer_width;
|
||||
*height = state->buffer_height;
|
||||
wlr_output_transform_coords(state->transform, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -23,3 +23,11 @@ enum wl_output_transform wlr_output_transform_compose(
|
|||
}
|
||||
return flipped | rotated;
|
||||
}
|
||||
|
||||
void wlr_output_transform_coords(enum wl_output_transform tr, int *x, int *y) {
|
||||
if (tr & WL_OUTPUT_TRANSFORM_90) {
|
||||
int tmp = *x;
|
||||
*x = *y;
|
||||
*y = tmp;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue