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

Unified Diff: sky/engine/core/painting/Point.cpp

Issue 1158843002: Sky: Add a Point class. (Closed) Base URL: git@github.com:/domokit/mojo.git@master
Patch Set: Created 5 years, 7 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/core/painting/Point.cpp
diff --git a/sky/engine/core/painting/Point.cpp b/sky/engine/core/painting/Point.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6cce76a98c1b051d273ba893831489ba1e4ea6d3
--- /dev/null
+++ b/sky/engine/core/painting/Point.cpp
@@ -0,0 +1,37 @@
+// 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/core/painting/Point.h"
+
+#include "sky/engine/tonic/dart_error.h"
+#include "sky/engine/tonic/dart_state.h"
+#include "base/logging.h"
+
+namespace blink {
+
+// Convert dartPoint.x,y ==> SkPoint.
+Point DartConverter<Point, void>::FromArgumentsWithNullCheck(
+ Dart_NativeArguments args,
+ int index,
+ Dart_Handle& exception) {
+ Point result;
+ result.isNull = true;
+
+ Dart_Handle dartPoint = Dart_GetNativeArgument(args, index);
+ DCHECK(!LogIfError(dartPoint));
+
+ Dart_Handle xValue = Dart_GetField(dartPoint, Dart_NewStringFromCString("x"));
+ Dart_Handle yValue = Dart_GetField(dartPoint, Dart_NewStringFromCString("y"));
abarth-chromium 2015/05/27 02:17:36 We should cache the "x" and "y" strings so that we
Matt Perry 2015/05/27 17:55:43 OK. Not sure what you mean by Symbols. Do we have
+
+ double x = 0.0, y = 0.0;
+ Dart_DoubleValue(xValue, &x);
+ Dart_Handle err = Dart_DoubleValue(xValue, &y);
abarth-chromium 2015/05/27 02:17:36 Why do we capture an error for y and not for x?
Matt Perry 2015/05/27 17:55:43 I was thinking the error would propagate to the la
+ DCHECK(!LogIfError(err));
+ result.skPoint.set(x, y);
+ result.isNull = false;
+ return result;
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698