0

Re-enable SkShaper_Primitive

https://skia-review.googlesource.com/c/skia/+/787018 changed the default
SkShaper factory behavior and inadvertently disabled text shaping in
Chromium Skottie builds.

1) define SK_SHAPER_PRIMITIVE_AVAILABLE to re-enable text shaping

2) update related unit tests to verify that text shaping actually works

3) add a unit test which triggers font fallback for
http://crbug.com/1520148

Change-Id: Ib3e69091a0e814eda0978b06abedc78812d45c86
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5260180
Reviewed-by: Kevin Lubick <kjlubick@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Ben Wagner <bungeman@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1256307}
This commit is contained in:
Florin Malita
2024-02-05 18:40:41 +00:00
committed by Chromium LUCI CQ
parent 3cde3ef0b3
commit aa8bc06722
3 changed files with 35 additions and 10 deletions

@ -28,6 +28,7 @@ namespace cc {
namespace {
using ::testing::_;
using ::testing::AtLeast;
using ::testing::Contains;
using ::testing::Eq;
using ::testing::FieldsAre;
@ -258,9 +259,10 @@ TEST(SkottieWrapperTest, SetsTextNodesWithDraw) {
SkottieTextPropertyValueMap text_map = {
{HashSkottieResourceId(kLottieDataWith2TextNode1),
SkottieTextPropertyValue("new-test-text-1", gfx::RectF(1, 1, 1, 1))},
SkottieTextPropertyValue("new-test-text-1", gfx::RectF(1, 1, 100, 100))},
{HashSkottieResourceId(kLottieDataWith2TextNode2),
SkottieTextPropertyValue("new-test-text-2", gfx::RectF(2, 2, 2, 2))}};
SkottieTextPropertyValue("new-test-text-2",
gfx::RectF(2, 2, 200, 200))}};
skottie->Draw(&canvas, /*t=*/0, SkRect::MakeWH(500, 500),
SkottieWrapper::FrameDataCallback(), SkottieColorMap(),
text_map);
@ -268,14 +270,16 @@ TEST(SkottieWrapperTest, SetsTextNodesWithDraw) {
UnorderedElementsAre(
Pair(HashSkottieResourceId(kLottieDataWith2TextNode1),
SkottieTextPropertyValue("new-test-text-1",
gfx::RectF(1, 1, 1, 1))),
gfx::RectF(1, 1, 100, 100))),
Pair(HashSkottieResourceId(kLottieDataWith2TextNode2),
SkottieTextPropertyValue("new-test-text-2",
gfx::RectF(2, 2, 2, 2)))));
gfx::RectF(2, 2, 200, 200)))));
// Check that we've actually drawn some text.
EXPECT_CALL(canvas, onDrawGlyphRunList).Times(AtLeast(1));
text_map = {
{HashSkottieResourceId(kLottieDataWith2TextNode2),
SkottieTextPropertyValue("new-test-text-2b", gfx::RectF(3, 3, 3, 3))}};
text_map = {{HashSkottieResourceId(kLottieDataWith2TextNode2),
SkottieTextPropertyValue("new-test-text-2b",
gfx::RectF(3, 3, 300, 300))}};
skottie->Draw(&canvas, /*t=*/0.1, SkRect::MakeWH(500, 500),
SkottieWrapper::FrameDataCallback(), SkottieColorMap(),
text_map);
@ -283,10 +287,26 @@ TEST(SkottieWrapperTest, SetsTextNodesWithDraw) {
UnorderedElementsAre(
Pair(HashSkottieResourceId(kLottieDataWith2TextNode1),
SkottieTextPropertyValue("new-test-text-1",
gfx::RectF(1, 1, 1, 1))),
gfx::RectF(1, 1, 100, 100))),
Pair(HashSkottieResourceId(kLottieDataWith2TextNode2),
SkottieTextPropertyValue("new-test-text-2b",
gfx::RectF(3, 3, 3, 3)))));
gfx::RectF(3, 3, 300, 300)))));
// Missing glyphs should not trigger a crash.
text_map = {
{HashSkottieResourceId(kLottieDataWith2TextNode1),
SkottieTextPropertyValue("hello 你好", gfx::RectF(4, 4, 400, 400))}};
skottie->Draw(&canvas, /*t=*/0.2, SkRect::MakeWH(500, 500),
SkottieWrapper::FrameDataCallback(), SkottieColorMap(),
text_map);
EXPECT_THAT(skottie->GetCurrentTextPropertyValues(),
UnorderedElementsAre(
Pair(HashSkottieResourceId(kLottieDataWith2TextNode1),
SkottieTextPropertyValue("hello 你好",
gfx::RectF(4, 4, 400, 400))),
Pair(HashSkottieResourceId(kLottieDataWith2TextNode2),
SkottieTextPropertyValue("new-test-text-2b",
gfx::RectF(3, 3, 300, 300)))));
}
TEST(SkottieWrapperTest, Marker) {

@ -76,6 +76,8 @@ class MockCanvas : public SkNoDrawCanvas {
MOCK_METHOD2(didTranslate, void(SkScalar, SkScalar));
MOCK_METHOD2(onDrawOval, void(const SkRect&, const SkPaint&));
MOCK_METHOD2(onCustomCallback, void(SkCanvas*, uint32_t));
MOCK_METHOD2(onDrawGlyphRunList,
void(const sktext::GlyphRunList&, const SkPaint&));
sk_sp<GrDirectContext> context_;
};

@ -596,7 +596,10 @@ component("skia") {
sources += skia_skresources_sources
sources += skia_sksg_sources
sources += skia_shaper_primitive_sources
defines += [ "SKOTTIE_TRIVIAL_FONTRUN_ITER" ]
defines += [
"SK_SHAPER_PRIMITIVE_AVAILABLE",
"SKOTTIE_TRIVIAL_FONTRUN_ITER",
]
}
}