m_textureB.unlock();
}
+void DoubleBufferedTexture::consumerDeleteTextures()
+{
+ m_textureA.lock();
+ m_textureB.lock();
+ LOGV("Deleting Consumer Textures A/B (%d:%d)", m_textureA.getTargetTextureId(),
+ m_textureB.getTargetTextureId());
+ m_textureA.deleteTargetTexture();
+ m_textureB.deleteTargetTexture();
+ m_textureA.unlock();
+ m_textureB.unlock();
+}
+
TextureInfo* DoubleBufferedTexture::producerLock()
{
SharedTexture* sharedTex = getWriteableTexture();
// consumer thread functions
TextureInfo* consumerLock();
void consumerRelease();
+ void consumerDeleteTextures();
protected:
SharedTexture* getReadableTexture();
/* Decrement the number of objects in the consumer's thread that are holding a
* reference to this object. When removing the last reference we must delete
* this object and by extension cleanup all GL objects that are associated with
- * the consumer's thread. At the time of deletion there should be no remaining
- * producer references.
+ * the consumer's thread. At the time of deletion if there is a remaining
+ * producer reference we must cleanup the consumer GL objects in the event that
+ * this texture will not be re-synced with the UI thread.
*/
void MediaTexture::consumerDec()
{
m_mediaLock.lock();
m_consumerRefCount--;
if (m_consumerRefCount == 0) {
- needsDeleted = true;
- if (m_producerRefCount != 0) {
- XLOG("ERROR: We should not delete the consumer before the producer is finished");
+ consumerDeleteTextures();
+ if (m_producerRefCount < 1) {
+ XLOG("WARNING: This texture still exists within webkit.");
+ needsDeleted = true;
}
}
m_mediaLock.unlock();
// source texture and EGLImage is the responsibility of the caller.
SharedTexture::~SharedTexture()
{
- if (m_supportsEGLImage)
- GLUtils::deleteTexture(&m_targetTexture.m_textureId);
- else
- GLUtils::deleteTexture(&m_sourceTexture.m_textureId);
+ deleteTargetTexture();
}
void SharedTexture::initSourceTexture()
}
}
+void SharedTexture::deleteTargetTexture()
+{
+ if (m_supportsEGLImage)
+ GLUtils::deleteTexture(&m_targetTexture.m_textureId);
+ else
+ GLUtils::deleteTexture(&m_sourceTexture.m_textureId);
+}
+
TextureInfo* SharedTexture::lockSource()
{
m_lock.lock();
void initSourceTexture(); // producer thread only
void deleteSourceTexture(); // producer thread only
+ void deleteTargetTexture(); // consumer thread only
GLuint getSourceTextureId() { return m_sourceTexture.m_textureId; }
GLuint getTargetTextureId() { return m_targetTexture.m_textureId; }
EGLImageKHR getEGLImage() { return m_eglImage; }