Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "sky/engine/config.h" | 5 #include "sky/engine/config.h" |
| 6 #include "sky/engine/core/painting/Rect.h" | 6 #include "sky/engine/core/painting/Rect.h" |
| 7 | 7 |
| 8 #include "sky/engine/tonic/dart_error.h" | 8 #include "sky/engine/tonic/dart_error.h" |
| 9 #include "sky/engine/tonic/dart_state.h" | 9 #include "sky/engine/tonic/dart_state.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 // Convert dart_rect._value[0...3] ==> SkRect. | 14 // Convert dartRect._value[0...3] ==> SkRect. |
| 15 Rect DartConverter<Rect, void>::FromArgumentsWithNullCheck( | 15 Rect DartConverter<Rect, void>::FromArgumentsWithNullCheck( |
| 16 Dart_NativeArguments args, | 16 Dart_NativeArguments args, |
| 17 int index, | 17 int index, |
| 18 Dart_Handle& exception) { | 18 Dart_Handle& exception) { |
| 19 Rect result; | 19 Rect result; |
| 20 result.is_null = true; | 20 result.isNull = true; |
| 21 | 21 |
| 22 Dart_Handle dart_rect = Dart_GetNativeArgument(args, index); | 22 Dart_Handle dartRect = Dart_GetNativeArgument(args, index); |
| 23 DCHECK(!LogIfError(dart_rect)); | 23 DCHECK(!LogIfError(dartRect)); |
| 24 | 24 |
| 25 Dart_Handle value = Dart_GetField(dart_rect, | 25 Dart_Handle value = Dart_GetField(dartRect, |
| 26 Dart_NewStringFromCString("_value")); | 26 Dart_NewStringFromCString("_value")); |
|
abarth-chromium
2015/05/27 02:17:36
Same caching point here. We should cache in https
| |
| 27 if (Dart_IsNull(value)) | 27 if (Dart_IsNull(value)) |
| 28 return result; | 28 return result; |
| 29 | 29 |
| 30 Dart_TypedData_Type type; | 30 Dart_TypedData_Type type; |
| 31 float* data = nullptr; | 31 float* data = nullptr; |
| 32 intptr_t num_elements = 0; | 32 intptr_t numElements = 0; |
| 33 Dart_TypedDataAcquireData( | 33 Dart_TypedDataAcquireData( |
| 34 value, &type, reinterpret_cast<void**>(&data), &num_elements); | 34 value, &type, reinterpret_cast<void**>(&data), &numElements); |
| 35 DCHECK(!LogIfError(value)); | 35 DCHECK(!LogIfError(value)); |
| 36 ASSERT(type == Dart_TypedData_kFloat32 && num_elements == 4); | 36 ASSERT(type == Dart_TypedData_kFloat32 && numElements == 4); |
| 37 | 37 |
| 38 SkScalar* dest[] = { | 38 SkScalar* dest[] = { |
| 39 &result.sk_rect.fLeft, | 39 &result.skRect.fLeft, |
| 40 &result.sk_rect.fTop, | 40 &result.skRect.fTop, |
| 41 &result.sk_rect.fRight, | 41 &result.skRect.fRight, |
| 42 &result.sk_rect.fBottom | 42 &result.skRect.fBottom |
| 43 }; | 43 }; |
| 44 for (intptr_t i = 0; i < 4; ++i) | 44 for (intptr_t i = 0; i < 4; ++i) |
| 45 *dest[i] = data[i]; | 45 *dest[i] = data[i]; |
| 46 | 46 |
| 47 Dart_TypedDataReleaseData(value); | 47 Dart_TypedDataReleaseData(value); |
| 48 | 48 |
| 49 result.is_null = false; | 49 result.isNull = false; |
| 50 return result; | 50 return result; |
| 51 } | 51 } |
| 52 | 52 |
| 53 } // namespace blink | 53 } // namespace blink |
| OLD | NEW |