[PATCH 3/4] modesetting: Refactor drmmode_glamor_new_screen_pixmap

Jason Ekstrand jason at jlekstrand.net
Fri Dec 19 14:12:44 PST 2014


The original drmmode_glamor_new_screen_pixmap function was specific to the
primary screen pixmap.  This commit pulls the guts out into a new, more
general, drmmode_set_pixmap_bo function for setting a buffer on a pixmap.
The new function also properly tears down the glamor bits if the buffer
being set is NULL.  The drmmode_glamor_new_screen_pixmap function is now
just a 3-line wrapper around drmmode_set_pixmap_bo.

Signed-off-by: Jason Ekstrand <jason.ekstrand at intel.com>
---
 hw/xfree86/drivers/modesetting/drmmode_display.c | 29 +++++++++++++++---------
 1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
index f4b0f1d..5648d7b 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -1124,29 +1124,28 @@ drmmode_clones_init(ScrnInfoPtr scrn, drmmode_ptr drmmode)
     }
 }
 
-Bool
-drmmode_glamor_handle_new_screen_pixmap(drmmode_ptr drmmode)
+static Bool
+drmmode_set_pixmap_bo(drmmode_ptr drmmode, PixmapPtr pixmap, drmmode_bo *bo)
 {
 #ifdef GLAMOR
     ScrnInfoPtr scrn = drmmode->scrn;
-    ScreenPtr screen = xf86ScrnToScreen(drmmode->scrn);
-    PixmapPtr screen_pixmap;
-    void *gbm_bo;
 
     if (!drmmode->glamor)
         return TRUE;
 
-#ifdef GLAMOR_HAS_GBM
-    gbm_bo = drmmode->front_bo.gbm;
-    screen_pixmap = screen->GetScreenPixmap(screen);
+    if (bo == NULL) {
+        glamor_egl_destroy_textured_pixmap(pixmap);
+        return TRUE;
+    }
 
-    if (!glamor_egl_create_textured_pixmap_from_gbm_bo(screen_pixmap, gbm_bo)) {
+#ifdef GLAMOR_HAS_GBM
+    if (!glamor_egl_create_textured_pixmap_from_gbm_bo(pixmap, bo->gbm)) {
         xf86DrvMsg(scrn->scrnIndex, X_ERROR, "Failed");
         return FALSE;
     }
-    glamor_set_screen_pixmap(screen_pixmap, NULL);
+    glamor_set_screen_pixmap(pixmap, NULL);
 #else
-    if (!glamor_egl_create_textured_screen(screen,
+    if (!glamor_egl_create_textured_screen(xf86ScrnToScreen(drmmode->scrn),
                                            drmmode_bo_get_handle(&drmmode->front_bo),
                                            scrn->displayWidth *
                                            scrn->bitsPerPixel / 8)) {
@@ -1160,6 +1159,14 @@ drmmode_glamor_handle_new_screen_pixmap(drmmode_ptr drmmode)
     return TRUE;
 }
 
+Bool
+drmmode_glamor_handle_new_screen_pixmap(drmmode_ptr drmmode)
+{
+    ScreenPtr screen = xf86ScrnToScreen(drmmode->scrn);
+    PixmapPtr screen_pixmap = screen->GetScreenPixmap(screen);
+    return drmmode_set_pixmap_bo(drmmode, screen_pixmap, &drmmode->front_bo);
+}
+
 static Bool
 drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
 {
-- 
2.2.0



More information about the xorg-devel mailing list