| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "gm.h" | 8 #include "gm.h" |
| 9 #include "SkMagnifierImageFilter.h" | 9 #include "SkMagnifierImageFilter.h" |
| 10 #include "SkRandom.h" | 10 #include "SkRandom.h" |
| 11 | 11 |
| 12 #define WIDTH 500 | 12 #define WIDTH 500 |
| 13 #define HEIGHT 500 | 13 #define HEIGHT 500 |
| 14 | 14 |
| 15 namespace skiagm { | 15 namespace skiagm { |
| 16 | 16 |
| 17 class ImageMagnifierGM : public GM { | 17 class ImageMagnifierGM : public GM { |
| 18 public: | 18 public: |
| 19 ImageMagnifierGM() { | 19 ImageMagnifierGM() { |
| 20 this->setBGColor(0xFF000000); | 20 this->setBGColor(0xFF000000); |
| 21 } | 21 } |
| 22 | 22 |
| 23 protected: | 23 protected: |
| 24 virtual uint32_t onGetFlags() const SK_OVERRIDE { | 24 uint32_t onGetFlags() const SK_OVERRIDE { |
| 25 // Skip tiled drawing until https://code.google.com/p/skia/issues/detail
?id=781 is fixed. | 25 // Skip tiled drawing until https://code.google.com/p/skia/issues/detail
?id=781 is fixed. |
| 26 return this->INHERITED::onGetFlags() | GM::kSkipTiled_Flag; | 26 return this->INHERITED::onGetFlags() | GM::kSkipTiled_Flag; |
| 27 } | 27 } |
| 28 | 28 |
| 29 virtual SkString onShortName() SK_OVERRIDE { | 29 SkString onShortName() SK_OVERRIDE { |
| 30 return SkString("imagemagnifier"); | 30 return SkString("imagemagnifier"); |
| 31 } | 31 } |
| 32 | 32 |
| 33 virtual SkISize onISize() SK_OVERRIDE { | 33 SkISize onISize() SK_OVERRIDE { |
| 34 return SkISize::Make(WIDTH, HEIGHT); | 34 return SkISize::Make(WIDTH, HEIGHT); |
| 35 } | 35 } |
| 36 | 36 |
| 37 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 37 void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
| 38 SkPaint filterPaint; | 38 SkPaint filterPaint; |
| 39 filterPaint.setImageFilter( | 39 filterPaint.setImageFilter( |
| 40 SkMagnifierImageFilter::Create( | 40 SkMagnifierImageFilter::Create( |
| 41 SkRect::MakeXYWH(SkIntToScalar(100), SkIntToScalar(100), | 41 SkRect::MakeXYWH(SkIntToScalar(100), SkIntToScalar(100), |
| 42 SkIntToScalar(WIDTH / 2), | 42 SkIntToScalar(WIDTH / 2), |
| 43 SkIntToScalar(HEIGHT / 2)), | 43 SkIntToScalar(HEIGHT / 2)), |
| 44 100))->unref(); | 44 100))->unref(); |
| 45 canvas->saveLayer(NULL, &filterPaint); | 45 canvas->saveLayer(NULL, &filterPaint); |
| 46 const char* str = "The quick brown fox jumped over the lazy dog."; | 46 const char* str = "The quick brown fox jumped over the lazy dog."; |
| 47 SkRandom rand; | 47 SkRandom rand; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 62 private: | 62 private: |
| 63 typedef GM INHERITED; | 63 typedef GM INHERITED; |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 ////////////////////////////////////////////////////////////////////////////// | 66 ////////////////////////////////////////////////////////////////////////////// |
| 67 | 67 |
| 68 static GM* MyFactory(void*) { return new ImageMagnifierGM; } | 68 static GM* MyFactory(void*) { return new ImageMagnifierGM; } |
| 69 static GMRegistry reg(MyFactory); | 69 static GMRegistry reg(MyFactory); |
| 70 | 70 |
| 71 } | 71 } |
| OLD | NEW |