commit d8b42d0279991cd3cd376fb3e8e12af3c2fe397c
Author: Leszek Koltunski <leszek@distoretedandroid.org>
Date:   Fri Jun 16 15:54:09 2017 +0100

    Change of API: move setting the EGL context back to the APP.

diff --git a/src/main/java/org/distorted/examples/save/SaveRenderer.java b/src/main/java/org/distorted/examples/save/SaveRenderer.java
index c668a57..0488ca4 100644
--- a/src/main/java/org/distorted/examples/save/SaveRenderer.java
+++ b/src/main/java/org/distorted/examples/save/SaveRenderer.java
@@ -154,13 +154,11 @@ class SaveRenderer implements GLSurfaceView.Renderer
    
   public void onDrawFrame(GL10 glUnused)
     {
-    long time = System.currentTimeMillis();
-
     if( isSaving )  // render to an offscreen buffer and read pixels
       {
       mMove.set(0,0,0);
       mScaleMain.set(1,1,1);
-      mOffscreen.render(time);
+      mOffscreen.render(System.currentTimeMillis());
       applyMatrixEffects(scrWidth,scrHeight);
 
       int fW =(int)(mScale*bmpWidth);
@@ -180,11 +178,17 @@ class SaveRenderer implements GLSurfaceView.Renderer
         {
         android.util.Log.e("Save", "Error trying to read from offscreen FBO, textureID="+textureID);
         }
-
       isSaving = false;
       }
 
-    mScreen.render(time);
+    // Quite subtle issue here. Since we share the DistortedEffects object between the mOffscreen
+    // and mScreen surfaces, we cannot render both of them in one go using the same time. That
+    // would make the second render, in this case mScreen's render, re-use the values of the
+    // Dynamics calculated the first time around and we don't want that (mOffscreen's scale and move
+    // are different! What would happen is the mScreen would be - one render when we are 'saving' -
+    // get drawn with different dimensions and on-screen position, i.e. we would see a flash.
+
+    mScreen.render(System.currentTimeMillis());
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
