blob: 1dcb633251237c775c6f26bc75d9dd33e3359b70 [file] [log] [blame]
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001/*
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 Carrcdf83202018-03-07 12:48:34 -080016#pragma once
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080017
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080018#include <sys/types.h>
19
Robert Carrcdf83202018-03-07 12:48:34 -080020#include <cstdint>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080021
Robert Carrcdf83202018-03-07 12:48:34 -080022#include "Layer.h"
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080023
Mathias Agopiancbb288b2009-09-07 16:32:45 -070024namespace android {
25
Vishnu Nairfa247b12020-02-11 08:58:26 -080026// 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.
30class EffectLayer : public Layer {
Jesse Hall382574d2014-08-07 22:33:14 -070031public:
Vishnu Nairfa247b12020-02-11 08:58:26 -080032 explicit EffectLayer(const LayerCreationArgs&);
33 ~EffectLayer() override;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080034
Lloyd Piquede196652020-01-22 17:29:58 -080035 sp<compositionengine::LayerFE> getCompositionEngineLayerFE() const override;
36 compositionengine::LayerFECompositionState* editCompositionState() override;
Lloyd Piquefeb73d72018-12-04 17:23:44 -080037
Vishnu Nairfa247b12020-02-11 08:58:26 -080038 const char* getType() const override { return "EffectLayer"; }
Lloyd Pique0449b0f2018-12-20 16:23:45 -080039 bool isVisible() const override;
David Sodman0c69cad2017-08-21 12:12:51 -070040
Valerie Haudd0b7572019-01-29 14:59:27 -080041 bool setColor(const half3& color) override;
42
Valerie Haub153bab2019-03-05 10:47:28 -080043 bool setDataspace(ui::Dataspace dataspace) override;
44
chaviw4244e032019-09-04 11:27:49 -070045 ui::Dataspace getDataSpace() const override;
Valerie Haub153bab2019-03-05 10:47:28 -080046
chaviw575144f2019-08-16 12:37:24 -070047 bool isOpaque(const Layer::State& s) const override;
48
Yichi Chenf6833402018-06-22 17:32:10 +080049protected:
Lloyd Piquef16688f2019-02-19 17:47:57 -080050 /*
51 * compositionengine::LayerFE overrides
52 */
Lloyd Piquede196652020-01-22 17:29:58 -080053 const compositionengine::LayerFECompositionState* getCompositionState() const override;
54 void preparePerFrameCompositionState() override;
Vishnu Nairb87d94f2020-02-13 09:17:36 -080055 std::vector<compositionengine::LayerFE::LayerSettings> prepareClientCompositionList(
56 compositionengine::LayerFE::ClientCompositionTargetSettings& targetSettings) override;
Lloyd Piquef5275482019-01-29 18:42:42 -080057
Lloyd Piquede196652020-01-22 17:29:58 -080058 std::unique_ptr<compositionengine::LayerFECompositionState> mCompositionState;
chaviwb4c6e582019-08-16 14:35:07 -070059
60 sp<Layer> createClone() override;
Vishnu Nairb87d94f2020-02-13 09:17:36 -080061
62private:
63 // Returns true if there is a valid color to fill.
64 bool fillsColor() const;
Lucas Dupinb83097d2020-02-18 19:49:27 -080065 // 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 Projectedbf3b62009-03-03 19:31:44 -080068};
69
Robert Carrcdf83202018-03-07 12:48:34 -080070} // namespace android