mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-10-31 22:25:21 -04:00
screencopy: add support for frame flags
This commit is contained in:
parent
bd8be19b79
commit
2b9cbaddf3
9 changed files with 77 additions and 32 deletions
|
|
@ -250,9 +250,9 @@ static int gles2_get_dmabuf_modifiers(struct wlr_renderer *wlr_renderer,
|
|||
}
|
||||
|
||||
static bool gles2_read_pixels(struct wlr_renderer *wlr_renderer,
|
||||
enum wl_shm_format wl_fmt, uint32_t stride, uint32_t width,
|
||||
uint32_t height, uint32_t src_x, uint32_t src_y, uint32_t dst_x,
|
||||
uint32_t dst_y, void *data) {
|
||||
enum wl_shm_format wl_fmt, uint32_t *flags, uint32_t stride,
|
||||
uint32_t width, uint32_t height, uint32_t src_x, uint32_t src_y,
|
||||
uint32_t dst_x, uint32_t dst_y, void *data) {
|
||||
gles2_get_renderer_in_context(wlr_renderer);
|
||||
|
||||
const struct wlr_gles2_pixel_format *fmt = get_gles2_format_from_wl(wl_fmt);
|
||||
|
|
@ -266,12 +266,24 @@ static bool gles2_read_pixels(struct wlr_renderer *wlr_renderer,
|
|||
// Make sure any pending drawing is finished before we try to read it
|
||||
glFinish();
|
||||
|
||||
// Unfortunately GLES2 doesn't support GL_PACK_*, so we have to read
|
||||
// the lines out row by row
|
||||
unsigned char *p = data + dst_y * stride;
|
||||
for (size_t i = src_y; i < src_y + height; ++i) {
|
||||
glReadPixels(src_x, src_y + height - i - 1, width, 1, fmt->gl_format,
|
||||
fmt->gl_type, p + i * stride + dst_x * fmt->bpp / 8);
|
||||
uint32_t pack_stride = width * fmt->bpp / 8;
|
||||
if (pack_stride == stride && dst_x == 0 && flags != NULL) {
|
||||
// Under these particular conditions, we can read the pixels with only
|
||||
// one glReadPixels call
|
||||
glReadPixels(src_x, src_y, width, height, fmt->gl_format,
|
||||
fmt->gl_type, p);
|
||||
*flags = WLR_RENDERER_READ_PIXELS_Y_INVERT;
|
||||
} else {
|
||||
// Unfortunately GLES2 doesn't support GL_PACK_*, so we have to read
|
||||
// the lines out row by row
|
||||
for (size_t i = src_y; i < src_y + height; ++i) {
|
||||
glReadPixels(src_x, src_y + height - i - 1, width, 1, fmt->gl_format,
|
||||
fmt->gl_type, p + i * stride + dst_x * fmt->bpp / 8);
|
||||
}
|
||||
if (flags != NULL) {
|
||||
*flags = 0;
|
||||
}
|
||||
}
|
||||
|
||||
POP_GLES2_DEBUG;
|
||||
|
|
|
|||
|
|
@ -139,14 +139,14 @@ int wlr_renderer_get_dmabuf_modifiers(struct wlr_renderer *r, int format,
|
|||
}
|
||||
|
||||
bool wlr_renderer_read_pixels(struct wlr_renderer *r, enum wl_shm_format fmt,
|
||||
uint32_t stride, uint32_t width, uint32_t height,
|
||||
uint32_t *flags, uint32_t stride, uint32_t width, uint32_t height,
|
||||
uint32_t src_x, uint32_t src_y, uint32_t dst_x, uint32_t dst_y,
|
||||
void *data) {
|
||||
if (!r->impl->read_pixels) {
|
||||
return false;
|
||||
}
|
||||
return r->impl->read_pixels(r, fmt, stride, width, height, src_x, src_y,
|
||||
dst_x, dst_y, data);
|
||||
return r->impl->read_pixels(r, fmt, flags, stride, width, height,
|
||||
src_x, src_y, dst_x, dst_y, data);
|
||||
}
|
||||
|
||||
bool wlr_renderer_format_supported(struct wlr_renderer *r,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue