mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-10-31 22:25:21 -04:00
render/gles2: make wlr_renderer_begin take viewport size
This allows raw GL calls outside wlr_renderer to be removed.
This commit is contained in:
parent
95e86e675a
commit
3581573bdc
14 changed files with 47 additions and 51 deletions
|
|
@ -643,14 +643,13 @@ static bool wlr_drm_connector_set_cursor(struct wlr_output *output,
|
|||
wlr_texture_upload_pixels(plane->wlr_tex, WL_SHM_FORMAT_ARGB8888,
|
||||
stride, width, height, buf);
|
||||
|
||||
glViewport(0, 0, plane->surf.width, plane->surf.height);
|
||||
glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
struct wlr_renderer *rend = plane->surf.renderer->wlr_rend;
|
||||
wlr_renderer_begin(rend, plane->surf.width, plane->surf.height);
|
||||
wlr_renderer_clear(rend, (float[]){ 0.0, 0.0, 0.0, 0.0 });
|
||||
wlr_render_texture(rend, plane->wlr_tex, plane->matrix, 0, 0, 1.0f);
|
||||
wlr_renderer_end(rend);
|
||||
|
||||
wlr_render_texture(plane->surf.renderer->wlr_rend, plane->wlr_tex,
|
||||
plane->matrix, 0, 0, 1.0f);
|
||||
|
||||
glFinish();
|
||||
// TODO: remove these raw GL calls
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, bo_stride);
|
||||
glReadPixels(0, 0, plane->surf.width, plane->surf.height, GL_BGRA_EXT,
|
||||
GL_UNSIGNED_BYTE, bo_data);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
#include <gbm.h>
|
||||
#include <GLES2/gl2.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
|
@ -107,9 +106,6 @@ void wlr_drm_surface_finish(struct wlr_drm_surface *surf) {
|
|||
return;
|
||||
}
|
||||
|
||||
eglMakeCurrent(surf->renderer->egl.display, EGL_NO_SURFACE, EGL_NO_SURFACE,
|
||||
EGL_NO_CONTEXT);
|
||||
|
||||
if (surf->front) {
|
||||
gbm_surface_release_buffer(surf->gbm, surf->front);
|
||||
}
|
||||
|
|
@ -151,9 +147,10 @@ struct gbm_bo *wlr_drm_surface_get_front(struct wlr_drm_surface *surf) {
|
|||
}
|
||||
|
||||
wlr_drm_surface_make_current(surf, NULL);
|
||||
glViewport(0, 0, surf->width, surf->height);
|
||||
glClearColor(0.0, 0.0, 0.0, 1.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
struct wlr_renderer *renderer = surf->renderer->wlr_rend;
|
||||
wlr_renderer_begin(renderer, surf->width, surf->height);
|
||||
wlr_renderer_clear(renderer, (float[]){ 0.0, 0.0, 0.0, 1.0 });
|
||||
wlr_renderer_end(renderer);
|
||||
return wlr_drm_surface_swap_buffers(surf, NULL);
|
||||
}
|
||||
|
||||
|
|
@ -185,6 +182,8 @@ static struct wlr_texture *get_tex_for_bo(struct wlr_drm_renderer *renderer,
|
|||
return tex->tex;
|
||||
}
|
||||
|
||||
// TODO: use wlr_texture_upload_dmabuf instead
|
||||
|
||||
tex = malloc(sizeof(*tex));
|
||||
if (!tex) {
|
||||
wlr_log_errno(L_ERROR, "Allocation failed");
|
||||
|
|
@ -230,14 +229,14 @@ struct gbm_bo *wlr_drm_surface_mgpu_copy(struct wlr_drm_surface *dest,
|
|||
struct wlr_texture *tex = get_tex_for_bo(dest->renderer, src);
|
||||
assert(tex);
|
||||
|
||||
static const float color[] = {0.0, 0.0, 0.0, 1.0};
|
||||
|
||||
float mat[9];
|
||||
wlr_matrix_projection(mat, 1, 1, WL_OUTPUT_TRANSFORM_FLIPPED_180);
|
||||
|
||||
glViewport(0, 0, dest->width, dest->height);
|
||||
wlr_renderer_clear(dest->renderer->wlr_rend, color);
|
||||
wlr_render_texture_with_matrix(dest->renderer->wlr_rend, tex, mat, 1.0f);
|
||||
struct wlr_renderer *renderer = dest->renderer->wlr_rend;
|
||||
wlr_renderer_begin(renderer, dest->width, dest->height);
|
||||
wlr_renderer_clear(renderer, (float[]){ 0.0, 0.0, 0.0, 1.0 });
|
||||
wlr_render_texture_with_matrix(renderer, tex, mat, 1.0f);
|
||||
wlr_renderer_end(renderer);
|
||||
|
||||
return wlr_drm_surface_swap_buffers(dest, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
#include <GLES2/gl2.h>
|
||||
#include <stdlib.h>
|
||||
#include <wlr/interfaces/wlr_output.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include "backend/headless.h"
|
||||
#include "util/signal.h"
|
||||
|
|
@ -120,16 +120,14 @@ struct wlr_output *wlr_headless_add_output(struct wlr_backend *wlr_backend,
|
|||
snprintf(wlr_output->name, sizeof(wlr_output->name), "HEADLESS-%d",
|
||||
wl_list_length(&backend->outputs) + 1);
|
||||
|
||||
if (!eglMakeCurrent(output->backend->egl.display,
|
||||
output->egl_surface, output->egl_surface,
|
||||
output->backend->egl.context)) {
|
||||
wlr_log(L_ERROR, "eglMakeCurrent failed: %s", egl_error());
|
||||
if (!wlr_egl_make_current(&output->backend->egl, output->egl_surface,
|
||||
NULL)) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
glViewport(0, 0, wlr_output->width, wlr_output->height);
|
||||
glClearColor(1.0, 1.0, 1.0, 1.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
wlr_renderer_begin(backend->renderer, wlr_output->width, wlr_output->height);
|
||||
wlr_renderer_clear(backend->renderer, (float[]){ 1.0, 1.0, 1.0, 1.0 });
|
||||
wlr_renderer_end(backend->renderer);
|
||||
|
||||
struct wl_event_loop *ev = wl_display_get_event_loop(backend->display);
|
||||
output->frame_timer = wl_event_loop_add_timer(ev, signal_frame, output);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
#include <assert.h>
|
||||
#include <GLES2/gl2.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
|
@ -9,6 +8,7 @@
|
|||
#include <unistd.h>
|
||||
#include <wayland-client.h>
|
||||
#include <wlr/interfaces/wlr_output.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include "backend/wayland.h"
|
||||
#include "util/signal.h"
|
||||
|
|
@ -313,27 +313,26 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend *_backend) {
|
|||
|
||||
output->egl_window = wl_egl_window_create(output->surface,
|
||||
wlr_output->width, wlr_output->height);
|
||||
output->egl_surface = wlr_egl_create_surface(&backend->egl, output->egl_window);
|
||||
output->egl_surface = wlr_egl_create_surface(&backend->egl,
|
||||
output->egl_window);
|
||||
|
||||
wl_display_roundtrip(output->backend->remote_display);
|
||||
|
||||
// start rendering loop per callbacks by rendering first frame
|
||||
if (!eglMakeCurrent(output->backend->egl.display,
|
||||
output->egl_surface, output->egl_surface,
|
||||
output->backend->egl.context)) {
|
||||
wlr_log(L_ERROR, "eglMakeCurrent failed: %s", egl_error());
|
||||
if (!wlr_egl_make_current(&output->backend->egl, output->egl_surface,
|
||||
NULL)) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
glViewport(0, 0, wlr_output->width, wlr_output->height);
|
||||
glClearColor(1.0, 1.0, 1.0, 1.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
wlr_renderer_begin(backend->renderer, wlr_output->width, wlr_output->height);
|
||||
wlr_renderer_clear(backend->renderer, (float[]){ 1.0, 1.0, 1.0, 1.0 });
|
||||
wlr_renderer_end(backend->renderer);
|
||||
|
||||
output->frame_callback = wl_surface_frame(output->surface);
|
||||
wl_callback_add_listener(output->frame_callback, &frame_listener, output);
|
||||
|
||||
if (!eglSwapBuffers(output->backend->egl.display, output->egl_surface)) {
|
||||
wlr_log(L_ERROR, "eglSwapBuffers failed: %s", egl_error());
|
||||
if (!wlr_egl_swap_buffers(&output->backend->egl, output->egl_surface,
|
||||
NULL)) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue