01: /*
02: * Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
03: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
04: *
05: * This code is free software; you can redistribute it and/or modify it
06: * under the terms of the GNU General Public License version 2 only, as
07: * published by the Free Software Foundation. Sun designates this
08: * particular file as subject to the "Classpath" exception as provided
09: * 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.d3d;
27:
28: import java.awt.GraphicsConfiguration;
29: import java.awt.Image;
30: import java.awt.Transparency;
31: import java.awt.image.ColorModel;
32: import sun.awt.Win32GraphicsDevice;
33: import sun.java2d.loops.SurfaceType;
34: import sun.java2d.windows.Win32SurfaceData;
35:
36: public class D3DBackBufferSurfaceData extends D3DSurfaceData {
37:
38: private Win32SurfaceData parentData;
39:
40: /**
41: * Private constructor. Use createData() to create an object.
42: */
43: private D3DBackBufferSurfaceData(int width, int height,
44: SurfaceType sType, ColorModel cm, GraphicsConfiguration gc,
45: Image image, int screen, Win32SurfaceData parentData) {
46: super (width, height, D3DSurfaceData.D3D_ATTACHED_SURFACE,
47: sType, cm, gc, image, Transparency.OPAQUE);
48: this .parentData = parentData;
49: initSurface(width, height, screen, parentData);
50: }
51:
52: private native void restoreDepthBuffer();
53:
54: @Override
55: public void restoreSurface() {
56: parentData.restoreSurface();
57: // The above call restores the primary surface
58: // to which this backbuffer is attached. But
59: // we need to explicitly restore the depth buffer
60: // associated with this backbuffer surface, because it's not
61: // part of a 'complex' primary surface, and thus will not be
62: // restored as part of the primary surface restoration.
63: restoreDepthBuffer();
64: }
65:
66: public static D3DBackBufferSurfaceData createData(int width,
67: int height, ColorModel cm, GraphicsConfiguration gc,
68: Image image, Win32SurfaceData parentData) {
69: Win32GraphicsDevice gd = (Win32GraphicsDevice) gc.getDevice();
70: if (!gd.isD3DEnabledOnDevice()) {
71: return null;
72: }
73: SurfaceType sType = getSurfaceType(cm, Transparency.OPAQUE);
74: return new D3DBackBufferSurfaceData(width, height,
75: getSurfaceType(gc, cm,
76: D3DSurfaceData.D3D_ATTACHED_SURFACE), cm, gc,
77: image, gd.getScreen(), parentData);
78: }
79: }
|