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

Unified Diff: sky/engine/tonic/dart_float32list.cc

Issue 1155193004: Canvas.concat takes a 16-element Float32List instead of an array. (Closed) Base URL: git@github.com:/domokit/mojo.git@master
Patch Set: abarth Created 5 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: sky/engine/tonic/dart_float32list.cc
diff --git a/sky/engine/tonic/dart_float32list.cc b/sky/engine/tonic/dart_float32list.cc
new file mode 100644
index 0000000000000000000000000000000000000000..48d02951d7d4a6e7124dbe5c03e6cc505e3fb207
--- /dev/null
+++ b/sky/engine/tonic/dart_float32list.cc
@@ -0,0 +1,46 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "sky/engine/config.h"
+#include "sky/engine/tonic/dart_error.h"
+#include "sky/engine/tonic/dart_float32list.h"
+
+namespace blink {
+
+Float32List::Float32List(Dart_Handle list)
+ : data_(nullptr), num_elements_(0), dart_handle_(list) {
+ if (Dart_IsNull(list))
+ return;
+
+ Dart_TypedData_Type type;
+ Dart_TypedDataAcquireData(
+ list, &type, reinterpret_cast<void**>(&data_), &num_elements_);
+ DCHECK(!LogIfError(list));
+ ASSERT(type == Dart_TypedData_kFloat32);
+}
+
+Float32List::Float32List(Float32List&& other)
+ : data_(other.data_),
+ num_elements_(other.num_elements_),
+ dart_handle_(other.dart_handle_) {
+ other.data_ = nullptr;
abarth-chromium 2015/06/04 17:29:28 I'd null out the other dart_handle_ too for parano
Matt Perry 2015/06/04 17:34:35 Done.
+}
+
+Float32List::~Float32List() {
+ if (data_)
+ Dart_TypedDataReleaseData(dart_handle_);
+}
+
+Float32List DartConverter<Float32List>::FromArgumentsWithNullCheck(
+ Dart_NativeArguments args,
+ int index,
+ Dart_Handle& exception) {
+ Dart_Handle list = Dart_GetNativeArgument(args, index);
+ DCHECK(!LogIfError(list));
+
+ Float32List result(list);
+ return std::move(result);
abarth-chromium 2015/06/04 17:29:28 return Float32List(list); No need for std::move.
Matt Perry 2015/06/04 17:34:35 Done.
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698