• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 RENDER_SERVICE_CLIENT_CORE_RENDER_RS_SHADOW_H
17 #define RENDER_SERVICE_CLIENT_CORE_RENDER_RS_SHADOW_H
18 
19 #include <memory>
20 
21 #include "common/rs_color.h"
22 #include "common/rs_macros.h"
23 #include "render/rs_path.h"
24 namespace OHOS {
25 namespace Rosen {
26 const float DEFAULT_LIGHT_POSITION_X = 540.0f;
27 const float DEFAULT_LIGHT_POSITION_Y = 0.0f;
28 const float DEFAULT_LIGHT_HEIGHT = 600.0f;
29 const float DEFAULT_LIGHT_RADIUS = 800.0f;
30 const float DEFAULT_SHADOW_OFFSET_X = 0.f;
31 const float DEFAULT_SHADOW_OFFSET_Y = 0.f;
32 const float DEFAULT_SHADOW_RADIUS = 0.f;
33 const float DEFAULT_TRANSLATION_Z = 300.0f;
34 const uint32_t DEFAULT_AMBIENT_COLOR = 0x0A000000;
35 const uint32_t DEFAULT_SPOT_COLOR = 0x00000000;
36 
37 class RSShadow {
38 public:
39     RSShadow();
40     virtual ~RSShadow();
41     void SetColor(Color color);
42     void SetOffsetX(float offsetX);
43     void SetOffsetY(float offsetY);
44     void SetAlpha(float alpha);
45     void SetElevation(float elevation);
46     void SetRadius(float radius);
47     void SetPath(std::shared_ptr<RSPath> path);
48 
49     Color GetColor() const;
50     float GetOffsetX() const;
51     float GetOffsetY() const;
52     float GetAlpha() const;
53     float GetElevation() const;
54     float GetRadius() const;
55     std::shared_ptr<RSPath> GetPath() const;
56 
GetHardwareAcceleration()57     bool GetHardwareAcceleration() const
58     {
59         return isHardwareAcceleration_;
60     }
61     bool IsValid() const;
62 
63 private:
64     bool isHardwareAcceleration_ = false;
65 
66     Color color_ = Color::FromArgbInt(DEFAULT_SPOT_COLOR);
67     float offsetX_ = DEFAULT_SHADOW_OFFSET_X;
68     float offsetY_ = DEFAULT_SHADOW_OFFSET_Y;
69     float radius_ = DEFAULT_SHADOW_RADIUS;
70     float elevation_ = 0.f;
71     std::shared_ptr<RSPath> path_ = nullptr;
72 };
73 } // namespace Rosen
74 } // namespace OHOS
75 
76 #endif // RENDER_SERVICE_CLIENT_CORE_RENDER_RS_SHADOW_H
77