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 /backend/drm/drm.c | |
parent | ce8786721b17febb5132c136213c95a095f13121 (diff) |
Refactored renderer startup to function.
Diffstat (limited to 'backend/drm/drm.c')
-rw-r--r-- | backend/drm/drm.c | 69 |
1 files changed, 26 insertions, 43 deletions
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"); -} |