diff --git a/include/render/wlr_texture.h b/include/render/wlr_texture.h new file mode 100644 index 000000000..7a40c1d02 --- /dev/null +++ b/include/render/wlr_texture.h @@ -0,0 +1,21 @@ +#ifndef RENDER_WLR_TEXTURE_H +#define RENDER_WLR_TEXTURE_H + +#include + +/** + * Refresh the texture contents from the underlying buffer storage. + * + * If the texture refers to external memory (i.e. memory owned by another + * process), the renderer may need a wlr_texture_invalidate call to make + * external changes visible to the texture. + * + * This operation must not perform any copy. + * + * If the texture cannot be invalidated, false is returned. If the texture + * doesn't need to be invalidated for external changes to be visible, true is + * immediately returned. + */ +bool wlr_texture_invalidate(struct wlr_texture *texture); + +#endif diff --git a/include/wlr/render/interface.h b/include/wlr/render/interface.h index f11e01188..459c3f57d 100644 --- a/include/wlr/render/interface.h +++ b/include/wlr/render/interface.h @@ -67,6 +67,7 @@ struct wlr_texture_impl { 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, const void *data); + bool (*invalidate)(struct wlr_texture *texture); void (*destroy)(struct wlr_texture *texture); }; diff --git a/render/wlr_texture.c b/render/wlr_texture.c index b382e6f3f..acacd8dde 100644 --- a/render/wlr_texture.c +++ b/render/wlr_texture.c @@ -3,6 +3,7 @@ #include #include #include +#include "render/wlr_texture.h" void wlr_texture_init(struct wlr_texture *texture, const struct wlr_texture_impl *impl, uint32_t width, uint32_t height) { @@ -69,3 +70,10 @@ bool wlr_texture_write_pixels(struct wlr_texture *texture, return texture->impl->write_pixels(texture, stride, width, height, src_x, src_y, dst_x, dst_y, data); } + +bool wlr_texture_invalidate(struct wlr_texture *texture) { + if (!texture->impl->invalidate) { + return false; + } + return texture->impl->invalidate(texture); +}