add assert that the lock-count on pixelref is balanced

BUG=skia:
TBR=

Review URL: https://codereview.chromium.org/1147153004
This commit is contained in:
reed 2015-05-21 06:29:05 -07:00 committed by Commit bot
parent b4a797f3aa
commit ab8657722c
3 changed files with 8 additions and 0 deletions

View File

@ -15,6 +15,7 @@
'skia_for_android_framework_defines': [
'SK_SUPPORT_LEGACY_PUBLIC_IMAGEINFO_FIELDS',
'SK_SUPPORT_LEGACY_GETDEVICE',
'SK_SUPPORT_LEGACY_UNBALANCED_PIXELREF_LOCKCOUNT',
# Needed until we fix skbug.com/2440.
'SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG',
'SK_IGNORE_LINEONLY_AA_CONVEX_PATH_OPTS',

View File

@ -10,6 +10,7 @@
#include "SkThread.h"
#include "SkTraceEvent.h"
//#define SK_SUPPORT_LEGACY_UNBALANCED_PIXELREF_LOCKCOUNT
//#define SK_TRACE_PIXELREF_LIFETIME
#ifdef SK_BUILD_FOR_WIN32
@ -130,6 +131,10 @@ SkPixelRef::SkPixelRef(const SkImageInfo& info, SkBaseMutex* mutex)
}
SkPixelRef::~SkPixelRef() {
#ifndef SK_SUPPORT_LEGACY_UNBALANCED_PIXELREF_LOCKCOUNT
SkASSERT(SKPIXELREF_PRELOCKED_LOCKCOUNT == fLockCount || 0 == fLockCount);
#endif
#ifdef SK_TRACE_PIXELREF_LIFETIME
SkDebugf("~pixelref %d\n", sk_atomic_dec(&gInstCounter) - 1);
#endif

View File

@ -262,11 +262,13 @@ static void check_pixelref(TestImageGenerator::TestType type,
// new/lock/delete is an odd pattern for a pixelref, but it needs to not assert
static void test_newlockdelete(skiatest::Reporter* reporter) {
#ifdef SK_SUPPORT_LEGACY_UNBALANCED_PIXELREF_LOCKCOUNT
SkBitmap bm;
SkImageGenerator* ig = new TestImageGenerator(
TestImageGenerator::kSucceedGetPixels_TestType, reporter);
SkInstallDiscardablePixelRef(ig, &bm);
bm.pixelRef()->lockPixels();
#endif
}
/**