| 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 #include "SkSurface.h" | 9 #include "SkSurface.h" |
| 10 | 10 |
| 11 static SkSurface* make_surface(SkCanvas* root, int N) { | 11 static sk_sp<SkSurface> make_surface(SkCanvas* root, int N) { |
| 12 SkImageInfo info = SkImageInfo::MakeN32Premul(N, N); | 12 SkImageInfo info = SkImageInfo::MakeN32Premul(N, N); |
| 13 SkSurface* surface = root->newSurface(info); | 13 auto surface = root->makeSurface(info); |
| 14 if (!surface) { | 14 if (!surface) { |
| 15 surface = SkSurface::NewRaster(info); | 15 surface = SkSurface::MakeRaster(info); |
| 16 } | 16 } |
| 17 return surface; | 17 return surface; |
| 18 } | 18 } |
| 19 | 19 |
| 20 static sk_sp<SkImage> make_image(SkCanvas* root, SkIRect* center) { | 20 static sk_sp<SkImage> make_image(SkCanvas* root, SkIRect* center) { |
| 21 const int kFixed = 28; | 21 const int kFixed = 28; |
| 22 const int kStretchy = 8; | 22 const int kStretchy = 8; |
| 23 const int kSize = 2*kFixed + kStretchy; | 23 const int kSize = 2*kFixed + kStretchy; |
| 24 | 24 |
| 25 SkAutoTUnref<SkSurface> surface(make_surface(root, kSize)); | 25 auto surface(make_surface(root, kSize)); |
| 26 SkCanvas* canvas = surface->getCanvas(); | 26 SkCanvas* canvas = surface->getCanvas(); |
| 27 | 27 |
| 28 SkRect r = SkRect::MakeWH(SkIntToScalar(kSize), SkIntToScalar(kSize)); | 28 SkRect r = SkRect::MakeWH(SkIntToScalar(kSize), SkIntToScalar(kSize)); |
| 29 const SkScalar strokeWidth = SkIntToScalar(6); | 29 const SkScalar strokeWidth = SkIntToScalar(6); |
| 30 const SkScalar radius = SkIntToScalar(kFixed) - strokeWidth/2; | 30 const SkScalar radius = SkIntToScalar(kFixed) - strokeWidth/2; |
| 31 | 31 |
| 32 center->setXYWH(kFixed, kFixed, kStretchy, kStretchy); | 32 center->setXYWH(kFixed, kFixed, kStretchy, kStretchy); |
| 33 | 33 |
| 34 SkPaint paint; | 34 SkPaint paint; |
| 35 paint.setAntiAlias(true); | 35 paint.setAntiAlias(true); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 } | 104 } |
| 105 } | 105 } |
| 106 } | 106 } |
| 107 } | 107 } |
| 108 | 108 |
| 109 private: | 109 private: |
| 110 typedef skiagm::GM INHERITED; | 110 typedef skiagm::GM INHERITED; |
| 111 }; | 111 }; |
| 112 DEF_GM( return new NinePatchStretchGM; ) | 112 DEF_GM( return new NinePatchStretchGM; ) |
| 113 | 113 |
| OLD | NEW |