Add CachingHint into SurfaceFlinger
Some system layers may need to be excluded from surfaceflinger caching
for a variety of reasons, including power or image quality
considerations. This provides a mechanism for those system layers to
never be cached on the GPU.
Bug: 259311918
Test: libcompositionengine_test
Test: run test app and inspect planner state
Change-Id: I35418ad5a41cb2546e3b27b0af290bf3c31a0180
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 084d9b9..dac0916 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -566,6 +566,7 @@
: Hwc2::IComposerClient::BlendMode::COVERAGE;
}
+ // Please keep in sync with LayerSnapshotBuilder
auto* snapshot = editLayerSnapshot();
snapshot->outputFilter = getOutputFilter();
snapshot->isVisible = isVisible();
@@ -592,6 +593,7 @@
const auto& drawingState{getDrawingState()};
auto* snapshot = editLayerSnapshot();
+ // Please keep in sync with LayerSnapshotBuilder
snapshot->geomBufferSize = getBufferSize(drawingState);
snapshot->geomContentCrop = getBufferCrop();
snapshot->geomCrop = getCrop(drawingState);
@@ -624,6 +626,7 @@
void Layer::preparePerFrameCompositionState() {
const auto& drawingState{getDrawingState()};
+ // Please keep in sync with LayerSnapshotBuilder
auto* snapshot = editLayerSnapshot();
snapshot->forceClientComposition = false;
@@ -637,6 +640,7 @@
snapshot->dimmingEnabled = isDimmingEnabled();
snapshot->currentSdrHdrRatio = getCurrentSdrHdrRatio();
snapshot->desiredSdrHdrRatio = getDesiredSdrHdrRatio();
+ snapshot->cachingHint = getCachingHint();
const bool usesRoundedCorners = hasRoundedCorners();
@@ -666,8 +670,9 @@
}
void Layer::preparePerFrameBufferCompositionState() {
- // Sideband layers
+ // Please keep in sync with LayerSnapshotBuilder
auto* snapshot = editLayerSnapshot();
+ // Sideband layers
if (snapshot->sidebandStream.get() && !snapshot->sidebandStreamHasFrame) {
snapshot->compositionType =
aidl::android::hardware::graphics::composer3::Composition::SIDEBAND;
@@ -690,6 +695,7 @@
}
void Layer::preparePerFrameEffectsCompositionState() {
+ // Please keep in sync with LayerSnapshotBuilder
auto* snapshot = editLayerSnapshot();
snapshot->color = getColor();
snapshot->compositionType =
@@ -698,6 +704,7 @@
void Layer::prepareCursorCompositionState() {
const State& drawingState{getDrawingState()};
+ // Please keep in sync with LayerSnapshotBuilder
auto* snapshot = editLayerSnapshot();
// Apply the layer's transform, followed by the display's global transform
@@ -3091,6 +3098,14 @@
return true;
}
+bool Layer::setCachingHint(gui::CachingHint cachingHint) {
+ if (mDrawingState.cachingHint == cachingHint) return false;
+ mDrawingState.cachingHint = cachingHint;
+ mDrawingState.modified = true;
+ setTransactionFlags(eTransactionNeeded);
+ return true;
+}
+
bool Layer::setHdrMetadata(const HdrMetadata& hdrMetadata) {
if (mDrawingState.hdrMetadata == hdrMetadata) return false;
mDrawingState.hdrMetadata = hdrMetadata;