| 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 "GrAAFillRectBatch.h" | |
| 11 #include "GrAAStrokeRectBatch.h" | 10 #include "GrAAStrokeRectBatch.h" |
| 12 #include "GrRectBatch.h" | |
| 13 #include "GrStrokeRectBatch.h" | 11 #include "GrStrokeRectBatch.h" |
| 14 | 12 |
| 15 #include "SkStrokeRec.h" | 13 #include "SkStrokeRec.h" |
| 16 | 14 |
| 17 static GrBatch* create_stroke_aa_batch(GrColor color, | 15 static GrBatch* create_stroke_aa_batch(GrColor color, |
| 18 const SkMatrix& viewMatrix, | 16 const SkMatrix& viewMatrix, |
| 19 const SkRect& devOutside, | 17 const SkRect& devOutside, |
| 20 const SkRect& devOutsideAssist, | 18 const SkRect& devOutsideAssist, |
| 21 const SkRect& devInside, | 19 const SkRect& devInside, |
| 22 bool miterStroke) { | 20 bool miterStroke) { |
| 23 GrAAStrokeRectBatch::Geometry geometry; | 21 GrAAStrokeRectBatch::Geometry geometry; |
| 24 geometry.fColor = color; | 22 geometry.fColor = color; |
| 25 geometry.fDevOutside = devOutside; | 23 geometry.fDevOutside = devOutside; |
| 26 geometry.fDevOutsideAssist = devOutsideAssist; | 24 geometry.fDevOutsideAssist = devOutsideAssist; |
| 27 geometry.fDevInside = devInside; | 25 geometry.fDevInside = devInside; |
| 28 geometry.fMiterStroke = miterStroke; | 26 geometry.fMiterStroke = miterStroke; |
| 29 | 27 |
| 30 return GrAAStrokeRectBatch::Create(geometry, viewMatrix); | 28 return GrAAStrokeRectBatch::Create(geometry, viewMatrix); |
| 31 } | 29 } |
| 32 | 30 |
| 33 namespace GrRectBatchFactory { | 31 namespace GrRectBatchFactory { |
| 34 | 32 |
| 35 GrBatch* CreateFillBW(GrColor color, | |
| 36 const SkMatrix& viewMatrix, | |
| 37 const SkRect& rect, | |
| 38 const SkRect* localRect, | |
| 39 const SkMatrix* localMatrix) { | |
| 40 GrRectBatch::Geometry geometry; | |
| 41 geometry.fColor = color; | |
| 42 geometry.fViewMatrix = viewMatrix; | |
| 43 geometry.fRect = rect; | |
| 44 | |
| 45 if (localRect) { | |
| 46 geometry.fHasLocalRect = true; | |
| 47 geometry.fLocalRect = *localRect; | |
| 48 } else { | |
| 49 geometry.fHasLocalRect = false; | |
| 50 } | |
| 51 | |
| 52 if (localMatrix) { | |
| 53 geometry.fHasLocalMatrix = true; | |
| 54 geometry.fLocalMatrix = *localMatrix; | |
| 55 } else { | |
| 56 geometry.fHasLocalMatrix = false; | |
| 57 } | |
| 58 | |
| 59 return GrRectBatch::Create(geometry); | |
| 60 } | |
| 61 | 33 |
| 62 GrBatch* CreateStrokeBW(GrColor color, | 34 GrBatch* CreateStrokeBW(GrColor color, |
| 63 const SkMatrix& viewMatrix, | 35 const SkMatrix& viewMatrix, |
| 64 const SkRect& rect, | 36 const SkRect& rect, |
| 65 SkScalar strokeWidth, | 37 SkScalar strokeWidth, |
| 66 bool snapToPixelCenters) { | 38 bool snapToPixelCenters) { |
| 67 GrStrokeRectBatch::Geometry geometry; | 39 GrStrokeRectBatch::Geometry geometry; |
| 68 geometry.fColor = color; | 40 geometry.fColor = color; |
| 69 geometry.fViewMatrix = viewMatrix; | 41 geometry.fViewMatrix = viewMatrix; |
| 70 geometry.fRect = rect; | 42 geometry.fRect = rect; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 viewMatrix.mapRect(&devInside, rects[1]); | 114 viewMatrix.mapRect(&devInside, rects[1]); |
| 143 | 115 |
| 144 if (devInside.isEmpty()) { | 116 if (devInside.isEmpty()) { |
| 145 return CreateFillAA(color, viewMatrix, devOutside, devOutside); | 117 return CreateFillAA(color, viewMatrix, devOutside, devOutside); |
| 146 } | 118 } |
| 147 | 119 |
| 148 return create_stroke_aa_batch(color, viewMatrix, devOutside, devOutside, dev
Inside, true); | 120 return create_stroke_aa_batch(color, viewMatrix, devOutside, devOutside, dev
Inside, true); |
| 149 } | 121 } |
| 150 | 122 |
| 151 }; | 123 }; |
| OLD | NEW |