diff options
author | Scott Anderson <ascent12@hotmail.com> | 2017-10-01 15:55:25 +1300 |
---|---|---|
committer | Scott Anderson <ascent12@hotmail.com> | 2017-10-01 15:55:25 +1300 |
commit | eaef028976d32e382c4ebcfbb8605a6f40cd22b8 (patch) | |
tree | f2451fe02f8ce043281a492ff37e91be87c0dc98 /backend/drm | |
parent | 4101b897000602caf04aba8a10c1b4a4b229f4d6 (diff) |
Add renderer pointer inside drm_surface
Diffstat (limited to 'backend/drm')
-rw-r--r-- | backend/drm/drm.c | 20 | ||||
-rw-r--r-- | backend/drm/renderer.c | 33 |
2 files changed, 25 insertions, 28 deletions
diff --git a/backend/drm/drm.c b/backend/drm/drm.c index 676f5f7b..5c5ac8cd 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -175,7 +175,7 @@ void wlr_drm_resources_free(struct wlr_drm_backend *drm) { static void wlr_drm_connector_make_current(struct wlr_output *output) { struct wlr_drm_connector *conn = (struct wlr_drm_connector *)output; - wlr_drm_surface_make_current(&conn->drm->renderer, &conn->crtc->primary->surf); + wlr_drm_surface_make_current(&conn->crtc->primary->surf); } static void wlr_drm_connector_swap_buffers(struct wlr_output *output) { @@ -185,7 +185,7 @@ static void wlr_drm_connector_swap_buffers(struct wlr_output *output) { struct wlr_drm_crtc *crtc = conn->crtc; struct wlr_drm_plane *plane = crtc->primary; - struct gbm_bo *bo = wlr_drm_surface_swap_buffers(&drm->renderer, &plane->surf); + struct gbm_bo *bo = wlr_drm_surface_swap_buffers(&plane->surf); uint32_t fb_id = get_fb_for_bo(bo); if (drm->iface->crtc_pageflip(drm, conn, crtc, fb_id, NULL)) { @@ -217,7 +217,7 @@ void wlr_drm_connector_start_renderer(struct wlr_drm_connector *conn) { struct wlr_drm_crtc *crtc = conn->crtc; struct wlr_drm_plane *plane = crtc->primary; - struct gbm_bo *bo = wlr_drm_surface_get_front(&drm->renderer, &plane->surf); + struct gbm_bo *bo = wlr_drm_surface_get_front(&plane->surf); uint32_t fb_id = get_fb_for_bo(bo); struct wlr_drm_mode *mode = (struct wlr_drm_mode *)conn->output.current_mode; @@ -283,9 +283,9 @@ static void realloc_planes(struct wlr_drm_backend *drm, const uint32_t *crtc_in) if (*old != new) { if (*old) { - wlr_drm_surface_finish(&drm->renderer, &(*old)->surf); + wlr_drm_surface_finish(&(*old)->surf); } - wlr_drm_surface_finish(&drm->renderer, &new->surf); + wlr_drm_surface_finish(&new->surf); *old = new; } } @@ -430,7 +430,7 @@ static bool wlr_drm_connector_set_mode(struct wlr_output *output, continue; } - if (!wlr_drm_surface_init(&drm->renderer, &crtc->primary->surf, + if (!wlr_drm_surface_init(&crtc->primary->surf, &drm->renderer, mode->width, mode->height, GBM_FORMAT_XRGB8888, GBM_BO_USE_SCANOUT)) { wlr_log(L_ERROR, "Failed to initalise renderer for plane"); @@ -488,7 +488,7 @@ static bool wlr_drm_connector_set_cursor(struct wlr_output *output, return false; } - if (!wlr_drm_surface_init(renderer, &plane->surf, w, h, GBM_FORMAT_ARGB8888, 0)) { + if (!wlr_drm_surface_init(&plane->surf, renderer, w, h, GBM_FORMAT_ARGB8888, 0)) { wlr_log(L_ERROR, "Cannot allocate cursor resources"); return false; } @@ -530,7 +530,7 @@ static bool wlr_drm_connector_set_cursor(struct wlr_output *output, return false; } - wlr_drm_surface_make_current(renderer, &plane->surf); + wlr_drm_surface_make_current(&plane->surf); wlr_texture_upload_pixels(plane->wlr_tex, WL_SHM_FORMAT_ARGB8888, stride, width, height, buf); @@ -548,7 +548,7 @@ static bool wlr_drm_connector_set_cursor(struct wlr_output *output, glReadPixels(0, 0, plane->surf.width, plane->surf.height, GL_BGRA_EXT, GL_UNSIGNED_BYTE, bo_data); glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, 0); - wlr_drm_surface_swap_buffers(renderer, &plane->surf); + wlr_drm_surface_swap_buffers(&plane->surf); gbm_bo_unmap(bo, bo_data); @@ -854,7 +854,7 @@ void wlr_drm_connector_cleanup(struct wlr_drm_connector *conn) { case WLR_DRM_CONN_CLEANUP:; struct wlr_drm_crtc *crtc = conn->crtc; for (int i = 0; i < 3; ++i) { - wlr_drm_surface_finish(&drm->renderer, &crtc->planes[i]->surf); + wlr_drm_surface_finish(&crtc->planes[i]->surf); if (crtc->planes[i] && crtc->planes[i]->id == 0) { free(crtc->planes[i]); crtc->planes[i] = NULL; diff --git a/backend/drm/renderer.c b/backend/drm/renderer.c index 8afc6dca..e1c6a4bc 100644 --- a/backend/drm/renderer.c +++ b/backend/drm/renderer.c @@ -35,13 +35,14 @@ void wlr_drm_renderer_finish(struct wlr_drm_renderer *renderer) { gbm_device_destroy(renderer->gbm); } -bool wlr_drm_surface_init(struct wlr_drm_renderer *renderer, - struct wlr_drm_surface *surf, uint32_t width, uint32_t height, +bool wlr_drm_surface_init(struct wlr_drm_surface *surf, + struct wlr_drm_renderer *renderer, uint32_t width, uint32_t height, uint32_t format, uint32_t flags) { if (surf->width == width && surf->height == height) { return true; } + surf->renderer = renderer; surf->width = width; surf->height = height; @@ -67,13 +68,12 @@ error_zero: return false; } -void wlr_drm_surface_finish(struct wlr_drm_renderer *renderer, - struct wlr_drm_surface *surf) { - if (!renderer || !surf || !surf->gbm) { +void wlr_drm_surface_finish(struct wlr_drm_surface *surf) { + if (!surf || !surf->renderer) { return; } - eglMakeCurrent(renderer->egl.display, EGL_NO_SURFACE, EGL_NO_SURFACE, + eglMakeCurrent(surf->renderer->egl.display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); if (surf->front) { @@ -84,7 +84,7 @@ void wlr_drm_surface_finish(struct wlr_drm_renderer *renderer, } if (surf->egl) { - eglDestroySurface(renderer->egl.display, surf->egl); + eglDestroySurface(surf->renderer->egl.display, surf->egl); } if (surf->gbm) { gbm_surface_destroy(surf->gbm); @@ -93,34 +93,31 @@ void wlr_drm_surface_finish(struct wlr_drm_renderer *renderer, memset(surf, 0, sizeof(*surf)); } -void wlr_drm_surface_make_current(struct wlr_drm_renderer *renderer, - struct wlr_drm_surface *surf) { - eglMakeCurrent(renderer->egl.display, surf->egl, surf->egl, - renderer->egl.context); +void wlr_drm_surface_make_current(struct wlr_drm_surface *surf) { + eglMakeCurrent(surf->renderer->egl.display, surf->egl, surf->egl, + surf->renderer->egl.context); } -struct gbm_bo *wlr_drm_surface_swap_buffers(struct wlr_drm_renderer *renderer, - struct wlr_drm_surface *surf) { +struct gbm_bo *wlr_drm_surface_swap_buffers(struct wlr_drm_surface *surf) { if (surf->front) { gbm_surface_release_buffer(surf->gbm, surf->front); } - eglSwapBuffers(renderer->egl.display, surf->egl); + eglSwapBuffers(surf->renderer->egl.display, surf->egl); surf->front = surf->back; surf->back = gbm_surface_lock_front_buffer(surf->gbm); return surf->back; } -struct gbm_bo *wlr_drm_surface_get_front(struct wlr_drm_renderer *renderer, - struct wlr_drm_surface *surf) { +struct gbm_bo *wlr_drm_surface_get_front(struct wlr_drm_surface *surf) { if (surf->front) { return surf->front; } - wlr_drm_surface_make_current(renderer, surf); + wlr_drm_surface_make_current(surf); glViewport(0, 0, surf->width, surf->height); glClearColor(0.0, 0.0, 0.0, 1.0); glClear(GL_COLOR_BUFFER_BIT); - return wlr_drm_surface_swap_buffers(renderer, surf); + return wlr_drm_surface_swap_buffers(surf); } |