Skip to content

Commit de39c83

Browse files
committed
make sure live wallpapers work properly
dispose native GL objects only when context is still current, dispose PGL's FBO layer when re-creating surface
1 parent e772fd5 commit de39c83

File tree

6 files changed

+14
-11
lines changed

6 files changed

+14
-11
lines changed

core/src/processing/a2d/PGraphicsAndroid2D.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public void dispose() {
167167

168168

169169
@Override
170-
public PSurface createSurface(AppComponent component, SurfaceHolder holder) { // ignore
170+
public PSurface createSurface(AppComponent component, SurfaceHolder holder, boolean reset) { // ignore
171171
return new PSurfaceAndroid2D(this, component, holder);
172172
}
173173

core/src/processing/core/PApplet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ public void initSurface(LayoutInflater inflater, ViewGroup container,
492492
if (DEBUG) println("Renderer " + rendererName);
493493
g = makeGraphics(width, height, rendererName, true);
494494
if (DEBUG) println("Created renderer");
495-
surface = g.createSurface(component, holder);
495+
surface = g.createSurface(component, holder, false);
496496
if (DEBUG) println("Created surface");
497497

498498
//set smooth level
@@ -536,7 +536,7 @@ public void resetSurface(LayoutInflater inflater, ViewGroup container,
536536
surface.stopThread(false);
537537
surface.dispose();
538538
}
539-
surface = g.createSurface(component, holder);
539+
surface = g.createSurface(component, holder, true);
540540

541541
if (parentLayout == -1) {
542542
setFullScreenVisibility();

core/src/processing/core/PGraphics.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ public void dispose() { // ignore
725725
}
726726

727727

728-
public PSurface createSurface(AppComponent component, SurfaceHolder holder) { // ignore
728+
public PSurface createSurface(AppComponent component, SurfaceHolder holder, boolean reset) { // ignore
729729
return null;
730730
}
731731

core/src/processing/opengl/PGraphicsOpenGL.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,8 @@ public PSurface createSurface() { // ignore
680680

681681
@Override
682682
// Android only
683-
public PSurface createSurface(AppComponent component, SurfaceHolder holder) { // ignore
683+
public PSurface createSurface(AppComponent component, SurfaceHolder holder, boolean reset) { // ignore
684+
if (reset) pgl.resetFBOLayer();
684685
return new PSurfaceGLES(this, component, holder);
685686
}
686687

@@ -876,7 +877,7 @@ public GLResourceTexture(Texture tex) {
876877
}
877878

878879
private void disposeNative() {
879-
if (pgl != null) {
880+
if (pgl != null && pgl.contextIsCurrent(context)) {
880881
if (glName != 0) {
881882
intBuffer.put(0, glName);
882883
pgl.deleteTextures(1, intBuffer);
@@ -950,7 +951,7 @@ public GLResourceVertexBuffer(VertexBuffer vbo) {
950951
}
951952

952953
private void disposeNative() {
953-
if (pgl != null) {
954+
if (pgl != null && pgl.contextIsCurrent(context)) {
954955
if (glId != 0) {
955956
intBuffer.put(0, glId);
956957
pgl.deleteBuffers(1, intBuffer);
@@ -1030,7 +1031,7 @@ public GLResourceShader(PShader sh) {
10301031
}
10311032

10321033
private void disposeNative() {
1033-
if (pgl != null) {
1034+
if (pgl != null && pgl.contextIsCurrent(context)) {
10341035
if (glFragment != 0) {
10351036
pgl.deleteShader(glFragment);
10361037
glFragment = 0;
@@ -1145,7 +1146,7 @@ public GLResourceFrameBuffer(FrameBuffer fb) {
11451146
}
11461147

11471148
private void disposeNative() {
1148-
if (pgl != null) {
1149+
if (pgl != null && pgl.contextIsCurrent(context)) {
11491150
if (glFbo != 0) {
11501151
intBuffer.put(0, glFbo);
11511152
pgl.deleteFramebuffers(1, intBuffer);

libraries/cardboard/src/processing/cardboard/PGraphicsCardboardMono.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828

2929
public class PGraphicsCardboardMono extends PGraphicsCardboard {
3030
@Override
31-
public PSurface createSurface(AppComponent component, SurfaceHolder holder) { // ignore
31+
public PSurface createSurface(AppComponent component, SurfaceHolder holder, boolean reset) { // ignore
32+
if (reset) pgl.resetFBOLayer();
3233
return new PSurfaceCardboard(this, component, holder, false);
3334
}
3435
}

libraries/cardboard/src/processing/cardboard/PGraphicsCardboardStereo.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828

2929
public class PGraphicsCardboardStereo extends PGraphicsCardboard {
3030
@Override
31-
public PSurface createSurface(AppComponent component, SurfaceHolder holder) { // ignore
31+
public PSurface createSurface(AppComponent component, SurfaceHolder holder, boolean reset) { // ignore
32+
if (reset) pgl.resetFBOLayer();
3233
return new PSurfaceCardboard(this, component, holder, true);
3334
}
3435
}

0 commit comments

Comments
 (0)