diff options
| author | 2019-10-29 13:19:27 -0700 | |
|---|---|---|
| committer | 2019-10-29 16:12:29 -0700 | |
| commit | 46b72df7d5064ecb90240210a7bf932af35e259d (patch) | |
| tree | b31a7071e3ed0a73c694c9cd3824b9f7761538f8 | |
| parent | bd080d602b73df4fb4ae15894171c244ad2e35d3 (diff) | |
CE: Fix color layer HWC call ordering
Always set the layer color value after setting the composition type to
SOLID_COLOR.
The unit test is modified to enforce this order.
Bug: 143078872
Bug: 143242857
Bug: 139761656
Test: atest libcompositionengine_test
Test: Observed no one frame flicker issues on rotation per the bugs
Test: go/wm-smoke
Change-Id: I27e880b06c16e4ce23004fccea6e9fa73449d54b
| -rw-r--r-- | services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp | 9 | ||||
| -rw-r--r-- | services/surfaceflinger/CompositionEngine/tests/OutputLayerTest.cpp | 8 |
2 files changed, 15 insertions, 2 deletions
diff --git a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp index 721e953d25..ce0222cee5 100644 --- a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp +++ b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp @@ -326,6 +326,9 @@ void OutputLayer::writeStateToHWC(bool includeGeometry) { writeOutputIndependentPerFrameStateToHWC(hwcLayer.get(), outputIndependentState); writeCompositionTypeToHWC(hwcLayer.get(), requestedCompositionType); + + // Always set the layer color after setting the composition type. + writeSolidColorStateToHWC(hwcLayer.get(), outputIndependentState); } void OutputLayer::writeOutputDependentGeometryStateToHWC( @@ -435,7 +438,7 @@ void OutputLayer::writeOutputIndependentPerFrameStateToHWC( // Content-specific per-frame state switch (outputIndependentState.compositionType) { case Hwc2::IComposerClient::Composition::SOLID_COLOR: - writeSolidColorStateToHWC(hwcLayer, outputIndependentState); + // For compatibility, should be written AFTER the composition type. break; case Hwc2::IComposerClient::Composition::SIDEBAND: writeSidebandStateToHWC(hwcLayer, outputIndependentState); @@ -453,6 +456,10 @@ void OutputLayer::writeOutputIndependentPerFrameStateToHWC( void OutputLayer::writeSolidColorStateToHWC(HWC2::Layer* hwcLayer, const LayerFECompositionState& outputIndependentState) { + if (outputIndependentState.compositionType != Hwc2::IComposerClient::Composition::SOLID_COLOR) { + return; + } + hwc_color_t color = {static_cast<uint8_t>(std::round(255.0f * outputIndependentState.color.r)), static_cast<uint8_t>(std::round(255.0f * outputIndependentState.color.g)), static_cast<uint8_t>(std::round(255.0f * outputIndependentState.color.b)), diff --git a/services/surfaceflinger/CompositionEngine/tests/OutputLayerTest.cpp b/services/surfaceflinger/CompositionEngine/tests/OutputLayerTest.cpp index a33878448f..88acd04141 100644 --- a/services/surfaceflinger/CompositionEngine/tests/OutputLayerTest.cpp +++ b/services/surfaceflinger/CompositionEngine/tests/OutputLayerTest.cpp @@ -33,6 +33,7 @@ namespace android::compositionengine { namespace { using testing::_; +using testing::InSequence; using testing::Return; using testing::ReturnRef; using testing::StrictMock; @@ -769,8 +770,13 @@ TEST_F(OutputLayerWriteStateToHWCTest, canSetPerFrameStateForSolidColor) { mLayerFEState.compositionType = Hwc2::IComposerClient::Composition::SOLID_COLOR; expectPerFrameCommonCalls(); - expectSetColorCall(); + + // Setting the composition type should happen before setting the color. We + // check this in this test only by setting up an testing::InSeqeuence + // instance before setting up the two expectations. + InSequence s; expectSetCompositionTypeCall(Hwc2::IComposerClient::Composition::SOLID_COLOR); + expectSetColorCall(); mOutputLayer.writeStateToHWC(false); } |