From ed2ce36a1fac9f85b65edf34a1c241c2f73d806c Mon Sep 17 00:00:00 2001 From: Nicolas Roard Date: Tue, 15 May 2012 14:11:20 -0700 Subject: Allow more layers to be merged (merging fixed) This will reduce the need to go to single surface rendering mode, as well as improving jank by reducing the number of surfaces we need. (tested on a set of popular sites, we now need up to 16 times less surfaces, commonly 4-5 times less) bug:5683630 bug:6499283 bug:6366440 Change-Id: I761c6a60279e5b21dca8bc1faccd956be58e3702 --- .../graphics/android/layers/BaseLayerAndroid.cpp | 2 +- .../graphics/android/layers/LayerAndroid.cpp | 38 ++++++++-------------- .../graphics/android/layers/LayerAndroid.h | 3 ++ 3 files changed, 18 insertions(+), 25 deletions(-) (limited to 'Source/WebCore/platform/graphics/android/layers') diff --git a/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.cpp index 62a5824..3239599 100644 --- a/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.cpp @@ -79,7 +79,7 @@ void BaseLayerAndroid::updatePositionsRecursive(const SkRect& visibleContentRect { updateLayerPositions(visibleContentRect); TransformationMatrix ident; - FloatRect clip(0, 0, 1e10, 1e10); + FloatRect clip(0, 0, getWidth(), getHeight()); updateGLPositionsAndScale(ident, clip, 1, state()->scale()); } diff --git a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp index 4a6bcbe..7a25e7f 100644 --- a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp @@ -578,9 +578,9 @@ void LayerAndroid::showLayer(int indent) IntRect visible = visibleContentArea(); IntRect clip(m_clippingRect.x(), m_clippingRect.y(), m_clippingRect.width(), m_clippingRect.height()); - ALOGD("%s %s %s (%d) [%d:%x - 0x%x] - %s %s - area (%d, %d, %d, %d) - visible (%d, %d, %d, %d) " + ALOGD("%s s:%x %s %s (%d) [%d:%x - 0x%x] - %s %s - area (%d, %d, %d, %d) - visible (%d, %d, %d, %d) " "clip (%d, %d, %d, %d) %s %s m_content(%x), pic w: %d h: %d originalLayer: %x %d", - spaces, m_haveClip ? "CLIP LAYER" : "", subclassName().ascii().data(), + spaces, m_surface, m_haveClip ? "CLIP LAYER" : "", subclassName().ascii().data(), subclassType(), uniqueId(), this, m_owningLayer, needsTexture() ? "needsTexture" : "", m_imageCRC ? "hasImage" : "", @@ -626,19 +626,8 @@ bool LayerAndroid::canJoinSurface(Surface* surface) LayerAndroid* lastLayer = surface->getFirstLayer(); - // isolate non-tiled layers - // TODO: remove this check so that multiple tiled layers with a invisible - // one inbetween can be merged - if (!needsTexture() || !lastLayer->needsTexture()) - return false; - - // isolate clipped layers - // TODO: paint correctly with clip when merged - if (m_haveClip || lastLayer->m_haveClip) - return false; - // isolate intrinsically composited layers - if (m_intrinsicallyComposited || lastLayer->m_intrinsicallyComposited) + if (needsIsolatedSurface() || lastLayer->needsIsolatedSurface()) return false; // TODO: investigate potential for combining transformed layers @@ -646,11 +635,6 @@ bool LayerAndroid::canJoinSurface(Surface* surface) || !lastLayer->m_drawTransform.isIdentityOrTranslation()) return false; - // currently, we don't surface zoomable with non-zoomable layers (unless the - // surface or the layer doesn't need a texture) - if (surface->needsTexture() && needsTexture() && m_content->hasText() != surface->hasText()) - return false; - // TODO: compare other layer properties - fixed? overscroll? transformed? return true; #endif @@ -670,24 +654,26 @@ void LayerAndroid::assignSurfaces(LayerMergeState* mergeState) } #ifdef LAYER_MERGING_DEBUG - ALOGD("%*slayer %p(%d) rl %p %s surface %p, fixed %d, anim %d, intCom %d, haveClip %d scroll %d", + ALOGD("%*slayer %p(%d) rl %p %s surface %p lvl: %d, fixed %d, anim %d, intCom %d, haveClip %d scroll %d hasText (layer: %d surface: %d) hasContent %d size %.2f x %.2f", 4*mergeState->depth, "", this, m_uniqueId, m_owningLayer, needNewSurface ? "NEW" : "joins", mergeState->currentSurface, + mergeState->nonMergeNestedLevel, isPositionFixed(), m_animations.size() != 0, m_intrinsicallyComposited, m_haveClip, - contentIsScrollable()); + contentIsScrollable(), m_content ? m_content->hasText() : -1, + mergeState->currentSurface ? mergeState->currentSurface->hasText() : -1, + needsTexture(), getWidth(), getHeight()); #endif mergeState->currentSurface->addLayer(this, m_drawTransform); m_surface = mergeState->currentSurface; - if (m_haveClip || contentIsScrollable() || isPositionFixed()) { + if (contentIsScrollable() || isPositionFixed()) { // disable layer merging within the children of these layer types mergeState->nonMergeNestedLevel++; } - // pass the surface through children in drawing order, so that they may // attach themselves (and paint on it) if possible, or ignore it and create // a new one if not @@ -705,13 +691,17 @@ void LayerAndroid::assignSurfaces(LayerMergeState* mergeState) mergeState->depth--; } - if (m_haveClip || contentIsScrollable() || isPositionFixed()) { + if (contentIsScrollable() || isPositionFixed()) { // re-enable joining mergeState->nonMergeNestedLevel--; // disallow layers painting after to join with this surface mergeState->currentSurface = 0; } + + if (needsIsolatedSurface()) + mergeState->currentSurface = 0; + } // We call this in WebViewCore, when copying the tree of layers. diff --git a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h index c7c795f..52df0cf 100644 --- a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h +++ b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h @@ -281,6 +281,9 @@ public: Surface* surface() { return m_surface; } void setIntrinsicallyComposited(bool intCom) { m_intrinsicallyComposited = intCom; } + bool needsIsolatedSurface() { + return (needsTexture() && m_intrinsicallyComposited) || m_animations.size(); + } int setHwAccelerated(bool hwAccelerated); -- cgit v1.1