commit 4bb94a7d921cbd8ac7c280c0c7f1e59da51724a6
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Mon Mar 2 15:47:02 2020 +0000

    Hide the InternalSurface class inside its package.

diff --git a/src/main/java/org/distorted/library/effectqueue/EffectQueuePostprocess.java b/src/main/java/org/distorted/library/effectqueue/EffectQueuePostprocess.java
index 239d8fa..cca3d17 100644
--- a/src/main/java/org/distorted/library/effectqueue/EffectQueuePostprocess.java
+++ b/src/main/java/org/distorted/library/effectqueue/EffectQueuePostprocess.java
@@ -33,7 +33,6 @@ import org.distorted.library.main.DistortedFramebuffer;
 import org.distorted.library.main.DistortedNode;
 import org.distorted.library.main.InternalOutputSurface;
 import org.distorted.library.main.InternalRenderState;
-import org.distorted.library.main.InternalSurface;
 import org.distorted.library.mesh.MeshBase;
 import org.distorted.library.message.EffectMessageSender;
 import org.distorted.library.program.DistortedProgram;
@@ -159,59 +158,52 @@ public class EffectQueuePostprocess extends EffectQueue
 
   public int preprocess(InternalOutputSurface buffer, DistortedNode node, float distance, float mipmap, float[] projection)
     {
-    buffer.setAsOutput();
-    InternalSurface input = node.getSurface();
+    MeshBase mesh = node.getMesh();
+    DistortedEffects effects = node.getEffects();
 
-    if( input.setAsInput() )
-      {
-      MeshBase mesh = node.getMesh();
-      DistortedEffects effects = node.getEffects();
-
-      float halfW = mesh.getStretchX() / 2.0f;
-      float halfH = mesh.getStretchY() / 2.0f;
-      float halfZ = mesh.getStretchZ() / 2.0f;
+    float halfW = mesh.getStretchX() / 2.0f;
+    float halfH = mesh.getStretchY() / 2.0f;
+    float halfZ = mesh.getStretchZ() / 2.0f;
 
-      int width   = buffer.getWidth();
-      int height  = buffer.getHeight();
+    int width   = buffer.getWidth();
+    int height  = buffer.getHeight();
 
-      InternalRenderState.setUpStencilMark(mA!=0.0f);
-      InternalRenderState.disableBlending();
+    InternalRenderState.setUpStencilMark(mA!=0.0f);
+    InternalRenderState.disableBlending();
 
-      GLES31.glViewport(0, 0, width, height );
+    GLES31.glViewport(0, 0, width, height );
 
-      mPreProgram.useProgram();
+    mPreProgram.useProgram();
 
-      mesh.bindVertexAttribs(mPreProgram);
+    mesh.bindVertexAttribs(mPreProgram);
 
-      EffectQueue[] queues = effects.getQueues();
-      EffectQueueMatrix matrix = (EffectQueueMatrix)queues[0];
-      EffectQueueVertex vertex = (EffectQueueVertex)queues[1];
+    EffectQueue[] queues = effects.getQueues();
+    EffectQueueMatrix matrix = (EffectQueueMatrix)queues[0];
+    EffectQueueVertex vertex = (EffectQueueVertex)queues[1];
 
-      float inflate=0.0f;
+    float inflate=0.0f;
 
-      matrix.send(distance, mipmap, projection, halfW, halfH, halfZ, 2);
+    matrix.send(distance, mipmap, projection, halfW, halfH, halfZ, 2);
 
-      if( mHalo!=0.0f )
-        {
-        inflate = matrix.magnify(projection, width, height, mipmap, halfW, halfH, halfZ, mHalo);
-        }
+    if( mHalo!=0.0f )
+      {
+      inflate = matrix.magnify(projection, width, height, mipmap, halfW, halfH, halfZ, mHalo);
+      }
 
-      vertex.send(inflate,2);
+    vertex.send(inflate,2);
 
-      if( mA!=0.0f )
-        {
-        GLES31.glUniform4f(mPreColorH, mR, mG, mB, mA);
-        GLES31.glUniform1i(mPreTextureH, 0);
-        }
+    if( mA!=0.0f )
+      {
+      GLES31.glUniform4f(mPreColorH, mR, mG, mB, mA);
+      GLES31.glUniform1i(mPreTextureH, 0);
+      }
 
-      GLES31.glDrawArrays(GLES31.GL_TRIANGLE_STRIP, 0, mesh.getNumVertices() );
+    GLES31.glDrawArrays(GLES31.GL_TRIANGLE_STRIP, 0, mesh.getNumVertices() );
 
-      InternalRenderState.restoreBlending();
-      InternalRenderState.unsetUpStencilMark();
+    InternalRenderState.restoreBlending();
+    InternalRenderState.unsetUpStencilMark();
 
-      return 1;
-      }
-    return 0;
+    return 1;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/java/org/distorted/library/main/InternalOutputSurface.java b/src/main/java/org/distorted/library/main/InternalOutputSurface.java
index 6cbe73f..e756621 100644
--- a/src/main/java/org/distorted/library/main/InternalOutputSurface.java
+++ b/src/main/java/org/distorted/library/main/InternalOutputSurface.java
@@ -424,7 +424,16 @@ public abstract class InternalOutputSurface extends InternalSurface implements I
             }
           else
             {
-            for(int j=bucketChange; j<i; j++) numRenders += lastQueue.preprocess( buffer,children.getChild(j), buffer.mDistance, buffer.mMipmap, buffer.mProjectionMatrix );
+            for(int j=bucketChange; j<i; j++)
+              {
+              DistortedNode node = children.getChild(j);
+
+              if( node.getSurface().setAsInput() )
+                {
+                buffer.setAsOutput();
+                numRenders += lastQueue.preprocess( buffer, node, buffer.mDistance, buffer.mMipmap, buffer.mProjectionMatrix );
+                }
+              }
             numRenders += lastQueue.postprocess(buffer);
 
             if( oit )
@@ -466,7 +475,16 @@ public abstract class InternalOutputSurface extends InternalSurface implements I
 
         if( i==numChildren-1 )
           {
-          for(int j=bucketChange; j<numChildren; j++) numRenders += currQueue.preprocess( buffer,children.getChild(j), buffer.mDistance, buffer.mMipmap, buffer.mProjectionMatrix );
+          for(int j=bucketChange; j<numChildren; j++)
+            {
+            DistortedNode node = children.getChild(j);
+
+            if( node.getSurface().setAsInput() )
+              {
+              buffer.setAsOutput();
+              numRenders += currQueue.preprocess( buffer, node, buffer.mDistance, buffer.mMipmap, buffer.mProjectionMatrix );
+              }
+            }
           numRenders += currQueue.postprocess(buffer);
 
           if( oit )
diff --git a/src/main/java/org/distorted/library/main/InternalSurface.java b/src/main/java/org/distorted/library/main/InternalSurface.java
index 54efbf6..06e65a2 100644
--- a/src/main/java/org/distorted/library/main/InternalSurface.java
+++ b/src/main/java/org/distorted/library/main/InternalSurface.java
@@ -21,15 +21,9 @@ package org.distorted.library.main;
 
 import android.opengl.GLES31;
 
-import org.distorted.library.mesh.MeshBase;
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * This is not really part of the public API.
- *
- * @y.exclude
- */
-public abstract class InternalSurface extends InternalObject
+
+abstract class InternalSurface extends InternalObject
 {
   int mColorCreated;
   int mNumColors;
@@ -90,23 +84,6 @@ public abstract class InternalSurface extends InternalObject
     return mHeight;
     }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Return the depth of this Surface.
- * <p>
- * Admittedly quite a strange method. Why do we need to pass a Mesh to it? Because one cannot determine
- * 'depth' of a Surface (bitmap really!) when rendered based only on the texture itself, that depends
- * on the Mesh it is rendered with.
- *
- * @return depth of the Object, in pixels.
- */
-
-/*
-  public int getDepth(MeshBase mesh)
-    {
-    return mesh==null ? 0 : (int)(mWidth*mesh.getZFactor() );
-    }
-*/
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 /**
  * Bind the underlying rectangle of pixels as a OpenGL Texture.
