[Mesa-dev] [PATCH 2/3] gbm: Introduce a helper function gbm_to_dri_flag()

Vivek Kasireddy vivek.kasireddy at intel.com
Fri Nov 20 19:38:03 PST 2015


Pull the code that updates the variable dri_use based on the
GBM flags into this helper function.

Cc: Michel Danzer <michel at daenzer.net>
Signed-off-by: Vivek Kasireddy <vivek.kasireddy at intel.com>
---
 src/gbm/backends/dri/gbm_dri.c | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
index 57cdeac..88e5c5e 100644
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -124,6 +124,18 @@ image_get_buffers(__DRIdrawable *driDrawable,
 }
 
 static void
+gbm_to_dri_flag(uint32_t usage,
+                unsigned *dri_use)
+{
+   if (usage & GBM_BO_USE_SCANOUT)
+      *dri_use |= __DRI_IMAGE_USE_SCANOUT;
+   if (usage & GBM_BO_USE_CURSOR)
+      *dri_use |= __DRI_IMAGE_USE_CURSOR;
+   if (usage & GBM_BO_USE_LINEAR)
+      *dri_use |= __DRI_IMAGE_USE_LINEAR;
+}
+
+static void
 swrast_get_drawable_info(__DRIdrawable *driDrawable,
                          int           *x,
                          int           *y,
@@ -746,10 +758,8 @@ gbm_dri_bo_import(struct gbm_device *gbm,
 
    bo->image = image;
 
-   if (usage & GBM_BO_USE_SCANOUT)
-      dri_use |= __DRI_IMAGE_USE_SCANOUT;
-   if (usage & GBM_BO_USE_CURSOR)
-      dri_use |= __DRI_IMAGE_USE_CURSOR;
+   gbm_to_dri_flag(usage, &dri_use);
+
    if (dri->image->base.version >= 2 &&
        !dri->image->validateUsage(bo->image, dri_use)) {
       errno = EINVAL;
@@ -878,12 +888,7 @@ gbm_dri_bo_create(struct gbm_device *gbm,
       goto failed;
    }
 
-   if (usage & GBM_BO_USE_SCANOUT)
-      dri_use |= __DRI_IMAGE_USE_SCANOUT;
-   if (usage & GBM_BO_USE_CURSOR)
-      dri_use |= __DRI_IMAGE_USE_CURSOR;
-   if (usage & GBM_BO_USE_LINEAR)
-      dri_use |= __DRI_IMAGE_USE_LINEAR;
+   gbm_to_dri_flag(usage, &dri_use);
 
    /* Gallium drivers requires shared in order to get the handle/stride */
    dri_use |= __DRI_IMAGE_USE_SHARE;
-- 
2.4.3



More information about the mesa-dev mailing list