• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 SKIA_RUNTIME_EFFECT_H
17 #define SKIA_RUNTIME_EFFECT_H
18 
19 #include "include/effects/SkRuntimeEffect.h"
20 
21 #include "effect/blender.h"
22 #include "effect/shader_effect.h"
23 #include "impl_interface/runtime_effect_impl.h"
24 #include "utils/data.h"
25 #include "utils/matrix.h"
26 
27 namespace OHOS {
28 namespace Rosen {
29 namespace Drawing {
30 class SkiaRuntimeEffect : public RuntimeEffectImpl {
31 public:
32     static inline constexpr AdapterType TYPE = AdapterType::SKIA_ADAPTER;
33 
34     SkiaRuntimeEffect() noexcept;
~SkiaRuntimeEffect()35     ~SkiaRuntimeEffect() override {};
36 
GetType()37     AdapterType GetType() const override
38     {
39         return AdapterType::SKIA_ADAPTER;
40     }
41 
42     void InitForShader(const std::string& sl, const RuntimeEffectOptions& options) override;
43     void InitForShader(const std::string& sl) override;
44     void InitForBlender(const std::string& sl) override;
45     std::shared_ptr<ShaderEffect> MakeShader(std::shared_ptr<Data> uniforms,
46         std::shared_ptr<ShaderEffect> children[], size_t childCount,
47         const Matrix* localMatrix, bool isOpaque) override;
48     sk_sp<SkRuntimeEffect> GetRuntimeEffect() const;
49     /*
50      * @brief  Update the member variable to SkRuntimeEffect, adaptation layer calls.
51      */
52     void SetRuntimeEffect(const sk_sp<SkRuntimeEffect>& skRuntimeEffect);
53 
54 private:
55     sk_sp<SkRuntimeEffect> skRuntimeEffect_;
56 };
57 } // namespace Drawing
58 } // namespace Rosen
59 } // namespace OHOS
60 #endif