Check rejects exist before attempting drawables.

Change-Id: I64b8a1e9da3351080bcc13eb490ec534c9d21eed
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/505797
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
This commit is contained in:
Ben Wagner 2022-02-08 14:00:47 -05:00
parent 61e7b64962
commit 654f09a5ad

View File

@ -147,21 +147,23 @@ void SkGlyphRunListPainter::drawForBitmapDevice(
}
}
fAccepted.startSource(fRejected.source());
strike->prepareForDrawableDrawing(&fAccepted, &fRejected);
fRejected.flipRejectsToSource();
if (!fRejected.source().empty()) {
fAccepted.startSource(fRejected.source());
strike->prepareForDrawableDrawing(&fAccepted, &fRejected);
fRejected.flipRejectsToSource();
for (auto [variant, pos] : fAccepted.accepted()) {
SkDrawable* drawable = variant.drawable();
SkMatrix m;
SkPoint translate = drawOrigin + pos;
m.setScaleTranslate(strikeToSourceScale, strikeToSourceScale,
translate.x(), translate.y());
SkAutoCanvasRestore acr(canvas, false);
SkRect drawableBounds = drawable->getBounds();
m.mapRect(&drawableBounds);
canvas->saveLayer(&drawableBounds, &paint);
drawable->draw(canvas, &m);
for (auto [variant, pos] : fAccepted.accepted()) {
SkDrawable* drawable = variant.drawable();
SkMatrix m;
SkPoint translate = drawOrigin + pos;
m.setScaleTranslate(strikeToSourceScale, strikeToSourceScale,
translate.x(), translate.y());
SkAutoCanvasRestore acr(canvas, false);
SkRect drawableBounds = drawable->getBounds();
m.mapRect(&drawableBounds);
canvas->saveLayer(&drawableBounds, &paint);
drawable->draw(canvas, &m);
}
}
}
if (!fRejected.source().empty() && !deviceMatrix.hasPerspective()) {