From afe1f824037397ab4f90b0ecc383d99312645a78 Mon Sep 17 00:00:00 2001 From: tdv Date: Wed, 14 May 2008 16:05:07 -0700 Subject: 6675596: SurfaceManagerFactory should allow plugging in different implementations Reviewed-by: tdv, campbell Contributed-by: Roman Kennke --- .../classes/sun/awt/X11GraphicsEnvironment.java | 6 ++ .../classes/sun/java2d/SurfaceManagerFactory.java | 65 ---------------------- .../sun/java2d/UnixSurfaceManagerFactory.java | 64 +++++++++++++++++++++ 3 files changed, 70 insertions(+), 65 deletions(-) delete mode 100644 src/solaris/classes/sun/java2d/SurfaceManagerFactory.java create mode 100644 src/solaris/classes/sun/java2d/UnixSurfaceManagerFactory.java (limited to 'src/solaris') diff --git a/src/solaris/classes/sun/awt/X11GraphicsEnvironment.java b/src/solaris/classes/sun/awt/X11GraphicsEnvironment.java index 27ba044c27..b531fa739b 100644 --- a/src/solaris/classes/sun/awt/X11GraphicsEnvironment.java +++ b/src/solaris/classes/sun/awt/X11GraphicsEnvironment.java @@ -48,6 +48,8 @@ import sun.font.Font2D; import sun.font.FontManager; import sun.font.NativeFont; import sun.java2d.SunGraphicsEnvironment; +import sun.java2d.SurfaceManagerFactory; +import sun.java2d.UnixSurfaceManagerFactory; /** * This is an implementation of a GraphicsEnvironment object for the @@ -177,6 +179,10 @@ public class X11GraphicsEnvironment return null; } }); + + // Install the correct surface manager factory. + SurfaceManagerFactory.setInstance(new UnixSurfaceManagerFactory()); + } private static boolean glxAvailable; diff --git a/src/solaris/classes/sun/java2d/SurfaceManagerFactory.java b/src/solaris/classes/sun/java2d/SurfaceManagerFactory.java deleted file mode 100644 index 525ec325a5..0000000000 --- a/src/solaris/classes/sun/java2d/SurfaceManagerFactory.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - */ - -package sun.java2d; - -import java.awt.GraphicsConfiguration; -import java.awt.image.BufferedImage; -import sun.awt.X11GraphicsConfig; -import sun.awt.image.SunVolatileImage; -import sun.awt.image.SurfaceManager; -import sun.awt.image.VolatileSurfaceManager; -import sun.java2d.opengl.GLXGraphicsConfig; -import sun.java2d.opengl.GLXVolatileSurfaceManager; -import sun.java2d.x11.X11VolatileSurfaceManager; - -/** - * This is a factory class with static methods for creating a - * platform-specific instance of a particular SurfaceManager. Each platform - * (Windows, Unix, etc.) has its own specialized SurfaceManagerFactory. - */ -public class SurfaceManagerFactory { - /** - * Creates a new instance of a VolatileSurfaceManager given any - * arbitrary SunVolatileImage. An optional context Object can be supplied - * as a way for the caller to pass pipeline-specific context data to - * the VolatileSurfaceManager (such as a backbuffer handle, for example). - * - * For Unix platforms, this method returns either an X11- or a GLX- - * specific VolatileSurfaceManager based on the GraphicsConfiguration - * under which the SunVolatileImage was created. - */ - public static VolatileSurfaceManager - createVolatileManager(SunVolatileImage vImg, - Object context) - { - GraphicsConfiguration gc = vImg.getGraphicsConfig(); - if (gc instanceof GLXGraphicsConfig) { - return new GLXVolatileSurfaceManager(vImg, context); - } else { - return new X11VolatileSurfaceManager(vImg, context); - } - } -} diff --git a/src/solaris/classes/sun/java2d/UnixSurfaceManagerFactory.java b/src/solaris/classes/sun/java2d/UnixSurfaceManagerFactory.java new file mode 100644 index 0000000000..719ae69c15 --- /dev/null +++ b/src/solaris/classes/sun/java2d/UnixSurfaceManagerFactory.java @@ -0,0 +1,64 @@ +/* + * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + + +package sun.java2d; + +import java.awt.GraphicsConfiguration; + +import sun.awt.image.SunVolatileImage; +import sun.awt.image.VolatileSurfaceManager; +import sun.java2d.opengl.GLXGraphicsConfig; +import sun.java2d.opengl.GLXVolatileSurfaceManager; +import sun.java2d.x11.X11VolatileSurfaceManager; + +/** + * The SurfaceManagerFactory that creates VolatileSurfaceManager + * implementations for the Unix volatile images. + */ +public class UnixSurfaceManagerFactory extends SurfaceManagerFactory { + + /** + * Creates a new instance of a VolatileSurfaceManager given any + * arbitrary SunVolatileImage. An optional context Object can be supplied + * as a way for the caller to pass pipeline-specific context data to + * the VolatileSurfaceManager (such as a backbuffer handle, for example). + * + * For Unix platforms, this method returns either an X11- or a GLX- + * specific VolatileSurfaceManager based on the GraphicsConfiguration + * under which the SunVolatileImage was created. + */ + public VolatileSurfaceManager createVolatileManager(SunVolatileImage vImg, + Object context) + { + GraphicsConfiguration gc = vImg.getGraphicsConfig(); + if (gc instanceof GLXGraphicsConfig) { + return new GLXVolatileSurfaceManager(vImg, context); + } else { + return new X11VolatileSurfaceManager(vImg, context); + } + } + +} -- cgit v1.2.3