author | prr |
Thu, 27 Feb 2014 10:43:53 -0800 | |
changeset 23328 | 4c53a6ebc779 |
parent 23297 | 2946ef51ee24 |
parent 23010 | 6dadb192ad81 |
child 24144 | 62b850e0054a |
permissions | -rw-r--r-- |
2 | 1 |
/* |
23297 | 2 |
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
package javax.swing; |
|
26 |
||
27 |
import java.awt.*; |
|
28 |
import java.awt.event.*; |
|
29 |
import java.awt.image.*; |
|
30 |
import java.lang.reflect.*; |
|
31 |
import java.lang.ref.WeakReference; |
|
32 |
import java.util.*; |
|
3105
b5931be76fbc
6679840: provide a way to choose v-synced BufferStrategy
malenkov
parents:
888
diff
changeset
|
33 |
|
b5931be76fbc
6679840: provide a way to choose v-synced BufferStrategy
malenkov
parents:
888
diff
changeset
|
34 |
import com.sun.java.swing.SwingUtilities3; |
23297 | 35 |
import java.util.logging.Level; |
36 |
import java.util.logging.Logger; |
|
37 |
import sun.awt.AWTAccessor; |
|
3105
b5931be76fbc
6679840: provide a way to choose v-synced BufferStrategy
malenkov
parents:
888
diff
changeset
|
38 |
|
2 | 39 |
import sun.awt.SubRegionShowable; |
40 |
import sun.java2d.SunGraphics2D; |
|
3105
b5931be76fbc
6679840: provide a way to choose v-synced BufferStrategy
malenkov
parents:
888
diff
changeset
|
41 |
import sun.java2d.pipe.hw.ExtendedBufferCapabilities; |
3084
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
888
diff
changeset
|
42 |
import sun.awt.SunToolkit; |
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3109
diff
changeset
|
43 |
import sun.util.logging.PlatformLogger; |
2 | 44 |
|
45 |
/** |
|
46 |
* A PaintManager implementation that uses a BufferStrategy for |
|
47 |
* rendering. |
|
48 |
* |
|
49 |
* @author Scott Violet |
|
50 |
*/ |
|
51 |
class BufferStrategyPaintManager extends RepaintManager.PaintManager { |
|
52 |
// |
|
53 |
// All drawing is done to a BufferStrategy. At the end of painting |
|
54 |
// (endPaint) the region that was painted is flushed to the screen |
|
55 |
// (using BufferStrategy.show). |
|
56 |
// |
|
57 |
// PaintManager.show is overriden to show directly from the |
|
58 |
// BufferStrategy (when using blit), if successful true is |
|
59 |
// returned and a paint event will not be generated. To avoid |
|
60 |
// showing from the buffer while painting a locking scheme is |
|
61 |
// implemented. When beginPaint is invoked the field painting is |
|
62 |
// set to true. If painting is true and show is invoked we |
|
63 |
// immediately return false. This is done to avoid blocking the |
|
64 |
// toolkit thread while painting happens. In a similar way when |
|
65 |
// show is invoked the field showing is set to true, beginPaint |
|
66 |
// will then block until showing is true. This scheme ensures we |
|
67 |
// only ever have one thread using the BufferStrategy and it also |
|
68 |
// ensures the toolkit thread remains as responsive as possible. |
|
69 |
// |
|
70 |
// If we're using a flip strategy the contents of the backbuffer may |
|
71 |
// have changed and so show only attempts to show from the backbuffer |
|
72 |
// if we get a blit strategy. |
|
73 |
// |
|
74 |
||
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3109
diff
changeset
|
75 |
private static final PlatformLogger LOGGER = PlatformLogger.getLogger( |
2 | 76 |
"javax.swing.BufferStrategyPaintManager"); |
77 |
||
78 |
/** |
|
79 |
* List of BufferInfos. We don't use a Map primarily because |
|
80 |
* there are typically only a handful of top level components making |
|
81 |
* a Map overkill. |
|
82 |
*/ |
|
83 |
private ArrayList<BufferInfo> bufferInfos; |
|
84 |
||
85 |
/** |
|
86 |
* Indicates <code>beginPaint</code> has been invoked. This is |
|
87 |
* set to true for the life of beginPaint/endPaint pair. |
|
88 |
*/ |
|
89 |
private boolean painting; |
|
90 |
/** |
|
91 |
* Indicates we're in the process of showing. All painting, on the EDT, |
|
92 |
* is blocked while this is true. |
|
93 |
*/ |
|
94 |
private boolean showing; |
|
95 |
||
96 |
// |
|
97 |
// Region that we need to flush. When beginPaint is called these are |
|
98 |
// reset and any subsequent calls to paint/copyArea then update these |
|
99 |
// fields accordingly. When endPaint is called we then try and show |
|
100 |
// the accumulated region. |
|
101 |
// These fields are in the coordinate system of the root. |
|
102 |
// |
|
103 |
private int accumulatedX; |
|
104 |
private int accumulatedY; |
|
105 |
private int accumulatedMaxX; |
|
106 |
private int accumulatedMaxY; |
|
107 |
||
108 |
// |
|
109 |
// The following fields are set by prepare |
|
110 |
// |
|
111 |
||
112 |
/** |
|
113 |
* Farthest JComponent ancestor for the current paint/copyArea. |
|
114 |
*/ |
|
115 |
private JComponent rootJ; |
|
116 |
/** |
|
117 |
* Location of component being painted relative to root. |
|
118 |
*/ |
|
119 |
private int xOffset; |
|
120 |
/** |
|
121 |
* Location of component being painted relative to root. |
|
122 |
*/ |
|
123 |
private int yOffset; |
|
124 |
/** |
|
125 |
* Graphics from the BufferStrategy. |
|
126 |
*/ |
|
127 |
private Graphics bsg; |
|
128 |
/** |
|
129 |
* BufferStrategy currently being used. |
|
130 |
*/ |
|
131 |
private BufferStrategy bufferStrategy; |
|
132 |
/** |
|
133 |
* BufferInfo corresponding to root. |
|
134 |
*/ |
|
135 |
private BufferInfo bufferInfo; |
|
136 |
||
137 |
/** |
|
138 |
* Set to true if the bufferInfo needs to be disposed when current |
|
139 |
* paint loop is done. |
|
140 |
*/ |
|
141 |
private boolean disposeBufferOnEnd; |
|
142 |
||
143 |
BufferStrategyPaintManager() { |
|
144 |
bufferInfos = new ArrayList<BufferInfo>(1); |
|
145 |
} |
|
146 |
||
147 |
// |
|
148 |
// PaintManager methods |
|
149 |
// |
|
150 |
||
151 |
/** |
|
152 |
* Cleans up any created BufferStrategies. |
|
153 |
*/ |
|
154 |
protected void dispose() { |
|
155 |
// dipose can be invoked at any random time. To avoid |
|
156 |
// threading dependancies we do the actual diposing via an |
|
157 |
// invokeLater. |
|
158 |
SwingUtilities.invokeLater(new Runnable() { |
|
159 |
public void run() { |
|
160 |
java.util.List<BufferInfo> bufferInfos; |
|
161 |
synchronized(BufferStrategyPaintManager.this) { |
|
162 |
while (showing) { |
|
163 |
try { |
|
8145
6714ca3d6773
7013453: BufferStrategyPaintManager.dispose will cause IllegalMonitorStateException in event thread
rupashka
parents:
5506
diff
changeset
|
164 |
BufferStrategyPaintManager.this.wait(); |
2 | 165 |
} catch (InterruptedException ie) { |
166 |
} |
|
167 |
} |
|
168 |
bufferInfos = BufferStrategyPaintManager.this.bufferInfos; |
|
169 |
BufferStrategyPaintManager.this.bufferInfos = null; |
|
170 |
} |
|
171 |
dispose(bufferInfos); |
|
172 |
} |
|
173 |
}); |
|
174 |
} |
|
175 |
||
176 |
private void dispose(java.util.List<BufferInfo> bufferInfos) { |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16839
diff
changeset
|
177 |
if (LOGGER.isLoggable(PlatformLogger.Level.FINER)) { |
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3109
diff
changeset
|
178 |
LOGGER.finer("BufferStrategyPaintManager disposed", |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3109
diff
changeset
|
179 |
new RuntimeException()); |
2 | 180 |
} |
181 |
if (bufferInfos != null) { |
|
182 |
for (BufferInfo bufferInfo : bufferInfos) { |
|
183 |
bufferInfo.dispose(); |
|
184 |
} |
|
185 |
} |
|
186 |
} |
|
187 |
||
188 |
/** |
|
189 |
* Shows the specified region of the back buffer. This will return |
|
190 |
* true if successful, false otherwise. This is invoked on the |
|
191 |
* toolkit thread in response to an expose event. |
|
192 |
*/ |
|
193 |
public boolean show(Container c, int x, int y, int w, int h) { |
|
194 |
synchronized(this) { |
|
195 |
if (painting) { |
|
196 |
// Don't show from backbuffer while in the process of |
|
197 |
// painting. |
|
198 |
return false; |
|
199 |
} |
|
200 |
showing = true; |
|
201 |
} |
|
202 |
try { |
|
203 |
BufferInfo info = getBufferInfo(c); |
|
204 |
BufferStrategy bufferStrategy; |
|
3105
b5931be76fbc
6679840: provide a way to choose v-synced BufferStrategy
malenkov
parents:
888
diff
changeset
|
205 |
if (info != null && info.isInSync() && |
2 | 206 |
(bufferStrategy = info.getBufferStrategy(false)) != null) { |
207 |
SubRegionShowable bsSubRegion = |
|
208 |
(SubRegionShowable)bufferStrategy; |
|
209 |
boolean paintAllOnExpose = info.getPaintAllOnExpose(); |
|
210 |
info.setPaintAllOnExpose(false); |
|
887 | 211 |
if (bsSubRegion.showIfNotLost(x, y, (x + w), (y + h))) { |
2 | 212 |
return !paintAllOnExpose; |
213 |
} |
|
214 |
// Mark the buffer as needing to be repainted. We don't |
|
215 |
// immediately do a repaint as this method will return false |
|
216 |
// indicating a PaintEvent should be generated which will |
|
217 |
// trigger a complete repaint. |
|
218 |
bufferInfo.setContentsLostDuringExpose(true); |
|
219 |
} |
|
220 |
} |
|
221 |
finally { |
|
222 |
synchronized(this) { |
|
223 |
showing = false; |
|
224 |
notifyAll(); |
|
225 |
} |
|
226 |
} |
|
227 |
return false; |
|
228 |
} |
|
229 |
||
230 |
public boolean paint(JComponent paintingComponent, |
|
231 |
JComponent bufferComponent, Graphics g, |
|
232 |
int x, int y, int w, int h) { |
|
10690
4e232ff8b640
7072167: The "root" field in BufferStrategyPaintManager leaks memory
rupashka
parents:
9035
diff
changeset
|
233 |
Container root = fetchRoot(paintingComponent); |
4e232ff8b640
7072167: The "root" field in BufferStrategyPaintManager leaks memory
rupashka
parents:
9035
diff
changeset
|
234 |
|
4e232ff8b640
7072167: The "root" field in BufferStrategyPaintManager leaks memory
rupashka
parents:
9035
diff
changeset
|
235 |
if (prepare(paintingComponent, root, true, x, y, w, h)) { |
2 | 236 |
if ((g instanceof SunGraphics2D) && |
237 |
((SunGraphics2D)g).getDestination() == root) { |
|
238 |
// BufferStrategy may have already constrained the Graphics. To |
|
239 |
// account for that we revert the constrain, then apply a |
|
240 |
// constrain for Swing on top of that. |
|
241 |
int cx = ((SunGraphics2D)bsg).constrainX; |
|
242 |
int cy = ((SunGraphics2D)bsg).constrainY; |
|
243 |
if (cx != 0 || cy != 0) { |
|
244 |
bsg.translate(-cx, -cy); |
|
245 |
} |
|
246 |
((SunGraphics2D)bsg).constrain(xOffset + cx, yOffset + cy, |
|
247 |
x + w, y + h); |
|
248 |
bsg.setClip(x, y, w, h); |
|
249 |
paintingComponent.paintToOffscreen(bsg, x, y, w, h, |
|
250 |
x + w, y + h); |
|
251 |
accumulate(xOffset + x, yOffset + y, w, h); |
|
252 |
return true; |
|
253 |
} else { |
|
254 |
// Assume they are going to eventually render to the screen. |
|
255 |
// This disables showing from backbuffer until a complete |
|
256 |
// repaint occurs. |
|
257 |
bufferInfo.setInSync(false); |
|
258 |
// Fall through to old rendering. |
|
259 |
} |
|
260 |
} |
|
261 |
// Invalid root, do what Swing has always done. |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16839
diff
changeset
|
262 |
if (LOGGER.isLoggable(PlatformLogger.Level.FINER)) { |
2 | 263 |
LOGGER.finer("prepare failed"); |
264 |
} |
|
265 |
return super.paint(paintingComponent, bufferComponent, g, x, y, w, h); |
|
266 |
} |
|
267 |
||
268 |
public void copyArea(JComponent c, Graphics g, int x, int y, int w, int h, |
|
269 |
int deltaX, int deltaY, boolean clip) { |
|
270 |
// Note: this method is only called internally and we know that |
|
271 |
// g is from a heavyweight Component, so no check is necessary as |
|
272 |
// it is in paint() above. |
|
273 |
// |
|
274 |
// If the buffer isn't in sync there is no point in doing a copyArea, |
|
275 |
// it has garbage. |
|
10690
4e232ff8b640
7072167: The "root" field in BufferStrategyPaintManager leaks memory
rupashka
parents:
9035
diff
changeset
|
276 |
Container root = fetchRoot(c); |
4e232ff8b640
7072167: The "root" field in BufferStrategyPaintManager leaks memory
rupashka
parents:
9035
diff
changeset
|
277 |
|
4e232ff8b640
7072167: The "root" field in BufferStrategyPaintManager leaks memory
rupashka
parents:
9035
diff
changeset
|
278 |
if (prepare(c, root, false, 0, 0, 0, 0) && bufferInfo.isInSync()) { |
2 | 279 |
if (clip) { |
280 |
Rectangle cBounds = c.getVisibleRect(); |
|
281 |
int relX = xOffset + x; |
|
282 |
int relY = yOffset + y; |
|
283 |
bsg.clipRect(xOffset + cBounds.x, |
|
284 |
yOffset + cBounds.y, |
|
285 |
cBounds.width, cBounds.height); |
|
286 |
bsg.copyArea(relX, relY, w, h, deltaX, deltaY); |
|
287 |
} |
|
288 |
else { |
|
289 |
bsg.copyArea(xOffset + x, yOffset + y, w, h, deltaX, |
|
290 |
deltaY); |
|
291 |
} |
|
292 |
accumulate(x + xOffset + deltaX, y + yOffset + deltaY, w, h); |
|
293 |
} else { |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16839
diff
changeset
|
294 |
if (LOGGER.isLoggable(PlatformLogger.Level.FINER)) { |
2 | 295 |
LOGGER.finer("copyArea: prepare failed or not in sync"); |
296 |
} |
|
297 |
// Prepare failed, or not in sync. By calling super.copyArea |
|
298 |
// we'll copy on screen. We need to flush any pending paint to |
|
299 |
// the screen otherwise we'll do a copyArea on the wrong thing. |
|
300 |
if (!flushAccumulatedRegion()) { |
|
301 |
// Flush failed, copyArea will be copying garbage, |
|
302 |
// force repaint of all. |
|
303 |
rootJ.repaint(); |
|
304 |
} else { |
|
305 |
super.copyArea(c, g, x, y, w, h, deltaX, deltaY, clip); |
|
306 |
} |
|
307 |
} |
|
308 |
} |
|
309 |
||
310 |
public void beginPaint() { |
|
311 |
synchronized(this) { |
|
312 |
painting = true; |
|
313 |
// Make sure another thread isn't attempting to show from |
|
314 |
// the back buffer. |
|
315 |
while(showing) { |
|
316 |
try { |
|
317 |
wait(); |
|
318 |
} catch (InterruptedException ie) { |
|
319 |
} |
|
320 |
} |
|
321 |
} |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16839
diff
changeset
|
322 |
if (LOGGER.isLoggable(PlatformLogger.Level.FINEST)) { |
2 | 323 |
LOGGER.finest("beginPaint"); |
324 |
} |
|
325 |
// Reset the area that needs to be painted. |
|
326 |
resetAccumulated(); |
|
327 |
} |
|
328 |
||
329 |
public void endPaint() { |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16839
diff
changeset
|
330 |
if (LOGGER.isLoggable(PlatformLogger.Level.FINEST)) { |
2 | 331 |
LOGGER.finest("endPaint: region " + accumulatedX + " " + |
332 |
accumulatedY + " " + accumulatedMaxX + " " + |
|
333 |
accumulatedMaxY); |
|
334 |
} |
|
335 |
if (painting) { |
|
336 |
if (!flushAccumulatedRegion()) { |
|
337 |
if (!isRepaintingRoot()) { |
|
338 |
repaintRoot(rootJ); |
|
339 |
} |
|
340 |
else { |
|
341 |
// Contents lost twice in a row, punt. |
|
342 |
resetDoubleBufferPerWindow(); |
|
343 |
// In case we've left junk on the screen, force a repaint. |
|
344 |
rootJ.repaint(); |
|
345 |
} |
|
346 |
} |
|
347 |
} |
|
348 |
||
349 |
BufferInfo toDispose = null; |
|
350 |
synchronized(this) { |
|
351 |
painting = false; |
|
352 |
if (disposeBufferOnEnd) { |
|
353 |
disposeBufferOnEnd = false; |
|
354 |
toDispose = bufferInfo; |
|
355 |
bufferInfos.remove(toDispose); |
|
356 |
} |
|
357 |
} |
|
358 |
if (toDispose != null) { |
|
359 |
toDispose.dispose(); |
|
360 |
} |
|
361 |
} |
|
362 |
||
363 |
/** |
|
364 |
* Renders the BufferStrategy to the screen. |
|
365 |
* |
|
366 |
* @return true if successful, false otherwise. |
|
367 |
*/ |
|
368 |
private boolean flushAccumulatedRegion() { |
|
369 |
boolean success = true; |
|
370 |
if (accumulatedX != Integer.MAX_VALUE) { |
|
371 |
SubRegionShowable bsSubRegion = (SubRegionShowable)bufferStrategy; |
|
372 |
boolean contentsLost = bufferStrategy.contentsLost(); |
|
373 |
if (!contentsLost) { |
|
374 |
bsSubRegion.show(accumulatedX, accumulatedY, |
|
375 |
accumulatedMaxX, accumulatedMaxY); |
|
376 |
contentsLost = bufferStrategy.contentsLost(); |
|
377 |
} |
|
378 |
if (contentsLost) { |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16839
diff
changeset
|
379 |
if (LOGGER.isLoggable(PlatformLogger.Level.FINER)) { |
2 | 380 |
LOGGER.finer("endPaint: contents lost"); |
381 |
} |
|
382 |
// Shown region was bogus, mark buffer as out of sync. |
|
383 |
bufferInfo.setInSync(false); |
|
384 |
success = false; |
|
385 |
} |
|
386 |
} |
|
387 |
resetAccumulated(); |
|
388 |
return success; |
|
389 |
} |
|
390 |
||
391 |
private void resetAccumulated() { |
|
392 |
accumulatedX = Integer.MAX_VALUE; |
|
393 |
accumulatedY = Integer.MAX_VALUE; |
|
394 |
accumulatedMaxX = 0; |
|
395 |
accumulatedMaxY = 0; |
|
396 |
} |
|
397 |
||
398 |
/** |
|
399 |
* Invoked when the double buffering or useTrueDoubleBuffering |
|
400 |
* changes for a JRootPane. If the rootpane is not double |
|
401 |
* buffered, or true double buffering changes we throw out any |
|
402 |
* cache we may have. |
|
403 |
*/ |
|
404 |
public void doubleBufferingChanged(final JRootPane rootPane) { |
|
405 |
if ((!rootPane.isDoubleBuffered() || |
|
406 |
!rootPane.getUseTrueDoubleBuffering()) && |
|
407 |
rootPane.getParent() != null) { |
|
408 |
if (!SwingUtilities.isEventDispatchThread()) { |
|
409 |
Runnable updater = new Runnable() { |
|
410 |
public void run() { |
|
411 |
doubleBufferingChanged0(rootPane); |
|
412 |
} |
|
413 |
}; |
|
414 |
SwingUtilities.invokeLater(updater); |
|
415 |
} |
|
416 |
else { |
|
417 |
doubleBufferingChanged0(rootPane); |
|
418 |
} |
|
419 |
} |
|
420 |
} |
|
421 |
||
422 |
/** |
|
423 |
* Does the work for doubleBufferingChanged. |
|
424 |
*/ |
|
425 |
private void doubleBufferingChanged0(JRootPane rootPane) { |
|
426 |
// This will only happen on the EDT. |
|
427 |
BufferInfo info; |
|
428 |
synchronized(this) { |
|
429 |
// Make sure another thread isn't attempting to show from |
|
430 |
// the back buffer. |
|
431 |
while(showing) { |
|
432 |
try { |
|
433 |
wait(); |
|
434 |
} catch (InterruptedException ie) { |
|
435 |
} |
|
436 |
} |
|
437 |
info = getBufferInfo(rootPane.getParent()); |
|
438 |
if (painting && bufferInfo == info) { |
|
439 |
// We're in the process of painting and the user grabbed |
|
440 |
// the Graphics. If we dispose now, endPaint will attempt |
|
441 |
// to show a bogus BufferStrategy. Set a flag so that |
|
442 |
// endPaint knows it needs to dispose this buffer. |
|
443 |
disposeBufferOnEnd = true; |
|
444 |
info = null; |
|
445 |
} else if (info != null) { |
|
446 |
bufferInfos.remove(info); |
|
447 |
} |
|
448 |
} |
|
449 |
if (info != null) { |
|
450 |
info.dispose(); |
|
451 |
} |
|
452 |
} |
|
453 |
||
454 |
/** |
|
455 |
* Calculates information common to paint/copyArea. |
|
456 |
* |
|
457 |
* @return true if should use buffering per window in painting. |
|
458 |
*/ |
|
10690
4e232ff8b640
7072167: The "root" field in BufferStrategyPaintManager leaks memory
rupashka
parents:
9035
diff
changeset
|
459 |
private boolean prepare(JComponent c, Container root, boolean isPaint, int x, int y, |
2 | 460 |
int w, int h) { |
461 |
if (bsg != null) { |
|
462 |
bsg.dispose(); |
|
463 |
bsg = null; |
|
464 |
} |
|
465 |
bufferStrategy = null; |
|
10690
4e232ff8b640
7072167: The "root" field in BufferStrategyPaintManager leaks memory
rupashka
parents:
9035
diff
changeset
|
466 |
if (root != null) { |
2 | 467 |
boolean contentsLost = false; |
468 |
BufferInfo bufferInfo = getBufferInfo(root); |
|
469 |
if (bufferInfo == null) { |
|
470 |
contentsLost = true; |
|
471 |
bufferInfo = new BufferInfo(root); |
|
472 |
bufferInfos.add(bufferInfo); |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16839
diff
changeset
|
473 |
if (LOGGER.isLoggable(PlatformLogger.Level.FINER)) { |
2 | 474 |
LOGGER.finer("prepare: new BufferInfo: " + root); |
475 |
} |
|
476 |
} |
|
477 |
this.bufferInfo = bufferInfo; |
|
478 |
if (!bufferInfo.hasBufferStrategyChanged()) { |
|
479 |
bufferStrategy = bufferInfo.getBufferStrategy(true); |
|
480 |
if (bufferStrategy != null) { |
|
481 |
bsg = bufferStrategy.getDrawGraphics(); |
|
482 |
if (bufferStrategy.contentsRestored()) { |
|
483 |
contentsLost = true; |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16839
diff
changeset
|
484 |
if (LOGGER.isLoggable(PlatformLogger.Level.FINER)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
10690
diff
changeset
|
485 |
LOGGER.finer("prepare: contents restored in prepare"); |
2 | 486 |
} |
487 |
} |
|
488 |
} |
|
489 |
else { |
|
490 |
// Couldn't create BufferStrategy, fallback to normal |
|
491 |
// painting. |
|
492 |
return false; |
|
493 |
} |
|
494 |
if (bufferInfo.getContentsLostDuringExpose()) { |
|
495 |
contentsLost = true; |
|
496 |
bufferInfo.setContentsLostDuringExpose(false); |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16839
diff
changeset
|
497 |
if (LOGGER.isLoggable(PlatformLogger.Level.FINER)) { |
2 | 498 |
LOGGER.finer("prepare: contents lost on expose"); |
499 |
} |
|
500 |
} |
|
501 |
if (isPaint && c == rootJ && x == 0 && y == 0 && |
|
502 |
c.getWidth() == w && c.getHeight() == h) { |
|
503 |
bufferInfo.setInSync(true); |
|
504 |
} |
|
505 |
else if (contentsLost) { |
|
506 |
// We either recreated the BufferStrategy, or the contents |
|
507 |
// of the buffer strategy were restored. We need to |
|
508 |
// repaint the root pane so that the back buffer is in sync |
|
509 |
// again. |
|
510 |
bufferInfo.setInSync(false); |
|
511 |
if (!isRepaintingRoot()) { |
|
512 |
repaintRoot(rootJ); |
|
513 |
} |
|
514 |
else { |
|
515 |
// Contents lost twice in a row, punt |
|
516 |
resetDoubleBufferPerWindow(); |
|
517 |
} |
|
518 |
} |
|
519 |
return (bufferInfos != null); |
|
520 |
} |
|
521 |
} |
|
522 |
return false; |
|
523 |
} |
|
524 |
||
10690
4e232ff8b640
7072167: The "root" field in BufferStrategyPaintManager leaks memory
rupashka
parents:
9035
diff
changeset
|
525 |
private Container fetchRoot(JComponent c) { |
2 | 526 |
boolean encounteredHW = false; |
527 |
rootJ = c; |
|
10690
4e232ff8b640
7072167: The "root" field in BufferStrategyPaintManager leaks memory
rupashka
parents:
9035
diff
changeset
|
528 |
Container root = c; |
2 | 529 |
xOffset = yOffset = 0; |
3084
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
888
diff
changeset
|
530 |
while (root != null && |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
888
diff
changeset
|
531 |
(!(root instanceof Window) && |
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
888
diff
changeset
|
532 |
!SunToolkit.isInstanceOf(root, "java.applet.Applet"))) { |
2 | 533 |
xOffset += root.getX(); |
534 |
yOffset += root.getY(); |
|
535 |
root = root.getParent(); |
|
536 |
if (root != null) { |
|
537 |
if (root instanceof JComponent) { |
|
538 |
rootJ = (JComponent)root; |
|
539 |
} |
|
540 |
else if (!root.isLightweight()) { |
|
541 |
if (!encounteredHW) { |
|
542 |
encounteredHW = true; |
|
543 |
} |
|
544 |
else { |
|
545 |
// We've encountered two hws now and may have |
|
546 |
// a containment hierarchy with lightweights containing |
|
547 |
// heavyweights containing other lightweights. |
|
548 |
// Heavyweights poke holes in lightweight |
|
549 |
// rendering so that if we call show on the BS |
|
550 |
// (which is associated with the Window) you will |
|
551 |
// not see the contents over any child |
|
552 |
// heavyweights. If we didn't do this when we |
|
553 |
// went to show the descendants of the nested hw |
|
554 |
// you would see nothing, so, we bail out here. |
|
10690
4e232ff8b640
7072167: The "root" field in BufferStrategyPaintManager leaks memory
rupashka
parents:
9035
diff
changeset
|
555 |
return null; |
2 | 556 |
} |
557 |
} |
|
558 |
} |
|
559 |
} |
|
560 |
if ((root instanceof RootPaneContainer) && |
|
561 |
(rootJ instanceof JRootPane)) { |
|
562 |
// We're in a Swing heavyeight (JFrame/JWindow...), use double |
|
563 |
// buffering if double buffering enabled on the JRootPane and |
|
564 |
// the JRootPane wants true double buffering. |
|
565 |
if (rootJ.isDoubleBuffered() && |
|
566 |
((JRootPane)rootJ).getUseTrueDoubleBuffering()) { |
|
567 |
// Whether or not a component is double buffered is a |
|
568 |
// bit tricky with Swing. This gives a good approximation |
|
569 |
// of the various ways to turn on double buffering for |
|
570 |
// components. |
|
10690
4e232ff8b640
7072167: The "root" field in BufferStrategyPaintManager leaks memory
rupashka
parents:
9035
diff
changeset
|
571 |
return root; |
2 | 572 |
} |
573 |
} |
|
574 |
// Don't do true double buffering. |
|
10690
4e232ff8b640
7072167: The "root" field in BufferStrategyPaintManager leaks memory
rupashka
parents:
9035
diff
changeset
|
575 |
return null; |
2 | 576 |
} |
577 |
||
578 |
/** |
|
579 |
* Turns off double buffering per window. |
|
580 |
*/ |
|
581 |
private void resetDoubleBufferPerWindow() { |
|
582 |
if (bufferInfos != null) { |
|
583 |
dispose(bufferInfos); |
|
584 |
bufferInfos = null; |
|
585 |
repaintManager.setPaintManager(null); |
|
586 |
} |
|
587 |
} |
|
588 |
||
589 |
/** |
|
590 |
* Returns the BufferInfo for the specified root or null if one |
|
591 |
* hasn't been created yet. |
|
592 |
*/ |
|
593 |
private BufferInfo getBufferInfo(Container root) { |
|
594 |
for (int counter = bufferInfos.size() - 1; counter >= 0; counter--) { |
|
595 |
BufferInfo bufferInfo = bufferInfos.get(counter); |
|
596 |
Container biRoot = bufferInfo.getRoot(); |
|
597 |
if (biRoot == null) { |
|
598 |
// Window gc'ed |
|
599 |
bufferInfos.remove(counter); |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16839
diff
changeset
|
600 |
if (LOGGER.isLoggable(PlatformLogger.Level.FINER)) { |
2 | 601 |
LOGGER.finer("BufferInfo pruned, root null"); |
602 |
} |
|
603 |
} |
|
604 |
else if (biRoot == root) { |
|
605 |
return bufferInfo; |
|
606 |
} |
|
607 |
} |
|
608 |
return null; |
|
609 |
} |
|
610 |
||
611 |
private void accumulate(int x, int y, int w, int h) { |
|
612 |
accumulatedX = Math.min(x, accumulatedX); |
|
613 |
accumulatedY = Math.min(y, accumulatedY); |
|
614 |
accumulatedMaxX = Math.max(accumulatedMaxX, x + w); |
|
615 |
accumulatedMaxY = Math.max(accumulatedMaxY, y + h); |
|
616 |
} |
|
617 |
||
618 |
||
619 |
||
620 |
/** |
|
621 |
* BufferInfo is used to track the BufferStrategy being used for |
|
622 |
* a particular Component. In addition to tracking the BufferStrategy |
|
623 |
* it will install a WindowListener and ComponentListener. When the |
|
624 |
* component is hidden/iconified the buffer is marked as needing to be |
|
625 |
* completely repainted. |
|
626 |
*/ |
|
627 |
private class BufferInfo extends ComponentAdapter implements |
|
628 |
WindowListener { |
|
629 |
// NOTE: This class does NOT hold a direct reference to the root, if it |
|
630 |
// did there would be a cycle between the BufferPerWindowPaintManager |
|
631 |
// and the Window so that it could never be GC'ed |
|
632 |
// |
|
633 |
// Reference to BufferStrategy is referenced via WeakReference for |
|
634 |
// same reason. |
|
635 |
private WeakReference<BufferStrategy> weakBS; |
|
636 |
private WeakReference<Container> root; |
|
637 |
// Indicates whether or not the backbuffer and display are in sync. |
|
638 |
// This is set to true when a full repaint on the rootpane is done. |
|
639 |
private boolean inSync; |
|
640 |
// Indicates the contents were lost during and expose event. |
|
641 |
private boolean contentsLostDuringExpose; |
|
642 |
// Indicates we need to generate a paint event on expose. |
|
643 |
private boolean paintAllOnExpose; |
|
644 |
||
645 |
||
646 |
public BufferInfo(Container root) { |
|
647 |
this.root = new WeakReference<Container>(root); |
|
648 |
root.addComponentListener(this); |
|
649 |
if (root instanceof Window) { |
|
650 |
((Window)root).addWindowListener(this); |
|
651 |
} |
|
652 |
} |
|
653 |
||
654 |
public void setPaintAllOnExpose(boolean paintAllOnExpose) { |
|
655 |
this.paintAllOnExpose = paintAllOnExpose; |
|
656 |
} |
|
657 |
||
658 |
public boolean getPaintAllOnExpose() { |
|
659 |
return paintAllOnExpose; |
|
660 |
} |
|
661 |
||
662 |
public void setContentsLostDuringExpose(boolean value) { |
|
663 |
contentsLostDuringExpose = value; |
|
664 |
} |
|
665 |
||
666 |
public boolean getContentsLostDuringExpose() { |
|
667 |
return contentsLostDuringExpose; |
|
668 |
} |
|
669 |
||
670 |
public void setInSync(boolean inSync) { |
|
671 |
this.inSync = inSync; |
|
672 |
} |
|
673 |
||
674 |
/** |
|
675 |
* Whether or not the contents of the buffer strategy |
|
676 |
* is in sync with the window. This is set to true when the root |
|
677 |
* pane paints all, and false when contents are lost/restored. |
|
678 |
*/ |
|
679 |
public boolean isInSync() { |
|
680 |
return inSync; |
|
681 |
} |
|
682 |
||
683 |
/** |
|
684 |
* Returns the Root (Window or Applet) that this BufferInfo references. |
|
685 |
*/ |
|
686 |
public Container getRoot() { |
|
687 |
return (root == null) ? null : root.get(); |
|
688 |
} |
|
689 |
||
690 |
/** |
|
691 |
* Returns the BufferStartegy. This will return null if |
|
692 |
* the BufferStartegy hasn't been created and <code>create</code> is |
|
693 |
* false, or if there is a problem in creating the |
|
694 |
* <code>BufferStartegy</code>. |
|
695 |
* |
|
696 |
* @param create If true, and the BufferStartegy is currently null, |
|
697 |
* one will be created. |
|
698 |
*/ |
|
699 |
public BufferStrategy getBufferStrategy(boolean create) { |
|
700 |
BufferStrategy bs = (weakBS == null) ? null : weakBS.get(); |
|
701 |
if (bs == null && create) { |
|
702 |
bs = createBufferStrategy(); |
|
703 |
if (bs != null) { |
|
704 |
weakBS = new WeakReference<BufferStrategy>(bs); |
|
705 |
} |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16839
diff
changeset
|
706 |
if (LOGGER.isLoggable(PlatformLogger.Level.FINER)) { |
2 | 707 |
LOGGER.finer("getBufferStrategy: created bs: " + bs); |
708 |
} |
|
709 |
} |
|
710 |
return bs; |
|
711 |
} |
|
712 |
||
713 |
/** |
|
714 |
* Returns true if the buffer strategy of the component differs |
|
715 |
* from current buffer strategy. |
|
716 |
*/ |
|
717 |
public boolean hasBufferStrategyChanged() { |
|
718 |
Container root = getRoot(); |
|
719 |
if (root != null) { |
|
720 |
BufferStrategy ourBS = null; |
|
721 |
BufferStrategy componentBS = null; |
|
722 |
||
723 |
ourBS = getBufferStrategy(false); |
|
724 |
if (root instanceof Window) { |
|
725 |
componentBS = ((Window)root).getBufferStrategy(); |
|
726 |
} |
|
727 |
else { |
|
23297 | 728 |
componentBS = AWTAccessor.getComponentAccessor().getBufferStrategy(root); |
2 | 729 |
} |
730 |
if (componentBS != ourBS) { |
|
731 |
// Component has a different BS, dispose ours. |
|
732 |
if (ourBS != null) { |
|
733 |
ourBS.dispose(); |
|
734 |
} |
|
735 |
weakBS = null; |
|
736 |
return true; |
|
737 |
} |
|
738 |
} |
|
739 |
return false; |
|
740 |
} |
|
741 |
||
742 |
/** |
|
743 |
* Creates the BufferStrategy. If the appropriate system property |
|
744 |
* has been set we'll try for flip first and then we'll try for |
|
745 |
* blit. |
|
746 |
*/ |
|
747 |
private BufferStrategy createBufferStrategy() { |
|
748 |
Container root = getRoot(); |
|
749 |
if (root == null) { |
|
750 |
return null; |
|
751 |
} |
|
752 |
BufferStrategy bs = null; |
|
3105
b5931be76fbc
6679840: provide a way to choose v-synced BufferStrategy
malenkov
parents:
888
diff
changeset
|
753 |
if (SwingUtilities3.isVsyncRequested(root)) { |
b5931be76fbc
6679840: provide a way to choose v-synced BufferStrategy
malenkov
parents:
888
diff
changeset
|
754 |
bs = createBufferStrategy(root, true); |
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16839
diff
changeset
|
755 |
if (LOGGER.isLoggable(PlatformLogger.Level.FINER)) { |
3105
b5931be76fbc
6679840: provide a way to choose v-synced BufferStrategy
malenkov
parents:
888
diff
changeset
|
756 |
LOGGER.finer("createBufferStrategy: using vsynced strategy"); |
2 | 757 |
} |
758 |
} |
|
759 |
if (bs == null) { |
|
3105
b5931be76fbc
6679840: provide a way to choose v-synced BufferStrategy
malenkov
parents:
888
diff
changeset
|
760 |
bs = createBufferStrategy(root, false); |
2 | 761 |
} |
762 |
if (!(bs instanceof SubRegionShowable)) { |
|
763 |
// We do this for two reasons: |
|
764 |
// 1. So that we know we can cast to SubRegionShowable and |
|
765 |
// invoke show with the minimal region to update |
|
766 |
// 2. To avoid the possibility of invoking client code |
|
767 |
// on the toolkit thread. |
|
768 |
bs = null; |
|
769 |
} |
|
770 |
return bs; |
|
771 |
} |
|
772 |
||
3105
b5931be76fbc
6679840: provide a way to choose v-synced BufferStrategy
malenkov
parents:
888
diff
changeset
|
773 |
// Creates and returns a buffer strategy. If |
2 | 774 |
// there is a problem creating the buffer strategy this will |
775 |
// eat the exception and return null. |
|
776 |
private BufferStrategy createBufferStrategy(Container root, |
|
3105
b5931be76fbc
6679840: provide a way to choose v-synced BufferStrategy
malenkov
parents:
888
diff
changeset
|
777 |
boolean isVsynced) { |
b5931be76fbc
6679840: provide a way to choose v-synced BufferStrategy
malenkov
parents:
888
diff
changeset
|
778 |
BufferCapabilities caps; |
b5931be76fbc
6679840: provide a way to choose v-synced BufferStrategy
malenkov
parents:
888
diff
changeset
|
779 |
if (isVsynced) { |
b5931be76fbc
6679840: provide a way to choose v-synced BufferStrategy
malenkov
parents:
888
diff
changeset
|
780 |
caps = new ExtendedBufferCapabilities( |
b5931be76fbc
6679840: provide a way to choose v-synced BufferStrategy
malenkov
parents:
888
diff
changeset
|
781 |
new ImageCapabilities(true), new ImageCapabilities(true), |
b5931be76fbc
6679840: provide a way to choose v-synced BufferStrategy
malenkov
parents:
888
diff
changeset
|
782 |
BufferCapabilities.FlipContents.COPIED, |
b5931be76fbc
6679840: provide a way to choose v-synced BufferStrategy
malenkov
parents:
888
diff
changeset
|
783 |
ExtendedBufferCapabilities.VSyncType.VSYNC_ON); |
b5931be76fbc
6679840: provide a way to choose v-synced BufferStrategy
malenkov
parents:
888
diff
changeset
|
784 |
} else { |
b5931be76fbc
6679840: provide a way to choose v-synced BufferStrategy
malenkov
parents:
888
diff
changeset
|
785 |
caps = new BufferCapabilities( |
b5931be76fbc
6679840: provide a way to choose v-synced BufferStrategy
malenkov
parents:
888
diff
changeset
|
786 |
new ImageCapabilities(true), new ImageCapabilities(true), |
b5931be76fbc
6679840: provide a way to choose v-synced BufferStrategy
malenkov
parents:
888
diff
changeset
|
787 |
null); |
b5931be76fbc
6679840: provide a way to choose v-synced BufferStrategy
malenkov
parents:
888
diff
changeset
|
788 |
} |
2 | 789 |
BufferStrategy bs = null; |
3084
67ca55732362
6824169: Need to remove some AWT class dependencies
dcherepanov
parents:
888
diff
changeset
|
790 |
if (SunToolkit.isInstanceOf(root, "java.applet.Applet")) { |
2 | 791 |
try { |
23297 | 792 |
AWTAccessor.ComponentAccessor componentAccessor |
793 |
= AWTAccessor.getComponentAccessor(); |
|
794 |
componentAccessor.createBufferStrategy(root, 2, caps); |
|
795 |
bs = componentAccessor.getBufferStrategy(root); |
|
796 |
} catch (AWTException e) { |
|
2 | 797 |
// Type is not supported |
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16839
diff
changeset
|
798 |
if (LOGGER.isLoggable(PlatformLogger.Level.FINER)) { |
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3109
diff
changeset
|
799 |
LOGGER.finer("createBufferStratety failed", |
23297 | 800 |
e); |
2 | 801 |
} |
802 |
} |
|
803 |
} |
|
804 |
else { |
|
805 |
try { |
|
806 |
((Window)root).createBufferStrategy(2, caps); |
|
807 |
bs = ((Window)root).getBufferStrategy(); |
|
808 |
} catch (AWTException e) { |
|
809 |
// Type not supported |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16839
diff
changeset
|
810 |
if (LOGGER.isLoggable(PlatformLogger.Level.FINER)) { |
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3109
diff
changeset
|
811 |
LOGGER.finer("createBufferStratety failed", |
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3109
diff
changeset
|
812 |
e); |
2 | 813 |
} |
814 |
} |
|
815 |
} |
|
816 |
return bs; |
|
817 |
} |
|
818 |
||
819 |
/** |
|
820 |
* Cleans up and removes any references. |
|
821 |
*/ |
|
822 |
public void dispose() { |
|
823 |
Container root = getRoot(); |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
16839
diff
changeset
|
824 |
if (LOGGER.isLoggable(PlatformLogger.Level.FINER)) { |
3938
ef327bd847c0
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents:
3109
diff
changeset
|
825 |
LOGGER.finer("disposed BufferInfo for: " + root); |
2 | 826 |
} |
827 |
if (root != null) { |
|
828 |
root.removeComponentListener(this); |
|
829 |
if (root instanceof Window) { |
|
830 |
((Window)root).removeWindowListener(this); |
|
831 |
} |
|
832 |
BufferStrategy bs = getBufferStrategy(false); |
|
833 |
if (bs != null) { |
|
834 |
bs.dispose(); |
|
835 |
} |
|
836 |
} |
|
837 |
this.root = null; |
|
838 |
weakBS = null; |
|
839 |
} |
|
840 |
||
841 |
// We mark the buffer as needing to be painted on a hide/iconify |
|
842 |
// because the developer may have conditionalized painting based on |
|
843 |
// visibility. |
|
844 |
// Ideally we would also move to having the BufferStrategy being |
|
845 |
// a SoftReference in Component here, but that requires changes to |
|
846 |
// Component and the like. |
|
847 |
public void componentHidden(ComponentEvent e) { |
|
848 |
Container root = getRoot(); |
|
849 |
if (root != null && root.isVisible()) { |
|
850 |
// This case will only happen if a developer calls |
|
851 |
// hide immediately followed by show. In this case |
|
852 |
// the event is delivered after show and the window |
|
853 |
// will still be visible. If a developer altered the |
|
854 |
// contents of the window between the hide/show |
|
855 |
// invocations we won't recognize we need to paint and |
|
856 |
// the contents would be bogus. Calling repaint here |
|
857 |
// fixs everything up. |
|
858 |
root.repaint(); |
|
859 |
} |
|
860 |
else { |
|
861 |
setPaintAllOnExpose(true); |
|
862 |
} |
|
863 |
} |
|
864 |
||
865 |
public void windowIconified(WindowEvent e) { |
|
866 |
setPaintAllOnExpose(true); |
|
867 |
} |
|
868 |
||
869 |
// On a dispose we chuck everything. |
|
870 |
public void windowClosed(WindowEvent e) { |
|
871 |
// Make sure we're not showing. |
|
872 |
synchronized(BufferStrategyPaintManager.this) { |
|
873 |
while (showing) { |
|
874 |
try { |
|
875 |
BufferStrategyPaintManager.this.wait(); |
|
876 |
} catch (InterruptedException ie) { |
|
877 |
} |
|
878 |
} |
|
879 |
bufferInfos.remove(this); |
|
880 |
} |
|
881 |
dispose(); |
|
882 |
} |
|
883 |
||
884 |
public void windowOpened(WindowEvent e) { |
|
885 |
} |
|
886 |
||
887 |
public void windowClosing(WindowEvent e) { |
|
888 |
} |
|
889 |
||
890 |
public void windowDeiconified(WindowEvent e) { |
|
891 |
} |
|
892 |
||
893 |
public void windowActivated(WindowEvent e) { |
|
894 |
} |
|
895 |
||
896 |
public void windowDeactivated(WindowEvent e) { |
|
897 |
} |
|
898 |
} |
|
899 |
} |