diff options
author | Teng-Hui Zhu <ztenghui@google.com> | 2012-05-30 16:20:14 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-05-30 16:20:14 -0700 |
commit | db590796ce589844c92205685ffae83c86b168f0 (patch) | |
tree | cf18d80d13667556cd2afe2f0c1fb6449226b282 | |
parent | e4d0c1973ec857d1408499010dca9f6856cecdd1 (diff) | |
parent | 45c2747dcc0151ebf5a296118c2d3c8f69ab4f68 (diff) | |
download | external_webkit-db590796ce589844c92205685ffae83c86b168f0.zip external_webkit-db590796ce589844c92205685ffae83c86b168f0.tar.gz external_webkit-db590796ce589844c92205685ffae83c86b168f0.tar.bz2 |
Merge "Minimize tearing for fixed element in single surface mode" into jb-dev
6 files changed, 28 insertions, 12 deletions
diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.h b/Source/WebCore/platform/graphics/android/GLWebViewState.h index 4921e89..e325590 100644 --- a/Source/WebCore/platform/graphics/android/GLWebViewState.h +++ b/Source/WebCore/platform/graphics/android/GLWebViewState.h @@ -197,6 +197,8 @@ public: float scale() { return m_scale; } + // Currently, we only use 3 modes : kAllTextures, kClippedTextures and + // kSingleSurfaceRendering ( for every mode > kClippedTextures ) . enum LayersRenderingMode { kAllTextures = 0, // all layers are drawn with textures fully covering them kClippedTextures = 1, // all layers are drawn, but their textures will be clipped @@ -207,6 +209,7 @@ public: }; LayersRenderingMode layersRenderingMode() { return m_layersRenderingMode; } + bool isSingleSurfaceRenderingMode() { return m_layersRenderingMode == kSingleSurfaceRendering; } void scrollLayer(int layerId, int x, int y); private: diff --git a/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.cpp index 5021c57..82af3bf 100644 --- a/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.cpp @@ -87,8 +87,20 @@ void BaseLayerAndroid::updatePositionsRecursive(const SkRect& visibleContentRect FloatRect clip(0, 0, getWidth(), getHeight()); bool forcePositionCalculation = !m_positionsCalculated; - float scale = state() ? state()->scale() : 1.0f; - updateGLPositionsAndScale(ident, clip, 1, scale, forcePositionCalculation); + float scale = 1.0f; + // To minimize tearing in single surface mode, don't update the fixed element + // when scrolling. The fixed element will move incorrectly when scrolling, + // but its position will be corrected after scrolling. + bool disableFixedElemUpdate = false; + GLWebViewState* webViewState = state(); + if (webViewState) { + scale = webViewState->scale(); + disableFixedElemUpdate = webViewState->isScrolling() + && webViewState->isSingleSurfaceRenderingMode(); + } + updateGLPositionsAndScale(ident, clip, 1, scale, forcePositionCalculation, + disableFixedElemUpdate); + m_positionsCalculated = true; } diff --git a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp index 906b1c1..293bbbc 100644 --- a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp @@ -446,7 +446,8 @@ void LayerAndroid::updateLocalTransformAndClip(const TransformationMatrix& paren void LayerAndroid::updateGLPositionsAndScale(const TransformationMatrix& parentMatrix, const FloatRect& clipping, float opacity, - float scale, bool forceCalculation) + float scale, bool forceCalculation, + bool disableFixedElemUpdate) { m_scale = scale; @@ -457,7 +458,7 @@ void LayerAndroid::updateGLPositionsAndScale(const TransformationMatrix& parentM forceCalculation |= isPositionFixed() || contentIsScrollable() || (m_animations.size() != 0); - + forceCalculation &= !(disableFixedElemUpdate && isPositionFixed()); if (forceCalculation) updateLocalTransformAndClip(parentMatrix, clipping); @@ -488,7 +489,9 @@ void LayerAndroid::updateGLPositionsAndScale(const TransformationMatrix& parentM childMatrix.translate(-getSize().width() * 0.5f, -getSize().height() * 0.5f); } for (int i = 0; i < countChildren(); i++) - this->getChild(i)->updateGLPositionsAndScale(childMatrix, drawClip(), opacity, scale, forceCalculation); + this->getChild(i)->updateGLPositionsAndScale(childMatrix, drawClip(), + opacity, scale, forceCalculation, + disableFixedElemUpdate); } bool LayerAndroid::visible() { diff --git a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h index 936ced0..c56d50a 100644 --- a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h +++ b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h @@ -156,7 +156,7 @@ public: void updateGLPositionsAndScale(const TransformationMatrix& parentMatrix, const FloatRect& clip, float opacity, float scale, - bool forceCalculations); + bool forceCalculations, bool disableFixedElemUpdate); void setDrawOpacity(float opacity) { m_drawOpacity = opacity; } float drawOpacity() { return m_drawOpacity; } bool visible(); diff --git a/Source/WebCore/platform/graphics/android/rendering/Surface.cpp b/Source/WebCore/platform/graphics/android/rendering/Surface.cpp index 106b045..9df1a7a 100644 --- a/Source/WebCore/platform/graphics/android/rendering/Surface.cpp +++ b/Source/WebCore/platform/graphics/android/rendering/Surface.cpp @@ -370,7 +370,7 @@ bool Surface::paint(SkCanvas* canvas) // In single surface mode, draw layer content onto the base layer if (isBase() && getFirstLayer()->countChildren() - && getFirstLayer()->state()->layersRenderingMode() > GLWebViewState::kClippedTextures) { + && getFirstLayer()->state()->isSingleSurfaceRenderingMode()) { for (int i = 0; i < getFirstLayer()->countChildren(); i++) getFirstLayer()->getChild(i)->drawCanvas(canvas, true, Layer::FlattenedLayers); } diff --git a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp index 093c947..3cfabe1 100644 --- a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp +++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp @@ -86,8 +86,7 @@ void SurfaceCollection::prepareGL(const SkRect& visibleContentRect, bool tryToFa { TRACE_METHOD(); updateLayerPositions(visibleContentRect); - bool layerTilesDisabled = m_compositedRoot->state()->layersRenderingMode() - > GLWebViewState::kClippedTextures; + bool layerTilesDisabled = m_compositedRoot->state()->isSingleSurfaceRenderingMode(); if (!layerTilesDisabled) { for (unsigned int i = 0; tryToFastBlit && i < m_surfaces.size(); i++) tryToFastBlit &= m_surfaces[i]->canUpdateWithBlit(); @@ -114,8 +113,7 @@ bool SurfaceCollection::drawGL(const SkRect& visibleContentRect) bool needsRedraw = false; updateLayerPositions(visibleContentRect); - bool layerTilesDisabled = m_compositedRoot->state()->layersRenderingMode() - > GLWebViewState::kClippedTextures; + bool layerTilesDisabled = m_compositedRoot->state()->isSingleSurfaceRenderingMode(); // create a duplicate vector of surfaces, sorted by z value Vector <Surface*> surfaces; @@ -153,7 +151,7 @@ void SurfaceCollection::addFrameworkInvals() bool SurfaceCollection::isReady() { // Override layer readiness check for single surface mode - if (m_compositedRoot->state()->layersRenderingMode() > GLWebViewState::kClippedTextures) { + if (m_compositedRoot->state()->isSingleSurfaceRenderingMode()) { // TODO: single surface mode should be properly double buffered return true; } |