Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(992)

Unified Diff: Source/core/html/canvas/WebGLObject.cpp

Issue 365653002: Oilpan: move 2D Canvas and WebGL objects to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Smaller adjustments Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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)
{

Powered by Google App Engine
This is Rietveld 408576698