cursor: Move wlr_output_cursor_set_buffer to wlr_raster

This commit is contained in:
Alexander Orzechowski 2022-06-25 19:40:27 -04:00
parent beaede2df0
commit 605c4aed38
2 changed files with 15 additions and 24 deletions

View file

@ -494,8 +494,8 @@ bool wlr_output_cursor_set_image(struct wlr_output_cursor *cursor,
int32_t hotspot_x, int32_t hotspot_y); int32_t hotspot_x, int32_t hotspot_y);
void wlr_output_cursor_set_surface(struct wlr_output_cursor *cursor, void wlr_output_cursor_set_surface(struct wlr_output_cursor *cursor,
struct wlr_surface *surface, int32_t hotspot_x, int32_t hotspot_y); struct wlr_surface *surface, int32_t hotspot_x, int32_t hotspot_y);
bool wlr_output_cursor_set_buffer(struct wlr_output_cursor *cursor, bool wlr_output_cursor_set_raster(struct wlr_output_cursor *cursor,
struct wlr_buffer *buffer, int32_t hotspot_x, int32_t hotspot_y); struct wlr_raster *raster, int32_t hotspot_x, int32_t hotspot_y);
bool wlr_output_cursor_move(struct wlr_output_cursor *cursor, bool wlr_output_cursor_move(struct wlr_output_cursor *cursor,
double x, double y); double x, double y);
void wlr_output_cursor_destroy(struct wlr_output_cursor *cursor); void wlr_output_cursor_destroy(struct wlr_output_cursor *cursor);

View file

@ -363,24 +363,20 @@ static bool output_cursor_attempt_hardware(struct wlr_output_cursor *cursor) {
bool wlr_output_cursor_set_image(struct wlr_output_cursor *cursor, bool wlr_output_cursor_set_image(struct wlr_output_cursor *cursor,
const uint8_t *pixels, int32_t stride, uint32_t width, uint32_t height, const uint8_t *pixels, int32_t stride, uint32_t width, uint32_t height,
int32_t hotspot_x, int32_t hotspot_y) { int32_t hotspot_x, int32_t hotspot_y) {
struct wlr_buffer *buffer = NULL; struct wlr_raster *raster = NULL;
if (pixels) { if (pixels) {
struct wlr_readonly_data_buffer *ro_buffer = readonly_data_buffer_create( raster = wlr_raster_from_pixels(DRM_FORMAT_ARGB8888,
DRM_FORMAT_ARGB8888, stride, width, height, pixels); stride, width, height, pixels);
if (ro_buffer == NULL) {
return false;
}
buffer = &ro_buffer->base;
} }
bool ok = wlr_output_cursor_set_buffer(cursor, buffer, hotspot_x, hotspot_y); bool ok = wlr_output_cursor_set_raster(cursor, raster, hotspot_x, hotspot_y);
wlr_buffer_drop(buffer); wlr_raster_unlock(raster);
return ok; return ok;
} }
bool wlr_output_cursor_set_buffer(struct wlr_output_cursor *cursor, bool wlr_output_cursor_set_raster(struct wlr_output_cursor *cursor,
struct wlr_buffer *buffer, int32_t hotspot_x, int32_t hotspot_y) { struct wlr_raster *raster, int32_t hotspot_x, int32_t hotspot_y) {
struct wlr_renderer *renderer = cursor->output->renderer; struct wlr_renderer *renderer = cursor->output->renderer;
if (!renderer) { if (!renderer) {
return false; return false;
@ -388,9 +384,9 @@ bool wlr_output_cursor_set_buffer(struct wlr_output_cursor *cursor,
output_cursor_reset(cursor); output_cursor_reset(cursor);
if (buffer != NULL) { if (raster) {
cursor->width = buffer->width; cursor->width = raster->width;
cursor->height = buffer->height; cursor->height = raster->height;
} else { } else {
cursor->width = 0; cursor->width = 0;
cursor->height = 0; cursor->height = 0;
@ -404,14 +400,9 @@ bool wlr_output_cursor_set_buffer(struct wlr_output_cursor *cursor,
wlr_raster_unlock(cursor->raster); wlr_raster_unlock(cursor->raster);
cursor->raster = NULL; cursor->raster = NULL;
cursor->enabled = false; cursor->enabled = raster;
if (buffer != NULL) { if (raster) {
cursor->raster = wlr_raster_create(buffer); cursor->raster = wlr_raster_lock(raster);
if (!cursor->raster) {
return false;
}
cursor->enabled = true;
} }
if (output_cursor_attempt_hardware(cursor)) { if (output_cursor_attempt_hardware(cursor)) {