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

Unified Diff: Source/core/html/canvas/WebGLVertexArrayObjectOES.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/WebGLVertexArrayObjectOES.cpp
diff --git a/Source/core/html/canvas/WebGLVertexArrayObjectOES.cpp b/Source/core/html/canvas/WebGLVertexArrayObjectOES.cpp
index a1d8f858ab7c23e42fbae0649bcd61a046c445b8..35260b393eeb49e03ddc2e0a583c63508bed06ca 100644
--- a/Source/core/html/canvas/WebGLVertexArrayObjectOES.cpp
+++ b/Source/core/html/canvas/WebGLVertexArrayObjectOES.cpp
@@ -31,9 +31,9 @@
namespace blink {
-PassRefPtr<WebGLVertexArrayObjectOES> WebGLVertexArrayObjectOES::create(WebGLRenderingContextBase* ctx, VaoType type)
+PassRefPtrWillBeRawPtr<WebGLVertexArrayObjectOES> WebGLVertexArrayObjectOES::create(WebGLRenderingContextBase* ctx, VaoType type)
{
- return adoptRef(new WebGLVertexArrayObjectOES(ctx, type));
+ return adoptRefWillBeNoop(new WebGLVertexArrayObjectOES(ctx, type));
}
WebGLVertexArrayObjectOES::WebGLVertexArrayObjectOES(WebGLRenderingContextBase* ctx, VaoType type)
@@ -56,7 +56,23 @@ WebGLVertexArrayObjectOES::WebGLVertexArrayObjectOES(WebGLRenderingContextBase*
WebGLVertexArrayObjectOES::~WebGLVertexArrayObjectOES()
{
- deleteObject(0);
+#if ENABLE(OILPAN)
+ // These heap objects must not be accessed by deleteObjectImpl(),
+ // clear them out before a call to it is triggered below. The
+ // finalizers of these two (and their elements) will themselves
+ // handle detachment.
+ m_boundElementArrayBuffer.clear();
+ m_vertexAttribState.clear();
+#endif
+ // Delete the platform framebuffer resource. Explicit detachment
+ // is for the benefit of Oilpan, where this vertex array object
+ // isn't detached when it and the WebGLRenderingContextBase object
+ // it is registered with are both finalized. Without Oilpan, the
+ // object will have been detached.
+ //
+ // To keep the code regular, the trivial detach()ment is always
+ // performed.
+ detachAndDeleteObject();
}
void WebGLVertexArrayObjectOES::deleteObjectImpl(blink::WebGraphicsContext3D* context3d, Platform3DObject object)
@@ -65,7 +81,7 @@ void WebGLVertexArrayObjectOES::deleteObjectImpl(blink::WebGraphicsContext3D* co
case VaoTypeDefault:
break;
default:
- context()->webContext()->deleteVertexArrayOES(object);
+ context3d->deleteVertexArrayOES(object);
break;
}
@@ -79,18 +95,17 @@ void WebGLVertexArrayObjectOES::deleteObjectImpl(blink::WebGraphicsContext3D* co
}
}
-void WebGLVertexArrayObjectOES::setElementArrayBuffer(PassRefPtr<WebGLBuffer> buffer)
+void WebGLVertexArrayObjectOES::setElementArrayBuffer(PassRefPtrWillBeRawPtr<WebGLBuffer> buffer)
{
if (buffer)
buffer->onAttached();
if (m_boundElementArrayBuffer)
m_boundElementArrayBuffer->onDetached(context()->webContext());
m_boundElementArrayBuffer = buffer;
-
}
void WebGLVertexArrayObjectOES::setVertexAttribState(
- GLuint index, GLsizei bytesPerElement, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset, PassRefPtr<WebGLBuffer> buffer)
+ GLuint index, GLsizei bytesPerElement, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset, PassRefPtrWillBeRawPtr<WebGLBuffer> buffer)
{
GLsizei validatedStride = stride ? stride : bytesPerElement;
@@ -111,7 +126,7 @@ void WebGLVertexArrayObjectOES::setVertexAttribState(
state.offset = offset;
}
-void WebGLVertexArrayObjectOES::unbindBuffer(PassRefPtr<WebGLBuffer> buffer)
+void WebGLVertexArrayObjectOES::unbindBuffer(PassRefPtrWillBeRawPtr<WebGLBuffer> buffer)
{
if (m_boundElementArrayBuffer == buffer) {
m_boundElementArrayBuffer->onDetached(context()->webContext());
@@ -133,4 +148,16 @@ void WebGLVertexArrayObjectOES::setVertexAttribDivisor(GLuint index, GLuint divi
state.divisor = divisor;
}
+void WebGLVertexArrayObjectOES::VertexAttribState::trace(Visitor* visitor)
+{
+ visitor->trace(bufferBinding);
+}
+
+void WebGLVertexArrayObjectOES::trace(Visitor* visitor)
+{
+ visitor->trace(m_boundElementArrayBuffer);
+ visitor->trace(m_vertexAttribState);
+ WebGLContextObject::trace(visitor);
+}
+
}

Powered by Google App Engine
This is Rietveld 408576698