author | serb |
Wed, 22 Oct 2014 12:33:28 +0400 | |
changeset 27283 | 99c4cb470573 |
parent 27264 | aa300ebffd04 |
child 31155 | 272c0790761f |
permissions | -rw-r--r-- |
2 | 1 |
/* |
25127 | 2 |
* Copyright (c) 2003, 2014, 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.opengl; |
|
27 |
||
14646
94eed98a7ecb
7124347: [macosx] java.lang.InternalError: not implemented yet on call Graphics2D.drawRenderedImage
bae
parents:
12813
diff
changeset
|
28 |
import java.awt.AlphaComposite; |
2 | 29 |
import java.awt.Composite; |
30 |
import java.awt.Transparency; |
|
31 |
import java.awt.geom.AffineTransform; |
|
32 |
import java.awt.image.AffineTransformOp; |
|
33 |
import java.awt.image.BufferedImage; |
|
34 |
import java.awt.image.BufferedImageOp; |
|
35 |
import java.lang.ref.WeakReference; |
|
36 |
import sun.java2d.SurfaceData; |
|
37 |
import sun.java2d.loops.Blit; |
|
38 |
import sun.java2d.loops.CompositeType; |
|
39 |
import sun.java2d.loops.GraphicsPrimitive; |
|
40 |
import sun.java2d.loops.GraphicsPrimitiveMgr; |
|
41 |
import sun.java2d.loops.ScaledBlit; |
|
42 |
import sun.java2d.loops.SurfaceType; |
|
43 |
import sun.java2d.loops.TransformBlit; |
|
44 |
import sun.java2d.pipe.Region; |
|
45 |
import sun.java2d.pipe.RenderBuffer; |
|
46 |
import sun.java2d.pipe.RenderQueue; |
|
47 |
import static sun.java2d.pipe.BufferedOpCodes.*; |
|
16734
da1901d79073
8000406: change files using @GenerateNativeHeader to use @Native
dxu
parents:
14646
diff
changeset
|
48 |
import java.lang.annotation.Native; |
2 | 49 |
|
27264
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
50 |
final class OGLBlitLoops { |
2 | 51 |
|
52 |
static void register() { |
|
53 |
Blit blitIntArgbPreToSurface = |
|
54 |
new OGLSwToSurfaceBlit(SurfaceType.IntArgbPre, |
|
55 |
OGLSurfaceData.PF_INT_ARGB_PRE); |
|
56 |
Blit blitIntArgbPreToTexture = |
|
57 |
new OGLSwToTextureBlit(SurfaceType.IntArgbPre, |
|
58 |
OGLSurfaceData.PF_INT_ARGB_PRE); |
|
27264
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
59 |
TransformBlit transformBlitIntArgbPreToSurface = |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
60 |
new OGLSwToSurfaceTransform(SurfaceType.IntArgbPre, |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
61 |
OGLSurfaceData.PF_INT_ARGB_PRE); |
2 | 62 |
GraphicsPrimitive[] primitives = { |
63 |
// surface->surface ops |
|
64 |
new OGLSurfaceToSurfaceBlit(), |
|
65 |
new OGLSurfaceToSurfaceScale(), |
|
66 |
new OGLSurfaceToSurfaceTransform(), |
|
67 |
||
68 |
// render-to-texture surface->surface ops |
|
69 |
new OGLRTTSurfaceToSurfaceBlit(), |
|
70 |
new OGLRTTSurfaceToSurfaceScale(), |
|
71 |
new OGLRTTSurfaceToSurfaceTransform(), |
|
72 |
||
73 |
// surface->sw ops |
|
74 |
new OGLSurfaceToSwBlit(SurfaceType.IntArgb, |
|
75 |
OGLSurfaceData.PF_INT_ARGB), |
|
25127 | 76 |
new OGLSurfaceToSwBlit(SurfaceType.IntArgbPre, |
77 |
OGLSurfaceData.PF_INT_ARGB_PRE), |
|
2 | 78 |
|
79 |
// sw->surface ops |
|
80 |
blitIntArgbPreToSurface, |
|
81 |
new OGLSwToSurfaceBlit(SurfaceType.IntRgb, |
|
82 |
OGLSurfaceData.PF_INT_RGB), |
|
83 |
new OGLSwToSurfaceBlit(SurfaceType.IntRgbx, |
|
84 |
OGLSurfaceData.PF_INT_RGBX), |
|
85 |
new OGLSwToSurfaceBlit(SurfaceType.IntBgr, |
|
86 |
OGLSurfaceData.PF_INT_BGR), |
|
87 |
new OGLSwToSurfaceBlit(SurfaceType.IntBgrx, |
|
88 |
OGLSurfaceData.PF_INT_BGRX), |
|
1723
4a616c1eac0b
6739267: D3D/OGL: add missing ThreeByteBgr to texture upload blit loop
tdv
parents:
2
diff
changeset
|
89 |
new OGLSwToSurfaceBlit(SurfaceType.ThreeByteBgr, |
4a616c1eac0b
6739267: D3D/OGL: add missing ThreeByteBgr to texture upload blit loop
tdv
parents:
2
diff
changeset
|
90 |
OGLSurfaceData.PF_3BYTE_BGR), |
2 | 91 |
new OGLSwToSurfaceBlit(SurfaceType.Ushort565Rgb, |
92 |
OGLSurfaceData.PF_USHORT_565_RGB), |
|
93 |
new OGLSwToSurfaceBlit(SurfaceType.Ushort555Rgb, |
|
94 |
OGLSurfaceData.PF_USHORT_555_RGB), |
|
95 |
new OGLSwToSurfaceBlit(SurfaceType.Ushort555Rgbx, |
|
96 |
OGLSurfaceData.PF_USHORT_555_RGBX), |
|
97 |
new OGLSwToSurfaceBlit(SurfaceType.ByteGray, |
|
98 |
OGLSurfaceData.PF_BYTE_GRAY), |
|
99 |
new OGLSwToSurfaceBlit(SurfaceType.UshortGray, |
|
100 |
OGLSurfaceData.PF_USHORT_GRAY), |
|
101 |
new OGLGeneralBlit(OGLSurfaceData.OpenGLSurface, |
|
102 |
CompositeType.AnyAlpha, |
|
103 |
blitIntArgbPreToSurface), |
|
104 |
||
27264
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
105 |
new OGLAnyCompositeBlit(), |
14646
94eed98a7ecb
7124347: [macosx] java.lang.InternalError: not implemented yet on call Graphics2D.drawRenderedImage
bae
parents:
12813
diff
changeset
|
106 |
|
2 | 107 |
new OGLSwToSurfaceScale(SurfaceType.IntRgb, |
108 |
OGLSurfaceData.PF_INT_RGB), |
|
109 |
new OGLSwToSurfaceScale(SurfaceType.IntRgbx, |
|
110 |
OGLSurfaceData.PF_INT_RGBX), |
|
111 |
new OGLSwToSurfaceScale(SurfaceType.IntBgr, |
|
112 |
OGLSurfaceData.PF_INT_BGR), |
|
113 |
new OGLSwToSurfaceScale(SurfaceType.IntBgrx, |
|
114 |
OGLSurfaceData.PF_INT_BGRX), |
|
1723
4a616c1eac0b
6739267: D3D/OGL: add missing ThreeByteBgr to texture upload blit loop
tdv
parents:
2
diff
changeset
|
115 |
new OGLSwToSurfaceScale(SurfaceType.ThreeByteBgr, |
4a616c1eac0b
6739267: D3D/OGL: add missing ThreeByteBgr to texture upload blit loop
tdv
parents:
2
diff
changeset
|
116 |
OGLSurfaceData.PF_3BYTE_BGR), |
2 | 117 |
new OGLSwToSurfaceScale(SurfaceType.Ushort565Rgb, |
118 |
OGLSurfaceData.PF_USHORT_565_RGB), |
|
119 |
new OGLSwToSurfaceScale(SurfaceType.Ushort555Rgb, |
|
120 |
OGLSurfaceData.PF_USHORT_555_RGB), |
|
121 |
new OGLSwToSurfaceScale(SurfaceType.Ushort555Rgbx, |
|
122 |
OGLSurfaceData.PF_USHORT_555_RGBX), |
|
123 |
new OGLSwToSurfaceScale(SurfaceType.ByteGray, |
|
124 |
OGLSurfaceData.PF_BYTE_GRAY), |
|
125 |
new OGLSwToSurfaceScale(SurfaceType.UshortGray, |
|
126 |
OGLSurfaceData.PF_USHORT_GRAY), |
|
127 |
new OGLSwToSurfaceScale(SurfaceType.IntArgbPre, |
|
128 |
OGLSurfaceData.PF_INT_ARGB_PRE), |
|
129 |
||
130 |
new OGLSwToSurfaceTransform(SurfaceType.IntRgb, |
|
131 |
OGLSurfaceData.PF_INT_RGB), |
|
132 |
new OGLSwToSurfaceTransform(SurfaceType.IntRgbx, |
|
133 |
OGLSurfaceData.PF_INT_RGBX), |
|
134 |
new OGLSwToSurfaceTransform(SurfaceType.IntBgr, |
|
135 |
OGLSurfaceData.PF_INT_BGR), |
|
136 |
new OGLSwToSurfaceTransform(SurfaceType.IntBgrx, |
|
137 |
OGLSurfaceData.PF_INT_BGRX), |
|
1723
4a616c1eac0b
6739267: D3D/OGL: add missing ThreeByteBgr to texture upload blit loop
tdv
parents:
2
diff
changeset
|
138 |
new OGLSwToSurfaceTransform(SurfaceType.ThreeByteBgr, |
4a616c1eac0b
6739267: D3D/OGL: add missing ThreeByteBgr to texture upload blit loop
tdv
parents:
2
diff
changeset
|
139 |
OGLSurfaceData.PF_3BYTE_BGR), |
2 | 140 |
new OGLSwToSurfaceTransform(SurfaceType.Ushort565Rgb, |
141 |
OGLSurfaceData.PF_USHORT_565_RGB), |
|
142 |
new OGLSwToSurfaceTransform(SurfaceType.Ushort555Rgb, |
|
143 |
OGLSurfaceData.PF_USHORT_555_RGB), |
|
144 |
new OGLSwToSurfaceTransform(SurfaceType.Ushort555Rgbx, |
|
145 |
OGLSurfaceData.PF_USHORT_555_RGBX), |
|
146 |
new OGLSwToSurfaceTransform(SurfaceType.ByteGray, |
|
147 |
OGLSurfaceData.PF_BYTE_GRAY), |
|
148 |
new OGLSwToSurfaceTransform(SurfaceType.UshortGray, |
|
149 |
OGLSurfaceData.PF_USHORT_GRAY), |
|
27264
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
150 |
transformBlitIntArgbPreToSurface, |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
151 |
|
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
152 |
new OGLGeneralTransformedBlit(transformBlitIntArgbPreToSurface), |
2 | 153 |
|
154 |
// texture->surface ops |
|
155 |
new OGLTextureToSurfaceBlit(), |
|
156 |
new OGLTextureToSurfaceScale(), |
|
157 |
new OGLTextureToSurfaceTransform(), |
|
158 |
||
159 |
// sw->texture ops |
|
160 |
blitIntArgbPreToTexture, |
|
161 |
new OGLSwToTextureBlit(SurfaceType.IntRgb, |
|
162 |
OGLSurfaceData.PF_INT_RGB), |
|
163 |
new OGLSwToTextureBlit(SurfaceType.IntRgbx, |
|
164 |
OGLSurfaceData.PF_INT_RGBX), |
|
165 |
new OGLSwToTextureBlit(SurfaceType.IntBgr, |
|
166 |
OGLSurfaceData.PF_INT_BGR), |
|
167 |
new OGLSwToTextureBlit(SurfaceType.IntBgrx, |
|
168 |
OGLSurfaceData.PF_INT_BGRX), |
|
1723
4a616c1eac0b
6739267: D3D/OGL: add missing ThreeByteBgr to texture upload blit loop
tdv
parents:
2
diff
changeset
|
169 |
new OGLSwToTextureBlit(SurfaceType.ThreeByteBgr, |
4a616c1eac0b
6739267: D3D/OGL: add missing ThreeByteBgr to texture upload blit loop
tdv
parents:
2
diff
changeset
|
170 |
OGLSurfaceData.PF_3BYTE_BGR), |
2 | 171 |
new OGLSwToTextureBlit(SurfaceType.Ushort565Rgb, |
172 |
OGLSurfaceData.PF_USHORT_565_RGB), |
|
173 |
new OGLSwToTextureBlit(SurfaceType.Ushort555Rgb, |
|
174 |
OGLSurfaceData.PF_USHORT_555_RGB), |
|
175 |
new OGLSwToTextureBlit(SurfaceType.Ushort555Rgbx, |
|
176 |
OGLSurfaceData.PF_USHORT_555_RGBX), |
|
177 |
new OGLSwToTextureBlit(SurfaceType.ByteGray, |
|
178 |
OGLSurfaceData.PF_BYTE_GRAY), |
|
179 |
new OGLSwToTextureBlit(SurfaceType.UshortGray, |
|
180 |
OGLSurfaceData.PF_USHORT_GRAY), |
|
181 |
new OGLGeneralBlit(OGLSurfaceData.OpenGLTexture, |
|
182 |
CompositeType.SrcNoEa, |
|
183 |
blitIntArgbPreToTexture), |
|
184 |
}; |
|
185 |
GraphicsPrimitiveMgr.register(primitives); |
|
186 |
} |
|
187 |
||
188 |
/** |
|
189 |
* The following offsets are used to pack the parameters in |
|
190 |
* createPackedParams(). (They are also used at the native level when |
|
191 |
* unpacking the params.) |
|
192 |
*/ |
|
16734
da1901d79073
8000406: change files using @GenerateNativeHeader to use @Native
dxu
parents:
14646
diff
changeset
|
193 |
@Native private static final int OFFSET_SRCTYPE = 16; |
da1901d79073
8000406: change files using @GenerateNativeHeader to use @Native
dxu
parents:
14646
diff
changeset
|
194 |
@Native private static final int OFFSET_HINT = 8; |
da1901d79073
8000406: change files using @GenerateNativeHeader to use @Native
dxu
parents:
14646
diff
changeset
|
195 |
@Native private static final int OFFSET_TEXTURE = 3; |
da1901d79073
8000406: change files using @GenerateNativeHeader to use @Native
dxu
parents:
14646
diff
changeset
|
196 |
@Native private static final int OFFSET_RTT = 2; |
da1901d79073
8000406: change files using @GenerateNativeHeader to use @Native
dxu
parents:
14646
diff
changeset
|
197 |
@Native private static final int OFFSET_XFORM = 1; |
da1901d79073
8000406: change files using @GenerateNativeHeader to use @Native
dxu
parents:
14646
diff
changeset
|
198 |
@Native private static final int OFFSET_ISOBLIT = 0; |
2 | 199 |
|
200 |
/** |
|
201 |
* Packs the given parameters into a single int value in order to save |
|
202 |
* space on the rendering queue. |
|
203 |
*/ |
|
204 |
private static int createPackedParams(boolean isoblit, boolean texture, |
|
205 |
boolean rtt, boolean xform, |
|
206 |
int hint, int srctype) |
|
207 |
{ |
|
208 |
return |
|
209 |
((srctype << OFFSET_SRCTYPE) | |
|
210 |
(hint << OFFSET_HINT ) | |
|
211 |
((texture ? 1 : 0) << OFFSET_TEXTURE) | |
|
212 |
((rtt ? 1 : 0) << OFFSET_RTT ) | |
|
213 |
((xform ? 1 : 0) << OFFSET_XFORM ) | |
|
214 |
((isoblit ? 1 : 0) << OFFSET_ISOBLIT)); |
|
215 |
} |
|
216 |
||
217 |
/** |
|
218 |
* Enqueues a BLIT operation with the given parameters. Note that the |
|
219 |
* RenderQueue lock must be held before calling this method. |
|
220 |
*/ |
|
221 |
private static void enqueueBlit(RenderQueue rq, |
|
222 |
SurfaceData src, SurfaceData dst, |
|
223 |
int packedParams, |
|
224 |
int sx1, int sy1, |
|
225 |
int sx2, int sy2, |
|
226 |
double dx1, double dy1, |
|
227 |
double dx2, double dy2) |
|
228 |
{ |
|
229 |
// assert rq.lock.isHeldByCurrentThread(); |
|
230 |
RenderBuffer buf = rq.getBuffer(); |
|
231 |
rq.ensureCapacityAndAlignment(72, 24); |
|
232 |
buf.putInt(BLIT); |
|
233 |
buf.putInt(packedParams); |
|
234 |
buf.putInt(sx1).putInt(sy1); |
|
235 |
buf.putInt(sx2).putInt(sy2); |
|
236 |
buf.putDouble(dx1).putDouble(dy1); |
|
237 |
buf.putDouble(dx2).putDouble(dy2); |
|
238 |
buf.putLong(src.getNativeOps()); |
|
239 |
buf.putLong(dst.getNativeOps()); |
|
240 |
} |
|
241 |
||
242 |
static void Blit(SurfaceData srcData, SurfaceData dstData, |
|
243 |
Composite comp, Region clip, |
|
244 |
AffineTransform xform, int hint, |
|
245 |
int sx1, int sy1, |
|
246 |
int sx2, int sy2, |
|
247 |
double dx1, double dy1, |
|
248 |
double dx2, double dy2, |
|
249 |
int srctype, boolean texture) |
|
250 |
{ |
|
251 |
int ctxflags = 0; |
|
252 |
if (srcData.getTransparency() == Transparency.OPAQUE) { |
|
253 |
ctxflags |= OGLContext.SRC_IS_OPAQUE; |
|
254 |
} |
|
255 |
||
256 |
OGLRenderQueue rq = OGLRenderQueue.getInstance(); |
|
257 |
rq.lock(); |
|
258 |
try { |
|
259 |
// make sure the RenderQueue keeps a hard reference to the |
|
260 |
// source (sysmem) SurfaceData to prevent it from being |
|
261 |
// disposed while the operation is processed on the QFT |
|
262 |
rq.addReference(srcData); |
|
263 |
||
264 |
OGLSurfaceData oglDst = (OGLSurfaceData)dstData; |
|
265 |
if (texture) { |
|
266 |
// make sure we have a current context before uploading |
|
267 |
// the sysmem data to the texture object |
|
268 |
OGLGraphicsConfig gc = oglDst.getOGLGraphicsConfig(); |
|
269 |
OGLContext.setScratchSurface(gc); |
|
270 |
} else { |
|
271 |
OGLContext.validateContext(oglDst, oglDst, |
|
272 |
clip, comp, xform, null, null, |
|
273 |
ctxflags); |
|
274 |
} |
|
275 |
||
276 |
int packedParams = createPackedParams(false, texture, |
|
277 |
false, xform != null, |
|
278 |
hint, srctype); |
|
279 |
enqueueBlit(rq, srcData, dstData, |
|
280 |
packedParams, |
|
281 |
sx1, sy1, sx2, sy2, |
|
282 |
dx1, dy1, dx2, dy2); |
|
283 |
||
284 |
// always flush immediately, since we (currently) have no means |
|
285 |
// of tracking changes to the system memory surface |
|
286 |
rq.flushNow(); |
|
287 |
} finally { |
|
288 |
rq.unlock(); |
|
289 |
} |
|
290 |
} |
|
291 |
||
292 |
/** |
|
293 |
* Note: The srcImg and biop parameters are only used when invoked |
|
294 |
* from the OGLBufImgOps.renderImageWithOp() method; in all other cases, |
|
295 |
* this method can be called with null values for those two parameters, |
|
296 |
* and they will be effectively ignored. |
|
297 |
*/ |
|
298 |
static void IsoBlit(SurfaceData srcData, SurfaceData dstData, |
|
299 |
BufferedImage srcImg, BufferedImageOp biop, |
|
300 |
Composite comp, Region clip, |
|
301 |
AffineTransform xform, int hint, |
|
302 |
int sx1, int sy1, |
|
303 |
int sx2, int sy2, |
|
304 |
double dx1, double dy1, |
|
305 |
double dx2, double dy2, |
|
306 |
boolean texture) |
|
307 |
{ |
|
308 |
int ctxflags = 0; |
|
309 |
if (srcData.getTransparency() == Transparency.OPAQUE) { |
|
310 |
ctxflags |= OGLContext.SRC_IS_OPAQUE; |
|
311 |
} |
|
312 |
||
313 |
OGLRenderQueue rq = OGLRenderQueue.getInstance(); |
|
314 |
rq.lock(); |
|
315 |
try { |
|
316 |
OGLSurfaceData oglSrc = (OGLSurfaceData)srcData; |
|
317 |
OGLSurfaceData oglDst = (OGLSurfaceData)dstData; |
|
318 |
int srctype = oglSrc.getType(); |
|
319 |
boolean rtt; |
|
320 |
OGLSurfaceData srcCtxData; |
|
321 |
if (srctype == OGLSurfaceData.TEXTURE) { |
|
322 |
// the source is a regular texture object; we substitute |
|
323 |
// the destination surface for the purposes of making a |
|
324 |
// context current |
|
325 |
rtt = false; |
|
326 |
srcCtxData = oglDst; |
|
327 |
} else { |
|
328 |
// the source is a pbuffer, backbuffer, or render-to-texture |
|
329 |
// surface; we set rtt to true to differentiate this kind |
|
330 |
// of surface from a regular texture object |
|
331 |
rtt = true; |
|
332 |
if (srctype == OGLSurfaceData.FBOBJECT) { |
|
333 |
srcCtxData = oglDst; |
|
334 |
} else { |
|
335 |
srcCtxData = oglSrc; |
|
336 |
} |
|
337 |
} |
|
338 |
||
339 |
OGLContext.validateContext(srcCtxData, oglDst, |
|
340 |
clip, comp, xform, null, null, |
|
341 |
ctxflags); |
|
342 |
||
343 |
if (biop != null) { |
|
344 |
OGLBufImgOps.enableBufImgOp(rq, oglSrc, srcImg, biop); |
|
345 |
} |
|
346 |
||
347 |
int packedParams = createPackedParams(true, texture, |
|
348 |
rtt, xform != null, |
|
349 |
hint, 0 /*unused*/); |
|
350 |
enqueueBlit(rq, srcData, dstData, |
|
351 |
packedParams, |
|
352 |
sx1, sy1, sx2, sy2, |
|
353 |
dx1, dy1, dx2, dy2); |
|
354 |
||
355 |
if (biop != null) { |
|
356 |
OGLBufImgOps.disableBufImgOp(rq, biop); |
|
357 |
} |
|
358 |
||
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
359 |
if (rtt && oglDst.isOnScreen()) { |
2 | 360 |
// we only have to flush immediately when copying from a |
361 |
// (non-texture) surface to the screen; otherwise Swing apps |
|
362 |
// might appear unresponsive until the auto-flush completes |
|
363 |
rq.flushNow(); |
|
364 |
} |
|
365 |
} finally { |
|
366 |
rq.unlock(); |
|
367 |
} |
|
368 |
} |
|
369 |
} |
|
370 |
||
371 |
class OGLSurfaceToSurfaceBlit extends Blit { |
|
372 |
||
373 |
OGLSurfaceToSurfaceBlit() { |
|
374 |
super(OGLSurfaceData.OpenGLSurface, |
|
375 |
CompositeType.AnyAlpha, |
|
376 |
OGLSurfaceData.OpenGLSurface); |
|
377 |
} |
|
378 |
||
379 |
public void Blit(SurfaceData src, SurfaceData dst, |
|
380 |
Composite comp, Region clip, |
|
381 |
int sx, int sy, int dx, int dy, int w, int h) |
|
382 |
{ |
|
383 |
OGLBlitLoops.IsoBlit(src, dst, |
|
384 |
null, null, |
|
385 |
comp, clip, null, |
|
386 |
AffineTransformOp.TYPE_NEAREST_NEIGHBOR, |
|
387 |
sx, sy, sx+w, sy+h, |
|
388 |
dx, dy, dx+w, dy+h, |
|
389 |
false); |
|
390 |
} |
|
391 |
} |
|
392 |
||
393 |
class OGLSurfaceToSurfaceScale extends ScaledBlit { |
|
394 |
||
395 |
OGLSurfaceToSurfaceScale() { |
|
396 |
super(OGLSurfaceData.OpenGLSurface, |
|
397 |
CompositeType.AnyAlpha, |
|
398 |
OGLSurfaceData.OpenGLSurface); |
|
399 |
} |
|
400 |
||
401 |
public void Scale(SurfaceData src, SurfaceData dst, |
|
402 |
Composite comp, Region clip, |
|
403 |
int sx1, int sy1, |
|
404 |
int sx2, int sy2, |
|
405 |
double dx1, double dy1, |
|
406 |
double dx2, double dy2) |
|
407 |
{ |
|
408 |
OGLBlitLoops.IsoBlit(src, dst, |
|
409 |
null, null, |
|
410 |
comp, clip, null, |
|
411 |
AffineTransformOp.TYPE_NEAREST_NEIGHBOR, |
|
412 |
sx1, sy1, sx2, sy2, |
|
413 |
dx1, dy1, dx2, dy2, |
|
414 |
false); |
|
415 |
} |
|
416 |
} |
|
417 |
||
418 |
class OGLSurfaceToSurfaceTransform extends TransformBlit { |
|
419 |
||
420 |
OGLSurfaceToSurfaceTransform() { |
|
421 |
super(OGLSurfaceData.OpenGLSurface, |
|
422 |
CompositeType.AnyAlpha, |
|
423 |
OGLSurfaceData.OpenGLSurface); |
|
424 |
} |
|
425 |
||
426 |
public void Transform(SurfaceData src, SurfaceData dst, |
|
427 |
Composite comp, Region clip, |
|
428 |
AffineTransform at, int hint, |
|
429 |
int sx, int sy, int dx, int dy, |
|
430 |
int w, int h) |
|
431 |
{ |
|
432 |
OGLBlitLoops.IsoBlit(src, dst, |
|
433 |
null, null, |
|
434 |
comp, clip, at, hint, |
|
435 |
sx, sy, sx+w, sy+h, |
|
436 |
dx, dy, dx+w, dy+h, |
|
437 |
false); |
|
438 |
} |
|
439 |
} |
|
440 |
||
441 |
class OGLRTTSurfaceToSurfaceBlit extends Blit { |
|
442 |
||
443 |
OGLRTTSurfaceToSurfaceBlit() { |
|
444 |
super(OGLSurfaceData.OpenGLSurfaceRTT, |
|
445 |
CompositeType.AnyAlpha, |
|
446 |
OGLSurfaceData.OpenGLSurface); |
|
447 |
} |
|
448 |
||
449 |
public void Blit(SurfaceData src, SurfaceData dst, |
|
450 |
Composite comp, Region clip, |
|
451 |
int sx, int sy, int dx, int dy, int w, int h) |
|
452 |
{ |
|
453 |
OGLBlitLoops.IsoBlit(src, dst, |
|
454 |
null, null, |
|
455 |
comp, clip, null, |
|
456 |
AffineTransformOp.TYPE_NEAREST_NEIGHBOR, |
|
457 |
sx, sy, sx+w, sy+h, |
|
458 |
dx, dy, dx+w, dy+h, |
|
459 |
true); |
|
460 |
} |
|
461 |
} |
|
462 |
||
463 |
class OGLRTTSurfaceToSurfaceScale extends ScaledBlit { |
|
464 |
||
465 |
OGLRTTSurfaceToSurfaceScale() { |
|
466 |
super(OGLSurfaceData.OpenGLSurfaceRTT, |
|
467 |
CompositeType.AnyAlpha, |
|
468 |
OGLSurfaceData.OpenGLSurface); |
|
469 |
} |
|
470 |
||
471 |
public void Scale(SurfaceData src, SurfaceData dst, |
|
472 |
Composite comp, Region clip, |
|
473 |
int sx1, int sy1, |
|
474 |
int sx2, int sy2, |
|
475 |
double dx1, double dy1, |
|
476 |
double dx2, double dy2) |
|
477 |
{ |
|
478 |
OGLBlitLoops.IsoBlit(src, dst, |
|
479 |
null, null, |
|
480 |
comp, clip, null, |
|
481 |
AffineTransformOp.TYPE_NEAREST_NEIGHBOR, |
|
482 |
sx1, sy1, sx2, sy2, |
|
483 |
dx1, dy1, dx2, dy2, |
|
484 |
true); |
|
485 |
} |
|
486 |
} |
|
487 |
||
488 |
class OGLRTTSurfaceToSurfaceTransform extends TransformBlit { |
|
489 |
||
490 |
OGLRTTSurfaceToSurfaceTransform() { |
|
491 |
super(OGLSurfaceData.OpenGLSurfaceRTT, |
|
492 |
CompositeType.AnyAlpha, |
|
493 |
OGLSurfaceData.OpenGLSurface); |
|
494 |
} |
|
495 |
||
496 |
public void Transform(SurfaceData src, SurfaceData dst, |
|
497 |
Composite comp, Region clip, |
|
498 |
AffineTransform at, int hint, |
|
499 |
int sx, int sy, int dx, int dy, int w, int h) |
|
500 |
{ |
|
501 |
OGLBlitLoops.IsoBlit(src, dst, |
|
502 |
null, null, |
|
503 |
comp, clip, at, hint, |
|
504 |
sx, sy, sx+w, sy+h, |
|
505 |
dx, dy, dx+w, dy+h, |
|
506 |
true); |
|
507 |
} |
|
508 |
} |
|
509 |
||
25127 | 510 |
final class OGLSurfaceToSwBlit extends Blit { |
2 | 511 |
|
25127 | 512 |
private final int typeval; |
25189
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
513 |
private WeakReference<SurfaceData> srcTmp; |
2 | 514 |
|
25127 | 515 |
// destination will actually be ArgbPre or Argb |
516 |
OGLSurfaceToSwBlit(final SurfaceType dstType,final int typeval) { |
|
2 | 517 |
super(OGLSurfaceData.OpenGLSurface, |
518 |
CompositeType.SrcNoEa, |
|
519 |
dstType); |
|
520 |
this.typeval = typeval; |
|
521 |
} |
|
522 |
||
25189
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
523 |
private synchronized void complexClipBlit(SurfaceData src, SurfaceData dst, |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
524 |
Composite comp, Region clip, |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
525 |
int sx, int sy, int dx, int dy, |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
526 |
int w, int h) { |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
527 |
SurfaceData cachedSrc = null; |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
528 |
if (srcTmp != null) { |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
529 |
// use cached intermediate surface, if available |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
530 |
cachedSrc = srcTmp.get(); |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
531 |
} |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
532 |
|
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
533 |
// We can convert argb_pre data from OpenGL surface in two places: |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
534 |
// - During OpenGL surface -> SW blit |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
535 |
// - During SW -> SW blit |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
536 |
// The first one is faster when we use opaque OGL surface, because in |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
537 |
// this case we simply skip conversion and use color components as is. |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
538 |
// Because of this we align intermediate buffer type with type of |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
539 |
// destination not source. |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
540 |
final int type = typeval == OGLSurfaceData.PF_INT_ARGB_PRE ? |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
541 |
BufferedImage.TYPE_INT_ARGB_PRE : |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
542 |
BufferedImage.TYPE_INT_ARGB; |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
543 |
|
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
544 |
src = convertFrom(this, src, sx, sy, w, h, cachedSrc, type); |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
545 |
|
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
546 |
// copy intermediate SW to destination SW using complex clip |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
547 |
final Blit performop = Blit.getFromCache(src.getSurfaceType(), |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
548 |
CompositeType.SrcNoEa, |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
549 |
dst.getSurfaceType()); |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
550 |
performop.Blit(src, dst, comp, clip, 0, 0, dx, dy, w, h); |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
551 |
|
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
552 |
if (src != cachedSrc) { |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
553 |
// cache the intermediate surface |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
554 |
srcTmp = new WeakReference<>(src); |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
555 |
} |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
556 |
} |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
557 |
|
2 | 558 |
public void Blit(SurfaceData src, SurfaceData dst, |
559 |
Composite comp, Region clip, |
|
560 |
int sx, int sy, int dx, int dy, |
|
561 |
int w, int h) |
|
562 |
{ |
|
25189
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
563 |
if (clip != null) { |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
564 |
clip = clip.getIntersectionXYWH(dx, dy, w, h); |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
565 |
// At the end this method will flush the RenderQueue, we should exit |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
566 |
// from it as soon as possible. |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
567 |
if (clip.isEmpty()) { |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
568 |
return; |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
569 |
} |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
570 |
sx += clip.getLoX() - dx; |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
571 |
sy += clip.getLoY() - dy; |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
572 |
dx = clip.getLoX(); |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
573 |
dy = clip.getLoY(); |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
574 |
w = clip.getWidth(); |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
575 |
h = clip.getHeight(); |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
576 |
|
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
577 |
if (!clip.isRectangular()) { |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
578 |
complexClipBlit(src, dst, comp, clip, sx, sy, dx, dy, w, h); |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
579 |
return; |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
580 |
} |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
581 |
} |
d9d25c9c0cdf
8041644: [OGL] clip is ignored during surface->sw blit
serb
parents:
25127
diff
changeset
|
582 |
|
2 | 583 |
OGLRenderQueue rq = OGLRenderQueue.getInstance(); |
584 |
rq.lock(); |
|
585 |
try { |
|
586 |
// make sure the RenderQueue keeps a hard reference to the |
|
587 |
// destination (sysmem) SurfaceData to prevent it from being |
|
588 |
// disposed while the operation is processed on the QFT |
|
589 |
rq.addReference(dst); |
|
590 |
||
591 |
RenderBuffer buf = rq.getBuffer(); |
|
592 |
OGLContext.validateContext((OGLSurfaceData)src); |
|
593 |
||
594 |
rq.ensureCapacityAndAlignment(48, 32); |
|
595 |
buf.putInt(SURFACE_TO_SW_BLIT); |
|
596 |
buf.putInt(sx).putInt(sy); |
|
597 |
buf.putInt(dx).putInt(dy); |
|
598 |
buf.putInt(w).putInt(h); |
|
599 |
buf.putInt(typeval); |
|
600 |
buf.putLong(src.getNativeOps()); |
|
601 |
buf.putLong(dst.getNativeOps()); |
|
602 |
||
603 |
// always flush immediately |
|
604 |
rq.flushNow(); |
|
605 |
} finally { |
|
606 |
rq.unlock(); |
|
607 |
} |
|
608 |
} |
|
609 |
} |
|
610 |
||
611 |
class OGLSwToSurfaceBlit extends Blit { |
|
612 |
||
613 |
private int typeval; |
|
614 |
||
615 |
OGLSwToSurfaceBlit(SurfaceType srcType, int typeval) { |
|
616 |
super(srcType, |
|
617 |
CompositeType.AnyAlpha, |
|
618 |
OGLSurfaceData.OpenGLSurface); |
|
619 |
this.typeval = typeval; |
|
620 |
} |
|
621 |
||
622 |
public void Blit(SurfaceData src, SurfaceData dst, |
|
623 |
Composite comp, Region clip, |
|
624 |
int sx, int sy, int dx, int dy, int w, int h) |
|
625 |
{ |
|
626 |
OGLBlitLoops.Blit(src, dst, |
|
627 |
comp, clip, null, |
|
628 |
AffineTransformOp.TYPE_NEAREST_NEIGHBOR, |
|
629 |
sx, sy, sx+w, sy+h, |
|
630 |
dx, dy, dx+w, dy+h, |
|
631 |
typeval, false); |
|
632 |
} |
|
633 |
} |
|
634 |
||
635 |
class OGLSwToSurfaceScale extends ScaledBlit { |
|
636 |
||
637 |
private int typeval; |
|
638 |
||
639 |
OGLSwToSurfaceScale(SurfaceType srcType, int typeval) { |
|
640 |
super(srcType, |
|
641 |
CompositeType.AnyAlpha, |
|
642 |
OGLSurfaceData.OpenGLSurface); |
|
643 |
this.typeval = typeval; |
|
644 |
} |
|
645 |
||
646 |
public void Scale(SurfaceData src, SurfaceData dst, |
|
647 |
Composite comp, Region clip, |
|
648 |
int sx1, int sy1, |
|
649 |
int sx2, int sy2, |
|
650 |
double dx1, double dy1, |
|
651 |
double dx2, double dy2) |
|
652 |
{ |
|
653 |
OGLBlitLoops.Blit(src, dst, |
|
654 |
comp, clip, null, |
|
655 |
AffineTransformOp.TYPE_NEAREST_NEIGHBOR, |
|
656 |
sx1, sy1, sx2, sy2, |
|
657 |
dx1, dy1, dx2, dy2, |
|
658 |
typeval, false); |
|
659 |
} |
|
660 |
} |
|
661 |
||
662 |
class OGLSwToSurfaceTransform extends TransformBlit { |
|
663 |
||
664 |
private int typeval; |
|
665 |
||
666 |
OGLSwToSurfaceTransform(SurfaceType srcType, int typeval) { |
|
667 |
super(srcType, |
|
668 |
CompositeType.AnyAlpha, |
|
669 |
OGLSurfaceData.OpenGLSurface); |
|
670 |
this.typeval = typeval; |
|
671 |
} |
|
672 |
||
673 |
public void Transform(SurfaceData src, SurfaceData dst, |
|
674 |
Composite comp, Region clip, |
|
675 |
AffineTransform at, int hint, |
|
676 |
int sx, int sy, int dx, int dy, int w, int h) |
|
677 |
{ |
|
678 |
OGLBlitLoops.Blit(src, dst, |
|
679 |
comp, clip, at, hint, |
|
680 |
sx, sy, sx+w, sy+h, |
|
681 |
dx, dy, dx+w, dy+h, |
|
682 |
typeval, false); |
|
683 |
} |
|
684 |
} |
|
685 |
||
686 |
class OGLSwToTextureBlit extends Blit { |
|
687 |
||
688 |
private int typeval; |
|
689 |
||
690 |
OGLSwToTextureBlit(SurfaceType srcType, int typeval) { |
|
691 |
super(srcType, |
|
692 |
CompositeType.SrcNoEa, |
|
693 |
OGLSurfaceData.OpenGLTexture); |
|
694 |
this.typeval = typeval; |
|
695 |
} |
|
696 |
||
697 |
public void Blit(SurfaceData src, SurfaceData dst, |
|
698 |
Composite comp, Region clip, |
|
699 |
int sx, int sy, int dx, int dy, int w, int h) |
|
700 |
{ |
|
701 |
OGLBlitLoops.Blit(src, dst, |
|
702 |
comp, clip, null, |
|
703 |
AffineTransformOp.TYPE_NEAREST_NEIGHBOR, |
|
704 |
sx, sy, sx+w, sy+h, |
|
705 |
dx, dy, dx+w, dy+h, |
|
706 |
typeval, true); |
|
707 |
} |
|
708 |
} |
|
709 |
||
710 |
class OGLTextureToSurfaceBlit extends Blit { |
|
711 |
||
712 |
OGLTextureToSurfaceBlit() { |
|
713 |
super(OGLSurfaceData.OpenGLTexture, |
|
714 |
CompositeType.AnyAlpha, |
|
715 |
OGLSurfaceData.OpenGLSurface); |
|
716 |
} |
|
717 |
||
718 |
public void Blit(SurfaceData src, SurfaceData dst, |
|
719 |
Composite comp, Region clip, |
|
720 |
int sx, int sy, int dx, int dy, int w, int h) |
|
721 |
{ |
|
722 |
OGLBlitLoops.IsoBlit(src, dst, |
|
723 |
null, null, |
|
724 |
comp, clip, null, |
|
725 |
AffineTransformOp.TYPE_NEAREST_NEIGHBOR, |
|
726 |
sx, sy, sx+w, sy+h, |
|
727 |
dx, dy, dx+w, dy+h, |
|
728 |
true); |
|
729 |
} |
|
730 |
} |
|
731 |
||
732 |
class OGLTextureToSurfaceScale extends ScaledBlit { |
|
733 |
||
734 |
OGLTextureToSurfaceScale() { |
|
735 |
super(OGLSurfaceData.OpenGLTexture, |
|
736 |
CompositeType.AnyAlpha, |
|
737 |
OGLSurfaceData.OpenGLSurface); |
|
738 |
} |
|
739 |
||
740 |
public void Scale(SurfaceData src, SurfaceData dst, |
|
741 |
Composite comp, Region clip, |
|
742 |
int sx1, int sy1, |
|
743 |
int sx2, int sy2, |
|
744 |
double dx1, double dy1, |
|
745 |
double dx2, double dy2) |
|
746 |
{ |
|
747 |
OGLBlitLoops.IsoBlit(src, dst, |
|
748 |
null, null, |
|
749 |
comp, clip, null, |
|
750 |
AffineTransformOp.TYPE_NEAREST_NEIGHBOR, |
|
751 |
sx1, sy1, sx2, sy2, |
|
752 |
dx1, dy1, dx2, dy2, |
|
753 |
true); |
|
754 |
} |
|
755 |
} |
|
756 |
||
757 |
class OGLTextureToSurfaceTransform extends TransformBlit { |
|
758 |
||
759 |
OGLTextureToSurfaceTransform() { |
|
760 |
super(OGLSurfaceData.OpenGLTexture, |
|
761 |
CompositeType.AnyAlpha, |
|
762 |
OGLSurfaceData.OpenGLSurface); |
|
763 |
} |
|
764 |
||
765 |
public void Transform(SurfaceData src, SurfaceData dst, |
|
766 |
Composite comp, Region clip, |
|
767 |
AffineTransform at, int hint, |
|
768 |
int sx, int sy, int dx, int dy, |
|
769 |
int w, int h) |
|
770 |
{ |
|
771 |
OGLBlitLoops.IsoBlit(src, dst, |
|
772 |
null, null, |
|
773 |
comp, clip, at, hint, |
|
774 |
sx, sy, sx+w, sy+h, |
|
775 |
dx, dy, dx+w, dy+h, |
|
776 |
true); |
|
777 |
} |
|
778 |
} |
|
779 |
||
780 |
/** |
|
21278 | 781 |
* This general Blit implementation converts any source surface to an |
2 | 782 |
* intermediate IntArgbPre surface, and then uses the more specific |
783 |
* IntArgbPre->OpenGLSurface/Texture loop to get the intermediate |
|
27264
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
784 |
* (premultiplied) surface down to OpenGL using simple blit. |
2 | 785 |
*/ |
786 |
class OGLGeneralBlit extends Blit { |
|
787 |
||
27264
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
788 |
private final Blit performop; |
24522
3a0bbf9f5e81
8038644: Fix raw and unchecked warnings in sun.java2d.*
henryjen
parents:
21278
diff
changeset
|
789 |
private WeakReference<SurfaceData> srcTmp; |
2 | 790 |
|
791 |
OGLGeneralBlit(SurfaceType dstType, |
|
792 |
CompositeType compType, |
|
793 |
Blit performop) |
|
794 |
{ |
|
795 |
super(SurfaceType.Any, compType, dstType); |
|
796 |
this.performop = performop; |
|
797 |
} |
|
798 |
||
799 |
public synchronized void Blit(SurfaceData src, SurfaceData dst, |
|
800 |
Composite comp, Region clip, |
|
801 |
int sx, int sy, int dx, int dy, |
|
802 |
int w, int h) |
|
803 |
{ |
|
804 |
Blit convertsrc = Blit.getFromCache(src.getSurfaceType(), |
|
805 |
CompositeType.SrcNoEa, |
|
806 |
SurfaceType.IntArgbPre); |
|
807 |
||
808 |
SurfaceData cachedSrc = null; |
|
809 |
if (srcTmp != null) { |
|
810 |
// use cached intermediate surface, if available |
|
24522
3a0bbf9f5e81
8038644: Fix raw and unchecked warnings in sun.java2d.*
henryjen
parents:
21278
diff
changeset
|
811 |
cachedSrc = srcTmp.get(); |
2 | 812 |
} |
813 |
||
814 |
// convert source to IntArgbPre |
|
815 |
src = convertFrom(convertsrc, src, sx, sy, w, h, |
|
816 |
cachedSrc, BufferedImage.TYPE_INT_ARGB_PRE); |
|
817 |
||
818 |
// copy IntArgbPre intermediate surface to OpenGL surface |
|
819 |
performop.Blit(src, dst, comp, clip, |
|
820 |
0, 0, dx, dy, w, h); |
|
821 |
||
822 |
if (src != cachedSrc) { |
|
823 |
// cache the intermediate surface |
|
24522
3a0bbf9f5e81
8038644: Fix raw and unchecked warnings in sun.java2d.*
henryjen
parents:
21278
diff
changeset
|
824 |
srcTmp = new WeakReference<>(src); |
2 | 825 |
} |
826 |
} |
|
827 |
} |
|
14646
94eed98a7ecb
7124347: [macosx] java.lang.InternalError: not implemented yet on call Graphics2D.drawRenderedImage
bae
parents:
12813
diff
changeset
|
828 |
|
27264
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
829 |
/** |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
830 |
* This general TransformedBlit implementation converts any source surface to an |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
831 |
* intermediate IntArgbPre surface, and then uses the more specific |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
832 |
* IntArgbPre->OpenGLSurface/Texture loop to get the intermediate |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
833 |
* (premultiplied) surface down to OpenGL using simple transformBlit. |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
834 |
*/ |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
835 |
final class OGLGeneralTransformedBlit extends TransformBlit { |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
836 |
|
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
837 |
private final TransformBlit performop; |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
838 |
private WeakReference<SurfaceData> srcTmp; |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
839 |
|
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
840 |
OGLGeneralTransformedBlit(final TransformBlit performop) { |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
841 |
super(SurfaceType.Any, CompositeType.AnyAlpha, |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
842 |
OGLSurfaceData.OpenGLSurface); |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
843 |
this.performop = performop; |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
844 |
} |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
845 |
|
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
846 |
@Override |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
847 |
public synchronized void Transform(SurfaceData src, SurfaceData dst, |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
848 |
Composite comp, Region clip, |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
849 |
AffineTransform at, int hint, int srcx, |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
850 |
int srcy, int dstx, int dsty, int width, |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
851 |
int height){ |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
852 |
Blit convertsrc = Blit.getFromCache(src.getSurfaceType(), |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
853 |
CompositeType.SrcNoEa, |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
854 |
SurfaceType.IntArgbPre); |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
855 |
// use cached intermediate surface, if available |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
856 |
final SurfaceData cachedSrc = srcTmp != null ? srcTmp.get() : null; |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
857 |
// convert source to IntArgbPre |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
858 |
src = convertFrom(convertsrc, src, srcx, srcy, width, height, cachedSrc, |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
859 |
BufferedImage.TYPE_INT_ARGB_PRE); |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
860 |
|
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
861 |
// transform IntArgbPre intermediate surface to OpenGL surface |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
862 |
performop.Transform(src, dst, comp, clip, at, hint, 0, 0, dstx, dsty, |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
863 |
width, height); |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
864 |
|
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
865 |
if (src != cachedSrc) { |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
866 |
// cache the intermediate surface |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
867 |
srcTmp = new WeakReference<>(src); |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
868 |
} |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
869 |
} |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
870 |
} |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
871 |
|
27283
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
27264
diff
changeset
|
872 |
final class OGLAnyCompositeBlit extends Blit { |
14646
94eed98a7ecb
7124347: [macosx] java.lang.InternalError: not implemented yet on call Graphics2D.drawRenderedImage
bae
parents:
12813
diff
changeset
|
873 |
private WeakReference<SurfaceData> dstTmp; |
94eed98a7ecb
7124347: [macosx] java.lang.InternalError: not implemented yet on call Graphics2D.drawRenderedImage
bae
parents:
12813
diff
changeset
|
874 |
|
27264
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
875 |
OGLAnyCompositeBlit() { |
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
876 |
super(SurfaceType.Any, CompositeType.Any, OGLSurfaceData.OpenGLSurface); |
14646
94eed98a7ecb
7124347: [macosx] java.lang.InternalError: not implemented yet on call Graphics2D.drawRenderedImage
bae
parents:
12813
diff
changeset
|
877 |
} |
27264
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
878 |
|
14646
94eed98a7ecb
7124347: [macosx] java.lang.InternalError: not implemented yet on call Graphics2D.drawRenderedImage
bae
parents:
12813
diff
changeset
|
879 |
public synchronized void Blit(SurfaceData src, SurfaceData dst, |
94eed98a7ecb
7124347: [macosx] java.lang.InternalError: not implemented yet on call Graphics2D.drawRenderedImage
bae
parents:
12813
diff
changeset
|
880 |
Composite comp, Region clip, |
94eed98a7ecb
7124347: [macosx] java.lang.InternalError: not implemented yet on call Graphics2D.drawRenderedImage
bae
parents:
12813
diff
changeset
|
881 |
int sx, int sy, int dx, int dy, |
94eed98a7ecb
7124347: [macosx] java.lang.InternalError: not implemented yet on call Graphics2D.drawRenderedImage
bae
parents:
12813
diff
changeset
|
882 |
int w, int h) |
94eed98a7ecb
7124347: [macosx] java.lang.InternalError: not implemented yet on call Graphics2D.drawRenderedImage
bae
parents:
12813
diff
changeset
|
883 |
{ |
94eed98a7ecb
7124347: [macosx] java.lang.InternalError: not implemented yet on call Graphics2D.drawRenderedImage
bae
parents:
12813
diff
changeset
|
884 |
Blit convertdst = Blit.getFromCache(dst.getSurfaceType(), |
94eed98a7ecb
7124347: [macosx] java.lang.InternalError: not implemented yet on call Graphics2D.drawRenderedImage
bae
parents:
12813
diff
changeset
|
885 |
CompositeType.SrcNoEa, |
94eed98a7ecb
7124347: [macosx] java.lang.InternalError: not implemented yet on call Graphics2D.drawRenderedImage
bae
parents:
12813
diff
changeset
|
886 |
SurfaceType.IntArgbPre); |
94eed98a7ecb
7124347: [macosx] java.lang.InternalError: not implemented yet on call Graphics2D.drawRenderedImage
bae
parents:
12813
diff
changeset
|
887 |
|
94eed98a7ecb
7124347: [macosx] java.lang.InternalError: not implemented yet on call Graphics2D.drawRenderedImage
bae
parents:
12813
diff
changeset
|
888 |
SurfaceData cachedDst = null; |
94eed98a7ecb
7124347: [macosx] java.lang.InternalError: not implemented yet on call Graphics2D.drawRenderedImage
bae
parents:
12813
diff
changeset
|
889 |
|
94eed98a7ecb
7124347: [macosx] java.lang.InternalError: not implemented yet on call Graphics2D.drawRenderedImage
bae
parents:
12813
diff
changeset
|
890 |
if (dstTmp != null) { |
94eed98a7ecb
7124347: [macosx] java.lang.InternalError: not implemented yet on call Graphics2D.drawRenderedImage
bae
parents:
12813
diff
changeset
|
891 |
// use cached intermediate surface, if available |
94eed98a7ecb
7124347: [macosx] java.lang.InternalError: not implemented yet on call Graphics2D.drawRenderedImage
bae
parents:
12813
diff
changeset
|
892 |
cachedDst = dstTmp.get(); |
94eed98a7ecb
7124347: [macosx] java.lang.InternalError: not implemented yet on call Graphics2D.drawRenderedImage
bae
parents:
12813
diff
changeset
|
893 |
} |
94eed98a7ecb
7124347: [macosx] java.lang.InternalError: not implemented yet on call Graphics2D.drawRenderedImage
bae
parents:
12813
diff
changeset
|
894 |
|
27264
aa300ebffd04
8029253: [macosx] Performance problems with Retina display on Mac OS X
serb
parents:
25859
diff
changeset
|
895 |
// convert destination to IntArgbPre |
14646
94eed98a7ecb
7124347: [macosx] java.lang.InternalError: not implemented yet on call Graphics2D.drawRenderedImage
bae
parents:
12813
diff
changeset
|
896 |
SurfaceData dstBuffer = convertFrom(convertdst, dst, dx, dy, w, h, |
94eed98a7ecb
7124347: [macosx] java.lang.InternalError: not implemented yet on call Graphics2D.drawRenderedImage
bae
parents:
12813
diff
changeset
|
897 |
cachedDst, BufferedImage.TYPE_INT_ARGB_PRE); |
27283
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
27264
diff
changeset
|
898 |
Region bufferClip = |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
27264
diff
changeset
|
899 |
clip == null ? null : clip.getTranslatedRegion(-dx, -dy); |
14646
94eed98a7ecb
7124347: [macosx] java.lang.InternalError: not implemented yet on call Graphics2D.drawRenderedImage
bae
parents:
12813
diff
changeset
|
900 |
|
94eed98a7ecb
7124347: [macosx] java.lang.InternalError: not implemented yet on call Graphics2D.drawRenderedImage
bae
parents:
12813
diff
changeset
|
901 |
Blit performop = Blit.getFromCache(src.getSurfaceType(), |
94eed98a7ecb
7124347: [macosx] java.lang.InternalError: not implemented yet on call Graphics2D.drawRenderedImage
bae
parents:
12813
diff
changeset
|
902 |
CompositeType.Any, dstBuffer.getSurfaceType()); |
27283
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
27264
diff
changeset
|
903 |
performop.Blit(src, dstBuffer, comp, bufferClip, sx, sy, 0, 0, w, h); |
14646
94eed98a7ecb
7124347: [macosx] java.lang.InternalError: not implemented yet on call Graphics2D.drawRenderedImage
bae
parents:
12813
diff
changeset
|
904 |
|
94eed98a7ecb
7124347: [macosx] java.lang.InternalError: not implemented yet on call Graphics2D.drawRenderedImage
bae
parents:
12813
diff
changeset
|
905 |
if (dstBuffer != cachedDst) { |
94eed98a7ecb
7124347: [macosx] java.lang.InternalError: not implemented yet on call Graphics2D.drawRenderedImage
bae
parents:
12813
diff
changeset
|
906 |
// cache the intermediate surface |
24522
3a0bbf9f5e81
8038644: Fix raw and unchecked warnings in sun.java2d.*
henryjen
parents:
21278
diff
changeset
|
907 |
dstTmp = new WeakReference<>(dstBuffer); |
14646
94eed98a7ecb
7124347: [macosx] java.lang.InternalError: not implemented yet on call Graphics2D.drawRenderedImage
bae
parents:
12813
diff
changeset
|
908 |
} |
94eed98a7ecb
7124347: [macosx] java.lang.InternalError: not implemented yet on call Graphics2D.drawRenderedImage
bae
parents:
12813
diff
changeset
|
909 |
|
94eed98a7ecb
7124347: [macosx] java.lang.InternalError: not implemented yet on call Graphics2D.drawRenderedImage
bae
parents:
12813
diff
changeset
|
910 |
// now blit the buffer back to the destination |
94eed98a7ecb
7124347: [macosx] java.lang.InternalError: not implemented yet on call Graphics2D.drawRenderedImage
bae
parents:
12813
diff
changeset
|
911 |
convertdst = Blit.getFromCache(dstBuffer.getSurfaceType(), |
94eed98a7ecb
7124347: [macosx] java.lang.InternalError: not implemented yet on call Graphics2D.drawRenderedImage
bae
parents:
12813
diff
changeset
|
912 |
CompositeType.SrcNoEa, |
94eed98a7ecb
7124347: [macosx] java.lang.InternalError: not implemented yet on call Graphics2D.drawRenderedImage
bae
parents:
12813
diff
changeset
|
913 |
dst.getSurfaceType()); |
94eed98a7ecb
7124347: [macosx] java.lang.InternalError: not implemented yet on call Graphics2D.drawRenderedImage
bae
parents:
12813
diff
changeset
|
914 |
convertdst.Blit(dstBuffer, dst, AlphaComposite.Src, |
94eed98a7ecb
7124347: [macosx] java.lang.InternalError: not implemented yet on call Graphics2D.drawRenderedImage
bae
parents:
12813
diff
changeset
|
915 |
clip, 0, 0, dx, dy, w, h); |
94eed98a7ecb
7124347: [macosx] java.lang.InternalError: not implemented yet on call Graphics2D.drawRenderedImage
bae
parents:
12813
diff
changeset
|
916 |
} |
94eed98a7ecb
7124347: [macosx] java.lang.InternalError: not implemented yet on call Graphics2D.drawRenderedImage
bae
parents:
12813
diff
changeset
|
917 |
} |