commit fa9b649487e32b2e32dad94f401b83b805bdacac
Author: Leszek Koltunski <leszek@distoretedandroid.org>
Date:   Fri Jun 9 16:01:13 2017 +0100

    Convert the first few Apps to the new Effect API.

diff --git a/src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldEffectsManager.java b/src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldEffectsManager.java
index 8c6baee..560b875 100644
--- a/src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldEffectsManager.java
+++ b/src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldEffectsManager.java
@@ -21,6 +21,12 @@ package org.distorted.examples.aroundtheworld;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
+import org.distorted.library.effect.FragmentEffectChroma;
+import org.distorted.library.effect.FragmentEffectContrast;
+import org.distorted.library.effect.VertexEffectDistort;
+import org.distorted.library.effect.VertexEffectPinch;
+import org.distorted.library.effect.VertexEffectSink;
+import org.distorted.library.effect.VertexEffectSwirl;
 import org.distorted.library.main.DistortedEffects;
 import org.distorted.library.type.Dynamic1D;
 import org.distorted.library.type.Dynamic2D;
@@ -260,34 +266,34 @@ class AroundTheWorldEffectsManager
     setRace(mBlackness, mAsianness);
 
     // WHITENESS
-    effects.sink(wLipsDyn, wLipsCenter, wLipsRegion);
+    effects.apply( new VertexEffectSink(wLipsDyn, wLipsCenter, wLipsRegion) );
 
     // ASIANNESS
-    effects.distort(aLipsNoseDyn, aLipsNoseCenter, aLipsNoseRegion);
-    effects.pinch(aNoseBroaderDyn, aNoseBroaderCenter, aNoseBroaderRegion);
-    effects.distort(aNostrilsDyn, aNostrilsCenter, aNostrilsRegion);
-    effects.swirl(aLEyeDyn, aLEyeCenter, aEyesRegion);
-    effects.swirl(aREyeDyn, aREyeCenter, aEyesRegion);
-    effects.distort(aEyebrowsDyn, aEyebrowsCenter, aEyebrowsRegion);
+    effects.apply( new VertexEffectDistort(aLipsNoseDyn, aLipsNoseCenter, aLipsNoseRegion) );
+    effects.apply( new VertexEffectPinch(aNoseBroaderDyn, aNoseBroaderCenter, aNoseBroaderRegion) );
+    effects.apply( new VertexEffectDistort( aNostrilsDyn, aNostrilsCenter, aNostrilsRegion) );
+    effects.apply( new VertexEffectSwirl( aLEyeDyn, aLEyeCenter, aEyesRegion) );
+    effects.apply( new VertexEffectSwirl( aREyeDyn, aREyeCenter, aEyesRegion) );
+    effects.apply( new VertexEffectDistort( aEyebrowsDyn, aEyebrowsCenter, aEyebrowsRegion) );
 
-    effects.chroma(aChromaSkinDyn, aChromaSkin, aSkinColorRegion, false);
-    effects.chroma(aChromaEyesDyn, aChromaEyes, aLEyeColorRegion, true);
-    effects.chroma(aChromaEyesDyn, aChromaEyes, aREyeColorRegion, true);
+    effects.apply( new FragmentEffectChroma( aChromaSkinDyn, aChromaSkin, aSkinColorRegion, false) );
+    effects.apply( new FragmentEffectChroma( aChromaEyesDyn, aChromaEyes, aLEyeColorRegion, true ) );
+    effects.apply( new FragmentEffectChroma( aChromaEyesDyn, aChromaEyes, aREyeColorRegion, true ) );
 
     // BLACKNESS
-    effects.pinch(bFaceDyn, bFaceCenter, bFaceRegion);
-    effects.distort(bTipLowerDyn, bTipLowerCenter, bTipLowerRegion);
-    effects.pinch(bWholeNoseDyn, bWholeNoseCenter, bWholeNoseRegion);
-    effects.pinch(bNoseBroaderDyn, bNoseBroaderCenter, bNoseBroaderRegion);
-    effects.pinch(bLipsDyn, bLipsCenter, bLipsRegion);
-
-    effects.chroma(bChromaSkinDyn, bChromaSkin, bSkinColorRegion, false);
-    effects.chroma(bChromaEyesDyn, bChromaEyes, bLEyeColorRegion, true);
-    effects.chroma(bChromaEyesDyn, bChromaEyes, bREyeColorRegion, true);
-    effects.chroma(bChromaPupilDyn, bChromaPupil, bLPupilColorRegion, true);
-    effects.chroma(bChromaPupilDyn, bChromaPupil, bRPupilColorRegion, true);
-
-    effects.contrast(bContrastDyn);
+    effects.apply( new VertexEffectPinch( bFaceDyn, bFaceCenter, bFaceRegion ) );
+    effects.apply( new VertexEffectDistort( bTipLowerDyn, bTipLowerCenter, bTipLowerRegion ) );
+    effects.apply( new VertexEffectPinch( bWholeNoseDyn, bWholeNoseCenter, bWholeNoseRegion ) );
+    effects.apply( new VertexEffectPinch( bNoseBroaderDyn, bNoseBroaderCenter, bNoseBroaderRegion ) );
+    effects.apply( new VertexEffectPinch( bLipsDyn, bLipsCenter, bLipsRegion ) );
+
+    effects.apply( new FragmentEffectChroma( bChromaSkinDyn, bChromaSkin, bSkinColorRegion, false ) );
+    effects.apply( new FragmentEffectChroma( bChromaEyesDyn, bChromaEyes, bLEyeColorRegion, true  ) );
+    effects.apply( new FragmentEffectChroma( bChromaEyesDyn, bChromaEyes, bREyeColorRegion, true  ) );
+    effects.apply( new FragmentEffectChroma( bChromaPupilDyn, bChromaPupil, bLPupilColorRegion, true) );
+    effects.apply( new FragmentEffectChroma( bChromaPupilDyn, bChromaPupil, bRPupilColorRegion, true) );
+
+    effects.apply( new FragmentEffectContrast(bContrastDyn) );
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldRenderer.java b/src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldRenderer.java
index afe1b41..8cef2b8 100644
--- a/src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldRenderer.java
+++ b/src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldRenderer.java
@@ -24,13 +24,14 @@ import android.graphics.BitmapFactory;
 import android.opengl.GLSurfaceView;
 
 import org.distorted.examples.R;
+import org.distorted.library.effect.EffectName;
+import org.distorted.library.effect.MatrixEffectMove;
+import org.distorted.library.effect.MatrixEffectScale;
 import org.distorted.library.main.Distorted;
 import org.distorted.library.main.DistortedEffects;
 import org.distorted.library.main.DistortedScreen;
-import org.distorted.library.EffectNames;
 import org.distorted.library.main.MeshFlat;
 import org.distorted.library.main.DistortedTexture;
-import org.distorted.library.EffectTypes;
 import org.distorted.library.type.Static3D;
 
 import java.io.IOException;
@@ -51,6 +52,8 @@ class AroundTheWorldRenderer implements GLSurfaceView.Renderer
    private AroundTheWorldEffectsManager mManager;
    private int mObjWidth, mObjHeight;
 
+   private Static3D mMove, mScale;
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
    AroundTheWorldRenderer(GLSurfaceView view)
@@ -58,9 +61,15 @@ class AroundTheWorldRenderer implements GLSurfaceView.Renderer
       DistortedEffects.setMaxVertex(12);
       DistortedEffects.setMaxFragment(9);
 
+      mMove = new Static3D(0,0,0);
+      mScale= new Static3D(1,1,1);
+
       mView = view;
       mManager = new AroundTheWorldEffectsManager();
       mEffects = new DistortedEffects();
+      mEffects.apply(new MatrixEffectMove(mMove));
+      mEffects.apply(new MatrixEffectScale(mScale));
+
       mManager.apply(mEffects);
       mScreen = new DistortedScreen(mView);
       mScreen.glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
@@ -84,21 +93,19 @@ class AroundTheWorldRenderer implements GLSurfaceView.Renderer
     
    public void onSurfaceChanged(GL10 glUnused, int width, int height) 
       {
-      mEffects.abortEffects(EffectTypes.MATRIX);
-
       if( (float)mObjHeight/mObjWidth > (float)height/width )
         {
         int w = (height*mObjWidth)/mObjHeight;
         float factor = (float)height/mObjHeight;
-        mEffects.move( new Static3D((width-w)/2,0,0) );
-        mEffects.scale(factor);
+        mMove.set((width-w)/2,0,0);
+        mScale.set(factor,factor,factor);
         }
       else
         {
         int h = (width*mObjHeight)/mObjWidth;
         float factor = (float)width/mObjWidth;
-        mEffects.move( new Static3D(0,(height-h)/2,0) );
-        mEffects.scale(factor);
+        mMove.set(0,(height-h)/2,0);
+        mScale.set(factor,factor,factor);
         }
 
       mScreen.resize(width,height);
@@ -135,13 +142,13 @@ class AroundTheWorldRenderer implements GLSurfaceView.Renderer
       mScreen.detachAll();
       mScreen.attach(mTexture, mEffects, mMesh);
 
-      DistortedEffects.enableEffect(EffectNames.DISTORT);
-      DistortedEffects.enableEffect(EffectNames.SINK);
-      DistortedEffects.enableEffect(EffectNames.PINCH);
-      DistortedEffects.enableEffect(EffectNames.SWIRL);
-      DistortedEffects.enableEffect(EffectNames.CHROMA);
-      DistortedEffects.enableEffect(EffectNames.SMOOTH_CHROMA);
-      DistortedEffects.enableEffect(EffectNames.CONTRAST);
+      DistortedEffects.enableEffect(EffectName.DISTORT);
+      DistortedEffects.enableEffect(EffectName.SINK);
+      DistortedEffects.enableEffect(EffectName.PINCH);
+      DistortedEffects.enableEffect(EffectName.SWIRL);
+      DistortedEffects.enableEffect(EffectName.CHROMA);
+      DistortedEffects.enableEffect(EffectName.SMOOTH_CHROMA);
+      DistortedEffects.enableEffect(EffectName.CONTRAST);
 
       try
         {
diff --git a/src/main/java/org/distorted/examples/bean/BeanRenderer.java b/src/main/java/org/distorted/examples/bean/BeanRenderer.java
index f6fed94..021a5a9 100644
--- a/src/main/java/org/distorted/examples/bean/BeanRenderer.java
+++ b/src/main/java/org/distorted/examples/bean/BeanRenderer.java
@@ -27,10 +27,12 @@ import javax.microedition.khronos.opengles.GL10;
 
 import org.distorted.examples.R;
 
+import org.distorted.library.effect.EffectName;
+import org.distorted.library.effect.MatrixEffectMove;
+import org.distorted.library.effect.MatrixEffectScale;
+import org.distorted.library.effect.VertexEffectDistort;
 import org.distorted.library.main.DistortedEffects;
 import org.distorted.library.main.DistortedScreen;
-import org.distorted.library.EffectNames;
-import org.distorted.library.EffectTypes;
 import org.distorted.library.main.Distorted;
 import org.distorted.library.main.DistortedTexture;
 import org.distorted.library.main.MeshFlat;
@@ -51,8 +53,9 @@ class BeanRenderer implements GLSurfaceView.Renderer
    private DistortedScreen mScreen;
    private DistortedTexture mTexture;
    private MeshFlat mMesh;
-   private int bmpHeight, bmpWidth;
-    
+   private int mObjHeight, mObjWidth;
+   private Static3D mMove, mScale;
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
    BeanRenderer(GLSurfaceView v)
@@ -85,84 +88,85 @@ class BeanRenderer implements GLSurfaceView.Renderer
       dRight.add(p1);
       dRight.add(p1);
 
+      mMove = new Static3D(0,0,0);
+      mScale= new Static3D(1,1,1);
+
       mEffects = new DistortedEffects();
-      mEffects.distort(dLeft , pLeft , rLeft );
-      mEffects.distort(dRight, pRight, rRight);
+      mEffects.apply( new VertexEffectDistort(dLeft , pLeft , rLeft) );
+      mEffects.apply( new VertexEffectDistort(dRight, pRight, rRight));
+      mEffects.apply(new MatrixEffectMove(mMove));
+      mEffects.apply(new MatrixEffectScale(mScale));
 
       mScreen = new DistortedScreen(mView);
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
    
-    public void onDrawFrame(GL10 glUnused) 
+   public void onDrawFrame(GL10 glUnused)
       {
       mScreen.render( System.currentTimeMillis() );
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
     
-    public void onSurfaceChanged(GL10 glUnused, int width, int height) 
-      { 
-      mEffects.abortEffects(EffectTypes.MATRIX);
-         
-      if( (float)bmpHeight/bmpWidth > (float)height/width )
+   public void onSurfaceChanged(GL10 glUnused, int width, int height)
+     {
+     if( (float)mObjHeight/mObjWidth > (float)height/width )
         {
-        int w = (height*bmpWidth)/bmpHeight;
-        float factor = (float)height/bmpHeight;
-
-        mEffects.move( new Static3D((width-w)/2,0,0) );
-        mEffects.scale(factor);
+        int w = (height*mObjWidth)/mObjHeight;
+        float factor = (float)height/mObjHeight;
+        mMove.set((width-w)/2,0,0);
+        mScale.set(factor,factor,factor);
         }
       else
         {
-        int h = (width*bmpHeight)/bmpWidth;
-        float factor = (float)width/bmpWidth;
-
-        mEffects.move( new Static3D(0,(height-h)/2,0) );
-        mEffects.scale(factor);
+        int h = (width*mObjHeight)/mObjWidth;
+        float factor = (float)width/mObjWidth;
+        mMove.set(0,(height-h)/2,0);
+        mScale.set(factor,factor,factor);
         }
-      
-      mScreen.resize(width, height);
-      }
+
+      mScreen.resize(width,height);
+     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
     
-    public void onSurfaceCreated(GL10 glUnused, EGLConfig config) 
-      {
-      InputStream is = mView.getContext().getResources().openRawResource(R.raw.bean);
-      Bitmap bitmap;
+   public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
+     {
+     InputStream is = mView.getContext().getResources().openRawResource(R.raw.bean);
+     Bitmap bitmap;
         
-      try 
-        {
-        bitmap = BitmapFactory.decodeStream(is);
-        } 
-      finally 
-        {
-        try 
-          {
-          is.close();
-          } 
-        catch(IOException e) { }
-        }  
+     try
+       {
+       bitmap = BitmapFactory.decodeStream(is);
+       }
+     finally
+       {
+       try
+         {
+         is.close();
+         }
+       catch(IOException e) { }
+       }
       
-      bmpHeight = bitmap.getHeight();
-      bmpWidth  = bitmap.getWidth();
+     mObjHeight = bitmap.getHeight();
+     mObjWidth  = bitmap.getWidth();
       
-      if( mTexture==null ) mTexture = new DistortedTexture(bmpWidth,bmpHeight);
-      mTexture.setTexture(bitmap);
-      if( mMesh==null ) mMesh = new MeshFlat(25,25*bmpHeight/bmpWidth);
-      mScreen.detachAll();
-      mScreen.attach(mTexture,mEffects,mMesh);
-
-      DistortedEffects.enableEffect(EffectNames.DISTORT);
-
-      try
-        {
-        Distorted.onCreate(mView.getContext());
-        }
-      catch(Exception ex)
-        {
-        android.util.Log.e("Bean", ex.getMessage() );
-        }
-      }
+     if( mTexture==null ) mTexture = new DistortedTexture(mObjWidth,mObjHeight);
+     mTexture.setTexture(bitmap);
+     if( mMesh==null ) mMesh = new MeshFlat(25,25*mObjHeight/mObjWidth);
+     mScreen.detachAll();
+     mScreen.attach(mTexture,mEffects,mMesh);
+
+     DistortedEffects.enableEffect(EffectName.DISTORT);
+
+     try
+       {
+       Distorted.onCreate(mView.getContext());
+       }
+     catch(Exception ex)
+       {
+       android.util.Log.e("Bean", ex.getMessage() );
+       }
+     }
 }
diff --git a/src/main/java/org/distorted/examples/blur/BlurRenderer.java b/src/main/java/org/distorted/examples/blur/BlurRenderer.java
index 15fc79c..fd73b4d 100644
--- a/src/main/java/org/distorted/examples/blur/BlurRenderer.java
+++ b/src/main/java/org/distorted/examples/blur/BlurRenderer.java
@@ -24,14 +24,16 @@ import android.graphics.BitmapFactory;
 import android.opengl.GLSurfaceView;
 
 import org.distorted.examples.R;
+import org.distorted.library.effect.EffectName;
+import org.distorted.library.effect.MatrixEffectMove;
+import org.distorted.library.effect.MatrixEffectScale;
+import org.distorted.library.effect.PostprocessEffectBlur;
 import org.distorted.library.main.Distorted;
 import org.distorted.library.main.DistortedEffects;
 import org.distorted.library.main.DistortedEffectsPostprocess;
 import org.distorted.library.main.DistortedNode;
 import org.distorted.library.main.DistortedScreen;
 import org.distorted.library.main.DistortedTexture;
-import org.distorted.library.EffectNames;
-import org.distorted.library.EffectTypes;
 import org.distorted.library.main.MeshFlat;
 import org.distorted.library.type.Dynamic1D;
 import org.distorted.library.type.Static1D;
@@ -54,7 +56,8 @@ class BlurRenderer implements GLSurfaceView.Renderer
     private DistortedScreen mScreen;
     private MeshFlat mMesh;
     private Static1D mRadiusSta;
-    private int bmpHeight, bmpWidth;
+    private int mObjHeight, mObjWidth;
+    private Static3D mMove, mScale;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -70,7 +73,12 @@ class BlurRenderer implements GLSurfaceView.Renderer
       Dynamic1D radiusDyn = new Dynamic1D();
       radiusDyn.add(mRadiusSta);
 
-      mPostEffects.blur(radiusDyn);
+      mMove = new Static3D(0,0,0);
+      mScale= new Static3D(1,1,1);
+
+      mPostEffects.apply( new PostprocessEffectBlur(radiusDyn) );
+      mEffects.apply(new MatrixEffectMove(mMove));
+      mEffects.apply(new MatrixEffectScale(mScale));
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -91,70 +99,66 @@ class BlurRenderer implements GLSurfaceView.Renderer
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
     
-    public void onSurfaceChanged(GL10 glUnused, int width, int height) 
-      { 
-      mEffects.abortEffects(EffectTypes.MATRIX);
-      
-      if( (float)bmpHeight/bmpWidth > (float)height/width )
-        {
-        int w = (height*bmpWidth)/bmpHeight;
-        float factor = (float)height/bmpHeight;
-
-        mEffects.move( new Static3D((width-w)/2,0,0) );
-        mEffects.scale(factor);
-        }
-      else
-        {
-        int h = (width*bmpHeight)/bmpWidth;
-        float factor = (float)width/bmpWidth;
-
-        mEffects.move( new Static3D(0,(height-h)/2,0) );
-        mEffects.scale(factor);
-        }
-      
-      mScreen.resize(width, height);
-      }
+   public void onSurfaceChanged(GL10 glUnused, int width, int height)
+     {
+     if( (float)mObjHeight/mObjWidth > (float)height/width )
+       {
+       int w = (height*mObjWidth)/mObjHeight;
+       float factor = (float)height/mObjHeight;
+       mMove.set((width-w)/2,0,0);
+       mScale.set(factor,factor,factor);
+       }
+     else
+       {
+       int h = (width*mObjHeight)/mObjWidth;
+       float factor = (float)width/mObjWidth;
+       mMove.set(0,(height-h)/2,0);
+       mScale.set(factor,factor,factor);
+       }
+
+     mScreen.resize(width,height);
+     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
     
-    public void onSurfaceCreated(GL10 glUnused, EGLConfig config) 
-      {
-      InputStream is = mView.getContext().getResources().openRawResource(R.raw.dog);
-      Bitmap bitmap;
+   public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
+     {
+     InputStream is = mView.getContext().getResources().openRawResource(R.raw.dog);
+     Bitmap bitmap;
         
-      try 
-        {
-        bitmap = BitmapFactory.decodeStream(is);
-        } 
-      finally 
-        {
-        try 
-          {
-          is.close();
-          } 
-        catch(IOException e) { }
-        }  
+     try
+       {
+       bitmap = BitmapFactory.decodeStream(is);
+       }
+     finally
+       {
+       try
+         {
+         is.close();
+         }
+       catch(IOException e) { }
+       }
       
-      bmpHeight = bitmap.getHeight();
-      bmpWidth  = bitmap.getWidth();
-
-      if( mTexture==null ) mTexture = new DistortedTexture(bmpWidth,bmpHeight);
-      mTexture.setTexture(bitmap);
-
-      mScreen.detachAll();
-      DistortedNode node = new DistortedNode(mTexture,mEffects,mMesh);
-      node.setPostprocessEffects(mPostEffects);
-      mScreen.attach(node);
-
-      DistortedEffects.enableEffect(EffectNames.BLUR);
-
-      try
-        {
-        Distorted.onCreate(mView.getContext());
-        }
-      catch(Exception ex)
-        {
-        android.util.Log.e("Blur", ex.getMessage() );
-        }
-      }
+     mObjHeight = bitmap.getHeight();
+     mObjWidth  = bitmap.getWidth();
+
+     if( mTexture==null ) mTexture = new DistortedTexture(mObjWidth,mObjHeight);
+     mTexture.setTexture(bitmap);
+
+     mScreen.detachAll();
+     DistortedNode node = new DistortedNode(mTexture,mEffects,mMesh);
+     node.setPostprocessEffects(mPostEffects);
+     mScreen.attach(node);
+
+     DistortedEffects.enableEffect(EffectName.BLUR);
+
+     try
+       {
+       Distorted.onCreate(mView.getContext());
+       }
+     catch(Exception ex)
+       {
+       android.util.Log.e("Blur", ex.getMessage() );
+       }
+     }
 }
diff --git a/src/main/java/org/distorted/examples/catanddog/CatAndDogRenderer.java b/src/main/java/org/distorted/examples/catanddog/CatAndDogRenderer.java
index 7b1c8ab..3ca2a53 100644
--- a/src/main/java/org/distorted/examples/catanddog/CatAndDogRenderer.java
+++ b/src/main/java/org/distorted/examples/catanddog/CatAndDogRenderer.java
@@ -26,13 +26,17 @@ import javax.microedition.khronos.egl.EGLConfig;
 import javax.microedition.khronos.opengles.GL10;
 
 import org.distorted.examples.R;
+import org.distorted.library.effect.EffectName;
+import org.distorted.library.effect.FragmentEffectAlpha;
+import org.distorted.library.effect.FragmentEffectChroma;
+import org.distorted.library.effect.MatrixEffectMove;
+import org.distorted.library.effect.MatrixEffectRotate;
+import org.distorted.library.effect.MatrixEffectScale;
 import org.distorted.library.main.Distorted;
 import org.distorted.library.main.DistortedEffects;
 import org.distorted.library.main.DistortedScreen;
 import org.distorted.library.main.DistortedTexture;
-import org.distorted.library.EffectNames;
 import org.distorted.library.main.MeshFlat;
-import org.distorted.library.EffectTypes;
 import org.distorted.library.type.Dynamic1D;
 import org.distorted.library.type.Dynamic3D;
 import org.distorted.library.type.Static1D;
@@ -47,12 +51,15 @@ import android.opengl.GLSurfaceView;
 
 class CatAndDogRenderer implements GLSurfaceView.Renderer
 {
+    private static final int DURATION = 10000;  // 10 seconds
+
     private GLSurfaceView mView;
     private DistortedEffects mEffects;
     private MeshFlat mMesh;
     private DistortedTexture mTexture;
     private DistortedScreen mScreen;
-    private int bmpHeight, bmpWidth;
+    private int mObjHeight, mObjWidth;
+    private Static3D mMove, mRotate;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -63,24 +70,47 @@ class CatAndDogRenderer implements GLSurfaceView.Renderer
       mMesh = new MeshFlat(1,1);  // no vertex effects, grid can be a (1x1) quad.
       mEffects = new DistortedEffects();
 
+      Dynamic3D move   = new Dynamic3D(DURATION,0.0f);
+      mRotate = new Static3D(0,0,0);
+      mMove   = new Static3D(0,0,0);
+      Static3D move2  = new Static3D(0,0,0);
+
+      move.add(mMove);
+      move.add(move2);
+
       Static4D chromaRegion= new Static4D( 530, 200,100,100);
       Static4D alphaRegion = new Static4D( 230, 200,100,100);
 
       Dynamic1D chromaDyn = new Dynamic1D(3000,0.0f);
       chromaDyn.add(new Static1D(1));
       chromaDyn.add(new Static1D(0));
-
-      mEffects.chroma(chromaDyn, new Static3D(1,0,0), chromaRegion ,true);
-
       Dynamic1D alphaDyn = new Dynamic1D(3000,0.0f);
       alphaDyn.add(new Static1D(1));
       alphaDyn.add(new Static1D(0));
+      Dynamic3D diScale = new Dynamic3D(DURATION,0.0f);
+      diScale.add(new Static3D(1,1,1));
+      diScale.add(new Static3D(0.33f,0.33f,1));
+      Dynamic1D diRotate = new Dynamic1D(DURATION,0.0f);
+      diRotate.add(new Static1D(  0));
+      diRotate.add(new Static1D(360));
 
-      mEffects.alpha( alphaDyn, alphaRegion, false );
+      mEffects.apply( new FragmentEffectChroma( chromaDyn, new Static3D(1,0,0), chromaRegion ,true) );
+      mEffects.apply( new FragmentEffectAlpha(alphaDyn, alphaRegion, false) );
+      mEffects.apply( new MatrixEffectMove(mMove));
+      mEffects.apply( new MatrixEffectScale(diScale));
+      mEffects.apply( new MatrixEffectRotate( diRotate, new Static3D(0,0,1), mRotate) );
 
       mScreen = new DistortedScreen(mView);
       }
 
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    public void onSurfaceChanged(GL10 glUnused, int width, int height)
+      {
+      mMove.set(width-mObjWidth,height-mObjHeight,0);
+      mRotate.set(mObjWidth/2,mObjHeight/2,0);
+      mScreen.resize(width, height);
+      }
 ///////////////////////////////////////////////////////////////////////////////////////////////////
    
     public void onDrawFrame(GL10 glUnused) 
@@ -108,17 +138,17 @@ class CatAndDogRenderer implements GLSurfaceView.Renderer
         catch(IOException e) { }
         }  
       
-      bmpHeight = bitmap.getHeight();
-      bmpWidth  = bitmap.getWidth();
+      mObjHeight = bitmap.getHeight();
+      mObjWidth  = bitmap.getWidth();
 
-      if( mTexture==null ) mTexture = new DistortedTexture(bmpWidth,bmpHeight);
+      if( mTexture==null ) mTexture = new DistortedTexture(mObjWidth,mObjHeight);
       mTexture.setTexture(bitmap);
 
       mScreen.detachAll();
       mScreen.attach(mTexture,mEffects,mMesh);
 
-      DistortedEffects.enableEffect(EffectNames.SMOOTH_CHROMA);
-      DistortedEffects.enableEffect(EffectNames.ALPHA);
+      DistortedEffects.enableEffect(EffectName.SMOOTH_CHROMA);
+      DistortedEffects.enableEffect(EffectName.ALPHA);
 
       try
         {
@@ -129,31 +159,4 @@ class CatAndDogRenderer implements GLSurfaceView.Renderer
         android.util.Log.e("Renderer", ex.getMessage() );
         }
       }
-    
-///////////////////////////////////////////////////////////////////////////////////////////////////
-    
-    public void onSurfaceChanged(GL10 glUnused, int width, int height) 
-      {
-      int duration = 10000;   // 10 seconds
-      
-      Dynamic3D diMove = new Dynamic3D(duration,0.0f);
-      diMove.add(new Static3D(width-bmpWidth,height-bmpHeight,0));
-      diMove.add(new Static3D(0,0,0));
-      
-      Dynamic3D diScale = new Dynamic3D(duration,0.0f);
-      diScale.add(new Static3D(1,1,1));
-      diScale.add(new Static3D(0.33f,0.33f,1));
-      
-      Dynamic1D diRotate = new Dynamic1D(duration,0.0f);
-      diRotate.add(new Static1D(  0));
-      diRotate.add(new Static1D(360));
-      
-      mEffects.abortEffects(EffectTypes.MATRIX);
-
-      mEffects.move(diMove);
-      mEffects.scale(diScale);
-      mEffects.rotate( diRotate, new Static3D(0,0,1), new Static3D(bmpWidth/2,bmpHeight/2,0) );
-
-      mScreen.resize(width, height);
-      }
 }
