summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2014-06-30 14:17:18 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-06-27 15:56:14 +0000
commit711ecaf000f66ea8e68e3d6fc8fe9212d1882e2a (patch)
tree766f4a9867cd3146318716070ecf34d40f159c15 /core/java/android
parent37271629b5bcf54858d6b4c4f5dbde6e85614d79 (diff)
parent918ad523b2780e0c893f3d2a32d4ec13f2a7e921 (diff)
Merge "More cleanups"
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/view/HardwareLayer.java23
-rw-r--r--core/java/android/view/HardwareRenderer.java30
-rw-r--r--core/java/android/view/TextureView.java11
-rw-r--r--core/java/android/view/ThreadedRenderer.java29
-rw-r--r--core/java/android/view/ViewRootImpl.java19
5 files changed, 13 insertions, 99 deletions
diff --git a/core/java/android/view/HardwareLayer.java b/core/java/android/view/HardwareLayer.java
index 266a6feda0a6..0c2e944d94b8 100644
--- a/core/java/android/view/HardwareLayer.java
+++ b/core/java/android/view/HardwareLayer.java
@@ -122,16 +122,8 @@ final class HardwareLayer {
/**
* Indicates that this layer has lost its texture.
*/
- public void detachSurfaceTexture(final SurfaceTexture surface) {
- mRenderer.safelyRun(new Runnable() {
- @Override
- public void run() {
- surface.detachFromGLContext();
- // SurfaceTexture owns the texture name and detachFromGLContext
- // should have deleted it
- nOnTextureDestroyed(mFinalizer.get());
- }
- });
+ public void detachSurfaceTexture() {
+ mRenderer.detachSurfaceTexture(mFinalizer.get());
}
public long getLayer() {
@@ -148,21 +140,10 @@ final class HardwareLayer {
mRenderer.pushLayerUpdate(this);
}
- /**
- * This should only be used by HardwareRenderer! Do not call directly
- */
- SurfaceTexture createSurfaceTexture() {
- SurfaceTexture st = new SurfaceTexture(nGetTexName(mFinalizer.get()));
- nSetSurfaceTexture(mFinalizer.get(), st, true);
- return st;
- }
-
static HardwareLayer adoptTextureLayer(HardwareRenderer renderer, long layer) {
return new HardwareLayer(renderer, layer);
}
- private static native void nOnTextureDestroyed(long layerUpdater);
-
private static native boolean nPrepare(long layerUpdater, int width, int height, boolean isOpaque);
private static native void nSetLayerPaint(long layerUpdater, long paint);
private static native void nSetTransform(long layerUpdater, long matrix);
diff --git a/core/java/android/view/HardwareRenderer.java b/core/java/android/view/HardwareRenderer.java
index cfb4af2a385f..e9bdcae1f25d 100644
--- a/core/java/android/view/HardwareRenderer.java
+++ b/core/java/android/view/HardwareRenderer.java
@@ -245,15 +245,10 @@ public abstract class HardwareRenderer {
abstract void invalidate(Surface surface);
/**
- * This method ensures the hardware renderer is in a valid state
- * before executing the specified action.
- *
- * This method will attempt to set a valid state even if the window
- * the renderer is attached to was destroyed.
- *
- * @return true if the action was run
+ * Detaches the layer's surface texture from the GL context and releases
+ * the texture id
*/
- abstract boolean safelyRun(Runnable action);
+ abstract void detachSurfaceTexture(long hardwareLayer);
/**
* Setup the hardware renderer for drawing. This is called whenever the
@@ -315,8 +310,6 @@ public abstract class HardwareRenderer {
* as soon as possible.
*
* @param layer The hardware layer that needs an update
- *
- * @see #flushLayerUpdates()
*/
abstract void pushLayerUpdate(HardwareLayer layer);
@@ -327,13 +320,6 @@ public abstract class HardwareRenderer {
abstract void onLayerDestroyed(HardwareLayer layer);
/**
- * Forces all enqueued layer updates to be executed immediately.
- *
- * @see #pushLayerUpdate(HardwareLayer)
- */
- abstract void flushLayerUpdates();
-
- /**
* Interface used to receive callbacks whenever a view is drawn by
* a hardware renderer instance.
*/
@@ -374,16 +360,6 @@ public abstract class HardwareRenderer {
*/
abstract HardwareLayer createTextureLayer();
- /**
- * Creates a new {@link SurfaceTexture} that can be used to render into the
- * specified hardware layer.
- *
- * @param layer The layer to render into using a {@link android.graphics.SurfaceTexture}
- *
- * @return A {@link SurfaceTexture}
- */
- abstract SurfaceTexture createSurfaceTexture(HardwareLayer layer);
-
abstract boolean copyLayerInto(HardwareLayer layer, Bitmap bitmap);
/**
diff --git a/core/java/android/view/TextureView.java b/core/java/android/view/TextureView.java
index 1f7eaa2dc333..59ec058b35dd 100644
--- a/core/java/android/view/TextureView.java
+++ b/core/java/android/view/TextureView.java
@@ -122,8 +122,7 @@ public class TextureView extends View {
private int mSaveCount;
private final Object[] mNativeWindowLock = new Object[0];
- // Used from native code, do not write!
- @SuppressWarnings({"UnusedDeclaration"})
+ // Set by native code, do not write!
private long mNativeWindow;
/**
@@ -142,7 +141,6 @@ public class TextureView extends View {
* @param context The context to associate this view with.
* @param attrs The attributes of the XML tag that is inflating the view.
*/
- @SuppressWarnings({"UnusedDeclaration"})
public TextureView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
@@ -157,7 +155,6 @@ public class TextureView extends View {
* reference to a style resource that supplies default values for
* the view. Can be 0 to not look for defaults.
*/
- @SuppressWarnings({"UnusedDeclaration"})
public TextureView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
@@ -176,7 +173,6 @@ public class TextureView extends View {
* defStyleAttr is 0 or can not be found in the theme. Can be 0
* to not look for defaults.
*/
- @SuppressWarnings({"UnusedDeclaration"})
public TextureView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
init();
@@ -234,7 +230,7 @@ public class TextureView extends View {
private void destroySurface() {
if (mLayer != null) {
- mLayer.detachSurfaceTexture(mSurface);
+ mLayer.detachSurfaceTexture();
boolean shouldRelease = true;
if (mListener != null) {
@@ -362,7 +358,8 @@ public class TextureView extends View {
mLayer = mAttachInfo.mHardwareRenderer.createTextureLayer();
if (!mUpdateSurface) {
// Create a new SurfaceTexture for the layer.
- mSurface = mAttachInfo.mHardwareRenderer.createSurfaceTexture(mLayer);
+ mSurface = new SurfaceTexture(false);
+ mLayer.setSurfaceTexture(mSurface);
}
mSurface.setDefaultBufferSize(getWidth(), getHeight());
nCreateNativeWindow(mSurface);
diff --git a/core/java/android/view/ThreadedRenderer.java b/core/java/android/view/ThreadedRenderer.java
index bfab65493f15..45714ff872c8 100644
--- a/core/java/android/view/ThreadedRenderer.java
+++ b/core/java/android/view/ThreadedRenderer.java
@@ -19,8 +19,6 @@ package android.view;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
-import android.graphics.Rect;
-import android.graphics.SurfaceTexture;
import android.graphics.drawable.Drawable;
import android.os.IBinder;
import android.os.RemoteException;
@@ -35,9 +33,6 @@ import android.view.View.AttachInfo;
import java.io.FileDescriptor;
import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
import java.util.HashSet;
/**
@@ -152,9 +147,8 @@ public class ThreadedRenderer extends HardwareRenderer {
}
@Override
- boolean safelyRun(Runnable action) {
- nRunWithGlContext(mNativeProxy, action);
- return true;
+ void detachSurfaceTexture(long hardwareLayer) {
+ nDetachSurfaceTexture(mNativeProxy, hardwareLayer);
}
@Override
@@ -270,18 +264,6 @@ public class ThreadedRenderer extends HardwareRenderer {
}
@Override
- SurfaceTexture createSurfaceTexture(final HardwareLayer layer) {
- final SurfaceTexture[] ret = new SurfaceTexture[1];
- nRunWithGlContext(mNativeProxy, new Runnable() {
- @Override
- public void run() {
- ret[0] = layer.createSurfaceTexture();
- }
- });
- return ret[0];
- }
-
- @Override
boolean copyLayerInto(final HardwareLayer layer, final Bitmap bitmap) {
return nCopyLayerInto(mNativeProxy,
layer.getDeferredLayerUpdater(), bitmap.mNativeBitmap);
@@ -293,11 +275,6 @@ public class ThreadedRenderer extends HardwareRenderer {
}
@Override
- void flushLayerUpdates() {
- // TODO: Figure out what this should do or remove it
- }
-
- @Override
void onLayerDestroyed(HardwareLayer layer) {
nCancelLayerUpdate(mNativeProxy, layer.getDeferredLayerUpdater());
}
@@ -415,7 +392,6 @@ public class ThreadedRenderer extends HardwareRenderer {
private static native void nSetOpaque(long nativeProxy, boolean opaque);
private static native int nSyncAndDrawFrame(long nativeProxy,
long frameTimeNanos, long recordDuration, float density);
- private static native void nRunWithGlContext(long nativeProxy, Runnable runnable);
private static native void nDestroyCanvasAndSurface(long nativeProxy);
private static native void nInvokeFunctor(long functor, boolean waitForCompletion);
@@ -425,6 +401,7 @@ public class ThreadedRenderer extends HardwareRenderer {
private static native boolean nCopyLayerInto(long nativeProxy, long layer, long bitmap);
private static native void nPushLayerUpdate(long nativeProxy, long layer);
private static native void nCancelLayerUpdate(long nativeProxy, long layer);
+ private static native void nDetachSurfaceTexture(long nativeProxy, long layer);
private static native void nFlushCaches(long nativeProxy, int flushMode);
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 84e30c6f171b..4c9d3f946cd7 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -640,17 +640,6 @@ public final class ViewRootImpl implements ViewParent,
// TODO Implement
}
- void flushHardwareLayerUpdates() {
- if (mAttachInfo.mHardwareRenderer != null && mAttachInfo.mHardwareRenderer.isEnabled()) {
- mAttachInfo.mHardwareRenderer.flushLayerUpdates();
- }
- }
-
- void dispatchFlushHardwareLayerUpdates() {
- mHandler.removeMessages(MSG_FLUSH_LAYER_UPDATES);
- mHandler.sendMessageAtFrontOfQueue(mHandler.obtainMessage(MSG_FLUSH_LAYER_UPDATES));
- }
-
public void detachFunctor(long functor) {
// TODO: Make the resize buffer some other way to not need this block
mBlockResizeBuffer = true;
@@ -2999,8 +2988,7 @@ public final class ViewRootImpl implements ViewParent,
private final static int MSG_DISPATCH_DONE_ANIMATING = 22;
private final static int MSG_INVALIDATE_WORLD = 23;
private final static int MSG_WINDOW_MOVED = 24;
- private final static int MSG_FLUSH_LAYER_UPDATES = 25;
- private final static int MSG_SYNTHESIZE_INPUT_EVENT = 26;
+ private final static int MSG_SYNTHESIZE_INPUT_EVENT = 25;
final class ViewRootHandler extends Handler {
@Override
@@ -3048,8 +3036,6 @@ public final class ViewRootImpl implements ViewParent,
return "MSG_DISPATCH_DONE_ANIMATING";
case MSG_WINDOW_MOVED:
return "MSG_WINDOW_MOVED";
- case MSG_FLUSH_LAYER_UPDATES:
- return "MSG_FLUSH_LAYER_UPDATES";
case MSG_SYNTHESIZE_INPUT_EVENT:
return "MSG_SYNTHESIZE_INPUT_EVENT";
}
@@ -3277,9 +3263,6 @@ public final class ViewRootImpl implements ViewParent,
invalidateWorld(mView);
}
} break;
- case MSG_FLUSH_LAYER_UPDATES: {
- flushHardwareLayerUpdates();
- } break;
}
}
}