blast: update hasDrawingBuffer to hasFrameUpdate
hasFrameUpdate is a more accurate name than hasDrawingBuffer.
Also keep track of when the current state has been modified
and only return true for BufferStateLayer::hasFrameUpdate
when the state has been modified and the buffer is not null.
Test: Transaction_test
Bug: 80477568
Change-Id: Icec6cf62490799988bd967914986bf92a07ce726
diff --git a/services/surfaceflinger/BufferLayer.cpp b/services/surfaceflinger/BufferLayer.cpp
index 440f1e2..b35bd6c 100644
--- a/services/surfaceflinger/BufferLayer.cpp
+++ b/services/surfaceflinger/BufferLayer.cpp
@@ -522,7 +522,7 @@
}
bool BufferLayer::hasReadyFrame() const {
- return hasDrawingBuffer() || getSidebandStreamChanged() || getAutoRefresh();
+ return hasFrameUpdate() || getSidebandStreamChanged() || getAutoRefresh();
}
uint32_t BufferLayer::getEffectiveScalingMode() const {
@@ -660,7 +660,7 @@
}
uint64_t BufferLayer::getHeadFrameNumber() const {
- if (hasDrawingBuffer()) {
+ if (hasFrameUpdate()) {
return getFrameNumber();
} else {
return mCurrentFrameNumber;
diff --git a/services/surfaceflinger/BufferLayer.h b/services/surfaceflinger/BufferLayer.h
index d000d85..187b34f 100644
--- a/services/surfaceflinger/BufferLayer.h
+++ b/services/surfaceflinger/BufferLayer.h
@@ -134,7 +134,7 @@
virtual std::optional<Region> latchSidebandStream(bool& recomputeVisibleRegions) = 0;
- virtual bool hasDrawingBuffer() const = 0;
+ virtual bool hasFrameUpdate() const = 0;
virtual void setFilteringEnabled(bool enabled) = 0;
diff --git a/services/surfaceflinger/BufferQueueLayer.cpp b/services/surfaceflinger/BufferQueueLayer.cpp
index c130bc5..ef09fd7 100644
--- a/services/surfaceflinger/BufferQueueLayer.cpp
+++ b/services/surfaceflinger/BufferQueueLayer.cpp
@@ -82,7 +82,7 @@
return true;
}
- if (!hasDrawingBuffer()) {
+ if (!hasFrameUpdate()) {
return false;
}
@@ -110,7 +110,7 @@
return true;
}
- if (!hasDrawingBuffer()) {
+ if (!hasFrameUpdate()) {
return true;
}
@@ -206,7 +206,7 @@
return {};
}
-bool BufferQueueLayer::hasDrawingBuffer() const {
+bool BufferQueueLayer::hasFrameUpdate() const {
return mQueuedFrames > 0;
}
@@ -403,7 +403,7 @@
}
}
- if (!hasDrawingBuffer()) {
+ if (!hasFrameUpdate()) {
ALOGE("Can't replace a frame on an empty queue");
return;
}
diff --git a/services/surfaceflinger/BufferQueueLayer.h b/services/surfaceflinger/BufferQueueLayer.h
index c9ebe04..3b93191 100644
--- a/services/surfaceflinger/BufferQueueLayer.h
+++ b/services/surfaceflinger/BufferQueueLayer.h
@@ -83,7 +83,7 @@
std::optional<Region> latchSidebandStream(bool& recomputeVisibleRegions) override;
- bool hasDrawingBuffer() const override;
+ bool hasFrameUpdate() const override;
void setFilteringEnabled(bool enabled) override;
diff --git a/services/surfaceflinger/BufferStateLayer.cpp b/services/surfaceflinger/BufferStateLayer.cpp
index 73098bf..9edff21 100644
--- a/services/surfaceflinger/BufferStateLayer.cpp
+++ b/services/surfaceflinger/BufferStateLayer.cpp
@@ -61,7 +61,7 @@
return true;
}
- return hasDrawingBuffer();
+ return hasFrameUpdate();
}
bool BufferStateLayer::getTransformToDisplayInverse() const {
@@ -81,6 +81,7 @@
while (!mPendingStates.empty()) {
popPendingState(stateToCommit);
}
+ mCurrentStateModified = stateUpdateAvailable && mCurrentState.modified;
mCurrentState.modified = false;
return stateUpdateAvailable;
}
@@ -314,8 +315,8 @@
return {};
}
-bool BufferStateLayer::hasDrawingBuffer() const {
- return getDrawingState().buffer != nullptr;
+bool BufferStateLayer::hasFrameUpdate() const {
+ return mCurrentStateModified && getCurrentState().buffer != nullptr;
}
void BufferStateLayer::setFilteringEnabled(bool enabled) {
@@ -513,6 +514,7 @@
s.buffer->handle, to_string(error).c_str(), static_cast<int32_t>(error));
}
+ mCurrentStateModified = false;
mFrameNumber++;
}
diff --git a/services/surfaceflinger/BufferStateLayer.h b/services/surfaceflinger/BufferStateLayer.h
index 0c6eaf5..cf4d0f0 100644
--- a/services/surfaceflinger/BufferStateLayer.h
+++ b/services/surfaceflinger/BufferStateLayer.h
@@ -110,7 +110,7 @@
std::optional<Region> latchSidebandStream(bool& recomputeVisibleRegions) override;
- bool hasDrawingBuffer() const override;
+ bool hasFrameUpdate() const override;
void setFilteringEnabled(bool enabled) override;
@@ -136,6 +136,8 @@
uint32_t mFrameNumber{0};
+ bool mCurrentStateModified = false;
+
// TODO(marissaw): support sticky transform for LEGACY camera mode
};