m_display = eglGetCurrentDisplay();
m_pContext = EGL_NO_CONTEXT;
m_cContext = sharedContext;
- m_writeableTexture = GL_NO_TEXTURE;
+ m_writeableTexture = &m_textureA;
m_lockedConsumerTexture = GL_NO_TEXTURE;
m_supportsEGLImage = GLUtils::isEGLImageSupported();
}
SharedTexture* DoubleBufferedTexture::getWriteableTexture()
{
- return (m_writeableTexture == &m_textureA) ? &m_textureA : &m_textureB;
+ return reinterpret_cast<SharedTexture*>(
+ android_atomic_release_load((int32_t*)&m_writeableTexture));
}
SharedTexture* DoubleBufferedTexture::getReadableTexture()
{
- return (m_writeableTexture != &m_textureA) ? &m_textureA : &m_textureB;
+ return (getWriteableTexture() != &m_textureA) ? &m_textureA : &m_textureB;
}
EGLContext DoubleBufferedTexture::producerAcquireContext()
m_textureA.unlock();
m_textureB.unlock();
- // select a front buffer
- m_writeableTexture = &m_textureA;
-
m_pContext = context;
return context;
}
SharedTexture* sharedTex = getWriteableTexture();
LOGV("Releasing P Lock (%d)", sharedTex->getSourceTextureId());
sharedTex->releaseSource();
+ LOGV("Released P Lock (%d)", sharedTex->getSourceTextureId());
}
void DoubleBufferedTexture::producerReleaseAndSwap()
// swap the front and back buffers using an atomic op for the memory barrier
android_atomic_acquire_store((int32_t)getReadableTexture(), (int32_t*)&m_writeableTexture);
- LOGV("Released P Lock (%d)", m_writeableTexture->getSourceTextureId());
}
TextureInfo* DoubleBufferedTexture::consumerLock()