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