add debugging flag SK_IGNORE_PIXELREF_SETPRELOCKED for pixelref locks (disabled)



git-svn-id: http://skia.googlecode.com/svn/trunk@6800 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/core/SkPixelRef.h b/include/core/SkPixelRef.h
index a2427ab..673e23c 100644
--- a/include/core/SkPixelRef.h
+++ b/include/core/SkPixelRef.h
@@ -15,6 +15,20 @@
 #include "SkString.h"
 #include "SkFlattenable.h"
 
+#ifdef SK_DEBUG
+    /**
+     *  Defining SK_IGNORE_PIXELREF_SETPRELOCKED will force all pixelref
+     *  subclasses to correctly handle lock/unlock pixels. For performance
+     *  reasons, simple malloc-based subclasses call setPreLocked() to skip
+     *  the overhead of implementing these calls.
+     *
+     *  This build-flag disables that optimization, to add in debugging our
+     *  call-sites, to ensure that they correctly balance their calls of
+     *  lock and unlock.
+     */
+//    #define SK_IGNORE_PIXELREF_SETPRELOCKED
+#endif
+
 class SkColorTable;
 class SkData;
 struct SkIRect;
diff --git a/src/core/SkPixelRef.cpp b/src/core/SkPixelRef.cpp
index 2eb6f45..4cf47e3 100644
--- a/src/core/SkPixelRef.cpp
+++ b/src/core/SkPixelRef.cpp
@@ -81,12 +81,14 @@
 }
 
 void SkPixelRef::setPreLocked(void* pixels, SkColorTable* ctable) {
+#ifndef SK_IGNORE_PIXELREF_SETPRELOCKED
     // only call me in your constructor, otherwise fLockCount tracking can get
     // out of sync.
     fPixels = pixels;
     fColorTable = ctable;
     fLockCount = SKPIXELREF_PRELOCKED_LOCKCOUNT;
     fPreLocked = true;
+#endif
 }
 
 void SkPixelRef::flatten(SkFlattenableWriteBuffer& buffer) const {