summaryrefslogtreecommitdiffstats
path: root/src/gbm/main
diff options
context:
space:
mode:
authorKristian Høgsberg <[email protected]>2012-05-02 15:30:13 -0400
committerKristian Høgsberg <[email protected]>2012-05-03 10:57:32 -0400
commit4fddb2ba21add1c1968330e5224ecead59da3995 (patch)
tree20b7a7e683f135f90e2fb5b67f1856e0f038e44b /src/gbm/main
parentb4789860c4416ba700ac5edeb692b59e33d45276 (diff)
gbm: Add gbm_bo_write entry point
This new gbm entry point allows writing data into a gbm bo. The bo has to be created with the GBM_BO_USE_WRITE flag, and it's only required to work for GBM_BO_USE_CURSOR_64X64 bos. The gbm API is designed to be the glue layer between EGL and KMS, but there was never a mechanism initialize a buffer suitable for use with KMS hw cursors. The hw cursor bo is typically not compatible with anything EGL can render to, and thus there's no way to get data into such a bo. gbm_bo_write() fills that gap while staying out of the efficient cpu->gpu pixel transfer business. Reviewed-by: Ander Conselvan de Oliveira <[email protected]>
Diffstat (limited to 'src/gbm/main')
-rw-r--r--src/gbm/main/gbm.c19
-rw-r--r--src/gbm/main/gbm.h9
-rw-r--r--src/gbm/main/gbmint.h1
3 files changed, 29 insertions, 0 deletions
diff --git a/src/gbm/main/gbm.c b/src/gbm/main/gbm.c
index 987e96500f8..3994f86aafc 100644
--- a/src/gbm/main/gbm.c
+++ b/src/gbm/main/gbm.c
@@ -231,6 +231,25 @@ gbm_bo_get_handle(struct gbm_bo *bo)
return bo->handle;
}
+/** Write data into the buffer object
+ *
+ * If the buffer object was created with the GBM_BO_USE_WRITE flag,
+ * this function can used to write data into the buffer object. The
+ * data is copied directly into the object and it's the responsiblity
+ * of the caller to make sure the data represents valid pixel data,
+ * according to the width, height, stride and format of the buffer object.
+ *
+ * \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
+ */
+GBM_EXPORT int
+gbm_bo_write(struct gbm_bo *bo, const void *buf, size_t count)
+{
+ return bo->gbm->bo_write(bo, buf, count);
+}
+
/** Get the gbm device used to create the buffer object
*
* \param bo The buffer object
diff --git a/src/gbm/main/gbm.h b/src/gbm/main/gbm.h
index cf3d4752c36..af5dc5aee8c 100644
--- a/src/gbm/main/gbm.h
+++ b/src/gbm/main/gbm.h
@@ -201,6 +201,12 @@ enum gbm_bo_flags {
* as the storage for a color buffer
*/
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.
+ */
+ GBM_BO_USE_WRITE = (1 << 3),
};
int
@@ -248,6 +254,9 @@ gbm_bo_get_device(struct gbm_bo *bo);
union gbm_bo_handle
gbm_bo_get_handle(struct gbm_bo *bo);
+int
+gbm_bo_write(struct gbm_bo *bo, const void *buf, size_t count);
+
void
gbm_bo_set_user_data(struct gbm_bo *bo, void *data,
void (*destroy_user_data)(struct gbm_bo *, void *));
diff --git a/src/gbm/main/gbmint.h b/src/gbm/main/gbmint.h
index 0e98bdf3d8d..8eb8671aeb2 100644
--- a/src/gbm/main/gbmint.h
+++ b/src/gbm/main/gbmint.h
@@ -70,6 +70,7 @@ struct gbm_device {
void *egl_dpy, void *egl_img,
uint32_t width, uint32_t height,
uint32_t usage);
+ int (*bo_write)(struct gbm_bo *bo, const void *buf, size_t data);
void (*bo_destroy)(struct gbm_bo *bo);
struct gbm_surface *(*surface_create)(struct gbm_device *gbm,