The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 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 | */ |
Robert Carr | cdf8320 | 2018-03-07 12:48:34 -0800 | [diff] [blame] | 16 | #pragma once |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 17 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 18 | #include <sys/types.h> |
| 19 | |
Robert Carr | cdf8320 | 2018-03-07 12:48:34 -0800 | [diff] [blame] | 20 | #include <cstdint> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 21 | |
Robert Carr | cdf8320 | 2018-03-07 12:48:34 -0800 | [diff] [blame] | 22 | #include "Layer.h" |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 23 | |
Mathias Agopian | cbb288b | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 24 | namespace android { |
| 25 | |
Vishnu Nair | fa247b1 | 2020-02-11 08:58:26 -0800 | [diff] [blame] | 26 | // A layer that can render a combination of the following effects. |
| 27 | // * fill the bounds of the layer with a color |
| 28 | // * render a shadow cast by the bounds of the layer |
| 29 | // If no effects are enabled, the layer is considered to be invisible. |
| 30 | class EffectLayer : public Layer { |
Jesse Hall | 382574d | 2014-08-07 22:33:14 -0700 | [diff] [blame] | 31 | public: |
Vishnu Nair | fa247b1 | 2020-02-11 08:58:26 -0800 | [diff] [blame] | 32 | explicit EffectLayer(const LayerCreationArgs&); |
| 33 | ~EffectLayer() override; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 34 | |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 35 | sp<compositionengine::LayerFE> getCompositionEngineLayerFE() const override; |
| 36 | compositionengine::LayerFECompositionState* editCompositionState() override; |
Lloyd Pique | feb73d7 | 2018-12-04 17:23:44 -0800 | [diff] [blame] | 37 | |
Vishnu Nair | fa247b1 | 2020-02-11 08:58:26 -0800 | [diff] [blame] | 38 | const char* getType() const override { return "EffectLayer"; } |
Lloyd Pique | 0449b0f | 2018-12-20 16:23:45 -0800 | [diff] [blame] | 39 | bool isVisible() const override; |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 40 | |
Valerie Hau | dd0b757 | 2019-01-29 14:59:27 -0800 | [diff] [blame] | 41 | bool setColor(const half3& color) override; |
| 42 | |
Valerie Hau | b153bab | 2019-03-05 10:47:28 -0800 | [diff] [blame] | 43 | bool setDataspace(ui::Dataspace dataspace) override; |
| 44 | |
chaviw | 4244e03 | 2019-09-04 11:27:49 -0700 | [diff] [blame] | 45 | ui::Dataspace getDataSpace() const override; |
Valerie Hau | b153bab | 2019-03-05 10:47:28 -0800 | [diff] [blame] | 46 | |
chaviw | 575144f | 2019-08-16 12:37:24 -0700 | [diff] [blame] | 47 | bool isOpaque(const Layer::State& s) const override; |
| 48 | |
Yichi Chen | f683340 | 2018-06-22 17:32:10 +0800 | [diff] [blame] | 49 | protected: |
Lloyd Pique | f16688f | 2019-02-19 17:47:57 -0800 | [diff] [blame] | 50 | /* |
| 51 | * compositionengine::LayerFE overrides |
| 52 | */ |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 53 | const compositionengine::LayerFECompositionState* getCompositionState() const override; |
| 54 | void preparePerFrameCompositionState() override; |
Vishnu Nair | b87d94f | 2020-02-13 09:17:36 -0800 | [diff] [blame] | 55 | std::vector<compositionengine::LayerFE::LayerSettings> prepareClientCompositionList( |
| 56 | compositionengine::LayerFE::ClientCompositionTargetSettings& targetSettings) override; |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 57 | |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 58 | std::unique_ptr<compositionengine::LayerFECompositionState> mCompositionState; |
chaviw | b4c6e58 | 2019-08-16 14:35:07 -0700 | [diff] [blame] | 59 | |
| 60 | sp<Layer> createClone() override; |
Vishnu Nair | b87d94f | 2020-02-13 09:17:36 -0800 | [diff] [blame] | 61 | |
| 62 | private: |
| 63 | // Returns true if there is a valid color to fill. |
| 64 | bool fillsColor() const; |
Lucas Dupin | b83097d | 2020-02-18 19:49:27 -0800 | [diff] [blame] | 65 | // Returns true if this layer has a blur value. |
| 66 | bool hasBlur() const; |
| 67 | bool hasSomethingToDraw() const { return fillsColor() || drawShadows() || hasBlur(); } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 68 | }; |
| 69 | |
Robert Carr | cdf8320 | 2018-03-07 12:48:34 -0800 | [diff] [blame] | 70 | } // namespace android |