summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Ekstrand <jason@jlekstrand.net>2015-01-13 15:08:35 -0800
committerKeith Packard <keithp@keithp.com>2015-01-23 10:49:33 -0800
commitb4703a5a6e529b78810db8d8782317f0b4e2f265 (patch)
tree68f7ce1da26a2edea9c17f34dc6b2c7aeb1bd76e
parentbb23fbf5bb278113c9c481875423b4d128180972 (diff)
modesetting: Refactor drmmode_glamor_new_screen_pixmap
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. v2 Jason Ekstrand <jason.ekstrand@intel.com>: - Re-arranged code in drmmode_set_pixmap_bo and drmmode_glamor_handle_new_screen_pixmap so that glamor_set_screen_pixmap only gets called for the screen pixmap - Guard the call to glamor_set_screen_pixmapa with a drmmode->glamor check Signed-off-by: Jason Ekstrand <jason.ekstrand@intel.com> Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--hw/xfree86/drivers/modesetting/drmmode_display.c39
1 files changed, 27 insertions, 12 deletions
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
index 824500bae..ea59ffeb9 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -1123,34 +1123,32 @@ 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);
#else
- if (!glamor_egl_create_textured_screen(screen,
+ if (!glamor_egl_create_textured_pixmap(pixmap,
drmmode_bo_get_handle(&drmmode->front_bo),
scrn->displayWidth *
scrn->bitsPerPixel / 8)) {
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
- "glamor_egl_create_textured_screen() failed\n");
+ "glamor_egl_create_textured_pixmap() failed\n");
return FALSE;
}
#endif
@@ -1159,6 +1157,23 @@ 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);
+
+ if (!drmmode_set_pixmap_bo(drmmode, screen_pixmap, &drmmode->front_bo))
+ return FALSE;
+
+#ifdef GLAMOR
+ if (drmmode->glamor)
+ glamor_set_screen_pixmap(screen_pixmap, NULL);
+#endif
+
+ return TRUE;
+}
+
static Bool
drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
{