• 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 "image/picture.h"
26 #include "utils/matrix.h"
27 #include "utils/point.h"
28 #include "utils/rect.h"
29 #include "utils/sampling_options.h"
30 #include "utils/scalar.h"
31 
32 namespace OHOS {
33 namespace Rosen {
34 namespace Drawing {
35 class Data;
36 class Image;
37 class ShaderEffect;
38 enum class TileMode;
39 class ShaderEffectImpl : public BaseImpl {
40 public:
ShaderEffectImpl()41     ShaderEffectImpl() noexcept {}
~ShaderEffectImpl()42     ~ShaderEffectImpl() override {}
43     virtual void InitWithColor(ColorQuad color) = 0;
44     virtual void InitWithBlend(const ShaderEffect& s1, const ShaderEffect& s2, BlendMode mode) = 0;
45     virtual void InitWithImage(
46         const Image& image, TileMode tileX, TileMode tileY, const SamplingOptions& sampling, const Matrix& matrix) = 0;
47     virtual void InitWithPicture(const Picture& picture, TileMode tileX, TileMode tileY, FilterMode mode,
48         const Matrix& matrix, const Rect& rect) = 0;
49     virtual void InitWithLinearGradient(const Point& startPt, const Point& endPt, const std::vector<ColorQuad>& colors,
50         const std::vector<scalar>& pos, TileMode mode) = 0;
51     virtual void InitWithRadialGradient(const Point& centerPt, scalar radius, const std::vector<ColorQuad>& colors,
52         const std::vector<scalar>& pos, TileMode mode) = 0;
53     virtual void InitWithTwoPointConical(const Point& startPt, scalar startRadius, const Point& endPtr,
54         scalar endRadius, const std::vector<ColorQuad>& colors, const std::vector<scalar>& pos, TileMode mode,
55         const Matrix *matrix) = 0;
56     virtual void InitWithSweepGradient(const Point& centerPt, const std::vector<ColorQuad>& colors,
57         const std::vector<scalar>& pos, TileMode mode, scalar startAngle, scalar endAngle, const Matrix *matrix) = 0;
58     virtual std::shared_ptr<Data> Serialize() const = 0;
59     virtual bool Deserialize(std::shared_ptr<Data> data) = 0;
60 };
61 } // namespace Drawing
62 } // namespace Rosen
63 } // namespace OHOS
64 #endif
65