Skip to content

Commit 44c9cfb

Browse files
hansonrhansonr
authored andcommitted
RepaintManager fix for background check in JApplet for direct pixel
writing.
1 parent 6627dd2 commit 44c9cfb

File tree

9 files changed

+18
-6
lines changed

9 files changed

+18
-6
lines changed
2.89 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20180916165130
1+
20180916182707
2.89 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20180916165130
1+
20180916182707
2.89 KB
Binary file not shown.

sources/net.sf.j2s.java.core/src/java/awt/JSComponent.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,4 +318,17 @@ public void validateComponent() {
318318

319319
}
320320

321+
/**
322+
* Paint this component, checking to see if the background got painted, and if so, make the
323+
* div background transparent so that that underlying HTML5 canvas shows through.
324+
*
325+
* @param g
326+
*/
327+
public void paintWithBackgroundCheck(Graphics g) {
328+
checkBackgroundPainted(null);
329+
paint(g);
330+
checkBackgroundPainted(getJSGraphic2D(g));
331+
}
332+
333+
321334
}

sources/net.sf.j2s.java.core/src/javax/swing/JComponent.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4573,9 +4573,7 @@ void _paintImmediately(int x, int y, int w, int h) {
45734573
// jpanel.repaint() and then draws on the background,
45744574
// the JPanel's background is made transparent
45754575
// (so that the underlying JRootPane canvas can show).
4576-
checkBackgroundPainted(null);
4577-
paintingComponent.paint(g);
4578-
checkBackgroundPainted(getJSGraphic2D(g));
4576+
paintingComponent.paintWithBackgroundCheck(g);
45794577
}
45804578
} finally {
45814579
g.dispose();

sources/net.sf.j2s.java.core/src/javax/swing/RepaintManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ private void paintDirtyRegions1(
870870
if (g != null) {
871871
// SwingJS not clipping, for performance g.setClip(rect.x, rect.y, rect.width, rect.height);
872872
try {
873-
((Container) dirtyComponent).paint(g); // SwingJS was paintContainer, but that bypasses user's paint(g)?? 9/15/18
873+
((Container) dirtyComponent).paintWithBackgroundCheck(g); // SwingJS was paintContainer, but that bypasses user's paint(g) and does not do the background check?? 9/15/18
874874
} finally {
875875
g.dispose();
876876
}

sources/net.sf.j2s.java.core/src/swingjs/JSGraphics2D.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ public boolean drawImagePriv(Image img, int x, int y, ImageObserver observer) {
498498

499499
public void drawDirectRGBA(int[] pixels) {
500500
// this can go VERY fast - for writing directly to the canvas context
501+
backgroundPainted = true;
501502
drawDirect(pixels, 0, 0, width, height, false);
502503
}
503504

0 commit comments

Comments
 (0)