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:
parent
b4a797f3aa
commit
ab8657722c
@ -15,6 +15,7 @@
|
|||||||
'skia_for_android_framework_defines': [
|
'skia_for_android_framework_defines': [
|
||||||
'SK_SUPPORT_LEGACY_PUBLIC_IMAGEINFO_FIELDS',
|
'SK_SUPPORT_LEGACY_PUBLIC_IMAGEINFO_FIELDS',
|
||||||
'SK_SUPPORT_LEGACY_GETDEVICE',
|
'SK_SUPPORT_LEGACY_GETDEVICE',
|
||||||
|
'SK_SUPPORT_LEGACY_UNBALANCED_PIXELREF_LOCKCOUNT',
|
||||||
# Needed until we fix skbug.com/2440.
|
# Needed until we fix skbug.com/2440.
|
||||||
'SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG',
|
'SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG',
|
||||||
'SK_IGNORE_LINEONLY_AA_CONVEX_PATH_OPTS',
|
'SK_IGNORE_LINEONLY_AA_CONVEX_PATH_OPTS',
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "SkThread.h"
|
#include "SkThread.h"
|
||||||
#include "SkTraceEvent.h"
|
#include "SkTraceEvent.h"
|
||||||
|
|
||||||
|
//#define SK_SUPPORT_LEGACY_UNBALANCED_PIXELREF_LOCKCOUNT
|
||||||
//#define SK_TRACE_PIXELREF_LIFETIME
|
//#define SK_TRACE_PIXELREF_LIFETIME
|
||||||
|
|
||||||
#ifdef SK_BUILD_FOR_WIN32
|
#ifdef SK_BUILD_FOR_WIN32
|
||||||
@ -130,6 +131,10 @@ SkPixelRef::SkPixelRef(const SkImageInfo& info, SkBaseMutex* mutex)
|
|||||||
}
|
}
|
||||||
|
|
||||||
SkPixelRef::~SkPixelRef() {
|
SkPixelRef::~SkPixelRef() {
|
||||||
|
#ifndef SK_SUPPORT_LEGACY_UNBALANCED_PIXELREF_LOCKCOUNT
|
||||||
|
SkASSERT(SKPIXELREF_PRELOCKED_LOCKCOUNT == fLockCount || 0 == fLockCount);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef SK_TRACE_PIXELREF_LIFETIME
|
#ifdef SK_TRACE_PIXELREF_LIFETIME
|
||||||
SkDebugf("~pixelref %d\n", sk_atomic_dec(&gInstCounter) - 1);
|
SkDebugf("~pixelref %d\n", sk_atomic_dec(&gInstCounter) - 1);
|
||||||
#endif
|
#endif
|
||||||
|
@ -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
|
// new/lock/delete is an odd pattern for a pixelref, but it needs to not assert
|
||||||
static void test_newlockdelete(skiatest::Reporter* reporter) {
|
static void test_newlockdelete(skiatest::Reporter* reporter) {
|
||||||
|
#ifdef SK_SUPPORT_LEGACY_UNBALANCED_PIXELREF_LOCKCOUNT
|
||||||
SkBitmap bm;
|
SkBitmap bm;
|
||||||
SkImageGenerator* ig = new TestImageGenerator(
|
SkImageGenerator* ig = new TestImageGenerator(
|
||||||
TestImageGenerator::kSucceedGetPixels_TestType, reporter);
|
TestImageGenerator::kSucceedGetPixels_TestType, reporter);
|
||||||
SkInstallDiscardablePixelRef(ig, &bm);
|
SkInstallDiscardablePixelRef(ig, &bm);
|
||||||
bm.pixelRef()->lockPixels();
|
bm.pixelRef()->lockPixels();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user