From 5f0350c3ee327062ec6e22a3935c3bd4534cd15d Mon Sep 17 00:00:00 2001 From: Chris Craik Date: Wed, 11 Apr 2012 11:39:55 -0700 Subject: Skip drawing the background (glClear) if the tiles cover it. bug:5631590 Change-Id: Ic7dc0dac0d7f98fb94eb2b111b3e59a0a7010caf --- .../platform/graphics/android/rendering/Surface.cpp | 12 ++++++++++++ .../platform/graphics/android/rendering/Surface.h | 3 +-- .../graphics/android/rendering/SurfaceBacking.h | 5 +++++ .../graphics/android/rendering/SurfaceCollection.cpp | 17 ++++++++++++----- .../graphics/android/rendering/SurfaceCollection.h | 3 ++- .../android/rendering/SurfaceCollectionManager.cpp | 17 +++++++++++------ 6 files changed, 43 insertions(+), 14 deletions(-) (limited to 'Source/WebCore/platform') diff --git a/Source/WebCore/platform/graphics/android/rendering/Surface.cpp b/Source/WebCore/platform/graphics/android/rendering/Surface.cpp index 3ed3aad..f0d9e58 100644 --- a/Source/WebCore/platform/graphics/android/rendering/Surface.cpp +++ b/Source/WebCore/platform/graphics/android/rendering/Surface.cpp @@ -30,6 +30,7 @@ #include "Surface.h" #include "AndroidLog.h" +#include "BaseLayerAndroid.h" #include "ClassTracker.h" #include "LayerAndroid.h" #include "GLWebViewState.h" @@ -140,6 +141,9 @@ void Surface::addLayer(LayerAndroid* layer, const TransformationMatrix& transfor m_unclippedArea.x(), m_unclippedArea.y(), m_unclippedArea.width(), m_unclippedArea.height()); } + + if (isBase()) + m_background = static_cast(layer)->getBackgroundColor(); } IntRect Surface::visibleArea() @@ -250,6 +254,14 @@ bool Surface::isReady() return m_surfaceBacking->isReady(); } +bool Surface::isMissingContent() +{ + if (!m_surfaceBacking) + return true; + + return m_surfaceBacking->isMissingContent(); +} + IntRect Surface::computePrepareArea() { IntRect area; diff --git a/Source/WebCore/platform/graphics/android/rendering/Surface.h b/Source/WebCore/platform/graphics/android/rendering/Surface.h index 756fabd..d197d43 100644 --- a/Source/WebCore/platform/graphics/android/rendering/Surface.h +++ b/Source/WebCore/platform/graphics/android/rendering/Surface.h @@ -53,6 +53,7 @@ public: bool drawGL(bool layerTilesDisabled); void swapTiles(); bool isReady(); + bool isMissingContent(); void computeTexturesAmount(TexturesResult* result); @@ -60,7 +61,6 @@ public: bool needsTexture() { return m_needsTexture; } bool hasText() { return m_hasText; } bool isBase(); - void setBackground(Color background) { m_background = background; } // TilePainter methods virtual bool paint(Tile* tile, SkCanvas* canvas); @@ -72,7 +72,6 @@ private: IntRect visibleArea(); IntRect unclippedArea(); bool singleLayer() { return m_layers.size() == 1; } - void updateBackground(const Color& background); bool useAggressiveRendering(); const TransformationMatrix* drawTransform(); diff --git a/Source/WebCore/platform/graphics/android/rendering/SurfaceBacking.h b/Source/WebCore/platform/graphics/android/rendering/SurfaceBacking.h index b04e462..ec01dbe 100644 --- a/Source/WebCore/platform/graphics/android/rendering/SurfaceBacking.h +++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceBacking.h @@ -59,6 +59,11 @@ public: return !m_zooming && m_frontTexture->isReady() && m_scale > 0; } + bool isMissingContent() + { + return !m_zooming && m_frontTexture->isMissingContent(); + } + int nbTextures(IntRect& area, float scale) { // TODO: consider the zooming case for the backTexture diff --git a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp index cd5ceef..24e196b 100644 --- a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp +++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp @@ -63,11 +63,8 @@ SurfaceCollection::SurfaceCollection(LayerAndroid* layer) // set the layersurfaces' update count, to be drawn on painted tiles unsigned int updateCount = TilesManager::instance()->incWebkitContentUpdates(); - for (unsigned int i = 0; i < m_surfaces.size(); i++) { + for (unsigned int i = 0; i < m_surfaces.size(); i++) m_surfaces[i]->setUpdateCount(updateCount); - if (m_surfaces[i]->isBase()) - m_surfaces[i]->setBackground(getBackground()); - } #ifdef DEBUG_COUNT ClassTracker::instance()->increment("SurfaceCollection"); @@ -128,7 +125,7 @@ bool SurfaceCollection::drawGL(const SkRect& visibleRect) return needsRedraw; } -Color SurfaceCollection::getBackground() +Color SurfaceCollection::getBackgroundColor() { return static_cast(m_compositedRoot)->getBackgroundColor(); } @@ -156,6 +153,16 @@ bool SurfaceCollection::isReady() return true; } +bool SurfaceCollection::isMissingBackgroundContent() +{ + if (!m_compositedRoot) + return true; + + // return true when the first surface is missing content (indicating the + // entire viewport isn't covered) + return m_surfaces[0]->isMissingContent(); +} + void SurfaceCollection::computeTexturesAmount(TexturesResult* result) { for (unsigned int i = 0; i < m_surfaces.size(); i++) diff --git a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.h b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.h index 6450c9c..7dfe140 100644 --- a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.h +++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.h @@ -50,9 +50,10 @@ public: // Tiled painting methods (executed on groups) void prepareGL(const SkRect& visibleRect); bool drawGL(const SkRect& visibleRect); - Color getBackground(); + Color getBackgroundColor(); void swapTiles(); bool isReady(); + bool isMissingBackgroundContent(); void computeTexturesAmount(TexturesResult* result); // Recursive tree methods (animations, invals, etc) diff --git a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp index 91335c7..8c9cad5 100644 --- a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp +++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp @@ -224,6 +224,7 @@ int SurfaceCollectionManager::drawGL(double currentTime, IntRect& viewRect, // =========================================================================== // Don't have a drawing collection, draw white background Color background = Color::white; + bool drawBackground = true; if (m_drawingCollection) { bool drawingReady = didCollectionSwap || m_drawingCollection->isReady(); @@ -245,17 +246,21 @@ int SurfaceCollectionManager::drawGL(double currentTime, IntRect& viewRect, m_drawingCollection->evaluateAnimations(currentTime); ALOGV("drawing collection %p", m_drawingCollection); - background = m_drawingCollection->getBackground(); + background = m_drawingCollection->getBackgroundColor(); + drawBackground = m_drawingCollection->isMissingBackgroundContent(); } else if (m_paintingCollection) { // Use paintingCollection background color while tiles are not done painting. - background = m_paintingCollection->getBackground(); + background = m_paintingCollection->getBackgroundColor(); } // Start doing the actual GL drawing. - ALOGV("background is %x", background.rgb()); - // If background is opaque, we can safely and efficiently clear it here. - // Otherwise, we have to calculate all the missing tiles and blend the background. - GLUtils::clearBackgroundIfOpaque(&background); + if (drawBackground) { + ALOGV("background is %x", background.rgb()); + // If background is opaque, we can safely and efficiently clear it here. + // Otherwise, we have to calculate all the missing tiles and blend the background. + GLUtils::clearBackgroundIfOpaque(&background); + } + if (m_drawingCollection && m_drawingCollection->drawGL(visibleRect)) returnFlags |= uirenderer::DrawGlInfo::kStatusDraw; -- cgit v1.1