Lines Matching +full:block +full:- +full:end
9 static inline SkUnichar nextUtf8Unit(const char** ptr, const char* end) { in nextUtf8Unit() argument
10 SkUnichar val = SkUTF::NextUTF8(ptr, end); in nextUtf8Unit()
19 fCurrentRun->commit(); in commitRunBuffer()
23 SkDebugf("Run [%zu:%zu)\n", fCurrentRun->fTextRange.start, fCurrentRun->fTextRange.end); in commitRunBuffer()
24 for (size_t i = 0; i < fCurrentRun->size(); ++i) { in commitRunBuffer()
25 …SkDebugf("[%zu] %hu %u %f\n", i, fCurrentRun->fGlyphs[i], fCurrentRun->fClusterIndexes[i], fCurren… in commitRunBuffer()
29 sortOutGlyphs([&](GlyphRange block){ in commitRunBuffer() argument
30 if (block.width() == 0) { in commitRunBuffer()
33 addUnresolvedWithRun(block); in commitRunBuffer()
38 // No unresolved blocks added - we resolved the block with one run entirely in commitRunBuffer()
41 } else if (oldUnresolvedCount == fUnresolvedBlocks.size() - 1) { in commitRunBuffer()
43 if (fCurrentRun->textRange() == unresolved.fText) { in commitRunBuffer()
63 resolved.fText.start, resolved.fText.end); in printState()
67 if (resolved.fRun->fFont.getTypeface() != nullptr) { in printState()
68 resolved.fRun->fFont.getTypeface()->getFamilyName(&name); in printState()
70 SkDebugf("[%zu:%zu) ", resolved.fGlyphs.start, resolved.fGlyphs.end); in printState()
72 resolved.fText.start, resolved.fText.end, in printState()
79 SkDebugf("[%zu:%zu)\n", unresolved.fText.start, unresolved.fText.end); in printState()
86 TextRange resolvedTextLimits = fCurrentRun->fTextRange; in fillGaps()
87 if (!fCurrentRun->leftToRight()) { in fillGaps()
88 std::swap(resolvedTextLimits.start, resolvedTextLimits.end); in fillGaps()
94 auto end = fUnresolvedBlocks.end(); in fillGaps() local
97 for (; begin != end; ++begin) { in fillGaps()
101 // Clean up repetitive blocks that appear inside the same grapheme block in fillGaps()
108 …e resolvedText(resolvedTextStart, fCurrentRun->leftToRight() ? unresolved.fText.start : unresolved… in fillGaps()
110 if (!fCurrentRun->leftToRight()) { in fillGaps()
111 std::swap(resolvedText.start, resolvedText.end); in fillGaps()
118 // Extend the unresolved block with an empty resolved in fillGaps()
119 if (unresolved.fText.end <= resolved.fText.start) { in fillGaps()
120 unresolved.fText.end = resolved.fText.end; in fillGaps()
122 if (unresolved.fText.start >= resolved.fText.end) { in fillGaps()
129 resolvedGlyphsStart = unresolved.fGlyphs.end; in fillGaps()
130 resolvedTextStart = fCurrentRun->leftToRight() in fillGaps()
131 ? unresolved.fText.end in fillGaps()
135 TextRange resolvedText(resolvedTextStart,resolvedTextLimits.end); in fillGaps()
137 if (!fCurrentRun->leftToRight()) { in fillGaps()
138 std::swap(resolvedText.start, resolvedText.end); in fillGaps()
141 GlyphRange resolvedGlyphs(resolvedGlyphsStart, fCurrentRun->size()); in fillGaps()
147 void OneLineShaper::finish(const Block& block, SkScalar height, SkScalar& advanceX) { in finish() argument
148 auto blockText = block.fRange; in finish()
162 std::sort(fResolvedBlocks.begin(), fResolvedBlocks.end(), in finish()
171 if (resolvedBlock.fText.end <= blockText.start) { in finish()
176 … fParagraph->fFontSwitches.emplace_back(resolvedBlock.fText.start, resolvedBlock.fRun->fFont); in finish()
183 SkDEBUGF("Text ranges mismatch: ...:%zu] - [%zu:%zu] (%zu-%zu)\n", in finish()
184 lastTextEnd, text.start, text.end, glyphs.start, glyphs.end); in finish()
187 lastTextEnd = text.end; in finish()
191 resolvedBlock.fRun->fIndex = this->fParagraph->fRuns.size(); in finish()
192 this->fParagraph->fRuns.emplace_back(*resolvedBlock.fRun); in finish()
199 …auto runAdvance = SkVector::Make(run->posX(glyphs.end) - run->posX(glyphs.start), run->fAdvance.fY… in finish()
201 run->fFont, in finish()
202 run->fBidiLevel, in finish()
205 SkShaper::RunHandler::Range(text.start - run->fClusterStart, text.width()) in finish()
207 this->fParagraph->fRuns.emplace_back( in finish()
208 this->fParagraph, in finish()
210 run->fClusterStart, in finish()
212 block.fStyle.getHalfLeading(), in finish()
213 block.fStyle.getBaselineShift(), in finish()
214 this->fParagraph->fRuns.count(), in finish()
217 auto piece = &this->fParagraph->fRuns.back(); in finish()
220 auto zero = run->fPositions[glyphs.start]; in finish()
221 for (size_t i = glyphs.start; i <= glyphs.end; ++i) { in finish()
223 auto index = i - glyphs.start; in finish()
224 if (i < glyphs.end) { in finish()
225 piece->fGlyphs[index] = run->fGlyphs[i]; in finish()
226 piece->fBounds[index] = run->fBounds[i]; in finish()
228 piece->fClusterIndexes[index] = run->fClusterIndexes[i]; in finish()
229 piece->fPositions[index] = run->fPositions[i] - zero; in finish()
230 piece->addX(index, advanceX); in finish()
239 if (lastTextEnd != blockText.end) { in finish()
240 SkDEBUGF("Last range mismatch: %zu - %zu\n", lastTextEnd, blockText.end); in finish()
248 if (fCurrentRun->leftToRight()) { in normalizeTextRange()
249 return TextRange(clusterIndex(glyphRange.start), clusterIndex(glyphRange.end)); in normalizeTextRange()
251 return TextRange(clusterIndex(glyphRange.end - 1), in normalizeTextRange()
253 ? clusterIndex(glyphRange.start - 1) in normalizeTextRange()
254 : fCurrentRun->fTextRange.end); in normalizeTextRange()
259 if (this->fCurrentRun->size() == 0) { in addFullyResolved()
263 this->fCurrentRun->fTextRange, in addFullyResolved()
264 GlyphRange(0, this->fCurrentRun->size()), in addFullyResolved()
265 this->fCurrentRun->size()); in addFullyResolved()
271 if (unresolved.fGlyphs.width() == fCurrentRun->size()) { in addUnresolvedWithRun()
272 SkASSERT(unresolved.fText.width() == fCurrentRun->fTextRange.width()); in addUnresolvedWithRun()
276 lastUnresolved.fRun->fIndex == fCurrentRun->fIndex) { in addUnresolvedWithRun()
278 if (lastUnresolved.fText.end == unresolved.fText.start) { in addUnresolvedWithRun()
279 // Two pieces next to each other - can join them in addUnresolvedWithRun()
280 lastUnresolved.fText.end = unresolved.fText.end; in addUnresolvedWithRun()
281 lastUnresolved.fGlyphs.end = glyphRange.end; in addUnresolvedWithRun()
290 // Few pieces of the same unresolved text block can ignore the second one in addUnresolvedWithRun()
292 lastUnresolved.fGlyphs.end = std::max(lastUnresolved.fGlyphs.end, glyphRange.end); in addUnresolvedWithRun()
306 auto text = fCurrentRun->fOwner->text(); in sortOutGlyphs()
309 GlyphRange block = EMPTY_RANGE; in sortOutGlyphs() local
312 for (size_t i = 0; i < fCurrentRun->size(); ++i) { in sortOutGlyphs()
318 auto glyph = fCurrentRun->fGlyphs[i]; in sortOutGlyphs()
320 GraphemeIndex gi = fParagraph->findPreviousGraphemeBoundary(ci); in sortOutGlyphs()
321 …if ((fCurrentRun->leftToRight() ? gi > graphemeStart : gi < graphemeStart) || graphemeStart == EMP… in sortOutGlyphs()
325 SkUnichar codepoint = nextUtf8Unit(&cluster, text.end()); in sortOutGlyphs()
326 bool isControl8 = fParagraph->getUnicode()->isControl(codepoint); in sortOutGlyphs()
331 // Found unresolved glyph - the entire grapheme is unresolved now in sortOutGlyphs()
337 if (block.start == EMPTY_INDEX) { in sortOutGlyphs()
338 // Start new unresolved block in sortOutGlyphs()
339 block.start = i; in sortOutGlyphs()
340 block.end = EMPTY_INDEX; in sortOutGlyphs()
342 // Keep skipping unresolved block in sortOutGlyphs()
345 if (block.start == EMPTY_INDEX) { in sortOutGlyphs()
348 // This is the end of unresolved block in sortOutGlyphs()
349 block.end = i; in sortOutGlyphs()
350 sortOutUnresolvedBLock(block); in sortOutGlyphs()
351 block = EMPTY_RANGE; in sortOutGlyphs()
356 // One last block could have been left in sortOutGlyphs()
357 if (block.start != EMPTY_INDEX) { in sortOutGlyphs()
358 block.end = fCurrentRun->size(); in sortOutGlyphs()
359 sortOutUnresolvedBLock(block); in sortOutGlyphs()
365 auto text = fCurrentRun->fOwner->text(); in sortOutGlyphs()
369 GlyphRange block = EMPTY_RANGE; in sortOutGlyphs() local
370 for (size_t i = 0; i < fCurrentRun->size(); ++i) { in sortOutGlyphs()
373 SkUnichar codepoint = nextUtf8Unit(&cluster, text.end()); in sortOutGlyphs()
374 bool isControl8 = fParagraph->getUnicode()->isControl(codepoint); in sortOutGlyphs()
378 bool isWhitespace8 = false; // fParagraph->getUnicode()->isWhitespace(codepoint); in sortOutGlyphs()
380 bool isWhitespace8 = fParagraph->getUnicode()->isWhitespace(codepoint); in sortOutGlyphs()
383 auto glyph = fCurrentRun->fGlyphs[i]; in sortOutGlyphs()
386 if (block.start == EMPTY_INDEX) { in sortOutGlyphs()
387 // Start new unresolved block in sortOutGlyphs()
389 block.start = whitespacesStart == 0 ? 0 : i; in sortOutGlyphs()
390 block.end = EMPTY_INDEX; in sortOutGlyphs()
392 // Keep skipping unresolved block in sortOutGlyphs()
395 if (block.start == EMPTY_INDEX) { in sortOutGlyphs()
398 // Glue whitespaces after to the unresolved block in sortOutGlyphs()
401 … // This is the end of unresolved block (all trailing whitespaces glued to the resolved part) in sortOutGlyphs()
402 block.end = whitespacesStart == EMPTY_INDEX ? i : whitespacesStart; in sortOutGlyphs()
403 sortOutUnresolvedBLock(block); in sortOutGlyphs()
404 block = EMPTY_RANGE; in sortOutGlyphs()
419 // One last block could have been left in sortOutGlyphs()
420 if (block.start != EMPTY_INDEX) { in sortOutGlyphs()
421 block.end = fCurrentRun->size(); in sortOutGlyphs()
422 sortOutUnresolvedBLock(block); in sortOutGlyphs()
428 SkSpan<Block> styleSpan, in iterateThroughFontStyles()
430 Block combinedBlock; in iterateThroughFontStyles()
433 auto addFeatures = [&features](const Block& block) { in iterateThroughFontStyles() argument
434 for (auto& ff : block.fStyle.getFontFeatures()) { in iterateThroughFontStyles()
442 block.fRange.start, in iterateThroughFontStyles()
443 block.fRange.end in iterateThroughFontStyles()
449 for (auto& block : styleSpan) { in iterateThroughFontStyles() local
450 …BlockRange blockRange(std::max(block.fRange.start, textRange.start), std::min(block.fRange.end, te… in iterateThroughFontStyles()
454 … SkASSERT(combinedBlock.fRange.width() == 0 || combinedBlock.fRange.end == block.fRange.start); in iterateThroughFontStyles()
457 if (block.fStyle.matchOneAttribute(StyleType::kFont, combinedBlock.fStyle)) { in iterateThroughFontStyles()
459 addFeatures(block); in iterateThroughFontStyles()
462 // Resolve all characters in the block for this style in iterateThroughFontStyles()
467 combinedBlock.fStyle = block.fStyle; in iterateThroughFontStyles()
469 addFeatures(block); in iterateThroughFontStyles()
480 …std::vector<sk_sp<SkTypeface>> typefaces = fParagraph->fFontCollection->findTypefaces(textStyle.ge… in matchResolvedFonts()
489 if (fParagraph->fFontCollection->fontFallbackEnabled()) { in matchResolvedFonts()
495 auto unresolvedText = fParagraph->text(unresolvedRange); in matchResolvedFonts()
498 // but we still need to keep track of all SkUnichars used in this unresolved block in matchResolvedFonts()
500 SkUnichar unicode = nextUtf8Unit(&ch, unresolvedText.end()); in matchResolvedFonts()
511 typeface = fParagraph->fFontCollection->defaultFallback( in matchResolvedFonts()
531 if (ch == unresolvedText.end()) { in matchResolvedFonts()
532 // Not a single codepoint could be resolved but we finished the block in matchResolvedFonts()
539 while (ch != unresolvedText.end()) { in matchResolvedFonts()
540 unicode = nextUtf8Unit(&ch, unresolvedText.end()); in matchResolvedFonts()
549 for (auto& block : hopelessBlocks) { in matchResolvedFonts() local
550 fUnresolvedBlocks.emplace_front(block); in matchResolvedFonts()
560 for (auto& placeholder : fParagraph->fPlaceholders) { in iterateThroughShapingRegions()
564 while (bidiIndex < fParagraph->fBidiRegions.size()) { in iterateThroughShapingRegions()
565 SkUnicode::BidiRegion& bidiRegion = fParagraph->fBidiRegions[bidiIndex]; in iterateThroughShapingRegions()
567 auto end = std::min(bidiRegion.end, placeholder.fTextBefore.end); in iterateThroughShapingRegions() local
570 TextRange textRange(start, end); in iterateThroughShapingRegions()
571 auto blockRange = fParagraph->findAllBlocks(textRange); in iterateThroughShapingRegions()
572 SkSpan<Block> styleSpan(fParagraph->blocks(blockRange)); in iterateThroughShapingRegions()
579 if (end == bidiRegion.end) { in iterateThroughShapingRegions()
581 } else /*if (end == placeholder.fTextBefore.end)*/ { in iterateThroughShapingRegions()
592 std::vector<sk_sp<SkTypeface>> typefaces = fParagraph->fFontCollection->findTypefaces( in iterateThroughShapingRegions()
606 auto& run = fParagraph->fRuns.emplace_back(this->fParagraph, in iterateThroughShapingRegions()
612 fParagraph->fRuns.count(), in iterateThroughShapingRegions()
617 run.fPlaceholderIndex = &placeholder - fParagraph->fPlaceholders.begin(); in iterateThroughShapingRegions()
631 …(TextRange textRange, SkSpan<Block> styleSpan, SkScalar& advanceX, TextIndex textStart, uint8_t de… in shape()
642 (Block block, SkTArray<SkShaper::Feature> features) { in shape() argument
643 auto blockSpan = SkSpan<Block>(&block, 1); in shape()
645 // Start from the beginning (hoping that it's a simple case one block - one run) in shape()
646 fHeight = block.fStyle.getHeightOverride() ? block.fStyle.getHeight() : 0; in shape()
647 fUseHalfLeading = block.fStyle.getHalfLeading(); in shape()
648 fBaselineShift = block.fStyle.getBaselineShift(); in shape()
650 fCurrentText = block.fRange; in shape()
651 fUnresolvedBlocks.emplace_back(RunBlock(block.fRange)); in shape()
653 matchResolvedFonts(block.fStyle, [&](sk_sp<SkTypeface> typeface) { in shape()
656 SkFont font(std::move(typeface), block.fStyle.getFontSize()); in shape()
663 int wantedWeight = block.fStyle.getFontStyle().weight(); in shape()
666 wantedWeight - font.getTypeface()->fontStyle().weight() >= 200; in shape()
668 block.fStyle.getFontStyle().slant() == SkFontStyle::kItalic_Slant && in shape()
669 font.getTypeface()->fontStyle().slant() != SkFontStyle::kItalic_Slant; in shape()
671 font.setSkewX(fakeItalic ? -SK_Scalar1 / 4 : 0); in shape()
677 while (unresolvedCount-- > 0) { in shape()
684 auto unresolvedText = fParagraph->text(unresolvedRange); in shape()
688 fParagraph->paragraphStyle().getTextStyle()); in shape()
691 … (fParagraph->getUnicode(), unresolvedText.begin(), unresolvedText.size()); in shape()
693 shaper->shape(unresolvedText.begin(), unresolvedText.size(), in shape()
698 // Take off the queue the block we tried to resolved - in shape()
712 this->finish(block, fHeight, advanceX); in shape()
728 auto findBaseChar = [&](TextIndex index, Dir dir) -> TextIndex { in clusteredText()
731 while (index < fCurrentRun->fTextRange.end) { in clusteredText()
732 if (this->fParagraph->codeUnitHasProperty(index, in clusteredText()
738 return fCurrentRun->fTextRange.end; in clusteredText()
740 while (index > fCurrentRun->fTextRange.start) { in clusteredText()
741 if (this->fParagraph->codeUnitHasProperty(index, in clusteredText()
745 --index; in clusteredText()
747 return fCurrentRun->fTextRange.start; in clusteredText()
753 textRange.end = findBaseChar(textRange.end, Dir::right); in clusteredText()
757 if (fCurrentRun->leftToRight()) { in clusteredText()
759 glyphs.start--; in clusteredText()
761 while (glyphs.end < fCurrentRun->size() && clusterIndex(glyphs.end) < textRange.end) { in clusteredText()
762 glyphs.end++; in clusteredText()
765 while (glyphs.start > 0 && clusterIndex(glyphs.start - 1) < textRange.end) { in clusteredText()
766 glyphs.start--; in clusteredText()
768 while (glyphs.end < fCurrentRun->size() && clusterIndex(glyphs.end) > textRange.start) { in clusteredText()
769 glyphs.end++; in clusteredText()
773 return { textRange.start, textRange.end }; in clusteredText()