changeset 7913:f1184656721a

RT-37810: [SwingNode]: Swing Nodes have serious rendering artifacts when first displayed on the primary Stage Summary: A partial fix. It eliminates a serious rendering artifact that could cause the whole FX Scene to paint black if there's a SwingNode present. Reviewed-by: ant
author Anthony Petrov <anthony.petrov@oracle.com>
date Fri, 29 Aug 2014 16:09:44 +0400
parents c594508c4f54
children d1505b59555d
files modules/graphics/src/main/java/com/sun/javafx/sg/prism/NGExternalNode.java modules/swing/src/main/java/javafx/embed/swing/SwingNode.java
diffstat 2 files changed, 24 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/java/com/sun/javafx/sg/prism/NGExternalNode.java	Fri Aug 29 10:24:14 2014 +0200
+++ b/modules/graphics/src/main/java/com/sun/javafx/sg/prism/NGExternalNode.java	Fri Aug 29 16:09:44 2014 +0400
@@ -94,7 +94,7 @@
                     bufferLock.unlock();
                 }
                 if (rd.clearTarget) {
-                    g.clear();
+                    g.clearQuad(0, 0, rd.bdata.usrwidth, rd.bdata.usrheight);
                 }
             }
             
--- a/modules/swing/src/main/java/javafx/embed/swing/SwingNode.java	Fri Aug 29 10:24:14 2014 +0200
+++ b/modules/swing/src/main/java/javafx/embed/swing/SwingNode.java	Fri Aug 29 16:09:44 2014 +0400
@@ -141,7 +141,7 @@
     private volatile JLightweightFrame lwFrame;
     final JLightweightFrame getLightweightFrame() { return lwFrame; }
 
-    private volatile NGExternalNode peer;
+    private NGExternalNode peer;
 
     private final ReentrantLock paintLock = new ReentrantLock();
 
@@ -298,12 +298,14 @@
         Runnable r = () -> {
             peer.setImageBuffer(IntBuffer.wrap(data), x, y, w, h, linestride, scale);
         };
-        if (peer != null) {
-            SwingFXUtils.runOnFxThread(r);
-        } else {
-            peerRequests.clear();
-            peerRequests.add(r);
-        }
+        SwingFXUtils.runOnFxThread(() -> {
+            if (peer != null) {
+                r.run();
+            } else {
+                peerRequests.clear();
+                peerRequests.add(r);
+            }
+        });
     }
 
     /*
@@ -313,11 +315,13 @@
         Runnable r = () -> {
             peer.setImageBounds(x, y, w, h);
         };
-        if (peer != null) {
-            SwingFXUtils.runOnFxThread(r);
-        } else {
-            peerRequests.add(r);
-        }
+        SwingFXUtils.runOnFxThread(() -> {
+            if (peer != null) {
+                r.run();
+            } else {
+                peerRequests.add(r);
+            }
+        });
     }
 
     /*
@@ -328,11 +332,13 @@
             peer.repaintDirtyRegion(dirtyX, dirtyY, dirtyWidth, dirtyHeight);
             impl_markDirty(DirtyBits.NODE_CONTENTS);
         };
-        if (peer != null) {
-            SwingFXUtils.runOnFxThread(r);
-        } else {
-            peerRequests.add(r);
-        }
+        SwingFXUtils.runOnFxThread(() -> {
+            if (peer != null) {
+                r.run();
+            } else {
+                peerRequests.add(r);
+            }
+        });
     }
 
     @Override public boolean isResizable() {