19066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project/*
29066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Copyright (C) 2006 The Android Open Source Project
39066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
49066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License");
59066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * you may not use this file except in compliance with the License.
69066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * You may obtain a copy of the License at
79066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
89066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *      http://www.apache.org/licenses/LICENSE-2.0
99066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Unless required by applicable law or agreed to in writing, software
119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS,
129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * See the License for the specific language governing permissions and
149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * limitations under the License.
159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */
169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectpackage android.graphics;
189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
19ecbcdd384c07402204064243981a432f5b0aad36sergeyvimport android.annotation.NonNull;
20ecbcdd384c07402204064243981a432f5b0aad36sergeyvimport android.annotation.Nullable;
21ecbcdd384c07402204064243981a432f5b0aad36sergeyv
229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project/**
239066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * The Path class encapsulates compound (multiple contour) geometric paths
249066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * consisting of straight line segments, quadratic curves, and cubic curves.
259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * It can be drawn with canvas.drawPath(path, paint), either filled or stroked
269066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * (based on the paint's Style), or it can be used for clipping or to draw
279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * text on a path.
289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */
299066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectpublic class Path {
3061c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy    /**
3161c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy     * @hide
3261c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy     */
33ffa84e008c712ceffa09d6b89a49882c88b3cca5Hans Boehm    public long mNativePath;
349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
36a48a1a87ba17f20f7006eaab21dcedf86c015c13Romain Guy     * @hide
37a48a1a87ba17f20f7006eaab21dcedf86c015c13Romain Guy     */
38a48a1a87ba17f20f7006eaab21dcedf86c015c13Romain Guy    public boolean isSimplePath = true;
39a48a1a87ba17f20f7006eaab21dcedf86c015c13Romain Guy    /**
40a48a1a87ba17f20f7006eaab21dcedf86c015c13Romain Guy     * @hide
41a48a1a87ba17f20f7006eaab21dcedf86c015c13Romain Guy     */
42a48a1a87ba17f20f7006eaab21dcedf86c015c13Romain Guy    public Region rects;
43d4b5795e5efd05be7e482e013dfdec519ad2601eRomain Guy    private Direction mLastDirection = null;
44a48a1a87ba17f20f7006eaab21dcedf86c015c13Romain Guy
45a48a1a87ba17f20f7006eaab21dcedf86c015c13Romain Guy    /**
469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Create an empty path
479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public Path() {
499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        mNativePath = init1();
509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
519066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
539066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Create a new path, copying the contents from the src path.
549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param src The path to copy from when initializing the new path
569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public Path(Path src) {
5836bef0bf30d6bae48cf3837df351075ca4fce654Ashok Bhat        long valNative = 0;
599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        if (src != null) {
609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            valNative = src.mNativePath;
61fa0853e0b92617128531188edd6a749a72b86432Chris Craik            isSimplePath = src.isSimplePath;
62fa0853e0b92617128531188edd6a749a72b86432Chris Craik            if (src.rects != null) {
63fa0853e0b92617128531188edd6a749a72b86432Chris Craik                rects = new Region(src.rects);
64fa0853e0b92617128531188edd6a749a72b86432Chris Craik            }
659066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
669066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        mNativePath = init2(valNative);
679066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
6824609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese
699066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
709066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Clear any lines and curves from the path, making it empty.
719066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * This does NOT change the fill-type setting.
729066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
739066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void reset() {
74a48a1a87ba17f20f7006eaab21dcedf86c015c13Romain Guy        isSimplePath = true;
7502a2aab57c71f1058348cec0fc3a6aaa07250bc9John Reck        mLastDirection = null;
7602a2aab57c71f1058348cec0fc3a6aaa07250bc9John Reck        if (rects != null) rects.setEmpty();
77d0f379c1976c600313f1f4c39f2587a649e3a4fcMike Klein        // We promised not to change this, so preserve it around the native
78d0f379c1976c600313f1f4c39f2587a649e3a4fcMike Klein        // call, which does now reset fill type.
79d0f379c1976c600313f1f4c39f2587a649e3a4fcMike Klein        final FillType fillType = getFillType();
809066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        native_reset(mNativePath);
81d0f379c1976c600313f1f4c39f2587a649e3a4fcMike Klein        setFillType(fillType);
829066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
839066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
849066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
859066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Rewinds the path: clears any lines and curves from the path but
869066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * keeps the internal data structure for faster reuse.
879066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
889066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void rewind() {
89a48a1a87ba17f20f7006eaab21dcedf86c015c13Romain Guy        isSimplePath = true;
9002a2aab57c71f1058348cec0fc3a6aaa07250bc9John Reck        mLastDirection = null;
9102a2aab57c71f1058348cec0fc3a6aaa07250bc9John Reck        if (rects != null) rects.setEmpty();
929066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        native_rewind(mNativePath);
939066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
949066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
959066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /** Replace the contents of this with the contents of src.
969066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    */
97ecbcdd384c07402204064243981a432f5b0aad36sergeyv    public void set(@NonNull Path src) {
98ecbcdd384c07402204064243981a432f5b0aad36sergeyv        if (this == src) {
99ecbcdd384c07402204064243981a432f5b0aad36sergeyv            return;
100ecbcdd384c07402204064243981a432f5b0aad36sergeyv        }
101ecbcdd384c07402204064243981a432f5b0aad36sergeyv        isSimplePath = src.isSimplePath;
102ecbcdd384c07402204064243981a432f5b0aad36sergeyv        native_set(mNativePath, src.mNativePath);
103ecbcdd384c07402204064243981a432f5b0aad36sergeyv        if (!isSimplePath) {
104ecbcdd384c07402204064243981a432f5b0aad36sergeyv            return;
105ecbcdd384c07402204064243981a432f5b0aad36sergeyv        }
106ecbcdd384c07402204064243981a432f5b0aad36sergeyv
107ecbcdd384c07402204064243981a432f5b0aad36sergeyv        if (rects != null && src.rects != null) {
108ecbcdd384c07402204064243981a432f5b0aad36sergeyv            rects.set(src.rects);
109ecbcdd384c07402204064243981a432f5b0aad36sergeyv        } else if (rects != null && src.rects == null) {
110ecbcdd384c07402204064243981a432f5b0aad36sergeyv            rects.setEmpty();
111ecbcdd384c07402204064243981a432f5b0aad36sergeyv        } else if (src.rects != null) {
112ecbcdd384c07402204064243981a432f5b0aad36sergeyv            rects = new Region(src.rects);
1139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
1149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
1159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
1168018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy    /**
1178018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy     * The logical operations that can be performed when combining two paths.
1188018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy     *
1198018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy     * @see #op(Path, android.graphics.Path.Op)
1208018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy     * @see #op(Path, Path, android.graphics.Path.Op)
1218018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy     */
1228018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy    public enum Op {
1238018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy        /**
1248018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy         * Subtract the second path from the first path.
1258018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy         */
1268018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy        DIFFERENCE,
1278018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy        /**
1288018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy         * Intersect the two paths.
1298018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy         */
1308018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy        INTERSECT,
1318018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy        /**
1328018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy         * Union (inclusive-or) the two paths.
1338018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy         */
1348018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy        UNION,
1358018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy        /**
1368018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy         * Exclusive-or the two paths.
1378018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy         */
1388018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy        XOR,
1398018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy        /**
1408018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy         * Subtract the first path from the second path.
1418018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy         */
1428018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy        REVERSE_DIFFERENCE
1438018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy    }
1448018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy
1458018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy    /**
1468018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy     * Set this path to the result of applying the Op to this path and the specified path.
1478018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy     * The resulting path will be constructed from non-overlapping contours.
1488018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy     * The curve order is reduced where possible so that cubics may be turned
1498018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy     * into quadratics, and quadratics maybe turned into lines.
1508018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy     *
1518018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy     * @param path The second operand (for difference, the subtrahend)
1528018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy     *
1538018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy     * @return True if operation succeeded, false otherwise and this path remains unmodified.
1548018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy     *
1558018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy     * @see Op
1568018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy     * @see #op(Path, Path, android.graphics.Path.Op)
1578018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy     */
1588018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy    public boolean op(Path path, Op op) {
1598018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy        return op(this, path, op);
1608018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy    }
1618018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy
1628018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy    /**
1638018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy     * Set this path to the result of applying the Op to the two specified paths.
1648018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy     * The resulting path will be constructed from non-overlapping contours.
1658018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy     * The curve order is reduced where possible so that cubics may be turned
1668018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy     * into quadratics, and quadratics maybe turned into lines.
1678018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy     *
1688018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy     * @param path1 The first operand (for difference, the minuend)
1698018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy     * @param path2 The second operand (for difference, the subtrahend)
1708018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy     *
1718018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy     * @return True if operation succeeded, false otherwise and this path remains unmodified.
1728018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy     *
1738018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy     * @see Op
1748018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy     * @see #op(Path, android.graphics.Path.Op)
1758018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy     */
1768018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy    public boolean op(Path path1, Path path2, Op op) {
1778018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy        if (native_op(path1.mNativePath, path2.mNativePath, op.ordinal(), this.mNativePath)) {
1788018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy            isSimplePath = false;
1798018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy            rects = null;
1808018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy            return true;
1818018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy        }
1828018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy        return false;
1838018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy    }
1848018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy
1858018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy    /**
1865be83edd15e11420287cc0af93a95d5a6dfae68fChris Craik     * Returns the path's convexity, as defined by the content of the path.
1875be83edd15e11420287cc0af93a95d5a6dfae68fChris Craik     * <p>
1885be83edd15e11420287cc0af93a95d5a6dfae68fChris Craik     * A path is convex if it has a single contour, and only ever curves in a
1895be83edd15e11420287cc0af93a95d5a6dfae68fChris Craik     * single direction.
1905be83edd15e11420287cc0af93a95d5a6dfae68fChris Craik     * <p>
1915be83edd15e11420287cc0af93a95d5a6dfae68fChris Craik     * This function will calculate the convexity of the path from its control
1925be83edd15e11420287cc0af93a95d5a6dfae68fChris Craik     * points, and cache the result.
1935be83edd15e11420287cc0af93a95d5a6dfae68fChris Craik     *
1945be83edd15e11420287cc0af93a95d5a6dfae68fChris Craik     * @return True if the path is convex.
1955be83edd15e11420287cc0af93a95d5a6dfae68fChris Craik     */
1965be83edd15e11420287cc0af93a95d5a6dfae68fChris Craik    public boolean isConvex() {
1975be83edd15e11420287cc0af93a95d5a6dfae68fChris Craik        return native_isConvex(mNativePath);
1985be83edd15e11420287cc0af93a95d5a6dfae68fChris Craik    }
1995be83edd15e11420287cc0af93a95d5a6dfae68fChris Craik
2005be83edd15e11420287cc0af93a95d5a6dfae68fChris Craik    /**
2018018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy     * Enum for the ways a path may be filled.
2028018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy     */
2039066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public enum FillType {
2049066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        // these must match the values in SkPath.h
2058018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy        /**
2068018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy         * Specifies that "inside" is computed by a non-zero sum of signed
2078018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy         * edge crossings.
2088018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy         */
2099066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        WINDING         (0),
2108018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy        /**
2118018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy         * Specifies that "inside" is computed by an odd number of edge
2128018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy         * crossings.
2138018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy         */
2149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        EVEN_ODD        (1),
2158018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy        /**
2168018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy         * Same as {@link #WINDING}, but draws outside of the path, rather than inside.
2178018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy         */
2189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        INVERSE_WINDING (2),
2198018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy        /**
2208018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy         * Same as {@link #EVEN_ODD}, but draws outside of the path, rather than inside.
2218018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy         */
2229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        INVERSE_EVEN_ODD(3);
22324609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese
2249066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        FillType(int ni) {
2259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            nativeInt = ni;
2269066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
2278018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy
2289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        final int nativeInt;
2299066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
2308018c8db8221aa604b3c083e09d173cc27e53d83Romain Guy
2319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    // these must be in the same order as their native values
2327f9f99ea11051614a7727dfb9f9578b518e76e3cXavier Ducrohet    static final FillType[] sFillTypeArray = {
2339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        FillType.WINDING,
2349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        FillType.EVEN_ODD,
2359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        FillType.INVERSE_WINDING,
2369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        FillType.INVERSE_EVEN_ODD
2379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    };
2389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
2399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
2409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Return the path's fill type. This defines how "inside" is
2419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * computed. The default value is WINDING.
2429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
2439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @return the path's fill type
2449066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
2459066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public FillType getFillType() {
2469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        return sFillTypeArray[native_getFillType(mNativePath)];
2479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
2489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
2499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
2509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Set the path's fill type. This defines how "inside" is computed.
2519066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
2529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param ft The new fill type for this path
2539066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
2549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void setFillType(FillType ft) {
2559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        native_setFillType(mNativePath, ft.nativeInt);
2569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
2575be83edd15e11420287cc0af93a95d5a6dfae68fChris Craik
2589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
2599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Returns true if the filltype is one of the INVERSE variants
2609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
2619066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @return true if the filltype is one of the INVERSE variants
2629066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
2639066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public boolean isInverseFillType() {
2649066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        final int ft = native_getFillType(mNativePath);
2655be83edd15e11420287cc0af93a95d5a6dfae68fChris Craik        return (ft & FillType.INVERSE_WINDING.nativeInt) != 0;
2669066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
2675be83edd15e11420287cc0af93a95d5a6dfae68fChris Craik
2689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
2699066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Toggles the INVERSE state of the filltype
2709066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
2719066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void toggleInverseFillType() {
2729066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        int ft = native_getFillType(mNativePath);
2735be83edd15e11420287cc0af93a95d5a6dfae68fChris Craik        ft ^= FillType.INVERSE_WINDING.nativeInt;
2749066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        native_setFillType(mNativePath, ft);
2759066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
2765be83edd15e11420287cc0af93a95d5a6dfae68fChris Craik
2779066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
2789066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Returns true if the path is empty (contains no lines or curves)
2799066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
2809066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @return true if the path is empty (contains no lines or curves)
2819066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
2829066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public boolean isEmpty() {
2839066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        return native_isEmpty(mNativePath);
2849066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
2859066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
2869066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
2879066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Returns true if the path specifies a rectangle. If so, and if rect is
2889066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * not null, set rect to the bounds of the path. If the path does not
2899066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * specify a rectangle, return false and ignore rect.
2909066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
2919066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param rect If not null, returns the bounds of the path if it specifies
2929066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *             a rectangle
2939066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @return     true if the path specifies a rectangle
2949066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
2959066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public boolean isRect(RectF rect) {
2969066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        return native_isRect(mNativePath, rect);
2979066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
2989066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
2999066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
30054900e8c05e92a0783e8468ad7c4513eb66adc80Mike Reed     * Compute the bounds of the control points of the path, and write the
30154900e8c05e92a0783e8468ad7c4513eb66adc80Mike Reed     * answer into bounds. If the path contains 0 or 1 points, the bounds is
30254900e8c05e92a0783e8468ad7c4513eb66adc80Mike Reed     * set to (0,0,0,0)
3039066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
30454900e8c05e92a0783e8468ad7c4513eb66adc80Mike Reed     * @param bounds Returns the computed bounds of the path's control points.
30554900e8c05e92a0783e8468ad7c4513eb66adc80Mike Reed     * @param exact This parameter is no longer used.
3069066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
307a48a1a87ba17f20f7006eaab21dcedf86c015c13Romain Guy    @SuppressWarnings({"UnusedDeclaration"})
3089066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void computeBounds(RectF bounds, boolean exact) {
30954900e8c05e92a0783e8468ad7c4513eb66adc80Mike Reed        native_computeBounds(mNativePath, bounds);
3109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
3119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
3129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
3139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Hint to the path to prepare for adding more points. This can allow the
3149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * path to more efficiently allocate its storage.
3159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
3169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param extraPtCount The number of extra points that may be added to this
3179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *                     path
3189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
3199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void incReserve(int extraPtCount) {
3209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        native_incReserve(mNativePath, extraPtCount);
3219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
3229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
3239066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
3249066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Set the beginning of the next contour to the point (x,y).
3259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
3269066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param x The x-coordinate of the start of a new contour
3279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param y The y-coordinate of the start of a new contour
3289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
3299066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void moveTo(float x, float y) {
3309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        native_moveTo(mNativePath, x, y);
3319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
3329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
3339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
3349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Set the beginning of the next contour relative to the last point on the
3359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * previous contour. If there is no previous contour, this is treated the
3369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * same as moveTo().
3379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
3389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param dx The amount to add to the x-coordinate of the end of the
3399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *           previous contour, to specify the start of a new contour
3409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param dy The amount to add to the y-coordinate of the end of the
3419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *           previous contour, to specify the start of a new contour
3429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
3439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void rMoveTo(float dx, float dy) {
3449066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        native_rMoveTo(mNativePath, dx, dy);
3459066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
3469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
3479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
3489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Add a line from the last point to the specified point (x,y).
3499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * If no moveTo() call has been made for this contour, the first point is
3509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * automatically set to (0,0).
3519066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
3529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param x The x-coordinate of the end of a line
3539066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param y The y-coordinate of the end of a line
3549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
3559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void lineTo(float x, float y) {
356d79991277043d6bdbd90bb63fd8aff73ef9e06a5Romain Guy        isSimplePath = false;
3579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        native_lineTo(mNativePath, x, y);
3589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
3599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
3609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
3619066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Same as lineTo, but the coordinates are considered relative to the last
3629066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * point on this contour. If there is no previous point, then a moveTo(0,0)
3639066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * is inserted automatically.
3649066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
3659066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param dx The amount to add to the x-coordinate of the previous point on
3669066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *           this contour, to specify a line
3679066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param dy The amount to add to the y-coordinate of the previous point on
3689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *           this contour, to specify a line
3699066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
3709066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void rLineTo(float dx, float dy) {
371d79991277043d6bdbd90bb63fd8aff73ef9e06a5Romain Guy        isSimplePath = false;
3729066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        native_rLineTo(mNativePath, dx, dy);
3739066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
3749066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
3759066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
3769066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Add a quadratic bezier from the last point, approaching control point
3779066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * (x1,y1), and ending at (x2,y2). If no moveTo() call has been made for
3789066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * this contour, the first point is automatically set to (0,0).
3799066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
3809066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param x1 The x-coordinate of the control point on a quadratic curve
3819066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param y1 The y-coordinate of the control point on a quadratic curve
3829066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param x2 The x-coordinate of the end point on a quadratic curve
3839066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param y2 The y-coordinate of the end point on a quadratic curve
3849066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
3859066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void quadTo(float x1, float y1, float x2, float y2) {
386a48a1a87ba17f20f7006eaab21dcedf86c015c13Romain Guy        isSimplePath = false;
3879066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        native_quadTo(mNativePath, x1, y1, x2, y2);
3889066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
3899066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
3909066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
3919066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Same as quadTo, but the coordinates are considered relative to the last
3929066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * point on this contour. If there is no previous point, then a moveTo(0,0)
3939066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * is inserted automatically.
3949066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
3959066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param dx1 The amount to add to the x-coordinate of the last point on
3969066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *            this contour, for the control point of a quadratic curve
3979066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param dy1 The amount to add to the y-coordinate of the last point on
3989066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *            this contour, for the control point of a quadratic curve
3999066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param dx2 The amount to add to the x-coordinate of the last point on
4009066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *            this contour, for the end point of a quadratic curve
4019066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param dy2 The amount to add to the y-coordinate of the last point on
4029066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *            this contour, for the end point of a quadratic curve
4039066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
4049066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void rQuadTo(float dx1, float dy1, float dx2, float dy2) {
405a48a1a87ba17f20f7006eaab21dcedf86c015c13Romain Guy        isSimplePath = false;
4069066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        native_rQuadTo(mNativePath, dx1, dy1, dx2, dy2);
4079066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
4089066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
4099066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
4109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Add a cubic bezier from the last point, approaching control points
4119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * (x1,y1) and (x2,y2), and ending at (x3,y3). If no moveTo() call has been
4129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * made for this contour, the first point is automatically set to (0,0).
4139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
4149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param x1 The x-coordinate of the 1st control point on a cubic curve
4159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param y1 The y-coordinate of the 1st control point on a cubic curve
4169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param x2 The x-coordinate of the 2nd control point on a cubic curve
4179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param y2 The y-coordinate of the 2nd control point on a cubic curve
4189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param x3 The x-coordinate of the end point on a cubic curve
4199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param y3 The y-coordinate of the end point on a cubic curve
4209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
4219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void cubicTo(float x1, float y1, float x2, float y2,
4229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                        float x3, float y3) {
423a48a1a87ba17f20f7006eaab21dcedf86c015c13Romain Guy        isSimplePath = false;
4249066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        native_cubicTo(mNativePath, x1, y1, x2, y2, x3, y3);
4259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
4269066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
4279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
4289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Same as cubicTo, but the coordinates are considered relative to the
4299066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * current point on this contour. If there is no previous point, then a
4309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * moveTo(0,0) is inserted automatically.
4319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
4329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void rCubicTo(float x1, float y1, float x2, float y2,
4339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                         float x3, float y3) {
434a48a1a87ba17f20f7006eaab21dcedf86c015c13Romain Guy        isSimplePath = false;
4359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        native_rCubicTo(mNativePath, x1, y1, x2, y2, x3, y3);
4369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
4379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
4389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
4399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Append the specified arc to the path as a new contour. If the start of
4409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * the path is different from the path's current last point, then an
4419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * automatic lineTo() is added to connect the current contour to the
4429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * start of the arc. However, if the path is empty, then we call moveTo()
44324609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese     * with the first point of the arc.
4449066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
4459066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param oval        The bounds of oval defining shape and size of the arc
4469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param startAngle  Starting angle (in degrees) where the arc begins
4479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param sweepAngle  Sweep angle (in degrees) measured clockwise, treated
4489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *                    mod 360.
4499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param forceMoveTo If true, always begin a new contour with the arc
4509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
4519066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void arcTo(RectF oval, float startAngle, float sweepAngle,
4529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                      boolean forceMoveTo) {
45324609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese        arcTo(oval.left, oval.top, oval.right, oval.bottom, startAngle, sweepAngle, forceMoveTo);
4549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
45524609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese
4569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
4579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Append the specified arc to the path as a new contour. If the start of
4589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * the path is different from the path's current last point, then an
4599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * automatic lineTo() is added to connect the current contour to the
4609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * start of the arc. However, if the path is empty, then we call moveTo()
4619066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * with the first point of the arc.
4629066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
4639066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param oval        The bounds of oval defining shape and size of the arc
4649066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param startAngle  Starting angle (in degrees) where the arc begins
4659066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param sweepAngle  Sweep angle (in degrees) measured clockwise
4669066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
4679066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void arcTo(RectF oval, float startAngle, float sweepAngle) {
46824609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese        arcTo(oval.left, oval.top, oval.right, oval.bottom, startAngle, sweepAngle, false);
46924609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese    }
47024609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese
47124609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese    /**
47224609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese     * Append the specified arc to the path as a new contour. If the start of
47324609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese     * the path is different from the path's current last point, then an
47424609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese     * automatic lineTo() is added to connect the current contour to the
47524609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese     * start of the arc. However, if the path is empty, then we call moveTo()
47624609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese     * with the first point of the arc.
47724609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese     *
47824609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese     * @param startAngle  Starting angle (in degrees) where the arc begins
47924609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese     * @param sweepAngle  Sweep angle (in degrees) measured clockwise, treated
48024609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese     *                    mod 360.
48124609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese     * @param forceMoveTo If true, always begin a new contour with the arc
48224609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese     */
48324609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese    public void arcTo(float left, float top, float right, float bottom, float startAngle,
48424609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese            float sweepAngle, boolean forceMoveTo) {
485a48a1a87ba17f20f7006eaab21dcedf86c015c13Romain Guy        isSimplePath = false;
48624609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese        native_arcTo(mNativePath, left, top, right, bottom, startAngle, sweepAngle, forceMoveTo);
4879066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
48824609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese
4899066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
4909066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Close the current contour. If the current point is not equal to the
4919066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * first point of the contour, a line segment is automatically added.
4929066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
4939066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void close() {
494a48a1a87ba17f20f7006eaab21dcedf86c015c13Romain Guy        isSimplePath = false;
4959066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        native_close(mNativePath);
4969066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
4979066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
4989066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
4999066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Specifies how closed shapes (e.g. rects, ovals) are oriented when they
5009066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * are added to a path.
5019066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
5029066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public enum Direction {
5039066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        /** clockwise */
5041ad545d207db840d0e403569ce214431eead4217Derek Sollenberger        CW  (0),    // must match enum in SkPath.h
5059066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        /** counter-clockwise */
5061ad545d207db840d0e403569ce214431eead4217Derek Sollenberger        CCW (1);    // must match enum in SkPath.h
50724609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese
5089066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        Direction(int ni) {
5099066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            nativeInt = ni;
5109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
5119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        final int nativeInt;
5129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
51324609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese
514d4b5795e5efd05be7e482e013dfdec519ad2601eRomain Guy    private void detectSimplePath(float left, float top, float right, float bottom, Direction dir) {
51502a2aab57c71f1058348cec0fc3a6aaa07250bc9John Reck        if (mLastDirection == null) {
51602a2aab57c71f1058348cec0fc3a6aaa07250bc9John Reck            mLastDirection = dir;
51702a2aab57c71f1058348cec0fc3a6aaa07250bc9John Reck        }
51802a2aab57c71f1058348cec0fc3a6aaa07250bc9John Reck        if (mLastDirection != dir) {
51902a2aab57c71f1058348cec0fc3a6aaa07250bc9John Reck            isSimplePath = false;
52002a2aab57c71f1058348cec0fc3a6aaa07250bc9John Reck        } else {
52102a2aab57c71f1058348cec0fc3a6aaa07250bc9John Reck            if (rects == null) rects = new Region();
52202a2aab57c71f1058348cec0fc3a6aaa07250bc9John Reck            rects.op((int) left, (int) top, (int) right, (int) bottom, Region.Op.UNION);
523d4b5795e5efd05be7e482e013dfdec519ad2601eRomain Guy        }
524d4b5795e5efd05be7e482e013dfdec519ad2601eRomain Guy    }
525d4b5795e5efd05be7e482e013dfdec519ad2601eRomain Guy
5269066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
5279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Add a closed rectangle contour to the path
5289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
5299066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param rect The rectangle to add as a closed contour to the path
5309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param dir  The direction to wind the rectangle's contour
5319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
5329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void addRect(RectF rect, Direction dir) {
5337979388d4f7d5d9dbfcf7e1cc4709f8088c034aeChris Craik        addRect(rect.left, rect.top, rect.right, rect.bottom, dir);
5349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
5359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
5369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
5379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Add a closed rectangle contour to the path
5389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
5399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param left   The left side of a rectangle to add to the path
5409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param top    The top of a rectangle to add to the path
5419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param right  The right side of a rectangle to add to the path
5429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param bottom The bottom of a rectangle to add to the path
5439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param dir    The direction to wind the rectangle's contour
5449066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
545a48a1a87ba17f20f7006eaab21dcedf86c015c13Romain Guy    public void addRect(float left, float top, float right, float bottom, Direction dir) {
546d4b5795e5efd05be7e482e013dfdec519ad2601eRomain Guy        detectSimplePath(left, top, right, bottom, dir);
5479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        native_addRect(mNativePath, left, top, right, bottom, dir.nativeInt);
5489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
5499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
5509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
5519066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Add a closed oval contour to the path
5529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
5539066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param oval The bounds of the oval to add as a closed contour to the path
5549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param dir  The direction to wind the oval's contour
5559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
5569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void addOval(RectF oval, Direction dir) {
5577979388d4f7d5d9dbfcf7e1cc4709f8088c034aeChris Craik        addOval(oval.left, oval.top, oval.right, oval.bottom, dir);
5587979388d4f7d5d9dbfcf7e1cc4709f8088c034aeChris Craik    }
5597979388d4f7d5d9dbfcf7e1cc4709f8088c034aeChris Craik
5607979388d4f7d5d9dbfcf7e1cc4709f8088c034aeChris Craik    /**
5617979388d4f7d5d9dbfcf7e1cc4709f8088c034aeChris Craik     * Add a closed oval contour to the path
5627979388d4f7d5d9dbfcf7e1cc4709f8088c034aeChris Craik     *
5637979388d4f7d5d9dbfcf7e1cc4709f8088c034aeChris Craik     * @param dir The direction to wind the oval's contour
5647979388d4f7d5d9dbfcf7e1cc4709f8088c034aeChris Craik     */
5657979388d4f7d5d9dbfcf7e1cc4709f8088c034aeChris Craik    public void addOval(float left, float top, float right, float bottom, Direction dir) {
566a48a1a87ba17f20f7006eaab21dcedf86c015c13Romain Guy        isSimplePath = false;
5677979388d4f7d5d9dbfcf7e1cc4709f8088c034aeChris Craik        native_addOval(mNativePath, left, top, right, bottom, dir.nativeInt);
5689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
5699066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
5709066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
5719066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Add a closed circle contour to the path
5729066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
5739066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param x   The x-coordinate of the center of a circle to add to the path
5749066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param y   The y-coordinate of the center of a circle to add to the path
5759066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param radius The radius of a circle to add to the path
5769066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param dir    The direction to wind the circle's contour
5779066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
5789066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void addCircle(float x, float y, float radius, Direction dir) {
579a48a1a87ba17f20f7006eaab21dcedf86c015c13Romain Guy        isSimplePath = false;
5809066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        native_addCircle(mNativePath, x, y, radius, dir.nativeInt);
5819066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
5829066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
5839066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
5849066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Add the specified arc to the path as a new contour.
5859066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
5869066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param oval The bounds of oval defining the shape and size of the arc
5879066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param startAngle Starting angle (in degrees) where the arc begins
5889066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param sweepAngle Sweep angle (in degrees) measured clockwise
5899066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
5909066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void addArc(RectF oval, float startAngle, float sweepAngle) {
59124609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese        addArc(oval.left, oval.top, oval.right, oval.bottom, startAngle, sweepAngle);
59224609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese    }
59324609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese
59424609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese    /**
59524609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese     * Add the specified arc to the path as a new contour.
59624609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese     *
59724609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese     * @param startAngle Starting angle (in degrees) where the arc begins
59824609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese     * @param sweepAngle Sweep angle (in degrees) measured clockwise
59924609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese     */
60024609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese    public void addArc(float left, float top, float right, float bottom, float startAngle,
60124609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese            float sweepAngle) {
602a48a1a87ba17f20f7006eaab21dcedf86c015c13Romain Guy        isSimplePath = false;
60324609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese        native_addArc(mNativePath, left, top, right, bottom, startAngle, sweepAngle);
6049066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
6059066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
6069066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
6079066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        * Add a closed round-rectangle contour to the path
6089066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
6099066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param rect The bounds of a round-rectangle to add to the path
6109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param rx   The x-radius of the rounded corners on the round-rectangle
6119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param ry   The y-radius of the rounded corners on the round-rectangle
6129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param dir  The direction to wind the round-rectangle's contour
6139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
6149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void addRoundRect(RectF rect, float rx, float ry, Direction dir) {
61524609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese        addRoundRect(rect.left, rect.top, rect.right, rect.bottom, rx, ry, dir);
61624609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese    }
61724609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese
61824609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese    /**
61924609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese     * Add a closed round-rectangle contour to the path
62024609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese     *
62124609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese     * @param rx   The x-radius of the rounded corners on the round-rectangle
62224609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese     * @param ry   The y-radius of the rounded corners on the round-rectangle
62324609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese     * @param dir  The direction to wind the round-rectangle's contour
62424609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese     */
62524609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese    public void addRoundRect(float left, float top, float right, float bottom, float rx, float ry,
62624609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese            Direction dir) {
627a48a1a87ba17f20f7006eaab21dcedf86c015c13Romain Guy        isSimplePath = false;
62824609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese        native_addRoundRect(mNativePath, left, top, right, bottom, rx, ry, dir.nativeInt);
6299066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
63024609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese
6319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
6329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Add a closed round-rectangle contour to the path. Each corner receives
6339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * two radius values [X, Y]. The corners are ordered top-left, top-right,
6349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * bottom-right, bottom-left
6359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
6369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param rect The bounds of a round-rectangle to add to the path
6379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param radii Array of 8 values, 4 pairs of [X,Y] radii
6389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param dir  The direction to wind the round-rectangle's contour
6399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
6409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void addRoundRect(RectF rect, float[] radii, Direction dir) {
6419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        if (rect == null) {
6429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            throw new NullPointerException("need rect parameter");
6439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
64424609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese        addRoundRect(rect.left, rect.top, rect.right, rect.bottom, radii, dir);
64524609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese    }
64624609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese
64724609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese    /**
64824609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese     * Add a closed round-rectangle contour to the path. Each corner receives
64924609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese     * two radius values [X, Y]. The corners are ordered top-left, top-right,
65024609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese     * bottom-right, bottom-left
65124609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese     *
65224609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese     * @param radii Array of 8 values, 4 pairs of [X,Y] radii
65324609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese     * @param dir  The direction to wind the round-rectangle's contour
65424609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese     */
65524609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese    public void addRoundRect(float left, float top, float right, float bottom, float[] radii,
65624609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese            Direction dir) {
6579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        if (radii.length < 8) {
6589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            throw new ArrayIndexOutOfBoundsException("radii[] needs 8 values");
6599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
660a48a1a87ba17f20f7006eaab21dcedf86c015c13Romain Guy        isSimplePath = false;
66124609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese        native_addRoundRect(mNativePath, left, top, right, bottom, radii, dir.nativeInt);
6629066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
66324609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese
6649066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
6659066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Add a copy of src to the path, offset by (dx,dy)
6669066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
6679066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param src The path to add as a new contour
6689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param dx  The amount to translate the path in X as it is added
6699066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
6709066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void addPath(Path src, float dx, float dy) {
671a48a1a87ba17f20f7006eaab21dcedf86c015c13Romain Guy        isSimplePath = false;
6729066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        native_addPath(mNativePath, src.mNativePath, dx, dy);
6739066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
6749066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
6759066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
6769066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Add a copy of src to the path
6779066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
6789066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param src The path that is appended to the current path
6799066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
6809066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void addPath(Path src) {
681a48a1a87ba17f20f7006eaab21dcedf86c015c13Romain Guy        isSimplePath = false;
6829066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        native_addPath(mNativePath, src.mNativePath);
6839066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
6849066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
6859066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
6869066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Add a copy of src to the path, transformed by matrix
6879066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
6889066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param src The path to add as a new contour
6899066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
6909066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void addPath(Path src, Matrix matrix) {
691a48a1a87ba17f20f7006eaab21dcedf86c015c13Romain Guy        if (!src.isSimplePath) isSimplePath = false;
6929066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        native_addPath(mNativePath, src.mNativePath, matrix.native_instance);
6939066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
6949066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
6959066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
6960e12fa12cb2cd4e049e560bdad8f1cd654825f3bChris Craik     * Offset the path by (dx,dy)
6979066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
6989066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param dx  The amount in the X direction to offset the entire path
6999066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param dy  The amount in the Y direction to offset the entire path
7009066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param dst The translated path is written here. If this is null, then
7019066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *            the original path is modified.
7029066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
703ecbcdd384c07402204064243981a432f5b0aad36sergeyv    public void offset(float dx, float dy, @Nullable Path dst) {
7049066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        if (dst != null) {
705ecbcdd384c07402204064243981a432f5b0aad36sergeyv            dst.set(this);
706ecbcdd384c07402204064243981a432f5b0aad36sergeyv        } else {
707ecbcdd384c07402204064243981a432f5b0aad36sergeyv            dst = this;
7089066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
709ecbcdd384c07402204064243981a432f5b0aad36sergeyv        dst.offset(dx, dy);
7109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
7119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
7129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
7130e12fa12cb2cd4e049e560bdad8f1cd654825f3bChris Craik     * Offset the path by (dx,dy)
7149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
7159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param dx The amount in the X direction to offset the entire path
7169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param dy The amount in the Y direction to offset the entire path
7179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
7189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void offset(float dx, float dy) {
719ecbcdd384c07402204064243981a432f5b0aad36sergeyv        if (isSimplePath && rects == null) {
720ecbcdd384c07402204064243981a432f5b0aad36sergeyv            // nothing to offset
721ecbcdd384c07402204064243981a432f5b0aad36sergeyv            return;
722ecbcdd384c07402204064243981a432f5b0aad36sergeyv        }
723ecbcdd384c07402204064243981a432f5b0aad36sergeyv        if (isSimplePath && dx == Math.rint(dx) && dy == Math.rint(dy)) {
724ecbcdd384c07402204064243981a432f5b0aad36sergeyv            rects.translate((int) dx, (int) dy);
725ecbcdd384c07402204064243981a432f5b0aad36sergeyv        } else {
726ecbcdd384c07402204064243981a432f5b0aad36sergeyv            isSimplePath = false;
727ecbcdd384c07402204064243981a432f5b0aad36sergeyv        }
7289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        native_offset(mNativePath, dx, dy);
7299066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
7309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
7319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
7329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Sets the last point of the path.
7339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
7349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param dx The new X coordinate for the last point
7359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param dy The new Y coordinate for the last point
7369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
7379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void setLastPoint(float dx, float dy) {
738a48a1a87ba17f20f7006eaab21dcedf86c015c13Romain Guy        isSimplePath = false;
7399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        native_setLastPoint(mNativePath, dx, dy);
7409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
7419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
7429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
7439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Transform the points in this path by matrix, and write the answer
7449066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * into dst. If dst is null, then the the original path is modified.
7459066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
7469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param matrix The matrix to apply to the path
7479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param dst    The transformed path is written here. If dst is null,
7489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *               then the the original path is modified
7499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
7509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void transform(Matrix matrix, Path dst) {
75136bef0bf30d6bae48cf3837df351075ca4fce654Ashok Bhat        long dstNative = 0;
7529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        if (dst != null) {
753fa0853e0b92617128531188edd6a749a72b86432Chris Craik            dst.isSimplePath = false;
7549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            dstNative = dst.mNativePath;
7559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
7569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        native_transform(mNativePath, matrix.native_instance, dstNative);
7579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
7589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
7599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
7609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Transform the points in this path by matrix.
7619066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *
7629066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param matrix The matrix to apply to the path
7639066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
7649066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void transform(Matrix matrix) {
765fa0853e0b92617128531188edd6a749a72b86432Chris Craik        isSimplePath = false;
7669066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        native_transform(mNativePath, matrix.native_instance);
7679066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
7689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
7699066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    protected void finalize() throws Throwable {
7709066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        try {
7719066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            finalizer(mNativePath);
772ffa84e008c712ceffa09d6b89a49882c88b3cca5Hans Boehm            mNativePath = 0;  //  Other finalizers can still call us.
7739066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        } finally {
7749066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            super.finalize();
7759066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
7769066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
77761c8c9c5b2006d18e9310b6521c65b36ffe75ce4Romain Guy
778a6a8557d6e6c8ecc170767b7552979dbdb4254efsergeyv    final long readOnlyNI() {
779a6a8557d6e6c8ecc170767b7552979dbdb4254efsergeyv        return mNativePath;
780a6a8557d6e6c8ecc170767b7552979dbdb4254efsergeyv    }
781a6a8557d6e6c8ecc170767b7552979dbdb4254efsergeyv
782a6a8557d6e6c8ecc170767b7552979dbdb4254efsergeyv    final long mutateNI() {
783a6a8557d6e6c8ecc170767b7552979dbdb4254efsergeyv        isSimplePath = false;
7849066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        return mNativePath;
7859066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
7869066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
787c96c7b2e54965e30c8fb82295f1ca9f891ebd5e7George Mount    /**
788c96c7b2e54965e30c8fb82295f1ca9f891ebd5e7George Mount     * Approximate the <code>Path</code> with a series of line segments.
789c96c7b2e54965e30c8fb82295f1ca9f891ebd5e7George Mount     * This returns float[] with the array containing point components.
790c96c7b2e54965e30c8fb82295f1ca9f891ebd5e7George Mount     * There are three components for each point, in order:
791c96c7b2e54965e30c8fb82295f1ca9f891ebd5e7George Mount     * <ul>
792c96c7b2e54965e30c8fb82295f1ca9f891ebd5e7George Mount     *     <li>Fraction along the length of the path that the point resides</li>
793c96c7b2e54965e30c8fb82295f1ca9f891ebd5e7George Mount     *     <li>The x coordinate of the point</li>
794c96c7b2e54965e30c8fb82295f1ca9f891ebd5e7George Mount     *     <li>The y coordinate of the point</li>
795c96c7b2e54965e30c8fb82295f1ca9f891ebd5e7George Mount     * </ul>
796c96c7b2e54965e30c8fb82295f1ca9f891ebd5e7George Mount     * <p>Two points may share the same fraction along its length when there is
797c96c7b2e54965e30c8fb82295f1ca9f891ebd5e7George Mount     * a move action within the Path.</p>
798c96c7b2e54965e30c8fb82295f1ca9f891ebd5e7George Mount     *
799c96c7b2e54965e30c8fb82295f1ca9f891ebd5e7George Mount     * @param acceptableError The acceptable error for a line on the
800c96c7b2e54965e30c8fb82295f1ca9f891ebd5e7George Mount     *                        Path. Typically this would be 0.5 so that
801c96c7b2e54965e30c8fb82295f1ca9f891ebd5e7George Mount     *                        the error is less than half a pixel.
802c96c7b2e54965e30c8fb82295f1ca9f891ebd5e7George Mount     * @return An array of components for points approximating the Path.
803c96c7b2e54965e30c8fb82295f1ca9f891ebd5e7George Mount     * @hide
804c96c7b2e54965e30c8fb82295f1ca9f891ebd5e7George Mount     */
805c96c7b2e54965e30c8fb82295f1ca9f891ebd5e7George Mount    public float[] approximate(float acceptableError) {
806c96c7b2e54965e30c8fb82295f1ca9f891ebd5e7George Mount        return native_approximate(mNativePath, acceptableError);
807c96c7b2e54965e30c8fb82295f1ca9f891ebd5e7George Mount    }
808c96c7b2e54965e30c8fb82295f1ca9f891ebd5e7George Mount
80936bef0bf30d6bae48cf3837df351075ca4fce654Ashok Bhat    private static native long init1();
81036bef0bf30d6bae48cf3837df351075ca4fce654Ashok Bhat    private static native long init2(long nPath);
81136bef0bf30d6bae48cf3837df351075ca4fce654Ashok Bhat    private static native void native_reset(long nPath);
81236bef0bf30d6bae48cf3837df351075ca4fce654Ashok Bhat    private static native void native_rewind(long nPath);
81336bef0bf30d6bae48cf3837df351075ca4fce654Ashok Bhat    private static native void native_set(long native_dst, long native_src);
8145be83edd15e11420287cc0af93a95d5a6dfae68fChris Craik    private static native boolean native_isConvex(long nPath);
81536bef0bf30d6bae48cf3837df351075ca4fce654Ashok Bhat    private static native int native_getFillType(long nPath);
81636bef0bf30d6bae48cf3837df351075ca4fce654Ashok Bhat    private static native void native_setFillType(long nPath, int ft);
81736bef0bf30d6bae48cf3837df351075ca4fce654Ashok Bhat    private static native boolean native_isEmpty(long nPath);
81836bef0bf30d6bae48cf3837df351075ca4fce654Ashok Bhat    private static native boolean native_isRect(long nPath, RectF rect);
81936bef0bf30d6bae48cf3837df351075ca4fce654Ashok Bhat    private static native void native_computeBounds(long nPath, RectF bounds);
82036bef0bf30d6bae48cf3837df351075ca4fce654Ashok Bhat    private static native void native_incReserve(long nPath, int extraPtCount);
82136bef0bf30d6bae48cf3837df351075ca4fce654Ashok Bhat    private static native void native_moveTo(long nPath, float x, float y);
82236bef0bf30d6bae48cf3837df351075ca4fce654Ashok Bhat    private static native void native_rMoveTo(long nPath, float dx, float dy);
82336bef0bf30d6bae48cf3837df351075ca4fce654Ashok Bhat    private static native void native_lineTo(long nPath, float x, float y);
82436bef0bf30d6bae48cf3837df351075ca4fce654Ashok Bhat    private static native void native_rLineTo(long nPath, float dx, float dy);
82536bef0bf30d6bae48cf3837df351075ca4fce654Ashok Bhat    private static native void native_quadTo(long nPath, float x1, float y1,
8269066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                                             float x2, float y2);
82736bef0bf30d6bae48cf3837df351075ca4fce654Ashok Bhat    private static native void native_rQuadTo(long nPath, float dx1, float dy1,
8289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                                              float dx2, float dy2);
82936bef0bf30d6bae48cf3837df351075ca4fce654Ashok Bhat    private static native void native_cubicTo(long nPath, float x1, float y1,
8309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                                        float x2, float y2, float x3, float y3);
83136bef0bf30d6bae48cf3837df351075ca4fce654Ashok Bhat    private static native void native_rCubicTo(long nPath, float x1, float y1,
8329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                                        float x2, float y2, float x3, float y3);
83324609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese    private static native void native_arcTo(long nPath, float left, float top,
83424609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese                                            float right, float bottom, float startAngle,
83524609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese                                            float sweepAngle, boolean forceMoveTo);
83636bef0bf30d6bae48cf3837df351075ca4fce654Ashok Bhat    private static native void native_close(long nPath);
83736bef0bf30d6bae48cf3837df351075ca4fce654Ashok Bhat    private static native void native_addRect(long nPath, float left, float top,
8389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                                            float right, float bottom, int dir);
8397979388d4f7d5d9dbfcf7e1cc4709f8088c034aeChris Craik    private static native void native_addOval(long nPath, float left, float top,
8407979388d4f7d5d9dbfcf7e1cc4709f8088c034aeChris Craik            float right, float bottom, int dir);
84136bef0bf30d6bae48cf3837df351075ca4fce654Ashok Bhat    private static native void native_addCircle(long nPath, float x, float y, float radius, int dir);
84224609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese    private static native void native_addArc(long nPath, float left, float top,
84324609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese                                             float right, float bottom,
84424609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese                                             float startAngle, float sweepAngle);
84524609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese    private static native void native_addRoundRect(long nPath, float left, float top,
84624609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese                                                   float right, float bottom,
8479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                                                   float rx, float ry, int dir);
84824609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese    private static native void native_addRoundRect(long nPath, float left, float top,
84924609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese                                                   float right, float bottom,
85024609581330bc350f797179e3c1a59789c645ec2Antonio Calabrese                                                   float[] radii, int dir);
85136bef0bf30d6bae48cf3837df351075ca4fce654Ashok Bhat    private static native void native_addPath(long nPath, long src, float dx, float dy);
85236bef0bf30d6bae48cf3837df351075ca4fce654Ashok Bhat    private static native void native_addPath(long nPath, long src);
85336bef0bf30d6bae48cf3837df351075ca4fce654Ashok Bhat    private static native void native_addPath(long nPath, long src, long matrix);
85436bef0bf30d6bae48cf3837df351075ca4fce654Ashok Bhat    private static native void native_offset(long nPath, float dx, float dy);
85536bef0bf30d6bae48cf3837df351075ca4fce654Ashok Bhat    private static native void native_setLastPoint(long nPath, float dx, float dy);
85636bef0bf30d6bae48cf3837df351075ca4fce654Ashok Bhat    private static native void native_transform(long nPath, long matrix, long dst_path);
85736bef0bf30d6bae48cf3837df351075ca4fce654Ashok Bhat    private static native void native_transform(long nPath, long matrix);
85836bef0bf30d6bae48cf3837df351075ca4fce654Ashok Bhat    private static native boolean native_op(long path1, long path2, int op, long result);
85936bef0bf30d6bae48cf3837df351075ca4fce654Ashok Bhat    private static native void finalizer(long nPath);
86036bef0bf30d6bae48cf3837df351075ca4fce654Ashok Bhat    private static native float[] native_approximate(long nPath, float error);
8619066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project}
862