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

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

Issue 1964313002: Make distance field bounds calculation more accurate for strokes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
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
« no previous file with comments | « no previous file | no next file » | 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 2014 Google Inc. 2 * Copyright 2014 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 "GrAADistanceFieldPathRenderer.h" 8 #include "GrAADistanceFieldPathRenderer.h"
9 9
10 #include "GrBatchFlushState.h" 10 #include "GrBatchFlushState.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 94
95 // currently don't support perspective 95 // currently don't support perspective
96 if (args.fViewMatrix->hasPerspective()) { 96 if (args.fViewMatrix->hasPerspective()) {
97 return false; 97 return false;
98 } 98 }
99 99
100 // only support paths with bounds within kMediumMIP by kMediumMIP, 100 // only support paths with bounds within kMediumMIP by kMediumMIP,
101 // scaled to have bounds within 2.0f*kLargeMIP by 2.0f*kLargeMIP 101 // scaled to have bounds within 2.0f*kLargeMIP by 2.0f*kLargeMIP
102 // the goal is to accelerate rendering of lots of small paths that may be sc aling 102 // the goal is to accelerate rendering of lots of small paths that may be sc aling
103 SkScalar maxScale = args.fViewMatrix->getMaxScale(); 103 SkScalar maxScale = args.fViewMatrix->getMaxScale();
104 #if 0 // This is more accurate but changes some GMs. TODO: Standalone change to enable this.
105 SkRect bounds; 104 SkRect bounds;
106 args.fStyle->adjustBounds(&bounds, args.fPath->getBounds()); 105 args.fStyle->adjustBounds(&bounds, args.fPath->getBounds());
107 SkScalar maxDim = SkMaxScalar(bounds.width(), bounds.height()); 106 SkScalar maxDim = SkMaxScalar(bounds.width(), bounds.height());
108 #else
109 const SkRect& bounds = args.fPath->getBounds();
110 SkScalar maxDim = SkMaxScalar(bounds.width(), bounds.height());
111 const SkStrokeRec& stroke = args.fStyle->strokeRec();
112 // Approximate stroked size by adding the maximum of the stroke width or 2x the miter limit
113 if (!stroke.isFillStyle()) {
114 SkScalar extraWidth = stroke.getWidth();
115 if (SkPaint::kMiter_Join == stroke.getJoin()) {
116 extraWidth = SkTMax(extraWidth, 2.0f*stroke.getMiter());
117 }
118 maxDim += extraWidth;
119 }
120 #endif
121 107
122 return maxDim <= kMediumMIP && maxDim * maxScale <= 2.0f*kLargeMIP; 108 return maxDim <= kMediumMIP && maxDim * maxScale <= 2.0f*kLargeMIP;
123 } 109 }
124 110
125 //////////////////////////////////////////////////////////////////////////////// 111 ////////////////////////////////////////////////////////////////////////////////
126 112
127 // padding around path bounds to allow for antialiased pixels 113 // padding around path bounds to allow for antialiased pixels
128 static const SkScalar kAntiAliasPad = 1.0f; 114 static const SkScalar kAntiAliasPad = 1.0f;
129 115
130 class AADistanceFieldPathBatch : public GrVertexBatch { 116 class AADistanceFieldPathBatch : public GrVertexBatch {
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 geometry.fGenID = random->nextU(); 640 geometry.fGenID = random->nextU();
655 641
656 return AADistanceFieldPathBatch::Create(geometry, viewMatrix, 642 return AADistanceFieldPathBatch::Create(geometry, viewMatrix,
657 gTestStruct.fAtlas, 643 gTestStruct.fAtlas,
658 &gTestStruct.fPathCache, 644 &gTestStruct.fPathCache,
659 &gTestStruct.fPathList, 645 &gTestStruct.fPathList,
660 gammaCorrect); 646 gammaCorrect);
661 } 647 }
662 648
663 #endif 649 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698