David Sodman | af8bab1 | 2017-12-14 15:30:55 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 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 <stdint.h> |
| 20 | #include <sys/types.h> |
| 21 | |
| 22 | #include <ui/Region.h> |
| 23 | |
| 24 | #include "SurfaceFlinger.h" |
| 25 | |
| 26 | #include "DisplayHardware/HWComposer.h" |
| 27 | #include "DisplayHardware/HWComposerBufferCache.h" |
| 28 | #include "RenderEngine/Mesh.h" |
| 29 | |
| 30 | namespace android { |
| 31 | |
| 32 | struct CompositionInfo { |
| 33 | HWC2::Composition compositionType; |
| 34 | sp<GraphicBuffer> mBuffer = nullptr; |
| 35 | int mBufferSlot = BufferQueue::INVALID_BUFFER_SLOT; |
| 36 | struct { |
| 37 | HWC2::Layer* hwcLayer; |
| 38 | int32_t hwid = -1; |
| 39 | sp<Fence> fence; |
| 40 | HWC2::BlendMode blendMode = HWC2::BlendMode::Invalid; |
| 41 | Rect displayFrame; |
| 42 | float alpha; |
| 43 | FloatRect sourceCrop; |
| 44 | HWC2::Transform transform = HWC2::Transform::None; |
| 45 | int z; |
| 46 | int type; |
| 47 | int appId; |
| 48 | Region visibleRegion; |
| 49 | Region surfaceDamage; |
| 50 | sp<NativeHandle> sidebandStream; |
| 51 | android_dataspace dataspace; |
| 52 | hwc_color_t color; |
| 53 | } hwc; |
| 54 | struct { |
| 55 | Mesh* mesh; |
| 56 | } renderEngine; |
| 57 | }; |
| 58 | |
| 59 | class LayerBE { |
| 60 | public: |
| 61 | LayerBE(); |
| 62 | |
| 63 | // The mesh used to draw the layer in GLES composition mode |
| 64 | Mesh mMesh; |
| 65 | |
| 66 | // HWC items, accessed from the main thread |
| 67 | struct HWCInfo { |
| 68 | HWCInfo() |
| 69 | : hwc(nullptr), |
| 70 | layer(nullptr), |
| 71 | forceClientComposition(false), |
| 72 | compositionType(HWC2::Composition::Invalid), |
Yiwei Zhang | 7124ad3 | 2018-02-21 13:02:45 -0800 | [diff] [blame^] | 73 | clearClientTarget(false), |
| 74 | transform(HWC2::Transform::None) {} |
David Sodman | af8bab1 | 2017-12-14 15:30:55 -0800 | [diff] [blame] | 75 | |
| 76 | HWComposer* hwc; |
| 77 | HWC2::Layer* layer; |
| 78 | bool forceClientComposition; |
| 79 | HWC2::Composition compositionType; |
| 80 | bool clearClientTarget; |
| 81 | Rect displayFrame; |
| 82 | FloatRect sourceCrop; |
| 83 | HWComposerBufferCache bufferCache; |
Yiwei Zhang | 7124ad3 | 2018-02-21 13:02:45 -0800 | [diff] [blame^] | 84 | HWC2::Transform transform; |
David Sodman | af8bab1 | 2017-12-14 15:30:55 -0800 | [diff] [blame] | 85 | }; |
| 86 | |
| 87 | |
| 88 | // A layer can be attached to multiple displays when operating in mirror mode |
| 89 | // (a.k.a: when several displays are attached with equal layerStack). In this |
| 90 | // case we need to keep track. In non-mirror mode, a layer will have only one |
| 91 | // HWCInfo. This map key is a display layerStack. |
| 92 | std::unordered_map<int32_t, HWCInfo> mHwcLayers; |
| 93 | |
| 94 | CompositionInfo compositionInfo; |
| 95 | }; |
| 96 | |
| 97 | }; // namespace android |
| 98 | |