Revision 30094332
Added by Leszek Koltunski over 3 years ago
src/main/java/org/distorted/library/effectqueue/EffectQueue.java | ||
---|---|---|
53 | 53 |
float[] mFloatUniforms; |
54 | 54 |
int[] mIntUniforms; |
55 | 55 |
|
56 |
static int[] mMax = new int[EffectType.LENGTH]; |
|
57 |
private static long mNextID; |
|
56 |
private static long mNextID = 1; |
|
58 | 57 |
private static HashMap<ArrayList<Long>,Long> mMapID = new HashMap<>(); // maps lists of Effect IDs (longs) to a |
59 | 58 |
// single long - the queue ID. |
60 | 59 |
private long mID; |
... | ... | |
80 | 79 |
|
81 | 80 |
private ArrayList<Job> mJobs = new ArrayList<>(); |
82 | 81 |
|
83 |
static |
|
84 |
{ |
|
85 |
onDestroy(); |
|
86 |
} |
|
87 |
|
|
88 | 82 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
89 | 83 |
|
90 | 84 |
EffectQueue(int numFloatUniforms, int numIntUniforms, int index) |
... | ... | |
139 | 133 |
mNumFloatUniforms = source.mNumFloatUniforms; |
140 | 134 |
mNumIntUniforms = source.mNumIntUniforms; |
141 | 135 |
|
142 |
int max = mMax[mIndex];
|
|
136 |
int max = InternalStackFrameList.getMax(mIndex);
|
|
143 | 137 |
|
144 | 138 |
if( max>0 ) |
145 | 139 |
{ |
... | ... | |
240 | 234 |
|
241 | 235 |
public static boolean setMax(int index, int m) |
242 | 236 |
{ |
243 |
if( !InternalStackFrameList.isInitialized() || m<=mMax[index] ) |
|
244 |
{ |
|
245 |
mMax[index] = m<0 ? 0:m; |
|
246 |
return true; |
|
247 |
} |
|
248 |
|
|
249 |
return false; |
|
237 |
return InternalStackFrameList.setMax(index, Math.max(m,0)); |
|
250 | 238 |
} |
251 | 239 |
|
252 | 240 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
253 | 241 |
|
254 | 242 |
public static int getMax(int index) |
255 | 243 |
{ |
256 |
return mMax[index];
|
|
244 |
return InternalStackFrameList.getMax(index);
|
|
257 | 245 |
} |
258 | 246 |
|
259 | 247 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
262 | 250 |
{ |
263 | 251 |
mNextID = 1; |
264 | 252 |
mMapID.clear(); |
265 |
EffectType.reset(mMax); |
|
266 | 253 |
} |
267 | 254 |
|
268 | 255 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
368 | 355 |
|
369 | 356 |
public boolean add(Effect effect) |
370 | 357 |
{ |
371 |
if( mMax[mIndex]>mNumEffectsToBe || !mCreated )
|
|
358 |
if( InternalStackFrameList.getMax(mIndex)>mNumEffectsToBe || !mCreated )
|
|
372 | 359 |
{ |
373 | 360 |
mJobs.add(new Job(ATTACH,-1,0,false,effect)); |
374 | 361 |
InternalMaster.newSlave(this); |
... | ... | |
383 | 370 |
|
384 | 371 |
public boolean add(Effect effect, int position) |
385 | 372 |
{ |
386 |
if( mMax[mIndex]>mNumEffectsToBe || !mCreated )
|
|
373 |
if( InternalStackFrameList.getMax(mIndex)>mNumEffectsToBe || !mCreated )
|
|
387 | 374 |
{ |
388 | 375 |
mJobs.add(new Job(ATTACH,position,0,false,effect)); |
389 | 376 |
InternalMaster.newSlave(this); |
... | ... | |
437 | 424 |
|
438 | 425 |
switch(job.type) |
439 | 426 |
{ |
440 |
case CREATE: int max = mMax[mIndex];
|
|
427 |
case CREATE: int max = InternalStackFrameList.getMax(mIndex);
|
|
441 | 428 |
if( max>0 ) |
442 | 429 |
{ |
443 | 430 |
mEffects = new Effect[max]; |
... | ... | |
447 | 434 |
mCreated = true; |
448 | 435 |
|
449 | 436 |
break; |
450 |
case ATTACH: if( mMax[mIndex]>mNumEffects ) // it is possible that we have first
|
|
451 |
{ // added effects and then lowered mMax |
|
437 |
case ATTACH: if( InternalStackFrameList.getMax(mIndex)>mNumEffects ) // it is possible that we have first
|
|
438 |
{ // added effects and then lowered mMax
|
|
452 | 439 |
int position = job.num1; |
453 | 440 |
|
454 | 441 |
if( position<0 ) |
Also available in: Unified diff
More support for using the library from more than one activity. Should be working now!