• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_BASE_RENDER_RENDER_RS_SHADER_H
17 #define RENDER_SERVICE_BASE_RENDER_RENDER_RS_SHADER_H
18 
19 #include "common/rs_macros.h"
20 #include "common/rs_rect.h"
21 #include "effect/shader_effect.h"
22 #include "transaction/rs_marshalling_helper.h"
23 
24 namespace OHOS {
25 namespace Rosen {
26 class RSB_EXPORT RSShader {
27 public:
28     enum class ShaderType{
29         DRAWING = 0,
30         DOT_MATRIX,
31         FLOW_LIGHT_SWEEP,
32         COMPLEX,
33         BORDER_LIGHT,
34     };
35 
36     RSShader() = default;
37     virtual ~RSShader() = default;
38     static std::shared_ptr<RSShader> CreateRSShader();
39     static std::shared_ptr<RSShader> CreateRSShader(const ShaderType& type);
40     static std::shared_ptr<RSShader> CreateRSShader(const std::shared_ptr<Drawing::ShaderEffect>& drShader);
41 
42     void SetDrawingShader(const std::shared_ptr<Drawing::ShaderEffect>& drShader);
MakeDrawingShader(const RectF & rect,float progress)43     virtual void MakeDrawingShader(const RectF& rect, float progress) {};
MakeDrawingShader(const RectF & rect,const std::vector<float> & params)44     virtual void MakeDrawingShader(const RectF& rect, const std::vector<float>& params) {};
45     virtual const std::shared_ptr<Drawing::ShaderEffect>& GetDrawingShader() const;
46 
47     virtual bool Marshalling(Parcel& parcel);
48     virtual bool Unmarshalling(Parcel& parcel, bool& needReset);
49 
GetShaderType()50     inline const ShaderType& GetShaderType() const { return type_; } ;
51 
52 private:
53     RSShader(const RSShader&) = delete;
54     RSShader(const RSShader&&) = delete;
55     RSShader& operator=(const RSShader&) = delete;
56     RSShader& operator=(const RSShader&&) = delete;
57 
58 protected:
59     ShaderType type_ = ShaderType::DRAWING;
60     std::shared_ptr<Drawing::ShaderEffect> drShader_ = nullptr;
61 };
62 } // namespace Rosen
63 } // namespace OHOS
64 
65 #endif // RENDER_SERVICE_BASE_RENDER_RENDER_RS_SHADER_H
66