[chromium] Pass screen refresh rate into compositor.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Nov 2011 14:04:57 +0000 (14:04 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Nov 2011 14:04:57 +0000 (14:04 +0000)
https://bugs.webkit.org/show_bug.cgi?id=71040

Patch by Iain Merrick <husky@google.com> on 2011-11-16
Reviewed by Tony Gentilcore.

Source/WebCore:

* platform/PlatformScreen.h:
* platform/chromium/PlatformScreenChromium.cpp:
(WebCore::screenRefreshRate):
* platform/chromium/PlatformSupport.h:
* platform/graphics/chromium/cc/CCLayerTreeHost.h:
(WebCore::CCSettings::CCSettings):
* platform/graphics/chromium/cc/CCThreadProxy.cpp:
(WebCore::CCThreadProxy::initializeImplOnImplThread):

Source/WebKit/chromium:

* public/WebScreenInfo.h:
(WebKit::WebScreenInfo::WebScreenInfo):
* src/PlatformSupport.cpp:
(WebCore::PlatformSupport::screenRefreshRate):
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::setIsAcceleratedCompositingActive):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@100438 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/PlatformScreen.h
Source/WebCore/platform/chromium/PlatformScreenChromium.cpp
Source/WebCore/platform/chromium/PlatformSupport.h
Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h
Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/public/WebScreenInfo.h
Source/WebKit/chromium/src/PlatformSupport.cpp
Source/WebKit/chromium/src/WebViewImpl.cpp

index ad7a3e90148764ae98ca1f931b1e3098ae950516..e4252b9327956a73c329eac17dd8d1496aa61820 100644 (file)
@@ -1,3 +1,19 @@
+2011-11-16  Iain Merrick  <husky@google.com>
+
+        [chromium] Pass screen refresh rate into compositor.
+        https://bugs.webkit.org/show_bug.cgi?id=71040
+
+        Reviewed by Tony Gentilcore.
+
+        * platform/PlatformScreen.h:
+        * platform/chromium/PlatformScreenChromium.cpp:
+        (WebCore::screenRefreshRate):
+        * platform/chromium/PlatformSupport.h:
+        * platform/graphics/chromium/cc/CCLayerTreeHost.h:
+        (WebCore::CCSettings::CCSettings):
+        * platform/graphics/chromium/cc/CCThreadProxy.cpp:
+        (WebCore::CCThreadProxy::initializeImplOnImplThread):
+
 2011-11-15  Andrey Kosyakov  <caseq@chromium.org>
 
         Web Inspector: [Extensions API] drop ExtensionSidebarPane.onUpdated, use callbacks instead
index 9d3058c59b0ec7b2ee2ca05d25282752d6aa8d7e..5bb4d2e9296d3c5955c96c70f2916ad2d01fb835 100644 (file)
@@ -54,6 +54,11 @@ namespace WebCore {
     FloatRect screenRect(Widget*);
     FloatRect screenAvailableRect(Widget*);
 
+#if PLATFORM(CHROMIUM)
+    // Measured in frames per second. 0 if the refresh rate is unknown, or not applicable.
+    double screenRefreshRate(Widget*);
+#endif
+
 #if PLATFORM(MAC)
     NSScreen *screenForWindow(NSWindow *);
 
index a7a7811d7954054fe8638524413c160ad798de3d..54365e28ee9092edc606a5595f49009cde19aa7d 100644 (file)
@@ -61,4 +61,9 @@ FloatRect screenAvailableRect(Widget* widget)
     return PlatformSupport::screenAvailableRect(widget);
 }
 
+double screenRefreshRate(Widget* widget)
+{
+    return PlatformSupport::screenRefreshRate(widget);
+}
+
 } // namespace WebCore
index 413edfcca556015e0db66e1b830109bb63efeb14..0baa9b51a324c1fc490a3481e8af058ba59b160b 100644 (file)
@@ -234,6 +234,7 @@ public:
     static bool screenIsMonochrome(Widget*);
     static IntRect screenRect(Widget*);
     static IntRect screenAvailableRect(Widget*);
+    static double screenRefreshRate(Widget*);
 
     // SharedTimers -------------------------------------------------------
     static void setSharedTimerFiredFunction(void (*func)());
index d814149c54b053ecea6fcae05624448dd311d911..c1e0670eb133696f46a018adfe17a38871393c6e 100644 (file)
@@ -73,13 +73,15 @@ struct CCSettings {
             , compositeOffscreen(false)
             , enableCompositorThread(false)
             , showFPSCounter(false)
-            , showPlatformLayerTree(false) { }
+            , showPlatformLayerTree(false)
+            , refreshRate(0) { }
 
     bool acceleratePainting;
     bool compositeOffscreen;
     bool enableCompositorThread;
     bool showFPSCounter;
     bool showPlatformLayerTree;
+    double refreshRate;
 };
 
 // Provides information on an Impl's rendering capabilities back to the CCLayerTreeHost
index 747c8df12ce2a918689a16ad772efeeaefe770ec..a86cde5efd4e8e93dd550d41ee0457ac85313779 100644 (file)
@@ -502,7 +502,8 @@ void CCThreadProxy::initializeImplOnImplThread(CCCompletionEvent* completion)
     TRACE_EVENT("CCThreadProxy::initializeImplOnImplThread", this, 0);
     ASSERT(isImplThread());
     m_layerTreeHostImpl = m_layerTreeHost->createLayerTreeHostImpl(this);
-    const double displayRefreshIntervalMs = 1000.0 / 60.0;
+    ASSERT(m_layerTreeHostImpl->settings().refreshRate > 0);
+    const double displayRefreshIntervalMs = 1000.0 / m_layerTreeHostImpl->settings().refreshRate;
     OwnPtr<CCFrameRateController> frameRateController = adoptPtr(new CCFrameRateController(CCDelayBasedTimeSource::create(displayRefreshIntervalMs, CCProxy::implThread())));
     m_schedulerOnImplThread = CCScheduler::create(this, frameRateController.release());
     m_schedulerOnImplThread->setVisible(m_layerTreeHostImpl->visible());
index aaadcbc36a6975b903c50db7b4f876607d56421c..013344f3c29e515957a030bb33dad60191ba1a6d 100644 (file)
@@ -1,3 +1,17 @@
+2011-11-16  Iain Merrick  <husky@google.com>
+
+        [chromium] Pass screen refresh rate into compositor.
+        https://bugs.webkit.org/show_bug.cgi?id=71040
+
+        Reviewed by Tony Gentilcore.
+
+        * public/WebScreenInfo.h:
+        (WebKit::WebScreenInfo::WebScreenInfo):
+        * src/PlatformSupport.cpp:
+        (WebCore::PlatformSupport::screenRefreshRate):
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::setIsAcceleratedCompositingActive):
+
 2011-11-15  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r100340.
index d3d268aa9f1209f96cc0a46c3b3ac1b6518a2548..c22e2a345923475f73ead135a72979907ea6ccd9 100644 (file)
@@ -63,10 +63,14 @@ struct WebScreenInfo {
     //   some of the rectangle's coordinates may be negative values".
     WebRect availableRect;
 
+    // Measured in frames per second. 0 if the rate is unknown or not applicable.
+    double refreshRate;
+
     WebScreenInfo()
         : depth(0)
         , depthPerComponent(0)
-        , isMonochrome(false) { }
+        , isMonochrome(false)
+        , refreshRate(0) { }
 };
 
 } // namespace WebKit
index f1f6686101f6269114d8ddbd9772968e5f1f3478..3680d65982d0f2db96a170997db34764b11f0df2 100644 (file)
@@ -1056,6 +1056,14 @@ IntRect PlatformSupport::screenAvailableRect(Widget* widget)
     return client->screenInfo().availableRect;
 }
 
+double PlatformSupport::screenRefreshRate(Widget* widget)
+{
+    WebWidgetClient* client = toWebWidgetClient(widget);
+    if (!client)
+        return 0;
+    return client->screenInfo().refreshRate;
+}
+
 bool PlatformSupport::popupsAllowed(NPP npp)
 {
     // FIXME: Give the embedder a way to control this.
index c304d2a75af2197aa0faf03c18cfd00d3e69875f..6f6be47ede76646736cfb0a2b0ed3a491201534e 100644 (file)
@@ -86,6 +86,7 @@
 #include "PlatformContextSkia.h"
 #include "PlatformKeyboardEvent.h"
 #include "PlatformMouseEvent.h"
+#include "PlatformScreen.h"
 #include "PlatformThemeChromiumLinux.h"
 #include "PlatformWheelEvent.h"
 #include "PopupContainer.h"
@@ -2728,12 +2729,18 @@ void WebViewImpl::setIsAcceleratedCompositingActive(bool active)
     } else {
         TRACE_EVENT("WebViewImpl::setIsAcceleratedCompositingActive(true)", this, 0);
 
+        static const double defaultRefreshRate = 60.0;
+
         WebCore::CCSettings ccSettings;
         ccSettings.acceleratePainting = page()->settings()->acceleratedDrawingEnabled();
         ccSettings.compositeOffscreen = settings()->compositeToTextureEnabled();
         ccSettings.enableCompositorThread = settings()->useThreadedCompositor();
         ccSettings.showFPSCounter = settings()->showFPSCounter();
         ccSettings.showPlatformLayerTree = settings()->showPlatformLayerTree();
+        ccSettings.refreshRate = screenRefreshRate(page()->mainFrame()->view());
+        ASSERT(ccSettings.refreshRate >= 0);
+        if (!ccSettings.refreshRate)
+            ccSettings.refreshRate = defaultRefreshRate;
 
         m_nonCompositedContentHost = NonCompositedContentHost::create(WebViewImplContentPainter::create(this));
         m_layerTreeHost = CCLayerTreeHost::create(this, ccSettings);