summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2018-06-03 07:22:50 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2018-06-03 07:22:50 +0000
commit9f8a7af982aaeb66ded62d9b62354a46c0aa8511 (patch)
tree507ee85cf915764d48de4b3fe8b4e6f0b2c1f52c
parent45d6f0affcdefe1f0f2a60e61d7cab3a0ddf338c (diff)
parent4f80b867b3433ddc16d416809c7e9cd5d6deb88b (diff)
downloadnative-9f8a7af982aaeb66ded62d9b62354a46c0aa8511.tar.gz
Snap for 4818534 from 4f80b867b3433ddc16d416809c7e9cd5d6deb88b to pi-release
Change-Id: I709277f165baf832a446f373c111df15409352fa
-rw-r--r--cmds/installd/otapreopt_chroot.cpp4
-rw-r--r--services/surfaceflinger/Layer.cpp14
-rw-r--r--services/surfaceflinger/Layer.h3
-rw-r--r--services/surfaceflinger/LayerVector.cpp25
-rw-r--r--services/surfaceflinger/LayerVector.h13
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp9
-rw-r--r--services/surfaceflinger/SurfaceFlinger.h2
-rw-r--r--services/surfaceflinger/VSyncModulator.h36
8 files changed, 75 insertions, 31 deletions
diff --git a/cmds/installd/otapreopt_chroot.cpp b/cmds/installd/otapreopt_chroot.cpp
index 3ae56dba65..e90cf3bab2 100644
--- a/cmds/installd/otapreopt_chroot.cpp
+++ b/cmds/installd/otapreopt_chroot.cpp
@@ -115,7 +115,7 @@ static int otapreopt_chroot(const int argc, char **arg) {
exit(207);
}
{
- std::string vendor_partition = StringPrintf("/dev/block/bootdevice/by-name/vendor%s",
+ std::string vendor_partition = StringPrintf("/dev/block/by-name/vendor%s",
arg[2]);
int vendor_result = mount(vendor_partition.c_str(),
"/postinstall/vendor",
@@ -128,7 +128,7 @@ static int otapreopt_chroot(const int argc, char **arg) {
// Try to mount the product partition. update_engine doesn't do this for us, but we
// want it for product APKs. Same notes as vendor above.
{
- std::string product_partition = StringPrintf("/dev/block/bootdevice/by-name/product%s",
+ std::string product_partition = StringPrintf("/dev/block/by-name/product%s",
arg[2]);
int product_result = mount(product_partition.c_str(),
"/postinstall/product",
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index b94af77967..2595ec1a05 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -98,8 +98,9 @@ Layer::Layer(SurfaceFlinger* flinger, const sp<Client>& client, const String8& n
mQueueItems(),
mLastFrameNumberReceived(0),
mAutoRefresh(false),
- mFreezeGeometryUpdates(false) {
-
+ mFreezeGeometryUpdates(false),
+ mCurrentChildren(LayerVector::StateSet::Current),
+ mDrawingChildren(LayerVector::StateSet::Drawing) {
mCurrentCrop.makeInvalid();
uint32_t layerFlags = 0;
@@ -137,7 +138,6 @@ Layer::Layer(SurfaceFlinger* flinger, const sp<Client>& client, const String8& n
CompositorTiming compositorTiming;
flinger->getCompositorTiming(&compositorTiming);
mFrameEventHistory.initializeCompositorTiming(compositorTiming);
-
}
void Layer::onFirstRef() {}
@@ -920,10 +920,7 @@ void Layer::pushPendingState() {
}
void Layer::popPendingState(State* stateToCommit) {
- auto oldFlags = stateToCommit->flags;
*stateToCommit = mPendingStates[0];
- stateToCommit->flags =
- (oldFlags & ~stateToCommit->mask) | (stateToCommit->flags & stateToCommit->mask);
mPendingStates.removeAt(0);
ATRACE_INT(mTransactionName.string(), mPendingStates.size());
@@ -1270,7 +1267,6 @@ bool Layer::setFlags(uint8_t flags, uint8_t mask) {
if (mCurrentState.flags == newFlags) return false;
mCurrentState.sequence++;
mCurrentState.flags = newFlags;
- mCurrentState.mask = mask;
mCurrentState.modified = true;
setTransactionFlags(eTransactionNeeded);
return true;
@@ -1681,7 +1677,7 @@ __attribute__((no_sanitize("unsigned-integer-overflow"))) LayerVector Layer::mak
return children;
}
- LayerVector traverse;
+ LayerVector traverse(stateSet);
for (const wp<Layer>& weakRelative : state.zOrderRelatives) {
sp<Layer> strongRelative = weakRelative.promote();
if (strongRelative != nullptr) {
@@ -1779,7 +1775,7 @@ LayerVector Layer::makeChildrenTraversalList(LayerVector::StateSet stateSet,
const LayerVector& children = useDrawing ? mDrawingChildren : mCurrentChildren;
const State& state = useDrawing ? mDrawingState : mCurrentState;
- LayerVector traverse;
+ LayerVector traverse(stateSet);
for (const wp<Layer>& weakRelative : state.zOrderRelatives) {
sp<Layer> strongRelative = weakRelative.promote();
// Only add relative layers that are also descendents of the top most parent of the tree.
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index 7342c8b987..ae80043a5d 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -186,7 +186,6 @@ public:
uint32_t layerStack;
uint8_t flags;
- uint8_t mask;
uint8_t reserved[2];
int32_t sequence; // changes when visible regions can change
bool modified;
@@ -588,6 +587,7 @@ public:
// SurfaceFlinger to complete a transaction.
void commitChildList();
int32_t getZ() const;
+ void pushPendingState();
protected:
// constant
@@ -670,7 +670,6 @@ protected:
// Returns false if the relevant frame has already been latched
bool addSyncPoint(const std::shared_ptr<SyncPoint>& point);
- void pushPendingState();
void popPendingState(State* stateToCommit);
bool applyPendingStates(State* stateToCommit);
diff --git a/services/surfaceflinger/LayerVector.cpp b/services/surfaceflinger/LayerVector.cpp
index 47156c19d2..84945247a6 100644
--- a/services/surfaceflinger/LayerVector.cpp
+++ b/services/surfaceflinger/LayerVector.cpp
@@ -19,26 +19,37 @@
namespace android {
-LayerVector::LayerVector() = default;
+LayerVector::LayerVector(const StateSet stateSet) : mStateSet(stateSet) {}
-LayerVector::LayerVector(const LayerVector& rhs) : SortedVector<sp<Layer>>(rhs) {
-}
+LayerVector::LayerVector(const LayerVector& rhs, const StateSet stateSet)
+ : SortedVector<sp<Layer>>(rhs), mStateSet(stateSet) {}
LayerVector::~LayerVector() = default;
+// This operator override is needed to prevent mStateSet from getting copied over.
+LayerVector& LayerVector::operator=(const LayerVector& rhs) {
+ SortedVector::operator=(rhs);
+ return *this;
+}
+
int LayerVector::do_compare(const void* lhs, const void* rhs) const
{
// sort layers per layer-stack, then by z-order and finally by sequence
const auto& l = *reinterpret_cast<const sp<Layer>*>(lhs);
const auto& r = *reinterpret_cast<const sp<Layer>*>(rhs);
- uint32_t ls = l->getCurrentState().layerStack;
- uint32_t rs = r->getCurrentState().layerStack;
+ const auto& lState =
+ (mStateSet == StateSet::Current) ? l->getCurrentState() : l->getDrawingState();
+ const auto& rState =
+ (mStateSet == StateSet::Current) ? r->getCurrentState() : r->getDrawingState();
+
+ uint32_t ls = lState.layerStack;
+ uint32_t rs = rState.layerStack;
if (ls != rs)
return (ls > rs) ? 1 : -1;
- int32_t lz = l->getCurrentState().z;
- int32_t rz = r->getCurrentState().z;
+ int32_t lz = lState.z;
+ int32_t rz = rState.z;
if (lz != rz)
return (lz > rz) ? 1 : -1;
diff --git a/services/surfaceflinger/LayerVector.h b/services/surfaceflinger/LayerVector.h
index a9adb4113a..88d7711bb8 100644
--- a/services/surfaceflinger/LayerVector.h
+++ b/services/surfaceflinger/LayerVector.h
@@ -32,22 +32,27 @@ class Layer;
*/
class LayerVector : public SortedVector<sp<Layer>> {
public:
- LayerVector();
- LayerVector(const LayerVector& rhs);
- ~LayerVector() override;
-
enum class StateSet {
Invalid,
Current,
Drawing,
};
+ explicit LayerVector(const StateSet stateSet);
+ LayerVector(const LayerVector& rhs, const StateSet stateSet);
+ ~LayerVector() override;
+
+ LayerVector& operator=(const LayerVector& rhs);
+
// Sorts layer by layer-stack, Z order, and finally creation order (sequence).
int do_compare(const void* lhs, const void* rhs) const override;
using Visitor = std::function<void(Layer*)>;
void traverseInReverseZOrder(StateSet stateSet, const Visitor& visitor) const;
void traverseInZOrder(StateSet stateSet, const Visitor& visitor) const;
+
+private:
+ const StateSet mStateSet;
};
}
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index a120738713..97edd357ed 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -1549,7 +1549,7 @@ void SurfaceFlinger::handleMessageRefresh() {
mHadClientComposition = mHadClientComposition ||
getBE().mHwc->hasClientComposition(displayDevice->getHwcDisplayId());
}
- mVsyncModulator.setLastFrameUsedRenderEngine(mHadClientComposition);
+ mVsyncModulator.onRefreshed(mHadClientComposition);
mLayersWithQueuedFrames.clear();
}
@@ -3345,6 +3345,13 @@ uint32_t SurfaceFlinger::setClientStateLocked(const ComposerState& composerState
const uint32_t what = s.what;
bool geometryAppliesWithResize =
what & layer_state_t::eGeometryAppliesWithResize;
+
+ // If we are deferring transaction, make sure to push the pending state, as otherwise the
+ // pending state will also be deferred.
+ if (what & layer_state_t::eDeferTransaction) {
+ layer->pushPendingState();
+ }
+
if (what & layer_state_t::ePositionChanged) {
if (layer->setPosition(s.x, s.y, !geometryAppliesWithResize)) {
flags |= eTraversalNeeded;
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 062cb76960..8566b0387c 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -369,7 +369,7 @@ private:
class State {
public:
- explicit State(LayerVector::StateSet set) : stateSet(set) {}
+ explicit State(LayerVector::StateSet set) : stateSet(set), layersSortedByZ(set) {}
State& operator=(const State& other) {
// We explicitly don't copy stateSet so that, e.g., mDrawingState
// always uses the Drawing StateSet.
diff --git a/services/surfaceflinger/VSyncModulator.h b/services/surfaceflinger/VSyncModulator.h
index 3e5800e2a2..d526313994 100644
--- a/services/surfaceflinger/VSyncModulator.h
+++ b/services/surfaceflinger/VSyncModulator.h
@@ -28,6 +28,12 @@ namespace android {
* Modulates the vsync-offsets depending on current SurfaceFlinger state.
*/
class VSyncModulator {
+private:
+
+ // Number of frames we'll keep the early phase offsets once they are activated. This acts as a
+ // low-pass filter in case the client isn't quick enough in sending new transactions.
+ const int MIN_EARLY_FRAME_COUNT = 2;
+
public:
enum TransactionStart {
@@ -55,6 +61,11 @@ public:
}
void setTransactionStart(TransactionStart transactionStart) {
+
+ if (transactionStart == TransactionStart::EARLY) {
+ mRemainingEarlyFrameCount = MIN_EARLY_FRAME_COUNT;
+ }
+
// An early transaction stays an early transaction.
if (transactionStart == mTransactionStart || mTransactionStart == TransactionStart::EARLY) {
return;
@@ -69,10 +80,19 @@ public:
updatePhaseOffsets();
}
- void setLastFrameUsedRenderEngine(bool re) {
- if (re == mLastFrameUsedRenderEngine) return;
- mLastFrameUsedRenderEngine = re;
- updatePhaseOffsets();
+ void onRefreshed(bool usedRenderEngine) {
+ bool updatePhaseOffsetsNeeded = false;
+ if (mRemainingEarlyFrameCount > 0) {
+ mRemainingEarlyFrameCount--;
+ updatePhaseOffsetsNeeded = true;
+ }
+ if (usedRenderEngine != mLastFrameUsedRenderEngine) {
+ mLastFrameUsedRenderEngine = usedRenderEngine;
+ updatePhaseOffsetsNeeded = true;
+ }
+ if (updatePhaseOffsetsNeeded) {
+ updatePhaseOffsets();
+ }
}
private:
@@ -82,7 +102,7 @@ private:
// Do not change phase offsets if disabled.
if (mEarlyPhaseOffset == mLatePhaseOffset) return;
- if (mTransactionStart == TransactionStart::EARLY || mLastFrameUsedRenderEngine) {
+ if (shouldUseEarlyOffset()) {
if (mPhaseOffset != mEarlyPhaseOffset) {
if (mEventThread) {
mEventThread->setPhaseOffset(mEarlyPhaseOffset);
@@ -99,12 +119,18 @@ private:
}
}
+ bool shouldUseEarlyOffset() {
+ return mTransactionStart == TransactionStart::EARLY || mLastFrameUsedRenderEngine
+ || mRemainingEarlyFrameCount > 0;
+ }
+
nsecs_t mLatePhaseOffset = 0;
nsecs_t mEarlyPhaseOffset = 0;
EventThread* mEventThread = nullptr;
std::atomic<nsecs_t> mPhaseOffset = 0;
std::atomic<TransactionStart> mTransactionStart = TransactionStart::NORMAL;
std::atomic<bool> mLastFrameUsedRenderEngine = false;
+ std::atomic<int> mRemainingEarlyFrameCount = 0;
};
} // namespace android