1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef HDI_BACKEND_HDI_LAYER_INFO_H 17 #define HDI_BACKEND_HDI_LAYER_INFO_H 18 19 #include <string> 20 #include "iconsumer_surface.h" 21 #include <surface.h> 22 #include <sync_fence.h> 23 #include "graphic_error.h" 24 #include "hdi_display_type.h" 25 #include "common/rs_anco_type.h" 26 27 namespace OHOS { 28 namespace Rosen { 29 static const std::map<GraphicTransformType, std::string> TransformTypeStrs = { 30 {GRAPHIC_ROTATE_NONE, "0 <no rotation>"}, 31 {GRAPHIC_ROTATE_90, "1 <rotation by 90 degrees>"}, 32 {GRAPHIC_ROTATE_180, "2 <rotation by 180 degrees>"}, 33 {GRAPHIC_ROTATE_270, "3 <rotation by 270 degrees>"}, 34 {GRAPHIC_FLIP_H, "4 <flip horizontally>"}, 35 {GRAPHIC_FLIP_V, "5 <flip vertically>"}, 36 {GRAPHIC_FLIP_H_ROT90, "6 <flip horizontally and rotate 90 degrees>"}, 37 {GRAPHIC_FLIP_V_ROT90, "7 <flip vertically and rotate 90 degrees>"}, 38 {GRAPHIC_FLIP_H_ROT180, "8 <flip horizontally and rotate 180 degrees>"}, 39 {GRAPHIC_FLIP_V_ROT180, "9 <flip vertically and rotate 180 degrees>"}, 40 {GRAPHIC_FLIP_H_ROT270, "10 <flip horizontally and rotate 270 degrees>"}, 41 {GRAPHIC_FLIP_V_ROT270, "11 <flip vertically and rotate 270 degrees>"}, 42 {GRAPHIC_ROTATE_BUTT, "12 <uninitialized>"}, 43 }; 44 45 static const std::map<GraphicCompositionType, std::string> CompositionTypeStrs = { 46 {GRAPHIC_COMPOSITION_CLIENT, "0 <client composistion>"}, 47 {GRAPHIC_COMPOSITION_DEVICE, "1 <device composistion>"}, 48 {GRAPHIC_COMPOSITION_CURSOR, "2 <cursor composistion>"}, 49 {GRAPHIC_COMPOSITION_VIDEO, "3 <video composistion>"}, 50 {GRAPHIC_COMPOSITION_DEVICE_CLEAR, "4 <device clear composistion>"}, 51 {GRAPHIC_COMPOSITION_CLIENT_CLEAR, "5 <client clear composistion>"}, 52 {GRAPHIC_COMPOSITION_TUNNEL, "6 <tunnel composistion>"}, 53 {GRAPHIC_COMPOSITION_SOLID_COLOR, "7 <layercolor composition>"}, 54 {GRAPHIC_COMPOSITION_BUTT, "8 <uninitialized>"}, 55 }; 56 57 static const std::map<GraphicBlendType, std::string> BlendTypeStrs = { 58 {GRAPHIC_BLEND_NONE, "0 <No blending>"}, 59 {GRAPHIC_BLEND_CLEAR, "1 <CLEAR blending>"}, 60 {GRAPHIC_BLEND_SRC, "2 <SRC blending>"}, 61 {GRAPHIC_BLEND_SRCOVER, "3 <SRC_OVER blending>"}, 62 {GRAPHIC_BLEND_DSTOVER, "4 <DST_OVER blending>"}, 63 {GRAPHIC_BLEND_SRCIN, "5 <SRC_IN blending>"}, 64 {GRAPHIC_BLEND_DSTIN, "6 <DST_IN blending>"}, 65 {GRAPHIC_BLEND_SRCOUT, "7 <SRC_OUT blending>"}, 66 {GRAPHIC_BLEND_DSTOUT, "8 <DST_OUT blending>"}, 67 {GRAPHIC_BLEND_SRCATOP, "9 <SRC_ATOP blending>"}, 68 {GRAPHIC_BLEND_DSTATOP, "10 <DST_ATOP blending>"}, 69 {GRAPHIC_BLEND_ADD, "11 <ADD blending>"}, 70 {GRAPHIC_BLEND_XOR, "12 <XOR blending>"}, 71 {GRAPHIC_BLEND_DST, "13 <DST blending>"}, 72 {GRAPHIC_BLEND_AKS, "14 <AKS blending>"}, 73 {GRAPHIC_BLEND_AKD, "15 <AKD blending>"}, 74 {GRAPHIC_BLEND_BUTT, "16 <Uninitialized>"}, 75 }; 76 77 class HdiLayerInfo { 78 public: 79 HdiLayerInfo() = default; 80 virtual ~HdiLayerInfo() = default; 81 82 enum class LayerMask { 83 LAYER_MASK_NORMAL = 0, 84 LAYER_MASK_HBM_SYNC = 1, // enable fingerprint 85 }; 86 87 /* rs create and set/get layer info begin */ CreateHdiLayerInfo()88 static std::shared_ptr<HdiLayerInfo> CreateHdiLayerInfo() 89 { 90 return std::make_shared<HdiLayerInfo>(); 91 } 92 SetSurface(const sptr<IConsumerSurface> & surface)93 void SetSurface(const sptr<IConsumerSurface> &surface) 94 { 95 cSurface_ = surface; 96 } 97 SetBuffer(const sptr<SurfaceBuffer> & sbuffer,const sptr<SyncFence> & acquireFence)98 void SetBuffer(const sptr<SurfaceBuffer> &sbuffer, const sptr<SyncFence> &acquireFence) 99 { 100 sbuffer_ = sbuffer; 101 acquireFence_ = acquireFence; 102 } 103 SetPreBuffer(const sptr<SurfaceBuffer> & buffer)104 void SetPreBuffer(const sptr<SurfaceBuffer> &buffer) 105 { 106 pbuffer_ = buffer; 107 } 108 SetZorder(int32_t zOrder)109 void SetZorder(int32_t zOrder) 110 { 111 zOrder_ = static_cast<uint32_t>(zOrder); 112 } 113 SetType(const GraphicLayerType & layerType)114 void SetType(const GraphicLayerType& layerType) 115 { 116 layerType_ = layerType; 117 } 118 GetType()119 GraphicLayerType GetType() const 120 { 121 return layerType_; 122 } 123 SetAlpha(const GraphicLayerAlpha & alpha)124 void SetAlpha(const GraphicLayerAlpha &alpha) 125 { 126 layerAlpha_ = alpha; 127 } 128 SetTransform(GraphicTransformType type)129 void SetTransform(GraphicTransformType type) 130 { 131 transformType_ = type; 132 } 133 SetCompositionType(GraphicCompositionType type)134 void SetCompositionType(GraphicCompositionType type) 135 { 136 compositionType_ = type; 137 } 138 SetVisibleRegions(const std::vector<GraphicIRect> & visibleRegions)139 void SetVisibleRegions(const std::vector<GraphicIRect> &visibleRegions) 140 { 141 std::lock_guard<std::mutex> lock(mutex_); 142 visibleRegions_ = visibleRegions; 143 } 144 SetDirtyRegions(const std::vector<GraphicIRect> & dirtyRegions)145 void SetDirtyRegions(const std::vector<GraphicIRect> &dirtyRegions) 146 { 147 std::lock_guard<std::mutex> lock(mutex_); 148 dirtyRegions_ = dirtyRegions; 149 } 150 SetBlendType(GraphicBlendType type)151 void SetBlendType(GraphicBlendType type) 152 { 153 blendType_ = type; 154 } 155 SetCropRect(const GraphicIRect & crop)156 void SetCropRect(const GraphicIRect &crop) 157 { 158 cropRect_ = crop; 159 } 160 SetPreMulti(bool preMulti)161 void SetPreMulti(bool preMulti) 162 { 163 preMulti_ = preMulti; 164 } 165 SetLayerSize(const GraphicIRect & layerRect)166 void SetLayerSize(const GraphicIRect &layerRect) 167 { 168 layerRect_ = layerRect; 169 } 170 SetBoundSize(const GraphicIRect & boundRect)171 void SetBoundSize(const GraphicIRect &boundRect) 172 { 173 boundRect_ = boundRect; 174 } 175 SetLayerColor(GraphicLayerColor layerColor)176 void SetLayerColor(GraphicLayerColor layerColor) 177 { 178 layerColor_ = layerColor; 179 } 180 SetBackgroundColor(GraphicLayerColor backgroundColor)181 void SetBackgroundColor(GraphicLayerColor backgroundColor) 182 { 183 backgroundColor_ = backgroundColor; 184 } 185 SetCornerRadiusInfoForDRM(const std::vector<float> & drmCornerRadiusInfo)186 void SetCornerRadiusInfoForDRM(const std::vector<float>& drmCornerRadiusInfo) 187 { 188 drmCornerRadiusInfo_ = drmCornerRadiusInfo; 189 } 190 SetColorTransform(const std::vector<float> & matrix)191 void SetColorTransform(const std::vector<float> &matrix) 192 { 193 colorTransformMatrix_ = matrix; 194 } 195 SetColorDataSpace(GraphicColorDataSpace colorSpace)196 void SetColorDataSpace(GraphicColorDataSpace colorSpace) 197 { 198 colorSpace_ = colorSpace; 199 } 200 SetMetaData(const std::vector<GraphicHDRMetaData> & metaData)201 void SetMetaData(const std::vector<GraphicHDRMetaData> &metaData) 202 { 203 metaData_ = metaData; 204 } 205 SetMetaDataSet(const GraphicHDRMetaDataSet & metaDataSet)206 void SetMetaDataSet(const GraphicHDRMetaDataSet &metaDataSet) 207 { 208 metaDataSet_ = metaDataSet; 209 } 210 SetMatrix(GraphicMatrix matrix)211 void SetMatrix(GraphicMatrix matrix) 212 { 213 matrix_ = matrix; 214 } 215 SetGravity(int32_t gravity)216 void SetGravity(int32_t gravity) 217 { 218 gravity_ = gravity; 219 } 220 SetUniRenderFlag(bool isUniRender)221 void SetUniRenderFlag(bool isUniRender) 222 { 223 isUniRender_ = isUniRender; 224 } 225 SetTunnelHandleChange(bool change)226 void SetTunnelHandleChange(bool change) 227 { 228 tunnelHandleChange_ = change; 229 } 230 SetTunnelHandle(const sptr<SurfaceTunnelHandle> & handle)231 void SetTunnelHandle(const sptr<SurfaceTunnelHandle> &handle) 232 { 233 tunnelHandle_ = handle; 234 } 235 SetTunnelLayerId(const uint64_t & tunnelLayerId)236 void SetTunnelLayerId(const uint64_t &tunnelLayerId) 237 { 238 tunnelLayerId_ = tunnelLayerId; 239 } 240 GetTunnelLayerId()241 uint64_t GetTunnelLayerId() const 242 { 243 return tunnelLayerId_; 244 } 245 SetTunnelLayerProperty(uint32_t tunnelLayerProperty)246 void SetTunnelLayerProperty(uint32_t tunnelLayerProperty) 247 { 248 tunnelLayerProperty_ = tunnelLayerProperty; 249 } 250 GetTunnelLayerProperty()251 uint32_t GetTunnelLayerProperty() const 252 { 253 return tunnelLayerProperty_; 254 } 255 IsSupportedPresentTimestamp()256 bool IsSupportedPresentTimestamp() const 257 { 258 return IsSupportedPresentTimestamp_; 259 } 260 GetPresentTimestamp()261 const GraphicPresentTimestamp &GetPresentTimestamp() 262 { 263 return presentTimestamp_; 264 } 265 266 /* rs create and set/get layer info end */ 267 268 /* hdiLayer get layer info begin */ GetSurface()269 sptr<IConsumerSurface> GetSurface() const 270 { 271 return cSurface_; 272 } 273 GetBuffer()274 sptr<SurfaceBuffer> GetBuffer() const 275 { 276 return sbuffer_; 277 } 278 GetPreBuffer()279 sptr<SurfaceBuffer> GetPreBuffer() const 280 { 281 return pbuffer_; 282 } 283 GetZorder()284 uint32_t GetZorder() const 285 { 286 return zOrder_; 287 } 288 GetAcquireFence()289 sptr<SyncFence> GetAcquireFence() const 290 { 291 return acquireFence_; 292 } 293 GetAlpha()294 const GraphicLayerAlpha &GetAlpha() 295 { 296 return layerAlpha_; 297 } 298 GetTransformType()299 GraphicTransformType GetTransformType() const 300 { 301 return transformType_; 302 } 303 GetCompositionType()304 GraphicCompositionType GetCompositionType() const 305 { 306 return compositionType_; 307 } 308 GetVisibleRegions()309 const std::vector<GraphicIRect> &GetVisibleRegions() 310 { 311 std::lock_guard<std::mutex> lock(mutex_); 312 return visibleRegions_; 313 } 314 GetDirtyRegions()315 const std::vector<GraphicIRect> &GetDirtyRegions() 316 { 317 std::lock_guard<std::mutex> lock(mutex_); 318 return dirtyRegions_; 319 } 320 GetBlendType()321 GraphicBlendType GetBlendType() const 322 { 323 return blendType_; 324 } 325 GetCropRect()326 const GraphicIRect &GetCropRect() 327 { 328 return cropRect_; 329 } 330 GetLayerSize()331 const GraphicIRect &GetLayerSize() 332 { 333 return layerRect_; 334 } 335 GetBoundSize()336 GraphicIRect GetBoundSize() const 337 { 338 return boundRect_; 339 } 340 GetMatrix()341 GraphicMatrix GetMatrix() const 342 { 343 return matrix_; 344 } 345 GetGravity()346 int32_t GetGravity() const 347 { 348 return gravity_; 349 } 350 GetUniRenderFlag()351 bool GetUniRenderFlag() const 352 { 353 return isUniRender_; 354 } 355 IsPreMulti()356 bool IsPreMulti() const 357 { 358 return preMulti_; 359 } 360 SetWindowsName(std::vector<std::string> & windowsName)361 void SetWindowsName(std::vector<std::string>& windowsName) 362 { 363 windowsName_ = windowsName; 364 } 365 GetWindowsName()366 const std::vector<std::string>& GetWindowsName() 367 { 368 return windowsName_; 369 } 370 GetColorTransform()371 const std::vector<float> &GetColorTransform() 372 { 373 return colorTransformMatrix_; 374 } 375 GetColorDataSpace()376 GraphicColorDataSpace GetColorDataSpace() const 377 { 378 return colorSpace_; 379 } 380 GetLayerColor()381 GraphicLayerColor GetLayerColor() const 382 { 383 return layerColor_; 384 } 385 GetBackgroundColor()386 GraphicLayerColor GetBackgroundColor() const 387 { 388 return backgroundColor_; 389 } 390 GetCornerRadiusInfoForDRM()391 const std::vector<float>& GetCornerRadiusInfoForDRM() const 392 { 393 return drmCornerRadiusInfo_; 394 } 395 GetMetaData()396 std::vector<GraphicHDRMetaData> &GetMetaData() 397 { 398 return metaData_; 399 } 400 GetMetaDataSet()401 GraphicHDRMetaDataSet &GetMetaDataSet() 402 { 403 return metaDataSet_; 404 } 405 GetTunnelHandleChange()406 bool GetTunnelHandleChange() const 407 { 408 return tunnelHandleChange_; 409 } 410 GetTunnelHandle()411 sptr<SurfaceTunnelHandle> GetTunnelHandle() const 412 { 413 return tunnelHandle_; 414 } 415 SetIsSupportedPresentTimestamp(bool isSupported)416 void SetIsSupportedPresentTimestamp(bool isSupported) 417 { 418 IsSupportedPresentTimestamp_ = isSupported; 419 } 420 SetPresentTimestamp(const GraphicPresentTimestamp & timestamp)421 void SetPresentTimestamp(const GraphicPresentTimestamp ×tamp) 422 { 423 presentTimestamp_ = timestamp; 424 } 425 GetSdrNit()426 float GetSdrNit() const 427 { 428 return sdrNit_; 429 } 430 GetDisplayNit()431 float GetDisplayNit() const 432 { 433 return displayNit_; 434 } 435 GetBrightnessRatio()436 float GetBrightnessRatio() const 437 { 438 return brightnessRatio_; 439 } 440 SetSdrNit(float sdrNit)441 void SetSdrNit(float sdrNit) 442 { 443 sdrNit_ = sdrNit; 444 } 445 SetDisplayNit(float displayNit)446 void SetDisplayNit(float displayNit) 447 { 448 displayNit_ = displayNit; 449 } 450 SetBrightnessRatio(float brightnessRatio)451 void SetBrightnessRatio(float brightnessRatio) 452 { 453 brightnessRatio_ = brightnessRatio; 454 } 455 GetLayerLinearMatrix()456 const std::vector<float>& GetLayerLinearMatrix() const 457 { 458 return layerLinearMatrix_; 459 } 460 SetLayerLinearMatrix(const std::vector<float> & layerLinearMatrix)461 void SetLayerLinearMatrix(const std::vector<float>& layerLinearMatrix) 462 { 463 layerLinearMatrix_ = layerLinearMatrix; 464 } 465 466 // source crop tuning GetLayerSourceTuning()467 int32_t GetLayerSourceTuning() const 468 { 469 return layerSource_; 470 } 471 SetLayerSourceTuning(int32_t layerSouce)472 void SetLayerSourceTuning(int32_t layerSouce) 473 { 474 layerSource_ = layerSouce; 475 } 476 SetRotationFixed(bool rotationFixed)477 void SetRotationFixed(bool rotationFixed) 478 { 479 rotationFixed_ = rotationFixed; 480 } 481 GetRotationFixed()482 bool GetRotationFixed() const 483 { 484 return rotationFixed_; 485 } 486 SetLayerArsr(bool arsrTag)487 void SetLayerArsr(bool arsrTag) 488 { 489 arsrTag_ = arsrTag; 490 } 491 GetLayerArsr()492 bool GetLayerArsr() const 493 { 494 return arsrTag_; 495 } 496 SetLayerCopybit(bool copybitTag)497 void SetLayerCopybit(bool copybitTag) 498 { 499 copybitTag_ = copybitTag; 500 } 501 GetLayerCopybit()502 bool GetLayerCopybit() const 503 { 504 return copybitTag_; 505 } 506 SetNeedBilinearInterpolation(bool need)507 void SetNeedBilinearInterpolation(bool need) 508 { 509 needBilinearInterpolation_ = need; 510 } 511 GetNeedBilinearInterpolation()512 bool GetNeedBilinearInterpolation() const 513 { 514 return needBilinearInterpolation_; 515 } 516 SetIsMaskLayer(bool isMaskLayer)517 void SetIsMaskLayer(bool isMaskLayer) 518 { 519 isMaskLayer_ = isMaskLayer; 520 } 521 IsMaskLayer()522 bool IsMaskLayer() const 523 { 524 return isMaskLayer_; 525 } 526 CopyLayerInfo(const std::shared_ptr<HdiLayerInfo> & layerInfo)527 void CopyLayerInfo(const std::shared_ptr<HdiLayerInfo> &layerInfo) 528 { 529 std::lock_guard<std::mutex> lock(mutex_); 530 zOrder_ = layerInfo->GetZorder(); 531 layerRect_ = layerInfo->GetLayerSize(); 532 boundRect_ = layerInfo->GetBoundSize(); 533 visibleRegions_ = layerInfo->GetVisibleRegions(); 534 dirtyRegions_ = layerInfo->GetDirtyRegions(); 535 cropRect_ = layerInfo->GetCropRect(); 536 matrix_ = layerInfo->GetMatrix(); 537 gravity_ = layerInfo->GetGravity(); 538 layerAlpha_ = layerInfo->GetAlpha(); 539 transformType_ = layerInfo->GetTransformType(); 540 compositionType_ = layerInfo->GetCompositionType(); 541 blendType_ = layerInfo->GetBlendType(); 542 colorTransformMatrix_ = layerInfo->GetColorTransform(); 543 colorSpace_ = layerInfo->GetColorDataSpace(); 544 layerColor_ = layerInfo->GetLayerColor(); 545 metaData_ = layerInfo->GetMetaData(); 546 metaDataSet_ = layerInfo->GetMetaDataSet(); 547 tunnelHandle_ = layerInfo->GetTunnelHandle(); 548 tunnelHandleChange_ = layerInfo->GetTunnelHandleChange(); 549 sbuffer_ = layerInfo->GetBuffer(); 550 pbuffer_= layerInfo->GetPreBuffer(); 551 acquireFence_ = layerInfo->GetAcquireFence(); 552 preMulti_ = layerInfo->IsPreMulti(); 553 sdrNit_ = layerInfo->GetSdrNit(); 554 displayNit_ = layerInfo->GetDisplayNit(); 555 brightnessRatio_ = layerInfo->GetBrightnessRatio(); 556 layerLinearMatrix_ = layerInfo->GetLayerLinearMatrix(); 557 layerSource_ = layerInfo->GetLayerSourceTuning(); 558 rotationFixed_ = layerInfo->GetRotationFixed(); 559 arsrTag_ = layerInfo->GetLayerArsr(); 560 copybitTag_ = layerInfo->GetLayerCopybit(); 561 needBilinearInterpolation_ = layerInfo->GetNeedBilinearInterpolation(); 562 tunnelLayerId_ = layerInfo->GetTunnelLayerId(); 563 tunnelLayerProperty_ = layerInfo->GetTunnelLayerProperty(); 564 ancoFlags_ = layerInfo->GetAncoFlags(); 565 } 566 Dump(std::string & result)567 void Dump(std::string &result) const 568 { 569 std::lock_guard<std::mutex> lock(mutex_); 570 if (TransformTypeStrs.find(transformType_) != TransformTypeStrs.end() && 571 CompositionTypeStrs.find(compositionType_) != CompositionTypeStrs.end() && 572 BlendTypeStrs.find(blendType_) != BlendTypeStrs.end()) { 573 result += " zOrder = " + std::to_string(zOrder_) + 574 ", visibleNum = " + std::to_string(visibleRegions_.size()) + 575 ", transformType = " + TransformTypeStrs.at(transformType_) + 576 ", compositionType = " + CompositionTypeStrs.at(compositionType_) + 577 ", blendType = " + BlendTypeStrs.at(blendType_) + 578 ", layerAlpha = [enGlobalAlpha(" + std::to_string(layerAlpha_.enGlobalAlpha) + "), enPixelAlpha(" + 579 std::to_string(layerAlpha_.enPixelAlpha) + "), alpha0(" + 580 std::to_string(layerAlpha_.alpha0) + "), alpha1(" + 581 std::to_string(layerAlpha_.alpha1) + "), gAlpha(" + 582 std::to_string(layerAlpha_.gAlpha) + ")].\n"; 583 } 584 result += " layerRect = [" + std::to_string(layerRect_.x) + ", " + 585 std::to_string(layerRect_.y) + ", " + 586 std::to_string(layerRect_.w) + ", " + 587 std::to_string(layerRect_.h) + "], "; 588 result += "cropRect = [" + std::to_string(cropRect_.x) + ", " + 589 std::to_string(cropRect_.y) + ", " + 590 std::to_string(cropRect_.w) + ", " + 591 std::to_string(cropRect_.h) + "],"; 592 for (decltype(visibleRegions_.size()) i = 0; i < visibleRegions_.size(); i++) { 593 result += "visibleRegions[" + std::to_string(i) + "] = [" + 594 std::to_string(visibleRegions_[i].x) + ", " + 595 std::to_string(visibleRegions_[i].y) + ", " + 596 std::to_string(visibleRegions_[i].w) + ", " + 597 std::to_string(visibleRegions_[i].h) + "], "; 598 } 599 for (decltype(dirtyRegions_.size()) i = 0; i < dirtyRegions_.size(); i++) { 600 result += "dirtyRegions[" + std::to_string(i) + "] = [" + 601 std::to_string(dirtyRegions_[i].x) + ", " + 602 std::to_string(dirtyRegions_[i].y) + ", " + 603 std::to_string(dirtyRegions_[i].w) + ", " + 604 std::to_string(dirtyRegions_[i].h) + "], "; 605 } 606 result += "layerColor = [R:" + std::to_string(layerColor_.r) + ", G:" + 607 std::to_string(layerColor_.g) + ", B:" + 608 std::to_string(layerColor_.b) + ", A:" + 609 std::to_string(layerColor_.a) + "],"; 610 if (cSurface_ != nullptr) { 611 cSurface_->Dump(result); 612 } 613 result += " displayNit = " + std::to_string(displayNit_) + 614 ", brightnessRatio = " + std::to_string(brightnessRatio_) + ", "; 615 result += " ancoFlags = " + std::to_string(ancoFlags_) + ", "; 616 } 617 DumpCurrentFrameLayer()618 void DumpCurrentFrameLayer() const 619 { 620 std::lock_guard<std::mutex> lock(mutex_); 621 if (cSurface_ != nullptr) { 622 cSurface_->DumpCurrentFrameLayer(); 623 } 624 } 625 SetLayerMaskInfo(LayerMask mask)626 RosenError SetLayerMaskInfo(LayerMask mask) 627 { 628 switch (mask) { 629 case LayerMask::LAYER_MASK_NORMAL: 630 case LayerMask::LAYER_MASK_HBM_SYNC: 631 break; 632 default: 633 return ROSEN_ERROR_INVALID_ARGUMENTS; 634 } 635 636 layerMask_ = mask; 637 return ROSEN_ERROR_OK; 638 } 639 GetLayerMaskInfo()640 LayerMask GetLayerMaskInfo() 641 { 642 return layerMask_; 643 } 644 GetNodeId()645 inline uint64_t GetNodeId() 646 { 647 return nodeId_; 648 } 649 SetNodeId(uint64_t nodeId)650 void SetNodeId(uint64_t nodeId) 651 { 652 nodeId_ = nodeId; 653 } 654 SetAncoFlags(const uint32_t ancoFlags)655 void SetAncoFlags(const uint32_t ancoFlags) { ancoFlags_ = ancoFlags; } GetAncoFlags()656 uint32_t GetAncoFlags() const { return ancoFlags_; } IsAncoNative()657 bool IsAncoNative() const 658 { 659 constexpr uint32_t ANCO_NATIVE_NODE_FLAG = static_cast<uint32_t>(AncoFlags::ANCO_NATIVE_NODE); 660 return (ancoFlags_ & ANCO_NATIVE_NODE_FLAG) == ANCO_NATIVE_NODE_FLAG; 661 } 662 /* hdiLayer get layer info end */ 663 664 private: 665 uint32_t zOrder_ = 0; 666 GraphicLayerType layerType_ = GraphicLayerType::GRAPHIC_LAYER_TYPE_GRAPHIC; 667 GraphicIRect layerRect_; 668 GraphicIRect boundRect_; // node's bound width and height related to this layer, used for uni render redraw 669 std::vector<GraphicIRect> visibleRegions_; 670 std::vector<GraphicIRect> dirtyRegions_; 671 GraphicIRect cropRect_; 672 GraphicMatrix matrix_; // matrix used for uni render redraw 673 int32_t gravity_; // used for uni render redraw 674 bool isUniRender_ = false; // true for uni render layer (DisplayNode) 675 GraphicLayerAlpha layerAlpha_; 676 GraphicTransformType transformType_ = GraphicTransformType::GRAPHIC_ROTATE_BUTT; 677 GraphicCompositionType compositionType_; 678 GraphicBlendType blendType_; 679 std::vector<float> colorTransformMatrix_; 680 GraphicLayerColor layerColor_; 681 GraphicLayerColor backgroundColor_; 682 GraphicColorDataSpace colorSpace_ = GraphicColorDataSpace::GRAPHIC_COLOR_DATA_SPACE_UNKNOWN; 683 std::vector<GraphicHDRMetaData> metaData_; 684 GraphicHDRMetaDataSet metaDataSet_; 685 sptr<SurfaceTunnelHandle> tunnelHandle_ = nullptr; 686 std::vector<std::string> windowsName_; 687 bool tunnelHandleChange_ = false; 688 bool IsSupportedPresentTimestamp_ = false; 689 GraphicPresentTimestamp presentTimestamp_ = {GRAPHIC_DISPLAY_PTS_UNSUPPORTED, 0}; 690 691 sptr<IConsumerSurface> cSurface_ = nullptr; 692 sptr<SyncFence> acquireFence_ = SyncFence::InvalidFence(); 693 sptr<SurfaceBuffer> sbuffer_ = nullptr; 694 sptr<SurfaceBuffer> pbuffer_ = nullptr; 695 bool preMulti_ = false; 696 bool needBilinearInterpolation_ = false; 697 LayerMask layerMask_ = LayerMask::LAYER_MASK_NORMAL; 698 mutable std::mutex mutex_; 699 float sdrNit_ = 500.0f; // default sdr nit 700 float displayNit_ = 500.0f; // default luminance for sdr 701 float brightnessRatio_ = 1.0f; // default ratio for sdr 702 std::vector<float> layerLinearMatrix_ 703 = {1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f}; // matrix for linear colorspace 704 uint64_t nodeId_ = 0; 705 uint64_t tunnelLayerId_ = 0; 706 uint32_t tunnelLayerProperty_ = 0; 707 int32_t layerSource_ = 0; // default layer source tag 708 bool rotationFixed_ = false; 709 bool arsrTag_ = true; 710 bool copybitTag_ = false; 711 std::vector<float> drmCornerRadiusInfo_; 712 uint32_t ancoFlags_ = 0; 713 bool isMaskLayer_ = false; 714 }; 715 } // namespace Rosen 716 } // namespace OHOS 717 718 #endif // HDI_BACKEND_HDI_LAYER_INFO_H