am 7c72a8f9: Merge "Fix perf regression from scale/density mismatch" into jb-mr1-dev

* commit '7c72a8f94ae3abf4eef9247017c0424a3c83c39a':
  Fix perf regression from scale/density mismatch
This commit is contained in:
John Reck
2012-09-27 19:56:53 -07:00
committed by Android Git Automerger
3 changed files with 13 additions and 7 deletions

View File

@@ -1025,7 +1025,7 @@ class BrowserFrame extends Handler {
}
private float density() {
return mContext.getResources().getDisplayMetrics().density;
return WebViewCore.getFixedDisplayDensity(mContext);
}
/**

View File

@@ -1664,7 +1664,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
mTouchSlopSquare = slop * slop;
slop = configuration.getScaledDoubleTapSlop();
mDoubleTapSlopSquare = slop * slop;
final float density = mContext.getResources().getDisplayMetrics().density;
final float density = WebViewCore.getFixedDisplayDensity(mContext);
// use one line height, 16 based on our current default font, for how
// far we allow a touch be away from the edge of a link
mNavSlop = (int) (16 * density);
@@ -1809,7 +1809,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
}
/* package */ void adjustDefaultZoomDensity(int zoomDensity) {
final float density = mContext.getResources().getDisplayMetrics().density
final float density = WebViewCore.getFixedDisplayDensity(mContext)
* 100 / zoomDensity;
updateDefaultZoomDensity(density);
}

View File

@@ -2479,6 +2479,13 @@ public final class WebViewCore {
setupViewport(true);
}
static float getFixedDisplayDensity(Context context) {
// We make bad assumptions about multiplying and dividing density by 100,
// force them to be true with this hack
float density = context.getResources().getDisplayMetrics().density;
return ((int) (density * 100)) / 100.0f;
}
private void setupViewport(boolean updateViewState) {
if (mWebViewClassic == null || mSettings == null) {
// We've been destroyed or are being destroyed, return early
@@ -2523,14 +2530,13 @@ public final class WebViewCore {
// adjust the default scale to match the densityDpi
float adjust = 1.0f;
if (mViewportDensityDpi == -1) {
adjust = mContext.getResources().getDisplayMetrics().density;
adjust = getFixedDisplayDensity(mContext);
} else if (mViewportDensityDpi > 0) {
adjust = (float) mContext.getResources().getDisplayMetrics().densityDpi
/ mViewportDensityDpi;
adjust = ((int) (adjust * 100)) / 100.0f;
}
// We make bad assumptions about multiplying and dividing by 100, force
// them to be true with this hack
adjust = ((int) (adjust * 100)) / 100.0f;
// Remove any update density messages in flight.
// If the density is indeed different from WebView's default scale,
// a new message will be queued.