summaryrefslogtreecommitdiffstats
path: root/libgralloc/alloc_controller.cpp
diff options
context:
space:
mode:
authorSaurabh Shah <saurshah@codeaurora.org>2014-12-19 10:05:41 -0800
committerGerrit - the friendly Code Review server <code-review@localhost>2014-12-19 18:30:00 -0800
commit1adcafe634716519f83141894a50d7faf4d2ef2b (patch)
treed4040a60dfb3a6921fa09df718cff6625af9eaf7 /libgralloc/alloc_controller.cpp
parent69574c0ce85635860c1529f397bff20c13fb77cb (diff)
downloadandroid_hardware_qcom_display-1adcafe634716519f83141894a50d7faf4d2ef2b.tar.gz
android_hardware_qcom_display-1adcafe634716519f83141894a50d7faf4d2ef2b.tar.bz2
android_hardware_qcom_display-1adcafe634716519f83141894a50d7faf4d2ef2b.zip
gralloc: Allocate cached by default, don't use bitops on SW flags
Allocate gralloc buffers cached by default unless clients specify uncached using PRIVATE_UNCACHED or READ_RARELY or WRITE_RARELY at allocation time. Some clients could use gralloc for allocation but later won't use lock()/unlock() for CPU operations and likely use their own caching methods. Cached by default helps such clients. SW usage flags are not defined as bit values, so do not use bitops on those flags. Change-Id: Id371de2ec6efbfa0ed84172b3540f3ebc8f5d459
Diffstat (limited to 'libgralloc/alloc_controller.cpp')
-rw-r--r--libgralloc/alloc_controller.cpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/libgralloc/alloc_controller.cpp b/libgralloc/alloc_controller.cpp
index cd6d5658b..fd81c708e 100644
--- a/libgralloc/alloc_controller.cpp
+++ b/libgralloc/alloc_controller.cpp
@@ -76,6 +76,21 @@ static bool canFallback(int usage, bool triedSystem)
return true;
}
+/* The default policy is to return cached buffers unless the client explicity
+ * sets the PRIVATE_UNCACHED flag or indicates that the buffer will be rarely
+ * read or written in software. Any combination with a _RARELY_ flag will be
+ * treated as uncached. */
+static bool useUncached(const int& usage) {
+ if((usage & GRALLOC_USAGE_PRIVATE_UNCACHED) or
+ ((usage & GRALLOC_USAGE_SW_WRITE_MASK) ==
+ GRALLOC_USAGE_SW_WRITE_RARELY) or
+ ((usage & GRALLOC_USAGE_SW_READ_MASK) ==
+ GRALLOC_USAGE_SW_READ_RARELY))
+ return true;
+
+ return false;
+}
+
//-------------- AdrenoMemInfo-----------------------//
AdrenoMemInfo::AdrenoMemInfo()
{
@@ -664,14 +679,3 @@ void free_buffer(private_handle_t *hnd)
delete hnd;
}
-
-bool useUncached(const int& usage) {
- if(usage & GRALLOC_USAGE_PRIVATE_UNCACHED)
- return true;
-
- if(not (usage & (GRALLOC_USAGE_SW_WRITE_OFTEN |
- GRALLOC_USAGE_SW_READ_OFTEN)))
- return true;
-
- return false;
-}