summaryrefslogtreecommitdiff
path: root/libs/gui/ConsumerBase.cpp
diff options
context:
space:
mode:
author Matthew Bouyack <mbouyack@google.com> 2016-10-07 15:06:15 -0700
committer Matthew Bouyack <mbouyack@google.com> 2016-10-17 12:47:33 -0700
commit377c2033750ad2a47e5c560f982a0242ea7dc79e (patch)
tree7282135b83be7c6b04a815ce10ee7e569735d646 /libs/gui/ConsumerBase.cpp
parent6db42ac36e69ab203e9078e9f70c2ff762af87cd (diff)
In SurfaceFlinger, test fence before merging
If the old fence for a given layer has already expired, we can replace it with the new fence rather than merging the two. This saves 300-400us per frame on Android Wear Change-Id: I5d907c336c7383ae4e2e0f71e42f23749494a359
Diffstat (limited to 'libs/gui/ConsumerBase.cpp')
-rw-r--r--libs/gui/ConsumerBase.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/libs/gui/ConsumerBase.cpp b/libs/gui/ConsumerBase.cpp
index e7bc7dc73d..65e4feefde 100644
--- a/libs/gui/ConsumerBase.cpp
+++ b/libs/gui/ConsumerBase.cpp
@@ -314,6 +314,18 @@ status_t ConsumerBase::addReleaseFenceLocked(int slot,
if (!mSlots[slot].mFence.get()) {
mSlots[slot].mFence = fence;
+ return OK;
+ }
+
+ auto signaled = mSlots[slot].mFence->hasSignaled();
+
+ if (!signaled) {
+ CB_LOGE("fence has invalid state");
+ return BAD_VALUE;
+ }
+
+ if (*signaled) {
+ mSlots[slot].mFence = fence;
} else {
char fenceName[32] = {};
snprintf(fenceName, 32, "%.28s:%d", mName.string(), slot);