aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Ben Wagner <bungeman@google.com>2018-05-04 10:20:57 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-05-04 18:40:03 +0000
commitbba38ee80e4140908ac0c351dc18a2f1224e5f0a (patch)
tree29898889506d1c4784ae59732ce5403e0d8d114a /src
parent87ccf33f157ad4a6d83ba079e43192b45d39cb6d (diff)
Avoid drawing BW clipped color glyphs many times.
Prior to this change if a color glyph is drawn through the raster device with an aliased clip the glyph is drawn once for each rectangular region in the aliased clip. In addition, even when the glyph was not a color glyph in this situation, the mask was checked for being a color glyph once for each rectangular region of the aliased clip. This change hoists the test for the color format out of the loop to ensure that the mask format is checked once and the mask is drawn once. This issue was discovered by rotating the coloremoji_blendmodes gm. Change-Id: I18b6b546356780e0b00948fff7b65783219f5c92 Reviewed-on: https://skia-review.googlesource.com/125868 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Ben Wagner <bungeman@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/core/SkDraw.cpp37
1 files changed, 21 insertions, 16 deletions
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp
index 0526f76f8e..34f5da5cfe 100644
--- a/src/core/SkDraw.cpp
+++ b/src/core/SkDraw.cpp
@@ -1441,11 +1441,15 @@ public:
SkRegion::Cliperator clipper(*fClip, mask.fBounds);
if (!clipper.done() && this->getImageData(glyph, &mask)) {
- const SkIRect& cr = clipper.rect();
- do {
- this->blitMask(mask, cr);
- clipper.next();
- } while (!clipper.done());
+ if (SkMask::kARGB32_Format == mask.fFormat) {
+ this->blitARGB32Mask(mask);
+ } else {
+ const SkIRect& cr = clipper.rect();
+ do {
+ fBlitter->blitMask(mask, cr);
+ clipper.next();
+ } while (!clipper.done());
+ }
}
} else {
SkIRect storage;
@@ -1460,7 +1464,11 @@ public:
}
if (this->getImageData(glyph, &mask)) {
- this->blitMask(mask, *bounds);
+ if (SkMask::kARGB32_Format == mask.fFormat) {
+ this->blitARGB32Mask(mask);
+ } else {
+ fBlitter->blitMask(mask, *bounds);
+ }
}
}
}
@@ -1491,17 +1499,14 @@ private:
return true;
}
- void blitMask(const SkMask& mask, const SkIRect& clip) const {
- if (SkMask::kARGB32_Format == mask.fFormat) {
- SkBitmap bm;
- bm.installPixels(
- SkImageInfo::MakeN32Premul(mask.fBounds.width(), mask.fBounds.height()),
- (SkPMColor*)mask.fImage, mask.fRowBytes);
+ void blitARGB32Mask(const SkMask& mask) const {
+ SkASSERT(SkMask::kARGB32_Format == mask.fFormat);
+ SkBitmap bm;
+ bm.installPixels(
+ SkImageInfo::MakeN32Premul(mask.fBounds.width(), mask.fBounds.height()),
+ (SkPMColor*)mask.fImage, mask.fRowBytes);
- fDraw.drawSprite(bm, mask.fBounds.x(), mask.fBounds.y(), fPaint);
- } else {
- fBlitter->blitMask(mask, clip);
- }
+ fDraw.drawSprite(bm, mask.fBounds.x(), mask.fBounds.y(), fPaint);
}
const bool fUseRegionToDraw;