summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChia-I Wu2017-04-07 23:32:18 -0500
committerChia-I Wu2017-04-10 11:47:34 -0500
commit1e29643f1380538bfeec8bd43ed66faf34d88727 (patch)
treed9682978f36f06395b6de9ac353da2cdbdb870a4 /libgrallocusage
parent9cadfde2d603afd693699e8ca6587e3b694ffea6 (diff)
downloadplatform-system-core-1e29643f1380538bfeec8bd43ed66faf34d88727.tar.gz
platform-system-core-1e29643f1380538bfeec8bd43ed66faf34d88727.tar.xz
platform-system-core-1e29643f1380538bfeec8bd43ed66faf34d88727.zip
libgrallocusage: use gralloc1.h usage flags
android/hardware/graphics/allocator/2.0/types.h is gone. Use usage flags from gralloc1.h. Test: make Change-Id: I43bc641edf86229d2df75dba857d7b5706df70e4
Diffstat (limited to 'libgrallocusage')
-rw-r--r--libgrallocusage/GrallocUsageConversion.cpp52
1 files changed, 27 insertions, 25 deletions
diff --git a/libgrallocusage/GrallocUsageConversion.cpp b/libgrallocusage/GrallocUsageConversion.cpp
index 8164beb80..05c8ec44f 100644
--- a/libgrallocusage/GrallocUsageConversion.cpp
+++ b/libgrallocusage/GrallocUsageConversion.cpp
@@ -16,49 +16,51 @@
16 16
17#include <grallocusage/GrallocUsageConversion.h> 17#include <grallocusage/GrallocUsageConversion.h>
18 18
19#include <android/hardware/graphics/allocator/2.0/types.h>
20#include <hardware/gralloc.h> 19#include <hardware/gralloc.h>
21 20#include <hardware/gralloc1.h>
22using android::hardware::graphics::allocator::V2_0::ProducerUsage;
23using android::hardware::graphics::allocator::V2_0::ConsumerUsage;
24 21
25void android_convertGralloc0To1Usage(int32_t usage, uint64_t* producerUsage, 22void android_convertGralloc0To1Usage(int32_t usage, uint64_t* producerUsage,
26 uint64_t* consumerUsage) { 23 uint64_t* consumerUsage) {
27 constexpr uint64_t PRODUCER_MASK = ProducerUsage::CPU_READ | 24 constexpr uint64_t PRODUCER_MASK =
28 /* ProducerUsage::CPU_READ_OFTEN | */ 25 GRALLOC1_PRODUCER_USAGE_CPU_READ |
29 ProducerUsage::CPU_WRITE | 26 /* GRALLOC1_PRODUCER_USAGE_CPU_READ_OFTEN | */
30 /* ProducerUsage::CPU_WRITE_OFTEN | */ 27 GRALLOC1_PRODUCER_USAGE_CPU_WRITE |
31 ProducerUsage::GPU_RENDER_TARGET | ProducerUsage::PROTECTED | 28 /* GRALLOC1_PRODUCER_USAGE_CPU_WRITE_OFTEN | */
32 ProducerUsage::CAMERA | ProducerUsage::VIDEO_DECODER | 29 GRALLOC1_PRODUCER_USAGE_GPU_RENDER_TARGET | GRALLOC1_PRODUCER_USAGE_PROTECTED |
33 ProducerUsage::SENSOR_DIRECT_DATA; 30 GRALLOC1_PRODUCER_USAGE_CAMERA | GRALLOC1_PRODUCER_USAGE_VIDEO_DECODER |
34 constexpr uint64_t CONSUMER_MASK = ConsumerUsage::CPU_READ | 31 GRALLOC1_PRODUCER_USAGE_SENSOR_DIRECT_DATA;
35 /* ConsumerUsage::CPU_READ_OFTEN | */ 32 constexpr uint64_t CONSUMER_MASK =
36 ConsumerUsage::GPU_TEXTURE | ConsumerUsage::HWCOMPOSER | 33 GRALLOC1_CONSUMER_USAGE_CPU_READ |
37 ConsumerUsage::CLIENT_TARGET | ConsumerUsage::CURSOR | 34 /* GRALLOC1_CONSUMER_USAGE_CPU_READ_OFTEN | */
38 ConsumerUsage::VIDEO_ENCODER | ConsumerUsage::CAMERA | 35 GRALLOC1_CONSUMER_USAGE_GPU_TEXTURE | GRALLOC1_CONSUMER_USAGE_HWCOMPOSER |
39 ConsumerUsage::RENDERSCRIPT | ConsumerUsage::GPU_DATA_BUFFER; 36 GRALLOC1_CONSUMER_USAGE_CLIENT_TARGET | GRALLOC1_CONSUMER_USAGE_CURSOR |
37 GRALLOC1_CONSUMER_USAGE_VIDEO_ENCODER | GRALLOC1_CONSUMER_USAGE_CAMERA |
38 GRALLOC1_CONSUMER_USAGE_RENDERSCRIPT | GRALLOC1_CONSUMER_USAGE_GPU_DATA_BUFFER;
40 *producerUsage = static_cast<uint64_t>(usage) & PRODUCER_MASK; 39 *producerUsage = static_cast<uint64_t>(usage) & PRODUCER_MASK;
41 *consumerUsage = static_cast<uint64_t>(usage) & CONSUMER_MASK; 40 *consumerUsage = static_cast<uint64_t>(usage) & CONSUMER_MASK;
42 if ((static_cast<uint32_t>(usage) & GRALLOC_USAGE_SW_READ_OFTEN) == GRALLOC_USAGE_SW_READ_OFTEN) { 41 if ((static_cast<uint32_t>(usage) & GRALLOC_USAGE_SW_READ_OFTEN) == GRALLOC_USAGE_SW_READ_OFTEN) {
43 *producerUsage |= ProducerUsage::CPU_READ_OFTEN; 42 *producerUsage |= GRALLOC1_PRODUCER_USAGE_CPU_READ_OFTEN;
44 *consumerUsage |= ConsumerUsage::CPU_READ_OFTEN; 43 *consumerUsage |= GRALLOC1_CONSUMER_USAGE_CPU_READ_OFTEN;
45 } 44 }
46 if ((static_cast<uint32_t>(usage) & GRALLOC_USAGE_SW_WRITE_OFTEN) == 45 if ((static_cast<uint32_t>(usage) & GRALLOC_USAGE_SW_WRITE_OFTEN) ==
47 GRALLOC_USAGE_SW_WRITE_OFTEN) { 46 GRALLOC_USAGE_SW_WRITE_OFTEN) {
48 *producerUsage |= ProducerUsage::CPU_WRITE_OFTEN; 47 *producerUsage |= GRALLOC1_PRODUCER_USAGE_CPU_WRITE_OFTEN;
49 } 48 }
50} 49}
51 50
52int32_t android_convertGralloc1To0Usage(uint64_t producerUsage, uint64_t consumerUsage) { 51int32_t android_convertGralloc1To0Usage(uint64_t producerUsage, uint64_t consumerUsage) {
53 static_assert(uint64_t(ConsumerUsage::CPU_READ_OFTEN) == uint64_t(ProducerUsage::CPU_READ_OFTEN), 52 static_assert(uint64_t(GRALLOC1_CONSUMER_USAGE_CPU_READ_OFTEN) ==
53 uint64_t(GRALLOC1_PRODUCER_USAGE_CPU_READ_OFTEN),
54 "expected ConsumerUsage and ProducerUsage CPU_READ_OFTEN bits to match"); 54 "expected ConsumerUsage and ProducerUsage CPU_READ_OFTEN bits to match");
55 uint64_t merged = producerUsage | consumerUsage; 55 uint64_t merged = producerUsage | consumerUsage;
56 if ((merged & (ConsumerUsage::CPU_READ_OFTEN)) != 0) { 56 if ((merged & (GRALLOC1_CONSUMER_USAGE_CPU_READ_OFTEN)) ==
57 merged &= ~uint64_t(ConsumerUsage::CPU_READ_OFTEN); 57 GRALLOC1_CONSUMER_USAGE_CPU_READ_OFTEN) {
58 merged &= ~uint64_t(GRALLOC1_CONSUMER_USAGE_CPU_READ_OFTEN);
58 merged |= GRALLOC_USAGE_SW_READ_OFTEN; 59 merged |= GRALLOC_USAGE_SW_READ_OFTEN;
59 } 60 }
60 if ((merged & (ProducerUsage::CPU_WRITE_OFTEN)) != 0) { 61 if ((merged & (GRALLOC1_PRODUCER_USAGE_CPU_WRITE_OFTEN)) ==
61 merged &= ~uint64_t(ProducerUsage::CPU_WRITE_OFTEN); 62 GRALLOC1_PRODUCER_USAGE_CPU_WRITE_OFTEN) {
63 merged &= ~uint64_t(GRALLOC1_PRODUCER_USAGE_CPU_WRITE_OFTEN);
62 merged |= GRALLOC_USAGE_SW_WRITE_OFTEN; 64 merged |= GRALLOC_USAGE_SW_WRITE_OFTEN;
63 } 65 }
64 return static_cast<int32_t>(merged); 66 return static_cast<int32_t>(merged);