| 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 #include "SkDisplacementMapEffect.h" | 9 #include "SkDisplacementMapEffect.h" |
| 10 #include "SkBitmapSource.h" | 10 #include "SkBitmapSource.h" |
| 11 | 11 |
| 12 namespace skiagm { | 12 namespace skiagm { |
| 13 | 13 |
| 14 class DisplacementMapGM : public GM { | 14 class DisplacementMapGM : public GM { |
| 15 public: | 15 public: |
| 16 DisplacementMapGM() : fInitialized(false) { | 16 DisplacementMapGM() : fInitialized(false) { |
| 17 this->setBGColor(0xFF000000); | 17 this->setBGColor(0xFF000000); |
| 18 } | 18 } |
| 19 | 19 |
| 20 protected: | 20 protected: |
| 21 virtual SkString onShortName() { | 21 virtual SkString onShortName() { |
| 22 return SkString("displacement"); | 22 return SkString("displacement"); |
| 23 } | 23 } |
| 24 | 24 |
| 25 void make_bitmap() { | 25 void make_bitmap() { |
| 26 fBitmap.setConfig(SkBitmap::kARGB_8888_Config, 80, 80); | 26 fBitmap.setConfig(SkBitmap::kARGB_8888_Config, 80, 80); |
| 27 fBitmap.allocPixels(); | 27 fBitmap.allocPixels(); |
| 28 SkDevice device(fBitmap); | 28 SkBitmapDevice device(fBitmap); |
| 29 SkCanvas canvas(&device); | 29 SkCanvas canvas(&device); |
| 30 canvas.clear(0x00000000); | 30 canvas.clear(0x00000000); |
| 31 SkPaint paint; | 31 SkPaint paint; |
| 32 paint.setAntiAlias(true); | 32 paint.setAntiAlias(true); |
| 33 paint.setColor(0xFF884422); | 33 paint.setColor(0xFF884422); |
| 34 paint.setTextSize(SkIntToScalar(96)); | 34 paint.setTextSize(SkIntToScalar(96)); |
| 35 const char* str = "g"; | 35 const char* str = "g"; |
| 36 canvas.drawText(str, strlen(str), SkIntToScalar(15), SkIntToScalar(55),
paint); | 36 canvas.drawText(str, strlen(str), SkIntToScalar(15), SkIntToScalar(55),
paint); |
| 37 } | 37 } |
| 38 | 38 |
| 39 void make_checkerboard() { | 39 void make_checkerboard() { |
| 40 fCheckerboard.setConfig(SkBitmap::kARGB_8888_Config, 80, 80); | 40 fCheckerboard.setConfig(SkBitmap::kARGB_8888_Config, 80, 80); |
| 41 fCheckerboard.allocPixels(); | 41 fCheckerboard.allocPixels(); |
| 42 SkDevice device(fCheckerboard); | 42 SkBitmapDevice device(fCheckerboard); |
| 43 SkCanvas canvas(&device); | 43 SkCanvas canvas(&device); |
| 44 canvas.clear(0x00000000); | 44 canvas.clear(0x00000000); |
| 45 SkPaint darkPaint; | 45 SkPaint darkPaint; |
| 46 darkPaint.setColor(0xFF804020); | 46 darkPaint.setColor(0xFF804020); |
| 47 SkPaint lightPaint; | 47 SkPaint lightPaint; |
| 48 lightPaint.setColor(0xFF244484); | 48 lightPaint.setColor(0xFF244484); |
| 49 for (int y = 0; y < 80; y += 16) { | 49 for (int y = 0; y < 80; y += 16) { |
| 50 for (int x = 0; x < 80; x += 16) { | 50 for (int x = 0; x < 80; x += 16) { |
| 51 canvas.save(); | 51 canvas.save(); |
| 52 canvas.translate(SkIntToScalar(x), SkIntToScalar(y)); | 52 canvas.translate(SkIntToScalar(x), SkIntToScalar(y)); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 SkBitmap fBitmap, fCheckerboard; | 128 SkBitmap fBitmap, fCheckerboard; |
| 129 bool fInitialized; | 129 bool fInitialized; |
| 130 }; | 130 }; |
| 131 | 131 |
| 132 ////////////////////////////////////////////////////////////////////////////// | 132 ////////////////////////////////////////////////////////////////////////////// |
| 133 | 133 |
| 134 static GM* MyFactory(void*) { return new DisplacementMapGM; } | 134 static GM* MyFactory(void*) { return new DisplacementMapGM; } |
| 135 static GMRegistry reg(MyFactory); | 135 static GMRegistry reg(MyFactory); |
| 136 | 136 |
| 137 } | 137 } |
| OLD | NEW |