Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 | |
| 43 SkRect devOutside(devRect); | 36 SkRect devOutside(devRect); |
| 44 devOutside.outset(rx, ry); | 37 devOutside.outset(rx, ry); |
| 45 | 38 |
| 46 bool miterStroke = true; | 39 bool miterStroke = true; |
| 47 // For hairlines, make bevel and round joins appear the same as mitered ones . | 40 // For hairlines, make bevel and round joins appear the same as mitered ones . |
| 48 // small miter limit means right angles show bevel... | 41 // small miter limit means right angles show bevel... |
| 49 if ((width > 0) && (stroke.getJoin() != SkPaint::kMiter_Join || | 42 if ((width > 0) && (stroke.getJoin() != SkPaint::kMiter_Join || |
| 50 stroke.getMiter() < SK_ScalarSqrt2)) { | 43 stroke.getMiter() < SK_ScalarSqrt2)) { |
| 51 miterStroke = false; | 44 miterStroke = false; |
| 52 } | 45 } |
| 53 | 46 |
| 54 if (spare <= 0 && miterStroke) { | |
| 55 return CreateAAFill(color, viewMatrix, devOutside, devOutside); | |
| 56 } | |
| 57 | |
| 58 SkRect devInside(devRect); | 47 SkRect devInside(devRect); |
|
robertphillips
2015/09/20 15:49:40
It seems like we could get cracking with this meth
| |
| 59 devInside.inset(rx, ry); | 48 SkScalar insideRx = SkTMin(devRect.width() / 2.0f, rx); |
| 49 SkScalar insideRy = SkTMin(devRect.height() / 2.0f, ry); | |
| 50 devInside.inset(insideRx, insideRy); | |
| 60 | 51 |
| 61 SkRect devOutsideAssist(devRect); | 52 SkRect devOutsideAssist(devRect); |
| 62 | 53 |
| 63 // For bevel-stroke, use 2 SkRect instances(devOutside and devOutsideAssist) | 54 // For bevel-stroke, use 2 SkRect instances(devOutside and devOutsideAssist) |
| 64 // to draw the outer of the rect. Because there are 8 vertices on the outer | 55 // to draw the outer of the rect. Because there are 8 vertices on the outer |
| 65 // edge, while vertex number of inner edge is 4, the same as miter-stroke. | 56 // edge, while vertex number of inner edge is 4, the same as miter-stroke. |
| 66 if (!miterStroke) { | 57 if (!miterStroke) { |
| 67 devOutside.inset(0, ry); | 58 devOutside.inset(0, ry); |
| 68 devOutsideAssist.outset(0, ry); | 59 devOutsideAssist.outset(0, ry); |
| 69 } | 60 } |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 83 viewMatrix.mapRect(&devInside, rects[1]); | 74 viewMatrix.mapRect(&devInside, rects[1]); |
| 84 | 75 |
| 85 if (devInside.isEmpty()) { | 76 if (devInside.isEmpty()) { |
| 86 return CreateAAFill(color, viewMatrix, devOutside, devOutside); | 77 return CreateAAFill(color, viewMatrix, devOutside, devOutside); |
| 87 } | 78 } |
| 88 | 79 |
| 89 return GrAAStrokeRectBatch::Create(color, viewMatrix, devOutside, devOutside , devInside, true); | 80 return GrAAStrokeRectBatch::Create(color, viewMatrix, devOutside, devOutside , devInside, true); |
| 90 } | 81 } |
| 91 | 82 |
| 92 }; | 83 }; |
| OLD | NEW |