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

Side by Side Diff: src/gpu/GrAADistanceFieldPathRenderer.cpp

Issue 783763002: Initial CL to move color / coverage off of drawstate (Closed) Base URL: https://skia.googlesource.com/skia.git@no-static-gp
Patch Set: bug fix Created 6 years 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 unified diff | Download patch
« no previous file with comments | « src/gpu/GrAADistanceFieldPathRenderer.h ('k') | src/gpu/GrAAHairLinePathRenderer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2014 Google Inc. 3 * Copyright 2014 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "GrAADistanceFieldPathRenderer.h" 9 #include "GrAADistanceFieldPathRenderer.h"
10 10
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 const GrDrawState*, 98 const GrDrawState*,
99 const SkPath&, 99 const SkPath&,
100 const SkStrokeRec&) const { 100 const SkStrokeRec&) const {
101 return GrPathRenderer::kNoSupport_StencilSupport; 101 return GrPathRenderer::kNoSupport_StencilSupport;
102 } 102 }
103 103
104 //////////////////////////////////////////////////////////////////////////////// 104 ////////////////////////////////////////////////////////////////////////////////
105 105
106 bool GrAADistanceFieldPathRenderer::onDrawPath(GrDrawTarget* target, 106 bool GrAADistanceFieldPathRenderer::onDrawPath(GrDrawTarget* target,
107 GrDrawState* drawState, 107 GrDrawState* drawState,
108 GrColor color,
108 const SkPath& path, 109 const SkPath& path,
109 const SkStrokeRec& stroke, 110 const SkStrokeRec& stroke,
110 bool antiAlias) { 111 bool antiAlias) {
111 // we've already bailed on inverse filled paths, so this is safe 112 // we've already bailed on inverse filled paths, so this is safe
112 if (path.isEmpty()) { 113 if (path.isEmpty()) {
113 return true; 114 return true;
114 } 115 }
115 116
116 SkASSERT(fContext); 117 SkASSERT(fContext);
117 118
(...skipping 18 matching lines...) Expand all
136 PathData* pathData = fPathCache.find(key); 137 PathData* pathData = fPathCache.find(key);
137 if (NULL == pathData) { 138 if (NULL == pathData) {
138 SkScalar scale = desiredDimension/maxDim; 139 SkScalar scale = desiredDimension/maxDim;
139 pathData = this->addPathToAtlas(path, stroke, antiAlias, desiredDimensio n, scale); 140 pathData = this->addPathToAtlas(path, stroke, antiAlias, desiredDimensio n, scale);
140 if (NULL == pathData) { 141 if (NULL == pathData) {
141 return false; 142 return false;
142 } 143 }
143 } 144 }
144 145
145 // use signed distance field to render 146 // use signed distance field to render
146 return this->internalDrawPath(target, drawState, path, pathData); 147 return this->internalDrawPath(target, drawState, color, path, pathData);
147 } 148 }
148 149
149 // padding around path bounds to allow for antialiased pixels 150 // padding around path bounds to allow for antialiased pixels
150 const SkScalar kAntiAliasPad = 1.0f; 151 const SkScalar kAntiAliasPad = 1.0f;
151 152
152 GrAADistanceFieldPathRenderer::PathData* GrAADistanceFieldPathRenderer::addPathT oAtlas( 153 GrAADistanceFieldPathRenderer::PathData* GrAADistanceFieldPathRenderer::addPathT oAtlas(
153 const Sk Path& path, 154 const Sk Path& path,
154 const Sk StrokeRec& stroke, 155 const Sk StrokeRec& stroke,
155 bool ant iAlias, 156 bool ant iAlias,
156 uint32_t dimension, 157 uint32_t dimension,
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 } 300 }
300 301
301 // tell the atlas to free the plot 302 // tell the atlas to free the plot
302 GrAtlas::RemovePlot(&fPlotUsage, plot); 303 GrAtlas::RemovePlot(&fPlotUsage, plot);
303 304
304 return true; 305 return true;
305 } 306 }
306 307
307 bool GrAADistanceFieldPathRenderer::internalDrawPath(GrDrawTarget* target, 308 bool GrAADistanceFieldPathRenderer::internalDrawPath(GrDrawTarget* target,
308 GrDrawState* drawState, 309 GrDrawState* drawState,
310 GrColor color,
309 const SkPath& path, 311 const SkPath& path,
310 const PathData* pathData) { 312 const PathData* pathData) {
311 GrTexture* texture = fAtlas->getTexture(); 313 GrTexture* texture = fAtlas->getTexture();
312 GrDrawState::AutoRestoreEffects are(drawState); 314 GrDrawState::AutoRestoreEffects are(drawState);
313 315
314 SkASSERT(pathData->fPlot); 316 SkASSERT(pathData->fPlot);
315 GrDrawTarget::DrawToken drawToken = target->getCurrentDrawToken(); 317 GrDrawTarget::DrawToken drawToken = target->getCurrentDrawToken();
316 pathData->fPlot->setDrawToken(drawToken); 318 pathData->fPlot->setDrawToken(drawToken);
317 319
318 // set up any flags 320 // set up any flags
319 uint32_t flags = 0; 321 uint32_t flags = 0;
320 const SkMatrix& vm = drawState->getViewMatrix(); 322 const SkMatrix& vm = drawState->getViewMatrix();
321 flags |= vm.isSimilarity() ? kSimilarity_DistanceFieldEffectFlag : 0; 323 flags |= vm.isSimilarity() ? kSimilarity_DistanceFieldEffectFlag : 0;
322 324
323 GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kBilerp_ FilterMode); 325 GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kBilerp_ FilterMode);
324 if (flags != fEffectFlags) { 326 if (flags != fEffectFlags || fCachedGeometryProcessor->getColor() != color) {
325 fCachedGeometryProcessor.reset(GrDistanceFieldNoGammaTextureEffect::Crea te(texture, 327 fCachedGeometryProcessor.reset(GrDistanceFieldNoGammaTextureEffect::Crea te(color,
328 texture,
326 params, 329 params,
327 flags)); 330 flags));
328 fEffectFlags = flags; 331 fEffectFlags = flags;
329 } 332 }
330 drawState->setGeometryProcessor(fCachedGeometryProcessor.get()); 333 drawState->setGeometryProcessor(fCachedGeometryProcessor.get());
331 334
332 void* vertices = NULL; 335 void* vertices = NULL;
333 bool success = target->reserveVertexAndIndexSpace(4, 336 bool success = target->reserveVertexAndIndexSpace(4,
334 fCachedGeometryProcessor-> getVertexStride(), 337 fCachedGeometryProcessor-> getVertexStride(),
335 0, &vertices, NULL); 338 0, &vertices, NULL);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 vertSize); 371 vertSize);
369 372
370 vm.mapRect(&r); 373 vm.mapRect(&r);
371 target->setIndexSourceToBuffer(fContext->getQuadIndexBuffer()); 374 target->setIndexSourceToBuffer(fContext->getQuadIndexBuffer());
372 target->drawIndexedInstances(drawState, kTriangles_GrPrimitiveType, 1, 4, 6, &r); 375 target->drawIndexedInstances(drawState, kTriangles_GrPrimitiveType, 1, 4, 6, &r);
373 target->resetVertexSource(); 376 target->resetVertexSource();
374 377
375 return true; 378 return true;
376 } 379 }
377 380
OLDNEW
« no previous file with comments | « src/gpu/GrAADistanceFieldPathRenderer.h ('k') | src/gpu/GrAAHairLinePathRenderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698