Merge "On new content, attach functor directly" into jb-dev

This commit is contained in:
John Reck
2012-04-26 12:27:56 -07:00
committed by Android (Google) Code Review
4 changed files with 21 additions and 26 deletions

View File

@@ -64,7 +64,6 @@ class ViewStateSerializer {
draw.mViewState = new WebViewCore.ViewState(); draw.mViewState = new WebViewCore.ViewState();
draw.mContentSize = new Point(contentWidth, contentHeight); draw.mContentSize = new Point(contentWidth, contentHeight);
draw.mBaseLayer = baseLayer; draw.mBaseLayer = baseLayer;
draw.mInvalRegion = new Region(0, 0, contentWidth, contentHeight);
stream.close(); stream.close();
return draw; return draw;
} }

View File

@@ -2669,7 +2669,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
public void clearView() { public void clearView() {
mContentWidth = 0; mContentWidth = 0;
mContentHeight = 0; mContentHeight = 0;
setBaseLayer(0, null, false, false); setBaseLayer(0, false, false);
mWebViewCore.sendMessage(EventHub.CLEAR_CONTENT); mWebViewCore.sendMessage(EventHub.CLEAR_CONTENT);
} }
@@ -4448,12 +4448,12 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
*/ */
private SelectActionModeCallback mSelectCallback; private SelectActionModeCallback mSelectCallback;
void setBaseLayer(int layer, Region invalRegion, boolean showVisualIndicator, void setBaseLayer(int layer, boolean showVisualIndicator,
boolean isPictureAfterFirstLayout) { boolean isPictureAfterFirstLayout) {
if (mNativeClass == 0) if (mNativeClass == 0)
return; return;
boolean queueFull; boolean queueFull;
queueFull = nativeSetBaseLayer(mNativeClass, layer, invalRegion, queueFull = nativeSetBaseLayer(mNativeClass, layer,
showVisualIndicator, isPictureAfterFirstLayout); showVisualIndicator, isPictureAfterFirstLayout);
if (queueFull) { if (queueFull) {
@@ -7848,7 +7848,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
boolean isPictureAfterFirstLayout = viewState != null; boolean isPictureAfterFirstLayout = viewState != null;
if (updateBaseLayer) { if (updateBaseLayer) {
setBaseLayer(draw.mBaseLayer, draw.mInvalRegion, setBaseLayer(draw.mBaseLayer,
getSettings().getShowVisualIndicator(), getSettings().getShowVisualIndicator(),
isPictureAfterFirstLayout); isPictureAfterFirstLayout);
} }
@@ -7880,15 +7880,17 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
} }
mSendScrollEvent = true; mSendScrollEvent = true;
if (DebugFlags.WEB_VIEW) { int functor = 0;
Rect b = draw.mInvalRegion.getBounds(); if (mWebView.isHardwareAccelerated()
Log.v(LOGTAG, "NEW_PICTURE_MSG_ID {" + || mWebView.getLayerType() != View.LAYER_TYPE_HARDWARE) {
b.left+","+b.top+","+b.right+","+b.bottom+"}"); functor = nativeGetDrawGLFunction(mNativeClass);
} }
Rect invalBounds = draw.mInvalRegion.getBounds();
if (!invalBounds.isEmpty()) { if (functor != 0) {
invalidateContentRect(invalBounds); mWebView.getViewRootImpl().attachFunctor(functor);
} else { } else {
// invalidate the screen so that the next repaint will show new content
// TODO: partial invalidate
mWebView.invalidate(); mWebView.invalidate();
} }
@@ -8576,8 +8578,7 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
private native Rect nativeLayerBounds(int layer); private native Rect nativeLayerBounds(int layer);
private native void nativeSetHeightCanMeasure(boolean measure); private native void nativeSetHeightCanMeasure(boolean measure);
private native boolean nativeSetBaseLayer(int nativeInstance, private native boolean nativeSetBaseLayer(int nativeInstance,
int layer, Region invalRegion, int layer, boolean showVisualIndicator, boolean isPictureAfterFirstLayout);
boolean showVisualIndicator, boolean isPictureAfterFirstLayout);
private native int nativeGetBaseLayer(); private native int nativeGetBaseLayer();
private native void nativeReplaceBaseContent(int content); private native void nativeReplaceBaseContent(int content);
private native void nativeCopyBaseContentToPicture(Picture pict); private native void nativeCopyBaseContentToPicture(Picture pict);

View File

@@ -601,8 +601,7 @@ public final class WebViewCore {
* Redraw a portion of the picture set. The Point wh returns the * Redraw a portion of the picture set. The Point wh returns the
* width and height of the overall picture. * width and height of the overall picture.
*/ */
private native int nativeRecordContent(int nativeClass, Region invalRegion, private native int nativeRecordContent(int nativeClass, Point wh);
Point wh);
/** /**
* Notify webkit that animations have begun (on the hardware accelerated content) * Notify webkit that animations have begun (on the hardware accelerated content)
@@ -2180,11 +2179,9 @@ public final class WebViewCore {
static class DrawData { static class DrawData {
DrawData() { DrawData() {
mBaseLayer = 0; mBaseLayer = 0;
mInvalRegion = new Region();
mContentSize = new Point(); mContentSize = new Point();
} }
int mBaseLayer; int mBaseLayer;
Region mInvalRegion;
// view size that was used by webkit during the most recent layout // view size that was used by webkit during the most recent layout
Point mViewSize; Point mViewSize;
Point mContentSize; Point mContentSize;
@@ -2230,8 +2227,7 @@ public final class WebViewCore {
mDrawIsScheduled = false; mDrawIsScheduled = false;
DrawData draw = new DrawData(); DrawData draw = new DrawData();
if (DebugFlags.WEB_VIEW_CORE) Log.v(LOGTAG, "webkitDraw start"); if (DebugFlags.WEB_VIEW_CORE) Log.v(LOGTAG, "webkitDraw start");
draw.mBaseLayer = nativeRecordContent(mNativeClass, draw.mInvalRegion, draw.mBaseLayer = nativeRecordContent(mNativeClass, draw.mContentSize);
draw.mContentSize);
if (draw.mBaseLayer == 0) { if (draw.mBaseLayer == 0) {
if (mWebViewClassic != null && !mWebViewClassic.isPaused()) { if (mWebViewClassic != null && !mWebViewClassic.isPaused()) {
if (DebugFlags.WEB_VIEW_CORE) Log.v(LOGTAG, "webkitDraw abort, resending draw message"); if (DebugFlags.WEB_VIEW_CORE) Log.v(LOGTAG, "webkitDraw abort, resending draw message");
@@ -2277,8 +2273,7 @@ public final class WebViewCore {
// the draw path (and fix saving <canvas>) // the draw path (and fix saving <canvas>)
DrawData draw = new DrawData(); DrawData draw = new DrawData();
if (DebugFlags.WEB_VIEW_CORE) Log.v(LOGTAG, "saveViewState start"); if (DebugFlags.WEB_VIEW_CORE) Log.v(LOGTAG, "saveViewState start");
draw.mBaseLayer = nativeRecordContent(mNativeClass, draw.mInvalRegion, draw.mBaseLayer = nativeRecordContent(mNativeClass, draw.mContentSize);
draw.mContentSize);
boolean result = false; boolean result = false;
try { try {
result = ViewStateSerializer.serializeViewState(stream, draw); result = ViewStateSerializer.serializeViewState(stream, draw);

View File

@@ -267,13 +267,13 @@ status_t OpenGLRenderer::invokeFunctors(Rect& dirty) {
Functor* f = functors.itemAt(i); Functor* f = functors.itemAt(i);
result |= (*f)(DrawGlInfo::kModeProcess, &info); result |= (*f)(DrawGlInfo::kModeProcess, &info);
if (result != DrawGlInfo::kStatusDone) { if (result & DrawGlInfo::kStatusDraw) {
Rect localDirty(info.dirtyLeft, info.dirtyTop, info.dirtyRight, info.dirtyBottom); Rect localDirty(info.dirtyLeft, info.dirtyTop, info.dirtyRight, info.dirtyBottom);
dirty.unionWith(localDirty); dirty.unionWith(localDirty);
}
if (result & DrawGlInfo::kStatusInvoke) { if (result & DrawGlInfo::kStatusInvoke) {
mFunctors.add(f); mFunctors.add(f);
}
} }
} }
} }