Title: [212316] trunk
Revision
212316
Author
[email protected]
Date
2017-02-14 12:12:27 -0800 (Tue, 14 Feb 2017)

Log Message

Rename preferLowPowerToHighPerformance to powerPreference
https://bugs.webkit.org/show_bug.cgi?id=168269
<rdar://problem/30504444>

Reviewed by Chris Dumez.

Source/WebCore:

Based on the discussion in https://github.com/KhronosGroup/WebGL/pull/2283.

Change WebGLContextAttributes's preferLowPowerToHighPerformance boolean
into a powerPreference enum taking three values. The implementation
of the enum is in GraphicsContext3DAttributes.

While the name and values have changed, there should be no change in
behaviour caused by this patch.

* html/canvas/WebGLContextAttributes.h: Use GraphicsContext3DAttributes
enum GraphicsContext3DPowerPreference.
* html/canvas/WebGLContextAttributes.idl: Rename and add the WebIDL enum.
* html/canvas/WebGLRenderingContextBase.cpp: Use the new values.
(WebCore::WebGLRenderingContextBase::create):
(WebCore::WebGLRenderingContextBase::registerWithWebGLStateTracker):
* platform/WebGLStateTracker.cpp:
* platform/WebGLStateTracker.h: Update the state tracker to use the new
values.
* platform/graphics/GraphicsContext3DAttributes.h:
* platform/graphics/mac/GraphicsContext3DMac.mm:
(WebCore::setPixelFormat): Accept GraphicsContext3DPowerPreference as a parameter.
(WebCore::GraphicsContext3D::GraphicsContext3D):

LayoutTests:

Handle the rename in the test case. Since Settings.in has
preferLowPowerWebGLRendering initial=true
we will override the incoming request and set the value to
"low-power". This behaviour will change in a subsequent bug.

* fast/canvas/webgl/context-creation-attributes-expected.txt:
* fast/canvas/webgl/context-creation-attributes.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (212315 => 212316)


--- trunk/LayoutTests/ChangeLog	2017-02-14 19:40:13 UTC (rev 212315)
+++ trunk/LayoutTests/ChangeLog	2017-02-14 20:12:27 UTC (rev 212316)
@@ -1,3 +1,19 @@
+2017-02-13  Dean Jackson  <[email protected]>
+
+        Rename preferLowPowerToHighPerformance to powerPreference
+        https://bugs.webkit.org/show_bug.cgi?id=168269
+        <rdar://problem/30504444>
+
+        Reviewed by Chris Dumez.
+
+        Handle the rename in the test case. Since Settings.in has
+        preferLowPowerWebGLRendering initial=true
+        we will override the incoming request and set the value to
+        "low-power". This behaviour will change in a subsequent bug.
+
+        * fast/canvas/webgl/context-creation-attributes-expected.txt:
+        * fast/canvas/webgl/context-creation-attributes.html:
+
 2017-02-14  Jeremy Jones  <[email protected]>
 
         When playing inline after fullscreen, set a flag instead of adding attribute plays inline, and use in requiresFullscreenForVideoPlayback.

Modified: trunk/LayoutTests/fast/canvas/webgl/context-creation-attributes-expected.txt (212315 => 212316)


--- trunk/LayoutTests/fast/canvas/webgl/context-creation-attributes-expected.txt	2017-02-14 19:40:13 UTC (rev 212315)
+++ trunk/LayoutTests/fast/canvas/webgl/context-creation-attributes-expected.txt	2017-02-14 20:12:27 UTC (rev 212316)
@@ -1,6 +1,6 @@
 Note that some of the values tested here might not be supported, and thus should return the default values.
 
-{"alpha":true,"antialias":true,"depth":true,"failIfMajorPerformanceCaveat":false,"preferLowPowerToHighPerformance":true,"premultipliedAlpha":true,"preserveDrawingBuffer":false,"stencil":false}
-{"alpha":true,"antialias":true,"depth":true,"failIfMajorPerformanceCaveat":false,"preferLowPowerToHighPerformance":true,"premultipliedAlpha":true,"preserveDrawingBuffer":false,"stencil":true}
-{"alpha":true,"antialias":true,"depth":true,"failIfMajorPerformanceCaveat":false,"preferLowPowerToHighPerformance":true,"premultipliedAlpha":true,"preserveDrawingBuffer":false,"stencil":false}
-{"alpha":true,"antialias":true,"depth":true,"failIfMajorPerformanceCaveat":true,"preferLowPowerToHighPerformance":true,"premultipliedAlpha":true,"preserveDrawingBuffer":false,"stencil":false}
+{"alpha":true,"antialias":true,"depth":true,"failIfMajorPerformanceCaveat":false,"powerPreference":"low-power","premultipliedAlpha":true,"preserveDrawingBuffer":false,"stencil":false}
+{"alpha":true,"antialias":true,"depth":true,"failIfMajorPerformanceCaveat":false,"powerPreference":"low-power","premultipliedAlpha":true,"preserveDrawingBuffer":false,"stencil":true}
+{"alpha":true,"antialias":true,"depth":true,"failIfMajorPerformanceCaveat":false,"powerPreference":"low-power","premultipliedAlpha":true,"preserveDrawingBuffer":false,"stencil":false}
+{"alpha":true,"antialias":true,"depth":true,"failIfMajorPerformanceCaveat":true,"powerPreference":"low-power","premultipliedAlpha":true,"preserveDrawingBuffer":false,"stencil":false}

Modified: trunk/LayoutTests/fast/canvas/webgl/context-creation-attributes.html (212315 => 212316)


--- trunk/LayoutTests/fast/canvas/webgl/context-creation-attributes.html	2017-02-14 19:40:13 UTC (rev 212315)
+++ trunk/LayoutTests/fast/canvas/webgl/context-creation-attributes.html	2017-02-14 20:12:27 UTC (rev 212316)
@@ -27,7 +27,7 @@
 function run() {
     testContextCreation({});
     testContextCreation({stencil: true});
-    testContextCreation({preferLowPowerToHighPerformance: true});
+    testContextCreation({powerPreference: "default"});
     testContextCreation({failIfMajorPerformanceCaveat: true});
 }
 

Modified: trunk/Source/WebCore/ChangeLog (212315 => 212316)


--- trunk/Source/WebCore/ChangeLog	2017-02-14 19:40:13 UTC (rev 212315)
+++ trunk/Source/WebCore/ChangeLog	2017-02-14 20:12:27 UTC (rev 212316)
@@ -1,3 +1,34 @@
+2017-02-13  Dean Jackson  <[email protected]>
+
+        Rename preferLowPowerToHighPerformance to powerPreference
+        https://bugs.webkit.org/show_bug.cgi?id=168269
+        <rdar://problem/30504444>
+
+        Reviewed by Chris Dumez.
+
+        Based on the discussion in https://github.com/KhronosGroup/WebGL/pull/2283.
+
+        Change WebGLContextAttributes's preferLowPowerToHighPerformance boolean
+        into a powerPreference enum taking three values. The implementation
+        of the enum is in GraphicsContext3DAttributes.
+
+        While the name and values have changed, there should be no change in
+        behaviour caused by this patch.
+
+        * html/canvas/WebGLContextAttributes.h: Use GraphicsContext3DAttributes
+        enum GraphicsContext3DPowerPreference.
+        * html/canvas/WebGLContextAttributes.idl: Rename and add the WebIDL enum.
+        * html/canvas/WebGLRenderingContextBase.cpp: Use the new values.
+        (WebCore::WebGLRenderingContextBase::create):
+        (WebCore::WebGLRenderingContextBase::registerWithWebGLStateTracker):
+        * platform/WebGLStateTracker.cpp:
+        * platform/WebGLStateTracker.h: Update the state tracker to use the new
+        values.
+        * platform/graphics/GraphicsContext3DAttributes.h:
+        * platform/graphics/mac/GraphicsContext3DMac.mm:
+        (WebCore::setPixelFormat): Accept GraphicsContext3DPowerPreference as a parameter.
+        (WebCore::GraphicsContext3D::GraphicsContext3D):
+
 2017-02-14  Youenn Fablet  <[email protected]>
 
         [WebRTC] Implement description getters for libwebrtc RTCPeerConnection

Modified: trunk/Source/WebCore/html/canvas/WebGLContextAttributes.h (212315 => 212316)


--- trunk/Source/WebCore/html/canvas/WebGLContextAttributes.h	2017-02-14 19:40:13 UTC (rev 212315)
+++ trunk/Source/WebCore/html/canvas/WebGLContextAttributes.h	2017-02-14 20:12:27 UTC (rev 212316)
@@ -31,6 +31,7 @@
 
 namespace WebCore {
 
+using WebGLPowerPreference = GraphicsContext3DPowerPreference;
 using WebGLContextAttributes = GraphicsContext3DAttributes;
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/html/canvas/WebGLContextAttributes.idl (212315 => 212316)


--- trunk/Source/WebCore/html/canvas/WebGLContextAttributes.idl	2017-02-14 19:40:13 UTC (rev 212315)
+++ trunk/Source/WebCore/html/canvas/WebGLContextAttributes.idl	2017-02-14 20:12:27 UTC (rev 212316)
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2010, Google Inc. All rights reserved.
+ * Copyright (c) 2017, Apple, Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -26,6 +27,12 @@
 
 typedef boolean GLboolean;
 
+enum WebGLPowerPreference {
+    "default",
+    "low-power",
+    "high-performance"
+};
+
 [
     Conditional=WEBGL,
     JSGenerateToJSObject
@@ -36,6 +43,6 @@
     GLboolean antialias = true;
     GLboolean premultipliedAlpha = true;
     GLboolean preserveDrawingBuffer = false;
-    GLboolean preferLowPowerToHighPerformance = false;
+    WebGLPowerPreference powerPreference = "default";
     GLboolean failIfMajorPerformanceCaveat = false;
 };

Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp (212315 => 212316)


--- trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp	2017-02-14 19:40:13 UTC (rev 212315)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp	2017-02-14 20:12:27 UTC (rev 212316)
@@ -397,9 +397,9 @@
     if (frame->settings().forceSoftwareWebGLRendering())
         attributes.forceSoftwareRenderer = true;
 
-    attributes.initialPreferLowPowerToHighPerformance = attributes.preferLowPowerToHighPerformance;
+    attributes.initialPowerPreference = attributes.powerPreference;
     if (frame->settings().preferLowPowerWebGLRendering())
-        attributes.preferLowPowerToHighPerformance = true;
+        attributes.powerPreference = GraphicsContext3DPowerPreference::LowPower;
 
     if (page)
         attributes.devicePixelRatio = page->deviceScaleFactor();
@@ -514,7 +514,7 @@
     if (!tracker)
         return;
 
-    m_trackerToken = tracker->token(m_attributes.initialPreferLowPowerToHighPerformance);
+    m_trackerToken = tracker->token(m_attributes.initialPowerPreference);
 }
 
 void WebGLRenderingContextBase::initializeNewContext()

Modified: trunk/Source/WebCore/platform/WebGLStateTracker.cpp (212315 => 212316)


--- trunk/Source/WebCore/platform/WebGLStateTracker.cpp	2017-02-14 19:40:13 UTC (rev 212315)
+++ trunk/Source/WebCore/platform/WebGLStateTracker.cpp	2017-02-14 20:12:27 UTC (rev 212316)
@@ -34,10 +34,10 @@
 {
 }
 
-auto WebGLStateTracker::token(bool preferLowPower) -> Token
+auto WebGLStateTracker::token(GraphicsContext3DPowerPreference powerPreference) -> Token
 {
     // We only track high performance WebGL contexts at the moment.
-    if (preferLowPower)
+    if (powerPreference != GraphicsContext3DPowerPreference::HighPerformance)
         return { };
     return m_webGLContextCounter.count();
 }

Modified: trunk/Source/WebCore/platform/WebGLStateTracker.h (212315 => 212316)


--- trunk/Source/WebCore/platform/WebGLStateTracker.h	2017-02-14 19:40:13 UTC (rev 212315)
+++ trunk/Source/WebCore/platform/WebGLStateTracker.h	2017-02-14 20:12:27 UTC (rev 212316)
@@ -25,6 +25,7 @@
 
 #pragma once
 
+#include "GraphicsContext3DAttributes.h"
 #include <wtf/Function.h>
 #include <wtf/RefCounter.h>
 
@@ -39,7 +40,7 @@
     using WebGLContextCounter = RefCounter<WebGLContextCounterType>;
     using Token = WebGLContextCounter::Token;
 
-    Token token(bool preferLowPower);
+    Token token(GraphicsContext3DPowerPreference);
 
 private:
     void updateWebGLState();

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext3DAttributes.h (212315 => 212316)


--- trunk/Source/WebCore/platform/graphics/GraphicsContext3DAttributes.h	2017-02-14 19:40:13 UTC (rev 212315)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext3DAttributes.h	2017-02-14 20:12:27 UTC (rev 212316)
@@ -27,6 +27,12 @@
 
 namespace WebCore {
 
+enum class GraphicsContext3DPowerPreference {
+    Default,
+    LowPower,
+    HighPerformance
+};
+
 struct GraphicsContext3DAttributes {
     // WebGLContextAttributes
     bool alpha { true };
@@ -35,8 +41,9 @@
     bool antialias { true };
     bool premultipliedAlpha { true };
     bool preserveDrawingBuffer { false };
-    bool preferLowPowerToHighPerformance { false };
     bool failIfMajorPerformanceCaveat { false };
+    using PowerPreference = GraphicsContext3DPowerPreference;
+    PowerPreference powerPreference { PowerPreference::Default };
 
     // Additional attributes.
     bool forceSoftwareRenderer { false };
@@ -44,7 +51,7 @@
     bool useGLES3 { false };
     bool noExtensions { false };
     float devicePixelRatio { 1 };
-    bool initialPreferLowPowerToHighPerformance { false };
+    PowerPreference initialPowerPreference { PowerPreference::Default };
 };
 
 }

Modified: trunk/Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm (212315 => 212316)


--- trunk/Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm	2017-02-14 19:40:13 UTC (rev 212315)
+++ trunk/Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm	2017-02-14 20:12:27 UTC (rev 212316)
@@ -195,8 +195,10 @@
     return canMux;
 }
 
-static void setPixelFormat(Vector<CGLPixelFormatAttribute>& attribs, int colorBits, int depthBits, bool accelerated, bool supersample, bool closest, bool antialias, bool allowOffline, bool useGLES3)
+static void setPixelFormat(Vector<CGLPixelFormatAttribute>& attribs, int colorBits, int depthBits, bool accelerated, bool supersample, bool closest, bool antialias, GraphicsContext3DPowerPreference powerPreference, bool useGLES3)
 {
+    bool allowOffline = powerPreference != GraphicsContext3DPowerPreference::HighPerformance;
+
     attribs.clear();
     
     attribs.append(kCGLPFAColorSize);
@@ -317,19 +319,19 @@
 
     bool useMultisampling = m_attrs.antialias;
 
-    setPixelFormat(attribs, 32, 32, !attrs.forceSoftwareRenderer, true, false, useMultisampling, attrs.preferLowPowerToHighPerformance, attrs.useGLES3);
+    setPixelFormat(attribs, 32, 32, !attrs.forceSoftwareRenderer, true, false, useMultisampling, attrs.powerPreference, attrs.useGLES3);
     CGLChoosePixelFormat(attribs.data(), &pixelFormatObj, &numPixelFormats);
 
     if (!numPixelFormats) {
-        setPixelFormat(attribs, 32, 32, !attrs.forceSoftwareRenderer, false, false, useMultisampling, attrs.preferLowPowerToHighPerformance, attrs.useGLES3);
+        setPixelFormat(attribs, 32, 32, !attrs.forceSoftwareRenderer, false, false, useMultisampling, attrs.powerPreference, attrs.useGLES3);
         CGLChoosePixelFormat(attribs.data(), &pixelFormatObj, &numPixelFormats);
 
         if (!numPixelFormats) {
-            setPixelFormat(attribs, 32, 16, !attrs.forceSoftwareRenderer, false, false, useMultisampling, attrs.preferLowPowerToHighPerformance, attrs.useGLES3);
+            setPixelFormat(attribs, 32, 16, !attrs.forceSoftwareRenderer, false, false, useMultisampling, attrs.powerPreference, attrs.useGLES3);
             CGLChoosePixelFormat(attribs.data(), &pixelFormatObj, &numPixelFormats);
 
             if (!attrs.forceSoftwareRenderer && !numPixelFormats) {
-                setPixelFormat(attribs, 32, 16, false, false, true, false, false, attrs.useGLES3);
+                setPixelFormat(attribs, 32, 16, false, false, true, false, GraphicsContext3DPowerPreference::Default, attrs.useGLES3);
                 CGLChoosePixelFormat(attribs.data(), &pixelFormatObj, &numPixelFormats);
                 useMultisampling = false;
             }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to