1 /* |
|
2 * Copyright 2000-2007 Sun Microsystems, Inc. All Rights Reserved. |
|
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 |
|
7 * published by the Free Software Foundation. Sun designates this |
|
8 * particular file as subject to the "Classpath" exception as provided |
|
9 * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
22 * CA 95054 USA or visit www.sun.com if you need additional information or |
|
23 * have any questions. |
|
24 */ |
|
25 |
|
26 package sun.java2d.windows; |
|
27 |
|
28 import java.awt.Component; |
|
29 import java.awt.GraphicsConfiguration; |
|
30 import java.awt.ImageCapabilities; |
|
31 import java.awt.image.ColorModel; |
|
32 import java.awt.image.VolatileImage; |
|
33 import sun.awt.image.SurfaceManager; |
|
34 import sun.awt.image.SunVolatileImage; |
|
35 import sun.awt.image.VolatileSurfaceManager; |
|
36 import sun.java2d.SurfaceData; |
|
37 |
|
38 import sun.java2d.d3d.D3DBackBufferSurfaceData; |
|
39 |
|
40 public class WinBackBuffer extends SunVolatileImage { |
|
41 |
|
42 /** |
|
43 * Create an image for an attached surface |
|
44 */ |
|
45 public WinBackBuffer(Component c, Win32SurfaceData parentData) { |
|
46 super(c, c.getWidth(), c.getHeight(), parentData); |
|
47 } |
|
48 |
|
49 @Override |
|
50 protected VolatileSurfaceManager createSurfaceManager(Object context, |
|
51 ImageCapabilities caps) |
|
52 { |
|
53 return new WinBackBufferSurfaceManager(this, context); |
|
54 } |
|
55 |
|
56 public Win32OffScreenSurfaceData getHWSurfaceData() { |
|
57 SurfaceData sd = SurfaceData.getPrimarySurfaceData(this); |
|
58 return (sd instanceof Win32OffScreenSurfaceData) ? |
|
59 (Win32OffScreenSurfaceData)sd : null; |
|
60 } |
|
61 |
|
62 private class WinBackBufferSurfaceManager |
|
63 extends WinVolatileSurfaceManager |
|
64 { |
|
65 public WinBackBufferSurfaceManager(SunVolatileImage vImg, |
|
66 Object context) |
|
67 { |
|
68 super(vImg, context); |
|
69 } |
|
70 |
|
71 protected Win32OffScreenSurfaceData createAccelSurface() { |
|
72 GraphicsConfiguration gc = vImg.getGraphicsConfig(); |
|
73 ColorModel cm = getDeviceColorModel(); |
|
74 Win32SurfaceData parent = (Win32SurfaceData)context; |
|
75 |
|
76 Win32OffScreenSurfaceData ret = |
|
77 D3DBackBufferSurfaceData.createData(vImg.getWidth(), |
|
78 vImg.getHeight(), |
|
79 cm, gc, vImg, parent); |
|
80 if (ret == null) { |
|
81 ret = WinBackBufferSurfaceData.createData(vImg.getWidth(), |
|
82 vImg.getHeight(), |
|
83 cm, gc, vImg, parent); |
|
84 } |
|
85 return ret; |
|
86 } |
|
87 |
|
88 /** |
|
89 * Removes this surface manager from the display change listeners. |
|
90 * Since the user don't have access to the VolatileImage |
|
91 * representing the backbuffer, we know that nobody but us |
|
92 * can call it. And we do it when the backbuffer is replaced. |
|
93 */ |
|
94 public void flush() { |
|
95 sun.awt.Win32GraphicsEnvironment ge = |
|
96 (sun.awt.Win32GraphicsEnvironment) |
|
97 java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(); |
|
98 ge.removeDisplayChangedListener(this); |
|
99 } |
|
100 } |
|
101 } |
|