src/macosx/classes/sun/lwawt/LWWindowPeer.java
Print this page
*** 654,674 ****
}
// First, update peer's bounds
setBounds(x, y, w, h, SET_BOUNDS, false, false);
// Second, update the graphics config and surface data
! checkIfOnNewScreen();
! if (resized) {
replaceSurfaceData();
- flushOnscreenGraphics();
}
// Third, COMPONENT_MOVED/COMPONENT_RESIZED/PAINT events
if (moved || invalid) {
handleMove(x, y, true);
}
! if (resized || invalid) {
handleResize(w, h, true);
repaintPeer();
}
}
--- 654,673 ----
}
// First, update peer's bounds
setBounds(x, y, w, h, SET_BOUNDS, false, false);
// Second, update the graphics config and surface data
! final boolean isNewDevice = updateGraphicsDevice();
! if (resized || isNewDevice) {
replaceSurfaceData();
}
// Third, COMPONENT_MOVED/COMPONENT_RESIZED/PAINT events
if (moved || invalid) {
handleMove(x, y, true);
}
! if (resized || invalid || isNewDevice) {
handleResize(w, h, true);
repaintPeer();
}
}
*** 684,694 ****
g.setColor(nonOpaqueBackground);
g.fillRect(0, 0, w, h);
}
if (!isTextured()) {
if (g instanceof SunGraphics2D) {
! SG2DConstraint((SunGraphics2D) g, getRegion());
}
g.setColor(getBackground());
g.fillRect(0, 0, w, h);
}
} finally {
--- 683,693 ----
g.setColor(nonOpaqueBackground);
g.fillRect(0, 0, w, h);
}
if (!isTextured()) {
if (g instanceof SunGraphics2D) {
! ((SunGraphics2D) g).constrain(0, 0, w, h, getRegion());
}
g.setColor(getBackground());
g.fillRect(0, 0, w, h);
}
} finally {
*** 959,995 ****
if (graphicsConfig == gc) {
return false;
}
// If window's graphics config is changed from the app code, the
// config correspond to the same device as before; when the window
! // is moved by user, graphicsDevice is updated in checkIfOnNewScreen().
// In either case, there's nothing to do with screenOn here
graphicsConfig = gc;
}
// SurfaceData is replaced later in updateGraphicsData()
return true;
}
! private void checkIfOnNewScreen() {
GraphicsDevice newGraphicsDevice = platformWindow.getGraphicsDevice();
synchronized (getStateLock()) {
if (graphicsDevice == newGraphicsDevice) {
! return;
}
graphicsDevice = newGraphicsDevice;
}
// TODO: DisplayChangedListener stuff
final GraphicsConfiguration newGC = newGraphicsDevice.getDefaultConfiguration();
! if (!setGraphicsConfig(newGC)) return;
SunToolkit.executeOnEventHandlerThread(getTarget(), new Runnable() {
public void run() {
AWTAccessor.getComponentAccessor().setGraphicsConfiguration(getTarget(), newGC);
}
});
}
/*
* May be called by delegate to provide SD to Java2D code.
*/
--- 958,998 ----
if (graphicsConfig == gc) {
return false;
}
// If window's graphics config is changed from the app code, the
// config correspond to the same device as before; when the window
! // is moved by user, graphicsDevice is updated in notifyReshape().
// In either case, there's nothing to do with screenOn here
graphicsConfig = gc;
}
// SurfaceData is replaced later in updateGraphicsData()
return true;
}
! /**
! * Returns true if the GraphicsDevice has been changed, false otherwise.
! */
! public boolean updateGraphicsDevice() {
GraphicsDevice newGraphicsDevice = platformWindow.getGraphicsDevice();
synchronized (getStateLock()) {
if (graphicsDevice == newGraphicsDevice) {
! return false;
}
graphicsDevice = newGraphicsDevice;
}
// TODO: DisplayChangedListener stuff
final GraphicsConfiguration newGC = newGraphicsDevice.getDefaultConfiguration();
! if (!setGraphicsConfig(newGC)) return false;
SunToolkit.executeOnEventHandlerThread(getTarget(), new Runnable() {
public void run() {
AWTAccessor.getComponentAccessor().setGraphicsConfiguration(getTarget(), newGC);
}
});
+ return true;
}
/*
* May be called by delegate to provide SD to Java2D code.
*/
*** 1044,1054 ****
((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);
}
--- 1047,1057 ----
((Graphics2D) g).setComposite(AlphaComposite.Src);
}
g.setColor(nonOpaqueBackground);
g.fillRect(0, 0, r.width, r.height);
if (g instanceof SunGraphics2D) {
! ((SunGraphics2D) g).constrain(0, 0, r.width, r.height, getRegion());
}
if (!isTextured()) {
g.setColor(getBackground());
g.fillRect(0, 0, r.width, r.height);
}
*** 1060,1084 ****
} finally {
g.dispose();
}
}
}
}
private void blitSurfaceData(final SurfaceData src, final SurfaceData dst) {
//TODO blit. proof-of-concept
if (src != dst && src != null && dst != null
&& !(dst instanceof NullSurfaceData)
&& !(src instanceof NullSurfaceData)
! && src.getSurfaceType().equals(dst.getSurfaceType())) {
! final Rectangle size = getSize();
final Blit blit = Blit.locate(src.getSurfaceType(),
CompositeType.Src,
dst.getSurfaceType());
if (blit != null) {
! blit.Blit(src, dst, AlphaComposite.Src,
! getRegion(), 0, 0, 0, 0, size.width, size.height);
}
}
}
public int getBackBufferCount() {
--- 1063,1089 ----
} finally {
g.dispose();
}
}
}
+ flushOnscreenGraphics();
}
private void blitSurfaceData(final SurfaceData src, final SurfaceData dst) {
//TODO blit. proof-of-concept
if (src != dst && src != null && dst != null
&& !(dst instanceof NullSurfaceData)
&& !(src instanceof NullSurfaceData)
! && src.getSurfaceType().equals(dst.getSurfaceType())
! && src.getDefaultScale() == dst.getDefaultScale()) {
! final Rectangle size = src.getBounds();
final Blit blit = Blit.locate(src.getSurfaceType(),
CompositeType.Src,
dst.getSurfaceType());
if (blit != null) {
! blit.Blit(src, dst, AlphaComposite.Src, null, 0, 0, 0, 0,
! size.width, size.height);
}
}
}
public int getBackBufferCount() {