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

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

Issue 1356223003: Revert of Fix for degenerate stroke rect (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 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/GrAAStrokeRectBatch.cpp ('k') | 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 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 "GrRectBatchFactory.h" 8 #include "GrRectBatchFactory.h"
9 9
10 #include "GrAAStrokeRectBatch.h" 10 #include "GrAAStrokeRectBatch.h"
(...skipping 15 matching lines...) Expand all
26 devStrokeSize.setAbs(devStrokeSize); 26 devStrokeSize.setAbs(devStrokeSize);
27 } else { 27 } else {
28 devStrokeSize.set(SK_Scalar1, SK_Scalar1); 28 devStrokeSize.set(SK_Scalar1, SK_Scalar1);
29 } 29 }
30 30
31 const SkScalar dx = devStrokeSize.fX; 31 const SkScalar dx = devStrokeSize.fX;
32 const SkScalar dy = devStrokeSize.fY; 32 const SkScalar dy = devStrokeSize.fY;
33 const SkScalar rx = SkScalarMul(dx, SK_ScalarHalf); 33 const SkScalar rx = SkScalarMul(dx, SK_ScalarHalf);
34 const SkScalar ry = SkScalarMul(dy, SK_ScalarHalf); 34 const SkScalar ry = SkScalarMul(dy, SK_ScalarHalf);
35 35
36 SkScalar spare;
37 {
38 SkScalar w = devRect.width() - dx;
39 SkScalar h = devRect.height() - dy;
40 spare = SkTMin(w, h);
41 }
42
36 SkRect devOutside(devRect); 43 SkRect devOutside(devRect);
37 devOutside.outset(rx, ry); 44 devOutside.outset(rx, ry);
38 45
39 bool miterStroke = true; 46 bool miterStroke = true;
40 // For hairlines, make bevel and round joins appear the same as mitered ones . 47 // For hairlines, make bevel and round joins appear the same as mitered ones .
41 // small miter limit means right angles show bevel... 48 // small miter limit means right angles show bevel...
42 if ((width > 0) && (stroke.getJoin() != SkPaint::kMiter_Join || 49 if ((width > 0) && (stroke.getJoin() != SkPaint::kMiter_Join ||
43 stroke.getMiter() < SK_ScalarSqrt2)) { 50 stroke.getMiter() < SK_ScalarSqrt2)) {
44 miterStroke = false; 51 miterStroke = false;
45 } 52 }
46 53
54 if (spare <= 0 && miterStroke) {
55 return CreateAAFill(color, viewMatrix, devOutside, devOutside);
56 }
57
47 SkRect devInside(devRect); 58 SkRect devInside(devRect);
48 devInside.inset(rx, ry); 59 devInside.inset(rx, ry);
49 60
50 // If we have a degenerate stroking rect(ie the stroke is larger than inner rect) then we
51 // make a degenerate inside rect to avoid double hitting. We will also jam all of the points
52 // together when we render these rects.
53 SkScalar spare;
54 {
55 SkScalar w = devRect.width() - dx;
56 SkScalar h = devRect.height() - dy;
57 spare = SkTMin(w, h);
58 }
59
60 bool degenerate = spare <= 0;
61 if (degenerate) {
62 devInside.fLeft = devInside.fRight = devRect.centerX();
63 devInside.fTop = devInside.fBottom = devRect.centerY();
64 }
65
66 SkRect devOutsideAssist(devRect); 61 SkRect devOutsideAssist(devRect);
67 62
68 // For bevel-stroke, use 2 SkRect instances(devOutside and devOutsideAssist) 63 // For bevel-stroke, use 2 SkRect instances(devOutside and devOutsideAssist)
69 // to draw the outer of the rect. Because there are 8 vertices on the outer 64 // to draw the outer of the rect. Because there are 8 vertices on the outer
70 // edge, while vertex number of inner edge is 4, the same as miter-stroke. 65 // edge, while vertex number of inner edge is 4, the same as miter-stroke.
71 if (!miterStroke) { 66 if (!miterStroke) {
72 devOutside.inset(0, ry); 67 devOutside.inset(0, ry);
73 devOutsideAssist.outset(0, ry); 68 devOutsideAssist.outset(0, ry);
74 } 69 }
75 70
76 return GrAAStrokeRectBatch::Create(color, viewMatrix, devOutside, devOutside Assist, devInside, 71 return GrAAStrokeRectBatch::Create(color, viewMatrix, devOutside, devOutside Assist, devInside,
77 miterStroke, degenerate); 72 miterStroke);
78 } 73 }
79 74
80 GrDrawBatch* CreateAAFillNestedRects(GrColor color, 75 GrDrawBatch* CreateAAFillNestedRects(GrColor color,
81 const SkMatrix& viewMatrix, 76 const SkMatrix& viewMatrix,
82 const SkRect rects[2]) { 77 const SkRect rects[2]) {
83 SkASSERT(viewMatrix.rectStaysRect()); 78 SkASSERT(viewMatrix.rectStaysRect());
84 SkASSERT(!rects[0].isEmpty() && !rects[1].isEmpty()); 79 SkASSERT(!rects[0].isEmpty() && !rects[1].isEmpty());
85 80
86 SkRect devOutside, devInside; 81 SkRect devOutside, devInside;
87 viewMatrix.mapRect(&devOutside, rects[0]); 82 viewMatrix.mapRect(&devOutside, rects[0]);
88 viewMatrix.mapRect(&devInside, rects[1]); 83 viewMatrix.mapRect(&devInside, rects[1]);
89 84
90 return GrAAStrokeRectBatch::Create(color, viewMatrix, devOutside, devOutside , devInside, true, 85 if (devInside.isEmpty()) {
91 devInside.isEmpty()); 86 return CreateAAFill(color, viewMatrix, devOutside, devOutside);
87 }
88
89 return GrAAStrokeRectBatch::Create(color, viewMatrix, devOutside, devOutside , devInside, true);
92 } 90 }
93 91
94 }; 92 };
OLDNEW
« no previous file with comments | « src/gpu/batches/GrAAStrokeRectBatch.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698