jdk/src/windows/classes/sun/java2d/WindowsSurfaceManagerFactory.java
author tdv
Wed, 14 May 2008 16:05:07 -0700
changeset 557 800259d3792b
child 887 0aab8d3fa11a
permissions -rw-r--r--
6675596: SurfaceManagerFactory should allow plugging in different implementations Reviewed-by: tdv, campbell Contributed-by: Roman Kennke <roman.kennke@aicas.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
557
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
     1
/*
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
     2
 * Copyright 2003-2008 Sun Microsystems, Inc.  All Rights Reserved.
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
     4
 *
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    10
 *
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    15
 * accompanied this code).
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    16
 *
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    20
 *
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    23
 * have any questions.
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    24
 */
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    25
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    26
package sun.java2d;
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    27
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    28
import java.awt.GraphicsConfiguration;
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    29
import java.awt.image.BufferedImage;
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    30
import sun.awt.image.SunVolatileImage;
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    31
import sun.awt.image.SurfaceManager;
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    32
import sun.awt.image.VolatileSurfaceManager;
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    33
import sun.java2d.opengl.WGLGraphicsConfig;
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    34
import sun.java2d.opengl.WGLVolatileSurfaceManager;
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    35
import sun.java2d.windows.WindowsFlags;
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    36
import sun.java2d.windows.WinVolatileSurfaceManager;
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    37
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    38
/**
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    39
 * The SurfaceManagerFactory that creates VolatileSurfaceManager
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    40
 * implementations for the Windows volatile images.
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    41
 */
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    42
public class WindowsSurfaceManagerFactory extends SurfaceManagerFactory {
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    43
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    44
    /**
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    45
     * Creates a new instance of a VolatileSurfaceManager given any
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    46
     * arbitrary SunVolatileImage.  An optional context Object can be supplied
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    47
     * as a way for the caller to pass pipeline-specific context data to
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    48
     * the VolatileSurfaceManager (such as a backbuffer handle, for example).
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    49
     *
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    50
     * For Windows platforms, this method returns a Windows-specific
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    51
     * VolatileSurfaceManager.
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    52
     */
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    53
    public VolatileSurfaceManager createVolatileManager(SunVolatileImage vImg,
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    54
                                                        Object context)
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    55
    {
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    56
        GraphicsConfiguration gc = vImg.getGraphicsConfig();
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    57
        if (gc instanceof WGLGraphicsConfig) {
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    58
            return new WGLVolatileSurfaceManager(vImg, context);
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    59
        } else {
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    60
            return new WinVolatileSurfaceManager(vImg, context);
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    61
        }
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    62
    }
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    63
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    64
}