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

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

Issue 1265763002: Args structs to GrPathRenderer functions (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more Created 5 years, 4 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 unified diff | Download patch
« no previous file with comments | « src/gpu/GrAALinearizingConvexPathRenderer.h ('k') | src/gpu/GrAddPathRenderers_default.cpp » ('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 2015 Google Inc. 3 * Copyright 2015 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 "GrAALinearizingConvexPathRenderer.h" 9 #include "GrAALinearizingConvexPathRenderer.h"
10 10
(...skipping 21 matching lines...) Expand all
32 32
33 // The thicker the stroke, the harder it is to produce high-quality results usin g tessellation. For 33 // The thicker the stroke, the harder it is to produce high-quality results usin g tessellation. For
34 // the time being, we simply drop back to software rendering above this stroke w idth. 34 // the time being, we simply drop back to software rendering above this stroke w idth.
35 static const SkScalar kMaxStrokeWidth = 20.0; 35 static const SkScalar kMaxStrokeWidth = 20.0;
36 36
37 GrAALinearizingConvexPathRenderer::GrAALinearizingConvexPathRenderer() { 37 GrAALinearizingConvexPathRenderer::GrAALinearizingConvexPathRenderer() {
38 } 38 }
39 39
40 /////////////////////////////////////////////////////////////////////////////// 40 ///////////////////////////////////////////////////////////////////////////////
41 41
42 bool GrAALinearizingConvexPathRenderer::canDrawPath(const GrDrawTarget* target, 42 bool GrAALinearizingConvexPathRenderer::onCanDrawPath(const CanDrawPathArgs& arg s) const {
43 const GrPipelineBuilder*, 43 if (!args.fAntiAlias) {
44 const SkMatrix& viewMatrix,
45 const SkPath& path,
46 const GrStrokeInfo& stroke,
47 bool antiAlias) const {
48 if (!antiAlias) {
49 return false; 44 return false;
50 } 45 }
51 if (path.isInverseFillType()) { 46 if (args.fPath->isInverseFillType()) {
52 return false; 47 return false;
53 } 48 }
54 if (!path.isConvex()) { 49 if (!args.fPath->isConvex()) {
55 return false; 50 return false;
56 } 51 }
57 if (stroke.getStyle() == SkStrokeRec::kStroke_Style) { 52 if (args.fStroke->getStyle() == SkStrokeRec::kStroke_Style) {
58 return viewMatrix.isSimilarity() && stroke.getWidth() >= 1.0f && 53 return args.fViewMatrix->isSimilarity() && args.fStroke->getWidth() >= 1 .0f &&
59 stroke.getWidth() <= kMaxStrokeWidth && !stroke.isDashed() && 54 args.fStroke->getWidth() <= kMaxStrokeWidth && !args.fStroke->is Dashed() &&
60 SkPathPriv::LastVerbIsClose(path) && stroke.getJoin() != SkPaint ::Join::kRound_Join; 55 SkPathPriv::LastVerbIsClose(*args.fPath) &&
56 args.fStroke->getJoin() != SkPaint::Join::kRound_Join;
61 } 57 }
62 return stroke.getStyle() == SkStrokeRec::kFill_Style; 58 return args.fStroke->getStyle() == SkStrokeRec::kFill_Style;
63 } 59 }
64 60
65 // extract the result vertices and indices from the GrAAConvexTessellator 61 // extract the result vertices and indices from the GrAAConvexTessellator
66 static void extract_verts(const GrAAConvexTessellator& tess, 62 static void extract_verts(const GrAAConvexTessellator& tess,
67 void* vertices, 63 void* vertices,
68 size_t vertexStride, 64 size_t vertexStride,
69 GrColor color, 65 GrColor color,
70 uint16_t firstIndex, 66 uint16_t firstIndex,
71 uint16_t* idxs, 67 uint16_t* idxs,
72 bool tweakAlphaForCoverage) { 68 bool tweakAlphaForCoverage) {
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 bool fColorIgnored; 292 bool fColorIgnored;
297 bool fCoverageIgnored; 293 bool fCoverageIgnored;
298 bool fLinesOnly; 294 bool fLinesOnly;
299 bool fCanTweakAlphaForCoverage; 295 bool fCanTweakAlphaForCoverage;
300 }; 296 };
301 297
302 BatchTracker fBatch; 298 BatchTracker fBatch;
303 SkSTArray<1, Geometry, true> fGeoData; 299 SkSTArray<1, Geometry, true> fGeoData;
304 }; 300 };
305 301
306 bool GrAALinearizingConvexPathRenderer::onDrawPath(GrDrawTarget* target, 302 bool GrAALinearizingConvexPathRenderer::onDrawPath(const DrawPathArgs& args) {
307 GrPipelineBuilder* pipelineBu ilder, 303 if (args.fPath->isEmpty()) {
308 GrColor color,
309 const SkMatrix& vm,
310 const SkPath& path,
311 const GrStrokeInfo& stroke,
312 bool antiAlias) {
313 if (path.isEmpty()) {
314 return true; 304 return true;
315 } 305 }
316 AAFlatteningConvexPathBatch::Geometry geometry; 306 AAFlatteningConvexPathBatch::Geometry geometry;
317 geometry.fColor = color; 307 geometry.fColor = args.fColor;
318 geometry.fViewMatrix = vm; 308 geometry.fViewMatrix = *args.fViewMatrix;
319 geometry.fPath = path; 309 geometry.fPath = *args.fPath;
320 geometry.fStrokeWidth = stroke.isFillStyle() ? -1.0f : stroke.getWidth(); 310 geometry.fStrokeWidth = args.fStroke->isFillStyle() ? -1.0f : args.fStroke-> getWidth();
321 geometry.fJoin = stroke.isFillStyle() ? SkPaint::Join::kMiter_Join : stroke. getJoin(); 311 geometry.fJoin = args.fStroke->isFillStyle() ? SkPaint::Join::kMiter_Join :
322 geometry.fMiterLimit = stroke.getMiter(); 312 args.fStroke->getJoin();
313 geometry.fMiterLimit = args.fStroke->getMiter();
323 314
324 SkAutoTUnref<GrBatch> batch(AAFlatteningConvexPathBatch::Create(geometry)); 315 SkAutoTUnref<GrBatch> batch(AAFlatteningConvexPathBatch::Create(geometry));
325 target->drawBatch(*pipelineBuilder, batch); 316 args.fTarget->drawBatch(*args.fPipelineBuilder, batch);
326 317
327 return true; 318 return true;
328 } 319 }
329 320
330 //////////////////////////////////////////////////////////////////////////////// /////////////////// 321 //////////////////////////////////////////////////////////////////////////////// ///////////////////
331 322
332 #ifdef GR_TEST_UTILS 323 #ifdef GR_TEST_UTILS
333 324
334 BATCH_TEST_DEFINE(AAFlatteningConvexPathBatch) { 325 BATCH_TEST_DEFINE(AAFlatteningConvexPathBatch) {
335 AAFlatteningConvexPathBatch::Geometry geometry; 326 AAFlatteningConvexPathBatch::Geometry geometry;
336 geometry.fColor = GrRandomColor(random); 327 geometry.fColor = GrRandomColor(random);
337 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); 328 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random);
338 geometry.fPath = GrTest::TestPathConvex(random); 329 geometry.fPath = GrTest::TestPathConvex(random);
339 330
340 return AAFlatteningConvexPathBatch::Create(geometry); 331 return AAFlatteningConvexPathBatch::Create(geometry);
341 } 332 }
342 333
343 #endif 334 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrAALinearizingConvexPathRenderer.h ('k') | src/gpu/GrAddPathRenderers_default.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698