| 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->allocN32Pixels(kSize, kSize); | 15 bitmap->allocN32Pixels(kSize, kSize); |
| 16 SkCanvas canvas(*bitmap); | 16 SkBaseDevice* dev = new SkBitmapDevice(*bitmap); |
| 17 |
| 18 SkCanvas canvas(dev); |
| 19 dev->unref(); |
| 17 canvas.clear(SK_ColorTRANSPARENT); | 20 canvas.clear(SK_ColorTRANSPARENT); |
| 18 | 21 |
| 19 SkRect r = SkRect::MakeWH(SkIntToScalar(kSize), SkIntToScalar(kSize)); | 22 SkRect r = SkRect::MakeWH(SkIntToScalar(kSize), SkIntToScalar(kSize)); |
| 20 const SkScalar strokeWidth = SkIntToScalar(6); | 23 const SkScalar strokeWidth = SkIntToScalar(6); |
| 21 const SkScalar radius = SkIntToScalar(kFixed) - strokeWidth/2; | 24 const SkScalar radius = SkIntToScalar(kFixed) - strokeWidth/2; |
| 22 | 25 |
| 23 center->setXYWH(kFixed, kFixed, kStretchy, kStretchy); | 26 center->setXYWH(kFixed, kFixed, kStretchy, kStretchy); |
| 24 | 27 |
| 25 SkPaint paint; | 28 SkPaint paint; |
| 26 paint.setAntiAlias(true); | 29 paint.setAntiAlias(true); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 private: | 91 private: |
| 89 typedef GM INHERITED; | 92 typedef GM INHERITED; |
| 90 }; | 93 }; |
| 91 | 94 |
| 92 ////////////////////////////////////////////////////////////////////////////// | 95 ////////////////////////////////////////////////////////////////////////////// |
| 93 | 96 |
| 94 static GM* MyFactory(void*) { return new NinePatchStretchGM; } | 97 static GM* MyFactory(void*) { return new NinePatchStretchGM; } |
| 95 static GMRegistry reg(MyFactory); | 98 static GMRegistry reg(MyFactory); |
| 96 | 99 |
| 97 } | 100 } |
| OLD | NEW |