am 38863336
: layers support
Merge commit '3886333644467beeaf60c13fb94f242538067765' into eclair-mr2-plus-aosp * commit '3886333644467beeaf60c13fb94f242538067765': layers support
This commit is contained in:
@ -208,6 +208,9 @@ public class WebView extends AbsoluteLayout
|
|||||||
static private final boolean AUTO_REDRAW_HACK = false;
|
static private final boolean AUTO_REDRAW_HACK = false;
|
||||||
// true means redraw the screen all-the-time. Only with AUTO_REDRAW_HACK
|
// true means redraw the screen all-the-time. Only with AUTO_REDRAW_HACK
|
||||||
private boolean mAutoRedraw;
|
private boolean mAutoRedraw;
|
||||||
|
private int mRootLayer; // C++ pointer to the root layer
|
||||||
|
private boolean mLayersHaveAnimations;
|
||||||
|
private EvaluateLayersAnimations mEvaluateThread;
|
||||||
|
|
||||||
static final String LOGTAG = "webview";
|
static final String LOGTAG = "webview";
|
||||||
|
|
||||||
@ -494,6 +497,8 @@ public class WebView extends AbsoluteLayout
|
|||||||
static final int SHOW_FULLSCREEN = 29;
|
static final int SHOW_FULLSCREEN = 29;
|
||||||
static final int HIDE_FULLSCREEN = 30;
|
static final int HIDE_FULLSCREEN = 30;
|
||||||
static final int DOM_FOCUS_CHANGED = 31;
|
static final int DOM_FOCUS_CHANGED = 31;
|
||||||
|
static final int IMMEDIATE_REPAINT_MSG_ID = 32;
|
||||||
|
static final int SET_ROOT_LAYER_MSG_ID = 33;
|
||||||
|
|
||||||
static final String[] HandlerDebugString = {
|
static final String[] HandlerDebugString = {
|
||||||
"REMEMBER_PASSWORD", // = 1;
|
"REMEMBER_PASSWORD", // = 1;
|
||||||
@ -526,7 +531,9 @@ public class WebView extends AbsoluteLayout
|
|||||||
"DO_MOTION_UP", // = 28;
|
"DO_MOTION_UP", // = 28;
|
||||||
"SHOW_FULLSCREEN", // = 29;
|
"SHOW_FULLSCREEN", // = 29;
|
||||||
"HIDE_FULLSCREEN", // = 30;
|
"HIDE_FULLSCREEN", // = 30;
|
||||||
"DOM_FOCUS_CHANGED" // = 31;
|
"DOM_FOCUS_CHANGED", // = 31;
|
||||||
|
"IMMEDIATE_REPAINT_MSG_ID", // = 32;
|
||||||
|
"SET_ROOT_LAYER_MSG_ID" // = 33;
|
||||||
};
|
};
|
||||||
|
|
||||||
// If the site doesn't use the viewport meta tag to specify the viewport,
|
// If the site doesn't use the viewport meta tag to specify the viewport,
|
||||||
@ -2919,6 +2926,7 @@ public class WebView extends AbsoluteLayout
|
|||||||
if (AUTO_REDRAW_HACK && mAutoRedraw) {
|
if (AUTO_REDRAW_HACK && mAutoRedraw) {
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
mWebViewCore.signalRepaintDone();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -2986,11 +2994,20 @@ public class WebView extends AbsoluteLayout
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void drawLayers(Canvas canvas) {
|
||||||
|
if (mRootLayer != 0) {
|
||||||
|
float scrollY = Math.max(mScrollY - getTitleHeight(), 0);
|
||||||
|
nativeDrawLayers(mRootLayer, mScrollX, scrollY,
|
||||||
|
mActualScale, canvas);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void drawCoreAndCursorRing(Canvas canvas, int color,
|
private void drawCoreAndCursorRing(Canvas canvas, int color,
|
||||||
boolean drawCursorRing) {
|
boolean drawCursorRing) {
|
||||||
if (mDrawHistory) {
|
if (mDrawHistory) {
|
||||||
canvas.scale(mActualScale, mActualScale);
|
canvas.scale(mActualScale, mActualScale);
|
||||||
canvas.drawPicture(mHistoryPicture);
|
canvas.drawPicture(mHistoryPicture);
|
||||||
|
drawLayers(canvas);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3069,6 +3086,8 @@ public class WebView extends AbsoluteLayout
|
|||||||
mWebViewCore.drawContentPicture(canvas, color, animateZoom,
|
mWebViewCore.drawContentPicture(canvas, color, animateZoom,
|
||||||
animateScroll);
|
animateScroll);
|
||||||
|
|
||||||
|
drawLayers(canvas);
|
||||||
|
|
||||||
if (mNativeClass == 0) return;
|
if (mNativeClass == 0) return;
|
||||||
if (mShiftIsPressed && !animateZoom) {
|
if (mShiftIsPressed && !animateZoom) {
|
||||||
if (mTouchSelection || mExtendSelection) {
|
if (mTouchSelection || mExtendSelection) {
|
||||||
@ -3289,6 +3308,40 @@ public class WebView extends AbsoluteLayout
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This class runs the layers animations in their own thread,
|
||||||
|
* so that we do not slow down the UI.
|
||||||
|
*/
|
||||||
|
private class EvaluateLayersAnimations extends Thread {
|
||||||
|
boolean mRunning = true;
|
||||||
|
// delay corresponds to 40fps, no need to go faster.
|
||||||
|
int mDelay = 25; // in ms
|
||||||
|
public void run() {
|
||||||
|
while (mRunning) {
|
||||||
|
if (mLayersHaveAnimations && mRootLayer != 0) {
|
||||||
|
// updates is a C++ pointer to a Vector of AnimationValues
|
||||||
|
int updates = nativeEvaluateLayersAnimations(mRootLayer);
|
||||||
|
if (updates == 0) {
|
||||||
|
mRunning = false;
|
||||||
|
}
|
||||||
|
Message.obtain(mPrivateHandler,
|
||||||
|
WebView.IMMEDIATE_REPAINT_MSG_ID,
|
||||||
|
updates, 0).sendToTarget();
|
||||||
|
} else {
|
||||||
|
mRunning = false;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Thread.currentThread().sleep(mDelay);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
mRunning = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void cancel() {
|
||||||
|
mRunning = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This class requests an Adapter for the WebTextView which shows past
|
* This class requests an Adapter for the WebTextView which shows past
|
||||||
* entries stored in the database. It is a Runnable so that it can be done
|
* entries stored in the database. It is a Runnable so that it can be done
|
||||||
@ -5308,7 +5361,7 @@ public class WebView extends AbsoluteLayout
|
|||||||
// exclude INVAL_RECT_MSG_ID since it is frequently output
|
// exclude INVAL_RECT_MSG_ID since it is frequently output
|
||||||
if (DebugFlags.WEB_VIEW && msg.what != INVAL_RECT_MSG_ID) {
|
if (DebugFlags.WEB_VIEW && msg.what != INVAL_RECT_MSG_ID) {
|
||||||
Log.v(LOGTAG, msg.what < REMEMBER_PASSWORD || msg.what
|
Log.v(LOGTAG, msg.what < REMEMBER_PASSWORD || msg.what
|
||||||
> DOM_FOCUS_CHANGED ? Integer.toString(msg.what)
|
> SET_ROOT_LAYER_MSG_ID ? Integer.toString(msg.what)
|
||||||
: HandlerDebugString[msg.what - REMEMBER_PASSWORD]);
|
: HandlerDebugString[msg.what - REMEMBER_PASSWORD]);
|
||||||
}
|
}
|
||||||
if (mWebViewCore == null) {
|
if (mWebViewCore == null) {
|
||||||
@ -5564,6 +5617,38 @@ public class WebView extends AbsoluteLayout
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case IMMEDIATE_REPAINT_MSG_ID: {
|
||||||
|
int updates = msg.arg1;
|
||||||
|
if (updates != 0) {
|
||||||
|
// updates is a C++ pointer to a Vector of
|
||||||
|
// AnimationValues that we apply to the layers.
|
||||||
|
// The Vector is deallocated in nativeUpdateLayers().
|
||||||
|
nativeUpdateLayers(mRootLayer, updates);
|
||||||
|
}
|
||||||
|
invalidate();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SET_ROOT_LAYER_MSG_ID: {
|
||||||
|
int oldLayer = mRootLayer;
|
||||||
|
mRootLayer = msg.arg1;
|
||||||
|
if (oldLayer > 0) {
|
||||||
|
nativeDestroyLayer(oldLayer);
|
||||||
|
}
|
||||||
|
if (mRootLayer == 0) {
|
||||||
|
mLayersHaveAnimations = false;
|
||||||
|
}
|
||||||
|
if (mEvaluateThread != null) {
|
||||||
|
mEvaluateThread.cancel();
|
||||||
|
mEvaluateThread = null;
|
||||||
|
}
|
||||||
|
if (nativeLayersHaveAnimations(mRootLayer)) {
|
||||||
|
mLayersHaveAnimations = true;
|
||||||
|
mEvaluateThread = new EvaluateLayersAnimations();
|
||||||
|
mEvaluateThread.start();
|
||||||
|
}
|
||||||
|
invalidate();
|
||||||
|
break;
|
||||||
|
}
|
||||||
case REQUEST_FORM_DATA:
|
case REQUEST_FORM_DATA:
|
||||||
AutoCompleteAdapter adapter = (AutoCompleteAdapter) msg.obj;
|
AutoCompleteAdapter adapter = (AutoCompleteAdapter) msg.obj;
|
||||||
if (mWebTextView.isSameTextField(msg.arg1)) {
|
if (mWebTextView.isSameTextField(msg.arg1)) {
|
||||||
@ -6251,6 +6336,13 @@ public class WebView extends AbsoluteLayout
|
|||||||
private native void nativeDebugDump();
|
private native void nativeDebugDump();
|
||||||
private native void nativeDestroy();
|
private native void nativeDestroy();
|
||||||
private native void nativeDrawCursorRing(Canvas content);
|
private native void nativeDrawCursorRing(Canvas content);
|
||||||
|
private native void nativeDestroyLayer(int layer);
|
||||||
|
private native int nativeEvaluateLayersAnimations(int layer);
|
||||||
|
private native boolean nativeLayersHaveAnimations(int layer);
|
||||||
|
private native void nativeUpdateLayers(int layer, int updates);
|
||||||
|
private native void nativeDrawLayers(int layer,
|
||||||
|
float scrollX, float scrollY,
|
||||||
|
float scale, Canvas canvas);
|
||||||
private native void nativeDrawMatches(Canvas canvas);
|
private native void nativeDrawMatches(Canvas canvas);
|
||||||
private native void nativeDrawSelectionPointer(Canvas content,
|
private native void nativeDrawSelectionPointer(Canvas content,
|
||||||
float scale, int x, int y, boolean extendSelection);
|
float scale, int x, int y, boolean extendSelection);
|
||||||
|
@ -1908,6 +1908,33 @@ final class WebViewCore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean mRepaintScheduled = false;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Called by the WebView thread
|
||||||
|
*/
|
||||||
|
/* package */ void signalRepaintDone() {
|
||||||
|
mRepaintScheduled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// called by JNI
|
||||||
|
private void sendImmediateRepaint() {
|
||||||
|
if (mWebView != null && !mRepaintScheduled) {
|
||||||
|
mRepaintScheduled = true;
|
||||||
|
Message.obtain(mWebView.mPrivateHandler,
|
||||||
|
WebView.IMMEDIATE_REPAINT_MSG_ID).sendToTarget();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// called by JNI
|
||||||
|
private void setRootLayer(int layer) {
|
||||||
|
if (mWebView != null) {
|
||||||
|
Message.obtain(mWebView.mPrivateHandler,
|
||||||
|
WebView.SET_ROOT_LAYER_MSG_ID,
|
||||||
|
layer, 0).sendToTarget();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* package */ WebView getWebView() {
|
/* package */ WebView getWebView() {
|
||||||
return mWebView;
|
return mWebView;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user