xref: /aosp_15_r20/frameworks/native/services/surfaceflinger/DisplayHardware/HWC2.h (revision 38e8c45f13ce32b0dcecb25141ffecaf386fa17f)
1*38e8c45fSAndroid Build Coastguard Worker /*
2*38e8c45fSAndroid Build Coastguard Worker  * Copyright 2015 The Android Open Source Project
3*38e8c45fSAndroid Build Coastguard Worker  *
4*38e8c45fSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*38e8c45fSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*38e8c45fSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*38e8c45fSAndroid Build Coastguard Worker  *
8*38e8c45fSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*38e8c45fSAndroid Build Coastguard Worker  *
10*38e8c45fSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*38e8c45fSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*38e8c45fSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*38e8c45fSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*38e8c45fSAndroid Build Coastguard Worker  * limitations under the License.
15*38e8c45fSAndroid Build Coastguard Worker  */
16*38e8c45fSAndroid Build Coastguard Worker 
17*38e8c45fSAndroid Build Coastguard Worker #pragma once
18*38e8c45fSAndroid Build Coastguard Worker 
19*38e8c45fSAndroid Build Coastguard Worker #include <android-base/expected.h>
20*38e8c45fSAndroid Build Coastguard Worker #include <android-base/thread_annotations.h>
21*38e8c45fSAndroid Build Coastguard Worker #include <ftl/expected.h>
22*38e8c45fSAndroid Build Coastguard Worker #include <ftl/future.h>
23*38e8c45fSAndroid Build Coastguard Worker #include <ftl/small_map.h>
24*38e8c45fSAndroid Build Coastguard Worker #include <gui/HdrMetadata.h>
25*38e8c45fSAndroid Build Coastguard Worker #include <math/mat4.h>
26*38e8c45fSAndroid Build Coastguard Worker #include <ui/HdrCapabilities.h>
27*38e8c45fSAndroid Build Coastguard Worker #include <ui/PictureProfileHandle.h>
28*38e8c45fSAndroid Build Coastguard Worker #include <ui/Region.h>
29*38e8c45fSAndroid Build Coastguard Worker #include <ui/StaticDisplayInfo.h>
30*38e8c45fSAndroid Build Coastguard Worker #include <utils/Log.h>
31*38e8c45fSAndroid Build Coastguard Worker #include <utils/StrongPointer.h>
32*38e8c45fSAndroid Build Coastguard Worker #include <utils/Timers.h>
33*38e8c45fSAndroid Build Coastguard Worker 
34*38e8c45fSAndroid Build Coastguard Worker #include <functional>
35*38e8c45fSAndroid Build Coastguard Worker #include <string>
36*38e8c45fSAndroid Build Coastguard Worker #include <unordered_map>
37*38e8c45fSAndroid Build Coastguard Worker #include <unordered_set>
38*38e8c45fSAndroid Build Coastguard Worker #include <vector>
39*38e8c45fSAndroid Build Coastguard Worker 
40*38e8c45fSAndroid Build Coastguard Worker #include "ComposerHal.h"
41*38e8c45fSAndroid Build Coastguard Worker #include "Hal.h"
42*38e8c45fSAndroid Build Coastguard Worker 
43*38e8c45fSAndroid Build Coastguard Worker #include <aidl/android/hardware/graphics/common/DisplayDecorationSupport.h>
44*38e8c45fSAndroid Build Coastguard Worker #include <aidl/android/hardware/graphics/common/DisplayHotplugEvent.h>
45*38e8c45fSAndroid Build Coastguard Worker #include <aidl/android/hardware/graphics/composer3/Capability.h>
46*38e8c45fSAndroid Build Coastguard Worker #include <aidl/android/hardware/graphics/composer3/ClientTargetPropertyWithBrightness.h>
47*38e8c45fSAndroid Build Coastguard Worker #include <aidl/android/hardware/graphics/composer3/Color.h>
48*38e8c45fSAndroid Build Coastguard Worker #include <aidl/android/hardware/graphics/composer3/Composition.h>
49*38e8c45fSAndroid Build Coastguard Worker #include <aidl/android/hardware/graphics/composer3/DisplayCapability.h>
50*38e8c45fSAndroid Build Coastguard Worker #include <aidl/android/hardware/graphics/composer3/Luts.h>
51*38e8c45fSAndroid Build Coastguard Worker #include <aidl/android/hardware/graphics/composer3/OverlayProperties.h>
52*38e8c45fSAndroid Build Coastguard Worker #include <aidl/android/hardware/graphics/composer3/RefreshRateChangedDebugData.h>
53*38e8c45fSAndroid Build Coastguard Worker 
54*38e8c45fSAndroid Build Coastguard Worker namespace android {
55*38e8c45fSAndroid Build Coastguard Worker 
56*38e8c45fSAndroid Build Coastguard Worker class Fence;
57*38e8c45fSAndroid Build Coastguard Worker class FloatRect;
58*38e8c45fSAndroid Build Coastguard Worker class GraphicBuffer;
59*38e8c45fSAndroid Build Coastguard Worker class TestableSurfaceFlinger;
60*38e8c45fSAndroid Build Coastguard Worker struct DisplayedFrameStats;
61*38e8c45fSAndroid Build Coastguard Worker 
62*38e8c45fSAndroid Build Coastguard Worker namespace Hwc2 {
63*38e8c45fSAndroid Build Coastguard Worker class Composer;
64*38e8c45fSAndroid Build Coastguard Worker } // namespace Hwc2
65*38e8c45fSAndroid Build Coastguard Worker 
66*38e8c45fSAndroid Build Coastguard Worker namespace HWC2 {
67*38e8c45fSAndroid Build Coastguard Worker 
68*38e8c45fSAndroid Build Coastguard Worker class Layer;
69*38e8c45fSAndroid Build Coastguard Worker 
70*38e8c45fSAndroid Build Coastguard Worker namespace hal = android::hardware::graphics::composer::hal;
71*38e8c45fSAndroid Build Coastguard Worker 
72*38e8c45fSAndroid Build Coastguard Worker using aidl::android::hardware::drm::HdcpLevels;
73*38e8c45fSAndroid Build Coastguard Worker using aidl::android::hardware::graphics::common::DisplayHotplugEvent;
74*38e8c45fSAndroid Build Coastguard Worker using aidl::android::hardware::graphics::composer3::RefreshRateChangedDebugData;
75*38e8c45fSAndroid Build Coastguard Worker 
76*38e8c45fSAndroid Build Coastguard Worker // Implement this interface to receive hardware composer events.
77*38e8c45fSAndroid Build Coastguard Worker //
78*38e8c45fSAndroid Build Coastguard Worker // These callback functions will generally be called on a hwbinder thread, but
79*38e8c45fSAndroid Build Coastguard Worker // when first registering the callback the onComposerHalHotplugEvent() function
80*38e8c45fSAndroid Build Coastguard Worker // will immediately be called on the thread calling registerCallback().
81*38e8c45fSAndroid Build Coastguard Worker struct ComposerCallback {
82*38e8c45fSAndroid Build Coastguard Worker     virtual void onComposerHalHotplugEvent(hal::HWDisplayId, DisplayHotplugEvent) = 0;
83*38e8c45fSAndroid Build Coastguard Worker     virtual void onComposerHalRefresh(hal::HWDisplayId) = 0;
84*38e8c45fSAndroid Build Coastguard Worker     virtual void onComposerHalVsync(hal::HWDisplayId, nsecs_t timestamp,
85*38e8c45fSAndroid Build Coastguard Worker                                     std::optional<hal::VsyncPeriodNanos>) = 0;
86*38e8c45fSAndroid Build Coastguard Worker     virtual void onComposerHalVsyncPeriodTimingChanged(hal::HWDisplayId,
87*38e8c45fSAndroid Build Coastguard Worker                                                        const hal::VsyncPeriodChangeTimeline&) = 0;
88*38e8c45fSAndroid Build Coastguard Worker     virtual void onComposerHalSeamlessPossible(hal::HWDisplayId) = 0;
89*38e8c45fSAndroid Build Coastguard Worker     virtual void onComposerHalVsyncIdle(hal::HWDisplayId) = 0;
90*38e8c45fSAndroid Build Coastguard Worker     virtual void onRefreshRateChangedDebug(const RefreshRateChangedDebugData&) = 0;
91*38e8c45fSAndroid Build Coastguard Worker     virtual void onComposerHalHdcpLevelsChanged(hal::HWDisplayId, const HdcpLevels& levels) = 0;
92*38e8c45fSAndroid Build Coastguard Worker 
93*38e8c45fSAndroid Build Coastguard Worker protected:
94*38e8c45fSAndroid Build Coastguard Worker     ~ComposerCallback() = default;
95*38e8c45fSAndroid Build Coastguard Worker };
96*38e8c45fSAndroid Build Coastguard Worker 
97*38e8c45fSAndroid Build Coastguard Worker // Convenience C++ class to access per display functions directly.
98*38e8c45fSAndroid Build Coastguard Worker class Display {
99*38e8c45fSAndroid Build Coastguard Worker public:
100*38e8c45fSAndroid Build Coastguard Worker     virtual ~Display();
101*38e8c45fSAndroid Build Coastguard Worker 
102*38e8c45fSAndroid Build Coastguard Worker     virtual hal::HWDisplayId getId() const = 0;
103*38e8c45fSAndroid Build Coastguard Worker     virtual bool isConnected() const = 0;
104*38e8c45fSAndroid Build Coastguard Worker     virtual void setConnected(bool connected) = 0; // For use by HWComposer only
105*38e8c45fSAndroid Build Coastguard Worker     virtual bool hasCapability(
106*38e8c45fSAndroid Build Coastguard Worker             aidl::android::hardware::graphics::composer3::DisplayCapability) const = 0;
107*38e8c45fSAndroid Build Coastguard Worker     virtual bool isVsyncPeriodSwitchSupported() const = 0;
108*38e8c45fSAndroid Build Coastguard Worker     virtual bool hasDisplayIdleTimerCapability() const = 0;
109*38e8c45fSAndroid Build Coastguard Worker     virtual void onLayerDestroyed(hal::HWLayerId layerId) = 0;
110*38e8c45fSAndroid Build Coastguard Worker     virtual std::optional<ui::Size> getPhysicalSizeInMm() const = 0;
111*38e8c45fSAndroid Build Coastguard Worker 
112*38e8c45fSAndroid Build Coastguard Worker     static const int kLutFileDescriptorMapperSize = 20;
113*38e8c45fSAndroid Build Coastguard Worker     using LutOffsetAndProperties = std::vector<
114*38e8c45fSAndroid Build Coastguard Worker             std::pair<int32_t, aidl::android::hardware::graphics::composer3::LutProperties>>;
115*38e8c45fSAndroid Build Coastguard Worker     using LayerLuts =
116*38e8c45fSAndroid Build Coastguard Worker             ftl::SmallMap<HWC2::Layer*, LutOffsetAndProperties, kLutFileDescriptorMapperSize>;
117*38e8c45fSAndroid Build Coastguard Worker     using LutFileDescriptorMapper =
118*38e8c45fSAndroid Build Coastguard Worker             ftl::SmallMap<HWC2::Layer*, ndk::ScopedFileDescriptor, kLutFileDescriptorMapperSize>;
119*38e8c45fSAndroid Build Coastguard Worker 
120*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error acceptChanges() = 0;
121*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual base::expected<std::shared_ptr<HWC2::Layer>, hal::Error>
122*38e8c45fSAndroid Build Coastguard Worker     createLayer() = 0;
123*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error getChangedCompositionTypes(
124*38e8c45fSAndroid Build Coastguard Worker             std::unordered_map<Layer*, aidl::android::hardware::graphics::composer3::Composition>*
125*38e8c45fSAndroid Build Coastguard Worker                     outTypes) = 0;
126*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error getColorModes(std::vector<hal::ColorMode>* outModes) const = 0;
127*38e8c45fSAndroid Build Coastguard Worker     // Returns a bitmask which contains HdrMetadata::Type::*.
128*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual int32_t getSupportedPerFrameMetadata() const = 0;
129*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error getRenderIntents(
130*38e8c45fSAndroid Build Coastguard Worker             hal::ColorMode colorMode, std::vector<hal::RenderIntent>* outRenderIntents) const = 0;
131*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error getDataspaceSaturationMatrix(hal::Dataspace dataspace,
132*38e8c45fSAndroid Build Coastguard Worker                                                                   android::mat4* outMatrix) = 0;
133*38e8c45fSAndroid Build Coastguard Worker 
134*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error getName(std::string* outName) const = 0;
135*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error getRequests(
136*38e8c45fSAndroid Build Coastguard Worker             hal::DisplayRequest* outDisplayRequests,
137*38e8c45fSAndroid Build Coastguard Worker             std::unordered_map<Layer*, hal::LayerRequest>* outLayerRequests) = 0;
138*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual ftl::Expected<ui::DisplayConnectionType, hal::Error> getConnectionType()
139*38e8c45fSAndroid Build Coastguard Worker             const = 0;
140*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error supportsDoze(bool* outSupport) const = 0;
141*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error getHdrCapabilities(
142*38e8c45fSAndroid Build Coastguard Worker             android::HdrCapabilities* outCapabilities) const = 0;
143*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error getOverlaySupport(
144*38e8c45fSAndroid Build Coastguard Worker             aidl::android::hardware::graphics::composer3::OverlayProperties* outProperties)
145*38e8c45fSAndroid Build Coastguard Worker             const = 0;
146*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error getDisplayedContentSamplingAttributes(
147*38e8c45fSAndroid Build Coastguard Worker             hal::PixelFormat* outFormat, hal::Dataspace* outDataspace,
148*38e8c45fSAndroid Build Coastguard Worker             uint8_t* outComponentMask) const = 0;
149*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error setDisplayContentSamplingEnabled(bool enabled,
150*38e8c45fSAndroid Build Coastguard Worker                                                                       uint8_t componentMask,
151*38e8c45fSAndroid Build Coastguard Worker                                                                       uint64_t maxFrames) const = 0;
152*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error getDisplayedContentSample(
153*38e8c45fSAndroid Build Coastguard Worker             uint64_t maxFrames, uint64_t timestamp,
154*38e8c45fSAndroid Build Coastguard Worker             android::DisplayedFrameStats* outStats) const = 0;
155*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error getReleaseFences(
156*38e8c45fSAndroid Build Coastguard Worker             std::unordered_map<Layer*, android::sp<android::Fence>>* outFences) const = 0;
157*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error present(android::sp<android::Fence>* outPresentFence) = 0;
158*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error setClientTarget(
159*38e8c45fSAndroid Build Coastguard Worker             uint32_t slot, const android::sp<android::GraphicBuffer>& target,
160*38e8c45fSAndroid Build Coastguard Worker             const android::sp<android::Fence>& acquireFence, hal::Dataspace dataspace,
161*38e8c45fSAndroid Build Coastguard Worker             float hdrSdrRatio) = 0;
162*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error setColorMode(hal::ColorMode mode,
163*38e8c45fSAndroid Build Coastguard Worker                                                   hal::RenderIntent renderIntent) = 0;
164*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error setColorTransform(const android::mat4& matrix) = 0;
165*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error setOutputBuffer(
166*38e8c45fSAndroid Build Coastguard Worker             const android::sp<android::GraphicBuffer>& buffer,
167*38e8c45fSAndroid Build Coastguard Worker             const android::sp<android::Fence>& releaseFence) = 0;
168*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error setPowerMode(hal::PowerMode mode) = 0;
169*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error setVsyncEnabled(hal::Vsync enabled) = 0;
170*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error validate(nsecs_t expectedPresentTime, int32_t frameIntervalNs,
171*38e8c45fSAndroid Build Coastguard Worker                                               uint32_t* outNumTypes, uint32_t* outNumRequests) = 0;
172*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error presentOrValidate(nsecs_t expectedPresentTime,
173*38e8c45fSAndroid Build Coastguard Worker                                                        int32_t frameIntervalNs,
174*38e8c45fSAndroid Build Coastguard Worker                                                        uint32_t* outNumTypes,
175*38e8c45fSAndroid Build Coastguard Worker                                                        uint32_t* outNumRequests,
176*38e8c45fSAndroid Build Coastguard Worker                                                        android::sp<android::Fence>* outPresentFence,
177*38e8c45fSAndroid Build Coastguard Worker                                                        uint32_t* state) = 0;
178*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual ftl::Future<hal::Error> setDisplayBrightness(
179*38e8c45fSAndroid Build Coastguard Worker             float brightness, float brightnessNits,
180*38e8c45fSAndroid Build Coastguard Worker             const Hwc2::Composer::DisplayBrightnessOptions& options) = 0;
181*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error setActiveConfigWithConstraints(
182*38e8c45fSAndroid Build Coastguard Worker             hal::HWConfigId configId, const hal::VsyncPeriodChangeConstraints& constraints,
183*38e8c45fSAndroid Build Coastguard Worker             hal::VsyncPeriodChangeTimeline* outTimeline) = 0;
184*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error setBootDisplayConfig(hal::HWConfigId configId) = 0;
185*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error clearBootDisplayConfig() = 0;
186*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error getPreferredBootDisplayConfig(
187*38e8c45fSAndroid Build Coastguard Worker             hal::HWConfigId* configId) const = 0;
188*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error setAutoLowLatencyMode(bool on) = 0;
189*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error getSupportedContentTypes(
190*38e8c45fSAndroid Build Coastguard Worker             std::vector<hal::ContentType>*) const = 0;
191*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error setContentType(hal::ContentType) = 0;
192*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error getClientTargetProperty(
193*38e8c45fSAndroid Build Coastguard Worker             aidl::android::hardware::graphics::composer3::ClientTargetPropertyWithBrightness*
194*38e8c45fSAndroid Build Coastguard Worker                     outClientTargetProperty) = 0;
195*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error getRequestedLuts(
196*38e8c45fSAndroid Build Coastguard Worker             LayerLuts* outLuts, LutFileDescriptorMapper& lutFileDescriptorMapper) = 0;
197*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error getDisplayDecorationSupport(
198*38e8c45fSAndroid Build Coastguard Worker             std::optional<aidl::android::hardware::graphics::common::DisplayDecorationSupport>*
199*38e8c45fSAndroid Build Coastguard Worker                     support) = 0;
200*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error setIdleTimerEnabled(std::chrono::milliseconds timeout) = 0;
201*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error getPhysicalDisplayOrientation(
202*38e8c45fSAndroid Build Coastguard Worker             Hwc2::AidlTransform* outTransform) const = 0;
203*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error getMaxLayerPictureProfiles(int32_t* maxProfiles) = 0;
204*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error setPictureProfileHandle(
205*38e8c45fSAndroid Build Coastguard Worker             const PictureProfileHandle& handle) = 0;
206*38e8c45fSAndroid Build Coastguard Worker };
207*38e8c45fSAndroid Build Coastguard Worker 
208*38e8c45fSAndroid Build Coastguard Worker namespace impl {
209*38e8c45fSAndroid Build Coastguard Worker 
210*38e8c45fSAndroid Build Coastguard Worker class Layer;
211*38e8c45fSAndroid Build Coastguard Worker 
212*38e8c45fSAndroid Build Coastguard Worker class Display : public HWC2::Display {
213*38e8c45fSAndroid Build Coastguard Worker public:
214*38e8c45fSAndroid Build Coastguard Worker     Display(android::Hwc2::Composer&,
215*38e8c45fSAndroid Build Coastguard Worker             const std::unordered_set<aidl::android::hardware::graphics::composer3::Capability>&,
216*38e8c45fSAndroid Build Coastguard Worker             hal::HWDisplayId, hal::DisplayType);
217*38e8c45fSAndroid Build Coastguard Worker     ~Display() override;
218*38e8c45fSAndroid Build Coastguard Worker 
219*38e8c45fSAndroid Build Coastguard Worker     // Required by HWC2
220*38e8c45fSAndroid Build Coastguard Worker     hal::Error acceptChanges() override;
221*38e8c45fSAndroid Build Coastguard Worker     base::expected<std::shared_ptr<HWC2::Layer>, hal::Error> createLayer() override;
222*38e8c45fSAndroid Build Coastguard Worker     hal::Error getChangedCompositionTypes(
223*38e8c45fSAndroid Build Coastguard Worker             std::unordered_map<HWC2::Layer*,
224*38e8c45fSAndroid Build Coastguard Worker                                aidl::android::hardware::graphics::composer3::Composition>* outTypes)
225*38e8c45fSAndroid Build Coastguard Worker             override;
226*38e8c45fSAndroid Build Coastguard Worker     hal::Error getColorModes(std::vector<hal::ColorMode>* outModes) const override;
227*38e8c45fSAndroid Build Coastguard Worker     // Returns a bitmask which contains HdrMetadata::Type::*.
228*38e8c45fSAndroid Build Coastguard Worker     int32_t getSupportedPerFrameMetadata() const override;
229*38e8c45fSAndroid Build Coastguard Worker     hal::Error getRenderIntents(hal::ColorMode colorMode,
230*38e8c45fSAndroid Build Coastguard Worker                                 std::vector<hal::RenderIntent>* outRenderIntents) const override;
231*38e8c45fSAndroid Build Coastguard Worker     hal::Error getDataspaceSaturationMatrix(hal::Dataspace, android::mat4* outMatrix) override;
232*38e8c45fSAndroid Build Coastguard Worker 
233*38e8c45fSAndroid Build Coastguard Worker     hal::Error getName(std::string* outName) const override;
234*38e8c45fSAndroid Build Coastguard Worker     hal::Error getRequests(
235*38e8c45fSAndroid Build Coastguard Worker             hal::DisplayRequest* outDisplayRequests,
236*38e8c45fSAndroid Build Coastguard Worker             std::unordered_map<HWC2::Layer*, hal::LayerRequest>* outLayerRequests) override;
237*38e8c45fSAndroid Build Coastguard Worker     ftl::Expected<ui::DisplayConnectionType, hal::Error> getConnectionType() const override;
238*38e8c45fSAndroid Build Coastguard Worker     hal::Error supportsDoze(bool* outSupport) const override EXCLUDES(mDisplayCapabilitiesMutex);
239*38e8c45fSAndroid Build Coastguard Worker     hal::Error getHdrCapabilities(android::HdrCapabilities* outCapabilities) const override;
240*38e8c45fSAndroid Build Coastguard Worker     hal::Error getOverlaySupport(aidl::android::hardware::graphics::composer3::OverlayProperties*
241*38e8c45fSAndroid Build Coastguard Worker                                          outProperties) const override;
242*38e8c45fSAndroid Build Coastguard Worker     hal::Error getDisplayedContentSamplingAttributes(hal::PixelFormat* outFormat,
243*38e8c45fSAndroid Build Coastguard Worker                                                      hal::Dataspace* outDataspace,
244*38e8c45fSAndroid Build Coastguard Worker                                                      uint8_t* outComponentMask) const override;
245*38e8c45fSAndroid Build Coastguard Worker     hal::Error setDisplayContentSamplingEnabled(bool enabled, uint8_t componentMask,
246*38e8c45fSAndroid Build Coastguard Worker                                                 uint64_t maxFrames) const override;
247*38e8c45fSAndroid Build Coastguard Worker     hal::Error getDisplayedContentSample(uint64_t maxFrames, uint64_t timestamp,
248*38e8c45fSAndroid Build Coastguard Worker                                          android::DisplayedFrameStats* outStats) const override;
249*38e8c45fSAndroid Build Coastguard Worker     hal::Error getReleaseFences(std::unordered_map<HWC2::Layer*, android::sp<android::Fence>>*
250*38e8c45fSAndroid Build Coastguard Worker                                         outFences) const override;
251*38e8c45fSAndroid Build Coastguard Worker     hal::Error present(android::sp<android::Fence>* outPresentFence) override;
252*38e8c45fSAndroid Build Coastguard Worker     hal::Error setClientTarget(uint32_t slot, const android::sp<android::GraphicBuffer>& target,
253*38e8c45fSAndroid Build Coastguard Worker                                const android::sp<android::Fence>& acquireFence,
254*38e8c45fSAndroid Build Coastguard Worker                                hal::Dataspace dataspace, float hdrSdrRatio) override;
255*38e8c45fSAndroid Build Coastguard Worker     hal::Error setColorMode(hal::ColorMode, hal::RenderIntent) override;
256*38e8c45fSAndroid Build Coastguard Worker     hal::Error setColorTransform(const android::mat4& matrix) override;
257*38e8c45fSAndroid Build Coastguard Worker     hal::Error setOutputBuffer(const android::sp<android::GraphicBuffer>&,
258*38e8c45fSAndroid Build Coastguard Worker                                const android::sp<android::Fence>& releaseFence) override;
259*38e8c45fSAndroid Build Coastguard Worker     hal::Error setPowerMode(hal::PowerMode) override;
260*38e8c45fSAndroid Build Coastguard Worker     hal::Error setVsyncEnabled(hal::Vsync enabled) override;
261*38e8c45fSAndroid Build Coastguard Worker     hal::Error validate(nsecs_t expectedPresentTime, int32_t frameIntervalNs, uint32_t* outNumTypes,
262*38e8c45fSAndroid Build Coastguard Worker                         uint32_t* outNumRequests) override;
263*38e8c45fSAndroid Build Coastguard Worker     hal::Error presentOrValidate(nsecs_t expectedPresentTime, int32_t frameIntervalNs,
264*38e8c45fSAndroid Build Coastguard Worker                                  uint32_t* outNumTypes, uint32_t* outNumRequests,
265*38e8c45fSAndroid Build Coastguard Worker                                  android::sp<android::Fence>* outPresentFence,
266*38e8c45fSAndroid Build Coastguard Worker                                  uint32_t* state) override;
267*38e8c45fSAndroid Build Coastguard Worker     ftl::Future<hal::Error> setDisplayBrightness(
268*38e8c45fSAndroid Build Coastguard Worker             float brightness, float brightnessNits,
269*38e8c45fSAndroid Build Coastguard Worker             const Hwc2::Composer::DisplayBrightnessOptions& options) override;
270*38e8c45fSAndroid Build Coastguard Worker     hal::Error setActiveConfigWithConstraints(hal::HWConfigId configId,
271*38e8c45fSAndroid Build Coastguard Worker                                               const hal::VsyncPeriodChangeConstraints& constraints,
272*38e8c45fSAndroid Build Coastguard Worker                                               hal::VsyncPeriodChangeTimeline* outTimeline) override;
273*38e8c45fSAndroid Build Coastguard Worker     hal::Error setBootDisplayConfig(hal::HWConfigId configId) override;
274*38e8c45fSAndroid Build Coastguard Worker     hal::Error clearBootDisplayConfig() override;
275*38e8c45fSAndroid Build Coastguard Worker     hal::Error getPreferredBootDisplayConfig(hal::HWConfigId* configId) const override;
276*38e8c45fSAndroid Build Coastguard Worker     hal::Error setAutoLowLatencyMode(bool on) override;
277*38e8c45fSAndroid Build Coastguard Worker     hal::Error getSupportedContentTypes(
278*38e8c45fSAndroid Build Coastguard Worker             std::vector<hal::ContentType>* outSupportedContentTypes) const override;
279*38e8c45fSAndroid Build Coastguard Worker     hal::Error setContentType(hal::ContentType) override;
280*38e8c45fSAndroid Build Coastguard Worker     hal::Error getClientTargetProperty(
281*38e8c45fSAndroid Build Coastguard Worker             aidl::android::hardware::graphics::composer3::ClientTargetPropertyWithBrightness*
282*38e8c45fSAndroid Build Coastguard Worker                     outClientTargetProperty) override;
283*38e8c45fSAndroid Build Coastguard Worker     hal::Error getRequestedLuts(LayerLuts* outLuts,
284*38e8c45fSAndroid Build Coastguard Worker                                 LutFileDescriptorMapper& lutFileDescriptorMapper) override;
285*38e8c45fSAndroid Build Coastguard Worker     hal::Error getDisplayDecorationSupport(
286*38e8c45fSAndroid Build Coastguard Worker             std::optional<aidl::android::hardware::graphics::common::DisplayDecorationSupport>*
287*38e8c45fSAndroid Build Coastguard Worker                     support) override;
288*38e8c45fSAndroid Build Coastguard Worker     hal::Error setIdleTimerEnabled(std::chrono::milliseconds timeout) override;
289*38e8c45fSAndroid Build Coastguard Worker     hal::Error getMaxLayerPictureProfiles(int32_t* maxProfiles) override;
290*38e8c45fSAndroid Build Coastguard Worker     hal::Error setPictureProfileHandle(const android::PictureProfileHandle& handle) override;
291*38e8c45fSAndroid Build Coastguard Worker 
292*38e8c45fSAndroid Build Coastguard Worker     // Other Display methods
getId()293*38e8c45fSAndroid Build Coastguard Worker     hal::HWDisplayId getId() const override { return mId; }
isConnected()294*38e8c45fSAndroid Build Coastguard Worker     bool isConnected() const override { return mIsConnected; }
295*38e8c45fSAndroid Build Coastguard Worker     void setConnected(bool connected) override;
296*38e8c45fSAndroid Build Coastguard Worker     bool hasCapability(aidl::android::hardware::graphics::composer3::DisplayCapability)
297*38e8c45fSAndroid Build Coastguard Worker             const override EXCLUDES(mDisplayCapabilitiesMutex);
298*38e8c45fSAndroid Build Coastguard Worker     bool isVsyncPeriodSwitchSupported() const override;
299*38e8c45fSAndroid Build Coastguard Worker     bool hasDisplayIdleTimerCapability() const override;
300*38e8c45fSAndroid Build Coastguard Worker     void onLayerDestroyed(hal::HWLayerId layerId) override;
301*38e8c45fSAndroid Build Coastguard Worker     hal::Error getPhysicalDisplayOrientation(Hwc2::AidlTransform* outTransform) const override;
302*38e8c45fSAndroid Build Coastguard Worker     void setPhysicalSizeInMm(std::optional<ui::Size> size);
getPhysicalSizeInMm()303*38e8c45fSAndroid Build Coastguard Worker     std::optional<ui::Size> getPhysicalSizeInMm() const override { return mPhysicalSize; }
304*38e8c45fSAndroid Build Coastguard Worker 
305*38e8c45fSAndroid Build Coastguard Worker private:
306*38e8c45fSAndroid Build Coastguard Worker     void loadDisplayCapabilities();
307*38e8c45fSAndroid Build Coastguard Worker 
308*38e8c45fSAndroid Build Coastguard Worker     // This may fail (and return a null pointer) if no layer with this ID exists
309*38e8c45fSAndroid Build Coastguard Worker     // on this display
310*38e8c45fSAndroid Build Coastguard Worker     std::shared_ptr<HWC2::Layer> getLayerById(hal::HWLayerId id) const;
311*38e8c45fSAndroid Build Coastguard Worker 
312*38e8c45fSAndroid Build Coastguard Worker     friend android::TestableSurfaceFlinger;
313*38e8c45fSAndroid Build Coastguard Worker 
314*38e8c45fSAndroid Build Coastguard Worker     // Member variables
315*38e8c45fSAndroid Build Coastguard Worker 
316*38e8c45fSAndroid Build Coastguard Worker     // These are references to data owned by HWComposer, which will outlive
317*38e8c45fSAndroid Build Coastguard Worker     // this HWC2::Display, so these references are guaranteed to be valid for
318*38e8c45fSAndroid Build Coastguard Worker     // the lifetime of this object.
319*38e8c45fSAndroid Build Coastguard Worker     android::Hwc2::Composer& mComposer;
320*38e8c45fSAndroid Build Coastguard Worker     const std::unordered_set<aidl::android::hardware::graphics::composer3::Capability>&
321*38e8c45fSAndroid Build Coastguard Worker             mCapabilities;
322*38e8c45fSAndroid Build Coastguard Worker 
323*38e8c45fSAndroid Build Coastguard Worker     const hal::HWDisplayId mId;
324*38e8c45fSAndroid Build Coastguard Worker     hal::DisplayType mType;
325*38e8c45fSAndroid Build Coastguard Worker     // Cached on first call to getConnectionType.
326*38e8c45fSAndroid Build Coastguard Worker     mutable std::optional<ftl::Expected<ui::DisplayConnectionType, hal::Error>> mConnectionType;
327*38e8c45fSAndroid Build Coastguard Worker     bool mIsConnected = false;
328*38e8c45fSAndroid Build Coastguard Worker 
329*38e8c45fSAndroid Build Coastguard Worker     using Layers = std::unordered_map<hal::HWLayerId, std::weak_ptr<HWC2::impl::Layer>>;
330*38e8c45fSAndroid Build Coastguard Worker     Layers mLayers;
331*38e8c45fSAndroid Build Coastguard Worker 
332*38e8c45fSAndroid Build Coastguard Worker     mutable std::mutex mDisplayCapabilitiesMutex;
333*38e8c45fSAndroid Build Coastguard Worker     std::once_flag mDisplayCapabilityQueryFlag;
334*38e8c45fSAndroid Build Coastguard Worker     std::optional<
335*38e8c45fSAndroid Build Coastguard Worker             std::unordered_set<aidl::android::hardware::graphics::composer3::DisplayCapability>>
336*38e8c45fSAndroid Build Coastguard Worker             mDisplayCapabilities GUARDED_BY(mDisplayCapabilitiesMutex);
337*38e8c45fSAndroid Build Coastguard Worker     // Physical size in mm.
338*38e8c45fSAndroid Build Coastguard Worker     std::optional<ui::Size> mPhysicalSize;
339*38e8c45fSAndroid Build Coastguard Worker };
340*38e8c45fSAndroid Build Coastguard Worker 
341*38e8c45fSAndroid Build Coastguard Worker } // namespace impl
342*38e8c45fSAndroid Build Coastguard Worker 
343*38e8c45fSAndroid Build Coastguard Worker class Layer {
344*38e8c45fSAndroid Build Coastguard Worker public:
345*38e8c45fSAndroid Build Coastguard Worker     virtual ~Layer();
346*38e8c45fSAndroid Build Coastguard Worker 
347*38e8c45fSAndroid Build Coastguard Worker     virtual hal::HWLayerId getId() const = 0;
348*38e8c45fSAndroid Build Coastguard Worker 
349*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error setCursorPosition(int32_t x, int32_t y) = 0;
350*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error setBuffer(uint32_t slot,
351*38e8c45fSAndroid Build Coastguard Worker                                                const android::sp<android::GraphicBuffer>& buffer,
352*38e8c45fSAndroid Build Coastguard Worker                                                const android::sp<android::Fence>& acquireFence) = 0;
353*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error setBufferSlotsToClear(
354*38e8c45fSAndroid Build Coastguard Worker             const std::vector<uint32_t>& slotsToClear, uint32_t activeBufferSlot) = 0;
355*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error setSurfaceDamage(const android::Region& damage) = 0;
356*38e8c45fSAndroid Build Coastguard Worker 
357*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error setBlendMode(hal::BlendMode mode) = 0;
358*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error setColor(
359*38e8c45fSAndroid Build Coastguard Worker             aidl::android::hardware::graphics::composer3::Color color) = 0;
360*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error setCompositionType(
361*38e8c45fSAndroid Build Coastguard Worker             aidl::android::hardware::graphics::composer3::Composition type) = 0;
362*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error setDataspace(hal::Dataspace dataspace) = 0;
363*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error setPerFrameMetadata(const int32_t supportedPerFrameMetadata,
364*38e8c45fSAndroid Build Coastguard Worker                                                          const android::HdrMetadata& metadata) = 0;
365*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error setDisplayFrame(const android::Rect& frame) = 0;
366*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error setPlaneAlpha(float alpha) = 0;
367*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error setSidebandStream(const native_handle_t* stream) = 0;
368*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error setSourceCrop(const android::FloatRect& crop) = 0;
369*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error setTransform(hal::Transform transform) = 0;
370*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error setVisibleRegion(const android::Region& region) = 0;
371*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error setZOrder(uint32_t z) = 0;
372*38e8c45fSAndroid Build Coastguard Worker 
373*38e8c45fSAndroid Build Coastguard Worker     // Composer HAL 2.3
374*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error setColorTransform(const android::mat4& matrix) = 0;
375*38e8c45fSAndroid Build Coastguard Worker 
376*38e8c45fSAndroid Build Coastguard Worker     // Composer HAL 2.4
377*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error setLayerGenericMetadata(const std::string& name,
378*38e8c45fSAndroid Build Coastguard Worker                                                              bool mandatory,
379*38e8c45fSAndroid Build Coastguard Worker                                                              const std::vector<uint8_t>& value) = 0;
380*38e8c45fSAndroid Build Coastguard Worker 
381*38e8c45fSAndroid Build Coastguard Worker     // AIDL HAL
382*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error setBrightness(float brightness) = 0;
383*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error setBlockingRegion(const android::Region& region) = 0;
384*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error setLuts(
385*38e8c45fSAndroid Build Coastguard Worker             aidl::android::hardware::graphics::composer3::Luts& luts) = 0;
386*38e8c45fSAndroid Build Coastguard Worker     [[nodiscard]] virtual hal::Error setPictureProfileHandle(
387*38e8c45fSAndroid Build Coastguard Worker             const PictureProfileHandle& handle) = 0;
388*38e8c45fSAndroid Build Coastguard Worker };
389*38e8c45fSAndroid Build Coastguard Worker 
390*38e8c45fSAndroid Build Coastguard Worker namespace impl {
391*38e8c45fSAndroid Build Coastguard Worker 
392*38e8c45fSAndroid Build Coastguard Worker // Convenience C++ class to access per layer functions directly.
393*38e8c45fSAndroid Build Coastguard Worker 
394*38e8c45fSAndroid Build Coastguard Worker class Layer : public HWC2::Layer {
395*38e8c45fSAndroid Build Coastguard Worker public:
396*38e8c45fSAndroid Build Coastguard Worker     Layer(android::Hwc2::Composer& composer,
397*38e8c45fSAndroid Build Coastguard Worker           const std::unordered_set<aidl::android::hardware::graphics::composer3::Capability>&
398*38e8c45fSAndroid Build Coastguard Worker                   capabilities,
399*38e8c45fSAndroid Build Coastguard Worker           HWC2::Display& display, hal::HWLayerId layerId);
400*38e8c45fSAndroid Build Coastguard Worker     ~Layer() override;
401*38e8c45fSAndroid Build Coastguard Worker 
402*38e8c45fSAndroid Build Coastguard Worker     void onOwningDisplayDestroyed();
403*38e8c45fSAndroid Build Coastguard Worker 
getId()404*38e8c45fSAndroid Build Coastguard Worker     hal::HWLayerId getId() const override { return mId; }
405*38e8c45fSAndroid Build Coastguard Worker 
406*38e8c45fSAndroid Build Coastguard Worker     hal::Error setCursorPosition(int32_t x, int32_t y) override;
407*38e8c45fSAndroid Build Coastguard Worker     hal::Error setBuffer(uint32_t slot, const android::sp<android::GraphicBuffer>& buffer,
408*38e8c45fSAndroid Build Coastguard Worker                          const android::sp<android::Fence>& acquireFence) override;
409*38e8c45fSAndroid Build Coastguard Worker     hal::Error setBufferSlotsToClear(const std::vector<uint32_t>& slotsToClear,
410*38e8c45fSAndroid Build Coastguard Worker                                      uint32_t activeBufferSlot) override;
411*38e8c45fSAndroid Build Coastguard Worker     hal::Error setSurfaceDamage(const android::Region& damage) override;
412*38e8c45fSAndroid Build Coastguard Worker 
413*38e8c45fSAndroid Build Coastguard Worker     hal::Error setBlendMode(hal::BlendMode mode) override;
414*38e8c45fSAndroid Build Coastguard Worker     hal::Error setColor(aidl::android::hardware::graphics::composer3::Color color) override;
415*38e8c45fSAndroid Build Coastguard Worker     hal::Error setCompositionType(
416*38e8c45fSAndroid Build Coastguard Worker             aidl::android::hardware::graphics::composer3::Composition type) override;
417*38e8c45fSAndroid Build Coastguard Worker     hal::Error setDataspace(hal::Dataspace dataspace) override;
418*38e8c45fSAndroid Build Coastguard Worker     hal::Error setPerFrameMetadata(const int32_t supportedPerFrameMetadata,
419*38e8c45fSAndroid Build Coastguard Worker                                    const android::HdrMetadata& metadata) override;
420*38e8c45fSAndroid Build Coastguard Worker     hal::Error setDisplayFrame(const android::Rect& frame) override;
421*38e8c45fSAndroid Build Coastguard Worker     hal::Error setPlaneAlpha(float alpha) override;
422*38e8c45fSAndroid Build Coastguard Worker     hal::Error setSidebandStream(const native_handle_t* stream) override;
423*38e8c45fSAndroid Build Coastguard Worker     hal::Error setSourceCrop(const android::FloatRect& crop) override;
424*38e8c45fSAndroid Build Coastguard Worker     hal::Error setTransform(hal::Transform transform) override;
425*38e8c45fSAndroid Build Coastguard Worker     hal::Error setVisibleRegion(const android::Region& region) override;
426*38e8c45fSAndroid Build Coastguard Worker     hal::Error setZOrder(uint32_t z) override;
427*38e8c45fSAndroid Build Coastguard Worker 
428*38e8c45fSAndroid Build Coastguard Worker     // Composer HAL 2.3
429*38e8c45fSAndroid Build Coastguard Worker     hal::Error setColorTransform(const android::mat4& matrix) override;
430*38e8c45fSAndroid Build Coastguard Worker 
431*38e8c45fSAndroid Build Coastguard Worker     // Composer HAL 2.4
432*38e8c45fSAndroid Build Coastguard Worker     hal::Error setLayerGenericMetadata(const std::string& name, bool mandatory,
433*38e8c45fSAndroid Build Coastguard Worker                                        const std::vector<uint8_t>& value) override;
434*38e8c45fSAndroid Build Coastguard Worker 
435*38e8c45fSAndroid Build Coastguard Worker     // AIDL HAL
436*38e8c45fSAndroid Build Coastguard Worker     hal::Error setBrightness(float brightness) override;
437*38e8c45fSAndroid Build Coastguard Worker     hal::Error setBlockingRegion(const android::Region& region) override;
438*38e8c45fSAndroid Build Coastguard Worker     hal::Error setLuts(aidl::android::hardware::graphics::composer3::Luts&) override;
439*38e8c45fSAndroid Build Coastguard Worker     hal::Error setPictureProfileHandle(const PictureProfileHandle& handle) override;
440*38e8c45fSAndroid Build Coastguard Worker 
441*38e8c45fSAndroid Build Coastguard Worker private:
442*38e8c45fSAndroid Build Coastguard Worker     // These are references to data owned by HWComposer, which will outlive
443*38e8c45fSAndroid Build Coastguard Worker     // this HWC2::Layer, so these references are guaranteed to be valid for
444*38e8c45fSAndroid Build Coastguard Worker     // the lifetime of this object.
445*38e8c45fSAndroid Build Coastguard Worker     android::Hwc2::Composer& mComposer;
446*38e8c45fSAndroid Build Coastguard Worker     const std::unordered_set<aidl::android::hardware::graphics::composer3::Capability>&
447*38e8c45fSAndroid Build Coastguard Worker             mCapabilities;
448*38e8c45fSAndroid Build Coastguard Worker 
449*38e8c45fSAndroid Build Coastguard Worker     HWC2::Display* mDisplay;
450*38e8c45fSAndroid Build Coastguard Worker     hal::HWLayerId mId;
451*38e8c45fSAndroid Build Coastguard Worker 
452*38e8c45fSAndroid Build Coastguard Worker     // Cached HWC2 data, to ensure the same commands aren't sent to the HWC
453*38e8c45fSAndroid Build Coastguard Worker     // multiple times.
454*38e8c45fSAndroid Build Coastguard Worker     android::Region mVisibleRegion = android::Region::INVALID_REGION;
455*38e8c45fSAndroid Build Coastguard Worker     android::Region mDamageRegion = android::Region::INVALID_REGION;
456*38e8c45fSAndroid Build Coastguard Worker     android::Region mBlockingRegion = android::Region::INVALID_REGION;
457*38e8c45fSAndroid Build Coastguard Worker     hal::Dataspace mDataSpace = hal::Dataspace::UNKNOWN;
458*38e8c45fSAndroid Build Coastguard Worker     android::HdrMetadata mHdrMetadata;
459*38e8c45fSAndroid Build Coastguard Worker     android::mat4 mColorMatrix;
460*38e8c45fSAndroid Build Coastguard Worker     uint32_t mBufferSlot;
461*38e8c45fSAndroid Build Coastguard Worker     android::PictureProfileHandle profile;
462*38e8c45fSAndroid Build Coastguard Worker };
463*38e8c45fSAndroid Build Coastguard Worker 
464*38e8c45fSAndroid Build Coastguard Worker } // namespace impl
465*38e8c45fSAndroid Build Coastguard Worker } // namespace HWC2
466*38e8c45fSAndroid Build Coastguard Worker } // namespace android
467