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

Side by Side Diff: tests/CachedDecodingPixelRefTest.cpp

Issue 114673002: be sure to unlock the discardablememory before deleting it (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « src/lazy/SkDiscardablePixelRef.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 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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkData.h" 10 #include "SkData.h"
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 REPORTER_ASSERT(reporter, success 261 REPORTER_ASSERT(reporter, success
262 == (TestImageGenerator::kFailGetInfo_TestType != type)); 262 == (TestImageGenerator::kFailGetInfo_TestType != type));
263 if (TestImageGenerator::kSucceedGetPixels_TestType == type) { 263 if (TestImageGenerator::kSucceedGetPixels_TestType == type) {
264 CheckTestImageGeneratorBitmap(reporter, lazy); 264 CheckTestImageGeneratorBitmap(reporter, lazy);
265 } else if (TestImageGenerator::kFailGetPixels_TestType == type) { 265 } else if (TestImageGenerator::kFailGetPixels_TestType == type) {
266 SkAutoLockPixels autoLockPixels(lazy); 266 SkAutoLockPixels autoLockPixels(lazy);
267 REPORTER_ASSERT(reporter, NULL == lazy.getPixels()); 267 REPORTER_ASSERT(reporter, NULL == lazy.getPixels());
268 } 268 }
269 } 269 }
270 } // namespace 270 } // namespace
271
272 // new/lock/delete is an odd pattern for a pixelref, but it needs to not assert
273 static void test_newlockdelete(skiatest::Reporter* reporter) {
274 SkBitmap bm;
275 SkImageGenerator* ig = new TestImageGenerator(
276 TestImageGenerator::kSucceedGetPixels_TestType,
277 reporter);
278 SkInstallDiscardablePixelRef(ig, &bm, NULL);
279 bm.pixelRef()->lockPixels();
280 }
281
271 /** 282 /**
272 * This tests the basic functionality of SkDiscardablePixelRef with a 283 * This tests the basic functionality of SkDiscardablePixelRef with a
273 * basic SkImageGenerator implementation and several 284 * basic SkImageGenerator implementation and several
274 * SkDiscardableMemory::Factory choices. 285 * SkDiscardableMemory::Factory choices.
275 */ 286 */
276 DEF_TEST(DiscardableAndCachingPixelRef, reporter) { 287 DEF_TEST(DiscardableAndCachingPixelRef, reporter) {
288 test_newlockdelete(reporter);
289
277 CheckPixelRef(TestImageGenerator::kFailGetInfo_TestType, 290 CheckPixelRef(TestImageGenerator::kFailGetInfo_TestType,
278 reporter, kSkCaching_PixelRefType, NULL); 291 reporter, kSkCaching_PixelRefType, NULL);
279 CheckPixelRef(TestImageGenerator::kFailGetPixels_TestType, 292 CheckPixelRef(TestImageGenerator::kFailGetPixels_TestType,
280 reporter, kSkCaching_PixelRefType, NULL); 293 reporter, kSkCaching_PixelRefType, NULL);
281 CheckPixelRef(TestImageGenerator::kSucceedGetPixels_TestType, 294 CheckPixelRef(TestImageGenerator::kSucceedGetPixels_TestType,
282 reporter, kSkCaching_PixelRefType, NULL); 295 reporter, kSkCaching_PixelRefType, NULL);
283 296
284 CheckPixelRef(TestImageGenerator::kFailGetInfo_TestType, 297 CheckPixelRef(TestImageGenerator::kFailGetInfo_TestType,
285 reporter, kSkDiscardable_PixelRefType, NULL); 298 reporter, kSkDiscardable_PixelRefType, NULL);
286 CheckPixelRef(TestImageGenerator::kFailGetPixels_TestType, 299 CheckPixelRef(TestImageGenerator::kFailGetPixels_TestType,
(...skipping 14 matching lines...) Expand all
301 SkDiscardableMemoryPool* globalPool = SkGetGlobalDiscardableMemoryPool(); 314 SkDiscardableMemoryPool* globalPool = SkGetGlobalDiscardableMemoryPool();
302 // Only acts differently from NULL on a platform that has a 315 // Only acts differently from NULL on a platform that has a
303 // default discardable memory implementation that differs from the 316 // default discardable memory implementation that differs from the
304 // global DM pool. 317 // global DM pool.
305 CheckPixelRef(TestImageGenerator::kFailGetPixels_TestType, 318 CheckPixelRef(TestImageGenerator::kFailGetPixels_TestType,
306 reporter, kSkDiscardable_PixelRefType, globalPool); 319 reporter, kSkDiscardable_PixelRefType, globalPool);
307 CheckPixelRef(TestImageGenerator::kSucceedGetPixels_TestType, 320 CheckPixelRef(TestImageGenerator::kSucceedGetPixels_TestType,
308 reporter, kSkDiscardable_PixelRefType, globalPool); 321 reporter, kSkDiscardable_PixelRefType, globalPool);
309 } 322 }
310 //////////////////////////////////////////////////////////////////////////////// 323 ////////////////////////////////////////////////////////////////////////////////
OLDNEW
« no previous file with comments | « src/lazy/SkDiscardablePixelRef.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698