author | darcy |
Tue, 16 Dec 2014 09:57:33 -0800 | |
changeset 28234 | f694f2576719 |
parent 25859 | 3317bb8137f4 |
child 30469 | bac0a7ff7e1e |
permissions | -rw-r--r-- |
2 | 1 |
/* |
28234
f694f2576719
8067092: Suppress windows-specific deprecation warnings in the java.desktop module
darcy
parents:
25859
diff
changeset
|
2 |
* Copyright (c) 2004, 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 |
||
887 | 28 |
import java.awt.BufferCapabilities; |
29 |
import static java.awt.BufferCapabilities.FlipContents.*; |
|
2 | 30 |
import java.awt.Component; |
31 |
import java.awt.GraphicsConfiguration; |
|
32 |
import java.awt.Transparency; |
|
33 |
import java.awt.image.ColorModel; |
|
34 |
import sun.awt.image.SunVolatileImage; |
|
35 |
import sun.awt.image.VolatileSurfaceManager; |
|
36 |
import sun.awt.windows.WComponentPeer; |
|
37 |
import sun.java2d.SurfaceData; |
|
887 | 38 |
import static sun.java2d.opengl.OGLContext.OGLContextCaps.*; |
39 |
import static sun.java2d.pipe.hw.AccelSurface.*; |
|
40 |
import sun.java2d.pipe.hw.ExtendedBufferCapabilities; |
|
41 |
import static sun.java2d.pipe.hw.ExtendedBufferCapabilities.VSyncType.*; |
|
2 | 42 |
|
43 |
public class WGLVolatileSurfaceManager |
|
44 |
extends VolatileSurfaceManager |
|
45 |
{ |
|
46 |
private boolean accelerationEnabled; |
|
47 |
||
48 |
public WGLVolatileSurfaceManager(SunVolatileImage vImg, Object context) { |
|
49 |
super(vImg, context); |
|
50 |
||
51 |
/* |
|
52 |
* We will attempt to accelerate this image only under the |
|
53 |
* following conditions: |
|
54 |
* - the image is opaque OR |
|
55 |
* - the image is translucent AND |
|
56 |
* - the GraphicsConfig supports the FBO extension OR |
|
57 |
* - the GraphicsConfig has a stored alpha channel |
|
58 |
*/ |
|
59 |
int transparency = vImg.getTransparency(); |
|
60 |
WGLGraphicsConfig gc = (WGLGraphicsConfig)vImg.getGraphicsConfig(); |
|
61 |
accelerationEnabled = |
|
62 |
(transparency == Transparency.OPAQUE) || |
|
63 |
((transparency == Transparency.TRANSLUCENT) && |
|
887 | 64 |
(gc.isCapPresent(CAPS_EXT_FBOBJECT) || |
65 |
gc.isCapPresent(CAPS_STORED_ALPHA))); |
|
2 | 66 |
} |
67 |
||
68 |
protected boolean isAccelerationEnabled() { |
|
69 |
return accelerationEnabled; |
|
70 |
} |
|
71 |
||
72 |
/** |
|
73 |
* Create a pbuffer-based SurfaceData object (or init the backbuffer |
|
74 |
* of an existing window if this is a double buffered GraphicsConfig). |
|
75 |
*/ |
|
28234
f694f2576719
8067092: Suppress windows-specific deprecation warnings in the java.desktop module
darcy
parents:
25859
diff
changeset
|
76 |
@SuppressWarnings("deprecation") |
2 | 77 |
protected SurfaceData initAcceleratedSurface() { |
78 |
SurfaceData sData; |
|
79 |
Component comp = vImg.getComponent(); |
|
80 |
WComponentPeer peer = |
|
81 |
(comp != null) ? (WComponentPeer)comp.getPeer() : null; |
|
82 |
||
83 |
try { |
|
887 | 84 |
boolean createVSynced = false; |
2 | 85 |
boolean forceback = false; |
86 |
if (context instanceof Boolean) { |
|
87 |
forceback = ((Boolean)context).booleanValue(); |
|
887 | 88 |
if (forceback) { |
89 |
BufferCapabilities caps = peer.getBackBufferCaps(); |
|
90 |
if (caps instanceof ExtendedBufferCapabilities) { |
|
91 |
ExtendedBufferCapabilities ebc = |
|
92 |
(ExtendedBufferCapabilities)caps; |
|
93 |
if (ebc.getVSync() == VSYNC_ON && |
|
94 |
ebc.getFlipContents() == COPIED) |
|
95 |
{ |
|
96 |
createVSynced = true; |
|
97 |
forceback = false; |
|
98 |
} |
|
99 |
} |
|
100 |
} |
|
2 | 101 |
} |
102 |
||
103 |
if (forceback) { |
|
104 |
// peer must be non-null in this case |
|
887 | 105 |
sData = WGLSurfaceData.createData(peer, vImg, FLIP_BACKBUFFER); |
2 | 106 |
} else { |
107 |
WGLGraphicsConfig gc = |
|
108 |
(WGLGraphicsConfig)vImg.getGraphicsConfig(); |
|
109 |
ColorModel cm = gc.getColorModel(vImg.getTransparency()); |
|
887 | 110 |
int type = vImg.getForcedAccelSurfaceType(); |
111 |
// if acceleration type is forced (type != UNDEFINED) then |
|
112 |
// use the forced type, otherwise choose one based on caps |
|
113 |
if (type == OGLSurfaceData.UNDEFINED) { |
|
114 |
type = gc.isCapPresent(CAPS_EXT_FBOBJECT) ? |
|
115 |
OGLSurfaceData.FBOBJECT : OGLSurfaceData.PBUFFER; |
|
116 |
} |
|
117 |
if (createVSynced) { |
|
118 |
sData = WGLSurfaceData.createData(peer, vImg, type); |
|
119 |
} else { |
|
120 |
sData = WGLSurfaceData.createData(gc, |
|
121 |
vImg.getWidth(), |
|
122 |
vImg.getHeight(), |
|
123 |
cm, vImg, type); |
|
124 |
} |
|
2 | 125 |
} |
126 |
} catch (NullPointerException ex) { |
|
127 |
sData = null; |
|
128 |
} catch (OutOfMemoryError er) { |
|
129 |
sData = null; |
|
130 |
} |
|
131 |
||
132 |
return sData; |
|
133 |
} |
|
134 |
||
887 | 135 |
@Override |
2 | 136 |
protected boolean isConfigValid(GraphicsConfiguration gc) { |
7761
bada7677e624
7003434: test/closed/java/awt/FullScreen/DisplayChangeVITest/DisplayChangeVITest.java fails with ClassCastExc
bae
parents:
5506
diff
changeset
|
137 |
return ((gc == null) || |
bada7677e624
7003434: test/closed/java/awt/FullScreen/DisplayChangeVITest/DisplayChangeVITest.java fails with ClassCastExc
bae
parents:
5506
diff
changeset
|
138 |
((gc instanceof WGLGraphicsConfig) && |
bada7677e624
7003434: test/closed/java/awt/FullScreen/DisplayChangeVITest/DisplayChangeVITest.java fails with ClassCastExc
bae
parents:
5506
diff
changeset
|
139 |
(gc == vImg.getGraphicsConfig()))); |
2 | 140 |
} |
887 | 141 |
|
142 |
@Override |
|
143 |
public void initContents() { |
|
144 |
if (vImg.getForcedAccelSurfaceType() != OGLSurfaceData.TEXTURE) { |
|
145 |
super.initContents(); |
|
146 |
} |
|
147 |
} |
|
2 | 148 |
} |