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

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 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY GOOGLE, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF 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 WebGLSharedResources::WebGLSharedResources(WebGLRenderingContext* context)
39 : WebGLExtension(context)
40 , m_shareGroup(WebGLShareGroup::create(context->contextGroup()))
41 {
42 }
43
44 WebGLSharedResources::~WebGLSharedResources()
45 {
46 }
47
48 bool WebGLSharedResources::intToAcquireMode(unsigned value, WebGLSharedObject::A cquireMode* mode)
49 {
50 switch (value) {
51 case 0:
52 *mode = WebGLSharedObject::Unacquired;
53 return true;
54 case 1:
55 *mode = WebGLSharedObject::ReadOnly;
56 return true;
57 case 4:
58 *mode = WebGLSharedObject::Exclusive;
59 return true;
60 default:
61 return false;
62 }
63 }
64
65 WebGLExtension::ExtensionName WebGLSharedResources::getName() const
66 {
67 return WebGLSharedResourcesName;
68 }
69
70 void WebGLSharedResources::lose(bool force)
71 {
72 // WebGLSharedResouces is not lost because it would cause too many hard to w ork around race considtions.
73 // It is not actually manipulating GL resources. It is just passing referenc es.
74 if (force)
75 WebGLExtension::lose(true);
76 }
77
78 PassRefPtr<WebGLSharedResources> WebGLSharedResources::create(WebGLRenderingCont ext* context)
79 {
80 return adoptRef(new WebGLSharedResources(context));
81 }
82
83 long WebGLSharedResources::acquireSharedResource(WebGLSharedObject* object, unsi gned desiredMode, PassRefPtr<WebGLAcquireSharedResourceCallback> callback, Excep tionCode& ec)
84 {
85 WebGLSharedObject::AcquireMode mode;
86 if (!intToAcquireMode(desiredMode, &mode)) {
87 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "acquireSh aredResource", "unknown mode");
88 return 0;
89 }
90 return m_context->acquireSharedResource(object, mode, callback, ec);
91 }
92
93 void WebGLSharedResources::releaseSharedResource(WebGLSharedObject* object, Exce ptionCode& ec)
94 {
95 m_context->releaseSharedResource(object, ec);
96 }
97
98 void WebGLSharedResources::cancelAcquireSharedResource(long id)
99 {
100 m_context->cancelAcquireSharedResource(id);
101 }
102
103 bool WebGLSharedResources::supported(WebGLRenderingContext*)
104 {
105 return true;
106 }
107
108 PassRefPtr<WebGLShareGroup> WebGLSharedResources::group() const
109 {
110 return m_shareGroup;
111 }
112
113 const char* WebGLSharedResources::getExtensionName()
114 {
115 return "WEBGL_shared_resources";
116 }
117
118 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/html/canvas/WebGLSharedResources.h ('k') | Source/core/html/canvas/WebGLSharedResources.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698