author | henryjen |
Thu, 05 Jun 2014 13:59:01 -0700 | |
changeset 25192 | 4e2dc0f8702d |
parent 23010 | 6dadb192ad81 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
23010
6dadb192ad81
8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents:
11897
diff
changeset
|
2 |
* Copyright (c) 2007, 2011, 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; |
|
11897
9e80dbac0293
7112642: Incorrect checking for graphics rendering object
bagiras
parents:
9653
diff
changeset
|
30 |
import sun.java2d.InvalidPipeException; |
2 | 31 |
import sun.java2d.SunGraphics2D; |
32 |
import sun.java2d.loops.GraphicsPrimitive; |
|
887 | 33 |
import sun.java2d.pipe.BufferedPaints; |
34 |
import sun.java2d.pipe.BufferedRenderPipe; |
|
35 |
import sun.java2d.pipe.RenderQueue; |
|
2 | 36 |
import sun.java2d.pipe.SpanIterator; |
887 | 37 |
import sun.java2d.pipe.ParallelogramPipe; |
38 |
import static sun.java2d.pipe.BufferedOpCodes.*; |
|
2 | 39 |
|
887 | 40 |
class D3DRenderer extends BufferedRenderPipe { |
2 | 41 |
|
887 | 42 |
D3DRenderer(RenderQueue rq) { |
43 |
super(rq); |
|
2 | 44 |
} |
45 |
||
46 |
@Override |
|
887 | 47 |
protected void validateContext(SunGraphics2D sg2d) { |
48 |
int ctxflags = |
|
49 |
sg2d.paint.getTransparency() == Transparency.OPAQUE ? |
|
50 |
D3DContext.SRC_IS_OPAQUE : D3DContext.NO_CONTEXT_FLAGS; |
|
11897
9e80dbac0293
7112642: Incorrect checking for graphics rendering object
bagiras
parents:
9653
diff
changeset
|
51 |
D3DSurfaceData dstData; |
9e80dbac0293
7112642: Incorrect checking for graphics rendering object
bagiras
parents:
9653
diff
changeset
|
52 |
try { |
9e80dbac0293
7112642: Incorrect checking for graphics rendering object
bagiras
parents:
9653
diff
changeset
|
53 |
dstData = (D3DSurfaceData)sg2d.surfaceData; |
9e80dbac0293
7112642: Incorrect checking for graphics rendering object
bagiras
parents:
9653
diff
changeset
|
54 |
} catch (ClassCastException e) { |
9e80dbac0293
7112642: Incorrect checking for graphics rendering object
bagiras
parents:
9653
diff
changeset
|
55 |
throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData); |
9e80dbac0293
7112642: Incorrect checking for graphics rendering object
bagiras
parents:
9653
diff
changeset
|
56 |
} |
887 | 57 |
D3DContext.validateContext(dstData, dstData, |
58 |
sg2d.getCompClip(), sg2d.composite, |
|
59 |
null, sg2d.paint, sg2d, ctxflags); |
|
2 | 60 |
} |
61 |
||
62 |
@Override |
|
887 | 63 |
protected void validateContextAA(SunGraphics2D sg2d) { |
64 |
int ctxflags = D3DContext.NO_CONTEXT_FLAGS; |
|
11897
9e80dbac0293
7112642: Incorrect checking for graphics rendering object
bagiras
parents:
9653
diff
changeset
|
65 |
D3DSurfaceData dstData; |
9e80dbac0293
7112642: Incorrect checking for graphics rendering object
bagiras
parents:
9653
diff
changeset
|
66 |
try { |
9e80dbac0293
7112642: Incorrect checking for graphics rendering object
bagiras
parents:
9653
diff
changeset
|
67 |
dstData = (D3DSurfaceData)sg2d.surfaceData; |
9e80dbac0293
7112642: Incorrect checking for graphics rendering object
bagiras
parents:
9653
diff
changeset
|
68 |
} catch (ClassCastException e) { |
9e80dbac0293
7112642: Incorrect checking for graphics rendering object
bagiras
parents:
9653
diff
changeset
|
69 |
throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData); |
9e80dbac0293
7112642: Incorrect checking for graphics rendering object
bagiras
parents:
9653
diff
changeset
|
70 |
} |
887 | 71 |
D3DContext.validateContext(dstData, dstData, |
72 |
sg2d.getCompClip(), sg2d.composite, |
|
73 |
null, sg2d.paint, sg2d, ctxflags); |
|
2 | 74 |
} |
75 |
||
887 | 76 |
void copyArea(SunGraphics2D sg2d, |
77 |
int x, int y, int w, int h, int dx, int dy) |
|
2 | 78 |
{ |
887 | 79 |
rq.lock(); |
80 |
try { |
|
81 |
int ctxflags = |
|
82 |
sg2d.surfaceData.getTransparency() == Transparency.OPAQUE ? |
|
83 |
D3DContext.SRC_IS_OPAQUE : D3DContext.NO_CONTEXT_FLAGS; |
|
11897
9e80dbac0293
7112642: Incorrect checking for graphics rendering object
bagiras
parents:
9653
diff
changeset
|
84 |
D3DSurfaceData dstData; |
9e80dbac0293
7112642: Incorrect checking for graphics rendering object
bagiras
parents:
9653
diff
changeset
|
85 |
try { |
9e80dbac0293
7112642: Incorrect checking for graphics rendering object
bagiras
parents:
9653
diff
changeset
|
86 |
dstData = (D3DSurfaceData)sg2d.surfaceData; |
9e80dbac0293
7112642: Incorrect checking for graphics rendering object
bagiras
parents:
9653
diff
changeset
|
87 |
} catch (ClassCastException e) { |
9e80dbac0293
7112642: Incorrect checking for graphics rendering object
bagiras
parents:
9653
diff
changeset
|
88 |
throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData); |
9e80dbac0293
7112642: Incorrect checking for graphics rendering object
bagiras
parents:
9653
diff
changeset
|
89 |
} |
887 | 90 |
D3DContext.validateContext(dstData, dstData, |
91 |
sg2d.getCompClip(), sg2d.composite, |
|
92 |
null, null, null, ctxflags); |
|
93 |
||
94 |
rq.ensureCapacity(28); |
|
95 |
buf.putInt(COPY_AREA); |
|
96 |
buf.putInt(x).putInt(y).putInt(w).putInt(h); |
|
97 |
buf.putInt(dx).putInt(dy); |
|
98 |
} finally { |
|
99 |
rq.unlock(); |
|
2 | 100 |
} |
101 |
} |
|
102 |
||
887 | 103 |
protected native void drawPoly(int[] xPoints, int[] yPoints, |
104 |
int nPoints, boolean isClosed, |
|
105 |
int transX, int transY); |
|
2 | 106 |
|
887 | 107 |
D3DRenderer traceWrap() { |
108 |
return new Tracer(this); |
|
2 | 109 |
} |
110 |
||
111 |
private class Tracer extends D3DRenderer { |
|
887 | 112 |
private D3DRenderer d3dr; |
113 |
Tracer(D3DRenderer d3dr) { |
|
114 |
super(d3dr.rq); |
|
115 |
this.d3dr = d3dr; |
|
116 |
} |
|
117 |
public ParallelogramPipe getAAParallelogramPipe() { |
|
118 |
final ParallelogramPipe realpipe = d3dr.getAAParallelogramPipe(); |
|
119 |
return new ParallelogramPipe() { |
|
120 |
public void fillParallelogram(SunGraphics2D sg2d, |
|
9653
6a1eff16874d
7043054: REGRESSION: JDK 7 b126 : Wrong userBounds in Paint.createContext()
flar
parents:
5506
diff
changeset
|
121 |
double ux1, double uy1, |
6a1eff16874d
7043054: REGRESSION: JDK 7 b126 : Wrong userBounds in Paint.createContext()
flar
parents:
5506
diff
changeset
|
122 |
double ux2, double uy2, |
887 | 123 |
double x, double y, |
124 |
double dx1, double dy1, |
|
125 |
double dx2, double dy2) |
|
126 |
{ |
|
127 |
GraphicsPrimitive.tracePrimitive("D3DFillAAParallelogram"); |
|
128 |
realpipe.fillParallelogram(sg2d, |
|
9653
6a1eff16874d
7043054: REGRESSION: JDK 7 b126 : Wrong userBounds in Paint.createContext()
flar
parents:
5506
diff
changeset
|
129 |
ux1, uy1, ux2, uy2, |
887 | 130 |
x, y, dx1, dy1, dx2, dy2); |
131 |
} |
|
132 |
public void drawParallelogram(SunGraphics2D sg2d, |
|
9653
6a1eff16874d
7043054: REGRESSION: JDK 7 b126 : Wrong userBounds in Paint.createContext()
flar
parents:
5506
diff
changeset
|
133 |
double ux1, double uy1, |
6a1eff16874d
7043054: REGRESSION: JDK 7 b126 : Wrong userBounds in Paint.createContext()
flar
parents:
5506
diff
changeset
|
134 |
double ux2, double uy2, |
887 | 135 |
double x, double y, |
136 |
double dx1, double dy1, |
|
137 |
double dx2, double dy2, |
|
138 |
double lw1, double lw2) |
|
139 |
{ |
|
140 |
GraphicsPrimitive.tracePrimitive("D3DDrawAAParallelogram"); |
|
141 |
realpipe.drawParallelogram(sg2d, |
|
9653
6a1eff16874d
7043054: REGRESSION: JDK 7 b126 : Wrong userBounds in Paint.createContext()
flar
parents:
5506
diff
changeset
|
142 |
ux1, uy1, ux2, uy2, |
887 | 143 |
x, y, dx1, dy1, dx2, dy2, |
144 |
lw1, lw2); |
|
145 |
} |
|
146 |
}; |
|
147 |
} |
|
148 |
||
149 |
protected void validateContext(SunGraphics2D sg2d) { |
|
150 |
d3dr.validateContext(sg2d); |
|
151 |
} |
|
2 | 152 |
public void drawLine(SunGraphics2D sg2d, |
153 |
int x1, int y1, int x2, int y2) |
|
154 |
{ |
|
155 |
GraphicsPrimitive.tracePrimitive("D3DDrawLine"); |
|
887 | 156 |
d3dr.drawLine(sg2d, x1, y1, x2, y2); |
2 | 157 |
} |
158 |
public void drawRect(SunGraphics2D sg2d, int x, int y, int w, int h) { |
|
159 |
GraphicsPrimitive.tracePrimitive("D3DDrawRect"); |
|
887 | 160 |
d3dr.drawRect(sg2d, x, y, w, h); |
2 | 161 |
} |
887 | 162 |
protected void drawPoly(SunGraphics2D sg2d, |
2 | 163 |
int[] xPoints, int[] yPoints, |
887 | 164 |
int nPoints, boolean isClosed) |
2 | 165 |
{ |
887 | 166 |
GraphicsPrimitive.tracePrimitive("D3DDrawPoly"); |
167 |
d3dr.drawPoly(sg2d, xPoints, yPoints, nPoints, isClosed); |
|
2 | 168 |
} |
169 |
public void fillRect(SunGraphics2D sg2d, int x, int y, int w, int h) { |
|
170 |
GraphicsPrimitive.tracePrimitive("D3DFillRect"); |
|
887 | 171 |
d3dr.fillRect(sg2d, x, y, w, h); |
172 |
} |
|
173 |
protected void drawPath(SunGraphics2D sg2d, |
|
174 |
Path2D.Float p2df, int transx, int transy) |
|
175 |
{ |
|
176 |
GraphicsPrimitive.tracePrimitive("D3DDrawPath"); |
|
177 |
d3dr.drawPath(sg2d, p2df, transx, transy); |
|
2 | 178 |
} |
887 | 179 |
protected void fillPath(SunGraphics2D sg2d, |
180 |
Path2D.Float p2df, int transx, int transy) |
|
181 |
{ |
|
182 |
GraphicsPrimitive.tracePrimitive("D3DFillPath"); |
|
183 |
d3dr.fillPath(sg2d, p2df, transx, transy); |
|
184 |
} |
|
185 |
protected void fillSpans(SunGraphics2D sg2d, SpanIterator si, |
|
186 |
int transx, int transy) |
|
2 | 187 |
{ |
188 |
GraphicsPrimitive.tracePrimitive("D3DFillSpans"); |
|
887 | 189 |
d3dr.fillSpans(sg2d, si, transx, transy); |
190 |
} |
|
191 |
public void fillParallelogram(SunGraphics2D sg2d, |
|
9653
6a1eff16874d
7043054: REGRESSION: JDK 7 b126 : Wrong userBounds in Paint.createContext()
flar
parents:
5506
diff
changeset
|
192 |
double ux1, double uy1, |
6a1eff16874d
7043054: REGRESSION: JDK 7 b126 : Wrong userBounds in Paint.createContext()
flar
parents:
5506
diff
changeset
|
193 |
double ux2, double uy2, |
887 | 194 |
double x, double y, |
195 |
double dx1, double dy1, |
|
196 |
double dx2, double dy2) |
|
197 |
{ |
|
198 |
GraphicsPrimitive.tracePrimitive("D3DFillParallelogram"); |
|
9653
6a1eff16874d
7043054: REGRESSION: JDK 7 b126 : Wrong userBounds in Paint.createContext()
flar
parents:
5506
diff
changeset
|
199 |
d3dr.fillParallelogram(sg2d, |
6a1eff16874d
7043054: REGRESSION: JDK 7 b126 : Wrong userBounds in Paint.createContext()
flar
parents:
5506
diff
changeset
|
200 |
ux1, uy1, ux2, uy2, |
6a1eff16874d
7043054: REGRESSION: JDK 7 b126 : Wrong userBounds in Paint.createContext()
flar
parents:
5506
diff
changeset
|
201 |
x, y, dx1, dy1, dx2, dy2); |
2 | 202 |
} |
887 | 203 |
public void drawParallelogram(SunGraphics2D sg2d, |
9653
6a1eff16874d
7043054: REGRESSION: JDK 7 b126 : Wrong userBounds in Paint.createContext()
flar
parents:
5506
diff
changeset
|
204 |
double ux1, double uy1, |
6a1eff16874d
7043054: REGRESSION: JDK 7 b126 : Wrong userBounds in Paint.createContext()
flar
parents:
5506
diff
changeset
|
205 |
double ux2, double uy2, |
887 | 206 |
double x, double y, |
207 |
double dx1, double dy1, |
|
208 |
double dx2, double dy2, |
|
209 |
double lw1, double lw2) |
|
2 | 210 |
{ |
887 | 211 |
GraphicsPrimitive.tracePrimitive("D3DDrawParallelogram"); |
9653
6a1eff16874d
7043054: REGRESSION: JDK 7 b126 : Wrong userBounds in Paint.createContext()
flar
parents:
5506
diff
changeset
|
212 |
d3dr.drawParallelogram(sg2d, |
6a1eff16874d
7043054: REGRESSION: JDK 7 b126 : Wrong userBounds in Paint.createContext()
flar
parents:
5506
diff
changeset
|
213 |
ux1, uy1, ux2, uy2, |
6a1eff16874d
7043054: REGRESSION: JDK 7 b126 : Wrong userBounds in Paint.createContext()
flar
parents:
5506
diff
changeset
|
214 |
x, y, dx1, dy1, dx2, dy2, lw1, lw2); |
2 | 215 |
} |
887 | 216 |
public void copyArea(SunGraphics2D sg2d, |
217 |
int x, int y, int w, int h, int dx, int dy) |
|
218 |
{ |
|
219 |
GraphicsPrimitive.tracePrimitive("D3DCopyArea"); |
|
220 |
d3dr.copyArea(sg2d, x, y, w, h, dx, dy); |
|
221 |
} |
|
2 | 222 |
} |
223 |
} |