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