| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 SkString onShortName() override { | 114 SkString onShortName() override { |
| 115 return SkString("bezier_cubic_effects"); | 115 return SkString("bezier_cubic_effects"); |
| 116 } | 116 } |
| 117 | 117 |
| 118 SkISize onISize() override { | 118 SkISize onISize() override { |
| 119 return SkISize::Make(800, 800); | 119 return SkISize::Make(800, 800); |
| 120 } | 120 } |
| 121 | 121 |
| 122 void onDraw(SkCanvas* canvas) override { | 122 void onDraw(SkCanvas* canvas) override { |
| 123 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget
(); | 123 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget
(); |
| 124 if (NULL == rt) { | 124 if (nullptr == rt) { |
| 125 this->drawGpuOnlyMessage(canvas); | 125 this->drawGpuOnlyMessage(canvas); |
| 126 return; | 126 return; |
| 127 } | 127 } |
| 128 GrContext* context = rt->getContext(); | 128 GrContext* context = rt->getContext(); |
| 129 if (NULL == context) { | 129 if (nullptr == context) { |
| 130 return; | 130 return; |
| 131 } | 131 } |
| 132 | 132 |
| 133 struct Vertex { | 133 struct Vertex { |
| 134 SkPoint fPosition; | 134 SkPoint fPosition; |
| 135 float fKLM[4]; // The last value is ignored. The effect expects a
vec4f. | 135 float fKLM[4]; // The last value is ignored. The effect expects a
vec4f. |
| 136 }; | 136 }; |
| 137 | 137 |
| 138 static const int kNumCubics = 15; | 138 static const int kNumCubics = 15; |
| 139 SkRandom rand; | 139 SkRandom rand; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 152 {rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)}, | 152 {rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)}, |
| 153 {rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)}, | 153 {rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)}, |
| 154 {rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)}, | 154 {rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)}, |
| 155 {rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)} | 155 {rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)} |
| 156 }; | 156 }; |
| 157 for(int edgeType = 0; edgeType < kGrProcessorEdgeTypeCnt; ++edgeType
) { | 157 for(int edgeType = 0; edgeType < kGrProcessorEdgeTypeCnt; ++edgeType
) { |
| 158 SkAutoTUnref<GrGeometryProcessor> gp; | 158 SkAutoTUnref<GrGeometryProcessor> gp; |
| 159 { // scope to contain GrTestTarget | 159 { // scope to contain GrTestTarget |
| 160 GrTestTarget tt; | 160 GrTestTarget tt; |
| 161 context->getTestTarget(&tt); | 161 context->getTestTarget(&tt); |
| 162 if (NULL == tt.target()) { | 162 if (nullptr == tt.target()) { |
| 163 continue; | 163 continue; |
| 164 } | 164 } |
| 165 GrPrimitiveEdgeType et = (GrPrimitiveEdgeType)edgeType; | 165 GrPrimitiveEdgeType et = (GrPrimitiveEdgeType)edgeType; |
| 166 gp.reset(GrCubicEffect::Create(color, SkMatrix::I(), et, | 166 gp.reset(GrCubicEffect::Create(color, SkMatrix::I(), et, |
| 167 *tt.target()->caps())); | 167 *tt.target()->caps())); |
| 168 if (!gp) { | 168 if (!gp) { |
| 169 continue; | 169 continue; |
| 170 } | 170 } |
| 171 } | 171 } |
| 172 | 172 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 return SkString("bezier_conic_effects"); | 262 return SkString("bezier_conic_effects"); |
| 263 } | 263 } |
| 264 | 264 |
| 265 SkISize onISize() override { | 265 SkISize onISize() override { |
| 266 return SkISize::Make(800, 800); | 266 return SkISize::Make(800, 800); |
| 267 } | 267 } |
| 268 | 268 |
| 269 | 269 |
| 270 void onDraw(SkCanvas* canvas) override { | 270 void onDraw(SkCanvas* canvas) override { |
| 271 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget
(); | 271 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget
(); |
| 272 if (NULL == rt) { | 272 if (nullptr == rt) { |
| 273 this->drawGpuOnlyMessage(canvas); | 273 this->drawGpuOnlyMessage(canvas); |
| 274 return; | 274 return; |
| 275 } | 275 } |
| 276 GrContext* context = rt->getContext(); | 276 GrContext* context = rt->getContext(); |
| 277 if (NULL == context) { | 277 if (nullptr == context) { |
| 278 return; | 278 return; |
| 279 } | 279 } |
| 280 | 280 |
| 281 struct Vertex { | 281 struct Vertex { |
| 282 SkPoint fPosition; | 282 SkPoint fPosition; |
| 283 float fKLM[4]; // The last value is ignored. The effect expects a
vec4f. | 283 float fKLM[4]; // The last value is ignored. The effect expects a
vec4f. |
| 284 }; | 284 }; |
| 285 | 285 |
| 286 static const int kNumConics = 10; | 286 static const int kNumConics = 10; |
| 287 SkRandom rand; | 287 SkRandom rand; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 300 {rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)}, | 300 {rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)}, |
| 301 {rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)}, | 301 {rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)}, |
| 302 {rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)} | 302 {rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)} |
| 303 }; | 303 }; |
| 304 SkScalar weight = rand.nextRangeF(0.f, 2.f); | 304 SkScalar weight = rand.nextRangeF(0.f, 2.f); |
| 305 for(int edgeType = 0; edgeType < kGrProcessorEdgeTypeCnt; ++edgeType
) { | 305 for(int edgeType = 0; edgeType < kGrProcessorEdgeTypeCnt; ++edgeType
) { |
| 306 SkAutoTUnref<GrGeometryProcessor> gp; | 306 SkAutoTUnref<GrGeometryProcessor> gp; |
| 307 { // scope to contain GrTestTarget | 307 { // scope to contain GrTestTarget |
| 308 GrTestTarget tt; | 308 GrTestTarget tt; |
| 309 context->getTestTarget(&tt); | 309 context->getTestTarget(&tt); |
| 310 if (NULL == tt.target()) { | 310 if (nullptr == tt.target()) { |
| 311 continue; | 311 continue; |
| 312 } | 312 } |
| 313 GrPrimitiveEdgeType et = (GrPrimitiveEdgeType)edgeType; | 313 GrPrimitiveEdgeType et = (GrPrimitiveEdgeType)edgeType; |
| 314 gp.reset(GrConicEffect::Create(color, SkMatrix::I(), et, | 314 gp.reset(GrConicEffect::Create(color, SkMatrix::I(), et, |
| 315 *tt.target()->caps(), SkMatri
x::I(), false)); | 315 *tt.target()->caps(), SkMatri
x::I(), false)); |
| 316 if (!gp) { | 316 if (!gp) { |
| 317 continue; | 317 continue; |
| 318 } | 318 } |
| 319 } | 319 } |
| 320 | 320 |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 return SkString("bezier_quad_effects"); | 505 return SkString("bezier_quad_effects"); |
| 506 } | 506 } |
| 507 | 507 |
| 508 SkISize onISize() override { | 508 SkISize onISize() override { |
| 509 return SkISize::Make(800, 800); | 509 return SkISize::Make(800, 800); |
| 510 } | 510 } |
| 511 | 511 |
| 512 | 512 |
| 513 void onDraw(SkCanvas* canvas) override { | 513 void onDraw(SkCanvas* canvas) override { |
| 514 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget
(); | 514 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget
(); |
| 515 if (NULL == rt) { | 515 if (nullptr == rt) { |
| 516 this->drawGpuOnlyMessage(canvas); | 516 this->drawGpuOnlyMessage(canvas); |
| 517 return; | 517 return; |
| 518 } | 518 } |
| 519 GrContext* context = rt->getContext(); | 519 GrContext* context = rt->getContext(); |
| 520 if (NULL == context) { | 520 if (nullptr == context) { |
| 521 return; | 521 return; |
| 522 } | 522 } |
| 523 | 523 |
| 524 struct Vertex { | 524 struct Vertex { |
| 525 SkPoint fPosition; | 525 SkPoint fPosition; |
| 526 float fUV[4]; // The last two values are ignored. The effect expec
ts a vec4f. | 526 float fUV[4]; // The last two values are ignored. The effect expec
ts a vec4f. |
| 527 }; | 527 }; |
| 528 | 528 |
| 529 static const int kNumQuads = 5; | 529 static const int kNumQuads = 5; |
| 530 SkRandom rand; | 530 SkRandom rand; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 541 SkPoint baseControlPts[] = { | 541 SkPoint baseControlPts[] = { |
| 542 {rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)}, | 542 {rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)}, |
| 543 {rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)}, | 543 {rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)}, |
| 544 {rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)} | 544 {rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)} |
| 545 }; | 545 }; |
| 546 for(int edgeType = 0; edgeType < kGrProcessorEdgeTypeCnt; ++edgeType
) { | 546 for(int edgeType = 0; edgeType < kGrProcessorEdgeTypeCnt; ++edgeType
) { |
| 547 SkAutoTUnref<GrGeometryProcessor> gp; | 547 SkAutoTUnref<GrGeometryProcessor> gp; |
| 548 { // scope to contain GrTestTarget | 548 { // scope to contain GrTestTarget |
| 549 GrTestTarget tt; | 549 GrTestTarget tt; |
| 550 context->getTestTarget(&tt); | 550 context->getTestTarget(&tt); |
| 551 if (NULL == tt.target()) { | 551 if (nullptr == tt.target()) { |
| 552 continue; | 552 continue; |
| 553 } | 553 } |
| 554 GrPrimitiveEdgeType et = (GrPrimitiveEdgeType)edgeType; | 554 GrPrimitiveEdgeType et = (GrPrimitiveEdgeType)edgeType; |
| 555 gp.reset(GrQuadEffect::Create(color, SkMatrix::I(), et, | 555 gp.reset(GrQuadEffect::Create(color, SkMatrix::I(), et, |
| 556 *tt.target()->caps(), SkMatrix
::I(), false)); | 556 *tt.target()->caps(), SkMatrix
::I(), false)); |
| 557 if (!gp) { | 557 if (!gp) { |
| 558 continue; | 558 continue; |
| 559 } | 559 } |
| 560 } | 560 } |
| 561 | 561 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 private: | 630 private: |
| 631 typedef GM INHERITED; | 631 typedef GM INHERITED; |
| 632 }; | 632 }; |
| 633 | 633 |
| 634 DEF_GM(return new BezierCubicEffects;) | 634 DEF_GM(return new BezierCubicEffects;) |
| 635 DEF_GM(return new BezierConicEffects;) | 635 DEF_GM(return new BezierConicEffects;) |
| 636 DEF_GM(return new BezierQuadEffects;) | 636 DEF_GM(return new BezierQuadEffects;) |
| 637 } | 637 } |
| 638 | 638 |
| 639 #endif | 639 #endif |
| OLD | NEW |