Merge from google/chrome/m55
[platform/upstream/libSkiaSharp.git] / src / c / sk_patheffect.cpp
1 /*
2  * Copyright 2016 Xamarin Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7
8 #include "SkPathEffect.h"
9 #include "SkDiscretePathEffect.h"
10 #include "SkCornerPathEffect.h"
11 #include "Sk1DPathEffect.h"
12 #include "Sk2DPathEffect.h"
13 #include "SkDashPathEffect.h"
14 #include "SkPath.h"
15
16 #include "sk_patheffect.h"
17
18 #include "sk_types_priv.h"
19
20 void sk_path_effect_unref(sk_path_effect_t* effect)
21 {
22     SkSafeUnref(AsPathEffect(effect));
23
24
25 sk_path_effect_t* sk_path_effect_create_compose(sk_path_effect_t* outer, sk_path_effect_t* inner)
26 {
27     return ToPathEffect(SkComposePathEffect::Make(sk_ref_sp(AsPathEffect(outer)), sk_ref_sp(AsPathEffect(inner))).release());
28 }
29
30 sk_path_effect_t* sk_path_effect_create_sum(sk_path_effect_t* first, sk_path_effect_t* second)
31 {
32     return ToPathEffect(SkSumPathEffect::Make(sk_ref_sp(AsPathEffect(first)), sk_ref_sp(AsPathEffect(second))).release());
33 }
34
35 sk_path_effect_t* sk_path_effect_create_discrete(float segLength, float deviation, uint32_t seedAssist /*0*/)
36 {
37     return ToPathEffect(SkDiscretePathEffect::Make(segLength, deviation, seedAssist).release());
38 }
39
40 sk_path_effect_t* sk_path_effect_create_corner(float radius)
41 {
42     return ToPathEffect(SkCornerPathEffect::Make(radius).release());
43 }
44
45 sk_path_effect_t* sk_path_effect_create_1d_path(const sk_path_t* path, float advance, float phase, sk_path_effect_1d_style_t style)
46 {
47     return ToPathEffect(SkPath1DPathEffect::Make(AsPath(*path), advance, phase, (SkPath1DPathEffect::Style)style).release());
48 }
49
50 sk_path_effect_t* sk_path_effect_create_2d_line(float width, const sk_matrix_t* cmatrix)
51 {
52     SkMatrix matrix;
53     if (cmatrix) {
54         from_c(cmatrix, &matrix);
55     }
56     return ToPathEffect(SkLine2DPathEffect::Make(width, matrix).release());
57 }
58
59 sk_path_effect_t* sk_path_effect_create_2d_path(const sk_matrix_t* cmatrix, const sk_path_t* path)
60 {
61     SkMatrix matrix;
62     if (cmatrix) {
63         from_c(cmatrix, &matrix);
64     }
65     return ToPathEffect(SkPath2DPathEffect::Make(matrix, AsPath(*path)).release());
66 }
67
68 sk_path_effect_t* sk_path_effect_create_dash(const float intervals[], int count, float phase)
69 {
70     return ToPathEffect(SkDashPathEffect::Make(intervals, count, phase).release());
71 }