diff options
author | Tony Crisci <tony@dubstepdish.com> | 2017-08-14 13:28:59 -0400 |
---|---|---|
committer | Tony Crisci <tony@dubstepdish.com> | 2017-08-15 07:36:50 -0400 |
commit | 72a33b736fdf2a03d45010182b16532df0753690 (patch) | |
tree | 3e2a2feba48f3167edceec6c3bfe23ad41611914 | |
parent | f0f190bfa5b7ebf2dbb5cc62e20e3b80038382b4 (diff) |
implement texture get buffer size
-rw-r--r-- | include/wlr/render/interface.h | 4 | ||||
-rw-r--r-- | render/gles2/texture.c | 13 | ||||
-rw-r--r-- | render/wlr_texture.c | 5 | ||||
-rw-r--r-- | types/wlr_surface.c | 14 |
4 files changed, 27 insertions, 9 deletions
diff --git a/include/wlr/render/interface.h b/include/wlr/render/interface.h index 59ece8b1..f98c3bc2 100644 --- a/include/wlr/render/interface.h +++ b/include/wlr/render/interface.h @@ -46,6 +46,8 @@ struct wlr_texture_impl { struct wl_resource *drm_buf); void (*get_matrix)(struct wlr_texture *state, float (*matrix)[16], const float (*projection)[16], int x, int y); + void (*get_buffer_size)(struct wlr_texture *texture, + struct wl_resource *resource, int *width, int *height); void (*bind)(struct wlr_texture *texture); void (*destroy)(struct wlr_texture *texture); }; @@ -53,5 +55,7 @@ struct wlr_texture_impl { void wlr_texture_init(struct wlr_texture *texture, struct wlr_texture_impl *impl); void wlr_texture_bind(struct wlr_texture *texture); +void wlr_texture_get_buffer_size(struct wlr_texture *texture, + struct wl_resource *resource, int *width, int *height); #endif diff --git a/render/gles2/texture.c b/render/gles2/texture.c index 1e80a8d6..1f4ae22c 100644 --- a/render/gles2/texture.c +++ b/render/gles2/texture.c @@ -218,6 +218,18 @@ static void gles2_texture_get_matrix(struct wlr_texture *_texture, wlr_matrix_mul(projection, matrix, matrix); } +static void gles2_texture_get_buffer_size(struct wlr_texture *texture, struct + wl_resource *resource, int *width, int *height) { + struct wl_shm_buffer *buffer = wl_shm_buffer_get(resource); + if (!buffer) { + wlr_log(L_ERROR, "getting buffer size is only implemented for shm buffers"); + return; + } + + *width = wl_shm_buffer_get_width(buffer); + *height = wl_shm_buffer_get_height(buffer); +} + static void gles2_texture_bind(struct wlr_texture *_texture) { struct wlr_gles2_texture *texture = (struct wlr_gles2_texture *)_texture; GL_CALL(glBindTexture(GL_TEXTURE_2D, texture->tex_id)); @@ -247,6 +259,7 @@ static struct wlr_texture_impl wlr_texture_impl = { .update_shm = gles2_texture_update_shm, .upload_drm = gles2_texture_upload_drm, .get_matrix = gles2_texture_get_matrix, + .get_buffer_size = gles2_texture_get_buffer_size, .bind = gles2_texture_bind, .destroy = gles2_texture_destroy, }; diff --git a/render/wlr_texture.c b/render/wlr_texture.c index f98284a1..9faea820 100644 --- a/render/wlr_texture.c +++ b/render/wlr_texture.c @@ -52,3 +52,8 @@ void wlr_texture_get_matrix(struct wlr_texture *texture, float (*matrix)[16], const float (*projection)[16], int x, int y) { texture->impl->get_matrix(texture, matrix, projection, x, y); } + +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); +} diff --git a/types/wlr_surface.c b/types/wlr_surface.c index e862d00e..0861e2e8 100644 --- a/types/wlr_surface.c +++ b/types/wlr_surface.c @@ -126,6 +126,9 @@ static void surface_commit(struct wl_client *client, surface->current.buffer = surface->pending.buffer; } if ((surface->pending.invalid & WLR_SURFACE_INVALID_SURFACE_DAMAGE)) { + int width, height; + wlr_texture_get_buffer_size(surface->texture, surface->current.buffer, &width, &height); + pixman_region32_union(&surface->current.surface_damage, &surface->current.surface_damage, &surface->pending.surface_damage); @@ -140,16 +143,9 @@ static void surface_commit(struct wl_client *client, pixman_region32_union(&surface->current.buffer_damage, &surface->current.buffer_damage, &buffer_damage); - struct wl_shm_buffer *buffer = wl_shm_buffer_get(surface->current.buffer); pixman_region32_intersect_rect(&surface->current.buffer_damage, - &surface->current.buffer_damage, 0, 0, - wl_shm_buffer_get_width(buffer), - wl_shm_buffer_get_height(buffer)); - - // TODO: Surface sizing is complicated - //pixman_region32_intersect_rect(&surface->current.surface_damage, - // &surface->current.surface_damage, - // 0, 0, surface->width, surface->height); + &surface->current.buffer_damage, 0, 0, width, height); + pixman_region32_clear(&surface->pending.surface_damage); pixman_region32_clear(&surface->pending.buffer_damage); } |