mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-04 20:55:58 +01:00
Have backend manage opengl context
This commit is contained in:
parent
66e02e97ec
commit
03c9b46034
3 changed files with 16 additions and 25 deletions
|
@ -94,23 +94,21 @@ static uint32_t get_fb_for_bo(int fd, struct gbm_bo *bo) {
|
|||
return *id;
|
||||
}
|
||||
|
||||
void wlr_drm_output_begin(struct wlr_output *output) {
|
||||
struct wlr_output_state *_output = output->state;
|
||||
struct wlr_drm_renderer *renderer = _output->renderer;
|
||||
eglMakeCurrent(renderer->egl.display, _output->egl,
|
||||
_output->egl, renderer->egl.context);
|
||||
static void wlr_drm_output_begin(struct wlr_output_state *output) {
|
||||
struct wlr_drm_renderer *renderer = output->renderer;
|
||||
eglMakeCurrent(renderer->egl.display, output->egl,
|
||||
output->egl, renderer->egl.context);
|
||||
}
|
||||
|
||||
void wlr_drm_output_end(struct wlr_output *output) {
|
||||
struct wlr_output_state *_output = output->state;
|
||||
struct wlr_drm_renderer *renderer = _output->renderer;
|
||||
static void wlr_drm_output_end(struct wlr_output_state *output) {
|
||||
struct wlr_drm_renderer *renderer = output->renderer;
|
||||
|
||||
eglSwapBuffers(renderer->egl.display, _output->egl);
|
||||
struct gbm_bo *bo = gbm_surface_lock_front_buffer(_output->gbm);
|
||||
eglSwapBuffers(renderer->egl.display, output->egl);
|
||||
struct gbm_bo *bo = gbm_surface_lock_front_buffer(output->gbm);
|
||||
uint32_t fb_id = get_fb_for_bo(renderer->fd, bo);
|
||||
drmModePageFlip(renderer->fd, _output->crtc, fb_id, DRM_MODE_PAGE_FLIP_EVENT, _output);
|
||||
gbm_surface_release_buffer(_output->gbm, bo);
|
||||
_output->pageflip_pending = true;
|
||||
drmModePageFlip(renderer->fd, output->crtc, fb_id, DRM_MODE_PAGE_FLIP_EVENT, output);
|
||||
gbm_surface_release_buffer(output->gbm, bo);
|
||||
output->pageflip_pending = true;
|
||||
}
|
||||
|
||||
static bool display_init_renderer(struct wlr_drm_renderer *renderer,
|
||||
|
@ -396,7 +394,9 @@ static void page_flip_handler(int fd, unsigned seq,
|
|||
|
||||
output->pageflip_pending = false;
|
||||
if (output->state == DRM_OUTPUT_CONNECTED) {
|
||||
wlr_drm_output_begin(output);
|
||||
wl_signal_emit(&output->wlr_output->events.frame, output->wlr_output);
|
||||
wlr_drm_output_end(output);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -465,10 +465,10 @@ void wlr_drm_output_dpms(int fd, struct wlr_output_state *output, bool screen_on
|
|||
DRM_MODE_DPMS_ON);
|
||||
|
||||
// Start rendering loop again by drawing a black frame
|
||||
wlr_drm_output_begin(output->wlr_output);
|
||||
wlr_drm_output_begin(output);
|
||||
glClearColor(0.0, 0.0, 0.0, 1.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
wlr_drm_output_end(output->wlr_output);
|
||||
wlr_drm_output_end(output);
|
||||
} else {
|
||||
drmModeConnectorSetProperty(fd, output->connector, output->props.dpms,
|
||||
DRM_MODE_DPMS_STANDBY);
|
||||
|
|
|
@ -24,9 +24,7 @@ struct output_state {
|
|||
};
|
||||
|
||||
void output_frame(struct wl_listener *listener, void *data) {
|
||||
struct wlr_output *output = data;
|
||||
struct output_state *ostate = wl_container_of(
|
||||
listener, ostate, frame);
|
||||
struct output_state *ostate = wl_container_of(listener, ostate, frame);
|
||||
struct state *s = ostate->state;
|
||||
|
||||
struct timespec now;
|
||||
|
@ -48,12 +46,8 @@ void output_frame(struct wl_listener *listener, void *data) {
|
|||
|
||||
s->last_frame = now;
|
||||
|
||||
wlr_drm_output_begin(output);
|
||||
|
||||
glClearColor(s->color[0], s->color[1], s->color[2], 1.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
wlr_drm_output_end(output);
|
||||
}
|
||||
|
||||
void output_add(struct wl_listener *listener, void *data) {
|
||||
|
|
|
@ -12,7 +12,4 @@ struct wlr_backend *wlr_drm_backend_create(struct wl_display *display,
|
|||
|
||||
void wlr_drm_backend_dpms(struct wlr_backend *backend, bool screen_on);
|
||||
|
||||
void wlr_drm_output_begin(struct wlr_output *out);
|
||||
void wlr_drm_output_end(struct wlr_output *out);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue