| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 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 #include "gm.h" | 8 #include "gm.h" |
| 9 #include "SkGradientShader.h" | 9 #include "SkGradientShader.h" |
| 10 | 10 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 | 98 |
| 99 /////////////////////////////////////////////////////////////////////////////// | 99 /////////////////////////////////////////////////////////////////////////////// |
| 100 | 100 |
| 101 class GradientsGM : public GM { | 101 class GradientsGM : public GM { |
| 102 public: | 102 public: |
| 103 GradientsGM() { | 103 GradientsGM() { |
| 104 this->setBGColor(0xFFDDDDDD); | 104 this->setBGColor(0xFFDDDDDD); |
| 105 } | 105 } |
| 106 | 106 |
| 107 protected: | 107 protected: |
| 108 virtual uint32_t onGetFlags() const SK_OVERRIDE { | 108 uint32_t onGetFlags() const SK_OVERRIDE { |
| 109 return kSkipTiled_Flag; | 109 return kSkipTiled_Flag; |
| 110 } | 110 } |
| 111 | 111 |
| 112 SkString onShortName() { | 112 SkString onShortName() { |
| 113 return SkString("gradients"); | 113 return SkString("gradients"); |
| 114 } | 114 } |
| 115 | 115 |
| 116 virtual SkISize onISize() { return SkISize::Make(840, 815); } | 116 virtual SkISize onISize() { return SkISize::Make(840, 815); } |
| 117 | 117 |
| 118 virtual void onDraw(SkCanvas* canvas) { | 118 virtual void onDraw(SkCanvas* canvas) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 155 |
| 156 // Based on the original gradient slide, but with perspective applied to the | 156 // Based on the original gradient slide, but with perspective applied to the |
| 157 // gradient shaders' local matrices | 157 // gradient shaders' local matrices |
| 158 class GradientsLocalPerspectiveGM : public GM { | 158 class GradientsLocalPerspectiveGM : public GM { |
| 159 public: | 159 public: |
| 160 GradientsLocalPerspectiveGM() { | 160 GradientsLocalPerspectiveGM() { |
| 161 this->setBGColor(0xFFDDDDDD); | 161 this->setBGColor(0xFFDDDDDD); |
| 162 } | 162 } |
| 163 | 163 |
| 164 protected: | 164 protected: |
| 165 virtual uint32_t onGetFlags() const SK_OVERRIDE { | 165 uint32_t onGetFlags() const SK_OVERRIDE { |
| 166 return kSkipTiled_Flag; | 166 return kSkipTiled_Flag; |
| 167 } | 167 } |
| 168 | 168 |
| 169 SkString onShortName() { | 169 SkString onShortName() { |
| 170 return SkString("gradients_local_perspective"); | 170 return SkString("gradients_local_perspective"); |
| 171 } | 171 } |
| 172 | 172 |
| 173 virtual SkISize onISize() { return SkISize::Make(840, 815); } | 173 virtual SkISize onISize() { return SkISize::Make(840, 815); } |
| 174 | 174 |
| 175 virtual void onDraw(SkCanvas* canvas) { | 175 virtual void onDraw(SkCanvas* canvas) { |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 }; | 327 }; |
| 328 | 328 |
| 329 /// Checks quality of large radial gradients, which may display | 329 /// Checks quality of large radial gradients, which may display |
| 330 /// some banding. | 330 /// some banding. |
| 331 | 331 |
| 332 class RadialGradientGM : public GM { | 332 class RadialGradientGM : public GM { |
| 333 public: | 333 public: |
| 334 RadialGradientGM() {} | 334 RadialGradientGM() {} |
| 335 | 335 |
| 336 protected: | 336 protected: |
| 337 virtual uint32_t onGetFlags() const SK_OVERRIDE { | 337 uint32_t onGetFlags() const SK_OVERRIDE { |
| 338 return kSkipTiled_Flag; | 338 return kSkipTiled_Flag; |
| 339 } | 339 } |
| 340 | 340 |
| 341 SkString onShortName() SK_OVERRIDE { return SkString("radial_gradient"); } | 341 SkString onShortName() SK_OVERRIDE { return SkString("radial_gradient"); } |
| 342 virtual SkISize onISize() SK_OVERRIDE { return SkISize::Make(1280, 1280); } | 342 SkISize onISize() SK_OVERRIDE { return SkISize::Make(1280, 1280); } |
| 343 void drawBG(SkCanvas* canvas) { | 343 void drawBG(SkCanvas* canvas) { |
| 344 canvas->drawColor(0xFF000000); | 344 canvas->drawColor(0xFF000000); |
| 345 } | 345 } |
| 346 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 346 void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
| 347 const SkISize dim = this->getISize(); | 347 const SkISize dim = this->getISize(); |
| 348 | 348 |
| 349 this->drawBG(canvas); | 349 this->drawBG(canvas); |
| 350 | 350 |
| 351 SkPaint paint; | 351 SkPaint paint; |
| 352 paint.setDither(true); | 352 paint.setDither(true); |
| 353 SkPoint center; | 353 SkPoint center; |
| 354 center.set(SkIntToScalar(dim.width())/2, SkIntToScalar(dim.height())/2); | 354 center.set(SkIntToScalar(dim.width())/2, SkIntToScalar(dim.height())/2); |
| 355 SkScalar radius = SkIntToScalar(dim.width())/2; | 355 SkScalar radius = SkIntToScalar(dim.width())/2; |
| 356 const SkColor colors[] = { 0x7f7f7f7f, 0x7f7f7f7f, 0xb2000000 }; | 356 const SkColor colors[] = { 0x7f7f7f7f, 0x7f7f7f7f, 0xb2000000 }; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 370 private: | 370 private: |
| 371 typedef GM INHERITED; | 371 typedef GM INHERITED; |
| 372 }; | 372 }; |
| 373 | 373 |
| 374 | 374 |
| 375 class RadialGradient2GM : public GM { | 375 class RadialGradient2GM : public GM { |
| 376 public: | 376 public: |
| 377 RadialGradient2GM() {} | 377 RadialGradient2GM() {} |
| 378 | 378 |
| 379 protected: | 379 protected: |
| 380 virtual uint32_t onGetFlags() const SK_OVERRIDE { | 380 uint32_t onGetFlags() const SK_OVERRIDE { |
| 381 return kSkipTiled_Flag; | 381 return kSkipTiled_Flag; |
| 382 } | 382 } |
| 383 | 383 |
| 384 SkString onShortName() SK_OVERRIDE { return SkString("radial_gradient2"); } | 384 SkString onShortName() SK_OVERRIDE { return SkString("radial_gradient2"); } |
| 385 virtual SkISize onISize() SK_OVERRIDE { return SkISize::Make(800, 400); } | 385 SkISize onISize() SK_OVERRIDE { return SkISize::Make(800, 400); } |
| 386 void drawBG(SkCanvas* canvas) { | 386 void drawBG(SkCanvas* canvas) { |
| 387 canvas->drawColor(0xFF000000); | 387 canvas->drawColor(0xFF000000); |
| 388 } | 388 } |
| 389 | 389 |
| 390 // Reproduces the example given in bug 7671058. | 390 // Reproduces the example given in bug 7671058. |
| 391 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 391 void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
| 392 SkPaint paint1, paint2, paint3; | 392 SkPaint paint1, paint2, paint3; |
| 393 paint1.setStyle(SkPaint::kFill_Style); | 393 paint1.setStyle(SkPaint::kFill_Style); |
| 394 paint2.setStyle(SkPaint::kFill_Style); | 394 paint2.setStyle(SkPaint::kFill_Style); |
| 395 paint3.setStyle(SkPaint::kFill_Style); | 395 paint3.setStyle(SkPaint::kFill_Style); |
| 396 | 396 |
| 397 const SkColor sweep_colors[] = | 397 const SkColor sweep_colors[] = |
| 398 { 0xFFFF0000, 0xFFFFFF00, 0xFF00FF00, 0xFF00FFFF, 0xFF0000FF, 0xFFFF
00FF, 0xFFFF0000 }; | 398 { 0xFFFF0000, 0xFFFFFF00, 0xFF00FF00, 0xFF00FFFF, 0xFF0000FF, 0xFFFF
00FF, 0xFFFF0000 }; |
| 399 const SkColor colors1[] = { 0xFFFFFFFF, 0x00000000 }; | 399 const SkColor colors1[] = { 0xFFFFFFFF, 0x00000000 }; |
| 400 const SkColor colors2[] = { 0xFF000000, 0x00000000 }; | 400 const SkColor colors2[] = { 0xFF000000, 0x00000000 }; |
| 401 | 401 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 | 454 |
| 455 static GM* MyFactory5(void*) { return new GradientsLocalPerspectiveGM; } | 455 static GM* MyFactory5(void*) { return new GradientsLocalPerspectiveGM; } |
| 456 static GMRegistry reg5(MyFactory5); | 456 static GMRegistry reg5(MyFactory5); |
| 457 | 457 |
| 458 static GM* MyFactory6(void*) { return new GradientsViewPerspectiveGM; } | 458 static GM* MyFactory6(void*) { return new GradientsViewPerspectiveGM; } |
| 459 static GMRegistry reg6(MyFactory6); | 459 static GMRegistry reg6(MyFactory6); |
| 460 | 460 |
| 461 static GM* MyFactory7(void*) { return new RadialGradient2GM; } | 461 static GM* MyFactory7(void*) { return new RadialGradient2GM; } |
| 462 static GMRegistry reg7(MyFactory7); | 462 static GMRegistry reg7(MyFactory7); |
| 463 } | 463 } |
| OLD | NEW |