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

Unified Diff: Source/core/html/canvas/WebGLContextGroup.cpp

Issue 17230006: Implement WEBGL_shared_resources Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 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 06204706c6c00ec9d79b816b717341f21eef9006..2603c1bb82e8ac18f324749b4ac291fe22dab325 100644
--- a/Source/core/html/canvas/WebGLContextGroup.cpp
+++ b/Source/core/html/canvas/WebGLContextGroup.cpp
@@ -39,6 +39,8 @@ PassRefPtr<WebGLContextGroup> WebGLContextGroup::create()
}
WebGLContextGroup::WebGLContextGroup()
+ : m_contextCreationCount(0)
+ , m_acquireRequestCount(0)
{
}
@@ -54,13 +56,19 @@ GraphicsContext3D* WebGLContextGroup::getAGraphicsContext3D()
return (*it)->graphicsContext3D();
}
-void WebGLContextGroup::addContext(WebGLRenderingContext* context)
+unsigned WebGLContextGroup::addContext(WebGLRenderingContext* context)
{
m_contexts.add(context);
+ return m_contextCreationCount++;
}
void WebGLContextGroup::removeContext(WebGLRenderingContext* context)
{
+ // Release all the resources this context has acquired.
+ for (HashSet<WebGLSharedObject*>::iterator it = m_groupObjects.begin(); it != m_groupObjects.end(); ++it) {
+ (*it)->release(context);
+ }
+
// We must call detachAndRemoveAllObjects before removing the last context.
if (m_contexts.size() == 1 && m_contexts.contains(context))
detachAndRemoveAllObjects();
@@ -94,4 +102,18 @@ void WebGLContextGroup::loseContextGroup(WebGLRenderingContext::LostContextMode
detachAndRemoveAllObjects();
}
+long WebGLContextGroup::generateAcquireRequestId()
+{
+ return ++m_acquireRequestCount;
+}
+
+void WebGLContextGroup::cancelAcquireSharedResource(const WebGLRenderingContext* context, long id)
+{
+ for (HashSet<WebGLSharedObject*>::iterator it = m_groupObjects.begin(); it != m_groupObjects.end(); ++it) {
+ if ((*it)->cancelAcquireRequest(context, id)) {
+ break;
+ }
+ }
+}
+
} // namespace WebCore

Powered by Google App Engine
This is Rietveld 408576698