OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "SkGradientShader.h" | 9 #include "SkGradientShader.h" |
10 #include "SkSurface.h" | 10 #include "SkSurface.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 | 133 |
134 void onDraw(SkCanvas* canvas) override { | 134 void onDraw(SkCanvas* canvas) override { |
135 SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100); | 135 SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100); |
136 | 136 |
137 SkAutoTUnref<SkSurface> surf(canvas->newSurface(info, nullptr)); | 137 SkAutoTUnref<SkSurface> surf(canvas->newSurface(info, nullptr)); |
138 if (!surf.get()) { | 138 if (!surf.get()) { |
139 surf.reset(SkSurface::NewRaster(info)); | 139 surf.reset(SkSurface::NewRaster(info)); |
140 } | 140 } |
141 drawInto(surf->getCanvas()); | 141 drawInto(surf->getCanvas()); |
142 | 142 |
143 SkAutoTUnref<SkImage> image(surf->newImageSnapshot()); | 143 sk_sp<SkImage> image(surf->makeImageSnapshot()); |
144 canvas->drawImage(image, 10, 10, nullptr); | 144 canvas->drawImage(image, 10, 10, nullptr); |
145 | 145 |
146 SkAutoTUnref<SkSurface> surf2(surf->newSurface(info)); | 146 SkAutoTUnref<SkSurface> surf2(surf->newSurface(info)); |
147 drawInto(surf2->getCanvas()); | 147 drawInto(surf2->getCanvas()); |
148 | 148 |
149 // Assert that the props were communicated transitively through the firs
t image | 149 // Assert that the props were communicated transitively through the firs
t image |
150 SkASSERT(equal(surf->props(), surf2->props())); | 150 SkASSERT(equal(surf->props(), surf2->props())); |
151 | 151 |
152 SkAutoTUnref<SkImage> image2(surf2->newImageSnapshot()); | 152 sk_sp<SkImage> image2(surf2->makeImageSnapshot()); |
153 canvas->drawImage(image2, 10 + SkIntToScalar(image->width()) + 10, 10, n
ullptr); | 153 canvas->drawImage(image2.get(), 10 + SkIntToScalar(image->width()) + 10,
10, nullptr); |
154 } | 154 } |
155 | 155 |
156 private: | 156 private: |
157 typedef GM INHERITED; | 157 typedef GM INHERITED; |
158 }; | 158 }; |
159 DEF_GM( return new NewSurfaceGM ) | 159 DEF_GM( return new NewSurfaceGM ) |
160 | 160 |
OLD | NEW |