mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-25 14:15:58 +01:00
wlr_texture: Introduce wlr_texture_read_pixels
This commit is contained in:
parent
a165261f7f
commit
4c6caa7c48
3 changed files with 28 additions and 0 deletions
|
@ -52,6 +52,8 @@ void wlr_renderer_init(struct wlr_renderer *renderer,
|
||||||
struct wlr_texture_impl {
|
struct wlr_texture_impl {
|
||||||
bool (*update_from_buffer)(struct wlr_texture *texture,
|
bool (*update_from_buffer)(struct wlr_texture *texture,
|
||||||
struct wlr_buffer *buffer, const pixman_region32_t *damage);
|
struct wlr_buffer *buffer, const pixman_region32_t *damage);
|
||||||
|
bool (*read_pixels)(struct wlr_texture *texture,
|
||||||
|
const struct wlr_texture_read_pixels_options *options);
|
||||||
void (*destroy)(struct wlr_texture *texture);
|
void (*destroy)(struct wlr_texture *texture);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <wayland-server-core.h>
|
#include <wayland-server-core.h>
|
||||||
#include <wlr/render/dmabuf.h>
|
#include <wlr/render/dmabuf.h>
|
||||||
|
#include <wlr/util/box.h>
|
||||||
|
|
||||||
struct wlr_buffer;
|
struct wlr_buffer;
|
||||||
struct wlr_renderer;
|
struct wlr_renderer;
|
||||||
|
@ -25,6 +26,22 @@ struct wlr_texture {
|
||||||
struct wlr_renderer *renderer;
|
struct wlr_renderer *renderer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct wlr_texture_read_pixels_options {
|
||||||
|
/** Memory location to read pixels into */
|
||||||
|
void *data;
|
||||||
|
/** Format used for writing the pixel data */
|
||||||
|
uint32_t format;
|
||||||
|
/** Stride in bytes for the data */
|
||||||
|
uint32_t stride;
|
||||||
|
/** Destination offsets */
|
||||||
|
uint32_t dst_x, dst_y;
|
||||||
|
/** Source box of the texture to read from. If empty, the full texture is assumed. */
|
||||||
|
const struct wlr_box src_box;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool wlr_texture_read_pixels(struct wlr_texture *texture,
|
||||||
|
const struct wlr_texture_read_pixels_options *options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new texture from raw pixel data. `stride` is in bytes. The returned
|
* Create a new texture from raw pixel data. `stride` is in bytes. The returned
|
||||||
* texture is mutable.
|
* texture is mutable.
|
||||||
|
|
|
@ -26,6 +26,15 @@ void wlr_texture_destroy(struct wlr_texture *texture) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wlr_texture_read_pixels(struct wlr_texture *texture,
|
||||||
|
const struct wlr_texture_read_pixels_options *options) {
|
||||||
|
if (!texture->impl->read_pixels) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return texture->impl->read_pixels(texture, options);
|
||||||
|
}
|
||||||
|
|
||||||
struct wlr_texture *wlr_texture_from_pixels(struct wlr_renderer *renderer,
|
struct wlr_texture *wlr_texture_from_pixels(struct wlr_renderer *renderer,
|
||||||
uint32_t fmt, uint32_t stride, uint32_t width, uint32_t height,
|
uint32_t fmt, uint32_t stride, uint32_t width, uint32_t height,
|
||||||
const void *data) {
|
const void *data) {
|
||||||
|
|
Loading…
Reference in a new issue