commit 3417ab4e3376cb73fad209aea5efa2be6014d79a
Author: leszek <leszek@koltunski.pl>
Date:   Wed Jun 21 01:34:03 2017 +0100

    Now all Postprocessing EffectQueues have the right IDs regardless of number of effects.

diff --git a/src/main/java/org/distorted/library/main/EffectQueue.java b/src/main/java/org/distorted/library/main/EffectQueue.java
index ff1bcd2..d1c5884 100644
--- a/src/main/java/org/distorted/library/main/EffectQueue.java
+++ b/src/main/java/org/distorted/library/main/EffectQueue.java
@@ -26,6 +26,7 @@ import org.distorted.library.message.EffectListener;
 import org.distorted.library.message.EffectMessage;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -47,6 +48,10 @@ abstract class EffectQueue implements DistortedSlave
   protected int mNumListeners=0;  // ==mListeners.length(), but we only create mListeners if the first one gets added
   protected long mDistortedEffectsID;
 
+  private static long mNextID;
+  private static HashMap<ArrayList<Long>,Long> mMapID = new HashMap<>(); // maps lists of Effect IDs (longs) to a
+                                                                         // single long - the queue ID.
+
   private ArrayList<DistortedNode> mNodes = null;
   private long mID;
   private static boolean mCreated;
@@ -97,12 +102,39 @@ abstract class EffectQueue implements DistortedSlave
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
-// TODO: introduce a Map to return an ID dependant on all Effects in the Queue.
-// For now this is good enough.
 
   private void regenerateID()
     {
-    mID = mNumEffects>0 ? mEffects[0].getID() : 0;
+    if( mNumEffects>0 )
+      {
+      ArrayList<Long> list = new ArrayList<>();
+      for (int i = 0; i < mNumEffects; i++) list.add(mEffects[i].getID());
+      Long id = mMapID.get(list);
+
+      if( id!=null )
+        {
+        mID = id;
+        }
+      else
+        {
+        mMapID.put(list,mNextID);
+        mID = mNextID++;
+        }
+      }
+    else
+      {
+      mID = 0;
+      }
+/*
+    if( mIndex == EffectType.MATRIX.ordinal() )
+      android.util.Log.d("queue", "queueM id="+mID);
+    if( mIndex == EffectType.VERTEX.ordinal() )
+      android.util.Log.d("queue", "queueV id="+mID);
+    if( mIndex == EffectType.FRAGMENT.ordinal() )
+      android.util.Log.d("queue", "queueF id="+mID);
+    if( mIndex == EffectType.POSTPROCESS.ordinal() )
+      android.util.Log.d("queue", "queueP id="+mID);
+*/
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -176,6 +208,8 @@ abstract class EffectQueue implements DistortedSlave
 
   static void onDestroy()
     {
+    mNextID = 1;
+    mMapID.clear();
     EffectType.reset(mMax);
     mCreated = false;  
     }
@@ -352,19 +386,11 @@ abstract class EffectQueue implements DistortedSlave
         }
       }
 
-    if( num>0 )
+    if( num>0 && mIndex==EffectType.POSTPROCESS.ordinal() )
       {
       regenerateID();
-
-      if( mIndex==EffectType.POSTPROCESS.ordinal() )
-        {
-        int numNodes = (mNodes==null ? 0: mNodes.size());
-
-        for(int i=0; i<numNodes; i++)
-          {
-          mNodes.get(i).sort();
-          }
-        }
+      int numNodes = (mNodes==null ? 0: mNodes.size());
+      for(int i=0; i<numNodes; i++) mNodes.get(i).sort();
       }
     }
   }
