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