• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package org.skia.androidkit;
2 
3 public class PathBuilder {
4     private long mNativeInstance;
5 
PathBuilder()6     public PathBuilder() {
7         mNativeInstance = nCreate();
8     }
9 
10     /**
11      * Releases any resources associated with this Path.
12      */
release()13     public void release() {
14         nRelease(mNativeInstance);
15         mNativeInstance = 0;
16     }
17 
moveTo(float x, float y)18     public void moveTo(float x, float y) {
19         nMoveTo(mNativeInstance, x, y);
20     }
21 
lineTo(float x, float y)22     public void lineTo(float x, float y) {
23         nLineTo(mNativeInstance, x, y);
24     }
25 
quadTo(float x1, float y1, float x2, float y2)26     public void quadTo(float x1, float y1, float x2, float y2) {
27         nQuadTo(mNativeInstance, x1, y1, x2, y2);
28     }
conicTo(float x1, float y1, float x2, float y2, float w)29     public void conicTo(float x1, float y1, float x2, float y2, float w) {
30         nConicTo(mNativeInstance, x1, y1, x2, y2, w);
31     }
cubicTo(float x1, float y1, float x2, float y2, float x3, float y3)32     public void cubicTo(float x1, float y1, float x2, float y2, float x3, float y3) {
33         nCubicTo(mNativeInstance, x1, y1, x2, y2, x3, y3);
34     }
35 
close()36     public void close() {
37         nClose(mNativeInstance);
38     }
39 
40     public enum FillType {
41         WINDING           (0),
42         EVEN_ODD          (1),
43         INVERSE_WINDING   (2),
44         INVERSE_EVEN_ODD  (3);
45 
46 
FillType(int nativeInt)47         FillType(int nativeInt) {
48             this.nativeInt = nativeInt;
49         }
50         final int nativeInt;
51     }
setFillType(FillType fillType)52     public void setFillType(FillType fillType) {
53         nSetFillType(mNativeInstance, fillType.nativeInt);
54     }
55 
56     /*
57      * Returns a path from the builder, resets the builder to empty.
58      * Wrapper for SkPath::detach()
59      */
makePath()60     public Path makePath() {
61         return new Path(nMake(mNativeInstance));
62     }
63 
64     // package private
getNativeInstance()65     long getNativeInstance() { return mNativeInstance; }
66 
nCreate()67     private static native long nCreate();
nRelease(long nativeInstance)68     private static native void nRelease(long nativeInstance);
nMoveTo(long mNativeInstance, float x, float y)69     private static native void nMoveTo(long mNativeInstance, float x, float y);
nLineTo(long mNativeInstance, float x, float y)70     private static native void nLineTo(long mNativeInstance, float x, float y);
nQuadTo(long mNativeInstance, float x1, float y1, float x2, float y2)71     private static native void nQuadTo(long mNativeInstance, float x1, float y1, float x2, float y2);
nConicTo(long mNativeInstance, float x1, float y1, float x2, float y2, float w)72     private static native void nConicTo(long mNativeInstance, float x1, float y1, float x2, float y2, float w);
nCubicTo(long mNativeInstance, float x1, float y1, float x2, float y2, float x3, float y3)73     private static native void nCubicTo(long mNativeInstance, float x1, float y1, float x2, float y2, float x3, float y3);
nClose(long mNativeInstance)74     private static native void nClose(long mNativeInstance);
nSetFillType(long mNativeInstance, int fillType)75     private static native void nSetFillType(long mNativeInstance, int fillType);
nMake(long mNativeInstance)76     private static native long nMake(long mNativeInstance);
77 
78 
79 }
80