diff options
author | Scott Anderson <ascent12@hotmail.com> | 2017-05-14 12:48:47 +1200 |
---|---|---|
committer | Scott Anderson <ascent12@hotmail.com> | 2017-05-14 12:48:47 +1200 |
commit | 7efdd3c9fc38de377a43bb368cf113524b5a73d7 (patch) | |
tree | 519f96e938feea40661a22b9da106867c8f739ea | |
parent | ce8786721b17febb5132c136213c95a095f13121 (diff) |
Refactored renderer startup to function.
-rw-r--r-- | backend/drm/backend.c | 2 | ||||
-rw-r--r-- | backend/drm/drm.c | 69 | ||||
-rw-r--r-- | include/backend/drm/drm.h | 2 |
3 files changed, 28 insertions, 45 deletions
diff --git a/backend/drm/backend.c b/backend/drm/backend.c index 3c7af14b..e49197ec 100644 --- a/backend/drm/backend.c +++ b/backend/drm/backend.c @@ -57,7 +57,7 @@ static void device_resumed(struct wl_listener *listener, void *data) { for (size_t i = 0; i < drm->outputs->length; ++i) { struct wlr_output_state *output = drm->outputs->items[i]; - wlr_drm_output_draw_blank(output); + wlr_drm_output_start_renderer(output); } } diff --git a/backend/drm/drm.c b/backend/drm/drm.c index bd8c6506..8a63a2d0 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -113,23 +113,13 @@ void wlr_drm_output_end(struct wlr_output *output) { _output->pageflip_pending = true; } -static bool display_init_renderer(struct wlr_drm_renderer *renderer, - struct wlr_output_state *output) { - struct wlr_output_mode *mode = output->wlr_output->current_mode; - output->renderer = renderer; - output->gbm = gbm_surface_create(renderer->gbm, mode->width, - mode->height, GBM_FORMAT_XRGB8888, GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING); - if (!output->gbm) { - wlr_log(L_ERROR, "Failed to create GBM surface for %s: %s", output->name, - strerror(errno)); - return false; +void wlr_drm_output_start_renderer(struct wlr_output_state *output) { + if (output->state != DRM_OUTPUT_CONNECTED) { + return; } - output->egl = wlr_egl_create_surface(&renderer->egl, output->gbm); - if (output->egl == EGL_NO_SURFACE) { - wlr_log(L_ERROR, "Failed to create EGL surface for %s", output->name); - return false; - } + struct wlr_drm_renderer *renderer = output->renderer; + struct wlr_output_mode *mode = output->wlr_output->current_mode; // Render black frame eglMakeCurrent(renderer->egl.display, output->egl, output->egl, renderer->egl.context); @@ -149,6 +139,27 @@ static bool display_init_renderer(struct wlr_drm_renderer *renderer, DRM_MODE_PAGE_FLIP_EVENT, output); gbm_surface_release_buffer(output->gbm, bo); +} + +static bool display_init_renderer(struct wlr_drm_renderer *renderer, + struct wlr_output_state *output) { + struct wlr_output_mode *mode = output->wlr_output->current_mode; + output->renderer = renderer; + output->gbm = gbm_surface_create(renderer->gbm, mode->width, + mode->height, GBM_FORMAT_XRGB8888, GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING); + if (!output->gbm) { + wlr_log(L_ERROR, "Failed to create GBM surface for %s: %s", output->name, + strerror(errno)); + return false; + } + + output->egl = wlr_egl_create_surface(&renderer->egl, output->gbm); + if (output->egl == EGL_NO_SURFACE) { + wlr_log(L_ERROR, "Failed to create EGL surface for %s", output->name); + return false; + } + + wlr_drm_output_start_renderer(output); return true; } @@ -474,31 +485,3 @@ void wlr_drm_output_dpms(int fd, struct wlr_output_state *output, bool screen_on DRM_MODE_DPMS_STANDBY); } } - -void wlr_drm_output_draw_blank(struct wlr_output_state *output) { - if (output->state != DRM_OUTPUT_CONNECTED) { - return; - } - - struct wlr_drm_renderer *renderer = output->renderer; - - eglMakeCurrent(renderer->egl.display, output->egl, output->egl, renderer->egl.context); - - glViewport(0, 0, output->width, output->height); - glClearColor(0.0, 0.0, 0.0, 1.0); - glClear(GL_COLOR_BUFFER_BIT); - - 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); - - drmModeSetCrtc(renderer->fd, output->crtc, fb_id, 0, 0, - &output->connector, 1, &output->wlr_output->current_mode->state->mode); - drmModePageFlip(renderer->fd, output->crtc, fb_id, - DRM_MODE_PAGE_FLIP_EVENT, output); - - gbm_surface_release_buffer(output->gbm, bo); - - wlr_log(L_INFO, "Drew blank frame"); -} diff --git a/include/backend/drm/drm.h b/include/backend/drm/drm.h index 6c60e2b6..1d9f95be 100644 --- a/include/backend/drm/drm.h +++ b/include/backend/drm/drm.h @@ -60,6 +60,6 @@ void wlr_drm_output_dpms(int fd, struct wlr_output_state *output, bool screen_on void wlr_drm_scan_connectors(struct wlr_backend_state *state); int wlr_drm_event(int fd, uint32_t mask, void *data); -void wlr_drm_output_draw_blank(struct wlr_output_state *output); +void wlr_drm_output_start_renderer(struct wlr_output_state *output); #endif |