1 /*
2 * Copyright (c) 2025 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 #include "modifier_ng/appearance/rs_shadow_render_modifier.h"
17
18 #include "render/rs_shadow.h"
19
20 namespace OHOS::Rosen::ModifierNG {
21 const RSShadowRenderModifier::LegacyPropertyApplierMap RSShadowRenderModifier::LegacyPropertyApplierMap_ = {
22 { RSPropertyType::SHADOW_COLOR, RSRenderModifier::PropertyApplyHelper<Color, &RSProperties::SetShadowColor> },
23 { RSPropertyType::SHADOW_OFFSET_X, RSRenderModifier::PropertyApplyHelper<float, &RSProperties::SetShadowOffsetX> },
24 { RSPropertyType::SHADOW_OFFSET_Y, RSRenderModifier::PropertyApplyHelper<float, &RSProperties::SetShadowOffsetY> },
25 { RSPropertyType::SHADOW_ALPHA, RSRenderModifier::PropertyApplyHelper<float, &RSProperties::SetShadowAlpha> },
26 { RSPropertyType::SHADOW_ELEVATION,
27 RSRenderModifier::PropertyApplyHelper<float, &RSProperties::SetShadowElevation> },
28 { RSPropertyType::SHADOW_RADIUS, RSRenderModifier::PropertyApplyHelper<float, &RSProperties::SetShadowRadius> },
29 { RSPropertyType::SHADOW_PATH,
30 RSRenderModifier::PropertyApplyHelper<std::shared_ptr<RSPath>, &RSProperties::SetShadowPath> },
31 { RSPropertyType::SHADOW_MASK, RSRenderModifier::PropertyApplyHelper<int, &RSProperties::SetShadowMask> },
32 { RSPropertyType::SHADOW_COLOR_STRATEGY,
33 RSRenderModifier::PropertyApplyHelper<int, &RSProperties::SetShadowColorStrategy> },
34 { RSPropertyType::SHADOW_IS_FILLED, RSRenderModifier::PropertyApplyHelper<bool, &RSProperties::SetShadowIsFilled> },
35 { RSPropertyType::USE_SHADOW_BATCHING,
36 RSRenderModifier::PropertyApplyHelper<bool, &RSProperties::SetUseShadowBatching> },
37 };
38
ResetProperties(RSProperties & properties)39 void RSShadowRenderModifier::ResetProperties(RSProperties& properties)
40 {
41 properties.SetShadowColor(Color::FromArgbInt(DEFAULT_SPOT_COLOR));
42 properties.SetShadowOffsetX(0.f);
43 properties.SetShadowOffsetY(0.f);
44 properties.SetShadowAlpha(1.f);
45 properties.SetShadowElevation(0.f);
46 properties.SetShadowRadius(0.f);
47 properties.SetShadowPath(nullptr);
48 properties.SetShadowMask(SHADOW_MASK_STRATEGY::MASK_NONE);
49 properties.SetShadowColorStrategy(static_cast<int>(SHADOW_COLOR_STRATEGY::COLOR_STRATEGY_NONE));
50 properties.SetShadowIsFilled(false);
51 properties.SetUseShadowBatching(false);
52 }
53 } // namespace OHOS::Rosen::ModifierNG
54