Cleanup SkText warnings
Some unused var and pessimizing move warnings, e.g. ../../experimental/sktext/src/Text.cpp:316:12: warning: moving a local object in a return statement prevents copy elision [-Wpessimizing-move] return std::move(shapedText); ^ ../../experimental/sktext/src/Text.cpp:316:12: note: remove std::move call here return std::move(shapedText); ^~~~~~~~~~ Change-Id: Id5c220b7a850b2013e2bf065a87d4a296bd0369c Reviewed-on: https://skia-review.googlesource.com/c/skia/+/542522 Reviewed-by: Julia Lavrova <jlavrova@google.com> Commit-Queue: Florin Malita <fmalita@google.com> Auto-Submit: Florin Malita <fmalita@chromium.org>
This commit is contained in:
parent
97caefd055
commit
1da7be7a85
@ -47,9 +47,6 @@ protected:
|
|||||||
const std::u16string& text,
|
const std::u16string& text,
|
||||||
TextAlign align,
|
TextAlign align,
|
||||||
TextDirection direction = TextDirection::kLtr) {
|
TextDirection direction = TextDirection::kLtr) {
|
||||||
const std::u16string& ellipsis = u"\u2026";
|
|
||||||
SkScalar margin = 20;
|
|
||||||
|
|
||||||
SkAutoCanvasRestore acr(canvas, true);
|
SkAutoCanvasRestore acr(canvas, true);
|
||||||
|
|
||||||
canvas->clipRect(SkRect::MakeWH(w, h));
|
canvas->clipRect(SkRect::MakeWH(w, h));
|
||||||
|
@ -94,7 +94,7 @@ std::unique_ptr<FontResolvedText> UnicodeText::resolveFonts(SkSpan<FontBlock> bl
|
|||||||
SkDebugf("[%d:%d)\n", f.textRange.fStart, f.textRange.fEnd);
|
SkDebugf("[%d:%d)\n", f.textRange.fStart, f.textRange.fEnd);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
return std::move(fontResolvedText);
|
return fontResolvedText;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FontResolvedText::resolveChain(UnicodeText* unicodeText, TextRange textRange, const FontChain& fontChain) {
|
bool FontResolvedText::resolveChain(UnicodeText* unicodeText, TextRange textRange, const FontChain& fontChain) {
|
||||||
@ -259,7 +259,6 @@ std::unique_ptr<ShapedText> FontResolvedText::shape(UnicodeText* unicodeText,
|
|||||||
formattingMarks.emplace_back(text8.size()/* UTF8FromUTF16[text16.size() */);
|
formattingMarks.emplace_back(text8.size()/* UTF8FromUTF16[text16.size() */);
|
||||||
// Convert fontBlocks from utf16 to utf8
|
// Convert fontBlocks from utf16 to utf8
|
||||||
SkTArray<ResolvedFontBlock, true> fontBlocks8;
|
SkTArray<ResolvedFontBlock, true> fontBlocks8;
|
||||||
TextIndex index8 = 0;
|
|
||||||
for (auto& fb : fResolvedFonts) {
|
for (auto& fb : fResolvedFonts) {
|
||||||
TextRange text8(UTF8FromUTF16[fb.textRange.fStart], UTF8FromUTF16[fb.textRange.fEnd]);
|
TextRange text8(UTF8FromUTF16[fb.textRange.fStart], UTF8FromUTF16[fb.textRange.fEnd]);
|
||||||
fontBlocks8.emplace_back(text8, fb.typeface, fb.size, fb.style);
|
fontBlocks8.emplace_back(text8, fb.typeface, fb.size, fb.style);
|
||||||
@ -313,7 +312,7 @@ std::unique_ptr<ShapedText> FontResolvedText::shape(UnicodeText* unicodeText,
|
|||||||
logicalRun.setRunType(LogicalRunType::kLineBreak);
|
logicalRun.setRunType(LogicalRunType::kLineBreak);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return std::move(shapedText);
|
return shapedText;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Implement the vertical restriction (height) and add ellipsis
|
// TODO: Implement the vertical restriction (height) and add ellipsis
|
||||||
@ -370,9 +369,7 @@ std::unique_ptr<WrappedText> ShapedText::wrap(UnicodeText* unicodeText, float wi
|
|||||||
clusterGlyphs.fEnd = glyphIndex;
|
clusterGlyphs.fEnd = glyphIndex;
|
||||||
cluster = Stretch(runIndex, clusterGlyphs, clusterText.normalized(), run.calculateWidth(clusterGlyphs), runMetrics);
|
cluster = Stretch(runIndex, clusterGlyphs, clusterText.normalized(), run.calculateWidth(clusterGlyphs), runMetrics);
|
||||||
|
|
||||||
auto isSoftLineBreak = unicodeText->isSoftLineBreak(cluster.textStart());
|
|
||||||
auto isWhitespaces = unicodeText->isWhitespaces(cluster.textRange());
|
auto isWhitespaces = unicodeText->isWhitespaces(cluster.textRange());
|
||||||
auto isEndOfText = run.leftToRight() ? textIndex == run.fUtf16Range.fEnd : textIndex == run.fUtf16Range.fStart;
|
|
||||||
// line + spaces + clusters + cluster
|
// line + spaces + clusters + cluster
|
||||||
if (isWhitespaces) {
|
if (isWhitespaces) {
|
||||||
// This is the end of the word
|
// This is the end of the word
|
||||||
@ -429,7 +426,7 @@ std::unique_ptr<WrappedText> ShapedText::wrap(UnicodeText* unicodeText, float wi
|
|||||||
}
|
}
|
||||||
this->addLine(wrappedText.get(), unicodeText->getUnicode(), line, spaces, false);
|
this->addLine(wrappedText.get(), unicodeText->getUnicode(), line, spaces, false);
|
||||||
wrappedText->fActualSize.fWidth = width;
|
wrappedText->fActualSize.fWidth = width;
|
||||||
return std::move(wrappedText);
|
return wrappedText;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkTArray<int32_t> ShapedText::getVisualOrder(SkUnicode* unicode, RunIndex startRun, RunIndex endRun) {
|
SkTArray<int32_t> ShapedText::getVisualOrder(SkUnicode* unicode, RunIndex startRun, RunIndex endRun) {
|
||||||
@ -458,7 +455,7 @@ void ShapedText::addLine(WrappedText* wrappedText, SkUnicode* unicode, Stretch&
|
|||||||
auto startRun = lineStretch.glyphStart().runIndex();
|
auto startRun = lineStretch.glyphStart().runIndex();
|
||||||
auto endRun = lineStretch.glyphEnd().runIndex();
|
auto endRun = lineStretch.glyphEnd().runIndex();
|
||||||
// Reorder and cut (if needed) runs so they fit the line
|
// Reorder and cut (if needed) runs so they fit the line
|
||||||
auto visualOrder = std::move(this->getVisualOrder(unicode, startRun, endRun));
|
auto visualOrder = this->getVisualOrder(unicode, startRun, endRun);
|
||||||
// Walk through the line's runs in visual order
|
// Walk through the line's runs in visual order
|
||||||
auto firstRunIndex = startRun;
|
auto firstRunIndex = startRun;
|
||||||
auto runStart = wrappedText->fVisualRuns.size();
|
auto runStart = wrappedText->fVisualRuns.size();
|
||||||
@ -547,7 +544,7 @@ std::vector<TextIndex> WrappedText::chunksToBlocks(SkSpan<size_t> chunks) {
|
|||||||
index += chunk;
|
index += chunk;
|
||||||
}
|
}
|
||||||
blocks.emplace_back(index);
|
blocks.emplace_back(index);
|
||||||
return std::move(blocks);
|
return blocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkSpan<TextIndex> WrappedText::limitBlocks(TextRange textRange, SkSpan<TextIndex> blocks) {
|
SkSpan<TextIndex> WrappedText::limitBlocks(TextRange textRange, SkSpan<TextIndex> blocks) {
|
||||||
|
@ -158,7 +158,6 @@ UNIX_ONLY_TEST(SkText_SelectableText_Navigation_FirstLast, reporter) {
|
|||||||
|
|
||||||
// First position
|
// First position
|
||||||
auto firstLine = testVisitor.fTestLines.front();
|
auto firstLine = testVisitor.fTestLines.front();
|
||||||
auto firstRun = testVisitor.fTestRuns.front();
|
|
||||||
auto firstPosition = selectableText->firstPosition(PositionType::kGraphemeCluster);
|
auto firstPosition = selectableText->firstPosition(PositionType::kGraphemeCluster);
|
||||||
REPORTER_ASSERT(reporter, firstPosition.fLineIndex == 0);
|
REPORTER_ASSERT(reporter, firstPosition.fLineIndex == 0);
|
||||||
REPORTER_ASSERT(reporter, firstPosition.fTextRange == TextRange(0, 0));
|
REPORTER_ASSERT(reporter, firstPosition.fTextRange == TextRange(0, 0));
|
||||||
|
Loading…
Reference in New Issue
Block a user