summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorChris Craik <ccraik@google.com>2012-04-10 17:07:55 -0700
committerChris Craik <ccraik@google.com>2012-04-11 11:26:40 -0700
commit09dfd2f9699f17de78d6fcaa7a36a5ceb667df36 (patch)
tree1d49ef534b0f3e37a341055d3ad2239c0cb79096 /Source
parent98e8504d9f510b8cbaca1b0144efea3a4d1a8eec (diff)
downloadexternal_webkit-09dfd2f9699f17de78d6fcaa7a36a5ceb667df36.zip
external_webkit-09dfd2f9699f17de78d6fcaa7a36a5ceb667df36.tar.gz
external_webkit-09dfd2f9699f17de78d6fcaa7a36a5ceb667df36.tar.bz2
Sort surface drawing order by Z value
bug:6275189 Change-Id: Ib9cabadb77777244c6ef707c32ce53db3ebf3181
Diffstat (limited to 'Source')
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/Surface.h2
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp19
2 files changed, 19 insertions, 2 deletions
diff --git a/Source/WebCore/platform/graphics/android/rendering/Surface.h b/Source/WebCore/platform/graphics/android/rendering/Surface.h
index 27c997e..756fabd 100644
--- a/Source/WebCore/platform/graphics/android/rendering/Surface.h
+++ b/Source/WebCore/platform/graphics/android/rendering/Surface.h
@@ -56,7 +56,7 @@ public:
void computeTexturesAmount(TexturesResult* result);
- LayerAndroid* getFirstLayer() { return m_layers[0]; }
+ LayerAndroid* getFirstLayer() const { return m_layers[0]; }
bool needsTexture() { return m_needsTexture; }
bool hasText() { return m_hasText; }
bool isBase();
diff --git a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp
index 0bbaf91..cd5ceef 100644
--- a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp
@@ -95,6 +95,15 @@ void SurfaceCollection::prepareGL(const SkRect& visibleRect)
m_surfaces[i]->prepareGL(layerTilesDisabled);
}
+static inline bool compareSurfaceZ(const Surface* a, const Surface* b)
+{
+ const LayerAndroid* la = a->getFirstLayer();
+ const LayerAndroid* lb = b->getFirstLayer();
+
+ // swap drawing order if zValue suggests it AND the layers are in the same stacking context
+ return (la->zValue() > lb->zValue()) && (la->getParent() == lb->getParent());
+}
+
bool SurfaceCollection::drawGL(const SkRect& visibleRect)
{
#ifdef DEBUG_COUNT
@@ -105,8 +114,16 @@ bool SurfaceCollection::drawGL(const SkRect& visibleRect)
updateLayerPositions(visibleRect);
bool layerTilesDisabled = m_compositedRoot->state()->layersRenderingMode()
> GLWebViewState::kClippedTextures;
+
+ // create a duplicate vector of surfaces, sorted by z value
+ Vector <Surface*> surfaces;
+ for (unsigned int i = 0; i < m_surfaces.size(); i++)
+ surfaces.append(m_surfaces[i]);
+ std::stable_sort(surfaces.begin()+1, surfaces.end(), compareSurfaceZ);
+
+ // draw the sorted vector
for (unsigned int i = 0; i < m_surfaces.size(); i++)
- needsRedraw |= m_surfaces[i]->drawGL(layerTilesDisabled);
+ needsRedraw |= surfaces[i]->drawGL(layerTilesDisabled);
return needsRedraw;
}