render/gles2: remove current_buffer checks

All backends now use wlr_swapchain. This means the renderer is
guaranteed to have a current_buffer bound.

Remove the legacy code used for EGLSurface.
master
Simon Ser 4 years ago
parent 6ca59519c9
commit bfd020047d

@ -34,6 +34,7 @@ static struct wlr_gles2_renderer *gles2_get_renderer_in_context(
struct wlr_renderer *wlr_renderer) { struct wlr_renderer *wlr_renderer) {
struct wlr_gles2_renderer *renderer = gles2_get_renderer(wlr_renderer); struct wlr_gles2_renderer *renderer = gles2_get_renderer(wlr_renderer);
assert(wlr_egl_is_current(renderer->egl)); assert(wlr_egl_is_current(renderer->egl));
assert(renderer->current_buffer != NULL);
return renderer; return renderer;
} }
@ -222,15 +223,7 @@ static void gles2_scissor(struct wlr_renderer *wlr_renderer,
push_gles2_debug(renderer); push_gles2_debug(renderer);
if (box != NULL) { if (box != NULL) {
struct wlr_box gl_box; glScissor(box->x, box->y, box->width, box->height);
if (renderer->current_buffer != NULL) {
memcpy(&gl_box, box, sizeof(gl_box));
} else {
wlr_box_transform(&gl_box, box, WL_OUTPUT_TRANSFORM_FLIPPED_180,
renderer->viewport_width, renderer->viewport_height);
}
glScissor(gl_box.x, gl_box.y, gl_box.width, gl_box.height);
glEnable(GL_SCISSOR_TEST); glEnable(GL_SCISSOR_TEST);
} else { } else {
glDisable(GL_SCISSOR_TEST); glDisable(GL_SCISSOR_TEST);
@ -277,11 +270,8 @@ static bool gles2_render_subtexture_with_matrix(
} }
float gl_matrix[9]; float gl_matrix[9];
if (renderer->current_buffer != NULL) { wlr_matrix_multiply(gl_matrix, flip_180, matrix);
wlr_matrix_multiply(gl_matrix, flip_180, matrix);
} else {
memcpy(gl_matrix, matrix, sizeof(gl_matrix));
}
// OpenGL ES 2 requires the glUniformMatrix3fv transpose parameter to be set // OpenGL ES 2 requires the glUniformMatrix3fv transpose parameter to be set
// to GL_FALSE // to GL_FALSE
wlr_matrix_transpose(gl_matrix, gl_matrix); wlr_matrix_transpose(gl_matrix, gl_matrix);
@ -334,11 +324,8 @@ static void gles2_render_quad_with_matrix(struct wlr_renderer *wlr_renderer,
gles2_get_renderer_in_context(wlr_renderer); gles2_get_renderer_in_context(wlr_renderer);
float gl_matrix[9]; float gl_matrix[9];
if (renderer->current_buffer != NULL) { wlr_matrix_multiply(gl_matrix, flip_180, matrix);
wlr_matrix_multiply(gl_matrix, flip_180, matrix);
} else {
memcpy(gl_matrix, matrix, sizeof(gl_matrix));
}
// OpenGL ES 2 requires the glUniformMatrix3fv transpose parameter to be set // OpenGL ES 2 requires the glUniformMatrix3fv transpose parameter to be set
// to GL_FALSE // to GL_FALSE
wlr_matrix_transpose(gl_matrix, gl_matrix); wlr_matrix_transpose(gl_matrix, gl_matrix);
@ -367,11 +354,8 @@ static void gles2_render_ellipse_with_matrix(struct wlr_renderer *wlr_renderer,
gles2_get_renderer_in_context(wlr_renderer); gles2_get_renderer_in_context(wlr_renderer);
float gl_matrix[9]; float gl_matrix[9];
if (renderer->current_buffer != NULL) { wlr_matrix_multiply(gl_matrix, flip_180, matrix);
wlr_matrix_multiply(gl_matrix, flip_180, matrix);
} else {
memcpy(gl_matrix, matrix, sizeof(gl_matrix));
}
// OpenGL ES 2 requires the glUniformMatrix3fv transpose parameter to be set // OpenGL ES 2 requires the glUniformMatrix3fv transpose parameter to be set
// to GL_FALSE // to GL_FALSE
wlr_matrix_transpose(gl_matrix, gl_matrix); wlr_matrix_transpose(gl_matrix, gl_matrix);
@ -454,19 +438,19 @@ static enum wl_shm_format gles2_preferred_read_format(
struct wlr_gles2_renderer *renderer = struct wlr_gles2_renderer *renderer =
gles2_get_renderer_in_context(wlr_renderer); gles2_get_renderer_in_context(wlr_renderer);
GLint gl_format = -1, gl_type = -1;
push_gles2_debug(renderer); push_gles2_debug(renderer);
GLint gl_format = -1, gl_type = -1;
glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &gl_format); glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &gl_format);
glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &gl_type); glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &gl_type);
pop_gles2_debug(renderer);
EGLint alpha_size = -1; EGLint alpha_size = -1;
if (renderer->current_buffer != NULL) { glBindRenderbuffer(GL_RENDERBUFFER, renderer->current_buffer->rbo);
glBindRenderbuffer(GL_RENDERBUFFER, renderer->current_buffer->rbo); glGetRenderbufferParameteriv(GL_RENDERBUFFER,
glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_ALPHA_SIZE, &alpha_size);
GL_RENDERBUFFER_ALPHA_SIZE, &alpha_size); glBindRenderbuffer(GL_RENDERBUFFER, 0);
glBindRenderbuffer(GL_RENDERBUFFER, 0);
} pop_gles2_debug(renderer);
const struct wlr_gles2_pixel_format *fmt = const struct wlr_gles2_pixel_format *fmt =
get_gles2_format_from_gl(gl_format, gl_type, alpha_size > 0); get_gles2_format_from_gl(gl_format, gl_type, alpha_size > 0);
@ -508,42 +492,27 @@ static bool gles2_read_pixels(struct wlr_renderer *wlr_renderer,
unsigned char *p = (unsigned char *)data + dst_y * stride; unsigned char *p = (unsigned char *)data + dst_y * stride;
uint32_t pack_stride = width * fmt->bpp / 8; uint32_t pack_stride = width * fmt->bpp / 8;
if (pack_stride == stride && dst_x == 0 && flags != NULL) { if (pack_stride == stride && dst_x == 0) {
// Under these particular conditions, we can read the pixels with only // Under these particular conditions, we can read the pixels with only
// one glReadPixels call // one glReadPixels call
uint32_t y = src_y; glReadPixels(src_x, src_y, width, height, fmt->gl_format, fmt->gl_type, p);
if (renderer->current_buffer == NULL) {
y = renderer->viewport_height - height - src_y;
}
glReadPixels(src_x, y, width, height, fmt->gl_format, fmt->gl_type, p);
if (renderer->current_buffer != NULL) {
*flags = 0;
} else {
*flags = WLR_RENDERER_READ_PIXELS_Y_INVERT;
}
} else { } else {
// Unfortunately GLES2 doesn't support GL_PACK_*, so we have to read // Unfortunately GLES2 doesn't support GL_PACK_*, so we have to read
// the lines out row by row // the lines out row by row
for (size_t i = 0; i < height; ++i) { for (size_t i = 0; i < height; ++i) {
uint32_t y = src_y + i; uint32_t y = src_y + i;
if (renderer->current_buffer == NULL) {
y = renderer->viewport_height - src_y - i - 1;
}
glReadPixels(src_x, y, width, 1, fmt->gl_format, glReadPixels(src_x, y, width, 1, fmt->gl_format,
fmt->gl_type, p + i * stride + dst_x * fmt->bpp / 8); fmt->gl_type, p + i * stride + dst_x * fmt->bpp / 8);
} }
if (flags != NULL) {
*flags = 0;
}
} }
pop_gles2_debug(renderer); pop_gles2_debug(renderer);
if (flags != NULL) {
*flags = 0;
}
return glGetError() == GL_NO_ERROR; return glGetError() == GL_NO_ERROR;
} }
@ -565,7 +534,7 @@ static bool gles2_blit_dmabuf(struct wlr_renderer *wlr_renderer,
goto restore_context_out; goto restore_context_out;
} }
// TODO: get inverted_y right when current_buffer != NULL // TODO: get inverted_y right
// This is to take into account y-inversion on both buffers rather than // This is to take into account y-inversion on both buffers rather than
// just the source buffer. // just the source buffer.
bool src_inverted_y = bool src_inverted_y =
@ -574,11 +543,6 @@ static bool gles2_blit_dmabuf(struct wlr_renderer *wlr_renderer,
!!(dst_attr->flags & WLR_DMABUF_ATTRIBUTES_FLAGS_Y_INVERT); !!(dst_attr->flags & WLR_DMABUF_ATTRIBUTES_FLAGS_Y_INVERT);
struct wlr_gles2_texture *gles2_src_tex = gles2_get_texture(src_tex); struct wlr_gles2_texture *gles2_src_tex = gles2_get_texture(src_tex);
gles2_src_tex->inverted_y = src_inverted_y ^ dst_inverted_y; gles2_src_tex->inverted_y = src_inverted_y ^ dst_inverted_y;
if (renderer->current_buffer == NULL) {
// The result is negated because wlr_matrix_projection y-inverts the
// texture.
gles2_src_tex->inverted_y = !gles2_src_tex->inverted_y;
}
if (!wlr_egl_make_current(renderer->egl)) { if (!wlr_egl_make_current(renderer->egl)) {
goto texture_destroy_out; goto texture_destroy_out;

Loading…
Cancel
Save