Skip to content

Commit 8e9eaf7

Browse files
committed
lots of work for retina/hi-dpi/2x images
1 parent b1d1974 commit 8e9eaf7

8 files changed

Lines changed: 360 additions & 349 deletions

File tree

core/src/processing/core/PGraphics.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7928,4 +7928,9 @@ public boolean is3D() { // ignore
79287928
public boolean isGL() { // ignore
79297929
return false;
79307930
}
7931+
7932+
7933+
public boolean is2X() {
7934+
return pixelFactor == 2;
7935+
}
79317936
}

core/src/processing/core/PGraphicsRetina2D.java

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
public class PGraphicsRetina2D extends PGraphicsJava2D {
7-
PImage retina;
7+
// PImage retina;
88
// int retinaWidth;
99
// int retinaHeight;
1010

@@ -14,21 +14,21 @@ public class PGraphicsRetina2D extends PGraphicsJava2D {
1414
// INTERNAL
1515

1616

17-
public PGraphicsRetina2D() {
18-
retina = new PImage();
19-
retina.format = RGB;
20-
}
17+
// public PGraphicsRetina2D() {
18+
// retina = new PImage();
19+
// retina.format = RGB;
20+
// }
2121

2222

23-
@Override
24-
public void setParent(PApplet parent) {
25-
super.setParent(parent);
26-
retina.parent = parent;
27-
}
23+
// @Override
24+
// public void setParent(PApplet parent) {
25+
// super.setParent(parent);
26+
// retina.parent = parent;
27+
// }
2828

2929

30-
@Override
31-
protected void allocate() {
30+
// @Override
31+
// protected void allocate() {
3232
// parent.setIgnoreRepaint(true);
3333
// g2 = (Graphics2D) parent.getGraphics();
3434

@@ -80,46 +80,30 @@ protected void allocate() {
8080
g2 = (Graphics2D) image.getGraphics();
8181
}
8282
*/
83-
}
83+
// }
8484

8585

8686
//////////////////////////////////////////////////////////////
8787

8888
// FRAME
8989

9090

91-
@Override
92-
public boolean canDraw() {
93-
return parent.getGraphicsConfiguration() != null;
94-
}
91+
// @Override
92+
// public boolean canDraw() {
93+
// return parent.getGraphicsConfiguration() != null;
94+
// }
9595

9696

9797
@Override
9898
public void beginDraw() {
99-
// g2 = (Graphics2D) parent.getGraphics();
100-
10199
GraphicsConfiguration gc = parent.getGraphicsConfiguration();
102100

103-
// if (false) {
104-
// if (image == null || ((VolatileImage) image).validate(gc) == VolatileImage.IMAGE_INCOMPATIBLE) {
105-
// image = gc.createCompatibleVolatileImage(width*2, height*2);
106-
// }
107-
// } else {
108101
if (image == null) {
109102
retina.width = width * 2;
110103
retina.height = height * 2;
111104
image = gc.createCompatibleImage(retina.width, retina.height);
112-
// System.out.println("image type is " + image);
113105
}
114-
// }
115106
g2 = (Graphics2D) image.getGraphics();
116-
// g2.scale(2, 2);
117-
118-
// if (bimage == null ||
119-
// bimage.getWidth() != width ||
120-
// bimage.getHeight() != height) {
121-
// PApplet.debug("PGraphicsJava2D creating new image");
122-
// bimage = gc.createCompatibleImage(width, height);
123107

124108
checkSettings();
125109
resetMatrix(); // reset model matrix
@@ -652,4 +636,10 @@ public boolean save(String filename) {
652636
return super.save(filename);
653637
}
654638
}
639+
640+
641+
@Override
642+
public boolean is2X() {
643+
return true;
644+
}
655645
}

0 commit comments

Comments
 (0)