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

Side by Side Diff: tests/CachedDecodingPixelRefTest.cpp

Issue 1147153004: add assert that the lock-count on pixelref is balanced (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 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
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 "SkCachingPixelRef.h" 9 #include "SkCachingPixelRef.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 success = SkInstallDiscardablePixelRef(gen.detach(), &lazy, factory); 252 success = SkInstallDiscardablePixelRef(gen.detach(), &lazy, factory);
253 } 253 }
254 REPORTER_ASSERT(reporter, success); 254 REPORTER_ASSERT(reporter, success);
255 if (TestImageGenerator::kSucceedGetPixels_TestType == type) { 255 if (TestImageGenerator::kSucceedGetPixels_TestType == type) {
256 check_test_image_generator_bitmap(reporter, lazy); 256 check_test_image_generator_bitmap(reporter, lazy);
257 } else if (TestImageGenerator::kFailGetPixels_TestType == type) { 257 } else if (TestImageGenerator::kFailGetPixels_TestType == type) {
258 SkAutoLockPixels autoLockPixels(lazy); 258 SkAutoLockPixels autoLockPixels(lazy);
259 REPORTER_ASSERT(reporter, NULL == lazy.getPixels()); 259 REPORTER_ASSERT(reporter, NULL == lazy.getPixels());
260 } 260 }
261 } 261 }
262 262
robertphillips 2015/05/21 13:32:04 // TODO: remove this test ?
263 // new/lock/delete is an odd pattern for a pixelref, but it needs to not assert 263 // new/lock/delete is an odd pattern for a pixelref, but it needs to not assert
264 static void test_newlockdelete(skiatest::Reporter* reporter) { 264 static void test_newlockdelete(skiatest::Reporter* reporter) {
265 #ifdef SK_SUPPORT_LEGACY_UNBALANCED_PIXELREF_LOCKCOUNT
265 SkBitmap bm; 266 SkBitmap bm;
266 SkImageGenerator* ig = new TestImageGenerator( 267 SkImageGenerator* ig = new TestImageGenerator(
267 TestImageGenerator::kSucceedGetPixels_TestType, reporter); 268 TestImageGenerator::kSucceedGetPixels_TestType, reporter);
268 SkInstallDiscardablePixelRef(ig, &bm); 269 SkInstallDiscardablePixelRef(ig, &bm);
269 bm.pixelRef()->lockPixels(); 270 bm.pixelRef()->lockPixels();
271 #endif
270 } 272 }
271 273
272 /** 274 /**
273 * This tests the basic functionality of SkDiscardablePixelRef with a 275 * This tests the basic functionality of SkDiscardablePixelRef with a
274 * basic SkImageGenerator implementation and several 276 * basic SkImageGenerator implementation and several
275 * SkDiscardableMemory::Factory choices. 277 * SkDiscardableMemory::Factory choices.
276 */ 278 */
277 DEF_TEST(DiscardableAndCachingPixelRef, reporter) { 279 DEF_TEST(DiscardableAndCachingPixelRef, reporter) {
278 test_newlockdelete(reporter); 280 test_newlockdelete(reporter);
279 281
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 canvas.clear(kDefaultColor); 335 canvas.clear(kDefaultColor);
334 canvas.drawImage(image, 0, 0, NULL); 336 canvas.drawImage(image, 0, 0, NULL);
335 if (TestImageGenerator::kSucceedGetPixels_TestType == test) { 337 if (TestImageGenerator::kSucceedGetPixels_TestType == test) {
336 REPORTER_ASSERT( 338 REPORTER_ASSERT(
337 r, TestImageGenerator::Color() == *bitmap.getAddr32(0, 0)); 339 r, TestImageGenerator::Color() == *bitmap.getAddr32(0, 0));
338 } else { 340 } else {
339 REPORTER_ASSERT(r, kDefaultColor == bitmap.getColor(0,0)); 341 REPORTER_ASSERT(r, kDefaultColor == bitmap.getColor(0,0));
340 } 342 }
341 } 343 }
342 } 344 }
OLDNEW
« gyp/skia_for_android_framework_defines.gypi ('K') | « src/core/SkPixelRef.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698