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 SKIA_SHADER_EFFECT_H 17 #define SKIA_SHADER_EFFECT_H 18 19 #include "include/core/SkShader.h" 20 21 #include "impl_interface/shader_effect_impl.h" 22 23 namespace OHOS { 24 namespace Rosen { 25 namespace Drawing { 26 class SkiaShaderEffect : public ShaderEffectImpl { 27 public: 28 static inline constexpr AdapterType TYPE = AdapterType::SKIA_ADAPTER; 29 SkiaShaderEffect() noexcept; ~SkiaShaderEffect()30 ~SkiaShaderEffect() override {}; GetType()31 AdapterType GetType() const override 32 { 33 return AdapterType::SKIA_ADAPTER; 34 } 35 36 void InitWithColor(ColorQuad color) override; 37 void InitWithBlend(const ShaderEffect& s1, const ShaderEffect& s2, BlendMode mode) override; 38 void InitWithImage(const Image& image, TileMode tileX, TileMode tileY, const SamplingOptions& sampling, 39 const Matrix& matrix) override; 40 void InitWithPicture(const Picture& picture, TileMode tileX, TileMode tileY, FilterMode mode, const Matrix& matrix, 41 const Rect& rect) override; 42 void InitWithLinearGradient(const Point& startPt, const Point& endPt, const std::vector<ColorQuad>& colors, 43 const std::vector<scalar>& pos, TileMode mode) override; 44 void InitWithRadialGradient(const Point& centerPt, scalar radius, const std::vector<ColorQuad>& colors, 45 const std::vector<scalar>& pos, TileMode mode) override; 46 void InitWithTwoPointConical(const Point& startPt, scalar startRadius, const Point& endPt, scalar endRadius, 47 const std::vector<ColorQuad>& colors, const std::vector<scalar>& pos, TileMode mode) override; 48 void InitWithSweepGradient(const Point& centerPt, const std::vector<ColorQuad>& colors, 49 const std::vector<scalar>& pos, TileMode mode, scalar startAngle, scalar endAngle) override; 50 sk_sp<SkShader> GetShader() const; 51 52 private: 53 sk_sp<SkShader> shader_; 54 }; 55 } // namespace Drawing 56 } // namespace Rosen 57 } // namespace OHOS 58 #endif