1/*
2 * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26#ifndef _Included_PathConsumer2D
27#define _Included_PathConsumer2D
28
29/* For forward referencing - struct defined below. */
30struct _PathConsumerVec;
31
32/*
33 * Note on Error Conditions:
34 * The following functions all return true on an error condition which
35 * precludes any further processing. The module calling these functions
36 * should cease the operation and invoke its own error handling.
37 * The return value is the only indication of the error, no exceptions
38 * should be thrown by the consumer - the caller is solely responsible
39 * for reporting the error/exception.
40 * The most common cause of failure is an allocation failure so a
41 * true return code could be reported as an "out of memory" error
42 * if so desired.
43 * No cleanup of the native consumer is required upon either a successful
44 * completion of the path or upon an error return. Such cleanup will
45 * be handled elsewhere via other mechanisms (finalization, try/finally,
46 * etc.)
47 */
48
49/* See GeneralPath.moveTo - returns true on error condition. */
50typedef jboolean (MoveToFunc)(struct _PathConsumerVec *pVec,
51 jfloat x0, jfloat y0);
52/* See GeneralPath.lineTo - returns true on error condition. */
53typedef jboolean (LineToFunc)(struct _PathConsumerVec *pVec,
54 jfloat x1, jfloat y1);
55/* See GeneralPath.quadTo - returns true on error condition. */
56typedef jboolean (QuadToFunc)(struct _PathConsumerVec *pVec,
57 jfloat xm, jfloat ym,
58 jfloat x1, jfloat y1);
59/* See GeneralPath.curveTo - returns true on error condition. */
60typedef jboolean (CubicToFunc)(struct _PathConsumerVec *pVec,
61 jfloat xm0, jfloat ym0,
62 jfloat xm1, jfloat ym1,
63 jfloat x1, jfloat y1);
64/* See GeneralPath.closePath - returns true on error condition. */
65typedef jboolean (ClosePathFunc)(struct _PathConsumerVec *pVec);
66
67/*
68 * This function must be called after the last segment of the last
69 * subpath is sent to the above methods. No further calls should
70 * be made to any of the PathConsumerVec functions subsequently.
71 */
72typedef jboolean (PathDoneFunc)(struct _PathConsumerVec *pVec);
73
74/*
75 * This structure defines the list of function pointers for implementations
76 * of the above specified functions. A pointer to this structure is also
77 * handed to each function as its first parameter. If the implementation
78 * needs private context-specific data then it can be stored adjacent to
79 * the PathConsumerVec structure in the same allocated storage.
80 */
81typedef struct _PathConsumerVec {
82 MoveToFunc *moveTo;
83 LineToFunc *lineTo;
84 QuadToFunc *quadTo;
85 CubicToFunc *cubicTo;
86 ClosePathFunc *closePath;
87 PathDoneFunc *pathDone;
88} PathConsumerVec;
89
90#endif
91