commit 718874840c889d5636c557c3cd6e227f42de38d5
Author: Leszek Koltunski <leszek@distoretedandroid.org>
Date:   Fri Jun 10 14:51:45 2016 +0100

    abstract setMax and getMax to EffectQueue.

diff --git a/src/main/java/org/distorted/library/Distorted.java b/src/main/java/org/distorted/library/Distorted.java
index 4599082..08e555e 100644
--- a/src/main/java/org/distorted/library/Distorted.java
+++ b/src/main/java/org/distorted/library/Distorted.java
@@ -108,11 +108,11 @@ public class Distorted
       int realMaxV = (maxV-11)/4;   // adjust this in case of changes to the shaders...
       int realMaxF = (maxF- 2)/4;   //
     
-      if( EffectQueueVertex.getMax() > realMaxV )
+      if( getMaxVertex()   > realMaxV )
         {
         throw new VertexUniformsException("Too many effects in the vertex shader, max is "+realMaxV, realMaxV);
         }
-      if( EffectQueueFragment.getMax() > realMaxF )
+      if( getMaxFragment() > realMaxF )
         {
         throw new FragmentUniformsException("Too many effects in the fragment shader, max is "+realMaxF, realMaxF);
         }
@@ -204,7 +204,7 @@ public class Distorted
    
     switch(type)
       {
-      case GLES20.GL_VERTEX_SHADER  : header += ("#define NUM_VERTEX "  + EffectQueueVertex.getMax()+"\n");
+      case GLES20.GL_VERTEX_SHADER  : header += ("#define NUM_VERTEX "  + getMaxVertex()+"\n");
      
                                       for(EffectNames name: EffectNames.values() )
                                         {
@@ -212,7 +212,7 @@ public class Distorted
                                         header += ("#define "+name.name()+" "+name.ordinal()+"\n");  
                                         }
                                       break;
-      case GLES20.GL_FRAGMENT_SHADER: header += ("#define NUM_FRAGMENT "+ EffectQueueFragment.getMax()+"\n");
+      case GLES20.GL_FRAGMENT_SHADER: header += ("#define NUM_FRAGMENT "+ getMaxFragment()+"\n");
      
                                       for(EffectNames name: EffectNames.values() )
                                         {
@@ -378,11 +378,7 @@ public class Distorted
     {
     DistortedObjectList.release();
     DistortedNode.release();
-
-    EffectQueueVertex.reset();
-    EffectQueueFragment.reset();
-    EffectQueueMatrix.reset();  // no need to reset Other EffectQueue
-
+    EffectQueue.reset();
     EffectMessageSender.stopSending();
    
     mInitialized = false;
@@ -408,7 +404,7 @@ public class Distorted
  */
   public static int getMaxMatrix()
     {
-    return EffectQueueMatrix.getMax();
+    return EffectQueue.getMax(EffectTypes.MATRIX.ordinal());
     }
  
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -419,7 +415,7 @@ public class Distorted
  */  
   public static int getMaxVertex()
     {
-    return EffectQueueVertex.getMax();
+    return EffectQueue.getMax(EffectTypes.VERTEX.ordinal());
     }
   
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -430,12 +426,23 @@ public class Distorted
  */  
   public static int getMaxFragment()
     {
-    return EffectQueueFragment.getMax();
+    return EffectQueue.getMax(EffectTypes.FRAGMENT.ordinal());
     }
-  
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Returns the maximum number of Other effects.
+ *
+ * @return The maximum number of Other effects
+ */
+  public static int getMaxOther()
+    {
+    return EffectQueue.getMax(EffectTypes.OTHER.ordinal());
+    }
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 /**
- * Sets the maximum number of Matrix effects that can be applied to a single DistortedBitmap at one time.
+ * Sets the maximum number of Matrix effects that can be applied to a single DistortedObject at one time.
  * This can fail if the value of 'max' is outside permitted range. 
  * 
  * @param max new maximum number of simultaneous Matrix Effects. Has to be a non-negative number not greater
@@ -444,12 +451,12 @@ public class Distorted
  */
   public static boolean setMaxMatrix(int max)
     {
-    return EffectQueueMatrix.setMax(max);
+    return EffectQueue.setMax(EffectTypes.MATRIX.ordinal(),max);
     }
   
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 /**
- * Sets the maximum number of Vertex effects that can be applied to a single DistortedBitmap at one time.
+ * Sets the maximum number of Vertex effects that can be applied to a single DistortedObject at one time.
  * This can fail if:
  * <ul>
  * <li>the value of 'max' is outside permitted range
@@ -464,12 +471,12 @@ public class Distorted
  */
   public static boolean setMaxVertex(int max)
     {
-    return EffectQueueVertex.setMax(max);
+    return EffectQueue.setMax(EffectTypes.VERTEX.ordinal(),max);
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 /**
- * Sets the maximum number of Fragment effects that can be applied to a single DistortedBitmap at one time.
+ * Sets the maximum number of Fragment effects that can be applied to a single DistortedObject at one time.
  * This can fail if:
  * <ul>
  * <li>the value of 'max' is outside permitted range
@@ -484,9 +491,23 @@ public class Distorted
  */
   public static boolean setMaxFragment(int max)
     {
-    return EffectQueueFragment.setMax(max);
+    return EffectQueue.setMax(EffectTypes.FRAGMENT.ordinal(),max);
     }
-    
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Sets the maximum number of Other effects that can be applied to a single DistortedObject at one time.
+ * This can fail if the value of 'max' is outside permitted range.
+ *
+ * @param max new maximum number of simultaneous Other Effects. Has to be a non-negative number not greater
+ *            than Byte.MAX_VALUE
+ * @return <code>true</code> if operation was successful, <code>false</code> otherwise.
+ */
+  public static boolean setMaxOther(int max)
+    {
+    return EffectQueue.setMax(EffectTypes.OTHER.ordinal(),max);
+    }
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 //end of file  
 }
diff --git a/src/main/java/org/distorted/library/EffectQueue.java b/src/main/java/org/distorted/library/EffectQueue.java
index 3ca5ac5..9adf5d3 100644
--- a/src/main/java/org/distorted/library/EffectQueue.java
+++ b/src/main/java/org/distorted/library/EffectQueue.java
@@ -23,12 +23,13 @@ abstract class EffectQueue
   
   protected static int[] mMax = new int[EffectTypes.LENGTH];
   protected int mMaxIndex;
-  protected static boolean mCreated;
- 
+
   protected Vector<EffectListener> mListeners =null;
   protected int mNumListeners=0;  // ==mListeners.length(), but we only create mListeners if the first one gets added
   protected long mBitmapID;
-  
+
+  private static boolean mCreated;
+
   static
     {
     reset();
@@ -75,6 +76,31 @@ abstract class EffectQueue
     return mNumEffects;  
     }
 
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Only max Byte.MAX_VALUE concurrent effects per DistortedObject.
+// If you want more, change type of the mNumEffects, mIDIndex and mFreeIndexes variables to shorts.
+
+  static boolean setMax(int index, int m)
+    {
+    if( (mCreated==false && !Distorted.isInitialized()) || m<=mMax[index] )
+      {
+      if( m<0              ) m = 0;
+      else if( m>Byte.MAX_VALUE ) m = Byte.MAX_VALUE;
+
+      mMax[index] = m;
+      return true;
+      }
+
+    return false;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  static int getMax(int index)
+    {
+    return mMax[index];
+    }
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   void addListener(EffectListener el)
diff --git a/src/main/java/org/distorted/library/EffectQueueFragment.java b/src/main/java/org/distorted/library/EffectQueueFragment.java
index c524c8d..20637d6 100644
--- a/src/main/java/org/distorted/library/EffectQueueFragment.java
+++ b/src/main/java/org/distorted/library/EffectQueueFragment.java
@@ -24,31 +24,6 @@ class EffectQueueFragment extends EffectQueue
       mBuf= new float[4*mMax[INDEX]];
       }
     }
-  
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// Only max Byte.MAX_VALUE concurrent effects per bitmap.
-// If you want more, change type of the mNumEffects, mIDIndex and mFreeIndexes variables to shorts.
-  
-  static boolean setMax(int m)
-    {
-    if( (mCreated==false && !Distorted.isInitialized()) || m<=mMax[INDEX] )
-      {
-           if( m<0              ) m = 0;
-      else if( m>Byte.MAX_VALUE ) m = Byte.MAX_VALUE;
-      
-      mMax[INDEX] = m;
-      return true;
-      }
-   
-    return false;
-    }
- 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  static int getMax()
-    {
-    return mMax[INDEX];
-    }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
diff --git a/src/main/java/org/distorted/library/EffectQueueMatrix.java b/src/main/java/org/distorted/library/EffectQueueMatrix.java
index 5dacdfd..eac17f1 100644
--- a/src/main/java/org/distorted/library/EffectQueueMatrix.java
+++ b/src/main/java/org/distorted/library/EffectQueueMatrix.java
@@ -53,31 +53,6 @@ class EffectQueueMatrix extends EffectQueue
     Matrix.multiplyMM(mMVPMatrix, 0, matrix, 0, mTmpMatrix, 0);  
     for(int j=0; j<16; j++) matrix[j] = mMVPMatrix[j];   
     }
-  
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// Only max Byte.MAX_VALUE concurrent effects per bitmap.
-// If you want more, change type of the mNumEffects, mIDIndex and mFreeIndexes variables to shorts.
-  
-  static boolean setMax(int m)
-    {
-    if( (mCreated==false && !Distorted.isInitialized()) || m<=mMax[INDEX] )
-      {
-           if( m<0              ) m = 0;
-      else if( m>Byte.MAX_VALUE ) m = Byte.MAX_VALUE;
-      
-      mMax[INDEX] = m;
-      return true;
-      }
-   
-    return false;
-    }
- 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  static int getMax()
-    {
-    return mMax[INDEX];
-    }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
diff --git a/src/main/java/org/distorted/library/EffectQueueOther.java b/src/main/java/org/distorted/library/EffectQueueOther.java
index 8b36ff4..f65e7b9 100644
--- a/src/main/java/org/distorted/library/EffectQueueOther.java
+++ b/src/main/java/org/distorted/library/EffectQueueOther.java
@@ -2,91 +2,31 @@ package org.distorted.library;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-import java.util.Vector;
-
-/**
- * Do NOT base this on EffectQueue - this is an entirely different animal than the first 3 EffectLists.
- * The Effects in here will be executed after all the shaders have been executed - thus there are no
- * uniforms to send, no real queues to maintain.
- * <p>
- * Only 2 effects here ATM:
- * - save current Surface to a PNG file
- * - save current animation to a .MP4 file
- *
- * In contrast to the other EffectLists, only one instance of each allowed at any given moment - thus
- * this is not even a real EffectQueue, it is named so only for consistency with the others.
- */
-public class EffectQueueOther
+class EffectQueueOther extends EffectQueue
   {
-  private Vector<EffectListener> mListeners =null;
-  private int mNumListeners=0;  // ==mListeners.length(), but we only create mListeners if the first one gets added
+  private static final int NUM_UNIFORMS = 0;
+  private static final int INDEX = EffectTypes.OTHER.ordinal();
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   public EffectQueueOther(DistortedObject obj)
     {
-
+    super(obj,NUM_UNIFORMS, INDEX );
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
+// There are no Uniforms, nothing to move
 
-  synchronized void send()
+  protected void moveEffect(int index)
     {
 
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  synchronized int abortAll()
-    {
-
-    return 0;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  void addListener(EffectListener el)
-    {
-    if( mListeners==null ) mListeners = new Vector<>(2,2);
-
-    mListeners.add(el);
-    mNumListeners++;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  void removeListener(EffectListener el)
-    {
-    if( mNumListeners>0 )
-      {
-      mListeners.remove(el);
-      mNumListeners--;
-      }
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  synchronized boolean removeByID(long id)
-    {
-    //....
-
-    return false;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  synchronized boolean removeByType(EffectNames effect)
+  synchronized void send()
     {
-    // ...
-
-    return false;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  protected boolean printByID(long id)
-    {
-    return false;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/java/org/distorted/library/EffectQueueVertex.java b/src/main/java/org/distorted/library/EffectQueueVertex.java
index f9987e3..f0d40c4 100644
--- a/src/main/java/org/distorted/library/EffectQueueVertex.java
+++ b/src/main/java/org/distorted/library/EffectQueueVertex.java
@@ -18,31 +18,6 @@ class EffectQueueVertex extends EffectQueue
     { 
     super(obj,NUM_UNIFORMS,INDEX);
     }
-  
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// Only max Byte.MAX_VALUE concurrent effects per bitmap.
-// If you want more, change type of the mNumEffects, mIDIndex and mFreeIndexes variables to shorts.
-  
-  static boolean setMax(int m)
-    {
-    if( (mCreated==false && !Distorted.isInitialized()) || m<=mMax[INDEX] )
-      {
-           if( m<0              ) m = 0;
-      else if( m>Byte.MAX_VALUE ) m = Byte.MAX_VALUE;
-      
-      mMax[INDEX] = m;
-      return true;
-      }
-   
-    return false;
-    }
- 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  static int getMax()
-    {
-    return mMax[INDEX];
-    }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
