< prev index next >

src/java.desktop/share/classes/java/awt/Component.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 1995, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 1995, 2018, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 350,360 **** * * @since 1.4 * @see java.awt.image.BufferStrategy * @see #getBufferStrategy() */ ! private transient BufferStrategy bufferStrategy = null; /** * True when the object should ignore all repaint events. * * @since 1.4 --- 350,360 ---- * * @since 1.4 * @see java.awt.image.BufferStrategy * @see #getBufferStrategy() */ ! transient BufferStrategy bufferStrategy = null; /** * True when the object should ignore all repaint events. * * @since 1.4
*** 4036,4051 **** */ /** * The width of the back buffers */ ! private int width; /** * The height of the back buffers */ ! private int height; /** * Creates a new flipping buffer strategy for this component. * The component must be a {@code Canvas} or {@code Window} or * {@code Applet}. --- 4036,4051 ---- */ /** * The width of the back buffers */ ! int width; /** * The height of the back buffers */ ! int height; /** * Creates a new flipping buffer strategy for this component. * The component must be a {@code Canvas} or {@code Window} or * {@code Applet}.
*** 4114,4124 **** width = getWidth(); height = getHeight(); if (drawBuffer != null) { // dispose the existing backbuffers ! invalidate(); // ... then recreate the backbuffers } if (caps instanceof ExtendedBufferCapabilities) { ExtendedBufferCapabilities ebc = --- 4114,4126 ---- width = getWidth(); height = getHeight(); if (drawBuffer != null) { // dispose the existing backbuffers ! drawBuffer = null; ! drawVBuffer = null; ! destroyBuffers(); // ... then recreate the backbuffers } if (caps instanceof ExtendedBufferCapabilities) { ExtendedBufferCapabilities ebc =
*** 4202,4220 **** "Component must have a valid peer"); } } /** - * Destroys the buffers and invalidates the state of FlipBufferStrategy. - */ - private void invalidate() { - drawBuffer = null; - drawVBuffer = null; - destroyBuffers(); - } - - /** * Destroys the buffers created through this object */ protected void destroyBuffers() { VSyncedBSManager.releaseVsync(this); if (peer != null) { --- 4204,4213 ----
*** 4249,4263 **** /** * Restore the drawing buffer if it has been lost */ protected void revalidate() { validatedContents = false; ! if (getWidth() != width || getHeight() != height ! || drawBuffer == null) { ! // component has been resized or the peer was recreated; ! // recreate the backbuffers try { createBuffers(numBuffers, caps); } catch (AWTException e) { // shouldn't be possible } --- 4242,4259 ---- /** * Restore the drawing buffer if it has been lost */ protected void revalidate() { + revalidate(true); + } + + void revalidate(boolean checkSize) { validatedContents = false; ! ! if (checkSize && (getWidth() != width || getHeight() != height)) { ! // component has been resized; recreate the backbuffers try { createBuffers(numBuffers, caps); } catch (AWTException e) { // shouldn't be possible }
*** 4331,4341 **** */ public void dispose() { if (Component.this.bufferStrategy == this) { Component.this.bufferStrategy = null; if (peer != null) { ! invalidate(); } } } } // Inner class FlipBufferStrategy --- 4327,4337 ---- */ public void dispose() { if (Component.this.bufferStrategy == this) { Component.this.bufferStrategy = null; if (peer != null) { ! destroyBuffers(); } } } } // Inner class FlipBufferStrategy
*** 7158,7168 **** ComponentPeer p = peer; if (p != null) { boolean isLightweight = isLightweight(); if (bufferStrategy instanceof FlipBufferStrategy) { ! ((FlipBufferStrategy)bufferStrategy).invalidate(); } if (dropTarget != null) dropTarget.removeNotify(); // Hide peer first to stop system events such as cursor moves. --- 7154,7164 ---- ComponentPeer p = peer; if (p != null) { boolean isLightweight = isLightweight(); if (bufferStrategy instanceof FlipBufferStrategy) { ! ((FlipBufferStrategy)bufferStrategy).destroyBuffers(); } if (dropTarget != null) dropTarget.removeNotify(); // Hide peer first to stop system events such as cursor moves.
< prev index next >