9 * by Oracle in the LICENSE file that accompanied this code.
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 *
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.
24 */
25
26 package sun.awt;
27
28 import java.awt.AWTError;
29 import java.awt.GraphicsConfiguration;
30 import java.awt.GraphicsDevice;
31 import java.awt.peer.ComponentPeer;
32 import java.lang.ref.WeakReference;
33 import java.util.ArrayList;
34 import java.util.ListIterator;
35
36 import sun.awt.windows.WToolkit;
37 import sun.java2d.SunGraphicsEnvironment;
38 import sun.java2d.SurfaceManagerFactory;
39 import sun.java2d.WindowsSurfaceManagerFactory;
40 import sun.java2d.d3d.D3DGraphicsDevice;
41 import sun.java2d.windows.WindowsFlags;
42
43 /**
44 * This is an implementation of a GraphicsEnvironment object for the
45 * default local GraphicsEnvironment used by the Java Runtime Environment
46 * for Windows.
47 *
48 * @see GraphicsDevice
49 * @see GraphicsConfiguration
50 */
51
52 public final class Win32GraphicsEnvironment extends SunGraphicsEnvironment {
53
54 static final float debugScaleX;
237 GraphicsConfiguration gc;
238 if (peer != null && (gc = peer.getGraphicsConfiguration()) != null) {
239 GraphicsDevice gd = gc.getDevice();
240 if (gd instanceof D3DGraphicsDevice) {
241 return ((D3DGraphicsDevice)gd).isD3DEnabledOnDevice();
242 }
243 }
244 return false;
245 }
246
247 private static volatile boolean isDWMCompositionEnabled;
248 /**
249 * Returns true if dwm composition is currently enabled, false otherwise.
250 *
251 * @return true if dwm composition is enabled, false otherwise
252 */
253 public static boolean isDWMCompositionEnabled() {
254 return isDWMCompositionEnabled;
255 }
256
257 /**
258 * Called from the native code when DWM composition state changed.
259 * May be called multiple times during the lifetime of the application.
260 * REMIND: we may want to create a listener mechanism for this.
261 *
262 * Note: called on the Toolkit thread, no user code or locks are allowed.
263 *
264 * @param enabled indicates the state of dwm composition
265 */
266 private static void dwmCompositionChanged(boolean enabled) {
267 isDWMCompositionEnabled = enabled;
268 }
269
270 /**
271 * Used to find out if the OS is Windows Vista or later.
272 *
273 * @return {@code true} if the OS is Vista or later, {@code false} otherwise
274 */
275 public static native boolean isVistaOS();
276 }
|
9 * by Oracle in the LICENSE file that accompanied this code.
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 *
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.
24 */
25
26 package sun.awt;
27
28 import java.awt.AWTError;
29 import java.awt.EventQueue;
30 import java.awt.GraphicsConfiguration;
31 import java.awt.GraphicsDevice;
32 import java.awt.peer.ComponentPeer;
33 import java.lang.ref.WeakReference;
34 import java.util.ArrayList;
35 import java.util.HashSet;
36 import java.util.ListIterator;
37 import java.util.Set;
38
39 import sun.awt.windows.WToolkit;
40 import sun.java2d.SunGraphicsEnvironment;
41 import sun.java2d.SurfaceManagerFactory;
42 import sun.java2d.WindowsSurfaceManagerFactory;
43 import sun.java2d.d3d.D3DGraphicsDevice;
44 import sun.java2d.windows.WindowsFlags;
45
46 /**
47 * This is an implementation of a GraphicsEnvironment object for the
48 * default local GraphicsEnvironment used by the Java Runtime Environment
49 * for Windows.
50 *
51 * @see GraphicsDevice
52 * @see GraphicsConfiguration
53 */
54
55 public final class Win32GraphicsEnvironment extends SunGraphicsEnvironment {
56
57 static final float debugScaleX;
240 GraphicsConfiguration gc;
241 if (peer != null && (gc = peer.getGraphicsConfiguration()) != null) {
242 GraphicsDevice gd = gc.getDevice();
243 if (gd instanceof D3DGraphicsDevice) {
244 return ((D3DGraphicsDevice)gd).isD3DEnabledOnDevice();
245 }
246 }
247 return false;
248 }
249
250 private static volatile boolean isDWMCompositionEnabled;
251 /**
252 * Returns true if dwm composition is currently enabled, false otherwise.
253 *
254 * @return true if dwm composition is enabled, false otherwise
255 */
256 public static boolean isDWMCompositionEnabled() {
257 return isDWMCompositionEnabled;
258 }
259
260 private static final Set<Runnable> dwmCompositionChangeListeners = new HashSet<>();
261
262 public static void addDwmCompositionChangeListener(Runnable listener) {
263 dwmCompositionChangeListeners.add(listener);
264 }
265
266 public static void removeDwmCompositionChangeListener(Runnable listener) {
267 dwmCompositionChangeListeners.remove(listener);
268 }
269
270 /**
271 * Called from the native code when DWM composition state changed. May be
272 * called multiple times during the lifetime of the application.
273 *
274 * Note: called on the Toolkit thread, no user code or locks are allowed.
275 *
276 * @param enabled indicates the state of dwm composition
277 */
278 private static void dwmCompositionChanged(boolean enabled) {
279 isDWMCompositionEnabled = enabled;
280 if (dwmCompositionChangeListeners != null) {
281 EventQueue.invokeLater(()
282 -> dwmCompositionChangeListeners.forEach(Runnable::run));
283 }
284 }
285
286 /**
287 * Used to find out if the OS is Windows Vista or later.
288 *
289 * @return {@code true} if the OS is Vista or later, {@code false} otherwise
290 */
291 public static native boolean isVistaOS();
292 }
|