summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Patrick Williams <pdwilliams@google.com> 2023-01-27 16:52:40 -0600
committer Patrick Williams <pdwilliams@google.com> 2023-01-31 11:20:24 -0600
commit278a88f603fbdbc46275dc67463b796a22e71353 (patch)
treea9cb05e2d3f73b09ff9b9978c90c07bea28e06b3
parent3fee9b9b32e599e6a71a43a5f6a6295c282649b1 (diff)
SF: clean up texture filtering logic
* Removes redundant logic for determining whether or not SurfaceFlinger should request texture filtering. * Fixes an issue where ScreenCaptureOutput was using incorrect values for its layer stack projection space. Bug: 238348307 Test: atest TextureFilteringTest Change-Id: I4ece87321ee73d10b86a2c01d53717d337c11926
-rw-r--r--services/surfaceflinger/CompositionEngine/include/compositionengine/impl/Output.h5
-rw-r--r--services/surfaceflinger/CompositionEngine/src/Output.cpp6
-rw-r--r--services/surfaceflinger/DisplayDevice.cpp4
-rw-r--r--services/surfaceflinger/DisplayDevice.h1
-rw-r--r--services/surfaceflinger/DisplayRenderArea.cpp30
-rw-r--r--services/surfaceflinger/DisplayRenderArea.h6
-rw-r--r--services/surfaceflinger/FrontEnd/LayerSnapshot.h1
-rw-r--r--services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp11
-rw-r--r--services/surfaceflinger/Layer.cpp82
-rw-r--r--services/surfaceflinger/Layer.h4
-rw-r--r--services/surfaceflinger/LayerFE.cpp9
-rw-r--r--services/surfaceflinger/LayerRenderArea.cpp28
-rw-r--r--services/surfaceflinger/LayerRenderArea.h8
-rw-r--r--services/surfaceflinger/RenderArea.h19
-rw-r--r--services/surfaceflinger/ScreenCaptureOutput.cpp29
-rw-r--r--services/surfaceflinger/ScreenCaptureOutput.h5
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp18
-rw-r--r--services/surfaceflinger/fuzzer/surfaceflinger_layer_fuzzer.cpp2
18 files changed, 30 insertions, 238 deletions
diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/Output.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/Output.h
index 8ec77c075b..229a657236 100644
--- a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/Output.h
+++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/Output.h
@@ -136,9 +136,8 @@ protected:
compositionengine::Output::FrameFences presentAndGetFrameFences() override;
virtual renderengine::DisplaySettings generateClientCompositionDisplaySettings() const;
std::vector<LayerFE::LayerSettings> generateClientCompositionRequests(
- bool supportsProtectedContent, ui::Dataspace outputDataspace,
- std::vector<LayerFE*> &outLayerFEs) override;
- virtual bool layerNeedsFiltering(const OutputLayer*) const;
+ bool supportsProtectedContent, ui::Dataspace outputDataspace,
+ std::vector<LayerFE*>& outLayerFEs) override;
void appendRegionFlashRequests(const Region&, std::vector<LayerFE::LayerSettings>&) override;
void setExpensiveRenderingExpected(bool enabled) override;
void setHintSessionGpuFence(std::unique_ptr<FenceTime>&& gpuFence) override;
diff --git a/services/surfaceflinger/CompositionEngine/src/Output.cpp b/services/surfaceflinger/CompositionEngine/src/Output.cpp
index 3ec681668b..403385ea8c 100644
--- a/services/surfaceflinger/CompositionEngine/src/Output.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/Output.cpp
@@ -1438,7 +1438,7 @@ std::vector<LayerFE::LayerSettings> Output::generateClientCompositionRequests(
Enabled);
compositionengine::LayerFE::ClientCompositionTargetSettings
targetSettings{.clip = clip,
- .needsFiltering = layerNeedsFiltering(layer) ||
+ .needsFiltering = layer->needsFiltering() ||
outputState.needsFiltering,
.isSecure = outputState.isSecure,
.supportsProtectedContent = supportsProtectedContent,
@@ -1469,10 +1469,6 @@ std::vector<LayerFE::LayerSettings> Output::generateClientCompositionRequests(
return clientCompositionLayers;
}
-bool Output::layerNeedsFiltering(const compositionengine::OutputLayer* layer) const {
- return layer->needsFiltering();
-}
-
void Output::appendRegionFlashRequests(
const Region& flashRegion, std::vector<LayerFE::LayerSettings>& clientCompositionLayers) {
if (flashRegion.isEmpty()) {
diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp
index c61f7d8e55..d0e0c4f8cf 100644
--- a/services/surfaceflinger/DisplayDevice.cpp
+++ b/services/surfaceflinger/DisplayDevice.cpp
@@ -347,10 +347,6 @@ const Region& DisplayDevice::getUndefinedRegion() const {
return mCompositionDisplay->getState().undefinedRegion;
}
-bool DisplayDevice::needsFiltering() const {
- return mCompositionDisplay->getState().needsFiltering;
-}
-
ui::LayerStack DisplayDevice::getLayerStack() const {
return mCompositionDisplay->getState().layerFilter.layerStack;
}
diff --git a/services/surfaceflinger/DisplayDevice.h b/services/surfaceflinger/DisplayDevice.h
index 370bd66b9e..e48e8130e1 100644
--- a/services/surfaceflinger/DisplayDevice.h
+++ b/services/surfaceflinger/DisplayDevice.h
@@ -115,7 +115,6 @@ public:
const ui::Transform& getTransform() const;
const Rect& getLayerStackSpaceRect() const;
const Rect& getOrientedDisplaySpaceRect() const;
- bool needsFiltering() const;
ui::LayerStack getLayerStack() const;
bool receivesInput() const { return mFlags & eReceivesInput; }
diff --git a/services/surfaceflinger/DisplayRenderArea.cpp b/services/surfaceflinger/DisplayRenderArea.cpp
index 20486e0aa3..8f39e26e0f 100644
--- a/services/surfaceflinger/DisplayRenderArea.cpp
+++ b/services/surfaceflinger/DisplayRenderArea.cpp
@@ -48,8 +48,8 @@ std::unique_ptr<RenderArea> DisplayRenderArea::create(wp<const DisplayDevice> di
DisplayRenderArea::DisplayRenderArea(sp<const DisplayDevice> display, const Rect& sourceCrop,
ui::Size reqSize, ui::Dataspace reqDataSpace,
bool useIdentityTransform, bool allowSecureLayers)
- : RenderArea(reqSize, CaptureFill::OPAQUE, reqDataSpace, display->getLayerStackSpaceRect(),
- allowSecureLayers, applyDeviceOrientation(useIdentityTransform, *display)),
+ : RenderArea(reqSize, CaptureFill::OPAQUE, reqDataSpace, allowSecureLayers,
+ applyDeviceOrientation(useIdentityTransform, *display)),
mDisplay(std::move(display)),
mSourceCrop(sourceCrop) {}
@@ -57,18 +57,6 @@ const ui::Transform& DisplayRenderArea::getTransform() const {
return mTransform;
}
-Rect DisplayRenderArea::getBounds() const {
- return mDisplay->getBounds();
-}
-
-int DisplayRenderArea::getHeight() const {
- return mDisplay->getHeight();
-}
-
-int DisplayRenderArea::getWidth() const {
- return mDisplay->getWidth();
-}
-
bool DisplayRenderArea::isSecure() const {
return mAllowSecureLayers && mDisplay->isSecure();
}
@@ -77,18 +65,6 @@ sp<const DisplayDevice> DisplayRenderArea::getDisplayDevice() const {
return mDisplay;
}
-bool DisplayRenderArea::needsFiltering() const {
- // check if the projection from the logical render area
- // to the physical render area requires filtering
- const Rect& sourceCrop = getSourceCrop();
- int width = sourceCrop.width();
- int height = sourceCrop.height();
- if (getRotationFlags() & ui::Transform::ROT_90) {
- std::swap(width, height);
- }
- return width != getReqWidth() || height != getReqHeight();
-}
-
Rect DisplayRenderArea::getSourceCrop() const {
// use the projected display viewport by default.
if (mSourceCrop.isEmpty()) {
@@ -107,4 +83,4 @@ Rect DisplayRenderArea::getSourceCrop() const {
return rotation.transform(mSourceCrop);
}
-} // namespace android \ No newline at end of file
+} // namespace android
diff --git a/services/surfaceflinger/DisplayRenderArea.h b/services/surfaceflinger/DisplayRenderArea.h
index 3478fc16c4..ce5410a90d 100644
--- a/services/surfaceflinger/DisplayRenderArea.h
+++ b/services/surfaceflinger/DisplayRenderArea.h
@@ -33,12 +33,8 @@ public:
bool allowSecureLayers = true);
const ui::Transform& getTransform() const override;
- Rect getBounds() const override;
- int getHeight() const override;
- int getWidth() const override;
bool isSecure() const override;
sp<const DisplayDevice> getDisplayDevice() const override;
- bool needsFiltering() const override;
Rect getSourceCrop() const override;
private:
@@ -50,4 +46,4 @@ private:
const ui::Transform mTransform;
};
-} // namespace android \ No newline at end of file
+} // namespace android
diff --git a/services/surfaceflinger/FrontEnd/LayerSnapshot.h b/services/surfaceflinger/FrontEnd/LayerSnapshot.h
index 159410f3ea..d173db3ec5 100644
--- a/services/surfaceflinger/FrontEnd/LayerSnapshot.h
+++ b/services/surfaceflinger/FrontEnd/LayerSnapshot.h
@@ -68,7 +68,6 @@ struct LayerSnapshot : public compositionengine::LayerFECompositionState {
renderengine::ShadowSettings shadowSettings;
bool premultipliedAlpha;
bool isHdrY410;
- bool bufferNeedsFiltering;
ui::Transform parentTransform;
Rect bufferSize;
Rect croppedBufferSize;
diff --git a/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp b/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp
index d0ffe613cc..6490476396 100644
--- a/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp
+++ b/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp
@@ -237,12 +237,6 @@ void handleDropInputMode(LayerSnapshot& snapshot, const LayerSnapshot& parentSna
}
}
-bool getBufferNeedsFiltering(const LayerSnapshot& snapshot, const ui::Size& unrotatedBufferSize) {
- const int32_t layerWidth = static_cast<int32_t>(snapshot.geomLayerBounds.getWidth());
- const int32_t layerHeight = static_cast<int32_t>(snapshot.geomLayerBounds.getHeight());
- return layerWidth != unrotatedBufferSize.width || layerHeight != unrotatedBufferSize.height;
-}
-
auto getBlendMode(const LayerSnapshot& snapshot, const RequestedLayerState& requested) {
auto blendMode = Hwc2::IComposerClient::BlendMode::NONE;
if (snapshot.alpha != 1.0f || !snapshot.isContentOpaque()) {
@@ -871,11 +865,6 @@ void LayerSnapshotBuilder::updateLayerBounds(LayerSnapshot& snapshot,
if (requested.potentialCursor) {
snapshot.cursorFrame = snapshot.geomLayerTransform.transform(bounds);
}
-
- // TODO(b/238781169) use dest vs src
- snapshot.bufferNeedsFiltering = snapshot.externalTexture &&
- getBufferNeedsFiltering(snapshot,
- requested.getUnrotatedBufferSize(displayRotationFlags));
}
void LayerSnapshotBuilder::updateShadows(LayerSnapshot& snapshot,
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 7a4b3375a1..c58ee2bdb2 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -3319,39 +3319,6 @@ sp<Layer> Layer::createClone() {
return layer;
}
-bool Layer::bufferNeedsFiltering() const {
- const State& s(getDrawingState());
- if (!s.buffer) {
- return false;
- }
-
- int32_t bufferWidth = static_cast<int32_t>(s.buffer->getWidth());
- int32_t bufferHeight = static_cast<int32_t>(s.buffer->getHeight());
-
- // Undo any transformations on the buffer and return the result.
- if (s.bufferTransform & ui::Transform::ROT_90) {
- std::swap(bufferWidth, bufferHeight);
- }
-
- if (s.transformToDisplayInverse) {
- uint32_t invTransform = DisplayDevice::getPrimaryDisplayRotationFlags();
- if (invTransform & ui::Transform::ROT_90) {
- std::swap(bufferWidth, bufferHeight);
- }
- }
-
- const Rect layerSize{getBounds()};
- int32_t layerWidth = layerSize.getWidth();
- int32_t layerHeight = layerSize.getHeight();
-
- // Align the layer orientation with the buffer before comparism
- if (mTransformHint & ui::Transform::ROT_90) {
- std::swap(layerWidth, layerHeight);
- }
-
- return layerWidth != bufferWidth || layerHeight != bufferHeight;
-}
-
void Layer::decrementPendingBufferCount() {
int32_t pendingBuffers = --mPendingBufferTransactions;
tracePendingBufferCount(pendingBuffers);
@@ -3821,54 +3788,6 @@ bool Layer::isProtected() const {
(mBufferInfo.mBuffer->getUsage() & GRALLOC_USAGE_PROTECTED);
}
-bool Layer::needsFiltering(const DisplayDevice* display) const {
- if (!hasBufferOrSidebandStream()) {
- return false;
- }
- const auto outputLayer = findOutputLayerForDisplay(display);
- if (outputLayer == nullptr) {
- return false;
- }
-
- // We need filtering if the sourceCrop rectangle size does not match the
- // displayframe rectangle size (not a 1:1 render)
- const auto& compositionState = outputLayer->getState();
- const auto displayFrame = compositionState.displayFrame;
- const auto sourceCrop = compositionState.sourceCrop;
- return sourceCrop.getHeight() != displayFrame.getHeight() ||
- sourceCrop.getWidth() != displayFrame.getWidth();
-}
-
-bool Layer::needsFilteringForScreenshots(const DisplayDevice* display,
- const ui::Transform& inverseParentTransform) const {
- if (!hasBufferOrSidebandStream()) {
- return false;
- }
- const auto outputLayer = findOutputLayerForDisplay(display);
- if (outputLayer == nullptr) {
- return false;
- }
-
- // We need filtering if the sourceCrop rectangle size does not match the
- // viewport rectangle size (not a 1:1 render)
- const auto& compositionState = outputLayer->getState();
- const ui::Transform& displayTransform = display->getTransform();
- const ui::Transform inverseTransform = inverseParentTransform * displayTransform.inverse();
- // Undo the transformation of the displayFrame so that we're back into
- // layer-stack space.
- const Rect frame = inverseTransform.transform(compositionState.displayFrame);
- const FloatRect sourceCrop = compositionState.sourceCrop;
-
- int32_t frameHeight = frame.getHeight();
- int32_t frameWidth = frame.getWidth();
- // If the display transform had a rotational component then undo the
- // rotation so that the orientation matches the source crop.
- if (displayTransform.getOrientation() & ui::Transform::ROT_90) {
- std::swap(frameHeight, frameWidth);
- }
- return sourceCrop.getHeight() != frameHeight || sourceCrop.getWidth() != frameWidth;
-}
-
void Layer::latchAndReleaseBuffer() {
if (hasReadyFrame()) {
bool ignored = false;
@@ -4014,7 +3933,6 @@ void Layer::updateSnapshot(bool updateGeometry) {
snapshot->layerOpaqueFlagSet =
(mDrawingState.flags & layer_state_t::eLayerOpaque) == layer_state_t::eLayerOpaque;
snapshot->isHdrY410 = isHdrY410();
- snapshot->bufferNeedsFiltering = bufferNeedsFiltering();
sp<Layer> p = mDrawingParent.promote();
if (p != nullptr) {
snapshot->parentTransform = p->getTransform();
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index 3384e4af2d..6ba772f2f0 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -1038,10 +1038,6 @@ private:
bool willPresentCurrentTransaction() const;
- // Returns true if the transformed buffer size does not match the layer size and we need
- // to apply filtering.
- bool bufferNeedsFiltering() const;
-
void callReleaseBufferCallback(const sp<ITransactionCompletedListener>& listener,
const sp<GraphicBuffer>& buffer, uint64_t framenumber,
const sp<Fence>& releaseFence,
diff --git a/services/surfaceflinger/LayerFE.cpp b/services/surfaceflinger/LayerFE.cpp
index c31a2e3cfc..b9c8b78f55 100644
--- a/services/surfaceflinger/LayerFE.cpp
+++ b/services/surfaceflinger/LayerFE.cpp
@@ -249,14 +249,11 @@ void LayerFE::prepareBufferStateClientComposition(
layerSettings.frameNumber = mSnapshot->frameNumber;
layerSettings.bufferId = mSnapshot->externalTexture->getId();
- const bool useFiltering = targetSettings.needsFiltering ||
- mSnapshot->geomLayerTransform.needsBilinearFiltering() ||
- mSnapshot->bufferNeedsFiltering;
-
// Query the texture matrix given our current filtering mode.
float textureMatrix[16];
getDrawingTransformMatrix(layerSettings.source.buffer.buffer, mSnapshot->geomContentCrop,
- mSnapshot->geomBufferTransform, useFiltering, textureMatrix);
+ mSnapshot->geomBufferTransform, targetSettings.needsFiltering,
+ textureMatrix);
if (mSnapshot->geomBufferUsesDisplayInverseTransform) {
/*
@@ -306,7 +303,7 @@ void LayerFE::prepareBufferStateClientComposition(
mat4::translate(vec4(translateX, translateY, 0.f, 1.f)) *
mat4::scale(vec4(scaleWidth, scaleHeight, 1.0f, 1.0f));
- layerSettings.source.buffer.useTextureFiltering = useFiltering;
+ layerSettings.source.buffer.useTextureFiltering = targetSettings.needsFiltering;
layerSettings.source.buffer.textureTransform =
mat4(static_cast<const float*>(textureMatrix)) * tr;
diff --git a/services/surfaceflinger/LayerRenderArea.cpp b/services/surfaceflinger/LayerRenderArea.cpp
index 554fae401e..2b4375b0fa 100644
--- a/services/surfaceflinger/LayerRenderArea.cpp
+++ b/services/surfaceflinger/LayerRenderArea.cpp
@@ -39,8 +39,8 @@ void reparentForDrawing(const sp<Layer>& oldParent, const sp<Layer>& newParent,
LayerRenderArea::LayerRenderArea(SurfaceFlinger& flinger, sp<Layer> layer, const Rect& crop,
ui::Size reqSize, ui::Dataspace reqDataSpace, bool childrenOnly,
- const Rect& layerStackRect, bool allowSecureLayers)
- : RenderArea(reqSize, CaptureFill::CLEAR, reqDataSpace, layerStackRect, allowSecureLayers),
+ bool allowSecureLayers)
+ : RenderArea(reqSize, CaptureFill::CLEAR, reqDataSpace, allowSecureLayers),
mLayer(std::move(layer)),
mCrop(crop),
mFlinger(flinger),
@@ -50,33 +50,17 @@ const ui::Transform& LayerRenderArea::getTransform() const {
return mTransform;
}
-Rect LayerRenderArea::getBounds() const {
- return mLayer->getBufferSize(mLayer->getDrawingState());
-}
-
-int LayerRenderArea::getHeight() const {
- return mLayer->getBufferSize(mLayer->getDrawingState()).getHeight();
-}
-
-int LayerRenderArea::getWidth() const {
- return mLayer->getBufferSize(mLayer->getDrawingState()).getWidth();
-}
-
bool LayerRenderArea::isSecure() const {
return mAllowSecureLayers;
}
-bool LayerRenderArea::needsFiltering() const {
- return mNeedsFiltering;
-}
-
sp<const DisplayDevice> LayerRenderArea::getDisplayDevice() const {
return nullptr;
}
Rect LayerRenderArea::getSourceCrop() const {
if (mCrop.isEmpty()) {
- return getBounds();
+ return mLayer->getBufferSize(mLayer->getDrawingState());
} else {
return mCrop;
}
@@ -85,10 +69,6 @@ Rect LayerRenderArea::getSourceCrop() const {
void LayerRenderArea::render(std::function<void()> drawLayers) {
using namespace std::string_literals;
- const Rect sourceCrop = getSourceCrop();
- // no need to check rotation because there is none
- mNeedsFiltering = sourceCrop.width() != getReqWidth() || sourceCrop.height() != getReqHeight();
-
// If layer is offscreen, update mirroring info if it exists
if (mLayer->isRemovedFromCurrentState()) {
mLayer->traverse(LayerVector::StateSet::Drawing,
@@ -116,7 +96,7 @@ void LayerRenderArea::render(std::function<void()> drawLayers) {
LayerMetadata()});
{
Mutex::Autolock _l(mFlinger.mStateLock);
- reparentForDrawing(mLayer, screenshotParentLayer, sourceCrop);
+ reparentForDrawing(mLayer, screenshotParentLayer, getSourceCrop());
}
drawLayers();
{
diff --git a/services/surfaceflinger/LayerRenderArea.h b/services/surfaceflinger/LayerRenderArea.h
index 41273e01c1..322dbd1bf4 100644
--- a/services/surfaceflinger/LayerRenderArea.h
+++ b/services/surfaceflinger/LayerRenderArea.h
@@ -33,15 +33,10 @@ class SurfaceFlinger;
class LayerRenderArea : public RenderArea {
public:
LayerRenderArea(SurfaceFlinger& flinger, sp<Layer> layer, const Rect& crop, ui::Size reqSize,
- ui::Dataspace reqDataSpace, bool childrenOnly, const Rect& layerStackRect,
- bool allowSecureLayers);
+ ui::Dataspace reqDataSpace, bool childrenOnly, bool allowSecureLayers);
const ui::Transform& getTransform() const override;
- Rect getBounds() const override;
- int getHeight() const override;
- int getWidth() const override;
bool isSecure() const override;
- bool needsFiltering() const override;
sp<const DisplayDevice> getDisplayDevice() const override;
Rect getSourceCrop() const override;
@@ -53,7 +48,6 @@ private:
const Rect mCrop;
ui::Transform mTransform;
- bool mNeedsFiltering = false;
SurfaceFlinger& mFlinger;
const bool mChildrenOnly;
diff --git a/services/surfaceflinger/RenderArea.h b/services/surfaceflinger/RenderArea.h
index 3c20e3b1e2..910fce043c 100644
--- a/services/surfaceflinger/RenderArea.h
+++ b/services/surfaceflinger/RenderArea.h
@@ -25,14 +25,12 @@ public:
static float getCaptureFillValue(CaptureFill captureFill);
RenderArea(ui::Size reqSize, CaptureFill captureFill, ui::Dataspace reqDataSpace,
- const Rect& layerStackRect, bool allowSecureLayers = false,
- RotationFlags rotation = ui::Transform::ROT_0)
+ bool allowSecureLayers = false, RotationFlags rotation = ui::Transform::ROT_0)
: mAllowSecureLayers(allowSecureLayers),
mReqSize(reqSize),
mReqDataSpace(reqDataSpace),
mCaptureFill(captureFill),
- mRotationFlags(rotation),
- mLayerStackSpaceRect(layerStackRect) {}
+ mRotationFlags(rotation) {}
static std::function<std::vector<std::pair<Layer*, sp<LayerFE>>>()> fromTraverseLayersLambda(
std::function<void(const LayerVector::Visitor&)> traverseLayers) {
@@ -58,20 +56,10 @@ public:
// blacked out / skipped when rendered to an insecure render area.
virtual bool isSecure() const = 0;
- // Returns true if the otherwise disabled layer filtering should be
- // enabled when rendering to this render area.
- virtual bool needsFiltering() const = 0;
-
// Returns the transform to be applied on layers to transform them into
// the logical render area.
virtual const ui::Transform& getTransform() const = 0;
- // Returns the size of the logical render area. Layers are clipped to the
- // logical render area.
- virtual int getWidth() const = 0;
- virtual int getHeight() const = 0;
- virtual Rect getBounds() const = 0;
-
// Returns the source crop of the render area. The source crop defines
// how layers are projected from the logical render area onto the physical
// render area. It can be larger than the logical render area. It can
@@ -98,9 +86,6 @@ public:
virtual sp<const DisplayDevice> getDisplayDevice() const = 0;
- // Returns the source display viewport.
- const Rect& getLayerStackSpaceRect() const { return mLayerStackSpaceRect; }
-
// If this is a LayerRenderArea, return the root layer of the
// capture operation.
virtual sp<Layer> getParentLayer() const { return nullptr; }
diff --git a/services/surfaceflinger/ScreenCaptureOutput.cpp b/services/surfaceflinger/ScreenCaptureOutput.cpp
index 6d195b9f7b..a1d5cd7379 100644
--- a/services/surfaceflinger/ScreenCaptureOutput.cpp
+++ b/services/surfaceflinger/ScreenCaptureOutput.cpp
@@ -27,11 +27,8 @@ namespace android {
std::shared_ptr<ScreenCaptureOutput> createScreenCaptureOutput(ScreenCaptureOutputArgs args) {
std::shared_ptr<ScreenCaptureOutput> output = compositionengine::impl::createOutputTemplated<
ScreenCaptureOutput, compositionengine::CompositionEngine, const RenderArea&,
- std::unordered_set<compositionengine::LayerFE*>,
const compositionengine::Output::ColorProfile&, bool>(args.compositionEngine,
args.renderArea,
- std::move(
- args.filterForScreenshot),
args.colorProfile,
args.regionSampling);
output->editState().isSecure = args.renderArea.isSecure();
@@ -45,12 +42,11 @@ std::shared_ptr<ScreenCaptureOutput> createScreenCaptureOutput(ScreenCaptureOutp
.setHasWideColorGamut(true)
.Build()));
- ui::Rotation orientation = ui::Transform::toRotation(args.renderArea.getRotationFlags());
- Rect orientedDisplaySpaceRect{args.renderArea.getReqWidth(), args.renderArea.getReqHeight()};
- output->setProjection(orientation, args.renderArea.getLayerStackSpaceRect(),
- orientedDisplaySpaceRect);
-
- Rect sourceCrop = args.renderArea.getSourceCrop();
+ const Rect& sourceCrop = args.renderArea.getSourceCrop();
+ const ui::Rotation orientation = ui::Transform::toRotation(args.renderArea.getRotationFlags());
+ const Rect orientedDisplaySpaceRect{args.renderArea.getReqWidth(),
+ args.renderArea.getReqHeight()};
+ output->setProjection(orientation, sourceCrop, orientedDisplaySpaceRect);
output->setDisplaySize({sourceCrop.getWidth(), sourceCrop.getHeight()});
{
@@ -64,13 +60,9 @@ std::shared_ptr<ScreenCaptureOutput> createScreenCaptureOutput(ScreenCaptureOutp
}
ScreenCaptureOutput::ScreenCaptureOutput(
- const RenderArea& renderArea,
- std::unordered_set<compositionengine::LayerFE*> filterForScreenshot,
- const compositionengine::Output::ColorProfile& colorProfile, bool regionSampling)
- : mRenderArea(renderArea),
- mFilterForScreenshot(std::move(filterForScreenshot)),
- mColorProfile(colorProfile),
- mRegionSampling(regionSampling) {}
+ const RenderArea& renderArea, const compositionengine::Output::ColorProfile& colorProfile,
+ bool regionSampling)
+ : mRenderArea(renderArea), mColorProfile(colorProfile), mRegionSampling(regionSampling) {}
void ScreenCaptureOutput::updateColorProfile(const compositionengine::CompositionRefreshArgs&) {
auto& outputState = editState();
@@ -115,9 +107,4 @@ ScreenCaptureOutput::generateClientCompositionRequests(
return clientCompositionLayers;
}
-bool ScreenCaptureOutput::layerNeedsFiltering(const compositionengine::OutputLayer* layer) const {
- return mRenderArea.needsFiltering() ||
- mFilterForScreenshot.find(&layer->getLayerFE()) != mFilterForScreenshot.end();
-}
-
} // namespace android
diff --git a/services/surfaceflinger/ScreenCaptureOutput.h b/services/surfaceflinger/ScreenCaptureOutput.h
index 5dffc1d530..4e5a0ccfd2 100644
--- a/services/surfaceflinger/ScreenCaptureOutput.h
+++ b/services/surfaceflinger/ScreenCaptureOutput.h
@@ -33,7 +33,6 @@ struct ScreenCaptureOutputArgs {
std::shared_ptr<renderengine::ExternalTexture> buffer;
float sdrWhitePointNits;
float displayBrightnessNits;
- std::unordered_set<compositionengine::LayerFE*> filterForScreenshot;
bool regionSampling;
};
@@ -44,7 +43,6 @@ struct ScreenCaptureOutputArgs {
class ScreenCaptureOutput : public compositionengine::impl::Output {
public:
ScreenCaptureOutput(const RenderArea& renderArea,
- std::unordered_set<compositionengine::LayerFE*> filterForScreenshot,
const compositionengine::Output::ColorProfile& colorProfile,
bool regionSampling);
@@ -54,15 +52,12 @@ public:
bool supportsProtectedContent, ui::Dataspace outputDataspace,
std::vector<compositionengine::LayerFE*>& outLayerFEs) override;
- bool layerNeedsFiltering(const compositionengine::OutputLayer*) const override;
-
protected:
bool getSkipColorTransform() const override { return false; }
renderengine::DisplaySettings generateClientCompositionDisplaySettings() const override;
private:
const RenderArea& mRenderArea;
- const std::unordered_set<compositionengine::LayerFE*> mFilterForScreenshot;
const compositionengine::Output::ColorProfile& mColorProfile;
const bool mRegionSampling;
};
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 0dc8b05993..ac61e94e01 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -6559,13 +6559,10 @@ status_t SurfaceFlinger::captureLayers(const LayerCaptureArgs& args,
return BAD_VALUE;
}
- Rect layerStackSpaceRect(crop.left, crop.top, crop.left + reqSize.width,
- crop.top + reqSize.height);
bool childrenOnly = args.childrenOnly;
RenderAreaFuture renderAreaFuture = ftl::defer([=]() -> std::unique_ptr<RenderArea> {
return std::make_unique<LayerRenderArea>(*this, parent, crop, reqSize, dataspace,
- childrenOnly, layerStackSpaceRect,
- args.captureSecureLayers);
+ childrenOnly, args.captureSecureLayers);
});
auto traverseLayers = [parent, args, excludeLayerIds](const LayerVector::Visitor& visitor) {
@@ -6720,9 +6717,6 @@ ftl::SharedFuture<FenceResult> SurfaceFlinger::renderScreenImpl(
ScreenCaptureResults& captureResults) {
ATRACE_CALL();
- const auto& display = renderArea->getDisplayDevice();
- const auto& transform = renderArea->getTransform();
- std::unordered_set<compositionengine::LayerFE*> filterForScreenshot;
auto layers = getLayerSnapshots();
for (auto& [layer, layerFE] : layers) {
frontend::LayerSnapshot* snapshot = layerFE->mSnapshot.get();
@@ -6730,9 +6724,6 @@ ftl::SharedFuture<FenceResult> SurfaceFlinger::renderScreenImpl(
captureResults.capturedHdrLayers |= isHdrLayer(*snapshot);
layerFE->mSnapshot->geomLayerTransform =
renderArea->getTransform() * layerFE->mSnapshot->geomLayerTransform;
- if (layer->needsFilteringForScreenshots(display.get(), transform)) {
- filterForScreenshot.insert(layerFE.get());
- }
}
// We allow the system server to take screenshots of secure layers for
@@ -6783,9 +6774,9 @@ ftl::SharedFuture<FenceResult> SurfaceFlinger::renderScreenImpl(
};
auto present = [this, buffer = std::move(buffer), dataspace, sdrWhitePointNits,
- displayBrightnessNits, filterForScreenshot = std::move(filterForScreenshot),
- grayscale, layerFEs = copyLayerFEs(), layerStack, regionSampling,
- renderArea = std::move(renderArea), renderIntent]() -> FenceResult {
+ displayBrightnessNits, grayscale, layerFEs = copyLayerFEs(), layerStack,
+ regionSampling, renderArea = std::move(renderArea),
+ renderIntent]() -> FenceResult {
std::unique_ptr<compositionengine::CompositionEngine> compositionEngine =
mFactory.createCompositionEngine();
compositionEngine->setRenderEngine(mRenderEngine.get());
@@ -6801,7 +6792,6 @@ ftl::SharedFuture<FenceResult> SurfaceFlinger::renderScreenImpl(
.buffer = std::move(buffer),
.sdrWhitePointNits = sdrWhitePointNits,
.displayBrightnessNits = displayBrightnessNits,
- .filterForScreenshot = std::move(filterForScreenshot),
.regionSampling = regionSampling});
const float colorSaturation = grayscale ? 0 : 1;
diff --git a/services/surfaceflinger/fuzzer/surfaceflinger_layer_fuzzer.cpp b/services/surfaceflinger/fuzzer/surfaceflinger_layer_fuzzer.cpp
index acfc1d4dc8..11719c435e 100644
--- a/services/surfaceflinger/fuzzer/surfaceflinger_layer_fuzzer.cpp
+++ b/services/surfaceflinger/fuzzer/surfaceflinger_layer_fuzzer.cpp
@@ -166,7 +166,7 @@ void LayerFuzzer::invokeBufferStateLayer() {
{mFdp.ConsumeIntegral<int32_t>(),
mFdp.ConsumeIntegral<int32_t>()} /*reqSize*/,
mFdp.PickValueInArray(kDataspaces), mFdp.ConsumeBool(),
- getFuzzedRect(), mFdp.ConsumeBool());
+ mFdp.ConsumeBool());
layerArea.render([]() {} /*drawLayers*/);
if (!ownsHandle) {