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 "GrStrokeRectBatch.h" | 8 #include "GrStrokeRectBatch.h" |
9 #include "GrBatchTest.h" | 9 #include "GrBatchTest.h" |
10 #include "SkRandom.h" | 10 #include "SkRandom.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 verts[3].set(rect.fRight + rad, rect.fTop - rad); | 59 verts[3].set(rect.fRight + rad, rect.fTop - rad); |
60 verts[4].set(rect.fRight - rad, rect.fBottom - rad); | 60 verts[4].set(rect.fRight - rad, rect.fBottom - rad); |
61 verts[5].set(rect.fRight + rad, rect.fBottom + rad); | 61 verts[5].set(rect.fRight + rad, rect.fBottom + rad); |
62 verts[6].set(rect.fLeft + rad, rect.fBottom - rad); | 62 verts[6].set(rect.fLeft + rad, rect.fBottom - rad); |
63 verts[7].set(rect.fLeft - rad, rect.fBottom + rad); | 63 verts[7].set(rect.fLeft - rad, rect.fBottom + rad); |
64 verts[8] = verts[0]; | 64 verts[8] = verts[0]; |
65 verts[9] = verts[1]; | 65 verts[9] = verts[1]; |
66 } | 66 } |
67 | 67 |
68 | 68 |
69 void GrStrokeRectBatch::generateGeometry(GrBatchTarget* batchTarget, const GrPip
eline* pipeline) { | 69 void GrStrokeRectBatch::generateGeometry(GrBatchTarget* batchTarget) { |
70 SkAutoTUnref<const GrGeometryProcessor> gp; | 70 SkAutoTUnref<const GrGeometryProcessor> gp; |
71 { | 71 { |
72 using namespace GrDefaultGeoProcFactory; | 72 using namespace GrDefaultGeoProcFactory; |
73 Color color(this->color()); | 73 Color color(this->color()); |
74 Coverage coverage(this->coverageIgnored() ? Coverage::kSolid_Type : | 74 Coverage coverage(this->coverageIgnored() ? Coverage::kSolid_Type : |
75 Coverage::kNone_Type); | 75 Coverage::kNone_Type); |
76 LocalCoords localCoords(this->usesLocalCoords() ? LocalCoords::kUsePosit
ion_Type : | 76 LocalCoords localCoords(this->usesLocalCoords() ? LocalCoords::kUsePosit
ion_Type : |
77 LocalCoords::kUnused
_Type); | 77 LocalCoords::kUnused
_Type); |
78 gp.reset(GrDefaultGeoProcFactory::Create(color, coverage, localCoords, | 78 gp.reset(GrDefaultGeoProcFactory::Create(color, coverage, localCoords, |
79 this->viewMatrix())); | 79 this->viewMatrix())); |
80 } | 80 } |
81 | 81 |
82 batchTarget->initDraw(gp, pipeline); | 82 batchTarget->initDraw(gp, this->pipeline()); |
83 | 83 |
84 size_t vertexStride = gp->getVertexStride(); | 84 size_t vertexStride = gp->getVertexStride(); |
85 | 85 |
86 SkASSERT(vertexStride == sizeof(GrDefaultGeoProcFactory::PositionAttr)); | 86 SkASSERT(vertexStride == sizeof(GrDefaultGeoProcFactory::PositionAttr)); |
87 | 87 |
88 Geometry& args = fGeoData[0]; | 88 Geometry& args = fGeoData[0]; |
89 | 89 |
90 int vertexCount = kVertsPerHairlineRect; | 90 int vertexCount = kVertsPerHairlineRect; |
91 if (args.fStrokeWidth > 0) { | 91 if (args.fStrokeWidth > 0) { |
92 vertexCount = kVertsPerStrokeRect; | 92 vertexCount = kVertsPerStrokeRect; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 GrStrokeRectBatch::Geometry geometry; | 132 GrStrokeRectBatch::Geometry geometry; |
133 geometry.fViewMatrix = GrTest::TestMatrix(random); | 133 geometry.fViewMatrix = GrTest::TestMatrix(random); |
134 geometry.fColor = GrRandomColor(random); | 134 geometry.fColor = GrRandomColor(random); |
135 geometry.fRect = GrTest::TestRect(random); | 135 geometry.fRect = GrTest::TestRect(random); |
136 geometry.fStrokeWidth = random->nextBool() ? 0.0f : 1.0f; | 136 geometry.fStrokeWidth = random->nextBool() ? 0.0f : 1.0f; |
137 | 137 |
138 return GrStrokeRectBatch::Create(geometry, random->nextBool()); | 138 return GrStrokeRectBatch::Create(geometry, random->nextBool()); |
139 } | 139 } |
140 | 140 |
141 #endif | 141 #endif |
OLD | NEW |