Revert "[skottie] Max lines text auto-sizing constraint"
This reverts commit 4d6d9e3f89
.
Reason for revert: g3 breakage
Original change's description:
> [skottie] Max lines text auto-sizing constraint
>
> Introduce a new text property ("xl"), to limit the number of lines when
> auto-sizing.
>
> This is a Skottie extension, pending UI/controls in Bodymovin.
>
> Change-Id: Id0f1e633e1b324a97b227d6b187cd540990796a7
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/518498
> Reviewed-by: Ben Wagner <bungeman@google.com>
> Reviewed-by: Jorge Betancourt <jmbetancourt@google.com>
> Commit-Queue: Florin Malita <fmalita@google.com>
Change-Id: I8877234d4d267f553b0f07255b5db13179294b90
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/518697
Auto-Submit: Florin Malita <fmalita@google.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
This commit is contained in:
parent
bdbb92a721
commit
4ea42a38eb
@ -46,7 +46,6 @@ struct TextPropertyValue {
|
||||
fLineHeight = 0,
|
||||
fLineShift = 0,
|
||||
fAscent = 0;
|
||||
size_t fMaxLines = 0; // when auto-sizing
|
||||
SkTextUtils::Align fHAlign = SkTextUtils::kLeft_Align;
|
||||
Shaper::VAlign fVAlign = Shaper::VAlign::kTop;
|
||||
Shaper::ResizePolicy fResize = Shaper::ResizePolicy::kNone;
|
||||
|
@ -22,7 +22,6 @@ bool TextPropertyValue::operator==(const TextPropertyValue& other) const {
|
||||
&& fLineHeight == other.fLineHeight
|
||||
&& fLineShift == other.fLineShift
|
||||
&& fAscent == other.fAscent
|
||||
&& fMaxLines == other.fMaxLines
|
||||
&& fHAlign == other.fHAlign
|
||||
&& fVAlign == other.fVAlign
|
||||
&& fResize == other.fResize
|
||||
|
@ -321,7 +321,6 @@ DEF_TEST(Skottie_Properties, reporter) {
|
||||
120,
|
||||
12,
|
||||
0,
|
||||
0,
|
||||
SkTextUtils::kLeft_Align,
|
||||
Shaper::VAlign::kTopBaseline,
|
||||
Shaper::ResizePolicy::kNone,
|
||||
@ -475,7 +474,6 @@ DEF_TEST(Skottie_Shaper_HAlign, reporter) {
|
||||
tsize.text_size,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
talign.align,
|
||||
Shaper::VAlign::kTopBaseline,
|
||||
Shaper::ResizePolicy::kNone,
|
||||
@ -547,7 +545,6 @@ DEF_TEST(Skottie_Shaper_VAlign, reporter) {
|
||||
tsize.text_size,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
SkTextUtils::Align::kCenter_Align,
|
||||
talign.align,
|
||||
Shaper::ResizePolicy::kNone,
|
||||
@ -589,7 +586,6 @@ DEF_TEST(Skottie_Shaper_FragmentGlyphs, reporter) {
|
||||
18,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
SkTextUtils::Align::kCenter_Align,
|
||||
Shaper::VAlign::kTop,
|
||||
Shaper::ResizePolicy::kNone,
|
||||
@ -683,7 +679,6 @@ DEF_TEST(Skottie_Shaper_ExplicitFontMgr, reporter) {
|
||||
18,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
SkTextUtils::Align::kCenter_Align,
|
||||
Shaper::VAlign::kTop,
|
||||
Shaper::ResizePolicy::kNone,
|
||||
|
@ -385,22 +385,6 @@ Shaper::Result ShapeImpl(const SkString& txt, const Shaper::TextDesc& desc,
|
||||
return blobMaker.finalize(shaped_size);
|
||||
}
|
||||
|
||||
bool result_fits(const Shaper::Result& res, const SkSize& res_size,
|
||||
const SkRect& box, const Shaper::TextDesc& desc) {
|
||||
// optional max line count constraint
|
||||
if (desc.fMaxLines) {
|
||||
const auto line_count = res.fFragments.empty()
|
||||
? 0
|
||||
: res.fFragments.back().fLineIndex + 1;
|
||||
if (line_count > desc.fMaxLines) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// geometric constraint
|
||||
return res_size.width() <= box.width() && res_size.height() <= box.height();
|
||||
}
|
||||
|
||||
Shaper::Result ShapeToFit(const SkString& txt, const Shaper::TextDesc& orig_desc,
|
||||
const SkRect& box, const sk_sp<SkFontMgr>& fontmgr) {
|
||||
Shaper::Result best_result;
|
||||
@ -435,7 +419,7 @@ Shaper::Result ShapeToFit(const SkString& txt, const Shaper::TextDesc& orig_desc
|
||||
auto res = ShapeImpl(txt, desc, box, fontmgr, &res_size);
|
||||
|
||||
const auto prev_scale = try_scale;
|
||||
if (!result_fits(res, res_size, box, desc)) {
|
||||
if (res_size.width() > box.width() || res_size.height() > box.height()) {
|
||||
out_scale = try_scale;
|
||||
try_scale = (in_scale == min_scale)
|
||||
// initial in_scale not found yet - search exponentially
|
||||
@ -514,7 +498,7 @@ Shaper::Result Shaper::Shape(const SkString& orig_txt, const TextDesc& desc, con
|
||||
SkSize size;
|
||||
auto result = ShapeImpl(txt, desc, box, fontmgr, &size);
|
||||
|
||||
return result_fits(result, size, box, desc)
|
||||
return (size.width() <= box.width() && size.height() <= box.height())
|
||||
? result
|
||||
: ShapeToFit(txt, desc, box, fontmgr);
|
||||
}
|
||||
|
@ -109,12 +109,11 @@ public:
|
||||
struct TextDesc {
|
||||
const sk_sp<SkTypeface>& fTypeface;
|
||||
SkScalar fTextSize,
|
||||
fMinTextSize, // when auto-sizing
|
||||
fMaxTextSize, // when auto-sizing
|
||||
fMinTextSize,
|
||||
fMaxTextSize,
|
||||
fLineHeight,
|
||||
fLineShift,
|
||||
fAscent;
|
||||
size_t fMaxLines; // when auto-sizing, 0 -> no max
|
||||
SkTextUtils::Align fHAlign;
|
||||
VAlign fVAlign;
|
||||
ResizePolicy fResize;
|
||||
|
@ -440,17 +440,10 @@ void TextAdapter::setText(const TextValue& txt) {
|
||||
uint32_t TextAdapter::shaperFlags() const {
|
||||
uint32_t flags = Shaper::Flags::kNone;
|
||||
|
||||
// We need granular fragments (as opposed to consolidated blobs):
|
||||
// - when animating
|
||||
// - when positioning on a path
|
||||
// - when clamping the number or lines (for accurate line count)
|
||||
if (!fAnimators.empty() || fPathInfo || fText->fMaxLines) {
|
||||
flags |= Shaper::Flags::kFragmentGlyphs;
|
||||
}
|
||||
|
||||
if (fRequiresAnchorPoint) {
|
||||
flags |= Shaper::Flags::kTrackFragmentAdvanceAscent;
|
||||
}
|
||||
// We need granular fragments (as opposed to consolidated blobs) when animating, or when
|
||||
// positioning on a path.
|
||||
if (!fAnimators.empty() || fPathInfo) flags |= Shaper::Flags::kFragmentGlyphs;
|
||||
if (fRequiresAnchorPoint) flags |= Shaper::Flags::kTrackFragmentAdvanceAscent;
|
||||
|
||||
return flags;
|
||||
}
|
||||
@ -464,7 +457,6 @@ void TextAdapter::reshape() {
|
||||
fText->fLineHeight,
|
||||
fText->fLineShift,
|
||||
fText->fAscent,
|
||||
fText->fMaxLines,
|
||||
fText->fHAlign,
|
||||
fText->fVAlign,
|
||||
fText->fResize,
|
||||
|
@ -74,10 +74,9 @@ bool Parse(const skjson::Value& jv, const internal::AnimationBuilder& abuilder,
|
||||
ParseDefault<size_t>((*jtxt)["sk_rs"], 0)),
|
||||
SK_ARRAY_COUNT(gResizeMap) - 1)];
|
||||
|
||||
// Optional min/max font size and line count (used when aute-resizing)
|
||||
// Optional min/max font size (used when aute-resizing)
|
||||
v->fMinTextSize = ParseDefault<SkScalar>((*jtxt)["mf"], 0.0f);
|
||||
v->fMaxTextSize = ParseDefault<SkScalar>((*jtxt)["xf"], std::numeric_limits<float>::max());
|
||||
v->fMaxLines = ParseDefault<size_t> ((*jtxt)["xl"], 0);
|
||||
|
||||
// At the moment, BM uses the paragraph box to discriminate point mode vs. paragraph mode.
|
||||
v->fLineBreak = v->fBox.isEmpty()
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user