commit 1beb6f13c4b8f1c3f859cfb36cecab11dd53f87c
Author: Leszek Koltunski <leszek@distoretedandroid.org>
Date:   Mon Nov 14 14:40:57 2016 +0000

    Encode more info in the EfectNames enum.

diff --git a/src/main/java/org/distorted/library/EffectNames.java b/src/main/java/org/distorted/library/EffectNames.java
index 970efaa..6b39a27 100644
--- a/src/main/java/org/distorted/library/EffectNames.java
+++ b/src/main/java/org/distorted/library/EffectNames.java
@@ -53,7 +53,7 @@ public enum EffectNames
    * <p>
    * Unity: angle==0
    */
-  ROTATE           ( EffectTypes.MATRIX  ,   new float[] {0.0f}           ),
+  ROTATE           ( EffectTypes.MATRIX  ,   new float[] {0.0f}           , 1, false ),
  /**
    * Rotate the whole Object around a center point (in quaternion notation).
    * <p>
@@ -61,7 +61,7 @@ public enum EffectNames
    * <p>
    * Unity: (quatX,quatY,quatZ) = (0,0,0)
    */
-  QUATERNION       ( EffectTypes.MATRIX  ,   new float[] {0.0f,0.0f,0.0f} ),
+  QUATERNION       ( EffectTypes.MATRIX  ,   new float[] {0.0f,0.0f,0.0f} , 4, false ),
  /**
    * Move the whole Object by a vector.
    * <p>
@@ -69,7 +69,7 @@ public enum EffectNames
    * <p>
    * Unity: (vectorX,vectorY,vectorZ) = (0,0,0)
    */
-  MOVE             ( EffectTypes.MATRIX  ,   new float[] {0.0f,0.0f,0.0f} ),
+  MOVE             ( EffectTypes.MATRIX  ,   new float[] {0.0f,0.0f,0.0f} , 3, false ),
  /**
    * Scale the whole Object independently in all 3 dimensions.
    * <p>
@@ -77,7 +77,7 @@ public enum EffectNames
    * <p>
    * Unity: (scaleX,scaleY,scaleZ) = (1,1,1)
    */
-  SCALE            ( EffectTypes.MATRIX  ,   new float[] {1.0f,1.0f,1.0f} ),
+  SCALE            ( EffectTypes.MATRIX  ,   new float[] {1.0f,1.0f,1.0f} , 3, false ),
  /**
    * Shear the whole Object in 3 dimensions around a center point.
    * <p>
@@ -85,7 +85,7 @@ public enum EffectNames
    * <p>
    * Unity:  (shearX,shearY,shearZ) = (0,0,0)
    */
-  SHEAR            ( EffectTypes.MATRIX  ,   new float[] {0.0f,0.0f,0.0f} ),
+  SHEAR            ( EffectTypes.MATRIX  ,   new float[] {0.0f,0.0f,0.0f} , 3, false ),
   // add new Matrix effects here...
 
  /////////////////////////////////////////////////////////////////////////////////
@@ -101,7 +101,7 @@ public enum EffectNames
    * <p>
    * Unity: (forceX,forceY,forceZ) = (0,0,0)
    */
-  DISTORT          ( EffectTypes.VERTEX  ,   new float[] {0.0f,0.0f,0.0f} ),
+  DISTORT          ( EffectTypes.VERTEX  ,   new float[] {0.0f,0.0f,0.0f} , 3, true ),
  /**
    * Deform the whole Object by applying a 2D vector of force to a center point.
    * <p>
@@ -111,7 +111,7 @@ public enum EffectNames
    * <p>
    * Unity: (forceX,forceY) = (0,0)
    */
-  DEFORM           ( EffectTypes.VERTEX  ,   new float[] {0.0f,0.0f}      ),
+  DEFORM           ( EffectTypes.VERTEX  ,   new float[] {0.0f,0.0f}      , 3, false ),
  /**
    * Pull (or push away) all points around a center point to (from) it.
    * <p>
@@ -121,7 +121,7 @@ public enum EffectNames
    * <p>
    * Unity: sinkFactor = 1
    */
-  SINK             ( EffectTypes.VERTEX  ,   new float[] {1.0f}           ),
+  SINK             ( EffectTypes.VERTEX  ,   new float[] {1.0f}           , 1, true ),
  /**
    * Smoothly rotate a limited area around a center point.
    * <p>
@@ -131,7 +131,7 @@ public enum EffectNames
    * <p>
    * Unity: swirlAngle = 0
    */
-  SWIRL            ( EffectTypes.VERTEX  ,   new float[] {0.0f}           ),
+  SWIRL            ( EffectTypes.VERTEX  ,   new float[] {0.0f}           , 1, true ),
   /**
    * Directional sinusoidal wave effect. The direction of the wave is given by the 'angle'
    * parameters. Details: {@link DistortedObject#wave(Data5D,Data2D)}
@@ -142,7 +142,7 @@ public enum EffectNames
    * <p>
    * Unity: amplitude  = 0
    */
-  WAVE             ( EffectTypes.VERTEX  ,   new float[] {0.0f}           ),
+  WAVE             ( EffectTypes.VERTEX  ,   new float[] {0.0f}           , 5, true ),
   // add new Vertex Effects here...
 
  /////////////////////////////////////////////////////////////////////////////////
@@ -155,7 +155,7 @@ public enum EffectNames
    * <p>
    * Unity: transparencyLevel = 1
    */
-  ALPHA            ( EffectTypes.FRAGMENT,   new float[] {1.0f}           ),
+  ALPHA            ( EffectTypes.FRAGMENT,   new float[] {1.0f}           , 1, true ),
  /**
    * Make a given Region (partially) transparent.
    * Effect smoothly fades towards the edges of the region.
@@ -163,7 +163,7 @@ public enum EffectNames
    * Uniforms: (transparencyLevel,UNUSED,UNUSED,UNUSED, regionX, regionY, regionRX, regionRY)
    * Unity: transparencyLevel = 1
    */
-  SMOOTH_ALPHA     ( EffectTypes.FRAGMENT,   new float[] {1.0f}           ),
+  SMOOTH_ALPHA     ( EffectTypes.FRAGMENT,   new float[] {1.0f}           , 1, true ),
  /**
    * Blend current color in the texture with a given color.
    * <p>
@@ -171,14 +171,14 @@ public enum EffectNames
    * <p>
    * Unity: blendLevel = 0
    */
-  CHROMA           ( EffectTypes.FRAGMENT,   new float[] {0.0f}           ),
+  CHROMA           ( EffectTypes.FRAGMENT,   new float[] {0.0f}           , 4, true ),
  /**
    * Smoothly blend current color in the texture with a given color.
    * <p>
    * Uniforms: (blendLevel,colorR,colorG,colorB, regionX, regionY, regionRX, regionRY)
    * Unity: blendLevel = 0
    */
-  SMOOTH_CHROMA    ( EffectTypes.FRAGMENT,   new float[] {0.0f}           ),
+  SMOOTH_CHROMA    ( EffectTypes.FRAGMENT,   new float[] {0.0f}           , 4, true ),
  /**
    * Change brightness level of a given Region.
    * <p>
@@ -186,7 +186,7 @@ public enum EffectNames
    * <p>
    * Unity: brightnessLevel = 1
    */
-  BRIGHTNESS       ( EffectTypes.FRAGMENT,   new float[] {1.0f}           ),
+  BRIGHTNESS       ( EffectTypes.FRAGMENT,   new float[] {1.0f}           , 1, true ),
  /**
    * Smoothly change brightness level of a given Region.
    * <p>
@@ -194,7 +194,7 @@ public enum EffectNames
    * <p>
    * Unity: brightnessLevel = 1
    */
-  SMOOTH_BRIGHTNESS( EffectTypes.FRAGMENT,   new float[] {1.0f}           ),
+  SMOOTH_BRIGHTNESS( EffectTypes.FRAGMENT,   new float[] {1.0f}           , 1, true ),
  /**
    * Change saturation level of a given Region.
    * <p>
@@ -202,7 +202,7 @@ public enum EffectNames
    * <p>
    * Unity: saturationLevel = 1
    */
-  SATURATION       ( EffectTypes.FRAGMENT,   new float[] {1.0f}           ),
+  SATURATION       ( EffectTypes.FRAGMENT,   new float[] {1.0f}           , 1, true ),
  /**
    * Smoothly change saturation level of a given Region.
    * <p>
@@ -210,7 +210,7 @@ public enum EffectNames
    * <p>
    * Unity: saturationLevel = 1
    */
-  SMOOTH_SATURATION( EffectTypes.FRAGMENT,   new float[] {1.0f}           ),
+  SMOOTH_SATURATION( EffectTypes.FRAGMENT,   new float[] {1.0f}           , 1, true ),
  /**
    * Change contrast level of a given Region.
    * <p>
@@ -218,7 +218,7 @@ public enum EffectNames
    * <p>
    * Unity: contrastLevel = 1
    */
-  CONTRAST         ( EffectTypes.FRAGMENT,   new float[] {1.0f}           ),
+  CONTRAST         ( EffectTypes.FRAGMENT,   new float[] {1.0f}           , 1, true ),
  /**
    * Smoothly change contrast level of a given Region.
    * <p>
@@ -226,7 +226,7 @@ public enum EffectNames
    * <p>
    * Unity: contrastLevel = 1
    */
-  SMOOTH_CONTRAST  ( EffectTypes.FRAGMENT,   new float[] {1.0f}           );
+  SMOOTH_CONTRAST  ( EffectTypes.FRAGMENT,   new float[] {1.0f}           , 1, true );
   // add new Fragment effects here...
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -235,9 +235,13 @@ public enum EffectNames
   
   private final EffectTypes type;
   private final float[] unity;
+  private final int dimension;
+  private final boolean supportsRegion;
   
   private static final float[] unities;
+  private static final int[] unityDimensions;
   private static final int[] dimensions;
+  private static final boolean[] supports;
   private static final EffectNames[] names;
 
   static
@@ -245,16 +249,20 @@ public enum EffectNames
     int len = values().length;
     int i=0;
     
-    dimensions = new int[len];
-    unities    = new float[MAXDIM*len];
-    names      = new EffectNames[len];
+    unityDimensions = new int[len];
+    dimensions      = new int[len];
+    supports        = new boolean[len];
+    unities         = new float[MAXDIM*len];
+    names           = new EffectNames[len];
 
     for(EffectNames name: EffectNames.values())
       {
-      dimensions[i] = (name.unity==null ? 0 : name.unity.length);
-      names[i]      = name;
+      unityDimensions[i] = (name.unity==null ? 0 : name.unity.length);
+      dimensions[i]      = name.dimension;
+      supports[i]        = name.supportsRegion;
+      names[i]           = name;
 
-      switch(dimensions[i])
+      switch(unityDimensions[i])
         {
         case 4: unities[MAXDIM*i+3] = name.unity[3];
         case 3: unities[MAXDIM*i+2] = name.unity[2];
@@ -269,10 +277,12 @@ public enum EffectNames
   
 ///////////////////////////////////////////////////////////////////////////////////////////////////
   
-  EffectNames(EffectTypes type, float[] unity)
+  EffectNames(EffectTypes type, float[] unity, int dimension, boolean supportsRegion)
     {
-    this.type = type;  
-    this.unity= unity;
+    this.type           = type;
+    this.unity          = unity;
+    this.dimension      = dimension;
+    this.supportsRegion = supportsRegion;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -293,7 +303,7 @@ public enum EffectNames
 
   static void fillWithUnities(int ordinal, float[] buffer, int index)
     {
-    switch(dimensions[ordinal])
+    switch(unityDimensions[ordinal])
       {
       case 0: break;
       case 1: buffer[index  ]=unities[MAXDIM*ordinal  ];
@@ -317,7 +327,7 @@ public enum EffectNames
   
   static boolean isUnity(int ordinal, float[] buffer, int index)
     {
-    switch(dimensions[ordinal])
+    switch(unityDimensions[ordinal])
       {
       case 0: return true;
       case 1: return buffer[index  ]==unities[MAXDIM*ordinal  ];
@@ -348,9 +358,20 @@ public enum EffectNames
     return type;
     }
 
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
 /**
  * Returns the dimension of an Effect (in other words, the number of interpolated values).
  * @return dimension of the Effect.
  */
   public int getDimension() { return dimensions[ordinal()]; }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Do we support being masked by a Region?
+ * @return true if the Effect supports being masked with a Region.
+ */
+  public boolean supportsRegion() { return supports[ordinal()]; }
+
   }
