Patrick Williams | 7584c6a | 2022-10-29 02:10:58 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2022 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #pragma once |
| 18 | |
| 19 | #include <compositionengine/DisplayColorProfile.h> |
| 20 | #include <compositionengine/RenderSurface.h> |
| 21 | #include <compositionengine/impl/Output.h> |
| 22 | #include <ui/Rect.h> |
| 23 | |
| 24 | #include "RenderArea.h" |
| 25 | |
| 26 | namespace android { |
| 27 | |
| 28 | struct ScreenCaptureOutputArgs { |
| 29 | const compositionengine::CompositionEngine& compositionEngine; |
| 30 | const compositionengine::Output::ColorProfile& colorProfile; |
| 31 | const RenderArea& renderArea; |
| 32 | ui::LayerStack layerStack; |
| 33 | std::shared_ptr<renderengine::ExternalTexture> buffer; |
| 34 | float sdrWhitePointNits; |
| 35 | float displayBrightnessNits; |
| 36 | std::unordered_set<compositionengine::LayerFE*> filterForScreenshot; |
| 37 | bool regionSampling; |
| 38 | }; |
| 39 | |
| 40 | // ScreenCaptureOutput is used to compose a set of layers into a preallocated buffer. |
| 41 | // |
| 42 | // SurfaceFlinger passes instances of ScreenCaptureOutput to CompositionEngine in calls to |
| 43 | // SurfaceFlinger::captureLayers and SurfaceFlinger::captureDisplay. |
| 44 | class ScreenCaptureOutput : public compositionengine::impl::Output { |
| 45 | public: |
Patrick Williams | 01c3116 | 2022-11-14 17:45:19 +0000 | [diff] [blame^] | 46 | ScreenCaptureOutput(const RenderArea& renderArea, |
| 47 | std::unordered_set<compositionengine::LayerFE*> filterForScreenshot, |
| 48 | const compositionengine::Output::ColorProfile& colorProfile, |
| 49 | bool regionSampling); |
Patrick Williams | 7584c6a | 2022-10-29 02:10:58 +0000 | [diff] [blame] | 50 | |
| 51 | void updateColorProfile(const compositionengine::CompositionRefreshArgs&) override; |
| 52 | |
| 53 | std::vector<compositionengine::LayerFE::LayerSettings> generateClientCompositionRequests( |
| 54 | bool supportsProtectedContent, ui::Dataspace outputDataspace, |
| 55 | std::vector<compositionengine::LayerFE*>& outLayerFEs) override; |
| 56 | |
| 57 | bool layerNeedsFiltering(const compositionengine::OutputLayer*) const override; |
| 58 | |
| 59 | protected: |
| 60 | bool getSkipColorTransform() const override { return false; } |
| 61 | renderengine::DisplaySettings generateClientCompositionDisplaySettings() const override; |
| 62 | |
| 63 | private: |
| 64 | const RenderArea& mRenderArea; |
| 65 | const std::unordered_set<compositionengine::LayerFE*> mFilterForScreenshot; |
| 66 | const compositionengine::Output::ColorProfile& mColorProfile; |
| 67 | const bool mRegionSampling; |
| 68 | }; |
| 69 | |
Patrick Williams | 01c3116 | 2022-11-14 17:45:19 +0000 | [diff] [blame^] | 70 | std::shared_ptr<ScreenCaptureOutput> createScreenCaptureOutput(ScreenCaptureOutputArgs); |
Patrick Williams | 7584c6a | 2022-10-29 02:10:58 +0000 | [diff] [blame] | 71 | |
| 72 | } // namespace android |