2017-08-08 16:02:14 +00:00
|
|
|
#include <stdbool.h>
|
2018-02-12 20:29:23 +00:00
|
|
|
#include <stdlib.h>
|
2017-08-08 16:02:14 +00:00
|
|
|
#include <wlr/render/interface.h>
|
2018-03-19 22:16:29 +00:00
|
|
|
#include <wlr/render/wlr_texture.h>
|
2017-08-08 16:02:14 +00:00
|
|
|
|
2017-08-14 12:25:26 +00:00
|
|
|
void wlr_texture_init(struct wlr_texture *texture,
|
2017-08-08 16:02:14 +00:00
|
|
|
struct wlr_texture_impl *impl) {
|
2017-08-14 12:25:26 +00:00
|
|
|
texture->impl = impl;
|
|
|
|
wl_signal_init(&texture->destroy_signal);
|
2017-08-08 16:02:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void wlr_texture_destroy(struct wlr_texture *texture) {
|
2017-08-14 14:16:20 +00:00
|
|
|
if (texture && texture->impl && texture->impl->destroy) {
|
2017-08-14 12:25:26 +00:00
|
|
|
texture->impl->destroy(texture);
|
2017-08-14 14:16:20 +00:00
|
|
|
} else {
|
|
|
|
free(texture);
|
2017-08-14 12:25:26 +00:00
|
|
|
}
|
2017-08-08 16:02:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void wlr_texture_bind(struct wlr_texture *texture) {
|
2017-08-14 12:25:26 +00:00
|
|
|
texture->impl->bind(texture);
|
2017-08-08 16:02:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool wlr_texture_upload_pixels(struct wlr_texture *texture, uint32_t format,
|
|
|
|
int stride, int width, int height, const unsigned char *pixels) {
|
2017-08-14 12:25:26 +00:00
|
|
|
return texture->impl->upload_pixels(texture, format, stride,
|
|
|
|
width, height, pixels);
|
2017-08-08 16:02:14 +00:00
|
|
|
}
|
|
|
|
|
2017-08-10 02:17:40 +00:00
|
|
|
bool wlr_texture_update_pixels(struct wlr_texture *texture,
|
|
|
|
enum wl_shm_format format, int stride, int x, int y,
|
|
|
|
int width, int height, const unsigned char *pixels) {
|
2017-08-14 12:25:26 +00:00
|
|
|
return texture->impl->update_pixels(texture, format, stride, x, y,
|
|
|
|
width, height, pixels);
|
2017-08-10 02:17:40 +00:00
|
|
|
}
|
|
|
|
|
2017-08-08 16:02:14 +00:00
|
|
|
bool wlr_texture_upload_shm(struct wlr_texture *texture, uint32_t format,
|
|
|
|
struct wl_shm_buffer *shm) {
|
2017-08-14 12:25:26 +00:00
|
|
|
return texture->impl->upload_shm(texture, format, shm);
|
2017-08-08 16:02:14 +00:00
|
|
|
}
|
|
|
|
|
2017-08-10 02:17:40 +00:00
|
|
|
bool wlr_texture_update_shm(struct wlr_texture *texture, uint32_t format,
|
|
|
|
int x, int y, int width, int height, struct wl_shm_buffer *shm) {
|
2017-08-14 12:25:26 +00:00
|
|
|
return texture->impl->update_shm(texture, format, x, y, width, height, shm);
|
2017-08-10 02:17:40 +00:00
|
|
|
}
|
|
|
|
|
2017-08-09 19:25:34 +00:00
|
|
|
bool wlr_texture_upload_drm(struct wlr_texture *texture,
|
|
|
|
struct wl_resource *drm_buffer) {
|
2017-08-14 12:25:26 +00:00
|
|
|
return texture->impl->upload_drm(texture, drm_buffer);
|
2017-08-09 19:25:34 +00:00
|
|
|
}
|
|
|
|
|
2017-10-01 06:22:47 +00:00
|
|
|
bool wlr_texture_upload_eglimage(struct wlr_texture *texture,
|
|
|
|
EGLImageKHR image, uint32_t width, uint32_t height) {
|
|
|
|
return texture->impl->upload_eglimage(texture, image, width, height);
|
|
|
|
}
|
|
|
|
|
2018-02-23 17:45:16 +00:00
|
|
|
bool wlr_texture_upload_dmabuf(struct wlr_texture *texture,
|
|
|
|
struct wl_resource *dmabuf_resource) {
|
|
|
|
return texture->impl->upload_dmabuf(texture, dmabuf_resource);
|
|
|
|
}
|
|
|
|
|
2017-08-14 17:28:59 +00:00
|
|
|
void wlr_texture_get_buffer_size(struct wlr_texture *texture, struct wl_resource
|
|
|
|
*resource, int *width, int *height) {
|
|
|
|
texture->impl->get_buffer_size(texture, resource, width, height);
|
|
|
|
}
|