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(const std::shared_ptr<RSPath>& path); 48 void SetMask(bool imageMask); 49 50 Color GetColor() const; 51 float GetOffsetX() const; 52 float GetOffsetY() const; 53 float GetAlpha() const; 54 float GetElevation() const; 55 float GetRadius() const; 56 const std::shared_ptr<RSPath>& GetPath() const; 57 bool GetMask() const; 58 GetHardwareAcceleration()59 bool GetHardwareAcceleration() const 60 { 61 return isHardwareAcceleration_; 62 } 63 bool IsValid() const; 64 65 private: 66 bool isHardwareAcceleration_ = false; 67 68 Color color_ = Color::FromArgbInt(DEFAULT_SPOT_COLOR); 69 float offsetX_ = DEFAULT_SHADOW_OFFSET_X; 70 float offsetY_ = DEFAULT_SHADOW_OFFSET_Y; 71 float radius_ = DEFAULT_SHADOW_RADIUS; 72 float elevation_ = 0.f; 73 std::shared_ptr<RSPath> path_ = nullptr; 74 bool imageMask_ = false; 75 }; 76 } // namespace Rosen 77 } // namespace OHOS 78 79 #endif // RENDER_SERVICE_CLIENT_CORE_RENDER_RS_SHADOW_H 80