23 * questions.
24 */
25 package sun.awt.windows;
26
27 import java.awt.AlphaComposite;
28 import java.awt.Color;
29 import java.awt.Graphics2D;
30 import java.awt.GraphicsConfiguration;
31 import java.awt.Image;
32 import java.awt.Window;
33 import java.awt.image.BufferedImage;
34 import java.awt.image.DataBufferInt;
35 import java.awt.image.VolatileImage;
36 import java.lang.ref.WeakReference;
37 import java.security.AccessController;
38 import sun.awt.image.BufImgSurfaceData;
39 import sun.java2d.DestSurfaceProvider;
40 import sun.java2d.InvalidPipeException;
41 import sun.java2d.Surface;
42 import sun.java2d.pipe.RenderQueue;
43 import sun.java2d.pipe.hw.AccelGraphicsConfig;
44 import sun.java2d.pipe.hw.AccelSurface;
45 import sun.security.action.GetPropertyAction;
46
47 import static java.awt.image.VolatileImage.*;
48 import static java.awt.Transparency.*;
49 import static sun.java2d.pipe.hw.AccelSurface.*;
50 import static sun.java2d.pipe.hw.ContextCapabilities.*;
51
52 /**
53 * This class handles the updates of the non-opaque windows.
54 * The window associated with the peer is updated either given an image or
55 * the window is repainted to an internal buffer which is then used to update
56 * the window.
57 *
58 * Note: this class does not attempt to be thread safe, it is expected to be
59 * called from a single thread (EDT).
60 */
61 public abstract class TranslucentWindowPainter {
62
293 private abstract static class VIOptWindowPainter extends VIWindowPainter {
294
295 protected VIOptWindowPainter(WWindowPeer peer) {
296 super(peer);
297 }
298
299 protected abstract boolean updateWindowAccel(long psdops, int w, int h);
300
301 @Override
302 protected boolean update(Image bb) {
303 if (bb instanceof DestSurfaceProvider) {
304 Surface s = ((DestSurfaceProvider)bb).getDestSurface();
305 if (s instanceof AccelSurface) {
306 final int w = bb.getWidth(null);
307 final int h = bb.getHeight(null);
308 final boolean arr[] = { false };
309 final AccelSurface as = (AccelSurface)s;
310 RenderQueue rq = as.getContext().getRenderQueue();
311 rq.lock();
312 try {
313 as.getContext().validateContext(as);
314 rq.flushAndInvokeNow(new Runnable() {
315 public void run() {
316 long psdops = as.getNativeOps();
317 arr[0] = updateWindowAccel(psdops, w, h);
318 }
319 });
320 } catch (InvalidPipeException e) {
321 // ignore, false will be returned
322 } finally {
323 rq.unlock();
324 }
325 return arr[0];
326 }
327 }
328 return super.update(bb);
329 }
330 }
331
332 private static class VIOptD3DWindowPainter extends VIOptWindowPainter {
333
|
23 * questions.
24 */
25 package sun.awt.windows;
26
27 import java.awt.AlphaComposite;
28 import java.awt.Color;
29 import java.awt.Graphics2D;
30 import java.awt.GraphicsConfiguration;
31 import java.awt.Image;
32 import java.awt.Window;
33 import java.awt.image.BufferedImage;
34 import java.awt.image.DataBufferInt;
35 import java.awt.image.VolatileImage;
36 import java.lang.ref.WeakReference;
37 import java.security.AccessController;
38 import sun.awt.image.BufImgSurfaceData;
39 import sun.java2d.DestSurfaceProvider;
40 import sun.java2d.InvalidPipeException;
41 import sun.java2d.Surface;
42 import sun.java2d.pipe.RenderQueue;
43 import sun.java2d.pipe.BufferedContext;
44 import sun.java2d.pipe.hw.AccelGraphicsConfig;
45 import sun.java2d.pipe.hw.AccelSurface;
46 import sun.security.action.GetPropertyAction;
47
48 import static java.awt.image.VolatileImage.*;
49 import static java.awt.Transparency.*;
50 import static sun.java2d.pipe.hw.AccelSurface.*;
51 import static sun.java2d.pipe.hw.ContextCapabilities.*;
52
53 /**
54 * This class handles the updates of the non-opaque windows.
55 * The window associated with the peer is updated either given an image or
56 * the window is repainted to an internal buffer which is then used to update
57 * the window.
58 *
59 * Note: this class does not attempt to be thread safe, it is expected to be
60 * called from a single thread (EDT).
61 */
62 public abstract class TranslucentWindowPainter {
63
294 private abstract static class VIOptWindowPainter extends VIWindowPainter {
295
296 protected VIOptWindowPainter(WWindowPeer peer) {
297 super(peer);
298 }
299
300 protected abstract boolean updateWindowAccel(long psdops, int w, int h);
301
302 @Override
303 protected boolean update(Image bb) {
304 if (bb instanceof DestSurfaceProvider) {
305 Surface s = ((DestSurfaceProvider)bb).getDestSurface();
306 if (s instanceof AccelSurface) {
307 final int w = bb.getWidth(null);
308 final int h = bb.getHeight(null);
309 final boolean arr[] = { false };
310 final AccelSurface as = (AccelSurface)s;
311 RenderQueue rq = as.getContext().getRenderQueue();
312 rq.lock();
313 try {
314 BufferedContext.validateContext(as);
315 rq.flushAndInvokeNow(new Runnable() {
316 public void run() {
317 long psdops = as.getNativeOps();
318 arr[0] = updateWindowAccel(psdops, w, h);
319 }
320 });
321 } catch (InvalidPipeException e) {
322 // ignore, false will be returned
323 } finally {
324 rq.unlock();
325 }
326 return arr[0];
327 }
328 }
329 return super.update(bb);
330 }
331 }
332
333 private static class VIOptD3DWindowPainter extends VIOptWindowPainter {
334
|