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

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

Issue 2081383006: Use GrShape in GrPathRenderer. (Closed) Base URL: https://chromium.googlesource.com/skia.git@shapemembers
Patch Set: Address comments Created 4 years, 5 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/batches/GrAAHairLinePathRenderer.cpp ('k') | src/gpu/batches/GrDashLinePathRenderer.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 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrAALinearizingConvexPathRenderer.h" 8 #include "GrAALinearizingConvexPathRenderer.h"
9 9
10 #include "GrAAConvexTessellator.h" 10 #include "GrAAConvexTessellator.h"
(...skipping 22 matching lines...) Expand all
33 33
34 GrAALinearizingConvexPathRenderer::GrAALinearizingConvexPathRenderer() { 34 GrAALinearizingConvexPathRenderer::GrAALinearizingConvexPathRenderer() {
35 } 35 }
36 36
37 /////////////////////////////////////////////////////////////////////////////// 37 ///////////////////////////////////////////////////////////////////////////////
38 38
39 bool GrAALinearizingConvexPathRenderer::onCanDrawPath(const CanDrawPathArgs& arg s) const { 39 bool GrAALinearizingConvexPathRenderer::onCanDrawPath(const CanDrawPathArgs& arg s) const {
40 if (!args.fAntiAlias) { 40 if (!args.fAntiAlias) {
41 return false; 41 return false;
42 } 42 }
43 if (args.fPath->isInverseFillType()) { 43 if (!args.fShape->knownToBeConvex()) {
44 return false; 44 return false;
45 } 45 }
46 if (!args.fPath->isConvex()) { 46 if (args.fShape->style().pathEffect()) {
47 return false; 47 return false;
48 } 48 }
49 if (args.fStyle->pathEffect()) { 49 if (args.fShape->inverseFilled()) {
50 return false; 50 return false;
51 } 51 }
52 const SkStrokeRec& stroke = args.fStyle->strokeRec(); 52 const SkStrokeRec& stroke = args.fShape->style().strokeRec();
53 if (stroke.getStyle() == SkStrokeRec::kStroke_Style) { 53 if (stroke.getStyle() == SkStrokeRec::kStroke_Style) {
54 if (!args.fViewMatrix->isSimilarity()) { 54 if (!args.fViewMatrix->isSimilarity()) {
55 return false; 55 return false;
56 } 56 }
57 SkScalar strokeWidth = args.fViewMatrix->getMaxScale() * stroke.getWidth (); 57 SkScalar strokeWidth = args.fViewMatrix->getMaxScale() * stroke.getWidth ();
58 return strokeWidth >= 1.0f && strokeWidth <= kMaxStrokeWidth && 58 return strokeWidth >= 1.0f && strokeWidth <= kMaxStrokeWidth &&
59 SkPathPriv::IsClosedSingleContour(*args.fPath) && 59 args.fShape->knownToBeClosed() &&
60 stroke.getJoin() != SkPaint::Join::kRound_Join; 60 stroke.getJoin() != SkPaint::Join::kRound_Join;
61 } 61 }
62 return stroke.getStyle() == SkStrokeRec::kFill_Style; 62 return stroke.getStyle() == SkStrokeRec::kFill_Style;
63 } 63 }
64 64
65 // extract the result vertices and indices from the GrAAConvexTessellator 65 // extract the result vertices and indices from the GrAAConvexTessellator
66 static void extract_verts(const GrAAConvexTessellator& tess, 66 static void extract_verts(const GrAAConvexTessellator& tess,
67 void* vertices, 67 void* vertices,
68 size_t vertexStride, 68 size_t vertexStride,
69 GrColor color, 69 GrColor color,
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 BatchTracker fBatch; 317 BatchTracker fBatch;
318 SkSTArray<1, Geometry, true> fGeoData; 318 SkSTArray<1, Geometry, true> fGeoData;
319 319
320 typedef GrVertexBatch INHERITED; 320 typedef GrVertexBatch INHERITED;
321 }; 321 };
322 322
323 bool GrAALinearizingConvexPathRenderer::onDrawPath(const DrawPathArgs& args) { 323 bool GrAALinearizingConvexPathRenderer::onDrawPath(const DrawPathArgs& args) {
324 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(), 324 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(),
325 "GrAALinearizingConvexPathRenderer::onDrawPath"); 325 "GrAALinearizingConvexPathRenderer::onDrawPath");
326 SkASSERT(!args.fDrawContext->isUnifiedMultisampled()); 326 SkASSERT(!args.fDrawContext->isUnifiedMultisampled());
327 SkASSERT(!args.fShape->isEmpty());
327 328
328 if (args.fPath->isEmpty()) {
329 return true;
330 }
331 AAFlatteningConvexPathBatch::Geometry geometry; 329 AAFlatteningConvexPathBatch::Geometry geometry;
332 geometry.fColor = args.fColor; 330 geometry.fColor = args.fColor;
333 geometry.fViewMatrix = *args.fViewMatrix; 331 geometry.fViewMatrix = *args.fViewMatrix;
334 geometry.fPath = *args.fPath; 332 args.fShape->asPath(&geometry.fPath);
335 bool fill = args.fStyle->isSimpleFill(); 333 bool fill = args.fShape->style().isSimpleFill();
336 geometry.fStrokeWidth = fill ? -1.0f : args.fStyle->strokeRec().getWidth(); 334 const SkStrokeRec& stroke = args.fShape->style().strokeRec();
337 geometry.fJoin = fill ? SkPaint::Join::kMiter_Join : args.fStyle->strokeRec( ).getJoin(); 335 geometry.fStrokeWidth = fill ? -1.0f : stroke.getWidth();
338 geometry.fMiterLimit = args.fStyle->strokeRec().getMiter(); 336 geometry.fJoin = fill ? SkPaint::Join::kMiter_Join : stroke.getJoin();
337 geometry.fMiterLimit = stroke.getMiter();
339 338
340 SkAutoTUnref<GrDrawBatch> batch(AAFlatteningConvexPathBatch::Create(geometry )); 339 SkAutoTUnref<GrDrawBatch> batch(AAFlatteningConvexPathBatch::Create(geometry ));
341 340
342 GrPipelineBuilder pipelineBuilder(*args.fPaint); 341 GrPipelineBuilder pipelineBuilder(*args.fPaint);
343 pipelineBuilder.setUserStencil(args.fUserStencilSettings); 342 pipelineBuilder.setUserStencil(args.fUserStencilSettings);
344 343
345 args.fDrawContext->drawBatch(pipelineBuilder, *args.fClip, batch); 344 args.fDrawContext->drawBatch(pipelineBuilder, *args.fClip, batch);
346 345
347 return true; 346 return true;
348 } 347 }
349 348
350 //////////////////////////////////////////////////////////////////////////////// /////////////////// 349 //////////////////////////////////////////////////////////////////////////////// ///////////////////
351 350
352 #ifdef GR_TEST_UTILS 351 #ifdef GR_TEST_UTILS
353 352
354 DRAW_BATCH_TEST_DEFINE(AAFlatteningConvexPathBatch) { 353 DRAW_BATCH_TEST_DEFINE(AAFlatteningConvexPathBatch) {
355 AAFlatteningConvexPathBatch::Geometry geometry; 354 AAFlatteningConvexPathBatch::Geometry geometry;
356 geometry.fColor = GrRandomColor(random); 355 geometry.fColor = GrRandomColor(random);
357 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); 356 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random);
358 geometry.fPath = GrTest::TestPathConvex(random); 357 geometry.fPath = GrTest::TestPathConvex(random);
359 358
360 return AAFlatteningConvexPathBatch::Create(geometry); 359 return AAFlatteningConvexPathBatch::Create(geometry);
361 } 360 }
362 361
363 #endif 362 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrAAHairLinePathRenderer.cpp ('k') | src/gpu/batches/GrDashLinePathRenderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698