diff options
Diffstat (limited to 'Source')
12 files changed, 86 insertions, 17 deletions
diff --git a/Source/WebCore/platform/ScrollView.cpp b/Source/WebCore/platform/ScrollView.cpp index e79f049..58a1fbf 100644 --- a/Source/WebCore/platform/ScrollView.cpp +++ b/Source/WebCore/platform/ScrollView.cpp @@ -27,6 +27,9 @@ #include "ScrollView.h" #include "AXObjectCache.h" +#if PLATFORM(ANDROID) +#include "FrameView.h" +#endif #include "GraphicsContext.h" #include "GraphicsLayer.h" #include "HostWindow.h" @@ -328,6 +331,14 @@ int ScrollView::actualScrollY() const return platformActualScrollY(); return scrollY(); } + +FrameView* ScrollView::frameView() { + if (this->isFrameView()) { + FrameView* frameView = reinterpret_cast<FrameView*>(this); + return frameView; + } + return 0; +} #endif IntPoint ScrollView::maximumScrollPosition() const diff --git a/Source/WebCore/platform/ScrollView.h b/Source/WebCore/platform/ScrollView.h index 558aee2..3228870 100644 --- a/Source/WebCore/platform/ScrollView.h +++ b/Source/WebCore/platform/ScrollView.h @@ -53,6 +53,10 @@ namespace WebCore { class HostWindow; class Scrollbar; +#if PLATFORM(ANDROID) +class FrameView; +#endif + class ScrollView : public Widget, public ScrollableArea { public: ~ScrollView(); @@ -172,6 +176,7 @@ public: int actualHeight() const; int actualScrollX() const; int actualScrollY() const; + FrameView* frameView(); #endif // Functions for querying the current scrolled position (both as a point, a size, or as individual X and Y values). diff --git a/Source/WebCore/platform/android/ScrollViewAndroid.cpp b/Source/WebCore/platform/android/ScrollViewAndroid.cpp index f29e998..8df0c2f 100644 --- a/Source/WebCore/platform/android/ScrollViewAndroid.cpp +++ b/Source/WebCore/platform/android/ScrollViewAndroid.cpp @@ -98,8 +98,6 @@ int ScrollView::platformActualScrollY() const void ScrollView::platformSetScrollPosition(const WebCore::IntPoint& pt) { - if (parent()) // don't attempt to scroll subframes; they're fully visible - return; PlatformBridge::setScrollPosition(this, m_scrollOrigin.x() + pt.x(), m_scrollOrigin.y() + pt.y()); } diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp index 76d7324..86f33e0 100644 --- a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp +++ b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp @@ -351,18 +351,26 @@ double GLWebViewState::setupDrawing(const IntRect& viewRect, const SkRect& visib int top = viewRect.y(); int width = viewRect.width(); int height = viewRect.height(); + TilesManager* tilesManager = TilesManager::instance(); + + // Make sure the GL Context has not changed, otherwise, re-create all GL + // resources. Only check this after onTrimMemory happens. + bool contextChanged = tilesManager->contextChanged(); + tilesManager->setContextChanged(false); // Make sure GL resources are created on the UI thread. - ShaderProgram* shader = TilesManager::instance()->shader(); - if (shader->needsInit()) { - XLOG("Reinit shader"); + ShaderProgram* shader = tilesManager->shader(); + if (shader->needsInit() || contextChanged) { + XLOGC("Reinit shader"); shader->init(); } - TransferQueue* transferQueue = TilesManager::instance()->transferQueue(); - if (transferQueue->needsInit()) { + TransferQueue* transferQueue = tilesManager->transferQueue(); + if (transferQueue->needsInit() || contextChanged) { + XLOGC("Reinit transferQueue"); transferQueue->initGLResources(TilesManager::tileWidth(), TilesManager::tileHeight()); } + // TODO: Add the video GL resource re-initialization code here. shader->setupDrawing(viewRect, visibleRect, webViewRect, titleBarHeight, screenClip, scale); diff --git a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp index 779eb36..bb17784 100644 --- a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp @@ -557,10 +557,13 @@ void GraphicsLayerAndroid::updateScrollingLayers() void GraphicsLayerAndroid::updateScrollOffset() { RenderLayer* layer = renderLayerFromClient(m_client); - if (!layer || !m_foregroundLayer) + if (!layer || !(m_foregroundLayer || m_contentLayer->contentIsScrollable())) return; IntSize scroll = layer->scrolledContentOffset(); - m_foregroundLayer->setScrollOffset(IntPoint(scroll.width(), scroll.height())); + if (m_foregroundLayer) + m_foregroundLayer->setScrollOffset(IntPoint(scroll.width(), scroll.height())); + else if (m_contentLayer->contentIsScrollable()) + static_cast<ScrollableLayerAndroid*>(m_contentLayer)->scrollTo(scroll.width(), scroll.height()); askForSync(); } @@ -637,10 +640,17 @@ bool GraphicsLayerAndroid::repaint() m_foregroundLayer->markAsDirty(region); m_foregroundLayer->needsRepaint(); } else { + // Paint at 0,0. + IntSize scroll = layer->scrolledContentOffset(); + layer->scrollToOffset(0, 0); // If there is no contents clip, we can draw everything into one // picture. - if (!paintContext(m_contentLayer->recordContext(), layerBounds)) + bool painting = paintContext(m_contentLayer->recordContext(), layerBounds); + // Move back to the scroll offset + layer->scrollToOffset(scroll.width(), scroll.height()); + if (!painting) return false; + // We painted new content m_contentLayer->checkForPictureOptimizations(); // Check for a scrollable iframe and report the scrolling // limits based on the view size. @@ -648,6 +658,9 @@ bool GraphicsLayerAndroid::repaint() FrameView* view = layer->renderer()->frame()->view(); static_cast<ScrollableLayerAndroid*>(m_contentLayer)->setScrollLimits( m_position.x(), m_position.y(), view->layoutWidth(), view->layoutHeight()); + LOG("setScrollLimits(%.2f, %.2f, w: %d h: %d) layer %d, frame scroll position is %d, %d (%d, %d)", + m_position.x(), m_position.y(), view->layoutWidth(), view->layoutHeight(), + m_contentLayer->uniqueId(), view->scrollX(), view->scrollY(), view->actualScrollX(), view->actualScrollY()); } } diff --git a/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp index 55692be..27a7df5 100644 --- a/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp @@ -29,7 +29,6 @@ void ScrollableLayerAndroid::getScrollBounds(IntRect* out) const out->setY(m_scrollLimits.fTop - pos.fY); out->setWidth(getSize().width() - m_scrollLimits.width()); out->setHeight(getSize().height() - m_scrollLimits.height()); - } void ScrollableLayerAndroid::getScrollRect(SkIRect* out) const diff --git a/Source/WebCore/platform/graphics/android/TilesManager.cpp b/Source/WebCore/platform/graphics/android/TilesManager.cpp index 184d80c..6640230 100644 --- a/Source/WebCore/platform/graphics/android/TilesManager.cpp +++ b/Source/WebCore/platform/graphics/android/TilesManager.cpp @@ -110,6 +110,7 @@ TilesManager::TilesManager() , m_drawGLCount(1) , m_lastTimeLayersUsed(0) , m_hasLayerTextures(false) + , m_EGLContextChanged(true) { XLOG("TilesManager ctor"); m_textures.reserveCapacity(MAX_TEXTURE_ALLOCATION); diff --git a/Source/WebCore/platform/graphics/android/TilesManager.h b/Source/WebCore/platform/graphics/android/TilesManager.h index b670055..749ba98 100644 --- a/Source/WebCore/platform/graphics/android/TilesManager.h +++ b/Source/WebCore/platform/graphics/android/TilesManager.h @@ -110,6 +110,9 @@ public: void setHighEndGfx(bool highEnd); bool highEndGfx(); + bool contextChanged() { return m_EGLContextChanged; } + void setContextChanged(bool changed) { m_EGLContextChanged = changed; } + int maxTextureCount(); int maxLayerTextureCount(); void setMaxTextureCount(int max); @@ -263,6 +266,8 @@ private: unsigned long long m_drawGLCount; double m_lastTimeLayersUsed; bool m_hasLayerTextures; + + bool m_EGLContextChanged; }; } // namespace WebCore diff --git a/Source/WebCore/rendering/RenderLayer.cpp b/Source/WebCore/rendering/RenderLayer.cpp index 0932224..66aab18 100644 --- a/Source/WebCore/rendering/RenderLayer.cpp +++ b/Source/WebCore/rendering/RenderLayer.cpp @@ -1390,11 +1390,27 @@ void RenderLayer::scrollTo(int x, int y) view->updateWidgetPositions(); } +#if PLATFORM(ANDROID) + GraphicsLayerAndroid* backingLayer = 0; + bool scrollableContent = false; +#endif + #if USE(ACCELERATED_COMPOSITING) if (compositor()->inCompositingMode()) { // Our stacking context is guaranteed to contain all of our descendants that may need // repositioning, so update compositing layers from there. +#if ENABLE(ANDROID_OVERFLOW_SCROLL) + if (view && backing() && backing()->graphicsLayer()) { + backingLayer = static_cast<GraphicsLayerAndroid*>(backing()->graphicsLayer()); + scrollableContent = backingLayer->contentLayer() + && backingLayer->contentLayer()->contentIsScrollable(); + } + // If we have a scrollable content, no need to do this + RenderLayer* compositingAncestor = enclosingCompositingLayer(); + if (!scrollableContent && compositingAncestor) { +#else if (RenderLayer* compositingAncestor = stackingContext()->enclosingCompositingLayer()) { +#endif if (compositor()->compositingConsultsOverlap()) compositor()->updateCompositingLayers(CompositingUpdateOnScroll, compositingAncestor); else { @@ -1423,10 +1439,10 @@ void RenderLayer::scrollTo(int x, int y) #if ENABLE(ANDROID_OVERFLOW_SCROLL) // On android, scrollable areas are put on composited layers, so we // do not need to repaint simply because we are scrolling - if (view && !hasOverflowScroll()) + if (view && !(hasOverflowScroll() || scrollableContent)) renderer()->repaintUsingContainer(repaintContainer, rectForRepaint); - if (view && hasOverflowScroll() && backing() && backing()->graphicsLayer()) - static_cast<GraphicsLayerAndroid*>(backing()->graphicsLayer())->updateScrollOffset(); + if (backingLayer && (hasOverflowScroll() || scrollableContent)) + backingLayer->updateScrollOffset(); #else if (view) renderer()->repaintUsingContainer(repaintContainer, rectForRepaint); diff --git a/Source/WebKit/android/WebCoreSupport/PlatformBridge.cpp b/Source/WebKit/android/WebCoreSupport/PlatformBridge.cpp index 0a4d828..b684a1a 100644 --- a/Source/WebKit/android/WebCoreSupport/PlatformBridge.cpp +++ b/Source/WebKit/android/WebCoreSupport/PlatformBridge.cpp @@ -35,6 +35,8 @@ #include "KeyGeneratorClient.h" #include "MemoryUsage.h" #include "PluginView.h" +#include "RenderLayer.h" +#include "RenderView.h" #include "Settings.h" #include "WebCookieJar.h" #include "WebRequestContext.h" @@ -171,6 +173,16 @@ void PlatformBridge::setScrollPosition(ScrollView* scrollView, int x, int y) { android::WebViewCore *webViewCore = android::WebViewCore::getWebViewCore(scrollView); if (webViewCore->mainFrame()->view() == scrollView) webViewCore->scrollTo(x, y); + else { + FrameView* frameView = scrollView->frameView(); + if (frameView) { + RenderView* renderer = frameView->frame()->contentRenderer(); + if (renderer) { + RenderLayer* layer = renderer->layer(); + layer->scrollToOffset(x, y); + } + } + } } int PlatformBridge::lowMemoryUsageMB() diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp index 6e899c2..e300976 100644 --- a/Source/WebKit/android/jni/WebViewCore.cpp +++ b/Source/WebKit/android/jni/WebViewCore.cpp @@ -4021,8 +4021,7 @@ void WebViewCore::scrollRenderLayer(int layer, const SkRect& rect) if (!owner) return; - if (owner->stackingContext()) - owner->scrollToOffset(rect.fLeft, rect.fTop); + owner->scrollToOffset(rect.fLeft, rect.fTop); #endif } diff --git a/Source/WebKit/android/nav/WebView.cpp b/Source/WebKit/android/nav/WebView.cpp index 4a172ea..624a696 100644 --- a/Source/WebKit/android/nav/WebView.cpp +++ b/Source/WebKit/android/nav/WebView.cpp @@ -1428,8 +1428,10 @@ static void nativeOnTrimMemory(JNIEnv *env, jobject obj, jint level) // Texture to avoid ANR b/c framework may destroy the EGL context. // Refer to WindowManagerImpl.java for conditions we followed. if (level >= TRIM_MEMORY_MODERATE - && !TilesManager::instance()->highEndGfx()) + && !TilesManager::instance()->highEndGfx()) { TilesManager::instance()->transferQueue()->emptyQueue(); + TilesManager::instance()->setContextChanged(true); + } bool freeAllTextures = (level > TRIM_MEMORY_UI_HIDDEN), glTextures = true; TilesManager::instance()->discardTextures(freeAllTextures, glTextures); |
