diff options
Diffstat (limited to 'render')
-rw-r--r-- | render/gles2/renderer.c | 5 | ||||
-rw-r--r-- | render/gles2/texture.c | 25 | ||||
-rw-r--r-- | render/wlr_texture.c | 5 |
3 files changed, 33 insertions, 2 deletions
diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c index 27f3d33e..1f3c3eeb 100644 --- a/render/gles2/renderer.c +++ b/render/gles2/renderer.c @@ -101,8 +101,9 @@ error: } static void init_image_ext() { - if (glEGLImageTargetTexture2DOES) + if (glEGLImageTargetTexture2DOES) { return; + } const char *exts = (const char*) glGetString(GL_EXTENSIONS); if (strstr(exts, "GL_OES_EGL_image_external")) { @@ -177,7 +178,7 @@ static void draw_quad() { static bool wlr_gles2_render_texture(struct wlr_renderer *_renderer, struct wlr_texture *texture, const float (*matrix)[16]) { - if(!texture || !texture->valid) { + if (!texture || !texture->valid) { wlr_log(L_ERROR, "attempt to render invalid texture"); return false; } diff --git a/render/gles2/texture.c b/render/gles2/texture.c index 041625fd..6bb93e4f 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, }; 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); +} |