Merge "actually pause webkit thread, remove costly invalidate"

This commit is contained in:
Chris Craik
2011-08-25 15:13:39 -07:00
committed by Android (Google) Code Review
2 changed files with 10 additions and 8 deletions

View File

@@ -3451,6 +3451,7 @@ public class WebView extends AbsoluteLayout
} }
abortAnimation(); abortAnimation();
mPrivateHandler.removeMessages(RESUME_WEBCORE_PRIORITY); mPrivateHandler.removeMessages(RESUME_WEBCORE_PRIORITY);
nativeSetIsScrolling(false);
if (!mBlockWebkitViewMessages) { if (!mBlockWebkitViewMessages) {
WebViewCore.resumePriority(); WebViewCore.resumePriority();
if (!mSelectingText) { if (!mSelectingText) {
@@ -6382,6 +6383,8 @@ public class WebView extends AbsoluteLayout
WebViewCore.reducePriority(); WebViewCore.reducePriority();
// to get better performance, pause updating the picture // to get better performance, pause updating the picture
WebViewCore.pauseUpdatePicture(mWebViewCore); WebViewCore.pauseUpdatePicture(mWebViewCore);
nativeSetIsScrolling(true);
if (!mDragFromTextInput) { if (!mDragFromTextInput) {
nativeHideCursor(); nativeHideCursor();
} }
@@ -6478,6 +6481,7 @@ public class WebView extends AbsoluteLayout
|| mTouchMode == TOUCH_DRAG_LAYER_MODE) && !mSelectingText) { || mTouchMode == TOUCH_DRAG_LAYER_MODE) && !mSelectingText) {
WebViewCore.resumePriority(); WebViewCore.resumePriority();
WebViewCore.resumeUpdatePicture(mWebViewCore); WebViewCore.resumeUpdatePicture(mWebViewCore);
nativeSetIsScrolling(false);
} }
mPrivateHandler.removeMessages(SWITCH_TO_SHORTPRESS); mPrivateHandler.removeMessages(SWITCH_TO_SHORTPRESS);
mPrivateHandler.removeMessages(SWITCH_TO_LONGPRESS); mPrivateHandler.removeMessages(SWITCH_TO_LONGPRESS);
@@ -9277,6 +9281,7 @@ public class WebView extends AbsoluteLayout
* @return True if the layer is successfully scrolled. * @return True if the layer is successfully scrolled.
*/ */
private native boolean nativeScrollLayer(int layer, int newX, int newY); private native boolean nativeScrollLayer(int layer, int newX, int newY);
private native void nativeSetIsScrolling(boolean isScrolling);
private native int nativeGetBackgroundColor(); private native int nativeGetBackgroundColor();
native boolean nativeSetProperty(String key, String value); native boolean nativeSetProperty(String key, String value);
native String nativeGetProperty(String key); native String nativeGetProperty(String key);

View File

@@ -2070,10 +2070,8 @@ public final class WebViewCore {
if (!core.getSettings().enableSmoothTransition()) return; if (!core.getSettings().enableSmoothTransition()) return;
synchronized (core) { synchronized (core) {
core.nativeSetIsPaused(true);
core.mDrawIsPaused = true; core.mDrawIsPaused = true;
if (core.mDrawIsScheduled) {
core.mEventHub.removeMessages(EventHub.WEBKIT_DRAW);
}
} }
} }
@@ -2082,15 +2080,14 @@ public final class WebViewCore {
static void resumeUpdatePicture(WebViewCore core) { static void resumeUpdatePicture(WebViewCore core) {
if (core != null) { if (core != null) {
// if mDrawIsPaused is true, ignore the setting, continue to resume // if mDrawIsPaused is true, ignore the setting, continue to resume
if (!core.mDrawIsPaused if (!core.mDrawIsPaused)
&& !core.getSettings().enableSmoothTransition()) return; return;
synchronized (core) { synchronized (core) {
core.nativeSetIsPaused(false);
core.mDrawIsPaused = false; core.mDrawIsPaused = false;
// always redraw on resume to reenable gif animations // always redraw on resume to reenable gif animations
core.mDrawIsScheduled = false; core.mDrawIsScheduled = false;
core.nativeContentInvalidateAll();
core.contentDraw();
} }
} }
} }
@@ -2127,7 +2124,6 @@ public final class WebViewCore {
// only fire an event if this is our first request // only fire an event if this is our first request
if (mDrawIsScheduled) return; if (mDrawIsScheduled) return;
mDrawIsScheduled = true; mDrawIsScheduled = true;
if (mDrawIsPaused) return;
mEventHub.sendMessage(Message.obtain(null, EventHub.WEBKIT_DRAW)); mEventHub.sendMessage(Message.obtain(null, EventHub.WEBKIT_DRAW));
} }
} }
@@ -2789,6 +2785,7 @@ public final class WebViewCore {
return mDeviceOrientationService; return mDeviceOrientationService;
} }
private native void nativeSetIsPaused(boolean isPaused);
private native void nativePause(); private native void nativePause();
private native void nativeResume(); private native void nativeResume();
private native void nativeFreeMemory(); private native void nativeFreeMemory();