src/solaris/classes/sun/java2d/xr/XRRenderer.java

Print this page

        

*** 51,64 **** --- 51,69 ---- */ public class XRRenderer implements PixelDrawPipe, PixelFillPipe, ShapeDrawPipe { XRDrawHandler drawHandler; MaskTileManager tileManager; + XRDrawLine lineGen; + GrowableRectArray rectBuffer; public XRRenderer(MaskTileManager tileManager) { this.tileManager = tileManager; + this.rectBuffer = tileManager.getMainTile().getRects(); + this.drawHandler = new XRDrawHandler(); + this.lineGen = new XRDrawLine(); } /** * Common validate method, used by all XRRender functions to validate the * destination context.
*** 75,98 **** int transX1 = Region.clipAdd(x1, sg2d.transX); int transY1 = Region.clipAdd(y1, sg2d.transY); int transX2 = Region.clipAdd(x2, sg2d.transX); int transY2 = Region.clipAdd(y2, sg2d.transY); - // Non clipped fast path - if (compClip.contains(transX1, transY1) - && compClip.contains(transX2, transY2)) { SunToolkit.awtLock(); try { validateSurface(sg2d); ! tileManager.addLine(transX1, transY1, transX2, transY2); tileManager.fillMask((XRSurfaceData) sg2d.surfaceData); } finally { SunToolkit.awtUnlock(); } - } else { - draw(sg2d, new Line2D.Float(x1, y1, x2, y2)); - } } public void drawRect(SunGraphics2D sg2d, int x, int y, int width, int height) { draw(sg2d, new Rectangle2D.Float(x, y, width, height)); --- 80,99 ---- int transX1 = Region.clipAdd(x1, sg2d.transX); int transY1 = Region.clipAdd(y1, sg2d.transY); int transX2 = Region.clipAdd(x2, sg2d.transX); int transY2 = Region.clipAdd(y2, sg2d.transY); SunToolkit.awtLock(); try { validateSurface(sg2d); ! lineGen.rasterizeLine(rectBuffer, transX1, transY1, ! transX2, transY2, compClip.getLoX(), compClip.getLoY(), ! compClip.getHiX(), compClip.getHiY(), true, true); tileManager.fillMask((XRSurfaceData) sg2d.surfaceData); } finally { SunToolkit.awtUnlock(); } } public void drawRect(SunGraphics2D sg2d, int x, int y, int width, int height) { draw(sg2d, new Rectangle2D.Float(x, y, width, height));
*** 146,156 **** } SunToolkit.awtLock(); try { validateSurface(sg2d); ! tileManager.addRect(x, y, width, height); tileManager.fillMask((XRSurfaceData) sg2d.surfaceData); } finally { SunToolkit.awtUnlock(); } } --- 147,157 ---- } SunToolkit.awtLock(); try { validateSurface(sg2d); ! rectBuffer.pushRectValues(x, y, width, height); tileManager.fillMask((XRSurfaceData) sg2d.surfaceData); } finally { SunToolkit.awtUnlock(); } }
*** 197,211 **** --- 198,214 ---- fill(sg2d, new Arc2D.Float(x, y, width, height, startAngle, arcAngle, Arc2D.PIE)); } private class XRDrawHandler extends ProcessPath.DrawHandler { + DirtyRegion region; XRDrawHandler() { // these are bogus values; the caller will use validate() // to ensure that they are set properly prior to each usage super(0, 0, 0, 0); + this.region = new DirtyRegion(); } /** * This method needs to be called prior to each draw/fillPath() * operation to ensure the clip bounds are up to date.
*** 216,234 **** clip.getHiX(), clip.getHiY(), sg2d.strokeHint); validateSurface(sg2d); } public void drawLine(int x1, int y1, int x2, int y2) { ! tileManager.addLine(x1, y1, x2, y2); } public void drawPixel(int x, int y) { ! tileManager.addRect(x, y, 1, 1); } public void drawScanline(int x1, int x2, int y) { ! tileManager.addRect(x1, y, x2 - x1 + 1, 1); } } protected void drawPath(SunGraphics2D sg2d, Path2D.Float p2df, int transx, int transy) { --- 219,254 ---- clip.getHiX(), clip.getHiY(), sg2d.strokeHint); validateSurface(sg2d); } public void drawLine(int x1, int y1, int x2, int y2) { ! region.setDirtyLineRegion(x1, y1, x2, y2); ! int xDiff = region.x2 - region.x; ! int yDiff = region.y2 - region.y; ! ! if (xDiff == 0 || yDiff == 0) { ! // horizontal / diagonal lines can be represented by a single ! // rectangle ! rectBuffer.pushRectValues(region.x, region.y, region.x2 - region.x ! + 1, region.y2 - region.y + 1); ! } else if (xDiff == 1 && yDiff == 1) { ! // fast path for pattern commonly generated by ! // ProcessPath.DrawHandler ! rectBuffer.pushRectValues(x1, y1, 1, 1); ! rectBuffer.pushRectValues(x2, y2, 1, 1); ! } else { ! lineGen.rasterizeLine(rectBuffer, x1, y1, x2, y2, 0, 0, ! 0, 0, false, false); ! } } public void drawPixel(int x, int y) { ! rectBuffer.pushRectValues(x, y, 1, 1); } public void drawScanline(int x1, int x2, int y) { ! rectBuffer.pushRectValues(x1, y, x2 - x1 + 1, 1); } } protected void drawPath(SunGraphics2D sg2d, Path2D.Float p2df, int transx, int transy) {
*** 261,271 **** SunToolkit.awtLock(); try { validateSurface(sg2d); int[] spanBox = new int[4]; while (si.nextSpan(spanBox)) { ! tileManager.addRect(spanBox[0] + transx, spanBox[1] + transy, spanBox[2] - spanBox[0], spanBox[3] - spanBox[1]); } tileManager.fillMask(((XRSurfaceData) sg2d.surfaceData)); --- 281,291 ---- SunToolkit.awtLock(); try { validateSurface(sg2d); int[] spanBox = new int[4]; while (si.nextSpan(spanBox)) { ! rectBuffer.pushRectValues(spanBox[0] + transx, spanBox[1] + transy, spanBox[2] - spanBox[0], spanBox[3] - spanBox[1]); } tileManager.fillMask(((XRSurfaceData) sg2d.surfaceData));