diff --git a/src/gfxstream/guest/android/GrallocEmulated.cpp b/src/gfxstream/guest/android/GrallocEmulated.cpp index d1714864ce7..e2b1cb92cce 100644 --- a/src/gfxstream/guest/android/GrallocEmulated.cpp +++ b/src/gfxstream/guest/android/GrallocEmulated.cpp @@ -218,6 +218,16 @@ uint32_t EmulatedGralloc::getFormatDrmFourcc(const AHardwareBuffer* handle) { return ahb->getDrmFormat(); } +uint32_t EmulatedGralloc::getWidth(const AHardwareBuffer* handle) { + const auto* ahb = reinterpret_cast(handle); + return ahb->getWidth(); +} + +uint32_t EmulatedGralloc::getHeight(const AHardwareBuffer* handle) { + const auto* ahb = reinterpret_cast(handle); + return ahb->getHeight(); +} + size_t EmulatedGralloc::getAllocatedSize(const native_handle_t*) { ALOGE("Unimplemented."); return 0; diff --git a/src/gfxstream/guest/android/GrallocEmulated.h b/src/gfxstream/guest/android/GrallocEmulated.h index cf1ba0f7f15..ded73f53668 100644 --- a/src/gfxstream/guest/android/GrallocEmulated.h +++ b/src/gfxstream/guest/android/GrallocEmulated.h @@ -87,6 +87,9 @@ class EmulatedGralloc : public Gralloc { uint32_t getFormatDrmFourcc(const AHardwareBuffer* handle) override; + uint32_t getWidth(const AHardwareBuffer* ahb) override; + uint32_t getHeight(const AHardwareBuffer* ahb) override; + size_t getAllocatedSize(const native_handle_t*) override; size_t getAllocatedSize(const AHardwareBuffer*) override; diff --git a/src/gfxstream/guest/android/GrallocGoldfish.cpp b/src/gfxstream/guest/android/GrallocGoldfish.cpp index bdd32e3edd5..7df87daf585 100644 --- a/src/gfxstream/guest/android/GrallocGoldfish.cpp +++ b/src/gfxstream/guest/android/GrallocGoldfish.cpp @@ -79,6 +79,18 @@ int GoldfishGralloc::getFormat(const AHardwareBuffer* ahb) { return getFormat(handle); } +uint32_t GoldfishGralloc::getWidth(const AHardwareBuffer* ahb) { + AHardwareBuffer_Desc desc = {}; + AHardwareBuffer_describe(ahb, &desc); + return desc.width; +} + +uint32_t GoldfishGralloc::getHeight(const AHardwareBuffer* ahb) { + AHardwareBuffer_Desc desc = {}; + AHardwareBuffer_describe(ahb, &desc); + return desc.height; +} + size_t GoldfishGralloc::getAllocatedSize(const native_handle_t* handle) { return static_cast(cb_handle_t::from(handle)->allocatedSize()); } diff --git a/src/gfxstream/guest/android/GrallocGoldfish.h b/src/gfxstream/guest/android/GrallocGoldfish.h index f25eedfb887..505d14f71cf 100644 --- a/src/gfxstream/guest/android/GrallocGoldfish.h +++ b/src/gfxstream/guest/android/GrallocGoldfish.h @@ -39,6 +39,9 @@ class GoldfishGralloc : public Gralloc { int getFormat(const native_handle_t* handle) override; int getFormat(const AHardwareBuffer* handle) override; + uint32_t getWidth(const AHardwareBuffer* ahb) override; + uint32_t getHeight(const AHardwareBuffer* ahb) override; + size_t getAllocatedSize(const native_handle_t* handle) override; size_t getAllocatedSize(const AHardwareBuffer* handle) override; diff --git a/src/gfxstream/guest/android/GrallocMinigbm.cpp b/src/gfxstream/guest/android/GrallocMinigbm.cpp index 85d7d9e2e2f..8d97be61420 100644 --- a/src/gfxstream/guest/android/GrallocMinigbm.cpp +++ b/src/gfxstream/guest/android/GrallocMinigbm.cpp @@ -221,6 +221,18 @@ uint32_t MinigbmGralloc::getFormatDrmFourcc(const AHardwareBuffer* ahb) { return getFormatDrmFourcc(handle); } +uint32_t MinigbmGralloc::getWidth(const AHardwareBuffer* ahb) { + AHardwareBuffer_Desc desc = {}; + AHardwareBuffer_describe(ahb, &desc); + return desc.width; +} + +uint32_t MinigbmGralloc::getHeight(const AHardwareBuffer* ahb) { + AHardwareBuffer_Desc desc = {}; + AHardwareBuffer_describe(ahb, &desc); + return desc.height; +} + size_t MinigbmGralloc::getAllocatedSize(const native_handle_t* handle) { struct drm_virtgpu_resource_info info; if (!getVirtioGpuResourceInfo(m_fd, handle, &info)) { diff --git a/src/gfxstream/guest/android/GrallocMinigbm.h b/src/gfxstream/guest/android/GrallocMinigbm.h index 3ec15855832..8a70bcaca22 100644 --- a/src/gfxstream/guest/android/GrallocMinigbm.h +++ b/src/gfxstream/guest/android/GrallocMinigbm.h @@ -42,6 +42,9 @@ class MinigbmGralloc : public Gralloc { uint32_t getFormatDrmFourcc(const native_handle_t* handle) override; uint32_t getFormatDrmFourcc(const AHardwareBuffer* handle) override; + uint32_t getWidth(const AHardwareBuffer* ahb) override; + uint32_t getHeight(const AHardwareBuffer* ahb) override; + size_t getAllocatedSize(const native_handle_t* handle) override; size_t getAllocatedSize(const AHardwareBuffer* handle) override;