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

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

Issue 1967513002: Revert of Replace GrStrokeInfo with GrStyle. (Closed) Base URL: https://chromium.googlesource.com/skia.git@resscale
Patch Set: 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 "GrStyle.h" 20 #include "GrStrokeInfo.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.fStyle->pathEffect()) { 49 if (args.fStroke->getStyle() == SkStrokeRec::kStroke_Style) {
50 return false;
51 }
52 const SkStrokeRec& stroke = args.fStyle->strokeRec();
53 if (stroke.getStyle() == SkStrokeRec::kStroke_Style) {
54 if (!args.fViewMatrix->isSimilarity()) { 50 if (!args.fViewMatrix->isSimilarity()) {
55 return false; 51 return false;
56 } 52 }
57 SkScalar strokeWidth = args.fViewMatrix->getMaxScale() * stroke.getWidth (); 53 SkScalar strokeWidth = args.fViewMatrix->getMaxScale() * args.fStroke->g etWidth();
58 return strokeWidth >= 1.0f && strokeWidth <= kMaxStrokeWidth && 54 return strokeWidth >= 1.0f && strokeWidth <= kMaxStrokeWidth && !args.fS troke->isDashed() &&
59 SkPathPriv::IsClosedSingleContour(*args.fPath) && 55 SkPathPriv::IsClosedSingleContour(*args.fPath) &&
60 stroke.getJoin() != SkPaint::Join::kRound_Join; 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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 bool GrAALinearizingConvexPathRenderer::onDrawPath(const DrawPathArgs& args) { 318 bool GrAALinearizingConvexPathRenderer::onDrawPath(const DrawPathArgs& args) {
323 GR_AUDIT_TRAIL_AUTO_FRAME(args.fTarget->getAuditTrail(), 319 GR_AUDIT_TRAIL_AUTO_FRAME(args.fTarget->getAuditTrail(),
324 "GrAALinearizingConvexPathRenderer::onDrawPath"); 320 "GrAALinearizingConvexPathRenderer::onDrawPath");
325 if (args.fPath->isEmpty()) { 321 if (args.fPath->isEmpty()) {
326 return true; 322 return true;
327 } 323 }
328 AAFlatteningConvexPathBatch::Geometry geometry; 324 AAFlatteningConvexPathBatch::Geometry geometry;
329 geometry.fColor = args.fColor; 325 geometry.fColor = args.fColor;
330 geometry.fViewMatrix = *args.fViewMatrix; 326 geometry.fViewMatrix = *args.fViewMatrix;
331 geometry.fPath = *args.fPath; 327 geometry.fPath = *args.fPath;
332 bool fill = args.fStyle->isSimpleFill(); 328 geometry.fStrokeWidth = args.fStroke->isFillStyle() ? -1.0f : args.fStroke-> getWidth();
333 geometry.fStrokeWidth = fill ? -1.0f : args.fStyle->strokeRec().getWidth(); 329 geometry.fJoin = args.fStroke->isFillStyle() ? SkPaint::Join::kMiter_Join :
334 geometry.fJoin = fill ? SkPaint::Join::kMiter_Join : args.fStyle->strokeRec( ).getJoin(); 330 args.fStroke->getJoin();
335 geometry.fMiterLimit = args.fStyle->strokeRec().getMiter(); 331 geometry.fMiterLimit = args.fStroke->getMiter();
336 332
337 SkAutoTUnref<GrDrawBatch> batch(AAFlatteningConvexPathBatch::Create(geometry )); 333 SkAutoTUnref<GrDrawBatch> batch(AAFlatteningConvexPathBatch::Create(geometry ));
338 args.fTarget->drawBatch(*args.fPipelineBuilder, batch); 334 args.fTarget->drawBatch(*args.fPipelineBuilder, batch);
339 335
340 return true; 336 return true;
341 } 337 }
342 338
343 //////////////////////////////////////////////////////////////////////////////// /////////////////// 339 //////////////////////////////////////////////////////////////////////////////// ///////////////////
344 340
345 #ifdef GR_TEST_UTILS 341 #ifdef GR_TEST_UTILS
346 342
347 DRAW_BATCH_TEST_DEFINE(AAFlatteningConvexPathBatch) { 343 DRAW_BATCH_TEST_DEFINE(AAFlatteningConvexPathBatch) {
348 AAFlatteningConvexPathBatch::Geometry geometry; 344 AAFlatteningConvexPathBatch::Geometry geometry;
349 geometry.fColor = GrRandomColor(random); 345 geometry.fColor = GrRandomColor(random);
350 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); 346 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random);
351 geometry.fPath = GrTest::TestPathConvex(random); 347 geometry.fPath = GrTest::TestPathConvex(random);
352 348
353 return AAFlatteningConvexPathBatch::Create(geometry); 349 return AAFlatteningConvexPathBatch::Create(geometry);
354 } 350 }
355 351
356 #endif 352 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrAAHairLinePathRenderer.cpp ('k') | src/gpu/batches/GrDashLinePathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698