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