commit dd00d05113aece0f0f39d0ee8d004bf1bcbf8f04
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Wed Oct 6 23:25:51 2021 +0200

    Relax objectlib's requirements: it can be displayed not only on top of a DistortedScreen, but any DistortedFramebuffer.

diff --git a/src/main/java/org/distorted/objectlib/automator/ObjectAutomator.java b/src/main/java/org/distorted/objectlib/automator/ObjectAutomator.java
index 19bc0f6c..020fdd03 100644
--- a/src/main/java/org/distorted/objectlib/automator/ObjectAutomator.java
+++ b/src/main/java/org/distorted/objectlib/automator/ObjectAutomator.java
@@ -23,8 +23,8 @@ import java.lang.ref.WeakReference;
 
 import android.app.Activity;
 
+import org.distorted.library.main.DistortedFramebuffer;
 import org.distorted.library.main.DistortedNode;
-import org.distorted.library.main.DistortedScreen;
 import org.distorted.library.message.EffectListener;
 import org.distorted.library.type.Static4D;
 
@@ -48,10 +48,10 @@ public class ObjectAutomator implements EffectListener
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  DistortedScreen getScreen()
+  DistortedFramebuffer getFramebuffer()
     {
     ObjectLibInterface inter = mObjectControl.getInterface();
-    return inter.getScreen();
+    return inter.getFramebuffer();
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -79,12 +79,12 @@ public class ObjectAutomator implements EffectListener
 
   private void addWholeObjects()
     {
-    DistortedScreen screen = getScreen();
+    DistortedFramebuffer frame = getFramebuffer();
     DistortedNode[] nodes = mWhole.getNodes();
 
-    if( screen!=null && nodes!=null )
+    if( frame!=null && nodes!=null )
       {
-      for (DistortedNode node : nodes) screen.attach(node);
+      for (DistortedNode node : nodes) frame.attach(node);
       }
     }
 
@@ -92,12 +92,12 @@ public class ObjectAutomator implements EffectListener
 
   private void removeWholeObjects()
     {
-    DistortedScreen screen = getScreen();
+    DistortedFramebuffer frame = getFramebuffer();
     DistortedNode[] nodes = mWhole.returnNodes();
 
-    if( screen!=null && nodes!=null )
+    if( frame!=null && nodes!=null )
       {
-      for (DistortedNode node : nodes) screen.detach(node);
+      for (DistortedNode node : nodes) frame.detach(node);
       }
     }
 
@@ -105,12 +105,12 @@ public class ObjectAutomator implements EffectListener
 
   private void addRotateObjects()
     {
-    DistortedScreen screen = getScreen();
+    DistortedFramebuffer frame = getFramebuffer();
     DistortedNode[] screenNodes = mRotate.getScreenNodes();
 
-    if( screen!=null && screenNodes!=null )
+    if( frame!=null && screenNodes!=null )
       {
-      for (DistortedNode node : screenNodes) screen.attach(node);
+      for (DistortedNode node : screenNodes) frame.attach(node);
       }
 
     DistortedNode object = mObjectControl.getObject();
@@ -126,12 +126,12 @@ public class ObjectAutomator implements EffectListener
 
   private void removeRotateObjects()
     {
-    DistortedScreen screen = getScreen();
+    DistortedFramebuffer frame = getFramebuffer();
     DistortedNode[] screenNodes = mRotate.returnScreenNodes();
 
-    if( screen!=null && screenNodes!=null )
+    if( frame!=null && screenNodes!=null )
       {
-      for (DistortedNode node : screenNodes) screen.detach(node);
+      for (DistortedNode node : screenNodes) frame.detach(node);
       }
 
     DistortedNode object = mObjectControl.getObject();
diff --git a/src/main/java/org/distorted/objectlib/automator/ObjectAutomatorRotate.java b/src/main/java/org/distorted/objectlib/automator/ObjectAutomatorRotate.java
index 1aceceb7..f706326c 100644
--- a/src/main/java/org/distorted/objectlib/automator/ObjectAutomatorRotate.java
+++ b/src/main/java/org/distorted/objectlib/automator/ObjectAutomatorRotate.java
@@ -29,8 +29,8 @@ import android.graphics.BitmapFactory;
 import org.distorted.library.effect.MatrixEffectQuaternion;
 import org.distorted.library.effect.MatrixEffectScale;
 import org.distorted.library.main.DistortedEffects;
+import org.distorted.library.main.DistortedFramebuffer;
 import org.distorted.library.main.DistortedNode;
-import org.distorted.library.main.DistortedScreen;
 import org.distorted.library.main.DistortedTexture;
 import org.distorted.library.mesh.MeshQuad;
 import org.distorted.library.message.EffectListener;
@@ -194,8 +194,8 @@ android.util.Log.e("D", "set: "+d.get0()+" "+d.get1()+" "+d.get2()+" "+d.get3()
     mScreenEffects   = new DistortedEffects[NUM_SCREEN];
     mScreenEffects[0]= new DistortedEffects();
 
-    DistortedScreen screen = mControl.getScreen();
-    int wid = screen.getWidth();
+    DistortedFramebuffer frame = mControl.getFramebuffer();
+    int wid = frame.getWidth();
 
     Static3D scaleStart= new Static3D(1,1,1);
     Static3D scaleEnd  = new Static3D(wid,wid,wid);
@@ -243,8 +243,8 @@ android.util.Log.e("D", "ax: "+ax.get0()+" "+ax.get1()+" "+ax.get2());
     mQuaternion = new MatrixEffectQuaternion(mDynamic4, center);
     mCubeEffectID = mQuaternion.getID();
 
-    DistortedScreen screen = mControl.getScreen();
-    int wid = screen.getWidth();
+    DistortedFramebuffer frame = mControl.getFramebuffer();
+    int wid = frame.getWidth();
     Static3D scaleFactor = new Static3D(wid,wid*0.1f,10);
     MatrixEffectScale scale = new MatrixEffectScale(scaleFactor);
     MatrixEffectQuaternion quat = new MatrixEffectQuaternion(INIT_QUAT,center);
diff --git a/src/main/java/org/distorted/objectlib/automator/ObjectAutomatorWhole.java b/src/main/java/org/distorted/objectlib/automator/ObjectAutomatorWhole.java
index 3aa17cb0..3cc20f34 100644
--- a/src/main/java/org/distorted/objectlib/automator/ObjectAutomatorWhole.java
+++ b/src/main/java/org/distorted/objectlib/automator/ObjectAutomatorWhole.java
@@ -29,8 +29,8 @@ import android.graphics.BitmapFactory;
 import org.distorted.library.effect.MatrixEffectMove;
 import org.distorted.library.effect.MatrixEffectScale;
 import org.distorted.library.main.DistortedEffects;
+import org.distorted.library.main.DistortedFramebuffer;
 import org.distorted.library.main.DistortedNode;
-import org.distorted.library.main.DistortedScreen;
 import org.distorted.library.main.DistortedTexture;
 import org.distorted.library.mesh.MeshQuad;
 import org.distorted.library.type.Dynamic;
@@ -801,9 +801,9 @@ class ObjectAutomatorWhole
     mEffects[3].apply(scaleHand2);
     mEffects[3].apply(moveHand2);
 
-    DistortedScreen screen = mControl.getScreen();
-    mWidth = screen.getWidth();
-    mHeight= screen.getHeight();
+    DistortedFramebuffer frame = mControl.getFramebuffer();
+    mWidth = frame.getWidth();
+    mHeight= frame.getHeight();
 
     X0   = mWidth*0.65f;
     X1   = mWidth*0.50f;
diff --git a/src/main/java/org/distorted/objectlib/effects/BaseEffect.java b/src/main/java/org/distorted/objectlib/effects/BaseEffect.java
index f42366ce..c4169791 100644
--- a/src/main/java/org/distorted/objectlib/effects/BaseEffect.java
+++ b/src/main/java/org/distorted/objectlib/effects/BaseEffect.java
@@ -23,7 +23,7 @@ import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import android.content.SharedPreferences;
 
-import org.distorted.library.main.DistortedScreen;
+import org.distorted.library.main.DistortedFramebuffer;
 
 import org.distorted.objectlib.effects.scramble.ScrambleEffect;
 import org.distorted.objectlib.effects.objectchange.ObjectChangeEffect;
@@ -198,17 +198,17 @@ public class BaseEffect
 
   ////////////////////////////////////////////////////////////////////////////////
 
-    public long startEffect(DistortedScreen screen, ObjectPreRender pre) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
+    public long startEffect(DistortedFramebuffer frame, ObjectPreRender pre) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
       {
       Method method1 = mClass.getDeclaredMethod("create", int.class);
 
       Object value1 = method1.invoke(null,mCurrentType);
       BaseEffect baseEffect = (BaseEffect)value1;
 
-      Method method2 = mClass.getDeclaredMethod("start", int.class, DistortedScreen.class, ObjectPreRender.class);
+      Method method2 = mClass.getDeclaredMethod("start", int.class, DistortedFramebuffer.class, ObjectPreRender.class);
 
       Integer translated = translatePos(mCurrentPos)+1;
-      Object value2 = method2.invoke(baseEffect,translated,screen,pre);
+      Object value2 = method2.invoke(baseEffect,translated,frame,pre);
       return (Long)value2;
       }
 
diff --git a/src/main/java/org/distorted/objectlib/effects/objectchange/ObjectChangeEffect.java b/src/main/java/org/distorted/objectlib/effects/objectchange/ObjectChangeEffect.java
index b9ac16f7..e8a07a10 100644
--- a/src/main/java/org/distorted/objectlib/effects/objectchange/ObjectChangeEffect.java
+++ b/src/main/java/org/distorted/objectlib/effects/objectchange/ObjectChangeEffect.java
@@ -23,7 +23,7 @@ import java.lang.reflect.Method;
 
 import org.distorted.library.effect.Effect;
 import org.distorted.library.main.DistortedEffects;
-import org.distorted.library.main.DistortedScreen;
+import org.distorted.library.main.DistortedFramebuffer;
 import org.distorted.library.message.EffectListener;
 
 import org.distorted.objectlib.main.ObjectPreRender;
@@ -75,7 +75,7 @@ public abstract class ObjectChangeEffect extends BaseEffect implements EffectLis
 
   ObjectPreRender mPre;
   TwistyObject[] mObject;
-  DistortedScreen mScreen;
+  DistortedFramebuffer mFrame;
   Effect[][] mCubeEffects;
   int[][] mCubeEffectPosition;
   Effect[][] mNodeEffects;
@@ -143,7 +143,7 @@ public abstract class ObjectChangeEffect extends BaseEffect implements EffectLis
         case 0: mPhaseActive[1] = true;
                 mEffectFinished[1] = createEffectsPhase1(mDuration);
                 assignEffects(1);
-                mScreen.attach(mObject[1]);
+                mFrame.attach(mObject[1]);
                 break;
         case 1: mPre.effectFinished(FAKE_EFFECT_ID);
                 break;
@@ -154,7 +154,7 @@ public abstract class ObjectChangeEffect extends BaseEffect implements EffectLis
       switch(phase)
         {
         case 0: mPhaseActive[0] = false;
-                mScreen.detach(mObject[0]);
+                mFrame.detach(mObject[0]);
                 break;
         case 1: mPhaseActive[1] = false;
                 break;
@@ -225,9 +225,9 @@ public abstract class ObjectChangeEffect extends BaseEffect implements EffectLis
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   @SuppressWarnings("unused")
-  public long start(int duration, DistortedScreen screen, ObjectPreRender pre)
+  public long start(int duration, DistortedFramebuffer frame, ObjectPreRender pre)
     {
-    mScreen    = screen;
+    mFrame     = frame;
     mObject[0] = pre.getOldObject();
     mObject[1] = pre.getObject();
     mPre       = pre;
@@ -244,7 +244,7 @@ public abstract class ObjectChangeEffect extends BaseEffect implements EffectLis
       mPhaseActive[1] = true;
       mEffectFinished[1] = createEffectsPhase1(mDuration);
       assignEffects(1);
-      mScreen.attach(mObject[1]);
+      mFrame.attach(mObject[1]);
       }
 
     return FAKE_EFFECT_ID;
diff --git a/src/main/java/org/distorted/objectlib/effects/objectchange/ObjectChangeEffectMove.java b/src/main/java/org/distorted/objectlib/effects/objectchange/ObjectChangeEffectMove.java
index f378aadf..de9bab1a 100644
--- a/src/main/java/org/distorted/objectlib/effects/objectchange/ObjectChangeEffectMove.java
+++ b/src/main/java/org/distorted/objectlib/effects/objectchange/ObjectChangeEffectMove.java
@@ -30,8 +30,8 @@ class ObjectChangeEffectMove extends ObjectChangeEffect
   {
   public int createEffectsPhase0(int duration)
     {
-    int w = mScreen.getWidth();
-    int h = mScreen.getHeight();
+    int w = mFrame.getWidth();
+    int h = mFrame.getHeight();
     int xmove = w/2 + (w<h?w:h)/2;
 
     mNodeEffectPosition[0] = new int[] {1};
@@ -49,8 +49,8 @@ class ObjectChangeEffectMove extends ObjectChangeEffect
 
   public int createEffectsPhase1(int duration)
     {
-    int w = mScreen.getWidth();
-    int h = mScreen.getHeight();
+    int w = mFrame.getWidth();
+    int h = mFrame.getHeight();
     int xmove = w/2 + (w<h?w:h)/2;
 
     mNodeEffectPosition[1] = new int[] {1};
diff --git a/src/main/java/org/distorted/objectlib/effects/scramble/ScrambleEffect.java b/src/main/java/org/distorted/objectlib/effects/scramble/ScrambleEffect.java
index 495c832f..e9dff3bb 100644
--- a/src/main/java/org/distorted/objectlib/effects/scramble/ScrambleEffect.java
+++ b/src/main/java/org/distorted/objectlib/effects/scramble/ScrambleEffect.java
@@ -24,7 +24,7 @@ import java.util.Random;
 
 import org.distorted.library.effect.Effect;
 import org.distorted.library.main.DistortedEffects;
-import org.distorted.library.main.DistortedScreen;
+import org.distorted.library.main.DistortedFramebuffer;
 import org.distorted.library.message.EffectListener;
 
 import org.distorted.objectlib.main.ObjectPreRender;
@@ -258,7 +258,7 @@ public abstract class ScrambleEffect extends BaseEffect implements EffectListene
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   @SuppressWarnings("unused")
-  public long start(int duration, DistortedScreen screen, ObjectPreRender pre)
+  public long start(int duration, DistortedFramebuffer frame, ObjectPreRender pre)
     {
     mObject= pre.getObject();
     mPre   = pre;
diff --git a/src/main/java/org/distorted/objectlib/effects/solve/SolveEffect.java b/src/main/java/org/distorted/objectlib/effects/solve/SolveEffect.java
index 65a3dd50..3bedf634 100644
--- a/src/main/java/org/distorted/objectlib/effects/solve/SolveEffect.java
+++ b/src/main/java/org/distorted/objectlib/effects/solve/SolveEffect.java
@@ -23,7 +23,7 @@ import java.lang.reflect.Method;
 
 import org.distorted.library.effect.Effect;
 import org.distorted.library.main.DistortedEffects;
-import org.distorted.library.main.DistortedScreen;
+import org.distorted.library.main.DistortedFramebuffer;
 import org.distorted.library.message.EffectListener;
 
 import org.distorted.objectlib.main.ObjectPreRender;
@@ -72,7 +72,7 @@ public abstract class SolveEffect extends BaseEffect implements EffectListener
 
   ObjectPreRender mPre;
   TwistyObject mObject;
-  DistortedScreen mScreen;
+  DistortedFramebuffer mFrame;
   Effect[][] mCubeEffects;
   int[][] mCubeEffectPosition;
   Effect[][] mNodeEffects;
@@ -199,9 +199,9 @@ public abstract class SolveEffect extends BaseEffect implements EffectListener
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   @SuppressWarnings("unused")
-  public long start(int duration, DistortedScreen screen, ObjectPreRender pre)
+  public long start(int duration, DistortedFramebuffer frame, ObjectPreRender pre)
     {
-    mScreen  = screen;
+    mFrame   = frame;
     mObject  = pre.getObject();
     mPre     = pre;
     mDuration= duration;
diff --git a/src/main/java/org/distorted/objectlib/effects/win/WinEffect.java b/src/main/java/org/distorted/objectlib/effects/win/WinEffect.java
index 5ed09f13..ff861f0c 100644
--- a/src/main/java/org/distorted/objectlib/effects/win/WinEffect.java
+++ b/src/main/java/org/distorted/objectlib/effects/win/WinEffect.java
@@ -23,7 +23,7 @@ import java.lang.reflect.Method;
 
 import org.distorted.library.effect.Effect;
 import org.distorted.library.main.DistortedEffects;
-import org.distorted.library.main.DistortedScreen;
+import org.distorted.library.main.DistortedFramebuffer;
 import org.distorted.library.message.EffectListener;
 
 import org.distorted.objectlib.main.ObjectPreRender;
@@ -69,7 +69,7 @@ public abstract class WinEffect extends BaseEffect implements EffectListener
 
   ObjectPreRender mPre;
   TwistyObject mObject;
-  DistortedScreen mScreen;
+  DistortedFramebuffer mFrame;
   Effect[] mCubeEffects;
   int[] mCubeEffectPosition;
   Effect[] mNodeEffects;
@@ -164,9 +164,9 @@ public abstract class WinEffect extends BaseEffect implements EffectListener
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   @SuppressWarnings("unused")
-  public long start(int duration, DistortedScreen screen, ObjectPreRender pre)
+  public long start(int duration, DistortedFramebuffer frame, ObjectPreRender pre)
     {
-    mScreen   = screen;
+    mFrame    = frame;
     mObject   = pre.getObject();
     mPre      = pre;
     mDuration = duration;
diff --git a/src/main/java/org/distorted/objectlib/effects/win/WinEffectGlow.java b/src/main/java/org/distorted/objectlib/effects/win/WinEffectGlow.java
index 54be2378..94ea7b8c 100644
--- a/src/main/java/org/distorted/objectlib/effects/win/WinEffectGlow.java
+++ b/src/main/java/org/distorted/objectlib/effects/win/WinEffectGlow.java
@@ -69,8 +69,8 @@ public class WinEffectGlow extends WinEffect
 
     float moveX = mPre.getMoveX();
     float moveY = mPre.getMoveY();
-    int width   = mScreen.getWidth();
-    int height  = mScreen.getHeight();
+    int width   = mFrame.getWidth();
+    int height  = mFrame.getHeight();
     Static3D center = new Static3D(moveX/width, moveY/height, 0);
     float ratio = 0.5f*mObject.getRatio();
 
diff --git a/src/main/java/org/distorted/objectlib/helpers/ObjectLibInterface.java b/src/main/java/org/distorted/objectlib/helpers/ObjectLibInterface.java
index 3f539786..28bd2e45 100644
--- a/src/main/java/org/distorted/objectlib/helpers/ObjectLibInterface.java
+++ b/src/main/java/org/distorted/objectlib/helpers/ObjectLibInterface.java
@@ -19,7 +19,8 @@
 
 package org.distorted.objectlib.helpers;
 
-import org.distorted.library.main.DistortedScreen;
+import org.distorted.library.main.DistortedFramebuffer;
+
 import org.distorted.objectlib.main.ObjectControl;
 import org.distorted.objectlib.main.ObjectType;
 
@@ -39,5 +40,5 @@ public interface ObjectLibInterface
   int getCurrentColor();
   int cubitIsLocked(ObjectType type, int cubit);
   ObjectControl getControl();
-  DistortedScreen getScreen();
+  DistortedFramebuffer getFramebuffer();
   }
diff --git a/src/main/java/org/distorted/objectlib/main/ObjectPreRender.java b/src/main/java/org/distorted/objectlib/main/ObjectPreRender.java
index 020b3dc7..9f38028e 100644
--- a/src/main/java/org/distorted/objectlib/main/ObjectPreRender.java
+++ b/src/main/java/org/distorted/objectlib/main/ObjectPreRender.java
@@ -24,7 +24,7 @@ import java.lang.ref.WeakReference;
 import android.app.Activity;
 import android.content.SharedPreferences;
 
-import org.distorted.library.main.DistortedScreen;
+import org.distorted.library.main.DistortedFramebuffer;
 import org.distorted.library.message.EffectListener;
 
 import org.distorted.library.type.Static3D;
@@ -125,8 +125,8 @@ public class ObjectPreRender implements EffectListener
     try
       {
       int index = type.ordinal();
-      DistortedScreen screen = mController.getInterface().getScreen();
-      mEffectID[index] = type.startEffect(screen,this);
+      DistortedFramebuffer frame = mController.getInterface().getFramebuffer();
+      mEffectID[index] = type.startEffect(frame,this);
       }
     catch( Exception ex )
       {
