Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Unified Diff: src/core/SkPaint.cpp

Issue 1866293003: Decouple contrast boost from fake gamma. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Missed one. Finish renaming to ScalerContextFlags Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/core/SkPaint.cpp
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp
index 8bd386a762a201d4e9adb4121a272e220ddbcc45..d05742df2b1b48ce6383007507e71a774540fe2c 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_ScalerContextFlags, 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);
bungeman-skia 2016/04/07 20:15:45 At the call site it's annoying that the bool param
Brian Osman 2016/04/07 21:23:46 Done. (Yeah, I like the broken-out API better).
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 scalerContextFlags,
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(scalerContextFlags & kFakeGamma_ScalerContextFlag),
+ SkToBool(scalerContextFlags & kBoostContrast_ScalerContextFlag),
+ 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 scalerContextFlags,
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(scalerContextFlags & kFakeGamma_ScalerContextFlag),
+ SkToBool(scalerContextFlags & kBoostContrast_ScalerContextFlag),
+ 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 scalerContextFlags,
const SkMatrix* deviceMatrix) const {
SkGlyphCache* cache;
- this->descriptorProc(surfaceProps, fakeGamma, deviceMatrix, DetachDescProc, &cache);
+ this->descriptorProc(surfaceProps, scalerContextFlags, deviceMatrix, DetachDescProc, &cache);
return cache;
}
@@ -2246,7 +2248,9 @@ 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::kFakeGammaAndBoostContrast_ScalerContextFlags,
+ nullptr);
SkPaint::Style style = SkPaint::kFill_Style;
sk_sp<SkPathEffect> pe;

Powered by Google App Engine
This is Rietveld 408576698