commit 5d7e316ea3b7f2069e8b2e3f8d89ed5d75c7544c
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Thu May 7 01:02:53 2020 +0100

    Convert SurfaceView to stretchless API.

diff --git a/src/main/java/org/distorted/examples/surfaceview/RenderThread.java b/src/main/java/org/distorted/examples/surfaceview/RenderThread.java
index f30e8e5..5e714f0 100644
--- a/src/main/java/org/distorted/examples/surfaceview/RenderThread.java
+++ b/src/main/java/org/distorted/examples/surfaceview/RenderThread.java
@@ -70,6 +70,7 @@ class RenderThread extends Thread
   private SurfaceView mView;
   private static boolean resourcesCreated = false;
   private Static3D mScale;
+  private float mBmpRatio;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -78,20 +79,20 @@ class RenderThread extends Thread
     mSurfaceHolder = holder;
     mView = view;
 
-    Static3D pLeft = new Static3D( 90-320/2, 108-366/2,0);
-    Static3D pRight= new Static3D(176-320/2, 111-366/2,0);
+    Static3D pLeft = new Static3D( ( 90-320*0.5f)/320.0f, (108-366*0.5f)/366.0f, 0);
+    Static3D pRight= new Static3D( (176-320*0.5f)/320.0f, (111-366*0.5f)/366.0f, 0);
 
-    Static4D rLeft = new Static4D(-10, 10, 0,25);
-    Static4D rRight= new Static4D( 10,  5, 0,25);
+    Static4D rLeft = new Static4D( -10/320.0f, 10/366.0f, 0, 25/320.0f);
+    Static4D rRight= new Static4D(  10/320.0f,  5/366.0f, 0, 25/320.0f);
 
     Dynamic3D dLeft = new Dynamic3D(1000,0.0f);
     Dynamic3D dRight= new Dynamic3D(1000,0.0f);
 
-    dLeft.add( new Static3D(  0,  0, 0) );
-    dLeft.add( new Static3D(-20, 20, 0) );
+    dLeft.add( new Static3D(         0,         0, 0) );
+    dLeft.add( new Static3D(-20/320.0f, 20/366.0f, 0) );
 
-    dRight.add( new Static3D(  0,  0, 0) );
-    dRight.add( new Static3D( 20, 10, 0) );
+    dRight.add( new Static3D(         0,         0, 0) );
+    dRight.add( new Static3D( 20/320.0f, 10/366.0f, 0) );
 
     mEffects = new DistortedEffects();
     mEffects.apply( new VertexEffectDistort(dLeft , pLeft , rLeft ) );
@@ -213,11 +214,9 @@ class RenderThread extends Thread
     {
     Log.d(TAG, "surfaceChanged " + width + "x" + height);
 
-    float horiRatio = (float)width / mMesh.getStretchX();
-    float vertRatio = (float)height/ mMesh.getStretchY();
-    float factor    = horiRatio > vertRatio ? vertRatio : horiRatio;
+    if( width<height ) mScale.set( width,   width*mBmpRatio, 1 );
+    else               mScale.set( height/mBmpRatio, height, 1 );
 
-    mScale.set( factor,factor,factor );
     mScreen.resize(width, height);
     }
 
@@ -243,17 +242,12 @@ class RenderThread extends Thread
       catch(IOException io) {}
       }
 
-    int bmpHeight = bmp.getHeight();
-    int bmpWidth  = bmp.getWidth();
+    mBmpRatio = (float)bmp.getHeight()/bmp.getWidth();
 
     if( mTexture==null ) mTexture = new DistortedTexture();
     mTexture.setTexture(bmp);
 
-    if( mMesh==null )
-      {
-      mMesh = new MeshRectangles(9,9*bmpHeight/bmpWidth);
-      mMesh.setStretch(bmpWidth,bmpHeight,0);
-      }
+    if( mMesh==null ) mMesh = new MeshRectangles(9,(int)(9*mBmpRatio));
 
     mScreen.detachAll();
     mScreen.attach(mTexture,mEffects,mMesh);
