Project

General

Profile

« Previous | Next » 

Revision 30094332

Added by Leszek Koltunski about 4 years ago

More support for using the library from more than one activity. Should be working now!

View differences:

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 )
src/main/java/org/distorted/library/main/DistortedLibrary.java
1093 1093
  public static void onPause(long id)
1094 1094
    {
1095 1095
    InternalStackFrameList.onPause(id);
1096
    Dynamic.onPause();
1096
    Dynamic.onPause();  // common for all frames
1097 1097

  
1098 1098
    mLinkedListSSBO[0]= -1;
1099 1099
    mAtomicCounter = null;
......
1137 1137

  
1138 1138
    if( InternalStackFrameList.isInitialized() )
1139 1139
      {
1140
      InternalStackFrameList.setInitialized(false);
1141
      mOITCompilationAttempted = false;
1142

  
1143 1140
      InternalStackFrameList.onDestroy(id);
1144 1141
      InternalNodeData.onDestroy();
1145 1142
      InternalMaster.onDestroy();
......
1148 1145
      EffectQueue.onDestroy();
1149 1146
      Effect.onDestroy();
1150 1147
      DeferredJobs.onDestroy();
1151
      EffectMessageSender.stopSending();
1148

  
1149
      mOITCompilationAttempted = false;
1152 1150
      }
1153 1151
    }
1154 1152

  
src/main/java/org/distorted/library/main/InternalStackFrame.java
19 19

  
20 20
package org.distorted.library.main;
21 21

  
22
import org.distorted.library.effect.EffectType;
23

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

  
......
49 51
  private long mNextSystemID;                   //
50 52
  private long mTaskId;                         //
51 53

  
52
  private static boolean mInitialized;          // DistortedLibrary
54
  private boolean mInitialized;                 // DistortedLibrary
55

  
56
  private int[] mMax;                           // EffectQueue
53 57

  
54 58
///////////////////////////////////////////////////////////////////////////////////////////////////
55 59

  
......
60 64
    mNextClientID = 0;
61 65
    mNextSystemID = 0;
62 66
    mTaskId       = taskID;
67
    mMax          = new int[EffectType.LENGTH];
68

  
69
    EffectType.reset(mMax);
63 70
    }
64 71

  
65 72
///////////////////////////////////////////////////////////////////////////////////////////////////
......
227 234
    mInitialized = init;
228 235
    }
229 236

  
237
///////////////////////////////////////////////////////////////////////////////////////////////////
238

  
239
  int getMax(int index)
240
    {
241
    return mMax[index];
242
    }
243

  
244
///////////////////////////////////////////////////////////////////////////////////////////////////
245

  
246
  boolean setMax(int index, int max)
247
    {
248
    if( !mInitialized || max<mMax[index] )
249
      {
250
      mMax[index] = max;
251
      return true;
252
      }
253

  
254
    return false;
255
    }
256

  
230 257
///////////////////////////////////////////////////////////////////////////////////////////////////
231 258

  
232 259
  void debugLists(String frameMarker)
src/main/java/org/distorted/library/main/InternalStackFrameList.java
19 19

  
20 20
package org.distorted.library.main;
21 21

  
22
import org.distorted.library.message.EffectMessageSender;
23

  
22 24
import java.util.ArrayList;
23 25

  
24 26
///////////////////////////////////////////////////////////////////////////////////////////////////
......
124 126
        break;
125 127
        }
126 128
      }
129

  
130
    setInitialized(false);
131

  
132
    if( num<2 )
133
      {
134
      EffectMessageSender.stopSending();
135
      }
127 136
    }
128 137

  
129 138
///////////////////////////////////////////////////////////////////////////////////////////////////
......
207 216
    return mCurrentFrame.isInitialized();
208 217
    }
209 218

  
219
///////////////////////////////////////////////////////////////////////////////////////////////////
220

  
221
  public static int getMax(int index)
222
    {
223
    return mCurrentFrame.getMax(index);
224
    }
225

  
226
///////////////////////////////////////////////////////////////////////////////////////////////////
227

  
228
  public static boolean setMax(int index,int max)
229
    {
230
    return mCurrentFrame.setMax(index,max);
231
    }
210 232
}
src/main/java/org/distorted/library/type/Dynamic.java
610 610
    return mDuration;
611 611
    }
612 612

  
613

  
614 613
///////////////////////////////////////////////////////////////////////////////////////////////////
615 614
/**
616 615
 * @param convexity If set to the default (1.0f) then interpolation between 4 points

Also available in: Unified diff