Lloyd Pique | 0b785d8 | 2018-12-04 17:25:27 -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 <cstdint> |
| 20 | |
| 21 | #include <gui/BufferQueue.h> |
| 22 | #include <gui/HdrMetadata.h> |
| 23 | #include <math/mat4.h> |
| 24 | #include <ui/FloatRect.h> |
| 25 | #include <ui/GraphicBuffer.h> |
| 26 | #include <ui/GraphicTypes.h> |
| 27 | #include <ui/Rect.h> |
| 28 | #include <ui/Region.h> |
| 29 | #include <ui/Transform.h> |
| 30 | |
| 31 | #include "DisplayHardware/ComposerHal.h" |
| 32 | |
| 33 | namespace android::compositionengine { |
| 34 | |
| 35 | /* |
| 36 | * Used by LayerFE::getCompositionState |
| 37 | */ |
| 38 | struct LayerFECompositionState { |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 39 | // If set to true, forces client composition on all output layers until |
| 40 | // the next geometry change. |
| 41 | bool forceClientComposition{false}; |
Lloyd Pique | 07e3321 | 2018-12-18 16:33:37 -0800 | [diff] [blame] | 42 | |
Lloyd Pique | c668734 | 2019-03-07 21:34:57 -0800 | [diff] [blame] | 43 | // TODO(b/121291683): Reorganize and rename the contents of this structure |
| 44 | |
| 45 | /* |
| 46 | * Visibility state |
| 47 | */ |
| 48 | // the layer stack this layer belongs to |
| 49 | std::optional<uint32_t> layerStackId; |
| 50 | |
| 51 | // If true, this layer should be only visible on the internal display |
| 52 | bool internalOnly{false}; |
| 53 | |
| 54 | // If false, this layer should not be considered visible |
| 55 | bool isVisible{true}; |
| 56 | |
| 57 | // True if the layer is completely opaque |
| 58 | bool isOpaque{true}; |
| 59 | |
| 60 | // If true, invalidates the entire visible region |
| 61 | bool contentDirty{false}; |
| 62 | |
| 63 | // The alpha value for this layer |
| 64 | float alpha{1.f}; |
| 65 | |
Lucas Dupin | 19c8f0e | 2019-11-25 17:55:44 -0800 | [diff] [blame^] | 66 | // Background blur in pixels |
| 67 | int backgroundBlurRadius{0}; |
| 68 | |
Lloyd Pique | c668734 | 2019-03-07 21:34:57 -0800 | [diff] [blame] | 69 | // The transform from layer local coordinates to composition coordinates |
| 70 | ui::Transform geomLayerTransform; |
| 71 | |
| 72 | // The inverse of the layer transform |
| 73 | ui::Transform geomInverseLayerTransform; |
| 74 | |
| 75 | // The hint from the layer producer as to what portion of the layer is |
| 76 | // transparent. |
| 77 | Region transparentRegionHint; |
| 78 | |
| 79 | // The blend mode for this layer |
| 80 | Hwc2::IComposerClient::BlendMode blendMode{Hwc2::IComposerClient::BlendMode::INVALID}; |
| 81 | |
| 82 | // The bounds of the layer in layer local coordinates |
| 83 | FloatRect geomLayerBounds; |
| 84 | |
Vishnu Nair | a483b4a | 2019-12-12 15:07:52 -0800 | [diff] [blame] | 85 | // length of the shadow in screen space |
| 86 | float shadowRadius; |
| 87 | |
Lloyd Pique | 0b785d8 | 2018-12-04 17:25:27 -0800 | [diff] [blame] | 88 | /* |
Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 89 | * Geometry state |
| 90 | */ |
| 91 | |
| 92 | bool isSecure{false}; |
| 93 | bool geomUsesSourceCrop{false}; |
| 94 | bool geomBufferUsesDisplayInverseTransform{false}; |
| 95 | uint32_t geomBufferTransform{0}; |
Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 96 | Rect geomBufferSize; |
| 97 | Rect geomContentCrop; |
| 98 | Rect geomCrop; |
Lloyd Pique | 0b785d8 | 2018-12-04 17:25:27 -0800 | [diff] [blame] | 99 | |
| 100 | /* |
| 101 | * Extra metadata |
| 102 | */ |
| 103 | |
| 104 | // The type for this layer |
| 105 | int type{0}; |
| 106 | |
| 107 | // The appId for this layer |
| 108 | int appId{0}; |
| 109 | |
| 110 | /* |
| 111 | * Per-frame content |
| 112 | */ |
| 113 | |
| 114 | // The type of composition for this layer |
| 115 | Hwc2::IComposerClient::Composition compositionType{Hwc2::IComposerClient::Composition::INVALID}; |
| 116 | |
| 117 | // The buffer and related state |
| 118 | sp<GraphicBuffer> buffer; |
| 119 | int bufferSlot{BufferQueue::INVALID_BUFFER_SLOT}; |
| 120 | sp<Fence> acquireFence; |
| 121 | Region surfaceDamage; |
| 122 | |
| 123 | // The handle to use for a sideband stream for this layer |
| 124 | sp<NativeHandle> sidebandStream; |
| 125 | |
| 126 | // The color for this layer |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 127 | half4 color; |
Lloyd Pique | 0b785d8 | 2018-12-04 17:25:27 -0800 | [diff] [blame] | 128 | |
| 129 | /* |
| 130 | * Per-frame presentation state |
| 131 | */ |
| 132 | |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 133 | // If true, this layer will use the dataspace chosen for the output and |
| 134 | // ignore the dataspace value just below |
| 135 | bool isColorspaceAgnostic{false}; |
| 136 | |
Lloyd Pique | 0b785d8 | 2018-12-04 17:25:27 -0800 | [diff] [blame] | 137 | // The dataspace for this layer |
| 138 | ui::Dataspace dataspace{ui::Dataspace::UNKNOWN}; |
| 139 | |
| 140 | // The metadata for this layer |
| 141 | HdrMetadata hdrMetadata; |
| 142 | |
| 143 | // The color transform |
| 144 | mat4 colorTransform; |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 145 | bool colorTransformIsIdentity{true}; |
Lloyd Pique | 688abd4 | 2019-02-15 15:42:24 -0800 | [diff] [blame] | 146 | |
Lloyd Pique | 688abd4 | 2019-02-15 15:42:24 -0800 | [diff] [blame] | 147 | // True if the layer has protected content |
| 148 | bool hasProtectedContent{false}; |
Lloyd Pique | c7b0c75 | 2019-03-07 20:59:59 -0800 | [diff] [blame] | 149 | |
| 150 | /* |
| 151 | * Cursor state |
| 152 | */ |
| 153 | |
| 154 | // The output-independent frame for the cursor |
| 155 | Rect cursorFrame; |
Lloyd Pique | 9755fb7 | 2019-03-26 14:44:40 -0700 | [diff] [blame] | 156 | |
| 157 | // Debugging |
| 158 | void dump(std::string& out) const; |
Lloyd Pique | 0b785d8 | 2018-12-04 17:25:27 -0800 | [diff] [blame] | 159 | }; |
| 160 | |
| 161 | } // namespace android::compositionengine |