summaryrefslogtreecommitdiffstats
path: root/tests/TileBenchmark/src/com
diff options
context:
space:
mode:
authorJonathan Dixon <joth@google.com>2012-02-28 18:45:06 +0000
committerJonathan Dixon <joth@google.com>2012-03-02 11:17:47 +0000
commit3c90952036a5ff7ddb2946c643f1a0bf1c31d53a (patch)
tree974ef2a94c60a2c72b8fbd804613792480a9c3e5 /tests/TileBenchmark/src/com
parent0dc0da67d9775b2364a38d015e0610492708a02e (diff)
downloadframeworks_base-3c90952036a5ff7ddb2946c643f1a0bf1c31d53a.zip
frameworks_base-3c90952036a5ff7ddb2946c643f1a0bf1c31d53a.tar.gz
frameworks_base-3c90952036a5ff7ddb2946c643f1a0bf1c31d53a.tar.bz2
Refactor WebView to be a thin proxy class
Splits interface and implementation; all client calls are forwarded to an abstract WebViewProvider interface, and the existing implementation moved into the WebViewClassic implementor of this interface. Originally taken from a snapshot from the development branch, by: git diff HEAD 9a4c328a54cc05e5 | git apply - but then rebased to keep up to date with master Interdepends on webkit and Browser changes: https://android-git.corp.google.com/g/158979 https://android-git.corp.google.com/g/167911 Change-Id: I91403f32654ff308934e95c832d17b292a7d9b2e
Diffstat (limited to 'tests/TileBenchmark/src/com')
-rw-r--r--tests/TileBenchmark/src/com/test/tilebenchmark/ProfiledWebView.java52
1 files changed, 28 insertions, 24 deletions
diff --git a/tests/TileBenchmark/src/com/test/tilebenchmark/ProfiledWebView.java b/tests/TileBenchmark/src/com/test/tilebenchmark/ProfiledWebView.java
index a38ac25..87baf76 100644
--- a/tests/TileBenchmark/src/com/test/tilebenchmark/ProfiledWebView.java
+++ b/tests/TileBenchmark/src/com/test/tilebenchmark/ProfiledWebView.java
@@ -20,8 +20,9 @@ import android.content.Context;
import android.os.CountDownTimer;
import android.util.AttributeSet;
import android.util.Log;
-import android.webkit.WebSettings;
+import android.webkit.WebSettingsClassic;
import android.webkit.WebView;
+import android.webkit.WebViewClassic;
import android.widget.Toast;
import java.util.ArrayList;
@@ -29,7 +30,7 @@ import java.util.ArrayList;
import com.test.tilebenchmark.ProfileActivity.ProfileCallback;
import com.test.tilebenchmark.RunData.TileData;
-public class ProfiledWebView extends WebView {
+public class ProfiledWebView extends WebView implements WebViewClassic.PageSwapDelegate {
private static final String LOGTAG = "ProfiledWebView";
private int mSpeed;
@@ -80,7 +81,7 @@ public class ProfiledWebView extends WebView {
}
public void init(Context c) {
- WebSettings settings = getSettings();
+ WebSettingsClassic settings = getWebViewClassic().getSettings();
settings.setJavaScriptEnabled(true);
settings.setSupportZoom(true);
settings.setEnableSmoothTransition(true);
@@ -118,7 +119,7 @@ public class ProfiledWebView extends WebView {
mCallback = callback;
mIsTesting = false;
mIsScrolling = false;
- WebSettings settings = getSettings();
+ WebSettingsClassic settings = getWebViewClassic().getSettings();
settings.setProperty("tree_updates", "0");
@@ -134,7 +135,7 @@ public class ProfiledWebView extends WebView {
// invalidate all content, and kick off redraw
Log.d("ProfiledWebView",
"kicking off test with callback registration, and tile discard...");
- discardAllTextures();
+ getWebViewClassic().discardAllTextures();
invalidate();
mIsScrolling = true;
mContentInvalMillis = System.currentTimeMillis();
@@ -142,30 +143,29 @@ public class ProfiledWebView extends WebView {
}.start();
} else {
mIsTesting = true;
- tileProfilingStart();
+ getWebViewClassic().tileProfilingStart();
}
}
/*
* Called after the manual contentInvalidateAll, after the tiles have all
* been redrawn.
+ * From PageSwapDelegate.
*/
@Override
- protected void pageSwapCallback(boolean startAnim) {
- super.pageSwapCallback(startAnim);
-
+ public void onPageSwapOccurred(boolean startAnim) {
if (!mIsTesting && mIsScrolling) {
// kick off testing
mContentInvalMillis = System.currentTimeMillis() - mContentInvalMillis;
Log.d("ProfiledWebView", "REDRAW TOOK " + mContentInvalMillis + "millis");
mIsTesting = true;
invalidate(); // ensure a redraw so that auto-scrolling can occur
- tileProfilingStart();
+ getWebViewClassic().tileProfilingStart();
}
}
private double animFramerate() {
- WebSettings settings = getSettings();
+ WebSettingsClassic settings = getWebViewClassic().getSettings();
String updatesString = settings.getProperty("tree_updates");
int updates = (updatesString == null) ? -1 : Integer.parseInt(updatesString);
@@ -180,7 +180,7 @@ public class ProfiledWebView extends WebView {
}
public void setDoubleBuffering(boolean useDoubleBuffering) {
- WebSettings settings = getSettings();
+ WebSettingsClassic settings = getWebViewClassic().getSettings();
settings.setProperty("use_double_buffering", useDoubleBuffering ? "true" : "false");
}
@@ -188,15 +188,15 @@ public class ProfiledWebView extends WebView {
* Called once the page has stopped scrolling
*/
public void stopScrollTest() {
- tileProfilingStop();
+ getWebViewClassic().tileProfilingStop();
mIsTesting = false;
if (mCallback == null) {
- tileProfilingClear();
+ getWebViewClassic().tileProfilingClear();
return;
}
- RunData data = new RunData(super.tileProfilingNumFrames());
+ RunData data = new RunData(getWebViewClassic().tileProfilingNumFrames());
// record the time spent (before scrolling) rendering the page
data.singleStats.put(getResources().getString(R.string.render_millis),
(double)mContentInvalMillis);
@@ -209,24 +209,24 @@ public class ProfiledWebView extends WebView {
for (int frame = 0; frame < data.frames.length; frame++) {
data.frames[frame] = new TileData[
- tileProfilingNumTilesInFrame(frame)];
+ getWebViewClassic().tileProfilingNumTilesInFrame(frame)];
for (int tile = 0; tile < data.frames[frame].length; tile++) {
- int left = tileProfilingGetInt(frame, tile, "left");
- int top = tileProfilingGetInt(frame, tile, "top");
- int right = tileProfilingGetInt(frame, tile, "right");
- int bottom = tileProfilingGetInt(frame, tile, "bottom");
+ int left = getWebViewClassic().tileProfilingGetInt(frame, tile, "left");
+ int top = getWebViewClassic().tileProfilingGetInt(frame, tile, "top");
+ int right = getWebViewClassic().tileProfilingGetInt(frame, tile, "right");
+ int bottom = getWebViewClassic().tileProfilingGetInt(frame, tile, "bottom");
- boolean isReady = super.tileProfilingGetInt(
+ boolean isReady = getWebViewClassic().tileProfilingGetInt(
frame, tile, "isReady") == 1;
- int level = tileProfilingGetInt(frame, tile, "level");
+ int level = getWebViewClassic().tileProfilingGetInt(frame, tile, "level");
- float scale = tileProfilingGetFloat(frame, tile, "scale");
+ float scale = getWebViewClassic().tileProfilingGetFloat(frame, tile, "scale");
data.frames[frame][tile] = data.new TileData(left, top, right, bottom,
isReady, level, scale);
}
}
- tileProfilingClear();
+ getWebViewClassic().tileProfilingClear();
mCallback.profileCallback(data);
}
@@ -244,4 +244,8 @@ public class ProfiledWebView extends WebView {
public void setAutoScrollSpeed(int speedInt) {
mSpeed = speedInt;
}
+
+ public WebViewClassic getWebViewClassic() {
+ return WebViewClassic.fromWebView(this);
+ }
}