aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/wlr/render/interface.h1
-rw-r--r--include/wlr/render/wlr_texture.h2
-rw-r--r--render/wlr_texture.c9
3 files changed, 12 insertions, 0 deletions
diff --git a/include/wlr/render/interface.h b/include/wlr/render/interface.h
index 29a78f92..befd2fdc 100644
--- a/include/wlr/render/interface.h
+++ b/include/wlr/render/interface.h
@@ -54,6 +54,7 @@ struct wlr_texture_impl {
struct wlr_buffer *buffer, const pixman_region32_t *damage);
bool (*read_pixels)(struct wlr_texture *texture,
const struct wlr_texture_read_pixels_options *options);
+ uint32_t (*preferred_read_format)(struct wlr_texture *texture);
void (*destroy)(struct wlr_texture *texture);
};
diff --git a/include/wlr/render/wlr_texture.h b/include/wlr/render/wlr_texture.h
index c24cfaa9..1e352c6e 100644
--- a/include/wlr/render/wlr_texture.h
+++ b/include/wlr/render/wlr_texture.h
@@ -42,6 +42,8 @@ struct wlr_texture_read_pixels_options {
bool wlr_texture_read_pixels(struct wlr_texture *texture,
const struct wlr_texture_read_pixels_options *options);
+uint32_t wlr_texture_preferred_read_format(struct wlr_texture *texture);
+
/**
* Create a new texture from raw pixel data. `stride` is in bytes. The returned
* texture is mutable.
diff --git a/render/wlr_texture.c b/render/wlr_texture.c
index 3496305f..3526ee14 100644
--- a/render/wlr_texture.c
+++ b/render/wlr_texture.c
@@ -1,4 +1,5 @@
#include <assert.h>
+#include <drm_fourcc.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
@@ -61,6 +62,14 @@ bool wlr_texture_read_pixels(struct wlr_texture *texture,
return texture->impl->read_pixels(texture, options);
}
+uint32_t wlr_texture_preferred_read_format(struct wlr_texture *texture) {
+ if (!texture->impl->preferred_read_format) {
+ return DRM_FORMAT_INVALID;
+ }
+
+ return texture->impl->preferred_read_format(texture);
+}
+
struct wlr_texture *wlr_texture_from_pixels(struct wlr_renderer *renderer,
uint32_t fmt, uint32_t stride, uint32_t width, uint32_t height,
const void *data) {