diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2015-02-15 14:13:56 +0900 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-02-23 10:10:20 +0100 |
commit | fd22d4b9b5e7bf9a1b54041f52a081d1a98e5332 (patch) | |
tree | 78dd8796b462bb82fb3c86f5e7943b13ab4e98c8 /android | |
parent | 23c4f26e2bccd4a1b41b7e9edcd155f674e1735d (diff) |
android: use mListener in LayerView for RenderControllerThread
Change-Id: I15b65f6eda04fce83831d8bee03b3840a1c15095
Diffstat (limited to 'android')
3 files changed, 23 insertions, 75 deletions
diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java index 4c3f87a38e35..6fdfc8b540f5 100644 --- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java +++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java @@ -20,7 +20,7 @@ import org.mozilla.gecko.util.FloatUtils; import java.util.List; -public class GeckoLayerClient implements PanZoomTarget, LayerView.Listener { +public class GeckoLayerClient implements PanZoomTarget { private static final String LOGTAG = GeckoLayerClient.class.getSimpleName(); private LayerRenderer mLayerRenderer; @@ -93,7 +93,6 @@ public class GeckoLayerClient implements PanZoomTarget, LayerView.Listener { mLayerRenderer = new LayerRenderer(mView); - mView.setListener(this); mView.setLayerRenderer(mLayerRenderer); sendResizeEventIfNecessary(); } @@ -252,38 +251,6 @@ public class GeckoLayerClient implements PanZoomTarget, LayerView.Listener { } } - /** Implementation of LayerView.Listener */ - @Override - public void renderRequested() { - } - - /** Implementation of LayerView.Listener */ - @Override - public void compositionPauseRequested() { - } - - /** Implementation of LayerView.Listener */ - @Override - public void compositionResumeRequested(int width, int height) { - } - - /** Implementation of LayerView.Listener */ - @Override - public void surfaceChanged(int width, int height) { - 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(width, height); - renderRequested(); - } - - /** Implementation of LayerView.Listener */ - @Override - public void compositorCreated() { - } - /** Implementation of PanZoomTarget */ public ImmutableViewportMetrics getViewportMetrics() { return mViewportMetrics; diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerView.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerView.java index 1b94fc4e3f50..b401fd4c90a4 100644 --- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerView.java +++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerView.java @@ -12,7 +12,6 @@ import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.PixelFormat; import android.graphics.SurfaceTexture; -import android.os.Build; import android.util.AttributeSet; import android.util.Log; import android.view.KeyEvent; @@ -24,16 +23,12 @@ import android.view.View; import android.view.ViewGroup; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputConnection; -import android.view.inputmethod.InputMethodManager; import android.widget.FrameLayout; import org.libreoffice.LibreOfficeMainActivity; import org.libreoffice.R; import org.mozilla.gecko.OnInterceptTouchListener; -import java.lang.reflect.Method; -import java.nio.IntBuffer; - /** * A view rendered by the layer compositor. * @@ -246,9 +241,6 @@ public class LayerView extends FrameLayout { } public void requestRender() { - if (mRenderControllerThread != null) { - mRenderControllerThread.renderFrame(); - } if (mListener != null) { mListener.renderRequested(); } @@ -324,9 +316,7 @@ public class LayerView extends FrameLayout { private void onSizeChanged(int width, int height) { mGLController.surfaceChanged(width, height); - if (mRenderControllerThread != null) { - mRenderControllerThread.surfaceChanged(width, height); - } + mLayerClient.setViewportSize(new FloatSize(width, height)); if (mListener != null) { mListener.surfaceChanged(width, height); @@ -336,10 +326,6 @@ public class LayerView extends FrameLayout { private void onDestroyed() { mGLController.surfaceDestroyed(); - if (mRenderControllerThread != null) { - mRenderControllerThread.surfaceDestroyed(); - } - if (mListener != null) { mListener.compositionPauseRequested(); } @@ -430,6 +416,7 @@ public class LayerView extends FrameLayout { Log.e(LOGTAG, "### Creating GL thread!"); mRenderControllerThread = new RenderControllerThread(mGLController); mRenderControllerThread.start(); + setListener(mRenderControllerThread); notifyAll(); } @@ -447,18 +434,11 @@ public class LayerView extends FrameLayout { Log.e(LOGTAG, "### Destroying GL thread!"); Thread thread = mRenderControllerThread; mRenderControllerThread.shutdown(); + setListener(null); mRenderControllerThread = null; return thread; } - public synchronized void recreateSurface() { - if (mRenderControllerThread == null) { - throw new LayerViewException("recreateSurface() called with no GL thread active!"); - } - - mRenderControllerThread.recreateSurface(); - } - public static class LayerViewException extends RuntimeException { public static final long serialVersionUID = 1L; diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/RenderControllerThread.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/RenderControllerThread.java index df710bf26142..dc211c4d40c7 100644 --- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/RenderControllerThread.java +++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/RenderControllerThread.java @@ -6,7 +6,7 @@ import java.util.concurrent.LinkedBlockingQueue; import javax.microedition.khronos.opengles.GL10; -public class RenderControllerThread extends Thread { +public class RenderControllerThread extends Thread implements LayerView.Listener { private LinkedBlockingQueue<RenderCommand> queue = new LinkedBlockingQueue<RenderCommand>(); private GLController controller; private boolean renderQueued = false; @@ -38,9 +38,6 @@ public class RenderControllerThread extends Thread { case SHUTDOWN: doShutdown(); break; - case RECREATE_SURFACE: - doRecreateSurface(); - break; case RENDER_FRAME: doRenderFrame(); break; @@ -56,11 +53,17 @@ public class RenderControllerThread extends Thread { } } - public void recreateSurface() { - queue.add(RenderCommand.RECREATE_SURFACE); + public void shutdown() { + queue.add(RenderCommand.SHUTDOWN); + } + + @Override + public void compositorCreated() { + } - public void renderFrame() { + @Override + public void renderRequested() { synchronized (this) { if (!renderQueued) { queue.add(RenderCommand.RENDER_FRAME); @@ -69,10 +72,17 @@ public class RenderControllerThread extends Thread { } } - public void shutdown() { - queue.add(RenderCommand.SHUTDOWN); + @Override + public void compositionPauseRequested() { + queue.add(RenderCommand.SURFACE_DESTROYED); } + @Override + public void compositionResumeRequested(int width, int height) { + + } + + @Override public void surfaceChanged(int width, int height) { this.width = width; this.height = height; @@ -83,15 +93,6 @@ public class RenderControllerThread extends Thread { queue.add(RenderCommand.SURFACE_CREATED); } - public void surfaceDestroyed() { - queue.add(RenderCommand.SURFACE_DESTROYED); - } - - private void doRecreateSurface() { - controller.disposeGLContext(); - controller.initGLContext(); - } - private GLSurfaceView.Renderer getRenderer() { return controller.getView().getRenderer(); } |