changeset 57378:e26c3e28f6f0

8234325: Delete unused vsync related code from the OGL pipeline on macOS Reviewed-by: jdv
author serb
date Mon, 18 Nov 2019 10:39:34 -0800
parents 8081bf6f4309
children 53eff6c5da11
files src/java.desktop/macosx/classes/sun/java2d/opengl/CGLSurfaceData.java src/java.desktop/macosx/classes/sun/java2d/opengl/CGLVolatileSurfaceManager.java
diffstat 2 files changed, 15 insertions(+), 121 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLSurfaceData.java	Tue Dec 03 12:45:47 2019 +0530
+++ b/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLSurfaceData.java	Mon Nov 18 10:39:34 2019 -0800
@@ -116,23 +116,6 @@
     }
 
     /**
-     * Creates a SurfaceData object representing the back buffer of a
-     * double-buffered on-screen Window.
-     */
-    public static CGLOffScreenSurfaceData createData(CPlatformView pView,
-            Image image, int type) {
-        CGLGraphicsConfig gc = getGC(pView);
-        Rectangle r = pView.getBounds();
-        if (type == FLIP_BACKBUFFER) {
-            return new CGLOffScreenSurfaceData(pView, gc, r.width, r.height,
-                    image, gc.getColorModel(), FLIP_BACKBUFFER);
-        } else {
-            return new CGLVSyncOffScreenSurfaceData(pView, gc, r.width,
-                    r.height, image, gc.getColorModel(), type);
-        }
-    }
-
-    /**
      * Creates a SurfaceData object representing an off-screen buffer (either a
      * FBO or Texture).
      */
@@ -273,38 +256,6 @@
         }
     }
 
-    /**
-     * A surface which implements a v-synced flip back-buffer with COPIED
-     * FlipContents.
-     *
-     * This surface serves as a back-buffer to the outside world, while it is
-     * actually an offscreen surface. When the BufferStrategy this surface
-     * belongs to is showed, it is first copied to the real private
-     * FLIP_BACKBUFFER, which is then flipped.
-     */
-    public static class CGLVSyncOffScreenSurfaceData extends
-            CGLOffScreenSurfaceData {
-        private CGLOffScreenSurfaceData flipSurface;
-
-        public CGLVSyncOffScreenSurfaceData(CPlatformView pView,
-                CGLGraphicsConfig gc, int width, int height, Image image,
-                ColorModel cm, int type) {
-            super(pView, gc, width, height, image, cm, type);
-            flipSurface = CGLSurfaceData.createData(pView, image,
-                    FLIP_BACKBUFFER);
-        }
-
-        public SurfaceData getFlipSurface() {
-            return flipSurface;
-        }
-
-        @Override
-        public void flush() {
-            flipSurface.flush();
-            super.flush();
-        }
-    }
-
     public static class CGLOffScreenSurfaceData extends CGLSurfaceData {
         private Image offscreenImage;
 
@@ -323,12 +274,7 @@
 
         @Override
         public Rectangle getBounds() {
-            if (type == FLIP_BACKBUFFER) {
-                Rectangle r = pView.getBounds();
-                return new Rectangle(0, 0, r.width, r.height);
-            } else {
-                return new Rectangle(width, height);
-            }
+            return new Rectangle(width, height);
         }
 
         /**
--- a/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLVolatileSurfaceManager.java	Tue Dec 03 12:45:47 2019 +0530
+++ b/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLVolatileSurfaceManager.java	Mon Nov 18 10:39:34 2019 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2019, 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
@@ -25,23 +25,15 @@
 
 package sun.java2d.opengl;
 
-import java.awt.BufferCapabilities;
-import static java.awt.BufferCapabilities.FlipContents.*;
-import java.awt.Component;
 import java.awt.GraphicsConfiguration;
 import java.awt.Transparency;
 import java.awt.image.ColorModel;
-import java.awt.peer.ComponentPeer;
 
-import sun.awt.AWTAccessor;
-import sun.awt.AWTAccessor.ComponentAccessor;
 import sun.awt.image.SunVolatileImage;
 import sun.awt.image.VolatileSurfaceManager;
-import sun.java2d.BackBufferCapsProvider;
 import sun.java2d.SurfaceData;
-import static sun.java2d.opengl.OGLContext.OGLContextCaps.*;
-import sun.java2d.pipe.hw.ExtendedBufferCapabilities;
-import static sun.java2d.pipe.hw.ExtendedBufferCapabilities.VSyncType.*;
+
+import static sun.java2d.opengl.OGLContext.OGLContextCaps.CAPS_EXT_FBOBJECT;
 
 public class CGLVolatileSurfaceManager extends VolatileSurfaceManager {
 
@@ -71,64 +63,20 @@
      * of an existing window if this is a double buffered GraphicsConfig)
      */
     protected SurfaceData initAcceleratedSurface() {
-        SurfaceData sData = null;
-        Component comp = vImg.getComponent();
-        final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
-        final ComponentPeer peer = (comp != null) ? acc.getPeer(comp) : null;
-
         try {
-            boolean createVSynced = false;
-            boolean forceback = false;
-            if (context instanceof Boolean) {
-                forceback = ((Boolean)context).booleanValue();
-                if (forceback && peer instanceof BackBufferCapsProvider) {
-                    BackBufferCapsProvider provider =
-                        (BackBufferCapsProvider)peer;
-                    BufferCapabilities caps = provider.getBackBufferCaps();
-                    if (caps instanceof ExtendedBufferCapabilities) {
-                        ExtendedBufferCapabilities ebc =
-                            (ExtendedBufferCapabilities)caps;
-                        if (ebc.getVSync() == VSYNC_ON &&
-                            ebc.getFlipContents() == COPIED)
-                        {
-                            createVSynced = true;
-                            forceback = false;
-                        }
-                    }
-                }
+            CGLGraphicsConfig gc = (CGLGraphicsConfig)vImg.getGraphicsConfig();
+            ColorModel cm = gc.getColorModel(vImg.getTransparency());
+            int type = vImg.getForcedAccelSurfaceType();
+            // if acceleration type is forced (type != UNDEFINED) then
+            // use the forced type, otherwise choose FBOBJECT
+            if (type == OGLSurfaceData.UNDEFINED) {
+                type = OGLSurfaceData.FBOBJECT;
             }
-
-            if (forceback) {
-                // peer must be non-null in this case
-                // TODO: modify parameter to delegate
-                //                sData = CGLSurfaceData.createData(peer, vImg, FLIP_BACKBUFFER);
-            } else {
-                CGLGraphicsConfig gc =
-                    (CGLGraphicsConfig)vImg.getGraphicsConfig();
-                ColorModel cm = gc.getColorModel(vImg.getTransparency());
-                int type = vImg.getForcedAccelSurfaceType();
-                // if acceleration type is forced (type != UNDEFINED) then
-                // use the forced type, otherwise choose FBOBJECT
-                if (type == OGLSurfaceData.UNDEFINED) {
-                    type = OGLSurfaceData.FBOBJECT;
-                }
-                if (createVSynced) {
-                    // TODO: modify parameter to delegate
-//                  sData = CGLSurfaceData.createData(peer, vImg, type);
-                } else {
-                    sData = CGLSurfaceData.createData(gc,
-                                                      vImg.getWidth(),
-                                                      vImg.getHeight(),
-                                                      cm, vImg, type);
-                }
-            }
-        } catch (NullPointerException ex) {
-            sData = null;
-        } catch (OutOfMemoryError er) {
-            sData = null;
+            return CGLSurfaceData.createData(gc, vImg.getWidth(),
+                                             vImg.getHeight(), cm, vImg, type);
+        } catch (NullPointerException | OutOfMemoryError ignored) {
+            return null;
         }
-
-        return sData;
     }
 
     @Override