{
return parentTexture->addRef();
}
-
- sw::atomicIncrement(&referenceCount);
+ int newCount = sw::atomicIncrement(&referenceCount);
+ LOGLOCK("%s image=%p referenceCount=%d", __FUNCTION__, this, newCount);
}
void Image::release()
return parentTexture->release();
}
- if(referenceCount > 0)
- {
- sw::atomicDecrement(&referenceCount);
- }
-
- if(referenceCount == 0)
+ int newCount = sw::atomicDecrement(&referenceCount);
+ LOGLOCK("%s image=%p referenceCount=%d", __FUNCTION__, this, newCount);
+ if (newCount == 0)
{
ASSERT(!shared); // Should still hold a reference if eglDestroyImage hasn't been called
delete this;
\r
#ifdef __ANDROID__\r
#include "../../Common/DebugAndroid.hpp"\r
+#define LOGLOCK(fmt, ...) // ALOGI(fmt " tid=%d", ##__VA_ARGS__, gettid())\r
#else\r
#include <assert.h>\r
+#define LOGLOCK(...)\r
#endif\r
\r
namespace egl\r
\r
virtual void *lockInternal(int x, int y, int z, sw::Lock lock, sw::Accessor client)\r
{\r
- if(nativeBuffer) // Lock the buffer from ANativeWindowBuffer\r
+ LOGLOCK("image=%p op=%s.swsurface lock=%d", this, __FUNCTION__, lock);\r
+ // Always do this for reference counting.\r
+ void *data = sw::Surface::lockInternal(x, y, z, lock, client);\r
+ if(nativeBuffer)\r
{\r
- void *data = lockNativeBuffer(\r
+ if (x || y || z)\r
+ {\r
+ ALOGI("badness: %s called with unsupported parms: image=%p x=%d y=%d z=%d", __FUNCTION__, this, x, y, z);\r
+ }\r
+ LOGLOCK("image=%p op=%s.ani lock=%d", this, __FUNCTION__, lock);\r
+ // Lock the ANativeWindowBuffer and use it's address.\r
+ data = lockNativeBuffer(\r
GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN);\r
if (lock == sw::LOCK_UNLOCKED)\r
{\r
// immediately. This keeps the gralloc reference counts sane.\r
unlockNativeBuffer();\r
}\r
- return data;\r
}\r
- return sw::Surface::lockInternal(x, y, z, lock, client);\r
+ return data;\r
}\r
\r
virtual void unlockInternal()\r
{\r
if(nativeBuffer) // Unlock the buffer from ANativeWindowBuffer\r
{\r
- return unlockNativeBuffer();\r
+ LOGLOCK("image=%p op=%s.ani", this, __FUNCTION__);\r
+ unlockNativeBuffer();\r
}\r
- return sw::Surface::unlockInternal();\r
+ LOGLOCK("image=%p op=%s.swsurface", this, __FUNCTION__);\r
+ sw::Surface::unlockInternal();\r
}\r
\r
- virtual void *lock(unsigned int /*left*/, unsigned int /*top*/, sw::Lock /*lock*/)\r
+ virtual void *lock(unsigned int left, unsigned int top, sw::Lock lock)\r
{\r
+ LOGLOCK("image=%p op=%s lock=%d", this, __FUNCTION__, lock);\r
+ (void)sw::Surface::lockExternal(left, top, 0, lock, sw::PUBLIC);\r
return lockNativeBuffer(GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN);\r
}\r
\r
virtual void unlock()\r
{\r
+ LOGLOCK("image=%p op=%s.ani", this, __FUNCTION__);\r
unlockNativeBuffer();\r
+ LOGLOCK("image=%p op=%s.swsurface", this, __FUNCTION__);\r
+ sw::Surface::unlockExternal();\r
}\r
\r
void* lockNativeBuffer(int usage)\r