diff options
author | 2016-04-12 12:48:21 -0700 | |
---|---|---|
committer | 2016-04-12 12:48:21 -0700 | |
commit | 0586f5cc9713268238394411a5daa2c7758b092b (patch) | |
tree | 74d7c1a3786a306dab0dd3fdfe8e1bcb25f9f57f /src/gpu/text/GrAtlasTextBlob.cpp | |
parent | 134ff5c9cf99e1a930cb1b77bf8fb2b7b2c31d31 (diff) |
sRGB support for distance field text.
Add a second distance field adjust table that only applies contrast,
not fake-gamma correction. Store a flag in the batch at creation time,
using the same logic we apply elsewhere (render target format, plus
paint flags).
That gets us close, but not as good as bitmap text. The final step is
to use a linear step function (rather than smoothstep) to map distance
to coverage, when we have sRGB output. Smoothstep's nonlinear response
is actually doing some fake-gamma, so it ends up over-correcting when
the output is already gamma-correct.
Results are now very close between L32 (old table, smoothstep) and S32
(contrast-only table, linstep).
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1885613002
Review URL: https://codereview.chromium.org/1885613002
Diffstat (limited to 'src/gpu/text/GrAtlasTextBlob.cpp')
-rw-r--r-- | src/gpu/text/GrAtlasTextBlob.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/gpu/text/GrAtlasTextBlob.cpp b/src/gpu/text/GrAtlasTextBlob.cpp index afbff46994..60f905df5f 100644 --- a/src/gpu/text/GrAtlasTextBlob.cpp +++ b/src/gpu/text/GrAtlasTextBlob.cpp @@ -257,6 +257,7 @@ inline GrDrawBatch* GrAtlasTextBlob::createBatch( GrColor color, const SkPaint& skPaint, const SkSurfaceProps& props, const GrDistanceFieldAdjustTable* distanceAdjustTable, + bool useSRGBDistanceTable, GrBatchFontCache* cache) { GrMaskFormat format = info.maskFormat(); GrColor subRunColor; @@ -278,8 +279,8 @@ inline GrDrawBatch* GrAtlasTextBlob::createBatch( } bool useBGR = SkPixelGeometryIsBGR(props.pixelGeometry()); batch = GrAtlasTextBatch::CreateDistanceField(glyphCount, cache, - distanceAdjustTable, filteredColor, - info.hasUseLCDText(), useBGR); + distanceAdjustTable, useSRGBDistanceTable, + filteredColor, info.hasUseLCDText(), useBGR); } else { batch = GrAtlasTextBatch::CreateBitmap(format, glyphCount, cache); } @@ -310,10 +311,14 @@ void GrAtlasTextBlob::flushRun(GrDrawContext* dc, GrPipelineBuilder* pipelineBui continue; } + bool useSRGBDistanceTable = GrPixelConfigIsSRGB(dc->accessRenderTarget()->config()) && + !pipelineBuilder->getDisableOutputConversionToSRGB(); + SkAutoTUnref<GrDrawBatch> batch(this->createBatch(info, glyphCount, run, subRun, viewMatrix, x, y, color, skPaint, props, - distanceAdjustTable, cache)); + distanceAdjustTable, useSRGBDistanceTable, + cache)); dc->drawBatch(pipelineBuilder, batch); } } @@ -463,7 +468,7 @@ GrDrawBatch* GrAtlasTextBlob::test_createBatch( GrBatchFontCache* cache) { const GrAtlasTextBlob::Run::SubRunInfo& info = fRuns[run].fSubRunInfo[subRun]; return this->createBatch(info, glyphCount, run, subRun, viewMatrix, x, y, color, skPaint, - props, distanceAdjustTable, cache); + props, distanceAdjustTable, false, cache); } void GrAtlasTextBlob::AssertEqual(const GrAtlasTextBlob& l, const GrAtlasTextBlob& r) { |