2
|
1 |
/*
|
5506
|
2 |
* Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
|
2
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
5506
|
7 |
* published by the Free Software Foundation. Oracle designates this
|
2
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
5506
|
9 |
* by Oracle in the LICENSE file that accompanied this code.
|
2
|
10 |
*
|
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
15 |
* accompanied this code).
|
|
16 |
*
|
|
17 |
* You should have received a copy of the GNU General Public License version
|
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20 |
*
|
5506
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
22 |
* or visit www.oracle.com if you need additional information or have any
|
|
23 |
* questions.
|
2
|
24 |
*/
|
|
25 |
|
|
26 |
package sun.java2d.d3d;
|
|
27 |
|
887
|
28 |
import java.awt.Transparency;
|
|
29 |
import java.awt.geom.Path2D;
|
2
|
30 |
import sun.java2d.SunGraphics2D;
|
|
31 |
import sun.java2d.loops.GraphicsPrimitive;
|
887
|
32 |
import sun.java2d.pipe.BufferedPaints;
|
|
33 |
import sun.java2d.pipe.BufferedRenderPipe;
|
|
34 |
import sun.java2d.pipe.RenderQueue;
|
2
|
35 |
import sun.java2d.pipe.SpanIterator;
|
887
|
36 |
import sun.java2d.pipe.ParallelogramPipe;
|
|
37 |
import static sun.java2d.pipe.BufferedOpCodes.*;
|
2
|
38 |
|
887
|
39 |
class D3DRenderer extends BufferedRenderPipe {
|
2
|
40 |
|
887
|
41 |
D3DRenderer(RenderQueue rq) {
|
|
42 |
super(rq);
|
2
|
43 |
}
|
|
44 |
|
|
45 |
@Override
|
887
|
46 |
protected void validateContext(SunGraphics2D sg2d) {
|
|
47 |
int ctxflags =
|
|
48 |
sg2d.paint.getTransparency() == Transparency.OPAQUE ?
|
|
49 |
D3DContext.SRC_IS_OPAQUE : D3DContext.NO_CONTEXT_FLAGS;
|
|
50 |
D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData;
|
|
51 |
D3DContext.validateContext(dstData, dstData,
|
|
52 |
sg2d.getCompClip(), sg2d.composite,
|
|
53 |
null, sg2d.paint, sg2d, ctxflags);
|
2
|
54 |
}
|
|
55 |
|
|
56 |
@Override
|
887
|
57 |
protected void validateContextAA(SunGraphics2D sg2d) {
|
|
58 |
int ctxflags = D3DContext.NO_CONTEXT_FLAGS;
|
|
59 |
D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData;
|
|
60 |
D3DContext.validateContext(dstData, dstData,
|
|
61 |
sg2d.getCompClip(), sg2d.composite,
|
|
62 |
null, sg2d.paint, sg2d, ctxflags);
|
2
|
63 |
}
|
|
64 |
|
887
|
65 |
void copyArea(SunGraphics2D sg2d,
|
|
66 |
int x, int y, int w, int h, int dx, int dy)
|
2
|
67 |
{
|
887
|
68 |
rq.lock();
|
|
69 |
try {
|
|
70 |
int ctxflags =
|
|
71 |
sg2d.surfaceData.getTransparency() == Transparency.OPAQUE ?
|
|
72 |
D3DContext.SRC_IS_OPAQUE : D3DContext.NO_CONTEXT_FLAGS;
|
|
73 |
D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData;
|
|
74 |
D3DContext.validateContext(dstData, dstData,
|
|
75 |
sg2d.getCompClip(), sg2d.composite,
|
|
76 |
null, null, null, ctxflags);
|
|
77 |
|
|
78 |
rq.ensureCapacity(28);
|
|
79 |
buf.putInt(COPY_AREA);
|
|
80 |
buf.putInt(x).putInt(y).putInt(w).putInt(h);
|
|
81 |
buf.putInt(dx).putInt(dy);
|
|
82 |
} finally {
|
|
83 |
rq.unlock();
|
2
|
84 |
}
|
|
85 |
}
|
|
86 |
|
887
|
87 |
protected native void drawPoly(int[] xPoints, int[] yPoints,
|
|
88 |
int nPoints, boolean isClosed,
|
|
89 |
int transX, int transY);
|
2
|
90 |
|
887
|
91 |
D3DRenderer traceWrap() {
|
|
92 |
return new Tracer(this);
|
2
|
93 |
}
|
|
94 |
|
|
95 |
private class Tracer extends D3DRenderer {
|
887
|
96 |
private D3DRenderer d3dr;
|
|
97 |
Tracer(D3DRenderer d3dr) {
|
|
98 |
super(d3dr.rq);
|
|
99 |
this.d3dr = d3dr;
|
|
100 |
}
|
|
101 |
public ParallelogramPipe getAAParallelogramPipe() {
|
|
102 |
final ParallelogramPipe realpipe = d3dr.getAAParallelogramPipe();
|
|
103 |
return new ParallelogramPipe() {
|
|
104 |
public void fillParallelogram(SunGraphics2D sg2d,
|
|
105 |
double x, double y,
|
|
106 |
double dx1, double dy1,
|
|
107 |
double dx2, double dy2)
|
|
108 |
{
|
|
109 |
GraphicsPrimitive.tracePrimitive("D3DFillAAParallelogram");
|
|
110 |
realpipe.fillParallelogram(sg2d,
|
|
111 |
x, y, dx1, dy1, dx2, dy2);
|
|
112 |
}
|
|
113 |
public void drawParallelogram(SunGraphics2D sg2d,
|
|
114 |
double x, double y,
|
|
115 |
double dx1, double dy1,
|
|
116 |
double dx2, double dy2,
|
|
117 |
double lw1, double lw2)
|
|
118 |
{
|
|
119 |
GraphicsPrimitive.tracePrimitive("D3DDrawAAParallelogram");
|
|
120 |
realpipe.drawParallelogram(sg2d,
|
|
121 |
x, y, dx1, dy1, dx2, dy2,
|
|
122 |
lw1, lw2);
|
|
123 |
}
|
|
124 |
};
|
|
125 |
}
|
|
126 |
|
|
127 |
protected void validateContext(SunGraphics2D sg2d) {
|
|
128 |
d3dr.validateContext(sg2d);
|
|
129 |
}
|
2
|
130 |
public void drawLine(SunGraphics2D sg2d,
|
|
131 |
int x1, int y1, int x2, int y2)
|
|
132 |
{
|
|
133 |
GraphicsPrimitive.tracePrimitive("D3DDrawLine");
|
887
|
134 |
d3dr.drawLine(sg2d, x1, y1, x2, y2);
|
2
|
135 |
}
|
|
136 |
public void drawRect(SunGraphics2D sg2d, int x, int y, int w, int h) {
|
|
137 |
GraphicsPrimitive.tracePrimitive("D3DDrawRect");
|
887
|
138 |
d3dr.drawRect(sg2d, x, y, w, h);
|
2
|
139 |
}
|
887
|
140 |
protected void drawPoly(SunGraphics2D sg2d,
|
2
|
141 |
int[] xPoints, int[] yPoints,
|
887
|
142 |
int nPoints, boolean isClosed)
|
2
|
143 |
{
|
887
|
144 |
GraphicsPrimitive.tracePrimitive("D3DDrawPoly");
|
|
145 |
d3dr.drawPoly(sg2d, xPoints, yPoints, nPoints, isClosed);
|
2
|
146 |
}
|
|
147 |
public void fillRect(SunGraphics2D sg2d, int x, int y, int w, int h) {
|
|
148 |
GraphicsPrimitive.tracePrimitive("D3DFillRect");
|
887
|
149 |
d3dr.fillRect(sg2d, x, y, w, h);
|
|
150 |
}
|
|
151 |
protected void drawPath(SunGraphics2D sg2d,
|
|
152 |
Path2D.Float p2df, int transx, int transy)
|
|
153 |
{
|
|
154 |
GraphicsPrimitive.tracePrimitive("D3DDrawPath");
|
|
155 |
d3dr.drawPath(sg2d, p2df, transx, transy);
|
2
|
156 |
}
|
887
|
157 |
protected void fillPath(SunGraphics2D sg2d,
|
|
158 |
Path2D.Float p2df, int transx, int transy)
|
|
159 |
{
|
|
160 |
GraphicsPrimitive.tracePrimitive("D3DFillPath");
|
|
161 |
d3dr.fillPath(sg2d, p2df, transx, transy);
|
|
162 |
}
|
|
163 |
protected void fillSpans(SunGraphics2D sg2d, SpanIterator si,
|
|
164 |
int transx, int transy)
|
2
|
165 |
{
|
|
166 |
GraphicsPrimitive.tracePrimitive("D3DFillSpans");
|
887
|
167 |
d3dr.fillSpans(sg2d, si, transx, transy);
|
|
168 |
}
|
|
169 |
public void fillParallelogram(SunGraphics2D sg2d,
|
|
170 |
double x, double y,
|
|
171 |
double dx1, double dy1,
|
|
172 |
double dx2, double dy2)
|
|
173 |
{
|
|
174 |
GraphicsPrimitive.tracePrimitive("D3DFillParallelogram");
|
|
175 |
d3dr.fillParallelogram(sg2d, x, y, dx1, dy1, dx2, dy2);
|
2
|
176 |
}
|
887
|
177 |
public void drawParallelogram(SunGraphics2D sg2d,
|
|
178 |
double x, double y,
|
|
179 |
double dx1, double dy1,
|
|
180 |
double dx2, double dy2,
|
|
181 |
double lw1, double lw2)
|
2
|
182 |
{
|
887
|
183 |
GraphicsPrimitive.tracePrimitive("D3DDrawParallelogram");
|
|
184 |
d3dr.drawParallelogram(sg2d, x, y, dx1, dy1, dx2, dy2, lw1, lw2);
|
2
|
185 |
}
|
887
|
186 |
public void copyArea(SunGraphics2D sg2d,
|
|
187 |
int x, int y, int w, int h, int dx, int dy)
|
|
188 |
{
|
|
189 |
GraphicsPrimitive.tracePrimitive("D3DCopyArea");
|
|
190 |
d3dr.copyArea(sg2d, x, y, w, h, dx, dy);
|
|
191 |
}
|
2
|
192 |
}
|
|
193 |
}
|