aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2018-07-12 23:35:33 +0100
committeremersion <contact@emersion.fr>2018-07-12 23:35:33 +0100
commitc4915d149289683b6a3b8c836ba5591a8973baba (patch)
tree84e3a2b6d35b5b7c4967a34c011afb8782a9da60
parentd8bbdf3bd5edce03c550bb0982ac997392ac5711 (diff)
render: add wlr_texture_is_opaque
-rw-r--r--include/wlr/render/interface.h1
-rw-r--r--include/wlr/render/wlr_texture.h5
-rw-r--r--render/gles2/texture.c6
-rw-r--r--render/wlr_texture.c7
4 files changed, 19 insertions, 0 deletions
diff --git a/include/wlr/render/interface.h b/include/wlr/render/interface.h
index 1b138ea3..f4565ad5 100644
--- a/include/wlr/render/interface.h
+++ b/include/wlr/render/interface.h
@@ -56,6 +56,7 @@ void wlr_renderer_init(struct wlr_renderer *renderer,
struct wlr_texture_impl {
void (*get_size)(struct wlr_texture *texture, int *width, int *height);
+ bool (*is_opaque)(struct wlr_texture *texture);
bool (*write_pixels)(struct wlr_texture *texture,
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,
diff --git a/include/wlr/render/wlr_texture.h b/include/wlr/render/wlr_texture.h
index 785f4fc6..9370fa25 100644
--- a/include/wlr/render/wlr_texture.h
+++ b/include/wlr/render/wlr_texture.h
@@ -41,6 +41,11 @@ struct wlr_texture *wlr_texture_from_dmabuf(struct wlr_renderer *renderer,
void wlr_texture_get_size(struct wlr_texture *texture, int *width, int *height);
/**
+ * Returns true if this texture is using a fully opaque format.
+ */
+bool wlr_texture_is_opaque(struct wlr_texture *texture);
+
+/**
* Update a texture with raw pixels. The texture must be mutable.
*/
bool wlr_texture_write_pixels(struct wlr_texture *texture,
diff --git a/render/gles2/texture.c b/render/gles2/texture.c
index 3c70a235..1e55f4c4 100644
--- a/render/gles2/texture.c
+++ b/render/gles2/texture.c
@@ -36,6 +36,11 @@ static void gles2_texture_get_size(struct wlr_texture *wlr_texture, int *width,
*height = texture->height;
}
+static bool gles2_texture_is_opaque(struct wlr_texture *wlr_texture) {
+ struct wlr_gles2_texture *texture = gles2_get_texture(wlr_texture);
+ return !texture->has_alpha;
+}
+
static bool gles2_texture_write_pixels(struct wlr_texture *wlr_texture,
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,
@@ -129,6 +134,7 @@ static void gles2_texture_destroy(struct wlr_texture *wlr_texture) {
static const struct wlr_texture_impl texture_impl = {
.get_size = gles2_texture_get_size,
+ .is_opaque = gles2_texture_is_opaque,
.write_pixels = gles2_texture_write_pixels,
.to_dmabuf = gles2_texture_to_dmabuf,
.destroy = gles2_texture_destroy,
diff --git a/render/wlr_texture.c b/render/wlr_texture.c
index 76986920..06872f1e 100644
--- a/render/wlr_texture.c
+++ b/render/wlr_texture.c
@@ -47,6 +47,13 @@ void wlr_texture_get_size(struct wlr_texture *texture, int *width,
return texture->impl->get_size(texture, width, height);
}
+bool wlr_texture_is_opaque(struct wlr_texture *texture) {
+ if (!texture->impl->is_opaque) {
+ return false;
+ }
+ return texture->impl->is_opaque(texture);
+}
+
bool wlr_texture_write_pixels(struct wlr_texture *texture,
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,