• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/background/rs_background_image_modifier.h"
17 
18 namespace OHOS::Rosen::ModifierNG {
SetBgImage(const std::shared_ptr<RSImage> & image)19 void RSBackgroundImageModifier::SetBgImage(const std::shared_ptr<RSImage>& image)
20 {
21     Setter<RSProperty, std::shared_ptr<RSImage>>(RSPropertyType::BG_IMAGE, image);
22 }
23 
GetBgImage() const24 std::shared_ptr<RSImage> RSBackgroundImageModifier::GetBgImage() const
25 {
26     return Getter<std::shared_ptr<RSImage>>(RSPropertyType::BG_IMAGE, nullptr);
27 }
28 
SetBgImageInnerRect(const Vector4f & innerRect)29 void RSBackgroundImageModifier::SetBgImageInnerRect(const Vector4f& innerRect)
30 {
31     Setter(RSPropertyType::BG_IMAGE_INNER_RECT, innerRect);
32 }
33 
GetBgImageInnerRect() const34 Vector4f RSBackgroundImageModifier::GetBgImageInnerRect() const
35 {
36     return Getter(RSPropertyType::BG_IMAGE_INNER_RECT, Vector4f(0.f));
37 }
38 
SetBgImageWidth(float width)39 void RSBackgroundImageModifier::SetBgImageWidth(float width)
40 {
41     Vector4f dstRect = RSBackgroundImageModifier::GetBgImageDstRect();
42     dstRect[2] = width; // 2 index of width
43     SetBgImageDstRect(dstRect);
44 }
45 
GetBgImageWidth() const46 float RSBackgroundImageModifier::GetBgImageWidth() const
47 {
48     Vector4f dstRect = RSBackgroundImageModifier::GetBgImageDstRect();
49     return dstRect[2]; // 2 index of width
50 }
51 
SetBgImageHeight(float height)52 void RSBackgroundImageModifier::SetBgImageHeight(float height)
53 {
54     Vector4f dstRect = RSBackgroundImageModifier::GetBgImageDstRect();
55     dstRect[3] = height; // 3 index of height
56     SetBgImageDstRect(dstRect);
57 }
58 
GetBgImageHeight() const59 float RSBackgroundImageModifier::GetBgImageHeight() const
60 {
61     Vector4f dstRect = RSBackgroundImageModifier::GetBgImageDstRect();
62     return dstRect[3]; // 3 index of height
63 }
64 
SetBgImagePositionX(float positionX)65 void RSBackgroundImageModifier::SetBgImagePositionX(float positionX)
66 {
67     Vector4f dstRect = RSBackgroundImageModifier::GetBgImageDstRect();
68     dstRect[0] = positionX; // 0 index of position x
69     SetBgImageDstRect(dstRect);
70 }
71 
GetBgImagePositionX() const72 float RSBackgroundImageModifier::GetBgImagePositionX() const
73 {
74     Vector4f dstRect = RSBackgroundImageModifier::GetBgImageDstRect();
75     return dstRect[0]; // 0 index of position x
76 }
77 
SetBgImagePositionY(float positionY)78 void RSBackgroundImageModifier::SetBgImagePositionY(float positionY)
79 {
80     Vector4f dstRect = RSBackgroundImageModifier::GetBgImageDstRect();
81     dstRect[1] = positionY; // 1 index of position y
82     SetBgImageDstRect(dstRect);
83 }
84 
GetBgImagePositionY() const85 float RSBackgroundImageModifier::GetBgImagePositionY() const
86 {
87     Vector4f dstRect = RSBackgroundImageModifier::GetBgImageDstRect();
88     return dstRect[1]; // 1 index of position y
89 }
90 
SetBgImageDstRect(const Vector4f & dstRect)91 void RSBackgroundImageModifier::SetBgImageDstRect(const Vector4f& dstRect)
92 {
93     Setter(RSPropertyType::BG_IMAGE_RECT, dstRect);
94 }
95 
GetBgImageDstRect() const96 Vector4f RSBackgroundImageModifier::GetBgImageDstRect() const
97 {
98     return Getter(RSPropertyType::BG_IMAGE_RECT, Vector4f(0.f));
99 }
100 } // namespace OHOS::Rosen::ModifierNG
101