aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkScalerContext.cpp
diff options
context:
space:
mode:
authorGravatar Ben Wagner <bungeman@google.com>2018-04-25 15:27:40 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-04-27 21:56:38 +0000
commit275df2e8730676c1e0ccc715a98868c6421bc5f4 (patch)
tree0aef3dbc8f2c117d879a5da20a27141f151f578e /src/core/SkScalerContext.cpp
parent34a388edbd277cf23d55627695b4bb6c46230d22 (diff)
Just pass color glyph masks to filters.
Allow the filters to try to apply themselves to the color mask. Most mask filters will just return false, but allow them the opprotunity. This removes the behavior of trying to create a mask from the color mask. This updates the blur mask filter to handle kARGB32_Format directly by using just the alpha (which mirrors current behavior). Change-Id: I15eb736060ecf9b24aca874758c167b74d9ebc22 Reviewed-on: https://skia-review.googlesource.com/124185 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Ben Wagner <bungeman@google.com>
Diffstat (limited to 'src/core/SkScalerContext.cpp')
-rw-r--r--src/core/SkScalerContext.cpp36
1 files changed, 2 insertions, 34 deletions
diff --git a/src/core/SkScalerContext.cpp b/src/core/SkScalerContext.cpp
index 68eb5688f7..b8cd107bd3 100644
--- a/src/core/SkScalerContext.cpp
+++ b/src/core/SkScalerContext.cpp
@@ -130,7 +130,7 @@ void SkScalerContext::getMetrics(SkGlyph* glyph) {
}
// If we are going to create the mask, then we cannot keep the color
- if ((generatingImageFromPath || fMaskFilter) && SkMask::kARGB32_Format == glyph->fMaskFormat) {
+ if (generatingImageFromPath && SkMask::kARGB32_Format == glyph->fMaskFormat) {
glyph->fMaskFormat = SkMask::kA8_Format;
}
@@ -382,26 +382,6 @@ static void generateMask(const SkMask& mask, const SkPath& path,
}
}
-static void extract_alpha(const SkMask& dst,
- const SkPMColor* srcRow, size_t srcRB) {
- int width = dst.fBounds.width();
- int height = dst.fBounds.height();
- int dstRB = dst.fRowBytes;
- uint8_t* dstRow = dst.fImage;
-
- for (int y = 0; y < height; ++y) {
- for (int x = 0; x < width; ++x) {
- dstRow[x] = SkGetPackedA32(srcRow[x]);
- }
- // zero any padding on each row
- for (int x = width; x < dstRB; ++x) {
- dstRow[x] = 0;
- }
- dstRow += dstRB;
- srcRow = (const SkPMColor*)((const char*)srcRow + srcRB);
- }
-}
-
void SkScalerContext::getImage(const SkGlyph& origGlyph) {
const SkGlyph* glyph = &origGlyph;
SkGlyph tmpGlyph;
@@ -456,19 +436,7 @@ void SkScalerContext::getImage(const SkGlyph& origGlyph) {
// the src glyph image shouldn't be 3D
SkASSERT(SkMask::k3D_Format != glyph->fMaskFormat);
- SkAutoSMalloc<32*32> a8storage;
glyph->toMask(&srcM);
- if (SkMask::kARGB32_Format == srcM.fFormat) {
- // now we need to extract the alpha-channel from the glyph's image
- // and copy it into a temp buffer, and then point srcM at that temp.
- srcM.fFormat = SkMask::kA8_Format;
- srcM.fRowBytes = SkAlign4(srcM.fBounds.width());
- size_t size = srcM.computeImageSize();
- a8storage.reset(size);
- srcM.fImage = (uint8_t*)a8storage.get();
- extract_alpha(srcM,
- (const SkPMColor*)glyph->fImage, glyph->rowBytes());
- }
fRec.getMatrixFrom2x2(&matrix);
@@ -496,7 +464,7 @@ void SkScalerContext::getImage(const SkGlyph& origGlyph) {
}
SkMask::FreeImage(dstM.fImage);
- if (fPreBlendForFilter.isApplicable()) {
+ if (SkMask::kA8_Format == dstM.fFormat && fPreBlendForFilter.isApplicable()) {
applyLUTToA8Mask(srcM, fPreBlendForFilter.fG);
}
}