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/girl/GirlRenderer.java
42 42

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

  
48 47
///////////////////////////////////////////////////////////////////////////////////////////////////
......
52 51
    private GLSurfaceView mView;
53 52
    private DistortedEffects mEffects;
54 53
    private DistortedScreen mScreen;
54
    private DistortedTexture mTexture;
55 55
    private Static3D v0,v1,v2,v3;
56 56
    private Static1D dBegin, dMiddle, dEnd, s0;
57 57
    private int bmpHeight, bmpWidth;
......
204 204
      bmpHeight = bitmap.getHeight();
205 205
      bmpWidth  = bitmap.getWidth();
206 206

  
207
      MeshFlat mesh = new MeshFlat(30,30*bmpHeight/bmpWidth);
208
      DistortedTexture texture = new DistortedTexture(bmpWidth,bmpHeight);
209
      texture.setTexture(bitmap);
207
      if( mTexture==null ) mTexture = new DistortedTexture(bmpWidth,bmpHeight);
208
      mTexture.setTexture(bitmap);
210 209

  
211 210
      mScreen.detachAll();
212
      mScreen.attach(texture,mEffects,mesh);
211
      mScreen.attach(mTexture,mEffects,new MeshFlat(30,30*bmpHeight/bmpWidth));
213 212

  
214 213
      DistortedEffects.enableEffect(EffectNames.DISTORT);
215 214
      DistortedEffects.enableEffect(EffectNames.SINK);

Also available in: Unified diff