Start removing Current state
Now that we only write to current state from the main thread
we can actually just write directly in to drawing state and
avoid copying current to drawing state on each frame. simpleperf
on bouncing ball indicates this was saving around 8% CPU or so
per frame. As a next target we will eliminate the remaining work
in doTransaction and eliminate the doTransaction pass.
Test: Existing tests pass. simpleperf
Bug: 186200583
Change-Id: I59b75747d7371b3ffe870129c8be100c7daa6c4e
diff --git a/services/surfaceflinger/BufferQueueLayer.cpp b/services/surfaceflinger/BufferQueueLayer.cpp
index e7f373f..c64371b 100644
--- a/services/surfaceflinger/BufferQueueLayer.cpp
+++ b/services/surfaceflinger/BufferQueueLayer.cpp
@@ -223,7 +223,7 @@
// buffer mode.
bool queuedBuffer = false;
const int32_t layerId = getSequence();
- LayerRejecter r(mDrawingState, getCurrentState(), recomputeVisibleRegions,
+ LayerRejecter r(mDrawingState, getDrawingState(), recomputeVisibleRegions,
getProducerStickyTransform() != 0, mName,
getTransformToDisplayInverse());
diff --git a/services/surfaceflinger/BufferStateLayer.cpp b/services/surfaceflinger/BufferStateLayer.cpp
index f8af908..a3b7b13 100644
--- a/services/surfaceflinger/BufferStateLayer.cpp
+++ b/services/surfaceflinger/BufferStateLayer.cpp
@@ -65,7 +65,7 @@
BufferStateLayer::BufferStateLayer(const LayerCreationArgs& args)
: BufferLayer(args), mHwcSlotGenerator(new HwcSlotGenerator()) {
- mCurrentState.dataspace = ui::Dataspace::V0_SRGB;
+ mDrawingState.dataspace = ui::Dataspace::V0_SRGB;
}
BufferStateLayer::~BufferStateLayer() {
@@ -257,8 +257,8 @@
bool BufferStateLayer::willPresentCurrentTransaction() const {
// Returns true if the most recent Transaction applied to CurrentState will be presented.
return (getSidebandStreamChanged() || getAutoRefresh() ||
- (mCurrentState.modified &&
- (mCurrentState.buffer != nullptr || mCurrentState.bgColorLayer != nullptr)));
+ (mDrawingState.modified &&
+ (mDrawingState.buffer != nullptr || mDrawingState.bgColorLayer != nullptr)));
}
Rect BufferStateLayer::getCrop(const Layer::State& s) const {
@@ -266,65 +266,72 @@
}
bool BufferStateLayer::setTransform(uint32_t transform) {
- if (mCurrentState.bufferTransform == transform) return false;
- mCurrentState.bufferTransform = transform;
- mCurrentState.modified = true;
+ if (mDrawingState.bufferTransform == transform) return false;
+ mDrawingState.bufferTransform = transform;
+ mDrawingState.modified = true;
setTransactionFlags(eTransactionNeeded);
return true;
}
bool BufferStateLayer::setTransformToDisplayInverse(bool transformToDisplayInverse) {
- if (mCurrentState.transformToDisplayInverse == transformToDisplayInverse) return false;
- mCurrentState.sequence++;
- mCurrentState.transformToDisplayInverse = transformToDisplayInverse;
- mCurrentState.modified = true;
+ if (mDrawingState.transformToDisplayInverse == transformToDisplayInverse) return false;
+ mDrawingState.sequence++;
+ mDrawingState.transformToDisplayInverse = transformToDisplayInverse;
+ mDrawingState.modified = true;
setTransactionFlags(eTransactionNeeded);
return true;
}
bool BufferStateLayer::setCrop(const Rect& crop) {
- if (mCurrentState.crop == crop) return false;
- mCurrentState.sequence++;
- mCurrentState.crop = crop;
+ if (mDrawingState.crop == crop) return false;
+ mDrawingState.sequence++;
+ mDrawingState.crop = crop;
- mCurrentState.modified = true;
+ mDrawingState.modified = true;
setTransactionFlags(eTransactionNeeded);
return true;
}
bool BufferStateLayer::setBufferCrop(const Rect& bufferCrop) {
- if (mCurrentState.bufferCrop == bufferCrop) return false;
+ if (mDrawingState.bufferCrop == bufferCrop) return false;
- mCurrentState.sequence++;
- mCurrentState.bufferCrop = bufferCrop;
+ mDrawingState.sequence++;
+ mDrawingState.bufferCrop = bufferCrop;
- mCurrentState.modified = true;
+ mDrawingState.modified = true;
setTransactionFlags(eTransactionNeeded);
return true;
}
bool BufferStateLayer::setDestinationFrame(const Rect& destinationFrame) {
- if (mCurrentState.destinationFrame == destinationFrame) return false;
+ if (mDrawingState.destinationFrame == destinationFrame) return false;
- mCurrentState.sequence++;
- mCurrentState.destinationFrame = destinationFrame;
+ mDrawingState.sequence++;
+ mDrawingState.destinationFrame = destinationFrame;
- mCurrentState.modified = true;
+ mDrawingState.modified = true;
setTransactionFlags(eTransactionNeeded);
return true;
}
+static bool assignTransform(ui::Transform* dst, ui::Transform& from) {
+ if (*dst == from) {
+ return false;
+ }
+ *dst = from;
+ return true;
+}
+
// Translate destination frame into scale and position. If a destination frame is not set, use the
// provided scale and position
-void BufferStateLayer::updateGeometry() {
- if (mCurrentState.destinationFrame.isEmpty()) {
+bool BufferStateLayer::updateGeometry() {
+ if (mDrawingState.destinationFrame.isEmpty()) {
// If destination frame is not set, use the requested transform set via
// BufferStateLayer::setPosition and BufferStateLayer::setMatrix.
- mCurrentState.transform = mRequestedTransform;
- return;
+ return assignTransform(&mDrawingState.transform, mRequestedTransform);
}
- Rect destRect = mCurrentState.destinationFrame;
+ Rect destRect = mDrawingState.destinationFrame;
int32_t destW = destRect.width();
int32_t destH = destRect.height();
if (destRect.left < 0) {
@@ -336,21 +343,20 @@
destRect.bottom = destH;
}
- if (!mCurrentState.buffer) {
+ if (!mDrawingState.buffer) {
ui::Transform t;
t.set(destRect.left, destRect.top);
- mCurrentState.transform = t;
- return;
+ return assignTransform(&mDrawingState.transform, t);
}
- uint32_t bufferWidth = mCurrentState.buffer->getBuffer()->getWidth();
- uint32_t bufferHeight = mCurrentState.buffer->getBuffer()->getHeight();
+ uint32_t bufferWidth = mDrawingState.buffer->getBuffer()->getWidth();
+ uint32_t bufferHeight = mDrawingState.buffer->getBuffer()->getHeight();
// Undo any transformations on the buffer.
- if (mCurrentState.bufferTransform & ui::Transform::ROT_90) {
+ if (mDrawingState.bufferTransform & ui::Transform::ROT_90) {
std::swap(bufferWidth, bufferHeight);
}
uint32_t invTransform = DisplayDevice::getPrimaryDisplayRotationFlags();
- if (mCurrentState.transformToDisplayInverse) {
+ if (mDrawingState.transformToDisplayInverse) {
if (invTransform & ui::Transform::ROT_90) {
std::swap(bufferWidth, bufferHeight);
}
@@ -361,8 +367,7 @@
ui::Transform t;
t.set(sx, 0, 0, sy);
t.set(destRect.left, destRect.top);
- mCurrentState.transform = t;
- return;
+ return assignTransform(&mDrawingState.transform, t);
}
bool BufferStateLayer::setMatrix(const layer_state_t::matrix22_t& matrix,
@@ -383,8 +388,8 @@
mRequestedTransform.set(matrix.dsdx, matrix.dtdy, matrix.dtdx, matrix.dsdy);
- mCurrentState.sequence++;
- mCurrentState.modified = true;
+ mDrawingState.sequence++;
+ mDrawingState.modified = true;
setTransactionFlags(eTransactionNeeded);
return true;
@@ -397,8 +402,8 @@
mRequestedTransform.set(x, y);
- mCurrentState.sequence++;
- mCurrentState.modified = true;
+ mDrawingState.sequence++;
+ mDrawingState.modified = true;
setTransactionFlags(eTransactionNeeded);
return true;
@@ -410,7 +415,7 @@
mAcquireTimeline.updateSignalTimes();
std::shared_ptr<FenceTime> acquireFenceTime =
std::make_shared<FenceTime>((acquireFence ? acquireFence : Fence::NO_FENCE));
- NewFrameEventsEntry newTimestamps = {mCurrentState.frameNumber, postedTime, desiredPresentTime,
+ NewFrameEventsEntry newTimestamps = {mDrawingState.frameNumber, postedTime, desiredPresentTime,
acquireFenceTime};
mFrameEventHistory.setProducerWantsEvents();
mFrameEventHistory.addQueue(newTimestamps);
@@ -425,38 +430,39 @@
const sp<ITransactionCompletedListener>& releaseBufferListener) {
ATRACE_CALL();
- if (mCurrentState.buffer) {
+ if (mDrawingState.buffer) {
mReleasePreviousBuffer = true;
- if (!mDrawingState.buffer ||
- mCurrentState.buffer->getBuffer() != mDrawingState.buffer->getBuffer()) {
- // If mCurrentState has a buffer, and we are about to update again
+ if (mDrawingState.buffer != mBufferInfo.mBuffer) {
+ // If mDrawingState has a buffer, and we are about to update again
// before swapping to drawing state, then the first buffer will be
// dropped and we should decrement the pending buffer count and
// call any release buffer callbacks if set.
- callReleaseBufferCallback(mCurrentState.releaseBufferListener,
- mCurrentState.buffer->getBuffer(), mCurrentState.acquireFence,
+ callReleaseBufferCallback(mDrawingState.releaseBufferListener,
+ mDrawingState.buffer->getBuffer(), mDrawingState.acquireFence,
mTransformHint,
mFlinger->getMaxAcquiredBufferCountForCurrentRefreshRate(
mOwnerUid));
decrementPendingBufferCount();
- if (mCurrentState.bufferSurfaceFrameTX != nullptr) {
- addSurfaceFrameDroppedForBuffer(mCurrentState.bufferSurfaceFrameTX);
- mCurrentState.bufferSurfaceFrameTX.reset();
+ if (mDrawingState.bufferSurfaceFrameTX != nullptr &&
+ mDrawingState.bufferSurfaceFrameTX->getPresentState() != PresentState::Presented) {
+ addSurfaceFrameDroppedForBuffer(mDrawingState.bufferSurfaceFrameTX);
+ mDrawingState.bufferSurfaceFrameTX.reset();
}
}
}
- mCurrentState.frameNumber = frameNumber;
- mCurrentState.releaseBufferListener = releaseBufferListener;
- mCurrentState.buffer = buffer;
- mCurrentState.clientCacheId = clientCacheId;
- mCurrentState.modified = true;
+
+ mDrawingState.frameNumber = frameNumber;
+ mDrawingState.releaseBufferListener = releaseBufferListener;
+ mDrawingState.buffer = buffer;
+ mDrawingState.clientCacheId = clientCacheId;
+ mDrawingState.modified = true;
setTransactionFlags(eTransactionNeeded);
const int32_t layerId = getSequence();
- mFlinger->mTimeStats->setPostTime(layerId, mCurrentState.frameNumber, getName().c_str(),
+ mFlinger->mTimeStats->setPostTime(layerId, mDrawingState.frameNumber, getName().c_str(),
mOwnerUid, postTime, getGameMode());
- mCurrentState.desiredPresentTime = desiredPresentTime;
- mCurrentState.isAutoTimestamp = isAutoTimestamp;
+ mDrawingState.desiredPresentTime = desiredPresentTime;
+ mDrawingState.isAutoTimestamp = isAutoTimestamp;
const nsecs_t presentTime = [&] {
if (!isAutoTimestamp) return desiredPresentTime;
@@ -483,59 +489,59 @@
FrameTracer::FrameEvent::QUEUE);
}
- mCurrentState.width = mCurrentState.buffer->getBuffer()->getWidth();
- mCurrentState.height = mCurrentState.buffer->getBuffer()->getHeight();
+ mDrawingState.width = mDrawingState.buffer->getBuffer()->getWidth();
+ mDrawingState.height = mDrawingState.buffer->getBuffer()->getHeight();
return true;
}
bool BufferStateLayer::setAcquireFence(const sp<Fence>& fence) {
- mCurrentState.acquireFence = fence;
- mCurrentState.acquireFenceTime = std::make_unique<FenceTime>(fence);
+ mDrawingState.acquireFence = fence;
+ mDrawingState.acquireFenceTime = std::make_unique<FenceTime>(fence);
// The acquire fences of BufferStateLayers have already signaled before they are set
- mCallbackHandleAcquireTime = mCurrentState.acquireFenceTime->getSignalTime();
+ mCallbackHandleAcquireTime = mDrawingState.acquireFenceTime->getSignalTime();
- mCurrentState.modified = true;
+ mDrawingState.modified = true;
setTransactionFlags(eTransactionNeeded);
return true;
}
bool BufferStateLayer::setDataspace(ui::Dataspace dataspace) {
- if (mCurrentState.dataspace == dataspace) return false;
- mCurrentState.dataspace = dataspace;
- mCurrentState.modified = true;
+ if (mDrawingState.dataspace == dataspace) return false;
+ mDrawingState.dataspace = dataspace;
+ mDrawingState.modified = true;
setTransactionFlags(eTransactionNeeded);
return true;
}
bool BufferStateLayer::setHdrMetadata(const HdrMetadata& hdrMetadata) {
- if (mCurrentState.hdrMetadata == hdrMetadata) return false;
- mCurrentState.hdrMetadata = hdrMetadata;
- mCurrentState.modified = true;
+ if (mDrawingState.hdrMetadata == hdrMetadata) return false;
+ mDrawingState.hdrMetadata = hdrMetadata;
+ mDrawingState.modified = true;
setTransactionFlags(eTransactionNeeded);
return true;
}
bool BufferStateLayer::setSurfaceDamageRegion(const Region& surfaceDamage) {
- mCurrentState.surfaceDamageRegion = surfaceDamage;
- mCurrentState.modified = true;
+ mDrawingState.surfaceDamageRegion = surfaceDamage;
+ mDrawingState.modified = true;
setTransactionFlags(eTransactionNeeded);
return true;
}
bool BufferStateLayer::setApi(int32_t api) {
- if (mCurrentState.api == api) return false;
- mCurrentState.api = api;
- mCurrentState.modified = true;
+ if (mDrawingState.api == api) return false;
+ mDrawingState.api = api;
+ mDrawingState.modified = true;
setTransactionFlags(eTransactionNeeded);
return true;
}
bool BufferStateLayer::setSidebandStream(const sp<NativeHandle>& sidebandStream) {
- if (mCurrentState.sidebandStream == sidebandStream) return false;
- mCurrentState.sidebandStream = sidebandStream;
- mCurrentState.modified = true;
+ if (mDrawingState.sidebandStream == sidebandStream) return false;
+ mDrawingState.sidebandStream = sidebandStream;
+ mDrawingState.modified = true;
setTransactionFlags(eTransactionNeeded);
if (!mSidebandStreamChanged.exchange(true)) {
@@ -563,14 +569,14 @@
if (willPresent) {
// If this transaction set an acquire fence on this layer, set its acquire time
handle->acquireTime = mCallbackHandleAcquireTime;
- handle->frameNumber = mCurrentState.frameNumber;
+ handle->frameNumber = mDrawingState.frameNumber;
// Notify the transaction completed thread that there is a pending latched callback
// handle
mFlinger->getTransactionCallbackInvoker().registerPendingCallbackHandle(handle);
// Store so latched time and release fence can be set
- mCurrentState.callbackHandles.push_back(handle);
+ mDrawingState.callbackHandles.push_back(handle);
} else { // If this layer will NOT need to be relatched and presented this frame
// Notify the transaction completed thread this handle is done
@@ -585,8 +591,8 @@
}
bool BufferStateLayer::setTransparentRegionHint(const Region& transparent) {
- mCurrentState.transparentRegionHint = transparent;
- mCurrentState.modified = true;
+ mDrawingState.transparentRegionHint = transparent;
+ mDrawingState.modified = true;
setTransactionFlags(eTransactionNeeded);
return true;
}
@@ -645,7 +651,7 @@
return true;
}
- return mCurrentState.isAutoTimestamp || mCurrentState.desiredPresentTime <= expectedPresentTime;
+ return mDrawingState.isAutoTimestamp || mDrawingState.desiredPresentTime <= expectedPresentTime;
}
bool BufferStateLayer::onPreComposition(nsecs_t refreshStartTime) {
@@ -674,7 +680,7 @@
* }
* Now imagine getHeadFrameNumber returned mDrawingState.mFrameNumber (or mCurrentFrameNumber).
* Prior to doTransaction SurfaceFlinger will call notifyAvailableFrames, but because we
- * haven't swapped mCurrentState to mDrawingState yet we will think the sync point
+ * haven't swapped mDrawingState to mDrawingState yet we will think the sync point
* is not ready. So we will return false from applyPendingState and not swap
* current state to drawing state. But because we don't swap current state
* to drawing state the number will never update and we will be stuck. This way
@@ -682,7 +688,7 @@
* to apply.
*/
uint64_t BufferStateLayer::getHeadFrameNumber(nsecs_t /* expectedPresentTime */) const {
- return mCurrentState.frameNumber;
+ return mDrawingState.frameNumber;
}
void BufferStateLayer::setAutoRefresh(bool autoRefresh) {
@@ -712,8 +718,8 @@
}
bool BufferStateLayer::hasFrameUpdate() const {
- const State& c(getCurrentState());
- return mCurrentStateModified && (c.buffer != nullptr || c.bgColorLayer != nullptr);
+ const State& c(getDrawingState());
+ return mDrawingStateModified && (c.buffer != nullptr || c.bgColorLayer != nullptr);
}
status_t BufferStateLayer::updateTexImage(bool& /*recomputeVisibleRegions*/, nsecs_t latchTime,
@@ -756,6 +762,7 @@
addSurfaceFramePresentedForBuffer(bufferSurfaceFrame,
mDrawingState.acquireFenceTime->getSignalTime(),
latchTime);
+ mDrawingState.bufferSurfaceFrameTX.reset();
}
std::deque<sp<CallbackHandle>> remainingHandles;
@@ -763,7 +770,7 @@
.finalizeOnCommitCallbackHandles(mDrawingState.callbackHandles, remainingHandles);
mDrawingState.callbackHandles = remainingHandles;
- mCurrentStateModified = false;
+ mDrawingStateModified = false;
return NO_ERROR;
}
diff --git a/services/surfaceflinger/BufferStateLayer.h b/services/surfaceflinger/BufferStateLayer.h
index 2e48452..2747018 100644
--- a/services/surfaceflinger/BufferStateLayer.h
+++ b/services/surfaceflinger/BufferStateLayer.h
@@ -47,10 +47,6 @@
bool isBufferDue(nsecs_t /*expectedPresentTime*/) const override { return true; }
- uint32_t doTransactionResize(uint32_t flags, Layer::State* /*stateToCommit*/) override {
- return flags;
- }
-
Region getActiveTransparentRegion(const Layer::State& s) const override {
return s.transparentRegionHint;
}
@@ -87,7 +83,7 @@
bool setBufferCrop(const Rect& bufferCrop) override;
bool setDestinationFrame(const Rect& destinationFrame) override;
- void updateGeometry() override;
+ bool updateGeometry() override;
// -----------------------------------------------------------------------
diff --git a/services/surfaceflinger/EffectLayer.cpp b/services/surfaceflinger/EffectLayer.cpp
index 0cc5f33..86c6b21 100644
--- a/services/surfaceflinger/EffectLayer.cpp
+++ b/services/surfaceflinger/EffectLayer.cpp
@@ -78,28 +78,28 @@
}
bool EffectLayer::setColor(const half3& color) {
- if (mCurrentState.color.r == color.r && mCurrentState.color.g == color.g &&
- mCurrentState.color.b == color.b) {
+ if (mDrawingState.color.r == color.r && mDrawingState.color.g == color.g &&
+ mDrawingState.color.b == color.b) {
return false;
}
- mCurrentState.sequence++;
- mCurrentState.color.r = color.r;
- mCurrentState.color.g = color.g;
- mCurrentState.color.b = color.b;
- mCurrentState.modified = true;
+ mDrawingState.sequence++;
+ mDrawingState.color.r = color.r;
+ mDrawingState.color.g = color.g;
+ mDrawingState.color.b = color.b;
+ mDrawingState.modified = true;
setTransactionFlags(eTransactionNeeded);
return true;
}
bool EffectLayer::setDataspace(ui::Dataspace dataspace) {
- if (mCurrentState.dataspace == dataspace) {
+ if (mDrawingState.dataspace == dataspace) {
return false;
}
- mCurrentState.sequence++;
- mCurrentState.dataspace = dataspace;
- mCurrentState.modified = true;
+ mDrawingState.sequence++;
+ mDrawingState.dataspace = dataspace;
+ mDrawingState.modified = true;
setTransactionFlags(eTransactionNeeded);
return true;
}
diff --git a/services/surfaceflinger/FpsReporter.cpp b/services/surfaceflinger/FpsReporter.cpp
index 23db805..e12835f 100644
--- a/services/surfaceflinger/FpsReporter.cpp
+++ b/services/surfaceflinger/FpsReporter.cpp
@@ -55,7 +55,7 @@
std::vector<std::pair<TrackedListener, sp<Layer>>> listenersAndLayersToReport;
mFlinger.mCurrentState.traverse([&](Layer* layer) {
- auto& currentState = layer->getCurrentState();
+ auto& currentState = layer->getDrawingState();
if (currentState.metadata.has(METADATA_TASK_ID)) {
int32_t taskId = currentState.metadata.getInt32(METADATA_TASK_ID, 0);
if (seenTasks.count(taskId) == 0) {
@@ -100,4 +100,4 @@
mListeners.erase(wp<IBinder>(IInterface::asBinder(listener)));
}
-} // namespace android
\ No newline at end of file
+} // namespace android
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 4beb526..b819dbe 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -98,52 +98,49 @@
if (args.flags & ISurfaceComposerClient::eSkipScreenshot)
layerFlags |= layer_state_t::eLayerSkipScreenshot;
- mCurrentState.active_legacy.w = args.w;
- mCurrentState.active_legacy.h = args.h;
- mCurrentState.flags = layerFlags;
- mCurrentState.active_legacy.transform.set(0, 0);
- mCurrentState.crop.makeInvalid();
- mCurrentState.requestedCrop = mCurrentState.crop;
- mCurrentState.z = 0;
- mCurrentState.color.a = 1.0f;
- mCurrentState.layerStack = 0;
- mCurrentState.sequence = 0;
- mCurrentState.requested_legacy = mCurrentState.active_legacy;
- mCurrentState.width = UINT32_MAX;
- mCurrentState.height = UINT32_MAX;
- mCurrentState.transform.set(0, 0);
- mCurrentState.frameNumber = 0;
- mCurrentState.bufferTransform = 0;
- mCurrentState.transformToDisplayInverse = false;
- mCurrentState.crop.makeInvalid();
- mCurrentState.acquireFence = sp<Fence>::make(-1);
- mCurrentState.acquireFenceTime = std::make_shared<FenceTime>(mCurrentState.acquireFence);
- mCurrentState.dataspace = ui::Dataspace::UNKNOWN;
- mCurrentState.hdrMetadata.validTypes = 0;
- mCurrentState.surfaceDamageRegion = Region::INVALID_REGION;
- mCurrentState.cornerRadius = 0.0f;
- mCurrentState.backgroundBlurRadius = 0;
- mCurrentState.api = -1;
- mCurrentState.hasColorTransform = false;
- mCurrentState.colorSpaceAgnostic = false;
- mCurrentState.frameRateSelectionPriority = PRIORITY_UNSET;
- mCurrentState.metadata = args.metadata;
- mCurrentState.shadowRadius = 0.f;
- mCurrentState.fixedTransformHint = ui::Transform::ROT_INVALID;
- mCurrentState.frameTimelineInfo = {};
- mCurrentState.postTime = -1;
- mCurrentState.destinationFrame.makeInvalid();
+ mDrawingState.active_legacy.w = args.w;
+ mDrawingState.active_legacy.h = args.h;
+ mDrawingState.flags = layerFlags;
+ mDrawingState.active_legacy.transform.set(0, 0);
+ mDrawingState.crop.makeInvalid();
+ mDrawingState.requestedCrop = mDrawingState.crop;
+ mDrawingState.z = 0;
+ mDrawingState.color.a = 1.0f;
+ mDrawingState.layerStack = 0;
+ mDrawingState.sequence = 0;
+ mDrawingState.requested_legacy = mDrawingState.active_legacy;
+ mDrawingState.width = UINT32_MAX;
+ mDrawingState.height = UINT32_MAX;
+ mDrawingState.transform.set(0, 0);
+ mDrawingState.frameNumber = 0;
+ mDrawingState.bufferTransform = 0;
+ mDrawingState.transformToDisplayInverse = false;
+ mDrawingState.crop.makeInvalid();
+ mDrawingState.acquireFence = sp<Fence>::make(-1);
+ mDrawingState.acquireFenceTime = std::make_shared<FenceTime>(mDrawingState.acquireFence);
+ mDrawingState.dataspace = ui::Dataspace::UNKNOWN;
+ mDrawingState.hdrMetadata.validTypes = 0;
+ mDrawingState.surfaceDamageRegion = Region::INVALID_REGION;
+ mDrawingState.cornerRadius = 0.0f;
+ mDrawingState.backgroundBlurRadius = 0;
+ mDrawingState.api = -1;
+ mDrawingState.hasColorTransform = false;
+ mDrawingState.colorSpaceAgnostic = false;
+ mDrawingState.frameRateSelectionPriority = PRIORITY_UNSET;
+ mDrawingState.metadata = args.metadata;
+ mDrawingState.shadowRadius = 0.f;
+ mDrawingState.fixedTransformHint = ui::Transform::ROT_INVALID;
+ mDrawingState.frameTimelineInfo = {};
+ mDrawingState.postTime = -1;
+ mDrawingState.destinationFrame.makeInvalid();
if (args.flags & ISurfaceComposerClient::eNoColorFill) {
// Set an invalid color so there is no color fill.
- mCurrentState.color.r = -1.0_hf;
- mCurrentState.color.g = -1.0_hf;
- mCurrentState.color.b = -1.0_hf;
+ mDrawingState.color.r = -1.0_hf;
+ mDrawingState.color.g = -1.0_hf;
+ mDrawingState.color.b = -1.0_hf;
}
- // drawing state & current state are identical
- mDrawingState = mCurrentState;
-
CompositorTiming compositorTiming;
args.flinger->getCompositorTiming(&compositorTiming);
mFrameEventHistory.initializeCompositorTiming(compositorTiming);
@@ -203,11 +200,11 @@
void Layer::onLayerDisplayed(const sp<Fence>& /*releaseFence*/) {}
void Layer::removeRelativeZ(const std::vector<Layer*>& layersInTree) {
- if (mCurrentState.zOrderRelativeOf == nullptr) {
+ if (mDrawingState.zOrderRelativeOf == nullptr) {
return;
}
- sp<Layer> strongRelative = mCurrentState.zOrderRelativeOf.promote();
+ sp<Layer> strongRelative = mDrawingState.zOrderRelativeOf.promote();
if (strongRelative == nullptr) {
setZOrderRelativeOf(nullptr);
return;
@@ -221,8 +218,8 @@
}
void Layer::removeFromCurrentState() {
- if (!mRemovedFromCurrentState) {
- mRemovedFromCurrentState = true;
+ if (!mRemovedFromDrawingState) {
+ mRemovedFromDrawingState = true;
mFlinger->mScheduler->deregisterLayer(this);
}
@@ -249,8 +246,8 @@
}
void Layer::addToCurrentState() {
- if (mRemovedFromCurrentState) {
- mRemovedFromCurrentState = false;
+ if (mRemovedFromDrawingState) {
+ mRemovedFromDrawingState = false;
mFlinger->mScheduler->registerLayer(this);
}
@@ -679,78 +676,6 @@
// transaction
// ----------------------------------------------------------------------------
-uint32_t Layer::doTransactionResize(uint32_t flags, State* stateToCommit) {
- const State& s(getDrawingState());
-
- const bool sizeChanged = (stateToCommit->requested_legacy.w != s.requested_legacy.w) ||
- (stateToCommit->requested_legacy.h != s.requested_legacy.h);
-
- if (sizeChanged) {
- // the size changed, we need to ask our client to request a new buffer
- ALOGD_IF(DEBUG_RESIZE,
- "doTransaction: geometry (layer=%p '%s'), tr=%02x, scalingMode=%d\n"
- " current={ active ={ wh={%4u,%4u} crop={%4d,%4d,%4d,%4d} (%4d,%4d) }\n"
- " requested={ wh={%4u,%4u} }}\n"
- " drawing={ active ={ wh={%4u,%4u} crop={%4d,%4d,%4d,%4d} (%4d,%4d) }\n"
- " requested={ wh={%4u,%4u} }}\n",
- this, getName().c_str(), getBufferTransform(), getEffectiveScalingMode(),
- stateToCommit->active_legacy.w, stateToCommit->active_legacy.h,
- stateToCommit->crop.left, stateToCommit->crop.top, stateToCommit->crop.right,
- stateToCommit->crop.bottom, stateToCommit->crop.getWidth(),
- stateToCommit->crop.getHeight(), stateToCommit->requested_legacy.w,
- stateToCommit->requested_legacy.h, s.active_legacy.w, s.active_legacy.h,
- s.crop.left, s.crop.top, s.crop.right, s.crop.bottom, s.crop.getWidth(),
- s.crop.getHeight(), s.requested_legacy.w, s.requested_legacy.h);
- }
-
- // Don't let Layer::doTransaction update the drawing state
- // if we have a pending resize, unless we are in fixed-size mode.
- // the drawing state will be updated only once we receive a buffer
- // with the correct size.
- //
- // In particular, we want to make sure the clip (which is part
- // of the geometry state) is latched together with the size but is
- // latched immediately when no resizing is involved.
- //
- // If a sideband stream is attached, however, we want to skip this
- // optimization so that transactions aren't missed when a buffer
- // never arrives
- //
- // In the case that we don't have a buffer we ignore other factors
- // and avoid entering the resizePending state. At a high level the
- // resizePending state is to avoid applying the state of the new buffer
- // to the old buffer. However in the state where we don't have an old buffer
- // there is no such concern but we may still be being used as a parent layer.
- const bool resizePending =
- ((stateToCommit->requested_legacy.w != stateToCommit->active_legacy.w) ||
- (stateToCommit->requested_legacy.h != stateToCommit->active_legacy.h)) &&
- (getBuffer() != nullptr);
- if (!isFixedSize()) {
- if (resizePending && mSidebandStream == nullptr) {
- flags |= eDontUpdateGeometryState;
- }
- }
-
- // Here we apply various requested geometry states, depending on our
- // latching configuration. See Layer.h for a detailed discussion of
- // how geometry latching is controlled.
- if (!(flags & eDontUpdateGeometryState)) {
- State& editCurrentState(getCurrentState());
-
- // There is an awkward asymmetry in the handling of the crop states in the position
- // states, as can be seen below. Largely this arises from position and transform
- // being stored in the same data structure while having different latching rules.
- // b/38182305
- //
- // Careful that "stateToCommit" and editCurrentState may not begin as equivalent due to
- // applyPendingStates in the presence of deferred transactions.
- editCurrentState.active_legacy = editCurrentState.requested_legacy;
- stateToCommit->active_legacy = stateToCommit->requested_legacy;
- }
-
- return flags;
-}
-
uint32_t Layer::doTransaction(uint32_t flags) {
ATRACE_CALL();
@@ -760,77 +685,37 @@
}
// TODO: This is unfortunate.
- mCurrentStateModified = mCurrentState.modified;
- mCurrentState.modified = false;
-
- flags = doTransactionResize(flags, &mCurrentState);
+ mDrawingStateModified = mDrawingState.modified;
+ mDrawingState.modified = false;
const State& s(getDrawingState());
- State& c(getCurrentState());
- // Translates dest frame into scale and position updates. This helps align geometry calculations
- // for BufferStateLayer with other layers. This should ideally happen in the client once client
- // has the display orientation details from WM.
- updateGeometry();
-
- if (c.width != s.width || c.height != s.height || !(c.transform == s.transform)) {
+ if (updateGeometry()) {
// invalidate and recompute the visible regions if needed
flags |= Layer::eVisibleRegion;
}
- if (c.sequence != s.sequence) {
+ if (s.sequence != mLastCommittedTxSequence) {
// invalidate and recompute the visible regions if needed
+ mLastCommittedTxSequence = s.sequence;
flags |= eVisibleRegion;
this->contentDirty = true;
// we may use linear filtering, if the matrix scales us
- mNeedsFiltering = getActiveTransform(c).needsBilinearFiltering();
+ mNeedsFiltering = getActiveTransform(s).needsBilinearFiltering();
}
- if (mCurrentState.inputInfoChanged) {
+ if (mDrawingState.inputInfoChanged) {
flags |= eInputInfoChanged;
- mCurrentState.inputInfoChanged = false;
+ mDrawingState.inputInfoChanged = false;
}
- // Add the callbacks from the drawing state into the current state. This is so when the current
- // state gets copied to drawing, we don't lose the callback handles that are still in drawing.
- for (auto& handle : s.callbackHandles) {
- c.callbackHandles.push_back(handle);
- }
-
- // Allow BufferStateLayer to release any unlatched buffers in drawing state.
- bufferMayChange(c.buffer->getBuffer());
-
- // Commit the transaction
- commitTransaction(c);
- mCurrentState.callbackHandles = {};
+ commitTransaction(mDrawingState);
return flags;
}
-void Layer::commitTransaction(State& stateToCommit) {
- if (auto& bufferSurfaceFrame = mDrawingState.bufferSurfaceFrameTX;
- ((mDrawingState.buffer && stateToCommit.buffer &&
- mDrawingState.buffer->getBuffer() != stateToCommit.buffer->getBuffer()) ||
- (mDrawingState.buffer && !stateToCommit.buffer) ||
- (!mDrawingState.buffer && stateToCommit.buffer)) &&
- bufferSurfaceFrame != nullptr &&
- bufferSurfaceFrame->getPresentState() != PresentState::Presented) {
- // If the previous buffer was committed but not latched (refreshPending - happens during
- // back to back invalidates), it gets silently dropped here. Mark the corresponding
- // SurfaceFrame as dropped to prevent it from getting stuck in the pending classification
- // list.
- addSurfaceFrameDroppedForBuffer(bufferSurfaceFrame);
- }
- const bool frameRateVoteChanged =
- mDrawingState.frameRateForLayerTree != stateToCommit.frameRateForLayerTree;
- mDrawingState = stateToCommit;
-
- if (frameRateVoteChanged) {
- mFlinger->mScheduler->recordLayerHistory(this, systemTime(),
- LayerHistory::LayerUpdateType::SetFrameRate);
- }
-
+void Layer::commitTransaction(State&) {
// Set the present state for all bufferlessSurfaceFramesTX to Presented. The
// bufferSurfaceFrameTX will be presented in latchBuffer.
for (auto& [token, surfaceFrame] : mDrawingState.bufferlessSurfaceFramesTX) {
@@ -841,9 +726,7 @@
mFlinger->mFrameTimeline->addSurfaceFrame(surfaceFrame);
}
}
- // Clear the surfaceFrames from the old state now that it has been copied into DrawingState.
- stateToCommit.bufferSurfaceFrameTX.reset();
- stateToCommit.bufferlessSurfaceFramesTX.clear();
+ mDrawingState.bufferlessSurfaceFramesTX.clear();
}
uint32_t Layer::getTransactionFlags(uint32_t flags) {
@@ -857,20 +740,11 @@
}
bool Layer::setPosition(float x, float y) {
- if (mCurrentState.transform.tx() == x && mCurrentState.transform.ty() == y) return false;
- mCurrentState.sequence++;
+ if (mDrawingState.transform.tx() == x && mDrawingState.transform.ty() == y) return false;
+ mDrawingState.sequence++;
+ mDrawingState.transform.set(x, y);
- // We update the requested and active position simultaneously because
- // we want to apply the position portion of the transform matrix immediately,
- // but still delay scaling when resizing a SCALING_MODE_FREEZE layer.
- mCurrentState.transform.set(x, y);
- // Here we directly update the active state
- // unlike other setters, because we store it within
- // the transform, but use different latching rules.
- // b/38182305
- mCurrentState.transform.set(x, y);
-
- mCurrentState.modified = true;
+ mDrawingState.modified = true;
setTransactionFlags(eTransactionNeeded);
return true;
}
@@ -903,14 +777,14 @@
}
bool Layer::setLayer(int32_t z) {
- if (mCurrentState.z == z && !usingRelativeZ(LayerVector::StateSet::Current)) return false;
- mCurrentState.sequence++;
- mCurrentState.z = z;
- mCurrentState.modified = true;
+ if (mDrawingState.z == z && !usingRelativeZ(LayerVector::StateSet::Current)) return false;
+ mDrawingState.sequence++;
+ mDrawingState.z = z;
+ mDrawingState.modified = true;
// Discard all relative layering.
- if (mCurrentState.zOrderRelativeOf != nullptr) {
- sp<Layer> strongRelative = mCurrentState.zOrderRelativeOf.promote();
+ if (mDrawingState.zOrderRelativeOf != nullptr) {
+ sp<Layer> strongRelative = mDrawingState.zOrderRelativeOf.promote();
if (strongRelative != nullptr) {
strongRelative->removeZOrderRelative(this);
}
@@ -921,24 +795,24 @@
}
void Layer::removeZOrderRelative(const wp<Layer>& relative) {
- mCurrentState.zOrderRelatives.remove(relative);
- mCurrentState.sequence++;
- mCurrentState.modified = true;
+ mDrawingState.zOrderRelatives.remove(relative);
+ mDrawingState.sequence++;
+ mDrawingState.modified = true;
setTransactionFlags(eTransactionNeeded);
}
void Layer::addZOrderRelative(const wp<Layer>& relative) {
- mCurrentState.zOrderRelatives.add(relative);
- mCurrentState.modified = true;
- mCurrentState.sequence++;
+ mDrawingState.zOrderRelatives.add(relative);
+ mDrawingState.modified = true;
+ mDrawingState.sequence++;
setTransactionFlags(eTransactionNeeded);
}
void Layer::setZOrderRelativeOf(const wp<Layer>& relativeOf) {
- mCurrentState.zOrderRelativeOf = relativeOf;
- mCurrentState.sequence++;
- mCurrentState.modified = true;
- mCurrentState.isRelativeOf = relativeOf != nullptr;
+ mDrawingState.zOrderRelativeOf = relativeOf;
+ mDrawingState.sequence++;
+ mDrawingState.modified = true;
+ mDrawingState.isRelativeOf = relativeOf != nullptr;
setTransactionFlags(eTransactionNeeded);
}
@@ -953,16 +827,16 @@
return false;
}
- if (mCurrentState.z == relativeZ && usingRelativeZ(LayerVector::StateSet::Current) &&
- mCurrentState.zOrderRelativeOf == relative) {
+ if (mDrawingState.z == relativeZ && usingRelativeZ(LayerVector::StateSet::Current) &&
+ mDrawingState.zOrderRelativeOf == relative) {
return false;
}
- mCurrentState.sequence++;
- mCurrentState.modified = true;
- mCurrentState.z = relativeZ;
+ mDrawingState.sequence++;
+ mDrawingState.modified = true;
+ mDrawingState.z = relativeZ;
- auto oldZOrderRelativeOf = mCurrentState.zOrderRelativeOf.promote();
+ auto oldZOrderRelativeOf = mDrawingState.zOrderRelativeOf.promote();
if (oldZOrderRelativeOf != nullptr) {
oldZOrderRelativeOf->removeZOrderRelative(this);
}
@@ -975,82 +849,82 @@
}
bool Layer::setSize(uint32_t w, uint32_t h) {
- if (mCurrentState.requested_legacy.w == w && mCurrentState.requested_legacy.h == h)
+ if (mDrawingState.requested_legacy.w == w && mDrawingState.requested_legacy.h == h)
return false;
- mCurrentState.requested_legacy.w = w;
- mCurrentState.requested_legacy.h = h;
- mCurrentState.modified = true;
+ mDrawingState.requested_legacy.w = w;
+ mDrawingState.requested_legacy.h = h;
+ mDrawingState.modified = true;
setTransactionFlags(eTransactionNeeded);
// record the new size, from this point on, when the client request
// a buffer, it'll get the new size.
- setDefaultBufferSize(mCurrentState.requested_legacy.w, mCurrentState.requested_legacy.h);
+ setDefaultBufferSize(mDrawingState.requested_legacy.w, mDrawingState.requested_legacy.h);
return true;
}
bool Layer::setAlpha(float alpha) {
- if (mCurrentState.color.a == alpha) return false;
- mCurrentState.sequence++;
- mCurrentState.color.a = alpha;
- mCurrentState.modified = true;
+ if (mDrawingState.color.a == alpha) return false;
+ mDrawingState.sequence++;
+ mDrawingState.color.a = alpha;
+ mDrawingState.modified = true;
setTransactionFlags(eTransactionNeeded);
return true;
}
bool Layer::setBackgroundColor(const half3& color, float alpha, ui::Dataspace dataspace) {
- if (!mCurrentState.bgColorLayer && alpha == 0) {
+ if (!mDrawingState.bgColorLayer && alpha == 0) {
return false;
}
- mCurrentState.sequence++;
- mCurrentState.modified = true;
+ mDrawingState.sequence++;
+ mDrawingState.modified = true;
setTransactionFlags(eTransactionNeeded);
- if (!mCurrentState.bgColorLayer && alpha != 0) {
+ if (!mDrawingState.bgColorLayer && alpha != 0) {
// create background color layer if one does not yet exist
uint32_t flags = ISurfaceComposerClient::eFXSurfaceEffect;
std::string name = mName + "BackgroundColorLayer";
- mCurrentState.bgColorLayer = mFlinger->getFactory().createEffectLayer(
+ mDrawingState.bgColorLayer = mFlinger->getFactory().createEffectLayer(
LayerCreationArgs(mFlinger.get(), nullptr, std::move(name), 0, 0, flags,
LayerMetadata()));
// add to child list
- addChild(mCurrentState.bgColorLayer);
+ addChild(mDrawingState.bgColorLayer);
mFlinger->mLayersAdded = true;
// set up SF to handle added color layer
if (isRemovedFromCurrentState()) {
- mCurrentState.bgColorLayer->onRemovedFromCurrentState();
+ mDrawingState.bgColorLayer->onRemovedFromCurrentState();
}
mFlinger->setTransactionFlags(eTransactionNeeded);
- } else if (mCurrentState.bgColorLayer && alpha == 0) {
- mCurrentState.bgColorLayer->reparent(nullptr);
- mCurrentState.bgColorLayer = nullptr;
+ } else if (mDrawingState.bgColorLayer && alpha == 0) {
+ mDrawingState.bgColorLayer->reparent(nullptr);
+ mDrawingState.bgColorLayer = nullptr;
return true;
}
- mCurrentState.bgColorLayer->setColor(color);
- mCurrentState.bgColorLayer->setLayer(std::numeric_limits<int32_t>::min());
- mCurrentState.bgColorLayer->setAlpha(alpha);
- mCurrentState.bgColorLayer->setDataspace(dataspace);
+ mDrawingState.bgColorLayer->setColor(color);
+ mDrawingState.bgColorLayer->setLayer(std::numeric_limits<int32_t>::min());
+ mDrawingState.bgColorLayer->setAlpha(alpha);
+ mDrawingState.bgColorLayer->setDataspace(dataspace);
return true;
}
bool Layer::setCornerRadius(float cornerRadius) {
- if (mCurrentState.cornerRadius == cornerRadius) return false;
+ if (mDrawingState.cornerRadius == cornerRadius) return false;
- mCurrentState.sequence++;
- mCurrentState.cornerRadius = cornerRadius;
- mCurrentState.modified = true;
+ mDrawingState.sequence++;
+ mDrawingState.cornerRadius = cornerRadius;
+ mDrawingState.modified = true;
setTransactionFlags(eTransactionNeeded);
return true;
}
bool Layer::setBackgroundBlurRadius(int backgroundBlurRadius) {
- if (mCurrentState.backgroundBlurRadius == backgroundBlurRadius) return false;
+ if (mDrawingState.backgroundBlurRadius == backgroundBlurRadius) return false;
- mCurrentState.sequence++;
- mCurrentState.backgroundBlurRadius = backgroundBlurRadius;
- mCurrentState.modified = true;
+ mDrawingState.sequence++;
+ mDrawingState.backgroundBlurRadius = backgroundBlurRadius;
+ mDrawingState.modified = true;
setTransactionFlags(eTransactionNeeded);
return true;
}
@@ -1065,81 +939,82 @@
"ROTATE_SURFACE_FLINGER ignored");
return false;
}
- mCurrentState.sequence++;
- mCurrentState.transform.set(matrix.dsdx, matrix.dtdy, matrix.dtdx, matrix.dsdy);
- mCurrentState.modified = true;
+ mDrawingState.sequence++;
+ mDrawingState.transform.set(matrix.dsdx, matrix.dtdy, matrix.dtdx, matrix.dsdy);
+ mDrawingState.modified = true;
+
setTransactionFlags(eTransactionNeeded);
return true;
}
bool Layer::setTransparentRegionHint(const Region& transparent) {
- mCurrentState.requestedTransparentRegion_legacy = transparent;
- mCurrentState.modified = true;
+ mDrawingState.requestedTransparentRegion_legacy = transparent;
+ mDrawingState.modified = true;
setTransactionFlags(eTransactionNeeded);
return true;
}
bool Layer::setBlurRegions(const std::vector<BlurRegion>& blurRegions) {
- mCurrentState.sequence++;
- mCurrentState.blurRegions = blurRegions;
- mCurrentState.modified = true;
+ mDrawingState.sequence++;
+ mDrawingState.blurRegions = blurRegions;
+ mDrawingState.modified = true;
setTransactionFlags(eTransactionNeeded);
return true;
}
bool Layer::setFlags(uint32_t flags, uint32_t mask) {
- const uint32_t newFlags = (mCurrentState.flags & ~mask) | (flags & mask);
- if (mCurrentState.flags == newFlags) return false;
- mCurrentState.sequence++;
- mCurrentState.flags = newFlags;
- mCurrentState.modified = true;
+ const uint32_t newFlags = (mDrawingState.flags & ~mask) | (flags & mask);
+ if (mDrawingState.flags == newFlags) return false;
+ mDrawingState.sequence++;
+ mDrawingState.flags = newFlags;
+ mDrawingState.modified = true;
setTransactionFlags(eTransactionNeeded);
return true;
}
bool Layer::setCrop(const Rect& crop) {
- if (mCurrentState.requestedCrop == crop) return false;
- mCurrentState.sequence++;
- mCurrentState.requestedCrop = crop;
- mCurrentState.crop = crop;
+ if (mDrawingState.requestedCrop == crop) return false;
+ mDrawingState.sequence++;
+ mDrawingState.requestedCrop = crop;
+ mDrawingState.crop = crop;
- mCurrentState.modified = true;
+ mDrawingState.modified = true;
setTransactionFlags(eTransactionNeeded);
return true;
}
bool Layer::setMetadata(const LayerMetadata& data) {
- if (!mCurrentState.metadata.merge(data, true /* eraseEmpty */)) return false;
- mCurrentState.modified = true;
+ if (!mDrawingState.metadata.merge(data, true /* eraseEmpty */)) return false;
+ mDrawingState.modified = true;
setTransactionFlags(eTransactionNeeded);
return true;
}
bool Layer::setLayerStack(uint32_t layerStack) {
- if (mCurrentState.layerStack == layerStack) return false;
- mCurrentState.sequence++;
- mCurrentState.layerStack = layerStack;
- mCurrentState.modified = true;
+ if (mDrawingState.layerStack == layerStack) return false;
+ mDrawingState.sequence++;
+ mDrawingState.layerStack = layerStack;
+ mDrawingState.modified = true;
setTransactionFlags(eTransactionNeeded);
return true;
}
bool Layer::setColorSpaceAgnostic(const bool agnostic) {
- if (mCurrentState.colorSpaceAgnostic == agnostic) {
+ if (mDrawingState.colorSpaceAgnostic == agnostic) {
return false;
}
- mCurrentState.sequence++;
- mCurrentState.colorSpaceAgnostic = agnostic;
- mCurrentState.modified = true;
+ mDrawingState.sequence++;
+ mDrawingState.colorSpaceAgnostic = agnostic;
+ mDrawingState.modified = true;
setTransactionFlags(eTransactionNeeded);
return true;
}
bool Layer::setFrameRateSelectionPriority(int32_t priority) {
- if (mCurrentState.frameRateSelectionPriority == priority) return false;
- mCurrentState.frameRateSelectionPriority = priority;
- mCurrentState.sequence++;
- mCurrentState.modified = true;
+ if (mDrawingState.frameRateSelectionPriority == priority) return false;
+ mDrawingState.frameRateSelectionPriority = priority;
+ mDrawingState.sequence++;
+ mDrawingState.modified = true;
setTransactionFlags(eTransactionNeeded);
return true;
}
@@ -1171,25 +1046,25 @@
}
bool Layer::setShadowRadius(float shadowRadius) {
- if (mCurrentState.shadowRadius == shadowRadius) {
+ if (mDrawingState.shadowRadius == shadowRadius) {
return false;
}
- mCurrentState.sequence++;
- mCurrentState.shadowRadius = shadowRadius;
- mCurrentState.modified = true;
+ mDrawingState.sequence++;
+ mDrawingState.shadowRadius = shadowRadius;
+ mDrawingState.modified = true;
setTransactionFlags(eTransactionNeeded);
return true;
}
bool Layer::setFixedTransformHint(ui::Transform::RotationFlags fixedTransformHint) {
- if (mCurrentState.fixedTransformHint == fixedTransformHint) {
+ if (mDrawingState.fixedTransformHint == fixedTransformHint) {
return false;
}
- mCurrentState.sequence++;
- mCurrentState.fixedTransformHint = fixedTransformHint;
- mCurrentState.modified = true;
+ mDrawingState.sequence++;
+ mDrawingState.fixedTransformHint = fixedTransformHint;
+ mDrawingState.modified = true;
setTransactionFlags(eTransactionNeeded);
return true;
}
@@ -1197,12 +1072,12 @@
bool Layer::setStretchEffect(const StretchEffect& effect) {
StretchEffect temp = effect;
temp.sanitize();
- if (mCurrentState.stretchEffect == temp) {
+ if (mDrawingState.stretchEffect == temp) {
return false;
}
- mCurrentState.sequence++;
- mCurrentState.stretchEffect = temp;
- mCurrentState.modified = true;
+ mDrawingState.sequence++;
+ mDrawingState.stretchEffect = temp;
+ mDrawingState.modified = true;
setTransactionFlags(eTransactionNeeded);
return true;
}
@@ -1239,12 +1114,12 @@
int layersWithVote = 0;
traverseTree([&layersWithVote](Layer* layer) {
const auto layerVotedWithDefaultCompatibility =
- layer->mCurrentState.frameRate.rate.isValid() &&
- layer->mCurrentState.frameRate.type == FrameRateCompatibility::Default;
+ layer->mDrawingState.frameRate.rate.isValid() &&
+ layer->mDrawingState.frameRate.type == FrameRateCompatibility::Default;
const auto layerVotedWithNoVote =
- layer->mCurrentState.frameRate.type == FrameRateCompatibility::NoVote;
+ layer->mDrawingState.frameRate.type == FrameRateCompatibility::NoVote;
const auto layerVotedWithExactCompatibility =
- layer->mCurrentState.frameRate.type == FrameRateCompatibility::Exact;
+ layer->mDrawingState.frameRate.type == FrameRateCompatibility::Exact;
// We do not count layers that are ExactOrMultiple for the same reason
// we are allowing touch boost for those layers. See
@@ -1258,6 +1133,7 @@
// Now we can update the tree frame rate vote for each layer in the tree
const bool treeHasFrameRateVote = layersWithVote > 0;
bool transactionNeeded = false;
+
traverseTree([treeHasFrameRateVote, &transactionNeeded](Layer* layer) {
transactionNeeded = layer->updateFrameRateForLayerTree(treeHasFrameRateVote);
});
@@ -1271,13 +1147,13 @@
if (!mFlinger->useFrameRateApi) {
return false;
}
- if (mCurrentState.frameRate == frameRate) {
+ if (mDrawingState.frameRate == frameRate) {
return false;
}
- mCurrentState.sequence++;
- mCurrentState.frameRate = frameRate;
- mCurrentState.modified = true;
+ mDrawingState.sequence++;
+ mDrawingState.frameRate = frameRate;
+ mDrawingState.modified = true;
updateTreeHasFrameRateVote();
@@ -1287,33 +1163,33 @@
void Layer::setFrameTimelineVsyncForBufferTransaction(const FrameTimelineInfo& info,
nsecs_t postTime) {
- mCurrentState.postTime = postTime;
+ mDrawingState.postTime = postTime;
// Check if one of the bufferlessSurfaceFramesTX contains the same vsyncId. This can happen if
// there are two transactions with the same token, the first one without a buffer and the
// second one with a buffer. We promote the bufferlessSurfaceFrame to a bufferSurfaceFrameTX
// in that case.
- auto it = mCurrentState.bufferlessSurfaceFramesTX.find(info.vsyncId);
- if (it != mCurrentState.bufferlessSurfaceFramesTX.end()) {
+ auto it = mDrawingState.bufferlessSurfaceFramesTX.find(info.vsyncId);
+ if (it != mDrawingState.bufferlessSurfaceFramesTX.end()) {
// Promote the bufferlessSurfaceFrame to a bufferSurfaceFrameTX
- mCurrentState.bufferSurfaceFrameTX = it->second;
- mCurrentState.bufferlessSurfaceFramesTX.erase(it);
- mCurrentState.bufferSurfaceFrameTX->promoteToBuffer();
- mCurrentState.bufferSurfaceFrameTX->setActualQueueTime(postTime);
+ mDrawingState.bufferSurfaceFrameTX = it->second;
+ mDrawingState.bufferlessSurfaceFramesTX.erase(it);
+ mDrawingState.bufferSurfaceFrameTX->promoteToBuffer();
+ mDrawingState.bufferSurfaceFrameTX->setActualQueueTime(postTime);
} else {
- mCurrentState.bufferSurfaceFrameTX =
+ mDrawingState.bufferSurfaceFrameTX =
createSurfaceFrameForBuffer(info, postTime, mTransactionName);
}
}
void Layer::setFrameTimelineVsyncForBufferlessTransaction(const FrameTimelineInfo& info,
nsecs_t postTime) {
- mCurrentState.frameTimelineInfo = info;
- mCurrentState.postTime = postTime;
- mCurrentState.modified = true;
+ mDrawingState.frameTimelineInfo = info;
+ mDrawingState.postTime = postTime;
+ mDrawingState.modified = true;
setTransactionFlags(eTransactionNeeded);
- if (const auto& bufferSurfaceFrameTX = mCurrentState.bufferSurfaceFrameTX;
+ if (const auto& bufferSurfaceFrameTX = mDrawingState.bufferSurfaceFrameTX;
bufferSurfaceFrameTX != nullptr) {
if (bufferSurfaceFrameTX->getToken() == info.vsyncId) {
// BufferSurfaceFrame takes precedence over BufferlessSurfaceFrame. If the same token is
@@ -1324,10 +1200,10 @@
// For Transactions without a buffer, we create only one SurfaceFrame per vsyncId. If multiple
// transactions use the same vsyncId, we just treat them as one SurfaceFrame (unless they are
// targeting different vsyncs).
- auto it = mCurrentState.bufferlessSurfaceFramesTX.find(info.vsyncId);
- if (it == mCurrentState.bufferlessSurfaceFramesTX.end()) {
+ auto it = mDrawingState.bufferlessSurfaceFramesTX.find(info.vsyncId);
+ if (it == mDrawingState.bufferlessSurfaceFramesTX.end()) {
auto surfaceFrame = createSurfaceFrameForTransaction(info, postTime);
- mCurrentState.bufferlessSurfaceFramesTX[info.vsyncId] = surfaceFrame;
+ mDrawingState.bufferlessSurfaceFramesTX[info.vsyncId] = surfaceFrame;
} else {
if (it->second->getPresentState() == PresentState::Presented) {
// If the SurfaceFrame was already presented, its safe to overwrite it since it must
@@ -1389,36 +1265,41 @@
}
bool Layer::updateFrameRateForLayerTree(bool treeHasFrameRateVote) {
- const auto updateCurrentState = [&](FrameRate frameRate) {
- if (mCurrentState.frameRateForLayerTree == frameRate) {
+ const auto updateDrawingState = [&](FrameRate frameRate) {
+ if (mDrawingState.frameRateForLayerTree == frameRate) {
return false;
}
- mCurrentState.frameRateForLayerTree = frameRate;
- mCurrentState.sequence++;
- mCurrentState.modified = true;
+
+ mDrawingState.frameRateForLayerTree = frameRate;
+ mDrawingState.sequence++;
+ mDrawingState.modified = true;
setTransactionFlags(eTransactionNeeded);
+
+ mFlinger->mScheduler->recordLayerHistory(this, systemTime(),
+ LayerHistory::LayerUpdateType::SetFrameRate);
+
return true;
};
- const auto frameRate = mCurrentState.frameRate;
+ const auto frameRate = mDrawingState.frameRate;
if (frameRate.rate.isValid() || frameRate.type == FrameRateCompatibility::NoVote) {
- return updateCurrentState(frameRate);
+ return updateDrawingState(frameRate);
}
// This layer doesn't have a frame rate. Check if its ancestors have a vote
for (sp<Layer> parent = getParent(); parent; parent = parent->getParent()) {
- if (parent->mCurrentState.frameRate.rate.isValid()) {
- return updateCurrentState(parent->mCurrentState.frameRate);
+ if (parent->mDrawingState.frameRate.rate.isValid()) {
+ return updateDrawingState(parent->mDrawingState.frameRate);
}
}
// This layer and its ancestors don't have a frame rate. If one of successors
// has a vote, return a NoVote for successors to set the vote
if (treeHasFrameRateVote) {
- return updateCurrentState(FrameRate(Fps(0.0f), FrameRateCompatibility::NoVote));
+ return updateDrawingState(FrameRate(Fps(0.0f), FrameRateCompatibility::NoVote));
}
- return updateCurrentState(frameRate);
+ return updateDrawingState(frameRate);
}
Layer::FrameRate Layer::getFrameRateForLayerTree() const {
@@ -1670,7 +1551,7 @@
void Layer::setGameModeForTree(int parentGameMode) {
int gameMode = parentGameMode;
- auto& currentState = getCurrentState();
+ auto& currentState = getDrawingState();
if (currentState.metadata.has(METADATA_GAME_MODE)) {
gameMode = currentState.metadata.getInt32(METADATA_GAME_MODE, 0);
}
@@ -1749,13 +1630,13 @@
bool Layer::setColorTransform(const mat4& matrix) {
static const mat4 identityMatrix = mat4();
- if (mCurrentState.colorTransform == matrix) {
+ if (mDrawingState.colorTransform == matrix) {
return false;
}
- ++mCurrentState.sequence;
- mCurrentState.colorTransform = matrix;
- mCurrentState.hasColorTransform = matrix != identityMatrix;
- mCurrentState.modified = true;
+ ++mDrawingState.sequence;
+ mDrawingState.colorTransform = matrix;
+ mDrawingState.hasColorTransform = matrix != identityMatrix;
+ mDrawingState.modified = true;
setTransactionFlags(eTransactionNeeded);
return true;
}
@@ -1787,15 +1668,13 @@
mCurrentParent = layer;
}
-int32_t Layer::getZ(LayerVector::StateSet stateSet) const {
- const bool useDrawing = stateSet == LayerVector::StateSet::Drawing;
- const State& state = useDrawing ? mDrawingState : mCurrentState;
- return state.z;
+int32_t Layer::getZ(LayerVector::StateSet) const {
+ return mDrawingState.z;
}
bool Layer::usingRelativeZ(LayerVector::StateSet stateSet) const {
const bool useDrawing = stateSet == LayerVector::StateSet::Drawing;
- const State& state = useDrawing ? mDrawingState : mCurrentState;
+ const State& state = useDrawing ? mDrawingState : mDrawingState;
return state.isRelativeOf;
}
@@ -1805,7 +1684,7 @@
"makeTraversalList received invalid stateSet");
const bool useDrawing = stateSet == LayerVector::StateSet::Drawing;
const LayerVector& children = useDrawing ? mDrawingChildren : mCurrentChildren;
- const State& state = useDrawing ? mDrawingState : mCurrentState;
+ const State& state = useDrawing ? mDrawingState : mDrawingState;
if (state.zOrderRelatives.size() == 0) {
*outSkipRelativeZUsers = true;
@@ -1904,7 +1783,7 @@
void Layer::traverse(LayerVector::StateSet state, const LayerVector::Visitor& visitor) {
visitor(this);
const LayerVector& children =
- state == LayerVector::StateSet::Drawing ? mDrawingChildren : mCurrentChildren;
+ state == LayerVector::StateSet::Drawing ? mDrawingChildren : mCurrentChildren;
for (const sp<Layer>& child : children) {
child->traverse(state, visitor);
}
@@ -1916,7 +1795,7 @@
"makeTraversalList received invalid stateSet");
const bool useDrawing = stateSet == LayerVector::StateSet::Drawing;
const LayerVector& children = useDrawing ? mDrawingChildren : mCurrentChildren;
- const State& state = useDrawing ? mDrawingState : mCurrentState;
+ const State& state = useDrawing ? mDrawingState : mDrawingState;
LayerVector traverse(stateSet);
for (const wp<Layer>& weakRelative : state.zOrderRelatives) {
@@ -1929,7 +1808,7 @@
}
for (const sp<Layer>& child : children) {
- const State& childState = useDrawing ? child->mDrawingState : child->mCurrentState;
+ const State& childState = useDrawing ? child->mDrawingState : child->mDrawingState;
// If a layer has a relativeOf layer, only ignore if the layer it's relative to is a
// descendent of the top most parent of the tree. If it's not a descendent, then just add
// the child here since it won't be added later as a relative.
@@ -1997,7 +1876,7 @@
}
ui::Transform::RotationFlags Layer::getFixedTransformHint() const {
- ui::Transform::RotationFlags fixedTransformHint = mCurrentState.fixedTransformHint;
+ ui::Transform::RotationFlags fixedTransformHint = mDrawingState.fixedTransformHint;
if (fixedTransformHint != ui::Transform::ROT_INVALID) {
return fixedTransformHint;
}
@@ -2109,10 +1988,10 @@
}
void Layer::setInputInfo(const InputWindowInfo& info) {
- mCurrentState.inputInfo = info;
- mCurrentState.touchableRegionCrop = extractLayerFromBinder(info.touchableRegionCropHandle);
- mCurrentState.modified = true;
- mCurrentState.inputInfoChanged = true;
+ mDrawingState.inputInfo = info;
+ mDrawingState.touchableRegionCrop = extractLayerFromBinder(info.touchableRegionCropHandle);
+ mDrawingState.modified = true;
+ mDrawingState.inputInfoChanged = true;
setTransactionFlags(eTransactionNeeded);
}
@@ -2190,7 +2069,7 @@
uint32_t traceFlags) {
const bool useDrawing = stateSet == LayerVector::StateSet::Drawing;
const LayerVector& children = useDrawing ? mDrawingChildren : mCurrentChildren;
- const State& state = useDrawing ? mDrawingState : mCurrentState;
+ const State& state = useDrawing ? mDrawingState : mDrawingState;
ui::Transform requestedTransform = state.transform;
@@ -2278,7 +2157,7 @@
}
bool Layer::isRemovedFromCurrentState() const {
- return mRemovedFromCurrentState;
+ return mRemovedFromDrawingState;
}
ui::Transform Layer::getInputTransform() const {
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index 5669049..9b30fcb 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -1,3 +1,4 @@
+
/*
* Copyright (C) 2007 The Android Open Source Project
*
@@ -732,8 +733,7 @@
void updateTransformHint(ui::Transform::RotationFlags);
inline const State& getDrawingState() const { return mDrawingState; }
- inline const State& getCurrentState() const { return mCurrentState; }
- inline State& getCurrentState() { return mCurrentState; }
+ inline State& getDrawingState() { return mDrawingState; }
LayerDebugInfo getLayerDebugInfo(const DisplayDevice*) const;
@@ -884,7 +884,7 @@
virtual bool setDestinationFrame(const Rect& /* destinationFrame */) { return false; }
virtual std::atomic<int32_t>* getPendingBufferCounter() { return nullptr; }
virtual std::string getPendingBufferCounterName() { return ""; }
- virtual void updateGeometry() {}
+ virtual bool updateGeometry() { return false; }
protected:
friend class impl::SurfaceInterceptor;
@@ -902,7 +902,6 @@
compositionengine::LayerFE::ClientCompositionTargetSettings&);
virtual void preparePerFrameCompositionState();
virtual void commitTransaction(State& stateToCommit);
- virtual uint32_t doTransactionResize(uint32_t flags, Layer::State* stateToCommit);
virtual void onSurfaceFrameCreated(const std::shared_ptr<frametimeline::SurfaceFrame>&) {}
// Returns mCurrentScaling mode (originating from the
@@ -958,9 +957,11 @@
// These are only accessed by the main thread or the tracing thread.
State mDrawingState;
- // these are protected by an external lock (mStateLock)
- State mCurrentState;
uint32_t mTransactionFlags{0};
+ // Updated in doTransaction, used to track the last sequence number we
+ // committed. Currently this is really only used for updating visible
+ // regions.
+ int32_t mLastCommittedTxSequence = -1;
// Timestamp history for UIAutomation. Thread safe.
FrameTracker mFrameTracker;
@@ -983,7 +984,7 @@
// Whether filtering is needed b/c of the drawingstate
bool mNeedsFiltering{false};
- std::atomic<bool> mRemovedFromCurrentState{false};
+ std::atomic<bool> mRemovedFromDrawingState{false};
// page-flip thread (currently main thread)
bool mProtectedByApp{false}; // application requires protected path to external sink
@@ -996,9 +997,7 @@
// This layer can be a cursor on some displays.
bool mPotentialCursor{false};
- // Child list about to be committed/used for editing.
- LayerVector mCurrentChildren{LayerVector::StateSet::Current};
- // Child list used for rendering.
+ LayerVector mCurrentChildren{LayerVector::StateSet::Drawing};
LayerVector mDrawingChildren{LayerVector::StateSet::Drawing};
wp<Layer> mCurrentParent;
@@ -1022,7 +1021,7 @@
// Used in buffer stuffing analysis in FrameTimeline.
nsecs_t mLastLatchTime = 0;
- mutable bool mCurrentStateModified = false;
+ mutable bool mDrawingStateModified = false;
private:
virtual void setTransformHint(ui::Transform::RotationFlags) {}
diff --git a/services/surfaceflinger/LayerVector.cpp b/services/surfaceflinger/LayerVector.cpp
index 9b94920..aee820a 100644
--- a/services/surfaceflinger/LayerVector.cpp
+++ b/services/surfaceflinger/LayerVector.cpp
@@ -42,10 +42,8 @@
const auto& l = *reinterpret_cast<const sp<Layer>*>(lhs);
const auto& r = *reinterpret_cast<const sp<Layer>*>(rhs);
- const auto& lState =
- (mStateSet == StateSet::Current) ? l->getCurrentState() : l->getDrawingState();
- const auto& rState =
- (mStateSet == StateSet::Current) ? r->getCurrentState() : r->getDrawingState();
+ const auto& lState = l->getDrawingState();
+ const auto& rState = r->getDrawingState();
uint32_t ls = lState.layerStack;
uint32_t rs = rState.layerStack;
@@ -66,8 +64,7 @@
void LayerVector::traverseInZOrder(StateSet stateSet, const Visitor& visitor) const {
for (size_t i = 0; i < size(); i++) {
const auto& layer = (*this)[i];
- auto& state = (stateSet == StateSet::Current) ? layer->getCurrentState()
- : layer->getDrawingState();
+ auto& state = layer->getDrawingState();
if (state.isRelativeOf) {
continue;
}
@@ -78,8 +75,7 @@
void LayerVector::traverseInReverseZOrder(StateSet stateSet, const Visitor& visitor) const {
for (auto i = static_cast<int64_t>(size()) - 1; i >= 0; i--) {
const auto& layer = (*this)[i];
- auto& state = (stateSet == StateSet::Current) ? layer->getCurrentState()
- : layer->getDrawingState();
+ auto& state = layer->getDrawingState();
if (state.isRelativeOf) {
continue;
}
diff --git a/services/surfaceflinger/RefreshRateOverlay.cpp b/services/surfaceflinger/RefreshRateOverlay.cpp
index a9fd16c..663e62a 100644
--- a/services/surfaceflinger/RefreshRateOverlay.cpp
+++ b/services/surfaceflinger/RefreshRateOverlay.cpp
@@ -199,10 +199,10 @@
mLayer->setFrameRate(Layer::FrameRate(Fps(0.0f), Layer::FrameRateCompatibility::NoVote));
// setting Layer's Z requires resorting layersSortedByZ
- ssize_t idx = mFlinger.mCurrentState.layersSortedByZ.indexOf(mLayer);
+ ssize_t idx = mFlinger.mDrawingState.layersSortedByZ.indexOf(mLayer);
if (mLayer->setLayer(INT32_MAX - 2) && idx >= 0) {
- mFlinger.mCurrentState.layersSortedByZ.removeAt(idx);
- mFlinger.mCurrentState.layersSortedByZ.add(mLayer);
+ mFlinger.mDrawingState.layersSortedByZ.removeAt(idx);
+ mFlinger.mDrawingState.layersSortedByZ.add(mLayer);
}
return true;
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index e7187b1..317b4f6 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -3200,6 +3200,7 @@
}
void SurfaceFlinger::commitTransaction() {
+ ATRACE_CALL();
commitTransactionLocked();
signalSynchronousTransactions(CountDownLatch::eSyncTransaction);
mAnimTransactionPending = false;
@@ -6050,12 +6051,12 @@
}
if (!canCaptureBlackoutContent &&
- parent->getCurrentState().flags & layer_state_t::eLayerSecure) {
+ parent->getDrawingState().flags & layer_state_t::eLayerSecure) {
ALOGW("Attempting to capture secure layer: PERMISSION_DENIED");
return PERMISSION_DENIED;
}
- Rect parentSourceBounds = parent->getCroppedBufferSize(parent->getCurrentState());
+ Rect parentSourceBounds = parent->getCroppedBufferSize(parent->getDrawingState());
if (args.sourceCrop.width() <= 0) {
crop.left = 0;
crop.right = parentSourceBounds.getWidth();
@@ -6294,7 +6295,7 @@
Region clearRegion = Region::INVALID_REGION;
bool disableBlurs = false;
traverseLayers([&](Layer* layer) {
- disableBlurs |= layer->getCurrentState().sidebandStream != nullptr;
+ disableBlurs |= layer->getDrawingState().sidebandStream != nullptr;
Region clip(renderArea.getBounds());
compositionengine::LayerFE::ClientCompositionTargetSettings targetSettings{
diff --git a/services/surfaceflinger/SurfaceInterceptor.cpp b/services/surfaceflinger/SurfaceInterceptor.cpp
index c5f1598..8ca241e 100644
--- a/services/surfaceflinger/SurfaceInterceptor.cpp
+++ b/services/surfaceflinger/SurfaceInterceptor.cpp
@@ -130,25 +130,25 @@
transaction->set_animation(layerFlags & BnSurfaceComposer::eAnimation);
const int32_t layerId(getLayerId(layer));
- addPositionLocked(transaction, layerId, layer->mCurrentState.transform.tx(),
- layer->mCurrentState.transform.ty());
- addDepthLocked(transaction, layerId, layer->mCurrentState.z);
- addAlphaLocked(transaction, layerId, layer->mCurrentState.color.a);
+ addPositionLocked(transaction, layerId, layer->mDrawingState.transform.tx(),
+ layer->mDrawingState.transform.ty());
+ addDepthLocked(transaction, layerId, layer->mDrawingState.z);
+ addAlphaLocked(transaction, layerId, layer->mDrawingState.color.a);
addTransparentRegionLocked(transaction, layerId,
- layer->mCurrentState.activeTransparentRegion_legacy);
- addLayerStackLocked(transaction, layerId, layer->mCurrentState.layerStack);
- addCropLocked(transaction, layerId, layer->mCurrentState.crop);
- addCornerRadiusLocked(transaction, layerId, layer->mCurrentState.cornerRadius);
- addBackgroundBlurRadiusLocked(transaction, layerId, layer->mCurrentState.backgroundBlurRadius);
- addBlurRegionsLocked(transaction, layerId, layer->mCurrentState.blurRegions);
- addFlagsLocked(transaction, layerId, layer->mCurrentState.flags,
+ layer->mDrawingState.activeTransparentRegion_legacy);
+ addLayerStackLocked(transaction, layerId, layer->mDrawingState.layerStack);
+ addCropLocked(transaction, layerId, layer->mDrawingState.crop);
+ addCornerRadiusLocked(transaction, layerId, layer->mDrawingState.cornerRadius);
+ addBackgroundBlurRadiusLocked(transaction, layerId, layer->mDrawingState.backgroundBlurRadius);
+ addBlurRegionsLocked(transaction, layerId, layer->mDrawingState.blurRegions);
+ addFlagsLocked(transaction, layerId, layer->mDrawingState.flags,
layer_state_t::eLayerHidden | layer_state_t::eLayerOpaque |
layer_state_t::eLayerSecure);
- addReparentLocked(transaction, layerId, getLayerIdFromWeakRef(layer->mCurrentParent));
+ addReparentLocked(transaction, layerId, getLayerIdFromWeakRef(layer->mDrawingParent));
addRelativeParentLocked(transaction, layerId,
- getLayerIdFromWeakRef(layer->mCurrentState.zOrderRelativeOf),
- layer->mCurrentState.z);
- addShadowRadiusLocked(transaction, layerId, layer->mCurrentState.shadowRadius);
+ getLayerIdFromWeakRef(layer->mDrawingState.zOrderRelativeOf),
+ layer->mDrawingState.z);
+ addShadowRadiusLocked(transaction, layerId, layer->mDrawingState.shadowRadius);
}
void SurfaceInterceptor::addInitialDisplayStateLocked(Increment* increment,
@@ -511,8 +511,8 @@
SurfaceCreation* creation(increment->mutable_surface_creation());
creation->set_id(getLayerId(layer));
creation->set_name(layer->getName());
- creation->set_w(layer->mCurrentState.active_legacy.w);
- creation->set_h(layer->mCurrentState.active_legacy.h);
+ creation->set_w(layer->mDrawingState.active_legacy.w);
+ creation->set_h(layer->mDrawingState.active_legacy.h);
}
void SurfaceInterceptor::addSurfaceDeletionLocked(Increment* increment,
diff --git a/services/surfaceflinger/TunnelModeEnabledReporter.cpp b/services/surfaceflinger/TunnelModeEnabledReporter.cpp
index 1b3ddf7..48e3216 100644
--- a/services/surfaceflinger/TunnelModeEnabledReporter.cpp
+++ b/services/surfaceflinger/TunnelModeEnabledReporter.cpp
@@ -31,8 +31,8 @@
void TunnelModeEnabledReporter::updateTunnelModeStatus() {
bool tunnelModeEnabled = false;
mFlinger.mCurrentState.traverse([&](Layer* layer) {
- auto& currentState = layer->getCurrentState();
- if (currentState.sidebandStream != nullptr) {
+ auto& state = layer->getDrawingState();
+ if (state.sidebandStream != nullptr) {
tunnelModeEnabled = true;
return;
}
diff --git a/services/surfaceflinger/tests/unittests/RefreshRateSelectionTest.cpp b/services/surfaceflinger/tests/unittests/RefreshRateSelectionTest.cpp
index fd3e564..35033ea 100644
--- a/services/surfaceflinger/tests/unittests/RefreshRateSelectionTest.cpp
+++ b/services/surfaceflinger/tests/unittests/RefreshRateSelectionTest.cpp
@@ -116,7 +116,7 @@
}
void RefreshRateSelectionTest::commitTransaction(Layer* layer) {
- auto c = layer->getCurrentState();
+ auto c = layer->getDrawingState();
layer->commitTransaction(c);
}
diff --git a/services/surfaceflinger/tests/unittests/SetFrameRateTest.cpp b/services/surfaceflinger/tests/unittests/SetFrameRateTest.cpp
index 46ef750..1ed52ea 100644
--- a/services/surfaceflinger/tests/unittests/SetFrameRateTest.cpp
+++ b/services/surfaceflinger/tests/unittests/SetFrameRateTest.cpp
@@ -152,7 +152,7 @@
void SetFrameRateTest::commitTransaction() {
for (auto layer : mLayers) {
- auto c = layer->getCurrentState();
+ auto c = layer->getDrawingState();
layer->commitTransaction(c);
}
}
diff --git a/services/surfaceflinger/tests/unittests/SurfaceFlinger_DestroyDisplayTest.cpp b/services/surfaceflinger/tests/unittests/SurfaceFlinger_DestroyDisplayTest.cpp
index 0614434..e2be074 100644
--- a/services/surfaceflinger/tests/unittests/SurfaceFlinger_DestroyDisplayTest.cpp
+++ b/services/surfaceflinger/tests/unittests/SurfaceFlinger_DestroyDisplayTest.cpp
@@ -74,4 +74,4 @@
}
} // namespace
-} // namespace android
\ No newline at end of file
+} // namespace android
diff --git a/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h b/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h
index b363146..7f6e05e 100644
--- a/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h
+++ b/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h
@@ -259,7 +259,6 @@
memcpy(&mFlinger->mInternalDisplayPrimaries, &primaries, sizeof(ui::DisplayPrimaries));
}
- static auto& mutableLayerCurrentState(const sp<Layer>& layer) { return layer->mCurrentState; }
static auto& mutableLayerDrawingState(const sp<Layer>& layer) { return layer->mDrawingState; }
auto& mutableStateLock() { return mFlinger->mStateLock; }
@@ -272,7 +271,6 @@
static void setLayerSidebandStream(const sp<Layer>& layer,
const sp<NativeHandle>& sidebandStream) {
layer->mDrawingState.sidebandStream = sidebandStream;
- layer->mCurrentState.sidebandStream = sidebandStream;
layer->mSidebandStream = sidebandStream;
layer->editCompositionState()->sidebandStream = sidebandStream;
}
diff --git a/services/surfaceflinger/tests/unittests/TransactionFrameTracerTest.cpp b/services/surfaceflinger/tests/unittests/TransactionFrameTracerTest.cpp
index 546bc4a..2845d0a 100644
--- a/services/surfaceflinger/tests/unittests/TransactionFrameTracerTest.cpp
+++ b/services/surfaceflinger/tests/unittests/TransactionFrameTracerTest.cpp
@@ -62,7 +62,7 @@
}
void commitTransaction(Layer* layer) {
- auto c = layer->getCurrentState();
+ auto c = layer->getDrawingState();
layer->commitTransaction(c);
}
diff --git a/services/surfaceflinger/tests/unittests/TransactionSurfaceFrameTest.cpp b/services/surfaceflinger/tests/unittests/TransactionSurfaceFrameTest.cpp
index c1123cd..7bf224d 100644
--- a/services/surfaceflinger/tests/unittests/TransactionSurfaceFrameTest.cpp
+++ b/services/surfaceflinger/tests/unittests/TransactionSurfaceFrameTest.cpp
@@ -62,7 +62,7 @@
}
void commitTransaction(Layer* layer) {
- auto c = layer->getCurrentState();
+ auto c = layer->getDrawingState();
layer->commitTransaction(c);
}
@@ -101,9 +101,9 @@
sp<BufferStateLayer> layer = createBufferStateLayer();
layer->setFrameTimelineVsyncForBufferlessTransaction({/*vsyncId*/ 1, /*inputEventId*/ 0},
10);
- EXPECT_EQ(1u, layer->mCurrentState.bufferlessSurfaceFramesTX.size());
- ASSERT_TRUE(layer->mCurrentState.bufferSurfaceFrameTX == nullptr);
- const auto surfaceFrame = layer->mCurrentState.bufferlessSurfaceFramesTX.at(/*token*/ 1);
+ EXPECT_EQ(1u, layer->mDrawingState.bufferlessSurfaceFramesTX.size());
+ ASSERT_TRUE(layer->mDrawingState.bufferSurfaceFrameTX == nullptr);
+ const auto surfaceFrame = layer->mDrawingState.bufferlessSurfaceFramesTX.at(/*token*/ 1);
commitTransaction(layer.get());
EXPECT_EQ(1, surfaceFrame->getToken());
EXPECT_EQ(false, surfaceFrame->getIsBuffer());
@@ -123,9 +123,9 @@
acquireFence->signalForTest(12);
commitTransaction(layer.get());
- EXPECT_EQ(0u, layer->mCurrentState.bufferlessSurfaceFramesTX.size());
- ASSERT_NE(nullptr, layer->mCurrentState.bufferSurfaceFrameTX);
- const auto& surfaceFrame = layer->mCurrentState.bufferSurfaceFrameTX;
+ EXPECT_EQ(0u, layer->mDrawingState.bufferlessSurfaceFramesTX.size());
+ ASSERT_NE(nullptr, layer->mDrawingState.bufferSurfaceFrameTX);
+ const auto surfaceFrame = layer->mDrawingState.bufferSurfaceFrameTX;
// Buffers are presented only at latch time.
EXPECT_EQ(PresentState::Unknown, surfaceFrame->getPresentState());
@@ -148,9 +148,9 @@
mRenderEngine, false);
layer->setBuffer(buffer1, fence1, 10, 20, false, mClientCache, 1, std::nullopt,
{/*vsyncId*/ 1, /*inputEventId*/ 0}, nullptr /* releaseBufferCallback */);
- EXPECT_EQ(0u, layer->mCurrentState.bufferlessSurfaceFramesTX.size());
- ASSERT_NE(nullptr, layer->mCurrentState.bufferSurfaceFrameTX);
- const auto droppedSurfaceFrame = layer->mCurrentState.bufferSurfaceFrameTX;
+ EXPECT_EQ(0u, layer->mDrawingState.bufferlessSurfaceFramesTX.size());
+ ASSERT_NE(nullptr, layer->mDrawingState.bufferSurfaceFrameTX);
+ const auto droppedSurfaceFrame = layer->mDrawingState.bufferSurfaceFrameTX;
sp<Fence> fence2(new Fence());
auto acquireFence2 = fenceFactory.createFenceTimeForTest(fence2);
@@ -164,9 +164,9 @@
nsecs_t end = systemTime();
acquireFence2->signalForTest(12);
- EXPECT_EQ(0u, layer->mCurrentState.bufferlessSurfaceFramesTX.size());
- ASSERT_NE(nullptr, layer->mCurrentState.bufferSurfaceFrameTX);
- const auto& presentedSurfaceFrame = layer->mCurrentState.bufferSurfaceFrameTX;
+ EXPECT_EQ(0u, layer->mDrawingState.bufferlessSurfaceFramesTX.size());
+ ASSERT_NE(nullptr, layer->mDrawingState.bufferSurfaceFrameTX);
+ const auto presentedSurfaceFrame = layer->mDrawingState.bufferSurfaceFrameTX;
commitTransaction(layer.get());
bool computeVisisbleRegions;
@@ -190,8 +190,8 @@
layer->setFrameTimelineVsyncForBufferlessTransaction({/*vsyncId*/ 1, /*inputEventId*/ 0},
10);
- EXPECT_EQ(1u, layer->mCurrentState.bufferlessSurfaceFramesTX.size());
- ASSERT_EQ(nullptr, layer->mCurrentState.bufferSurfaceFrameTX);
+ EXPECT_EQ(1u, layer->mDrawingState.bufferlessSurfaceFramesTX.size());
+ ASSERT_EQ(nullptr, layer->mDrawingState.bufferSurfaceFrameTX);
sp<Fence> fence(new Fence());
auto acquireFence = fenceFactory.createFenceTimeForTest(fence);
@@ -203,9 +203,9 @@
{/*vsyncId*/ 1, /*inputEventId*/ 0}, nullptr /* releaseBufferCallback */);
acquireFence->signalForTest(12);
- EXPECT_EQ(0u, layer->mCurrentState.bufferlessSurfaceFramesTX.size());
- ASSERT_NE(nullptr, layer->mCurrentState.bufferSurfaceFrameTX);
- const auto& surfaceFrame = layer->mCurrentState.bufferSurfaceFrameTX;
+ EXPECT_EQ(0u, layer->mDrawingState.bufferlessSurfaceFramesTX.size());
+ ASSERT_NE(nullptr, layer->mDrawingState.bufferSurfaceFrameTX);
+ const auto surfaceFrame = layer->mDrawingState.bufferSurfaceFrameTX;
commitTransaction(layer.get());
EXPECT_EQ(1, surfaceFrame->getToken());
@@ -229,29 +229,29 @@
mRenderEngine, false);
layer->setBuffer(buffer, fence, 10, 20, false, mClientCache, 1, std::nullopt,
{/*vsyncId*/ 1, /*inputEventId*/ 0}, nullptr /* releaseBufferCallback */);
- EXPECT_EQ(0u, layer->mCurrentState.bufferlessSurfaceFramesTX.size());
- ASSERT_NE(nullptr, layer->mCurrentState.bufferSurfaceFrameTX);
+ EXPECT_EQ(0u, layer->mDrawingState.bufferlessSurfaceFramesTX.size());
+ ASSERT_NE(nullptr, layer->mDrawingState.bufferSurfaceFrameTX);
layer->setFrameTimelineVsyncForBufferlessTransaction({/*vsyncId*/ 1, /*inputEventId*/ 0},
10);
- EXPECT_EQ(0u, layer->mCurrentState.bufferlessSurfaceFramesTX.size());
- ASSERT_NE(nullptr, layer->mCurrentState.bufferSurfaceFrameTX);
+ EXPECT_EQ(0u, layer->mDrawingState.bufferlessSurfaceFramesTX.size());
+ ASSERT_NE(nullptr, layer->mDrawingState.bufferSurfaceFrameTX);
}
void MultipleSurfaceFramesPresentedTogether() {
sp<BufferStateLayer> layer = createBufferStateLayer();
layer->setFrameTimelineVsyncForBufferlessTransaction({/*vsyncId*/ 1, /*inputEventId*/ 0},
10);
- EXPECT_EQ(1u, layer->mCurrentState.bufferlessSurfaceFramesTX.size());
- ASSERT_EQ(nullptr, layer->mCurrentState.bufferSurfaceFrameTX);
+ EXPECT_EQ(1u, layer->mDrawingState.bufferlessSurfaceFramesTX.size());
+ ASSERT_EQ(nullptr, layer->mDrawingState.bufferSurfaceFrameTX);
const auto bufferlessSurfaceFrame1 =
- layer->mCurrentState.bufferlessSurfaceFramesTX.at(/*token*/ 1);
+ layer->mDrawingState.bufferlessSurfaceFramesTX.at(/*token*/ 1);
layer->setFrameTimelineVsyncForBufferlessTransaction({/*vsyncId*/ 4, /*inputEventId*/ 0},
10);
- EXPECT_EQ(2u, layer->mCurrentState.bufferlessSurfaceFramesTX.size());
- ASSERT_EQ(nullptr, layer->mCurrentState.bufferSurfaceFrameTX);
- const auto bufferlessSurfaceFrame2 = layer->mCurrentState.bufferlessSurfaceFramesTX[4];
+ EXPECT_EQ(2u, layer->mDrawingState.bufferlessSurfaceFramesTX.size());
+ ASSERT_EQ(nullptr, layer->mDrawingState.bufferSurfaceFrameTX);
+ const auto bufferlessSurfaceFrame2 = layer->mDrawingState.bufferlessSurfaceFramesTX[4];
sp<Fence> fence(new Fence());
auto acquireFence = fenceFactory.createFenceTimeForTest(fence);
@@ -261,9 +261,9 @@
mRenderEngine, false);
layer->setBuffer(buffer, fence, 10, 20, false, mClientCache, 1, std::nullopt,
{/*vsyncId*/ 3, /*inputEventId*/ 0}, nullptr /* releaseBufferCallback */);
- EXPECT_EQ(2u, layer->mCurrentState.bufferlessSurfaceFramesTX.size());
- ASSERT_NE(nullptr, layer->mCurrentState.bufferSurfaceFrameTX);
- const auto& bufferSurfaceFrameTX = layer->mCurrentState.bufferSurfaceFrameTX;
+ EXPECT_EQ(2u, layer->mDrawingState.bufferlessSurfaceFramesTX.size());
+ ASSERT_NE(nullptr, layer->mDrawingState.bufferSurfaceFrameTX);
+ const auto bufferSurfaceFrameTX = layer->mDrawingState.bufferSurfaceFrameTX;
acquireFence->signalForTest(12);
@@ -299,8 +299,8 @@
mRenderEngine, false);
layer->setBuffer(buffer1, fence1, 10, 20, false, mClientCache, 1, std::nullopt,
{/*vsyncId*/ 1, /*inputEventId*/ 0}, nullptr /* releaseBufferCallback */);
- ASSERT_NE(nullptr, layer->mCurrentState.bufferSurfaceFrameTX);
- const auto droppedSurfaceFrame = layer->mCurrentState.bufferSurfaceFrameTX;
+ ASSERT_NE(nullptr, layer->mDrawingState.bufferSurfaceFrameTX);
+ const auto droppedSurfaceFrame = layer->mDrawingState.bufferSurfaceFrameTX;
sp<Fence> fence2(new Fence());
auto acquireFence2 = fenceFactory.createFenceTimeForTest(fence2);
@@ -312,8 +312,8 @@
{/*vsyncId*/ 1, /*inputEventId*/ 0}, nullptr /* releaseBufferCallback */);
acquireFence2->signalForTest(12);
- ASSERT_NE(nullptr, layer->mCurrentState.bufferSurfaceFrameTX);
- auto& presentedSurfaceFrame = layer->mCurrentState.bufferSurfaceFrameTX;
+ ASSERT_NE(nullptr, layer->mDrawingState.bufferSurfaceFrameTX);
+ auto presentedSurfaceFrame = layer->mDrawingState.bufferSurfaceFrameTX;
commitTransaction(layer.get());
bool computeVisisbleRegions;
@@ -340,9 +340,9 @@
mRenderEngine, false);
layer->setBuffer(buffer1, fence1, 10, 20, false, mClientCache, 1, std::nullopt,
{/*vsyncId*/ 1, /*inputEventId*/ 0}, nullptr /* releaseBufferCallback */);
- EXPECT_EQ(0u, layer->mCurrentState.bufferlessSurfaceFramesTX.size());
- ASSERT_NE(nullptr, layer->mCurrentState.bufferSurfaceFrameTX);
- const auto droppedSurfaceFrame1 = layer->mCurrentState.bufferSurfaceFrameTX;
+ EXPECT_EQ(0u, layer->mDrawingState.bufferlessSurfaceFramesTX.size());
+ ASSERT_NE(nullptr, layer->mDrawingState.bufferSurfaceFrameTX);
+ const auto droppedSurfaceFrame1 = layer->mDrawingState.bufferSurfaceFrameTX;
sp<Fence> fence2(new Fence());
auto acquireFence2 = fenceFactory.createFenceTimeForTest(fence2);
@@ -355,9 +355,9 @@
{/*vsyncId*/ FrameTimelineInfo::INVALID_VSYNC_ID, /*inputEventId*/ 0},
nullptr /* releaseBufferCallback */);
auto dropEndTime1 = systemTime();
- EXPECT_EQ(0u, layer->mCurrentState.bufferlessSurfaceFramesTX.size());
- ASSERT_NE(nullptr, layer->mCurrentState.bufferSurfaceFrameTX);
- const auto droppedSurfaceFrame2 = layer->mCurrentState.bufferSurfaceFrameTX;
+ EXPECT_EQ(0u, layer->mDrawingState.bufferlessSurfaceFramesTX.size());
+ ASSERT_NE(nullptr, layer->mDrawingState.bufferSurfaceFrameTX);
+ const auto droppedSurfaceFrame2 = layer->mDrawingState.bufferSurfaceFrameTX;
sp<Fence> fence3(new Fence());
auto acquireFence3 = fenceFactory.createFenceTimeForTest(fence3);
@@ -371,9 +371,9 @@
auto dropEndTime2 = systemTime();
acquireFence3->signalForTest(12);
- EXPECT_EQ(0u, layer->mCurrentState.bufferlessSurfaceFramesTX.size());
- ASSERT_NE(nullptr, layer->mCurrentState.bufferSurfaceFrameTX);
- const auto& presentedSurfaceFrame = layer->mCurrentState.bufferSurfaceFrameTX;
+ EXPECT_EQ(0u, layer->mDrawingState.bufferlessSurfaceFramesTX.size());
+ ASSERT_NE(nullptr, layer->mDrawingState.bufferSurfaceFrameTX);
+ const auto presentedSurfaceFrame = layer->mDrawingState.bufferSurfaceFrameTX;
commitTransaction(layer.get());
bool computeVisisbleRegions;
@@ -415,10 +415,10 @@
layer->setFrameTimelineVsyncForBufferlessTransaction({/*vsyncId*/ 2,
/*inputEventId*/ 0},
10);
- ASSERT_NE(nullptr, layer->mCurrentState.bufferSurfaceFrameTX);
- EXPECT_EQ(1u, layer->mCurrentState.bufferlessSurfaceFramesTX.size());
+ ASSERT_NE(nullptr, layer->mDrawingState.bufferSurfaceFrameTX);
+ EXPECT_EQ(1u, layer->mDrawingState.bufferlessSurfaceFramesTX.size());
auto& bufferlessSurfaceFrame =
- layer->mCurrentState.bufferlessSurfaceFramesTX.at(/*vsyncId*/ 2);
+ layer->mDrawingState.bufferlessSurfaceFramesTX.at(/*vsyncId*/ 2);
bufferlessSurfaceFrames.push_back(bufferlessSurfaceFrame);
commitTransaction(layer.get());