| 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) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 protected: | 46 protected: |
| 47 virtual uint32_t onGetFlags() const SK_OVERRIDE { | 47 virtual uint32_t onGetFlags() const SK_OVERRIDE { |
| 48 return kSkipTiled_Flag; | 48 return kSkipTiled_Flag; |
| 49 } | 49 } |
| 50 | 50 |
| 51 virtual SkString onShortName() { | 51 virtual SkString onShortName() { |
| 52 return SkString("ninepatch-stretch"); | 52 return SkString("ninepatch-stretch"); |
| 53 } | 53 } |
| 54 | 54 |
| 55 virtual SkISize onISize() { | 55 virtual SkISize onISize() { |
| 56 return make_isize(400, 400); | 56 return SkISize::Make(400, 400); |
| 57 } | 57 } |
| 58 | 58 |
| 59 virtual void onDraw(SkCanvas* canvas) { | 59 virtual void onDraw(SkCanvas* canvas) { |
| 60 SkBitmap bm; | 60 SkBitmap bm; |
| 61 SkIRect center; | 61 SkIRect center; |
| 62 make_bitmap(&bm, ¢er); | 62 make_bitmap(&bm, ¢er); |
| 63 | 63 |
| 64 // amount of bm that should not be stretched (unless we have to) | 64 // amount of bm that should not be stretched (unless we have to) |
| 65 const SkScalar fixed = SkIntToScalar(bm.width() - center.width()); | 65 const SkScalar fixed = SkIntToScalar(bm.width() - center.width()); |
| 66 | 66 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 92 private: | 92 private: |
| 93 typedef GM INHERITED; | 93 typedef GM INHERITED; |
| 94 }; | 94 }; |
| 95 | 95 |
| 96 ////////////////////////////////////////////////////////////////////////////// | 96 ////////////////////////////////////////////////////////////////////////////// |
| 97 | 97 |
| 98 static GM* MyFactory(void*) { return new NinePatchStretchGM; } | 98 static GM* MyFactory(void*) { return new NinePatchStretchGM; } |
| 99 static GMRegistry reg(MyFactory); | 99 static GMRegistry reg(MyFactory); |
| 100 | 100 |
| 101 } | 101 } |
| OLD | NEW |