aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/types/wlr_output.h5
-rw-r--r--include/wlr/types/wlr_output.h2
-rw-r--r--types/output/cursor.c41
-rw-r--r--types/wlr_cursor.c20
4 files changed, 46 insertions, 22 deletions
diff --git a/include/types/wlr_output.h b/include/types/wlr_output.h
index 22a5c463..1fbe3949 100644
--- a/include/types/wlr_output.h
+++ b/include/types/wlr_output.h
@@ -15,7 +15,8 @@ bool output_ensure_buffer(struct wlr_output *output,
struct wlr_output_state *state, bool *new_back_buffer);
bool output_cursor_set_texture(struct wlr_output_cursor *cursor,
- struct wlr_texture *texture, bool own_texture, float scale,
- enum wl_output_transform transform, int32_t hotspot_x, int32_t hotspot_y);
+ struct wlr_texture *texture, bool own_texture, const struct wlr_fbox *src_box,
+ int dst_width, int dst_height, enum wl_output_transform transform,
+ int32_t hotspot_x, int32_t hotspot_y);
#endif
diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h
index f3ed7c10..1ec22cfe 100644
--- a/include/wlr/types/wlr_output.h
+++ b/include/wlr/types/wlr_output.h
@@ -40,7 +40,7 @@ struct wlr_output_cursor {
bool enabled;
bool visible;
uint32_t width, height;
- float scale;
+ struct wlr_fbox src_box;
enum wl_output_transform transform;
int32_t hotspot_x, hotspot_y;
struct wlr_texture *texture;
diff --git a/types/output/cursor.c b/types/output/cursor.c
index eb6ac6f2..c2510896 100644
--- a/types/output/cursor.c
+++ b/types/output/cursor.c
@@ -195,6 +195,7 @@ void wlr_output_add_software_cursors_to_render_pass(struct wlr_output *output,
wlr_render_pass_add_texture(render_pass, &(struct wlr_render_texture_options) {
.texture = texture,
+ .src_box = cursor->src_box,
.dst_box = box,
.clip = &cursor_damage,
.transform = output->transform,
@@ -272,8 +273,8 @@ static struct wlr_buffer *render_cursor_buffer(struct wlr_output_cursor *cursor)
struct wlr_renderer *renderer = output->renderer;
assert(allocator != NULL && renderer != NULL);
- int width = texture->width * output->scale / cursor->scale;
- int height = texture->height * output->scale / cursor->scale;
+ int width = cursor->width;
+ int height = cursor->height;
if (output->impl->get_cursor_size) {
// Apply hardware limitations on buffer size
output->impl->get_cursor_size(cursor->output, &width, &height);
@@ -311,10 +312,9 @@ static struct wlr_buffer *render_cursor_buffer(struct wlr_output_cursor *cursor)
}
struct wlr_box dst_box = {
- .width = texture->width * output->scale / cursor->scale,
- .height = texture->height * output->scale / cursor->scale,
+ .width = cursor->width,
+ .height = cursor->height,
};
-
wlr_box_transform(&dst_box, &dst_box, wlr_output_transform_invert(output->transform),
buffer->width, buffer->height);
@@ -333,6 +333,7 @@ static struct wlr_buffer *render_cursor_buffer(struct wlr_output_cursor *cursor)
});
wlr_render_pass_add_texture(pass, &(struct wlr_render_texture_options){
.texture = texture,
+ .src_box = cursor->src_box,
.dst_box = dst_box,
.transform = transform,
});
@@ -398,37 +399,43 @@ bool wlr_output_cursor_set_buffer(struct wlr_output_cursor *cursor,
}
struct wlr_texture *texture = NULL;
+ struct wlr_fbox src_box = {0};
+ int dst_width = 0, dst_height = 0;
if (buffer != NULL) {
texture = wlr_texture_from_buffer(renderer, buffer);
if (texture == NULL) {
return false;
}
+
+ src_box = (struct wlr_fbox){
+ .width = texture->width,
+ .height = texture->height,
+ };
+
+ dst_width = texture->width / cursor->output->scale;
+ dst_height = texture->height / cursor->output->scale;
}
hotspot_x /= cursor->output->scale;
hotspot_y /= cursor->output->scale;
- return output_cursor_set_texture(cursor, texture, true, cursor->output->scale,
- WL_OUTPUT_TRANSFORM_NORMAL, hotspot_x, hotspot_y);
+ return output_cursor_set_texture(cursor, texture, true, &src_box,
+ dst_width, dst_height, WL_OUTPUT_TRANSFORM_NORMAL, hotspot_x, hotspot_y);
}
bool output_cursor_set_texture(struct wlr_output_cursor *cursor,
- struct wlr_texture *texture, bool own_texture, float scale,
- enum wl_output_transform transform, int32_t hotspot_x, int32_t hotspot_y) {
+ struct wlr_texture *texture, bool own_texture, const struct wlr_fbox *src_box,
+ int dst_width, int dst_height, enum wl_output_transform transform,
+ int32_t hotspot_x, int32_t hotspot_y) {
struct wlr_output *output = cursor->output;
output_cursor_reset(cursor);
cursor->enabled = texture != NULL;
if (texture != NULL) {
- struct wlr_box box = {
- .width = texture->width / scale,
- .height = texture->height / scale,
- };
- wlr_box_transform(&box, &box, wlr_output_transform_invert(transform), 0, 0);
- cursor->width = (int)roundf(box.width * output->scale);
- cursor->height = (int)roundf(box.height * output->scale);
- cursor->scale = scale;
+ cursor->width = (int)roundf(dst_width * output->scale);
+ cursor->height = (int)roundf(dst_height * output->scale);
+ cursor->src_box = *src_box;
cursor->transform = transform;
} else {
cursor->width = 0;
diff --git a/types/wlr_cursor.c b/types/wlr_cursor.c
index f2e5c19d..aca43bee 100644
--- a/types/wlr_cursor.c
+++ b/types/wlr_cursor.c
@@ -519,15 +519,26 @@ static void cursor_output_cursor_update(struct wlr_cursor_output_cursor *output_
float scale = cur->state->buffer_scale;
struct wlr_texture *texture = NULL;
+ struct wlr_fbox src_box = {0};
+ int dst_width = 0, dst_height = 0;
if (buffer != NULL) {
texture = wlr_texture_from_buffer(renderer, buffer);
if (texture == NULL) {
return;
}
+
+ src_box = (struct wlr_fbox){
+ .width = texture->width,
+ .height = texture->height,
+ };
+
+ dst_width = texture->width / scale;
+ dst_height = texture->height / scale;
}
output_cursor_set_texture(output_cursor->output_cursor, texture, true,
- scale, WL_OUTPUT_TRANSFORM_NORMAL, hotspot_x, hotspot_y);
+ &src_box, dst_width, dst_height, WL_OUTPUT_TRANSFORM_NORMAL,
+ hotspot_x, hotspot_y);
} else if (cur->state->surface != NULL) {
struct wlr_surface *surface = cur->state->surface;
@@ -539,8 +550,13 @@ static void cursor_output_cursor_update(struct wlr_cursor_output_cursor *output_
int32_t hotspot_x = cur->state->surface_hotspot.x;
int32_t hotspot_y = cur->state->surface_hotspot.y;
+ struct wlr_fbox src_box;
+ wlr_surface_get_buffer_source_box(surface, &src_box);
+ int dst_width = surface->current.width;
+ int dst_height = surface->current.height;
+
output_cursor_set_texture(output_cursor->output_cursor, texture, false,
- surface->current.scale, surface->current.transform,
+ &src_box, dst_width, dst_height, surface->current.transform,
hotspot_x, hotspot_y);
struct wlr_output *output = output_cursor->output_cursor->output;