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

Unified Diff: Source/core/html/canvas/WebGLContextGroup.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: Complete VectorTraits<> specialization for VertexAttribState Created 6 years, 6 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/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();
haraken 2014/07/02 07:47:37 return adoptRefWillBeNoop(new WebGLContextGroup())
sof 2014/07/02 11:43:52 I've switched this back to returning PassRefPtr<>
}
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)
haraken 2014/07/02 07:47:38 Just help me understand: This branch hits only whe
sof 2014/07/02 11:43:52 Yes (to the last point), that's what I ended up wi
+ 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.
haraken 2014/07/02 07:47:38 Specifically, when can the removal happen during w
sof 2014/07/02 11:43:52 It happens when tracing has determined that no con
+ // 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();
haraken 2014/07/02 07:47:37 It looks dangerous to do something non-trivial in
+ ASSERT(m_savedContext);
+ }
+#endif
+ visitor->trace(m_contexts);
+ visitor->trace(m_groupObjects);
+ visitor->registerWeakMembers<WebGLContextGroup, &WebGLContextGroup::clearWeakMembers>(this);
+}
+
} // namespace WebCore

Powered by Google App Engine
This is Rietveld 408576698