render/texture: introduce wlr_texture_invalidate

This commit is contained in:
Simon Ser 2021-04-12 11:56:20 +02:00
parent 5c699f09cb
commit a3a85a9aed
3 changed files with 30 additions and 0 deletions

View file

@ -0,0 +1,21 @@
#ifndef RENDER_WLR_TEXTURE_H
#define RENDER_WLR_TEXTURE_H
#include <wlr/render/wlr_texture.h>
/**
* 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

View file

@ -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);
};

View file

@ -3,6 +3,7 @@
#include <stdlib.h>
#include <wlr/render/interface.h>
#include <wlr/render/wlr_texture.h>
#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);
}