Title: [110227] trunk/Source
Revision
110227
Author
[email protected]
Date
2012-03-08 15:52:56 -0800 (Thu, 08 Mar 2012)

Log Message

Use an explicit attribute to signal that a context prefers to use a discrete GPU
https://bugs.webkit.org/show_bug.cgi?id=80639

Reviewed by Stephen White.

Source/Platform:

Adds preferDiscreteGPU attribute to WebGraphicsContext3D::Attributes. Also remove the forUseOnAnotherThread
attribute, this has been dead code for a while now.

* chromium/public/WebGraphicsContext3D.h:
(WebKit::WebGraphicsContext3D::Attributes::Attributes):
(Attributes):

Source/WebCore:

On platforms that support both integrated and discrete GPUs and can dynamically switch between the two, we
sometimes have a specific preference for a given context. Specifically, contexts used for WebGL and canvas 2d
acceleration should use the discrete GPU if available, but compositor contexts can run fine on an integrated
GPU. Instead of attempting to infer the intent from examining other context attributes, this adds an explicit
attribute to control this behavior.

* html/canvas/WebGLRenderingContext.cpp:
(WebCore):
(WebCore::WebGLRenderingContext::create):
* platform/graphics/GraphicsContext3D.h:
(WebCore::GraphicsContext3D::Attributes::Attributes):
(Attributes):
* platform/graphics/gpu/SharedGraphicsContext3D.cpp:
(WebCore::SharedGraphicsContext3D::get):

Source/WebKit/chromium:

* src/GraphicsContext3DChromium.cpp:
(WebCore::GraphicsContext3DPrivate::getContextAttributes):
(WebCore::GraphicsContext3D::create):
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::createCompositorGraphicsContext3D):

Modified Paths

Diff

Modified: trunk/Source/Platform/ChangeLog (110226 => 110227)


--- trunk/Source/Platform/ChangeLog	2012-03-08 23:47:36 UTC (rev 110226)
+++ trunk/Source/Platform/ChangeLog	2012-03-08 23:52:56 UTC (rev 110227)
@@ -1,3 +1,17 @@
+2012-03-08  James Robinson  <[email protected]>
+
+        Use an explicit attribute to signal that a context prefers to use a discrete GPU
+        https://bugs.webkit.org/show_bug.cgi?id=80639
+
+        Reviewed by Stephen White.
+
+        Adds preferDiscreteGPU attribute to WebGraphicsContext3D::Attributes. Also remove the forUseOnAnotherThread
+        attribute, this has been dead code for a while now.
+
+        * chromium/public/WebGraphicsContext3D.h:
+        (WebKit::WebGraphicsContext3D::Attributes::Attributes):
+        (Attributes):
+
 2012-02-24  James Robinson  <[email protected]>
 
         [chromium] WebKit::setColorNames is a client API

Modified: trunk/Source/Platform/chromium/public/WebGraphicsContext3D.h (110226 => 110227)


--- trunk/Source/Platform/chromium/public/WebGraphicsContext3D.h	2012-03-08 23:47:36 UTC (rev 110226)
+++ trunk/Source/Platform/chromium/public/WebGraphicsContext3D.h	2012-03-08 23:52:56 UTC (rev 110227)
@@ -94,7 +94,7 @@
             , canRecoverFromContextLoss(true)
             , noExtensions(false)
             , shareResources(true)
-            , forUseOnAnotherThread(false)
+            , preferDiscreteGPU(false)
         {
         }
 
@@ -106,7 +106,7 @@
         bool canRecoverFromContextLoss;
         bool noExtensions;
         bool shareResources;
-        bool forUseOnAnotherThread;
+        bool preferDiscreteGPU;
     };
 
     class WebGraphicsContextLostCallback {

Modified: trunk/Source/WebCore/ChangeLog (110226 => 110227)


--- trunk/Source/WebCore/ChangeLog	2012-03-08 23:47:36 UTC (rev 110226)
+++ trunk/Source/WebCore/ChangeLog	2012-03-08 23:52:56 UTC (rev 110227)
@@ -1,3 +1,25 @@
+2012-03-08  James Robinson  <[email protected]>
+
+        Use an explicit attribute to signal that a context prefers to use a discrete GPU
+        https://bugs.webkit.org/show_bug.cgi?id=80639
+
+        Reviewed by Stephen White.
+
+        On platforms that support both integrated and discrete GPUs and can dynamically switch between the two, we
+        sometimes have a specific preference for a given context. Specifically, contexts used for WebGL and canvas 2d
+        acceleration should use the discrete GPU if available, but compositor contexts can run fine on an integrated
+        GPU. Instead of attempting to infer the intent from examining other context attributes, this adds an explicit
+        attribute to control this behavior.
+
+        * html/canvas/WebGLRenderingContext.cpp:
+        (WebCore):
+        (WebCore::WebGLRenderingContext::create):
+        * platform/graphics/GraphicsContext3D.h:
+        (WebCore::GraphicsContext3D::Attributes::Attributes):
+        (Attributes):
+        * platform/graphics/gpu/SharedGraphicsContext3D.cpp:
+        (WebCore::SharedGraphicsContext3D::get):
+
 2012-03-08  Andy Estes  <[email protected]>
 
         NULL renderer possible in WebCore::HTMLInputElement::setCanReceiveDroppedFiles()

Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp (110226 => 110227)


--- trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp	2012-03-08 23:47:36 UTC (rev 110226)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp	2012-03-08 23:52:56 UTC (rev 110227)
@@ -403,6 +403,7 @@
 #else
     attributes.shareResources = false;
 #endif
+    attributes.preferDiscreteGPU = true;
 
 
     RefPtr<GraphicsContext3D> context(GraphicsContext3D::create(attributes, hostWindow));

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h (110226 => 110227)


--- trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h	2012-03-08 23:47:36 UTC (rev 110226)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h	2012-03-08 23:52:56 UTC (rev 110227)
@@ -443,6 +443,7 @@
             , preserveDrawingBuffer(false)
             , noExtensions(false)
             , shareResources(true)
+            , preferDiscreteGPU(false)
         {
         }
 
@@ -455,6 +456,7 @@
         bool preserveDrawingBuffer;
         bool noExtensions;
         bool shareResources;
+        bool preferDiscreteGPU;
     };
 
     enum RenderStyle {

Modified: trunk/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp (110226 => 110227)


--- trunk/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp	2012-03-08 23:47:36 UTC (rev 110226)
+++ trunk/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp	2012-03-08 23:52:56 UTC (rev 110227)
@@ -38,6 +38,7 @@
     attributes.antialias = false;
     attributes.canRecoverFromContextLoss = false; // Canvas contexts can not handle lost contexts.
     attributes.shareResources = true;
+    attributes.preferDiscreteGPU = true;
     static GraphicsContext3D* context = GraphicsContext3D::create(attributes, 0).leakRef();
     if (context && !context->makeContextCurrent())
         context = 0;

Modified: trunk/Source/WebKit/chromium/ChangeLog (110226 => 110227)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-03-08 23:47:36 UTC (rev 110226)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-03-08 23:52:56 UTC (rev 110227)
@@ -1,3 +1,16 @@
+2012-03-08  James Robinson  <[email protected]>
+
+        Use an explicit attribute to signal that a context prefers to use a discrete GPU
+        https://bugs.webkit.org/show_bug.cgi?id=80639
+
+        Reviewed by Stephen White.
+
+        * src/GraphicsContext3DChromium.cpp:
+        (WebCore::GraphicsContext3DPrivate::getContextAttributes):
+        (WebCore::GraphicsContext3D::create):
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::createCompositorGraphicsContext3D):
+
 2012-03-08  Scott Byer  <[email protected]>
 
         Have ScrollAnimatorNone use requestAnimationFrame

Modified: trunk/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp (110226 => 110227)


--- trunk/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp	2012-03-08 23:47:36 UTC (rev 110226)
+++ trunk/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp	2012-03-08 23:52:56 UTC (rev 110227)
@@ -573,6 +573,7 @@
     attributes.antialias = webAttributes.antialias;
     attributes.premultipliedAlpha = webAttributes.premultipliedAlpha;
     attributes.preserveDrawingBuffer = m_preserveDrawingBuffer;
+    attributes.preferDiscreteGPU = webAttributes.preferDiscreteGPU;
     return attributes;
 }
 
@@ -1017,6 +1018,7 @@
     webAttributes.canRecoverFromContextLoss = attrs.canRecoverFromContextLoss;
     webAttributes.noExtensions = attrs.noExtensions;
     webAttributes.shareResources = attrs.shareResources;
+    webAttributes.preferDiscreteGPU = attrs.preferDiscreteGPU;
 
     OwnPtr<WebKit::WebGraphicsContext3D> webContext = adoptPtr(WebKit::webKitPlatformSupport()->createOffscreenGraphicsContext3D(webAttributes));
     if (!webContext)

Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.cpp (110226 => 110227)


--- trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2012-03-08 23:47:36 UTC (rev 110226)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2012-03-08 23:52:56 UTC (rev 110227)
@@ -171,27 +171,6 @@
 using namespace WebCore;
 using namespace std;
 
-namespace {
-
-WebKit::WebGraphicsContext3D::Attributes getCompositorContextAttributes(bool threaded)
-{
-    // Explicitly disable antialiasing for the compositor. As of the time of
-    // this writing, the only platform that supported antialiasing for the
-    // compositor was Mac OS X, because the on-screen OpenGL context creation
-    // code paths on Windows and Linux didn't yet have multisampling support.
-    // Mac OS X essentially always behaves as though it's rendering offscreen.
-    // Multisampling has a heavy cost especially on devices with relatively low
-    // fill rate like most notebooks, and the Mac implementation would need to
-    // be optimized to resolve directly into the IOSurface shared between the
-    // GPU and browser processes. For these reasons and to avoid platform
-    // disparities we explicitly disable antialiasing.
-    WebKit::WebGraphicsContext3D::Attributes attributes;
-    attributes.antialias = false;
-    attributes.shareResources = true;
-    attributes.forUseOnAnotherThread = threaded;
-    return attributes;
-}
-
 // The following constants control parameters for automated scaling of webpages
 // (such as due to a double tap gesture or find in page etc.). These are
 // experimentally determined.
@@ -200,8 +179,6 @@
 static const float doubleTapZoomContentDefaultMargin = 5;
 static const float doubleTapZoomContentMinimumMargin = 2;
 
-} // anonymous namespace
-
 namespace WebKit {
 
 // Change the text zoom level by kTextSizeMultiplierRatio each time the user
@@ -3221,7 +3198,20 @@
 
 PassOwnPtr<WebKit::WebGraphicsContext3D> WebViewImpl::createCompositorGraphicsContext3D()
 {
-    WebKit::WebGraphicsContext3D::Attributes attributes = getCompositorContextAttributes(CCProxy::hasImplThread());
+    // Explicitly disable antialiasing for the compositor. As of the time of
+    // this writing, the only platform that supported antialiasing for the
+    // compositor was Mac OS X, because the on-screen OpenGL context creation
+    // code paths on Windows and Linux didn't yet have multisampling support.
+    // Mac OS X essentially always behaves as though it's rendering offscreen.
+    // Multisampling has a heavy cost especially on devices with relatively low
+    // fill rate like most notebooks, and the Mac implementation would need to
+    // be optimized to resolve directly into the IOSurface shared between the
+    // GPU and browser processes. For these reasons and to avoid platform
+    // disparities we explicitly disable antialiasing.
+    WebKit::WebGraphicsContext3D::Attributes attributes;
+    attributes.antialias = false;
+    attributes.shareResources = true;
+
     OwnPtr<WebGraphicsContext3D> webContext = adoptPtr(client()->createGraphicsContext3D(attributes, true /* renderDirectlyToHostWindow */));
     if (!webContext)
         return nullptr;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to