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 Image; 36 class ShaderEffect; 37 enum class TileMode; 38 class ShaderEffectImpl : public BaseImpl { 39 public: 40 static inline constexpr AdapterType TYPE = AdapterType::BASE_INTERFACE; ShaderEffectImpl()41 ShaderEffectImpl() noexcept {} ~ShaderEffectImpl()42 ~ShaderEffectImpl() override {} GetType()43 AdapterType GetType() const override 44 { 45 return AdapterType::BASE_INTERFACE; 46 } 47 48 virtual void InitWithColor(ColorQuad color) = 0; 49 virtual void InitWithBlend(const ShaderEffect& s1, const ShaderEffect& s2, BlendMode mode) = 0; 50 virtual void InitWithImage( 51 const Image& image, TileMode tileX, TileMode tileY, const SamplingOptions& sampling, const Matrix& matrix) = 0; 52 virtual void InitWithPicture(const Picture& picture, TileMode tileX, TileMode tileY, FilterMode mode, 53 const Matrix& matrix, const Rect& rect) = 0; 54 virtual void InitWithLinearGradient(const Point& startPt, const Point& endPt, const std::vector<ColorQuad>& colors, 55 const std::vector<scalar>& pos, TileMode mode) = 0; 56 virtual void InitWithRadialGradient(const Point& centerPt, scalar radius, const std::vector<ColorQuad>& colors, 57 const std::vector<scalar>& pos, TileMode mode) = 0; 58 virtual void InitWithTwoPointConical(const Point& startPt, scalar startRadius, const Point& endPtr, 59 scalar endRadius, const std::vector<ColorQuad>& colors, const std::vector<scalar>& pos, TileMode mode) = 0; 60 virtual void InitWithSweepGradient(const Point& centerPt, const std::vector<ColorQuad>& colors, 61 const std::vector<scalar>& pos, TileMode mode, scalar startAngle, scalar endAngle) = 0; 62 }; 63 } // namespace Drawing 64 } // namespace Rosen 65 } // namespace OHOS 66 #endif 67