Add Color Layer to ASurfaceControl
Bug:122326454
Test: atest CtsViewTestCases:android.view.cts.ASurfaceControlTests
Change-Id: Ib05ad70d838c79aa6f2e309217b93906c950b6fa
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index aa9bc15..ef77590 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -109,6 +109,7 @@
mCurrentState.cornerRadius = 0.0f;
mCurrentState.api = -1;
mCurrentState.hasColorTransform = false;
+ mCurrentState.colorDataspace = ui::Dataspace::UNKNOWN;
// drawing state & current state are identical
mDrawingState = mCurrentState;
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index 95a8630..0f83464 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -202,6 +202,8 @@
mat4 colorTransform;
bool hasColorTransform;
+ ui::Dataspace colorDataspace; // The dataspace of the background color layer
+
// The deque of callback handles for this frame. The back of the deque contains the most
// recent callback handle.
std::deque<sp<CallbackHandle>> callbackHandles;
@@ -308,6 +310,8 @@
const std::vector<sp<CallbackHandle>>& /*handles*/) {
return false;
};
+ virtual bool setColorAlpha(float /*alpha*/) { return false; };
+ virtual bool setColorDataspace(ui::Dataspace /*dataspace*/) { return false; };
ui::Dataspace getDataSpace() const { return mCurrentDataSpace; }
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 3f6298f..709b1ef 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -3828,6 +3828,12 @@
if (layer->setColor(s.color))
flags |= eTraversalNeeded;
}
+ if (what & layer_state_t::eColorAlphaChanged) {
+ if (layer->setColorAlpha(s.colorAlpha)) flags |= eTraversalNeeded;
+ }
+ if (what & layer_state_t::eColorDataspaceChanged) {
+ if (layer->setColorDataspace(s.colorDataspace)) flags |= eTraversalNeeded;
+ }
if (what & layer_state_t::eColorTransformChanged) {
if (layer->setColorTransform(s.colorTransform)) {
flags |= eTraversalNeeded;