1 /*
2 * Copyright (c) 1998, 2016, 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
65 public final class ShapeSpanIterator
66 implements SpanIterator, PathConsumer2D
67 {
68 long pData;
69
70 static {
71 initIDs();
72 }
73
74 public static native void initIDs();
75
76 public ShapeSpanIterator(boolean adjust) {
77 setNormalize(adjust);
78 }
79
80 /*
81 * Appends the geometry and winding rule from the indicated
82 * path iterator.
83 */
84 public void appendPath(PathIterator pi) {
85 float coords[] = new float[6];
86
87 setRule(pi.getWindingRule());
88 while (!pi.isDone()) {
89 addSegment(pi.currentSegment(coords), coords);
90 pi.next();
91 }
92 pathDone();
93 }
94
95 /*
96 * Appends the geometry from the indicated set of polygon points.
97 */
98 public native void appendPoly(int xPoints[], int yPoints[], int nPoints,
99 int xoff, int yoff);
100
101 /*
102 * Sets the normalization flag so that incoming data is
103 * adjusted to nearest (0.25, 0.25) subpixel position.
104 */
105 private native void setNormalize(boolean adjust);
106
107 /*
108 * Sets the rectangle of interest for storing and returning
109 * span segments.
110 */
111 public void setOutputAreaXYWH(int x, int y, int w, int h) {
112 setOutputAreaXYXY(x, y, Region.dimAdd(x, w), Region.dimAdd(y, h));
113 }
114
115 /*
116 * Sets the rectangle of interest for storing and returning
117 * span segments.
118 */
126 setOutputAreaXYWH(r.x, r.y, r.width, r.height);
127 }
128
129 /*
130 * Sets the rectangle of interest for storing and returning
131 * span segments to the bounds of the specified Region.
132 */
133 public void setOutputArea(Region r) {
134 setOutputAreaXYXY(r.getLoX(), r.getLoY(), r.getHiX(), r.getHiY());
135 }
136
137 /*
138 * Sets the winding rule in the native data structures.
139 */
140 public native void setRule(int rule);
141
142 /*
143 * Adds a single PathIterator segment to the internal list of
144 * path element structures.
145 */
146 public native void addSegment(int type, float coords[]);
147
148 /*
149 * Gets the bbox of the available path segments, clipped to the
150 * OutputArea.
151 */
152 public native void getPathBox(int pathbox[]);
153
154 /*
155 * Intersects the path box with the given bbox.
156 * Returned spans are clipped to this region, or discarded
157 * altogether if they lie outside it.
158 */
159 public native void intersectClipBox(int lox, int loy, int hix, int hiy);
160
161 /*
162 * Fetches the next span that needs to be operated on.
163 * If the return value is false then there are no more spans.
164 */
165 public native boolean nextSpan(int spanbox[]);
166
167 /**
168 * This method tells the iterator that it may skip all spans
169 * whose Y range is completely above the indicated Y coordinate.
170 */
171 public native void skipDownTo(int y);
172
173 /**
174 * This method returns a native pointer to a function block that
175 * can be used by a native method to perform the same iteration
176 * cycle that the above methods provide while avoiding upcalls to
177 * the Java object.
178 * The definition of the structure whose pointer is returned by
179 * this method is defined in:
180 * <pre>
181 * src/share/native/sun/java2d/pipe/SpanIterator.h
182 * </pre>
183 */
184 public native long getNativeIterator();
185
|
1 /*
2 * Copyright (c) 1998, 2018, 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
65 public final class ShapeSpanIterator
66 implements SpanIterator, PathConsumer2D
67 {
68 long pData;
69
70 static {
71 initIDs();
72 }
73
74 public static native void initIDs();
75
76 public ShapeSpanIterator(boolean adjust) {
77 setNormalize(adjust);
78 }
79
80 /*
81 * Appends the geometry and winding rule from the indicated
82 * path iterator.
83 */
84 public void appendPath(PathIterator pi) {
85 float[] coords = new float[6];
86
87 setRule(pi.getWindingRule());
88 while (!pi.isDone()) {
89 addSegment(pi.currentSegment(coords), coords);
90 pi.next();
91 }
92 pathDone();
93 }
94
95 /*
96 * Appends the geometry from the indicated set of polygon points.
97 */
98 public native void appendPoly(int[] xPoints, int[] yPoints, int nPoints,
99 int xoff, int yoff);
100
101 /*
102 * Sets the normalization flag so that incoming data is
103 * adjusted to nearest (0.25, 0.25) subpixel position.
104 */
105 private native void setNormalize(boolean adjust);
106
107 /*
108 * Sets the rectangle of interest for storing and returning
109 * span segments.
110 */
111 public void setOutputAreaXYWH(int x, int y, int w, int h) {
112 setOutputAreaXYXY(x, y, Region.dimAdd(x, w), Region.dimAdd(y, h));
113 }
114
115 /*
116 * Sets the rectangle of interest for storing and returning
117 * span segments.
118 */
126 setOutputAreaXYWH(r.x, r.y, r.width, r.height);
127 }
128
129 /*
130 * Sets the rectangle of interest for storing and returning
131 * span segments to the bounds of the specified Region.
132 */
133 public void setOutputArea(Region r) {
134 setOutputAreaXYXY(r.getLoX(), r.getLoY(), r.getHiX(), r.getHiY());
135 }
136
137 /*
138 * Sets the winding rule in the native data structures.
139 */
140 public native void setRule(int rule);
141
142 /*
143 * Adds a single PathIterator segment to the internal list of
144 * path element structures.
145 */
146 public native void addSegment(int type, float[] coords);
147
148 /*
149 * Gets the bbox of the available path segments, clipped to the
150 * OutputArea.
151 */
152 public native void getPathBox(int[] pathbox);
153
154 /*
155 * Intersects the path box with the given bbox.
156 * Returned spans are clipped to this region, or discarded
157 * altogether if they lie outside it.
158 */
159 public native void intersectClipBox(int lox, int loy, int hix, int hiy);
160
161 /*
162 * Fetches the next span that needs to be operated on.
163 * If the return value is false then there are no more spans.
164 */
165 public native boolean nextSpan(int[] spanbox);
166
167 /**
168 * This method tells the iterator that it may skip all spans
169 * whose Y range is completely above the indicated Y coordinate.
170 */
171 public native void skipDownTo(int y);
172
173 /**
174 * This method returns a native pointer to a function block that
175 * can be used by a native method to perform the same iteration
176 * cycle that the above methods provide while avoiding upcalls to
177 * the Java object.
178 * The definition of the structure whose pointer is returned by
179 * this method is defined in:
180 * <pre>
181 * src/share/native/sun/java2d/pipe/SpanIterator.h
182 * </pre>
183 */
184 public native long getNativeIterator();
185
|