diff options
| author | 2020-04-23 21:11:26 +0000 | |
|---|---|---|
| committer | 2020-04-23 21:11:26 +0000 | |
| commit | dbdf0ab6f470d6edc85b7902bef2d153b8295c17 (patch) | |
| tree | 8712da807f0df5cc5d77951ddd15b48f39a00473 | |
| parent | b6ddea2951caf8af136a32345afe116fa37da4d2 (diff) | |
| parent | f11eba5d705efac846e96acf5f748102da45a044 (diff) | |
Merge "Do not blur when doing region sampling" into rvc-dev
5 files changed, 27 insertions, 15 deletions
diff --git a/services/surfaceflinger/RegionSamplingThread.cpp b/services/surfaceflinger/RegionSamplingThread.cpp index 0b9e3d73d8..27353d8c0b 100644 --- a/services/surfaceflinger/RegionSamplingThread.cpp +++ b/services/surfaceflinger/RegionSamplingThread.cpp @@ -425,7 +425,8 @@ void RegionSamplingThread::captureSample() { } bool ignored; - mFlinger.captureScreenCommon(renderArea, traverseLayers, buffer, false, ignored); + mFlinger.captureScreenCommon(renderArea, traverseLayers, buffer, false /* identityTransform */, + true /* regionSampling */, ignored); std::vector<Descriptor> activeDescriptors; for (const auto& descriptor : descriptors) { diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 5ccf7c7c8e..c5ebc540ab 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -5668,13 +5668,13 @@ status_t SurfaceFlinger::captureScreenCommon(RenderArea& renderArea, usage, "screenshot"); return captureScreenCommon(renderArea, traverseLayers, *outBuffer, useIdentityTransform, - outCapturedSecureLayers); + false /* regionSampling */, outCapturedSecureLayers); } status_t SurfaceFlinger::captureScreenCommon(RenderArea& renderArea, TraverseLayersFunction traverseLayers, const sp<GraphicBuffer>& buffer, - bool useIdentityTransform, + bool useIdentityTransform, bool regionSampling, bool& outCapturedSecureLayers) { // This mutex protects syncFd and captureResult for communication of the return values from the // main thread back to this Binder thread @@ -5705,7 +5705,7 @@ status_t SurfaceFlinger::captureScreenCommon(RenderArea& renderArea, renderArea.render([&] { result = captureScreenImplLocked(renderArea, traverseLayers, buffer.get(), useIdentityTransform, forSystem, &fd, - outCapturedSecureLayers); + regionSampling, outCapturedSecureLayers); }); } @@ -5742,7 +5742,7 @@ status_t SurfaceFlinger::captureScreenCommon(RenderArea& renderArea, void SurfaceFlinger::renderScreenImplLocked(const RenderArea& renderArea, TraverseLayersFunction traverseLayers, ANativeWindowBuffer* buffer, bool useIdentityTransform, - int* outSyncFd) { + bool regionSampling, int* outSyncFd) { ATRACE_CALL(); const auto reqWidth = renderArea.getReqWidth(); @@ -5798,6 +5798,12 @@ void SurfaceFlinger::renderScreenImplLocked(const RenderArea& renderArea, for (auto& settings : results) { settings.geometry.positionTransform = transform.asMatrix4() * settings.geometry.positionTransform; + // There's no need to process blurs when we're executing region sampling, + // we're just trying to understand what we're drawing, and doing so without + // blurs is already a pretty good approximation. + if (regionSampling) { + settings.backgroundBlurRadius = 0; + } } clientCompositionLayers.insert(clientCompositionLayers.end(), std::make_move_iterator(results.begin()), @@ -5835,7 +5841,8 @@ status_t SurfaceFlinger::captureScreenImplLocked(const RenderArea& renderArea, TraverseLayersFunction traverseLayers, ANativeWindowBuffer* buffer, bool useIdentityTransform, bool forSystem, - int* outSyncFd, bool& outCapturedSecureLayers) { + int* outSyncFd, bool regionSampling, + bool& outCapturedSecureLayers) { ATRACE_CALL(); traverseLayers([&](Layer* layer) { @@ -5850,7 +5857,8 @@ status_t SurfaceFlinger::captureScreenImplLocked(const RenderArea& renderArea, ALOGW("FB is protected: PERMISSION_DENIED"); return PERMISSION_DENIED; } - renderScreenImplLocked(renderArea, traverseLayers, buffer, useIdentityTransform, outSyncFd); + renderScreenImplLocked(renderArea, traverseLayers, buffer, useIdentityTransform, regionSampling, + outSyncFd); return NO_ERROR; } diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index 6e49f37354..8973bc92f5 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -701,19 +701,20 @@ private: void renderScreenImplLocked(const RenderArea& renderArea, TraverseLayersFunction traverseLayers, ANativeWindowBuffer* buffer, bool useIdentityTransform, - int* outSyncFd); + bool regionSampling, int* outSyncFd); status_t captureScreenCommon(RenderArea& renderArea, TraverseLayersFunction traverseLayers, sp<GraphicBuffer>* outBuffer, const ui::PixelFormat reqPixelFormat, bool useIdentityTransform, bool& outCapturedSecureLayers); status_t captureScreenCommon(RenderArea& renderArea, TraverseLayersFunction traverseLayers, const sp<GraphicBuffer>& buffer, bool useIdentityTransform, - bool& outCapturedSecureLayers); + bool regionSampling, bool& outCapturedSecureLayers); const sp<DisplayDevice> getDisplayByIdOrLayerStack(uint64_t displayOrLayerStack); const sp<DisplayDevice> getDisplayByLayerStack(uint64_t layerStack); status_t captureScreenImplLocked(const RenderArea& renderArea, TraverseLayersFunction traverseLayers, ANativeWindowBuffer* buffer, bool useIdentityTransform, - bool forSystem, int* outSyncFd, bool& outCapturedSecureLayers); + bool forSystem, int* outSyncFd, bool regionSampling, + bool& outCapturedSecureLayers); void traverseLayersInDisplay(const sp<const DisplayDevice>& display, const LayerVector::Visitor& visitor); diff --git a/services/surfaceflinger/tests/unittests/CompositionTest.cpp b/services/surfaceflinger/tests/unittests/CompositionTest.cpp index 0a0c9b7c51..e0dd0d9f07 100644 --- a/services/surfaceflinger/tests/unittests/CompositionTest.cpp +++ b/services/surfaceflinger/tests/unittests/CompositionTest.cpp @@ -231,6 +231,7 @@ void CompositionTest::captureScreenComposition() { const Rect sourceCrop(0, 0, DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT); constexpr bool useIdentityTransform = true; constexpr bool forSystem = true; + constexpr bool regionSampling = false; DisplayRenderArea renderArea(mDisplay, sourceCrop, DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT, ui::Dataspace::V0_SRGB, @@ -249,7 +250,7 @@ void CompositionTest::captureScreenComposition() { int fd = -1; status_t result = mFlinger.captureScreenImplLocked(renderArea, traverseLayers, mCaptureScreenBuffer.get(), - useIdentityTransform, forSystem, &fd); + useIdentityTransform, forSystem, &fd, regionSampling); if (fd >= 0) { close(fd); } diff --git a/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h b/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h index ba640de419..add33270f9 100644 --- a/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h +++ b/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h @@ -323,13 +323,14 @@ public: auto onMessageReceived(int32_t what) { return mFlinger->onMessageReceived(what, systemTime()); } - auto captureScreenImplLocked( - const RenderArea& renderArea, SurfaceFlinger::TraverseLayersFunction traverseLayers, - ANativeWindowBuffer* buffer, bool useIdentityTransform, bool forSystem, int* outSyncFd) { + auto captureScreenImplLocked(const RenderArea& renderArea, + SurfaceFlinger::TraverseLayersFunction traverseLayers, + ANativeWindowBuffer* buffer, bool useIdentityTransform, + bool forSystem, int* outSyncFd, bool regionSampling) { bool ignored; return mFlinger->captureScreenImplLocked(renderArea, traverseLayers, buffer, useIdentityTransform, forSystem, outSyncFd, - ignored); + regionSampling, ignored); } auto traverseLayersInDisplay(const sp<const DisplayDevice>& display, |