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 | |
| 66 | // The transform from layer local coordinates to composition coordinates |
| 67 | ui::Transform geomLayerTransform; |
| 68 | |
| 69 | // The inverse of the layer transform |
| 70 | ui::Transform geomInverseLayerTransform; |
| 71 | |
| 72 | // The hint from the layer producer as to what portion of the layer is |
| 73 | // transparent. |
| 74 | Region transparentRegionHint; |
| 75 | |
| 76 | // The blend mode for this layer |
| 77 | Hwc2::IComposerClient::BlendMode blendMode{Hwc2::IComposerClient::BlendMode::INVALID}; |
| 78 | |
| 79 | // The bounds of the layer in layer local coordinates |
| 80 | FloatRect geomLayerBounds; |
| 81 | |
Lloyd Pique | 0b785d8 | 2018-12-04 17:25:27 -0800 | [diff] [blame] | 82 | /* |
Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 83 | * Geometry state |
| 84 | */ |
| 85 | |
| 86 | bool isSecure{false}; |
| 87 | bool geomUsesSourceCrop{false}; |
| 88 | bool geomBufferUsesDisplayInverseTransform{false}; |
| 89 | uint32_t geomBufferTransform{0}; |
Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 90 | Rect geomBufferSize; |
| 91 | Rect geomContentCrop; |
| 92 | Rect geomCrop; |
Lloyd Pique | 0b785d8 | 2018-12-04 17:25:27 -0800 | [diff] [blame] | 93 | |
| 94 | /* |
| 95 | * Extra metadata |
| 96 | */ |
| 97 | |
| 98 | // The type for this layer |
| 99 | int type{0}; |
| 100 | |
| 101 | // The appId for this layer |
| 102 | int appId{0}; |
| 103 | |
| 104 | /* |
| 105 | * Per-frame content |
| 106 | */ |
| 107 | |
| 108 | // The type of composition for this layer |
| 109 | Hwc2::IComposerClient::Composition compositionType{Hwc2::IComposerClient::Composition::INVALID}; |
| 110 | |
| 111 | // The buffer and related state |
| 112 | sp<GraphicBuffer> buffer; |
| 113 | int bufferSlot{BufferQueue::INVALID_BUFFER_SLOT}; |
| 114 | sp<Fence> acquireFence; |
| 115 | Region surfaceDamage; |
| 116 | |
| 117 | // The handle to use for a sideband stream for this layer |
| 118 | sp<NativeHandle> sidebandStream; |
| 119 | |
| 120 | // The color for this layer |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 121 | half4 color; |
Lloyd Pique | 0b785d8 | 2018-12-04 17:25:27 -0800 | [diff] [blame] | 122 | |
| 123 | /* |
| 124 | * Per-frame presentation state |
| 125 | */ |
| 126 | |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 127 | // If true, this layer will use the dataspace chosen for the output and |
| 128 | // ignore the dataspace value just below |
| 129 | bool isColorspaceAgnostic{false}; |
| 130 | |
Lloyd Pique | 0b785d8 | 2018-12-04 17:25:27 -0800 | [diff] [blame] | 131 | // The dataspace for this layer |
| 132 | ui::Dataspace dataspace{ui::Dataspace::UNKNOWN}; |
| 133 | |
| 134 | // The metadata for this layer |
| 135 | HdrMetadata hdrMetadata; |
| 136 | |
| 137 | // The color transform |
| 138 | mat4 colorTransform; |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 139 | bool colorTransformIsIdentity{true}; |
Lloyd Pique | 688abd4 | 2019-02-15 15:42:24 -0800 | [diff] [blame] | 140 | |
Lloyd Pique | 688abd4 | 2019-02-15 15:42:24 -0800 | [diff] [blame] | 141 | // True if the layer has protected content |
| 142 | bool hasProtectedContent{false}; |
Lloyd Pique | c7b0c75 | 2019-03-07 20:59:59 -0800 | [diff] [blame] | 143 | |
| 144 | /* |
| 145 | * Cursor state |
| 146 | */ |
| 147 | |
| 148 | // The output-independent frame for the cursor |
| 149 | Rect cursorFrame; |
Lloyd Pique | 0b785d8 | 2018-12-04 17:25:27 -0800 | [diff] [blame] | 150 | }; |
| 151 | |
| 152 | } // namespace android::compositionengine |