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_TEXT_LINE_BASE_IMPL_H 17 #define SKPARAGRAPH_SRC_TEXT_LINE_BASE_IMPL_H 18 19 #include "modules/skparagraph/include/TextLineBase.h" 20 #include "modules/skparagraph/src/TextLine.h" 21 22 namespace skia { 23 namespace textlayout { 24 class TextLineBaseImpl : public TextLineBase { 25 public: 26 #ifdef OHOS_SUPPORT 27 TextLineBaseImpl(std::unique_ptr<TextLine> visitorTextLine); 28 #else 29 TextLineBaseImpl(TextLine* visitorTextLine); 30 #endif 31 size_t getGlyphCount() const override; 32 std::vector<std::unique_ptr<RunBase>> getGlyphRuns() const override; 33 SkRange<size_t> getTextRange() const override; 34 void paint(ParagraphPainter* painter, SkScalar x, SkScalar y) override; 35 36 #ifdef OHOS_SUPPORT 37 std::unique_ptr<TextLineBase> createTruncatedLine(double width, EllipsisModal ellipsisMode, 38 const std::string& ellipsisStr) override; 39 double getTypographicBounds(double* ascent, double* descent, double* leading) const override; 40 RSRect getImageBounds() const override; 41 double getTrailingSpaceWidth() const override; 42 int32_t getStringIndexForPosition(SkPoint point) const override; 43 double getOffsetForStringIndex(int32_t index) const override; 44 std::map<int32_t, double> getIndexAndOffsets(bool& isHardBreak) const override; 45 double getAlignmentOffset(double alignmentFactor, double alignmentWidth) const override; 46 #endif 47 48 private: 49 #ifdef OHOS_SUPPORT 50 std::unique_ptr<TextLine> fVisitorTextLine; 51 #else 52 TextLine* fVisitorTextLine; 53 #endif 54 }; 55 } // namespace textlayout 56 } // namespace skia 57 58 #endif // SKPARAGRAPH_SRC_TEXT_LINE_BASE_IMPL_H