Title: [123421] trunk/Source
Revision
123421
Author
[email protected]
Date
2012-07-23 21:17:49 -0700 (Mon, 23 Jul 2012)

Log Message

[chromium] Add droppedFrameCount to renderingStats.
https://bugs.webkit.org/show_bug.cgi?id=91694

Patch by Dave Tu <[email protected]> on 2012-07-23
Reviewed by Adrienne Walker.

Source/Platform:

* chromium/public/WebRenderingStats.h:
(WebRenderingStats):
(WebKit::WebRenderingStats::WebRenderingStats):

Source/WebCore:

* platform/graphics/chromium/cc/CCFrameRateCounter.cpp:
(WebCore):
(WebCore::CCFrameRateCounter::frameInterval):
(WebCore::CCFrameRateCounter::frameIndex):
(WebCore::CCFrameRateCounter::CCFrameRateCounter):
(WebCore::CCFrameRateCounter::markBeginningOfFrame):
(WebCore::CCFrameRateCounter::isBadFrame):
* platform/graphics/chromium/cc/CCFrameRateCounter.h:
(WebCore::CCFrameRateCounter::droppedFrameCount):
(CCFrameRateCounter):
* platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
(WebCore::CCLayerTreeHost::renderingStats):
* platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
(WebCore::CCLayerTreeHostImpl::CCLayerTreeHostImpl):
(WebCore::CCLayerTreeHostImpl::drawLayers):
* platform/graphics/chromium/cc/CCLayerTreeHostImpl.h:
(CCLayerTreeHostImpl):
* platform/graphics/chromium/cc/CCRenderingStats.h:
(CCRenderingStats):
(WebCore::CCRenderingStats::CCRenderingStats):
* platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:
(WebCore::CCSingleThreadProxy::implSideRenderingStats):
* platform/graphics/chromium/cc/CCThreadProxy.cpp:
(WebCore::CCThreadProxy::implSideRenderingStatsOnImplThread):

Source/WebKit/chromium:

* src/WebLayerTreeView.cpp:
(WebKit::WebLayerTreeView::renderingStats):
* tests/CCLayerTreeHostTest.cpp:
(WTF::CCLayerTreeHostTestScrollMultipleRedraw::drawLayersOnCCThread):

Modified Paths

Diff

Modified: trunk/Source/Platform/ChangeLog (123420 => 123421)


--- trunk/Source/Platform/ChangeLog	2012-07-24 02:55:43 UTC (rev 123420)
+++ trunk/Source/Platform/ChangeLog	2012-07-24 04:17:49 UTC (rev 123421)
@@ -1,3 +1,14 @@
+2012-07-23  Dave Tu  <[email protected]>
+
+        [chromium] Add droppedFrameCount to renderingStats.
+        https://bugs.webkit.org/show_bug.cgi?id=91694
+
+        Reviewed by Adrienne Walker.
+
+        * chromium/public/WebRenderingStats.h:
+        (WebRenderingStats):
+        (WebKit::WebRenderingStats::WebRenderingStats):
+
 2012-07-23  Brian Anderson  <[email protected]>
 
         [chromium] Use shallow flushes that don't glFlush

Modified: trunk/Source/Platform/chromium/public/WebRenderingStats.h (123420 => 123421)


--- trunk/Source/Platform/chromium/public/WebRenderingStats.h	2012-07-24 02:55:43 UTC (rev 123420)
+++ trunk/Source/Platform/chromium/public/WebRenderingStats.h	2012-07-24 04:17:49 UTC (rev 123421)
@@ -31,10 +31,12 @@
 struct WebRenderingStats {
     int numAnimationFrames;
     int numFramesSentToScreen;
+    int droppedFrameCount;
 
     WebRenderingStats()
         : numAnimationFrames(0)
         , numFramesSentToScreen(0)
+        , droppedFrameCount(0)
     {
     }
 };

Modified: trunk/Source/WebCore/ChangeLog (123420 => 123421)


--- trunk/Source/WebCore/ChangeLog	2012-07-24 02:55:43 UTC (rev 123420)
+++ trunk/Source/WebCore/ChangeLog	2012-07-24 04:17:49 UTC (rev 123421)
@@ -1,3 +1,35 @@
+2012-07-23  Dave Tu  <[email protected]>
+
+        [chromium] Add droppedFrameCount to renderingStats.
+        https://bugs.webkit.org/show_bug.cgi?id=91694
+
+        Reviewed by Adrienne Walker.
+
+        * platform/graphics/chromium/cc/CCFrameRateCounter.cpp:
+        (WebCore):
+        (WebCore::CCFrameRateCounter::frameInterval):
+        (WebCore::CCFrameRateCounter::frameIndex):
+        (WebCore::CCFrameRateCounter::CCFrameRateCounter):
+        (WebCore::CCFrameRateCounter::markBeginningOfFrame):
+        (WebCore::CCFrameRateCounter::isBadFrame):
+        * platform/graphics/chromium/cc/CCFrameRateCounter.h:
+        (WebCore::CCFrameRateCounter::droppedFrameCount):
+        (CCFrameRateCounter):
+        * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
+        (WebCore::CCLayerTreeHost::renderingStats):
+        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
+        (WebCore::CCLayerTreeHostImpl::CCLayerTreeHostImpl):
+        (WebCore::CCLayerTreeHostImpl::drawLayers):
+        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.h:
+        (CCLayerTreeHostImpl):
+        * platform/graphics/chromium/cc/CCRenderingStats.h:
+        (CCRenderingStats):
+        (WebCore::CCRenderingStats::CCRenderingStats):
+        * platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:
+        (WebCore::CCSingleThreadProxy::implSideRenderingStats):
+        * platform/graphics/chromium/cc/CCThreadProxy.cpp:
+        (WebCore::CCThreadProxy::implSideRenderingStatsOnImplThread):
+
 2012-07-23  Dan Bernstein  <[email protected]>
 
         Fixed the build after r123418.

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCFrameRateCounter.cpp (123420 => 123421)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCFrameRateCounter.cpp	2012-07-24 02:55:43 UTC (rev 123420)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCFrameRateCounter.cpp	2012-07-24 04:17:49 UTC (rev 123421)
@@ -35,6 +35,7 @@
 
 const double CCFrameRateCounter::kFrameTooFast = 1.0 / 70.0; // measured in seconds
 const double CCFrameRateCounter::kFrameTooSlow = 1.0 / 12.0;
+const double CCFrameRateCounter::kDroppedFrameTime = 1.0 / 50.0;
 
 // safeMod works on -1, returning m-1 in that case.
 static inline int safeMod(int number, int modulus)
@@ -42,13 +43,20 @@
     return (number + modulus) % modulus;
 }
 
-inline int CCFrameRateCounter::frameIndex(int frame) const
+inline double CCFrameRateCounter::frameInterval(int frameNumber) const
 {
-    return safeMod(frame, kTimeStampHistorySize);
+    return m_timeStampHistory[frameIndex(frameNumber)] -
+        m_timeStampHistory[frameIndex(frameNumber - 1)];
 }
 
+inline int CCFrameRateCounter::frameIndex(int frameNumber) const
+{
+    return safeMod(frameNumber, kTimeStampHistorySize);
+}
+
 CCFrameRateCounter::CCFrameRateCounter()
     : m_currentFrameNumber(1)
+    , m_droppedFrameCount(0)
 {
     m_timeStampHistory[0] = currentTime();
     m_timeStampHistory[1] = m_timeStampHistory[0];
@@ -67,6 +75,9 @@
     }
 
     m_timeStampHistory[frameIndex(m_currentFrameNumber)] = timestamp;
+    double delta = frameInterval(m_currentFrameNumber);
+    if (!isBadFrameInterval(delta) && delta > kDroppedFrameTime)
+        ++m_droppedFrameCount;
 }
 
 void CCFrameRateCounter::markEndOfFrame()
@@ -84,9 +95,7 @@
 
 bool CCFrameRateCounter::isBadFrame(int frameNumber) const
 {
-    double delta = m_timeStampHistory[frameIndex(frameNumber)] -
-            m_timeStampHistory[frameIndex(frameNumber - 1)];
-    return isBadFrameInterval(delta);
+    return isBadFrameInterval(frameInterval(frameNumber));
 }
 
 void CCFrameRateCounter::getAverageFPSAndStandardDeviation(double& averageFPS, double& standardDeviation) const

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCFrameRateCounter.h (123420 => 123421)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCFrameRateCounter.h	2012-07-24 02:55:43 UTC (rev 123420)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCFrameRateCounter.h	2012-07-24 04:17:49 UTC (rev 123421)
@@ -56,9 +56,12 @@
     // true if the given frame interval is too fast or too slow, based on constant thresholds.
     bool isBadFrameInterval(double intervalBetweenConsecutiveFrames) const;
 
+    int droppedFrameCount() const { return m_droppedFrameCount; }
+
 private:
     CCFrameRateCounter();
 
+    double frameInterval(int frameNumber) const;
     int frameIndex(int frameNumber) const;
     bool isBadFrame(int frameNumber) const;
 
@@ -68,10 +71,17 @@
     static const double kFrameTooFast;
     static const double kFrameTooSlow;
 
+    // If a frame takes longer than this threshold (measured in seconds) then we
+    // (naively) assume that it missed a screen refresh; that is, we dropped a frame.
+    // FIXME: Determine this threshold based on monitor refresh rate, crbug.com/138642.
+    static const double kDroppedFrameTime;
+
     static const int kTimeStampHistorySize = 120;
 
     int m_currentFrameNumber;
     double m_timeStampHistory[kTimeStampHistorySize];
+
+    int m_droppedFrameCount;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp (123420 => 123421)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp	2012-07-24 02:55:43 UTC (rev 123420)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp	2012-07-24 04:17:49 UTC (rev 123421)
@@ -43,6 +43,7 @@
 #include "cc/CCPageScaleAnimation.h"
 #include "cc/CCPrioritizedTextureManager.h"
 #include "cc/CCRenderPassDrawQuad.h"
+#include "cc/CCRenderingStats.h"
 #include "cc/CCSettings.h"
 #include "cc/CCSingleThreadProxy.h"
 #include <wtf/CurrentTime.h>
@@ -114,7 +115,6 @@
 CCLayerTreeHostImpl::CCLayerTreeHostImpl(const CCLayerTreeSettings& settings, CCLayerTreeHostImplClient* client)
     : m_client(client)
     , m_sourceFrameNumber(-1)
-    , m_sourceAnimationFrameNumber(0)
     , m_rootScrollLayerImpl(0)
     , m_currentlyScrollingLayerImpl(0)
     , m_scrollingLayerIdFromPreviousTree(-1)
@@ -562,8 +562,6 @@
     if (m_debugRectHistory->enabled(settings()))
         m_debugRectHistory->saveDebugRectsForCurrentFrame(m_rootLayerImpl.get(), *frame.renderSurfaceLayerList, frame.occludingScreenSpaceRects, settings());
 
-    ++m_sourceAnimationFrameNumber;
-
     // The next frame should start by assuming nothing has changed, and changes are noted as they occur.
     m_rootLayerImpl->resetAllChangeTrackingForSubtree();
 }
@@ -1187,4 +1185,15 @@
         m_activeGestureAnimation.clear();
 }
 
+int CCLayerTreeHostImpl::sourceAnimationFrameNumber() const
+{
+    return fpsCounter()->currentFrameNumber();
+}
+
+void CCLayerTreeHostImpl::renderingStats(CCRenderingStats& stats) const
+{
+    stats.numFramesSentToScreen = fpsCounter()->currentFrameNumber();
+    stats.droppedFrameCount = fpsCounter()->droppedFrameCount();
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h (123420 => 123421)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h	2012-07-24 02:55:43 UTC (rev 123420)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h	2012-07-24 04:17:49 UTC (rev 123421)
@@ -49,6 +49,7 @@
 class CCResourceProvider;
 class LayerRendererChromium;
 struct LayerRendererCapabilities;
+struct CCRenderingStats;
 
 // CCLayerTreeHost->CCProxy callback interface.
 class CCLayerTreeHostImplClient {
@@ -121,7 +122,7 @@
     void setFontAtlas(PassOwnPtr<CCFontAtlas>);
 
     void finishAllRendering();
-    int sourceAnimationFrameNumber() const { return m_sourceAnimationFrameNumber; }
+    int sourceAnimationFrameNumber() const;
 
     bool initializeLayerRenderer(PassOwnPtr<CCGraphicsContext>, TextureUploaderOption);
     bool isContextLost();
@@ -174,6 +175,8 @@
 
     void setNeedsRedraw();
 
+    void renderingStats(CCRenderingStats&) const;
+
     CCFrameRateCounter* fpsCounter() const { return m_fpsCounter.get(); }
     CCDebugRectHistory* debugRectHistory() const { return m_debugRectHistory.get(); }
     CCResourceProvider* resourceProvider() const { return m_resourceProvider.get(); }
@@ -225,7 +228,6 @@
 
     CCLayerTreeHostImplClient* m_client;
     int m_sourceFrameNumber;
-    int m_sourceAnimationFrameNumber;
 
 private:
     void computeDoubleTapZoomDeltas(CCScrollAndScaleSet* scrollInfo);

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderingStats.h (123420 => 123421)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderingStats.h	2012-07-24 02:55:43 UTC (rev 123420)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderingStats.h	2012-07-24 04:17:49 UTC (rev 123421)
@@ -28,12 +28,15 @@
 namespace WebCore {
 
 struct CCRenderingStats {
+    // FIXME: Rename these to animationFrameCount and screenFrameCount, crbug.com/138641.
     int numAnimationFrames;
     int numFramesSentToScreen;
+    int droppedFrameCount;
 
     CCRenderingStats()
         : numAnimationFrames(0)
         , numFramesSentToScreen(0)
+        , droppedFrameCount(0)
     {
     }
 };

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp (123420 => 123421)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp	2012-07-24 02:55:43 UTC (rev 123420)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp	2012-07-24 04:17:49 UTC (rev 123421)
@@ -31,7 +31,6 @@
 #include "cc/CCFontAtlas.h"
 #include "cc/CCGraphicsContext.h"
 #include "cc/CCLayerTreeHost.h"
-#include "cc/CCRenderingStats.h"
 #include "cc/CCTextureUpdater.h"
 #include "cc/CCTimer.h"
 #include <wtf/CurrentTime.h>
@@ -173,7 +172,7 @@
 
 void CCSingleThreadProxy::implSideRenderingStats(CCRenderingStats& stats)
 {
-    stats.numFramesSentToScreen = m_layerTreeHostImpl->sourceAnimationFrameNumber();
+    m_layerTreeHostImpl->renderingStats(stats);
 }
 
 const LayerRendererCapabilities& CCSingleThreadProxy::layerRendererCapabilities() const

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp (123420 => 123421)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp	2012-07-24 02:55:43 UTC (rev 123420)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp	2012-07-24 04:17:49 UTC (rev 123421)
@@ -36,7 +36,6 @@
 #include "cc/CCGraphicsContext.h"
 #include "cc/CCInputHandler.h"
 #include "cc/CCLayerTreeHost.h"
-#include "cc/CCRenderingStats.h"
 #include "cc/CCScheduler.h"
 #include "cc/CCScopedThreadProxy.h"
 #include "cc/CCTextureUpdater.h"
@@ -895,7 +894,7 @@
 void CCThreadProxy::implSideRenderingStatsOnImplThread(CCCompletionEvent* completion, CCRenderingStats* stats)
 {
     ASSERT(isImplThread());
-    stats->numFramesSentToScreen = m_layerTreeHostImpl->sourceAnimationFrameNumber();
+    m_layerTreeHostImpl->renderingStats(*stats);
     completion->signal();
 }
 

Modified: trunk/Source/WebKit/chromium/ChangeLog (123420 => 123421)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-07-24 02:55:43 UTC (rev 123420)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-07-24 04:17:49 UTC (rev 123421)
@@ -1,3 +1,15 @@
+2012-07-23  Dave Tu  <[email protected]>
+
+        [chromium] Add droppedFrameCount to renderingStats.
+        https://bugs.webkit.org/show_bug.cgi?id=91694
+
+        Reviewed by Adrienne Walker.
+
+        * src/WebLayerTreeView.cpp:
+        (WebKit::WebLayerTreeView::renderingStats):
+        * tests/CCLayerTreeHostTest.cpp:
+        (WTF::CCLayerTreeHostTestScrollMultipleRedraw::drawLayersOnCCThread):
+
 2012-07-23  Brian Anderson  <[email protected]>
 
         [chromium] Use shallow flushes that don't glFlush

Modified: trunk/Source/WebKit/chromium/src/WebLayerTreeView.cpp (123420 => 123421)


--- trunk/Source/WebKit/chromium/src/WebLayerTreeView.cpp	2012-07-24 02:55:43 UTC (rev 123420)
+++ trunk/Source/WebKit/chromium/src/WebLayerTreeView.cpp	2012-07-24 04:17:49 UTC (rev 123421)
@@ -182,6 +182,7 @@
 
     stats.numAnimationFrames = ccStats.numAnimationFrames;
     stats.numFramesSentToScreen = ccStats.numFramesSentToScreen;
+    stats.droppedFrameCount = ccStats.droppedFrameCount;
 }
 
 void WebLayerTreeView::loseCompositorContext(int numTimes)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to