<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[210273] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/210273">210273</a></dd>
<dt>Author</dt> <dd>timothy_horton@apple.com</dd>
<dt>Date</dt> <dd>2017-01-04 00:55:38 -0800 (Wed, 04 Jan 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Provide a setting for clients to always prefer low-power WebGL
https://bugs.webkit.org/show_bug.cgi?id=166675
&lt;rdar://problem/29834093&gt;

Reviewed by Dan Bernstein.

No new tests; as noted in <a href="http://trac.webkit.org/projects/webkit/changeset/204664">r204664</a>, we don't know how to reliably test
automatic graphics switching. One could use the manual test introduced
in that commit; after this commit, with the setting switched on, on a
dual-GPU machine that is actively using integrated graphics, that test
should return the same result for both contexts.

* page/Settings.in:
Add a setting to prefer low-power WebGL.

* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::create):
If said setting is enabled, set preferLowPowerToHighPerformance.

* WebView/WebPreferenceKeysPrivate.h:
* WebView/WebPreferences.mm:
(+[WebPreferences initialize]):
(-[WebPreferences preferLowPowerWebGLRendering]):
(-[WebPreferences setPreferLowPowerWebGLRendering:]):
* WebView/WebPreferencesPrivate.h:
* WebView/WebView.mm:
(-[WebView _preferencesChanged:]):
Expose a new private preferLowPowerWebGLRendering WebKit1 preference.

* MiniBrowser/mac/Info.plist:
Have MiniBrowser claim to be a modern app that supports
automatic graphics switching. WebKit needs to support automatic
graphics switching, so our test app might as well. Without this
Info.plist parameter, this change has no effect, and bringing up
a WebGL context still brings up the discrete GPU (also true of the
existing web-exposed preferLowPowerToHighPerformance API).</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehtmlcanvasWebGLRenderingContextBasecpp">trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp</a></li>
<li><a href="#trunkSourceWebCorepageSettingsin">trunk/Source/WebCore/page/Settings.in</a></li>
<li><a href="#trunkSourceWebKitmacChangeLog">trunk/Source/WebKit/mac/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebPreferenceKeysPrivateh">trunk/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebPreferencesmm">trunk/Source/WebKit/mac/WebView/WebPreferences.mm</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebPreferencesPrivateh">trunk/Source/WebKit/mac/WebView/WebPreferencesPrivate.h</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebViewmm">trunk/Source/WebKit/mac/WebView/WebView.mm</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsMiniBrowsermacInfoplist">trunk/Tools/MiniBrowser/mac/Info.plist</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (210272 => 210273)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-01-04 08:29:52 UTC (rev 210272)
+++ trunk/Source/WebCore/ChangeLog        2017-01-04 08:55:38 UTC (rev 210273)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2017-01-04  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        Provide a setting for clients to always prefer low-power WebGL
+        https://bugs.webkit.org/show_bug.cgi?id=166675
+        &lt;rdar://problem/29834093&gt;
+
+        Reviewed by Dan Bernstein.
+
+        No new tests; as noted in r204664, we don't know how to reliably test
+        automatic graphics switching. One could use the manual test introduced
+        in that commit; after this commit, with the setting switched on, on a
+        dual-GPU machine that is actively using integrated graphics, that test
+        should return the same result for both contexts.
+
+        * page/Settings.in:
+        Add a setting to prefer low-power WebGL.
+
+        * html/canvas/WebGLRenderingContextBase.cpp:
+        (WebCore::WebGLRenderingContextBase::create):
+        If said setting is enabled, set preferLowPowerToHighPerformance.
+
</ins><span class="cx"> 2017-01-03  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         label element with tabindex &gt;= 0 is not focusable
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlcanvasWebGLRenderingContextBasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp (210272 => 210273)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp        2017-01-04 08:29:52 UTC (rev 210272)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp        2017-01-04 08:55:38 UTC (rev 210273)
</span><span class="lines">@@ -399,6 +399,9 @@
</span><span class="cx">     if (frame-&gt;settings().forceSoftwareWebGLRendering())
</span><span class="cx">         attributes.forceSoftwareRenderer = true;
</span><span class="cx"> 
</span><ins>+    if (!attributes.preferLowPowerToHighPerformance &amp;&amp; frame-&gt;settings().preferLowPowerWebGLRendering())
+        attributes.preferLowPowerToHighPerformance = true;
+
</ins><span class="cx">     if (page)
</span><span class="cx">         attributes.devicePixelRatio = page-&gt;deviceScaleFactor();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorepageSettingsin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Settings.in (210272 => 210273)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Settings.in        2017-01-04 08:29:52 UTC (rev 210272)
+++ trunk/Source/WebCore/page/Settings.in        2017-01-04 08:55:38 UTC (rev 210273)
</span><span class="lines">@@ -108,6 +108,7 @@
</span><span class="cx"> webGLErrorsToConsoleEnabled initial=true
</span><span class="cx"> openGLMultisamplingEnabled initial=true
</span><span class="cx"> forceSoftwareWebGLRendering initial=false
</span><ins>+preferLowPowerWebGLRendering initial=false
</ins><span class="cx"> accelerated2dCanvasEnabled initial=false
</span><span class="cx"> antialiased2dCanvasEnabled initial=true
</span><span class="cx"> loadDeferringEnabled initial=true
</span></span></pre></div>
<a id="trunkSourceWebKitmacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/ChangeLog (210272 => 210273)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/ChangeLog        2017-01-04 08:29:52 UTC (rev 210272)
+++ trunk/Source/WebKit/mac/ChangeLog        2017-01-04 08:55:38 UTC (rev 210273)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2017-01-04  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        Provide a setting for clients to always prefer low-power WebGL
+        https://bugs.webkit.org/show_bug.cgi?id=166675
+        &lt;rdar://problem/29834093&gt;
+
+        Reviewed by Dan Bernstein.
+
+        * WebView/WebPreferenceKeysPrivate.h:
+        * WebView/WebPreferences.mm:
+        (+[WebPreferences initialize]):
+        (-[WebPreferences preferLowPowerWebGLRendering]):
+        (-[WebPreferences setPreferLowPowerWebGLRendering:]):
+        * WebView/WebPreferencesPrivate.h:
+        * WebView/WebView.mm:
+        (-[WebView _preferencesChanged:]):
+        Expose a new private preferLowPowerWebGLRendering WebKit1 preference.
+
</ins><span class="cx"> 2017-01-03  Tim Horton  &lt;timothy_horton@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         NSSpellChecker's recordResponse isn't called for unseen automatic corrections
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebPreferenceKeysPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h (210272 => 210273)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h        2017-01-04 08:29:52 UTC (rev 210272)
+++ trunk/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h        2017-01-04 08:55:38 UTC (rev 210273)
</span><span class="lines">@@ -111,6 +111,7 @@
</span><span class="cx"> #define WebKitWebGLEnabledPreferenceKey @&quot;WebKitWebGLEnabled&quot;
</span><span class="cx"> #define WebKitWebGL2EnabledPreferenceKey @&quot;WebKitWebGL2Enabled&quot;
</span><span class="cx"> #define WebKitForceSoftwareWebGLRenderingPreferenceKey @&quot;WebKitForceSoftwareWebGLRendering&quot;
</span><ins>+#define WebKitPreferLowPowerWebGLRenderingPreferenceKey @&quot;WebKitPreferLowPowerWebGLRendering&quot;
</ins><span class="cx"> #define WebKitAccelerated2dCanvasEnabledPreferenceKey @&quot;WebKitAccelerated2dCanvasEnabled&quot;
</span><span class="cx"> #define WebKitFrameFlatteningEnabledPreferenceKey @&quot;WebKitFrameFlatteningEnabled&quot;
</span><span class="cx"> #define WebKitSpatialNavigationEnabledPreferenceKey @&quot;WebKitSpatialNavigationEnabled&quot;
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebPreferencesmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebPreferences.mm (210272 => 210273)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebPreferences.mm        2017-01-04 08:29:52 UTC (rev 210272)
+++ trunk/Source/WebKit/mac/WebView/WebPreferences.mm        2017-01-04 08:55:38 UTC (rev 210273)
</span><span class="lines">@@ -504,6 +504,7 @@
</span><span class="cx">         [NSNumber numberWithBool:NO],   WebKitShowRepaintCounterPreferenceKey,
</span><span class="cx">         [NSNumber numberWithBool:YES],  WebKitWebGLEnabledPreferenceKey,
</span><span class="cx">         [NSNumber numberWithBool:NO],  WebKitForceSoftwareWebGLRenderingPreferenceKey,
</span><ins>+        [NSNumber numberWithBool:NO],   WebKitPreferLowPowerWebGLRenderingPreferenceKey,
</ins><span class="cx">         [NSNumber numberWithBool:NO],   WebKitAccelerated2dCanvasEnabledPreferenceKey,
</span><span class="cx">         [NSNumber numberWithBool:NO],  WebKitSubpixelCSSOMElementMetricsEnabledPreferenceKey,
</span><span class="cx">         [NSNumber numberWithBool:NO],  WebKitResourceLoadStatisticsEnabledPreferenceKey,
</span><span class="lines">@@ -2028,6 +2029,16 @@
</span><span class="cx">     [self _setBoolValue:forced forKey:WebKitForceSoftwareWebGLRenderingPreferenceKey];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (BOOL)preferLowPowerWebGLRendering
+{
+    return [self _boolValueForKey:WebKitPreferLowPowerWebGLRenderingPreferenceKey];
+}
+
+- (void)setPreferLowPowerWebGLRendering:(BOOL)preferLowPower
+{
+    [self _setBoolValue:preferLowPower forKey:WebKitPreferLowPowerWebGLRenderingPreferenceKey];
+}
+
</ins><span class="cx"> - (BOOL)accelerated2dCanvasEnabled
</span><span class="cx"> {
</span><span class="cx">     return [self _boolValueForKey:WebKitAccelerated2dCanvasEnabledPreferenceKey];
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebPreferencesPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebPreferencesPrivate.h (210272 => 210273)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebPreferencesPrivate.h        2017-01-04 08:29:52 UTC (rev 210272)
+++ trunk/Source/WebKit/mac/WebView/WebPreferencesPrivate.h        2017-01-04 08:55:38 UTC (rev 210273)
</span><span class="lines">@@ -248,6 +248,9 @@
</span><span class="cx"> - (BOOL)forceSoftwareWebGLRendering;
</span><span class="cx"> - (void)setForceSoftwareWebGLRendering:(BOOL)forced;
</span><span class="cx"> 
</span><ins>+- (BOOL)preferLowPowerWebGLRendering;
+- (void)setPreferLowPowerWebGLRendering:(BOOL)preferLowPower;
+
</ins><span class="cx"> - (BOOL)accelerated2dCanvasEnabled;
</span><span class="cx"> - (void)setAccelerated2dCanvasEnabled:(BOOL)enabled;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (210272 => 210273)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebView.mm        2017-01-04 08:29:52 UTC (rev 210272)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm        2017-01-04 08:55:38 UTC (rev 210273)
</span><span class="lines">@@ -2661,6 +2661,7 @@
</span><span class="cx">     settings.setSubpixelCSSOMElementMetricsEnabled([preferences subpixelCSSOMElementMetricsEnabled]);
</span><span class="cx"> 
</span><span class="cx">     settings.setForceSoftwareWebGLRendering([preferences forceSoftwareWebGLRendering]);
</span><ins>+    settings.setPreferLowPowerWebGLRendering([preferences preferLowPowerWebGLRendering]);
</ins><span class="cx">     settings.setAccelerated2dCanvasEnabled([preferences accelerated2dCanvasEnabled]);
</span><span class="cx">     settings.setLoadDeferringEnabled(shouldEnableLoadDeferring());
</span><span class="cx">     settings.setWindowFocusRestricted(shouldRestrictWindowFocus());
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (210272 => 210273)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2017-01-04 08:29:52 UTC (rev 210272)
+++ trunk/Tools/ChangeLog        2017-01-04 08:55:38 UTC (rev 210273)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2017-01-04  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        Provide a setting for clients to always prefer low-power WebGL
+        https://bugs.webkit.org/show_bug.cgi?id=166675
+        &lt;rdar://problem/29834093&gt;
+
+        Reviewed by Dan Bernstein.
+
+        * MiniBrowser/mac/Info.plist:
+        Have MiniBrowser claim to be a modern app that supports
+        automatic graphics switching. WebKit needs to support automatic
+        graphics switching, so our test app might as well. Without this
+        Info.plist parameter, this change has no effect, and bringing up
+        a WebGL context still brings up the discrete GPU (also true of the
+        existing web-exposed preferLowPowerToHighPerformance API).
+
</ins><span class="cx"> 2017-01-03  Yusuke Suzuki  &lt;utatane.tea@gmail.com&gt;
</span><span class="cx"> 
</span><span class="cx">         WorkQueueGeneric's platformInvalidate() can deadlock when called on the RunLoop's thread
</span></span></pre></div>
<a id="trunkToolsMiniBrowsermacInfoplist"></a>
<div class="modfile"><h4>Modified: trunk/Tools/MiniBrowser/mac/Info.plist (210272 => 210273)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/MiniBrowser/mac/Info.plist        2017-01-04 08:29:52 UTC (rev 210272)
+++ trunk/Tools/MiniBrowser/mac/Info.plist        2017-01-04 08:55:38 UTC (rev 210273)
</span><span class="lines">@@ -33,5 +33,7 @@
</span><span class="cx">                 &lt;key&gt;NSAllowsArbitraryLoads&lt;/key&gt;
</span><span class="cx">                 &lt;true/&gt;
</span><span class="cx">         &lt;/dict&gt;
</span><ins>+        &lt;key&gt;NSSupportsAutomaticGraphicsSwitching&lt;/key&gt;
+        &lt;true/&gt;
</ins><span class="cx"> &lt;/dict&gt;
</span><span class="cx"> &lt;/plist&gt;
</span></span></pre>
</div>
</div>

</body>
</html>