summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorChris Craik <ccraik@google.com>2011-09-18 14:29:47 -0700
committerChris Craik <ccraik@google.com>2011-09-19 10:57:54 -0700
commitf45b65828632d455874dd29ed5a753f6ca0c94e1 (patch)
tree35cffd7bde352a0d2c0747ef2891a941bc9255c1 /Source
parent2ab28e97ec8eac2a936562f659c055847724ffd7 (diff)
downloadexternal_webkit-f45b65828632d455874dd29ed5a753f6ca0c94e1.zip
external_webkit-f45b65828632d455874dd29ed5a753f6ca0c94e1.tar.gz
external_webkit-f45b65828632d455874dd29ed5a753f6ca0c94e1.tar.bz2
Prepare tiles in reverse draw order
bug:5335634 By preparing tiles in the reverse of draw order, tiles on top are given textures first and less likely to be missing. Change-Id: Idafde3e0789e24459bba2db150081969810a0021
Diffstat (limited to 'Source')
-rw-r--r--Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp1
-rw-r--r--Source/WebCore/platform/graphics/android/LayerAndroid.cpp25
-rw-r--r--Source/WebCore/platform/graphics/android/LayerAndroid.h6
3 files changed, 28 insertions, 4 deletions
diff --git a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
index 1fa69f8..1d22cf9 100644
--- a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
@@ -281,6 +281,7 @@ bool BaseLayerAndroid::drawGL(double currentTime, LayerAndroid* compositedRoot,
// Clean up GL textures for video layer.
TilesManager::instance()->videoLayerManager()->deleteUnusedTextures();
+ compositedRoot->prepare(m_glWebViewState);
if (compositedRoot->drawGL(m_glWebViewState, matrix))
needsRedraw = true;
else if (!animsRunning)
diff --git a/Source/WebCore/platform/graphics/android/LayerAndroid.cpp b/Source/WebCore/platform/graphics/android/LayerAndroid.cpp
index 48dcaaa..17e466f 100644
--- a/Source/WebCore/platform/graphics/android/LayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/LayerAndroid.cpp
@@ -793,6 +793,26 @@ void LayerAndroid::clearDirtyRegion()
m_dirtyRegion.setEmpty();
}
+void LayerAndroid::prepare(GLWebViewState* glWebViewState)
+{
+ int count = this->countChildren();
+ if (count > 0) {
+ Vector <LayerAndroid*> sublayers;
+ for (int i = 0; i < count; i++)
+ sublayers.append(this->getChild(i));
+
+ // now we sort for the transparency
+ std::stable_sort(sublayers.begin(), sublayers.end(), compareLayerZ);
+
+ // iterate in reverse so top layers get textures first
+ for (int i = count-1; i >= 0; i--)
+ sublayers[i]->prepare(glWebViewState);
+ }
+
+ if (m_texture)
+ m_texture->prepare(glWebViewState);
+}
+
bool LayerAndroid::drawGL(GLWebViewState* glWebViewState, SkMatrix& matrix)
{
TilesManager::instance()->shader()->clip(m_clippingRect);
@@ -801,10 +821,8 @@ bool LayerAndroid::drawGL(GLWebViewState* glWebViewState, SkMatrix& matrix)
bool askPaint = false;
- if (m_texture) {
- m_texture->prepare(glWebViewState);
+ if (m_texture)
askPaint |= m_texture->draw();
- }
// When the layer is dirty, the UI thread should be notified to redraw.
askPaint |= drawChildrenGL(glWebViewState, matrix);
@@ -817,7 +835,6 @@ bool LayerAndroid::drawGL(GLWebViewState* glWebViewState, SkMatrix& matrix)
return askPaint;
}
-
bool LayerAndroid::drawChildrenGL(GLWebViewState* glWebViewState, SkMatrix& matrix)
{
bool askPaint = false;
diff --git a/Source/WebCore/platform/graphics/android/LayerAndroid.h b/Source/WebCore/platform/graphics/android/LayerAndroid.h
index 7192aaf..6aca993 100644
--- a/Source/WebCore/platform/graphics/android/LayerAndroid.h
+++ b/Source/WebCore/platform/graphics/android/LayerAndroid.h
@@ -121,8 +121,14 @@ public:
void showLayer(int indent);
float getScale() { return m_scale; }
+
+ // draw layer and its children via Z, pre-order traversal
virtual bool drawGL(GLWebViewState*, SkMatrix&);
bool drawChildrenGL(GLWebViewState*, SkMatrix&);
+
+ // prepare layer and its children via reverse-Z, post-order traversal
+ void prepare(GLWebViewState*);
+
void updateGLPositionsAndScale(const TransformationMatrix& parentMatrix,
const FloatRect& clip, float opacity, float scale);
void setDrawOpacity(float opacity) { m_drawOpacity = opacity; }