[PATCH xf86-video-ati 2/4] Consolidate get_drawable_pixmap helper

Michel Dänzer michel at daenzer.net
Tue Sep 13 08:55:54 UTC 2016


From: Michel Dänzer <michel.daenzer at amd.com>

There were two static helpers for the same purpose. Consolidate them
into a single inline helper which can be used anywhere.

(Ported from amdgpu commit 641f4647b7f51dfd2da330376cd10fa9702b6423)

Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
---
 src/radeon_bo_helper.h       | 16 ++++++++++++++++
 src/radeon_dri2.c            |  9 ---------
 src/radeon_glamor_wrappers.c | 19 +------------------
 3 files changed, 17 insertions(+), 27 deletions(-)

diff --git a/src/radeon_bo_helper.h b/src/radeon_bo_helper.h
index d4a4ee0..f1aed55 100644
--- a/src/radeon_bo_helper.h
+++ b/src/radeon_bo_helper.h
@@ -41,4 +41,20 @@ extern Bool
 radeon_set_shared_pixmap_backing(PixmapPtr ppix, void *fd_handle,
 				 struct radeon_surface *surface);
 
+/**
+ * get_drawable_pixmap() returns the backing pixmap for a given drawable.
+ *
+ * @param drawable the drawable being requested.
+ *
+ * This function returns the backing pixmap for a drawable, whether it is a
+ * redirected window, unredirected window, or already a pixmap.
+ */
+static inline PixmapPtr get_drawable_pixmap(DrawablePtr drawable)
+{
+    if (drawable->type == DRAWABLE_PIXMAP)
+	return (PixmapPtr)drawable;
+    else
+	return drawable->pScreen->GetWindowPixmap((WindowPtr)drawable);
+}
+
 #endif /* RADEON_BO_HELPER_H */
diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c
index c55e6ee..069e446 100644
--- a/src/radeon_dri2.c
+++ b/src/radeon_dri2.c
@@ -78,15 +78,6 @@ static DevPrivateKeyRec dri2_window_private_key_rec;
      dixLookupPrivate(&(window)->devPrivates, dri2_window_private_key))
 
 
-static PixmapPtr get_drawable_pixmap(DrawablePtr drawable)
-{
-    if (drawable->type == DRAWABLE_PIXMAP)
-	return (PixmapPtr)drawable;
-    else
-	return (*drawable->pScreen->GetWindowPixmap)((WindowPtr)drawable);
-}
-
-
 static PixmapPtr fixup_glamor(DrawablePtr drawable, PixmapPtr pixmap)
 {
 	PixmapPtr old = get_drawable_pixmap(drawable);
diff --git a/src/radeon_glamor_wrappers.c b/src/radeon_glamor_wrappers.c
index cd02b06..5f165eb 100644
--- a/src/radeon_glamor_wrappers.c
+++ b/src/radeon_glamor_wrappers.c
@@ -35,27 +35,10 @@
 #ifdef USE_GLAMOR
 
 #include "radeon.h"
+#include "radeon_bo_helper.h"
 #include "radeon_glamor.h"
 
 
-/**
- * get_drawable_pixmap() returns the backing pixmap for a given drawable.
- *
- * @param pDrawable the drawable being requested.
- *
- * This function returns the backing pixmap for a drawable, whether it is a
- * redirected window, unredirected window, or already a pixmap.
- */
-static PixmapPtr
-get_drawable_pixmap(DrawablePtr pDrawable)
-{
-	if (pDrawable->type == DRAWABLE_WINDOW)
-		return pDrawable->pScreen->
-		    GetWindowPixmap((WindowPtr) pDrawable);
-	else
-		return (PixmapPtr) pDrawable;
-}
-
 /* Are there any outstanding GPU operations for this pixmap? */
 static Bool
 radeon_glamor_gpu_pending(uint_fast32_t gpu_synced, uint_fast32_t gpu_access)
-- 
2.9.3



More information about the amd-gfx mailing list