/**
 * Copyright 2011 The PlayN Authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package playn.tests.core;

import playn.core.Color;
import playn.core.Game;
import playn.core.Pointer;
import playn.core.SurfaceLayer;
import static playn.core.PlayN.*;

public class TestsGame implements Game {
  Test[] tests = new Test[] {
    new CanvasTest(),
    new ImmediateTest(),
    new ImageTypeTest(),
    new AlphaLayerTest(),
    new DepthTest(),
    new ClearBackgroundTest(),
    /*new YourTest(),*/
  };
  int currentTest;

  @Override
  public void init() {
    // display basic instructions
    log().info("Click or touch to go to the next test.");

    // add a listener for pointer (mouse, touch) input
    pointer().setListener(new Pointer.Adapter() {
      @Override
      public void onPointerStart(Pointer.Event event) {
        nextTest();
      }
    });

    currentTest = -1;
    nextTest();
  }

  Test currentTest() {
    return tests[currentTest];
  }

  void nextTest() {
    currentTest = (currentTest + 1) % tests.length;
    // setup root layer for next test
    graphics().rootLayer().clear();
    SurfaceLayer bg = graphics().createSurfaceLayer(graphics().width(), graphics().height());
    bg.surface().setFillColor(Color.rgb(255, 255, 255));
    bg.surface().fillRect(0, 0, bg.surface().width(), bg.surface().height());
    bg.setDepth(Float.NEGATIVE_INFINITY); // render behind everything
    graphics().rootLayer().add(bg);

    log().info("Starting " + currentTest().getName());
    log().info(" Description: " + currentTest().getDescription());
    currentTest().init();
  }

  @Override
  public void paint(float alpha) {
    currentTest().paint(alpha);
  }

  @Override
  public void update(float delta) {
    currentTest().update(delta);
  }

  @Override
  public int updateRate() {
    return currentTest().updateRate();
  }
}

@@ -667,16 +667,50 @@
 e.Game;%0A
+import playn.core.ImmediateLayer;%0A
 import p
@@ -753,21 +753,16 @@
 .Surface
-Layer
 ;%0Aimport
@@ -1576,16 +1576,17 @@
 length;%0A
+%0A
     // s
@@ -1655,22 +1655,24 @@
 ();%0A    
-Surfac
+Immediat
 eLayer b
@@ -1696,79 +1696,108 @@
 eate
-SurfaceLayer(graphics().width(), graphics().height());%0A
+ImmediateLayer(new ImmediateLayer.Renderer() %7B%0A      public void render(Surface surf) %7B%0A   
     
-bg.
+ 
 surf
-ace()
 .set
@@ -1837,28 +1837,24 @@
 ));%0A    
-bg.surface()
+    surf
 .fillRec
@@ -1861,26 +1861,24 @@
 t(0, 0, 
-bg.surface
+graphics
 ().width
@@ -1885,18 +1885,16 @@
 (), 
-bg.surface
+graphics
 ().h
@@ -1899,24 +1899,40 @@
 .height());%0A
+      %7D%0A    %7D);%0A
     bg.setDe

Use an immediate layer instead of a surface layer. GPU RAM--.