diff --git a/src/java.desktop/macosx/classes/sun/awt/CGraphicsConfig.java b/src/java.desktop/macosx/classes/sun/awt/CGraphicsConfig.java index 3c09758e87f3b..0ca8510481704 100644 --- a/src/java.desktop/macosx/classes/sun/awt/CGraphicsConfig.java +++ b/src/java.desktop/macosx/classes/sun/awt/CGraphicsConfig.java @@ -41,7 +41,8 @@ public abstract class CGraphicsConfig extends GraphicsConfiguration private final CGraphicsDevice device; private ColorModel colorModel; - private final SurfaceManager.ProxyCache surfaceDataProxyCache = new SurfaceManager.ProxyCache(); + private final SurfaceManager.ProxyCache surfaceDataProxyCache = + new SurfaceManager.ProxyCache(); protected CGraphicsConfig(CGraphicsDevice device) { this.device = device; diff --git a/src/java.desktop/macosx/classes/sun/awt/CGraphicsEnvironment.java b/src/java.desktop/macosx/classes/sun/awt/CGraphicsEnvironment.java index fe4431e309128..e11dabc7a10db 100644 --- a/src/java.desktop/macosx/classes/sun/awt/CGraphicsEnvironment.java +++ b/src/java.desktop/macosx/classes/sun/awt/CGraphicsEnvironment.java @@ -37,9 +37,7 @@ import java.util.ListIterator; import java.util.Map; -import sun.java2d.MacosxSurfaceManagerFactory; import sun.java2d.SunGraphicsEnvironment; -import sun.java2d.SurfaceManagerFactory; /** * This is an implementation of a GraphicsEnvironment object for the default @@ -70,8 +68,6 @@ public static void init() { } static { // Load libraries and initialize the Toolkit. Toolkit.getDefaultToolkit(); - // Install the correct surface manager factory. - SurfaceManagerFactory.setInstance(new MacosxSurfaceManagerFactory()); } /** diff --git a/src/java.desktop/macosx/classes/sun/java2d/MacosxSurfaceManagerFactory.java b/src/java.desktop/macosx/classes/sun/java2d/MacosxSurfaceManagerFactory.java deleted file mode 100644 index 93fac3fb22a49..0000000000000 --- a/src/java.desktop/macosx/classes/sun/java2d/MacosxSurfaceManagerFactory.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2011, 2021, Oracle and/or its affiliates. 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.java2d; - -import sun.awt.image.SunVolatileImage; -import sun.awt.image.VolatileSurfaceManager; -import sun.awt.CGraphicsDevice; -import sun.java2d.metal.MTLVolatileSurfaceManager; -import sun.java2d.opengl.CGLVolatileSurfaceManager; - -/** - * 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 MacosxSurfaceManagerFactory 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 Mac OS X, this method returns either an CGL/MTL-specific - * VolatileSurfaceManager based on the GraphicsConfiguration - * under which the SunVolatileImage was created. - */ - public VolatileSurfaceManager createVolatileManager(SunVolatileImage vImg, - Object context) - { - return CGraphicsDevice.usingMetalPipeline() ? new MTLVolatileSurfaceManager(vImg, context) : - new CGLVolatileSurfaceManager(vImg, context); - } -} diff --git a/src/java.desktop/macosx/classes/sun/java2d/metal/MTLGraphicsConfig.java b/src/java.desktop/macosx/classes/sun/java2d/metal/MTLGraphicsConfig.java index 82adac72c03b5..e4afec42482ab 100644 --- a/src/java.desktop/macosx/classes/sun/java2d/metal/MTLGraphicsConfig.java +++ b/src/java.desktop/macosx/classes/sun/java2d/metal/MTLGraphicsConfig.java @@ -29,6 +29,8 @@ import sun.awt.CGraphicsDevice; import sun.awt.image.OffScreenImage; import sun.awt.image.SunVolatileImage; +import sun.awt.image.SurfaceManager; +import sun.awt.image.VolatileSurfaceManager; import sun.java2d.Disposer; import sun.java2d.DisposerRecord; import sun.java2d.Surface; @@ -67,7 +69,7 @@ import static sun.java2d.metal.MTLContext.MTLContextCaps.CAPS_EXT_BIOP_SHADER; public final class MTLGraphicsConfig extends CGraphicsConfig - implements AccelGraphicsConfig + implements AccelGraphicsConfig, SurfaceManager.Factory { private static ImageCapabilities imageCaps = new MTLImageCaps(); @@ -372,4 +374,10 @@ public int getMaxTextureHeight() { return Math.max(maxTextureSize / getDevice().getScaleFactor(), getBounds().height); } + + @Override + public VolatileSurfaceManager createVolatileManager(SunVolatileImage image, + Object context) { + return new MTLVolatileSurfaceManager(image, context); + } } diff --git a/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLGraphicsConfig.java b/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLGraphicsConfig.java index ee9b0aec3a009..6022d516bf90f 100644 --- a/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLGraphicsConfig.java +++ b/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLGraphicsConfig.java @@ -46,6 +46,8 @@ import sun.awt.CGraphicsDevice; import sun.awt.image.OffScreenImage; import sun.awt.image.SunVolatileImage; +import sun.awt.image.SurfaceManager; +import sun.awt.image.VolatileSurfaceManager; import sun.java2d.Disposer; import sun.java2d.DisposerRecord; import sun.java2d.Surface; @@ -386,4 +388,10 @@ public int getMaxTextureHeight() { return Math.max(maxTextureSize / getDevice().getScaleFactor(), getBounds().height); } + + @Override + public VolatileSurfaceManager createVolatileManager(SunVolatileImage image, + Object context) { + return new CGLVolatileSurfaceManager(image, context); + } } diff --git a/src/java.desktop/share/classes/sun/awt/image/SunVolatileImage.java b/src/java.desktop/share/classes/sun/awt/image/SunVolatileImage.java index 55dfc8db7662a..4bcd5f6b44313 100644 --- a/src/java.desktop/share/classes/sun/awt/image/SunVolatileImage.java +++ b/src/java.desktop/share/classes/sun/awt/image/SunVolatileImage.java @@ -37,7 +37,6 @@ import java.awt.image.ImageObserver; import java.awt.image.VolatileImage; import sun.java2d.SunGraphics2D; -import sun.java2d.SurfaceManagerFactory; import sun.java2d.DestSurfaceProvider; import sun.java2d.Surface; import sun.java2d.pipe.Region; @@ -158,29 +157,19 @@ public int getForcedAccelSurfaceType() { return forcedAccelSurfaceType; } - protected VolatileSurfaceManager createSurfaceManager(Object context, - ImageCapabilities caps) - { - /** - * Platform-specific SurfaceManagerFactories will return a - * manager suited to acceleration on each platform. But if - * the user is asking for a VolatileImage from a BufferedImageGC, - * then we need to return the appropriate unaccelerated manager. - * Note: this could change in the future; if some platform would - * like to accelerate BIGC volatile images, then this special-casing - * of the BIGC graphicsConfig should live in platform-specific - * code instead. - * We do the same for a Printer Device, and if user requested an - * unaccelerated VolatileImage by passing the capabilities object. - */ - if (graphicsConfig instanceof BufferedImageGraphicsConfig || - graphicsConfig instanceof sun.print.PrinterGraphicsConfig || - (caps != null && !caps.isAccelerated())) - { + private VolatileSurfaceManager createSurfaceManager( + Object context, ImageCapabilities caps) { + // GraphicsConfig may provide some specific surface manager + // implementation. + // In case it doesn't, or we were specifically requested to use + // an unaccelerated surface, fall back to the buffered image + // surface manager. + if ((caps == null || caps.isAccelerated()) && + graphicsConfig instanceof SurfaceManager.Factory factory) { + return factory.createVolatileManager(this, context); + } else { return new BufImgVolatileSurfaceManager(this, context); } - SurfaceManagerFactory smf = SurfaceManagerFactory.getInstance(); - return smf.createVolatileManager(this, context); } private Color getForeground() { diff --git a/src/java.desktop/share/classes/sun/awt/image/SurfaceManager.java b/src/java.desktop/share/classes/sun/awt/image/SurfaceManager.java index 9f605eed4e398..9b86d469d984d 100644 --- a/src/java.desktop/share/classes/sun/awt/image/SurfaceManager.java +++ b/src/java.desktop/share/classes/sun/awt/image/SurfaceManager.java @@ -183,6 +183,23 @@ public boolean isAccelerated() { } } + /** + * An interface for GraphicsConfiguration objects to implement if + * they create their own VolatileSurfaceManager implementations. + */ + public interface Factory { + + /** + * Creates a new instance of a VolatileSurfaceManager given a + * compatible 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). + */ + VolatileSurfaceManager createVolatileManager(SunVolatileImage image, + Object context); + } + /** * An interface for GraphicsConfiguration objects to implement if * their surfaces accelerate images using SurfaceDataProxy objects. @@ -201,7 +218,8 @@ public interface ProxiedGraphicsConfig { } public static class ProxyCache { - private final Map map = Collections.synchronizedMap(new WeakHashMap<>()); + private final Map map = + Collections.synchronizedMap(new WeakHashMap<>()); /** * Return a cached SurfaceDataProxy object for a given SurfaceManager. @@ -252,7 +270,8 @@ public synchronized void flush() { void flush(boolean deaccelerate) { synchronized (weakCache) { - Iterator> i = weakCache.values().iterator(); + Iterator> i = + weakCache.values().iterator(); while (i.hasNext()) { SurfaceDataProxy sdp = i.next().get(); if (sdp == null || sdp.flush(deaccelerate)) { diff --git a/src/java.desktop/share/classes/sun/java2d/SurfaceManagerFactory.java b/src/java.desktop/share/classes/sun/java2d/SurfaceManagerFactory.java deleted file mode 100644 index 39b6d2e33cf5b..0000000000000 --- a/src/java.desktop/share/classes/sun/java2d/SurfaceManagerFactory.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2003, 2008, Oracle and/or its affiliates. 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.java2d; - -import sun.awt.image.SunVolatileImage; -import sun.awt.image.VolatileSurfaceManager; - -/** - * This factory creates platform specific VolatileSurfaceManager - * implementations. - * - * There are two platform specific SurfaceManagerFactories in OpenJDK, - * UnixSurfaceManagerFactory and WindowsSurfaceManagerFactory. - * The actually used SurfaceManagerFactory is set by the respective platform - * GraphicsEnvironment implementations in the static initializer. - */ -public abstract class SurfaceManagerFactory { - - /** - * The single shared instance. - */ - private static SurfaceManagerFactory instance; - - /** - * Returns the surface manager factory instance. This returns a factory - * that has been set by {@link #setInstance(SurfaceManagerFactory)}. - * - * @return the surface manager factory - */ - public static synchronized SurfaceManagerFactory getInstance() { - - if (instance == null) { - throw new IllegalStateException("No SurfaceManagerFactory set."); - } - return instance; - } - - /** - * Sets the surface manager factory. This may only be called once, and it - * may not be set back to {@code null} when the factory is already - * instantiated. - * - * @param factory the factory to set - */ - public static synchronized void setInstance(SurfaceManagerFactory factory) { - - if (factory == null) { - // We don't want to allow setting this to null at any time. - throw new IllegalArgumentException("factory must be non-null"); - } - - if (instance != null) { - // We don't want to re-set the instance at any time. - throw new IllegalStateException("The surface manager factory is already initialized"); - } - - instance = factory; - } - - /** - * 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). - */ - public abstract VolatileSurfaceManager - createVolatileManager(SunVolatileImage image, Object context); -} diff --git a/src/java.desktop/share/classes/sun/java2d/opengl/OGLGraphicsConfig.java b/src/java.desktop/share/classes/sun/java2d/opengl/OGLGraphicsConfig.java index 252644b7e49f4..a090458801943 100644 --- a/src/java.desktop/share/classes/sun/java2d/opengl/OGLGraphicsConfig.java +++ b/src/java.desktop/share/classes/sun/java2d/opengl/OGLGraphicsConfig.java @@ -35,7 +35,7 @@ * methods directly from OGLSurfaceData. */ interface OGLGraphicsConfig extends - AccelGraphicsConfig, SurfaceManager.ProxiedGraphicsConfig + AccelGraphicsConfig, SurfaceManager.ProxiedGraphicsConfig, SurfaceManager.Factory { OGLContext getContext(); long getNativeConfigInfo(); diff --git a/src/java.desktop/unix/classes/sun/awt/X11GraphicsConfig.java b/src/java.desktop/unix/classes/sun/awt/X11GraphicsConfig.java index ba06574cdd708..9c7a7d5c376a1 100644 --- a/src/java.desktop/unix/classes/sun/awt/X11GraphicsConfig.java +++ b/src/java.desktop/unix/classes/sun/awt/X11GraphicsConfig.java @@ -47,6 +47,7 @@ import sun.awt.image.OffScreenImage; import sun.awt.image.SunVolatileImage; import sun.awt.image.SurfaceManager; +import sun.awt.image.VolatileSurfaceManager; import sun.java2d.Disposer; import sun.java2d.DisposerRecord; import sun.java2d.SurfaceData; @@ -55,6 +56,7 @@ import sun.java2d.loops.SurfaceType; import sun.java2d.pipe.Region; import sun.java2d.x11.X11SurfaceData; +import sun.java2d.x11.X11VolatileSurfaceManager; /** * This is an implementation of a GraphicsConfiguration object for a @@ -64,7 +66,7 @@ * @see GraphicsDevice */ public class X11GraphicsConfig extends GraphicsConfiguration - implements SurfaceManager.ProxiedGraphicsConfig + implements SurfaceManager.ProxiedGraphicsConfig, SurfaceManager.Factory { private final X11GraphicsDevice device; protected int visual; @@ -500,4 +502,10 @@ public boolean isTranslucencyCapable() { } private native boolean isTranslucencyCapable(long x11ConfigData); + + @Override + public VolatileSurfaceManager createVolatileManager(SunVolatileImage image, + Object context) { + return new X11VolatileSurfaceManager(image, context); + } } diff --git a/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java b/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java index 39ecb13c6a4d0..a7ec9ccc9fd63 100644 --- a/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java +++ b/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java @@ -62,7 +62,8 @@ public final class X11GraphicsDevice extends GraphicsDevice * therefore methods, which is using this id should be ready to it. */ private volatile int screen; - Map x11ProxyCacheMap = Collections.synchronizedMap(new HashMap<>()); + Map x11ProxyCacheMap = + Collections.synchronizedMap(new HashMap<>()); private static Boolean xrandrExtSupported; private SunDisplayChanger topLevels = new SunDisplayChanger(); @@ -95,7 +96,8 @@ public int getScreen() { } public SurfaceManager.ProxyCache getProxyCacheFor(SurfaceType st) { - return x11ProxyCacheMap.computeIfAbsent(st, unused -> new SurfaceManager.ProxyCache()); + return x11ProxyCacheMap.computeIfAbsent(st, + unused -> new SurfaceManager.ProxyCache()); } /** diff --git a/src/java.desktop/unix/classes/sun/awt/X11GraphicsEnvironment.java b/src/java.desktop/unix/classes/sun/awt/X11GraphicsEnvironment.java index 82490e88a99d2..c24e311017e80 100644 --- a/src/java.desktop/unix/classes/sun/awt/X11GraphicsEnvironment.java +++ b/src/java.desktop/unix/classes/sun/awt/X11GraphicsEnvironment.java @@ -41,8 +41,6 @@ import sun.awt.X11.XToolkit; import sun.java2d.SunGraphicsEnvironment; -import sun.java2d.SurfaceManagerFactory; -import sun.java2d.UnixSurfaceManagerFactory; import sun.java2d.xr.XRSurfaceData; /** @@ -124,10 +122,6 @@ private static void initStatic() { XRSurfaceData.initXRSurfaceData(); } } - - // Install the correct surface manager factory. - SurfaceManagerFactory.setInstance(new UnixSurfaceManagerFactory()); - } diff --git a/src/java.desktop/unix/classes/sun/java2d/UnixSurfaceManagerFactory.java b/src/java.desktop/unix/classes/sun/java2d/UnixSurfaceManagerFactory.java deleted file mode 100644 index 5ab78ee39eefd..0000000000000 --- a/src/java.desktop/unix/classes/sun/java2d/UnixSurfaceManagerFactory.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.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; -import sun.java2d.xr.*; - -/** - * 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 if(gc instanceof XRGraphicsConfig) { - return new XRVolatileSurfaceManager(vImg, context); - }else { - return new X11VolatileSurfaceManager(vImg, context); - } - } - -} diff --git a/src/java.desktop/unix/classes/sun/java2d/opengl/GLXGraphicsConfig.java b/src/java.desktop/unix/classes/sun/java2d/opengl/GLXGraphicsConfig.java index 96b0dc491830c..2ea076f805166 100644 --- a/src/java.desktop/unix/classes/sun/java2d/opengl/GLXGraphicsConfig.java +++ b/src/java.desktop/unix/classes/sun/java2d/opengl/GLXGraphicsConfig.java @@ -49,6 +49,7 @@ import sun.awt.image.OffScreenImage; import sun.awt.image.SunVolatileImage; import sun.awt.image.SurfaceManager; +import sun.awt.image.VolatileSurfaceManager; import sun.java2d.SunGraphics2D; import sun.java2d.Surface; import sun.java2d.SurfaceData; @@ -72,7 +73,8 @@ public final class GLXGraphicsConfig private long pConfigInfo; private ContextCapabilities oglCaps; private final OGLContext context; - private final SurfaceManager.ProxyCache surfaceDataProxyCache = new SurfaceManager.ProxyCache(); + private final SurfaceManager.ProxyCache surfaceDataProxyCache = + new SurfaceManager.ProxyCache(); private static native long getGLXConfigInfo(int screennum, int visualnum); private static native int getOGLCapabilities(long configInfo); @@ -413,4 +415,10 @@ public ImageCapabilities getImageCapabilities() { public ContextCapabilities getContextCapabilities() { return oglCaps; } + + @Override + public VolatileSurfaceManager createVolatileManager(SunVolatileImage image, + Object context) { + return new GLXVolatileSurfaceManager(image, context); + } } diff --git a/src/java.desktop/unix/classes/sun/java2d/xr/XRGraphicsConfig.java b/src/java.desktop/unix/classes/sun/java2d/xr/XRGraphicsConfig.java index fb2c8ad480108..43f17e11ae122 100644 --- a/src/java.desktop/unix/classes/sun/java2d/xr/XRGraphicsConfig.java +++ b/src/java.desktop/unix/classes/sun/java2d/xr/XRGraphicsConfig.java @@ -30,11 +30,14 @@ import sun.awt.X11GraphicsDevice; import sun.awt.X11GraphicsEnvironment; import sun.awt.image.SurfaceManager; +import sun.awt.image.SunVolatileImage; +import sun.awt.image.VolatileSurfaceManager; import sun.java2d.SurfaceData; public class XRGraphicsConfig extends X11GraphicsConfig implements SurfaceManager.ProxiedGraphicsConfig { - private final SurfaceManager.ProxyCache surfaceDataProxyCache = new SurfaceManager.ProxyCache(); + private final SurfaceManager.ProxyCache surfaceDataProxyCache = + new SurfaceManager.ProxyCache(); private XRGraphicsConfig(X11GraphicsDevice device, int visualnum, int depth, int colormap, boolean doubleBuffer) { @@ -59,4 +62,10 @@ public static XRGraphicsConfig getConfig(X11GraphicsDevice device, public SurfaceManager.ProxyCache getSurfaceDataProxyCache() { return surfaceDataProxyCache; } + + @Override + public VolatileSurfaceManager createVolatileManager(SunVolatileImage image, + Object context) { + return new XRVolatileSurfaceManager(image, context); + } } diff --git a/src/java.desktop/windows/classes/sun/awt/Win32GraphicsDevice.java b/src/java.desktop/windows/classes/sun/awt/Win32GraphicsDevice.java index 865fe48085362..fedc7f3898066 100644 --- a/src/java.desktop/windows/classes/sun/awt/Win32GraphicsDevice.java +++ b/src/java.desktop/windows/classes/sun/awt/Win32GraphicsDevice.java @@ -89,7 +89,8 @@ public class Win32GraphicsDevice extends GraphicsDevice implements private float scaleX; private float scaleY; - final SurfaceManager.ProxyCache surfaceDataProxyCache = new SurfaceManager.ProxyCache(); + final SurfaceManager.ProxyCache surfaceDataProxyCache = + new SurfaceManager.ProxyCache(); static { diff --git a/src/java.desktop/windows/classes/sun/awt/Win32GraphicsEnvironment.java b/src/java.desktop/windows/classes/sun/awt/Win32GraphicsEnvironment.java index 09768148f3dc9..2e11d5510590d 100644 --- a/src/java.desktop/windows/classes/sun/awt/Win32GraphicsEnvironment.java +++ b/src/java.desktop/windows/classes/sun/awt/Win32GraphicsEnvironment.java @@ -35,8 +35,6 @@ import sun.awt.windows.WToolkit; import sun.java2d.SunGraphicsEnvironment; -import sun.java2d.SurfaceManagerFactory; -import sun.java2d.WindowsSurfaceManagerFactory; import sun.java2d.d3d.D3DGraphicsDevice; import sun.java2d.windows.WindowsFlags; @@ -63,9 +61,6 @@ public final class Win32GraphicsEnvironment extends SunGraphicsEnvironment { initDisplay(); - // Install correct surface manager factory. - SurfaceManagerFactory.setInstance(new WindowsSurfaceManagerFactory()); - double sx = -1; double sy = -1; if (isUIScaleEnabled()) { diff --git a/src/java.desktop/windows/classes/sun/java2d/WindowsSurfaceManagerFactory.java b/src/java.desktop/windows/classes/sun/java2d/WindowsSurfaceManagerFactory.java deleted file mode 100644 index 4abb8c823f6e9..0000000000000 --- a/src/java.desktop/windows/classes/sun/java2d/WindowsSurfaceManagerFactory.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2003, 2008, Oracle and/or its affiliates. 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.java2d; - -import java.awt.GraphicsConfiguration; -import sun.awt.image.BufImgVolatileSurfaceManager; -import sun.awt.image.SunVolatileImage; -import sun.awt.image.VolatileSurfaceManager; -import sun.java2d.d3d.D3DGraphicsConfig; -import sun.java2d.d3d.D3DVolatileSurfaceManager; -import sun.java2d.opengl.WGLGraphicsConfig; -import sun.java2d.opengl.WGLVolatileSurfaceManager; - -/** - * The SurfaceManagerFactory that creates VolatileSurfaceManager - * implementations for the Windows volatile images. - */ -public final class WindowsSurfaceManagerFactory 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 Windows platforms, this method returns a Windows-specific - * VolatileSurfaceManager. - */ - @Override - public VolatileSurfaceManager createVolatileManager(SunVolatileImage vImg, - Object context) - { - GraphicsConfiguration gc = vImg.getGraphicsConfig(); - if (gc instanceof D3DGraphicsConfig) { - return new D3DVolatileSurfaceManager(vImg, context); - } else if (gc instanceof WGLGraphicsConfig) { - return new WGLVolatileSurfaceManager(vImg, context); - } else { - return new BufImgVolatileSurfaceManager(vImg, context); - } - } - -} diff --git a/src/java.desktop/windows/classes/sun/java2d/d3d/D3DGraphicsConfig.java b/src/java.desktop/windows/classes/sun/java2d/d3d/D3DGraphicsConfig.java index aab6b720d6a89..8b001317dcaff 100644 --- a/src/java.desktop/windows/classes/sun/java2d/d3d/D3DGraphicsConfig.java +++ b/src/java.desktop/windows/classes/sun/java2d/d3d/D3DGraphicsConfig.java @@ -39,6 +39,7 @@ import sun.awt.Win32GraphicsConfig; import sun.awt.image.SunVolatileImage; import sun.awt.image.SurfaceManager; +import sun.awt.image.VolatileSurfaceManager; import sun.awt.windows.WComponentPeer; import sun.java2d.Surface; import sun.java2d.SurfaceData; @@ -51,7 +52,7 @@ public final class D3DGraphicsConfig extends Win32GraphicsConfig - implements AccelGraphicsConfig + implements AccelGraphicsConfig, SurfaceManager.Factory { private static ImageCapabilities imageCaps = new D3DImageCaps(); @@ -307,4 +308,10 @@ public D3DContext getContext() { public ContextCapabilities getContextCapabilities() { return device.getContextCapabilities(); } + + @Override + public VolatileSurfaceManager createVolatileManager(SunVolatileImage image, + Object context) { + return new D3DVolatileSurfaceManager(image, context); + } } diff --git a/src/java.desktop/windows/classes/sun/java2d/opengl/WGLGraphicsConfig.java b/src/java.desktop/windows/classes/sun/java2d/opengl/WGLGraphicsConfig.java index c6658bf291423..40d2af5c12aa3 100644 --- a/src/java.desktop/windows/classes/sun/java2d/opengl/WGLGraphicsConfig.java +++ b/src/java.desktop/windows/classes/sun/java2d/opengl/WGLGraphicsConfig.java @@ -43,6 +43,7 @@ import sun.awt.Win32GraphicsDevice; import sun.awt.image.SunVolatileImage; import sun.awt.image.SurfaceManager; +import sun.awt.image.VolatileSurfaceManager; import sun.awt.windows.WComponentPeer; import sun.java2d.Disposer; import sun.java2d.DisposerRecord; @@ -73,7 +74,8 @@ public final class WGLGraphicsConfig private ContextCapabilities oglCaps; private final OGLContext context; private Object disposerReferent = new Object(); - private final SurfaceManager.ProxyCache surfaceDataProxyCache = new SurfaceManager.ProxyCache(); + private final SurfaceManager.ProxyCache surfaceDataProxyCache = + new SurfaceManager.ProxyCache(); public static native int getDefaultPixFmt(int screennum); private static native boolean initWGL(); @@ -432,4 +434,10 @@ public ImageCapabilities getImageCapabilities() { public ContextCapabilities getContextCapabilities() { return oglCaps; } + + @Override + public VolatileSurfaceManager createVolatileManager(SunVolatileImage image, + Object context) { + return new WGLVolatileSurfaceManager(image, context); + } }