/* Checking SEG_MOVETO coordinates if they are out of the * [LOWER_BND, UPPER_BND] range. This check also handles NaN * and Infinity values. Skipping next path segment in case * of invalid data. */ if (point[0] < UPPER_BND && point[0] > LOWER_BND && point[1] < UPPER_BND && point[1] > LOWER_BND) { mx = point[0]; my = point[1]; r.beginSubpath(mx, my); subpathStarted = true; skip = false; } else { skip = true; } break; case PathIterator.SEG_LINETO: /* Checking SEG_LINETO coordinates if they are out of the * [LOWER_BND, UPPER_BND] range. This check also handles * NaN and Infinity values. Ignoring current path segment * in case of invalid data. If segment is skipped its * endpoint (if valid) is used to begin new subpath. */ if (point[0] < UPPER_BND && point[0] > LOWER_BND && point[1] < UPPER_BND && point[1] > LOWER_BND) { if (skip) { r.beginSubpath(point[0], point[1]); subpathStarted = true; skip = false; } else { r.appendLine(point[0], point[1]); } } break; case PathIterator.SEG_QUADTO: // Quadratic curves take two points /* Checking SEG_QUADTO coordinates if they are out of the * [LOWER_BND, UPPER_BND] range. This check also handles * NaN and Infinity values. Ignoring current path segment * in case of invalid endpoints's data. Equivalent to the * SEG_LINETO if endpoint coordinates are valid but there * are invalid data amoung other coordinates */ if (point[2] < UPPER_BND && point[2] > LOWER_BND && point[3] < UPPER_BND && point[3] > LOWER_BND) { if (skip) { r.beginSubpath(point[2], point[3]); subpathStarted = true; skip = false; } else { if (point[0] < UPPER_BND && point[0] > LOWER_BND && point[1] < UPPER_BND && point[1] > LOWER_BND) { r.appendQuadratic(point[0], point[1], point[2], point[3]); } else { r.appendLine(point[2], point[3]); } } } break; case PathIterator.SEG_CUBICTO: // Cubic curves take three points /* Checking SEG_CUBICTO coordinates if they are out of the * [LOWER_BND, UPPER_BND] range. This check also handles * NaN and Infinity values. Ignoring current path segment * in case of invalid endpoints's data. Equivalent to the * SEG_LINETO if endpoint coordinates are valid but there * are invalid data amoung other coordinates */ if (point[4] < UPPER_BND && point[4] > LOWER_BND && point[5] < UPPER_BND && point[5] > LOWER_BND) { if (skip) { r.beginSubpath(point[4], point[5]); subpathStarted = true; skip = false; } else { if (point[0] < UPPER_BND && point[0] > LOWER_BND && point[1] < UPPER_BND && point[1] > LOWER_BND && point[2] < UPPER_BND && point[2] > LOWER_BND && point[3] < UPPER_BND && point[3] > LOWER_BND) { r.appendCubic(point[0], point[1], point[2], point[3], point[4], point[5]); } else { r.appendLine(point[4], point[5]); } } } break; case PathIterator.SEG_CLOSE: if (subpathStarted) { r.closedSubpath(); subpathStarted = false; pathClosed = true; } break; } pi.next(); } } try { r.endPath(); r.getAlphaBox(bbox); clip.clipBoxToBounds(bbox); if (bbox[0] >= bbox[2] || bbox[1] >= bbox[3]) { dropRasterizer(r); return null; } r.setOutputArea(bbox[0], bbox[1], bbox[2] - bbox[0], bbox[3] - bbox[1]); } catch (PRException e) { /* * This exeption is thrown from the native part of the Ductus * (only in case of a debug build) to indicate that some * segments of the path have very large coordinates. * See 4485298 for more info. */ System.err.println("DuctusRenderingEngine.getAATileGenerator: "+e); } return r; } /** * {@inheritDoc} */ @Override public AATileGenerator getAATileGenerator(double x, double y, double dx1, double dy1, double dx2, double dy2, double lw1, double lw2, Region clip, int bbox[]) { // REMIND: Deal with large coordinates! double ldx1, ldy1, ldx2, ldy2; boolean innerpgram = (lw1 > 0 && lw2 > 0); if (innerpgram) { ldx1 = dx1 * lw1; ldy1 = dy1 * lw1; ldx2 = dx2 * lw2; ldy2 = dy2 * lw2; x -= (ldx1 + ldx2) / 2.0; y -= (ldy1 + ldy2) / 2.0; dx1 += ldx1; dy1 += ldy1; dx2 += ldx2; dy2 += ldy2; if (lw1 > 1 && lw2 > 1) { // Inner parallelogram was entirely consumed by stroke... innerpgram = false; } } else { ldx1 = ldy1 = ldx2 = ldy2 = 0; } Rasterizer r = getRasterizer(); r.setUsage(Rasterizer.EOFILL); r.beginPath(); r.beginSubpath((float) x, (float) y); r.appendLine((float) (x+dx1), (float) (y+dy1)); r.appendLine((float) (x+dx1+dx2), (float) (y+dy1+dy2)); r.appendLine((float) (x+dx2), (float) (y+dy2)); r.closedSubpath(); if (innerpgram) { x += ldx1 + ldx2; y += ldy1 + ldy2; dx1 -= 2.0 * ldx1; dy1 -= 2.0 * ldy1; dx2 -= 2.0 * ldx2; dy2 -= 2.0 * ldy2; r.beginSubpath((float) x, (float) y); r.appendLine((float) (x+dx1), (float) (y+dy1)); r.appendLine((float) (x+dx1+dx2), (float) (y+dy1+dy2)); r.appendLine((float) (x+dx2), (float) (y+dy2)); r.closedSubpath(); } try { r.endPath(); r.getAlphaBox(bbox); clip.clipBoxToBounds(bbox); if (bbox[0] >= bbox[2] || bbox[1] >= bbox[3]) { dropRasterizer(r); return null; } r.setOutputArea(bbox[0], bbox[1], bbox[2] - bbox[0], bbox[3] - bbox[1]); } catch (PRException e) { /* * This exeption is thrown from the native part of the Ductus * (only in case of a debug build) to indicate that some * segments of the path have very large coordinates. * See 4485298 for more info. */ System.err.println("DuctusRenderingEngine.getAATileGenerator: "+e); } return r; } private void feedConsumer(PathConsumer consumer, PathIterator pi) { try { consumer.beginPath(); boolean pathClosed = false; float mx = 0.0f; float my = 0.0f; float point[] = new float[6]; while (!pi.isDone()) { int type = pi.currentSegment(point); if (pathClosed == true) { pathClosed = false; if (type != PathIterator.SEG_MOVETO) { // Force current point back to last moveto point consumer.beginSubpath(mx, my); } } switch (type) { case PathIterator.SEG_MOVETO: mx = point[0]; my = point[1]; consumer.beginSubpath(point[0], point[1]); break; case PathIterator.SEG_LINETO: consumer.appendLine(point[0], point[1]); break; case PathIterator.SEG_QUADTO: consumer.appendQuadratic(point[0], point[1], point[2], point[3]); break; case PathIterator.SEG_CUBICTO: consumer.appendCubic(point[0], point[1], point[2], point[3], point[4], point[5]); break; case PathIterator.SEG_CLOSE: consumer.closedSubpath(); pathClosed = true; break; } pi.next(); } consumer.endPath(); } catch (PathException e) { throw new InternalError("Unable to Stroke shape ("+ e.getMessage()+")"); } } private class FillAdapter implements PathConsumer { boolean closed; Path2D.Float path; public FillAdapter() { // Ductus only supplies float coordinates so // Path2D.Double is not necessary here. path = new Path2D.Float(Path2D.WIND_NON_ZERO); } public Shape getShape() { return path; } public void dispose() { } public PathConsumer getConsumer() { return null; } public void beginPath() {} public void beginSubpath(float x0, float y0) { if (closed) { path.closePath(); closed = false; } path.moveTo(x0, y0); } public void appendLine(float x1, float y1) { path.lineTo(x1, y1); } public void appendQuadratic(float xm, float ym, float x1, float y1) { path.quadTo(xm, ym, x1, y1); } public void appendCubic(float xm, float ym, float xn, float yn, float x1, float y1) { path.curveTo(xm, ym, xn, yn, x1, y1); } public void closedSubpath() { closed = true; } public void endPath() { if (closed) { path.closePath(); closed = false; } } public void useProxy(FastPathProducer proxy) throws PathException { proxy.sendTo(this); } public long getCPathConsumer() { return 0; } }}Lines 501–836 of 836. Previous lines
/* Checking SEG_MOVETO coordinates if they are out of the * [LOWER_BND, UPPER_BND] range. This check also handles NaN * and Infinity values. Skipping next path segment in case * of invalid data. */ if (point[0] < UPPER_BND && point[0] > LOWER_BND && point[1] < UPPER_BND && point[1] > LOWER_BND) { mx = point[0]; my = point[1]; r.beginSubpath(mx, my); subpathStarted = true; skip = false; } else { skip = true; } break; case PathIterator.SEG_LINETO: /* Checking SEG_LINETO coordinates if they are out of the * [LOWER_BND, UPPER_BND] range. This check also handles * NaN and Infinity values. Ignoring current path segment * in case of invalid data. If segment is skipped its * endpoint (if valid) is used to begin new subpath. */ if (point[0] < UPPER_BND && point[0] > LOWER_BND && point[1] < UPPER_BND && point[1] > LOWER_BND) { if (skip) { r.beginSubpath(point[0], point[1]); subpathStarted = true; skip = false; } else { r.appendLine(point[0], point[1]); } } break; case PathIterator.SEG_QUADTO: // Quadratic curves take two points /* Checking SEG_QUADTO coordinates if they are out of the * [LOWER_BND, UPPER_BND] range. This check also handles * NaN and Infinity values. Ignoring current path segment * in case of invalid endpoints's data. Equivalent to the * SEG_LINETO if endpoint coordinates are valid but there * are invalid data amoung other coordinates */ if (point[2] < UPPER_BND && point[2] > LOWER_BND && point[3] < UPPER_BND && point[3] > LOWER_BND) { if (skip) { r.beginSubpath(point[2], point[3]); subpathStarted = true; skip = false; } else { if (point[0] < UPPER_BND && point[0] > LOWER_BND && point[1] < UPPER_BND && point[1] > LOWER_BND) { r.appendQuadratic(point[0], point[1], point[2], point[3]); } else { r.appendLine(point[2], point[3]); } } } break; case PathIterator.SEG_CUBICTO: // Cubic curves take three points /* Checking SEG_CUBICTO coordinates if they are out of the * [LOWER_BND, UPPER_BND] range. This check also handles * NaN and Infinity values. Ignoring current path segment * in case of invalid endpoints's data. Equivalent to the * SEG_LINETO if endpoint coordinates are valid but there * are invalid data amoung other coordinates */ if (point[4] < UPPER_BND && point[4] > LOWER_BND && point[5] < UPPER_BND && point[5] > LOWER_BND) { if (skip) { r.beginSubpath(point[4], point[5]); subpathStarted = true; skip = false; } else { if (point[0] < UPPER_BND && point[0] > LOWER_BND && point[1] < UPPER_BND && point[1] > LOWER_BND && point[2] < UPPER_BND && point[2] > LOWER_BND && point[3] < UPPER_BND && point[3] > LOWER_BND) { r.appendCubic(point[0], point[1], point[2], point[3], point[4], point[5]); } else { r.appendLine(point[4], point[5]); } } } break; case PathIterator.SEG_CLOSE: if (subpathStarted) { r.closedSubpath(); subpathStarted = false; pathClosed = true; } break; } pi.next(); } } try { r.endPath(); r.getAlphaBox(bbox); clip.clipBoxToBounds(bbox); if (bbox[0] >= bbox[2] || bbox[1] >= bbox[3]) { dropRasterizer(r); return null; } r.setOutputArea(bbox[0], bbox[1], bbox[2] - bbox[0], bbox[3] - bbox[1]); } catch (PRException e) { /* * This exeption is thrown from the native part of the Ductus * (only in case of a debug build) to indicate that some * segments of the path have very large coordinates. * See 4485298 for more info. */ System.err.println("DuctusRenderingEngine.getAATileGenerator: "+e); } return r; } /** * {@inheritDoc} */ @Override public AATileGenerator getAATileGenerator(double x, double y, double dx1, double dy1, double dx2, double dy2, double lw1, double lw2, Region clip, int bbox[]) { // REMIND: Deal with large coordinates! double ldx1, ldy1, ldx2, ldy2; boolean innerpgram = (lw1 > 0 && lw2 > 0); if (innerpgram) { ldx1 = dx1 * lw1; ldy1 = dy1 * lw1; ldx2 = dx2 * lw2; ldy2 = dy2 * lw2; x -= (ldx1 + ldx2) / 2.0; y -= (ldy1 + ldy2) / 2.0; dx1 += ldx1; dy1 += ldy1; dx2 += ldx2; dy2 += ldy2; if (lw1 > 1 && lw2 > 1) { // Inner parallelogram was entirely consumed by stroke... innerpgram = false; } } else { ldx1 = ldy1 = ldx2 = ldy2 = 0; } Rasterizer r = getRasterizer(); r.setUsage(Rasterizer.EOFILL); r.beginPath(); r.beginSubpath((float) x, (float) y); r.appendLine((float) (x+dx1), (float) (y+dy1)); r.appendLine((float) (x+dx1+dx2), (float) (y+dy1+dy2)); r.appendLine((float) (x+dx2), (float) (y+dy2)); r.closedSubpath(); if (innerpgram) { x += ldx1 + ldx2; y += ldy1 + ldy2; dx1 -= 2.0 * ldx1; dy1 -= 2.0 * ldy1; dx2 -= 2.0 * ldx2; dy2 -= 2.0 * ldy2; r.beginSubpath((float) x, (float) y); r.appendLine((float) (x+dx1), (float) (y+dy1)); r.appendLine((float) (x+dx1+dx2), (float) (y+dy1+dy2)); r.appendLine((float) (x+dx2), (float) (y+dy2)); r.closedSubpath(); } try { r.endPath(); r.getAlphaBox(bbox); clip.clipBoxToBounds(bbox); if (bbox[0] >= bbox[2] || bbox[1] >= bbox[3]) { dropRasterizer(r); return null; } r.setOutputArea(bbox[0], bbox[1], bbox[2] - bbox[0], bbox[3] - bbox[1]); } catch (PRException e) { /* * This exeption is thrown from the native part of the Ductus * (only in case of a debug build) to indicate that some * segments of the path have very large coordinates. * See 4485298 for more info. */ System.err.println("DuctusRenderingEngine.getAATileGenerator: "+e); } return r; } private void feedConsumer(PathConsumer consumer, PathIterator pi) { try { consumer.beginPath(); boolean pathClosed = false; float mx = 0.0f; float my = 0.0f; float point[] = new float[6]; while (!pi.isDone()) { int type = pi.currentSegment(point); if (pathClosed == true) { pathClosed = false; if (type != PathIterator.SEG_MOVETO) { // Force current point back to last moveto point consumer.beginSubpath(mx, my); } } switch (type) { case PathIterator.SEG_MOVETO: mx = point[0]; my = point[1]; consumer.beginSubpath(point[0], point[1]); break; case PathIterator.SEG_LINETO: consumer.appendLine(point[0], point[1]); break; case PathIterator.SEG_QUADTO: consumer.appendQuadratic(point[0], point[1], point[2], point[3]); break; case PathIterator.SEG_CUBICTO: consumer.appendCubic(point[0], point[1], point[2], point[3], point[4], point[5]); break; case PathIterator.SEG_CLOSE: consumer.closedSubpath(); pathClosed = true; break; } pi.next(); } consumer.endPath(); } catch (PathException e) { throw new InternalError("Unable to Stroke shape ("+ e.getMessage()+")"); } } private class FillAdapter implements PathConsumer { boolean closed; Path2D.Float path; public FillAdapter() { // Ductus only supplies float coordinates so // Path2D.Double is not necessary here. path = new Path2D.Float(Path2D.WIND_NON_ZERO); } public Shape getShape() { return path; } public void dispose() { } public PathConsumer getConsumer() { return null; } public void beginPath() {} public void beginSubpath(float x0, float y0) { if (closed) { path.closePath(); closed = false; } path.moveTo(x0, y0); } public void appendLine(float x1, float y1) { path.lineTo(x1, y1); } public void appendQuadratic(float xm, float ym, float x1, float y1) { path.quadTo(xm, ym, x1, y1); } public void appendCubic(float xm, float ym, float xn, float yn, float x1, float y1) { path.curveTo(xm, ym, xn, yn, x1, y1); } public void closedSubpath() { closed = true; } public void endPath() { if (closed) { path.closePath(); closed = false; } } public void useProxy(FastPathProducer proxy) throws PathException { proxy.sendTo(this); } public long getCPathConsumer() { return 0; } } }