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

Unified Diff: Source/core/html/canvas/WebGLProgram.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/WebGLProgram.cpp
diff --git a/Source/core/html/canvas/WebGLProgram.cpp b/Source/core/html/canvas/WebGLProgram.cpp
index e43b387dc06f192d5d1a9e9f22ffe95640c52324..db19263ecc2bcca766175231f8c69c10ecb5bc62 100644
--- a/Source/core/html/canvas/WebGLProgram.cpp
+++ b/Source/core/html/canvas/WebGLProgram.cpp
@@ -27,13 +27,14 @@
#include "core/html/canvas/WebGLProgram.h"
+#include "core/html/canvas/WebGLContextGroup.h"
#include "core/html/canvas/WebGLRenderingContextBase.h"
namespace blink {
-PassRefPtr<WebGLProgram> WebGLProgram::create(WebGLRenderingContextBase* ctx)
+PassRefPtrWillBeRawPtr<WebGLProgram> WebGLProgram::create(WebGLRenderingContextBase* ctx)
{
- return adoptRef(new WebGLProgram(ctx));
+ return adoptRefWillBeNoop(new WebGLProgram(ctx));
}
WebGLProgram::WebGLProgram(WebGLRenderingContextBase* ctx)
@@ -48,7 +49,22 @@ WebGLProgram::WebGLProgram(WebGLRenderingContextBase* ctx)
WebGLProgram::~WebGLProgram()
{
- deleteObject(0);
+#if ENABLE(OILPAN)
+ // These heap objects handle detachment on their own. Clear out
+ // the references to prevent deleteObjectImpl() from trying to do
+ // same, as we cannot safely access other heap objects from this
+ // destructor.
+ m_vertexShader = nullptr;
+ m_fragmentShader = nullptr;
+#endif
+ // Always call detach here to ensure that platform object deletion
+ // happens with Oilpan enabled. It keeps the code regular to do it
+ // with or without Oilpan enabled.
+ //
+ // See comment in WebGLBuffer's destructor for additional
+ // information on why this is done for WebGLSharedObject-derived
+ // objects.
+ detachAndDeleteObject();
}
void WebGLProgram::deleteObjectImpl(blink::WebGraphicsContext3D* context3d, Platform3DObject obj)
@@ -174,7 +190,9 @@ void WebGLProgram::cacheInfoIfNeeded()
if (!object())
return;
- blink::WebGraphicsContext3D* context = getAWebGraphicsContext3D();
+ if (!contextGroup())
+ return;
+ blink::WebGraphicsContext3D* context = contextGroup()->getAWebGraphicsContext3D();
if (!context)
return;
GLint linkStatus = 0;
@@ -185,4 +203,11 @@ void WebGLProgram::cacheInfoIfNeeded()
m_infoValid = true;
}
+void WebGLProgram::trace(Visitor* visitor)
+{
+ visitor->trace(m_vertexShader);
+ visitor->trace(m_fragmentShader);
+ WebGLSharedObject::trace(visitor);
+}
+
}

Powered by Google App Engine
This is Rietveld 408576698