Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [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 <cstdint> |
| 20 | #include <string> |
| 21 | |
| 22 | #include <math/mat4.h> |
| 23 | #include <ui/GraphicTypes.h> |
| 24 | #include <ui/Region.h> |
| 25 | #include <ui/Transform.h> |
Lloyd Pique | cc01a45 | 2018-12-04 17:24:00 -0800 | [diff] [blame] | 26 | #include <utils/StrongPointer.h> |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 27 | |
| 28 | namespace android::compositionengine { |
| 29 | |
Lloyd Pique | 3d0c02e | 2018-10-19 18:38:12 -0700 | [diff] [blame] | 30 | class DisplayColorProfile; |
Lloyd Pique | cc01a45 | 2018-12-04 17:24:00 -0800 | [diff] [blame] | 31 | class Layer; |
| 32 | class LayerFE; |
Lloyd Pique | 31cb294 | 2018-10-19 17:23:03 -0700 | [diff] [blame] | 33 | class RenderSurface; |
Lloyd Pique | cc01a45 | 2018-12-04 17:24:00 -0800 | [diff] [blame] | 34 | class OutputLayer; |
Lloyd Pique | 31cb294 | 2018-10-19 17:23:03 -0700 | [diff] [blame] | 35 | |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 36 | namespace impl { |
| 37 | struct OutputCompositionState; |
| 38 | } // namespace impl |
| 39 | |
| 40 | /** |
| 41 | * Encapsulates all the state involved with composing layers for an output |
| 42 | */ |
| 43 | class Output { |
| 44 | public: |
Lloyd Pique | cc01a45 | 2018-12-04 17:24:00 -0800 | [diff] [blame] | 45 | using OutputLayers = std::vector<std::unique_ptr<compositionengine::OutputLayer>>; |
| 46 | |
Lloyd Pique | feb73d7 | 2018-12-04 17:23:44 -0800 | [diff] [blame] | 47 | virtual ~Output(); |
| 48 | |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 49 | // Returns true if the output is valid. This is meant to be checked post- |
| 50 | // construction and prior to use, as not everything is set up by the |
| 51 | // constructor. |
| 52 | virtual bool isValid() const = 0; |
| 53 | |
| 54 | // Enables (or disables) composition on this output |
| 55 | virtual void setCompositionEnabled(bool) = 0; |
| 56 | |
| 57 | // Sets the projection state to use |
| 58 | virtual void setProjection(const ui::Transform&, int32_t orientation, const Rect& frame, |
| 59 | const Rect& viewport, const Rect& scissor, bool needsFiltering) = 0; |
| 60 | // Sets the bounds to use |
Lloyd Pique | 31cb294 | 2018-10-19 17:23:03 -0700 | [diff] [blame] | 61 | virtual void setBounds(const ui::Size&) = 0; |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 62 | |
Lloyd Pique | ef36b00 | 2019-01-23 17:52:04 -0800 | [diff] [blame] | 63 | // Sets the layer stack filtering settings for this output. See |
| 64 | // belongsInOutput for full details. |
| 65 | virtual void setLayerStackFilter(uint32_t layerStackId, bool isInternal) = 0; |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 66 | |
| 67 | // Sets the color transform matrix to use |
| 68 | virtual void setColorTransform(const mat4&) = 0; |
| 69 | |
| 70 | // Sets the output color mode |
| 71 | virtual void setColorMode(ui::ColorMode, ui::Dataspace, ui::RenderIntent) = 0; |
| 72 | |
| 73 | // Outputs a string with a state dump |
| 74 | virtual void dump(std::string&) const = 0; |
| 75 | |
| 76 | // Gets the debug name for the output |
| 77 | virtual const std::string& getName() const = 0; |
| 78 | |
| 79 | // Sets a debug name for the output |
| 80 | virtual void setName(const std::string&) = 0; |
| 81 | |
Lloyd Pique | 3d0c02e | 2018-10-19 18:38:12 -0700 | [diff] [blame] | 82 | // Gets the current render color mode for the output |
| 83 | virtual DisplayColorProfile* getDisplayColorProfile() const = 0; |
| 84 | |
Lloyd Pique | 31cb294 | 2018-10-19 17:23:03 -0700 | [diff] [blame] | 85 | // Gets the current render surface for the output |
| 86 | virtual RenderSurface* getRenderSurface() const = 0; |
| 87 | |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 88 | using OutputCompositionState = compositionengine::impl::OutputCompositionState; |
| 89 | |
| 90 | // Gets the raw composition state data for the output |
| 91 | // TODO(lpique): Make this protected once it is only internally called. |
| 92 | virtual const OutputCompositionState& getState() const = 0; |
| 93 | |
| 94 | // Allows mutable access to the raw composition state data for the output. |
| 95 | // This is meant to be used by the various functions that are part of the |
| 96 | // composition process. |
| 97 | // TODO(lpique): Make this protected once it is only internally called. |
| 98 | virtual OutputCompositionState& editState() = 0; |
| 99 | |
Alec Mouri | 79108df | 2019-02-04 19:33:44 +0000 | [diff] [blame] | 100 | // Gets the physical space dirty region. If repaintEverything is true, this |
| 101 | // will be the full display bounds. Internally the dirty region is stored in |
| 102 | // logical (aka layer stack) space. |
| 103 | virtual Region getPhysicalSpaceDirtyRegion(bool repaintEverything) const = 0; |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 104 | |
Lloyd Pique | ef36b00 | 2019-01-23 17:52:04 -0800 | [diff] [blame] | 105 | // Tests whether a given layerStackId belongs in this output. |
| 106 | // A layer belongs to the output if its layerStackId matches the of the output layerStackId, |
| 107 | // unless the layer should display on the primary output only and this is not the primary output |
| 108 | |
| 109 | // A layer belongs to the output if its layerStackId matches. Additionally |
| 110 | // if the layer should only show in the internal (primary) display only and |
| 111 | // this output allows that. |
| 112 | virtual bool belongsInOutput(uint32_t layerStackId, bool internalOnly) const = 0; |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 113 | |
Lloyd Pique | cc01a45 | 2018-12-04 17:24:00 -0800 | [diff] [blame] | 114 | // Returns a pointer to the output layer corresponding to the given layer on |
| 115 | // this output, or nullptr if the layer does not have one |
| 116 | virtual OutputLayer* getOutputLayerForLayer(Layer*) const = 0; |
| 117 | |
| 118 | // Gets the OutputLayer corresponding to the input Layer instance from the |
| 119 | // current ordered set of output layers. If there is no such layer, a new |
| 120 | // one is created and returned. |
| 121 | virtual std::unique_ptr<OutputLayer> getOrCreateOutputLayer(std::shared_ptr<Layer>, |
| 122 | sp<LayerFE>) = 0; |
| 123 | |
| 124 | // Sets the new ordered set of output layers for this output |
| 125 | virtual void setOutputLayersOrderedByZ(OutputLayers&&) = 0; |
| 126 | |
| 127 | // Gets the ordered set of output layers for this output |
| 128 | virtual const OutputLayers& getOutputLayersOrderedByZ() const = 0; |
| 129 | |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 130 | protected: |
Lloyd Pique | 3d0c02e | 2018-10-19 18:38:12 -0700 | [diff] [blame] | 131 | virtual void setDisplayColorProfile(std::unique_ptr<DisplayColorProfile>) = 0; |
| 132 | virtual void setRenderSurface(std::unique_ptr<RenderSurface>) = 0; |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 133 | }; |
| 134 | |
| 135 | } // namespace android::compositionengine |