Project

General

Profile

« Previous | Next » 

Revision b0ebdf5e

Added by Leszek Koltunski about 7 years ago

Major:

1) in the Library, fix the fact that some applications (those that were creating their DistortedSurface objects outside of onSurfaceCreated or onSurfaceChanged) would not render after the activity went to background (press POWER to see that).
2) in the Apps, call the new 'Distorted.onPause()' API to fix the above problem

The above fixes the problem, but it still leaks memory if an App creates its Surface in onSurfaceCreated/Changed (precisely: it leaves the old Surface in the DistortedSurface Map). Thus

3) Fix the first 15 Apps to avoid the memory leak. Next Apps coming.

View differences:

src/main/java/org/distorted/examples/listener/ListenerRenderer.java
43 43

  
44 44
import android.graphics.Bitmap;
45 45
import android.graphics.BitmapFactory;
46
import android.opengl.GLES30;
47 46
import android.opengl.GLSurfaceView;
48 47

  
49 48
///////////////////////////////////////////////////////////////////////////////////////////////////
......
55 54
   private GLSurfaceView mView;
56 55
   private DistortedEffects mEffects;
57 56
   private DistortedScreen mScreen;
57
   private DistortedTexture mTexture;
58 58
   private int bmpHeight, bmpWidth;
59 59
   private Random mRnd;
60 60

  
......
155 155
      bmpHeight = bitmap.getHeight();
156 156
      bmpWidth  = bitmap.getWidth();
157 157

  
158
      MeshFlat mesh = new MeshFlat(50,50*bmpHeight/bmpWidth);
159
      DistortedTexture texture = new DistortedTexture(bmpWidth,bmpHeight);
160
      texture.setTexture(bitmap);
158
      if( mTexture==null ) mTexture = new DistortedTexture(bmpWidth,bmpHeight);
159
      mTexture.setTexture(bitmap);
161 160

  
162 161
      mScreen.detachAll();
163
      mScreen.attach(texture,mEffects,mesh);
162
      mScreen.attach(mTexture,mEffects,new MeshFlat(50,50*bmpHeight/bmpWidth));
164 163

  
165 164
      for(int i=0; i<NUM_BUBBLES; i++) randomizeNewBubble();
166 165

  

Also available in: Unified diff