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 */ 16 #pragma once 17 18 #include <sys/types.h> 19 20 #include <cstdint> 21 22 #include "Layer.h" 23 24 namespace android { 25 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 { 31 public: 32 explicit EffectLayer(const LayerCreationArgs&); 33 ~EffectLayer() override; 34 35 sp<compositionengine::LayerFE> getCompositionEngineLayerFE() const override; 36 compositionengine::LayerFECompositionState* editCompositionState() override; 37 getType()38 const char* getType() const override { return "EffectLayer"; } 39 bool isVisible() const override; 40 41 bool setColor(const half3& color) override; 42 43 bool setDataspace(ui::Dataspace dataspace) override; 44 45 ui::Dataspace getDataSpace() const override; 46 47 bool isOpaque(const Layer::State& s) const override; 48 49 protected: 50 /* 51 * compositionengine::LayerFE overrides 52 */ 53 const compositionengine::LayerFECompositionState* getCompositionState() const override; 54 void preparePerFrameCompositionState() override; 55 std::vector<compositionengine::LayerFE::LayerSettings> prepareClientCompositionList( 56 compositionengine::LayerFE::ClientCompositionTargetSettings& targetSettings) override; 57 58 std::unique_ptr<compositionengine::LayerFECompositionState> mCompositionState; 59 60 sp<Layer> createClone() override; 61 62 private: 63 // Returns true if there is a valid color to fill. 64 bool fillsColor() const; 65 // Returns true if this layer has a blur value. 66 bool hasBlur() const; hasSomethingToDraw()67 bool hasSomethingToDraw() const { return fillsColor() || drawShadows() || hasBlur(); } 68 }; 69 70 } // namespace android 71