| Index: Source/core/html/canvas/WebGLContextGroup.cpp
|
| diff --git a/Source/core/html/canvas/WebGLContextGroup.cpp b/Source/core/html/canvas/WebGLContextGroup.cpp
|
| index e9e3ebe267e639e30864491c04db7236a589b020..1eeb1ad91ddcaffc2b0b757065fd1034423fdb64 100644
|
| --- a/Source/core/html/canvas/WebGLContextGroup.cpp
|
| +++ b/Source/core/html/canvas/WebGLContextGroup.cpp
|
| @@ -31,25 +31,36 @@
|
|
|
| namespace WebCore {
|
|
|
| -PassRefPtr<WebGLContextGroup> WebGLContextGroup::create()
|
| +PassRefPtrWillBeRawPtr<WebGLContextGroup> WebGLContextGroup::create()
|
| {
|
| - RefPtr<WebGLContextGroup> contextGroup = adoptRef(new WebGLContextGroup());
|
| + RefPtrWillBeRawPtr<WebGLContextGroup> contextGroup = adoptRefWillBeNoop(new WebGLContextGroup());
|
| return contextGroup.release();
|
| }
|
|
|
| WebGLContextGroup::WebGLContextGroup()
|
| +#if ENABLE(OILPAN)
|
| + : m_savedContext(0)
|
| +#endif
|
| {
|
| }
|
|
|
| +#if !ENABLE(OILPAN)
|
| WebGLContextGroup::~WebGLContextGroup()
|
| {
|
| detachAndRemoveAllObjects();
|
| }
|
| +#endif
|
|
|
| blink::WebGraphicsContext3D* WebGLContextGroup::getAWebGraphicsContext3D()
|
| {
|
| +#if ENABLE(OILPAN)
|
| + ASSERT(!m_contexts.isEmpty() || m_savedContext);
|
| + if (m_savedContext)
|
| + return m_savedContext;
|
| +#else
|
| ASSERT(!m_contexts.isEmpty());
|
| - HashSet<WebGLRenderingContextBase*>::iterator it = m_contexts.begin();
|
| +#endif
|
| + WillBeHeapHashSet<RawPtrWillBeWeakMember<WebGLRenderingContextBase> >::iterator it = m_contexts.begin();
|
| return (*it)->webContext();
|
| }
|
|
|
| @@ -69,6 +80,13 @@ void WebGLContextGroup::removeContext(WebGLRenderingContextBase* context)
|
|
|
| void WebGLContextGroup::removeObject(WebGLSharedObject* object)
|
| {
|
| +#if ENABLE(OILPAN)
|
| + // Oilpan: if removal happens during weak callback processing, ignore.
|
| + // Done so as to prevent re-allocation of the backing store; the table
|
| + // is cleared afterwards instead.
|
| + if (m_savedContext)
|
| + return;
|
| +#endif
|
| m_groupObjects.remove(object);
|
| }
|
|
|
| @@ -80,7 +98,7 @@ void WebGLContextGroup::addObject(WebGLSharedObject* object)
|
| void WebGLContextGroup::detachAndRemoveAllObjects()
|
| {
|
| while (!m_groupObjects.isEmpty()) {
|
| - HashSet<WebGLSharedObject*>::iterator it = m_groupObjects.begin();
|
| + WillBeHeapHashSet<RawPtrWillBeWeakMember<WebGLSharedObject> >::iterator it = m_groupObjects.begin();
|
| (*it)->detachContextGroup();
|
| }
|
| }
|
| @@ -91,8 +109,36 @@ void WebGLContextGroup::loseContextGroup(WebGLRenderingContextBase::LostContextM
|
| // and prevents groupObjects from being properly deleted.
|
| detachAndRemoveAllObjects();
|
|
|
| - for (HashSet<WebGLRenderingContextBase*>::iterator it = m_contexts.begin(); it != m_contexts.end(); ++it)
|
| + for (WillBeHeapHashSet<RawPtrWillBeWeakMember<WebGLRenderingContextBase> >::iterator it = m_contexts.begin(); it != m_contexts.end(); ++it)
|
| (*it)->loseContextImpl(mode);
|
| }
|
|
|
| +void WebGLContextGroup::clearWeakMembers(Visitor*)
|
| +{
|
| +#if ENABLE(OILPAN)
|
| + // We must call detachAndRemoveAllObjects when there are no contexts left.
|
| + // In order to be able to provide the group objects with the WebGraphicsContext3D
|
| + // object they need on detach, one is saved away during tracing.
|
| + if (!m_contexts.size() && m_savedContext) {
|
| + detachAndRemoveAllObjects();
|
| + m_groupObjects.clear();
|
| + }
|
| + m_savedContext = 0;
|
| +#endif
|
| +}
|
| +
|
| +void WebGLContextGroup::trace(Visitor* visitor)
|
| +{
|
| +#if ENABLE(OILPAN)
|
| + // See clearWeakMembers() comment.
|
| + if (m_contexts.size() && m_groupObjects.size()) {
|
| + m_savedContext = getAWebGraphicsContext3D();
|
| + ASSERT(m_savedContext);
|
| + }
|
| +#endif
|
| + visitor->trace(m_contexts);
|
| + visitor->trace(m_groupObjects);
|
| + visitor->registerWeakMembers<WebGLContextGroup, &WebGLContextGroup::clearWeakMembers>(this);
|
| +}
|
| +
|
| } // namespace WebCore
|
|
|