OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "GrAARectRenderer.h" | 8 #include "GrAARectRenderer.h" |
9 #include "GrRefCnt.h" | 9 #include "GrRefCnt.h" |
10 #include "GrGpu.h" | 10 #include "GrGpu.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 } | 123 } |
124 | 124 |
125 void GrAARectRenderer::fillAARect(GrGpu* gpu, | 125 void GrAARectRenderer::fillAARect(GrGpu* gpu, |
126 GrDrawTarget* target, | 126 GrDrawTarget* target, |
127 const GrRect& devRect, | 127 const GrRect& devRect, |
128 bool useVertexCoverage) { | 128 bool useVertexCoverage) { |
129 GrDrawState* drawState = target->drawState(); | 129 GrDrawState* drawState = target->drawState(); |
130 | 130 |
131 // position + color/coverage | 131 // position + color/coverage |
132 static const GrVertexAttrib kVertexAttribs[] = { | 132 static const GrVertexAttrib kVertexAttribs[] = { |
133 GrVertexAttrib(kVec2f_GrVertexAttribType, 0), | 133 {kVec2f_GrVertexAttribType, 0}, |
134 GrVertexAttrib(kVec4ub_GrVertexAttribType, sizeof(GrPoint)) | 134 {kVec4ub_GrVertexAttribType, sizeof(GrPoint)} |
135 }; | 135 }; |
136 GrAttribBindings bindings; | 136 GrAttribBindings bindings; |
137 GrDrawState::AttribIndex attribIndex; | 137 GrDrawState::AttribIndex attribIndex; |
138 aa_rect_attributes(useVertexCoverage, &bindings, &attribIndex); | 138 aa_rect_attributes(useVertexCoverage, &bindings, &attribIndex); |
139 drawState->setVertexAttribs(kVertexAttribs, SK_ARRAY_COUNT(kVertexAttribs)); | 139 drawState->setVertexAttribs(kVertexAttribs, SK_ARRAY_COUNT(kVertexAttribs)); |
140 drawState->setAttribBindings(bindings); | 140 drawState->setAttribBindings(bindings); |
141 drawState->setAttribIndex(GrDrawState::kPosition_AttribIndex, 0); | 141 drawState->setAttribIndex(GrDrawState::kPosition_AttribIndex, 0); |
142 drawState->setAttribIndex(attribIndex, 1); | 142 drawState->setAttribIndex(attribIndex, 1); |
143 | 143 |
144 GrDrawTarget::AutoReleaseGeometry geo(target, 8, 0); | 144 GrDrawTarget::AutoReleaseGeometry geo(target, 8, 0); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 | 207 |
208 if (spare <= 0) { | 208 if (spare <= 0) { |
209 GrRect r(devRect); | 209 GrRect r(devRect); |
210 r.inset(-rx, -ry); | 210 r.inset(-rx, -ry); |
211 this->fillAARect(gpu, target, r, useVertexCoverage); | 211 this->fillAARect(gpu, target, r, useVertexCoverage); |
212 return; | 212 return; |
213 } | 213 } |
214 | 214 |
215 // position + color/coverage | 215 // position + color/coverage |
216 static const GrVertexAttrib kVertexAttribs[] = { | 216 static const GrVertexAttrib kVertexAttribs[] = { |
217 GrVertexAttrib(kVec2f_GrVertexAttribType, 0), | 217 {kVec2f_GrVertexAttribType, 0}, |
218 GrVertexAttrib(kVec4ub_GrVertexAttribType, sizeof(GrPoint)) | 218 {kVec4ub_GrVertexAttribType, sizeof(GrPoint)} |
219 }; | 219 }; |
220 GrAttribBindings bindings; | 220 GrAttribBindings bindings; |
221 GrDrawState::AttribIndex attribIndex; | 221 GrDrawState::AttribIndex attribIndex; |
222 aa_rect_attributes(useVertexCoverage, &bindings, &attribIndex); | 222 aa_rect_attributes(useVertexCoverage, &bindings, &attribIndex); |
223 drawState->setVertexAttribs(kVertexAttribs, SK_ARRAY_COUNT(kVertexAttribs)); | 223 drawState->setVertexAttribs(kVertexAttribs, SK_ARRAY_COUNT(kVertexAttribs)); |
224 drawState->setAttribBindings(bindings); | 224 drawState->setAttribBindings(bindings); |
225 drawState->setAttribIndex(GrDrawState::kPosition_AttribIndex, 0); | 225 drawState->setAttribIndex(GrDrawState::kPosition_AttribIndex, 0); |
226 drawState->setAttribIndex(attribIndex, 1); | 226 drawState->setAttribIndex(attribIndex, 1); |
227 | 227 |
228 GrDrawTarget::AutoReleaseGeometry geo(target, 16, 0); | 228 GrDrawTarget::AutoReleaseGeometry geo(target, 16, 0); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 // The innermost rect has full coverage | 278 // The innermost rect has full coverage |
279 verts += 8 * vsize; | 279 verts += 8 * vsize; |
280 for (int i = 0; i < 4; ++i) { | 280 for (int i = 0; i < 4; ++i) { |
281 *reinterpret_cast<GrColor*>(verts + i * vsize) = 0; | 281 *reinterpret_cast<GrColor*>(verts + i * vsize) = 0; |
282 } | 282 } |
283 | 283 |
284 target->setIndexSourceToBuffer(indexBuffer); | 284 target->setIndexSourceToBuffer(indexBuffer); |
285 target->drawIndexed(kTriangles_GrPrimitiveType, | 285 target->drawIndexed(kTriangles_GrPrimitiveType, |
286 0, 0, 16, aaStrokeRectIndexCount()); | 286 0, 0, 16, aaStrokeRectIndexCount()); |
287 } | 287 } |
OLD | NEW |