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
23 * questions.
24 */
25
26 package sun.lwawt;
27
28 import java.awt.*;
29 import java.awt.event.*;
30 import java.awt.image.BufferedImage;
31 import java.awt.peer.*;
32 import java.util.List;
33
34 import javax.swing.*;
35
36 import sun.awt.*;
37 import sun.java2d.*;
38 import sun.java2d.loops.Blit;
39 import sun.java2d.loops.CompositeType;
40 import sun.util.logging.PlatformLogger;
41
42 public class LWWindowPeer
43 extends LWContainerPeer<Window, JComponent>
44 implements WindowPeer, FramePeer, DialogPeer, FullScreenCapable
45 {
46 public static enum PeerType {
47 SIMPLEWINDOW,
48 FRAME,
49 DIALOG,
50 EMBEDDEDFRAME
51 }
52
53 private static final PlatformLogger focusLog = PlatformLogger.getLogger("sun.lwawt.focus.LWWindowPeer");
54
55 private PlatformWindow platformWindow;
56
57 // Window bounds reported by the native system (as opposed to
58 // regular bounds inherited from LWComponentPeer which are
59 // requested by user and may haven't been applied yet because
92 // find the component under cursor
93 private static volatile LWComponentPeer lastMouseEventPeer = null;
94
95 // Peers where all dragged/released events should come to,
96 // depending on what mouse button is being dragged according to Cocoa
97 private static LWComponentPeer mouseDownTarget[] = new LWComponentPeer[3];
98
99 // A bitmask that indicates what mouse buttons produce MOUSE_CLICKED events
100 // on MOUSE_RELEASE. Click events are only generated if there were no drag
101 // events between MOUSE_PRESSED and MOUSE_RELEASED for particular button
102 private static int mouseClickButtons = 0;
103
104 private volatile boolean isOpaque = true;
105
106 private static final Font DEFAULT_FONT = new Font("Lucida Grande", Font.PLAIN, 13);
107
108 private static LWWindowPeer grabbingWindow;
109
110 private volatile boolean skipNextFocusChange;
111
112 /**
113 * Current modal blocker or null.
114 *
115 * Synchronization: peerTreeLock.
116 */
117 private LWWindowPeer blocker;
118
119 public LWWindowPeer(Window target, PlatformComponent platformComponent,
120 PlatformWindow platformWindow)
121 {
122 super(target, platformComponent);
123 this.platformWindow = platformWindow;
124
125 Window owner = target.getOwner();
126 LWWindowPeer ownerPeer = (owner != null) ? (LWWindowPeer)owner.getPeer() : null;
127 PlatformWindow ownerDelegate = (ownerPeer != null) ? ownerPeer.getPlatformWindow() : null;
128
129 // The delegate.initialize() needs a non-null GC on X11.
130 GraphicsConfiguration gc = getTarget().getGraphicsConfiguration();
131 synchronized (getStateLock()) {
152 // we should not call setForeground because it will call a repaint
153 // which the peer may not be ready to do yet.
154 }
155
156 platformWindow.initialize(target, this, ownerDelegate);
157 }
158
159 @Override
160 void initializeImpl() {
161 super.initializeImpl();
162 if (getTarget() instanceof Frame) {
163 setTitle(((Frame) getTarget()).getTitle());
164 setState(((Frame) getTarget()).getExtendedState());
165 } else if (getTarget() instanceof Dialog) {
166 setTitle(((Dialog) getTarget()).getTitle());
167 }
168
169 setAlwaysOnTop(getTarget().isAlwaysOnTop());
170 updateMinimumSize();
171
172 final float opacity = getTarget().getOpacity();
173 if (opacity < 1.0f) {
174 setOpacity(opacity);
175 }
176
177 setOpaque(getTarget().isOpaque());
178
179 updateInsets(platformWindow.getInsets());
180 if (getSurfaceData() == null) {
181 replaceSurfaceData();
182 }
183 }
184
185 // Just a helper method
186 public PlatformWindow getPlatformWindow() {
187 return platformWindow;
188 }
189
190 @Override
191 protected LWWindowPeer getWindowPeerOrSelf() {
192 return this;
193 }
194
195 @Override
196 protected void initializeContainerPeer() {
197 // No-op as LWWindowPeer doesn't have any containerPeer
198 }
199
200 // ---- PEER METHODS ---- //
201
263 if (bg == null) {
264 bg = SystemColor.window;
265 }
266 if (f == null) {
267 f = DEFAULT_FONT;
268 }
269 return platformWindow.transformGraphics(new SunGraphics2D(getSurfaceData(), fg, bg, f));
270 }
271
272 @Override
273 public void createBuffers(int numBuffers, BufferCapabilities caps)
274 throws AWTException
275 {
276 try {
277 // Assume this method is never called with numBuffers <= 1, as 0 is
278 // unsupported, and 1 corresponds to a SingleBufferStrategy which
279 // doesn't depend on the peer. Screen is considered as a separate
280 // "buffer", that's why numBuffers - 1
281 assert numBuffers > 1;
282
283 replaceSurfaceData(numBuffers - 1, caps);
284 } catch (InvalidPipeException z) {
285 throw new AWTException(z.toString());
286 }
287 }
288
289 @Override
290 public final Image getBackBuffer() {
291 synchronized (getStateLock()) {
292 return backBuffer;
293 }
294 }
295
296 @Override
297 public void flip(int x1, int y1, int x2, int y2,
298 BufferCapabilities.FlipContents flipAction)
299 {
300 platformWindow.flip(x1, y1, x2, y2, flipAction);
301 }
302
303 @Override
403 d = new Dimension(MINIMUM_WIDTH, MINIMUM_HEIGHT);
404 }
405 platformWindow.setMinimumSize(d.width, d.height);
406 }
407
408 @Override
409 public void updateIconImages() {
410 getPlatformWindow().updateIconImages();
411 }
412
413 @Override
414 public void setOpacity(float opacity) {
415 getPlatformWindow().setOpacity(opacity);
416 repaintPeer();
417 }
418
419 @Override
420 public final void setOpaque(final boolean isOpaque) {
421 if (this.isOpaque != isOpaque) {
422 this.isOpaque = isOpaque;
423 getPlatformWindow().setOpaque(isOpaque);
424 replaceSurfaceData();
425 repaintPeer();
426 }
427 }
428
429 public final boolean isOpaque() {
430 return isOpaque;
431 }
432
433 @Override
434 public void updateWindow() {
435 flushOffscreenGraphics();
436 }
437
438 @Override
439 public void repositionSecurityWarning() {
440 throw new RuntimeException("not implemented");
441 }
442
443 // ---- FRAME PEER METHODS ---- //
444
445 @Override // FramePeer and DialogPeer
446 public void setTitle(String title) {
447 platformWindow.setTitle(title == null ? "" : title);
448 }
449
450 @Override
451 public void setMenuBar(MenuBar mb) {
452 platformWindow.setMenuBar(mb);
453 }
454
455 @Override // FramePeer and DialogPeer
570 checkIfOnNewScreen();
571 if (resized) {
572 replaceSurfaceData();
573 flushOnscreenGraphics();
574 }
575
576 // Third, COMPONENT_MOVED/COMPONENT_RESIZED events
577 if (moved) {
578 handleMove(x, y, true);
579 }
580 if (resized) {
581 handleResize(w, h,true);
582 }
583 }
584
585 private void clearBackground(final int w, final int h) {
586 final Graphics g = getOnscreenGraphics(getForeground(), getBackground(),
587 getFont());
588 if (g != null) {
589 try {
590 g.clearRect(0, 0, w, h);
591 } finally {
592 g.dispose();
593 }
594 }
595 }
596
597 public void notifyUpdateCursor() {
598 getLWToolkit().getCursorManager().updateCursorLater(this);
599 }
600
601 public void notifyActivation(boolean activation) {
602 changeFocusedWindow(activation);
603 }
604
605 // MouseDown in non-client area
606 public void notifyNCMouseDown() {
607 // Ungrab except for a click on a Dialog with the grabbing owner
608 if (grabbingWindow != null &&
609 grabbingWindow != getOwnerFrameDialog(this))
610 {
877 GraphicsDevice newGraphicsDevice = platformWindow.getGraphicsDevice();
878 synchronized (getStateLock()) {
879 if (graphicsDevice == newGraphicsDevice) {
880 return;
881 }
882 graphicsDevice = newGraphicsDevice;
883 }
884
885 // TODO: DisplayChangedListener stuff
886 final GraphicsConfiguration newGC = newGraphicsDevice.getDefaultConfiguration();
887
888 if (!setGraphicsConfig(newGC)) return;
889
890 SunToolkit.executeOnEventHandlerThread(getTarget(), new Runnable() {
891 public void run() {
892 AWTAccessor.getComponentAccessor().setGraphicsConfiguration(getTarget(), newGC);
893 }
894 });
895 }
896
897 /**
898 * This method returns a back buffer Graphics to render all the
899 * peers to. After the peer is painted, the back buffer contents
900 * should be flushed to the screen. All the target painting
901 * (Component.paint() method) should be done directly to the screen.
902 */
903 protected final Graphics getOffscreenGraphics(Color fg, Color bg, Font f) {
904 final Image bb = getBackBuffer();
905 if (bb == null) {
906 return null;
907 }
908 if (fg == null) {
909 fg = SystemColor.windowText;
910 }
911 if (bg == null) {
912 bg = SystemColor.window;
913 }
914 if (f == null) {
915 f = DEFAULT_FONT;
916 }
917 final Graphics2D g = (Graphics2D) bb.getGraphics();
918 if (g != null) {
919 g.setColor(fg);
920 g.setBackground(bg);
921 g.setFont(f);
922 }
923 return g;
924 }
925
926 /*
927 * May be called by delegate to provide SD to Java2D code.
928 */
929 public SurfaceData getSurfaceData() {
930 synchronized (surfaceDataLock) {
931 return surfaceData;
932 }
933 }
934
935 private void replaceSurfaceData() {
936 replaceSurfaceData(backBufferCount, backBufferCaps);
937 }
938
939 private void replaceSurfaceData(int newBackBufferCount,
940 BufferCapabilities newBackBufferCaps) {
941 synchronized (surfaceDataLock) {
942 final SurfaceData oldData = getSurfaceData();
943 surfaceData = platformWindow.replaceSurfaceData();
944 // TODO: volatile image
945 // VolatileImage oldBB = backBuffer;
946 BufferedImage oldBB = backBuffer;
947 backBufferCount = newBackBufferCount;
948 backBufferCaps = newBackBufferCaps;
949 final Rectangle size = getSize();
950 if (getSurfaceData() != null && oldData != getSurfaceData()) {
951 clearBackground(size.width, size.height);
952 }
953 blitSurfaceData(oldData, getSurfaceData());
954
955 if (oldData != null && oldData != getSurfaceData()) {
956 // TODO: drop oldData for D3D/WGL pipelines
957 // This can only happen when this peer is being created
958 oldData.flush();
959 }
960
961 // TODO: volatile image
962 // backBuffer = (VolatileImage)delegate.createBackBuffer();
963 backBuffer = (BufferedImage) platformWindow.createBackBuffer();
964 if (backBuffer != null) {
965 Graphics g = backBuffer.getGraphics();
966 try {
967 Rectangle r = getBounds();
968 g.setColor(getBackground());
969 if (g instanceof Graphics2D) {
970 ((Graphics2D) g).setComposite(AlphaComposite.Src);
971 }
972 g.fillRect(0, 0, r.width, r.height);
973 if (oldBB != null) {
974 // Draw the old back buffer to the new one
975 g.drawImage(oldBB, 0, 0, null);
976 oldBB.flush();
977 }
978 } finally {
979 g.dispose();
980 }
981 }
982 }
983 }
984
985 private void blitSurfaceData(final SurfaceData src, final SurfaceData dst) {
986 //TODO blit. proof-of-concept
987 if (src != dst && src != null && dst != null
988 && !(dst instanceof NullSurfaceData)
989 && !(src instanceof NullSurfaceData)
990 && src.getSurfaceType().equals(dst.getSurfaceType())) {
991 final Rectangle size = getSize();
992 final Blit blit = Blit.locate(src.getSurfaceType(),
993 CompositeType.Src,
994 dst.getSurfaceType());
995 if (blit != null) {
996 blit.Blit(src, dst, ((Graphics2D) getGraphics()).getComposite(),
997 getRegion(), 0, 0, 0, 0, size.width, size.height);
998 }
999 }
1000 }
1001
1002 public int getBackBufferCount() {
1003 return backBufferCount;
1004 }
1005
1006 public BufferCapabilities getBackBufferCaps() {
1007 return backBufferCaps;
1008 }
1009
1010 /*
1011 * Request the window insets from the delegate and compares it
1012 * with the current one. This method is mostly called by the
1013 * delegate, e.g. when the window state is changed and insets
1014 * should be recalculated.
1015 *
1016 * This method may be called on the toolkit thread.
|
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
23 * questions.
24 */
25
26 package sun.lwawt;
27
28 import java.awt.*;
29 import java.awt.event.*;
30 import java.awt.image.BufferedImage;
31 import java.awt.peer.*;
32 import java.util.List;
33
34 import javax.swing.*;
35
36 import sun.awt.*;
37 import sun.java2d.*;
38 import sun.java2d.loops.Blit;
39 import sun.java2d.loops.CompositeType;
40 import sun.java2d.pipe.Region;
41 import sun.util.logging.PlatformLogger;
42
43 public class LWWindowPeer
44 extends LWContainerPeer<Window, JComponent>
45 implements WindowPeer, FramePeer, DialogPeer, FullScreenCapable
46 {
47 public static enum PeerType {
48 SIMPLEWINDOW,
49 FRAME,
50 DIALOG,
51 EMBEDDEDFRAME
52 }
53
54 private static final PlatformLogger focusLog = PlatformLogger.getLogger("sun.lwawt.focus.LWWindowPeer");
55
56 private PlatformWindow platformWindow;
57
58 // Window bounds reported by the native system (as opposed to
59 // regular bounds inherited from LWComponentPeer which are
60 // requested by user and may haven't been applied yet because
93 // find the component under cursor
94 private static volatile LWComponentPeer lastMouseEventPeer = null;
95
96 // Peers where all dragged/released events should come to,
97 // depending on what mouse button is being dragged according to Cocoa
98 private static LWComponentPeer mouseDownTarget[] = new LWComponentPeer[3];
99
100 // A bitmask that indicates what mouse buttons produce MOUSE_CLICKED events
101 // on MOUSE_RELEASE. Click events are only generated if there were no drag
102 // events between MOUSE_PRESSED and MOUSE_RELEASED for particular button
103 private static int mouseClickButtons = 0;
104
105 private volatile boolean isOpaque = true;
106
107 private static final Font DEFAULT_FONT = new Font("Lucida Grande", Font.PLAIN, 13);
108
109 private static LWWindowPeer grabbingWindow;
110
111 private volatile boolean skipNextFocusChange;
112
113 private static final Color nonOpaqueBackground = new Color(0, 0, 0, 0);
114
115 /**
116 * Current modal blocker or null.
117 *
118 * Synchronization: peerTreeLock.
119 */
120 private LWWindowPeer blocker;
121
122 public LWWindowPeer(Window target, PlatformComponent platformComponent,
123 PlatformWindow platformWindow)
124 {
125 super(target, platformComponent);
126 this.platformWindow = platformWindow;
127
128 Window owner = target.getOwner();
129 LWWindowPeer ownerPeer = (owner != null) ? (LWWindowPeer)owner.getPeer() : null;
130 PlatformWindow ownerDelegate = (ownerPeer != null) ? ownerPeer.getPlatformWindow() : null;
131
132 // The delegate.initialize() needs a non-null GC on X11.
133 GraphicsConfiguration gc = getTarget().getGraphicsConfiguration();
134 synchronized (getStateLock()) {
155 // we should not call setForeground because it will call a repaint
156 // which the peer may not be ready to do yet.
157 }
158
159 platformWindow.initialize(target, this, ownerDelegate);
160 }
161
162 @Override
163 void initializeImpl() {
164 super.initializeImpl();
165 if (getTarget() instanceof Frame) {
166 setTitle(((Frame) getTarget()).getTitle());
167 setState(((Frame) getTarget()).getExtendedState());
168 } else if (getTarget() instanceof Dialog) {
169 setTitle(((Dialog) getTarget()).getTitle());
170 }
171
172 setAlwaysOnTop(getTarget().isAlwaysOnTop());
173 updateMinimumSize();
174
175 final Shape shape = getTarget().getShape();
176 if (shape != null) {
177 applyShape(Region.getInstance(shape, null));
178 }
179
180 final float opacity = getTarget().getOpacity();
181 if (opacity < 1.0f) {
182 setOpacity(opacity);
183 }
184
185 setOpaque(getTarget().isOpaque());
186
187 updateInsets(platformWindow.getInsets());
188 if (getSurfaceData() == null) {
189 replaceSurfaceData(false);
190 }
191 }
192
193 // Just a helper method
194 public PlatformWindow getPlatformWindow() {
195 return platformWindow;
196 }
197
198 @Override
199 protected LWWindowPeer getWindowPeerOrSelf() {
200 return this;
201 }
202
203 @Override
204 protected void initializeContainerPeer() {
205 // No-op as LWWindowPeer doesn't have any containerPeer
206 }
207
208 // ---- PEER METHODS ---- //
209
271 if (bg == null) {
272 bg = SystemColor.window;
273 }
274 if (f == null) {
275 f = DEFAULT_FONT;
276 }
277 return platformWindow.transformGraphics(new SunGraphics2D(getSurfaceData(), fg, bg, f));
278 }
279
280 @Override
281 public void createBuffers(int numBuffers, BufferCapabilities caps)
282 throws AWTException
283 {
284 try {
285 // Assume this method is never called with numBuffers <= 1, as 0 is
286 // unsupported, and 1 corresponds to a SingleBufferStrategy which
287 // doesn't depend on the peer. Screen is considered as a separate
288 // "buffer", that's why numBuffers - 1
289 assert numBuffers > 1;
290
291 replaceSurfaceData(numBuffers - 1, caps, false);
292 } catch (InvalidPipeException z) {
293 throw new AWTException(z.toString());
294 }
295 }
296
297 @Override
298 public final Image getBackBuffer() {
299 synchronized (getStateLock()) {
300 return backBuffer;
301 }
302 }
303
304 @Override
305 public void flip(int x1, int y1, int x2, int y2,
306 BufferCapabilities.FlipContents flipAction)
307 {
308 platformWindow.flip(x1, y1, x2, y2, flipAction);
309 }
310
311 @Override
411 d = new Dimension(MINIMUM_WIDTH, MINIMUM_HEIGHT);
412 }
413 platformWindow.setMinimumSize(d.width, d.height);
414 }
415
416 @Override
417 public void updateIconImages() {
418 getPlatformWindow().updateIconImages();
419 }
420
421 @Override
422 public void setOpacity(float opacity) {
423 getPlatformWindow().setOpacity(opacity);
424 repaintPeer();
425 }
426
427 @Override
428 public final void setOpaque(final boolean isOpaque) {
429 if (this.isOpaque != isOpaque) {
430 this.isOpaque = isOpaque;
431 updateOpaque();
432 }
433 }
434
435 private void updateOpaque() {
436 getPlatformWindow().setOpaque(!isTranslucent());
437 replaceSurfaceData(false);
438 repaintPeer();
439 }
440
441 @Override
442 public void updateWindow() {
443 }
444
445 public final boolean isTranslucent() {
446 synchronized (getStateLock()) {
447 return !isOpaque || isShaped();
448 }
449 }
450
451 @Override
452 final void applyShapeImpl(final Region shape) {
453 super.applyShapeImpl(shape);
454 updateOpaque();
455 }
456
457 @Override
458 public void repositionSecurityWarning() {
459 throw new RuntimeException("not implemented");
460 }
461
462 // ---- FRAME PEER METHODS ---- //
463
464 @Override // FramePeer and DialogPeer
465 public void setTitle(String title) {
466 platformWindow.setTitle(title == null ? "" : title);
467 }
468
469 @Override
470 public void setMenuBar(MenuBar mb) {
471 platformWindow.setMenuBar(mb);
472 }
473
474 @Override // FramePeer and DialogPeer
589 checkIfOnNewScreen();
590 if (resized) {
591 replaceSurfaceData();
592 flushOnscreenGraphics();
593 }
594
595 // Third, COMPONENT_MOVED/COMPONENT_RESIZED events
596 if (moved) {
597 handleMove(x, y, true);
598 }
599 if (resized) {
600 handleResize(w, h,true);
601 }
602 }
603
604 private void clearBackground(final int w, final int h) {
605 final Graphics g = getOnscreenGraphics(getForeground(), getBackground(),
606 getFont());
607 if (g != null) {
608 try {
609 if (g instanceof Graphics2D) {
610 ((Graphics2D) g).setComposite(AlphaComposite.Src);
611 }
612 if (isTranslucent()) {
613 g.setColor(nonOpaqueBackground);
614 g.fillRect(0, 0, w, h);
615 }
616 if (g instanceof SunGraphics2D) {
617 SG2DConstraint((SunGraphics2D) g, getRegion());
618 }
619 g.setColor(getBackground());
620 g.fillRect(0, 0, w, h);
621 } finally {
622 g.dispose();
623 }
624 }
625 }
626
627 public void notifyUpdateCursor() {
628 getLWToolkit().getCursorManager().updateCursorLater(this);
629 }
630
631 public void notifyActivation(boolean activation) {
632 changeFocusedWindow(activation);
633 }
634
635 // MouseDown in non-client area
636 public void notifyNCMouseDown() {
637 // Ungrab except for a click on a Dialog with the grabbing owner
638 if (grabbingWindow != null &&
639 grabbingWindow != getOwnerFrameDialog(this))
640 {
907 GraphicsDevice newGraphicsDevice = platformWindow.getGraphicsDevice();
908 synchronized (getStateLock()) {
909 if (graphicsDevice == newGraphicsDevice) {
910 return;
911 }
912 graphicsDevice = newGraphicsDevice;
913 }
914
915 // TODO: DisplayChangedListener stuff
916 final GraphicsConfiguration newGC = newGraphicsDevice.getDefaultConfiguration();
917
918 if (!setGraphicsConfig(newGC)) return;
919
920 SunToolkit.executeOnEventHandlerThread(getTarget(), new Runnable() {
921 public void run() {
922 AWTAccessor.getComponentAccessor().setGraphicsConfiguration(getTarget(), newGC);
923 }
924 });
925 }
926
927 /*
928 * May be called by delegate to provide SD to Java2D code.
929 */
930 public SurfaceData getSurfaceData() {
931 synchronized (surfaceDataLock) {
932 return surfaceData;
933 }
934 }
935
936 private void replaceSurfaceData() {
937 replaceSurfaceData(true);
938 }
939
940 private void replaceSurfaceData(boolean blit) {
941 replaceSurfaceData(backBufferCount, backBufferCaps, blit);
942 }
943
944 private void replaceSurfaceData(int newBackBufferCount,
945 BufferCapabilities newBackBufferCaps,
946 boolean blit) {
947 synchronized (surfaceDataLock) {
948 final SurfaceData oldData = getSurfaceData();
949 surfaceData = platformWindow.replaceSurfaceData();
950 // TODO: volatile image
951 // VolatileImage oldBB = backBuffer;
952 BufferedImage oldBB = backBuffer;
953 backBufferCount = newBackBufferCount;
954 backBufferCaps = newBackBufferCaps;
955 final Rectangle size = getSize();
956 if (getSurfaceData() != null && oldData != getSurfaceData()) {
957 clearBackground(size.width, size.height);
958 }
959
960 if (blit) {
961 blitSurfaceData(oldData, getSurfaceData());
962 }
963
964 if (oldData != null && oldData != getSurfaceData()) {
965 // TODO: drop oldData for D3D/WGL pipelines
966 // This can only happen when this peer is being created
967 oldData.flush();
968 }
969
970 // TODO: volatile image
971 // backBuffer = (VolatileImage)delegate.createBackBuffer();
972 backBuffer = (BufferedImage) platformWindow.createBackBuffer();
973 if (backBuffer != null) {
974 Graphics g = backBuffer.getGraphics();
975 try {
976 Rectangle r = getBounds();
977 if (g instanceof Graphics2D) {
978 ((Graphics2D) g).setComposite(AlphaComposite.Src);
979 }
980 g.setColor(nonOpaqueBackground);
981 g.fillRect(0, 0, r.width, r.height);
982 if (g instanceof SunGraphics2D) {
983 SG2DConstraint((SunGraphics2D) g, getRegion());
984 }
985 g.setColor(getBackground());
986 g.fillRect(0, 0, r.width, r.height);
987 if (oldBB != null) {
988 // Draw the old back buffer to the new one
989 g.drawImage(oldBB, 0, 0, null);
990 oldBB.flush();
991 }
992 } finally {
993 g.dispose();
994 }
995 }
996 }
997 }
998
999 private void blitSurfaceData(final SurfaceData src, final SurfaceData dst) {
1000 //TODO blit. proof-of-concept
1001 if (src != dst && src != null && dst != null
1002 && !(dst instanceof NullSurfaceData)
1003 && !(src instanceof NullSurfaceData)
1004 && src.getSurfaceType().equals(dst.getSurfaceType())) {
1005 final Rectangle size = getSize();
1006 final Blit blit = Blit.locate(src.getSurfaceType(),
1007 CompositeType.Src,
1008 dst.getSurfaceType());
1009 if (blit != null) {
1010 blit.Blit(src, dst, AlphaComposite.Src,
1011 getRegion(), 0, 0, 0, 0, size.width, size.height);
1012 }
1013 }
1014 }
1015
1016 public int getBackBufferCount() {
1017 return backBufferCount;
1018 }
1019
1020 public BufferCapabilities getBackBufferCaps() {
1021 return backBufferCaps;
1022 }
1023
1024 /*
1025 * Request the window insets from the delegate and compares it
1026 * with the current one. This method is mostly called by the
1027 * delegate, e.g. when the window state is changed and insets
1028 * should be recalculated.
1029 *
1030 * This method may be called on the toolkit thread.
|