Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/windows/classes/sun/java2d/d3d/D3DRenderer.java
32288 views
/*1* Copyright (c) 2007, 2011, 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.d3d;2627import java.awt.Transparency;28import java.awt.geom.Path2D;29import sun.java2d.InvalidPipeException;30import sun.java2d.SunGraphics2D;31import sun.java2d.loops.GraphicsPrimitive;32import sun.java2d.pipe.BufferedPaints;33import sun.java2d.pipe.BufferedRenderPipe;34import sun.java2d.pipe.RenderQueue;35import sun.java2d.pipe.SpanIterator;36import sun.java2d.pipe.ParallelogramPipe;37import static sun.java2d.pipe.BufferedOpCodes.*;3839class D3DRenderer extends BufferedRenderPipe {4041D3DRenderer(RenderQueue rq) {42super(rq);43}4445@Override46protected void validateContext(SunGraphics2D sg2d) {47int ctxflags =48sg2d.paint.getTransparency() == Transparency.OPAQUE ?49D3DContext.SRC_IS_OPAQUE : D3DContext.NO_CONTEXT_FLAGS;50D3DSurfaceData dstData;51try {52dstData = (D3DSurfaceData)sg2d.surfaceData;53} catch (ClassCastException e) {54throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);55}56D3DContext.validateContext(dstData, dstData,57sg2d.getCompClip(), sg2d.composite,58null, sg2d.paint, sg2d, ctxflags);59}6061@Override62protected void validateContextAA(SunGraphics2D sg2d) {63int ctxflags = D3DContext.NO_CONTEXT_FLAGS;64D3DSurfaceData dstData;65try {66dstData = (D3DSurfaceData)sg2d.surfaceData;67} catch (ClassCastException e) {68throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);69}70D3DContext.validateContext(dstData, dstData,71sg2d.getCompClip(), sg2d.composite,72null, sg2d.paint, sg2d, ctxflags);73}7475void copyArea(SunGraphics2D sg2d,76int x, int y, int w, int h, int dx, int dy)77{78rq.lock();79try {80int ctxflags =81sg2d.surfaceData.getTransparency() == Transparency.OPAQUE ?82D3DContext.SRC_IS_OPAQUE : D3DContext.NO_CONTEXT_FLAGS;83D3DSurfaceData dstData;84try {85dstData = (D3DSurfaceData)sg2d.surfaceData;86} catch (ClassCastException e) {87throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);88}89D3DContext.validateContext(dstData, dstData,90sg2d.getCompClip(), sg2d.composite,91null, null, null, ctxflags);9293rq.ensureCapacity(28);94buf.putInt(COPY_AREA);95buf.putInt(x).putInt(y).putInt(w).putInt(h);96buf.putInt(dx).putInt(dy);97} finally {98rq.unlock();99}100}101102protected native void drawPoly(int[] xPoints, int[] yPoints,103int nPoints, boolean isClosed,104int transX, int transY);105106D3DRenderer traceWrap() {107return new Tracer(this);108}109110private class Tracer extends D3DRenderer {111private D3DRenderer d3dr;112Tracer(D3DRenderer d3dr) {113super(d3dr.rq);114this.d3dr = d3dr;115}116public ParallelogramPipe getAAParallelogramPipe() {117final ParallelogramPipe realpipe = d3dr.getAAParallelogramPipe();118return new ParallelogramPipe() {119public void fillParallelogram(SunGraphics2D sg2d,120double ux1, double uy1,121double ux2, double uy2,122double x, double y,123double dx1, double dy1,124double dx2, double dy2)125{126GraphicsPrimitive.tracePrimitive("D3DFillAAParallelogram");127realpipe.fillParallelogram(sg2d,128ux1, uy1, ux2, uy2,129x, y, dx1, dy1, dx2, dy2);130}131public void drawParallelogram(SunGraphics2D sg2d,132double ux1, double uy1,133double ux2, double uy2,134double x, double y,135double dx1, double dy1,136double dx2, double dy2,137double lw1, double lw2)138{139GraphicsPrimitive.tracePrimitive("D3DDrawAAParallelogram");140realpipe.drawParallelogram(sg2d,141ux1, uy1, ux2, uy2,142x, y, dx1, dy1, dx2, dy2,143lw1, lw2);144}145};146}147148protected void validateContext(SunGraphics2D sg2d) {149d3dr.validateContext(sg2d);150}151public void drawLine(SunGraphics2D sg2d,152int x1, int y1, int x2, int y2)153{154GraphicsPrimitive.tracePrimitive("D3DDrawLine");155d3dr.drawLine(sg2d, x1, y1, x2, y2);156}157public void drawRect(SunGraphics2D sg2d, int x, int y, int w, int h) {158GraphicsPrimitive.tracePrimitive("D3DDrawRect");159d3dr.drawRect(sg2d, x, y, w, h);160}161protected void drawPoly(SunGraphics2D sg2d,162int[] xPoints, int[] yPoints,163int nPoints, boolean isClosed)164{165GraphicsPrimitive.tracePrimitive("D3DDrawPoly");166d3dr.drawPoly(sg2d, xPoints, yPoints, nPoints, isClosed);167}168public void fillRect(SunGraphics2D sg2d, int x, int y, int w, int h) {169GraphicsPrimitive.tracePrimitive("D3DFillRect");170d3dr.fillRect(sg2d, x, y, w, h);171}172protected void drawPath(SunGraphics2D sg2d,173Path2D.Float p2df, int transx, int transy)174{175GraphicsPrimitive.tracePrimitive("D3DDrawPath");176d3dr.drawPath(sg2d, p2df, transx, transy);177}178protected void fillPath(SunGraphics2D sg2d,179Path2D.Float p2df, int transx, int transy)180{181GraphicsPrimitive.tracePrimitive("D3DFillPath");182d3dr.fillPath(sg2d, p2df, transx, transy);183}184protected void fillSpans(SunGraphics2D sg2d, SpanIterator si,185int transx, int transy)186{187GraphicsPrimitive.tracePrimitive("D3DFillSpans");188d3dr.fillSpans(sg2d, si, transx, transy);189}190public void fillParallelogram(SunGraphics2D sg2d,191double ux1, double uy1,192double ux2, double uy2,193double x, double y,194double dx1, double dy1,195double dx2, double dy2)196{197GraphicsPrimitive.tracePrimitive("D3DFillParallelogram");198d3dr.fillParallelogram(sg2d,199ux1, uy1, ux2, uy2,200x, y, dx1, dy1, dx2, dy2);201}202public void drawParallelogram(SunGraphics2D sg2d,203double ux1, double uy1,204double ux2, double uy2,205double x, double y,206double dx1, double dy1,207double dx2, double dy2,208double lw1, double lw2)209{210GraphicsPrimitive.tracePrimitive("D3DDrawParallelogram");211d3dr.drawParallelogram(sg2d,212ux1, uy1, ux2, uy2,213x, y, dx1, dy1, dx2, dy2, lw1, lw2);214}215public void copyArea(SunGraphics2D sg2d,216int x, int y, int w, int h, int dx, int dy)217{218GraphicsPrimitive.tracePrimitive("D3DCopyArea");219d3dr.copyArea(sg2d, x, y, w, h, dx, dy);220}221}222}223224225