Skip to content

Commit d81f0b2

Browse files
committed
add sized flag to recreate bitmap and canvas, fixes #324
1 parent ba14e97 commit d81f0b2

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

core/src/processing/a2d/PGraphicsAndroid2D.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ public class PGraphicsAndroid2D extends PGraphics {
104104
Paint tintPaint;
105105

106106

107+
/**
108+
* Marks when changes to the size have occurred, so that the backing bitmap
109+
* can be recreated.
110+
*/
111+
protected boolean sized;
112+
107113
//////////////////////////////////////////////////////////////
108114

109115
// INTERNAL
@@ -135,6 +141,12 @@ public PGraphicsAndroid2D() {
135141
//public void setPath(String path)
136142

137143

144+
@Override
145+
public void setSize(int iwidth, int iheight) {
146+
super.setSize(iwidth, iheight);
147+
sized = true;
148+
}
149+
138150

139151
@Override
140152
public void dispose() {
@@ -165,15 +177,16 @@ public void requestDraw() {
165177

166178
// @Override
167179
// public void requestDraw() {
168-
// parent.handleDraw();
180+
//parent.handleDraw();
169181
// }
170182

171183

172184
protected Canvas checkCanvas() {
173-
if (canvas == null && (useBitmap || !primaryGraphics)) {
185+
if ((canvas == null || sized) && (useBitmap || !primaryGraphics)) {
174186
if (bitmap != null) bitmap.recycle();
175187
bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
176188
canvas = new Canvas(bitmap);
189+
sized = false;
177190
}
178191
return canvas;
179192
}

0 commit comments

Comments
 (0)