1 /* 2 * Copyright (c) 2021-2023 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 RENDER_SERVICE_CLIENT_CORE_PROPERTY_RS_PROPERTIES_H 17 #define RENDER_SERVICE_CLIENT_CORE_PROPERTY_RS_PROPERTIES_H 18 19 #include <bitset> 20 #include <optional> 21 #include <tuple> 22 #include <vector> 23 24 #include "animation/rs_render_particle.h" 25 #include "animation/rs_particle_noise_field.h" 26 #include "common/rs_macros.h" 27 #include "common/rs_matrix3.h" 28 #include "common/rs_vector4.h" 29 #include "effect/runtime_blender_builder.h" 30 #include "modifier/rs_modifier_type.h" 31 #include "property/rs_properties_def.h" 32 #include "render/rs_border.h" 33 #include "render/rs_filter.h" 34 #include "render/rs_gradient_blur_para.h" 35 #include "render/rs_image.h" 36 #include "render/rs_magnifier_para.h" 37 #include "render/rs_mask.h" 38 #include "render/rs_motion_blur_filter.h" 39 #include "render/rs_particles_drawable.h" 40 #include "render/rs_path.h" 41 #include "render/rs_shader.h" 42 #include "render/rs_shadow.h" 43 #include "render/rs_attraction_effect_filter.h" 44 45 #include "property/rs_filter_cache_manager.h" 46 47 namespace OHOS { 48 namespace Rosen { 49 class RSRenderNode; 50 class RSObjAbsGeometry; 51 namespace DrawableV2 { 52 class RSBackgroundImageDrawable; 53 class RSBackgroundFilterDrawable; 54 class RSShadowDrawable; 55 class RSFilterDrawable; 56 } 57 class RSB_EXPORT RSProperties final { 58 public: 59 RSProperties(); 60 RSProperties(const RSProperties&) = delete; 61 RSProperties(const RSProperties&&) = delete; 62 RSProperties& operator=(const RSProperties&) = delete; 63 RSProperties& operator=(const RSProperties&&) = delete; 64 virtual ~RSProperties(); 65 66 // geometry properties 67 void SetBounds(Vector4f bounds); 68 void SetBoundsSize(Vector2f size); 69 void SetBoundsWidth(float width); 70 void SetBoundsHeight(float height); 71 void SetBoundsPosition(Vector2f position); 72 void SetBoundsPositionX(float positionX); 73 void SetBoundsPositionY(float positionY); 74 Vector4f GetBounds() const; 75 Vector2f GetBoundsSize() const; 76 float GetBoundsWidth() const; 77 float GetBoundsHeight() const; 78 Vector2f GetBoundsPosition() const; 79 float GetBoundsPositionX() const; 80 float GetBoundsPositionY() const; 81 82 void SetFrame(Vector4f frame); 83 void SetFrameSize(Vector2f size); 84 void SetFrameWidth(float width); 85 void SetFrameHeight(float height); 86 void SetFramePosition(Vector2f position); 87 void SetFramePositionX(float positionX); 88 void SetFramePositionY(float positionY); 89 Vector4f GetFrame() const; 90 Vector2f GetFrameSize() const; 91 float GetFrameWidth() const; 92 float GetFrameHeight() const; 93 Vector2f GetFramePosition() const; 94 float GetFramePositionX() const; 95 float GetFramePositionY() const; 96 float GetFrameOffsetX() const; 97 float GetFrameOffsetY() const; 98 99 void SetSandBox(const std::optional<Vector2f>& parentPosition); 100 std::optional<Vector2f> GetSandBox() const; 101 void ResetSandBox(); 102 void UpdateSandBoxMatrix(const std::optional<Drawing::Matrix>& rootMatrix); 103 std::optional<Drawing::Matrix> GetSandBoxMatrix() const; 104 105 void SetPositionZ(float positionZ); 106 float GetPositionZ() const; 107 void SetPositionZApplicableCamera3D(bool isApplicable); 108 bool GetPositionZApplicableCamera3D() const; 109 110 void SetPivot(Vector2f pivot); 111 void SetPivotX(float pivotX); 112 void SetPivotY(float pivotY); 113 void SetPivotZ(float pivotZ); 114 Vector2f GetPivot() const; 115 float GetPivotX() const; 116 float GetPivotY() const; 117 float GetPivotZ() const; 118 119 void SetCornerRadius(const Vector4f& cornerRadius); 120 const Vector4f& GetCornerRadius() const; 121 122 void SetQuaternion(Quaternion quaternion); 123 void SetRotation(float degree); 124 void SetRotationX(float degree); 125 void SetRotationY(float degree); 126 void SetCameraDistance(float cameraDistance); 127 Quaternion GetQuaternion() const; 128 float GetRotation() const; 129 float GetRotationX() const; 130 float GetRotationY() const; 131 float GetCameraDistance() const; 132 133 void SetTranslate(Vector2f translate); 134 void SetTranslateX(float translate); 135 void SetTranslateY(float translate); 136 void SetTranslateZ(float translate); 137 Vector2f GetTranslate() const; 138 float GetTranslateX() const; 139 float GetTranslateY() const; 140 float GetTranslateZ() const; 141 142 void SetScale(Vector2f scale); 143 void SetScaleX(float sx); 144 void SetScaleY(float sy); 145 Vector2f GetScale() const; 146 float GetScaleX() const; 147 float GetScaleY() const; 148 149 void SetSkew(Vector2f skew); 150 void SetSkewX(float skewX); 151 void SetSkewY(float skewY); 152 Vector2f GetSkew() const; 153 float GetSkewX() const; 154 float GetSkewY() const; 155 156 void SetPersp(Vector2f persp); 157 void SetPerspX(float perspX); 158 void SetPerspY(float perspY); 159 Vector2f GetPersp() const; 160 float GetPerspX() const; 161 float GetPerspY() const; 162 163 void SetAlpha(float alpha); 164 float GetAlpha() const; 165 void SetAlphaOffscreen(bool alphaOffscreen); 166 bool GetAlphaOffscreen() const; 167 168 void SetSublayerTransform(const std::optional<Matrix3f>& sublayerTransform); 169 const std::optional<Matrix3f>& GetSublayerTransform() const; 170 GetUseShadowBatching()171 inline bool GetUseShadowBatching() const 172 { 173 return useShadowBatching_; 174 } 175 176 void SetUseShadowBatching(bool useShadowBatching); GetNeedSkipShadow()177 inline bool GetNeedSkipShadow() const 178 { 179 return needSkipShadow_; 180 } 181 SetNeedSkipShadow(bool needSkipShadow)182 inline void SetNeedSkipShadow(bool needSkipShadow) 183 { 184 needSkipShadow_ = needSkipShadow; 185 } 186 187 // particle properties 188 void SetParticles(const RSRenderParticleVector& particles); 189 const RSRenderParticleVector& GetParticles() const; 190 191 // foreground properties 192 void SetForegroundColor(Color color); 193 Color GetForegroundColor() const; 194 195 // background properties 196 void SetBackgroundColor(Color color); 197 const Color& GetBackgroundColor() const; 198 void SetBackgroundShader(const std::shared_ptr<RSShader>& shader); 199 std::shared_ptr<RSShader> GetBackgroundShader() const; 200 void SetBgImage(const std::shared_ptr<RSImage>& image); 201 std::shared_ptr<RSImage> GetBgImage() const; 202 void SetBgImageInnerRect(const Vector4f& rect); 203 Vector4f GetBgImageInnerRect() const; 204 void SetBgImageWidth(float width); 205 void SetBgImageHeight(float height); 206 void SetBgImagePositionX(float positionX); 207 void SetBgImagePositionY(float positionY); 208 float GetBgImageWidth() const; 209 float GetBgImageHeight() const; 210 float GetBgImagePositionX() const; 211 float GetBgImagePositionY() const; 212 213 // border properties 214 void SetBorderColor(Vector4<Color> color); 215 void SetBorderWidth(Vector4f width); 216 void SetBorderStyle(Vector4<uint32_t> style); 217 void SetBorderDashWidth(const Vector4f& dashWidth); 218 void SetBorderDashGap(const Vector4f& dashGap); 219 Vector4<Color> GetBorderColor() const; 220 Vector4f GetBorderWidth() const; 221 Vector4<uint32_t> GetBorderStyle() const; 222 Vector4f GetBorderDashWidth() const; 223 Vector4f GetBorderDashGap() const; 224 const std::shared_ptr<RSBorder>& GetBorder() const; 225 void SetOutlineColor(Vector4<Color> color); 226 void SetOutlineWidth(Vector4f width); 227 void SetOutlineStyle(Vector4<uint32_t> style); 228 void SetOutlineDashWidth(const Vector4f& dashWidth); 229 void SetOutlineDashGap(const Vector4f& dashGap); 230 void SetOutlineRadius(Vector4f radius); 231 Vector4<Color> GetOutlineColor() const; 232 Vector4f GetOutlineWidth() const; 233 Vector4<uint32_t> GetOutlineStyle() const; 234 Vector4f GetOutlineDashWidth() const; 235 Vector4f GetOutlineDashGap() const; 236 Vector4f GetOutlineRadius() const; 237 const std::shared_ptr<RSBorder>& GetOutline() const; 238 bool GetBorderColorIsTransparent() const; 239 240 void SetForegroundEffectRadius(const float foregroundEffectRadius); 241 float GetForegroundEffectRadius() const; 242 bool IsForegroundEffectRadiusValid() const; 243 void SetForegroundEffectDirty(bool dirty); 244 bool GetForegroundEffectDirty() const; 245 void SetForegroundFilterCache(const std::shared_ptr<RSFilter>& foregroundFilterCache); 246 const std::shared_ptr<RSFilter>& GetForegroundFilterCache() const; 247 248 // filter properties 249 void SetBackgroundFilter(const std::shared_ptr<RSFilter>& backgroundFilter); 250 void SetLinearGradientBlurPara(const std::shared_ptr<RSLinearGradientBlurPara>& para); 251 void SetEmitterUpdater(const std::vector<std::shared_ptr<EmitterUpdater>>& para); 252 void SetParticleNoiseFields(const std::shared_ptr<ParticleNoiseFields>& para); 253 void SetDynamicLightUpRate(const std::optional<float>& rate); 254 void SetDynamicLightUpDegree(const std::optional<float>& lightUpDegree); 255 void SetDynamicDimDegree(const std::optional<float>& DimDegree); 256 257 void SetFgBrightnessRates(const Vector4f& rates); 258 Vector4f GetFgBrightnessRates() const; 259 void SetFgBrightnessSaturation(const float& saturation); 260 float GetFgBrightnessSaturation() const; 261 void SetFgBrightnessPosCoeff(const Vector4f& coeff); 262 Vector4f GetFgBrightnessPosCoeff() const; 263 void SetFgBrightnessNegCoeff(const Vector4f& coeff); 264 Vector4f GetFgBrightnessNegCoeff() const; 265 void SetFgBrightnessFract(const float& fraction); 266 float GetFgBrightnessFract() const; 267 void SetFgBrightnessParams(const std::optional<RSDynamicBrightnessPara>& params); 268 std::optional<RSDynamicBrightnessPara> GetFgBrightnessParams() const; 269 270 void SetWaterRippleParams(const std::optional<RSWaterRipplePara>& params); 271 std::optional<RSWaterRipplePara> GetWaterRippleParams() const; 272 void SetWaterRippleProgress(const float& progress); 273 float GetWaterRippleProgress() const; 274 275 void SetFlyOutParams(const std::optional<RSFlyOutPara>& params); 276 std::optional<RSFlyOutPara> GetFlyOutParams() const; 277 void SetFlyOutDegree(const float& degree); 278 float GetFlyOutDegree() const; 279 void CreateFlyOutShaderFilter(); 280 281 void SetDistortionK(const std::optional<float>& distortionK); 282 const std::optional<float>& GetDistortionK() const; 283 284 void SetBgBrightnessRates(const Vector4f& rates); 285 Vector4f GetBgBrightnessRates() const; 286 void SetBgBrightnessSaturation(const float& saturation); 287 float GetBgBrightnessSaturation() const; 288 void SetBgBrightnessPosCoeff(const Vector4f& coeff); 289 Vector4f GetBgBrightnessPosCoeff() const; 290 void SetBgBrightnessNegCoeff(const Vector4f& coeff); 291 Vector4f GetBgBrightnessNegCoeff() const; 292 void SetBgBrightnessFract(const float& fraction); 293 float GetBgBrightnessFract() const; 294 void SetBgBrightnessParams(const std::optional<RSDynamicBrightnessPara>& params); 295 std::optional<RSDynamicBrightnessPara> GetBgBrightnessParams() const; 296 297 void SetFilter(const std::shared_ptr<RSFilter>& filter); 298 void SetMotionBlurPara(const std::shared_ptr<MotionBlurParam>& para); 299 void SetMagnifierParams(const std::shared_ptr<RSMagnifierParams>& para); 300 const std::shared_ptr<RSFilter>& GetBackgroundFilter() const; 301 const std::shared_ptr<RSLinearGradientBlurPara>& GetLinearGradientBlurPara() const; 302 const std::vector<std::shared_ptr<EmitterUpdater>>& GetEmitterUpdater() const; 303 const std::shared_ptr<ParticleNoiseFields>& GetParticleNoiseFields() const; 304 void IfLinearGradientBlurInvalid(); 305 const std::shared_ptr<RSFilter>& GetFilter() const; 306 const std::shared_ptr<MotionBlurParam>& GetMotionBlurPara() const; 307 const std::shared_ptr<RSMagnifierParams>& GetMagnifierPara() const; 308 bool NeedFilter() const; 309 void SetGreyCoef(const std::optional<Vector2f>& greyCoef); 310 const std::optional<Vector2f>& GetGreyCoef() const; 311 const std::shared_ptr<RSFilter>& GetForegroundFilter() const; 312 void SetForegroundFilter(const std::shared_ptr<RSFilter>& foregroundFilter); 313 314 void SetBackgroundBlurRadius(float backgroundBlurRadius); 315 float GetBackgroundBlurRadius() const; 316 bool IsBackgroundBlurRadiusValid() const; 317 318 void SetBackgroundBlurSaturation(float backgroundBlurSaturation); 319 float GetBackgroundBlurSaturation() const; 320 bool IsBackgroundBlurSaturationValid() const; 321 322 void SetBackgroundBlurBrightness(float backgroundBlurBrightness); 323 float GetBackgroundBlurBrightness() const; 324 bool IsBackgroundBlurBrightnessValid() const; 325 326 void SetBackgroundBlurMaskColor(Color backgroundMaskColor); 327 const Color& GetBackgroundBlurMaskColor() const; 328 bool IsBackgroundBlurMaskColorValid() const; 329 330 void SetBackgroundBlurColorMode(int backgroundColorMode); 331 int GetBackgroundBlurColorMode() const; 332 333 void SetBackgroundBlurRadiusX(float backgroundBlurRadiusX); 334 float GetBackgroundBlurRadiusX() const; 335 bool IsBackgroundBlurRadiusXValid() const; 336 337 void SetBackgroundBlurRadiusY(float backgroundBlurRadiusY); 338 float GetBackgroundBlurRadiusY() const; 339 bool IsBackgroundBlurRadiusYValid() const; 340 341 void SetForegroundBlurRadius(float ForegroundBlurRadius); 342 float GetForegroundBlurRadius() const; 343 bool IsForegroundBlurRadiusValid() const; 344 345 void SetForegroundBlurSaturation(float ForegroundBlurSaturation); 346 float GetForegroundBlurSaturation() const; 347 bool IsForegroundBlurSaturationValid() const; 348 349 void SetForegroundBlurBrightness(float ForegroundBlurBrightness); 350 float GetForegroundBlurBrightness() const; 351 bool IsForegroundBlurBrightnessValid() const; 352 353 void SetForegroundBlurMaskColor(Color ForegroundMaskColor); 354 const Color& GetForegroundBlurMaskColor() const; 355 bool IsForegroundBlurMaskColorValid() const; 356 357 void SetForegroundBlurColorMode(int ForegroundColorMode); 358 int GetForegroundBlurColorMode() const; 359 360 void SetForegroundBlurRadiusX(float foregroundBlurRadiusX); 361 float GetForegroundBlurRadiusX() const; 362 bool IsForegroundBlurRadiusXValid() const; 363 364 void SetForegroundBlurRadiusY(float foregroundBlurRadiusY); 365 float GetForegroundBlurRadiusY() const; 366 bool IsForegroundBlurRadiusYValid() const; 367 368 bool IsBackgroundMaterialFilterValid() const; 369 bool IsForegroundMaterialFilterVaild() const; 370 371 // shadow properties 372 void SetShadowColor(Color color); 373 void SetShadowOffsetX(float offsetX); 374 void SetShadowOffsetY(float offsetY); 375 void SetShadowAlpha(float alpha); 376 void SetShadowElevation(float radius); 377 void SetShadowRadius(float radius); 378 void SetShadowPath(std::shared_ptr<RSPath> shadowPath); 379 void SetShadowMask(bool shadowMask); 380 void SetShadowIsFilled(bool shadowIsFilled); 381 void SetShadowColorStrategy(int shadowColorStrategy); 382 const Color& GetShadowColor() const; 383 float GetShadowOffsetX() const; 384 float GetShadowOffsetY() const; 385 float GetShadowAlpha() const; 386 float GetShadowElevation() const; 387 float GetShadowRadius() const; 388 const std::optional<float>& GetDynamicLightUpRate() const; 389 const std::optional<float>& GetDynamicLightUpDegree() const; 390 const std::optional<float>& GetDynamicDimDegree() const; 391 std::shared_ptr<RSPath> GetShadowPath() const; 392 bool GetShadowMask() const; 393 bool GetShadowIsFilled() const; 394 int GetShadowColorStrategy() const; 395 const std::optional<RSShadow>& GetShadow() const; 396 bool IsShadowValid() const; 397 398 void SetFrameGravity(Gravity gravity); 399 Gravity GetFrameGravity() const; 400 401 void SetDrawRegion(const std::shared_ptr<RectF>& rect); 402 std::shared_ptr<RectF> GetDrawRegion() const; 403 404 void SetClipRRect(RRect clipRRect); 405 RRect GetClipRRect() const; 406 bool GetClipToRRect() const; 407 void SetClipBounds(const std::shared_ptr<RSPath>& path); 408 const std::shared_ptr<RSPath>& GetClipBounds() const; 409 void SetClipToBounds(bool clipToBounds); 410 bool GetClipToBounds() const; 411 void SetClipToFrame(bool clipToFrame); 412 bool GetClipToFrame() const; 413 414 void SetVisible(bool visible); 415 bool GetVisible() const; 416 std::string Dump() const; 417 418 void SetMask(const std::shared_ptr<RSMask>& mask); 419 std::shared_ptr<RSMask> GetMask() const; 420 421 // Pixel Stretch 422 void SetPixelStretch(const std::optional<Vector4f>& stretchSize); GetPixelStretch()423 inline const std::optional<Vector4f>& GetPixelStretch() const 424 { 425 return pixelStretch_; 426 } 427 428 void SetPixelStretchPercent(const std::optional<Vector4f>& stretchPercent); GetPixelStretchPercent()429 inline const std::optional<Vector4f>& GetPixelStretchPercent() const 430 { 431 return pixelStretchPercent_; 432 } 433 434 void SetPixelStretchTileMode(int stretchTileMode); 435 int GetPixelStretchTileMode() const; 436 437 void SetAiInvert(const std::optional<Vector4f>& aiInvert); 438 const std::optional<Vector4f>& GetAiInvert() const; 439 void SetSystemBarEffect(bool systemBarEffect); 440 bool GetSystemBarEffect() const; 441 RectI GetPixelStretchDirtyRect() const; 442 443 const std::shared_ptr<RSObjAbsGeometry>& GetBoundsGeometry() const; 444 const std::shared_ptr<RSObjGeometry>& GetFrameGeometry() const; 445 bool UpdateGeometry(const RSProperties* parent, bool dirtyFlag, const std::optional<Drawing::Point>& offset); 446 bool UpdateGeometryByParent(const Drawing::Matrix* parentMatrix, const std::optional<Drawing::Point>& offset); 447 RectF GetLocalBoundsAndFramesRect() const; 448 RectF GetBoundsRect() const; 449 450 bool IsGeoDirty() const; 451 bool IsCurGeoDirty() const; 452 bool IsContentDirty() const; 453 454 void SetSpherize(float spherizeDegree); 455 float GetSpherize() const; 456 bool IsSpherizeValid() const; 457 void CreateSphereEffectFilter(); 458 459 bool IsAttractionValid() const; 460 void SetAttractionFraction(float fraction); 461 void SetAttractionDstPoint(Vector2f dstPoint); 462 float GetAttractionFraction() const; 463 Vector2f GetAttractionDstPoint() const; 464 void CreateAttractionEffectFilter(); 465 RectI GetAttractionEffectCurrentDirtyRegion() const; 466 467 void SetLightUpEffect(float lightUpEffectDegree); 468 float GetLightUpEffect() const; 469 bool IsLightUpEffectValid() const; 470 bool IsDynamicLightUpValid() const; 471 bool IsDynamicDimValid() const; 472 bool IsFgBrightnessValid() const; 473 bool IsBgBrightnessValid() const; 474 bool IsWaterRippleValid() const; 475 bool IsFlyOutValid() const; 476 bool IsDistortionKValid() const; 477 void SetDistortionDirty(bool distortionEffectDirty); 478 bool GetDistortionDirty() const; 479 std::string GetFgBrightnessDescription() const; 480 std::string GetBgBrightnessDescription() const; 481 482 // Image effect properties 483 void SetGrayScale(const std::optional<float>& grayScale); GetGrayScale()484 inline const std::optional<float>& GetGrayScale() const 485 { 486 return grayScale_; 487 } 488 489 void SetBrightness(const std::optional<float>& brightness); 490 const std::optional<float>& GetBrightness() const; 491 void SetContrast(const std::optional<float>& contrast); 492 const std::optional<float>& GetContrast() const; 493 void SetSaturate(const std::optional<float>& saturate); 494 const std::optional<float>& GetSaturate() const; 495 void SetSepia(const std::optional<float>& sepia); 496 const std::optional<float>& GetSepia() const; 497 void SetInvert(const std::optional<float>& invert); 498 const std::optional<float>& GetInvert() const; 499 void SetHueRotate(const std::optional<float>& hueRotate); 500 const std::optional<float>& GetHueRotate() const; 501 void SetColorBlend(const std::optional<Color>& colorBlend); 502 const std::optional<Color>& GetColorBlend() const; 503 504 const std::shared_ptr<Drawing::ColorFilter>& GetColorFilter() const; 505 506 void SetLightIntensity(float lightIntensity); 507 void SetLightColor(Color lightColor); 508 void SetLightPosition(const Vector4f& lightPosition); 509 void SetIlluminatedBorderWidth(float illuminatedBorderWidth); 510 void SetIlluminatedType(int illuminatedType); 511 void SetBloom(float bloomIntensity); 512 float GetLightIntensity() const; 513 Color GetLightColor() const; 514 Vector4f GetLightPosition() const; GetIlluminatedBorderWidth()515 inline float GetIlluminatedBorderWidth() const 516 { 517 return illuminatedPtr_ ? illuminatedPtr_->GetIlluminatedBorderWidth() : 0.f; 518 } 519 520 int GetIlluminatedType() const; GetBloom()521 inline float GetBloom() const 522 { 523 return illuminatedPtr_ ? illuminatedPtr_->GetBloomIntensity() : 0.f; 524 } 525 526 void CalculateAbsLightPosition(); GetLightSource()527 inline const std::shared_ptr<RSLightSource>& GetLightSource() const 528 { 529 return lightSourcePtr_; 530 } GetIlluminated()531 inline const std::shared_ptr<RSIlluminated>& GetIlluminated() const 532 { 533 return illuminatedPtr_; 534 } 535 536 void SetUseEffect(bool useEffect); 537 bool GetUseEffect() const; 538 void SetUseEffectType(int useEffectType); 539 int GetUseEffectType() const; 540 void SetNeedDrawBehindWindow(bool needDrawBehindWindow); 541 bool GetNeedDrawBehindWindow() const; 542 543 void SetColorBlendMode(int colorBlendMode); 544 int GetColorBlendMode() const; 545 void SetColorBlendApplyType(int colorBlendApplyType); 546 int GetColorBlendApplyType() const; 547 548 #if defined(NEW_SKIA) && (defined(RS_ENABLE_GL) || defined(RS_ENABLE_VK)) 549 const std::unique_ptr<RSFilterCacheManager>& GetFilterCacheManager(bool isForeground) const; 550 void ClearFilterCache(); 551 #endif 552 553 const RRect& GetRRect() const; 554 RRect GetInnerRRect() const; 555 RectF GetFrameRect() const; 556 557 bool GetHaveEffectRegion() const; 558 void SetHaveEffectRegion(bool hasEffectRegion); 559 560 void OnApplyModifiers(); 561 562 private: 563 void ResetProperty(const std::bitset<static_cast<int>(RSModifierType::MAX_RS_MODIFIER_TYPE)>& dirtyTypes); 564 void SetDirty(); 565 void ResetDirty(); 566 bool IsDirty() const; 567 void AccmulateDirtyStatus(); 568 void RecordCurDirtyStatus(); 569 570 // generate filter 571 void GenerateBackgroundFilter(); 572 void GenerateForegroundFilter(); 573 void GenerateBackgroundBlurFilter(); 574 void GenerateForegroundBlurFilter(); 575 void GenerateBackgroundMaterialBlurFilter(); 576 void GenerateForegroundMaterialBlurFilter(); 577 void GenerateBackgroundMaterialFuzedBlurFilter(); 578 void GenerateCompositingMaterialFuzedBlurFilter(); 579 std::shared_ptr<Drawing::ColorFilter> GetMaterialColorFilter(float sat, float brightness); 580 void GenerateAIBarFilter(); 581 void GenerateWaterRippleFilter(); 582 void GenerateLinearGradientBlurFilter(); 583 void GenerateMagnifierFilter(); 584 585 bool NeedClip() const; 586 bool NeedBlurFuzed(); 587 588 const RectF& GetBgImageRect() const; 589 void GenerateRRect(); 590 RectI GetDirtyRect() const; 591 // added for update dirty region dfx 592 RectI GetDirtyRect(RectI& drawRegion) const; 593 594 bool visible_ = true; 595 bool clipToBounds_ = false; 596 bool clipToFrame_ = false; 597 bool isDirty_ = false; 598 bool geoDirty_ = false; 599 bool contentDirty_ = false; 600 bool curIsDirty_ = false; 601 bool curGeoDirty_ = false; 602 bool curContentDirty_ = false; 603 bool isDrawn_ = false; 604 bool alphaNeedApply_ = false; 605 bool systemBarEffect_ = false; 606 607 bool hasBounds_ = false; 608 bool useEffect_ = false; 609 int useEffectType_ = 0; 610 bool needDrawBehindWindow_ = false; 611 bool useShadowBatching_ = false; 612 bool needSkipShadow_ = false; 613 614 int colorBlendMode_ = 0; 615 int colorBlendApplyType_ = 0; 616 617 std::optional<RSWaterRipplePara> waterRippleParams_ = std::nullopt; 618 float waterRippleProgress_ = 0.0f; 619 620 std::optional<RSFlyOutPara> flyOutParams_ = std::nullopt; 621 float flyOutDegree_ = 0.0f; 622 623 std::optional<float> distortionK_ = std::nullopt; 624 bool distortionEffectDirty_ = false; 625 626 std::optional<RSDynamicBrightnessPara> fgBrightnessParams_; 627 std::optional<RSDynamicBrightnessPara> bgBrightnessParams_; 628 629 Gravity frameGravity_ = Gravity::DEFAULT; 630 631 std::shared_ptr<RectF> drawRegion_ = nullptr; 632 633 float alpha_ = 1.f; 634 bool alphaOffscreen_ = false; 635 636 std::shared_ptr<RSObjAbsGeometry> boundsGeo_; 637 std::shared_ptr<RSObjGeometry> frameGeo_; 638 639 std::shared_ptr<RSLightSource> lightSourcePtr_ = nullptr; 640 std::shared_ptr<RSIlluminated> illuminatedPtr_ = nullptr; 641 642 float foregroundEffectRadius_ = 0.f; 643 std::shared_ptr<RSFilter> backgroundFilter_ = nullptr; 644 std::shared_ptr<RSLinearGradientBlurPara> linearGradientBlurPara_ = nullptr; 645 std::shared_ptr<MotionBlurParam> motionBlurPara_ = nullptr; 646 std::shared_ptr<RSMagnifierParams> magnifierPara_ = nullptr; 647 std::vector<std::shared_ptr<EmitterUpdater>> emitterUpdater_; 648 std::shared_ptr<ParticleNoiseFields> particleNoiseFields_ = nullptr; 649 std::shared_ptr<RSBorder> border_ = nullptr; 650 std::shared_ptr<RSBorder> outline_ = nullptr; 651 std::shared_ptr<RSPath> clipPath_ = nullptr; 652 std::optional<Vector4f> cornerRadius_; 653 std::optional<Decoration> decoration_; 654 std::shared_ptr<RSFilter> filter_ = nullptr; 655 std::shared_ptr<RSMask> mask_ = nullptr; 656 std::optional<RSShadow> shadow_; 657 std::optional<Matrix3f> sublayerTransform_; 658 float spherizeDegree_ = 0.f; 659 bool isSpherizeValid_ = false; 660 float lightUpEffectDegree_ = 1.0f; 661 std::shared_ptr<RSFilter> foregroundFilter_ = nullptr; // view content filter 662 std::shared_ptr<RSFilter> foregroundFilterCache_ = nullptr; // view content filter via cache 663 bool foregroundEffectDirty_ = false; 664 665 float attractFraction_ = 0.f; 666 Vector2f attractDstPoint_ = {0.f, 0.f}; 667 bool isAttractionValid_ = false; 668 RectI attractionEffectCurrentDirtyRegion_ = {0, 0, 0, 0}; 669 670 // filter property 671 float backgroundBlurRadius_ = 0.f; 672 float backgroundBlurSaturation_ = 1.f; 673 float backgroundBlurBrightness_ = 1.f; 674 Color backgroundMaskColor_ = RSColor(); 675 int backgroundColorMode_ = BLUR_COLOR_MODE::DEFAULT; 676 float backgroundBlurRadiusX_ = 0.f; 677 float backgroundBlurRadiusY_ = 0.f; 678 679 float foregroundBlurRadius_ = 0.f; 680 float foregroundBlurSaturation_ = 1.f; 681 float foregroundBlurBrightness_ = 1.f; 682 Color foregroundMaskColor_ = RSColor(); 683 int foregroundColorMode_ = BLUR_COLOR_MODE::DEFAULT; 684 float foregroundBlurRadiusX_ = 0.f; 685 float foregroundBlurRadiusY_ = 0.f; 686 687 std::weak_ptr<RSRenderNode> backref_; 688 689 std::optional<Vector4f> pixelStretch_; 690 std::optional<Vector4f> pixelStretchPercent_; 691 int pixelStretchTileMode_ = 0; 692 693 std::optional<Vector4f> aiInvert_; 694 std::optional<RRect> clipRRect_; 695 696 std::optional<float> grayScale_; 697 std::optional<float> brightness_; 698 std::optional<float> contrast_; 699 std::optional<float> saturate_; 700 std::optional<float> sepia_; 701 std::optional<float> invert_; 702 std::optional<float> hueRotate_; 703 std::optional<float> dynamicLightUpRate_; 704 std::optional<float> dynamicLightUpDegree_; 705 std::optional<float> dynamicDimDegree_; 706 std::optional<Color> colorBlend_; 707 std::optional<RectI> lastRect_; 708 std::optional<Vector2f> greyCoef_; 709 710 // OnApplyModifiers hooks 711 void CheckEmptyBounds(); 712 void GenerateColorFilter(); 713 void CalculatePixelStretch(); 714 void CalculateFrameOffset(); 715 void CheckGreyCoef(); 716 717 void UpdateFilter(); 718 void UpdateForegroundFilter(); 719 720 // partial update 721 bool colorFilterNeedUpdate_ = false; 722 bool pixelStretchNeedUpdate_ = false; 723 bool filterNeedUpdate_ = false; 724 bool greyCoefNeedUpdate_ = false; 725 float frameOffsetX_ = 0.f; 726 float frameOffsetY_ = 0.f; 727 bool needFilter_ = false; 728 RRect rrect_ = RRect{}; 729 Drawing::Matrix prevAbsMatrix_; 730 731 RSRenderParticleVector particles_; 732 std::shared_ptr<Drawing::ColorFilter> colorFilter_ = nullptr; 733 bool haveEffectRegion_ = false; 734 735 #if defined(NEW_SKIA) && (defined(RS_ENABLE_GL) || defined(RS_ENABLE_VK)) 736 void CreateFilterCacheManagerIfNeed(); 737 std::unique_ptr<RSFilterCacheManager> backgroundFilterCacheManager_; 738 std::unique_ptr<RSFilterCacheManager> foregroundFilterCacheManager_; 739 static const bool FilterCacheEnabled; 740 #endif 741 static const bool IS_UNI_RENDER; 742 static const bool FOREGROUND_FILTER_ENABLED; 743 744 std::unique_ptr<Sandbox> sandbox_ = nullptr; 745 746 friend class RSBackgroundImageDrawable; 747 friend class RSCanvasRenderNode; 748 friend class RSColorfulShadowDrawable; 749 friend class RSEffectDataGenerateDrawable; 750 friend class RSModifierDrawable; 751 friend class RSPropertiesPainter; 752 friend class RSRenderNode; 753 friend class RSEffectRenderNode; 754 friend class RSPropertyDrawableUtils; 755 756 friend class DrawableV2::RSBackgroundImageDrawable; 757 friend class DrawableV2::RSBackgroundFilterDrawable; 758 friend class DrawableV2::RSShadowDrawable; 759 friend class DrawableV2::RSFilterDrawable; 760 #ifdef RS_PROFILER_ENABLED 761 friend class RSProfiler; 762 #endif 763 }; 764 } // namespace Rosen 765 } // namespace OHOS 766 767 #endif // RENDER_SERVICE_CLIENT_CORE_PROPERTY_RS_PROPERTIES_H 768