Title: [121288] trunk/Source
Revision
121288
Author
[email protected]
Date
2012-06-26 14:30:44 -0700 (Tue, 26 Jun 2012)

Log Message

[chromium] Expose rendering statistics to WebWidget.
https://bugs.webkit.org/show_bug.cgi?id=88268

Patch by Dave Tu <[email protected]> on 2012-06-26
Reviewed by James Robinson.

The WebKit side of a basic framework for exposing rendering statistics
to Chromium's --enable-benchmarking extension.

Source/Platform:

* chromium/public/WebLayerTreeView.h:
(WebRenderingStatistics):
(WebKit):
(WebLayerTreeView):

Source/WebCore:

* platform/graphics/chromium/cc/CCLayerTreeHost.h:
(WebCore::CCLayerTreeHost::implFrameNumber):
* platform/graphics/chromium/cc/CCProxy.h:
(CCProxy):
* platform/graphics/chromium/cc/CCSingleThreadProxy.h:
* platform/graphics/chromium/cc/CCThreadProxy.cpp:
(WebCore::CCThreadProxy::implFrameNumber):
(WebCore):
(WebCore::CCThreadProxy::implFrameNumberOnImplThread):
* platform/graphics/chromium/cc/CCThreadProxy.h:
(CCThreadProxy):

Source/WebKit/chromium:

* src/WebLayerTreeView.cpp:
(WebKit::WebLayerTreeView::renderingStatistics):
(WebKit):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/Platform/ChangeLog (121287 => 121288)


--- trunk/Source/Platform/ChangeLog	2012-06-26 21:21:54 UTC (rev 121287)
+++ trunk/Source/Platform/ChangeLog	2012-06-26 21:30:44 UTC (rev 121288)
@@ -1,3 +1,18 @@
+2012-06-26  Dave Tu  <[email protected]>
+
+        [chromium] Expose rendering statistics to WebWidget.
+        https://bugs.webkit.org/show_bug.cgi?id=88268
+
+        Reviewed by James Robinson.
+
+        The WebKit side of a basic framework for exposing rendering statistics
+        to Chromium's --enable-benchmarking extension.
+
+        * chromium/public/WebLayerTreeView.h:
+        (WebRenderingStatistics):
+        (WebKit):
+        (WebLayerTreeView):
+
 2012-06-25  James Robinson  <[email protected]>
 
         [chromium] Add WebLayer API for scrolling

Modified: trunk/Source/Platform/Platform.gypi (121287 => 121288)


--- trunk/Source/Platform/Platform.gypi	2012-06-26 21:21:54 UTC (rev 121287)
+++ trunk/Source/Platform/Platform.gypi	2012-06-26 21:30:44 UTC (rev 121288)
@@ -94,6 +94,7 @@
             'chromium/public/WebPrivatePtr.h',
             'chromium/public/WebRect.h',
             'chromium/public/WebReferrerPolicy.h',
+            'chromium/public/WebRenderingStats.h',
             'chromium/public/WebSessionDescriptionDescriptor.h',
             'chromium/public/WebSize.h',
             'chromium/public/WebSocketStreamError.h',

Modified: trunk/Source/Platform/chromium/public/WebLayerTreeView.h (121287 => 121288)


--- trunk/Source/Platform/chromium/public/WebLayerTreeView.h	2012-06-26 21:21:54 UTC (rev 121287)
+++ trunk/Source/Platform/chromium/public/WebLayerTreeView.h	2012-06-26 21:30:44 UTC (rev 121288)
@@ -44,6 +44,7 @@
 class WebLayerTreeViewImpl;
 struct WebPoint;
 struct WebRect;
+struct WebRenderingStats;
 
 class WebLayerTreeView : public WebNonCopyable {
 public:
@@ -173,6 +174,10 @@
 
     // Debugging / dangerous ---------------------------------------------
 
+    // Fills in a WebRenderingStats struct containing information about the state of the compositor.
+    // This call is relatively expensive in threaded mode as it blocks on the compositor thread.
+    WEBKIT_EXPORT void renderingStats(WebRenderingStats&) const;
+
     // Simulates a lost context. For testing only.
     WEBKIT_EXPORT void loseCompositorContext(int numTimes);
 

Added: trunk/Source/Platform/chromium/public/WebRenderingStats.h (0 => 121288)


--- trunk/Source/Platform/chromium/public/WebRenderingStats.h	                        (rev 0)
+++ trunk/Source/Platform/chromium/public/WebRenderingStats.h	2012-06-26 21:30:44 UTC (rev 121288)
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebRenderingStats_h
+#define WebRenderingStats_h
+
+namespace WebKit {
+
+struct WebRenderingStats {
+    int numAnimationFrames;
+    int numFramesSentToScreen;
+
+    WebRenderingStats()
+        : numAnimationFrames(0)
+        , numFramesSentToScreen(0)
+    {
+    }
+};
+
+} // namespace WebKit
+
+#endif // WebRenderingStats_h

Modified: trunk/Source/WebCore/ChangeLog (121287 => 121288)


--- trunk/Source/WebCore/ChangeLog	2012-06-26 21:21:54 UTC (rev 121287)
+++ trunk/Source/WebCore/ChangeLog	2012-06-26 21:30:44 UTC (rev 121288)
@@ -1,3 +1,25 @@
+2012-06-26  Dave Tu  <[email protected]>
+
+        [chromium] Expose rendering statistics to WebWidget.
+        https://bugs.webkit.org/show_bug.cgi?id=88268
+
+        Reviewed by James Robinson.
+
+        The WebKit side of a basic framework for exposing rendering statistics
+        to Chromium's --enable-benchmarking extension.
+
+        * platform/graphics/chromium/cc/CCLayerTreeHost.h:
+        (WebCore::CCLayerTreeHost::implFrameNumber):
+        * platform/graphics/chromium/cc/CCProxy.h:
+        (CCProxy):
+        * platform/graphics/chromium/cc/CCSingleThreadProxy.h:
+        * platform/graphics/chromium/cc/CCThreadProxy.cpp:
+        (WebCore::CCThreadProxy::implFrameNumber):
+        (WebCore):
+        (WebCore::CCThreadProxy::implFrameNumberOnImplThread):
+        * platform/graphics/chromium/cc/CCThreadProxy.h:
+        (CCThreadProxy):
+
 2012-06-26  Dave Tharp  <[email protected]>
 
         ietestcenter/css3/valuesandunits/units-000.htm asserts

Modified: trunk/Source/WebCore/WebCore.gypi (121287 => 121288)


--- trunk/Source/WebCore/WebCore.gypi	2012-06-26 21:21:54 UTC (rev 121287)
+++ trunk/Source/WebCore/WebCore.gypi	2012-06-26 21:30:44 UTC (rev 121288)
@@ -3753,6 +3753,7 @@
             'platform/graphics/chromium/cc/CCProxy.h',
             'platform/graphics/chromium/cc/CCQuadCuller.cpp',
             'platform/graphics/chromium/cc/CCQuadCuller.h',
+            'platform/graphics/chromium/cc/CCRenderingStats.h',
             'platform/graphics/chromium/cc/CCRenderPass.cpp',
             'platform/graphics/chromium/cc/CCRenderPass.h',
             'platform/graphics/chromium/cc/CCRenderPassDrawQuad.cpp',

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp (121287 => 121288)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp	2012-06-26 21:21:54 UTC (rev 121287)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp	2012-06-26 21:30:44 UTC (rev 121288)
@@ -39,6 +39,7 @@
 #include "cc/CCLayerTreeHostImpl.h"
 #include "cc/CCOcclusionTracker.h"
 #include "cc/CCOverdrawMetrics.h"
+#include "cc/CCRenderingStats.h"
 #include "cc/CCSettings.h"
 #include "cc/CCSingleThreadProxy.h"
 #include "cc/CCThreadProxy.h"
@@ -72,7 +73,8 @@
     , m_animating(false)
     , m_needsAnimateLayers(false)
     , m_client(client)
-    , m_frameNumber(0)
+    , m_animationFrameNumber(0)
+    , m_commitNumber(0)
     , m_layerRendererInitialized(false)
     , m_contextLost(false)
     , m_numTimesRecreateShouldFail(0)
@@ -211,6 +213,8 @@
     m_client->updateAnimations(monotonicFrameBeginTime);
     animateLayers(monotonicFrameBeginTime);
     m_animating = false;
+
+    m_animationFrameNumber++;
 }
 
 void CCLayerTreeHost::layout()
@@ -243,14 +247,14 @@
     if (rootLayer() && m_needsAnimateLayers)
         hostImpl->setNeedsAnimateLayers();
 
-    hostImpl->setSourceFrameNumber(frameNumber());
+    hostImpl->setSourceFrameNumber(commitNumber());
     hostImpl->setViewportSize(viewportSize());
     hostImpl->setDeviceScaleFactor(deviceScaleFactor());
     hostImpl->setPageScaleFactorAndLimits(m_pageScaleFactor, m_minPageScaleFactor, m_maxPageScaleFactor);
     hostImpl->setBackgroundColor(m_backgroundColor);
     hostImpl->setHasTransparentBackground(m_hasTransparentBackground);
 
-    m_frameNumber++;
+    m_commitNumber++;
 }
 
 void CCLayerTreeHost::commitComplete()
@@ -302,6 +306,12 @@
     m_proxy->finishAllRendering();
 }
 
+void CCLayerTreeHost::renderingStats(CCRenderingStats& stats) const
+{
+    m_proxy->implSideRenderingStats(stats);
+    stats.numAnimationFrames = animationFrameNumber();
+}
+
 const LayerRendererCapabilities& CCLayerTreeHost::layerRendererCapabilities() const
 {
     return m_proxy->layerRendererCapabilities();

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h (121287 => 121288)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h	2012-06-26 21:21:54 UTC (rev 121287)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h	2012-06-26 21:30:44 UTC (rev 121288)
@@ -46,12 +46,13 @@
 class CCLayerChromium;
 class CCLayerTreeHostImpl;
 class CCLayerTreeHostImplClient;
-struct CCScrollAndScaleSet;
 class CCTextureUpdater;
 class ManagedTexture;
 class Region;
 class TextureAllocator;
 class TextureManager;
+struct CCRenderingStats;
+struct CCScrollAndScaleSet;
 
 class CCLayerTreeHostClient {
 public:
@@ -195,8 +196,12 @@
 
     void finishAllRendering();
 
-    int frameNumber() const { return m_frameNumber; }
+    int animationFrameNumber() const { return m_animationFrameNumber; }
 
+    int commitNumber() const { return m_commitNumber; }
+
+    void renderingStats(CCRenderingStats&) const;
+
     const LayerRendererCapabilities& layerRendererCapabilities() const;
 
     // Test only hook
@@ -287,7 +292,8 @@
 
     CCLayerTreeHostClient* m_client;
 
-    int m_frameNumber;
+    int m_animationFrameNumber;
+    int m_commitNumber;
 
     OwnPtr<CCProxy> m_proxy;
     bool m_layerRendererInitialized;

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


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp	2012-06-26 21:21:54 UTC (rev 121287)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp	2012-06-26 21:30:44 UTC (rev 121288)
@@ -114,7 +114,7 @@
 CCLayerTreeHostImpl::CCLayerTreeHostImpl(const CCLayerTreeSettings& settings, CCLayerTreeHostImplClient* client)
     : m_client(client)
     , m_sourceFrameNumber(-1)
-    , m_frameNumber(0)
+    , m_sourceAnimationFrameNumber(0)
     , m_rootScrollLayerImpl(0)
     , m_currentlyScrollingLayerImpl(0)
     , m_scrollingLayerIdFromPreviousTree(-1)
@@ -519,7 +519,7 @@
 
     m_layerRenderer->finishDrawingFrame();
 
-    ++m_frameNumber;
+    ++m_sourceAnimationFrameNumber;
 
     // The next frame should start by assuming nothing has changed, and changes are noted as they occur.
     m_rootLayerImpl->resetAllChangeTrackingForSubtree();

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


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h	2012-06-26 21:21:54 UTC (rev 121287)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h	2012-06-26 21:30:44 UTC (rev 121288)
@@ -119,7 +119,7 @@
     void setFontAtlas(PassOwnPtr<CCFontAtlas>);
 
     void finishAllRendering();
-    int frameNumber() const { return m_frameNumber; }
+    int sourceAnimationFrameNumber() const { return m_sourceAnimationFrameNumber; }
 
     bool initializeLayerRenderer(PassOwnPtr<CCGraphicsContext>, TextureUploaderOption);
     bool isContextLost();
@@ -196,7 +196,7 @@
 
     CCLayerTreeHostImplClient* m_client;
     int m_sourceFrameNumber;
-    int m_frameNumber;
+    int m_sourceAnimationFrameNumber;
 
 private:
     void computeDoubleTapZoomDeltas(CCScrollAndScaleSet* scrollInfo);

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCProxy.h (121287 => 121288)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCProxy.h	2012-06-26 21:21:54 UTC (rev 121287)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCProxy.h	2012-06-26 21:30:44 UTC (rev 121288)
@@ -36,6 +36,7 @@
 class CCFontAtlas;
 class CCThread;
 class CCGraphicsContext;
+struct CCRenderingStats;
 struct LayerRendererCapabilities;
 
 // Abstract class responsible for proxying commands from the main-thread side of
@@ -81,6 +82,8 @@
 
     virtual int compositorIdentifier() const = 0;
 
+    virtual void implSideRenderingStats(CCRenderingStats&) = 0;
+
     virtual const LayerRendererCapabilities& layerRendererCapabilities() const = 0;
 
     virtual void setNeedsAnimate() = 0;

Added: trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderingStats.h (0 => 121288)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderingStats.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderingStats.h	2012-06-26 21:30:44 UTC (rev 121288)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CCRenderingStats_h
+#define CCRenderingStats_h
+
+namespace WebCore {
+
+struct CCRenderingStats {
+    int numAnimationFrames;
+    int numFramesSentToScreen;
+
+    CCRenderingStats()
+        : numAnimationFrames(0)
+        , numFramesSentToScreen(0)
+    {
+    }
+};
+
+}
+
+#endif

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


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp	2012-06-26 21:21:54 UTC (rev 121287)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp	2012-06-26 21:30:44 UTC (rev 121288)
@@ -31,6 +31,7 @@
 #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>
@@ -179,6 +180,11 @@
     return initialized;
 }
 
+void CCSingleThreadProxy::implSideRenderingStats(CCRenderingStats& stats)
+{
+    stats.numFramesSentToScreen = m_layerTreeHostImpl->sourceAnimationFrameNumber();
+}
+
 const LayerRendererCapabilities& CCSingleThreadProxy::layerRendererCapabilities() const
 {
     ASSERT(m_layerRendererInitialized);

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h (121287 => 121288)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h	2012-06-26 21:21:54 UTC (rev 121287)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h	2012-06-26 21:30:44 UTC (rev 121288)
@@ -52,6 +52,7 @@
     virtual bool initializeLayerRenderer() OVERRIDE;
     virtual bool recreateContext() OVERRIDE;
     virtual int compositorIdentifier() const OVERRIDE { return m_compositorIdentifier; }
+    virtual void implSideRenderingStats(CCRenderingStats&) OVERRIDE;
     virtual const LayerRendererCapabilities& layerRendererCapabilities() const OVERRIDE;
     virtual void loseContext() OVERRIDE;
     virtual void setNeedsAnimate() OVERRIDE;

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


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp	2012-06-26 21:21:54 UTC (rev 121287)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp	2012-06-26 21:30:44 UTC (rev 121288)
@@ -36,6 +36,7 @@
 #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"
@@ -275,6 +276,17 @@
     return m_compositorIdentifier;
 }
 
+void CCThreadProxy::implSideRenderingStats(CCRenderingStats& stats)
+{
+    ASSERT(isMainThread());
+
+    CCCompletionEvent completion;
+    CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::implSideRenderingStatsOnImplThread,
+                                                       AllowCrossThreadAccess(&completion),
+                                                       AllowCrossThreadAccess(&stats)));
+    completion.wait();
+}
+
 const LayerRendererCapabilities& CCThreadProxy::layerRendererCapabilities() const
 {
     ASSERT(m_layerRendererInitialized);
@@ -886,4 +898,11 @@
     completion->signal();
 }
 
+void CCThreadProxy::implSideRenderingStatsOnImplThread(CCCompletionEvent* completion, CCRenderingStats* stats)
+{
+    ASSERT(isImplThread());
+    stats->numFramesSentToScreen = m_layerTreeHostImpl->sourceAnimationFrameNumber();
+    completion->signal();
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h (121287 => 121288)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h	2012-06-26 21:21:54 UTC (rev 121287)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h	2012-06-26 21:30:44 UTC (rev 121288)
@@ -60,6 +60,7 @@
     virtual bool initializeLayerRenderer() OVERRIDE;
     virtual bool recreateContext() OVERRIDE;
     virtual int compositorIdentifier() const OVERRIDE;
+    virtual void implSideRenderingStats(CCRenderingStats&) OVERRIDE;
     virtual const LayerRendererCapabilities& layerRendererCapabilities() const OVERRIDE;
     virtual void loseContext() OVERRIDE;
     virtual void setNeedsAnimate() OVERRIDE;
@@ -142,6 +143,7 @@
     void setFullRootLayerDamageOnImplThread();
     void acquireLayerTexturesForMainThreadOnImplThread(CCCompletionEvent*);
     void recreateContextOnImplThread(CCCompletionEvent*, CCGraphicsContext*, bool* recreateSucceeded, LayerRendererCapabilities*);
+    void implSideRenderingStatsOnImplThread(CCCompletionEvent*, CCRenderingStats*);
     CCScheduledActionDrawAndSwapResult scheduledActionDrawAndSwapInternal(bool forcedDraw);
     void setFontAtlasOnImplThread(PassOwnPtr<CCFontAtlas>);
     void forceSerializeOnSwapBuffersOnImplThread(CCCompletionEvent*);

Modified: trunk/Source/WebKit/chromium/ChangeLog (121287 => 121288)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-06-26 21:21:54 UTC (rev 121287)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-06-26 21:30:44 UTC (rev 121288)
@@ -1,3 +1,17 @@
+2012-06-26  Dave Tu  <[email protected]>
+
+        [chromium] Expose rendering statistics to WebWidget.
+        https://bugs.webkit.org/show_bug.cgi?id=88268
+
+        Reviewed by James Robinson.
+
+        The WebKit side of a basic framework for exposing rendering statistics
+        to Chromium's --enable-benchmarking extension.
+
+        * src/WebLayerTreeView.cpp:
+        (WebKit::WebLayerTreeView::renderingStatistics):
+        (WebKit):
+
 2012-06-25  James Robinson  <[email protected]>
 
         [chromium] Add WebLayer API for scrolling

Modified: trunk/Source/WebKit/chromium/public/WebView.h (121287 => 121288)


--- trunk/Source/WebKit/chromium/public/WebView.h	2012-06-26 21:21:54 UTC (rev 121287)
+++ trunk/Source/WebKit/chromium/public/WebView.h	2012-06-26 21:30:44 UTC (rev 121288)
@@ -62,6 +62,7 @@
 struct WebMediaPlayerAction;
 struct WebPluginAction;
 struct WebPoint;
+struct WebRenderingStats;
 
 class WebView : public WebWidget {
 public:
@@ -464,6 +465,10 @@
 
     virtual bool setEditableSelectionOffsets(int start, int end) = 0;
 
+    // Fills in a WebRenderingStats struct containing information about the state of the compositor.
+    // This call is relatively expensive in threaded mode as it blocks on the compositor thread.
+    virtual void renderingStats(WebRenderingStats&) const { }
+
     // Visibility -----------------------------------------------------------
 
     // Sets the visibility of the WebView.

Modified: trunk/Source/WebKit/chromium/src/WebLayerTreeView.cpp (121287 => 121288)


--- trunk/Source/WebKit/chromium/src/WebLayerTreeView.cpp	2012-06-26 21:21:54 UTC (rev 121287)
+++ trunk/Source/WebKit/chromium/src/WebLayerTreeView.cpp	2012-06-26 21:30:44 UTC (rev 121288)
@@ -31,10 +31,12 @@
 #include "WebLayerTreeViewImpl.h"
 #include "cc/CCGraphicsContext.h"
 #include "cc/CCLayerTreeHost.h"
+#include "cc/CCRenderingStats.h"
 #include "platform/WebLayer.h"
 #include "platform/WebPoint.h"
 #include "platform/WebRect.h"
 #include "platform/WebSize.h"
+#include <public/WebRenderingStats.h>
 
 using namespace WebCore;
 
@@ -178,6 +180,15 @@
     return m_private->layerTreeHost()->context()->context3D();
 }
 
+void WebLayerTreeView::renderingStats(WebRenderingStats& stats) const
+{
+    CCRenderingStats ccStats;
+    m_private->layerTreeHost()->renderingStats(ccStats);
+
+    stats.numAnimationFrames = ccStats.numAnimationFrames;
+    stats.numFramesSentToScreen = ccStats.numFramesSentToScreen;
+}
+
 void WebLayerTreeView::loseCompositorContext(int numTimes)
 {
     m_private->layerTreeHost()->loseContext(numTimes);

Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.cpp (121287 => 121288)


--- trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2012-06-26 21:21:54 UTC (rev 121287)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2012-06-26 21:30:44 UTC (rev 121288)
@@ -729,6 +729,13 @@
     scheduleAnimation();
 }
 
+void WebViewImpl::renderingStats(WebRenderingStats& stats) const
+{
+    ASSERT(isAcceleratedCompositingActive());
+    if (!m_layerTreeView.isNull())
+        m_layerTreeView.renderingStats(stats);
+}
+
 void WebViewImpl::startPageScaleAnimation(const IntPoint& scroll, bool useAnchor, float newScale, double durationSec)
 {
     if (!m_layerTreeView.isNull())

Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.h (121287 => 121288)


--- trunk/Source/WebKit/chromium/src/WebViewImpl.h	2012-06-26 21:21:54 UTC (rev 121287)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.h	2012-06-26 21:30:44 UTC (rev 121288)
@@ -294,6 +294,7 @@
     virtual void updateBatteryStatus(const WebBatteryStatus&);
 #endif
     virtual void transferActiveWheelFlingAnimation(const WebActiveWheelFlingParameters&);
+    virtual void renderingStats(WebRenderingStats&) const;
 
     // WebLayerTreeViewClient
     virtual void willBeginFrame();

Modified: trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp (121287 => 121288)


--- trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp	2012-06-26 21:21:54 UTC (rev 121287)
+++ trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp	2012-06-26 21:30:44 UTC (rev 121288)
@@ -866,7 +866,7 @@
     virtual void layout()
     {
         LayerChromium* root = m_layerTreeHost->rootLayer();
-        if (!m_layerTreeHost->frameNumber())
+        if (!m_layerTreeHost->commitNumber())
             EXPECT_EQ(root->scrollPosition(), m_initialScroll);
         else {
             EXPECT_EQ(root->scrollPosition(), m_initialScroll + m_scrollAmount);
@@ -952,7 +952,7 @@
         root->setScrollable(true);
         root->setMaxScrollPosition(IntSize(100, 100));
 
-        if (!impl->sourceFrameNumber() && impl->frameNumber() == 1) {
+        if (!impl->sourceFrameNumber() && impl->sourceAnimationFrameNumber() == 1) {
             // First draw after first commit.
             EXPECT_EQ(root->scrollDelta(), IntSize());
             root->scrollBy(m_scrollAmount);
@@ -960,7 +960,7 @@
 
             EXPECT_EQ(root->scrollPosition(), m_initialScroll);
             postSetNeedsRedrawToMainThread();
-        } else if (!impl->sourceFrameNumber() && impl->frameNumber() == 2) {
+        } else if (!impl->sourceFrameNumber() && impl->sourceAnimationFrameNumber() == 2) {
             // Second draw after first commit.
             EXPECT_EQ(root->scrollDelta(), m_scrollAmount);
             root->scrollBy(m_scrollAmount);
@@ -970,7 +970,7 @@
             postSetNeedsCommitToMainThread();
         } else if (impl->sourceFrameNumber() == 1) {
             // Third or later draw after second commit.
-            EXPECT_GE(impl->frameNumber(), 3);
+            EXPECT_GE(impl->sourceAnimationFrameNumber(), 3);
             EXPECT_EQ(root->scrollDelta(), IntSize());
             EXPECT_EQ(root->scrollPosition(), m_initialScroll + m_scrollAmount + m_scrollAmount);
             endTest();
@@ -2235,7 +2235,7 @@
     virtual void beginCommitOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE
     {
         EXPECT_EQ(m_rootScrollLayer->scrollPosition(), IntPoint());
-        if (!m_layerTreeHost->frameNumber())
+        if (!m_layerTreeHost->commitNumber())
             EXPECT_EQ(m_childLayer->scrollPosition(), IntPoint());
         else
             EXPECT_EQ(m_childLayer->scrollPosition(), IntPoint() + m_scrollAmount);
@@ -2243,11 +2243,11 @@
 
     virtual void drawLayersOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE
     {
-        if (impl->frameNumber() == 1) {
+        if (impl->sourceAnimationFrameNumber() == 1) {
             EXPECT_EQ(impl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Wheel), CCInputHandlerClient::ScrollStarted);
             impl->scrollBy(m_scrollAmount);
             impl->scrollEnd();
-        } else if (impl->frameNumber() == 2)
+        } else if (impl->sourceAnimationFrameNumber() == 2)
             endTest();
     }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to