From e73b71c2e699401389367aaaf2866af4b796cd50 Mon Sep 17 00:00:00 2001 From: John Reck Date: Tue, 15 May 2012 16:30:20 -0700 Subject: flicker fix Bug: 6479523 After a layout, sync the compositing tree *before* doing any drawing Change-Id: I2c314731620be58c044f100ef335087961cbd223 --- Source/WebKit/android/jni/PicturePile.cpp | 8 +++--- Source/WebKit/android/jni/WebViewCore.cpp | 44 +++++++++++++++---------------- Source/WebKit/android/jni/WebViewCore.h | 8 ++---- 3 files changed, 29 insertions(+), 31 deletions(-) (limited to 'Source/WebKit/android') diff --git a/Source/WebKit/android/jni/PicturePile.cpp b/Source/WebKit/android/jni/PicturePile.cpp index f3e46ac..ccdfa59 100644 --- a/Source/WebKit/android/jni/PicturePile.cpp +++ b/Source/WebKit/android/jni/PicturePile.cpp @@ -144,9 +144,11 @@ void PicturePile::setSize(const IntSize& size) // TODO: See above about just adding invals for new content m_pile.clear(); m_webkitInvals.clear(); - IntRect area(0, 0, size.width(), size.height()); - m_webkitInvals.append(area); - m_pile.append(area); + if (!size.isEmpty()) { + IntRect area(0, 0, size.width(), size.height()); + m_webkitInvals.append(area); + m_pile.append(area); + } } void PicturePile::updatePicturesIfNeeded(PicturePainter* painter) diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp index ede8b69..734eb76 100644 --- a/Source/WebKit/android/jni/WebViewCore.cpp +++ b/Source/WebKit/android/jni/WebViewCore.cpp @@ -617,7 +617,7 @@ WebCore::Node* WebViewCore::currentFocus() return focusedFrame()->document()->focusedNode(); } -void WebViewCore::recordPicturePile() +void WebViewCore::layout() { TRACE_METHOD(); @@ -631,9 +631,7 @@ void WebViewCore::recordPicturePile() // it's fine for layout to gather invalidates, but defeat sending a message // back to java to call webkitDraw, since we're already in the middle of // doing that - m_skipContentDraw = true; bool success = layoutIfNeededRecursive(m_mainFrame); - m_skipContentDraw = false; // We may be mid-layout and thus cannot draw. if (!success) @@ -699,16 +697,16 @@ void WebViewCore::recordPicturePile() view->forceLayout(); // Relayout similar to above - m_skipContentDraw = true; - bool success = layoutIfNeededRecursive(m_mainFrame); - m_skipContentDraw = false; - if (!success) - return; - - // Set the computed content width - width = view->contentsWidth(); - height = view->contentsHeight(); + layoutIfNeededRecursive(m_mainFrame); } +} + +void WebViewCore::recordPicturePile() +{ + // if the webkit page dimensions changed, discard the pictureset and redraw. + WebCore::FrameView* view = m_mainFrame->view(); + int width = view ? view->contentsWidth() : 0; + int height = view ? view->contentsHeight() : 0; m_content.setSize(IntSize(width, height)); @@ -732,6 +730,11 @@ bool WebViewCore::focusBoundsChanged() void WebViewCore::paintContents(WebCore::GraphicsContext* gc, WebCore::IntRect& dirty) { WebCore::FrameView* view = m_mainFrame->view(); + if (!view) { + gc->setFillColor(WebCore::Color::white, WebCore::ColorSpaceDeviceRGB); + gc->fillColor(); + return; + } IntPoint origin = view->minimumScrollPosition(); IntRect drawArea = dirty; @@ -813,7 +816,7 @@ void WebViewCore::notifyAnimationStarted() } -BaseLayerAndroid* WebViewCore::createBaseLayer() +BaseLayerAndroid* WebViewCore::createBaseLayer(GraphicsLayerAndroid* root) { // We set the background color Color background = Color::white; @@ -877,15 +880,7 @@ BaseLayerAndroid* WebViewCore::createBaseLayer() SkSafeUnref(content); - m_skipContentDraw = true; - bool layoutSucceeded = layoutIfNeededRecursive(m_mainFrame); - m_skipContentDraw = false; - // Layout only fails if called during a layout. - ALOG_ASSERT(layoutSucceeded, "Can never be called recursively"); - // We update the layers - ChromeClientAndroid* chromeC = static_cast(m_mainFrame->page()->chrome()->client()); - GraphicsLayerAndroid* root = static_cast(chromeC->layersSync()); if (root) { LayerAndroid* copyLayer = new LayerAndroid(*root->contentLayer()); base->addChild(copyLayer); @@ -898,9 +893,14 @@ BaseLayerAndroid* WebViewCore::createBaseLayer() BaseLayerAndroid* WebViewCore::recordContent(SkIPoint* point) { + m_skipContentDraw = true; + layout(); + ChromeClientAndroid* chromeC = static_cast(m_mainFrame->page()->chrome()->client()); + GraphicsLayerAndroid* root = static_cast(chromeC->layersSync()); + m_skipContentDraw = false; recordPicturePile(); - BaseLayerAndroid* baseLayer = createBaseLayer(); + BaseLayerAndroid* baseLayer = createBaseLayer(root); baseLayer->markAsDirty(m_content.dirtyRegion()); m_content.dirtyRegion().setEmpty(); diff --git a/Source/WebKit/android/jni/WebViewCore.h b/Source/WebKit/android/jni/WebViewCore.h index a3c1e7c..b43262c 100644 --- a/Source/WebKit/android/jni/WebViewCore.h +++ b/Source/WebKit/android/jni/WebViewCore.h @@ -161,11 +161,6 @@ namespace android { */ void contentDraw(); - /** - * copy the layers to the UI side - */ - void layersDraw(); - #if USE(ACCELERATED_COMPOSITING) WebCore::GraphicsLayerAndroid* graphicsRootLayer() const; #endif @@ -517,7 +512,7 @@ namespace android { // This creates a new BaseLayerAndroid by copying the current m_content // and doing a copy of the layers. The layers' content may be updated // as we are calling layersSync(). - WebCore::BaseLayerAndroid* createBaseLayer(); + WebCore::BaseLayerAndroid* createBaseLayer(GraphicsLayerAndroid* root); bool updateLayers(WebCore::LayerAndroid*); void notifyAnimationStarted(); @@ -618,6 +613,7 @@ namespace android { }; WebCore::Node* currentFocus(); + void layout(); // Create a set of pictures to represent the drawn DOM, driven by // the invalidated region and the time required to draw (used to draw) void recordPicturePile(); -- cgit v1.1