diff options
author | John Reck <jreck@google.com> | 2012-05-06 15:47:30 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-05-06 15:47:30 -0700 |
commit | e712b54e831d077c789984b8206f64d81dbceaa2 (patch) | |
tree | 62fecef344a19c3163f376a8822595a0d16a1622 /Source/WebKit/android/jni | |
parent | c4ea1619cb3bb0af9e7b69d6a72da772d71f5e9c (diff) | |
parent | d30efeae4fa6b64029cfa478fe80981232f502e5 (diff) | |
download | external_webkit-e712b54e831d077c789984b8206f64d81dbceaa2.zip external_webkit-e712b54e831d077c789984b8206f64d81dbceaa2.tar.gz external_webkit-e712b54e831d077c789984b8206f64d81dbceaa2.tar.bz2 |
Merge "Broaden fast inval path" into jb-dev
Diffstat (limited to 'Source/WebKit/android/jni')
-rw-r--r-- | Source/WebKit/android/jni/WebViewCore.cpp | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp index 2818ba8..1a1fc16 100644 --- a/Source/WebKit/android/jni/WebViewCore.cpp +++ b/Source/WebKit/android/jni/WebViewCore.cpp @@ -124,6 +124,7 @@ #include "SkUtils.h" #include "Text.h" #include "TextIterator.h" +#include "TilesManager.h" #include "TypingCommand.h" #include "WebCache.h" #include "WebCoreFrameBridge.h" @@ -736,38 +737,42 @@ void WebViewCore::paintContents(WebCore::GraphicsContext* gc, WebCore::IntRect& SkCanvas* WebViewCore::createPrerenderCanvas(PrerenderedInval* prerendered) { - IntRect screen(m_scrollOffsetX, m_scrollOffsetY, m_screenWidth, m_screenHeight); - if (prerendered->area.isEmpty() || !prerendered->area.intersects(screen)) + if (prerendered->area.isEmpty()) return 0; + FloatRect scaleTemp(m_scrollOffsetX, m_scrollOffsetY, m_screenWidth, m_screenHeight); + scaleTemp.scale(m_scale); + IntRect visibleTileClip = enclosingIntRect(scaleTemp); FloatRect scaledArea = prerendered->area; scaledArea.scale(m_scale); IntRect enclosingScaledArea = enclosingIntRect(scaledArea); if (enclosingScaledArea.isEmpty()) return 0; + // "round out" the screen to tile boundaries so that we can clip yet still + // cover any visible tiles with the prerender + int tw = TilesManager::tileWidth(); + int th = TilesManager::tileHeight(); + float left = tw * (int) (visibleTileClip.x() / tw); + float top = th * (int) (visibleTileClip.y() / th); + float right = tw * (int) ceilf(visibleTileClip.maxX() / (float) tw); + float bottom = th * (int) ceilf(visibleTileClip.maxY() / (float) th); + visibleTileClip = IntRect(left, top, right - left, bottom - top); + enclosingScaledArea.intersect(visibleTileClip); + if (enclosingScaledArea.isEmpty()) + return 0; prerendered->screenArea = enclosingScaledArea; FloatRect enclosingDocArea(enclosingScaledArea); enclosingDocArea.scale(1 / m_scale); prerendered->area = enclosingIntRect(enclosingDocArea); if (prerendered->area.isEmpty()) return 0; - // TODO: We need a better heuristic for this. We should change this to: - // 1) Limit by area, not width/height (as we care more about the RAM than size) - // 2) Clip by the screen, but "round out" to make sure we cover partially - // visible tiles - int maxWidth = ceilf(m_screenWidth * m_scale); - int maxHeight = ceilf(m_screenHeight * m_scale); - if (enclosingScaledArea.width() <= maxWidth - && enclosingScaledArea.height() <= maxHeight) { - prerendered->bitmap.setConfig(SkBitmap::kARGB_8888_Config, - enclosingScaledArea.width(), - enclosingScaledArea.height()); - prerendered->bitmap.allocPixels(); - SkCanvas* bitmapCanvas = new SkCanvas(prerendered->bitmap); - bitmapCanvas->scale(m_scale, m_scale); - bitmapCanvas->translate(-enclosingDocArea.x(), -enclosingDocArea.y()); - return bitmapCanvas; - } - return 0; + prerendered->bitmap.setConfig(SkBitmap::kARGB_8888_Config, + enclosingScaledArea.width(), + enclosingScaledArea.height()); + prerendered->bitmap.allocPixels(); + SkCanvas* bitmapCanvas = new SkCanvas(prerendered->bitmap); + bitmapCanvas->scale(m_scale, m_scale); + bitmapCanvas->translate(-enclosingDocArea.x(), -enclosingDocArea.y()); + return bitmapCanvas; } void WebViewCore::notifyAnimationStarted() |