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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 | 147 |
148 SkRect bounds; | 148 SkRect bounds; |
149 bounds.set(pts, 4); | 149 bounds.set(pts, 4); |
150 | 150 |
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 Vertex verts[4]; | 157 GrTestTarget tt; |
| 158 context->getTestTarget(&tt); |
| 159 SkASSERT(tt.target()); |
| 160 |
| 161 GrDrawState* drawState = tt.target()->drawState(); |
| 162 drawState->setVertexAttribs<kAttribs>(2, sizeof(Vertex)); |
| 163 |
| 164 GrDrawTarget::AutoReleaseGeometry geo(tt.target(), 4, 0); |
| 165 Vertex* verts = reinterpret_cast<Vertex*>(geo.vertices()); |
| 166 |
158 verts[0].fPosition.setRectFan(bounds.fLeft, bounds.fTop, | 167 verts[0].fPosition.setRectFan(bounds.fLeft, bounds.fTop, |
159 bounds.fRight, bounds.fBottom, | 168 bounds.fRight, bounds.fBottom, |
160 sizeof(Vertex)); | 169 sizeof(Vertex)); |
161 for (int v = 0; v < 4; ++v) { | 170 for (int v = 0; v < 4; ++v) { |
162 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]); |
163 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]); |
164 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); |
165 } | 174 } |
166 | 175 |
167 GrTestTarget tt; | |
168 context->getTestTarget(&tt); | |
169 SkASSERT(tt.target()); | |
170 GrDrawState* drawState = tt.target()->drawState(); | |
171 drawState->setVertexAttribs<kAttribs>(2, sizeof(Vertex)); | |
172 | |
173 drawState->setGeometryProcessor(gp); | 176 drawState->setGeometryProcessor(gp); |
174 drawState->setRenderTarget(rt); | 177 drawState->setRenderTarget(rt); |
175 drawState->setColor(0xff000000); | 178 drawState->setColor(0xff000000); |
176 | 179 |
177 tt.target()->setVertexSourceToArray(verts, 4); | |
178 tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuf
fer()); | 180 tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuf
fer()); |
179 tt.target()->drawIndexed(kTriangleFan_GrPrimitiveType, 0, 0,
4, 6); | 181 tt.target()->drawIndexed(kTriangleFan_GrPrimitiveType, 0, 0,
4, 6); |
180 } | 182 } |
181 ++col; | 183 ++col; |
182 if (numCols == col) { | 184 if (numCols == col) { |
183 col = 0; | 185 col = 0; |
184 ++row; | 186 ++row; |
185 } | 187 } |
186 } | 188 } |
187 } | 189 } |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 //SkPoint bPts[] = {{0.f, 0.f}, {800.f, 800.f}}; | 304 //SkPoint bPts[] = {{0.f, 0.f}, {800.f, 800.f}}; |
303 //bounds.set(bPts, 2); | 305 //bounds.set(bPts, 2); |
304 bounds.set(pts, 3); | 306 bounds.set(pts, 3); |
305 | 307 |
306 SkPaint boundsPaint; | 308 SkPaint boundsPaint; |
307 boundsPaint.setColor(0xff808080); | 309 boundsPaint.setColor(0xff808080); |
308 boundsPaint.setStrokeWidth(0); | 310 boundsPaint.setStrokeWidth(0); |
309 boundsPaint.setStyle(SkPaint::kStroke_Style); | 311 boundsPaint.setStyle(SkPaint::kStroke_Style); |
310 canvas->drawRect(bounds, boundsPaint); | 312 canvas->drawRect(bounds, boundsPaint); |
311 | 313 |
312 Vertex verts[4]; | 314 GrTestTarget tt; |
| 315 context->getTestTarget(&tt); |
| 316 SkASSERT(tt.target()); |
| 317 |
| 318 GrDrawState* drawState = tt.target()->drawState(); |
| 319 drawState->setVertexAttribs<kAttribs>(2, sizeof(Vertex)); |
| 320 |
| 321 GrDrawTarget::AutoReleaseGeometry geo(tt.target(), 4, 0); |
| 322 Vertex* verts = reinterpret_cast<Vertex*>(geo.vertices()); |
| 323 |
313 verts[0].fPosition.setRectFan(bounds.fLeft, bounds.fTop, | 324 verts[0].fPosition.setRectFan(bounds.fLeft, bounds.fTop, |
314 bounds.fRight, bounds.fBottom, | 325 bounds.fRight, bounds.fBottom, |
315 sizeof(Vertex)); | 326 sizeof(Vertex)); |
316 for (int v = 0; v < 4; ++v) { | 327 for (int v = 0; v < 4; ++v) { |
317 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); |
318 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); |
319 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); |
320 } | 331 } |
321 | 332 |
322 GrTestTarget tt; | |
323 context->getTestTarget(&tt); | |
324 SkASSERT(tt.target()); | |
325 GrDrawState* drawState = tt.target()->drawState(); | |
326 drawState->setVertexAttribs<kAttribs>(2, sizeof(Vertex)); | |
327 | |
328 drawState->setGeometryProcessor(gp); | 333 drawState->setGeometryProcessor(gp); |
329 drawState->setRenderTarget(rt); | 334 drawState->setRenderTarget(rt); |
330 drawState->setColor(0xff000000); | 335 drawState->setColor(0xff000000); |
331 | 336 |
332 tt.target()->setVertexSourceToArray(verts, 4); | |
333 tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuf
fer()); | 337 tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuf
fer()); |
334 tt.target()->drawIndexed(kTriangleFan_GrPrimitiveType, 0, 0,
4, 6); | 338 tt.target()->drawIndexed(kTriangleFan_GrPrimitiveType, 0, 0,
4, 6); |
335 } | 339 } |
336 ++col; | 340 ++col; |
337 if (numCols == col) { | 341 if (numCols == col) { |
338 col = 0; | 342 col = 0; |
339 ++row; | 343 ++row; |
340 } | 344 } |
341 } | 345 } |
342 } | 346 } |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 | 492 |
489 SkRect bounds; | 493 SkRect bounds; |
490 bounds.set(pts, 3); | 494 bounds.set(pts, 3); |
491 | 495 |
492 SkPaint boundsPaint; | 496 SkPaint boundsPaint; |
493 boundsPaint.setColor(0xff808080); | 497 boundsPaint.setColor(0xff808080); |
494 boundsPaint.setStrokeWidth(0); | 498 boundsPaint.setStrokeWidth(0); |
495 boundsPaint.setStyle(SkPaint::kStroke_Style); | 499 boundsPaint.setStyle(SkPaint::kStroke_Style); |
496 canvas->drawRect(bounds, boundsPaint); | 500 canvas->drawRect(bounds, boundsPaint); |
497 | 501 |
498 Vertex verts[4]; | 502 GrTestTarget tt; |
| 503 context->getTestTarget(&tt); |
| 504 SkASSERT(tt.target()); |
| 505 |
| 506 GrDrawState* drawState = tt.target()->drawState(); |
| 507 drawState->setVertexAttribs<kAttribs>(2, sizeof(Vertex)); |
| 508 |
| 509 GrDrawTarget::AutoReleaseGeometry geo(tt.target(), 4, 0); |
| 510 Vertex* verts = reinterpret_cast<Vertex*>(geo.vertices()); |
| 511 |
499 verts[0].fPosition.setRectFan(bounds.fLeft, bounds.fTop, | 512 verts[0].fPosition.setRectFan(bounds.fLeft, bounds.fTop, |
500 bounds.fRight, bounds.fBottom, | 513 bounds.fRight, bounds.fBottom, |
501 sizeof(Vertex)); | 514 sizeof(Vertex)); |
502 | 515 |
503 GrPathUtils::QuadUVMatrix DevToUV(pts); | 516 GrPathUtils::QuadUVMatrix DevToUV(pts); |
504 DevToUV.apply<4, sizeof(Vertex), sizeof(SkPoint)>(verts); | 517 DevToUV.apply<4, sizeof(Vertex), sizeof(SkPoint)>(verts); |
505 | 518 |
506 GrTestTarget tt; | |
507 context->getTestTarget(&tt); | |
508 SkASSERT(tt.target()); | |
509 GrDrawState* drawState = tt.target()->drawState(); | |
510 drawState->setVertexAttribs<kAttribs>(2, sizeof(Vertex)); | |
511 | |
512 drawState->setGeometryProcessor(gp); | 519 drawState->setGeometryProcessor(gp); |
513 drawState->setRenderTarget(rt); | 520 drawState->setRenderTarget(rt); |
514 drawState->setColor(0xff000000); | 521 drawState->setColor(0xff000000); |
515 | 522 |
516 tt.target()->setVertexSourceToArray(verts, 4); | |
517 tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuf
fer()); | 523 tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuf
fer()); |
518 tt.target()->drawIndexed(kTriangles_GrPrimitiveType, 0, 0, 4
, 6); | 524 tt.target()->drawIndexed(kTriangles_GrPrimitiveType, 0, 0, 4
, 6); |
519 } | 525 } |
520 ++col; | 526 ++col; |
521 if (numCols == col) { | 527 if (numCols == col) { |
522 col = 0; | 528 col = 0; |
523 ++row; | 529 ++row; |
524 } | 530 } |
525 } | 531 } |
526 } | 532 } |
527 } | 533 } |
528 | 534 |
529 private: | 535 private: |
530 typedef GM INHERITED; | 536 typedef GM INHERITED; |
531 }; | 537 }; |
532 | 538 |
533 DEF_GM( return SkNEW(BezierCubicEffects); ) | 539 DEF_GM( return SkNEW(BezierCubicEffects); ) |
534 DEF_GM( return SkNEW(BezierConicEffects); ) | 540 DEF_GM( return SkNEW(BezierConicEffects); ) |
535 DEF_GM( return SkNEW(BezierQuadEffects); ) | 541 DEF_GM( return SkNEW(BezierQuadEffects); ) |
536 | 542 |
537 } | 543 } |
538 | 544 |
539 #endif | 545 #endif |
OLD | NEW |