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

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

Issue 1957363002: Replace GrStrokeInfo with GrStyle. (Closed) Base URL: https://chromium.googlesource.com/skia.git@resscale
Patch Set: Fix issue where hairlines were going to MSAAPathRenderer Created 4 years, 7 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
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"
11 #include "GrBatchFlushState.h" 11 #include "GrBatchFlushState.h"
12 #include "GrBatchTest.h" 12 #include "GrBatchTest.h"
13 #include "GrContext.h" 13 #include "GrContext.h"
14 #include "GrDefaultGeoProcFactory.h" 14 #include "GrDefaultGeoProcFactory.h"
15 #include "GrGeometryProcessor.h" 15 #include "GrGeometryProcessor.h"
16 #include "GrInvariantOutput.h" 16 #include "GrInvariantOutput.h"
17 #include "GrPathUtils.h" 17 #include "GrPathUtils.h"
18 #include "GrProcessor.h" 18 #include "GrProcessor.h"
19 #include "GrPipelineBuilder.h" 19 #include "GrPipelineBuilder.h"
20 #include "GrStrokeInfo.h" 20 #include "GrStyle.h"
21 #include "SkGeometry.h" 21 #include "SkGeometry.h"
22 #include "SkString.h" 22 #include "SkString.h"
23 #include "SkTraceEvent.h" 23 #include "SkTraceEvent.h"
24 #include "SkPathPriv.h" 24 #include "SkPathPriv.h"
25 #include "batches/GrVertexBatch.h" 25 #include "batches/GrVertexBatch.h"
26 #include "glsl/GrGLSLGeometryProcessor.h" 26 #include "glsl/GrGLSLGeometryProcessor.h"
27 27
28 static const int DEFAULT_BUFFER_SIZE = 100; 28 static const int DEFAULT_BUFFER_SIZE = 100;
29 29
30 // The thicker the stroke, the harder it is to produce high-quality results usin g tessellation. For 30 // The thicker the stroke, the harder it is to produce high-quality results usin g tessellation. For
31 // the time being, we simply drop back to software rendering above this stroke w idth. 31 // the time being, we simply drop back to software rendering above this stroke w idth.
32 static const SkScalar kMaxStrokeWidth = 20.0; 32 static const SkScalar kMaxStrokeWidth = 20.0;
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.fPath->isInverseFillType()) {
44 return false; 44 return false;
45 } 45 }
46 if (!args.fPath->isConvex()) { 46 if (!args.fPath->isConvex()) {
47 return false; 47 return false;
48 } 48 }
49 if (args.fStroke->getStyle() == SkStrokeRec::kStroke_Style) { 49 if (args.fStyle->pathEffect()) {
50 return false;
51 }
52 const SkStrokeRec& stroke = args.fStyle->strokeRec();
53 if (stroke.getStyle() == SkStrokeRec::kStroke_Style) {
50 if (!args.fViewMatrix->isSimilarity()) { 54 if (!args.fViewMatrix->isSimilarity()) {
51 return false; 55 return false;
52 } 56 }
53 SkScalar strokeWidth = args.fViewMatrix->getMaxScale() * args.fStroke->g etWidth(); 57 SkScalar strokeWidth = args.fViewMatrix->getMaxScale() * stroke.getWidth ();
54 return strokeWidth >= 1.0f && strokeWidth <= kMaxStrokeWidth && !args.fS troke->isDashed() && 58 return strokeWidth >= 1.0f && strokeWidth <= kMaxStrokeWidth &&
55 SkPathPriv::IsClosedSingleContour(*args.fPath) && 59 SkPathPriv::IsClosedSingleContour(*args.fPath) &&
56 args.fStroke->getJoin() != SkPaint::Join::kRound_Join; 60 stroke.getJoin() != SkPaint::Join::kRound_Join;
57 } 61 }
58 return args.fStroke->getStyle() == SkStrokeRec::kFill_Style; 62 return stroke.getStyle() == SkStrokeRec::kFill_Style;
59 } 63 }
60 64
61 // extract the result vertices and indices from the GrAAConvexTessellator 65 // extract the result vertices and indices from the GrAAConvexTessellator
62 static void extract_verts(const GrAAConvexTessellator& tess, 66 static void extract_verts(const GrAAConvexTessellator& tess,
63 void* vertices, 67 void* vertices,
64 size_t vertexStride, 68 size_t vertexStride,
65 GrColor color, 69 GrColor color,
66 uint16_t firstIndex, 70 uint16_t firstIndex,
67 uint16_t* idxs, 71 uint16_t* idxs,
68 bool tweakAlphaForCoverage) { 72 bool tweakAlphaForCoverage) {
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 bool GrAALinearizingConvexPathRenderer::onDrawPath(const DrawPathArgs& args) { 322 bool GrAALinearizingConvexPathRenderer::onDrawPath(const DrawPathArgs& args) {
319 GR_AUDIT_TRAIL_AUTO_FRAME(args.fTarget->getAuditTrail(), 323 GR_AUDIT_TRAIL_AUTO_FRAME(args.fTarget->getAuditTrail(),
320 "GrAALinearizingConvexPathRenderer::onDrawPath"); 324 "GrAALinearizingConvexPathRenderer::onDrawPath");
321 if (args.fPath->isEmpty()) { 325 if (args.fPath->isEmpty()) {
322 return true; 326 return true;
323 } 327 }
324 AAFlatteningConvexPathBatch::Geometry geometry; 328 AAFlatteningConvexPathBatch::Geometry geometry;
325 geometry.fColor = args.fColor; 329 geometry.fColor = args.fColor;
326 geometry.fViewMatrix = *args.fViewMatrix; 330 geometry.fViewMatrix = *args.fViewMatrix;
327 geometry.fPath = *args.fPath; 331 geometry.fPath = *args.fPath;
328 geometry.fStrokeWidth = args.fStroke->isFillStyle() ? -1.0f : args.fStroke-> getWidth(); 332 bool fill = args.fStyle->isSimpleFill();
329 geometry.fJoin = args.fStroke->isFillStyle() ? SkPaint::Join::kMiter_Join : 333 geometry.fStrokeWidth = fill ? -1.0f : args.fStyle->strokeRec().getWidth();
330 args.fStroke->getJoin(); 334 geometry.fJoin = fill ? SkPaint::Join::kMiter_Join : args.fStyle->strokeRec( ).getJoin();
331 geometry.fMiterLimit = args.fStroke->getMiter(); 335 geometry.fMiterLimit = args.fStyle->strokeRec().getMiter();
332 336
333 SkAutoTUnref<GrDrawBatch> batch(AAFlatteningConvexPathBatch::Create(geometry )); 337 SkAutoTUnref<GrDrawBatch> batch(AAFlatteningConvexPathBatch::Create(geometry ));
334 args.fTarget->drawBatch(*args.fPipelineBuilder, batch); 338 args.fTarget->drawBatch(*args.fPipelineBuilder, batch);
335 339
336 return true; 340 return true;
337 } 341 }
338 342
339 //////////////////////////////////////////////////////////////////////////////// /////////////////// 343 //////////////////////////////////////////////////////////////////////////////// ///////////////////
340 344
341 #ifdef GR_TEST_UTILS 345 #ifdef GR_TEST_UTILS
342 346
343 DRAW_BATCH_TEST_DEFINE(AAFlatteningConvexPathBatch) { 347 DRAW_BATCH_TEST_DEFINE(AAFlatteningConvexPathBatch) {
344 AAFlatteningConvexPathBatch::Geometry geometry; 348 AAFlatteningConvexPathBatch::Geometry geometry;
345 geometry.fColor = GrRandomColor(random); 349 geometry.fColor = GrRandomColor(random);
346 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); 350 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random);
347 geometry.fPath = GrTest::TestPathConvex(random); 351 geometry.fPath = GrTest::TestPathConvex(random);
348 352
349 return AAFlatteningConvexPathBatch::Create(geometry); 353 return AAFlatteningConvexPathBatch::Create(geometry);
350 } 354 }
351 355
352 #endif 356 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698