Project

General

Profile

« Previous | Next » 

Revision 05ecc6fe

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/library/DistortedSurface.java
20 20
package org.distorted.library;
21 21

  
22 22
import java.util.HashMap;
23
import java.util.Iterator;
23 24
import java.util.LinkedList;
25
import java.util.Map;
24 26

  
25 27
///////////////////////////////////////////////////////////////////////////////////////////////////
26 28
/**
......
75 77
  abstract void recreate();
76 78

  
77 79
///////////////////////////////////////////////////////////////////////////////////////////////////
78
// must be called form a thread holding OpenGL Context
80
// must be called from a thread holding OpenGL Context
79 81

  
80 82
  static synchronized void toDo()
81 83
    {
......
109 111

  
110 112
///////////////////////////////////////////////////////////////////////////////////////////////////
111 113

  
112
  static synchronized void onDestroy()
114
  static synchronized void onPause()
113 115
    {
114
    Job job;
115 116
    DistortedSurface surface;
117
    int num = mDoneList.size();
116 118

  
117
    for(Long key: mToDoMap.keySet())
119
    for(int i=0; i<num; i++)
118 120
      {
119
      job = mToDoMap.get(key);
120

  
121
      if( job.surface.mType==TYPE_SYST )
122
        {
123
        mDoneList.add(job.surface);
124
        }
121
      surface = mDoneList.removeFirst();
122
      mToDoMap.put(surface.getID(), surface.new Job(surface,JOB_CREATE) );
123
      surface.recreate();
125 124
      }
126 125

  
127
    mToDoMap.clear();
126
    mToDo = true;
127
    }
128

  
129
///////////////////////////////////////////////////////////////////////////////////////////////////
128 130

  
129
    int num = mDoneList.size();
131
  static synchronized void onDestroy()
132
    {
133
    Job job;
134
    Iterator<Map.Entry<Long,Job>> it = mToDoMap.entrySet().iterator();
130 135

  
131
    for(int i=0; i<num; i++)
136
    while (it.hasNext())
132 137
      {
133
      surface = mDoneList.removeFirst();
134

  
135
      if( surface.mType==TYPE_SYST )
136
        {
137
        mToDoMap.put(surface.getID(), surface.new Job(surface,JOB_CREATE) );
138
        surface.recreate();
139
        }
138
      Map.Entry<Long,Job> entry = it.next();
139
      job = entry.getValue();
140
      if (job.surface.mType!=TYPE_SYST) it.remove();
140 141
      }
141 142

  
143
    mDoneList.clear();
144

  
142 145
    mToDo = true;
143 146
    mNextClientID = 0;
144 147
    }

Also available in: Unified diff