Skip to content

Commit bd0b53f

Browse files
committed
retina may be working
1 parent 7be7251 commit bd0b53f

5 files changed

Lines changed: 23 additions & 26 deletions

File tree

core/src/processing/core/PApplet.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13997,12 +13997,18 @@ public PImage get(int x, int y, int w, int h) {
1399713997

1399813998
/**
1399913999
* Returns a copy of this PImage. Equivalent to get(0, 0, width, height).
14000+
* Deprecated, just use copy() instead.
1400014001
*/
1400114002
public PImage get() {
1400214003
return g.get();
1400314004
}
1400414005

1400514006

14007+
public PImage copy() {
14008+
return g.copy();
14009+
}
14010+
14011+
1400614012
/**
1400714013
* ( begin auto-generated from PImage_set.xml )
1400814014
*

core/src/processing/core/PGraphicsJava2D.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,8 @@ public void endDraw() {
381381
// Marks pixels as modified so that the pixels will be updated.
382382
// Also sets mx1/y1/x2/y2 so that OpenGL will pick it up.
383383
setModified();
384+
385+
g2.dispose();
384386
}
385387

386388

core/src/processing/core/PGraphicsRetina2D.java

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ public class PGraphicsRetina2D extends PGraphicsJava2D {
1414
// INTERNAL
1515

1616

17-
// public PGraphicsRetina2D() {
17+
public PGraphicsRetina2D() {
18+
pixelFactor = 2;
1819
// retina = new PImage();
1920
// retina.format = RGB;
20-
// }
21+
}
2122

2223

2324
// @Override
@@ -96,13 +97,13 @@ public class PGraphicsRetina2D extends PGraphicsJava2D {
9697

9798
@Override
9899
public void beginDraw() {
99-
GraphicsConfiguration gc = parent.getGraphicsConfiguration();
100-
101-
if (image == null) {
102-
retina.width = width * 2;
103-
retina.height = height * 2;
104-
image = gc.createCompatibleImage(retina.width, retina.height);
105-
}
100+
// GraphicsConfiguration gc = parent.getGraphicsConfiguration();
101+
//
102+
// if (image == null) {
103+
// retina.width = width * 2;
104+
// retina.height = height * 2;
105+
// image = gc.createCompatibleImage(retina.width, retina.height);
106+
// }
106107
g2 = (Graphics2D) image.getGraphics();
107108

108109
checkSettings();
@@ -196,8 +197,7 @@ public void endDraw() {
196197
//////////////////////////////////////////////////////////////
197198

198199

199-
// int[] retinaPixels;
200-
200+
/*
201201
@Override
202202
public void loadPixels() {
203203
if ((retina.pixels == null) || (retina.pixels.length != retina.width * retina.height)) {
@@ -265,12 +265,6 @@ public void updatePixels() {
265265
}
266266
267267
268-
/**
269-
* Update the pixels[] buffer to the PGraphics image.
270-
* <P>
271-
* Unlike in PImage, where updatePixels() only requests that the
272-
* update happens, in PGraphicsJava2D, this will happen immediately.
273-
*/
274268
@Override
275269
public void updatePixels(int ux, int uy, int uw, int uh) {
276270
int wide = hints[ENABLE_RETINA_PIXELS] ? retina.width : width;
@@ -636,10 +630,5 @@ public boolean save(String filename) {
636630
return super.save(filename);
637631
}
638632
}
639-
640-
641-
@Override
642-
public boolean is2X() {
643-
return true;
644-
}
633+
*/
645634
}

core/src/processing/core/PImage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ public class PImage implements PConstants, Cloneable {
210210
*/
211211
public PImage() {
212212
format = ARGB; // default to ARGB images for release 0116
213-
// cache = null;
213+
pixelFactor = 1;
214214
}
215215

216216

core/src/processing/core/PSurfaceAWT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -785,8 +785,8 @@ public void setSize(int wide, int high) {
785785

786786
// Formerly this was broken into separate versions based on offscreen or
787787
// not, but we may as well create a compatible image; it won't hurt, right?
788-
graphics.image = gc.createCompatibleImage(wide, high);
789-
// System.out.println(graphics.image);
788+
int factor = graphics.pixelFactor;
789+
graphics.image = gc.createCompatibleImage(wide * factor, high * factor);
790790

791791
//throw new RuntimeException("implement me, see readme.md");
792792
sketchWidth = sketch.width = wide;

0 commit comments

Comments
 (0)