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/differentbitmaps/DifferentBitmapsRenderer.java
41 41

  
42 42
import android.graphics.Bitmap;
43 43
import android.graphics.BitmapFactory;
44
import android.opengl.GLES30;
45 44
import android.opengl.GLSurfaceView;
46 45

  
47 46
///////////////////////////////////////////////////////////////////////////////////////////////////
......
52 51
   
53 52
   private GLSurfaceView mView;
54 53
   private DistortedEffects[] mEffects;
54
   private DistortedTexture[] mTexture;
55 55
   private DistortedScreen mScreen;
56 56
   private int bmpHeight, bmpWidth;
57 57
    
......
156 156
      
157 157
      bmpHeight = bitmap0.getHeight();
158 158
      bmpWidth  = bitmap0.getWidth();
159
      
160
      DistortedTexture[] texture = new DistortedTexture[NUM];
161
      for(int i=0; i<NUM; i++)
162
        texture[i] = new DistortedTexture(bmpWidth,bmpHeight);
163
      
164
      texture[0].setTexture(bitmap0);
165
      texture[1].setTexture(bitmap1);
166
      texture[2].setTexture(bitmap2);
159

  
160
      if( mTexture==null )
161
        {
162
        mTexture = new DistortedTexture[NUM];
163

  
164
        for(int i=0; i<NUM; i++)
165
          mTexture[i] = new DistortedTexture(bmpWidth,bmpHeight);
166
        }
167

  
168
      mTexture[0].setTexture(bitmap0);
169
      mTexture[1].setTexture(bitmap1);
170
      mTexture[2].setTexture(bitmap2);
167 171

  
168 172
      MeshFlat mesh = new MeshFlat(30,30*bmpHeight/bmpWidth);
169 173

  
170 174
      mScreen.detachAll();
171
      for(int i=NUM-1; i>=0; i--) mScreen.attach(texture[i], mEffects[i], mesh);
175
      for(int i=NUM-1; i>=0; i--) mScreen.attach(mTexture[i], mEffects[i], mesh);
172 176

  
173 177
      DistortedEffects.enableEffect(EffectNames.SINK);
174 178
      DistortedEffects.enableEffect(EffectNames.DISTORT);

Also available in: Unified diff