From 983aece75ec4a559dcf65890b260976687fa8cc8 Mon Sep 17 00:00:00 2001 From: Nicolas Roard Date: Tue, 23 Aug 2011 15:31:32 -0700 Subject: Limit the number of inval rects we send to the UI bug:5204192 Change-Id: I5c29e9b2411ac2e05274d9a89c472285ed1aeb67 --- Source/WebKit/android/jni/WebViewCore.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'Source/WebKit') diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp index 964a33d..3af55a3 100644 --- a/Source/WebKit/android/jni/WebViewCore.cpp +++ b/Source/WebKit/android/jni/WebViewCore.cpp @@ -164,6 +164,11 @@ FILE* gRenderTreeFile = 0; #include #endif +// In some cases, too many invalidations passed to the UI will slow us down. +// Limit ourselves to 32 rectangles, past this just send the area bounds to the UI. +// see WebViewCore::recordPictureSet(). +#define MAX_INVALIDATIONS 32 + /* We pass this flag when recording the actual content, so that we don't spend time actually regionizing complex path clips, when all we really want to do is record them. @@ -684,6 +689,21 @@ void WebViewCore::recordPictureSet(PictureSet* content) // Add the current inval rects to the PictureSet, and rebuild it. content->add(m_addInval, 0, 0, false); + + // If we have too many invalidations, just get the area bounds + SkRegion::Iterator iterator(m_addInval); + int nbInvals = 0; + while (!iterator.done()) { + iterator.next(); + nbInvals++; + if (nbInvals > MAX_INVALIDATIONS) + break; + } + if (nbInvals > MAX_INVALIDATIONS) { + SkIRect r = m_addInval.getBounds(); + m_addInval.setRect(r); + } + rebuildPictureSet(content); } // WebViewCoreRecordTimeCounter -- cgit v1.1