Path: blob/master/src/java.desktop/macosx/classes/sun/java2d/CRenderer.java
41152 views
/*1* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.java2d;2627import java.awt.*;28import java.awt.geom.*;29import java.awt.image.*;30import java.nio.*;3132import sun.awt.image.*;33import sun.java2d.loops.*;34import sun.java2d.pipe.*;35import sun.lwawt.macosx.*;3637public class CRenderer implements PixelDrawPipe, PixelFillPipe, ShapeDrawPipe, DrawImagePipe {38static native void init();3940// cache of the runtime options41static {42init(); // initialize coordinate tables for shapes43}4445native void doLine(SurfaceData sData, float x1, float y1, float x2, float y2);4647public void drawLine(SunGraphics2D sg2d, int x1, int y1, int x2, int y2) {48drawLine(sg2d, (float) x1, (float) y1, (float) x2, (float) y2);49}5051Line2D lineToShape;5253public void drawLine(SunGraphics2D sg2d, float x1, float y1, float x2, float y2) {54OSXSurfaceData surfaceData = (OSXSurfaceData) sg2d.getSurfaceData();55if ((sg2d.strokeState != SunGraphics2D.STROKE_CUSTOM) && (OSXSurfaceData.IsSimpleColor(sg2d.paint))) {56surfaceData.doLine(this, sg2d, x1, y1, x2, y2);57} else {58if (lineToShape == null) {59synchronized (this) {60if (lineToShape == null) {61lineToShape = new Line2D.Float();62}63}64}65synchronized (lineToShape) {66lineToShape.setLine(x1, y1, x2, y2);67drawfillShape(sg2d, sg2d.stroke.createStrokedShape(lineToShape), true, true);68}69}70}7172native void doRect(SurfaceData sData, float x, float y, float width, float height, boolean isfill);7374public void drawRect(SunGraphics2D sg2d, int x, int y, int width, int height) {75drawRect(sg2d, (float) x, (float) y, (float) width, (float) height);76}7778Rectangle2D rectToShape;7980public void drawRect(SunGraphics2D sg2d, float x, float y, float width, float height) {81if ((width < 0) || (height < 0)) return;8283OSXSurfaceData surfaceData = (OSXSurfaceData) sg2d.getSurfaceData();84if ((sg2d.strokeState != SunGraphics2D.STROKE_CUSTOM) && (OSXSurfaceData.IsSimpleColor(sg2d.paint))) {85surfaceData.doRect(this, sg2d, x, y, width, height, false);86} else {87if (rectToShape == null) {88synchronized (this) {89if (rectToShape == null) {90rectToShape = new Rectangle2D.Float();91}92}93}94synchronized (rectToShape) {95rectToShape.setRect(x, y, width, height);96drawfillShape(sg2d, sg2d.stroke.createStrokedShape(rectToShape), true, true);97}98}99}100101public void fillRect(SunGraphics2D sg2d, int x, int y, int width, int height) {102fillRect(sg2d, (float) x, (float) y, (float) width, (float) height);103}104105public void fillRect(SunGraphics2D sg2d, float x, float y, float width, float height) {106if ((width >= 0) && (height >= 0)) {107OSXSurfaceData surfaceData = (OSXSurfaceData) sg2d.getSurfaceData();108surfaceData.doRect(this, sg2d, x, y, width, height, true);109}110}111112native void doRoundRect(SurfaceData sData, float x, float y, float width, float height, float arcW, float arcH, boolean isfill);113114public void drawRoundRect(SunGraphics2D sg2d, int x, int y, int width, int height, int arcWidth, int arcHeight) {115drawRoundRect(sg2d, (float) x, (float) y, (float) width, (float) height, (float) arcWidth, (float) arcHeight);116}117118RoundRectangle2D roundrectToShape;119120public void drawRoundRect(SunGraphics2D sg2d, float x, float y, float width, float height, float arcWidth, float arcHeight) {121if ((width < 0) || (height < 0)) return;122123OSXSurfaceData surfaceData = (OSXSurfaceData) sg2d.getSurfaceData();124if ((sg2d.strokeState != SunGraphics2D.STROKE_CUSTOM) && (OSXSurfaceData.IsSimpleColor(sg2d.paint))) {125surfaceData.doRoundRect(this, sg2d, x, y, width, height, arcWidth, arcHeight, false);126} else {127if (roundrectToShape == null) {128synchronized (this) {129if (roundrectToShape == null) {130roundrectToShape = new RoundRectangle2D.Float();131}132}133}134synchronized (roundrectToShape) {135roundrectToShape.setRoundRect(x, y, width, height, arcWidth, arcHeight);136drawfillShape(sg2d, sg2d.stroke.createStrokedShape(roundrectToShape), true, true);137}138}139}140141public void fillRoundRect(SunGraphics2D sg2d, int x, int y, int width, int height, int arcWidth, int arcHeight) {142fillRoundRect(sg2d, (float) x, (float) y, (float) width, (float) height, (float) arcWidth, (float) arcHeight);143}144145public void fillRoundRect(SunGraphics2D sg2d, float x, float y, float width, float height, float arcWidth, float arcHeight) {146if ((width < 0) || (height < 0)) return;147OSXSurfaceData surfaceData = (OSXSurfaceData) sg2d.getSurfaceData();148surfaceData.doRoundRect(this, sg2d, x, y, width, height, arcWidth, arcHeight, true);149}150151native void doOval(SurfaceData sData, float x, float y, float width, float height, boolean isfill);152153public void drawOval(SunGraphics2D sg2d, int x, int y, int width, int height) {154drawOval(sg2d, (float) x, (float) y, (float) width, (float) height);155}156157Ellipse2D ovalToShape;158159public void drawOval(SunGraphics2D sg2d, float x, float y, float width, float height) {160if ((width < 0) || (height < 0)) return;161162OSXSurfaceData surfaceData = (OSXSurfaceData) sg2d.getSurfaceData();163if ((sg2d.strokeState != SunGraphics2D.STROKE_CUSTOM) && (OSXSurfaceData.IsSimpleColor(sg2d.paint))) {164surfaceData.doOval(this, sg2d, x, y, width, height, false);165} else {166if (ovalToShape == null) {167synchronized (this) {168if (ovalToShape == null) {169ovalToShape = new Ellipse2D.Float();170}171}172}173synchronized (ovalToShape) {174ovalToShape.setFrame(x, y, width, height);175drawfillShape(sg2d, sg2d.stroke.createStrokedShape(ovalToShape), true, true);176}177}178}179180public void fillOval(SunGraphics2D sg2d, int x, int y, int width, int height) {181fillOval(sg2d, (float) x, (float) y, (float) width, (float) height);182}183184public void fillOval(SunGraphics2D sg2d, float x, float y, float width, float height) {185if ((width < 0) || (height < 0)) return;186OSXSurfaceData surfaceData = (OSXSurfaceData) sg2d.getSurfaceData();187surfaceData.doOval(this, sg2d, x, y, width, height, true);188}189190native void doArc(SurfaceData sData, float x, float y, float width, float height, float angleStart, float angleExtent, int type, boolean isfill);191192public void drawArc(SunGraphics2D sg2d, int x, int y, int width, int height, int startAngle, int arcAngle) {193drawArc(sg2d, x, y, width, height, startAngle, arcAngle, Arc2D.OPEN);194}195196Arc2D arcToShape;197198public void drawArc(SunGraphics2D sg2d, float x, float y, float width, float height, float startAngle, float arcAngle, int type) {199if ((width < 0) || (height < 0)) return;200201OSXSurfaceData surfaceData = (OSXSurfaceData) sg2d.getSurfaceData();202if ((sg2d.strokeState != SunGraphics2D.STROKE_CUSTOM) && (OSXSurfaceData.IsSimpleColor(sg2d.paint))) {203surfaceData.doArc(this, sg2d, x, y, width, height, startAngle, arcAngle, type, false);204} else {205if (arcToShape == null) {206synchronized (this) {207if (arcToShape == null) {208arcToShape = new Arc2D.Float();209}210}211}212synchronized (arcToShape) {213arcToShape.setArc(x, y, width, height, startAngle, arcAngle, type);214drawfillShape(sg2d, sg2d.stroke.createStrokedShape(arcToShape), true, true);215}216}217}218219public void fillArc(SunGraphics2D sg2d, int x, int y, int width, int height, int startAngle, int arcAngle) {220fillArc(sg2d, x, y, width, height, startAngle, arcAngle, Arc2D.PIE);221}222223public void fillArc(SunGraphics2D sg2d, float x, float y, float width, float height, float startAngle, float arcAngle, int type) {224if ((width < 0) || (height < 0)) return;225226OSXSurfaceData surfaceData = (OSXSurfaceData) sg2d.getSurfaceData();227surfaceData.doArc(this, sg2d, x, y, width, height, startAngle, arcAngle, type, true);228}229230native void doPoly(SurfaceData sData, int[] xpoints, int[] ypoints, int npoints, boolean ispolygon, boolean isfill);231232public void drawPolyline(SunGraphics2D sg2d, int[] xpoints, int[] ypoints, int npoints) {233OSXSurfaceData surfaceData = (OSXSurfaceData) sg2d.getSurfaceData();234if ((sg2d.strokeState != SunGraphics2D.STROKE_CUSTOM) && (OSXSurfaceData.IsSimpleColor(sg2d.paint))) {235surfaceData.doPolygon(this, sg2d, xpoints, ypoints, npoints, false, false);236} else {237GeneralPath polyToShape = new GeneralPath();238polyToShape.moveTo(xpoints[0], ypoints[0]);239for (int i = 1; i < npoints; i++) {240polyToShape.lineTo(xpoints[i], ypoints[i]);241}242drawfillShape(sg2d, sg2d.stroke.createStrokedShape(polyToShape), true, true);243}244}245246public void drawPolygon(SunGraphics2D sg2d, int[] xpoints, int[] ypoints, int npoints) {247OSXSurfaceData surfaceData = (OSXSurfaceData) sg2d.getSurfaceData();248if ((sg2d.strokeState != SunGraphics2D.STROKE_CUSTOM) && (OSXSurfaceData.IsSimpleColor(sg2d.paint))) {249surfaceData.doPolygon(this, sg2d, xpoints, ypoints, npoints, true, false);250} else {251GeneralPath polyToShape = new GeneralPath();252polyToShape.moveTo(xpoints[0], ypoints[0]);253for (int i = 1; i < npoints; i++) {254polyToShape.lineTo(xpoints[i], ypoints[i]);255}256polyToShape.lineTo(xpoints[0], ypoints[0]);257drawfillShape(sg2d, sg2d.stroke.createStrokedShape(polyToShape), true, true);258}259}260261public void fillPolygon(SunGraphics2D sg2d, int[] xpoints, int[] ypoints, int npoints) {262OSXSurfaceData surfaceData = (OSXSurfaceData) sg2d.getSurfaceData();263surfaceData.doPolygon(this, sg2d, xpoints, ypoints, npoints, true, true);264}265266native void doShape(SurfaceData sData, int length, FloatBuffer coordinates, IntBuffer types, int windingRule, boolean isfill, boolean shouldApplyOffset);267268void drawfillShape(SunGraphics2D sg2d, Shape s, boolean isfill, boolean shouldApplyOffset) {269if (s == null) { throw new NullPointerException(); }270271OSXSurfaceData surfaceData = (OSXSurfaceData) sg2d.getSurfaceData();272// TODO:273boolean sOptimizeShapes = true;274if (sOptimizeShapes && OSXSurfaceData.IsSimpleColor(sg2d.paint)) {275if (s instanceof Rectangle2D) {276Rectangle2D rectangle = (Rectangle2D) s;277278float x = (float) rectangle.getX();279float y = (float) rectangle.getY();280float w = (float) rectangle.getWidth();281float h = (float) rectangle.getHeight();282if (isfill) {283fillRect(sg2d, x, y, w, h);284} else {285drawRect(sg2d, x, y, w, h);286}287} else if (s instanceof Ellipse2D) {288Ellipse2D ellipse = (Ellipse2D) s;289290float x = (float) ellipse.getX();291float y = (float) ellipse.getY();292float w = (float) ellipse.getWidth();293float h = (float) ellipse.getHeight();294295if (isfill) {296fillOval(sg2d, x, y, w, h);297} else {298drawOval(sg2d, x, y, w, h);299}300} else if (s instanceof Arc2D) {301Arc2D arc = (Arc2D) s;302303float x = (float) arc.getX();304float y = (float) arc.getY();305float w = (float) arc.getWidth();306float h = (float) arc.getHeight();307float as = (float) arc.getAngleStart();308float ae = (float) arc.getAngleExtent();309310if (isfill) {311fillArc(sg2d, x, y, w, h, as, ae, arc.getArcType());312} else {313drawArc(sg2d, x, y, w, h, as, ae, arc.getArcType());314}315} else if (s instanceof RoundRectangle2D) {316RoundRectangle2D roundrect = (RoundRectangle2D) s;317318float x = (float) roundrect.getX();319float y = (float) roundrect.getY();320float w = (float) roundrect.getWidth();321float h = (float) roundrect.getHeight();322float aw = (float) roundrect.getArcWidth();323float ah = (float) roundrect.getArcHeight();324325if (isfill) {326fillRoundRect(sg2d, x, y, w, h, aw, ah);327} else {328drawRoundRect(sg2d, x, y, w, h, aw, ah);329}330} else if (s instanceof Line2D) {331Line2D line = (Line2D) s;332333float x1 = (float) line.getX1();334float y1 = (float) line.getY1();335float x2 = (float) line.getX2();336float y2 = (float) line.getY2();337338drawLine(sg2d, x1, y1, x2, y2);339} else if (s instanceof Point2D) {340Point2D point = (Point2D) s;341342float x = (float) point.getX();343float y = (float) point.getY();344345drawLine(sg2d, x, y, x, y);346} else {347GeneralPath gp;348349if (s instanceof GeneralPath) {350gp = (GeneralPath) s;351} else {352gp = new GeneralPath(s);353}354355PathIterator pi = gp.getPathIterator(null);356if (pi.isDone() == false) {357surfaceData.drawfillShape(this, sg2d, gp, isfill, shouldApplyOffset);358}359}360} else {361GeneralPath gp;362363if (s instanceof GeneralPath) {364gp = (GeneralPath) s;365} else {366gp = new GeneralPath(s);367}368369PathIterator pi = gp.getPathIterator(null);370if (pi.isDone() == false) {371surfaceData.drawfillShape(this, sg2d, gp, isfill, shouldApplyOffset);372}373}374}375376public void draw(SunGraphics2D sg2d, Shape s) {377OSXSurfaceData surfaceData = (OSXSurfaceData) sg2d.getSurfaceData();378if ((sg2d.strokeState != SunGraphics2D.STROKE_CUSTOM) && (OSXSurfaceData.IsSimpleColor(sg2d.paint))) {379drawfillShape(sg2d, s, false, true);380} else {381drawfillShape(sg2d, sg2d.stroke.createStrokedShape(s), true, true);382}383}384385public void fill(SunGraphics2D sg2d, Shape s) {386drawfillShape(sg2d, s, true, false);387}388389native void doImage(SurfaceData sData, SurfaceData img, boolean fliph, boolean flipv, int w, int h, int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh);390391// Copy img to scaled sg2d @ x,y with width height392public boolean scaleImage(SunGraphics2D sg2d, Image img, int x, int y, int width, int height, Color bgColor) {393OSXSurfaceData surfaceData = (OSXSurfaceData) sg2d.getSurfaceData();394395int sx = 0;396int sy = 0;397int iw = img.getWidth(null);398int ih = img.getHeight(null);399400return scaleImage(sg2d, img, x, y, x + width, y + height, sx, sy, sx + iw, sy + ih, bgColor);401}402403// Copy img, clipped to sx1, sy1 by sx2, sy2 to dx1, dy2 by dx2, dy2404public boolean scaleImage(SunGraphics2D sg2d, Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgColor) {405406// System.err.println("scaleImage");407// System.err.println(" sx1="+sx1+", sy1="+sy1+", sx2="+sx2+", sy2="+sy2);408// System.err.println(" dx1="+dx1+", dy1="+dy1+", dx2="+dx2+", dy2="+dy2);409410int srcW, srcH, dstW, dstH;411int srcX, srcY, dstX, dstY;412boolean srcWidthFlip = false;413boolean srcHeightFlip = false;414boolean dstWidthFlip = false;415boolean dstHeightFlip = false;416417if (sx2 > sx1) {418srcW = sx2 - sx1;419srcX = sx1;420} else {421srcWidthFlip = true;422srcW = sx1 - sx2;423srcX = sx2;424}425if (sy2 > sy1) {426srcH = sy2 - sy1;427srcY = sy1;428} else {429srcHeightFlip = true;430srcH = sy1 - sy2;431srcY = sy2;432}433if (dx2 > dx1) {434dstW = dx2 - dx1;435dstX = dx1;436} else {437dstW = dx1 - dx2;438dstWidthFlip = true;439dstX = dx2;440}441if (dy2 > dy1) {442dstH = dy2 - dy1;443dstY = dy1;444} else {445dstH = dy1 - dy2;446dstHeightFlip = true;447dstY = dy2;448}449if (srcW <= 0 || srcH <= 0) { return true; }450451boolean flipv = (srcHeightFlip != dstHeightFlip);452boolean fliph = (srcWidthFlip != dstWidthFlip);453454return blitImage(sg2d, img, fliph, flipv, srcX, srcY, srcW, srcH, dstX, dstY, dstW, dstH, bgColor);455}456457protected boolean blitImage(SunGraphics2D sg2d, Image img, boolean fliph, boolean flipv, int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, Color bgColor) {458CPrinterSurfaceData surfaceData = (CPrinterSurfaceData)sg2d.getSurfaceData();459OSXOffScreenSurfaceData imgSurfaceData = OSXOffScreenSurfaceData.createNewSurface((BufferedImage)img);460surfaceData.blitImage(this, sg2d, imgSurfaceData, fliph, flipv, sx, sy, sw, sh, dx, dy, dw, dh, bgColor);461return true;462}463464// Copy img to sg2d @ x, y465protected boolean copyImage(SunGraphics2D sg2d, Image img, int dx, int dy, Color bgColor) {466if (img == null) { return true; }467468int sx = 0;469int sy = 0;470int width = img.getWidth(null);471int height = img.getHeight(null);472473return blitImage(sg2d, img, false, false, sx, sy, width, height, dx, dy, width, height, bgColor);474}475476// Copy img, clipped to sx, sy with width, height to sg2d @ dx, dy477protected boolean copyImage(SunGraphics2D sg2d, Image img, int dx, int dy, int sx, int sy, int width, int height, Color bgColor) {478return blitImage(sg2d, img, false, false, sx, sy, width, height, dx, dy, width, height, bgColor);479}480481protected void transformImage(SunGraphics2D sg2d, Image img, int x, int y, BufferedImageOp op, AffineTransform xf, Color bgColor) {482if (img != null) {483int iw = img.getWidth(null);484int ih = img.getHeight(null);485486if ((op != null) && (img instanceof BufferedImage)) {487if (((BufferedImage) img).getType() == BufferedImage.TYPE_CUSTOM) {488// BufferedImageOp can not handle custom images489BufferedImage dest = null;490dest = new BufferedImage(iw, ih, BufferedImage.TYPE_INT_ARGB_PRE);491Graphics g = dest.createGraphics();492g.drawImage(img, 0, 0, null);493g.dispose();494img = op.filter(dest, null);495} else {496// sun.awt.image.BufImgSurfaceData.createData((BufferedImage)img).finishLazyDrawing();497img = op.filter((BufferedImage) img, null);498}499500iw = img.getWidth(null);501ih = img.getHeight(null);502}503504if (xf != null) {505AffineTransform reset = sg2d.getTransform();506sg2d.transform(xf);507scaleImage(sg2d, img, x, y, x + iw, y + ih, 0, 0, iw, ih, bgColor);508sg2d.setTransform(reset);509} else {510scaleImage(sg2d, img, x, y, x + iw, y + ih, 0, 0, iw, ih, bgColor);511}512} else {513throw new NullPointerException();514}515}516517// copied from DrawImage.java518protected boolean imageReady(sun.awt.image.ToolkitImage sunimg, ImageObserver observer) {519if (sunimg.hasError()) {520if (observer != null) {521observer.imageUpdate(sunimg, ImageObserver.ERROR | ImageObserver.ABORT, -1, -1, -1, -1);522}523return false;524}525return true;526}527528// copied from DrawImage.java529public boolean copyImage(SunGraphics2D sg2d, Image img, int x, int y, Color bgColor, ImageObserver observer) {530if (img == null) { throw new NullPointerException(); }531532if (!(img instanceof sun.awt.image.ToolkitImage)) { return copyImage(sg2d, img, x, y, bgColor); }533534sun.awt.image.ToolkitImage sunimg = (sun.awt.image.ToolkitImage) img;535if (!imageReady(sunimg, observer)) { return false; }536ImageRepresentation ir = sunimg.getImageRep();537return ir.drawToBufImage(sg2d, sunimg, x, y, bgColor, observer);538}539540// copied from DrawImage.java541public boolean copyImage(SunGraphics2D sg2d, Image img, int dx, int dy, int sx, int sy, int width, int height, Color bgColor, ImageObserver observer) {542if (img == null) { throw new NullPointerException(); }543544if (!(img instanceof sun.awt.image.ToolkitImage)) { return copyImage(sg2d, img, dx, dy, sx, sy, width, height, bgColor); }545546sun.awt.image.ToolkitImage sunimg = (sun.awt.image.ToolkitImage) img;547if (!imageReady(sunimg, observer)) { return false; }548ImageRepresentation ir = sunimg.getImageRep();549return ir.drawToBufImage(sg2d, sunimg, dx, dy, (dx + width), (dy + height), sx, sy, (sx + width), (sy + height), null, observer);550}551552// copied from DrawImage.java553public boolean scaleImage(SunGraphics2D sg2d, Image img, int x, int y, int width, int height, Color bgColor, ImageObserver observer) {554if (img == null) { throw new NullPointerException(); }555556if (!(img instanceof sun.awt.image.ToolkitImage)) { return scaleImage(sg2d, img, x, y, width, height, bgColor); }557558sun.awt.image.ToolkitImage sunimg = (sun.awt.image.ToolkitImage) img;559if (!imageReady(sunimg, observer)) { return false; }560ImageRepresentation ir = sunimg.getImageRep();561return ir.drawToBufImage(sg2d, sunimg, x, y, width, height, bgColor, observer);562}563564// copied from DrawImage.java565public boolean scaleImage(SunGraphics2D sg2d, Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgColor, ImageObserver observer) {566if (img == null) { throw new NullPointerException(); }567568if (!(img instanceof sun.awt.image.ToolkitImage)) { return scaleImage(sg2d, img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, bgColor); }569570sun.awt.image.ToolkitImage sunimg = (sun.awt.image.ToolkitImage) img;571if (!imageReady(sunimg, observer)) { return false; }572ImageRepresentation ir = sunimg.getImageRep();573return ir.drawToBufImage(sg2d, sunimg, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, bgColor, observer);574}575576// copied from DrawImage.java577public boolean transformImage(SunGraphics2D sg2d, Image img, AffineTransform atfm, ImageObserver observer) {578if (img == null) { throw new NullPointerException(); }579580if (!(img instanceof sun.awt.image.ToolkitImage)) {581transformImage(sg2d, img, 0, 0, null, atfm, null);582return true;583}584585sun.awt.image.ToolkitImage sunimg = (sun.awt.image.ToolkitImage) img;586if (!imageReady(sunimg, observer)) { return false; }587ImageRepresentation ir = sunimg.getImageRep();588return ir.drawToBufImage(sg2d, sunimg, atfm, observer);589}590591// copied from DrawImage.java592public void transformImage(SunGraphics2D sg2d, BufferedImage img, BufferedImageOp op, int x, int y) {593if (img != null) {594transformImage(sg2d, img, x, y, op, null, null);595} else {596throw new NullPointerException();597}598}599600public CRenderer traceWrap() {601return new Tracer();602}603604public static class Tracer extends CRenderer {605void doLine(SurfaceData sData, float x1, float y1, float x2, float y2) {606GraphicsPrimitive.tracePrimitive("QuartzLine");607super.doLine(sData, x1, y1, x2, y2);608}609610void doRect(SurfaceData sData, float x, float y, float width, float height, boolean isfill) {611GraphicsPrimitive.tracePrimitive("QuartzRect");612super.doRect(sData, x, y, width, height, isfill);613}614615void doRoundRect(SurfaceData sData, float x, float y, float width, float height, float arcW, float arcH, boolean isfill) {616GraphicsPrimitive.tracePrimitive("QuartzRoundRect");617super.doRoundRect(sData, x, y, width, height, arcW, arcH, isfill);618}619620void doOval(SurfaceData sData, float x, float y, float width, float height, boolean isfill) {621GraphicsPrimitive.tracePrimitive("QuartzOval");622super.doOval(sData, x, y, width, height, isfill);623}624625void doArc(SurfaceData sData, float x, float y, float width, float height, float angleStart, float angleExtent, int type, boolean isfill) {626GraphicsPrimitive.tracePrimitive("QuartzArc");627super.doArc(sData, x, y, width, height, angleStart, angleExtent, type, isfill);628}629630void doPoly(SurfaceData sData, int[] xpoints, int[] ypoints, int npoints, boolean ispolygon, boolean isfill) {631GraphicsPrimitive.tracePrimitive("QuartzDoPoly");632super.doPoly(sData, xpoints, ypoints, npoints, ispolygon, isfill);633}634635void doShape(SurfaceData sData, int length, FloatBuffer coordinates, IntBuffer types, int windingRule, boolean isfill, boolean shouldApplyOffset) {636GraphicsPrimitive.tracePrimitive("QuartzFillOrDrawShape");637super.doShape(sData, length, coordinates, types, windingRule, isfill, shouldApplyOffset);638}639640void doImage(SurfaceData sData, SurfaceData img, boolean fliph, boolean flipv, int w, int h, int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh) {641GraphicsPrimitive.tracePrimitive("QuartzDrawImage");642super.doImage(sData, img, fliph, flipv, w, h, sx, sy, sw, sh, dx, dy, dw, dh);643}644}645}646647648