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/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) {}