Combining background color related transactions/functions
Bug:122326454
Test: build, boot, SurfaceFlinger_test, ASurfaceControlTest cts test
Change-Id: I7ec9f2214c7422ab90ab56dd84daafd5b0bf720a
diff --git a/libs/gui/LayerState.cpp b/libs/gui/LayerState.cpp
index 6091d3f..206bc30 100644
--- a/libs/gui/LayerState.cpp
+++ b/libs/gui/LayerState.cpp
@@ -98,8 +98,8 @@
output.writeInt32(cachedBuffer.bufferId);
output.writeParcelable(metadata);
- output.writeFloat(colorAlpha);
- output.writeUint32(static_cast<uint32_t>(colorDataspace));
+ output.writeFloat(bgColorAlpha);
+ output.writeUint32(static_cast<uint32_t>(bgColorDataspace));
return NO_ERROR;
}
@@ -175,8 +175,8 @@
cachedBuffer.bufferId = input.readInt32();
input.readParcelable(&metadata);
- colorAlpha = input.readFloat();
- colorDataspace = static_cast<ui::Dataspace>(input.readUint32());
+ bgColorAlpha = input.readFloat();
+ bgColorDataspace = static_cast<ui::Dataspace>(input.readUint32());
return NO_ERROR;
}
@@ -390,13 +390,11 @@
what |= eCachedBufferChanged;
cachedBuffer = other.cachedBuffer;
}
- if (other.what & eColorAlphaChanged) {
- what |= eColorAlphaChanged;
- colorAlpha = other.colorAlpha;
- }
- if (other.what & eColorDataspaceChanged) {
- what |= eColorDataspaceChanged;
- colorDataspace = other.colorDataspace;
+ if (other.what & eBackgroundColorChanged) {
+ what |= eBackgroundColorChanged;
+ color = other.color;
+ bgColorAlpha = other.bgColorAlpha;
+ bgColorDataspace = other.bgColorDataspace;
}
if (other.what & eMetadataChanged) {
what |= eMetadataChanged;
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index c712bde..51385b8 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -678,31 +678,18 @@
return *this;
}
-SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setColorAlpha(
- const sp<SurfaceControl>& sc, float alpha) {
+SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setBackgroundColor(
+ const sp<SurfaceControl>& sc, const half3& color, float alpha, ui::Dataspace dataspace) {
layer_state_t* s = getLayerState(sc);
if (!s) {
mStatus = BAD_INDEX;
return *this;
}
- s->what |= layer_state_t::eColorAlphaChanged;
- s->colorAlpha = alpha;
-
- registerSurfaceControlForCallback(sc);
- return *this;
-}
-
-SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setColorDataspace(
- const sp<SurfaceControl>& sc, ui::Dataspace dataspace) {
- layer_state_t* s = getLayerState(sc);
- if (!s) {
- mStatus = BAD_INDEX;
- return *this;
- }
-
- s->what |= layer_state_t::eColorDataspaceChanged;
- s->colorDataspace = dataspace;
+ s->what |= layer_state_t::eBackgroundColorChanged;
+ s->color = color;
+ s->bgColorAlpha = alpha;
+ s->bgColorDataspace = dataspace;
registerSurfaceControlForCallback(sc);
return *this;
diff --git a/libs/gui/include/gui/LayerState.h b/libs/gui/include/gui/LayerState.h
index afd843f..c780c07 100644
--- a/libs/gui/include/gui/LayerState.h
+++ b/libs/gui/include/gui/LayerState.h
@@ -86,9 +86,8 @@
eCornerRadiusChanged = 0x80000000,
eFrameChanged = 0x1'00000000,
eCachedBufferChanged = 0x2'00000000,
- eColorAlphaChanged = 0x4'00000000,
- eColorDataspaceChanged = 0x8'00000000,
- eMetadataChanged = 0x10'00000000,
+ eBackgroundColorChanged = 0x4'00000000,
+ eMetadataChanged = 0x8'00000000,
};
layer_state_t()
@@ -115,8 +114,8 @@
surfaceDamageRegion(),
api(-1),
colorTransform(mat4()),
- colorAlpha(0),
- colorDataspace(ui::Dataspace::UNKNOWN) {
+ bgColorAlpha(0),
+ bgColorDataspace(ui::Dataspace::UNKNOWN) {
matrix.dsdx = matrix.dtdy = 1.0f;
matrix.dsdy = matrix.dtdx = 0.0f;
hdrMetadata.validTypes = 0;
@@ -187,10 +186,12 @@
cached_buffer_t cachedBuffer;
- float colorAlpha;
- ui::Dataspace colorDataspace;
-
LayerMetadata metadata;
+
+ // The following refer to the alpha, and dataspace, respectively of
+ // the background color layer
+ float bgColorAlpha;
+ ui::Dataspace bgColorDataspace;
};
struct ComposerState {
diff --git a/libs/gui/include/gui/SurfaceComposerClient.h b/libs/gui/include/gui/SurfaceComposerClient.h
index 8e2bb2b..a95664b 100644
--- a/libs/gui/include/gui/SurfaceComposerClient.h
+++ b/libs/gui/include/gui/SurfaceComposerClient.h
@@ -330,11 +330,9 @@
Transaction& setColor(const sp<SurfaceControl>& sc, const half3& color);
- // Sets the alpha of the background color layer if it exists.
- Transaction& setColorAlpha(const sp<SurfaceControl>& sc, float alpha);
-
- // Sets the dataspace of the background color layer if it exists.
- Transaction& setColorDataspace(const sp<SurfaceControl>& sc, ui::Dataspace dataspace);
+ // Sets the background color of a layer with the specified color, alpha, and dataspace
+ Transaction& setBackgroundColor(const sp<SurfaceControl>& sc, const half3& color,
+ float alpha, ui::Dataspace dataspace);
Transaction& setTransform(const sp<SurfaceControl>& sc, uint32_t transform);
Transaction& setTransformToDisplayInverse(const sp<SurfaceControl>& sc,