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 "GrNonAAStrokeRectBatch.h" | 8 #include "GrNonAAStrokeRectBatch.h" |
9 | 9 |
10 #include "GrBatchTest.h" | 10 #include "GrBatchTest.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 using namespace GrDefaultGeoProcFactory; | 110 using namespace GrDefaultGeoProcFactory; |
111 Color color(this->color()); | 111 Color color(this->color()); |
112 Coverage coverage(this->coverageIgnored() ? Coverage::kSolid_Type : | 112 Coverage coverage(this->coverageIgnored() ? Coverage::kSolid_Type : |
113 Coverage::kNone_Type); | 113 Coverage::kNone_Type); |
114 LocalCoords localCoords(this->usesLocalCoords() ? LocalCoords::kUseP
osition_Type : | 114 LocalCoords localCoords(this->usesLocalCoords() ? LocalCoords::kUseP
osition_Type : |
115 LocalCoords::kUnus
ed_Type); | 115 LocalCoords::kUnus
ed_Type); |
116 gp.reset(GrDefaultGeoProcFactory::Create(color, coverage, localCoord
s, | 116 gp.reset(GrDefaultGeoProcFactory::Create(color, coverage, localCoord
s, |
117 this->viewMatrix())); | 117 this->viewMatrix())); |
118 } | 118 } |
119 | 119 |
120 target->initDraw(gp); | |
121 | |
122 size_t vertexStride = gp->getVertexStride(); | 120 size_t vertexStride = gp->getVertexStride(); |
123 | 121 |
124 SkASSERT(vertexStride == sizeof(GrDefaultGeoProcFactory::PositionAttr)); | 122 SkASSERT(vertexStride == sizeof(GrDefaultGeoProcFactory::PositionAttr)); |
125 | 123 |
126 const Geometry& args = fGeoData[0]; | 124 const Geometry& args = fGeoData[0]; |
127 | 125 |
128 int vertexCount = kVertsPerHairlineRect; | 126 int vertexCount = kVertsPerHairlineRect; |
129 if (args.fStrokeWidth > 0) { | 127 if (args.fStrokeWidth > 0) { |
130 vertexCount = kVertsPerStrokeRect; | 128 vertexCount = kVertsPerStrokeRect; |
131 } | 129 } |
(...skipping 20 matching lines...) Expand all Loading... |
152 primType = kLineStrip_GrPrimitiveType; | 150 primType = kLineStrip_GrPrimitiveType; |
153 vertex[0].set(args.fRect.fLeft, args.fRect.fTop); | 151 vertex[0].set(args.fRect.fLeft, args.fRect.fTop); |
154 vertex[1].set(args.fRect.fRight, args.fRect.fTop); | 152 vertex[1].set(args.fRect.fRight, args.fRect.fTop); |
155 vertex[2].set(args.fRect.fRight, args.fRect.fBottom); | 153 vertex[2].set(args.fRect.fRight, args.fRect.fBottom); |
156 vertex[3].set(args.fRect.fLeft, args.fRect.fBottom); | 154 vertex[3].set(args.fRect.fLeft, args.fRect.fBottom); |
157 vertex[4].set(args.fRect.fLeft, args.fRect.fTop); | 155 vertex[4].set(args.fRect.fLeft, args.fRect.fTop); |
158 } | 156 } |
159 | 157 |
160 GrMesh mesh; | 158 GrMesh mesh; |
161 mesh.init(primType, vertexBuffer, firstVertex, vertexCount); | 159 mesh.init(primType, vertexBuffer, firstVertex, vertexCount); |
162 target->draw(mesh); | 160 target->draw(gp, mesh); |
163 } | 161 } |
164 | 162 |
165 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { | 163 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { |
166 // Handle any color overrides | 164 // Handle any color overrides |
167 if (!overrides.readsColor()) { | 165 if (!overrides.readsColor()) { |
168 fGeoData[0].fColor = GrColor_ILLEGAL; | 166 fGeoData[0].fColor = GrColor_ILLEGAL; |
169 } | 167 } |
170 overrides.getOverrideColorIfSet(&fGeoData[0].fColor); | 168 overrides.getOverrideColorIfSet(&fGeoData[0].fColor); |
171 | 169 |
172 // setup batch properties | 170 // setup batch properties |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 DRAW_BATCH_TEST_DEFINE(NonAAStrokeRectBatch) { | 242 DRAW_BATCH_TEST_DEFINE(NonAAStrokeRectBatch) { |
245 SkMatrix viewMatrix = GrTest::TestMatrix(random); | 243 SkMatrix viewMatrix = GrTest::TestMatrix(random); |
246 GrColor color = GrRandomColor(random); | 244 GrColor color = GrRandomColor(random); |
247 SkRect rect = GrTest::TestRect(random); | 245 SkRect rect = GrTest::TestRect(random); |
248 SkScalar strokeWidth = random->nextBool() ? 0.0f : 1.0f; | 246 SkScalar strokeWidth = random->nextBool() ? 0.0f : 1.0f; |
249 | 247 |
250 return GrNonAAStrokeRectBatch::Create(color, viewMatrix, rect, strokeWidth,
random->nextBool()); | 248 return GrNonAAStrokeRectBatch::Create(color, viewMatrix, rect, strokeWidth,
random->nextBool()); |
251 } | 249 } |
252 | 250 |
253 #endif | 251 #endif |
OLD | NEW |