Skip to content

Commit 264d25d

Browse files
committed
removed unnecessary checks for pause/resume
1 parent 4f658d1 commit 264d25d

File tree

4 files changed

+19
-22
lines changed

4 files changed

+19
-22
lines changed

core/src/processing/a2d/PGraphicsAndroid2D.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public void surfaceChanged() {
171171
@Override
172172
public void setSize(int iwidth, int iheight) {
173173
// OR with prev value in case setSize() gets called twice before the renderer has the chance to resize
174-
sized |= iwidth != width || iheight != height;
174+
sized = iwidth != width || iheight != height;
175175
System.out.println("======================> RESIZING AT FRAME " + parent.frameCount + " FROM " + width + "x" + height + " to " + iwidth + "x" + iheight);
176176
super.setSize(iwidth, iheight);
177177
}
@@ -2067,14 +2067,13 @@ public void resize(int wide, int high) {
20672067

20682068
@Override
20692069
protected void saveState() {
2070-
restoreWidth = pixelWidth;
2071-
restoreHeight = pixelHeight;
2072-
if (restoreWidth == 0 || restoreHeight == 0) return; // maybe still initializing...
2073-
20742070
Context context = parent.getContext();
2075-
if (context == null || bitmap == null) return;
2071+
if (context == null || bitmap == null || parent.getSurface().getComponent().isService()) return;
20762072
try {
20772073
// Saving current width and height to avoid restoring the screen after a screen rotation
2074+
restoreWidth = pixelWidth;
2075+
restoreHeight = pixelHeight;
2076+
20782077
System.out.println("============================> SAVING SCREEN FROM " + restoreWidth + " " + pixelHeight);
20792078

20802079
int size = bitmap.getHeight() * bitmap.getRowBytes();

core/src/processing/android/PWallpaper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ public void onSurfaceChanged(final SurfaceHolder holder, final int format,
173173
@Override
174174
public void onVisibilityChanged(boolean visible) {
175175
if (sketch != null) {
176+
System.out.println("============> CHANGING WALLPAPER VISIBILITY TO " + visible);
176177
if (visible) {
177178
sketch.onResume();
178179
} else {

core/src/processing/android/PWatchFaceCanvas.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ public class PWatchFaceCanvas extends CanvasWatchFaceService implements AppCompo
4747
private DisplayMetrics metrics;
4848
private CanvasEngine engine;
4949

50-
5150
public void initDimensions() {
5251
metrics = new DisplayMetrics();
5352
size = new Point();

core/src/processing/opengl/PGraphicsOpenGL.java

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ public void reset() {
671671
@Override
672672
public void setSize(int iwidth, int iheight) {
673673
// OR with prev value in case setSize() gets called twice before the renderer has the chance to resize
674-
sized |= iwidth != width || iheight != height;
674+
sized = iwidth != width || iheight != height;
675675
System.out.println("======================> RESIZING AT FRAME " + parent.frameCount + " FROM " + width + "x" + height + " to " + iwidth + "x" + iheight);
676676
super.setSize(iwidth, iheight);
677677

@@ -5703,28 +5703,26 @@ protected void drawPixels(int[] pixBuffer, int x, int y, int w, int h) {
57035703

57045704
@Override
57055705
protected void saveState() {
5706-
// Saving current width and height to avoid restoring the screen after a screen rotation
5707-
restoreWidth = pixelWidth;
5708-
restoreHeight = pixelHeight;
5709-
if (restoreWidth == 0 || restoreHeight == 0) return; // maybe still initializing...
5710-
57115706
// Queue the pixel read operation so it is performed when the surface is ready
57125707
pgl.queueEvent(new Runnable() {
57135708
@Override
57145709
public void run() {
57155710
Context context = parent.getContext();
5716-
if (context == null) return;
5711+
if (context == null || parent.getSurface().getComponent().isService()) return;
57175712
try {
5718-
if (restoreWidth != pixelWidth && restoreHeight != pixelHeight) {
5719-
// The screen size changed between calling saveState() and the pixel read operation,
5720-
// so it does no longer makes sense to try saving the screen's contents.
5721-
restoreWidth = -1;
5722-
restoreHeight = -1;
5723-
return;
5724-
}
5725-
5713+
// if (restoreWidth != pixelWidth && restoreHeight != pixelHeight) {
5714+
// // The screen size changed between calling saveState() and the pixel read operation,
5715+
// // so it does no longer makes sense to try saving the screen's contents.
5716+
// restoreWidth = -1;
5717+
// restoreHeight = -1;
5718+
// return;
5719+
// }
5720+
5721+
restoreWidth = pixelWidth;
5722+
restoreHeight = pixelHeight;
57265723
System.out.println("============================> SAVING SCREEN FROM " + restoreWidth + " " + pixelHeight);
57275724

5725+
57285726
int[] restorePixels = new int[restoreWidth * restoreHeight];
57295727
IntBuffer buf = IntBuffer.wrap(restorePixels);
57305728
buf.position(0);

0 commit comments

Comments
 (0)