From e5c9306b222e597f907697ab28a7936bfc61e487 Mon Sep 17 00:00:00 2001 From: John Reck Date: Fri, 4 May 2012 11:08:55 -0700 Subject: Disable prerenders while scrolling Bug: 6445656 Change-Id: I3d9e2cece4b3ec86deb00e98ae98f281525dab48 --- .../graphics/android/rendering/SurfaceCollection.cpp | 12 ++++-------- .../platform/graphics/android/rendering/SurfaceCollection.h | 2 +- .../graphics/android/rendering/SurfaceCollectionManager.cpp | 3 ++- Source/WebKit/android/jni/WebViewCore.cpp | 7 +++++++ Source/WebKit/android/jni/WebViewCore.h | 1 + 5 files changed, 15 insertions(+), 10 deletions(-) (limited to 'Source') diff --git a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp index 0bdbf38..7e7a503 100644 --- a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp +++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp @@ -83,21 +83,17 @@ SurfaceCollection::~SurfaceCollection() #endif } -void SurfaceCollection::prepareGL(const SkRect& visibleContentRect) +void SurfaceCollection::prepareGL(const SkRect& visibleContentRect, bool tryToFastBlit) { updateLayerPositions(visibleContentRect); bool layerTilesDisabled = m_compositedRoot->state()->layersRenderingMode() > GLWebViewState::kClippedTextures; - bool updateWithBlit = true; if (!layerTilesDisabled) { - for (unsigned int i = 0; i < m_surfaces.size(); i++) { - updateWithBlit &= m_surfaces[i]->canUpdateWithBlit(); - if (!updateWithBlit) - break; - } + for (unsigned int i = 0; tryToFastBlit && i < m_surfaces.size(); i++) + tryToFastBlit &= m_surfaces[i]->canUpdateWithBlit(); } for (unsigned int i = 0; i < m_surfaces.size(); i++) - m_surfaces[i]->prepareGL(layerTilesDisabled, updateWithBlit); + m_surfaces[i]->prepareGL(layerTilesDisabled, tryToFastBlit); } static inline bool compareSurfaceZ(const Surface* a, const Surface* b) diff --git a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.h b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.h index 5cfd943..18e50ee 100644 --- a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.h +++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.h @@ -48,7 +48,7 @@ public: virtual ~SurfaceCollection(); // Tiled painting methods (executed on groups) - void prepareGL(const SkRect& visibleContentRect); + void prepareGL(const SkRect& visibleContentRect, bool tryToFastBlit = false); bool drawGL(const SkRect& visibleContentRect); Color getBackgroundColor(); void swapTiles(); diff --git a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp index b26be03..7c42bd9 100644 --- a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp +++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp @@ -171,7 +171,8 @@ int SurfaceCollectionManager::drawGL(double currentTime, IntRect& viewRect, m_paintingCollection->evaluateAnimations(currentTime); - m_paintingCollection->prepareGL(visibleContentRect); + bool tryFastBlit = !m_fastSwapMode; + m_paintingCollection->prepareGL(visibleContentRect, tryFastBlit); m_paintingCollection->computeTexturesAmount(texturesResultPtr); if (!TilesManager::instance()->useDoubleBuffering() || m_paintingCollection->isReady()) { diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp index 1a1fc16..dddae43 100644 --- a/Source/WebKit/android/jni/WebViewCore.cpp +++ b/Source/WebKit/android/jni/WebViewCore.cpp @@ -171,6 +171,10 @@ FILE* gRenderTreeFile = 0; #include "RenderLayerCompositor.h" #endif +// How many ms to wait for the scroll to "settle" before we will consider doing +// prerenders +#define PRERENDER_AFTER_SCROLL_DELAY 750 + //////////////////////////////////////////////////////////////////////////////////////////////// namespace android { @@ -737,6 +741,8 @@ void WebViewCore::paintContents(WebCore::GraphicsContext* gc, WebCore::IntRect& SkCanvas* WebViewCore::createPrerenderCanvas(PrerenderedInval* prerendered) { + if (currentTimeMS() - m_scrollSetTime < PRERENDER_AFTER_SCROLL_DELAY) + return 0; if (prerendered->area.isEmpty()) return 0; FloatRect scaleTemp(m_scrollOffsetX, m_scrollOffsetY, m_screenWidth, m_screenHeight); @@ -1049,6 +1055,7 @@ void WebViewCore::setScrollOffset(bool sendScrollEvent, int dx, int dy) if (m_scrollOffsetX != dx || m_scrollOffsetY != dy) { m_scrollOffsetX = dx; m_scrollOffsetY = dy; + m_scrollSetTime = currentTimeMS(); // The visible rect is located within our coordinate space so it // contains the actual scroll position. Setting the location makes hit // testing work correctly. diff --git a/Source/WebKit/android/jni/WebViewCore.h b/Source/WebKit/android/jni/WebViewCore.h index 8dc1d07..043953b 100644 --- a/Source/WebKit/android/jni/WebViewCore.h +++ b/Source/WebKit/android/jni/WebViewCore.h @@ -760,6 +760,7 @@ namespace android { int m_maxYScroll; int m_scrollOffsetX; // webview.java's current scroll in X int m_scrollOffsetY; // webview.java's current scroll in Y + double m_scrollSetTime; // when the scroll was last set WebCore::IntPoint m_mousePos; int m_screenWidth; // width of the visible rect in document coordinates int m_screenHeight;// height of the visible rect in document coordinates -- cgit v1.1