| 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 |
| 11 #include "gm.h" | 11 #include "gm.h" |
| 12 | 12 |
| 13 #if SK_SUPPORT_GPU | 13 #if SK_SUPPORT_GPU |
| 14 | 14 |
| 15 #include "GrDrawContext.h" |
| 15 #include "GrContext.h" | 16 #include "GrContext.h" |
| 16 #include "GrPathUtils.h" | 17 #include "GrPathUtils.h" |
| 17 #include "GrTest.h" | 18 #include "GrTest.h" |
| 18 #include "SkColorPriv.h" | 19 #include "SkColorPriv.h" |
| 19 #include "SkDevice.h" | 20 #include "SkDevice.h" |
| 20 #include "SkGeometry.h" | 21 #include "SkGeometry.h" |
| 21 | 22 |
| 22 #include "batches/GrTestBatch.h" | 23 #include "batches/GrTestBatch.h" |
| 23 | 24 |
| 24 #include "effects/GrBezierEffect.h" | 25 #include "effects/GrBezierEffect.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget
(); | 123 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget
(); |
| 123 if (nullptr == rt) { | 124 if (nullptr == rt) { |
| 124 skiagm::GM::DrawGpuOnlyMessage(canvas); | 125 skiagm::GM::DrawGpuOnlyMessage(canvas); |
| 125 return; | 126 return; |
| 126 } | 127 } |
| 127 GrContext* context = rt->getContext(); | 128 GrContext* context = rt->getContext(); |
| 128 if (nullptr == context) { | 129 if (nullptr == context) { |
| 129 return; | 130 return; |
| 130 } | 131 } |
| 131 | 132 |
| 133 GrDrawContext* drawContext = context->drawContext(rt); |
| 134 |
| 132 struct Vertex { | 135 struct Vertex { |
| 133 SkPoint fPosition; | 136 SkPoint fPosition; |
| 134 float fKLM[4]; // The last value is ignored. The effect expects a
vec4f. | 137 float fKLM[4]; // The last value is ignored. The effect expects a
vec4f. |
| 135 }; | 138 }; |
| 136 | 139 |
| 137 static const int kNumCubics = 15; | 140 static const int kNumCubics = 15; |
| 138 SkRandom rand; | 141 SkRandom rand; |
| 139 | 142 |
| 140 // Mult by 3 for each edge effect type | 143 // Mult by 3 for each edge effect type |
| 141 int numCols = SkScalarCeilToInt(SkScalarSqrt(SkIntToScalar(kNumCubics*3)
)); | 144 int numCols = SkScalarCeilToInt(SkScalarSqrt(SkIntToScalar(kNumCubics*3)
)); |
| 142 int numRows = SkScalarCeilToInt(SkIntToScalar(kNumCubics*3) / numCols); | 145 int numRows = SkScalarCeilToInt(SkIntToScalar(kNumCubics*3) / numCols); |
| 143 SkScalar w = SkIntToScalar(rt->width()) / numCols; | 146 SkScalar w = SkIntToScalar(rt->width()) / numCols; |
| 144 SkScalar h = SkIntToScalar(rt->height()) / numRows; | 147 SkScalar h = SkIntToScalar(rt->height()) / numRows; |
| 145 int row = 0; | 148 int row = 0; |
| 146 int col = 0; | 149 int col = 0; |
| 147 static const GrColor color = 0xff000000; | 150 static const GrColor color = 0xff000000; |
| 148 | 151 |
| 149 for (int i = 0; i < kNumCubics; ++i) { | 152 for (int i = 0; i < kNumCubics; ++i) { |
| 150 SkPoint baseControlPts[] = { | 153 SkPoint baseControlPts[] = { |
| 151 {rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)}, | 154 {rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)}, |
| 152 {rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)}, | 155 {rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)}, |
| 153 {rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)}, | 156 {rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)}, |
| 154 {rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)} | 157 {rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)} |
| 155 }; | 158 }; |
| 156 for(int edgeType = 0; edgeType < kGrProcessorEdgeTypeCnt; ++edgeType
) { | 159 for(int edgeType = 0; edgeType < kGrProcessorEdgeTypeCnt; ++edgeType
) { |
| 157 SkAutoTUnref<GrGeometryProcessor> gp; | 160 SkAutoTUnref<GrGeometryProcessor> gp; |
| 158 { // scope to contain GrTestTarget | 161 GrPrimitiveEdgeType et = (GrPrimitiveEdgeType)edgeType; |
| 159 GrTestTarget tt; | 162 gp.reset(GrCubicEffect::Create(color, SkMatrix::I(), et, |
| 160 context->getTestTarget(&tt, rt); | 163 *context->caps())); |
| 161 if (nullptr == tt.target()) { | 164 if (!gp) { |
| 162 continue; | 165 continue; |
| 163 } | |
| 164 GrPrimitiveEdgeType et = (GrPrimitiveEdgeType)edgeType; | |
| 165 gp.reset(GrCubicEffect::Create(color, SkMatrix::I(), et, | |
| 166 *tt.target()->caps())); | |
| 167 if (!gp) { | |
| 168 continue; | |
| 169 } | |
| 170 } | 166 } |
| 171 | |
| 172 SkScalar x = SkScalarMul(col, w); | 167 SkScalar x = SkScalarMul(col, w); |
| 173 SkScalar y = SkScalarMul(row, h); | 168 SkScalar y = SkScalarMul(row, h); |
| 174 SkPoint controlPts[] = { | 169 SkPoint controlPts[] = { |
| 175 {x + baseControlPts[0].fX, y + baseControlPts[0].fY}, | 170 {x + baseControlPts[0].fX, y + baseControlPts[0].fY}, |
| 176 {x + baseControlPts[1].fX, y + baseControlPts[1].fY}, | 171 {x + baseControlPts[1].fX, y + baseControlPts[1].fY}, |
| 177 {x + baseControlPts[2].fX, y + baseControlPts[2].fY}, | 172 {x + baseControlPts[2].fX, y + baseControlPts[2].fY}, |
| 178 {x + baseControlPts[3].fX, y + baseControlPts[3].fY} | 173 {x + baseControlPts[3].fX, y + baseControlPts[3].fY} |
| 179 }; | 174 }; |
| 180 SkPoint chopped[10]; | 175 SkPoint chopped[10]; |
| 181 SkScalar klmEqs[9]; | 176 SkScalar klmEqs[9]; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 209 | 204 |
| 210 SkRect bounds; | 205 SkRect bounds; |
| 211 bounds.set(pts, 4); | 206 bounds.set(pts, 4); |
| 212 | 207 |
| 213 SkPaint boundsPaint; | 208 SkPaint boundsPaint; |
| 214 boundsPaint.setColor(0xff808080); | 209 boundsPaint.setColor(0xff808080); |
| 215 boundsPaint.setStrokeWidth(0); | 210 boundsPaint.setStrokeWidth(0); |
| 216 boundsPaint.setStyle(SkPaint::kStroke_Style); | 211 boundsPaint.setStyle(SkPaint::kStroke_Style); |
| 217 canvas->drawRect(bounds, boundsPaint); | 212 canvas->drawRect(bounds, boundsPaint); |
| 218 | 213 |
| 219 GrTestTarget tt; | |
| 220 context->getTestTarget(&tt, rt); | |
| 221 SkASSERT(tt.target()); | |
| 222 | |
| 223 GrPipelineBuilder pipelineBuilder; | 214 GrPipelineBuilder pipelineBuilder; |
| 224 pipelineBuilder.setXPFactory( | 215 pipelineBuilder.setXPFactory( |
| 225 GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->u
nref(); | 216 GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->u
nref(); |
| 226 pipelineBuilder.setRenderTarget(rt); | 217 pipelineBuilder.setRenderTarget(rt); |
| 227 | 218 |
| 228 BezierCubicOrConicTestBatch::Geometry geometry; | 219 BezierCubicOrConicTestBatch::Geometry geometry; |
| 229 geometry.fColor = color; | 220 geometry.fColor = color; |
| 230 geometry.fBounds = bounds; | 221 geometry.fBounds = bounds; |
| 231 | 222 |
| 232 SkAutoTUnref<GrDrawBatch> batch( | 223 SkAutoTUnref<GrDrawBatch> batch( |
| 233 BezierCubicOrConicTestBatch::Create(gp, geometry, kl
mEqs, klmSigns[c])); | 224 BezierCubicOrConicTestBatch::Create(gp, geometry, kl
mEqs, klmSigns[c])); |
| 234 | 225 |
| 235 tt.target()->drawBatch(pipelineBuilder, batch); | 226 drawContext->internal_drawBatch(&pipelineBuilder, batch); |
| 236 } | 227 } |
| 237 ++col; | 228 ++col; |
| 238 if (numCols == col) { | 229 if (numCols == col) { |
| 239 col = 0; | 230 col = 0; |
| 240 ++row; | 231 ++row; |
| 241 } | 232 } |
| 242 } | 233 } |
| 243 } | 234 } |
| 244 } | 235 } |
| 245 | 236 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 272 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget
(); | 263 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget
(); |
| 273 if (nullptr == rt) { | 264 if (nullptr == rt) { |
| 274 skiagm::GM::DrawGpuOnlyMessage(canvas); | 265 skiagm::GM::DrawGpuOnlyMessage(canvas); |
| 275 return; | 266 return; |
| 276 } | 267 } |
| 277 GrContext* context = rt->getContext(); | 268 GrContext* context = rt->getContext(); |
| 278 if (nullptr == context) { | 269 if (nullptr == context) { |
| 279 return; | 270 return; |
| 280 } | 271 } |
| 281 | 272 |
| 273 GrDrawContext* drawContext = context->drawContext(rt); |
| 274 |
| 282 struct Vertex { | 275 struct Vertex { |
| 283 SkPoint fPosition; | 276 SkPoint fPosition; |
| 284 float fKLM[4]; // The last value is ignored. The effect expects a
vec4f. | 277 float fKLM[4]; // The last value is ignored. The effect expects a
vec4f. |
| 285 }; | 278 }; |
| 286 | 279 |
| 287 static const int kNumConics = 10; | 280 static const int kNumConics = 10; |
| 288 SkRandom rand; | 281 SkRandom rand; |
| 289 | 282 |
| 290 // Mult by 3 for each edge effect type | 283 // Mult by 3 for each edge effect type |
| 291 int numCols = SkScalarCeilToInt(SkScalarSqrt(SkIntToScalar(kNumConics*3)
)); | 284 int numCols = SkScalarCeilToInt(SkScalarSqrt(SkIntToScalar(kNumConics*3)
)); |
| 292 int numRows = SkScalarCeilToInt(SkIntToScalar(kNumConics*3) / numCols); | 285 int numRows = SkScalarCeilToInt(SkIntToScalar(kNumConics*3) / numCols); |
| 293 SkScalar w = SkIntToScalar(rt->width()) / numCols; | 286 SkScalar w = SkIntToScalar(rt->width()) / numCols; |
| 294 SkScalar h = SkIntToScalar(rt->height()) / numRows; | 287 SkScalar h = SkIntToScalar(rt->height()) / numRows; |
| 295 int row = 0; | 288 int row = 0; |
| 296 int col = 0; | 289 int col = 0; |
| 297 static const GrColor color = 0xff000000; | 290 static const GrColor color = 0xff000000; |
| 298 | 291 |
| 299 for (int i = 0; i < kNumConics; ++i) { | 292 for (int i = 0; i < kNumConics; ++i) { |
| 300 SkPoint baseControlPts[] = { | 293 SkPoint baseControlPts[] = { |
| 301 {rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)}, | 294 {rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)}, |
| 302 {rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)}, | 295 {rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)}, |
| 303 {rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)} | 296 {rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)} |
| 304 }; | 297 }; |
| 305 SkScalar weight = rand.nextRangeF(0.f, 2.f); | 298 SkScalar weight = rand.nextRangeF(0.f, 2.f); |
| 306 for(int edgeType = 0; edgeType < kGrProcessorEdgeTypeCnt; ++edgeType
) { | 299 for(int edgeType = 0; edgeType < kGrProcessorEdgeTypeCnt; ++edgeType
) { |
| 307 SkAutoTUnref<GrGeometryProcessor> gp; | 300 SkAutoTUnref<GrGeometryProcessor> gp; |
| 308 { // scope to contain GrTestTarget | 301 GrPrimitiveEdgeType et = (GrPrimitiveEdgeType)edgeType; |
| 309 GrTestTarget tt; | 302 gp.reset(GrConicEffect::Create(color, SkMatrix::I(), et, |
| 310 context->getTestTarget(&tt, rt); | 303 *context->caps(), SkMatrix::I(),
false)); |
| 311 if (nullptr == tt.target()) { | 304 if (!gp) { |
| 312 continue; | 305 continue; |
| 313 } | |
| 314 GrPrimitiveEdgeType et = (GrPrimitiveEdgeType)edgeType; | |
| 315 gp.reset(GrConicEffect::Create(color, SkMatrix::I(), et, | |
| 316 *tt.target()->caps(), SkMatri
x::I(), false)); | |
| 317 if (!gp) { | |
| 318 continue; | |
| 319 } | |
| 320 } | 306 } |
| 321 | 307 |
| 322 SkScalar x = SkScalarMul(col, w); | 308 SkScalar x = SkScalarMul(col, w); |
| 323 SkScalar y = SkScalarMul(row, h); | 309 SkScalar y = SkScalarMul(row, h); |
| 324 SkPoint controlPts[] = { | 310 SkPoint controlPts[] = { |
| 325 {x + baseControlPts[0].fX, y + baseControlPts[0].fY}, | 311 {x + baseControlPts[0].fX, y + baseControlPts[0].fY}, |
| 326 {x + baseControlPts[1].fX, y + baseControlPts[1].fY}, | 312 {x + baseControlPts[1].fX, y + baseControlPts[1].fY}, |
| 327 {x + baseControlPts[2].fX, y + baseControlPts[2].fY} | 313 {x + baseControlPts[2].fX, y + baseControlPts[2].fY} |
| 328 }; | 314 }; |
| 329 SkConic dst[4]; | 315 SkConic dst[4]; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 356 //SkPoint bPts[] = {{0.f, 0.f}, {800.f, 800.f}}; | 342 //SkPoint bPts[] = {{0.f, 0.f}, {800.f, 800.f}}; |
| 357 //bounds.set(bPts, 2); | 343 //bounds.set(bPts, 2); |
| 358 bounds.set(pts, 3); | 344 bounds.set(pts, 3); |
| 359 | 345 |
| 360 SkPaint boundsPaint; | 346 SkPaint boundsPaint; |
| 361 boundsPaint.setColor(0xff808080); | 347 boundsPaint.setColor(0xff808080); |
| 362 boundsPaint.setStrokeWidth(0); | 348 boundsPaint.setStrokeWidth(0); |
| 363 boundsPaint.setStyle(SkPaint::kStroke_Style); | 349 boundsPaint.setStyle(SkPaint::kStroke_Style); |
| 364 canvas->drawRect(bounds, boundsPaint); | 350 canvas->drawRect(bounds, boundsPaint); |
| 365 | 351 |
| 366 GrTestTarget tt; | |
| 367 context->getTestTarget(&tt, rt); | |
| 368 SkASSERT(tt.target()); | |
| 369 | |
| 370 GrPipelineBuilder pipelineBuilder; | 352 GrPipelineBuilder pipelineBuilder; |
| 371 pipelineBuilder.setXPFactory( | 353 pipelineBuilder.setXPFactory( |
| 372 GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->u
nref(); | 354 GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->u
nref(); |
| 373 pipelineBuilder.setRenderTarget(rt); | 355 pipelineBuilder.setRenderTarget(rt); |
| 374 | 356 |
| 375 BezierCubicOrConicTestBatch::Geometry geometry; | 357 BezierCubicOrConicTestBatch::Geometry geometry; |
| 376 geometry.fColor = color; | 358 geometry.fColor = color; |
| 377 geometry.fBounds = bounds; | 359 geometry.fBounds = bounds; |
| 378 | 360 |
| 379 SkAutoTUnref<GrDrawBatch> batch( | 361 SkAutoTUnref<GrDrawBatch> batch( |
| 380 BezierCubicOrConicTestBatch::Create(gp, geometry, kl
mEqs, 1.f)); | 362 BezierCubicOrConicTestBatch::Create(gp, geometry, kl
mEqs, 1.f)); |
| 381 | 363 |
| 382 tt.target()->drawBatch(pipelineBuilder, batch); | 364 drawContext->internal_drawBatch(&pipelineBuilder, batch); |
| 383 } | 365 } |
| 384 ++col; | 366 ++col; |
| 385 if (numCols == col) { | 367 if (numCols == col) { |
| 386 col = 0; | 368 col = 0; |
| 387 ++row; | 369 ++row; |
| 388 } | 370 } |
| 389 } | 371 } |
| 390 } | 372 } |
| 391 } | 373 } |
| 392 | 374 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget
(); | 499 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget
(); |
| 518 if (nullptr == rt) { | 500 if (nullptr == rt) { |
| 519 skiagm::GM::DrawGpuOnlyMessage(canvas); | 501 skiagm::GM::DrawGpuOnlyMessage(canvas); |
| 520 return; | 502 return; |
| 521 } | 503 } |
| 522 GrContext* context = rt->getContext(); | 504 GrContext* context = rt->getContext(); |
| 523 if (nullptr == context) { | 505 if (nullptr == context) { |
| 524 return; | 506 return; |
| 525 } | 507 } |
| 526 | 508 |
| 509 GrDrawContext* drawContext = context->drawContext(rt); |
| 510 |
| 527 struct Vertex { | 511 struct Vertex { |
| 528 SkPoint fPosition; | 512 SkPoint fPosition; |
| 529 float fUV[4]; // The last two values are ignored. The effect expec
ts a vec4f. | 513 float fUV[4]; // The last two values are ignored. The effect expec
ts a vec4f. |
| 530 }; | 514 }; |
| 531 | 515 |
| 532 static const int kNumQuads = 5; | 516 static const int kNumQuads = 5; |
| 533 SkRandom rand; | 517 SkRandom rand; |
| 534 | 518 |
| 535 int numCols = SkScalarCeilToInt(SkScalarSqrt(SkIntToScalar(kNumQuads*3))
); | 519 int numCols = SkScalarCeilToInt(SkScalarSqrt(SkIntToScalar(kNumQuads*3))
); |
| 536 int numRows = SkScalarCeilToInt(SkIntToScalar(kNumQuads*3) / numCols); | 520 int numRows = SkScalarCeilToInt(SkIntToScalar(kNumQuads*3) / numCols); |
| 537 SkScalar w = SkIntToScalar(rt->width()) / numCols; | 521 SkScalar w = SkIntToScalar(rt->width()) / numCols; |
| 538 SkScalar h = SkIntToScalar(rt->height()) / numRows; | 522 SkScalar h = SkIntToScalar(rt->height()) / numRows; |
| 539 int row = 0; | 523 int row = 0; |
| 540 int col = 0; | 524 int col = 0; |
| 541 static const GrColor color = 0xff000000; | 525 static const GrColor color = 0xff000000; |
| 542 | 526 |
| 543 for (int i = 0; i < kNumQuads; ++i) { | 527 for (int i = 0; i < kNumQuads; ++i) { |
| 544 SkPoint baseControlPts[] = { | 528 SkPoint baseControlPts[] = { |
| 545 {rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)}, | 529 {rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)}, |
| 546 {rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)}, | 530 {rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)}, |
| 547 {rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)} | 531 {rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)} |
| 548 }; | 532 }; |
| 549 for(int edgeType = 0; edgeType < kGrProcessorEdgeTypeCnt; ++edgeType
) { | 533 for(int edgeType = 0; edgeType < kGrProcessorEdgeTypeCnt; ++edgeType
) { |
| 550 SkAutoTUnref<GrGeometryProcessor> gp; | 534 SkAutoTUnref<GrGeometryProcessor> gp; |
| 551 { // scope to contain GrTestTarget | 535 GrPrimitiveEdgeType et = (GrPrimitiveEdgeType)edgeType; |
| 552 GrTestTarget tt; | 536 gp.reset(GrQuadEffect::Create(color, SkMatrix::I(), et, |
| 553 context->getTestTarget(&tt, rt); | 537 *context->caps(), SkMatrix::I(), f
alse)); |
| 554 if (nullptr == tt.target()) { | 538 if (!gp) { |
| 555 continue; | 539 continue; |
| 556 } | |
| 557 GrPrimitiveEdgeType et = (GrPrimitiveEdgeType)edgeType; | |
| 558 gp.reset(GrQuadEffect::Create(color, SkMatrix::I(), et, | |
| 559 *tt.target()->caps(), SkMatrix
::I(), false)); | |
| 560 if (!gp) { | |
| 561 continue; | |
| 562 } | |
| 563 } | 540 } |
| 564 | 541 |
| 565 SkScalar x = SkScalarMul(col, w); | 542 SkScalar x = SkScalarMul(col, w); |
| 566 SkScalar y = SkScalarMul(row, h); | 543 SkScalar y = SkScalarMul(row, h); |
| 567 SkPoint controlPts[] = { | 544 SkPoint controlPts[] = { |
| 568 {x + baseControlPts[0].fX, y + baseControlPts[0].fY}, | 545 {x + baseControlPts[0].fX, y + baseControlPts[0].fY}, |
| 569 {x + baseControlPts[1].fX, y + baseControlPts[1].fY}, | 546 {x + baseControlPts[1].fX, y + baseControlPts[1].fY}, |
| 570 {x + baseControlPts[2].fX, y + baseControlPts[2].fY} | 547 {x + baseControlPts[2].fX, y + baseControlPts[2].fY} |
| 571 }; | 548 }; |
| 572 SkPoint chopped[5]; | 549 SkPoint chopped[5]; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 596 | 573 |
| 597 SkRect bounds; | 574 SkRect bounds; |
| 598 bounds.set(pts, 3); | 575 bounds.set(pts, 3); |
| 599 | 576 |
| 600 SkPaint boundsPaint; | 577 SkPaint boundsPaint; |
| 601 boundsPaint.setColor(0xff808080); | 578 boundsPaint.setColor(0xff808080); |
| 602 boundsPaint.setStrokeWidth(0); | 579 boundsPaint.setStrokeWidth(0); |
| 603 boundsPaint.setStyle(SkPaint::kStroke_Style); | 580 boundsPaint.setStyle(SkPaint::kStroke_Style); |
| 604 canvas->drawRect(bounds, boundsPaint); | 581 canvas->drawRect(bounds, boundsPaint); |
| 605 | 582 |
| 606 GrTestTarget tt; | |
| 607 context->getTestTarget(&tt, rt); | |
| 608 SkASSERT(tt.target()); | |
| 609 | |
| 610 GrPipelineBuilder pipelineBuilder; | 583 GrPipelineBuilder pipelineBuilder; |
| 611 pipelineBuilder.setXPFactory( | 584 pipelineBuilder.setXPFactory( |
| 612 GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->u
nref(); | 585 GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->u
nref(); |
| 613 pipelineBuilder.setRenderTarget(rt); | 586 pipelineBuilder.setRenderTarget(rt); |
| 614 | 587 |
| 615 GrPathUtils::QuadUVMatrix DevToUV(pts); | 588 GrPathUtils::QuadUVMatrix DevToUV(pts); |
| 616 | 589 |
| 617 BezierQuadTestBatch::Geometry geometry; | 590 BezierQuadTestBatch::Geometry geometry; |
| 618 geometry.fColor = color; | 591 geometry.fColor = color; |
| 619 geometry.fBounds = bounds; | 592 geometry.fBounds = bounds; |
| 620 | 593 |
| 621 SkAutoTUnref<GrDrawBatch> batch(BezierQuadTestBatch::Create(
gp, geometry, | 594 SkAutoTUnref<GrDrawBatch> batch(BezierQuadTestBatch::Create(
gp, geometry, |
| 622
DevToUV)); | 595
DevToUV)); |
| 623 | 596 |
| 624 tt.target()->drawBatch(pipelineBuilder, batch); | 597 drawContext->internal_drawBatch(&pipelineBuilder, batch); |
| 625 } | 598 } |
| 626 ++col; | 599 ++col; |
| 627 if (numCols == col) { | 600 if (numCols == col) { |
| 628 col = 0; | 601 col = 0; |
| 629 ++row; | 602 ++row; |
| 630 } | 603 } |
| 631 } | 604 } |
| 632 } | 605 } |
| 633 } | 606 } |
| 634 | 607 |
| 635 private: | 608 private: |
| 636 typedef GM INHERITED; | 609 typedef GM INHERITED; |
| 637 }; | 610 }; |
| 638 | 611 |
| 639 DEF_GM(return new BezierCubicEffects;) | 612 DEF_GM(return new BezierCubicEffects;) |
| 640 DEF_GM(return new BezierConicEffects;) | 613 DEF_GM(return new BezierConicEffects;) |
| 641 DEF_GM(return new BezierQuadEffects;) | 614 DEF_GM(return new BezierQuadEffects;) |
| 642 } | 615 } |
| 643 | 616 |
| 644 #endif | 617 #endif |
| OLD | NEW |