| 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 "SkBitmapDevice.h" | |
| 10 #include "SkBitmapSource.h" | 9 #include "SkBitmapSource.h" |
| 11 #include "SkColor.h" | 10 #include "SkColor.h" |
| 12 #include "SkRefCnt.h" | 11 #include "SkRefCnt.h" |
| 13 | 12 |
| 14 namespace skiagm { | 13 namespace skiagm { |
| 15 | 14 |
| 16 class ResizeGM : public GM { | 15 class ResizeGM : public GM { |
| 17 public: | 16 public: |
| 18 ResizeGM() { | 17 ResizeGM() { |
| 19 this->setBGColor(0x00000000); | 18 this->setBGColor(0x00000000); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 canvas->translate(srcRect.width() + SkIntToScalar(10), 0); | 83 canvas->translate(srcRect.width() + SkIntToScalar(10), 0); |
| 85 draw(canvas, | 84 draw(canvas, |
| 86 srcRect, | 85 srcRect, |
| 87 deviceSize, | 86 deviceSize, |
| 88 kHigh_SkFilterQuality); | 87 kHigh_SkFilterQuality); |
| 89 | 88 |
| 90 SkBitmap bitmap; | 89 SkBitmap bitmap; |
| 91 bitmap.allocN32Pixels(16, 16); | 90 bitmap.allocN32Pixels(16, 16); |
| 92 bitmap.eraseARGB(0x00, 0x00, 0x00, 0x00); | 91 bitmap.eraseARGB(0x00, 0x00, 0x00, 0x00); |
| 93 { | 92 { |
| 94 SkBitmapDevice bitmapDevice(bitmap); | 93 SkCanvas bitmapCanvas(bitmap); |
| 95 SkCanvas bitmapCanvas(&bitmapDevice); | |
| 96 SkPaint paint; | 94 SkPaint paint; |
| 97 paint.setColor(0xFF00FF00); | 95 paint.setColor(0xFF00FF00); |
| 98 SkRect ovalRect = SkRect::MakeWH(16, 16); | 96 SkRect ovalRect = SkRect::MakeWH(16, 16); |
| 99 ovalRect.inset(SkIntToScalar(2)/3, SkIntToScalar(2)/3); | 97 ovalRect.inset(SkIntToScalar(2)/3, SkIntToScalar(2)/3); |
| 100 bitmapCanvas.drawOval(ovalRect, paint); | 98 bitmapCanvas.drawOval(ovalRect, paint); |
| 101 } | 99 } |
| 102 SkRect inRect = SkRect::MakeXYWH(-4, -4, 20, 20); | 100 SkRect inRect = SkRect::MakeXYWH(-4, -4, 20, 20); |
| 103 SkRect outRect = SkRect::MakeXYWH(-24, -24, 120, 120); | 101 SkRect outRect = SkRect::MakeXYWH(-24, -24, 120, 120); |
| 104 SkAutoTUnref<SkBitmapSource> source(SkBitmapSource::Create(bitmap, inRec
t, outRect)); | 102 SkAutoTUnref<SkBitmapSource> source(SkBitmapSource::Create(bitmap, inRec
t, outRect)); |
| 105 canvas->translate(srcRect.width() + SkIntToScalar(10), 0); | 103 canvas->translate(srcRect.width() + SkIntToScalar(10), 0); |
| 106 draw(canvas, | 104 draw(canvas, |
| 107 srcRect, | 105 srcRect, |
| 108 deviceSize, | 106 deviceSize, |
| 109 kHigh_SkFilterQuality, | 107 kHigh_SkFilterQuality, |
| 110 source.get()); | 108 source.get()); |
| 111 } | 109 } |
| 112 | 110 |
| 113 private: | 111 private: |
| 114 typedef GM INHERITED; | 112 typedef GM INHERITED; |
| 115 }; | 113 }; |
| 116 | 114 |
| 117 ////////////////////////////////////////////////////////////////////////////// | 115 ////////////////////////////////////////////////////////////////////////////// |
| 118 | 116 |
| 119 static GM* MyFactory(void*) { return new ResizeGM; } | 117 static GM* MyFactory(void*) { return new ResizeGM; } |
| 120 static GMRegistry reg(MyFactory); | 118 static GMRegistry reg(MyFactory); |
| 121 | 119 |
| 122 } | 120 } |
| OLD | NEW |