3261N/A * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * This is an implementation of a GraphicsDevice object for a single 0N/A * @see GraphicsEnvironment 0N/A * @see GraphicsConfiguration 0N/A // Note that we do not synchronize access to this variable - it doesn't 0N/A // really matter if a thread does an operation on graphics device which is 0N/A // about to become invalid (or already become) - we are prepared to deal 0N/A // with this on the native level. 0N/A // keep track of top-level windows on this display 430N/A // REMIND: we may disable the use of pixel formats for some accelerated 430N/A // pipelines which are mutually exclusive with opengl, for which 430N/A // pixel formats were added in the first place 0N/A // the original display mode we had before entering the fullscreen 0N/A // 4455041 - Even when ddraw is disabled, ddraw.dll is loaded when 0N/A // pixel format calls are made. This causes problems when a Java app 0N/A // is run as an NT service. To prevent the loading of ddraw.dll 0N/A // completely, sun.awt.nopixfmt should be set as well. Apps which use 0N/A // OpenGL w/ Java probably don't want to set this. 0N/A // we cache the strings because we want toString() and getIDstring 0N/A // to reflect the original screen number (which may change if the 0N/A // device is removed) 430N/A // REMIND: may be should use class name? 0N/A * Returns the type of the graphics device. 0N/A * @see #TYPE_RASTER_SCREEN 0N/A * @see #TYPE_PRINTER 0N/A * @see #TYPE_IMAGE_BUFFER 0N/A * Returns the Win32 screen of the device. 0N/A * Returns whether this is a valid devicie. Device can become 0N/A * invalid as a result of device removal event. 0N/A * Called from native code when the device was removed. 0N/A * @param defaultScreen the current default screen 0N/A * Returns the identification string associated with this graphics 0N/A * Returns all of the graphics 0N/A * configurations associated with this graphics device. 430N/A // Workaround for failing GDI calls 0N/A for (
int i =
1; i <=
max; i++) {
0N/A * Returns the maximum number of graphics configurations available, or 1 0N/A * if PixelFormat calls fail or are disabled. 0N/A * This number is less than or equal to the number of graphics 0N/A * configurations supported. 0N/A * Returns whether or not the PixelFormat indicated by index is 0N/A * supported. Supported PixelFormats support drawing to a Window 0N/A * (PFD_DRAW_TO_WINDOW), support GDI (PFD_SUPPORT_GDI), and in the 0N/A * case of an 8-bit format (cColorBits <= 8) uses indexed colors 0N/A * (iPixelType == PFD_TYPE_COLORINDEX). 0N/A * We use the index 0 to indicate that PixelFormat calls don't work, or 0N/A * are disabled. Do not call this function with an index of 0. 0N/A * @param index a PixelFormat index 0N/A * Returns the PixelFormatID of the default graphics configuration 0N/A * associated with this graphics device, or 0 if PixelFormats calls fail or 0N/A * Returns the default PixelFormat ID from GDI. Do not call if PixelFormats 0N/A * Returns the default graphics configuration 0N/A * associated with this graphics device. 0N/A // first try to create a WGLGraphicsConfig if OGL is enabled 0N/A // REMIND: the WGL code does not yet work properly in multimon 0N/A // situations, so we will fallback on GDI if we are not on the 0N/A // default device... 0N/A // Fix for 4669614. Most apps are not concerned with PixelFormats, 0N/A // yet we ALWAYS used them for determining ColorModels and such. 0N/A // By passing in 0 as the PixelFormatID here, we signal that 0N/A // PixelFormats should not be used, thus avoid loading the opengl 0N/A // library. Apps concerned with PixelFormats can still use 0N/A // GraphicsConfiguration.getConfigurations(). 0N/A // Note that calling native pixel format functions tends to cause 0N/A // problems between those functions (which are OpenGL-related) 0N/A // and our use of DirectX. For example, some Matrox boards will 0N/A // crash or hang calling these functions when any app is running 0N/A // in DirectX fullscreen mode. So avoiding these calls unless 0N/A // absolutely necessary is preferable. 0N/A * Returns true if this is the default GraphicsDevice for the 0N/A * GraphicsEnvironment. 430N/A * returns true unless we're not allowed to use fullscreen mode. 0N/A // Enter windowed mode. 0N/A // restore the original display mode 0N/A // we set the default display mode to null here 0N/A // because the default mode could change during 0N/A // the life of the application (user can change it through 0N/A // the desktop properties dialog, for example), so 0N/A // we need to record it every time prior to 0N/A // entering the fullscreen mode. 430N/A // we used to destroy the buffers on exiting fs mode, this 430N/A // is no longer needed since fs change will cause a surface 0N/A // always record the default display mode prior to going 0N/A // Enter full screen exclusive mode. 1890N/A // Note: removed replaceSurfaceData() call because 1890N/A // changing the window size or making it visible 1890N/A // will cause this anyway, and both of these events happen 1890N/A // as part of switching into fullscreen mode. 0N/A // Entering and exiting full-screen mode are done within a 0N/A // tree-lock and should never lock on any resources which are 0N/A // required by other threads which may have them and may require 430N/A // REMIND: in the future these methods may need to become protected so that 430N/A // subclasses could override them and use appropriate api other than GDI 430N/A // for implementing these functions. 0N/A // resize the fullscreen window to the dimensions of the new 0N/A // Note: no call to replaceSurfaceData is required here since 0N/A // replacement will be caused by an upcoming display change event 0N/A "in order to set display mode");
0N/A * From the DisplayChangeListener interface. 0N/A * Called from Win32GraphicsEnvironment when the display settings have 0N/A // pass on to all top-level windows on this display 0N/A * Part of the DisplayChangedListener interface: devices 0N/A * do not need to react to this event 0N/A * Add a DisplayChangeListener to be notified when the display settings 0N/A * are changed. Typically, only top-level containers need to be added 0N/A * to Win32GraphicsDevice. 0N/A * Remove a DisplayChangeListener from this Win32GraphicsDevice 0N/A * Creates and returns the color model associated with this device 0N/A * Returns a dynamic ColorModel which is updated when there 0N/A * are any changes (e.g., palette changes) in the device 0N/A * Returns the non-dynamic ColorModel associated with this device 430N/A * The listener restores the default display mode when window is iconified 430N/A * and sets it back to the one set by the user on de-iconification. 430N/A // fs window and ignore the event if that's the case 430N/A // otherwise apply state to all fullscreen windows 430N/A // restore the default display mode for this device 430N/A // restore the user-set display mode for this device 430N/A * Adds a WindowListener to be used as 430N/A * @param w full-screen window 430N/A // Note: even though we create a listener for Window instances of 430N/A // fs windows they will not receive window events. 3177N/A // Fix for 6709453. Using invokeLater to avoid listening 3177N/A // for the events already posted to the queue. 430N/A * Removes the fs window listener. 430N/A * @param w full-screen window