diff options
author | Nicolas Roard <nicolas@android.com> | 2011-02-28 09:58:49 -0800 |
---|---|---|
committer | Nicolas Roard <nicolas@android.com> | 2011-02-28 13:39:23 -0800 |
commit | 6d5a826027fa96886cf0232041e8d4ac0887234f (patch) | |
tree | 9ed771b051c446e10b2a1b5194ddcd3be5188964 /WebCore/platform/graphics/android | |
parent | d914e54363c3b0482ac7f4843af11d1beb340afe (diff) | |
download | external_webkit-6d5a826027fa96886cf0232041e8d4ac0887234f.zip external_webkit-6d5a826027fa96886cf0232041e8d4ac0887234f.tar.gz external_webkit-6d5a826027fa96886cf0232041e8d4ac0887234f.tar.bz2 |
Cap framerate at 60fps
Change-Id: I1b6be15a38d2afc55659872b82e13ebcd8fd2ada
Diffstat (limited to 'WebCore/platform/graphics/android')
-rw-r--r-- | WebCore/platform/graphics/android/BaseLayerAndroid.cpp | 1 | ||||
-rw-r--r-- | WebCore/platform/graphics/android/GLWebViewState.cpp | 16 |
2 files changed, 15 insertions, 2 deletions
diff --git a/WebCore/platform/graphics/android/BaseLayerAndroid.cpp b/WebCore/platform/graphics/android/BaseLayerAndroid.cpp index 2166e9d..584add1 100644 --- a/WebCore/platform/graphics/android/BaseLayerAndroid.cpp +++ b/WebCore/platform/graphics/android/BaseLayerAndroid.cpp @@ -334,7 +334,6 @@ bool BaseLayerAndroid::drawGL(IntRect& viewRect, SkRect& visibleRect, TilesManager::instance()->cleanupLayersTextures(0); } - glFinish(); glBindBuffer(GL_ARRAY_BUFFER, 0); m_previousVisible = visibleRect; diff --git a/WebCore/platform/graphics/android/GLWebViewState.cpp b/WebCore/platform/graphics/android/GLWebViewState.cpp index b3c5b02..3ca04e9 100644 --- a/WebCore/platform/graphics/android/GLWebViewState.cpp +++ b/WebCore/platform/graphics/android/GLWebViewState.cpp @@ -32,11 +32,11 @@ #include "ClassTracker.h" #include "LayerAndroid.h" #include "TilesManager.h" +#include <wtf/CurrentTime.h> #ifdef DEBUG #include <cutils/log.h> -#include <wtf/CurrentTime.h> #include <wtf/text/CString.h> #undef XLOG @@ -52,6 +52,8 @@ #define FIRST_TILED_PAGE_ID 1 #define SECOND_TILED_PAGE_ID 2 +#define FRAMERATE_CAP 0.01666 // We cap at 60 fps + namespace WebCore { using namespace android; @@ -299,8 +301,20 @@ void GLWebViewState::setViewport(SkRect& viewport, float scale) m_tiledPageB->updateBaseTileSize(); } +static double gPrevTime = 0; + bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, float scale, SkColor color) { + glFinish(); + + double currentTime = WTF::currentTime(); + double delta = currentTime - gPrevTime; + + if (delta < FRAMERATE_CAP) + return true; + + gPrevTime = currentTime; + m_baseLayerLock.lock(); BaseLayerAndroid* baseLayer = m_currentBaseLayer; SkSafeRef(baseLayer); |