summaryrefslogtreecommitdiff
path: root/gralloc/gr_utils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gralloc/gr_utils.cpp')
-rw-r--r--gralloc/gr_utils.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/gralloc/gr_utils.cpp b/gralloc/gr_utils.cpp
index 16cdce81..dc64b584 100644
--- a/gralloc/gr_utils.cpp
+++ b/gralloc/gr_utils.cpp
@@ -218,6 +218,21 @@ uint32_t GetDataAlignment(int format, uint64_t usage) {
return align;
}
+bool IsGPUFlagSupported(uint64_t usage) {
+ bool ret = true;
+ if ((usage & BufferUsage::GPU_MIPMAP_COMPLETE)) {
+ ALOGE("GPU_MIPMAP_COMPLETE not supported");
+ ret = false;
+ }
+
+ if ((usage & BufferUsage::GPU_CUBE_MAP)) {
+ ALOGE("GPU_CUBE_MAP not supported");
+ ret = false;
+ }
+
+ return ret;
+}
+
// Returns the final buffer size meant to be allocated with ion
unsigned int GetSize(const BufferInfo &info, unsigned int alignedw, unsigned int alignedh) {
unsigned int size = 0;
@@ -226,6 +241,11 @@ unsigned int GetSize(const BufferInfo &info, unsigned int alignedw, unsigned int
int height = info.height;
uint64_t usage = info.usage;
+ if (!IsGPUFlagSupported(usage)) {
+ ALOGE("Unsupported GPU usage flags present 0x%" PRIx64, usage);
+ return 0;
+ }
+
if (IsUBwcEnabled(format, usage)) {
size = GetUBwcSize(width, height, format, alignedw, alignedh);
} else if (IsUncompressedRGBFormat(format)) {