Skip to content
Permalink
Browse files

8234325: Delete unused vsync related code from the OGL pipeline on macOS

Reviewed-by: jdv
  • Loading branch information
mrserb committed Nov 18, 2019
1 parent 999f05b commit 24b9c2a59e4b88d63a464af3a816ff349a6fbd15
@@ -115,23 +115,6 @@ public static CGLLayerSurfaceData createData(CGLLayer layer) {
return new CGLLayerSurfaceData(layer, gc, r.width, r.height);
}

/**
* 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 @@ public void invalidate() {
}
}

/**
* 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 @@ public SurfaceData getReplacement() {

@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);
}

/**
@@ -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 @@ protected boolean isAccelerationEnabled() {
* 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

0 comments on commit 24b9c2a

Please sign in to comment.
You can’t perform that action at this time.