aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/batches
diff options
context:
space:
mode:
authorGravatar brianosman <brianosman@google.com>2016-04-13 13:56:21 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-04-13 13:56:21 -0700
commit0e3c55431b463b5575983c0c875909e08a3562bf (patch)
tree4aa76104cefbbbf35f6ba57a90bb0824ce59ed5e /src/gpu/batches
parentd3b63d3244add67b1d087123f36a418f7fd7ec0f (diff)
Tweak distance field path renderer behavior in gamma-correct mode to match
recent changes to text rendering. Uses linear coverage falloff. Produces results that are perceptually more similar to L32 (raster and gpu). Smoothstep + sRGB was too soft. Plumb the gamma-correctness via DrawPathArgs, which also paves the way for other path rendering implementations to easily make decisions about rendering technique based on that flag. Fix a few typos and formatting issues from my most recent change. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1889453002 Review URL: https://codereview.chromium.org/1889453002
Diffstat (limited to 'src/gpu/batches')
-rw-r--r--src/gpu/batches/GrAADistanceFieldPathRenderer.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp b/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp
index 35d1f61977..655a77127e 100644
--- a/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp
+++ b/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp
@@ -148,8 +148,10 @@ public:
};
static GrDrawBatch* Create(const Geometry& geometry, const SkMatrix& viewMatrix,
- GrBatchAtlas* atlas, PathCache* pathCache, PathDataList* pathList) {
- return new AADistanceFieldPathBatch(geometry, viewMatrix, atlas, pathCache, pathList);
+ GrBatchAtlas* atlas, PathCache* pathCache, PathDataList* pathList,
+ bool gammaCorrect) {
+ return new AADistanceFieldPathBatch(geometry, viewMatrix, atlas, pathCache, pathList,
+ gammaCorrect);
}
const char* name() const override { return "AADistanceFieldPathBatch"; }
@@ -196,6 +198,7 @@ private:
uint32_t flags = 0;
flags |= ctm.isScaleTranslate() ? kScaleOnly_DistanceFieldEffectFlag : 0;
flags |= ctm.isSimilarity() ? kSimilarity_DistanceFieldEffectFlag : 0;
+ flags |= fGammaCorrect ? kGammaCorrect_DistanceFieldEffectFlag : 0;
GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kBilerp_FilterMode);
@@ -296,7 +299,8 @@ private:
AADistanceFieldPathBatch(const Geometry& geometry,
const SkMatrix& viewMatrix,
GrBatchAtlas* atlas,
- PathCache* pathCache, PathDataList* pathList)
+ PathCache* pathCache, PathDataList* pathList,
+ bool gammaCorrect)
: INHERITED(ClassID()) {
fBatch.fViewMatrix = viewMatrix;
fGeoData.push_back(geometry);
@@ -304,6 +308,7 @@ private:
fAtlas = atlas;
fPathCache = pathCache;
fPathList = pathList;
+ fGammaCorrect = gammaCorrect;
// Compute bounds
fBounds = geometry.fPath.getBounds();
@@ -524,6 +529,7 @@ private:
GrBatchAtlas* fAtlas;
PathCache* fPathCache;
PathDataList* fPathList;
+ bool fGammaCorrect;
typedef GrVertexBatch INHERITED;
};
@@ -562,7 +568,8 @@ bool GrAADistanceFieldPathRenderer::onDrawPath(const DrawPathArgs& args) {
SkAutoTUnref<GrDrawBatch> batch(AADistanceFieldPathBatch::Create(geometry,
*args.fViewMatrix, fAtlas,
- &fPathCache, &fPathList));
+ &fPathCache, &fPathList,
+ args.fGammaCorrect));
args.fTarget->drawBatch(*args.fPipelineBuilder, batch);
return true;
@@ -630,6 +637,7 @@ DRAW_BATCH_TEST_DEFINE(AADistanceFieldPathBatch) {
SkMatrix viewMatrix = GrTest::TestMatrix(random);
GrColor color = GrRandomColor(random);
+ bool gammaCorrect = random->nextBool();
AADistanceFieldPathBatch::Geometry geometry(GrTest::TestStrokeRec(random));
geometry.fColor = color;
@@ -640,7 +648,8 @@ DRAW_BATCH_TEST_DEFINE(AADistanceFieldPathBatch) {
return AADistanceFieldPathBatch::Create(geometry, viewMatrix,
gTestStruct.fAtlas,
&gTestStruct.fPathCache,
- &gTestStruct.fPathList);
+ &gTestStruct.fPathList,
+ gammaCorrect);
}
#endif