Proliferate gl::Context everywhere.
This gives the D3D back-end access to the GL state almost anywhere.
This uses the onDestroy hook for Textures to push errors up from
destructors, although they still don't quite make it to the Context.
There are places, such as in EGL object (Context/Surface) destruction,
where we end up calling through to GL implementation internals without
having access to a gl::Context. We handle this via a proxy Context
to a Display, basically a null context, that has access to impl-side
state like the Renderer pointer if necessary. It does not have access
to the normal GL state.
Also Pass gl::Context to RefCountObject::release(). Since we're using
destroy() methods now, we should not ever call the destructor directly.
BUG=angleproject:1156
Change-Id: Ie4c32ad6bf6caaff0289901f30b5c6bafa2ce259
Reviewed-on: https://chromium-review.googlesource.com/529707
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libANGLE/ResourceManager.cpp b/src/libANGLE/ResourceManager.cpp
index 18e1fd2..d8690b7 100644
--- a/src/libANGLE/ResourceManager.cpp
+++ b/src/libANGLE/ResourceManager.cpp
@@ -92,8 +92,7 @@
if (objectIter->second != nullptr)
{
- objectIter->second->destroy(context);
- ImplT::DeleteObject(objectIter->second);
+ ImplT::DeleteObject(context, objectIter->second);
}
// Requires an explicit this-> because of C++ template rules.
@@ -168,9 +167,9 @@
}
// static
-void BufferManager::DeleteObject(Buffer *buffer)
+void BufferManager::DeleteObject(const Context *context, Buffer *buffer)
{
- buffer->release();
+ buffer->release(context);
}
GLuint BufferManager::createBuffer()
@@ -262,8 +261,7 @@
if (object->getRefCount() == 0)
{
mHandleAllocator.release(id);
- object->destroy(context);
- SafeDelete(object);
+ object->onDestroy(context);
objectMap->erase(iter);
}
else
@@ -283,9 +281,9 @@
}
// static
-void TextureManager::DeleteObject(Texture *texture)
+void TextureManager::DeleteObject(const Context *context, Texture *texture)
{
- texture->release();
+ texture->release(context);
}
GLuint TextureManager::createTexture()
@@ -326,9 +324,9 @@
}
// static
-void RenderbufferManager::DeleteObject(Renderbuffer *renderbuffer)
+void RenderbufferManager::DeleteObject(const Context *context, Renderbuffer *renderbuffer)
{
- renderbuffer->release();
+ renderbuffer->release(context);
}
GLuint RenderbufferManager::createRenderbuffer()
@@ -357,9 +355,9 @@
}
// static
-void SamplerManager::DeleteObject(Sampler *sampler)
+void SamplerManager::DeleteObject(const Context *context, Sampler *sampler)
{
- sampler->release();
+ sampler->release(context);
}
GLuint SamplerManager::createSampler()
@@ -380,9 +378,9 @@
// FenceSyncManager Implementation.
// static
-void FenceSyncManager::DeleteObject(FenceSync *fenceSync)
+void FenceSyncManager::DeleteObject(const Context *context, FenceSync *fenceSync)
{
- fenceSync->release();
+ fenceSync->release(context);
}
GLuint FenceSyncManager::createFenceSync(rx::GLImplFactory *factory)
@@ -477,11 +475,12 @@
}
// static
-void FramebufferManager::DeleteObject(Framebuffer *framebuffer)
+void FramebufferManager::DeleteObject(const Context *context, Framebuffer *framebuffer)
{
// Default framebuffer are owned by their respective Surface
if (framebuffer->id() != 0)
{
+ framebuffer->onDestroy(context);
delete framebuffer;
}
}