Remove RemoveAbstractView, pushing new head

This commit is contained in:
Benoit Girard 2012-02-08 10:46:26 -05:00
parent 79f5549c0a
commit 9b2cd37240
12 changed files with 29 additions and 245 deletions

View File

@ -1612,7 +1612,7 @@ abstract public class GeckoApp
mPlaceholderLayerClient = PlaceholderLayerClient.createInstance(this);
mLayerController.setLayerClient(mPlaceholderLayerClient);
mGeckoLayout.addView(mLayerController.getView().getAndroidView(), 0);
mGeckoLayout.addView(mLayerController.getView(), 0);
}
mPluginContainer = (AbsoluteLayout) findViewById(R.id.plugin_container);

View File

@ -41,7 +41,7 @@ package org.mozilla.gecko;
import org.mozilla.gecko.gfx.BitmapUtils;
import org.mozilla.gecko.gfx.GeckoLayerClient;
import org.mozilla.gecko.gfx.LayerController;
import org.mozilla.gecko.gfx.AbstractLayerView;
import org.mozilla.gecko.gfx.LayerView;
import java.io.*;
import java.lang.reflect.*;
@ -501,7 +501,7 @@ public class GeckoAppShell
// Called on the UI thread after Gecko loads.
private static void geckoLoaded() {
final LayerController layerController = GeckoApp.mAppContext.getLayerController();
AbstractLayerView v = layerController.getView();
LayerView v = layerController.getView();
mInputConnection = v.setInputConnectionHandler();
layerController.setOnTouchListener(new View.OnTouchListener() {
@ -586,7 +586,7 @@ public class GeckoAppShell
static Sensor gOrientationSensor = null;
public static void enableDeviceMotion(boolean enable) {
AbstractLayerView v = GeckoApp.mAppContext.getLayerController().getView();
LayerView v = GeckoApp.mAppContext.getLayerController().getView();
SensorManager sm = (SensorManager) v.getContext().getSystemService(Context.SENSOR_SERVICE);
if (gAccelerometerSensor == null || gOrientationSensor == null) {
@ -610,8 +610,6 @@ public class GeckoAppShell
public static void enableLocation(final boolean enable) {
getMainHandler().post(new Runnable() {
public void run() {
//AbstractLayerView v = GeckoApp.mAppContext.getLayerController().getView();
LocationManager lm = (LocationManager)
GeckoApp.mAppContext.getSystemService(Context.LOCATION_SERVICE);
@ -1084,15 +1082,15 @@ public class GeckoAppShell
public static void performHapticFeedback(boolean aIsLongPress) {
LayerController layerController = GeckoApp.mAppContext.getLayerController();
AbstractLayerView layerView = layerController.getView();
layerView.getAndroidView().performHapticFeedback(aIsLongPress ?
LayerView layerView = layerController.getView();
layerView.performHapticFeedback(aIsLongPress ?
HapticFeedbackConstants.LONG_PRESS :
HapticFeedbackConstants.VIRTUAL_KEY);
}
private static Vibrator vibrator() {
LayerController layerController = GeckoApp.mAppContext.getLayerController();
AbstractLayerView layerView = layerController.getView();
LayerView layerView = layerController.getView();
return (Vibrator) layerView.getContext().getSystemService(Context.VIBRATOR_SERVICE);
}
@ -1774,7 +1772,7 @@ public class GeckoAppShell
return;
LayerController layerController = GeckoApp.mAppContext.getLayerController();
AbstractLayerView layerView = layerController.getView();
LayerView layerView = layerController.getView();
AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
event.setClassName(layerView.getClass().getName() + "$" + role);

View File

@ -385,7 +385,7 @@ public class GeckoInputConnection
if (mUpdateRequest == null)
return;
View v = GeckoApp.mAppContext.getLayerController().getView().getAndroidView();
View v = GeckoApp.mAppContext.getLayerController().getView();
if (imm == null) {
imm = (InputMethodManager)v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
@ -436,7 +436,7 @@ public class GeckoInputConnection
}
if (imm != null && imm.isFullscreenMode()) {
View v = GeckoApp.mAppContext.getLayerController().getView().getAndroidView();
View v = GeckoApp.mAppContext.getLayerController().getView();
imm.updateSelection(v, start, end, -1, -1);
}
}
@ -669,7 +669,7 @@ public class GeckoInputConnection
// Let active IME process pre-IME key events
return false;
View v = GeckoApp.mAppContext.getLayerController().getView().getAndroidView();
View v = GeckoApp.mAppContext.getLayerController().getView();
// KeyListener returns true if it handled the event for us.
if (mIMEState == IME_STATE_DISABLED ||
@ -711,7 +711,7 @@ public class GeckoInputConnection
// Let active IME process pre-IME key events
return false;
View v = GeckoApp.mAppContext.getLayerController().getView().getAndroidView();
View v = GeckoApp.mAppContext.getLayerController().getView();
if (mIMEState == IME_STATE_DISABLED ||
keyCode == KeyEvent.KEYCODE_ENTER ||
@ -728,7 +728,7 @@ public class GeckoInputConnection
}
public boolean onKeyLongPress(int keyCode, KeyEvent event) {
View v = GeckoApp.mAppContext.getLayerController().getView().getAndroidView();
View v = GeckoApp.mAppContext.getLayerController().getView();
switch (keyCode) {
case KeyEvent.KEYCODE_MENU:
InputMethodManager imm = (InputMethodManager)
@ -748,7 +748,7 @@ public class GeckoInputConnection
}
public void notifyIME(int type, int state) {
View v = GeckoApp.mAppContext.getLayerController().getView().getAndroidView();
View v = GeckoApp.mAppContext.getLayerController().getView();
if (v == null)
return;
@ -792,7 +792,7 @@ public class GeckoInputConnection
public void notifyIMEEnabled(int state, String typeHint,
String actionHint, boolean landscapeFS)
{
View v = GeckoApp.mAppContext.getLayerController().getView().getAndroidView();
View v = GeckoApp.mAppContext.getLayerController().getView();
if (v == null)
return;
@ -808,7 +808,7 @@ public class GeckoInputConnection
public void notifyIMEChange(String text, int start, int end, int newEnd) {
View v = GeckoApp.mAppContext.getLayerController().getView().getAndroidView();
View v = GeckoApp.mAppContext.getLayerController().getView();
if (v == null)
return;
@ -867,7 +867,7 @@ public class GeckoInputConnection
instance = null;
}
View v = GeckoApp.mAppContext.getLayerController().getView().getAndroidView();
View v = GeckoApp.mAppContext.getLayerController().getView();
if (DEBUG) Log.d(LOGTAG, "IME: v="+v);
InputMethodManager imm = (InputMethodManager) v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);

View File

@ -101,7 +101,6 @@ FENNEC_JAVA_FILES = \
Tab.java \
Tabs.java \
TabsTray.java \
gfx/AbstractLayerView.java \
gfx/BitmapUtils.java \
gfx/BufferedCairoImage.java \
gfx/CairoGLInfo.java \

View File

@ -1,62 +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) 2009-2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Benoit Girard <bgirard@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 android.content.Context;
import android.widget.RelativeLayout;
import android.view.View;
import org.mozilla.gecko.gfx.LayerController;
import org.mozilla.gecko.gfx.InputConnectionHandler;
import org.mozilla.gecko.GeckoInputConnection;
public interface AbstractLayerView {
public LayerController getController();
public GeckoInputConnection setInputConnectionHandler();
public View getAndroidView();
/** The LayerRenderer calls this to indicate that the window has changed size. */
public void setViewportSize(IntSize size);
public void requestRender();
public boolean post(Runnable action);
public boolean postDelayed(Runnable action, long delayMillis);
public Context getContext();
public int getMaxTextureSize();
public void clearEventQueue();
public void processEventQueue();
}

View File

@ -53,7 +53,7 @@ public abstract class Layer {
private Point mNewOrigin;
private float mResolution;
private float mNewResolution;
private AbstractLayerView mView;
private LayerView mView;
public Layer() {
mTransactionLock = new ReentrantLock();
@ -111,7 +111,7 @@ public abstract class Layer {
*
* This function may block, so you should never call this on the main UI thread.
*/
public void beginTransaction(AbstractLayerView aView) {
public void beginTransaction(LayerView aView) {
if (mTransactionLock.isHeldByCurrentThread())
throw new RuntimeException("Nested transactions are not supported");
mTransactionLock.lock();

View File

@ -54,11 +54,11 @@ public abstract class LayerClient {
/**
* A utility function for calling Layer.beginTransaction with the
* appropriate AbstractLayerView.
* appropriate LayerView.
*/
public void beginTransaction(Layer aLayer) {
if (mLayerController != null) {
AbstractLayerView view = mLayerController.getView();
LayerView view = mLayerController.getView();
if (view != null) {
aLayer.beginTransaction(view);
return;

View File

@ -41,7 +41,6 @@ package org.mozilla.gecko.gfx;
import org.mozilla.gecko.gfx.IntSize;
import org.mozilla.gecko.gfx.Layer;
import org.mozilla.gecko.gfx.LayerClient;
import org.mozilla.gecko.gfx.AbstractLayerView;
import org.mozilla.gecko.ui.PanZoomController;
import org.mozilla.gecko.ui.SimpleScaleGestureDetector;
import org.mozilla.gecko.GeckoApp;
@ -75,7 +74,7 @@ public class LayerController {
private static final String LOGTAG = "GeckoLayerController";
private Layer mRootLayer; /* The root layer. */
private AbstractLayerView mView; /* The main rendering view. */
private LayerView mView; /* The main rendering view. */
private Context mContext; /* The current context. */
private ViewportMetrics mViewportMetrics; /* The current viewport metrics. */
private boolean mWaitForTouchListeners;
@ -136,7 +135,7 @@ public class LayerController {
public LayerClient getLayerClient() { return mLayerClient; }
public Layer getRoot() { return mRootLayer; }
public AbstractLayerView getView() { return mView; }
public LayerView getView() { return mView; }
public Context getContext() { return mContext; }
public ViewportMetrics getViewportMetrics() { return mViewportMetrics; }
@ -403,7 +402,7 @@ public class LayerController {
}
if (mOnTouchListener != null)
mOnTouchListener.onTouch(mView.getAndroidView(), event);
mOnTouchListener.onTouch(mView, event);
if (!mWaitForTouchListeners)
return !allowDefaultActions;

View File

@ -42,7 +42,6 @@ import org.mozilla.gecko.gfx.BufferedCairoImage;
import org.mozilla.gecko.gfx.IntSize;
import org.mozilla.gecko.gfx.Layer.RenderContext;
import org.mozilla.gecko.gfx.LayerController;
import org.mozilla.gecko.gfx.AbstractLayerView;
import org.mozilla.gecko.gfx.NinePatchTileLayer;
import org.mozilla.gecko.gfx.SingleTileLayer;
import org.mozilla.gecko.gfx.TextureReaper;
@ -78,7 +77,7 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
private static final int FRAME_RATE_METER_WIDTH = 64;
private static final int FRAME_RATE_METER_HEIGHT = 32;
private final AbstractLayerView mView;
private final LayerView mView;
private final SingleTileLayer mBackgroundLayer;
private final CheckerboardImage mCheckerboardImage;
private final SingleTileLayer mCheckerboardLayer;
@ -98,7 +97,7 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
/* Used by robocop for testing purposes */
private IntBuffer mPixelBuffer;
public LayerRenderer(AbstractLayerView view) {
public LayerRenderer(LayerView view) {
mView = view;
LayerController controller = view.getController();
@ -263,7 +262,7 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
/** Used by robocop for testing purposes. Not for production use! */
IntBuffer getPixels() {
IntBuffer pixelBuffer = IntBuffer.allocate(mView.getAndroidView().getWidth() * mView.getAndroidView().getHeight());
IntBuffer pixelBuffer = IntBuffer.allocate(mView.getWidth() * mView.getHeight());
synchronized (pixelBuffer) {
mPixelBuffer = pixelBuffer;
mView.requestRender();

View File

@ -69,8 +69,7 @@ import org.json.JSONObject;
* This view delegates to LayerRenderer to actually do the drawing. Its role is largely that of a
* mediator between the LayerRenderer and the LayerController.
*/
public class LayerView extends FlexibleGLSurfaceView implements AbstractLayerView,
GeckoEventListener {
public class LayerView extends FlexibleGLSurfaceView implements GeckoEventListener {
private Context mContext;
private LayerController mController;
private InputConnectionHandler mInputConnectionHandler;
@ -246,10 +245,6 @@ public class LayerView extends FlexibleGLSurfaceView implements AbstractLayerVie
return mRenderer.getMaxTextureSize();
}
public View getAndroidView() {
return this;
}
/** Used by robocop for testing purposes. Not for production use! This is called via reflection by robocop. */
public IntBuffer getPixels() {
return mRenderer.getPixels();

View File

@ -383,7 +383,7 @@ public class MultiTileLayer extends Layer {
}
@Override
public void beginTransaction(AbstractLayerView aView) {
public void beginTransaction(LayerView aView) {
super.beginTransaction(aView);
for (SubTile layer : mTiles) {

View File

@ -1,144 +0,0 @@
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; 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
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Benoit Girard <bgirard@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.layers;
import android.content.Context;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.util.Log;
import android.view.View;
import org.mozilla.gecko.GeckoApp;
import org.mozilla.gecko.gfx.*;
import org.mozilla.gecko.GeckoInputConnection;
public class OGLSurfaceView implements AbstractLayerView {
private static final String LOGTAG = "OGLSurfaceView";
// Used by registerCompositor to replace the temporary java compositor
private static LayerController mLayerController;
private Context mContext;
private LayerController mController;
private InputConnectionHandler mInputConnectionHandler;
public OGLSurfaceView(Context context, LayerController controller) {
// Constructed on the main thread
mContext = context;
mController = controller;
System.out.println("construct");
}
public SurfaceHolder getHolder() {
System.out.println("Get Holder");
return null;
}
// Called from the Java thread
public static void registerLayerController(LayerController layerController) {
System.out.println("register layer controller");
synchronized (OGLSurfaceView.class) {
mLayerController = layerController;
OGLSurfaceView.class.notifyAll();
}
}
// Called from the compositor thread
public static void registerCompositor() {
System.out.println("register layer comp");
synchronized (OGLSurfaceView.class) {
// Wait for the layer controller if by some miracle
// gecko beats the java thread here.
while (mLayerController == null) {
try {
OGLSurfaceView.class.wait();
} catch (InterruptedException e) {}
}
final LayerController controller = mLayerController;
GeckoApp.mAppContext.runOnUiThread(new Runnable() {
public void run() {
synchronized (OGLSurfaceView.class) {
OGLSurfaceView surfaceView =
new OGLSurfaceView(controller.getContext(), controller);
OGLSurfaceView.class.notifyAll();
}
}
});
// Wait for the compositor to be setup on the
// Java UI thread.
try {
OGLSurfaceView.class.wait();
} catch (InterruptedException e) {}
}
}
public static native void setSurfaceView(SurfaceView sv);
public LayerController getController() {
return mController;
}
public GeckoInputConnection setInputConnectionHandler() {
GeckoInputConnection geckoInputConnection = GeckoInputConnection.create(getAndroidView());
mInputConnectionHandler = geckoInputConnection;
return geckoInputConnection;
}
public View getAndroidView() {
return null;
}
/** The LayerRenderer calls this to indicate that the window has changed size. */
public void setViewportSize(IntSize size) {}
public void requestRender() {}
public boolean post(Runnable action) { return false; }
public boolean postDelayed(Runnable action, long delayMillis) { return false; }
public Context getContext() { return mContext; }
public int getMaxTextureSize() { return 1024; }
public void clearEventQueue() {}
public void processEventQueue() {}
private class InternalSurfaceView extends SurfaceView {
public InternalSurfaceView() {
super(OGLSurfaceView.this.mContext);
}
}
}