[skottie] Add support for text stroke line join

New 'lj' text property to match BM values:

  1: miter
  2: round
  3: bevel

Change-Id: I3997c6b8c702a3f80da1cbee6cb950eca775bc77
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/517896
Reviewed-by: Jorge Betancourt <jmbetancourt@google.com>
Commit-Queue: Florin Malita <fmalita@google.com>
This commit is contained in:
Florin Malita 2022-03-10 09:32:29 -05:00 committed by SkCQ
parent 1df655a427
commit 38b9591b5a
6 changed files with 15 additions and 0 deletions

View File

@ -9,6 +9,7 @@
#define SkottieProperty_DEFINED
#include "include/core/SkColor.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPoint.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkTypeface.h"
@ -57,6 +58,7 @@ struct TextPropertyValue {
SkColor fFillColor = SK_ColorTRANSPARENT,
fStrokeColor = SK_ColorTRANSPARENT;
TextPaintOrder fPaintOrder = TextPaintOrder::kFillStroke;
SkPaint::Join fStrokeJoin = SkPaint::Join::kMiter_Join;
bool fHasFill = false,
fHasStroke = false;

View File

@ -32,6 +32,8 @@ bool TextPropertyValue::operator==(const TextPropertyValue& other) const {
&& fBox == other.fBox
&& fFillColor == other.fFillColor
&& fStrokeColor == other.fStrokeColor
&& fPaintOrder == other.fPaintOrder
&& fStrokeJoin == other.fStrokeJoin
&& fHasFill == other.fHasFill
&& fHasStroke == other.fHasStroke;
}

View File

@ -332,6 +332,7 @@ DEF_TEST(Skottie_Properties, reporter) {
SK_ColorTRANSPARENT,
SK_ColorTRANSPARENT,
TextPaintOrder::kFillStroke,
SkPaint::Join::kDefault_Join,
false,
false
}));

View File

@ -336,6 +336,7 @@ void TextAdapter::addFragment(const Shaper::Fragment& frag, float scale) {
rec.fStrokeColorNode->setAntiAlias(true);
rec.fStrokeColorNode->setStyle(SkPaint::kStroke_Style);
rec.fStrokeColorNode->setStrokeWidth(fText->fStrokeWidth * scale);
rec.fStrokeColorNode->setStrokeJoin(fText->fStrokeJoin);
draws.push_back(sksg::Draw::Make(blob_node, rec.fStrokeColorNode));
}
};

View File

@ -161,6 +161,14 @@ bool Parse(const skjson::Value& jv, const internal::AnimationBuilder& abuilder,
v->fPaintOrder = ParseDefault((*jtxt)["of"], true)
? TextPaintOrder::kFillStroke
: TextPaintOrder::kStrokeFill;
static constexpr SkPaint::Join gJoins[] = {
SkPaint::kMiter_Join, // lj: 1
SkPaint::kRound_Join, // lj: 2
SkPaint::kBevel_Join, // lj: 3
};
v->fStrokeJoin = gJoins[std::min<size_t>(ParseDefault<size_t>((*jtxt)["lj"], 1) - 1,
SK_ARRAY_COUNT(gJoins) - 1)];
}
return true;

View File

@ -0,0 +1 @@
{"v":"5.8.1","fr":60,"ip":0,"op":301,"w":500,"h":500,"nm":"stroke-linejoin","ddd":0,"assets":[],"fonts":{"list":[{"origin":0,"fPath":"","fClass":"","fFamily":"Google Sans","fWeight":"","fStyle":"Bold","fName":"GoogleSans-Bold","ascent":95.6476929411292}]},"layers":[{"ddd":0,"ind":1,"ty":5,"nm":"bevel","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[250,380,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"t":{"d":{"k":[{"s":{"s":72,"f":"GoogleSans-Bold","t":"Foo Bar Baz","lj":3,"ca":0,"j":2,"tr":0,"lh":96,"ls":0,"sc":[1,0,0],"sw":20},"t":0}]},"p":{},"m":{"g":1,"a":{"a":0,"k":[0,0],"ix":2}},"a":[]},"ip":0,"op":301,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":5,"nm":"round","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[250,250,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"t":{"d":{"k":[{"s":{"s":72,"f":"GoogleSans-Bold","t":"Foo Bar Baz","lj":2,"ca":0,"j":2,"tr":0,"lh":96,"ls":0,"sc":[1,0,0],"sw":20},"t":0}]},"p":{},"m":{"g":1,"a":{"a":0,"k":[0,0],"ix":2}},"a":[]},"ip":0,"op":301,"st":0,"bm":0},{"ddd":0,"ind":3,"ty":5,"nm":"miter","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[250,120,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"t":{"d":{"k":[{"s":{"s":72,"f":"GoogleSans-Bold","t":"Foo Bar Baz","lj":1,"ca":0,"j":2,"tr":0,"lh":96,"ls":0,"sc":[1,0,0],"sw":20},"t":0}]},"p":{},"m":{"g":1,"a":{"a":0,"k":[0,0],"ix":2}},"a":[]},"ip":0,"op":301,"st":0,"bm":0},{"ddd":0,"ind":4,"ty":1,"nm":"Black Solid 1","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[250,250,0],"ix":2,"l":2},"a":{"a":0,"k":[256,256,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"sw":512,"sh":512,"sc":"#000000","ip":0,"op":301,"st":0,"bm":0}],"markers":[]}