OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 // This test only works with the GPU backend. | 9 // This test only works with the GPU backend. |
10 | 10 |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 SkPaint boundsPaint; | 151 SkPaint boundsPaint; |
152 boundsPaint.setColor(0xff808080); | 152 boundsPaint.setColor(0xff808080); |
153 boundsPaint.setStrokeWidth(0); | 153 boundsPaint.setStrokeWidth(0); |
154 boundsPaint.setStyle(SkPaint::kStroke_Style); | 154 boundsPaint.setStyle(SkPaint::kStroke_Style); |
155 canvas->drawRect(bounds, boundsPaint); | 155 canvas->drawRect(bounds, boundsPaint); |
156 | 156 |
157 GrTestTarget tt; | 157 GrTestTarget tt; |
158 context->getTestTarget(&tt); | 158 context->getTestTarget(&tt); |
159 SkASSERT(tt.target()); | 159 SkASSERT(tt.target()); |
160 | 160 |
161 GrDrawState* drawState = tt.target()->drawState(); | 161 GrDrawState ds; |
162 drawState->setVertexAttribs<kAttribs>(2, sizeof(Vertex)); | 162 ds.setVertexAttribs<kAttribs>(2, sizeof(Vertex)); |
163 | 163 |
164 GrDrawTarget::AutoReleaseGeometry geo(tt.target(), 4, 0); | 164 GrDrawTarget::AutoReleaseGeometry geo(tt.target(), 4, ds.get
VertexStride(), 0); |
165 Vertex* verts = reinterpret_cast<Vertex*>(geo.vertices()); | 165 Vertex* verts = reinterpret_cast<Vertex*>(geo.vertices()); |
166 | 166 |
167 verts[0].fPosition.setRectFan(bounds.fLeft, bounds.fTop, | 167 verts[0].fPosition.setRectFan(bounds.fLeft, bounds.fTop, |
168 bounds.fRight, bounds.fBottom, | 168 bounds.fRight, bounds.fBottom, |
169 sizeof(Vertex)); | 169 sizeof(Vertex)); |
170 for (int v = 0; v < 4; ++v) { | 170 for (int v = 0; v < 4; ++v) { |
171 verts[v].fKLM[0] = eval_line(verts[v].fPosition, klmEqs
+ 0, klmSigns[c]); | 171 verts[v].fKLM[0] = eval_line(verts[v].fPosition, klmEqs
+ 0, klmSigns[c]); |
172 verts[v].fKLM[1] = eval_line(verts[v].fPosition, klmEqs
+ 3, klmSigns[c]); | 172 verts[v].fKLM[1] = eval_line(verts[v].fPosition, klmEqs
+ 3, klmSigns[c]); |
173 verts[v].fKLM[2] = eval_line(verts[v].fPosition, klmEqs
+ 6, 1.f); | 173 verts[v].fKLM[2] = eval_line(verts[v].fPosition, klmEqs
+ 6, 1.f); |
174 } | 174 } |
175 | 175 |
176 drawState->setGeometryProcessor(gp); | 176 ds.setGeometryProcessor(gp); |
177 drawState->setRenderTarget(rt); | 177 ds.setRenderTarget(rt); |
178 drawState->setColor(0xff000000); | 178 ds.setColor(0xff000000); |
179 | 179 |
180 tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuf
fer()); | 180 tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuf
fer()); |
181 tt.target()->drawIndexed(kTriangleFan_GrPrimitiveType, 0, 0,
4, 6); | 181 tt.target()->drawIndexed(&ds, kTriangleFan_GrPrimitiveType,
0, 0, 4, 6); |
182 } | 182 } |
183 ++col; | 183 ++col; |
184 if (numCols == col) { | 184 if (numCols == col) { |
185 col = 0; | 185 col = 0; |
186 ++row; | 186 ++row; |
187 } | 187 } |
188 } | 188 } |
189 } | 189 } |
190 } | 190 } |
191 | 191 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 SkPaint boundsPaint; | 308 SkPaint boundsPaint; |
309 boundsPaint.setColor(0xff808080); | 309 boundsPaint.setColor(0xff808080); |
310 boundsPaint.setStrokeWidth(0); | 310 boundsPaint.setStrokeWidth(0); |
311 boundsPaint.setStyle(SkPaint::kStroke_Style); | 311 boundsPaint.setStyle(SkPaint::kStroke_Style); |
312 canvas->drawRect(bounds, boundsPaint); | 312 canvas->drawRect(bounds, boundsPaint); |
313 | 313 |
314 GrTestTarget tt; | 314 GrTestTarget tt; |
315 context->getTestTarget(&tt); | 315 context->getTestTarget(&tt); |
316 SkASSERT(tt.target()); | 316 SkASSERT(tt.target()); |
317 | 317 |
318 GrDrawState* drawState = tt.target()->drawState(); | 318 GrDrawState ds; |
319 drawState->setVertexAttribs<kAttribs>(2, sizeof(Vertex)); | 319 ds.setVertexAttribs<kAttribs>(2, sizeof(Vertex)); |
320 | 320 |
321 GrDrawTarget::AutoReleaseGeometry geo(tt.target(), 4, 0); | 321 GrDrawTarget::AutoReleaseGeometry geo(tt.target(), 4, ds.get
VertexStride(), 0); |
322 Vertex* verts = reinterpret_cast<Vertex*>(geo.vertices()); | 322 Vertex* verts = reinterpret_cast<Vertex*>(geo.vertices()); |
323 | 323 |
324 verts[0].fPosition.setRectFan(bounds.fLeft, bounds.fTop, | 324 verts[0].fPosition.setRectFan(bounds.fLeft, bounds.fTop, |
325 bounds.fRight, bounds.fBottom, | 325 bounds.fRight, bounds.fBottom, |
326 sizeof(Vertex)); | 326 sizeof(Vertex)); |
327 for (int v = 0; v < 4; ++v) { | 327 for (int v = 0; v < 4; ++v) { |
328 verts[v].fKLM[0] = eval_line(verts[v].fPosition, klmEqs
+ 0, 1.f); | 328 verts[v].fKLM[0] = eval_line(verts[v].fPosition, klmEqs
+ 0, 1.f); |
329 verts[v].fKLM[1] = eval_line(verts[v].fPosition, klmEqs
+ 3, 1.f); | 329 verts[v].fKLM[1] = eval_line(verts[v].fPosition, klmEqs
+ 3, 1.f); |
330 verts[v].fKLM[2] = eval_line(verts[v].fPosition, klmEqs
+ 6, 1.f); | 330 verts[v].fKLM[2] = eval_line(verts[v].fPosition, klmEqs
+ 6, 1.f); |
331 } | 331 } |
332 | 332 |
333 drawState->setGeometryProcessor(gp); | 333 ds.setGeometryProcessor(gp); |
334 drawState->setRenderTarget(rt); | 334 ds.setRenderTarget(rt); |
335 drawState->setColor(0xff000000); | 335 ds.setColor(0xff000000); |
336 | 336 |
337 tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuf
fer()); | 337 tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuf
fer()); |
338 tt.target()->drawIndexed(kTriangleFan_GrPrimitiveType, 0, 0,
4, 6); | 338 tt.target()->drawIndexed(&ds, kTriangleFan_GrPrimitiveType,
0, 0, 4, 6); |
339 } | 339 } |
340 ++col; | 340 ++col; |
341 if (numCols == col) { | 341 if (numCols == col) { |
342 col = 0; | 342 col = 0; |
343 ++row; | 343 ++row; |
344 } | 344 } |
345 } | 345 } |
346 } | 346 } |
347 } | 347 } |
348 | 348 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 SkPaint boundsPaint; | 496 SkPaint boundsPaint; |
497 boundsPaint.setColor(0xff808080); | 497 boundsPaint.setColor(0xff808080); |
498 boundsPaint.setStrokeWidth(0); | 498 boundsPaint.setStrokeWidth(0); |
499 boundsPaint.setStyle(SkPaint::kStroke_Style); | 499 boundsPaint.setStyle(SkPaint::kStroke_Style); |
500 canvas->drawRect(bounds, boundsPaint); | 500 canvas->drawRect(bounds, boundsPaint); |
501 | 501 |
502 GrTestTarget tt; | 502 GrTestTarget tt; |
503 context->getTestTarget(&tt); | 503 context->getTestTarget(&tt); |
504 SkASSERT(tt.target()); | 504 SkASSERT(tt.target()); |
505 | 505 |
506 GrDrawState* drawState = tt.target()->drawState(); | 506 GrDrawState ds; |
507 drawState->setVertexAttribs<kAttribs>(2, sizeof(Vertex)); | 507 ds.setVertexAttribs<kAttribs>(2, sizeof(Vertex)); |
508 | 508 |
509 GrDrawTarget::AutoReleaseGeometry geo(tt.target(), 4, 0); | 509 GrDrawTarget::AutoReleaseGeometry geo(tt.target(), 4, ds.get
VertexStride(), 0); |
510 Vertex* verts = reinterpret_cast<Vertex*>(geo.vertices()); | 510 Vertex* verts = reinterpret_cast<Vertex*>(geo.vertices()); |
511 | 511 |
512 verts[0].fPosition.setRectFan(bounds.fLeft, bounds.fTop, | 512 verts[0].fPosition.setRectFan(bounds.fLeft, bounds.fTop, |
513 bounds.fRight, bounds.fBottom, | 513 bounds.fRight, bounds.fBottom, |
514 sizeof(Vertex)); | 514 sizeof(Vertex)); |
515 | 515 |
516 GrPathUtils::QuadUVMatrix DevToUV(pts); | 516 GrPathUtils::QuadUVMatrix DevToUV(pts); |
517 DevToUV.apply<4, sizeof(Vertex), sizeof(SkPoint)>(verts); | 517 DevToUV.apply<4, sizeof(Vertex), sizeof(SkPoint)>(verts); |
518 | 518 |
519 drawState->setGeometryProcessor(gp); | 519 ds.setGeometryProcessor(gp); |
520 drawState->setRenderTarget(rt); | 520 ds.setRenderTarget(rt); |
521 drawState->setColor(0xff000000); | 521 ds.setColor(0xff000000); |
522 | 522 |
523 tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuf
fer()); | 523 tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuf
fer()); |
524 tt.target()->drawIndexed(kTriangles_GrPrimitiveType, 0, 0, 4
, 6); | 524 tt.target()->drawIndexed(&ds, kTriangles_GrPrimitiveType, 0,
0, 4, 6); |
525 } | 525 } |
526 ++col; | 526 ++col; |
527 if (numCols == col) { | 527 if (numCols == col) { |
528 col = 0; | 528 col = 0; |
529 ++row; | 529 ++row; |
530 } | 530 } |
531 } | 531 } |
532 } | 532 } |
533 } | 533 } |
534 | 534 |
535 private: | 535 private: |
536 typedef GM INHERITED; | 536 typedef GM INHERITED; |
537 }; | 537 }; |
538 | 538 |
539 DEF_GM( return SkNEW(BezierCubicEffects); ) | 539 DEF_GM( return SkNEW(BezierCubicEffects); ) |
540 DEF_GM( return SkNEW(BezierConicEffects); ) | 540 DEF_GM( return SkNEW(BezierConicEffects); ) |
541 DEF_GM( return SkNEW(BezierQuadEffects); ) | 541 DEF_GM( return SkNEW(BezierQuadEffects); ) |
542 | 542 |
543 } | 543 } |
544 | 544 |
545 #endif | 545 #endif |
OLD | NEW |