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

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

Issue 1159663003: Re-land "Add a Color class to dart:sky." (Closed) Base URL: git@github.com:/domokit/mojo.git@master
Patch Set: ink_well 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
« no previous file with comments | « sky/engine/core/painting/CanvasColor.h ('k') | sky/engine/core/painting/Color.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/engine/core/painting/CanvasColor.cpp
diff --git a/sky/engine/core/painting/CanvasColor.cpp b/sky/engine/core/painting/CanvasColor.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9788da811c8b85efcc6dbc684970bfb19fa6deac
--- /dev/null
+++ b/sky/engine/core/painting/CanvasColor.cpp
@@ -0,0 +1,45 @@
+// 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/CanvasColor.h"
+
+#include "sky/engine/core/script/dom_dart_state.h"
+#include "sky/engine/tonic/dart_builtin.h"
+#include "sky/engine/tonic/dart_error.h"
+#include "sky/engine/tonic/dart_value.h"
+
+namespace blink {
+
+// Convert dart_color => SkColor.
+CanvasColor DartConverter<CanvasColor, void>::FromArgumentsWithNullCheck(
+ Dart_NativeArguments args,
+ int index,
+ Dart_Handle& exception) {
+ CanvasColor result;
+
+ Dart_Handle dart_color = Dart_GetNativeArgument(args, index);
+ DCHECK(!LogIfError(dart_color));
+
+ Dart_Handle value =
+ Dart_GetField(dart_color, DOMDartState::Current()->value_handle());
+
+ uint64_t color = 0;
+ Dart_Handle rv = Dart_IntegerToUint64(value, &color);
+ DCHECK(!LogIfError(rv));
+ DCHECK(color <= 0xffffffff);
+
+ result.sk_color = static_cast<SkColor>(color);
+ return result;
+}
+
+void DartConverter<CanvasColor, void>::SetReturnValue(
+ Dart_NativeArguments args, unsigned val) {
+ Dart_Handle color_class = DOMDartState::Current()->color_class();
+ Dart_Handle constructor_args[] = { ToDart(val) };
+ Dart_SetReturnValue(args,
+ Dart_New(color_class, Dart_Null(), 1, constructor_args));
+}
+
+} // namespace blink
« no previous file with comments | « sky/engine/core/painting/CanvasColor.h ('k') | sky/engine/core/painting/Color.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698