author | ssadetsky |
Mon, 26 Sep 2016 13:15:37 +0300 | |
changeset 41398 | 1f7d85a74c12 |
parent 41397 | f44bb269125c |
child 41399 | 367e803499c1 |
--- a/jdk/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLGraphicsConfig.java Mon Sep 26 14:47:41 2016 +0530 +++ b/jdk/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLGraphicsConfig.java Mon Sep 26 13:15:37 2016 +0300 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2016, 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 @@ -56,8 +56,6 @@ import sun.java2d.pipe.hw.ContextCapabilities; import static sun.java2d.opengl.OGLSurfaceData.*; import static sun.java2d.opengl.OGLContext.OGLContextCaps.*; -import sun.java2d.pipe.hw.AccelDeviceEventListener; -import sun.java2d.pipe.hw.AccelDeviceEventNotifier; import sun.lwawt.LWComponentPeer; import sun.lwawt.macosx.CPlatformView; @@ -408,17 +406,6 @@ } @Override - public void addDeviceEventListener(AccelDeviceEventListener l) { - int displayID = getDevice().getCGDisplayID(); - AccelDeviceEventNotifier.addListener(l, displayID); - } - - @Override - public void removeDeviceEventListener(AccelDeviceEventListener l) { - AccelDeviceEventNotifier.removeListener(l); - } - - @Override public int getMaxTextureWidth() { return Math.max(maxTextureSize / getDevice().getScaleFactor(), getBounds().width);
--- a/jdk/src/java.desktop/share/classes/sun/java2d/pipe/hw/AccelDeviceEventListener.java Mon Sep 26 14:47:41 2016 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2007, 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.pipe.hw; - -/** - * An interface for receiving notifications about imminent accelerated device's - * events. Upon receiving such event appropriate actions can be taken (for - * example, resources associated with the device can be freed). - */ -public interface AccelDeviceEventListener { - /** - * Called when the device is about to be reset. - * - * One must release all native resources associated with the device which - * prevent the device from being reset (such as Default Pool resources for - * the D3D pipeline). - * - * It is safe to remove the listener while in the call back. - * - * Note: this method is called on the rendering thread, - * do not call into user code, do not take RQ lock! - */ - public void onDeviceReset(); - - /** - * Called when the device is about to be disposed of. - * - * One must release all native resources associated with the device. - * - * It is safe to remove the listener while in the call back. - * - * Note: this method is called on the rendering thread, - * do not call into user code, do not take RQ lock! - */ - public void onDeviceDispose(); -}
--- a/jdk/src/java.desktop/share/classes/sun/java2d/pipe/hw/AccelDeviceEventNotifier.java Mon Sep 26 14:47:41 2016 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,169 +0,0 @@ -/* - * Copyright (c) 2007, 2013, 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.pipe.hw; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import java.lang.annotation.Native; - - -/** - * This class is used to notify listeners about accelerated device's - * events such as device reset or dispose that are about to occur. - */ -public class AccelDeviceEventNotifier { - - private static AccelDeviceEventNotifier theInstance; - - /** - * A device is about to be reset. The listeners have to release all - * resources associated with the device which are required for the device - * to be reset. - */ - @Native public static final int DEVICE_RESET = 0; - - /** - * A device is about to be disposed. The listeners have to release all - * resources associated with the device. - */ - @Native public static final int DEVICE_DISPOSED = 1; - - private final Map<AccelDeviceEventListener, Integer> listeners; - - private AccelDeviceEventNotifier() { - listeners = Collections.synchronizedMap( - new HashMap<AccelDeviceEventListener, Integer>(1)); - } - - /** - * Returns a singleton of AccelDeviceEventNotifier if it exists. If the - * passed boolean is false and singleton doesn't exist yet, null is - * returned. If the passed boolean is {@code true} and singleton doesn't - * exist it will be created and returned. - * - * @param create whether to create a singleton instance if doesn't yet - * exist - * @return a singleton instance or null - */ - private static synchronized - AccelDeviceEventNotifier getInstance(boolean create) - { - if (theInstance == null && create) { - theInstance = new AccelDeviceEventNotifier(); - } - return theInstance; - } - - /** - * Called to indicate that a device event had occurred. - * If a singleton exists, the listeners (those associated with - * the device) will be notified. - * - * @param screen a screen number of the device which is a source of - * the event - * @param eventType a type of the event - * @see #DEVICE_DISPOSED - * @see #DEVICE_RESET - */ - public static final void eventOccured(int screen, int eventType) { - AccelDeviceEventNotifier notifier = getInstance(false); - if (notifier != null) { - notifier.notifyListeners(eventType, screen); - } - } - - /** - * Adds the listener associated with a device on particular screen. - * - * Note: the listener must be removed as otherwise it will forever - * be referenced by the notifier. - * - * @param l the listener - * @param screen the screen number indicating which device the listener is - * interested in. - */ - public static final void addListener(AccelDeviceEventListener l,int screen){ - getInstance(true).add(l, screen); - } - - /** - * Removes the listener. - * - * @param l the listener - */ - public static final void removeListener(AccelDeviceEventListener l) { - getInstance(true).remove(l); - } - - private final void add(AccelDeviceEventListener theListener, int screen) { - listeners.put(theListener, screen); - } - private final void remove(AccelDeviceEventListener theListener) { - listeners.remove(theListener); - } - - /** - * Notifies the listeners associated with the screen's device about the - * event. - * - * Implementation note: the current list of listeners is first duplicated - * which allows the listeners to remove themselves during the iteration. - * - * @param screen a screen number with which the device which is a source of - * the event is associated with - * @param deviceEventType a type of the event - * @see #DEVICE_DISPOSED - * @see #DEVICE_RESET - */ - private final void notifyListeners(int deviceEventType, int screen) { - HashMap<AccelDeviceEventListener, Integer> listClone; - Set<AccelDeviceEventListener> cloneSet; - - synchronized(listeners) { - listClone = - new HashMap<AccelDeviceEventListener, Integer>(listeners); - } - - cloneSet = listClone.keySet(); - Iterator<AccelDeviceEventListener> itr = cloneSet.iterator(); - while (itr.hasNext()) { - AccelDeviceEventListener current = itr.next(); - Integer i = listClone.get(current); - // only notify listeners which are interested in this device - if (i != null && i.intValue() != screen) { - continue; - } - if (deviceEventType == DEVICE_RESET) { - current.onDeviceReset(); - } else if (deviceEventType == DEVICE_DISPOSED) { - current.onDeviceDispose(); - } - } - } -}
--- a/jdk/src/java.desktop/share/classes/sun/java2d/pipe/hw/AccelGraphicsConfig.java Mon Sep 26 14:47:41 2016 +0530 +++ b/jdk/src/java.desktop/share/classes/sun/java2d/pipe/hw/AccelGraphicsConfig.java Mon Sep 26 13:15:37 2016 +0300 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -70,26 +70,4 @@ * @see ContextCapabilities */ public ContextCapabilities getContextCapabilities(); - - /** - * Adds an {@code AccelDeviceEventListener} to listen to accelerated - * device's (which is associated with this {@code AccelGraphicsConfig}) - * events. - * - * Note: a hard link to the listener may be kept so it must be explicitly - * removed via {@link #removeDeviceEventListener}. - * - * @param l the listener - * @see AccelDeviceEventListener - */ - public void addDeviceEventListener(AccelDeviceEventListener l); - - /** - * Removes an {@code AccelDeviceEventListener} from the list of listeners - * for this device's events. - * - * @param l the listener - * @see AccelDeviceEventListener - */ - public void removeDeviceEventListener(AccelDeviceEventListener l); }
--- a/jdk/src/java.desktop/unix/classes/sun/java2d/opengl/GLXGraphicsConfig.java Mon Sep 26 14:47:41 2016 +0530 +++ b/jdk/src/java.desktop/unix/classes/sun/java2d/opengl/GLXGraphicsConfig.java Mon Sep 26 13:15:37 2016 +0300 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, 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 @@ -27,7 +27,6 @@ import java.awt.AWTException; import java.awt.BufferCapabilities; -import java.awt.BufferCapabilities.FlipContents; import java.awt.Color; import java.awt.Component; import java.awt.Graphics; @@ -59,8 +58,6 @@ import static sun.java2d.opengl.OGLContext.*; import static sun.java2d.opengl.OGLContext.OGLContextCaps.*; import sun.java2d.opengl.GLXSurfaceData.GLXVSyncOffScreenSurfaceData; -import sun.java2d.pipe.hw.AccelDeviceEventListener; -import sun.java2d.pipe.hw.AccelDeviceEventNotifier; public class GLXGraphicsConfig extends X11GraphicsConfig @@ -426,14 +423,4 @@ public ContextCapabilities getContextCapabilities() { return oglCaps; } - - @Override - public void addDeviceEventListener(AccelDeviceEventListener l) { - AccelDeviceEventNotifier.addListener(l, screen.getScreen()); - } - - @Override - public void removeDeviceEventListener(AccelDeviceEventListener l) { - AccelDeviceEventNotifier.removeListener(l); - } }
--- a/jdk/src/java.desktop/windows/classes/sun/java2d/d3d/D3DGraphicsConfig.java Mon Sep 26 14:47:41 2016 +0530 +++ b/jdk/src/java.desktop/windows/classes/sun/java2d/d3d/D3DGraphicsConfig.java Mon Sep 26 13:15:37 2016 +0300 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -27,7 +27,6 @@ import java.awt.AWTException; import java.awt.BufferCapabilities; -import java.awt.BufferCapabilities.FlipContents; import java.awt.Component; import java.awt.Graphics; import java.awt.ImageCapabilities; @@ -43,14 +42,12 @@ import sun.awt.windows.WComponentPeer; import sun.java2d.Surface; import sun.java2d.SurfaceData; -import sun.java2d.pipe.hw.AccelDeviceEventNotifier; import sun.java2d.pipe.hw.AccelTypedVolatileImage; import sun.java2d.pipe.hw.AccelGraphicsConfig; import sun.java2d.pipe.hw.AccelSurface; import sun.java2d.pipe.hw.ContextCapabilities; import static sun.java2d.pipe.hw.AccelSurface.*; import static sun.java2d.d3d.D3DContext.D3DContextCaps.*; -import sun.java2d.pipe.hw.AccelDeviceEventListener; public class D3DGraphicsConfig extends Win32GraphicsConfig @@ -315,14 +312,4 @@ public ContextCapabilities getContextCapabilities() { return device.getContextCapabilities(); } - - @Override - public void addDeviceEventListener(AccelDeviceEventListener l) { - AccelDeviceEventNotifier.addListener(l, device.getScreen()); - } - - @Override - public void removeDeviceEventListener(AccelDeviceEventListener l) { - AccelDeviceEventNotifier.removeListener(l); - } }
--- a/jdk/src/java.desktop/windows/classes/sun/java2d/opengl/WGLGraphicsConfig.java Mon Sep 26 14:47:41 2016 +0530 +++ b/jdk/src/java.desktop/windows/classes/sun/java2d/opengl/WGLGraphicsConfig.java Mon Sep 26 13:15:37 2016 +0300 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2016, 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 @@ -54,8 +54,6 @@ import static sun.java2d.opengl.OGLContext.OGLContextCaps.*; import static sun.java2d.opengl.WGLSurfaceData.*; import sun.java2d.opengl.OGLContext.OGLContextCaps; -import sun.java2d.pipe.hw.AccelDeviceEventListener; -import sun.java2d.pipe.hw.AccelDeviceEventNotifier; import sun.java2d.windows.GDIWindowSurfaceData; public class WGLGraphicsConfig @@ -92,8 +90,7 @@ // add a record to the Disposer so that we destroy the native // WGLGraphicsConfigInfo data when this object goes away Disposer.addRecord(disposerReferent, - new WGLGCDisposerRecord(pConfigInfo, - device.getScreen())); + new WGLGCDisposerRecord(pConfigInfo)); } public Object getProxyKey() { @@ -198,27 +195,10 @@ private static class WGLGCDisposerRecord implements DisposerRecord { private long pCfgInfo; - private int screen; - public WGLGCDisposerRecord(long pCfgInfo, int screen) { + public WGLGCDisposerRecord(long pCfgInfo) { this.pCfgInfo = pCfgInfo; } public void dispose() { - OGLRenderQueue rq = OGLRenderQueue.getInstance(); - rq.lock(); - try { - rq.flushAndInvokeNow(new Runnable() { - public void run() { - AccelDeviceEventNotifier. - eventOccured(screen, - AccelDeviceEventNotifier.DEVICE_RESET); - AccelDeviceEventNotifier. - eventOccured(screen, - AccelDeviceEventNotifier.DEVICE_DISPOSED); - } - }); - } finally { - rq.unlock(); - } if (pCfgInfo != 0) { OGLRenderQueue.disposeGraphicsConfig(pCfgInfo); pCfgInfo = 0; @@ -455,14 +435,4 @@ public ContextCapabilities getContextCapabilities() { return oglCaps; } - - @Override - public void addDeviceEventListener(AccelDeviceEventListener l) { - AccelDeviceEventNotifier.addListener(l, screen.getScreen()); - } - - @Override - public void removeDeviceEventListener(AccelDeviceEventListener l) { - AccelDeviceEventNotifier.removeListener(l); - } }
--- a/jdk/src/java.desktop/windows/native/libawt/java2d/d3d/D3DContext.cpp Mon Sep 26 14:47:41 2016 +0530 +++ b/jdk/src/java.desktop/windows/native/libawt/java2d/d3d/D3DContext.cpp Mon Sep 26 13:15:37 2016 +0300 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -253,9 +253,6 @@ EndScene(); - D3DPipelineManager::NotifyAdapterEventListeners(devCaps.AdapterOrdinal, - DEVICE_RESET); - contextCaps = CAPS_EMPTY; SAFE_RELEASE(pSyncQuery); @@ -292,9 +289,6 @@ ReleaseDefPoolResources(); - D3DPipelineManager::NotifyAdapterEventListeners(devCaps.AdapterOrdinal, - DEVICE_DISPOSED); - // dispose shader lists ShaderList_Dispose(&convolvePrograms); ShaderList_Dispose(&rescalePrograms);
--- a/jdk/src/java.desktop/windows/native/libawt/java2d/d3d/D3DContext.h Mon Sep 26 14:47:41 2016 +0530 +++ b/jdk/src/java.desktop/windows/native/libawt/java2d/d3d/D3DContext.h Mon Sep 26 13:15:37 2016 +0300 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -30,7 +30,6 @@ #include "sun_java2d_pipe_BufferedContext.h" #include "sun_java2d_d3d_D3DContext_D3DContextCaps.h" #include "sun_java2d_d3d_D3DSurfaceData.h" -#include "sun_java2d_pipe_hw_AccelDeviceEventNotifier.h" #include "ShaderList.h" #include "D3DPipeline.h" @@ -413,9 +412,4 @@ #define CAPS_PS30 \ sun_java2d_d3d_D3DContext_D3DContextCaps_CAPS_PS30 -#define DEVICE_RESET \ - sun_java2d_pipe_hw_AccelDeviceEventNotifier_DEVICE_RESET -#define DEVICE_DISPOSED \ - sun_java2d_pipe_hw_AccelDeviceEventNotifier_DEVICE_DISPOSED - #endif // D3DCONTEXT_H
--- a/jdk/src/java.desktop/windows/native/libawt/java2d/d3d/D3DPipelineManager.cpp Mon Sep 26 14:47:41 2016 +0530 +++ b/jdk/src/java.desktop/windows/native/libawt/java2d/d3d/D3DPipelineManager.cpp Mon Sep 26 13:15:37 2016 +0300 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -173,41 +173,6 @@ return S_OK; } -// static -void D3DPipelineManager::NotifyAdapterEventListeners(UINT adapter, - jint eventType) -{ - HMONITOR hMon; - int gdiScreen; - D3DPipelineManager *pMgr; - - // fix for 6946559: if d3d preloading fails jmv may be NULL - if (jvm == NULL) { - return; - } - - JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); - RETURN_IF_NULL(env); - - pMgr = D3DPipelineManager::GetInstance(); - RETURN_IF_NULL(pMgr); - hMon = pMgr->pd3d9->GetAdapterMonitor(adapter); - - /* - * If we don't have devices initialized yet, no sense to clear them. - */ - if (!Devices::GetInstance()){ - return; - } - - gdiScreen = AwtWin32GraphicsDevice::GetScreenFromHMONITOR(hMon); - - JNU_CallStaticMethodByName(env, NULL, - "sun/java2d/pipe/hw/AccelDeviceEventNotifier", - "eventOccured", "(II)V", - gdiScreen, eventType); -} - UINT D3DPipelineManager::GetAdapterOrdinalForScreen(jint gdiScreen) { HMONITOR mHnd = AwtWin32GraphicsDevice::GetMonitor(gdiScreen);
--- a/jdk/src/java.desktop/windows/native/libawt/java2d/d3d/D3DPipelineManager.h Mon Sep 26 14:47:41 2016 +0530 +++ b/jdk/src/java.desktop/windows/native/libawt/java2d/d3d/D3DPipelineManager.h Mon Sep 26 13:15:37 2016 +0300 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, 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 @@ -78,11 +78,6 @@ // these may differ depending on which display is primary UINT GetAdapterOrdinalForScreen(jint gdiScreen); - // notifies adapter event listeners by calling - // AccelDeviceEventNotifier.eventOccured() - static - void NotifyAdapterEventListeners(UINT adapter, jint eventType); - private: D3DPipelineManager(void); ~D3DPipelineManager(void);
--- a/jdk/test/sun/java2d/pipe/hw/RSLAPITest/RSLAPITest.java Mon Sep 26 14:47:41 2016 +0530 +++ b/jdk/test/sun/java2d/pipe/hw/RSLAPITest/RSLAPITest.java Mon Sep 26 13:15:37 2016 +0300 @@ -47,7 +47,6 @@ import sun.java2d.Surface; import sun.java2d.pipe.BufferedContext; import sun.java2d.pipe.RenderQueue; -import sun.java2d.pipe.hw.AccelDeviceEventListener; import sun.java2d.pipe.hw.AccelGraphicsConfig; import sun.java2d.pipe.hw.AccelSurface; import static java.awt.Transparency.*; @@ -254,16 +253,6 @@ private static void testContext(final AccelGraphicsConfig agc) { BufferedContext c = agc.getContext(); - final AccelDeviceEventListener l = new AccelDeviceEventListener() { - public void onDeviceDispose() { - System.out.println("onDeviceDispose invoked"); - agc.removeDeviceEventListener(this); - } - public void onDeviceReset() { - System.out.println("onDeviceReset invoked"); - } - }; - agc.addDeviceEventListener(l); RenderQueue rq = c.getRenderQueue(); rq.lock();