38 import java.awt.geom.Path2D;
39 import java.awt.font.GlyphVector;
40 import sun.java2d.SunGraphics2D;
41 import sun.java2d.SurfaceData;
42 import sun.java2d.loops.FontInfo;
43 import sun.java2d.loops.DrawPolygons;
44 import sun.awt.SunHints;
45
46 public class LoopPipe
47 implements PixelDrawPipe,
48 PixelFillPipe,
49 ShapeDrawPipe
50 {
51 final static RenderingEngine RenderEngine = RenderingEngine.getInstance();
52
53 public void drawLine(SunGraphics2D sg2d,
54 int x1, int y1, int x2, int y2)
55 {
56 int tX = sg2d.transX;
57 int tY = sg2d.transY;
58 sg2d.loops.drawLineLoop.DrawLine(sg2d, sg2d.getSurfaceData(),
59 x1 + tX, y1 + tY,
60 x2 + tX, y2 + tY);
61 }
62
63 public void drawRect(SunGraphics2D sg2d,
64 int x, int y, int width, int height)
65 {
66 sg2d.loops.drawRectLoop.DrawRect(sg2d, sg2d.getSurfaceData(),
67 x + sg2d.transX,
68 y + sg2d.transY,
69 width, height);
70 }
71
72 public void drawRoundRect(SunGraphics2D sg2d,
73 int x, int y, int width, int height,
74 int arcWidth, int arcHeight)
75 {
76 sg2d.shapepipe.draw(sg2d,
77 new RoundRectangle2D.Float(x, y, width, height,
78 arcWidth, arcHeight));
79 }
80
81 public void drawOval(SunGraphics2D sg2d,
82 int x, int y, int width, int height)
83 {
84 sg2d.shapepipe.draw(sg2d, new Ellipse2D.Float(x, y, width, height));
85 }
86
87 public void drawArc(SunGraphics2D sg2d,
88 int x, int y, int width, int height,
89 int startAngle, int arcAngle)
90 {
91 sg2d.shapepipe.draw(sg2d, new Arc2D.Float(x, y, width, height,
92 startAngle, arcAngle,
93 Arc2D.OPEN));
94 }
95
96 public void drawPolyline(SunGraphics2D sg2d,
97 int xPoints[], int yPoints[],
98 int nPoints)
99 {
100 int nPointsArray[] = { nPoints };
101 sg2d.loops.drawPolygonsLoop.DrawPolygons(sg2d, sg2d.getSurfaceData(),
102 xPoints, yPoints,
103 nPointsArray, 1,
104 sg2d.transX, sg2d.transY,
105 false);
106 }
107
108 public void drawPolygon(SunGraphics2D sg2d,
109 int xPoints[], int yPoints[],
110 int nPoints)
111 {
112 int nPointsArray[] = { nPoints };
113 sg2d.loops.drawPolygonsLoop.DrawPolygons(sg2d, sg2d.getSurfaceData(),
114 xPoints, yPoints,
115 nPointsArray, 1,
116 sg2d.transX, sg2d.transY,
117 true);
118 }
119
120 public void fillRect(SunGraphics2D sg2d,
121 int x, int y, int width, int height)
122 {
123 sg2d.loops.fillRectLoop.FillRect(sg2d, sg2d.getSurfaceData(),
124 x + sg2d.transX,
125 y + sg2d.transY,
126 width, height);
127 }
128
129 public void fillRoundRect(SunGraphics2D sg2d,
130 int x, int y, int width, int height,
131 int arcWidth, int arcHeight)
132 {
133 sg2d.shapepipe.fill(sg2d,
134 new RoundRectangle2D.Float(x, y, width, height,
135 arcWidth, arcHeight));
136 }
137
138 public void fillOval(SunGraphics2D sg2d,
139 int x, int y, int width, int height)
140 {
141 sg2d.shapepipe.fill(sg2d, new Ellipse2D.Float(x, y, width, height));
142 }
143
167
168
169 public void draw(SunGraphics2D sg2d, Shape s) {
170 if (sg2d.strokeState == sg2d.STROKE_THIN) {
171 Path2D.Float p2df;
172 int transX;
173 int transY;
174 if (sg2d.transformState <= sg2d.TRANSFORM_INT_TRANSLATE) {
175 if (s instanceof Path2D.Float) {
176 p2df = (Path2D.Float)s;
177 } else {
178 p2df = new Path2D.Float(s);
179 }
180 transX = sg2d.transX;
181 transY = sg2d.transY;
182 } else {
183 p2df = new Path2D.Float(s, sg2d.transform);
184 transX = 0;
185 transY = 0;
186 }
187 sg2d.loops.drawPathLoop.DrawPath(sg2d, sg2d.getSurfaceData(),
188 transX, transY, p2df);
189 return;
190 }
191
192 if (sg2d.strokeState == sg2d.STROKE_CUSTOM) {
193 fill(sg2d, sg2d.stroke.createStrokedShape(s));
194 return;
195 }
196
197 ShapeSpanIterator sr = getStrokeSpans(sg2d, s);
198
199 try {
200 fillSpans(sg2d, sr);
201 } finally {
202 sr.dispose();
203 }
204 }
205
206 /**
207 * Return a ShapeSpanIterator instance that normalizes as
285 }
286
287 public void fill(SunGraphics2D sg2d, Shape s) {
288 if (sg2d.strokeState == sg2d.STROKE_THIN) {
289 Path2D.Float p2df;
290 int transX;
291 int transY;
292 if (sg2d.transformState <= sg2d.TRANSFORM_INT_TRANSLATE) {
293 if (s instanceof Path2D.Float) {
294 p2df = (Path2D.Float)s;
295 } else {
296 p2df = new Path2D.Float(s);
297 }
298 transX = sg2d.transX;
299 transY = sg2d.transY;
300 } else {
301 p2df = new Path2D.Float(s, sg2d.transform);
302 transX = 0;
303 transY = 0;
304 }
305 sg2d.loops.fillPathLoop.FillPath(sg2d, sg2d.getSurfaceData(),
306 transX, transY, p2df);
307 return;
308 }
309
310 ShapeSpanIterator sr = getFillSSI(sg2d);
311 try {
312 sr.setOutputArea(sg2d.getCompClip());
313 AffineTransform at =
314 ((sg2d.transformState == sg2d.TRANSFORM_ISIDENT)
315 ? null
316 : sg2d.transform);
317 sr.appendPath(s.getPathIterator(at));
318 fillSpans(sg2d, sr);
319 } finally {
320 sr.dispose();
321 }
322 }
323
324 private static void fillSpans(SunGraphics2D sg2d, SpanIterator si) {
325 // REMIND: Eventually, the plan is that it will not be possible for
326 // fs to be null since the FillSpans loop will be the fundamental
327 // loop implemented for any destination type...
328 if (sg2d.clipState == sg2d.CLIP_SHAPE) {
329 si = sg2d.clipRegion.filter(si);
330 // REMIND: Region.filter produces a Java-only iterator
331 // with no native counterpart...
332 } else {
333 sun.java2d.loops.FillSpans fs = sg2d.loops.fillSpansLoop;
334 if (fs != null) {
335 fs.FillSpans(sg2d, sg2d.getSurfaceData(), si);
336 return;
337 }
338 }
339 int spanbox[] = new int[4];
340 SurfaceData sd = sg2d.getSurfaceData();
341 while (si.nextSpan(spanbox)) {
342 int x = spanbox[0];
343 int y = spanbox[1];
344 int w = spanbox[2] - x;
345 int h = spanbox[3] - y;
346 sg2d.loops.fillRectLoop.FillRect(sg2d, sd, x, y, w, h);
347 }
348 }
349 }
|
38 import java.awt.geom.Path2D;
39 import java.awt.font.GlyphVector;
40 import sun.java2d.SunGraphics2D;
41 import sun.java2d.SurfaceData;
42 import sun.java2d.loops.FontInfo;
43 import sun.java2d.loops.DrawPolygons;
44 import sun.awt.SunHints;
45
46 public class LoopPipe
47 implements PixelDrawPipe,
48 PixelFillPipe,
49 ShapeDrawPipe
50 {
51 final static RenderingEngine RenderEngine = RenderingEngine.getInstance();
52
53 public void drawLine(SunGraphics2D sg2d,
54 int x1, int y1, int x2, int y2)
55 {
56 int tX = sg2d.transX;
57 int tY = sg2d.transY;
58 sg2d.getLoops().drawLineLoop.DrawLine(sg2d, sg2d.getSurfaceData(),
59 x1 + tX, y1 + tY,
60 x2 + tX, y2 + tY);
61 }
62
63 public void drawRect(SunGraphics2D sg2d,
64 int x, int y, int width, int height)
65 {
66 sg2d.getLoops().drawRectLoop.DrawRect(sg2d, sg2d.getSurfaceData(),
67 x + sg2d.transX,
68 y + sg2d.transY,
69 width, height);
70 }
71
72 public void drawRoundRect(SunGraphics2D sg2d,
73 int x, int y, int width, int height,
74 int arcWidth, int arcHeight)
75 {
76 sg2d.shapepipe.draw(sg2d,
77 new RoundRectangle2D.Float(x, y, width, height,
78 arcWidth, arcHeight));
79 }
80
81 public void drawOval(SunGraphics2D sg2d,
82 int x, int y, int width, int height)
83 {
84 sg2d.shapepipe.draw(sg2d, new Ellipse2D.Float(x, y, width, height));
85 }
86
87 public void drawArc(SunGraphics2D sg2d,
88 int x, int y, int width, int height,
89 int startAngle, int arcAngle)
90 {
91 sg2d.shapepipe.draw(sg2d, new Arc2D.Float(x, y, width, height,
92 startAngle, arcAngle,
93 Arc2D.OPEN));
94 }
95
96 public void drawPolyline(SunGraphics2D sg2d,
97 int xPoints[], int yPoints[],
98 int nPoints)
99 {
100 int nPointsArray[] = { nPoints };
101 sg2d.getLoops().drawPolygonsLoop.DrawPolygons(sg2d, sg2d.getSurfaceData(),
102 xPoints, yPoints,
103 nPointsArray, 1,
104 sg2d.transX, sg2d.transY,
105 false);
106 }
107
108 public void drawPolygon(SunGraphics2D sg2d,
109 int xPoints[], int yPoints[],
110 int nPoints)
111 {
112 int nPointsArray[] = { nPoints };
113 sg2d.getLoops().drawPolygonsLoop.DrawPolygons(sg2d, sg2d.getSurfaceData(),
114 xPoints, yPoints,
115 nPointsArray, 1,
116 sg2d.transX, sg2d.transY,
117 true);
118 }
119
120 public void fillRect(SunGraphics2D sg2d,
121 int x, int y, int width, int height)
122 {
123 sg2d.getLoops().fillRectLoop.FillRect(sg2d, sg2d.getSurfaceData(),
124 x + sg2d.transX,
125 y + sg2d.transY,
126 width, height);
127 }
128
129 public void fillRoundRect(SunGraphics2D sg2d,
130 int x, int y, int width, int height,
131 int arcWidth, int arcHeight)
132 {
133 sg2d.shapepipe.fill(sg2d,
134 new RoundRectangle2D.Float(x, y, width, height,
135 arcWidth, arcHeight));
136 }
137
138 public void fillOval(SunGraphics2D sg2d,
139 int x, int y, int width, int height)
140 {
141 sg2d.shapepipe.fill(sg2d, new Ellipse2D.Float(x, y, width, height));
142 }
143
167
168
169 public void draw(SunGraphics2D sg2d, Shape s) {
170 if (sg2d.strokeState == sg2d.STROKE_THIN) {
171 Path2D.Float p2df;
172 int transX;
173 int transY;
174 if (sg2d.transformState <= sg2d.TRANSFORM_INT_TRANSLATE) {
175 if (s instanceof Path2D.Float) {
176 p2df = (Path2D.Float)s;
177 } else {
178 p2df = new Path2D.Float(s);
179 }
180 transX = sg2d.transX;
181 transY = sg2d.transY;
182 } else {
183 p2df = new Path2D.Float(s, sg2d.transform);
184 transX = 0;
185 transY = 0;
186 }
187 sg2d.getLoops().drawPathLoop.DrawPath(sg2d, sg2d.getSurfaceData(),
188 transX, transY, p2df);
189 return;
190 }
191
192 if (sg2d.strokeState == sg2d.STROKE_CUSTOM) {
193 fill(sg2d, sg2d.stroke.createStrokedShape(s));
194 return;
195 }
196
197 ShapeSpanIterator sr = getStrokeSpans(sg2d, s);
198
199 try {
200 fillSpans(sg2d, sr);
201 } finally {
202 sr.dispose();
203 }
204 }
205
206 /**
207 * Return a ShapeSpanIterator instance that normalizes as
285 }
286
287 public void fill(SunGraphics2D sg2d, Shape s) {
288 if (sg2d.strokeState == sg2d.STROKE_THIN) {
289 Path2D.Float p2df;
290 int transX;
291 int transY;
292 if (sg2d.transformState <= sg2d.TRANSFORM_INT_TRANSLATE) {
293 if (s instanceof Path2D.Float) {
294 p2df = (Path2D.Float)s;
295 } else {
296 p2df = new Path2D.Float(s);
297 }
298 transX = sg2d.transX;
299 transY = sg2d.transY;
300 } else {
301 p2df = new Path2D.Float(s, sg2d.transform);
302 transX = 0;
303 transY = 0;
304 }
305 sg2d.getLoops().fillPathLoop.FillPath(sg2d, sg2d.getSurfaceData(),
306 transX, transY, p2df);
307 return;
308 }
309
310 ShapeSpanIterator sr = getFillSSI(sg2d);
311 try {
312 sr.setOutputArea(sg2d.getCompClip());
313 AffineTransform at =
314 ((sg2d.transformState == sg2d.TRANSFORM_ISIDENT)
315 ? null
316 : sg2d.transform);
317 sr.appendPath(s.getPathIterator(at));
318 fillSpans(sg2d, sr);
319 } finally {
320 sr.dispose();
321 }
322 }
323
324 private static void fillSpans(SunGraphics2D sg2d, SpanIterator si) {
325 // REMIND: Eventually, the plan is that it will not be possible for
326 // fs to be null since the FillSpans loop will be the fundamental
327 // loop implemented for any destination type...
328 if (sg2d.clipState == sg2d.CLIP_SHAPE) {
329 si = sg2d.clipRegion.filter(si);
330 // REMIND: Region.filter produces a Java-only iterator
331 // with no native counterpart...
332 } else {
333 sun.java2d.loops.FillSpans fs = sg2d.getLoops().fillSpansLoop;
334 if (fs != null) {
335 fs.FillSpans(sg2d, sg2d.getSurfaceData(), si);
336 return;
337 }
338 }
339 int spanbox[] = new int[4];
340 SurfaceData sd = sg2d.getSurfaceData();
341 while (si.nextSpan(spanbox)) {
342 int x = spanbox[0];
343 int y = spanbox[1];
344 int w = spanbox[2] - x;
345 int h = spanbox[3] - y;
346 sg2d.getLoops().fillRectLoop.FillRect(sg2d, sd, x, y, w, h);
347 }
348 }
349 }
|