Lloyd Pique | cc01a45 | 2018-12-04 17:24:00 -0800 | [diff] [blame] | 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> |
Lloyd Pique | 37c2c9b | 2018-12-04 17:25:10 -0800 | [diff] [blame] | 20 | #include <string> |
Lloyd Pique | cc01a45 | 2018-12-04 17:24:00 -0800 | [diff] [blame] | 21 | |
| 22 | #include <compositionengine/OutputLayer.h> |
Lloyd Pique | 37c2c9b | 2018-12-04 17:25:10 -0800 | [diff] [blame] | 23 | #include <compositionengine/impl/OutputLayerCompositionState.h> |
Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 24 | #include <ui/FloatRect.h> |
| 25 | #include <ui/Rect.h> |
Lloyd Pique | cc01a45 | 2018-12-04 17:24:00 -0800 | [diff] [blame] | 26 | |
Lloyd Pique | 07e3321 | 2018-12-18 16:33:37 -0800 | [diff] [blame] | 27 | #include "DisplayHardware/DisplayIdentification.h" |
| 28 | |
Lloyd Pique | cc01a45 | 2018-12-04 17:24:00 -0800 | [diff] [blame] | 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 | |
Lloyd Pique | 07e3321 | 2018-12-18 16:33:37 -0800 | [diff] [blame] | 37 | void initialize(const CompositionEngine&, std::optional<DisplayId>); |
| 38 | |
Lloyd Pique | cc01a45 | 2018-12-04 17:24:00 -0800 | [diff] [blame] | 39 | const compositionengine::Output& getOutput() const override; |
| 40 | compositionengine::Layer& getLayer() const override; |
| 41 | compositionengine::LayerFE& getLayerFE() const override; |
| 42 | |
Lloyd Pique | 37c2c9b | 2018-12-04 17:25:10 -0800 | [diff] [blame] | 43 | const OutputLayerCompositionState& getState() const override; |
| 44 | OutputLayerCompositionState& editState() override; |
| 45 | |
Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 46 | void updateCompositionState(bool) override; |
| 47 | void writeStateToHWC(bool) const override; |
| 48 | |
Lloyd Pique | 37c2c9b | 2018-12-04 17:25:10 -0800 | [diff] [blame] | 49 | void dump(std::string& result) const override; |
| 50 | |
Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 51 | virtual FloatRect calculateOutputSourceCrop() const; |
| 52 | virtual Rect calculateOutputDisplayFrame() const; |
| 53 | virtual uint32_t calculateOutputRelativeBufferTransform() const; |
| 54 | |
Lloyd Pique | cc01a45 | 2018-12-04 17:24:00 -0800 | [diff] [blame] | 55 | private: |
Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 56 | Rect calculateInitialCrop() const; |
| 57 | |
Lloyd Pique | cc01a45 | 2018-12-04 17:24:00 -0800 | [diff] [blame] | 58 | const compositionengine::Output& mOutput; |
| 59 | std::shared_ptr<compositionengine::Layer> mLayer; |
| 60 | sp<compositionengine::LayerFE> mLayerFE; |
Lloyd Pique | 37c2c9b | 2018-12-04 17:25:10 -0800 | [diff] [blame] | 61 | |
| 62 | OutputLayerCompositionState mState; |
Lloyd Pique | cc01a45 | 2018-12-04 17:24:00 -0800 | [diff] [blame] | 63 | }; |
| 64 | |
| 65 | std::unique_ptr<compositionengine::OutputLayer> createOutputLayer( |
Lloyd Pique | 07e3321 | 2018-12-18 16:33:37 -0800 | [diff] [blame] | 66 | const CompositionEngine&, std::optional<DisplayId>, const compositionengine::Output&, |
| 67 | std::shared_ptr<compositionengine::Layer>, sp<compositionengine::LayerFE>); |
Lloyd Pique | cc01a45 | 2018-12-04 17:24:00 -0800 | [diff] [blame] | 68 | |
| 69 | } // namespace android::compositionengine::impl |