1 /* 2 * Copyright 2019 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 19 #include <memory> 20 #include <string> 21 22 #include <compositionengine/OutputLayer.h> 23 #include <compositionengine/impl/OutputLayerCompositionState.h> 24 #include <ui/FloatRect.h> 25 #include <ui/Rect.h> 26 27 #include "DisplayHardware/DisplayIdentification.h" 28 29 namespace android::compositionengine::impl { 30 31 class OutputLayer : public compositionengine::OutputLayer { 32 public: 33 OutputLayer(const compositionengine::Output&, std::shared_ptr<compositionengine::Layer>, 34 sp<compositionengine::LayerFE>); 35 ~OutputLayer() override; 36 37 void initialize(const CompositionEngine&, std::optional<DisplayId>); 38 39 const compositionengine::Output& getOutput() const override; 40 compositionengine::Layer& getLayer() const override; 41 compositionengine::LayerFE& getLayerFE() const override; 42 43 const OutputLayerCompositionState& getState() const override; 44 OutputLayerCompositionState& editState() override; 45 46 void updateCompositionState(bool) override; 47 void writeStateToHWC(bool) const override; 48 49 void dump(std::string& result) const override; 50 51 virtual FloatRect calculateOutputSourceCrop() const; 52 virtual Rect calculateOutputDisplayFrame() const; 53 virtual uint32_t calculateOutputRelativeBufferTransform() const; 54 55 private: 56 Rect calculateInitialCrop() const; 57 58 const compositionengine::Output& mOutput; 59 std::shared_ptr<compositionengine::Layer> mLayer; 60 sp<compositionengine::LayerFE> mLayerFE; 61 62 OutputLayerCompositionState mState; 63 }; 64 65 std::unique_ptr<compositionengine::OutputLayer> createOutputLayer( 66 const CompositionEngine&, std::optional<DisplayId>, const compositionengine::Output&, 67 std::shared_ptr<compositionengine::Layer>, sp<compositionengine::LayerFE>); 68 69 } // namespace android::compositionengine::impl 70