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