0N/A/*
2362N/A * Copyright (c) 2007, 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
0N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
0N/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,
2362N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2362N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0N/A * or visit www.oracle.com if you need additional information or have any
0N/A * questions.
0N/A */
0N/A
0N/Apackage sun.java2d.d3d;
0N/A
0N/Aimport java.awt.Transparency;
0N/Aimport java.awt.geom.Path2D;
0N/Aimport sun.java2d.InvalidPipeException;
0N/Aimport sun.java2d.SunGraphics2D;
0N/Aimport sun.java2d.loops.GraphicsPrimitive;
0N/Aimport sun.java2d.pipe.BufferedPaints;
0N/Aimport sun.java2d.pipe.BufferedRenderPipe;
0N/Aimport sun.java2d.pipe.RenderQueue;
0N/Aimport sun.java2d.pipe.SpanIterator;
0N/Aimport sun.java2d.pipe.ParallelogramPipe;
0N/Aimport static sun.java2d.pipe.BufferedOpCodes.*;
0N/A
0N/Aclass D3DRenderer extends BufferedRenderPipe {
0N/A
0N/A D3DRenderer(RenderQueue rq) {
0N/A super(rq);
0N/A }
0N/A
0N/A @Override
0N/A protected void validateContext(SunGraphics2D sg2d) {
0N/A int ctxflags =
0N/A sg2d.paint.getTransparency() == Transparency.OPAQUE ?
0N/A D3DContext.SRC_IS_OPAQUE : D3DContext.NO_CONTEXT_FLAGS;
0N/A D3DSurfaceData dstData;
0N/A try {
0N/A dstData = (D3DSurfaceData)sg2d.surfaceData;
0N/A } catch (ClassCastException e) {
0N/A throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
0N/A }
0N/A D3DContext.validateContext(dstData, dstData,
0N/A sg2d.getCompClip(), sg2d.composite,
0N/A null, sg2d.paint, sg2d, ctxflags);
0N/A }
0N/A
0N/A @Override
0N/A protected void validateContextAA(SunGraphics2D sg2d) {
0N/A int ctxflags = D3DContext.NO_CONTEXT_FLAGS;
0N/A D3DSurfaceData dstData;
0N/A try {
0N/A dstData = (D3DSurfaceData)sg2d.surfaceData;
0N/A } catch (ClassCastException e) {
0N/A throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
0N/A }
0N/A D3DContext.validateContext(dstData, dstData,
0N/A sg2d.getCompClip(), sg2d.composite,
0N/A null, sg2d.paint, sg2d, ctxflags);
0N/A }
0N/A
0N/A void copyArea(SunGraphics2D sg2d,
0N/A int x, int y, int w, int h, int dx, int dy)
0N/A {
0N/A rq.lock();
0N/A try {
0N/A int ctxflags =
0N/A sg2d.surfaceData.getTransparency() == Transparency.OPAQUE ?
0N/A D3DContext.SRC_IS_OPAQUE : D3DContext.NO_CONTEXT_FLAGS;
0N/A D3DSurfaceData dstData;
0N/A try {
0N/A dstData = (D3DSurfaceData)sg2d.surfaceData;
0N/A } catch (ClassCastException e) {
0N/A throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
0N/A }
0N/A D3DContext.validateContext(dstData, dstData,
0N/A sg2d.getCompClip(), sg2d.composite,
0N/A null, null, null, ctxflags);
0N/A
0N/A rq.ensureCapacity(28);
0N/A buf.putInt(COPY_AREA);
0N/A buf.putInt(x).putInt(y).putInt(w).putInt(h);
0N/A buf.putInt(dx).putInt(dy);
0N/A } finally {
0N/A rq.unlock();
0N/A }
0N/A }
0N/A
0N/A protected native void drawPoly(int[] xPoints, int[] yPoints,
0N/A int nPoints, boolean isClosed,
0N/A int transX, int transY);
0N/A
0N/A D3DRenderer traceWrap() {
0N/A return new Tracer(this);
0N/A }
0N/A
0N/A private class Tracer extends D3DRenderer {
0N/A private D3DRenderer d3dr;
0N/A Tracer(D3DRenderer d3dr) {
0N/A super(d3dr.rq);
0N/A this.d3dr = d3dr;
0N/A }
0N/A public ParallelogramPipe getAAParallelogramPipe() {
0N/A final ParallelogramPipe realpipe = d3dr.getAAParallelogramPipe();
0N/A return new ParallelogramPipe() {
0N/A public void fillParallelogram(SunGraphics2D sg2d,
0N/A double ux1, double uy1,
0N/A double ux2, double uy2,
0N/A double x, double y,
0N/A double dx1, double dy1,
0N/A double dx2, double dy2)
0N/A {
0N/A GraphicsPrimitive.tracePrimitive("D3DFillAAParallelogram");
0N/A realpipe.fillParallelogram(sg2d,
0N/A ux1, uy1, ux2, uy2,
0N/A x, y, dx1, dy1, dx2, dy2);
0N/A }
0N/A public void drawParallelogram(SunGraphics2D sg2d,
0N/A double ux1, double uy1,
0N/A double ux2, double uy2,
0N/A double x, double y,
0N/A double dx1, double dy1,
0N/A double dx2, double dy2,
0N/A double lw1, double lw2)
0N/A {
0N/A GraphicsPrimitive.tracePrimitive("D3DDrawAAParallelogram");
0N/A realpipe.drawParallelogram(sg2d,
0N/A ux1, uy1, ux2, uy2,
0N/A x, y, dx1, dy1, dx2, dy2,
0N/A lw1, lw2);
0N/A }
0N/A };
0N/A }
0N/A
0N/A protected void validateContext(SunGraphics2D sg2d) {
0N/A d3dr.validateContext(sg2d);
0N/A }
0N/A public void drawLine(SunGraphics2D sg2d,
0N/A int x1, int y1, int x2, int y2)
0N/A {
0N/A GraphicsPrimitive.tracePrimitive("D3DDrawLine");
0N/A d3dr.drawLine(sg2d, x1, y1, x2, y2);
0N/A }
0N/A public void drawRect(SunGraphics2D sg2d, int x, int y, int w, int h) {
0N/A GraphicsPrimitive.tracePrimitive("D3DDrawRect");
0N/A d3dr.drawRect(sg2d, x, y, w, h);
0N/A }
0N/A protected void drawPoly(SunGraphics2D sg2d,
0N/A int[] xPoints, int[] yPoints,
0N/A int nPoints, boolean isClosed)
0N/A {
0N/A GraphicsPrimitive.tracePrimitive("D3DDrawPoly");
0N/A d3dr.drawPoly(sg2d, xPoints, yPoints, nPoints, isClosed);
0N/A }
0N/A public void fillRect(SunGraphics2D sg2d, int x, int y, int w, int h) {
0N/A GraphicsPrimitive.tracePrimitive("D3DFillRect");
0N/A d3dr.fillRect(sg2d, x, y, w, h);
0N/A }
0N/A protected void drawPath(SunGraphics2D sg2d,
0N/A Path2D.Float p2df, int transx, int transy)
0N/A {
0N/A GraphicsPrimitive.tracePrimitive("D3DDrawPath");
0N/A d3dr.drawPath(sg2d, p2df, transx, transy);
0N/A }
0N/A protected void fillPath(SunGraphics2D sg2d,
0N/A Path2D.Float p2df, int transx, int transy)
0N/A {
0N/A GraphicsPrimitive.tracePrimitive("D3DFillPath");
0N/A d3dr.fillPath(sg2d, p2df, transx, transy);
0N/A }
0N/A protected void fillSpans(SunGraphics2D sg2d, SpanIterator si,
0N/A int transx, int transy)
0N/A {
0N/A GraphicsPrimitive.tracePrimitive("D3DFillSpans");
0N/A d3dr.fillSpans(sg2d, si, transx, transy);
0N/A }
0N/A public void fillParallelogram(SunGraphics2D sg2d,
0N/A double ux1, double uy1,
0N/A double ux2, double uy2,
0N/A double x, double y,
0N/A double dx1, double dy1,
0N/A double dx2, double dy2)
0N/A {
0N/A GraphicsPrimitive.tracePrimitive("D3DFillParallelogram");
0N/A d3dr.fillParallelogram(sg2d,
0N/A ux1, uy1, ux2, uy2,
0N/A x, y, dx1, dy1, dx2, dy2);
0N/A }
0N/A public void drawParallelogram(SunGraphics2D sg2d,
0N/A double ux1, double uy1,
0N/A double ux2, double uy2,
0N/A double x, double y,
0N/A double dx1, double dy1,
0N/A double dx2, double dy2,
0N/A double lw1, double lw2)
0N/A {
0N/A GraphicsPrimitive.tracePrimitive("D3DDrawParallelogram");
0N/A d3dr.drawParallelogram(sg2d,
0N/A ux1, uy1, ux2, uy2,
0N/A x, y, dx1, dy1, dx2, dy2, lw1, lw2);
}
public void copyArea(SunGraphics2D sg2d,
int x, int y, int w, int h, int dx, int dy)
{
GraphicsPrimitive.tracePrimitive("D3DCopyArea");
d3dr.copyArea(sg2d, x, y, w, h, dx, dy);
}
}
}