Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(503)

Side by Side Diff: tests/SpecialImageTest.cpp

Issue 1821303002: Remove SkPixmap::release (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkAutoPixmapStorage.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 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 "SkAutoPixmapStorage.h" 8 #include "SkAutoPixmapStorage.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 176
177 const SkImageInfo info = SkImageInfo::MakeN32(kFullSize, kFullSize, kOpaque_ SkAlphaType); 177 const SkImageInfo info = SkImageInfo::MakeN32(kFullSize, kFullSize, kOpaque_ SkAlphaType);
178 pixmap.alloc(info); 178 pixmap.alloc(info);
179 pixmap.erase(SK_ColorGREEN); 179 pixmap.erase(SK_ColorGREEN);
180 180
181 const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmaller Size); 181 const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmaller Size);
182 182
183 pixmap.erase(SK_ColorRED, subset); 183 pixmap.erase(SK_ColorRED, subset);
184 184
185 { 185 {
186 // The SkAutoPixmapStorage keeps hold of the memory
187 sk_sp<SkSpecialImage> img(SkSpecialImage::MakeFromPixmap(nullptr, subset , pixmap, 186 sk_sp<SkSpecialImage> img(SkSpecialImage::MakeFromPixmap(nullptr, subset , pixmap,
188 nullptr, nullpt r)); 187 nullptr, nullpt r));
189 test_image(img, reporter, true, false, kPad, kFullSize); 188 test_image(img, reporter, true, false, kPad, kFullSize);
190 } 189 }
191
192 {
193 // The image takes ownership of the memory
194 sk_sp<SkSpecialImage> img(SkSpecialImage::MakeFromPixmap(
195 nullptr, subset, pixmap,
196 [] (void* addr, void*) -> void {
197 sk_free(addr);
198 },
199 nullptr));
200 pixmap.release();
201 test_image(img, reporter, true, false, kPad, kFullSize);
202 }
203 } 190 }
204 191
205 192
206 #if SK_SUPPORT_GPU 193 #if SK_SUPPORT_GPU
207 194
208 static void test_texture_backed(skiatest::Reporter* reporter, 195 static void test_texture_backed(skiatest::Reporter* reporter,
209 const sk_sp<SkSpecialImage>& orig, 196 const sk_sp<SkSpecialImage>& orig,
210 const sk_sp<SkSpecialImage>& gpuBacked) { 197 const sk_sp<SkSpecialImage>& gpuBacked) {
211 REPORTER_ASSERT(reporter, gpuBacked); 198 REPORTER_ASSERT(reporter, gpuBacked);
212 REPORTER_ASSERT(reporter, gpuBacked->peekTexture()); 199 REPORTER_ASSERT(reporter, gpuBacked->peekTexture());
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 test_image(subSImg1, reporter, false, true, kPad, kFullSize); 298 test_image(subSImg1, reporter, false, true, kPad, kFullSize);
312 } 299 }
313 300
314 { 301 {
315 sk_sp<SkSpecialImage> subSImg2(fullSImg->makeSubset(subset)); 302 sk_sp<SkSpecialImage> subSImg2(fullSImg->makeSubset(subset));
316 test_image(subSImg2, reporter, false, true, kPad, kFullSize); 303 test_image(subSImg2, reporter, false, true, kPad, kFullSize);
317 } 304 }
318 } 305 }
319 306
320 #endif 307 #endif
OLDNEW
« no previous file with comments | « src/core/SkAutoPixmapStorage.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698