提交 5a8ab9f5 编写于 作者: S serb

7124552: [macosx] NullPointerException in getBufferStrategy()

7124219: [macosx] Unable to draw images to fullscreen
Reviewed-by: bae, anthony
上级 5346462b
......@@ -31,13 +31,16 @@ import java.awt.image.*;
import sun.java2d.SurfaceData;
import sun.java2d.opengl.CGLLayer;
import sun.lwawt.LWGraphicsConfig;
import sun.lwawt.macosx.CPlatformView;
public class CGraphicsConfig extends GraphicsConfiguration {
public abstract class CGraphicsConfig extends GraphicsConfiguration
implements LWGraphicsConfig {
private final CGraphicsDevice device;
private ColorModel colorModel;
public CGraphicsConfig(CGraphicsDevice device) {
protected CGraphicsConfig(CGraphicsDevice device) {
this.device = device;
}
......@@ -84,88 +87,20 @@ public class CGraphicsConfig extends GraphicsConfiguration {
return new AffineTransform(xscale, 0.0, 0.0, yscale, 0.0, 0.0);
}
/**
* The following methods are invoked from CToolkit.java and
* LWWindowPeer.java rather than having the native
* implementations hardcoded in those classes. This way the appropriate
* actions are taken based on the peer's GraphicsConfig, whether it is
* an CGLGraphicsConfig or something else.
*/
/**
* Creates a new SurfaceData that will be associated with the given
* LWWindowPeer.
*/
public SurfaceData createSurfaceData(CPlatformView pView) {
throw new UnsupportedOperationException("not implemented");
}
public abstract SurfaceData createSurfaceData(CPlatformView pView);
/**
* Creates a new SurfaceData that will be associated with the given
* CGLLayer.
*/
public SurfaceData createSurfaceData(CGLLayer layer) {
throw new UnsupportedOperationException("not implemented");
}
/**
* Creates a new hidden-acceleration image of the given width and height
* that is associated with the target Component.
*/
public Image createAcceleratedImage(Component target,
int width, int height)
{
throw new UnsupportedOperationException("not implemented");
}
/**
* The following methods correspond to the multibuffering methods in
* LWWindowPeer.java...
*/
/**
* Attempts to create a native backbuffer for the given peer. If
* the requested configuration is not natively supported, an AWTException
* is thrown. Otherwise, if the backbuffer creation is successful, a
* handle to the native backbuffer is returned.
*/
public long createBackBuffer(CPlatformView pView,
int numBuffers, BufferCapabilities caps)
throws AWTException
{
throw new UnsupportedOperationException("not implemented");
}
public void destroyBackBuffer(long backBuffer)
throws AWTException
{
throw new UnsupportedOperationException("not implemented");
}
/**
* Creates a VolatileImage that essentially wraps the target Component's
* backbuffer, using the provided backbuffer handle.
*/
public VolatileImage createBackBufferImage(Component target,
long backBuffer)
{
throw new UnsupportedOperationException("not implemented");
}
/**
* Performs the native flip operation for the given target Component.
*/
public void flip(CPlatformView delegate,
Component target, VolatileImage xBackBuffer,
int x1, int y1, int x2, int y2,
BufferCapabilities.FlipContents flipAction)
{
throw new UnsupportedOperationException("not implemented");
}
public abstract SurfaceData createSurfaceData(CGLLayer layer);
@Override
public boolean isTranslucencyCapable() {
public final boolean isTranslucencyCapable() {
//we know for sure we have capable config :)
return true;
}
......
......@@ -27,7 +27,6 @@ package sun.java2d.opengl;
import java.awt.AWTException;
import java.awt.BufferCapabilities;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
......@@ -48,13 +47,10 @@ import java.awt.image.WritableRaster;
import sun.awt.CGraphicsConfig;
import sun.awt.CGraphicsDevice;
import sun.awt.TextureSizeConstraining;
import sun.awt.image.OffScreenImage;
import sun.awt.image.SunVolatileImage;
import sun.awt.image.SurfaceManager;
import sun.java2d.Disposer;
import sun.java2d.DisposerRecord;
import sun.java2d.SunGraphics2D;
import sun.java2d.Surface;
import sun.java2d.SurfaceData;
import sun.java2d.opengl.OGLContext.OGLContextCaps;
......@@ -63,18 +59,19 @@ import sun.java2d.pipe.hw.AccelTypedVolatileImage;
import sun.java2d.pipe.hw.ContextCapabilities;
import static sun.java2d.opengl.OGLSurfaceData.*;
import static sun.java2d.opengl.OGLContext.OGLContextCaps.*;
import sun.java2d.opengl.CGLSurfaceData.CGLVSyncOffScreenSurfaceData;
import sun.java2d.pipe.hw.AccelDeviceEventListener;
import sun.java2d.pipe.hw.AccelDeviceEventNotifier;
import sun.lwawt.LWComponentPeer;
import sun.lwawt.macosx.CPlatformView;
public class CGLGraphicsConfig extends CGraphicsConfig
implements OGLGraphicsConfig, TextureSizeConstraining
public final class CGLGraphicsConfig extends CGraphicsConfig
implements OGLGraphicsConfig
{
//private static final int kOpenGLSwapInterval = RuntimeOptions.getCurrentOptions().OpenGLSwapInterval;
//private static final int kOpenGLSwapInterval =
// RuntimeOptions.getCurrentOptions().OpenGLSwapInterval;
private static final int kOpenGLSwapInterval = 0; // TODO
protected static boolean cglAvailable;
private static boolean cglAvailable;
private static ImageCapabilities imageCaps = new CGLImageCaps();
private int pixfmt;
......@@ -82,7 +79,7 @@ public class CGLGraphicsConfig extends CGraphicsConfig
private long pConfigInfo;
private ContextCapabilities oglCaps;
private OGLContext context;
private Object disposerReferent = new Object();
private final Object disposerReferent = new Object();
public static native int getDefaultPixFmt(int screennum);
private static native boolean initCGL();
......@@ -94,7 +91,7 @@ public class CGLGraphicsConfig extends CGraphicsConfig
cglAvailable = initCGL();
}
protected CGLGraphicsConfig(CGraphicsDevice device, int pixfmt,
private CGLGraphicsConfig(CGraphicsDevice device, int pixfmt,
long configInfo, ContextCapabilities oglCaps)
{
super(device);
......@@ -170,11 +167,13 @@ public class CGLGraphicsConfig extends CGraphicsConfig
* Returns true if the provided capability bit is present for this config.
* See OGLContext.java for a list of supported capabilities.
*/
public final boolean isCapPresent(int cap) {
@Override
public boolean isCapPresent(int cap) {
return ((oglCaps.getCaps() & cap) != 0);
}
public final long getNativeConfigInfo() {
@Override
public long getNativeConfigInfo() {
return pConfigInfo;
}
......@@ -183,7 +182,8 @@ public class CGLGraphicsConfig extends CGraphicsConfig
*
* @see sun.java2d.pipe.hw.BufferedContextProvider#getContext
*/
public final OGLContext getContext() {
@Override
public OGLContext getContext() {
return context;
}
......@@ -257,145 +257,83 @@ public class CGLGraphicsConfig extends CGraphicsConfig
return ("CGLGraphicsConfig[dev="+screen+",pixfmt="+pixfmt+"]");
}
/**
* The following methods are invoked from ComponentModel.java rather
* than having the Mac OS X-dependent implementations hardcoded in that
* class. This way the appropriate actions are taken based on the peer's
* GraphicsConfig, whether it is a CGraphicsConfig or a
* CGLGraphicsConfig.
*/
/**
* Creates a new SurfaceData that will be associated with the given
* LWWindowPeer.
*/
@Override
public SurfaceData createSurfaceData(CPlatformView pView) {
return CGLSurfaceData.createData(pView);
}
/**
* Creates a new SurfaceData that will be associated with the given
* CGLLayer.
*/
@Override
public SurfaceData createSurfaceData(CGLLayer layer) {
return CGLSurfaceData.createData(layer);
}
/**
* Creates a new hidden-acceleration image of the given width and height
* that is associated with the target Component.
*/
@Override
public Image createAcceleratedImage(Component target,
int width, int height)
{
ColorModel model = getColorModel(Transparency.OPAQUE);
WritableRaster wr =
model.createCompatibleWritableRaster(width, height);
WritableRaster wr = model.createCompatibleWritableRaster(width, height);
return new OffScreenImage(target, model, wr,
model.isAlphaPremultiplied());
}
/**
* The following methods correspond to the multibuffering methods in
* CWindowPeer.java...
*/
/**
* Attempts to create a OGL-based backbuffer for the given peer. If
* the requested configuration is not natively supported, an AWTException
* is thrown. Otherwise, if the backbuffer creation is successful, a
* value of 1 is returned.
*/
@Override
public long createBackBuffer(CPlatformView pView,
int numBuffers, BufferCapabilities caps)
throws AWTException
{
if (numBuffers > 2) {
throw new AWTException(
"Only double or single buffering is supported");
}
BufferCapabilities configCaps = getBufferCapabilities();
public void assertOperationSupported(final int numBuffers,
final BufferCapabilities caps)
throws AWTException {
// Assume this method is never called with numBuffers != 2, as 0 is
// unsupported, and 1 corresponds to a SingleBufferStrategy which
// doesn't depend on the peer. Screen is considered as a separate
// "buffer".
if (numBuffers != 2) {
throw new AWTException("Only double buffering is supported");
}
final BufferCapabilities configCaps = getBufferCapabilities();
if (!configCaps.isPageFlipping()) {
throw new AWTException("Page flipping is not supported");
}
if (caps.getFlipContents() == BufferCapabilities.FlipContents.PRIOR) {
throw new AWTException("FlipContents.PRIOR is not supported");
}
// non-zero return value means backbuffer creation was successful
// (checked in CPlatformWindow.flip(), etc.)
return 1;
}
/**
* Destroys the backbuffer object represented by the given handle value.
*/
@Override
public void destroyBackBuffer(long backBuffer) {
public Image createBackBuffer(final LWComponentPeer<?, ?> peer) {
final Rectangle r = peer.getBounds();
// It is possible for the component to have size 0x0, adjust it to
// be at least 1x1 to avoid IAE
final int w = Math.max(1, r.width);
final int h = Math.max(1, r.height);
final int transparency = peer.isTranslucent() ? Transparency.TRANSLUCENT
: Transparency.OPAQUE;
return new SunVolatileImage(this, w, h, transparency, null);
}
/**
* Creates a VolatileImage that essentially wraps the target Component's
* backbuffer (the provided backbuffer handle is essentially ignored).
*/
@Override
public VolatileImage createBackBufferImage(Component target,
long backBuffer)
{
return new SunVolatileImage(target,
target.getWidth(), target.getHeight(),
Boolean.TRUE);
public void destroyBackBuffer(final Image backBuffer) {
if (backBuffer != null) {
backBuffer.flush();
}
}
/**
* Performs the native OGL flip operation for the given target Component.
*/
@Override
public void flip(CPlatformView pView,
Component target, VolatileImage xBackBuffer,
int x1, int y1, int x2, int y2,
BufferCapabilities.FlipContents flipAction)
{
if (flipAction == BufferCapabilities.FlipContents.COPIED) {
SurfaceManager vsm = SurfaceManager.getManager(xBackBuffer);
SurfaceData sd = vsm.getPrimarySurfaceData();
if (sd instanceof CGLVSyncOffScreenSurfaceData) {
CGLVSyncOffScreenSurfaceData vsd =
(CGLVSyncOffScreenSurfaceData)sd;
SurfaceData bbsd = vsd.getFlipSurface();
Graphics2D bbg =
new SunGraphics2D(bbsd, Color.black, Color.white, null);
public void flip(final LWComponentPeer<?, ?> peer, final Image backBuffer,
final int x1, final int y1, final int x2, final int y2,
final BufferCapabilities.FlipContents flipAction) {
final Graphics g = peer.getGraphics();
try {
bbg.drawImage(xBackBuffer, 0, 0, null);
g.drawImage(backBuffer, x1, y1, x2, y2, x1, y1, x2, y2, null);
} finally {
bbg.dispose();
}
} else {
pView.drawImageOnPeer(xBackBuffer, x1, y1, x2, y2);
return;
}
} else if (flipAction == BufferCapabilities.FlipContents.PRIOR) {
// not supported by CGL...
return;
g.dispose();
}
OGLSurfaceData.swapBuffers(pView.getAWTView());
if (flipAction == BufferCapabilities.FlipContents.BACKGROUND) {
Graphics g = xBackBuffer.getGraphics();
final Graphics2D bg = (Graphics2D) backBuffer.getGraphics();
try {
g.setColor(target.getBackground());
g.fillRect(0, 0,
xBackBuffer.getWidth(),
xBackBuffer.getHeight());
bg.setBackground(peer.getBackground());
bg.clearRect(0, 0, backBuffer.getWidth(null),
backBuffer.getHeight(null));
} finally {
g.dispose();
bg.dispose();
}
}
}
......@@ -429,15 +367,10 @@ public class CGLGraphicsConfig extends CGraphicsConfig
return imageCaps;
}
/**
* {@inheritDoc}
*
* @see sun.java2d.pipe.hw.AccelGraphicsConfig#createCompatibleVolatileImage
*/
public VolatileImage
createCompatibleVolatileImage(int width, int height,
int transparency, int type)
{
@Override
public VolatileImage createCompatibleVolatileImage(int width, int height,
int transparency,
int type) {
if (type == FLIP_BACKBUFFER || type == WINDOW || type == UNDEFINED ||
transparency == Transparency.BITMASK)
{
......@@ -473,15 +406,18 @@ public class CGLGraphicsConfig extends CGraphicsConfig
*
* @see sun.java2d.pipe.hw.AccelGraphicsConfig#getContextCapabilities
*/
@Override
public ContextCapabilities getContextCapabilities() {
return oglCaps;
}
@Override
public void addDeviceEventListener(AccelDeviceEventListener l) {
int screen = getDevice().getCoreGraphicsScreen();
AccelDeviceEventNotifier.addListener(l, screen);
}
@Override
public void removeDeviceEventListener(AccelDeviceEventListener l) {
AccelDeviceEventNotifier.removeListener(l);
}
......
......@@ -26,12 +26,9 @@
package sun.lwawt;
import java.awt.AWTException;
import java.awt.BufferCapabilities;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.GraphicsConfiguration;
import java.awt.Image;
import java.awt.peer.CanvasPeer;
import javax.swing.JComponent;
......@@ -42,35 +39,10 @@ class LWCanvasPeer<T extends Component, D extends JComponent>
LWCanvasPeer(final T target, final PlatformComponent platformComponent) {
super(target, platformComponent);
}
// ---- PEER METHODS ---- //
@Override
public void createBuffers(int numBuffers, BufferCapabilities caps)
throws AWTException {
// TODO
}
@Override
public Image getBackBuffer() {
// TODO
return null;
}
@Override
public void flip(int x1, int y1, int x2, int y2,
BufferCapabilities.FlipContents flipAction) {
// TODO
}
@Override
public void destroyBuffers() {
// TODO
}
@Override
public final GraphicsConfiguration getAppropriateGraphicsConfiguration(
GraphicsConfiguration gc)
{
final GraphicsConfiguration gc) {
// TODO
return gc;
}
......
......@@ -138,6 +138,11 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
*/
static final char WIDE_CHAR = '0';
/**
* The back buffer provide user with a BufferStrategy.
*/
private Image backBuffer;
private final class DelegateContainer extends Container {
{
enableEvents(0xFFFFFFFF);
......@@ -389,6 +394,7 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
}
protected void disposeImpl() {
destroyBuffers();
LWContainerPeer cp = getContainerPeer();
if (cp != null) {
cp.removeChildPeer(this);
......@@ -415,6 +421,12 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
return getWindowPeer().getGraphicsConfiguration();
}
// Just a helper method
public final LWGraphicsConfig getLWGC() {
return (LWGraphicsConfig) getGraphicsConfiguration();
}
/*
* Overridden in LWWindowPeer to replace its surface
* data and back buffer.
......@@ -506,31 +518,45 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
return getGraphicsConfiguration().getColorModel();
}
public boolean isTranslucent() {
// Translucent windows of the top level are supported only
return false;
}
@Override
public void createBuffers(int numBuffers, BufferCapabilities caps)
public final void createBuffers(int numBuffers, BufferCapabilities caps)
throws AWTException {
throw new AWTException("Back buffers are only supported for " +
"Window or Canvas components.");
getLWGC().assertOperationSupported(numBuffers, caps);
final Image buffer = getLWGC().createBackBuffer(this);
synchronized (getStateLock()) {
backBuffer = buffer;
}
}
/*
* To be overridden in LWWindowPeer and LWCanvasPeer.
*/
@Override
public Image getBackBuffer() {
// Return null or throw AWTException?
return null;
public final Image getBackBuffer() {
synchronized (getStateLock()) {
if (backBuffer != null) {
return backBuffer;
}
}
throw new IllegalStateException("Buffers have not been created");
}
@Override
public void flip(int x1, int y1, int x2, int y2,
public final void flip(int x1, int y1, int x2, int y2,
BufferCapabilities.FlipContents flipAction) {
// Skip silently or throw AWTException?
getLWGC().flip(this, getBackBuffer(), x1, y1, x2, y2, flipAction);
}
@Override
public void destroyBuffers() {
// Do nothing
public final void destroyBuffers() {
final Image oldBB;
synchronized (getStateLock()) {
oldBB = backBuffer;
backBuffer = null;
}
getLWGC().destroyBackBuffer(oldBB);
}
// Helper method
......@@ -642,7 +668,7 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
}
}
protected final Color getBackground() {
public final Color getBackground() {
synchronized (getStateLock()) {
return background;
}
......@@ -982,19 +1008,17 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
}
@Override
public Image createImage(ImageProducer producer) {
public final Image createImage(final ImageProducer producer) {
return new ToolkitImage(producer);
}
@Override
public Image createImage(int w, int h) {
CGraphicsConfig gc = (CGraphicsConfig)getGraphicsConfiguration();
return gc.createAcceleratedImage(getTarget(), w, h);
public final Image createImage(final int width, final int height) {
return getLWGC().createAcceleratedImage(getTarget(), width, height);
}
@Override
public VolatileImage createVolatileImage(int w, int h) {
// TODO: is it a right/complete implementation?
public final VolatileImage createVolatileImage(final int w, final int h) {
return new SunVolatileImage(getTarget(), w, h);
}
......@@ -1105,8 +1129,6 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
* of target.setLocation() or as a result of user actions (window is
* dragged with mouse).
*
* To be overridden in LWWindowPeer to update its GraphicsConfig.
*
* This method could be called on the toolkit thread.
*/
protected final void handleMove(final int x, final int y,
......@@ -1122,13 +1144,19 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
* Called when this peer's size has been changed either as a result of
* target.setSize() or as a result of user actions (window is resized).
*
* To be overridden in LWWindowPeer to update its SurfaceData and
* GraphicsConfig.
*
* This method could be called on the toolkit thread.
*/
protected final void handleResize(final int w, final int h,
final boolean updateTarget) {
Image oldBB = null;
synchronized (getStateLock()) {
if (backBuffer != null) {
oldBB = backBuffer;
backBuffer = getLWGC().createBackBuffer(this);
}
}
getLWGC().destroyBackBuffer(oldBB);
if (updateTarget) {
AWTAccessor.getComponentAccessor().setSize(getTarget(), w, h);
}
......
......@@ -23,23 +23,75 @@
* questions.
*/
package sun.awt;
package sun.lwawt;
import java.awt.AWTException;
import java.awt.BufferCapabilities;
import java.awt.Component;
import java.awt.Image;
/**
* A GraphicsConfiguration implements the TextureSizeConstraining
* interface to indicate that it imposes certain limitations on the
* maximum size of supported textures.
* As lwawt can be used on different platforms with different graphic
* configurations, the general set of methods is necessary. This interface
* collects the methods that should be provided by GraphicsConfiguration,
* simplifying use by the LWAWT.
*
* @author Sergey Bylokhov
*/
public interface LWGraphicsConfig {
/*
* A GraphicsConfiguration must implements following methods to indicate
* that it imposes certain limitations on the maximum size of supported
* textures.
*/
/**
* Returns the maximum width of any texture image. By default return {@code
* Integer.MAX_VALUE}.
*/
int getMaxTextureWidth();
/**
* Returns the maximum height of any texture image. By default return {@code
* Integer.MAX_VALUE}.
*/
public interface TextureSizeConstraining {
int getMaxTextureHeight();
/*
* The following methods correspond to the multi-buffering methods in
* LWComponentPeer.java.
*/
/**
* Checks that the requested configuration is natively supported; if not, an
* AWTException is thrown.
*/
void assertOperationSupported(int numBuffers, BufferCapabilities caps)
throws AWTException;
/**
* Returns the maximum width of any texture image.
* Creates a back buffer for the given peer and returns the image wrapper.
*/
public int getMaxTextureWidth();
Image createBackBuffer(LWComponentPeer<?, ?> peer);
/**
* Returns the maximum height of any texture image.
* Destroys the back buffer object.
*/
public int getMaxTextureHeight();
void destroyBackBuffer(Image backBuffer);
/**
* Performs the native flip operation for the given target Component. Our
* flip is implemented through normal drawImage() to the graphic object,
* because of our components uses a graphic object of the container(in this
* case we also apply necessary constrains)
*/
void flip(LWComponentPeer<?, ?> peer, Image backBuffer, int x1, int y1,
int x2, int y2, BufferCapabilities.FlipContents flipAction);
/**
* Creates a new hidden-acceleration image of the given width and height
* that is associated with the target Component.
*/
Image createAcceleratedImage(Component target, int width, int height);
}
......@@ -27,7 +27,6 @@ package sun.lwawt;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.awt.peer.*;
import java.util.List;
......@@ -75,17 +74,6 @@ public class LWWindowPeer
private SurfaceData surfaceData;
private final Object surfaceDataLock = new Object();
private int backBufferCount;
private BufferCapabilities backBufferCaps;
// The back buffer is used for two purposes:
// 1. To render all the lightweight peers
// 2. To provide user with a BufferStrategy
// Need to check if a single back buffer can be used for both
// TODO: VolatileImage
// private VolatileImage backBuffer;
private volatile BufferedImage backBuffer;
private volatile int windowState = Frame.NORMAL;
// check that the mouse is over the window
......@@ -227,7 +215,6 @@ public class LWWindowPeer
if (isGrabbing()) {
ungrab();
}
destroyBuffers();
platformWindow.dispose();
super.disposeImpl();
}
......@@ -258,9 +245,11 @@ public class LWWindowPeer
}
@Override
public GraphicsConfiguration getGraphicsConfiguration() {
public final GraphicsConfiguration getGraphicsConfiguration() {
synchronized (getStateLock()) {
return graphicsConfig;
}
}
@Override
public boolean updateGraphicsData(GraphicsConfiguration gc) {
......@@ -284,48 +273,6 @@ public class LWWindowPeer
return platformWindow.transformGraphics(new SunGraphics2D(getSurfaceData(), fg, bg, f));
}
@Override
public void createBuffers(int numBuffers, BufferCapabilities caps)
throws AWTException
{
try {
// Assume this method is never called with numBuffers <= 1, as 0 is
// unsupported, and 1 corresponds to a SingleBufferStrategy which
// doesn't depend on the peer. Screen is considered as a separate
// "buffer", that's why numBuffers - 1
assert numBuffers > 1;
replaceSurfaceData(numBuffers - 1, caps, false);
} catch (InvalidPipeException z) {
throw new AWTException(z.toString());
}
}
@Override
public final Image getBackBuffer() {
synchronized (getStateLock()) {
return backBuffer;
}
}
@Override
public void flip(int x1, int y1, int x2, int y2,
BufferCapabilities.FlipContents flipAction)
{
platformWindow.flip(x1, y1, x2, y2, flipAction);
}
@Override
public final void destroyBuffers() {
final Image oldBB = getBackBuffer();
synchronized (getStateLock()) {
backBuffer = null;
}
if (oldBB != null) {
oldBB.flush();
}
}
@Override
public void setBounds(int x, int y, int w, int h, int op) {
if ((op & SET_CLIENT_SIZE) != 0) {
......@@ -343,9 +290,8 @@ public class LWWindowPeer
h = MINIMUM_HEIGHT;
}
if (graphicsConfig instanceof TextureSizeConstraining) {
final int maxW = ((TextureSizeConstraining)graphicsConfig).getMaxTextureWidth();
final int maxH = ((TextureSizeConstraining)graphicsConfig).getMaxTextureHeight();
final int maxW = getLWGC().getMaxTextureWidth();
final int maxH = getLWGC().getMaxTextureHeight();
if (w > maxW) {
w = maxW;
......@@ -353,7 +299,6 @@ public class LWWindowPeer
if (h > maxH) {
h = maxH;
}
}
// Don't post ComponentMoved/Resized and Paint events
// until we've got a notification from the delegate
......@@ -431,21 +376,14 @@ public class LWWindowPeer
min = new Dimension(MINIMUM_WIDTH, MINIMUM_HEIGHT);
}
final int maxW, maxH;
if (graphicsConfig instanceof TextureSizeConstraining) {
maxW = ((TextureSizeConstraining)graphicsConfig).getMaxTextureWidth();
maxH = ((TextureSizeConstraining)graphicsConfig).getMaxTextureHeight();
} else {
maxW = maxH = Integer.MAX_VALUE;
}
final Dimension max;
if (getTarget().isMaximumSizeSet()) {
max = getTarget().getMaximumSize();
max.width = Math.min(max.width, maxW);
max.height = Math.min(max.height, maxH);
max.width = Math.min(max.width, getLWGC().getMaxTextureWidth());
max.height = Math.min(max.height, getLWGC().getMaxTextureHeight());
} else {
max = new Dimension(maxW, maxH);
max = new Dimension(getLWGC().getMaxTextureWidth(),
getLWGC().getMaxTextureHeight());
}
platformWindow.setSizeConstraints(min.width, min.height, max.width, max.height);
......@@ -1014,21 +952,10 @@ public class LWWindowPeer
replaceSurfaceData(true);
}
private void replaceSurfaceData(boolean blit) {
replaceSurfaceData(backBufferCount, backBufferCaps, blit);
}
private void replaceSurfaceData(int newBackBufferCount,
BufferCapabilities newBackBufferCaps,
boolean blit) {
private void replaceSurfaceData(final boolean blit) {
synchronized (surfaceDataLock) {
final SurfaceData oldData = getSurfaceData();
surfaceData = platformWindow.replaceSurfaceData();
// TODO: volatile image
// VolatileImage oldBB = backBuffer;
BufferedImage oldBB = backBuffer;
backBufferCount = newBackBufferCount;
backBufferCaps = newBackBufferCaps;
final Rectangle size = getSize();
if (getSurfaceData() != null && oldData != getSurfaceData()) {
clearBackground(size.width, size.height);
......@@ -1043,35 +970,6 @@ public class LWWindowPeer
// This can only happen when this peer is being created
oldData.flush();
}
// TODO: volatile image
// backBuffer = (VolatileImage)delegate.createBackBuffer();
backBuffer = (BufferedImage) platformWindow.createBackBuffer();
if (backBuffer != null) {
Graphics g = backBuffer.getGraphics();
try {
Rectangle r = getBounds();
if (g instanceof Graphics2D) {
((Graphics2D) g).setComposite(AlphaComposite.Src);
}
g.setColor(nonOpaqueBackground);
g.fillRect(0, 0, r.width, r.height);
if (g instanceof SunGraphics2D) {
SG2DConstraint((SunGraphics2D) g, getRegion());
}
if (!isTextured()) {
g.setColor(getBackground());
g.fillRect(0, 0, r.width, r.height);
}
if (oldBB != null) {
// Draw the old back buffer to the new one
g.drawImage(oldBB, 0, 0, null);
oldBB.flush();
}
} finally {
g.dispose();
}
}
}
}
......@@ -1092,14 +990,6 @@ public class LWWindowPeer
}
}
public int getBackBufferCount() {
return backBufferCount;
}
public BufferCapabilities getBackBufferCaps() {
return backBufferCaps;
}
/*
* Request the window insets from the delegate and compares it
* with the current one. This method is mostly called by the
......
......@@ -97,17 +97,6 @@ public interface PlatformWindow {
*/
public SurfaceData replaceSurfaceData();
/*
* Creates a new image to serve as a back buffer.
*/
public Image createBackBuffer();
/*
* Move the given part of the back buffer to the front buffer.
*/
public void flip(int x1, int y1, int x2, int y2,
BufferCapabilities.FlipContents flipAction);
public void setModalBlocked(boolean blocked);
public void toFront();
......
......@@ -31,12 +31,9 @@ import sun.lwawt.LWWindowPeer;
import sun.java2d.opengl.CGLLayer;
import sun.java2d.SurfaceData;
import sun.awt.CGraphicsConfig;
import sun.awt.CGraphicsDevice;
import sun.awt.CausedFocusEvent;
import java.awt.*;
import java.awt.BufferCapabilities.FlipContents;
import sun.util.logging.PlatformLogger;
......@@ -112,22 +109,6 @@ public class CPlatformEmbeddedFrame implements PlatformWindow {
return windowLayer.replaceSurfaceData();
}
@Override
public Image createBackBuffer() {
Rectangle r = peer.getBounds();
Image im = null;
if (!r.isEmpty()) {
int transparency = peer.isTranslucent() ? Transparency.TRANSLUCENT : Transparency.OPAQUE;
im = peer.getGraphicsConfiguration().createCompatibleImage(r.width, r.height, transparency);
}
return im;
}
@Override
public void flip(int x1, int y1, int x2, int y2, FlipContents flipAction) {
throw new RuntimeException("Not implemented");
}
@Override
public void setVisible(boolean visible) {}
......
......@@ -26,7 +26,6 @@
package sun.lwawt.macosx;
import java.awt.*;
import java.awt.image.VolatileImage;
import sun.awt.CGraphicsConfig;
import sun.lwawt.LWWindowPeer;
......@@ -115,26 +114,6 @@ public class CPlatformView extends CFRetainedResource {
// ----------------------------------------------------------------------
// PAINTING METHODS
// ----------------------------------------------------------------------
public void drawImageOnPeer(VolatileImage xBackBuffer, int x1, int y1, int x2, int y2) {
Graphics g = peer.getGraphics();
try {
g.drawImage(xBackBuffer, x1, y1, x2, y2, x1, y1, x2, y2, null);
} finally {
g.dispose();
}
}
public Image createBackBuffer() {
Rectangle r = peer.getBounds();
Image im = null;
if (!r.isEmpty()) {
int transparency = (isOpaque() ? Transparency.OPAQUE : Transparency.TRANSLUCENT);
im = peer.getGraphicsConfiguration().createCompatibleImage(r.width, r.height, transparency);
}
return im;
}
public SurfaceData replaceSurfaceData() {
if (!LWCToolkit.getSunAwtDisableCALayers()) {
surfaceData = windowLayer.replaceSurfaceData();
......
......@@ -25,7 +25,6 @@
package sun.lwawt.macosx;
import java.awt.BufferCapabilities.FlipContents;
import java.awt.*;
import java.awt.Dialog.ModalityType;
import java.awt.event.*;
......@@ -401,11 +400,6 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor
}
}
@Override // PlatformWindow
public Image createBackBuffer() {
return contentView.createBackBuffer();
}
@Override // PlatformWindow
public void dispose() {
if (owner != null) {
......@@ -416,12 +410,6 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor
CPlatformWindow.super.dispose();
}
@Override // PlatformWindow
public void flip(int x1, int y1, int x2, int y2, FlipContents flipAction) {
// TODO: not implemented
(new RuntimeException("unimplemented")).printStackTrace();
}
@Override // PlatformWindow
public FontMetrics getFontMetrics(Font f) {
// TODO: not implemented
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册