diff options
Diffstat (limited to 'render/gles2/renderer.c')
-rw-r--r-- | render/gles2/renderer.c | 144 |
1 files changed, 0 insertions, 144 deletions
diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c index 4899cfc7..e61c276c 100644 --- a/render/gles2/renderer.c +++ b/render/gles2/renderer.c @@ -28,13 +28,6 @@ #include "tex_rgbx_frag_src.h" #include "tex_external_frag_src.h" -static const GLfloat verts[] = { - 1, 0, // top right - 0, 0, // top left - 1, 1, // bottom right - 0, 1, // bottom left -}; - static const struct wlr_renderer_impl renderer_impl; static const struct wlr_render_timer_impl render_timer_impl; @@ -258,139 +251,6 @@ static void gles2_end(struct wlr_renderer *wlr_renderer) { // no-op } -static void gles2_clear(struct wlr_renderer *wlr_renderer, - const float color[static 4]) { - struct wlr_gles2_renderer *renderer = - gles2_get_renderer_in_context(wlr_renderer); - - push_gles2_debug(renderer); - glClearColor(color[0], color[1], color[2], color[3]); - glClear(GL_COLOR_BUFFER_BIT); - pop_gles2_debug(renderer); -} - -static void gles2_scissor(struct wlr_renderer *wlr_renderer, - struct wlr_box *box) { - struct wlr_gles2_renderer *renderer = - gles2_get_renderer_in_context(wlr_renderer); - - push_gles2_debug(renderer); - if (box != NULL) { - glScissor(box->x, box->y, box->width, box->height); - glEnable(GL_SCISSOR_TEST); - } else { - glDisable(GL_SCISSOR_TEST); - } - pop_gles2_debug(renderer); -} - -static bool gles2_render_subtexture_with_matrix( - struct wlr_renderer *wlr_renderer, struct wlr_texture *wlr_texture, - const struct wlr_fbox *box, const float matrix[static 9], - float alpha) { - struct wlr_gles2_renderer *renderer = - gles2_get_renderer_in_context(wlr_renderer); - struct wlr_gles2_texture *texture = - gles2_get_texture(wlr_texture); - assert(texture->renderer == renderer); - - struct wlr_gles2_tex_shader *shader = NULL; - - switch (texture->target) { - case GL_TEXTURE_2D: - if (texture->has_alpha) { - shader = &renderer->shaders.tex_rgba; - } else { - shader = &renderer->shaders.tex_rgbx; - } - break; - case GL_TEXTURE_EXTERNAL_OES: - // EGL_EXT_image_dma_buf_import_modifiers requires - // GL_OES_EGL_image_external - assert(renderer->exts.OES_egl_image_external); - shader = &renderer->shaders.tex_ext; - break; - default: - abort(); - } - - float gl_matrix[9]; - wlr_matrix_multiply(gl_matrix, renderer->projection, matrix); - - push_gles2_debug(renderer); - - if (!texture->has_alpha && alpha == 1.0) { - glDisable(GL_BLEND); - } else { - glEnable(GL_BLEND); - } - - glActiveTexture(GL_TEXTURE0); - glBindTexture(texture->target, texture->tex); - - glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - - glUseProgram(shader->program); - - glUniformMatrix3fv(shader->proj, 1, GL_FALSE, gl_matrix); - glUniform1i(shader->tex, 0); - glUniform1f(shader->alpha, alpha); - - float tex_matrix[9]; - wlr_matrix_identity(tex_matrix); - wlr_matrix_translate(tex_matrix, box->x / texture->wlr_texture.width, - box->y / texture->wlr_texture.height); - wlr_matrix_scale(tex_matrix, box->width / texture->wlr_texture.width, - box->height / texture->wlr_texture.height); - glUniformMatrix3fv(shader->tex_proj, 1, GL_FALSE, tex_matrix); - - glVertexAttribPointer(shader->pos_attrib, 2, GL_FLOAT, GL_FALSE, 0, verts); - - glEnableVertexAttribArray(shader->pos_attrib); - - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - - glDisableVertexAttribArray(shader->pos_attrib); - - glBindTexture(texture->target, 0); - - pop_gles2_debug(renderer); - return true; -} - -static void gles2_render_quad_with_matrix(struct wlr_renderer *wlr_renderer, - const float color[static 4], const float matrix[static 9]) { - struct wlr_gles2_renderer *renderer = - gles2_get_renderer_in_context(wlr_renderer); - - float gl_matrix[9]; - wlr_matrix_multiply(gl_matrix, renderer->projection, matrix); - - push_gles2_debug(renderer); - - if (color[3] == 1.0) { - glDisable(GL_BLEND); - } else { - glEnable(GL_BLEND); - } - - glUseProgram(renderer->shaders.quad.program); - - glUniformMatrix3fv(renderer->shaders.quad.proj, 1, GL_FALSE, gl_matrix); - glUniform4f(renderer->shaders.quad.color, color[0], color[1], color[2], color[3]); - - glVertexAttribPointer(renderer->shaders.quad.pos_attrib, 2, GL_FLOAT, GL_FALSE, - 0, verts); - - glEnableVertexAttribArray(renderer->shaders.quad.pos_attrib); - - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - - glDisableVertexAttribArray(renderer->shaders.quad.pos_attrib); - - pop_gles2_debug(renderer); -} - static const uint32_t *gles2_get_shm_texture_formats( struct wlr_renderer *wlr_renderer, size_t *len) { struct wlr_gles2_renderer *renderer = gles2_get_renderer(wlr_renderer); @@ -651,10 +511,6 @@ static const struct wlr_renderer_impl renderer_impl = { .bind_buffer = gles2_bind_buffer, .begin = gles2_begin, .end = gles2_end, - .clear = gles2_clear, - .scissor = gles2_scissor, - .render_subtexture_with_matrix = gles2_render_subtexture_with_matrix, - .render_quad_with_matrix = gles2_render_quad_with_matrix, .get_shm_texture_formats = gles2_get_shm_texture_formats, .get_dmabuf_texture_formats = gles2_get_dmabuf_texture_formats, .get_render_formats = gles2_get_render_formats, |