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 <optional> 21 #include <string> 22 23 #include <ui/Transform.h> 24 #include <utils/StrongPointer.h> 25 26 // TODO(b/129481165): remove the #pragma below and fix conversion issues 27 #pragma clang diagnostic push 28 #pragma clang diagnostic ignored "-Wconversion" 29 #pragma clang diagnostic ignored "-Wextra" 30 31 #include "DisplayHardware/ComposerHal.h" 32 #include "DisplayHardware/DisplayIdentification.h" 33 34 #include "LayerFE.h" 35 36 // TODO(b/129481165): remove the #pragma below and fix conversion issues 37 #pragma clang diagnostic pop // ignored "-Wconversion -Wextra" 38 39 namespace android { 40 41 namespace HWC2 { 42 class Layer; 43 } // namespace HWC2 44 45 namespace compositionengine { 46 47 class CompositionEngine; 48 class Output; 49 50 namespace impl { 51 struct OutputLayerCompositionState; 52 } // namespace impl 53 54 /** 55 * An output layer contains the output-dependent composition state for a layer 56 */ 57 class OutputLayer { 58 public: 59 virtual ~OutputLayer(); 60 61 // Sets the HWC2::Layer associated with this layer 62 virtual void setHwcLayer(std::shared_ptr<HWC2::Layer>) = 0; 63 64 // Gets the output which owns this output layer 65 virtual const Output& getOutput() const = 0; 66 67 // Gets the front-end layer interface this output layer represents 68 virtual LayerFE& getLayerFE() const = 0; 69 70 using CompositionState = compositionengine::impl::OutputLayerCompositionState; 71 72 // Gets the raw composition state data for the layer 73 // TODO(lpique): Make this protected once it is only internally called. 74 virtual const CompositionState& getState() const = 0; 75 76 // Allows mutable access to the raw composition state data for the layer. 77 // This is meant to be used by the various functions that are part of the 78 // composition process. 79 // TODO(lpique): Make this protected once it is only internally called. 80 virtual CompositionState& editState() = 0; 81 82 // Recalculates the state of the output layer from the output-independent 83 // layer. If includeGeometry is false, the geometry state can be skipped. 84 // internalDisplayRotationFlags must be set to the rotation flags for the 85 // internal display, and is used to properly compute the inverse-display 86 // transform, if needed. 87 virtual void updateCompositionState( 88 bool includeGeometry, bool forceClientComposition, 89 ui::Transform::RotationFlags internalDisplayRotationFlags) = 0; 90 91 // Writes the geometry state to the HWC, or does nothing if this layer does 92 // not use the HWC. If includeGeometry is false, the geometry state can be 93 // skipped. If skipLayer is true, then the alpha of the layer is forced to 94 // 0 so that HWC will ignore it. z specifies the order to draw the layer in 95 // (starting with 0 for the back layer, and increasing for each following 96 // layer). zIsOverridden specifies whether the layer has been reordered. 97 // isPeekingThrough specifies whether this layer will be shown through a 98 // hole punch in a layer above it. 99 virtual void writeStateToHWC(bool includeGeometry, bool skipLayer, uint32_t z, 100 bool zIsOverridden, bool isPeekingThrough) = 0; 101 102 // Updates the cursor position with the HWC 103 virtual void writeCursorPositionToHWC() const = 0; 104 105 // Returns the HWC2::Layer associated with this layer, if it exists 106 virtual HWC2::Layer* getHwcLayer() const = 0; 107 108 // Returns true if the current layer state requires client composition 109 virtual bool requiresClientComposition() const = 0; 110 111 // Returns true if the current layer should be treated as a cursor layer 112 virtual bool isHardwareCursor() const = 0; 113 114 // Applies a HWC device requested composition type change 115 virtual void applyDeviceCompositionTypeChange(Hwc2::IComposerClient::Composition) = 0; 116 117 // Prepares to apply any HWC device layer requests 118 virtual void prepareForDeviceLayerRequests() = 0; 119 120 // Applies a HWC device layer request 121 virtual void applyDeviceLayerRequest(Hwc2::IComposerClient::LayerRequest request) = 0; 122 123 // Returns true if the composition settings scale pixels 124 virtual bool needsFiltering() const = 0; 125 126 // Returns a composition list to be used by RenderEngine if the layer has been overridden 127 // during the composition process 128 virtual std::vector<LayerFE::LayerSettings> getOverrideCompositionList() const = 0; 129 130 // Debugging 131 virtual void dump(std::string& result) const = 0; 132 }; 133 134 } // namespace compositionengine 135 } // namespace android 136