diff options
author | Ben Widawsky <[email protected]> | 2016-11-29 21:53:52 -0800 |
---|---|---|
committer | Ben Widawsky <[email protected]> | 2017-03-09 15:35:44 -0800 |
commit | 42eacddfc027dd8668956dd836b85e16bab4f9f4 (patch) | |
tree | bb004208cfb66fc50a515f3c56e8a0514b949704 /src/gbm/backends | |
parent | 770b06588f79abe44d4fa1128759c45d0496362e (diff) |
gbm: Export a plane getter function
This will be used by clients that need to know the number of planes
allocated for them on behalf of the GL or other API. The best current
example of this is when an extra "plane" is allocated to store
compression data for the primary plane.
v2: Return 1 for cases where there is no image, ie. dumb bo (Daniel)
Signed-off-by: Ben Widawsky <[email protected]>
Reviewed-by: Eric Engestrom <[email protected]>
Reviewed-by: Jason Ekstrand <[email protected]>
Acked-by: Daniel Stone <[email protected]>
Diffstat (limited to 'src/gbm/backends')
-rw-r--r-- | src/gbm/backends/dri/gbm_dri.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c index 3faa19e3f19..9bd647fa19f 100644 --- a/src/gbm/backends/dri/gbm_dri.c +++ b/src/gbm/backends/dri/gbm_dri.c @@ -599,6 +599,32 @@ gbm_dri_bo_get_fd(struct gbm_bo *_bo) return fd; } +static int +get_number_planes(struct gbm_dri_device *dri, __DRIimage *image) +{ + int num_planes = 0; + + /* Dumb buffers are single-plane only. */ + if (!image) + return 1; + + dri->image->queryImage(image, __DRI_IMAGE_ATTRIB_NUM_PLANES, &num_planes); + + if (num_planes <= 0) + num_planes = 1; + + return num_planes; +} + +static int +gbm_dri_bo_get_planes(struct gbm_bo *_bo) +{ + struct gbm_dri_device *dri = gbm_dri_device(_bo->gbm); + struct gbm_dri_bo *bo = gbm_dri_bo(_bo); + + return get_number_planes(dri, bo->image); +} + static void gbm_dri_bo_destroy(struct gbm_bo *_bo) { @@ -1091,6 +1117,7 @@ dri_device_create(int fd) dri->base.base.is_format_supported = gbm_dri_is_format_supported; dri->base.base.bo_write = gbm_dri_bo_write; dri->base.base.bo_get_fd = gbm_dri_bo_get_fd; + dri->base.base.bo_get_planes = gbm_dri_bo_get_planes; dri->base.base.bo_destroy = gbm_dri_bo_destroy; dri->base.base.destroy = dri_destroy; dri->base.base.surface_create = gbm_dri_surface_create; |