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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26 #include "config.h"
27
28 #include "core/html/canvas/WebGLSharedResources.h"
29
30 #include "core/html/canvas/WebGLAcquireSharedResourceCallback.h"
31 #include "core/html/canvas/WebGLContextGroup.h"
32 #include "core/html/canvas/WebGLRenderingContext.h"
33 #include "core/html/canvas/WebGLShareGroup.h"
34 #include "core/platform/graphics/Extensions3D.h"
35
36 namespace WebCore {
37
38
39 WebGLSharedResources::WebGLSharedResources(WebGLRenderingContext* context)
40 : WebGLExtension(context)
41 , m_shareGroup(WebGLShareGroup::create(context->contextGroup()))
42 {
43 }
44
45 WebGLSharedResources::~WebGLSharedResources()
46 {
47 }
48
49 WebGLExtension::ExtensionName WebGLSharedResources::getName() const
50 {
51 return WebGLSharedResourcesName;
52 }
53
54 PassRefPtr<WebGLSharedResources> WebGLSharedResources::create(WebGLRenderingCont ext* context)
55 {
56 return adoptRef(new WebGLSharedResources(context));
57 }
58
59 long WebGLSharedResources::acquireSharedResource(WebGLSharedObject* object, unsi gned desiredMode, PassRefPtr<WebGLAcquireSharedResourceCallback> callback, Excep tionCode& ec)
60 {
61 if (isLost()) {
62 return 0;
63 }
64
65 WebGLSharedObject::AcquireMode mode;
66 if (!WebGLSharedObject::IntToAcquireMode(desiredMode, &mode)) {
67 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "acquireSh aredResource", "unknown mode");
68 return 0;
69 }
70 return m_context->acquireSharedResource(object, mode, callback, ec);
71 }
72
73 void WebGLSharedResources::releaseSharedResource(WebGLSharedObject* object, Exce ptionCode& ec)
74 {
75 if (isLost()) {
76 return;
77 }
78
79 m_context->releaseSharedResource(object, ec);
80 }
81
82 void WebGLSharedResources::cancelAcquireSharedResource(long id)
83 {
84 if (isLost()) {
85 return;
86 }
87
88 m_context->cancelAcquireSharedResource(id);
89 }
90
91 bool WebGLSharedResources::supported(WebGLRenderingContext*)
92 {
93 return true;
94 }
95
96 PassRefPtr<WebGLShareGroup> WebGLSharedResources::group() const
97 {
98 if (isLost()) {
99 return 0;
100 }
101
102 return m_shareGroup;
103 }
104
105 const char* WebGLSharedResources::getExtensionName()
106 {
107 return "WEBGL_shared_resources";
108 }
109
110 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698