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

Unified Diff: Source/core/html/canvas/WebGLSharedResources.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/WebGLSharedResources.cpp
diff --git a/Source/core/html/canvas/WebGLSharedResources.cpp b/Source/core/html/canvas/WebGLSharedResources.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..fb1f3307ee117b7318020f0d111e642cbcfcb041
--- /dev/null
+++ b/Source/core/html/canvas/WebGLSharedResources.cpp
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2013 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include "core/html/canvas/WebGLSharedResources.h"
+
+#include "core/html/canvas/WebGLAcquireSharedResourceCallback.h"
+#include "core/html/canvas/WebGLContextGroup.h"
+#include "core/html/canvas/WebGLRenderingContext.h"
+#include "core/html/canvas/WebGLShareGroup.h"
+#include "core/platform/graphics/Extensions3D.h"
+
+namespace WebCore {
+
+
+WebGLSharedResources::WebGLSharedResources(WebGLRenderingContext* context)
+ : WebGLExtension(context)
+ , m_shareGroup(WebGLShareGroup::create(context->contextGroup()))
+{
+}
+
+WebGLSharedResources::~WebGLSharedResources()
+{
+}
+
+WebGLExtension::ExtensionName WebGLSharedResources::getName() const
+{
+ return WebGLSharedResourcesName;
+}
+
+PassRefPtr<WebGLSharedResources> WebGLSharedResources::create(WebGLRenderingContext* context)
+{
+ return adoptRef(new WebGLSharedResources(context));
+}
+
+long WebGLSharedResources::acquireSharedResource(WebGLSharedObject* object, unsigned desiredMode, PassRefPtr<WebGLAcquireSharedResourceCallback> callback, ExceptionCode& ec)
+{
+ if (isLost()) {
+ return 0;
+ }
+
+ WebGLSharedObject::AcquireMode mode;
+ if (!WebGLSharedObject::IntToAcquireMode(desiredMode, &mode)) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "acquireSharedResource", "unknown mode");
+ return 0;
+ }
+ return m_context->acquireSharedResource(object, mode, callback, ec);
+}
+
+void WebGLSharedResources::releaseSharedResource(WebGLSharedObject* object, ExceptionCode& ec)
+{
+ if (isLost()) {
+ return;
+ }
+
+ m_context->releaseSharedResource(object, ec);
+}
+
+void WebGLSharedResources::cancelAcquireSharedResource(long id)
+{
+ if (isLost()) {
+ return;
+ }
+
+ m_context->cancelAcquireSharedResource(id);
+}
+
+bool WebGLSharedResources::supported(WebGLRenderingContext*)
+{
+ return true;
+}
+
+PassRefPtr<WebGLShareGroup> WebGLSharedResources::group() const
+{
+ if (isLost()) {
+ return 0;
+ }
+
+ return m_shareGroup;
+}
+
+const char* WebGLSharedResources::getExtensionName()
+{
+ return "WEBGL_shared_resources";
+}
+
+} // namespace WebCore

Powered by Google App Engine
This is Rietveld 408576698