Chromium Code Reviews| Index: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp |
| diff --git a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp |
| index e156684c20d05c411f7b235db09fb49701e16d35..ee8357c18b57bf18ec4bb2aa18666d8637203bbb 100644 |
| --- a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp |
| +++ b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp |
| @@ -96,7 +96,9 @@ |
| #include "public/platform/Platform.h" |
| #include "public/platform/WebGraphicsContext3D.h" |
| #include "public/platform/WebGraphicsContext3DProvider.h" |
| +#include "public/platform/callback/WebClosure.h" |
| #include "wtf/ArrayBufferContents.h" |
| +#include "wtf/Functional.h" |
| #include "wtf/PassOwnPtr.h" |
| #include "wtf/text/StringBuilder.h" |
| #include "wtf/text/StringUTF8Adaptor.h" |
| @@ -491,29 +493,6 @@ private: |
| RawPtrWillBeMember<WebGLRenderingContextBase> m_context; |
| }; |
| -class WebGLRenderingContextLostCallback final : public GarbageCollectedFinalized<WebGLRenderingContextLostCallback>, public WebGraphicsContext3D::WebGraphicsContextLostCallback { |
| -public: |
| - static WebGLRenderingContextLostCallback* create(WebGLRenderingContextBase* context) |
| - { |
| - return new WebGLRenderingContextLostCallback(context); |
| - } |
| - |
| - ~WebGLRenderingContextLostCallback() override { } |
| - |
| - virtual void onContextLost() { m_context->forceLostContext(WebGLRenderingContextBase::RealLostContext, WebGLRenderingContextBase::Auto); } |
| - |
| - DEFINE_INLINE_TRACE() |
| - { |
| - visitor->trace(m_context); |
| - } |
| - |
| -private: |
| - explicit WebGLRenderingContextLostCallback(WebGLRenderingContextBase* context) |
| - : m_context(context) { } |
| - |
| - RawPtrWillBeMember<WebGLRenderingContextBase> m_context; |
| -}; |
| - |
| class WebGLRenderingContextErrorMessageCallback final : public GarbageCollectedFinalized<WebGLRenderingContextErrorMessageCallback>, public WebGraphicsContext3D::WebGraphicsErrorMessageCallback { |
| public: |
| static WebGLRenderingContextErrorMessageCallback* create(WebGLRenderingContextBase* context) |
| @@ -993,10 +972,10 @@ void WebGLRenderingContextBase::initializeNewContext() |
| contextGL()->Viewport(0, 0, drawingBufferWidth(), drawingBufferHeight()); |
| contextGL()->Scissor(0, 0, drawingBufferWidth(), drawingBufferHeight()); |
| - m_contextLostCallbackAdapter = WebGLRenderingContextLostCallback::create(this); |
| m_errorMessageCallbackAdapter = WebGLRenderingContextErrorMessageCallback::create(this); |
| - webContext()->setContextLostCallback(m_contextLostCallbackAdapter.get()); |
| + // Uses raw |this| as the callback is reset before |this| is destroyed. |
| + drawingBuffer()->contextProvider()->setLostContextCallback(WebClosure(WTF::bind(&WebGLRenderingContextBase::forceLostContext, this, WebGLRenderingContextBase::RealLostContext, WebGLRenderingContextBase::Auto))); |
|
danakj
2016/03/24 23:12:56
Maybe this bind is keeping things alive from being
|
| webContext()->setErrorMessageCallback(m_errorMessageCallbackAdapter.get()); |
| // This ensures that the context has a valid "lastFlushID" and won't be mistakenly identified as the "least recently used" context. |
| @@ -1112,7 +1091,7 @@ void WebGLRenderingContextBase::destroyContext() |
| m_extensionsUtil.clear(); |
| - webContext()->setContextLostCallback(nullptr); |
| + drawingBuffer()->contextProvider()->setLostContextCallback(WebClosure()); |
| webContext()->setErrorMessageCallback(nullptr); |
| ASSERT(drawingBuffer()); |
| @@ -6283,7 +6262,6 @@ DEFINE_TRACE(WebGLRenderingContextBase) |
| #if ENABLE(OILPAN) |
| visitor->trace(m_contextObjects); |
| #endif |
| - visitor->trace(m_contextLostCallbackAdapter); |
| visitor->trace(m_errorMessageCallbackAdapter); |
| visitor->trace(m_boundArrayBuffer); |
| visitor->trace(m_defaultVertexArrayObject); |