OSDN Git Service

DO NOT MERGE : Cherry-pick of change I9942e8e4 from master
authorNicolas Roard <nicolas@android.com>
Thu, 3 Mar 2011 18:16:31 +0000 (10:16 -0800)
committerThe Android Automerger <android-build@android.com>
Thu, 3 Mar 2011 20:34:30 +0000 (12:34 -0800)
Wait the remaining of the 60FPS cap delay rather than not paint.

Returning true if called faster than 60FPS means
we are not drawing and ask for the framework to call
us again; this works in general because the framework recopy
the previous framebuffer. But in some cases, it didn't, causing
the webview to flicker. A correct fix would be to introduce
the capping in framework rather than try to doing it in the
webview; in the meantime we will sleep the remaining of the delay
as a workaround, so that we still provide the GPU
benefits we wanted (at >60FPS the GPU was being saturated in
some cases).

bug:3500655
Change-Id: Iae50737b6d3202a8a0d3ec6d4a5261fe1b6d1b3f

WebCore/platform/graphics/android/GLWebViewState.cpp

index 0e7f559..8a88463 100644 (file)
@@ -306,8 +306,10 @@ bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, float scale, SkColo
     double currentTime = WTF::currentTime();
     double delta = currentTime - m_prevDrawTime;
 
-    if (delta < FRAMERATE_CAP)
-        return true;
+    if (delta < FRAMERATE_CAP) {
+        unsigned int usecs = (FRAMERATE_CAP - delta) * 1E6;
+        usleep(usecs);
+    }
 
     m_prevDrawTime = currentTime;