• 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 SHADER_EFFECT_IMPL_H
17 #define SHADER_EFFECT_IMPL_H
18 
19 #include <memory>
20 
21 #include "base_impl.h"
22 
23 #include "draw/blend_mode.h"
24 #include "draw/color.h"
25 #include "draw/sdf_shaper_base.h"
26 #include "image/picture.h"
27 #include "utils/matrix.h"
28 #include "utils/point.h"
29 #include "utils/point3.h"
30 #include "utils/rect.h"
31 #include "utils/sampling_options.h"
32 #include "utils/scalar.h"
33 
34 namespace OHOS {
35 namespace Rosen {
36 namespace Drawing {
37 class Data;
38 class Image;
39 class ShaderEffect;
40 enum class TileMode;
41 class ShaderEffectImpl : public BaseImpl {
42 public:
ShaderEffectImpl()43     ShaderEffectImpl() noexcept {}
~ShaderEffectImpl()44     ~ShaderEffectImpl() override {}
45 
46     virtual void InitWithColor(ColorQuad color) = 0;
47 
48     virtual void InitWithColorSpace(const Color4f& color, std::shared_ptr<ColorSpace> colorSpace) = 0;
49 
50     virtual void InitWithBlend(const ShaderEffect& s1, const ShaderEffect& s2, BlendMode mode) = 0;
51 
52     virtual void InitWithImage(const Image& image, TileMode tileX, TileMode tileY,
53         const SamplingOptions& sampling, const Matrix& matrix) = 0;
54 
55     virtual void InitWithPicture(const Picture& picture, TileMode tileX, TileMode tileY, FilterMode mode,
56         const Matrix& matrix, const Rect& rect) = 0;
57 
58     virtual void InitWithLinearGradient(const Point& startPt, const Point& endPt, const std::vector<ColorQuad>& colors,
59         const std::vector<scalar>& pos, TileMode mode, const Matrix *matrix) = 0;
60 
61     virtual void InitWithRadialGradient(const Point& centerPt, scalar radius, const std::vector<ColorQuad>& colors,
62         const std::vector<scalar>& pos, TileMode mode, const Matrix *matrix) = 0;
63 
64     virtual void InitWithTwoPointConical(const Point& startPt, scalar startRadius, const Point& endPtr,
65         scalar endRadius, const std::vector<ColorQuad>& colors, const std::vector<scalar>& pos, TileMode mode,
66         const Matrix *matrix) = 0;
67 
68     virtual void InitWithSweepGradient(const Point& centerPt, const std::vector<ColorQuad>& colors,
69         const std::vector<scalar>& pos, TileMode mode, scalar startAngle, scalar endAngle, const Matrix *matrix) = 0;
70 
71     virtual void InitWithSdf(const SDFShapeBase& shape) = 0;
72 
73     virtual std::shared_ptr<Data> Serialize() const = 0;
74     virtual bool Deserialize(std::shared_ptr<Data> data) = 0;
75 };
76 } // namespace Drawing
77 } // namespace Rosen
78 } // namespace OHOS
79 #endif
80