Revision 3543a3cf
Added by Leszek Koltunski about 4 years ago
src/main/java/org/distorted/library/effect/Effect.java | ||
---|---|---|
20 | 20 |
package org.distorted.library.effect; |
21 | 21 |
|
22 | 22 |
import org.distorted.library.effectqueue.EffectQueue; |
23 |
import org.distorted.library.main.InternalStackFrameList; |
|
23 | 24 |
import org.distorted.library.message.EffectListener; |
24 | 25 |
|
25 | 26 |
import java.lang.reflect.Method; |
... | ... | |
44 | 45 |
private ArrayList<EffectListener> mListeners =null; |
45 | 46 |
private int mNumListeners=0; // ==mListeners.length(), but we only create mListeners if the first one gets added |
46 | 47 |
|
47 |
private static long mNextID = 0; |
|
48 |
|
|
49 | 48 |
private final static float[] mUnity= new float[MAX_UNITY_DIM*NUM_EFFECTS]; |
50 | 49 |
private final static int[] mUnityDim = new int[NUM_EFFECTS]; |
51 | 50 |
|
... | ... | |
85 | 84 |
|
86 | 85 |
mUnityDim[n] = l; |
87 | 86 |
|
88 |
mID = ((mNextID++)<<EffectType.LENGTH) + mType.ordinal();
|
|
87 |
mID = (InternalStackFrameList.getNextEffectID()<<EffectType.LENGTH) + mType.ordinal();
|
|
89 | 88 |
} |
90 | 89 |
|
91 | 90 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
96 | 95 |
*/ |
97 | 96 |
public static void onDestroy() |
98 | 97 |
{ |
99 |
mNextID = 0; |
|
100 |
|
|
101 | 98 |
for(int i=0; i<NUM_EFFECTS; i++) mEnabled[i] = false; |
102 | 99 |
|
103 | 100 |
MatrixEffect.destroyStatics(); |
src/main/java/org/distorted/library/main/DistortedEffects.java | ||
---|---|---|
32 | 32 |
*/ |
33 | 33 |
public class DistortedEffects |
34 | 34 |
{ |
35 |
private static long mNextID =0; |
|
36 | 35 |
private long mID; |
37 | 36 |
private EffectQueue[] mQueues; |
38 | 37 |
|
... | ... | |
53 | 52 |
*/ |
54 | 53 |
public DistortedEffects() |
55 | 54 |
{ |
56 |
mID = ++mNextID;
|
|
55 |
mID = InternalStackFrameList.getNextEffectsID();
|
|
57 | 56 |
mQueues = new EffectQueue[EffectType.LENGTH]; |
58 | 57 |
EffectQueue.allocateQueues(mQueues,null,0); |
59 | 58 |
} |
... | ... | |
70 | 69 |
*/ |
71 | 70 |
public DistortedEffects(DistortedEffects dc, int flags) |
72 | 71 |
{ |
73 |
mID = ++mNextID;
|
|
72 |
mID = InternalStackFrameList.getNextEffectsID();
|
|
74 | 73 |
mQueues = new EffectQueue[EffectType.LENGTH]; |
75 | 74 |
EffectQueue.allocateQueues(mQueues,dc.getQueues(),flags); |
76 | 75 |
} |
src/main/java/org/distorted/library/main/DistortedLibrary.java | ||
---|---|---|
1133 | 1133 |
if( InternalStackFrameList.isInitialized() ) |
1134 | 1134 |
{ |
1135 | 1135 |
InternalStackFrameList.onDestroy(id); |
1136 |
InternalNodeData.onDestroy(); |
|
1137 | 1136 |
InternalMaster.onDestroy(); |
1138 | 1137 |
InternalOutputSurface.onDestroy(); |
1139 | 1138 |
EffectQueue.onDestroy(); |
src/main/java/org/distorted/library/main/InternalNodeData.java | ||
---|---|---|
20 | 20 |
package org.distorted.library.main; |
21 | 21 |
|
22 | 22 |
import java.util.ArrayList; |
23 |
import java.util.HashMap; |
|
24 | 23 |
|
25 | 24 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
26 | 25 |
/** |
... | ... | |
28 | 27 |
*/ |
29 | 28 |
class InternalNodeData |
30 | 29 |
{ |
31 |
private static HashMap<ArrayList<Long>, InternalNodeData> mMapNodeID = new HashMap<>(); |
|
32 |
private static long mNextNodeID =0; |
|
33 |
|
|
34 |
private final ArrayList<Long> key; |
|
30 |
private final ArrayList<Long> mKey; |
|
35 | 31 |
private int numPointingNodes; |
36 | 32 |
private long currTime; |
37 | 33 |
|
... | ... | |
40 | 36 |
|
41 | 37 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
42 | 38 |
|
43 |
private InternalNodeData(long id, ArrayList<Long> k)
|
|
39 |
InternalNodeData(long id, ArrayList<Long> k) |
|
44 | 40 |
{ |
45 | 41 |
ID = id; |
46 |
key = k;
|
|
42 |
mKey = k;
|
|
47 | 43 |
numPointingNodes= 1; |
48 | 44 |
currTime =-1; |
49 | 45 |
mFBO = null; |
50 | 46 |
} |
51 | 47 |
|
52 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
53 |
|
|
54 |
static synchronized void onDestroy() |
|
55 |
{ |
|
56 |
mNextNodeID = 0; |
|
57 |
mMapNodeID.clear(); |
|
58 |
} |
|
59 |
|
|
60 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
61 |
|
|
62 |
@SuppressWarnings("unused") |
|
63 |
static void debugMap() |
|
64 |
{ |
|
65 |
InternalNodeData tmp; |
|
66 |
|
|
67 |
for(ArrayList<Long> key: mMapNodeID.keySet()) |
|
68 |
{ |
|
69 |
tmp = mMapNodeID.get(key); |
|
70 |
android.util.Log.e("NodeData", "NodeID: "+tmp.ID+" <-- "+key); |
|
71 |
} |
|
72 |
} |
|
73 |
|
|
74 | 48 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
75 | 49 |
|
76 | 50 |
static InternalNodeData returnData(ArrayList<Long> list) |
77 | 51 |
{ |
78 |
InternalNodeData newData = mMapNodeID.get(list);
|
|
52 |
InternalNodeData data = InternalStackFrameList.getMapID(list);
|
|
79 | 53 |
|
80 |
if( newData!=null )
|
|
54 |
if( data!=null )
|
|
81 | 55 |
{ |
82 |
newData.numPointingNodes++;
|
|
56 |
data.numPointingNodes++;
|
|
83 | 57 |
} |
84 | 58 |
else |
85 | 59 |
{ |
86 |
newData = new InternalNodeData(++mNextNodeID,list); |
|
87 |
mMapNodeID.put(list,newData); |
|
60 |
data = InternalStackFrameList.putNewDataToMap(list); |
|
88 | 61 |
} |
89 | 62 |
|
90 |
return newData;
|
|
63 |
return data;
|
|
91 | 64 |
} |
92 | 65 |
|
93 | 66 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
96 | 69 |
{ |
97 | 70 |
if( --numPointingNodes==0 ) |
98 | 71 |
{ |
99 |
mMapNodeID.remove(key);
|
|
72 |
InternalStackFrameList.removeKeyFromMap(mKey);
|
|
100 | 73 |
|
101 | 74 |
if( mFBO!=null ) return true; |
102 | 75 |
} |
src/main/java/org/distorted/library/main/InternalStackFrame.java | ||
---|---|---|
21 | 21 |
|
22 | 22 |
import org.distorted.library.effect.EffectType; |
23 | 23 |
|
24 |
import java.util.ArrayList; |
|
24 | 25 |
import java.util.HashMap; |
25 | 26 |
import java.util.LinkedList; |
26 | 27 |
|
... | ... | |
45 | 46 |
private static long mCommonNextClientID = 0; // InternalObject |
46 | 47 |
private static long mCommonNextSystemID = 0; // (postprocessing) |
47 | 48 |
|
48 |
private LinkedList<InternalObject> mDoneList; // |
|
49 |
private HashMap<Long,Job> mToDoMap; // |
|
50 |
private long mNextClientID; // InternalObject |
|
51 |
private long mNextSystemID; // |
|
52 |
private long mTaskId; // |
|
49 |
////////////////////////////////////////////////////////////////// |
|
50 |
private LinkedList<InternalObject> mDoneList; // |
|
51 |
private HashMap<Long,Job> mToDoMap; // |
|
52 |
private long mNextClientID; // InternalObject |
|
53 |
private long mNextSystemID; // |
|
54 |
private long mTaskId; // |
|
53 | 55 |
|
54 |
private boolean mInitialized; // DistortedLibrary |
|
56 |
////////////////////////////////////////////////////////////////// |
|
57 |
private boolean mInitialized; // DistortedLibrary |
|
55 | 58 |
|
56 |
private int[] mMax; // EffectQueue |
|
59 |
////////////////////////////////////////////////////////////////// |
|
60 |
private int[] mMax; // EffectQueue |
|
61 |
|
|
62 |
////////////////////////////////////////////////////////////////// |
|
63 |
private long mNextEffectsID; // DistortedEffects; |
|
64 |
|
|
65 |
////////////////////////////////////////////////////////////////// |
|
66 |
private long mNextEffectID; // Effect; |
|
67 |
|
|
68 |
////////////////////////////////////////////////////////////////// |
|
69 |
private HashMap<ArrayList<Long>, InternalNodeData> mMapNodeID; // InternalNodeData |
|
70 |
private long mNextNodeID; |
|
57 | 71 |
|
58 | 72 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
59 | 73 |
|
... | ... | |
61 | 75 |
{ |
62 | 76 |
mDoneList = new LinkedList<>(); |
63 | 77 |
mToDoMap = new HashMap<>(); |
78 |
mMapNodeID = new HashMap<>(); |
|
79 |
mNextEffectsID= 0; |
|
64 | 80 |
mNextClientID = 0; |
65 | 81 |
mNextSystemID = 0; |
82 |
mNextNodeID = 0; |
|
66 | 83 |
mTaskId = taskID; |
67 | 84 |
mMax = new int[EffectType.LENGTH]; |
68 | 85 |
|
... | ... | |
234 | 251 |
mInitialized = init; |
235 | 252 |
} |
236 | 253 |
|
254 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
255 |
|
|
256 |
long getNextEffectsID() |
|
257 |
{ |
|
258 |
return ++mNextEffectsID; |
|
259 |
} |
|
260 |
|
|
261 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
262 |
|
|
263 |
long getNextEffectID() |
|
264 |
{ |
|
265 |
return mNextEffectID++; |
|
266 |
} |
|
267 |
|
|
237 | 268 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
238 | 269 |
|
239 | 270 |
int getMax(int index) |
... | ... | |
254 | 285 |
return false; |
255 | 286 |
} |
256 | 287 |
|
288 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
289 |
|
|
290 |
InternalNodeData getMapID(ArrayList<Long> key) |
|
291 |
{ |
|
292 |
return mMapNodeID.get(key); |
|
293 |
} |
|
294 |
|
|
295 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
296 |
|
|
297 |
InternalNodeData putNewDataToMap(ArrayList<Long> key) |
|
298 |
{ |
|
299 |
InternalNodeData data = new InternalNodeData(++mNextNodeID,key); |
|
300 |
mMapNodeID.put(key,data); |
|
301 |
return data; |
|
302 |
} |
|
303 |
|
|
304 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
305 |
|
|
306 |
void removeKeyFromMap(ArrayList<Long> key) |
|
307 |
{ |
|
308 |
mMapNodeID.remove(key); |
|
309 |
} |
|
310 |
|
|
257 | 311 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
258 | 312 |
|
259 | 313 |
void debugLists(String frameMarker) |
... | ... | |
290 | 344 |
job.object.print(job.action==InternalObject.JOB_CREATE ? " create":" delete"); |
291 | 345 |
} |
292 | 346 |
} |
347 |
|
|
348 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
349 |
|
|
350 |
void debugMap(String frameMarker) |
|
351 |
{ |
|
352 |
android.util.Log.e("Object", frameMarker); |
|
353 |
InternalNodeData tmp; |
|
354 |
|
|
355 |
for(ArrayList<Long> key: mMapNodeID.keySet()) |
|
356 |
{ |
|
357 |
tmp = mMapNodeID.get(key); |
|
358 |
android.util.Log.e("NodeData", "NodeID: "+tmp.ID+" <-- "+key); |
|
359 |
} |
|
360 |
} |
|
293 | 361 |
} |
src/main/java/org/distorted/library/main/InternalStackFrameList.java | ||
---|---|---|
152 | 152 |
} |
153 | 153 |
} |
154 | 154 |
|
155 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
156 |
|
|
157 |
@SuppressWarnings("unused") |
|
158 |
static void debugMap() |
|
159 |
{ |
|
160 |
int num = mFrameList.size(); |
|
161 |
InternalStackFrame frame; |
|
162 |
|
|
163 |
for(int i=0; i<num; i++) |
|
164 |
{ |
|
165 |
frame = mFrameList.get(i); |
|
166 |
frame.debugMap("frame "+i); |
|
167 |
} |
|
168 |
} |
|
169 |
|
|
155 | 170 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
156 | 171 |
// must be called from a thread holding OpenGL Context |
157 | 172 |
|
... | ... | |
200 | 215 |
return mCurrentFrame; |
201 | 216 |
} |
202 | 217 |
|
218 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
219 |
|
|
220 |
static long getNextEffectsID() |
|
221 |
{ |
|
222 |
return mCurrentFrame.getNextEffectsID(); |
|
223 |
} |
|
224 |
|
|
203 | 225 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
204 | 226 |
|
205 | 227 |
static void setInitialized(boolean init) |
... | ... | |
207 | 229 |
mCurrentFrame.setInitialized(init); |
208 | 230 |
} |
209 | 231 |
|
232 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
233 |
|
|
234 |
static InternalNodeData getMapID(ArrayList<Long> key) |
|
235 |
{ |
|
236 |
return mCurrentFrame.getMapID(key); |
|
237 |
} |
|
238 |
|
|
239 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
240 |
|
|
241 |
static InternalNodeData putNewDataToMap(ArrayList<Long> key) |
|
242 |
{ |
|
243 |
return mCurrentFrame.putNewDataToMap(key); |
|
244 |
} |
|
245 |
|
|
246 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
247 |
|
|
248 |
static void removeKeyFromMap(ArrayList<Long> key) |
|
249 |
{ |
|
250 |
mCurrentFrame.removeKeyFromMap(key); |
|
251 |
} |
|
252 |
|
|
210 | 253 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
211 | 254 |
// PUBLIC API |
255 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
256 |
|
|
257 |
public static long getNextEffectID() |
|
258 |
{ |
|
259 |
return mCurrentFrame.getNextEffectID(); |
|
260 |
} |
|
261 |
|
|
212 | 262 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
213 | 263 |
|
214 | 264 |
public static boolean isInitialized() |
Also available in: Unified diff
Put new things to the StackFrame.