mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 04:45:58 +01:00
backend/x11: Use wlr_texture_read_pixels
This commit is contained in:
parent
c5a3c5ca4c
commit
8ac5139007
1 changed files with 14 additions and 13 deletions
|
@ -448,25 +448,26 @@ static bool output_cursor_to_picture(struct wlr_x11_output *output,
|
|||
return true;
|
||||
}
|
||||
|
||||
struct wlr_texture *texture = wlr_texture_from_buffer(renderer, buffer);
|
||||
if (!texture) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int depth = 32;
|
||||
int stride = buffer->width * 4;
|
||||
|
||||
uint8_t *data = malloc(buffer->height * stride);
|
||||
int stride = texture->width * 4;
|
||||
uint8_t *data = malloc(texture->height * stride);
|
||||
if (data == NULL) {
|
||||
wlr_texture_destroy(texture);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!wlr_renderer_begin_with_buffer(renderer, buffer)) {
|
||||
free(data);
|
||||
return false;
|
||||
}
|
||||
bool result = wlr_texture_read_pixels(texture, &(struct wlr_texture_read_pixels_options) {
|
||||
.format = DRM_FORMAT_ARGB8888,
|
||||
.stride = stride,
|
||||
.data = data,
|
||||
});
|
||||
|
||||
bool result = wlr_renderer_read_pixels(
|
||||
renderer, DRM_FORMAT_ARGB8888,
|
||||
stride, buffer->width, buffer->height, 0, 0, 0, 0,
|
||||
data);
|
||||
|
||||
wlr_renderer_end(renderer);
|
||||
wlr_texture_destroy(texture);
|
||||
|
||||
if (!result) {
|
||||
free(data);
|
||||
|
|
Loading…
Reference in a new issue