| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 static void make_bitmap(SkBitmap* bitmap, SkIRect* center) { | 10 static void make_bitmap(SkBitmap* bitmap, SkIRect* center) { |
| 11 const int kFixed = 28; | 11 const int kFixed = 28; |
| 12 const int kStretchy = 8; | 12 const int kStretchy = 8; |
| 13 const int kSize = 2*kFixed + kStretchy; | 13 const int kSize = 2*kFixed + kStretchy; |
| 14 | 14 |
| 15 bitmap->setConfig(SkBitmap::kARGB_8888_Config, kSize, kSize); | 15 bitmap->allocN32Pixels(kSize, kSize); |
| 16 bitmap->allocPixels(); | |
| 17 SkBaseDevice* dev = new SkBitmapDevice(*bitmap); | 16 SkBaseDevice* dev = new SkBitmapDevice(*bitmap); |
| 18 | 17 |
| 19 SkCanvas canvas(dev); | 18 SkCanvas canvas(dev); |
| 20 dev->unref(); | 19 dev->unref(); |
| 21 canvas.clear(SK_ColorTRANSPARENT); | 20 canvas.clear(SK_ColorTRANSPARENT); |
| 22 | 21 |
| 23 SkRect r = SkRect::MakeWH(SkIntToScalar(kSize), SkIntToScalar(kSize)); | 22 SkRect r = SkRect::MakeWH(SkIntToScalar(kSize), SkIntToScalar(kSize)); |
| 24 const SkScalar strokeWidth = SkIntToScalar(6); | 23 const SkScalar strokeWidth = SkIntToScalar(6); |
| 25 const SkScalar radius = SkIntToScalar(kFixed) - strokeWidth/2; | 24 const SkScalar radius = SkIntToScalar(kFixed) - strokeWidth/2; |
| 26 | 25 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 private: | 91 private: |
| 93 typedef GM INHERITED; | 92 typedef GM INHERITED; |
| 94 }; | 93 }; |
| 95 | 94 |
| 96 ////////////////////////////////////////////////////////////////////////////// | 95 ////////////////////////////////////////////////////////////////////////////// |
| 97 | 96 |
| 98 static GM* MyFactory(void*) { return new NinePatchStretchGM; } | 97 static GM* MyFactory(void*) { return new NinePatchStretchGM; } |
| 99 static GMRegistry reg(MyFactory); | 98 static GMRegistry reg(MyFactory); |
| 100 | 99 |
| 101 } | 100 } |
| OLD | NEW |