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

Unified Diff: src/gpu/text/GrAtlasTextContext.cpp

Issue 1866293003: Decouple contrast boost from fake gamma. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Improve ignorePreBlend API, add storage type to enum 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
« no previous file with comments | « src/gpu/text/GrAtlasTextContext.h ('k') | src/gpu/text/GrStencilAndCoverTextContext.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/text/GrAtlasTextContext.cpp
diff --git a/src/gpu/text/GrAtlasTextContext.cpp b/src/gpu/text/GrAtlasTextContext.cpp
index 574993a3ca683aec8a1994bc9e2b6ba6d5f5fe4a..6a1f7af4b3bd457d1abce556550cafc0368d7d2a 100644
--- a/src/gpu/text/GrAtlasTextContext.cpp
+++ b/src/gpu/text/GrAtlasTextContext.cpp
@@ -53,14 +53,15 @@ GrColor GrAtlasTextContext::ComputeCanonicalColor(const SkPaint& paint, bool lcd
return canonicalColor;
}
-SkPaint::FakeGamma GrAtlasTextContext::ComputeFakeGamma(GrDrawContext* dc, const GrPaint& grPaint) {
+uint32_t GrAtlasTextContext::ComputeScalerContextFlags(GrDrawContext* dc, const GrPaint& grPaint) {
// If we're rendering to an sRGB render target, and we aren't forcing sRGB blending off,
- // then we can disable the gamma hacks. Otherwise, leave them on:
+ // then we can disable the gamma hacks. Otherwise, leave them on. In either case, we still
+ // want the contrast boost:
if (GrPixelConfigIsSRGB(dc->accessRenderTarget()->config()) &&
!grPaint.getDisableOutputConversionToSRGB()) {
- return SkPaint::FakeGamma::Off;
+ return SkPaint::kBoostContrast_ScalerContextFlag;
} else {
- return SkPaint::FakeGamma::On;
+ return SkPaint::kFakeGammaAndBoostContrast_ScalerContextFlags;
}
}
@@ -127,7 +128,7 @@ void GrAtlasTextContext::drawTextBlob(GrContext* context, GrDrawContext* dc,
return;
}
- SkPaint::FakeGamma fakeGamma = ComputeFakeGamma(dc, grPaint);
+ uint32_t scalerContextFlags = ComputeScalerContextFlags(dc, grPaint);
if (cacheBlob) {
if (cacheBlob->mustRegenerate(skPaint, grPaint.getColor(), blurRec, viewMatrix, x, y)) {
@@ -138,7 +139,7 @@ void GrAtlasTextContext::drawTextBlob(GrContext* context, GrDrawContext* dc,
cacheBlob.reset(SkRef(cache->createCachedBlob(blob, key, blurRec, skPaint)));
RegenerateTextBlob(cacheBlob, context->getBatchFontCache(),
*context->caps()->shaderCaps(), skPaint, grPaint.getColor(),
- fakeGamma, viewMatrix, props,
+ scalerContextFlags, viewMatrix, props,
blob, x, y, drawFilter);
} else {
cache->makeMRU(cacheBlob);
@@ -151,7 +152,7 @@ void GrAtlasTextContext::drawTextBlob(GrContext* context, GrDrawContext* dc,
sanityBlob->setupKey(key, blurRec, skPaint);
RegenerateTextBlob(sanityBlob, context->getBatchFontCache(),
*context->caps()->shaderCaps(), skPaint,
- grPaint.getColor(), fakeGamma, viewMatrix, props,
+ grPaint.getColor(), scalerContextFlags, viewMatrix, props,
blob, x, y, drawFilter);
GrAtlasTextBlob::AssertEqual(*sanityBlob, *cacheBlob);
}
@@ -164,7 +165,7 @@ void GrAtlasTextContext::drawTextBlob(GrContext* context, GrDrawContext* dc,
}
RegenerateTextBlob(cacheBlob, context->getBatchFontCache(),
*context->caps()->shaderCaps(), skPaint, grPaint.getColor(),
- fakeGamma, viewMatrix, props,
+ scalerContextFlags, viewMatrix, props,
blob, x, y, drawFilter);
}
@@ -176,7 +177,7 @@ void GrAtlasTextContext::RegenerateTextBlob(GrAtlasTextBlob* cacheBlob,
GrBatchFontCache* fontCache,
const GrShaderCaps& shaderCaps,
const SkPaint& skPaint, GrColor color,
- SkPaint::FakeGamma fakeGamma,
+ uint32_t scalerContextFlags,
const SkMatrix& viewMatrix,
const SkSurfaceProps& props,
const SkTextBlob* blob, SkScalar x, SkScalar y,
@@ -208,25 +209,25 @@ void GrAtlasTextContext::RegenerateTextBlob(GrAtlasTextBlob* cacheBlob,
switch (it.positioning()) {
case SkTextBlob::kDefault_Positioning: {
GrTextUtils::DrawDFText(cacheBlob, run, fontCache,
- props, runPaint, color, fakeGamma, viewMatrix,
- (const char *)it.glyphs(), textLen,
+ props, runPaint, color, scalerContextFlags,
+ viewMatrix, (const char *)it.glyphs(), textLen,
x + offset.x(), y + offset.y());
break;
}
case SkTextBlob::kHorizontal_Positioning: {
SkPoint dfOffset = SkPoint::Make(x, y + offset.y());
GrTextUtils::DrawDFPosText(cacheBlob, run, fontCache,
- props, runPaint, color, fakeGamma, viewMatrix,
- (const char*)it.glyphs(), textLen, it.pos(),
- 1, dfOffset);
+ props, runPaint, color, scalerContextFlags,
+ viewMatrix, (const char*)it.glyphs(), textLen,
+ it.pos(), 1, dfOffset);
break;
}
case SkTextBlob::kFull_Positioning: {
SkPoint dfOffset = SkPoint::Make(x, y);
GrTextUtils::DrawDFPosText(cacheBlob, run, fontCache,
- props, runPaint, color, fakeGamma, viewMatrix,
- (const char*)it.glyphs(), textLen, it.pos(),
- 2, dfOffset);
+ props, runPaint, color, scalerContextFlags,
+ viewMatrix, (const char*)it.glyphs(), textLen,
+ it.pos(), 2, dfOffset);
break;
}
}
@@ -236,21 +237,21 @@ void GrAtlasTextContext::RegenerateTextBlob(GrAtlasTextBlob* cacheBlob,
switch (it.positioning()) {
case SkTextBlob::kDefault_Positioning:
GrTextUtils::DrawBmpText(cacheBlob, run, fontCache,
- props, runPaint, color, fakeGamma, viewMatrix,
- (const char *)it.glyphs(), textLen,
+ props, runPaint, color, scalerContextFlags,
+ viewMatrix, (const char *)it.glyphs(), textLen,
x + offset.x(), y + offset.y());
break;
case SkTextBlob::kHorizontal_Positioning:
GrTextUtils::DrawBmpPosText(cacheBlob, run, fontCache,
- props, runPaint, color, fakeGamma, viewMatrix,
- (const char*)it.glyphs(), textLen, it.pos(), 1,
- SkPoint::Make(x, y + offset.y()));
+ props, runPaint, color, scalerContextFlags,
+ viewMatrix, (const char*)it.glyphs(), textLen,
+ it.pos(), 1, SkPoint::Make(x, y + offset.y()));
break;
case SkTextBlob::kFull_Positioning:
GrTextUtils::DrawBmpPosText(cacheBlob, run, fontCache,
- props, runPaint, color, fakeGamma, viewMatrix,
- (const char*)it.glyphs(), textLen, it.pos(), 2,
- SkPoint::Make(x, y));
+ props, runPaint, color, scalerContextFlags,
+ viewMatrix, (const char*)it.glyphs(), textLen,
+ it.pos(), 2, SkPoint::Make(x, y));
break;
}
}
@@ -268,7 +269,7 @@ GrAtlasTextContext::CreateDrawTextBlob(GrTextBlobCache* blobCache,
const GrShaderCaps& shaderCaps,
const GrPaint& paint,
const SkPaint& skPaint,
- SkPaint::FakeGamma fakeGamma,
+ uint32_t scalerContextFlags,
const SkMatrix& viewMatrix,
const SkSurfaceProps& props,
const char text[], size_t byteLength,
@@ -279,12 +280,11 @@ GrAtlasTextContext::CreateDrawTextBlob(GrTextBlobCache* blobCache,
blob->initThrowawayBlob(viewMatrix, x, y);
if (GrTextUtils::CanDrawAsDistanceFields(skPaint, viewMatrix, props, shaderCaps)) {
- GrTextUtils::DrawDFText(blob, 0, fontCache, props,
- skPaint, paint.getColor(), fakeGamma, viewMatrix, text,
- byteLength, x, y);
+ GrTextUtils::DrawDFText(blob, 0, fontCache, props, skPaint, paint.getColor(),
+ scalerContextFlags, viewMatrix, text, byteLength, x, y);
} else {
- GrTextUtils::DrawBmpText(blob, 0, fontCache, props, skPaint,
- paint.getColor(), fakeGamma, viewMatrix, text, byteLength, x, y);
+ GrTextUtils::DrawBmpText(blob, 0, fontCache, props, skPaint, paint.getColor(),
+ scalerContextFlags, viewMatrix, text, byteLength, x, y);
}
return blob;
}
@@ -292,7 +292,7 @@ GrAtlasTextContext::CreateDrawTextBlob(GrTextBlobCache* blobCache,
inline GrAtlasTextBlob*
GrAtlasTextContext::CreateDrawPosTextBlob(GrTextBlobCache* blobCache, GrBatchFontCache* fontCache,
const GrShaderCaps& shaderCaps, const GrPaint& paint,
- const SkPaint& skPaint, SkPaint::FakeGamma fakeGamma,
+ const SkPaint& skPaint, uint32_t scalerContextFlags,
const SkMatrix& viewMatrix, const SkSurfaceProps& props,
const char text[], size_t byteLength,
const SkScalar pos[], int scalarsPerPosition,
@@ -304,11 +304,11 @@ GrAtlasTextContext::CreateDrawPosTextBlob(GrTextBlobCache* blobCache, GrBatchFon
if (GrTextUtils::CanDrawAsDistanceFields(skPaint, viewMatrix, props, shaderCaps)) {
GrTextUtils::DrawDFPosText(blob, 0, fontCache, props,
- skPaint, paint.getColor(), fakeGamma, viewMatrix, text,
+ skPaint, paint.getColor(), scalerContextFlags, viewMatrix, text,
byteLength, pos, scalarsPerPosition, offset);
} else {
GrTextUtils::DrawBmpPosText(blob, 0, fontCache, props, skPaint,
- paint.getColor(), fakeGamma, viewMatrix, text,
+ paint.getColor(), scalerContextFlags, viewMatrix, text,
byteLength, pos, scalarsPerPosition, offset);
}
return blob;
@@ -329,7 +329,7 @@ void GrAtlasTextContext::drawText(GrContext* context,
CreateDrawTextBlob(context->getTextBlobCache(), context->getBatchFontCache(),
*context->caps()->shaderCaps(),
paint, skPaint,
- ComputeFakeGamma(dc, paint),
+ ComputeScalerContextFlags(dc, paint),
viewMatrix, props,
text, byteLength, x, y));
blob->flushThrowaway(context, dc, props, fDistanceAdjustTable, skPaint, paint,
@@ -359,7 +359,7 @@ void GrAtlasTextContext::drawPosText(GrContext* context,
context->getBatchFontCache(),
*context->caps()->shaderCaps(),
paint, skPaint,
- ComputeFakeGamma(dc, paint),
+ ComputeScalerContextFlags(dc, paint),
viewMatrix, props,
text, byteLength,
pos, scalarsPerPosition,
@@ -423,7 +423,7 @@ DRAW_BATCH_TEST_DEFINE(TextBlobBatch) {
GrAtlasTextContext::CreateDrawTextBlob(context->getTextBlobCache(),
context->getBatchFontCache(),
*context->caps()->shaderCaps(), grPaint, skPaint,
- GrAtlasTextContext::kTextBlobBatchFakeGamma,
+ GrAtlasTextContext::kTextBlobBatchScalerContextFlags,
viewMatrix,
gSurfaceProps, text,
static_cast<size_t>(textLen), x, y));
« no previous file with comments | « src/gpu/text/GrAtlasTextContext.h ('k') | src/gpu/text/GrStencilAndCoverTextContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698