[skottie] Clip overflowing paragraph lines

AE discards lines with baselines outside the paragraph box.

This aligns Skottie's behavior with AE for default/top-alignment
(but not for any of the custom vertical alignment modes).

Bug: skia:9933
Change-Id: Id0318f0744bf89580774e89494faf19bfb6f6d14
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/272376
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
This commit is contained in:
Florin Malita 2020-02-20 12:34:34 -05:00 committed by Skia Commit-Bot
parent 5e5e848770
commit 0de01c05b7
2 changed files with 18 additions and 3 deletions

View File

@ -144,9 +144,7 @@ public:
fResult.fFragments.push_back({fBuilder.make(), {fBox.x(), fBox.y()}, 0, false});
}
// Use the explicit ascent, when specified.
// Note: ascent values are negative (relative to the baseline).
const auto ascent = fDesc.fAscent ? fDesc.fAscent : fFirstLineAscent;
const auto ascent = this->ascent();
// For visual VAlign modes, we use a hybrid extent box computed as the union of
// actual visual bounds and the vertical typographical extent.
@ -228,6 +226,16 @@ public:
return;
}
// In default paragraph mode (VAlign::kTop), AE clips out lines when the baseline
// goes below the box lower edge.
if (fDesc.fVAlign == Shaper::VAlign::kTop) {
// fOffset is relative to the first line baseline.
const auto max_offset = fBox.height() + this->ascent(); // NB: ascent is negative
if (fOffset.y() > max_offset) {
return;
}
}
// When no text box is present, text is laid out on a single infinite line
// (modulo explicit line breaks).
const auto shape_width = fBox.isEmpty() ? SK_ScalarMax
@ -297,6 +305,12 @@ private:
return 0.0f; // go home, msvc...
}
SkScalar ascent() const {
// Use the explicit ascent, when specified.
// Note: ascent values are negative (relative to the baseline).
return fDesc.fAscent ? fDesc.fAscent : fFirstLineAscent;
}
static constexpr SkGlyphID kMissingGlyphID = 0;
const Shaper::TextDesc& fDesc;

File diff suppressed because one or more lines are too long