summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDerek Sollenberger <djsollen@google.com>2010-11-16 14:19:01 -0500
committerDerek Sollenberger <djsollen@google.com>2010-11-16 15:41:13 -0500
commitffa561e00d3934de9451bf599a2d4f355a33041b (patch)
tree76cc8a2a5947678f0b6d6e5e275cd9f954602ae0
parente5e8175d73f3e6e0176d84117797ac0165c54b0c (diff)
downloadpackages_apps_Browser-ffa561e00d3934de9451bf599a2d4f355a33041b.zip
packages_apps_Browser-ffa561e00d3934de9451bf599a2d4f355a33041b.tar.gz
packages_apps_Browser-ffa561e00d3934de9451bf599a2d4f355a33041b.tar.bz2
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
-rw-r--r--res/values/strings.xml2
-rw-r--r--res/xml/debug_preferences.xml5
-rw-r--r--src/com/android/browser/BrowserActivity.java22
-rw-r--r--src/com/android/browser/BrowserSettings.java11
4 files changed, 31 insertions, 9 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml
index a6ad15e..d724085 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -520,6 +520,8 @@
<!-- Do not tranlsate. Development option -->
<string name="pref_development_nav_dump" translatable="false">Enable nav cache dump</string>
<!-- Do not tranlsate. Development option -->
+ <string name="pref_development_hardware_accel" translatable="false">Enable OpenGL Rendering</string>
+ <!-- Do not tranlsate. Development option -->
<string name="js_engine_flags" translatable="false">Set JS flags</string>
<!-- Do not tranlsate. Development option -->
<string name="pref_development_uastring" translatable="false">UAString</string>
diff --git a/res/xml/debug_preferences.xml b/res/xml/debug_preferences.xml
index 54b2bd5..2ff4e79 100644
--- a/res/xml/debug_preferences.xml
+++ b/res/xml/debug_preferences.xml
@@ -54,6 +54,11 @@
android:defaultValue="false"
android:title="@string/pref_development_nav_dump" />
+ <CheckBoxPreference
+ android:key="enable_hardware_accel"
+ android:defaultValue="false"
+ android:title="@string/pref_development_hardware_accel" />
+
<EditTextPreference
android:key="js_engine_flags"
android:title="@string/js_engine_flags"
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 com.android.common.speech.LoggingEvents;
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.IntentFilter;
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;
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.WebHistoryItem;
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 @@ public class BrowserActivity extends Activity
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 @@ public class BrowserActivity extends Activity
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())) {
diff --git a/src/com/android/browser/BrowserSettings.java b/src/com/android/browser/BrowserSettings.java
index 99de9dc..44842be 100644
--- a/src/com/android/browser/BrowserSettings.java
+++ b/src/com/android/browser/BrowserSettings.java
@@ -115,6 +115,7 @@ public class BrowserSettings extends Observable {
private boolean tracing = false;
private boolean lightTouch = false;
private boolean navDump = false;
+ private boolean hardwareAccelerated = false;
// By default the error console is shown once the user navigates to about:debug.
// The setting can be then toggled from the settings menu.
@@ -446,6 +447,12 @@ public class BrowserSettings extends Observable {
navDump = p.getBoolean("enable_nav_dump", navDump);
userAgent = Integer.parseInt(p.getString("user_agent", "0"));
}
+
+ // This setting can only be modified when the debug settings have been
+ // enabled but it is read and used by the browser at startup so we must
+ // initialize it regardless of the status of the debug settings.
+ hardwareAccelerated = p.getBoolean("enable_hardware_accel", hardwareAccelerated);
+
// JS flags is loaded from DB even if showDebugSettings is false,
// so that it can be set once and be effective all the time.
jsFlags = p.getString("js_engine_flags", "");
@@ -519,6 +526,10 @@ public class BrowserSettings extends Observable {
return navDump;
}
+ public boolean isHardwareAccelerated() {
+ return hardwareAccelerated;
+ }
+
public boolean showDebugSettings() {
return showDebugSettings;
}