From 65b97159d8d180594e604d2ca5f6674388354416 Mon Sep 17 00:00:00 2001 From: Nicolas Roard Date: Mon, 28 Feb 2011 09:58:49 -0800 Subject: Cap framerate at 60fps bug:3471680 Change-Id: Ia19c4402858b758312c1f801bda990275f970b63 --- WebCore/platform/graphics/android/BaseLayerAndroid.cpp | 1 - WebCore/platform/graphics/android/GLWebViewState.cpp | 16 +++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'WebCore/platform') diff --git a/WebCore/platform/graphics/android/BaseLayerAndroid.cpp b/WebCore/platform/graphics/android/BaseLayerAndroid.cpp index e373c3d..6f27321 100644 --- a/WebCore/platform/graphics/android/BaseLayerAndroid.cpp +++ b/WebCore/platform/graphics/android/BaseLayerAndroid.cpp @@ -337,7 +337,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 eef32e8..57d4c66 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 #ifdef DEBUG #include -#include #include #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; @@ -296,8 +298,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; baseLayer->safeRef(); -- cgit v1.1