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 #include "modules/skparagraph/src/TextLineBaseImpl.h"
17
18 namespace skia {
19 namespace textlayout {
TextLineBaseImpl(TextLine * visitorTextLine)20 TextLineBaseImpl::TextLineBaseImpl(TextLine* visitorTextLine) : fVisitorTextLine(visitorTextLine)
21 {
22 }
23
getGlyphCount() const24 size_t TextLineBaseImpl::getGlyphCount() const
25 {
26 if (!fVisitorTextLine) {
27 return 0;
28 }
29 fVisitorTextLine->ensureTextBlobCachePopulated();
30 return fVisitorTextLine->getGlyphCount();
31 }
32
getGlyphRuns() const33 std::vector<std::unique_ptr<RunBase>> TextLineBaseImpl::getGlyphRuns() const
34 {
35 if (!fVisitorTextLine) {
36 return {};
37 }
38 fVisitorTextLine->ensureTextBlobCachePopulated();
39 return fVisitorTextLine->getGlyphRuns();
40 }
41
getTextRange() const42 SkRange<size_t> TextLineBaseImpl::getTextRange() const
43 {
44 if (!fVisitorTextLine) {
45 return {};
46 }
47 return fVisitorTextLine->text();
48 }
49
paint(ParagraphPainter * painter,SkScalar x,SkScalar y)50 void TextLineBaseImpl::paint(ParagraphPainter* painter, SkScalar x, SkScalar y)
51 {
52 if (!fVisitorTextLine || !painter) {
53 return;
54 }
55 return fVisitorTextLine->paint(painter, x, y);
56 }
57
58 } // namespace textlayout
59 } // namespace skia