Flutter Engine
 
Loading...
Searching...
No Matches
path_ops.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 "path_ops.h"
6
7namespace flutter {
8SkPath* CreatePath(SkPathFillType fill_type) {
9 auto* path = new SkPath();
10 path->setFillType(fill_type);
11 return path;
12}
13
14void DestroyPath(SkPath* path) {
15 delete path;
16}
17
18void MoveTo(SkPath* path, SkScalar x, SkScalar y) {
19 path->moveTo(x, y);
20}
21
22void LineTo(SkPath* path, SkScalar x, SkScalar y) {
23 path->lineTo(x, y);
24}
25
26void CubicTo(SkPath* path,
27 SkScalar x1,
28 SkScalar y1,
29 SkScalar x2,
30 SkScalar y2,
31 SkScalar x3,
32 SkScalar y3) {
33 path->cubicTo(x1, y1, x2, y2, x3, y3);
34}
35
36void Close(SkPath* path) {
37 path->close();
38}
39
40void Reset(SkPath* path) {
41 path->reset();
42}
43
44void Op(SkPath* one, SkPath* two, SkPathOp op) {
45 Op(*one, *two, op, one);
46}
47
48int GetFillType(SkPath* path) {
49 return static_cast<int>(path->getFillType());
50}
51
52struct PathData* Data(SkPath* path) {
53 int point_count = path->countPoints();
54 int verb_count = path->countVerbs();
55
56 auto data = new PathData();
57 data->points = new float[point_count * 2];
58 data->point_count = point_count * 2;
59 data->verbs = new uint8_t[verb_count];
60 data->verb_count = verb_count;
61
62 SkSpan<uint8_t> outVerbs(data->verbs, verb_count);
63 path->getVerbs(outVerbs);
64 SkSpan<SkPoint> outPoints(reinterpret_cast<SkPoint*>(data->points),
65 point_count);
66 path->getPoints(outPoints);
67 return data;
68}
69
71 delete[] data->points;
72 delete[] data->verbs;
73 delete data;
74}
75
76} // namespace flutter
int32_t x
double y
void Op(SkPath *one, SkPath *two, SkPathOp op)
Definition path_ops.cc:44
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition switch_defs.h:52
void DestroyData(PathData *data)
Definition path_ops.cc:70
void DestroyPath(SkPath *path)
Definition path_ops.cc:14
int GetFillType(SkPath *path)
Definition path_ops.cc:48
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switch_defs.h:36
SkPath * CreatePath(SkPathFillType fill_type)
Definition path_ops.cc:8
void Reset(SkPath *path)
Definition path_ops.cc:40
void MoveTo(PathBuilder *builder, Scalar x, Scalar y)
void LineTo(PathBuilder *builder, Scalar x, Scalar y)
void CubicTo(PathBuilder *builder, Scalar x1, Scalar y1, Scalar x2, Scalar y2, Scalar x3, Scalar y3)
void Close(PathBuilder *builder)
Definition data.h:17