Sync with codes from Mesa3D in Tizen Public 23/52323/2
authorSangwon Ha <sw815.ha@samsung.com>
Wed, 31 Dec 2014 09:44:36 +0000 (18:44 +0900)
committerSangjin Lee <lsj119@samsung.com>
Mon, 23 Nov 2015 02:55:35 +0000 (18:55 -0800)
  - mesa commit id: f3880bb35eb8d0dbe4ba7d4a5744a135b340c821

Change-Id: I14bad6afe39963fc22adbe1e1f7c1b8c34c1a820

src/backend.c
src/gbm.c
src/gbm.h

index a38b71f..bf3f06b 100644 (file)
 
 #define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))
 
+extern const struct gbm_backend gbm_dri_backend;
+
 struct backend_desc {
    const char *name;
    const struct gbm_backend *builtin;
 };
 
 static const struct backend_desc backends[] = {
-   { "gbm_dri.so", NULL },
+   { "gbm_dri.so", &gbm_dri_backend },
    { "gbm_gallium_drm.so", NULL },
    { "gbm_tbm.so", NULL },
 };
index 6179e5b..cb24e92 100644 (file)
--- a/src/gbm.c
+++ b/src/gbm.c
@@ -36,6 +36,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
+#include <errno.h>
 
 #include "gbm.h"
 #include "gbmint.h"
@@ -109,7 +110,7 @@ _gbm_mesa_get_device(int fd)
    int i;
 
    if (fd < 0 || fstat(fd, &buf) < 0 || !S_ISCHR(buf.st_mode)) {
-      fprintf(stderr, "_gbm_mesa_get_device: invalid fd: %d\n", fd);
+      errno = EINVAL;
       return NULL;
    }
 
@@ -145,7 +146,7 @@ gbm_create_device(int fd)
    struct stat buf;
 
    if (fd < 0 || fstat(fd, &buf) < 0 || !S_ISCHR(buf.st_mode)) {
-      fprintf(stderr, "gbm_create_device: invalid fd: %d\n", fd);
+      errno = EINVAL;
       return NULL;
    }
 
@@ -258,7 +259,7 @@ gbm_bo_get_fd(struct gbm_bo *bo)
  * \param bo The buffer object
  * \param buf The data to write
  * \param count The number of bytes to write
- * \return Returns -1 on error, 0 otherwise
+ * \return Returns 0 on success, otherwise -1 is returned an errno set
  */
 GBM_EXPORT int
 gbm_bo_write(struct gbm_bo *bo, const void *buf, size_t count)
@@ -332,7 +333,7 @@ gbm_bo_destroy(struct gbm_bo *bo)
  *
  * \return A newly allocated buffer that should be freed with gbm_bo_destroy()
  * when no longer needed. If an error occurs during allocation %NULL will be
- * returned.
+ * returned and errno set.
  *
  * \sa enum gbm_bo_format for the list of formats
  * \sa enum gbm_bo_flags for the list of usage flags
@@ -342,8 +343,10 @@ gbm_bo_create(struct gbm_device *gbm,
               uint32_t width, uint32_t height,
               uint32_t format, uint32_t usage)
 {
-   if (width == 0 || height == 0)
+   if (width == 0 || height == 0) {
+      errno = EINVAL;
       return NULL;
+   }
 
    if (usage & GBM_BO_USE_CURSOR_64X64 &&
        (width != 64 || height != 64))
@@ -373,7 +376,8 @@ gbm_bo_create(struct gbm_device *gbm,
  * \param usage The union of the usage flags for this buffer
  *
  * \return A newly allocated buffer object that should be freed with
- * gbm_bo_destroy() when no longer needed.
+ * gbm_bo_destroy() when no longer needed. On error, %NULL is returned
+ * and errno is set.
  *
  * \sa enum gbm_bo_flags for the list of usage flags
  */
index 92d472a..7b23c26 100644 (file)
--- a/src/gbm.h
+++ b/src/gbm.h
@@ -192,10 +192,13 @@ enum gbm_bo_flags {
     */
    GBM_BO_USE_SCANOUT      = (1 << 0),
    /**
-    * Buffer is going to be used as cursor - the dimensions for the buffer
-    * must be 64x64 if this flag is passed.
+    * Buffer is going to be used as cursor
     */
-   GBM_BO_USE_CURSOR_64X64 = (1 << 1),
+   GBM_BO_USE_CURSOR       = (1 << 1),
+   /**
+    * Deprecated
+    */
+   GBM_BO_USE_CURSOR_64X64 = GBM_BO_USE_CURSOR,
    /**
     * Buffer is to be used for rendering - for example it is going to be used
     * as the storage for a color buffer
@@ -203,8 +206,7 @@ enum gbm_bo_flags {
    GBM_BO_USE_RENDERING    = (1 << 2),
    /**
     * Buffer can be used for gbm_bo_write.  This is guaranteed to work
-    * with GBM_BO_USE_CURSOR_64X64. but may not work for other
-    * combinations.
+    * with GBM_BO_USE_CURSOR. but may not work for other combinations.
     */
    GBM_BO_USE_WRITE    = (1 << 3),
 };
@@ -285,6 +287,9 @@ gbm_surface_create(struct gbm_device *gbm,
                    uint32_t width, uint32_t height,
                   uint32_t format, uint32_t flags);
 
+int
+gbm_surface_needs_lock_front_buffer(struct gbm_surface *surface);
+
 struct gbm_bo *
 gbm_surface_lock_front_buffer(struct gbm_surface *surface);