diff options
| author | 2019-04-18 10:26:19 -0700 | |
|---|---|---|
| committer | 2019-04-18 10:26:19 -0700 | |
| commit | 04d2587f88121ceae6437f1f407308b0b0a83993 (patch) | |
| tree | 15f1a81f424784c3f78c3f2da71e096ed9bf6522 | |
| parent | aa45ab582dec1053a5be075cb95a77fcb67c8965 (diff) | |
[SurfaceFlinger] Use GPU composition for per layer color transform when necessary.
Previously we moved the fallback mechanism to composer@2.3 passthrough, as a
result composer before 2.3 can't trigger GPU composition. This patch help
proactively set the composition type to CLIENT on devices that don't upgrade to
composer@2.3.
BUG: 130621073
Test: Verify with customized grayscaled matrix.
Change-Id: I08e6a215872a62008deef708444245bd50807640
| -rw-r--r-- | services/surfaceflinger/BufferLayer.cpp | 5 | ||||
| -rw-r--r-- | services/surfaceflinger/DisplayHardware/HWC2.cpp | 8 |
2 files changed, 10 insertions, 3 deletions
diff --git a/services/surfaceflinger/BufferLayer.cpp b/services/surfaceflinger/BufferLayer.cpp index a08ae8c7e6..4ea587dbba 100644 --- a/services/surfaceflinger/BufferLayer.cpp +++ b/services/surfaceflinger/BufferLayer.cpp @@ -321,7 +321,10 @@ void BufferLayer::setPerFrameData(const sp<const DisplayDevice>& displayDevice, } error = hwcLayer->setColorTransform(getColorTransform()); - if (error != HWC2::Error::None) { + if (error == HWC2::Error::Unsupported) { + // If per layer color transform is not supported, we use GPU composition. + setCompositionType(displayDevice, Hwc2::IComposerClient::Composition::CLIENT); + } else if (error != HWC2::Error::None) { ALOGE("[%s] Failed to setColorTransform: %s (%d)", mName.string(), to_string(error).c_str(), static_cast<int32_t>(error)); } diff --git a/services/surfaceflinger/DisplayHardware/HWC2.cpp b/services/surfaceflinger/DisplayHardware/HWC2.cpp index 9690605b6f..3012ed8b16 100644 --- a/services/surfaceflinger/DisplayHardware/HWC2.cpp +++ b/services/surfaceflinger/DisplayHardware/HWC2.cpp @@ -1029,9 +1029,13 @@ Error Layer::setColorTransform(const android::mat4& matrix) { if (matrix == mColorMatrix) { return Error::None; } - mColorMatrix = matrix; auto intError = mComposer.setLayerColorTransform(mDisplayId, mId, matrix.asArray()); - return static_cast<Error>(intError); + Error error = static_cast<Error>(intError); + if (error != Error::None) { + return error; + } + mColorMatrix = matrix; + return error; } } // namespace impl |