jdk/src/windows/classes/sun/java2d/d3d/D3DBackBufferSurfaceData.java
changeset 930 2f703334f63f
parent 929 d958f883b42a
parent 923 e9301d8f49ef
child 932 2aabadbd9e85
equal deleted inserted replaced
929:d958f883b42a 930:2f703334f63f
     1 /*
       
     2  * Copyright 2005 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.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,
       
    45                                      GraphicsConfiguration gc,
       
    46                                      Image image, int screen,
       
    47                                      Win32SurfaceData parentData)
       
    48     {
       
    49         super(width, height, D3DSurfaceData.D3D_ATTACHED_SURFACE,
       
    50               sType, cm, gc, image, Transparency.OPAQUE);
       
    51         this.parentData = parentData;
       
    52         initSurface(width, height, screen, parentData);
       
    53     }
       
    54 
       
    55     private native void restoreDepthBuffer();
       
    56 
       
    57     @Override
       
    58     public void restoreSurface() {
       
    59         parentData.restoreSurface();
       
    60         // The above call restores the primary surface
       
    61         // to which this backbuffer is attached. But
       
    62         // we need to explicitly restore the depth buffer
       
    63         // associated with this backbuffer surface, because it's not
       
    64         // part of a 'complex' primary surface, and thus will not be
       
    65         // restored as part of the primary surface restoration.
       
    66         restoreDepthBuffer();
       
    67     }
       
    68 
       
    69     public static D3DBackBufferSurfaceData
       
    70         createData(int width, int height,
       
    71                    ColorModel cm, GraphicsConfiguration gc,
       
    72                    Image image,
       
    73                    Win32SurfaceData parentData)
       
    74     {
       
    75         Win32GraphicsDevice gd = (Win32GraphicsDevice)gc.getDevice();
       
    76         if (!gd.isD3DEnabledOnDevice()) {
       
    77             return null;
       
    78         }
       
    79         SurfaceType sType = getSurfaceType(cm, Transparency.OPAQUE);
       
    80         return new
       
    81             D3DBackBufferSurfaceData(width, height,
       
    82                  getSurfaceType(gc, cm,
       
    83                                 D3DSurfaceData.D3D_ATTACHED_SURFACE),
       
    84                  cm, gc, image,
       
    85                  gd.getScreen(), parentData);
       
    86     }
       
    87 }