Bug 740898. Merge LayerView and GLSurfaceView. r=pcwalton
authorJeff Muizelaar <jmuizelaar@mozilla.com>
Thu, 05 Apr 2012 11:28:50 -0400
changeset 94397 fab75de4ad2ed61333038cee30eb71dc7083429e
parent 94396 c77aa84222f12636f765ee8f613352ed2a0175ab
child 94398 5738f35ffb113d6ea2ef39f30709e855c6dc38a8
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspcwalton
bugs740898
milestone14.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 740898. Merge LayerView and GLSurfaceView. r=pcwalton Once, GLThread is gone we don't have any need to support both styles of GL rendering. Merging LayerView and FlexibleGLSurfaceView makes it clearer what's going on, and I expect we'll also be able to take out some dead code from the resulting LayerView. This patch is mostly uninteresting. The interesting bits are that implementations of requestRender and the constructors are merged. Everything else is mostly copying over methods and renaming FlexibleGLSurfaceView's mController to mGLController.
mobile/android/base/Makefile.in
mobile/android/base/gfx/FlexibleGLSurfaceView.java
mobile/android/base/gfx/GLController.java
mobile/android/base/gfx/GeckoLayerClient.java
mobile/android/base/gfx/LayerView.java
widget/android/AndroidBridge.cpp
widget/android/AndroidBridge.h
widget/android/AndroidFlexViewWrapper.cpp
widget/android/AndroidFlexViewWrapper.h
widget/android/AndroidLayerViewWrapper.cpp
widget/android/AndroidLayerViewWrapper.h
widget/android/Makefile.in
--- a/mobile/android/base/Makefile.in
+++ b/mobile/android/base/Makefile.in
@@ -118,17 +118,16 @@ FENNEC_JAVA_FILES = \
   gfx/BitmapUtils.java \
   gfx/BufferedCairoImage.java \
   gfx/CairoGLInfo.java \
   gfx/CairoImage.java \
   gfx/CairoUtils.java \
   gfx/CheckerboardImage.java \
   gfx/DisplayPortCalculator.java \
   gfx/DisplayPortMetrics.java \
-  gfx/FlexibleGLSurfaceView.java \
   gfx/FloatSize.java \
   gfx/GeckoLayerClient.java \
   gfx/GLController.java \
   gfx/ImmutableViewportMetrics.java \
   gfx/InputConnectionHandler.java \
   gfx/IntSize.java \
   gfx/Layer.java \
   gfx/LayerController.java \
deleted file mode 100644
--- a/mobile/android/base/gfx/FlexibleGLSurfaceView.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (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.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Android code.
- *
- * The Initial Developer of the Original Code is Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2011-2012
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Patrick Walton <pcwalton@mozilla.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-package org.mozilla.gecko.gfx;
-
-import org.mozilla.gecko.GeckoApp;
-import android.content.Context;
-import android.graphics.PixelFormat;
-import android.opengl.GLSurfaceView;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.view.SurfaceHolder;
-import android.view.SurfaceView;
-import javax.microedition.khronos.opengles.GL10;
-
-/*
- * This class extends SurfaceView and allows dynamically switching between two modes
- * of operation. In one mode, it is used like a GLSurfaceView, and has it's own GL
- * thread. In the other mode, it allows external code to perform GL composition, by
- * exposing the GL controller.
- *
- * In our case, we start off in the first mode because we are rendering the placeholder
- * image. This mode is initiated by a call to createGLThread(). Once Gecko comes up,
- * it invokes registerCxxCompositor() via a JNI call, which shuts down the GL thread and
- * returns the GL controller. The JNI code then takes the EGL surface from the GL
- * controller and allows the off-main thread compositor to deal with it directly.
- */
-public class FlexibleGLSurfaceView extends SurfaceView implements SurfaceHolder.Callback {
-    private static final String LOGTAG = "GeckoFlexibleGLSurfaceView";
-
-    private GLSurfaceView.Renderer mRenderer;
-    private GLController mController;
-    private Listener mListener;
-
-    public FlexibleGLSurfaceView(Context context) {
-        super(context);
-        init();
-    }
-
-    public FlexibleGLSurfaceView(Context context, AttributeSet attributeSet) {
-        super(context, attributeSet);
-        init();
-    }
-
-    public void init() {
-        SurfaceHolder holder = getHolder();
-        holder.addCallback(this);
-        holder.setFormat(PixelFormat.RGB_565);
-
-        mController = new GLController(this);
-    }
-
-    public void setRenderer(GLSurfaceView.Renderer renderer) {
-        mRenderer = renderer;
-    }
-
-    public GLSurfaceView.Renderer getRenderer() {
-        return mRenderer;
-    }
-
-    public void setListener(Listener listener) {
-        mListener = listener;
-    }
-
-    public synchronized void requestRender() {
-        if (mListener != null) {
-            mListener.renderRequested();
-        }
-    }
-
-    public synchronized GLController getGLController() {
-        return mController;
-    }
-
-    /** Implementation of SurfaceHolder.Callback */
-    public synchronized void surfaceChanged(SurfaceHolder holder, int format, int width,
-                                            int height) {
-        mController.sizeChanged(width, height);
-
-        if (mListener != null) {
-            mListener.surfaceChanged(width, height);
-        }
-    }
-
-    /** Implementation of SurfaceHolder.Callback */
-    public synchronized void surfaceCreated(SurfaceHolder holder) {
-        mController.surfaceCreated();
-    }
-
-    /** Implementation of SurfaceHolder.Callback */
-    public synchronized void surfaceDestroyed(SurfaceHolder holder) {
-        mController.surfaceDestroyed();
-        if (mListener != null) {
-            mListener.compositionPauseRequested();
-        }
-    }
-
-    /** This function is invoked by Gecko (compositor thread) via JNI; be careful when modifying signature. */
-    public static GLController registerCxxCompositor() {
-        try {
-            FlexibleGLSurfaceView flexView = (FlexibleGLSurfaceView)GeckoApp.mAppContext.getLayerController().getView();
-            return flexView.getGLController();
-        } catch (Exception e) {
-            Log.e(LOGTAG, "### Exception! " + e);
-            return null;
-        }
-    }
-
-    public interface Listener {
-        void renderRequested();
-        void compositionPauseRequested();
-        void compositionResumeRequested();
-        void surfaceChanged(int width, int height);
-    }
-
-    public static class FlexibleGLSurfaceViewException extends RuntimeException {
-        public static final long serialVersionUID = 1L;
-
-        FlexibleGLSurfaceViewException(String e) {
-            super(e);
-        }
-    }
-}
-
--- a/mobile/android/base/gfx/GLController.java
+++ b/mobile/android/base/gfx/GLController.java
@@ -48,17 +48,17 @@ import javax.microedition.khronos.egl.EG
 import javax.microedition.khronos.egl.EGLSurface;
 import javax.microedition.khronos.opengles.GL;
 import javax.microedition.khronos.opengles.GL10;
 
 public class GLController {
     private static final int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
     private static final String LOGTAG = "GeckoGLController";
 
-    private FlexibleGLSurfaceView mView;
+    private LayerView mView;
     private int mGLVersion;
     private boolean mSurfaceValid;
     private int mWidth, mHeight;
 
     private EGL10 mEGL;
     private EGLDisplay mEGLDisplay;
     private EGLConfig mEGLConfig;
     private EGLContext mEGLContext;
@@ -72,32 +72,32 @@ public class GLController {
         EGL10.EGL_RED_SIZE, 5,
         EGL10.EGL_GREEN_SIZE, 6,
         EGL10.EGL_BLUE_SIZE, 5,
         EGL10.EGL_SURFACE_TYPE, EGL10.EGL_WINDOW_BIT,
         EGL10.EGL_RENDERABLE_TYPE, LOCAL_EGL_OPENGL_ES2_BIT,
         EGL10.EGL_NONE
     };
 
-    public GLController(FlexibleGLSurfaceView view) {
+    public GLController(LayerView view) {
         mView = view;
         mGLVersion = 2;
         mSurfaceValid = false;
     }
 
     public void setGLVersion(int version) {
         mGLVersion = version;
     }
 
     public GL getGL()                       { return mEGLContext.getGL(); }
     public EGLDisplay getEGLDisplay()       { return mEGLDisplay;         }
     public EGLConfig getEGLConfig()         { return mEGLConfig;          }
     public EGLContext getEGLContext()       { return mEGLContext;         }
     public EGLSurface getEGLSurface()       { return mEGLSurface;         }
-    public FlexibleGLSurfaceView getView()  { return mView;               }
+    public LayerView getView()              { return mView;               }
 
     public boolean hasSurface() {
         return mEGLSurface != null;
     }
 
     public boolean swapBuffers() {
         return mEGL.eglSwapBuffers(mEGLDisplay, mEGLSurface);
     }
--- a/mobile/android/base/gfx/GeckoLayerClient.java
+++ b/mobile/android/base/gfx/GeckoLayerClient.java
@@ -53,17 +53,17 @@ import android.graphics.PointF;
 import android.graphics.Rect;
 import android.graphics.RectF;
 import android.os.SystemClock;
 import android.util.DisplayMetrics;
 import android.util.Log;
 import android.view.View;
 
 public class GeckoLayerClient implements GeckoEventResponder,
-                                         FlexibleGLSurfaceView.Listener {
+                                         LayerView.Listener {
     private static final String LOGTAG = "GeckoLayerClient";
     private static final String PREF_DISPLAYPORT_STRATEGY = "gfx.displayport.strategy";
 
     private LayerController mLayerController;
     private LayerRenderer mLayerRenderer;
     private boolean mLayerRendererInitialized;
 
     private IntSize mScreenSize;
@@ -402,39 +402,39 @@ public class GeckoLayerClient implements
         mLayerRenderer.activateDefaultProgram();
     }
 
     /** This function is invoked by Gecko via JNI; be careful when modifying signature. */
     public void deactivateProgram() {
         mLayerRenderer.deactivateDefaultProgram();
     }
 
-    /** Implementation of FlexibleGLSurfaceView.Listener */
+    /** Implementation of LayerView.Listener */
     public void renderRequested() {
         GeckoAppShell.scheduleComposite();
     }
 
-    /** Implementation of FlexibleGLSurfaceView.Listener */
+    /** Implementation of LayerView.Listener */
     public void compositionPauseRequested() {
         // We need to coordinate with Gecko when pausing composition, to ensure
         // that Gecko never executes a draw event while the compositor is paused.
         GeckoAppShell.sendEventToGecko(GeckoEvent.createCompositorPauseEvent());
     }
 
-    /** Implementation of FlexibleGLSurfaceView.Listener */
+    /** Implementation of LayerView.Listener */
     public void compositionResumeRequested() {
         // Asking Gecko to resume the compositor takes too long (see
         // https://bugzilla.mozilla.org/show_bug.cgi?id=735230#c23), so we
         // resume the compositor directly. We still need to inform Gecko about
         // the compositor resuming, so that Gecko knows that it can now draw.
         GeckoAppShell.scheduleResumeComposition();
         GeckoAppShell.sendEventToGecko(GeckoEvent.createCompositorResumeEvent());
     }
 
-    /** Implementation of FlexibleGLSurfaceView.Listener */
+    /** Implementation of LayerView.Listener */
     public void surfaceChanged(int width, int height) {
         mLayerController.setViewportSize(new FloatSize(width, height));
 
         // We need to make this call even when the compositor isn't currently
         // paused (e.g. during an orientation change), to make the compositor
         // aware of the changed surface.
         compositionResumeRequested();
         renderRequested();
--- a/mobile/android/base/gfx/LayerView.java
+++ b/mobile/android/base/gfx/LayerView.java
@@ -53,53 +53,70 @@ import android.view.MotionEvent;
 import android.view.inputmethod.EditorInfo;
 import android.view.inputmethod.InputConnection;
 import android.view.ScaleGestureDetector;
 import android.widget.RelativeLayout;
 import android.util.Log;
 import java.nio.IntBuffer;
 import java.util.LinkedList;
 
+import org.mozilla.gecko.GeckoApp;
+import android.content.Context;
+import android.graphics.PixelFormat;
+import android.opengl.GLSurfaceView;
+import android.util.AttributeSet;
+import android.view.SurfaceHolder;
+import android.view.SurfaceView;
+import javax.microedition.khronos.opengles.GL10;
+
+
 /**
  * A view rendered by the layer compositor.
  *
  * This view delegates to LayerRenderer to actually do the drawing. Its role is largely that of a
  * mediator between the LayerRenderer and the LayerController.
  *
  * Note that LayerView is accessed by Robocop via reflection.
  */
-public class LayerView extends FlexibleGLSurfaceView {
+public class LayerView extends SurfaceView implements SurfaceHolder.Callback {
     private Context mContext;
     private LayerController mController;
+    private GLController mGLController;
     private InputConnectionHandler mInputConnectionHandler;
     private LayerRenderer mRenderer;
     private GestureDetector mGestureDetector;
     private SimpleScaleGestureDetector mScaleGestureDetector;
     private long mRenderTime;
     private boolean mRenderTimeReset;
     private static String LOGTAG = "GeckoLayerView";
     /* List of events to be processed if the page does not prevent them. Should only be touched on the main thread */
     private LinkedList<MotionEvent> mEventQueue = new LinkedList<MotionEvent>();
     /* Must be a PAINT_xxx constant */
     private int mPaintState = PAINT_NONE;
 
+    private Listener mListener;
+
     /* Flags used to determine when to show the painted surface. The integer
      * order must correspond to the order in which these states occur. */
     public static final int PAINT_NONE = 0;
     public static final int PAINT_BEFORE_FIRST = 1;
     public static final int PAINT_AFTER_FIRST = 2;
 
 
     public LayerView(Context context, LayerController controller) {
         super(context);
 
+        SurfaceHolder holder = getHolder();
+        holder.addCallback(this);
+        holder.setFormat(PixelFormat.RGB_565);
+
+        mGLController = new GLController(this);
         mContext = context;
         mController = controller;
         mRenderer = new LayerRenderer(this);
-        setRenderer(mRenderer);
         mGestureDetector = new GestureDetector(context, controller.getGestureListener());
         mScaleGestureDetector =
             new SimpleScaleGestureDetector(controller.getScaleGestureListener());
         mGestureDetector.setOnDoubleTapListener(controller.getDoubleTapListener());
         mInputConnectionHandler = null;
 
         setFocusable(true);
         setFocusableInTouchMode(true);
@@ -191,25 +208,19 @@ public class LayerView extends FlexibleG
 
     @Override
     public boolean onKeyUp(int keyCode, KeyEvent event) {
         if (mInputConnectionHandler != null)
             return mInputConnectionHandler.onKeyUp(keyCode, event);
         return false;
     }
 
-    @Override
-    public void requestRender() {
-        super.requestRender();
-
-        synchronized(this) {
-            if (!mRenderTimeReset) {
-                mRenderTimeReset = true;
-                mRenderTime = System.nanoTime();
-            }
+    public synchronized void requestRender() {
+        if (mListener != null) {
+            mListener.renderRequested();
         }
     }
 
     public void addLayer(Layer layer) {
         mRenderer.addLayer(layer);
     }
 
     public void removeLayer(Layer layer) {
@@ -233,29 +244,84 @@ public class LayerView extends FlexibleG
 
     /** Used by robocop for testing purposes. Not for production use! This is called via reflection by robocop. */
     public IntBuffer getPixels() {
         return mRenderer.getPixels();
     }
 
     public void setLayerRenderer(LayerRenderer renderer) {
         mRenderer = renderer;
-        setRenderer(mRenderer);
     }
 
     public LayerRenderer getLayerRenderer() {
         return mRenderer;
     }
-    
+
     /* paintState must be a PAINT_xxx constant. The state will only be changed
      * if paintState represents a state that occurs after the current state. */
     public void setPaintState(int paintState) {
         if (paintState > mPaintState) {
             Log.d(LOGTAG, "LayerView paint state set to " + paintState);
             mPaintState = paintState;
         }
     }
 
     public int getPaintState() {
         return mPaintState;
     }
+
+
+    public GLSurfaceView.Renderer getRenderer() {
+        return mRenderer;
+    }
+
+    public void setListener(Listener listener) {
+        mListener = listener;
+    }
+
+    public synchronized GLController getGLController() {
+        return mGLController;
+    }
+
+    /** Implementation of SurfaceHolder.Callback */
+    public synchronized void surfaceChanged(SurfaceHolder holder, int format, int width,
+                                            int height) {
+        mGLController.sizeChanged(width, height);
+
+        if (mListener != null) {
+            mListener.surfaceChanged(width, height);
+        }
+    }
+
+    /** Implementation of SurfaceHolder.Callback */
+    public synchronized void surfaceCreated(SurfaceHolder holder) {
+        mGLController.surfaceCreated();
+    }
+
+    /** Implementation of SurfaceHolder.Callback */
+    public synchronized void surfaceDestroyed(SurfaceHolder holder) {
+        mGLController.surfaceDestroyed();
+
+        if (mListener != null) {
+            mListener.compositionPauseRequested();
+        }
+    }
+
+    /** This function is invoked by Gecko (compositor thread) via JNI; be careful when modifying signature. */
+    public static GLController registerCxxCompositor() {
+        try {
+            LayerView layerView = GeckoApp.mAppContext.getLayerController().getView();
+            return layerView.getGLController();
+        } catch (Exception e) {
+            Log.e(LOGTAG, "### Exception! " + e);
+            return null;
+        }
+    }
+
+    public interface Listener {
+        void renderRequested();
+        void compositionPauseRequested();
+        void compositionResumeRequested();
+        void surfaceChanged(int width, int height);
+    }
+
+
 }
-
--- a/widget/android/AndroidBridge.cpp
+++ b/widget/android/AndroidBridge.cpp
@@ -196,17 +196,17 @@ AndroidBridge::Init(JNIEnv *jEnv,
     jEGLSurfaceImplClass = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("com/google/android/gles_jni/EGLSurfaceImpl"));
     jEGLContextImplClass = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("com/google/android/gles_jni/EGLContextImpl"));
     jEGLConfigImplClass = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("com/google/android/gles_jni/EGLConfigImpl"));
     jEGLDisplayImplClass = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("com/google/android/gles_jni/EGLDisplayImpl"));
 
     jStringClass = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("java/lang/String"));
 
 #ifdef MOZ_JAVA_COMPOSITOR
-    jFlexSurfaceView = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("org/mozilla/gecko/gfx/FlexibleGLSurfaceView"));
+    jLayerView = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("org/mozilla/gecko/gfx/LayerView"));
 
     AndroidGLController::Init(jEnv);
     AndroidEGLObject::Init(jEnv);
 #endif
 
     InitAndroidJavaWrappers(jEnv);
 
     // jEnv should NOT be cached here by anything -- the jEnv here
@@ -1114,19 +1114,19 @@ AndroidBridge::RegisterCompositor()
 {
     ALOG_BRIDGE("AndroidBridge::RegisterCompositor");
     JNIEnv *env = GetJNIForThread();    // called on the compositor thread
     if (!env)
         return;
 
     AutoLocalJNIFrame jniFrame(env, 3);
 
-    jmethodID registerCompositor = env->GetStaticMethodID(jFlexSurfaceView, "registerCxxCompositor", "()Lorg/mozilla/gecko/gfx/GLController;");
+    jmethodID registerCompositor = env->GetStaticMethodID(jLayerView, "registerCxxCompositor", "()Lorg/mozilla/gecko/gfx/GLController;");
 
-    jobject glController = env->CallStaticObjectMethod(jFlexSurfaceView, registerCompositor);
+    jobject glController = env->CallStaticObjectMethod(jLayerView, registerCompositor);
 
     sController.Acquire(env, glController);
     sController.SetGLVersion(2);
 }
 
 EGLSurface
 AndroidBridge::ProvideEGLSurface()
 {
--- a/widget/android/AndroidBridge.h
+++ b/widget/android/AndroidBridge.h
@@ -44,17 +44,17 @@
 #include <pthread.h>
 
 #include "nsCOMPtr.h"
 #include "nsCOMArray.h"
 #include "nsIRunnable.h"
 #include "nsIObserver.h"
 #include "nsThreadUtils.h"
 
-#include "AndroidFlexViewWrapper.h"
+#include "AndroidLayerViewWrapper.h"
 #include "AndroidJavaWrappers.h"
 
 #include "nsIMutableArray.h"
 #include "nsIMIMEInfo.h"
 #include "nsColor.h"
 #include "BasicLayers.h"
 #include "gfxRect.h"
 
@@ -549,17 +549,17 @@ protected:
     // stuff we need for CallEglCreateWindowSurface
     jclass jEGLSurfaceImplClass;
     jclass jEGLContextImplClass;
     jclass jEGLConfigImplClass;
     jclass jEGLDisplayImplClass;
     jclass jEGLContextClass;
     jclass jEGL10Class;
 
-    jclass jFlexSurfaceView;
+    jclass jLayerView;
     jmethodID jRegisterCompositorMethod;
 
     // some convinient types to have around
     jclass jStringClass;
 
     // calls we've dlopened from libjnigraphics.so
     int (* AndroidBitmap_getInfo)(JNIEnv *env, jobject bitmap, void *info);
     int (* AndroidBitmap_lockPixels)(JNIEnv *env, jobject bitmap, void **buffer);
deleted file mode 100644
--- a/widget/android/AndroidFlexViewWrapper.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
-* ***** BEGIN LICENSE BLOCK *****
-* Version: MPL 1.1/GPL 2.0/LGPL 2.1
-*
-* The contents of this file are subject to the Mozilla Public License Version
-* 1.1 (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.mozilla.org/MPL/
-*
-* Software distributed under the License is distributed on an "AS IS" basis,
-* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-* for the specific language governing rights and limitations under the
-* License.
-*
-* The Original Code is Mozilla Android code.
-*
-* The Initial Developer of the Original Code is Mozilla Foundation.
-* Portions created by the Initial Developer are Copyright (C) 2011-2012
-* the Initial Developer. All Rights Reserved.
-*
-* Contributor(s):
-* Patrick Walton <pcwalton@mozilla.com>
-*
-* Alternatively, the contents of this file may be used under the terms of
-* either the GNU General Public License Version 2 or later (the "GPL"), or
-* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-* in which case the provisions of the GPL or the LGPL are applicable instead
-* of those above. If you wish to allow use of your version of this file only
-* under the terms of either the GPL or the LGPL, and not to allow others to
-* use your version of this file under the terms of the MPL, indicate your
-* decision by deleting the provisions above and replace them with the notice
-* and other provisions required by the GPL or the LGPL. If you do not delete
-* the provisions above, a recipient may use your version of this file under
-* the terms of any one of the MPL, the GPL or the LGPL.
-*
-* ***** END LICENSE BLOCK ***** */
-
-#include "AndroidFlexViewWrapper.h"
-#include "nsDebug.h"
-
-#define ASSERT_THREAD() \
-        NS_ASSERTION((void*)pthread_self() == mThread, "Something is calling AndroidGLController from the wrong thread!")
-
-static jfieldID jEGLSurfacePointerField = 0;
-
-void AndroidEGLObject::Init(JNIEnv* aJEnv) {
-    jclass jClass;
-    jClass = reinterpret_cast<jclass>
-        (aJEnv->NewGlobalRef(aJEnv->FindClass("com/google/android/gles_jni/EGLSurfaceImpl")));
-    jEGLSurfacePointerField = aJEnv->GetFieldID(jClass, "mEGLSurface", "I");
-}
-
-jmethodID AndroidGLController::jSetGLVersionMethod = 0;
-jmethodID AndroidGLController::jWaitForValidSurfaceMethod = 0;
-jmethodID AndroidGLController::jProvideEGLSurfaceMethod = 0;
-
-void
-AndroidGLController::Init(JNIEnv *aJEnv)
-{
-    jclass jClass = reinterpret_cast<jclass>(aJEnv->NewGlobalRef(aJEnv->FindClass("org/mozilla/gecko/gfx/GLController")));
-
-    jSetGLVersionMethod = aJEnv->GetMethodID(jClass, "setGLVersion", "(I)V");
-    jProvideEGLSurfaceMethod = aJEnv->GetMethodID(jClass, "provideEGLSurface",
-                                                  "()Ljavax/microedition/khronos/egl/EGLSurface;");
-    jWaitForValidSurfaceMethod = aJEnv->GetMethodID(jClass, "waitForValidSurface", "()V");
-}
-
-void
-AndroidGLController::Acquire(JNIEnv* aJEnv, jobject aJObj)
-{
-    mJEnv = aJEnv;
-    mThread = (void*)pthread_self();
-    mJObj = aJEnv->NewGlobalRef(aJObj);
-}
-
-void
-AndroidGLController::SetGLVersion(int aVersion)
-{
-    ASSERT_THREAD();
-    mJEnv->CallVoidMethod(mJObj, jSetGLVersionMethod, aVersion);
-}
-
-EGLSurface
-AndroidGLController::ProvideEGLSurface()
-{
-    ASSERT_THREAD();
-    jobject jObj = mJEnv->CallObjectMethod(mJObj, jProvideEGLSurfaceMethod);
-    return reinterpret_cast<EGLSurface>(mJEnv->GetIntField(jObj, jEGLSurfacePointerField));
-}
-
-void
-AndroidGLController::WaitForValidSurface()
-{
-    ASSERT_THREAD();
-    mJEnv->CallVoidMethod(mJObj, jWaitForValidSurfaceMethod);
-}
deleted file mode 100644
--- a/widget/android/AndroidFlexViewWrapper.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
-* ***** BEGIN LICENSE BLOCK *****
-* Version: MPL 1.1/GPL 2.0/LGPL 2.1
-*
-* The contents of this file are subject to the Mozilla Public License Version
-* 1.1 (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.mozilla.org/MPL/
-*
-* Software distributed under the License is distributed on an "AS IS" basis,
-* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-* for the specific language governing rights and limitations under the
-* License.
-*
-* The Original Code is Mozilla Android code.
-*
-* The Initial Developer of the Original Code is Mozilla Foundation.
-* Portions created by the Initial Developer are Copyright (C) 2011-2012
-* the Initial Developer. All Rights Reserved.
-*
-* Contributor(s):
-* Patrick Walton <pcwalton@mozilla.com>
-*
-* Alternatively, the contents of this file may be used under the terms of
-* either the GNU General Public License Version 2 or later (the "GPL"), or
-* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-* in which case the provisions of the GPL or the LGPL are applicable instead
-* of those above. If you wish to allow use of your version of this file only
-* under the terms of either the GPL or the LGPL, and not to allow others to
-* use your version of this file under the terms of the MPL, indicate your
-* decision by deleting the provisions above and replace them with the notice
-* and other provisions required by the GPL or the LGPL. If you do not delete
-* the provisions above, a recipient may use your version of this file under
-* the terms of any one of the MPL, the GPL or the LGPL.
-*
-* ***** END LICENSE BLOCK ***** */
-
-#ifndef AndroidFlexViewWrapper_h__
-#define AndroidFlexViewWrapper_h__
-
-#include <jni.h>
-#include <cassert>
-#include <cstdlib>
-#include <pthread.h>
-#include <android/log.h>
-
-class AndroidEGLObject {
-public:
-    static void Init(JNIEnv* aJEnv);
-};
-
-typedef void *EGLSurface;
-
-class AndroidGLController {
-public:
-    static void Init(JNIEnv* aJEnv);
-
-    void Acquire(JNIEnv *aJEnv, jobject aJObj);
-    void SetGLVersion(int aVersion);
-    EGLSurface ProvideEGLSurface();
-    void WaitForValidSurface();
-
-private:
-    static jmethodID jSetGLVersionMethod;
-    static jmethodID jWaitForValidSurfaceMethod;
-    static jmethodID jProvideEGLSurfaceMethod;
-
-    // the JNIEnv for the compositor thread
-    JNIEnv *mJEnv;
-    void *mThread;
-    jobject mJObj;
-};
-
-#endif
-
new file mode 100644
--- /dev/null
+++ b/widget/android/AndroidLayerViewWrapper.cpp
@@ -0,0 +1,96 @@
+/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
+* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (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.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+* The Original Code is Mozilla Android code.
+*
+* The Initial Developer of the Original Code is Mozilla Foundation.
+* Portions created by the Initial Developer are Copyright (C) 2011-2012
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Patrick Walton <pcwalton@mozilla.com>
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+
+#include "AndroidLayerViewWrapper.h"
+#include "nsDebug.h"
+
+#define ASSERT_THREAD() \
+        NS_ASSERTION(pthread_self() == mThread, "Something is calling AndroidGLController from the wrong thread!")
+
+static jfieldID jEGLSurfacePointerField = 0;
+
+void AndroidEGLObject::Init(JNIEnv* aJEnv) {
+    jclass jClass;
+    jClass = reinterpret_cast<jclass>
+        (aJEnv->NewGlobalRef(aJEnv->FindClass("com/google/android/gles_jni/EGLSurfaceImpl")));
+    jEGLSurfacePointerField = aJEnv->GetFieldID(jClass, "mEGLSurface", "I");
+}
+
+jmethodID AndroidGLController::jSetGLVersionMethod = 0;
+jmethodID AndroidGLController::jWaitForValidSurfaceMethod = 0;
+jmethodID AndroidGLController::jProvideEGLSurfaceMethod = 0;
+
+void
+AndroidGLController::Init(JNIEnv* aJEnv)
+{
+    jclass jClass = reinterpret_cast<jclass>(aJEnv->NewGlobalRef(aJEnv->FindClass("org/mozilla/gecko/gfx/GLController")));
+
+    jSetGLVersionMethod = aJEnv->GetMethodID(jClass, "setGLVersion", "(I)V");
+    jProvideEGLSurfaceMethod = aJEnv->GetMethodID(jClass, "provideEGLSurface",
+                                                  "()Ljavax/microedition/khronos/egl/EGLSurface;");
+    jWaitForValidSurfaceMethod = aJEnv->GetMethodID(jClass, "waitForValidSurface", "()V");
+}
+
+void
+AndroidGLController::Acquire(JNIEnv* aJEnv, jobject aJObj)
+{
+    mJEnv = aJEnv;
+    mThread = pthread_self();
+    mJObj = aJEnv->NewGlobalRef(aJObj);
+}
+
+void
+AndroidGLController::SetGLVersion(int aVersion)
+{
+    ASSERT_THREAD();
+    mJEnv->CallVoidMethod(mJObj, jSetGLVersionMethod, aVersion);
+}
+
+EGLSurface
+AndroidGLController::ProvideEGLSurface()
+{
+    ASSERT_THREAD();
+    jobject jObj = mJEnv->CallObjectMethod(mJObj, jProvideEGLSurfaceMethod);
+    return reinterpret_cast<EGLSurface>(mJEnv->GetIntField(jObj, jEGLSurfacePointerField));
+}
+
+void
+AndroidGLController::WaitForValidSurface()
+{
+    ASSERT_THREAD();
+    mJEnv->CallVoidMethod(mJObj, jWaitForValidSurfaceMethod);
+}
new file mode 100644
--- /dev/null
+++ b/widget/android/AndroidLayerViewWrapper.h
@@ -0,0 +1,72 @@
+/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
+* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (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.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+* The Original Code is Mozilla Android code.
+*
+* The Initial Developer of the Original Code is Mozilla Foundation.
+* Portions created by the Initial Developer are Copyright (C) 2011-2012
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Patrick Walton <pcwalton@mozilla.com>
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+
+#ifndef AndroidLayerViewWrapper_h__
+#define AndroidLayerViewWrapper_h__
+
+#include <jni.h>
+#include <pthread.h>
+
+class AndroidEGLObject {
+public:
+    static void Init(JNIEnv* aJEnv);
+};
+
+typedef void* EGLSurface;
+
+class AndroidGLController {
+public:
+    static void Init(JNIEnv* aJEnv);
+
+    void Acquire(JNIEnv* aJEnv, jobject aJObj);
+    void SetGLVersion(int aVersion);
+    EGLSurface ProvideEGLSurface();
+    void WaitForValidSurface();
+
+private:
+    static jmethodID jSetGLVersionMethod;
+    static jmethodID jWaitForValidSurfaceMethod;
+    static jmethodID jProvideEGLSurfaceMethod;
+
+    // the JNIEnv for the compositor thread
+    JNIEnv* mJEnv;
+    pthread_t mThread;
+    jobject mJObj;
+};
+
+#endif
+
--- a/widget/android/Makefile.in
+++ b/widget/android/Makefile.in
@@ -57,17 +57,17 @@ endif
 
 CPPSRCS	= \
 	GfxInfo.cpp \
 	nsWidgetFactory.cpp \
 	nsAppShell.cpp \
 	AndroidJavaWrappers.cpp \
 	AndroidBridge.cpp \
 	AndroidDirectTexture.cpp \
-	AndroidFlexViewWrapper.cpp \
+	AndroidLayerViewWrapper.cpp \
 	AndroidGraphicBuffer.cpp \
 	AndroidJNI.cpp \
 	AndroidMediaLayer.cpp \
 	nsWindow.cpp \
 	nsLookAndFeel.cpp \
 	nsScreenManagerAndroid.cpp \
 	nsIdleServiceAndroid.cpp \
 	nsClipboard.cpp \
@@ -87,17 +87,17 @@ NOT_THERE_YET_CPPSRCS = \
 	$(NULL)
 
 XPIDLSRCS	= \
 	nsIAndroidBridge.idl \
 	$(NULL)
 
 SHARED_LIBRARY_LIBS = ../xpwidgets/libxpwidgets_s.a
 
-EXPORTS = AndroidBridge.h AndroidJavaWrappers.h AndroidFlexViewWrapper.h
+EXPORTS = AndroidBridge.h AndroidJavaWrappers.h AndroidLayerViewWrapper.h
 
 include $(topsrcdir)/config/rules.mk
 
 DEFINES += -D_IMPL_NS_WIDGET
 #DEFINES += -DDEBUG_WIDGETS
 
 LOCAL_INCLUDES += \
 	-I$(topsrcdir)/widget/xpwidgets \