summaryrefslogtreecommitdiff
path: root/services/surfaceflinger/SurfaceFlinger.cpp
diff options
context:
space:
mode:
author Lloyd Pique <lpique@google.com> 2018-12-20 16:23:45 -0800
committer Lloyd Pique <lpique@google.com> 2019-01-07 13:39:45 -0800
commit0449b0fa3e3e88da8622da6e95a7eefea8c46a70 (patch)
tree57eac962d959508de399454604076cd343d36f66 /services/surfaceflinger/SurfaceFlinger.cpp
parentf2c793939c42ff233ced4095cf85bb93ec74523f (diff)
Revert "SurfaceFlinger: protect state members in Layer"
State update transactions must be atomic. The fine-grained lock on each Layer implied otherwise. Revert the fine grained lock as being unhelpful. Unfortunately there does not seem to be a way to use Clang thread annotations to specify the desired locking behavior. Note that the parent CL addresses the locking problem that led to the bug. This reverts commit 83729883eecd31a9907bc79bc21998a90f17105c. Bug: 119481871 Test: SurfaceFlinger unit tests Test: go/wm-smoke Change-Id: I361741f8d10102aeb57f164c847c6063ff93dd14
Diffstat (limited to 'services/surfaceflinger/SurfaceFlinger.cpp')
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp26
1 files changed, 16 insertions, 10 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 1b31674d03..fd25abf1a5 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -2836,6 +2836,9 @@ void SurfaceFlinger::computeVisibleRegions(const sp<const DisplayDevice>& displa
outDirtyRegion.clear();
mDrawingState.traverseInReverseZOrder([&](Layer* layer) {
+ // start with the whole surface at its current location
+ const Layer::State& s(layer->getDrawingState());
+
// only consider the layers on the given layer stack
if (!layer->belongsToDisplay(display->getLayerStack(), display->isPrimary())) {
return;
@@ -2873,7 +2876,7 @@ void SurfaceFlinger::computeVisibleRegions(const sp<const DisplayDevice>& displa
// handle hidden surfaces by setting the visible region to empty
if (CC_LIKELY(layer->isVisible())) {
- const bool translucent = !layer->isDrawingOpaque();
+ const bool translucent = !layer->isOpaque(s);
Rect bounds(layer->computeScreenBounds());
visibleRegion.set(bounds);
@@ -2883,8 +2886,7 @@ void SurfaceFlinger::computeVisibleRegions(const sp<const DisplayDevice>& displa
if (translucent) {
if (tr.preserveRects()) {
// transform the transparent region
- transparentRegion =
- tr.transform(layer->getDrawingActiveTransparentRegion());
+ transparentRegion = tr.transform(layer->getActiveTransparentRegion(s));
} else {
// transformation too complex, can't do the
// transparent region optimization.
@@ -3183,8 +3185,9 @@ bool SurfaceFlinger::doComposeSurfaces(const sp<DisplayDevice>& display) {
case HWC2::Composition::Sideband:
case HWC2::Composition::SolidColor: {
LOG_ALWAYS_FATAL_IF(!displayId);
+ const Layer::State& state(layer->getDrawingState());
if (layer->getClearClientTarget(*displayId) && !firstLayer &&
- layer->isDrawingOpaque() && (layer->getAlpha() == 1.0f) &&
+ layer->isOpaque(state) && (layer->getAlpha() == 1.0f) &&
layer->getRoundedCornerState().radius == 0.0f && hasClientComposition) {
// never clear the very first layer since we're
// guaranteed the FB is already cleared
@@ -5268,12 +5271,15 @@ status_t SurfaceFlinger::captureLayers(const sp<IBinder>& layerHandleBinder,
mFlinger(flinger),
mChildrenOnly(childrenOnly) {}
const ui::Transform& getTransform() const override { return mTransform; }
- Rect getBounds() const override { return mLayer->getBufferSize(StateSet::Drawing); }
+ Rect getBounds() const override {
+ const Layer::State& layerState(mLayer->getDrawingState());
+ return mLayer->getBufferSize(layerState);
+ }
int getHeight() const override {
- return mLayer->getBufferSize(StateSet::Drawing).getHeight();
+ return mLayer->getBufferSize(mLayer->getDrawingState()).getHeight();
}
int getWidth() const override {
- return mLayer->getBufferSize(StateSet::Drawing).getWidth();
+ return mLayer->getBufferSize(mLayer->getDrawingState()).getWidth();
}
bool isSecure() const override { return false; }
bool needsFiltering() const override { return mNeedsFiltering; }
@@ -5340,7 +5346,7 @@ status_t SurfaceFlinger::captureLayers(const sp<IBinder>& layerHandleBinder,
const int uid = IPCThreadState::self()->getCallingUid();
const bool forSystem = uid == AID_GRAPHICS || uid == AID_SYSTEM;
- if (!forSystem && parent->getCurrentFlags() & layer_state_t::eLayerSecure) {
+ if (!forSystem && parent->getCurrentState().flags & layer_state_t::eLayerSecure) {
ALOGW("Attempting to capture secure layer: PERMISSION_DENIED");
return PERMISSION_DENIED;
}
@@ -5348,12 +5354,12 @@ status_t SurfaceFlinger::captureLayers(const sp<IBinder>& layerHandleBinder,
Rect crop(sourceCrop);
if (sourceCrop.width() <= 0) {
crop.left = 0;
- crop.right = parent->getBufferSize(StateSet::Current).getWidth();
+ crop.right = parent->getBufferSize(parent->getCurrentState()).getWidth();
}
if (sourceCrop.height() <= 0) {
crop.top = 0;
- crop.bottom = parent->getBufferSize(StateSet::Current).getHeight();
+ crop.bottom = parent->getBufferSize(parent->getCurrentState()).getHeight();
}
int32_t reqWidth = crop.width() * frameScale;