render/texture: add width and height fields

Instead of requiring compositors to call wlr_texture_get_size each time
they want to access the texture's size, expose this information as
wlr_texture fields.
This commit is contained in:
Simon Ser 2020-04-27 12:45:21 +02:00 committed by Drew DeVault
parent 21397e2b4a
commit 06f4c3945d
5 changed files with 32 additions and 31 deletions

View file

@ -5,10 +5,11 @@
#include <wlr/render/wlr_texture.h>
void wlr_texture_init(struct wlr_texture *texture,
const struct wlr_texture_impl *impl) {
assert(impl->get_size);
const struct wlr_texture_impl *impl, uint32_t width, uint32_t height) {
assert(impl->write_pixels);
texture->impl = impl;
texture->width = width;
texture->height = height;
}
void wlr_texture_destroy(struct wlr_texture *texture) {
@ -44,7 +45,8 @@ struct wlr_texture *wlr_texture_from_dmabuf(struct wlr_renderer *renderer,
void wlr_texture_get_size(struct wlr_texture *texture, int *width,
int *height) {
texture->impl->get_size(texture, width, height);
*width = texture->width;
*height = texture->height;
}
bool wlr_texture_is_opaque(struct wlr_texture *texture) {