1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd.. All rights reserved. 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 SKPARAGRAPH_SRC_RUN_BASE_IMPL_H 17 #define SKPARAGRAPH_SRC_RUN_BASE_IMPL_H 18 19 #include "modules/skparagraph/include/RunBase.h" 20 #include "modules/skparagraph/src/Run.h" 21 22 namespace skia { 23 namespace textlayout { 24 class RunBaseImpl : public RunBase { 25 public: 26 RunBaseImpl( 27 #ifndef USE_SKIA_TXT 28 sk_sp<SkTextBlob> blob, 29 #else 30 std::shared_ptr<RSTextBlob> blob, 31 #endif 32 SkPoint offset, 33 ParagraphPainter::SkPaintOrID paint, 34 bool clippingNeeded, 35 SkRect clipRect, 36 const Run* visitorRun, 37 size_t visitorPos, 38 size_t visitorSize 39 ); 40 41 #ifndef USE_SKIA_TXT 42 const SkFont& font() const override; 43 #else 44 const RSFont& font() const override; 45 #endif 46 47 size_t size() const override; 48 std::vector<uint16_t> getGlyphs() const override; 49 std::vector<RSPoint> getPositions() const override; 50 std::vector<RSPoint> getOffsets() const override; 51 52 void paint(ParagraphPainter* painter, SkScalar x, SkScalar y) override; 53 54 size_t getVisitorPos() const; 55 size_t getVisitorSize() const; 56 57 private: 58 59 #ifndef USE_SKIA_TXT 60 sk_sp<SkTextBlob> fBlob; 61 #else 62 std::shared_ptr<RSTextBlob> fBlob; 63 #endif 64 SkPoint fOffset = SkPoint::Make(0.0f, 0.0f); 65 ParagraphPainter::SkPaintOrID fPaint; 66 bool fClippingNeeded = false; 67 SkRect fClipRect = SkRect::MakeEmpty(); 68 69 const Run* fVisitorRun; 70 size_t fVisitorPos; 71 size_t fVisitorSize; 72 }; 73 } // namespace textlayout 74 } // namespace skia 75 76 #endif // SKPARAGRAPH_SRC_RUN_BASE_IMPL_H