summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp30
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.h9
2 files changed, 33 insertions, 6 deletions
diff --git a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp
index 1270498..09cb832 100644
--- a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp
@@ -49,6 +49,7 @@ SurfaceCollectionManager::SurfaceCollectionManager()
, m_fastSwapMode(false)
, m_previouslyScrolling(false)
, m_newPaintingCollection(false)
+ , m_lastPreparedCollection(0)
{
}
@@ -229,6 +230,26 @@ int SurfaceCollectionManager::singleSurfaceModeInvalidation(bool hasRunningAnima
return returnFlags;
}
+void SurfaceCollectionManager::prepareGL(SurfaceCollection* collection, SkRect& visibleContentRect,
+ float scale, TexturesResult* texturesResultPtr,
+ bool shouldDraw, bool tryFastBlit)
+{
+
+ // don't prepare if not drawing, and nothing changed
+ if (!shouldDraw
+ && collection == m_lastPreparedCollection
+ && visibleContentRect == m_lastPreparedRect
+ && std::abs(scale - m_lastPreparedScale) < 0.01)
+ return;
+
+ collection->prepareGL(visibleContentRect, tryFastBlit);
+ collection->computeTexturesAmount(texturesResultPtr);
+
+ m_lastPreparedCollection = collection;
+ m_lastPreparedRect = visibleContentRect;
+ m_lastPreparedScale = scale;
+}
+
int SurfaceCollectionManager::drawGL(double currentTime, IntRect& viewRect,
SkRect& visibleContentRect, float scale,
bool scrolling, bool singleSurfaceMode,
@@ -252,9 +273,8 @@ int SurfaceCollectionManager::drawGL(double currentTime, IntRect& viewRect,
m_paintingCollection->evaluateAnimations(currentTime);
- m_paintingCollection->prepareGL(visibleContentRect, tryFastBlit);
- m_paintingCollection->computeTexturesAmount(texturesResultPtr);
-
+ prepareGL(m_paintingCollection, visibleContentRect, scale,
+ texturesResultPtr, shouldDraw, tryFastBlit);
if (!TilesManager::instance()->useDoubleBuffering() || m_paintingCollection->isReady()) {
ALOGV("have painting collection %p ready, swapping!", m_paintingCollection);
didCollectionSwap = true;
@@ -268,8 +288,8 @@ int SurfaceCollectionManager::drawGL(double currentTime, IntRect& viewRect,
}
} else if (m_drawingCollection) {
ALOGV("preparing drawing collection %p", m_drawingCollection);
- m_drawingCollection->prepareGL(visibleContentRect);
- m_drawingCollection->computeTexturesAmount(texturesResultPtr);
+ prepareGL(m_drawingCollection, visibleContentRect, scale,
+ texturesResultPtr, shouldDraw, tryFastBlit);
}
if (m_paintingCollection)
diff --git a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.h b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.h
index 53b5bb6..70b84df 100644
--- a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.h
+++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.h
@@ -26,10 +26,10 @@
#ifndef SurfaceCollectionManager_h
#define SurfaceCollectionManager_h
+#include "SkRect.h"
#include "TestExport.h"
#include <utils/threads.h>
-class SkRect;
class SkCanvas;
namespace WebCore {
@@ -60,6 +60,9 @@ private:
void clearCollections();
void updatePaintingCollection(SurfaceCollection* newCollection);
int singleSurfaceModeInvalidation(bool hasRunningAnimation, bool scrolling, bool shouldDraw);
+ void prepareGL(SurfaceCollection* collection, SkRect& visibleContentRect, float scale,
+ TexturesResult* texturesResultPtr, bool shouldDraw, bool tryFastBlit);
+
SurfaceCollection* m_drawingCollection;
SurfaceCollection* m_paintingCollection;
SurfaceCollection* m_queuedCollection;
@@ -70,6 +73,10 @@ private:
// Used in single surface mode only. True if there is a new painting tree
// added for the current frame.
bool m_newPaintingCollection;
+
+ SurfaceCollection* m_lastPreparedCollection;
+ SkRect m_lastPreparedRect;
+ float m_lastPreparedScale;
};
} // namespace WebCore