diff options
author | Teng-Hui Zhu <ztenghui@google.com> | 2012-05-30 16:54:41 -0700 |
---|---|---|
committer | Teng-Hui Zhu <ztenghui@google.com> | 2012-05-31 09:47:35 -0700 |
commit | 150a26fa5442a5fc931e5df05808e33aac1a7dea (patch) | |
tree | cb7bb0b1d274a3832535b9c78d7c673a6e001420 | |
parent | 6f60c96bbd87b5c54d89aeb23ace06ae3647e2f3 (diff) | |
download | external_webkit-150a26fa5442a5fc931e5df05808e33aac1a7dea.zip external_webkit-150a26fa5442a5fc931e5df05808e33aac1a7dea.tar.gz external_webkit-150a26fa5442a5fc931e5df05808e33aac1a7dea.tar.bz2 |
Fix animation in single surface mode
bug:5683630
Change-Id: I4d617962a8412de884903f150799f733ea996e1c
4 files changed, 27 insertions, 27 deletions
diff --git a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp index 3cfabe1..1c769bf 100644 --- a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp +++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.cpp @@ -151,10 +151,8 @@ void SurfaceCollection::addFrameworkInvals() bool SurfaceCollection::isReady() { // Override layer readiness check for single surface mode - if (m_compositedRoot->state()->isSingleSurfaceRenderingMode()) { - // TODO: single surface mode should be properly double buffered - return true; - } + if (m_compositedRoot->state()->isSingleSurfaceRenderingMode()) + return m_surfaces[0]->isReady(); for (unsigned int i = 0; i < m_surfaces.size(); i++) { if (!m_surfaces[i]->isReady()) { @@ -165,12 +163,6 @@ bool SurfaceCollection::isReady() return true; } -bool SurfaceCollection::isBaseSurfaceReady() -{ - // m_surfaces[0] should be the base surface when in single surface mode. - return m_surfaces[0]->isReady(); -} - bool SurfaceCollection::isMissingBackgroundContent() { // return true when the first surface is missing content (indicating the @@ -222,9 +214,9 @@ void SurfaceCollection::mergeInvalsInto(SurfaceCollection* replacementSurface) m_compositedRoot->mergeInvalsInto(replacementSurface->m_compositedRoot); } -void SurfaceCollection::evaluateAnimations(double currentTime) +bool SurfaceCollection::evaluateAnimations(double currentTime) { - m_compositedRoot->evaluateAnimations(currentTime); + return m_compositedRoot->evaluateAnimations(currentTime); } bool SurfaceCollection::hasCompositedLayers() diff --git a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.h b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.h index ff4195f..a903015 100644 --- a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.h +++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollection.h @@ -54,7 +54,6 @@ public: void swapTiles(); void addFrameworkInvals(); bool isReady(); - bool isBaseSurfaceReady(); bool isMissingBackgroundContent(); void removePainterOperations(); void computeTexturesAmount(TexturesResult* result); @@ -63,7 +62,7 @@ public: void setIsPainting(SurfaceCollection* drawingSurfaceCollection); void setIsDrawing(); void mergeInvalsInto(SurfaceCollection* replacementSurfaceCollection); - void evaluateAnimations(double currentTime); + bool evaluateAnimations(double currentTime); bool hasCompositedLayers(); bool hasCompositedAnimations(); diff --git a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp index 724bf89..174720f 100644 --- a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp +++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp @@ -171,7 +171,8 @@ void SurfaceCollectionManager::updateScrollableLayer(int layerId, int x, int y) } -int SurfaceCollectionManager::singleSurfaceModeInvalidation(bool scrolling, +int SurfaceCollectionManager::singleSurfaceModeInvalidation(bool hasRunningAnimation, + bool scrolling, bool shouldDraw) { int returnFlags = 0; @@ -179,21 +180,28 @@ int SurfaceCollectionManager::singleSurfaceModeInvalidation(bool scrolling, // scrolling or have an incoming painting tree. bool requireDirtyAll = (m_previouslyScrolling && !scrolling) || m_newPaintingCollection; - if (requireDirtyAll) - TilesManager::instance()->dirtyAllTiles(); // We also need to tell the framework to continue to invoke until // the base layer is ready. bool drawingBaseSurfaceReady = m_drawingCollection - && m_drawingCollection->isBaseSurfaceReady(); + && m_drawingCollection->isReady(); + + // When the base layer is ready, we can ask the framework to draw. And if + // animation is running, dirty all the tiles, otherwise the animation will + // be paused. + if (drawingBaseSurfaceReady) { + if (!shouldDraw) + returnFlags |= DrawGlInfo::kStatusDraw; + else + requireDirtyAll |= hasRunningAnimation; + } + if (requireDirtyAll) + TilesManager::instance()->dirtyAllTiles(); + bool requireInvoke = requireDirtyAll || !drawingBaseSurfaceReady; if (requireInvoke) returnFlags |= DrawGlInfo::kStatusInvoke; - // When the base layer is ready, we can ask the framework to draw. - if (!shouldDraw && drawingBaseSurfaceReady) - returnFlags |= DrawGlInfo::kStatusDraw; - m_newPaintingCollection = false; m_previouslyScrolling = scrolling; @@ -246,9 +254,6 @@ int SurfaceCollectionManager::drawGL(double currentTime, IntRect& viewRect, if (m_paintingCollection) returnFlags |= DrawGlInfo::kStatusInvoke; - if (singleSurfaceMode) - returnFlags |= singleSurfaceModeInvalidation(scrolling, shouldDraw); - if (!shouldDraw) { if (didCollectionSwap || (!m_paintingCollection @@ -270,6 +275,7 @@ int SurfaceCollectionManager::drawGL(double currentTime, IntRect& viewRect, // Don't have a drawing collection, draw white background Color background = Color::white; bool drawBackground = true; + bool hasRunningAnimation = false; if (m_drawingCollection) { bool drawingReady = didCollectionSwap || m_drawingCollection->isReady(); @@ -288,7 +294,7 @@ int SurfaceCollectionManager::drawGL(double currentTime, IntRect& viewRect, returnFlags |= DrawGlInfo::kStatusInvoke; } - m_drawingCollection->evaluateAnimations(currentTime); + hasRunningAnimation = m_drawingCollection->evaluateAnimations(currentTime); ALOGV("drawing collection %p", m_drawingCollection); background = m_drawingCollection->getBackgroundColor(); @@ -298,6 +304,9 @@ int SurfaceCollectionManager::drawGL(double currentTime, IntRect& viewRect, background = m_paintingCollection->getBackgroundColor(); } + if (singleSurfaceMode) + returnFlags |= singleSurfaceModeInvalidation(hasRunningAnimation, + scrolling, shouldDraw); // Start doing the actual GL drawing. if (drawBackground) { ALOGV("background is %x", background.rgb()); diff --git a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.h b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.h index 6aed060..53b5bb6 100644 --- a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.h +++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.h @@ -59,7 +59,7 @@ private: void swap(); void clearCollections(); void updatePaintingCollection(SurfaceCollection* newCollection); - int singleSurfaceModeInvalidation(bool scrolling, bool shouldDraw); + int singleSurfaceModeInvalidation(bool hasRunningAnimation, bool scrolling, bool shouldDraw); SurfaceCollection* m_drawingCollection; SurfaceCollection* m_paintingCollection; SurfaceCollection* m_queuedCollection; |