• 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 #include "render/rs_shader.h"
17 
18 namespace OHOS {
19 namespace Rosen {
CreateRSShader()20 std::shared_ptr<RSShader> RSShader::CreateRSShader()
21 {
22     std::shared_ptr<RSShader> rsShader(new RSShader());
23     return rsShader;
24 }
25 
26 #ifndef USE_ROSEN_DRAWING
CreateRSShader(const sk_sp<SkShader> & skShader)27 std::shared_ptr<RSShader> RSShader::CreateRSShader(const sk_sp<SkShader>& skShader)
28 {
29     std::shared_ptr<RSShader> rsShader(new RSShader());
30     rsShader->SetSkShader(skShader);
31     return rsShader;
32 }
33 
SetSkShader(const sk_sp<SkShader> & skShader)34 void RSShader::SetSkShader(const sk_sp<SkShader>& skShader)
35 {
36     skShader_ = skShader;
37 }
38 
GetSkShader() const39 const sk_sp<SkShader>& RSShader::GetSkShader() const
40 {
41     return skShader_;
42 }
43 #else
CreateRSShader(const std::shared_ptr<Drawing::ShaderEffect> & drShader)44 std::shared_ptr<RSShader> RSShader::CreateRSShader(const std::shared_ptr<Drawing::ShaderEffect>& drShader)
45 {
46     std::shared_ptr<RSShader> rsShader(new RSShader());
47     rsShader->SetDrawingShader(drShader);
48     return rsShader;
49 }
50 
SetDrawingShader(const std::shared_ptr<Drawing::ShaderEffect> & drShader)51 void RSShader::SetDrawingShader(const std::shared_ptr<Drawing::ShaderEffect>& drShader)
52 {
53     drShader_ = drShader;
54 }
55 
GetDrawingShader() const56 const std::shared_ptr<Drawing::ShaderEffect>& RSShader::GetDrawingShader() const
57 {
58     return drShader_;
59 }
60 #endif
61 } // namespace Rosen
62 } // namespace OHOS