src/macosx/classes/sun/lwawt/LWComponentPeer.java

Print this page

        

*** 136,145 **** --- 136,150 ---- /** * Character with reasonable value between the minimum width and maximum. */ 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); }
*** 387,396 **** --- 392,402 ---- disposeImpl(); } } protected void disposeImpl() { + destroyBuffers(); LWContainerPeer cp = getContainerPeer(); if (cp != null) { cp.removeChildPeer(this); } platformComponent.dispose();
*** 413,422 **** --- 419,434 ---- // for windows, but this method is overridden in // LWWindowPeer and doesn't call super() 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. */ @Override
*** 504,538 **** public ColorModel getColorModel() { // Is it a correct implementation? return getGraphicsConfiguration().getColorModel(); } @Override ! public void createBuffers(int numBuffers, BufferCapabilities caps) throws AWTException { ! throw new AWTException("Back buffers are only supported for " + ! "Window or Canvas components."); } - /* - * To be overridden in LWWindowPeer and LWCanvasPeer. - */ @Override ! public Image getBackBuffer() { ! // Return null or throw AWTException? ! return null; } @Override ! public void flip(int x1, int y1, int x2, int y2, BufferCapabilities.FlipContents flipAction) { ! // Skip silently or throw AWTException? } @Override ! public void destroyBuffers() { ! // Do nothing } // Helper method public void setBounds(Rectangle r) { setBounds(r.x, r.y, r.width, r.height, SET_BOUNDS); --- 516,564 ---- public ColorModel getColorModel() { // Is it a correct implementation? return getGraphicsConfiguration().getColorModel(); } + public boolean isTranslucent() { + // Translucent windows of the top level are supported only + return false; + } + @Override ! public final void createBuffers(int numBuffers, BufferCapabilities caps) throws AWTException { ! getLWGC().assertOperationSupported(numBuffers, caps); ! final Image buffer = getLWGC().createBackBuffer(this); ! synchronized (getStateLock()) { ! backBuffer = buffer; ! } } @Override ! public final Image getBackBuffer() { ! synchronized (getStateLock()) { ! if (backBuffer != null) { ! return backBuffer; ! } ! } ! throw new IllegalStateException("Buffers have not been created"); } @Override ! public final void flip(int x1, int y1, int x2, int y2, BufferCapabilities.FlipContents flipAction) { ! getLWGC().flip(this, getBackBuffer(), x1, y1, x2, y2, flipAction); } @Override ! public final void destroyBuffers() { ! final Image oldBB; ! synchronized (getStateLock()) { ! oldBB = backBuffer; ! backBuffer = null; ! } ! getLWGC().destroyBackBuffer(oldBB); } // Helper method public void setBounds(Rectangle r) { setBounds(r.x, r.y, r.width, r.height, SET_BOUNDS);
*** 640,650 **** } else { repaintPeer(); } } ! protected final Color getBackground() { synchronized (getStateLock()) { return background; } } --- 666,676 ---- } else { repaintPeer(); } } ! public final Color getBackground() { synchronized (getStateLock()) { return background; } }
*** 980,1002 **** return false; } @Override ! public Image createImage(ImageProducer producer) { return new ToolkitImage(producer); } @Override ! public Image createImage(int w, int h) { ! CGraphicsConfig gc = (CGraphicsConfig)getGraphicsConfiguration(); ! return gc.createAcceleratedImage(getTarget(), w, h); } @Override ! public VolatileImage createVolatileImage(int w, int h) { ! // TODO: is it a right/complete implementation? return new SunVolatileImage(getTarget(), w, h); } @Override public boolean prepareImage(Image img, int w, int h, ImageObserver o) { --- 1006,1026 ---- return false; } @Override ! public final Image createImage(final ImageProducer producer) { return new ToolkitImage(producer); } @Override ! public final Image createImage(final int width, final int height) { ! return getLWGC().createAcceleratedImage(getTarget(), width, height); } @Override ! public final VolatileImage createVolatileImage(final int w, final int h) { return new SunVolatileImage(getTarget(), w, h); } @Override public boolean prepareImage(Image img, int w, int h, ImageObserver o) {
*** 1103,1114 **** /** * Called when this peer's location has been changed either as a result * 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, final boolean updateTarget) { if (updateTarget) { --- 1127,1136 ----
*** 1120,1136 **** /** * 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) { if (updateTarget) { AWTAccessor.getComponentAccessor().setSize(getTarget(), w, h); } postEvent(new ComponentEvent(getTarget(), ComponentEvent.COMPONENT_RESIZED)); --- 1142,1164 ---- /** * 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). * * 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); } postEvent(new ComponentEvent(getTarget(), ComponentEvent.COMPONENT_RESIZED));