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 24 #include "draw/brush.h" 25 #include "draw/pen.h" 26 27 namespace OHOS { 28 namespace Rosen { 29 namespace Drawing { 30 struct PaintData { 31 SkPaint paint; 32 bool isEnabled = false; 33 }; 34 35 class SkiaPaint { 36 public: 37 SkiaPaint() noexcept; ~SkiaPaint()38 ~SkiaPaint() {}; 39 40 void ApplyBrushToFill(const Brush& brush); 41 void ApplyPenToStroke(const Pen& pen); 42 43 void BrushToSkPaint(const Brush& brush, SkPaint& paint) const; 44 void PenToSkPaint(const Pen& pen, SkPaint& paint) const; 45 46 void DisableStroke(); 47 void DisableFill(); 48 49 std::vector<std::shared_ptr<PaintData>> GetSortedPaints() const; 50 void SetStrokeFirst(bool isStrokeFirst); 51 bool IsStrokeFirst() const; 52 53 private: 54 void ApplyFilter(SkPaint& paint, const Filter& filter) const; 55 56 std::shared_ptr<PaintData> stroke_; 57 std::shared_ptr<PaintData> fill_; 58 bool isStrokeFirst_; 59 }; 60 } // namespace Drawing 61 } // namespace Rosen 62 } // namespace OHOS 63 #endif