0N/A/*
4749N/A * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage sun.java2d.windows;
0N/A
0N/Aimport java.awt.Composite;
0N/Aimport java.awt.Shape;
0N/Aimport java.awt.geom.Path2D;
0N/Aimport java.awt.geom.PathIterator;
4749N/Aimport sun.java2d.InvalidPipeException;
0N/Aimport sun.java2d.SunGraphics2D;
0N/Aimport sun.java2d.SurfaceData;
0N/Aimport sun.java2d.pipe.Region;
0N/Aimport sun.java2d.pipe.PixelDrawPipe;
0N/Aimport sun.java2d.pipe.PixelFillPipe;
0N/Aimport sun.java2d.pipe.ShapeDrawPipe;
0N/Aimport sun.java2d.pipe.SpanIterator;
0N/Aimport sun.java2d.pipe.ShapeSpanIterator;
0N/Aimport sun.java2d.pipe.LoopPipe;
0N/Aimport sun.java2d.loops.GraphicsPrimitive;
0N/A
0N/Apublic class GDIRenderer implements
0N/A PixelDrawPipe,
0N/A PixelFillPipe,
0N/A ShapeDrawPipe
0N/A{
4749N/A native void doDrawLine(GDIWindowSurfaceData sData,
0N/A Region clip, Composite comp, int color,
0N/A int x1, int y1, int x2, int y2);
0N/A
0N/A public void drawLine(SunGraphics2D sg2d,
0N/A int x1, int y1, int x2, int y2)
0N/A {
0N/A int transx = sg2d.transX;
0N/A int transy = sg2d.transY;
4749N/A try {
4749N/A doDrawLine((GDIWindowSurfaceData)sg2d.surfaceData,
4749N/A sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
4749N/A x1+transx, y1+transy, x2+transx, y2+transy);
4749N/A } catch (ClassCastException e) {
4749N/A throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
4749N/A }
0N/A }
0N/A
4749N/A native void doDrawRect(GDIWindowSurfaceData sData,
0N/A Region clip, Composite comp, int color,
0N/A int x, int y, int w, int h);
0N/A
0N/A public void drawRect(SunGraphics2D sg2d,
0N/A int x, int y, int width, int height)
0N/A {
4749N/A try {
4749N/A doDrawRect((GDIWindowSurfaceData)sg2d.surfaceData,
4749N/A sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
4749N/A x+sg2d.transX, y+sg2d.transY, width, height);
4749N/A } catch (ClassCastException e) {
4749N/A throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
4749N/A }
0N/A }
0N/A
4749N/A native void doDrawRoundRect(GDIWindowSurfaceData sData,
0N/A Region clip, Composite comp, int color,
0N/A int x, int y, int w, int h,
0N/A int arcW, int arcH);
0N/A
0N/A public void drawRoundRect(SunGraphics2D sg2d,
0N/A int x, int y, int width, int height,
0N/A int arcWidth, int arcHeight)
0N/A {
4749N/A try {
4749N/A doDrawRoundRect((GDIWindowSurfaceData)sg2d.surfaceData,
4749N/A sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
4749N/A x+sg2d.transX, y+sg2d.transY, width, height,
4749N/A arcWidth, arcHeight);
4749N/A } catch (ClassCastException e) {
4749N/A throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
4749N/A }
0N/A }
0N/A
4749N/A native void doDrawOval(GDIWindowSurfaceData sData,
0N/A Region clip, Composite comp, int color,
0N/A int x, int y, int w, int h);
0N/A
0N/A public void drawOval(SunGraphics2D sg2d,
0N/A int x, int y, int width, int height)
0N/A {
4749N/A try {
4749N/A doDrawOval((GDIWindowSurfaceData)sg2d.surfaceData,
4749N/A sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
4749N/A x+sg2d.transX, y+sg2d.transY, width, height);
4749N/A } catch (ClassCastException e) {
4749N/A throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
4749N/A }
0N/A }
0N/A
4749N/A native void doDrawArc(GDIWindowSurfaceData sData,
0N/A Region clip, Composite comp, int color,
0N/A int x, int y, int w, int h,
0N/A int angleStart, int angleExtent);
0N/A
0N/A public void drawArc(SunGraphics2D sg2d,
0N/A int x, int y, int width, int height,
0N/A int startAngle, int arcAngle)
0N/A {
4749N/A try {
4749N/A doDrawArc((GDIWindowSurfaceData)sg2d.surfaceData,
4749N/A sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
4749N/A x+sg2d.transX, y+sg2d.transY, width, height,
4749N/A startAngle, arcAngle);
4749N/A } catch (ClassCastException e) {
4749N/A throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
4749N/A }
0N/A }
0N/A
4749N/A native void doDrawPoly(GDIWindowSurfaceData sData,
0N/A Region clip, Composite comp, int color,
0N/A int transx, int transy,
0N/A int[] xpoints, int[] ypoints,
0N/A int npoints, boolean isclosed);
0N/A
0N/A public void drawPolyline(SunGraphics2D sg2d,
0N/A int xpoints[], int ypoints[],
0N/A int npoints)
0N/A {
4749N/A try {
4749N/A doDrawPoly((GDIWindowSurfaceData)sg2d.surfaceData,
4749N/A sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
4749N/A sg2d.transX, sg2d.transY, xpoints, ypoints, npoints, false);
4749N/A } catch (ClassCastException e) {
4749N/A throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
4749N/A }
0N/A }
0N/A
0N/A public void drawPolygon(SunGraphics2D sg2d,
0N/A int xpoints[], int ypoints[],
0N/A int npoints)
0N/A {
4749N/A try {
4749N/A doDrawPoly((GDIWindowSurfaceData)sg2d.surfaceData,
4749N/A sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
4749N/A sg2d.transX, sg2d.transY, xpoints, ypoints, npoints, true);
4749N/A } catch (ClassCastException e) {
4749N/A throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
4749N/A }
0N/A }
0N/A
4749N/A native void doFillRect(GDIWindowSurfaceData sData,
0N/A Region clip, Composite comp, int color,
0N/A int x, int y, int w, int h);
0N/A
0N/A public void fillRect(SunGraphics2D sg2d,
0N/A int x, int y, int width, int height)
0N/A {
4749N/A try {
4749N/A doFillRect((GDIWindowSurfaceData)sg2d.surfaceData,
4749N/A sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
4749N/A x+sg2d.transX, y+sg2d.transY, width, height);
4749N/A } catch (ClassCastException e) {
4749N/A throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
4749N/A }
0N/A }
0N/A
4749N/A native void doFillRoundRect(GDIWindowSurfaceData sData,
0N/A Region clip, Composite comp, int color,
0N/A int x, int y, int w, int h,
0N/A int arcW, int arcH);
0N/A
0N/A public void fillRoundRect(SunGraphics2D sg2d,
0N/A int x, int y, int width, int height,
0N/A int arcWidth, int arcHeight)
0N/A {
4749N/A try {
4749N/A doFillRoundRect((GDIWindowSurfaceData)sg2d.surfaceData,
4749N/A sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
4749N/A x+sg2d.transX, y+sg2d.transY, width, height,
4749N/A arcWidth, arcHeight);
4749N/A } catch (ClassCastException e) {
4749N/A throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
4749N/A }
0N/A }
0N/A
4749N/A native void doFillOval(GDIWindowSurfaceData sData,
0N/A Region clip, Composite comp, int color,
0N/A int x, int y, int w, int h);
0N/A
0N/A public void fillOval(SunGraphics2D sg2d,
0N/A int x, int y, int width, int height)
0N/A {
4749N/A try {
4749N/A doFillOval((GDIWindowSurfaceData)sg2d.surfaceData,
4749N/A sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
4749N/A x+sg2d.transX, y+sg2d.transY, width, height);
4749N/A } catch (ClassCastException e) {
4749N/A throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
4749N/A }
0N/A }
0N/A
4749N/A native void doFillArc(GDIWindowSurfaceData sData,
0N/A Region clip, Composite comp, int color,
0N/A int x, int y, int w, int h,
0N/A int angleStart, int angleExtent);
0N/A
0N/A public void fillArc(SunGraphics2D sg2d,
0N/A int x, int y, int width, int height,
0N/A int startAngle, int arcAngle)
0N/A {
4749N/A try {
4749N/A doFillArc((GDIWindowSurfaceData)sg2d.surfaceData,
4749N/A sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
4749N/A x+sg2d.transX, y+sg2d.transY, width, height,
4749N/A startAngle, arcAngle);
4749N/A } catch (ClassCastException e) {
4749N/A throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
4749N/A }
0N/A }
0N/A
4749N/A native void doFillPoly(GDIWindowSurfaceData sData,
0N/A Region clip, Composite comp, int color,
0N/A int transx, int transy,
0N/A int[] xpoints, int[] ypoints,
0N/A int npoints);
0N/A
0N/A public void fillPolygon(SunGraphics2D sg2d,
0N/A int xpoints[], int ypoints[],
0N/A int npoints)
0N/A {
4749N/A try {
4749N/A doFillPoly((GDIWindowSurfaceData)sg2d.surfaceData,
4749N/A sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
4749N/A sg2d.transX, sg2d.transY, xpoints, ypoints, npoints);
4749N/A } catch (ClassCastException e) {
4749N/A throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
4749N/A }
0N/A }
0N/A
4749N/A native void doShape(GDIWindowSurfaceData sData,
0N/A Region clip, Composite comp, int color,
0N/A int transX, int transY,
0N/A Path2D.Float p2df, boolean isfill);
0N/A
0N/A void doShape(SunGraphics2D sg2d, Shape s, boolean isfill) {
0N/A Path2D.Float p2df;
0N/A int transX;
0N/A int transY;
0N/A if (sg2d.transformState <= sg2d.TRANSFORM_INT_TRANSLATE) {
0N/A if (s instanceof Path2D.Float) {
0N/A p2df = (Path2D.Float)s;
0N/A } else {
0N/A p2df = new Path2D.Float(s);
0N/A }
0N/A transX = sg2d.transX;
0N/A transY = sg2d.transY;
0N/A } else {
0N/A p2df = new Path2D.Float(s, sg2d.transform);
0N/A transX = 0;
0N/A transY = 0;
0N/A }
4749N/A try {
4749N/A doShape((GDIWindowSurfaceData)sg2d.surfaceData,
4749N/A sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
4749N/A transX, transY, p2df, isfill);
4749N/A } catch (ClassCastException e) {
4749N/A throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
4749N/A }
0N/A }
0N/A
0N/A // REMIND: This is just a hack to get WIDE lines to honor the
0N/A // necessary hinted pixelization rules. This should be replaced
0N/A // by a native FillSpans method or a getHintedStrokeGeneralPath()
0N/A // method that could be filled by the doShape method more quickly.
0N/A public void doFillSpans(SunGraphics2D sg2d, SpanIterator si) {
0N/A int box[] = new int[4];
4749N/A GDIWindowSurfaceData sd;
4749N/A try {
4749N/A sd = (GDIWindowSurfaceData)sg2d.surfaceData;
4749N/A } catch (ClassCastException e) {
4749N/A throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
4749N/A }
0N/A Region clip = sg2d.getCompClip();
0N/A Composite comp = sg2d.composite;
0N/A int eargb = sg2d.eargb;
0N/A while (si.nextSpan(box)) {
0N/A doFillRect(sd, clip, comp, eargb,
0N/A box[0], box[1], box[2]-box[0], box[3]-box[1]);
0N/A }
0N/A }
0N/A
0N/A public void draw(SunGraphics2D sg2d, Shape s) {
0N/A if (sg2d.strokeState == sg2d.STROKE_THIN) {
0N/A doShape(sg2d, s, false);
0N/A } else if (sg2d.strokeState < sg2d.STROKE_CUSTOM) {
0N/A ShapeSpanIterator si = LoopPipe.getStrokeSpans(sg2d, s);
0N/A try {
0N/A doFillSpans(sg2d, si);
0N/A } finally {
0N/A si.dispose();
0N/A }
0N/A } else {
0N/A doShape(sg2d, sg2d.stroke.createStrokedShape(s), true);
0N/A }
0N/A }
0N/A
0N/A public void fill(SunGraphics2D sg2d, Shape s) {
0N/A doShape(sg2d, s, true);
0N/A }
0N/A
4749N/A public native void devCopyArea(GDIWindowSurfaceData sData,
0N/A int srcx, int srcy,
0N/A int dx, int dy,
0N/A int w, int h);
0N/A
0N/A public GDIRenderer traceWrap() {
0N/A return new Tracer();
0N/A }
0N/A
0N/A public static class Tracer extends GDIRenderer {
4749N/A void doDrawLine(GDIWindowSurfaceData sData,
0N/A Region clip, Composite comp, int color,
0N/A int x1, int y1, int x2, int y2)
0N/A {
0N/A GraphicsPrimitive.tracePrimitive("GDIDrawLine");
0N/A super.doDrawLine(sData, clip, comp, color, x1, y1, x2, y2);
0N/A }
4749N/A void doDrawRect(GDIWindowSurfaceData sData,
0N/A Region clip, Composite comp, int color,
0N/A int x, int y, int w, int h)
0N/A {
0N/A GraphicsPrimitive.tracePrimitive("GDIDrawRect");
0N/A super.doDrawRect(sData, clip, comp, color, x, y, w, h);
0N/A }
4749N/A void doDrawRoundRect(GDIWindowSurfaceData sData,
0N/A Region clip, Composite comp, int color,
0N/A int x, int y, int w, int h,
0N/A int arcW, int arcH)
0N/A {
0N/A GraphicsPrimitive.tracePrimitive("GDIDrawRoundRect");
0N/A super.doDrawRoundRect(sData, clip, comp, color,
0N/A x, y, w, h, arcW, arcH);
0N/A }
4749N/A void doDrawOval(GDIWindowSurfaceData sData,
0N/A Region clip, Composite comp, int color,
0N/A int x, int y, int w, int h)
0N/A {
0N/A GraphicsPrimitive.tracePrimitive("GDIDrawOval");
0N/A super.doDrawOval(sData, clip, comp, color, x, y, w, h);
0N/A }
4749N/A void doDrawArc(GDIWindowSurfaceData sData,
0N/A Region clip, Composite comp, int color,
0N/A int x, int y, int w, int h,
0N/A int angleStart, int angleExtent)
0N/A {
0N/A GraphicsPrimitive.tracePrimitive("GDIDrawArc");
0N/A super.doDrawArc(sData, clip, comp, color, x, y, w, h,
0N/A angleStart, angleExtent);
0N/A }
4749N/A void doDrawPoly(GDIWindowSurfaceData sData,
0N/A Region clip, Composite comp, int color,
0N/A int transx, int transy,
0N/A int[] xpoints, int[] ypoints,
0N/A int npoints, boolean isclosed)
0N/A {
0N/A GraphicsPrimitive.tracePrimitive("GDIDrawPoly");
0N/A super.doDrawPoly(sData, clip, comp, color, transx, transy,
0N/A xpoints, ypoints, npoints, isclosed);
0N/A }
4749N/A void doFillRect(GDIWindowSurfaceData sData,
0N/A Region clip, Composite comp, int color,
0N/A int x, int y, int w, int h)
0N/A {
0N/A GraphicsPrimitive.tracePrimitive("GDIFillRect");
0N/A super.doFillRect(sData, clip, comp, color, x, y, w, h);
0N/A }
4749N/A void doFillRoundRect(GDIWindowSurfaceData sData,
0N/A Region clip, Composite comp, int color,
0N/A int x, int y, int w, int h,
0N/A int arcW, int arcH)
0N/A {
0N/A GraphicsPrimitive.tracePrimitive("GDIFillRoundRect");
0N/A super.doFillRoundRect(sData, clip, comp, color,
0N/A x, y, w, h, arcW, arcH);
0N/A }
4749N/A void doFillOval(GDIWindowSurfaceData sData,
0N/A Region clip, Composite comp, int color,
0N/A int x, int y, int w, int h)
0N/A {
0N/A GraphicsPrimitive.tracePrimitive("GDIFillOval");
0N/A super.doFillOval(sData, clip, comp, color, x, y, w, h);
0N/A }
4749N/A void doFillArc(GDIWindowSurfaceData sData,
0N/A Region clip, Composite comp, int color,
0N/A int x, int y, int w, int h,
0N/A int angleStart, int angleExtent)
0N/A {
0N/A GraphicsPrimitive.tracePrimitive("GDIFillArc");
0N/A super.doFillArc(sData, clip, comp, color, x, y, w, h,
0N/A angleStart, angleExtent);
0N/A }
4749N/A void doFillPoly(GDIWindowSurfaceData sData,
0N/A Region clip, Composite comp, int color,
0N/A int transx, int transy,
0N/A int[] xpoints, int[] ypoints,
0N/A int npoints)
0N/A {
0N/A GraphicsPrimitive.tracePrimitive("GDIFillPoly");
0N/A super.doFillPoly(sData, clip, comp, color, transx, transy,
0N/A xpoints, ypoints, npoints);
0N/A }
4749N/A void doShape(GDIWindowSurfaceData sData,
0N/A Region clip, Composite comp, int color,
0N/A int transX, int transY,
0N/A Path2D.Float p2df, boolean isfill)
0N/A {
0N/A GraphicsPrimitive.tracePrimitive(isfill
0N/A ? "GDIFillShape"
0N/A : "GDIDrawShape");
0N/A super.doShape(sData, clip, comp, color,
0N/A transX, transY, p2df, isfill);
0N/A }
4749N/A public void devCopyArea(GDIWindowSurfaceData sData,
0N/A int srcx, int srcy,
0N/A int dx, int dy,
0N/A int w, int h)
0N/A {
0N/A GraphicsPrimitive.tracePrimitive("GDICopyArea");
0N/A super.devCopyArea(sData, srcx, srcy, dx, dy, w, h);
0N/A }
0N/A }
0N/A}