summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/graphics
diff options
context:
space:
mode:
authorChris Craik <ccraik@google.com>2012-07-16 11:02:34 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-07-16 11:02:34 -0700
commit13078dbf441da0e715fd3d00e5c04865c8e27e27 (patch)
treeb6c540b446adf89d8c49f6900196536296b2ddfe /Source/WebCore/platform/graphics
parent0a1eee83533d49ee4ee90be5cd6c6071478c03a9 (diff)
parent0453f79675ffe6fddb59add2dcee0e3f0e7e74b1 (diff)
downloadexternal_webkit-13078dbf441da0e715fd3d00e5c04865c8e27e27.zip
external_webkit-13078dbf441da0e715fd3d00e5c04865c8e27e27.tar.gz
external_webkit-13078dbf441da0e715fd3d00e5c04865c8e27e27.tar.bz2
Merge "Don't prepare in invoke mode unless needed"
Diffstat (limited to 'Source/WebCore/platform/graphics')
-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