1 /*
2 * Copyright (c) 1999, 2014, 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
124 int x, int y, int width, int height,
125 int startAngle, int arcAngle)
126 {
127 try {
128 doDrawArc((GDIWindowSurfaceData)sg2d.surfaceData,
129 sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
130 x+sg2d.transX, y+sg2d.transY, width, height,
131 startAngle, arcAngle);
132 } catch (ClassCastException e) {
133 throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
134 }
135 }
136
137 native void doDrawPoly(GDIWindowSurfaceData sData,
138 Region clip, Composite comp, int color,
139 int transx, int transy,
140 int[] xpoints, int[] ypoints,
141 int npoints, boolean isclosed);
142
143 public void drawPolyline(SunGraphics2D sg2d,
144 int xpoints[], int ypoints[],
145 int npoints)
146 {
147 try {
148 doDrawPoly((GDIWindowSurfaceData)sg2d.surfaceData,
149 sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
150 sg2d.transX, sg2d.transY, xpoints, ypoints, npoints, false);
151 } catch (ClassCastException e) {
152 throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
153 }
154 }
155
156 public void drawPolygon(SunGraphics2D sg2d,
157 int xpoints[], int ypoints[],
158 int npoints)
159 {
160 try {
161 doDrawPoly((GDIWindowSurfaceData)sg2d.surfaceData,
162 sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
163 sg2d.transX, sg2d.transY, xpoints, ypoints, npoints, true);
164 } catch (ClassCastException e) {
165 throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
166 }
167 }
168
169 native void doFillRect(GDIWindowSurfaceData sData,
170 Region clip, Composite comp, int color,
171 int x, int y, int w, int h);
172
173 public void fillRect(SunGraphics2D sg2d,
174 int x, int y, int width, int height)
175 {
176 try {
177 doFillRect((GDIWindowSurfaceData)sg2d.surfaceData,
226 int x, int y, int width, int height,
227 int startAngle, int arcAngle)
228 {
229 try {
230 doFillArc((GDIWindowSurfaceData)sg2d.surfaceData,
231 sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
232 x+sg2d.transX, y+sg2d.transY, width, height,
233 startAngle, arcAngle);
234 } catch (ClassCastException e) {
235 throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
236 }
237 }
238
239 native void doFillPoly(GDIWindowSurfaceData sData,
240 Region clip, Composite comp, int color,
241 int transx, int transy,
242 int[] xpoints, int[] ypoints,
243 int npoints);
244
245 public void fillPolygon(SunGraphics2D sg2d,
246 int xpoints[], int ypoints[],
247 int npoints)
248 {
249 try {
250 doFillPoly((GDIWindowSurfaceData)sg2d.surfaceData,
251 sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
252 sg2d.transX, sg2d.transY, xpoints, ypoints, npoints);
253 } catch (ClassCastException e) {
254 throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
255 }
256 }
257
258 native void doShape(GDIWindowSurfaceData sData,
259 Region clip, Composite comp, int color,
260 int transX, int transY,
261 Path2D.Float p2df, boolean isfill);
262
263 void doShape(SunGraphics2D sg2d, Shape s, boolean isfill) {
264 Path2D.Float p2df;
265 int transX;
266 int transY;
274 transY = sg2d.transY;
275 } else {
276 p2df = new Path2D.Float(s, sg2d.transform);
277 transX = 0;
278 transY = 0;
279 }
280 try {
281 doShape((GDIWindowSurfaceData)sg2d.surfaceData,
282 sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
283 transX, transY, p2df, isfill);
284 } catch (ClassCastException e) {
285 throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
286 }
287 }
288
289 // REMIND: This is just a hack to get WIDE lines to honor the
290 // necessary hinted pixelization rules. This should be replaced
291 // by a native FillSpans method or a getHintedStrokeGeneralPath()
292 // method that could be filled by the doShape method more quickly.
293 public void doFillSpans(SunGraphics2D sg2d, SpanIterator si) {
294 int box[] = new int[4];
295 GDIWindowSurfaceData sd;
296 try {
297 sd = (GDIWindowSurfaceData)sg2d.surfaceData;
298 } catch (ClassCastException e) {
299 throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
300 }
301 Region clip = sg2d.getCompClip();
302 Composite comp = sg2d.composite;
303 int eargb = sg2d.eargb;
304 while (si.nextSpan(box)) {
305 doFillRect(sd, clip, comp, eargb,
306 box[0], box[1], box[2]-box[0], box[3]-box[1]);
307 }
308 }
309
310 public void draw(SunGraphics2D sg2d, Shape s) {
311 if (sg2d.strokeState == SunGraphics2D.STROKE_THIN) {
312 doShape(sg2d, s, false);
313 } else if (sg2d.strokeState < SunGraphics2D.STROKE_CUSTOM) {
314 ShapeSpanIterator si = LoopPipe.getStrokeSpans(sg2d, s);
|
1 /*
2 * Copyright (c) 1999, 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
124 int x, int y, int width, int height,
125 int startAngle, int arcAngle)
126 {
127 try {
128 doDrawArc((GDIWindowSurfaceData)sg2d.surfaceData,
129 sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
130 x+sg2d.transX, y+sg2d.transY, width, height,
131 startAngle, arcAngle);
132 } catch (ClassCastException e) {
133 throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
134 }
135 }
136
137 native void doDrawPoly(GDIWindowSurfaceData sData,
138 Region clip, Composite comp, int color,
139 int transx, int transy,
140 int[] xpoints, int[] ypoints,
141 int npoints, boolean isclosed);
142
143 public void drawPolyline(SunGraphics2D sg2d,
144 int[] xpoints, int[] ypoints,
145 int npoints)
146 {
147 try {
148 doDrawPoly((GDIWindowSurfaceData)sg2d.surfaceData,
149 sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
150 sg2d.transX, sg2d.transY, xpoints, ypoints, npoints, false);
151 } catch (ClassCastException e) {
152 throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
153 }
154 }
155
156 public void drawPolygon(SunGraphics2D sg2d,
157 int[] xpoints, int[] ypoints,
158 int npoints)
159 {
160 try {
161 doDrawPoly((GDIWindowSurfaceData)sg2d.surfaceData,
162 sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
163 sg2d.transX, sg2d.transY, xpoints, ypoints, npoints, true);
164 } catch (ClassCastException e) {
165 throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
166 }
167 }
168
169 native void doFillRect(GDIWindowSurfaceData sData,
170 Region clip, Composite comp, int color,
171 int x, int y, int w, int h);
172
173 public void fillRect(SunGraphics2D sg2d,
174 int x, int y, int width, int height)
175 {
176 try {
177 doFillRect((GDIWindowSurfaceData)sg2d.surfaceData,
226 int x, int y, int width, int height,
227 int startAngle, int arcAngle)
228 {
229 try {
230 doFillArc((GDIWindowSurfaceData)sg2d.surfaceData,
231 sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
232 x+sg2d.transX, y+sg2d.transY, width, height,
233 startAngle, arcAngle);
234 } catch (ClassCastException e) {
235 throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
236 }
237 }
238
239 native void doFillPoly(GDIWindowSurfaceData sData,
240 Region clip, Composite comp, int color,
241 int transx, int transy,
242 int[] xpoints, int[] ypoints,
243 int npoints);
244
245 public void fillPolygon(SunGraphics2D sg2d,
246 int[] xpoints, int[] ypoints,
247 int npoints)
248 {
249 try {
250 doFillPoly((GDIWindowSurfaceData)sg2d.surfaceData,
251 sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
252 sg2d.transX, sg2d.transY, xpoints, ypoints, npoints);
253 } catch (ClassCastException e) {
254 throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
255 }
256 }
257
258 native void doShape(GDIWindowSurfaceData sData,
259 Region clip, Composite comp, int color,
260 int transX, int transY,
261 Path2D.Float p2df, boolean isfill);
262
263 void doShape(SunGraphics2D sg2d, Shape s, boolean isfill) {
264 Path2D.Float p2df;
265 int transX;
266 int transY;
274 transY = sg2d.transY;
275 } else {
276 p2df = new Path2D.Float(s, sg2d.transform);
277 transX = 0;
278 transY = 0;
279 }
280 try {
281 doShape((GDIWindowSurfaceData)sg2d.surfaceData,
282 sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
283 transX, transY, p2df, isfill);
284 } catch (ClassCastException e) {
285 throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
286 }
287 }
288
289 // REMIND: This is just a hack to get WIDE lines to honor the
290 // necessary hinted pixelization rules. This should be replaced
291 // by a native FillSpans method or a getHintedStrokeGeneralPath()
292 // method that could be filled by the doShape method more quickly.
293 public void doFillSpans(SunGraphics2D sg2d, SpanIterator si) {
294 int[] box = new int[4];
295 GDIWindowSurfaceData sd;
296 try {
297 sd = (GDIWindowSurfaceData)sg2d.surfaceData;
298 } catch (ClassCastException e) {
299 throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
300 }
301 Region clip = sg2d.getCompClip();
302 Composite comp = sg2d.composite;
303 int eargb = sg2d.eargb;
304 while (si.nextSpan(box)) {
305 doFillRect(sd, clip, comp, eargb,
306 box[0], box[1], box[2]-box[0], box[3]-box[1]);
307 }
308 }
309
310 public void draw(SunGraphics2D sg2d, Shape s) {
311 if (sg2d.strokeState == SunGraphics2D.STROKE_THIN) {
312 doShape(sg2d, s, false);
313 } else if (sg2d.strokeState < SunGraphics2D.STROKE_CUSTOM) {
314 ShapeSpanIterator si = LoopPipe.getStrokeSpans(sg2d, s);
|