summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Dan Stoza <stoza@google.com> 2016-05-17 10:48:38 -0700
committer Dan Stoza <stoza@google.com> 2016-05-17 10:48:38 -0700
commit0f67b3f01fc74bbd8cf4be24fce4a1e42f102282 (patch)
tree54a3d3aa524a9c56678cc33f5a59b67f0563adaf
parent853f8f9c0b95120731459c1f7567af69ce457fe0 (diff)
HWC2: Set composition type before setting buffer
SurfaceFlinger was incorrectly setting the buffer handle before setting the composition type. This led to cases where the layer was initially marked as Invalid or Client, allowing HWC2 to ignore the buffer handle, even though the layer was later changed to Device before presentation. Bug: 28814745 Change-Id: I41189495dcb254f04e6b2b329c044301c5cff97c
-rw-r--r--services/surfaceflinger/Layer.cpp65
1 files changed, 31 insertions, 34 deletions
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index ed320cb3d0..2e16d8467f 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -721,53 +721,50 @@ void Layer::setPerFrameData(const sp<const DisplayDevice>& displayDevice) {
surfaceDamageRegion.dump(LOG_TAG);
}
- auto compositionType = HWC2::Composition::Invalid;
+ // Sideband layers
if (mSidebandStream.get()) {
- compositionType = HWC2::Composition::Sideband;
- auto error = hwcLayer->setSidebandStream(mSidebandStream->handle());
+ setCompositionType(hwcId, HWC2::Composition::Sideband);
+ ALOGV("[%s] Requesting Sideband composition", mName.string());
+ error = hwcLayer->setSidebandStream(mSidebandStream->handle());
if (error != HWC2::Error::None) {
ALOGE("[%s] Failed to set sideband stream %p: %s (%d)",
mName.string(), mSidebandStream->handle(),
to_string(error).c_str(), static_cast<int32_t>(error));
- return;
- }
- } else {
- if (mActiveBuffer == nullptr || mActiveBuffer->handle == nullptr) {
- compositionType = HWC2::Composition::Client;
- auto error = hwcLayer->setBuffer(nullptr, Fence::NO_FENCE);
- if (error != HWC2::Error::None) {
- ALOGE("[%s] Failed to set null buffer: %s (%d)", mName.string(),
- to_string(error).c_str(), static_cast<int32_t>(error));
- return;
- }
- } else {
- if (mPotentialCursor) {
- compositionType = HWC2::Composition::Cursor;
- }
- auto acquireFence = mSurfaceFlingerConsumer->getCurrentFence();
- auto error = hwcLayer->setBuffer(mActiveBuffer->handle,
- acquireFence);
- if (error != HWC2::Error::None) {
- ALOGE("[%s] Failed to set buffer %p: %s (%d)", mName.string(),
- mActiveBuffer->handle, to_string(error).c_str(),
- static_cast<int32_t>(error));
- return;
- }
- // If it's not a cursor, default to device composition
}
+ return;
}
- if (mHwcLayers[hwcId].forceClientComposition) {
- ALOGV("[%s] Forcing Client composition", mName.string());
+ // Client or SolidColor layers
+ if (mActiveBuffer == nullptr || mActiveBuffer->handle == nullptr ||
+ mHwcLayers[hwcId].forceClientComposition) {
+ // TODO: This also includes solid color layers, but no API exists to
+ // setup a solid color layer yet
+ ALOGV("[%s] Requesting Client composition", mName.string());
setCompositionType(hwcId, HWC2::Composition::Client);
- } else if (compositionType != HWC2::Composition::Invalid) {
- ALOGV("[%s] Requesting %s composition", mName.string(),
- to_string(compositionType).c_str());
- setCompositionType(hwcId, compositionType);
+ error = hwcLayer->setBuffer(nullptr, Fence::NO_FENCE);
+ if (error != HWC2::Error::None) {
+ ALOGE("[%s] Failed to set null buffer: %s (%d)", mName.string(),
+ to_string(error).c_str(), static_cast<int32_t>(error));
+ }
+ return;
+ }
+
+ // Device or Cursor layers
+ if (mPotentialCursor) {
+ ALOGV("[%s] Requesting Cursor composition", mName.string());
+ setCompositionType(hwcId, HWC2::Composition::Cursor);
} else {
ALOGV("[%s] Requesting Device composition", mName.string());
setCompositionType(hwcId, HWC2::Composition::Device);
}
+
+ auto acquireFence = mSurfaceFlingerConsumer->getCurrentFence();
+ error = hwcLayer->setBuffer(mActiveBuffer->handle, acquireFence);
+ if (error != HWC2::Error::None) {
+ ALOGE("[%s] Failed to set buffer %p: %s (%d)", mName.string(),
+ mActiveBuffer->handle, to_string(error).c_str(),
+ static_cast<int32_t>(error));
+ }
}
#else
void Layer::setPerFrameData(const sp<const DisplayDevice>& hw,