mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-21 20:35: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 wlr_output_transform_compose(
|
||||||
enum wl_output_transform tr_a, enum wl_output_transform tr_b);
|
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
|
#endif
|
||||||
|
|
|
@ -130,12 +130,7 @@ static void surface_reconfigure(struct wlr_scene_surface *scene_surface) {
|
||||||
|
|
||||||
wlr_fbox_transform(&src_box, &src_box, state->transform,
|
wlr_fbox_transform(&src_box, &src_box, state->transform,
|
||||||
buffer_width, buffer_height);
|
buffer_width, buffer_height);
|
||||||
|
wlr_output_transform_coords(state->transform, &buffer_width, &buffer_height);
|
||||||
if (state->transform & WL_OUTPUT_TRANSFORM_90) {
|
|
||||||
int tmp = buffer_width;
|
|
||||||
buffer_width = buffer_height;
|
|
||||||
buffer_height = tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
src_box.x += (double)(clip->x * buffer_width) / state->width;
|
src_box.x += (double)(clip->x * buffer_width) / state->width;
|
||||||
src_box.y += (double)(clip->y * buffer_height) / state->height;
|
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;
|
*width = scene_buffer->dst_width;
|
||||||
*height = scene_buffer->dst_height;
|
*height = scene_buffer->dst_height;
|
||||||
} else if (scene_buffer->buffer) {
|
} else if (scene_buffer->buffer) {
|
||||||
if (scene_buffer->transform & WL_OUTPUT_TRANSFORM_90) {
|
*width = scene_buffer->buffer->width;
|
||||||
*height = scene_buffer->buffer->width;
|
*height = scene_buffer->buffer->height;
|
||||||
*width = scene_buffer->buffer->height;
|
wlr_output_transform_coords(scene_buffer->transform, width, height);
|
||||||
} else {
|
|
||||||
*width = scene_buffer->buffer->width;
|
|
||||||
*height = scene_buffer->buffer->height;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
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_scene_buffer *buffer = wlr_scene_buffer_from_node(node);
|
||||||
|
|
||||||
struct wlr_fbox default_box = {0};
|
int default_width = buffer->buffer->width;
|
||||||
if (buffer->transform & WL_OUTPUT_TRANSFORM_90) {
|
int default_height = buffer->buffer->height;
|
||||||
default_box.width = buffer->buffer->height;
|
wlr_output_transform_coords(buffer->transform, &default_width, &default_height);
|
||||||
default_box.height = buffer->buffer->width;
|
struct wlr_fbox default_box = {
|
||||||
} else {
|
.width = default_width,
|
||||||
default_box.width = buffer->buffer->width;
|
.height = default_height,
|
||||||
default_box.height = buffer->buffer->height;
|
};
|
||||||
}
|
|
||||||
|
|
||||||
if (!wlr_fbox_empty(&buffer->src_box) &&
|
if (!wlr_fbox_empty(&buffer->src_box) &&
|
||||||
!wlr_fbox_equal(&buffer->src_box, &default_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;
|
render_data.scale = state->scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (render_data.transform & WL_OUTPUT_TRANSFORM_90) {
|
wlr_output_transform_coords(render_data.transform,
|
||||||
int tmp = render_data.trans_width;
|
&render_data.trans_width, &render_data.trans_height);
|
||||||
render_data.trans_width = render_data.trans_height;
|
|
||||||
render_data.trans_height = tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
render_data.logical.width = render_data.trans_width / render_data.scale;
|
render_data.logical.width = render_data.trans_width / render_data.scale;
|
||||||
render_data.logical.height = render_data.trans_height / 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,
|
static void surface_state_transformed_buffer_size(struct wlr_surface_state *state,
|
||||||
int *out_width, int *out_height) {
|
int *width, int *height) {
|
||||||
int width = state->buffer_width;
|
*width = state->buffer_width;
|
||||||
int height = state->buffer_height;
|
*height = state->buffer_height;
|
||||||
if ((state->transform & WL_OUTPUT_TRANSFORM_90) != 0) {
|
wlr_output_transform_coords(state->transform, width, height);
|
||||||
int tmp = width;
|
|
||||||
width = height;
|
|
||||||
height = tmp;
|
|
||||||
}
|
|
||||||
*out_width = width;
|
|
||||||
*out_height = height;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -23,3 +23,11 @@ enum wl_output_transform wlr_output_transform_compose(
|
||||||
}
|
}
|
||||||
return flipped | rotated;
|
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