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 "SkColor.h" | 9 #include "SkColor.h" |
10 #include "SkImageSource.h" | 10 #include "SkImageSource.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(16, 16)); | 90 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(16, 16)); |
91 SkCanvas* surfaceCanvas = surface->getCanvas(); | 91 SkCanvas* surfaceCanvas = surface->getCanvas(); |
92 surfaceCanvas->clear(0x000000); | 92 surfaceCanvas->clear(0x000000); |
93 { | 93 { |
94 SkPaint paint; | 94 SkPaint paint; |
95 paint.setColor(0xFF00FF00); | 95 paint.setColor(0xFF00FF00); |
96 SkRect ovalRect = SkRect::MakeWH(16, 16); | 96 SkRect ovalRect = SkRect::MakeWH(16, 16); |
97 ovalRect.inset(SkIntToScalar(2)/3, SkIntToScalar(2)/3); | 97 ovalRect.inset(SkIntToScalar(2)/3, SkIntToScalar(2)/3); |
98 surfaceCanvas->drawOval(ovalRect, paint); | 98 surfaceCanvas->drawOval(ovalRect, paint); |
99 } | 99 } |
100 SkAutoTUnref<SkImage> image(surface->newImageSnapshot()); | 100 sk_sp<SkImage> image(surface->makeImageSnapshot()); |
101 SkRect inRect = SkRect::MakeXYWH(-4, -4, 20, 20); | 101 SkRect inRect = SkRect::MakeXYWH(-4, -4, 20, 20); |
102 SkRect outRect = SkRect::MakeXYWH(-24, -24, 120, 120); | 102 SkRect outRect = SkRect::MakeXYWH(-24, -24, 120, 120); |
103 SkAutoTUnref<SkImageFilter> source( | 103 SkAutoTUnref<SkImageFilter> source( |
104 SkImageSource::Create(image, inRect, outRect, kHigh_SkFilterQuality)
); | 104 SkImageSource::Create(image.get(), inRect, outRect, kHigh_SkFilterQu
ality)); |
105 canvas->translate(srcRect.width() + SkIntToScalar(10), 0); | 105 canvas->translate(srcRect.width() + SkIntToScalar(10), 0); |
106 draw(canvas, | 106 draw(canvas, |
107 srcRect, | 107 srcRect, |
108 deviceSize, | 108 deviceSize, |
109 kHigh_SkFilterQuality, | 109 kHigh_SkFilterQuality, |
110 source.get()); | 110 source.get()); |
111 } | 111 } |
112 | 112 |
113 private: | 113 private: |
114 typedef GM INHERITED; | 114 typedef GM INHERITED; |
115 }; | 115 }; |
116 | 116 |
117 ////////////////////////////////////////////////////////////////////////////// | 117 ////////////////////////////////////////////////////////////////////////////// |
118 | 118 |
119 static GM* MyFactory(void*) { return new ResizeGM; } | 119 static GM* MyFactory(void*) { return new ResizeGM; } |
120 static GMRegistry reg(MyFactory); | 120 static GMRegistry reg(MyFactory); |
121 | 121 |
122 } | 122 } |
OLD | NEW |