jdk/src/solaris/classes/sun/java2d/UnixSurfaceManagerFactory.java
author tdv
Wed, 14 May 2008 16:05:07 -0700
changeset 557 800259d3792b
child 5506 202f599c92aa
child 5579 1a5e995a710b
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
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    27
package sun.java2d;
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    28
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    29
import java.awt.GraphicsConfiguration;
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    30
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    31
import sun.awt.image.SunVolatileImage;
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.GLXGraphicsConfig;
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    34
import sun.java2d.opengl.GLXVolatileSurfaceManager;
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    35
import sun.java2d.x11.X11VolatileSurfaceManager;
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    36
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
 * The SurfaceManagerFactory that creates VolatileSurfaceManager
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    39
 * implementations for the Unix volatile images.
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    40
 */
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    41
public class UnixSurfaceManagerFactory extends SurfaceManagerFactory {
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    42
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
     * Creates a new instance of a VolatileSurfaceManager given any
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    45
     * arbitrary SunVolatileImage.  An optional context Object can be supplied
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    46
     * 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
    47
     * the VolatileSurfaceManager (such as a backbuffer handle, for example).
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    48
     *
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    49
     * For Unix platforms, this method returns either an X11- or a GLX-
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    50
     * specific VolatileSurfaceManager based on the GraphicsConfiguration
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    51
     * under which the SunVolatileImage was created.
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 GLXGraphicsConfig) {
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents:
diff changeset
    58
            return new GLXVolatileSurfaceManager(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 X11VolatileSurfaceManager(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
}