add SK_DISABLE_PIXELREF_LOCKCOUNT_BALANCE_CHECK option, to disable check for
lock-count-balance when we use pixelrefs.



git-svn-id: http://skia.googlecode.com/svn/trunk@7460 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index b1e8678..63f783a 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -58,6 +58,22 @@
 #ifdef SK_DEBUG
 #include "SkPixelRef.h"
 
+/*
+ *  Some pixelref subclasses can support being "locked" from another thread
+ *  during the lock-scope of skia calling them. In these instances, this balance
+ *  check will fail, but may not be indicative of a problem, so we allow a build
+ *  flag to disable this check.
+ *
+ *  Potentially another fix would be to have a (debug-only) virtual or flag on
+ *  pixelref, which could tell us at runtime if this check is valid. That would
+ *  eliminate the need for this heavy-handed build check.
+ */
+#ifdef SK_DISABLE_PIXELREF_LOCKCOUNT_BALANCE_CHECK
+class AutoCheckLockCountBalance {
+public:
+    AutoCheckLockCountBalance(const SkBitmap&) { /* do nothing */ }
+};
+#else
 class AutoCheckLockCountBalance {
 public:
     AutoCheckLockCountBalance(const SkBitmap& bm) : fPixelRef(bm.pixelRef()) {
@@ -72,6 +88,7 @@
     const SkPixelRef* fPixelRef;
     int               fLockCount;
 };
+#endif
 
 class AutoCheckNoSetContext {
 public: