Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 90787fe

Browse files
RusinoSkia Commit-Bot
authored andcommitted
Reland #3 "ICU API: only in SkParagraph, simplified."
This is the fix for google3 failure. This reverts commit e36a466. Reason for revert: Trying to fix google3 build brake Original change's description: > Revert "Reland "ICU API: only in SkParagraph, simplified (relanding reverted)."" > > This reverts commit 16fbc24. > > Reason for revert: Checking to see if this is blocking the G3 roll > > Original change's description: > > Reland "ICU API: only in SkParagraph, simplified (relanding reverted)." > > > > This reverts commit a30095d. > > > > Reason for revert: Fixing the build > > > > Original change's description: > > > Revert "ICU API: only in SkParagraph, simplified (relanding reverted)." > > > > > > This reverts commit 7479eda. > > > > > > Reason for revert: Breaking build > > > > > > Original change's description: > > > > ICU API: only in SkParagraph, simplified (relanding reverted). > > > > > > > > Reverted commit: https://skia-review.googlesource.com/c/skia/+/296128/ > > > > > > > > Change-Id: Iaf793bff94a6060579c7d6176d477e598c047be6 > > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/303261 > > > > Reviewed-by: Mike Reed <reed@google.com> > > > > Commit-Queue: Julia Lavrova <jlavrova@google.com> > > > > > > TBR=reed@google.com,jlavrova@google.com > > > > > > Change-Id: Idd4c41e22aa59e24bdbd07f2fa5e9258c1bbb7a7 > > > No-Presubmit: true > > > No-Tree-Checks: true > > > No-Try: true > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/303358 > > > Reviewed-by: Julia Lavrova <jlavrova@google.com> > > > Commit-Queue: Julia Lavrova <jlavrova@google.com> > > > > TBR=reed@google.com,jlavrova@google.com > > > > Change-Id: Iea5da4535ea2e388e8e632e6c556b66c8781631a > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/303377 > > Reviewed-by: Ben Wagner <bungeman@google.com> > > Reviewed-by: Julia Lavrova <jlavrova@google.com> > > Commit-Queue: Julia Lavrova <jlavrova@google.com> > > TBR=bungeman@google.com,reed@google.com,jlavrova@google.com > > Change-Id: I1edfecc56add670b251adf44892265088fd32c42 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/304058 > Reviewed-by: Robert Phillips <robertphillips@google.com> > Commit-Queue: Robert Phillips <robertphillips@google.com> TBR=bungeman@google.com,robertphillips@google.com,reed@google.com,jlavrova@google.com Change-Id: Ife73aa21539e870d69bda6b5892979646732d778 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/304060 Commit-Queue: Julia Lavrova <jlavrova@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
1 parent 4cfae3b commit 90787fe

File tree

16 files changed

+473
-280
lines changed

16 files changed

+473
-280
lines changed

modules/skparagraph/src/OneLineShaper.cpp

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,13 @@
22

33
#include "modules/skparagraph/src/Iterators.h"
44
#include "modules/skparagraph/src/OneLineShaper.h"
5-
#include <unicode/uchar.h>
5+
#include "modules/skparagraph/src/ParagraphUtil.h"
66
#include <algorithm>
77
#include <unordered_set>
8-
#include "src/utils/SkUTF.h"
98

109
namespace skia {
1110
namespace textlayout {
1211

13-
namespace {
14-
15-
SkUnichar utf8_next(const char** ptr, const char* end) {
16-
SkUnichar val = SkUTF::NextUTF8(ptr, end);
17-
return val < 0 ? 0xFFFD : val;
18-
}
19-
20-
}
21-
2212
void OneLineShaper::commitRunBuffer(const RunInfo&) {
2313

2414
fCurrentRun->commit();
@@ -313,8 +303,8 @@ void OneLineShaper::sortOutGlyphs(std::function<void(GlyphRange)>&& sortOutUnres
313303
block.end = i;
314304
} else {
315305
const char* cluster = text.begin() + clusterIndex(i);
316-
SkUnichar codepoint = utf8_next(&cluster, text.end());
317-
if (u_iscntrl(codepoint)) {
306+
SkUnichar codepoint = nextUtf8Unit(&cluster, text.end());
307+
if (isControl(codepoint)) {
318308
// This codepoint does not have to be resolved; let's pretend it's resolved
319309
if (block.start == EMPTY_INDEX) {
320310
// Keep skipping resolved code points
@@ -419,7 +409,7 @@ void OneLineShaper::matchResolvedFonts(const TextStyle& textStyle,
419409
// We have the global cache for all already found typefaces for SkUnichar
420410
// but we still need to keep track of all SkUnichars used in this unresolved block
421411
SkTHashSet<SkUnichar> alreadyTried;
422-
SkUnichar unicode = utf8_next(&ch, unresolvedText.end());
412+
SkUnichar unicode = nextUtf8Unit(&ch, unresolvedText.end());
423413
while (true) {
424414

425415
sk_sp<SkTypeface> typeface;
@@ -457,7 +447,7 @@ void OneLineShaper::matchResolvedFonts(const TextStyle& textStyle,
457447

458448
// We can stop here or we can switch to another DIFFERENT codepoint
459449
while (ch != unresolvedText.end()) {
460-
unicode = utf8_next(&ch, unresolvedText.end());
450+
unicode = nextUtf8Unit(&ch, unresolvedText.end());
461451
auto found = alreadyTried.find(unicode);
462452
if (found == nullptr) {
463453
alreadyTried.add(unicode);
@@ -472,10 +462,6 @@ void OneLineShaper::matchResolvedFonts(const TextStyle& textStyle,
472462

473463
bool OneLineShaper::iterateThroughShapingRegions(const ShapeVisitor& shape) {
474464

475-
if (!fParagraph->getBidiRegions()) {
476-
return false;
477-
}
478-
479465
size_t bidiIndex = 0;
480466

481467
SkScalar advanceX = 0;
@@ -485,20 +471,20 @@ bool OneLineShaper::iterateThroughShapingRegions(const ShapeVisitor& shape) {
485471
// Shape the text by bidi regions
486472
while (bidiIndex < fParagraph->fBidiRegions.size()) {
487473
BidiRegion& bidiRegion = fParagraph->fBidiRegions[bidiIndex];
488-
auto start = std::max(bidiRegion.text.start, placeholder.fTextBefore.start);
489-
auto end = std::min(bidiRegion.text.end, placeholder.fTextBefore.end);
474+
auto start = std::max(bidiRegion.start, placeholder.fTextBefore.start);
475+
auto end = std::min(bidiRegion.end, placeholder.fTextBefore.end);
490476

491477
// Set up the iterators (the style iterator points to a bigger region that it could
492478
TextRange textRange(start, end);
493479
auto blockRange = fParagraph->findAllBlocks(textRange);
494480
SkSpan<Block> styleSpan(fParagraph->blocks(blockRange));
495481

496482
// Shape the text between placeholders
497-
if (!shape(textRange, styleSpan, advanceX, start, bidiRegion.direction)) {
483+
if (!shape(textRange, styleSpan, advanceX, start, bidiRegion.level)) {
498484
return false;
499485
}
500486

501-
if (end == bidiRegion.text.end) {
487+
if (end == bidiRegion.end) {
502488
++bidiIndex;
503489
} else /*if (end == placeholder.fTextBefore.end)*/ {
504490
break;

modules/skparagraph/src/ParagraphCache.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class ParagraphCacheValue {
5050
// ICU results
5151
SkTArray<CodeUnitFlags> fCodeUnitProperties;
5252
std::vector<size_t> fWords;
53-
SkTArray<BidiRegion> fBidiRegions;
53+
std::vector<BidiRegion> fBidiRegions;
5454
SkTArray<TextIndex, true> fUTF8IndexForUTF16Index;
5555
SkTArray<size_t, true> fUTF16IndexForUTF8Index;
5656
};

0 commit comments

Comments
 (0)