Chromium Code Reviews| Index: src/core/SkPaint.cpp |
| diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp |
| index 8bd386a762a201d4e9adb4121a272e220ddbcc45..650bfa47eec17a2f1fdf8f938fb66351519770a5 100644 |
| --- a/src/core/SkPaint.cpp |
| +++ b/src/core/SkPaint.cpp |
| @@ -959,7 +959,7 @@ SkScalar SkPaint::getFontMetrics(FontMetrics* metrics, SkScalar zoom) const { |
| metrics = &storage; |
| } |
| - paint.descriptorProc(nullptr, FakeGamma::Off, zoomPtr, FontMetricsDescProc, metrics); |
| + paint.descriptorProc(nullptr, kNone_FontWeightFlag, zoomPtr, FontMetricsDescProc, metrics); |
| if (scale) { |
| metrics->fTop = SkScalarMul(metrics->fTop, scale); |
| @@ -1516,8 +1516,8 @@ void SkScalerContext::PostMakeRec(const SkPaint&, SkScalerContext::Rec* rec) { |
| break; |
| } |
| case SkMask::kBW_Format: |
| - // No need to differentiate gamma if we're BW |
| - rec->ignorePreBlend(); |
| + // No need to differentiate gamma or apply contrast if we're BW |
| + rec->ignorePreBlend(false); |
| break; |
| } |
| } |
| @@ -1551,14 +1551,14 @@ static void write_out_descriptor(SkDescriptor* desc, const SkScalerContext::Rec& |
| static size_t fill_out_rec(const SkPaint& paint, SkScalerContext::Rec* rec, |
| const SkSurfaceProps* surfaceProps, |
| - bool fakeGamma, |
| + bool fakeGamma, bool boostContrast, |
| const SkMatrix* deviceMatrix, |
| const SkPathEffect* pe, SkWriteBuffer* peBuffer, |
| const SkMaskFilter* mf, SkWriteBuffer* mfBuffer, |
| const SkRasterizer* ra, SkWriteBuffer* raBuffer) { |
| SkScalerContext::MakeRec(paint, surfaceProps, deviceMatrix, rec); |
| if (!fakeGamma) { |
| - rec->ignorePreBlend(); |
| + rec->ignorePreBlend(boostContrast); |
| } |
| int entryCount = 1; |
| @@ -1580,7 +1580,7 @@ static size_t fill_out_rec(const SkPaint& paint, SkScalerContext::Rec* rec, |
| The primary filter is blur, for which contrast makes no sense, |
| and for which the destination guess error is more visible. |
| Also, all existing users of blur have calibrated for linear. */ |
| - rec->ignorePreBlend(); |
| + rec->ignorePreBlend(false); |
| } |
| if (ra) { |
| raBuffer->writeFlattenable(ra); |
| @@ -1647,7 +1647,7 @@ static void test_desc(const SkScalerContext::Rec& rec, |
| /* see the note on ignoreGamma on descriptorProc */ |
| void SkPaint::getScalerContextDescriptor(SkAutoDescriptor* ad, |
| const SkSurfaceProps& surfaceProps, |
| - FakeGamma fakeGamma, |
| + uint32_t fontWeightFlags, |
| const SkMatrix* deviceMatrix) const { |
| SkScalerContext::Rec rec; |
| @@ -1656,9 +1656,10 @@ void SkPaint::getScalerContextDescriptor(SkAutoDescriptor* ad, |
| SkRasterizer* ra = this->getRasterizer(); |
| SkWriteBuffer peBuffer, mfBuffer, raBuffer; |
| - size_t descSize = fill_out_rec(*this, &rec, |
| - &surfaceProps, FakeGamma::On == fakeGamma, deviceMatrix, |
| - pe, &peBuffer, mf, &mfBuffer, ra, &raBuffer); |
| + size_t descSize = fill_out_rec(*this, &rec, &surfaceProps, |
| + SkToBool(fontWeightFlags & kFakeGamma_FontWeightFlag), |
| + SkToBool(fontWeightFlags & kBoostContrast_FontWeightFlag), |
| + deviceMatrix, pe, &peBuffer, mf, &mfBuffer, ra, &raBuffer); |
| ad->reset(descSize); |
| SkDescriptor* desc = ad->getDesc(); |
| @@ -1678,7 +1679,7 @@ void SkPaint::getScalerContextDescriptor(SkAutoDescriptor* ad, |
| * contrast = 0, luminanceColor = transparent black. |
| */ |
| void SkPaint::descriptorProc(const SkSurfaceProps* surfaceProps, |
| - FakeGamma fakeGamma, |
| + uint32_t fontWeightFlags, |
| const SkMatrix* deviceMatrix, |
| void (*proc)(SkTypeface*, const SkDescriptor*, void*), |
| void* context) const { |
| @@ -1689,9 +1690,10 @@ void SkPaint::descriptorProc(const SkSurfaceProps* surfaceProps, |
| SkRasterizer* ra = this->getRasterizer(); |
| SkWriteBuffer peBuffer, mfBuffer, raBuffer; |
| - size_t descSize = fill_out_rec(*this, &rec, |
| - surfaceProps, FakeGamma::On == fakeGamma, deviceMatrix, |
| - pe, &peBuffer, mf, &mfBuffer, ra, &raBuffer); |
| + size_t descSize = fill_out_rec(*this, &rec, surfaceProps, |
| + SkToBool(fontWeightFlags & kFakeGamma_FontWeightFlag), |
| + SkToBool(fontWeightFlags & kBoostContrast_FontWeightFlag), |
| + deviceMatrix, pe, &peBuffer, mf, &mfBuffer, ra, &raBuffer); |
| SkAutoDescriptor ad(descSize); |
| SkDescriptor* desc = ad.getDesc(); |
| @@ -1708,10 +1710,10 @@ void SkPaint::descriptorProc(const SkSurfaceProps* surfaceProps, |
| } |
| SkGlyphCache* SkPaint::detachCache(const SkSurfaceProps* surfaceProps, |
| - FakeGamma fakeGamma, |
| + uint32_t fontWeightFlags, |
| const SkMatrix* deviceMatrix) const { |
| SkGlyphCache* cache; |
| - this->descriptorProc(surfaceProps, fakeGamma, deviceMatrix, DetachDescProc, &cache); |
| + this->descriptorProc(surfaceProps, fontWeightFlags, deviceMatrix, DetachDescProc, &cache); |
| return cache; |
| } |
| @@ -2246,7 +2248,8 @@ SkTextBaseIter::SkTextBaseIter(const char text[], size_t length, |
| fPaint.setPathEffect(nullptr); |
| } |
| - fCache = fPaint.detachCache(nullptr, SkPaint::FakeGamma::On, nullptr); |
| + // SRGBTODO: Is this correct? |
| + fCache = fPaint.detachCache(nullptr, SkPaint::kFakeGammaAndContrast_FontWeightFlag, nullptr); |
|
Brian Osman
2016/04/07 17:08:32
It seems like the choice of flags here may be arbi
|
| SkPaint::Style style = SkPaint::kFill_Style; |
| sk_sp<SkPathEffect> pe; |