summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTeng-Hui Zhu <ztenghui@google.com>2012-05-30 10:19:21 -0700
committerTeng-Hui Zhu <ztenghui@google.com>2012-05-30 15:21:34 -0700
commit45c2747dcc0151ebf5a296118c2d3c8f69ab4f68 (patch)
treecc9992fe8397395e6338334f6f23a00490183c3e
parent86ba073431c8ddf2e9d1f2d5d4f89157dd32ec33 (diff)
downloadwebkit-45c2747dcc0151ebf5a296118c2d3c8f69ab4f68.tar.gz
Minimize tearing for fixed element in single surface mode
bug:5683630 Change-Id: I43f738f2649a79b4ad7865ed27375c07195fa9b9
-rw-r--r--Source/WebCore/platform/graphics/android/GLWebViewState.h3
-rw-r--r--Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.cpp16
-rw-r--r--Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp9
-rw-r--r--Source/WebCore/platform/graphics/android/layers/LayerAndroid.h2
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/Surface.cpp2
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp8
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 b643405d6..c2094ffe6 100644
--- a/Source/WebCore/platform/graphics/android/GLWebViewState.h
+++ b/Source/WebCore/platform/graphics/android/GLWebViewState.h
@@ -196,6 +196,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
@@ -206,6 +208,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 f03a1404b..511261ebf 100644
--- a/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.cpp
@@ -86,8 +86,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 18f65c7c3..bca1614ee 100644
--- a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp
@@ -461,13 +461,14 @@ void LayerAndroid::updateLocalGLPositionsAndScale(const TransformationMatrix& pa
void LayerAndroid::updateGLPositionsAndScale(const TransformationMatrix& parentMatrix,
const FloatRect& clipping, float opacity,
- float scale, bool forceCalculation)
+ float scale, bool forceCalculation,
+ bool disableFixedElemUpdate)
{
// constantly recalculate the draw transform of layers that may require it (and their children)
forceCalculation |= isPositionFixed()
|| contentIsScrollable()
|| (m_animations.size() != 0);
-
+ forceCalculation &= !(disableFixedElemUpdate && isPositionFixed());
if (forceCalculation)
updateLocalGLPositionsAndScale(parentMatrix, clipping, opacity, scale);
@@ -498,7 +499,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 cd2635656..fbd0aa5c4 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 94b7b6e47..176e86e5a 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 83b81a16c..e09486904 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;
@@ -151,7 +149,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;
}