Allow HW accleration to be activated on demand.
This CL adds a debugging preference that allows developers to
enable/disable Open GL rendering on demand. The setting change
does not take effect until the browser is restarted.
bug: 3185844
Change-Id: Ifcf5a7b7d4ddbf02a649a28c4f462e2da3f34bb6
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java
index b882338..ef26145 100644
--- a/src/com/android/browser/BrowserActivity.java
+++ b/src/com/android/browser/BrowserActivity.java
@@ -24,7 +24,6 @@
import android.app.ActionBar;
import android.app.Activity;
import android.app.AlertDialog;
-import android.app.Dialog;
import android.app.DownloadManager;
import android.app.ProgressDialog;
import android.app.SearchManager;
@@ -43,7 +42,6 @@
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.Configuration;
-import android.content.res.Resources;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
@@ -71,7 +69,6 @@
import android.provider.BrowserContract.Images;
import android.provider.ContactsContract;
import android.provider.ContactsContract.Intents.Insert;
-import android.provider.Downloads;
import android.provider.MediaStore;
import android.speech.RecognizerResultsIntent;
import android.text.TextUtils;
@@ -105,7 +102,6 @@
import android.webkit.WebIconDatabase;
import android.webkit.WebSettings;
import android.webkit.WebView;
-import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;
@@ -172,8 +168,19 @@
Log.v(LOGTAG, this + " onStart");
}
super.onCreate(icicle);
- // test the browser in OpenGL
- // requestWindowFeature(Window.FEATURE_OPENGL);
+
+ // Keep a settings instance handy.
+ mSettings = BrowserSettings.getInstance();
+
+ // render the browser in OpenGL
+ if (mSettings.isHardwareAccelerated()) {
+ // Set the flag in the activity's window
+ this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
+ WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
+ } else {
+ // Clear the flag in the activity's window
+ this.getWindow().setFlags(0, WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
+ }
// enable this to test the browser in 32bit
if (false) {
@@ -189,9 +196,6 @@
mResolver = getContentResolver();
- // Keep a settings instance handy.
- mSettings = BrowserSettings.getInstance();
-
// If this was a web search request, pass it on to the default web
// search provider and finish this activity.
if (handleWebSearchIntent(getIntent())) {