Index: Source/core/html/canvas/WebGLObject.cpp |
diff --git a/Source/core/html/canvas/WebGLObject.cpp b/Source/core/html/canvas/WebGLObject.cpp |
index bcc8adc3e9dcf171d5ec2b735ef97a69bf0ea79a..802a4ad3ff189e641eca85554c0fd8bb0c1cf36c 100644 |
--- a/Source/core/html/canvas/WebGLObject.cpp |
+++ b/Source/core/html/canvas/WebGLObject.cpp |
@@ -38,6 +38,8 @@ WebGLObject::WebGLObject(WebGLRenderingContextBase*) |
WebGLObject::~WebGLObject() |
{ |
+ // Verify that platform objects have been explicitly deleted. |
+ ASSERT(m_deleted); |
} |
void WebGLObject::setObject(Platform3DObject object) |
@@ -70,8 +72,25 @@ void WebGLObject::deleteObject(blink::WebGraphicsContext3D* context3d) |
void WebGLObject::detach() |
{ |
m_attachmentCount = 0; // Make sure OpenGL resource is deleted. |
- } |
+} |
+void WebGLObject::detachAndDeleteObject() |
+{ |
+ // Helper method that pairs detachment with platform object |
+ // deletion. |
+ // |
+ // With Oilpan enabled, objects may end up being finalized without |
+ // having been detached first. Consequently, the objects force |
+ // detachment first before deleting the platform object. Without |
+ // Oilpan, the objects will have been detached from the 'parent' |
+ // objects first and do not separately require it when finalizing. |
+ // |
+ // However, as detach() is trivial, the individual WebGL |
+ // destructors will always call detachAndDeleteObject() rather |
+ // than do it based on Oilpan being enabled. |
+ detach(); |
+ deleteObject(0); |
+} |
void WebGLObject::onDetached(blink::WebGraphicsContext3D* context3d) |
{ |