| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 | 9 |
| 10 #include "SkBitmapSource.h" | 10 #include "SkBitmapSource.h" |
| 11 | 11 |
| 12 // This GM exercises the SkBitmapSource ImageFilter class. | 12 // This GM exercises the SkBitmapSource ImageFilter class. |
| 13 | 13 |
| 14 class BitmapSourceGM : public skiagm::GM { | 14 class BitmapSourceGM : public skiagm::GM { |
| 15 public: | 15 public: |
| 16 BitmapSourceGM() { | 16 BitmapSourceGM() { |
| 17 } | 17 } |
| 18 | 18 |
| 19 protected: | 19 protected: |
| 20 SkString onShortName() override { | 20 SkString onShortName() override { |
| 21 return SkString("bitmapsource"); | 21 return SkString("bitmapsource"); |
| 22 } | 22 } |
| 23 | 23 |
| 24 void makeBitmap() { | 24 void makeBitmap() { |
| 25 fBitmap.allocN32Pixels(100, 100); | 25 fBitmap.allocN32Pixels(100, 100); |
| 26 SkCanvas canvas(fBitmap); | 26 SkCanvas canvas(fBitmap); |
| 27 canvas.clear(0x00000000); | 27 canvas.clear(0x00000000); |
| 28 SkPaint paint; | 28 SkPaint paint; |
| 29 paint.setAntiAlias(true); | 29 paint.setAntiAlias(true); |
| 30 sk_tool_utils::set_portable_typeface(&paint); | 30 sk_tool_utils::set_portable_typeface_always(&paint); |
| 31 paint.setColor(0xFFFFFFFF); | 31 paint.setColor(0xFFFFFFFF); |
| 32 paint.setTextSize(SkIntToScalar(96)); | 32 paint.setTextSize(SkIntToScalar(96)); |
| 33 const char* str = "e"; | 33 const char* str = "e"; |
| 34 canvas.drawText(str, strlen(str), SkIntToScalar(20), SkIntToScalar(70),
paint); | 34 canvas.drawText(str, strlen(str), SkIntToScalar(20), SkIntToScalar(70),
paint); |
| 35 } | 35 } |
| 36 | 36 |
| 37 SkISize onISize() override { return SkISize::Make(500, 150); } | 37 SkISize onISize() override { return SkISize::Make(500, 150); } |
| 38 | 38 |
| 39 void onOnceBeforeDraw() override { | 39 void onOnceBeforeDraw() override { |
| 40 this->makeBitmap(); | 40 this->makeBitmap(); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 } | 81 } |
| 82 | 82 |
| 83 private: | 83 private: |
| 84 SkBitmap fBitmap; | 84 SkBitmap fBitmap; |
| 85 typedef GM INHERITED; | 85 typedef GM INHERITED; |
| 86 }; | 86 }; |
| 87 | 87 |
| 88 /////////////////////////////////////////////////////////////////////////////// | 88 /////////////////////////////////////////////////////////////////////////////// |
| 89 | 89 |
| 90 DEF_GM( return new BitmapSourceGM; ) | 90 DEF_GM( return new BitmapSourceGM; ) |
| OLD | NEW |