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

Unified Diff: Source/WebCore/bindings/dart/custom/DartArrayBufferViewCustom.h

Issue 9231022: WebGL support. (Closed) Base URL: svn://svn.chromium.org/multivm/trunk/webkit
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: Source/WebCore/bindings/dart/custom/DartArrayBufferViewCustom.h
diff --git a/Source/WebCore/bindings/dart/custom/DartArrayBufferViewCustom.h b/Source/WebCore/bindings/dart/custom/DartArrayBufferViewCustom.h
new file mode 100644
index 0000000000000000000000000000000000000000..187c77aa14ab44116430c34d02c9efc9b563c1da
--- /dev/null
+++ b/Source/WebCore/bindings/dart/custom/DartArrayBufferViewCustom.h
@@ -0,0 +1,154 @@
+/*
+ * Copyright (C) 2009, 2012 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:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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.
+ */
+
+#ifndef DartArrayBufferViewCustom_h
+#define DartArrayBufferViewCustom_h
+
+#include "DartUtilities.h"
+
+#include <dart_api.h>
+
+namespace WebCore {
+
+namespace DartArrayBufferViewInternal {
+
+template<class ArrayClass, class ElementType>
+void constructWebGLArray(Dart_NativeArguments args)
+{
+ DartApiScope dartApiScope;
+ Dart_Handle exception;
+ {
+ Dart_Handle arg1 = Dart_GetNativeArgument(args, 1);
+ RefPtr<ArrayClass> array;
+ if (Dart_IsNumber(arg1)) {
+ ParameterAdapter<int> length(arg1);
+ if (!length.conversionSuccessful()) {
+ exception = length.exception();
+ goto fail;
+ }
+ array = ArrayClass::create(length);
+ } else {
+ ParameterAdapter<Vector<ElementType> > list(arg1);
+ if (!list.conversionSuccessful()) {
+ exception = list.exception();
+ goto fail;
+ }
+ array = ArrayClass::create(list->data(), list->size());
+ }
+ // FIXME: also process 3 argument constructor.
+ DartDOMWrapper::bindDOMObjectToDartWrapper(array.get(), Dart_GetNativeArgument(args, 0));
+ return;
+ }
+
+fail:
+ Dart_ThrowException(exception);
+ ASSERT_NOT_REACHED();
+}
+
+template <class ArrayClass, class DartArrayClass>
+void setWebGLArrayHelper(Dart_NativeArguments args)
+{
+ DartApiScope dartApiScope;
+ Dart_Handle exception;
+ {
+ ArrayClass* receiver = DartDOMWrapper::receiver<ArrayClass>(args);
+ ParameterAdapter<ArrayClass, DartArrayClass> arrayParam(Dart_GetNativeArgument(args, 1));
+ if (!arrayParam.conversionSuccessful()) {
+ exception = arrayParam.exception();
+ goto fail;
+ }
+ ParameterAdapter<int> offsetParam(Dart_GetNativeArgument(args, 2));
+ if (!offsetParam.conversionSuccessful()) {
+ exception = offsetParam.exception();
+ goto fail;
+ }
+
+ receiver->set(arrayParam, offsetParam);
+ return;
+ }
+
+fail:
+ Dart_ThrowException(exception);
+ ASSERT_NOT_REACHED();
+}
+
+template <class ArrayClass, class ElementType>
+void indexGetter(Dart_NativeArguments args)
+{
+ DartApiScope dartApiScope;
+ Dart_Handle exception;
+ {
+ ArrayClass* receiver = DartDOMWrapper::receiver<ArrayClass>(args);
+ const ParameterAdapter<unsigned int> index(Dart_GetNativeArgument(args, 1));
+ if (!index.conversionSuccessful()) {
+ exception = index.exception();
+ goto fail;
+ }
+
+ DartDOMWrapper::returnValue(args, static_cast<ElementType>(receiver->item(index)));
antonm 2012/01/18 15:12:23 do we need this static_cast, just double checking?
Nikolay 2012/01/19 13:27:34 Yes, we do. On 2012/01/18 15:12:23, antonm wrote:
+ return;
+ }
+
+fail:
+ Dart_ThrowException(exception);
+ ASSERT_NOT_REACHED();
+}
+
+template <class ArrayClass, class ElementType>
+void indexSetter(Dart_NativeArguments args)
+{
+ DartApiScope dartApiScope;
+ Dart_Handle exception;
+ {
+ ArrayClass* receiver = DartDOMWrapper::receiver<ArrayClass>(args);
+ const ParameterAdapter<unsigned int> index(Dart_GetNativeArgument(args, 1));
+ if (!index.conversionSuccessful()) {
+ exception = index.exception();
+ goto fail;
+ }
+ const ParameterAdapter<double> value(Dart_GetNativeArgument(args, 2));
+ if (!value.conversionSuccessful()) {
+ exception = value.exception();
+ goto fail;
+ }
+
+ receiver->set(index, value);
+ return;
+ }
+
+fail:
+ Dart_ThrowException(exception);
+ ASSERT_NOT_REACHED();
+}
+
+}
+
+}
+#endif // DartArrayBufferViewCustom_h

Powered by Google App Engine
This is Rietveld 408576698