Vishnu Nair | e14c6b3 | 2022-08-06 04:20:15 +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 | |
Alec Mouri | f4af03e | 2023-02-11 00:25:24 +0000 | [diff] [blame] | 19 | #include <android/gui/CachingHint.h> |
Vishnu Nair | e14c6b3 | 2022-08-06 04:20:15 +0000 | [diff] [blame] | 20 | #include <gui/LayerMetadata.h> |
Vishnu Nair | 8fc721b | 2022-12-22 20:06:32 +0000 | [diff] [blame] | 21 | #include "FrontEnd/LayerSnapshot.h" |
Vishnu Nair | e14c6b3 | 2022-08-06 04:20:15 +0000 | [diff] [blame] | 22 | #include "compositionengine/LayerFE.h" |
| 23 | #include "compositionengine/LayerFECompositionState.h" |
| 24 | #include "renderengine/LayerSettings.h" |
| 25 | |
| 26 | namespace android { |
Vishnu Nair | e14c6b3 | 2022-08-06 04:20:15 +0000 | [diff] [blame] | 27 | |
| 28 | struct CompositionResult { |
Vishnu Nair | 7ee4f46 | 2023-04-19 09:54:09 -0700 | [diff] [blame] | 29 | std::vector<std::pair<ftl::SharedFuture<FenceResult>, ui::LayerStack>> releaseFences; |
Vishnu Nair | e14c6b3 | 2022-08-06 04:20:15 +0000 | [diff] [blame] | 30 | sp<Fence> lastClientCompositionFence = nullptr; |
| 31 | }; |
| 32 | |
| 33 | class LayerFE : public virtual RefBase, public virtual compositionengine::LayerFE { |
| 34 | public: |
| 35 | LayerFE(const std::string& name); |
| 36 | |
| 37 | // compositionengine::LayerFE overrides |
| 38 | const compositionengine::LayerFECompositionState* getCompositionState() const override; |
Melody Hsu | c949cde | 2024-03-12 01:43:34 +0000 | [diff] [blame^] | 39 | bool onPreComposition(bool updatingOutputGeometryThisFrame) override; |
Vishnu Nair | 7ee4f46 | 2023-04-19 09:54:09 -0700 | [diff] [blame] | 40 | void onLayerDisplayed(ftl::SharedFuture<FenceResult>, ui::LayerStack) override; |
Vishnu Nair | e14c6b3 | 2022-08-06 04:20:15 +0000 | [diff] [blame] | 41 | const char* getDebugName() const override; |
| 42 | int32_t getSequence() const override; |
| 43 | bool hasRoundedCorners() const override; |
| 44 | void setWasClientComposed(const sp<Fence>&) override; |
| 45 | const gui::LayerMetadata* getMetadata() const override; |
| 46 | const gui::LayerMetadata* getRelativeMetadata() const override; |
| 47 | std::optional<compositionengine::LayerFE::LayerSettings> prepareClientComposition( |
| 48 | compositionengine::LayerFE::ClientCompositionTargetSettings&) const; |
| 49 | CompositionResult&& stealCompositionResult(); |
| 50 | |
Vishnu Nair | 8fc721b | 2022-12-22 20:06:32 +0000 | [diff] [blame] | 51 | std::unique_ptr<surfaceflinger::frontend::LayerSnapshot> mSnapshot; |
Vishnu Nair | e14c6b3 | 2022-08-06 04:20:15 +0000 | [diff] [blame] | 52 | |
| 53 | private: |
| 54 | std::optional<compositionengine::LayerFE::LayerSettings> prepareClientCompositionInternal( |
| 55 | compositionengine::LayerFE::ClientCompositionTargetSettings&) const; |
| 56 | // Modifies the passed in layer settings to clear the contents. If the blackout flag is set, |
| 57 | // the settings clears the content with a solid black fill. |
| 58 | void prepareClearClientComposition(LayerFE::LayerSettings&, bool blackout) const; |
| 59 | void prepareShadowClientComposition(LayerFE::LayerSettings& caster, |
| 60 | const Rect& layerStackRect) const; |
| 61 | void prepareBufferStateClientComposition( |
| 62 | compositionengine::LayerFE::LayerSettings&, |
| 63 | compositionengine::LayerFE::ClientCompositionTargetSettings&) const; |
| 64 | void prepareEffectsClientComposition( |
| 65 | compositionengine::LayerFE::LayerSettings&, |
| 66 | compositionengine::LayerFE::ClientCompositionTargetSettings&) const; |
| 67 | |
| 68 | bool hasEffect() const { return fillsColor() || drawShadows() || hasBlur(); } |
| 69 | bool hasBufferOrSidebandStream() const; |
| 70 | |
| 71 | bool fillsColor() const; |
| 72 | bool hasBlur() const; |
| 73 | bool drawShadows() const; |
| 74 | |
| 75 | const sp<GraphicBuffer> getBuffer() const; |
| 76 | |
| 77 | CompositionResult mCompositionResult; |
| 78 | std::string mName; |
| 79 | }; |
| 80 | |
| 81 | } // namespace android |