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