b=779936; can't use TextureView without android hardware accelerated windows (S3 bustage); r=snorp

This commit is contained in:
Vladimir Vukicevic 2012-08-03 13:40:33 -04:00
Родитель 82fd149d83
Коммит 1e624b347a
2 изменённых файлов: 28 добавлений и 7 удалений

Просмотреть файл

@ -50,6 +50,7 @@
<application android:label="@MOZ_APP_DISPLAYNAME@"
android:icon="@drawable/icon"
android:name="org.mozilla.gecko.GeckoApplication"
android:hardwareAccelerated="true"
#if MOZILLA_OFFICIAL
android:debuggable="false">
#else

Просмотреть файл

@ -19,6 +19,7 @@ import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.TextureView;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
@ -26,6 +27,8 @@ import android.widget.FrameLayout;
import java.nio.IntBuffer;
import java.lang.reflect.Method;
/**
* A view rendered by the layer compositor.
*
@ -56,21 +59,38 @@ public class LayerView extends FrameLayout {
public static final int PAINT_BEFORE_FIRST = 1;
public static final int PAINT_AFTER_FIRST = 2;
boolean shouldUseTextureView() {
// we can only use TextureView on ICS or higher
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
Log.i(LOGTAG, "Not using TextureView: not on ICS+");
return false;
}
try {
// and then we can only use it if we have a hardware accelerated window
Method m = View.class.getMethod("isHardwareAccelerated", new Class[0]);
return (Boolean) m.invoke(this);
} catch (Exception e) {
Log.i(LOGTAG, "Not using TextureView: caught exception checking for hw accel: " + e.toString());
return false;
}
}
public LayerView(Context context, AttributeSet attrs) {
super(context, attrs);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
if (shouldUseTextureView()) {
mTextureView = new TextureView(context);
mTextureView.setSurfaceTextureListener(new SurfaceTextureListener());
addView(mTextureView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
} else {
mSurfaceView = new SurfaceView(context);
addView(mSurfaceView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
SurfaceHolder holder = mSurfaceView.getHolder();
holder.addCallback(new SurfaceListener());
holder.setFormat(PixelFormat.RGB_565);
} else {
mTextureView = new TextureView(context);
mTextureView.setSurfaceTextureListener(new SurfaceTextureListener());
addView(mTextureView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
}
mGLController = new GLController(this);
@ -237,7 +257,7 @@ public class LayerView extends FrameLayout {
}
public Object getNativeWindow() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH)
if (mSurfaceView != null)
return mSurfaceView.getHolder();
return mTextureView.getSurfaceTexture();