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_PAINT_H 17 #define SKIA_PAINT_H 18 19 #include <memory> 20 #include <vector> 21 22 #include "include/core/SkPaint.h" 23 #include "include/core/SkColorSpace.h" 24 #include "include/core/SkShader.h" 25 #include "include/core/SkColorFilter.h" 26 #include "include/core/SkImageFilter.h" 27 #include "include/core/SkMaskFilter.h" 28 #include "include/core/SkPathEffect.h" 29 #include "src/core/SkPaintDefaults.h" 30 31 #include "draw/paint.h" 32 33 namespace OHOS { 34 namespace Rosen { 35 namespace Drawing { 36 const int MAX_PAINTS_NUMBER = 2; 37 38 class SkiaPaint { 39 public: 40 SkiaPaint() noexcept; 41 ~SkiaPaint(); 42 43 static void BrushToSkPaint(const Brush& brush, SkPaint& paint); 44 static void PenToSkPaint(const Pen& pen, SkPaint& paint); 45 static void PaintToSkPaint(const Paint& paint, SkPaint& skPaint); 46 47 static bool GetFillPath(const Pen& pen, const Path& src, Path& dst, const Rect* rect, const Matrix& matrix); 48 static bool CanComputeFastBounds(const Brush& brush); 49 static const Rect& ComputeFastBounds(const Brush& brush, const Rect& orig, Rect* storage); 50 51 static bool AsBlendMode(const Brush& brush); 52 53 private: 54 static void ApplyFilter(SkPaint& paint, const Filter& filter); 55 static void ApplyStrokeParam(const Paint& paint, SkPaint& skPaint); 56 }; 57 } // namespace Drawing 58 } // namespace Rosen 59 } // namespace OHOS 60 #endif