1 /*
2 * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
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
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
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 *
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
263 // because they may be accessed on that thread at the time of the
264 // disposal (for example, when the accel. cache is invalidated)
265
266 // Whilst this is a bit heavyweight, in most applications
267 // strike disposal is a relatively infrequent operation, so it
268 // doesn't matter. But in some tests that use vast numbers
269 // of strikes, the switching back and forth is measurable.
270 // So the "pollRemove" call is added to batch up the work.
271 // If we are polling we know we've already been called back
272 // and can directly dispose the record.
273 // Also worrisome is the necessity of getting a GC here.
274
275 if (Disposer.pollingQueue) {
276 doDispose(disposer);
277 return;
278 }
279
280 RenderQueue rq = null;
281 GraphicsEnvironment ge =
282 GraphicsEnvironment.getLocalGraphicsEnvironment();
283 if (!ge.isHeadless()) {
284 GraphicsConfiguration gc =
285 ge.getDefaultScreenDevice().getDefaultConfiguration();
286 if (gc instanceof AccelGraphicsConfig) {
287 AccelGraphicsConfig agc = (AccelGraphicsConfig)gc;
288 BufferedContext bc = agc.getContext();
289 if (bc != null) {
290 rq = bc.getRenderQueue();
291 }
292 }
293 }
294 if (rq != null) {
295 rq.lock();
296 try {
297 rq.flushAndInvokeNow(new Runnable() {
298 public void run() {
299 doDispose(disposer);
300 Disposer.pollRemove();
301 }
302 });
303 } finally {
|
1 /*
2 * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
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
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
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 *
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
263 // because they may be accessed on that thread at the time of the
264 // disposal (for example, when the accel. cache is invalidated)
265
266 // Whilst this is a bit heavyweight, in most applications
267 // strike disposal is a relatively infrequent operation, so it
268 // doesn't matter. But in some tests that use vast numbers
269 // of strikes, the switching back and forth is measurable.
270 // So the "pollRemove" call is added to batch up the work.
271 // If we are polling we know we've already been called back
272 // and can directly dispose the record.
273 // Also worrisome is the necessity of getting a GC here.
274
275 if (Disposer.pollingQueue) {
276 doDispose(disposer);
277 return;
278 }
279
280 RenderQueue rq = null;
281 GraphicsEnvironment ge =
282 GraphicsEnvironment.getLocalGraphicsEnvironment();
283 if (!GraphicsEnvironment.isHeadless()) {
284 GraphicsConfiguration gc =
285 ge.getDefaultScreenDevice().getDefaultConfiguration();
286 if (gc instanceof AccelGraphicsConfig) {
287 AccelGraphicsConfig agc = (AccelGraphicsConfig)gc;
288 BufferedContext bc = agc.getContext();
289 if (bc != null) {
290 rq = bc.getRenderQueue();
291 }
292 }
293 }
294 if (rq != null) {
295 rq.lock();
296 try {
297 rq.flushAndInvokeNow(new Runnable() {
298 public void run() {
299 doDispose(disposer);
300 Disposer.pollRemove();
301 }
302 });
303 } finally {
|