Flutter Engine
rrect.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter 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 "flutter/lib/ui/painting/rrect.h"
6 
7 #include "flutter/fml/logging.h"
10 
11 using flutter::RRect;
12 
13 namespace tonic {
14 
15 // Construct an SkRRect from a Dart RRect object.
16 // The Dart RRect is a Float32List containing
17 // [left, top, right, bottom, xRadius, yRadius]
19  Float32List buffer(value);
20 
21  RRect result;
22  result.is_null = true;
23  if (buffer.data() == nullptr) {
24  return result;
25  }
26 
27  SkVector radii[4] = {{buffer[4], buffer[5]},
28  {buffer[6], buffer[7]},
29  {buffer[8], buffer[9]},
30  {buffer[10], buffer[11]}};
31 
32  result.sk_rrect.setRectRadii(
33  SkRect::MakeLTRB(buffer[0], buffer[1], buffer[2], buffer[3]), radii);
34 
35  result.is_null = false;
36  return result;
37 }
38 
40  int index,
41  Dart_Handle& exception) {
42  Dart_Handle value = Dart_GetNativeArgument(args, index);
43  FML_DCHECK(!LogIfError(value));
44  return FromDart(value);
45 }
46 
47 } // namespace tonic
G_BEGIN_DECLS FlValue * args
SkRRect sk_rrect
Definition: rrect.h:16
#define FML_DCHECK(condition)
Definition: logging.h:86
bool is_null
Definition: rrect.h:17
uint8_t value
bool LogIfError(Dart_Handle handle)
Definition: dart_error.cc:15