diff options
Diffstat (limited to 'render')
-rw-r--r-- | render/egl.c | 30 | ||||
-rw-r--r-- | render/gles2/renderer.c | 6 | ||||
-rw-r--r-- | render/gles2/texture.c | 3 | ||||
-rw-r--r-- | render/wlr_renderer.c | 4 |
4 files changed, 31 insertions, 12 deletions
diff --git a/render/egl.c b/render/egl.c index 21c446f1..0a68d6e5 100644 --- a/render/egl.c +++ b/render/egl.c @@ -83,6 +83,24 @@ static bool egl_get_config(EGLDisplay disp, EGLint *attribs, EGLConfig *out, return false; } +static bool check_egl_ext(const char *egl_exts, const char *ext) { + size_t extlen = strlen(ext); + const char *end = egl_exts + strlen(egl_exts); + + while (egl_exts < end) { + if (*egl_exts == ' ') { + egl_exts++; + continue; + } + size_t n = strcspn(egl_exts, " "); + if (n == extlen && strncmp(ext, egl_exts, n) == 0) { + return true; + } + egl_exts += n; + } + return false; +} + bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform, void *remote_display, EGLint *config_attribs, EGLint visual_id) { if (!load_glapi()) { @@ -137,17 +155,17 @@ bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform, void *remote_display, wlr_log(L_INFO, "GL vendor: %s", glGetString(GL_VENDOR)); wlr_log(L_INFO, "Supported OpenGL ES extensions: %s", egl->gl_exts_str); - if (strstr(egl->egl_exts_str, "EGL_WL_bind_wayland_display") == NULL || - strstr(egl->egl_exts_str, "EGL_KHR_image_base") == NULL) { + if (!check_egl_ext(egl->egl_exts_str, "EGL_WL_bind_wayland_display") || + !check_egl_ext(egl->egl_exts_str, "EGL_KHR_image_base")) { wlr_log(L_ERROR, "Required egl extensions not supported"); goto error; } egl->egl_exts.buffer_age = - strstr(egl->egl_exts_str, "EGL_EXT_buffer_age") != NULL; + check_egl_ext(egl->egl_exts_str, "EGL_EXT_buffer_age"); egl->egl_exts.swap_buffers_with_damage = - strstr(egl->egl_exts_str, "EGL_EXT_swap_buffers_with_damage") != NULL || - strstr(egl->egl_exts_str, "EGL_KHR_swap_buffers_with_damage") != NULL; + check_egl_ext(egl->egl_exts_str, "EGL_EXT_swap_buffers_with_damage") || + check_egl_ext(egl->egl_exts_str, "EGL_KHR_swap_buffers_with_damage"); return true; @@ -193,7 +211,7 @@ bool wlr_egl_query_buffer(struct wlr_egl *egl, struct wl_resource *buf, EGLImage wlr_egl_create_image(struct wlr_egl *egl, EGLenum target, EGLClientBuffer buffer, const EGLint *attribs) { if (!eglCreateImageKHR) { - return false; + return NULL; } return eglCreateImageKHR(egl->display, egl->context, target, diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c index 81a932e6..ad739cf8 100644 --- a/render/gles2/renderer.c +++ b/render/gles2/renderer.c @@ -171,7 +171,7 @@ static void draw_quad() { } static bool wlr_gles2_render_texture(struct wlr_renderer *wlr_renderer, - struct wlr_texture *texture, const float (*matrix)[16]) { + struct wlr_texture *texture, const float (*matrix)[16], float alpha) { if (!texture || !texture->valid) { wlr_log(L_ERROR, "attempt to render invalid texture"); return false; @@ -179,12 +179,12 @@ static bool wlr_gles2_render_texture(struct wlr_renderer *wlr_renderer, wlr_texture_bind(texture); GL_CALL(glUniformMatrix4fv(0, 1, GL_FALSE, *matrix)); - // TODO: source alpha from somewhere else I guess - GL_CALL(glUniform1f(2, 1.0f)); + GL_CALL(glUniform1f(2, alpha)); draw_quad(); return true; } + static void wlr_gles2_render_quad(struct wlr_renderer *wlr_renderer, const float (*color)[4], const float (*matrix)[16]) { GL_CALL(glUseProgram(shaders.quad)); diff --git a/render/gles2/texture.c b/render/gles2/texture.c index 688a51d8..241b94a8 100644 --- a/render/gles2/texture.c +++ b/render/gles2/texture.c @@ -86,7 +86,8 @@ static bool gles2_texture_upload_shm(struct wlr_texture *_texture, struct wlr_gles2_texture *texture = (struct wlr_gles2_texture *)_texture; const struct pixel_format *fmt = gl_format_for_wl_format(format); if (!fmt || !fmt->gl_format) { - wlr_log(L_ERROR, "No supported pixel format for this texture"); + wlr_log(L_ERROR, "Unsupported pixel format %"PRIu32" for this texture", + format); return false; } wl_shm_buffer_begin_access(buffer); diff --git a/render/wlr_renderer.c b/render/wlr_renderer.c index fa6c6fc3..ce8fbe36 100644 --- a/render/wlr_renderer.c +++ b/render/wlr_renderer.c @@ -36,8 +36,8 @@ struct wlr_texture *wlr_render_texture_create(struct wlr_renderer *r) { } bool wlr_render_with_matrix(struct wlr_renderer *r, - struct wlr_texture *texture, const float (*matrix)[16]) { - return r->impl->render_with_matrix(r, texture, matrix); + struct wlr_texture *texture, const float (*matrix)[16], float alpha) { + return r->impl->render_with_matrix(r, texture, matrix, alpha); } void wlr_render_colored_quad(struct wlr_renderer *r, |