diff options
author | Chris Craik <ccraik@google.com> | 2012-04-11 12:57:57 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-04-11 12:57:57 -0700 |
commit | 5d119b85382480f33eefb397ef6b34a4331671b9 (patch) | |
tree | 72955b445f2fc4cea8dec893ab9063943f72f1cc /Source | |
parent | 083c893085f553eb655abcfffbfaccd06a48943d (diff) | |
parent | 09dfd2f9699f17de78d6fcaa7a36a5ceb667df36 (diff) | |
download | external_webkit-5d119b85382480f33eefb397ef6b34a4331671b9.zip external_webkit-5d119b85382480f33eefb397ef6b34a4331671b9.tar.gz external_webkit-5d119b85382480f33eefb397ef6b34a4331671b9.tar.bz2 |
Merge "Sort surface drawing order by Z value"
Diffstat (limited to 'Source')
-rw-r--r-- | Source/WebCore/platform/graphics/android/rendering/Surface.h | 2 | ||||
-rw-r--r-- | Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp | 19 |
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; } |