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

Side by Side Diff: Source/WebCore/bindings/dart/custom/DartArrayBufferViewCustom.h

Issue 9231022: WebGL support. (Closed) Base URL: svn://svn.chromium.org/multivm/trunk/webkit
Patch Set: Final version. Created 8 years, 11 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) 2009, 2012 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 are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #ifndef DartArrayBufferViewCustom_h
32 #define DartArrayBufferViewCustom_h
33
34 #include "DartUtilities.h"
35
36 #include <dart_api.h>
37
38 namespace WebCore {
39
40 namespace DartArrayBufferViewInternal {
41
42 template<class ArrayClass, class ElementType>
43 void constructWebGLArray(Dart_NativeArguments args)
44 {
45 DartApiScope dartApiScope;
46 Dart_Handle exception;
47 {
48 Dart_Handle arg1 = Dart_GetNativeArgument(args, 1);
49 RefPtr<ArrayClass> array;
50 if (Dart_IsNumber(arg1)) {
51 ParameterAdapter<int> length(arg1);
52 if (!length.conversionSuccessful()) {
53 exception = length.exception();
54 goto fail;
55 }
56 array = ArrayClass::create(length);
57 } else {
58 ParameterAdapter< Vector<ElementType> > list(arg1);
59 if (!list.conversionSuccessful()) {
60 exception = list.exception();
61 goto fail;
62 }
63 array = ArrayClass::create(list->data(), list->size());
64 }
65 // FIXME: also process 3 argument constructor.
66 DartDOMWrapper::bindDOMObjectToDartWrapper(array.get(), Dart_GetNativeAr gument(args, 0));
67 return;
68 }
69
70 fail:
71 Dart_ThrowException(exception);
72 ASSERT_NOT_REACHED();
73 }
74
75 template <class ArrayClass, class DartArrayClass>
76 void setWebGLArrayHelper(Dart_NativeArguments args)
77 {
78 DartApiScope dartApiScope;
79 Dart_Handle exception;
80 {
81 ArrayClass* receiver = DartDOMWrapper::receiver<ArrayClass>(args);
82 ParameterAdapter<ArrayClass, DartArrayClass> arrayParam(Dart_GetNativeAr gument(args, 1));
83 if (!arrayParam.conversionSuccessful()) {
84 exception = arrayParam.exception();
85 goto fail;
86 }
87 ParameterAdapter<int> offsetParam(Dart_GetNativeArgument(args, 2));
88 if (!offsetParam.conversionSuccessful()) {
89 exception = offsetParam.exception();
90 goto fail;
91 }
92
93 receiver->set(arrayParam, offsetParam);
94 return;
95 }
96
97 fail:
98 Dart_ThrowException(exception);
99 ASSERT_NOT_REACHED();
100 }
101
102 template <class ArrayClass, class ElementType>
103 void indexGetter(Dart_NativeArguments args)
104 {
105 DartApiScope dartApiScope;
106 Dart_Handle exception;
107 {
108 ArrayClass* receiver = DartDOMWrapper::receiver<ArrayClass>(args);
109 const ParameterAdapter<unsigned int> index(Dart_GetNativeArgument(args, 1));
110 if (!index.conversionSuccessful()) {
111 exception = index.exception();
112 goto fail;
113 }
114
115 DartDOMWrapper::returnValue(args, static_cast<ElementType>(receiver->ite m(index)));
116 return;
117 }
118
119 fail:
120 Dart_ThrowException(exception);
121 ASSERT_NOT_REACHED();
122 }
123
124 template <class ArrayClass, class ElementType>
125 void indexSetter(Dart_NativeArguments args)
126 {
127 DartApiScope dartApiScope;
128 Dart_Handle exception;
129 {
130 ArrayClass* receiver = DartDOMWrapper::receiver<ArrayClass>(args);
131 const ParameterAdapter<unsigned int> index(Dart_GetNativeArgument(args, 1));
132 if (!index.conversionSuccessful()) {
133 exception = index.exception();
134 goto fail;
135 }
136 const ParameterAdapter<double> value(Dart_GetNativeArgument(args, 2));
137 if (!value.conversionSuccessful()) {
138 exception = value.exception();
139 goto fail;
140 }
141
142 receiver->set(index, value);
143 return;
144 }
145
146 fail:
147 Dart_ThrowException(exception);
148 ASSERT_NOT_REACHED();
149 }
150
151 }
152
153 }
154 #endif // DartArrayBufferViewCustom_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698