diff options
author | Drew DeVault <sir@cmpwn.com> | 2017-08-15 08:31:30 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-15 08:31:30 -0400 |
commit | 09faf4ff6430bd93fec4269b35c7a87d14e9e8b3 (patch) | |
tree | 56847c7d36a6e361f6a84a56063f9a4cb1819703 /render/gles2 | |
parent | d2e796edb7256bb2e2b694a13c86e8bee7056309 (diff) | |
parent | d5f98dbf61e3627f46c499a2ecac0e581241299b (diff) |
Merge pull request #83 from acrisci/feature/buffer-damage2
Buffer damage and scaling (attempt 2)
Diffstat (limited to 'render/gles2')
-rw-r--r-- | render/gles2/texture.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/render/gles2/texture.c b/render/gles2/texture.c index 1e80a8d6..4eb79374 100644 --- a/render/gles2/texture.c +++ b/render/gles2/texture.c @@ -218,6 +218,30 @@ 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) { + struct wlr_gles2_texture *tex = (struct wlr_gles2_texture *)texture; + if (!glEGLImageTargetTexture2DOES) { + return; + } + if (!wlr_egl_query_buffer(tex->egl, resource, EGL_WIDTH, + (EGLint*)&width)) { + wlr_log(L_ERROR, "could not get size of the buffer " + "(no buffer found)"); + return; + }; + wlr_egl_query_buffer(tex->egl, resource, EGL_HEIGHT, + (EGLint*)&height); + + 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 +271,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, }; |