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

Side by Side Diff: sky/engine/core/painting/Rect.cpp

Issue 1151673002: Sky: different tack for custom Rect type in the Canvas API. (Closed) Base URL: git@github.com:/domokit/mojo.git@master
Patch Set: Float32List 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 unified diff | Download patch
« no previous file with comments | « sky/engine/core/painting/Rect.h ('k') | sky/engine/core/painting/Rect.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "sky/engine/config.h"
6 #include "sky/engine/core/painting/Rect.h"
7
8 #include "sky/engine/tonic/dart_error.h"
9 #include "sky/engine/tonic/dart_state.h"
10 #include "base/logging.h"
11
12 namespace blink {
13
14 // Convert dart_rect._value[0...3] ==> SkRect.
15 Rect DartConverter<Rect, void>::FromArgumentsWithNullCheck(
16 Dart_NativeArguments args,
17 int index,
18 Dart_Handle& exception) {
19 Rect result;
20 result.is_null = true;
21
22 Dart_Handle dart_rect = Dart_GetNativeArgument(args, index);
23 DCHECK(!LogIfError(dart_rect));
24
25 Dart_Handle value = Dart_GetField(dart_rect,
26 Dart_NewStringFromCString("_value"));
27 if (Dart_IsNull(value))
28 return result;
29
30 Dart_TypedData_Type type;
31 float* data = nullptr;
32 intptr_t num_elements = 0;
33 Dart_TypedDataAcquireData(
34 value, &type, reinterpret_cast<void**>(&data), &num_elements);
35 DCHECK(!LogIfError(value));
36 ASSERT(type == Dart_TypedData_kFloat32 && num_elements == 4);
37
38 SkScalar* dest[] = {
39 &result.sk_rect.fLeft,
40 &result.sk_rect.fTop,
41 &result.sk_rect.fRight,
42 &result.sk_rect.fBottom
43 };
44 for (intptr_t i = 0; i < 4; ++i)
45 *dest[i] = data[i];
46
47 Dart_TypedDataReleaseData(value);
48
49 result.is_null = false;
50 return result;
51 }
52
53 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/painting/Rect.h ('k') | sky/engine/core/painting/Rect.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698