Title: [161294] trunk/Source/WebCore
Revision
161294
Author
[email protected]
Date
2014-01-03 16:20:27 -0800 (Fri, 03 Jan 2014)

Log Message

[WebGL] CGLPixelFormat should specify SampleBuffer and Sample count when using MSAA
https://bugs.webkit.org/show_bug.cgi?id=126468

Reviewed by Dean Jackson.

Covered by webgl/1.0.2/resources/webgl_test_files/conformance/rendering/gl-scissor-test.html

* platform/graphics/mac/GraphicsContext3DMac.mm:
(WebCore::setPixelFormat): Add kCGLPFAMultisample, kCGLPFASampleBuffers (and count), and
kCGLPFASamples (and count) to our pixel format when 'antialias=true'.
(WebCore::GraphicsContext3D::GraphicsContext3D): Pass a new 'antialias' flag to the setPixelFormat
method so we can turn on MSAA features when needed.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (161293 => 161294)


--- trunk/Source/WebCore/ChangeLog	2014-01-04 00:15:12 UTC (rev 161293)
+++ trunk/Source/WebCore/ChangeLog	2014-01-04 00:20:27 UTC (rev 161294)
@@ -1,3 +1,18 @@
+2014-01-03  Brent Fulgham  <[email protected]>
+
+        [WebGL] CGLPixelFormat should specify SampleBuffer and Sample count when using MSAA
+        https://bugs.webkit.org/show_bug.cgi?id=126468
+
+        Reviewed by Dean Jackson.
+
+        Covered by webgl/1.0.2/resources/webgl_test_files/conformance/rendering/gl-scissor-test.html
+
+        * platform/graphics/mac/GraphicsContext3DMac.mm:
+        (WebCore::setPixelFormat): Add kCGLPFAMultisample, kCGLPFASampleBuffers (and count), and
+        kCGLPFASamples (and count) to our pixel format when 'antialias=true'.
+        (WebCore::GraphicsContext3D::GraphicsContext3D): Pass a new 'antialias' flag to the setPixelFormat
+        method so we can turn on MSAA features when needed.
+
 2014-01-03  Simon Fraser  <[email protected]>
 
         Give all PlatformCALayers a PlatformLayerID, not just remote ones

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


--- trunk/Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm	2014-01-04 00:15:12 UTC (rev 161293)
+++ trunk/Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm	2014-01-04 00:20:27 UTC (rev 161294)
@@ -61,7 +61,7 @@
     ~GraphicsContext3DPrivate() { }
 };
 
-static void setPixelFormat(Vector<CGLPixelFormatAttribute>& attribs, int colorBits, int depthBits, bool accelerated, bool supersample, bool closest)
+static void setPixelFormat(Vector<CGLPixelFormatAttribute>& attribs, int colorBits, int depthBits, bool accelerated, bool supersample, bool closest, bool antialias)
 {
     attribs.clear();
     
@@ -77,11 +77,19 @@
         attribs.append(static_cast<CGLPixelFormatAttribute>(kCGLRendererGenericFloatID));
     }
         
-    if (supersample)
+    if (supersample && !antialias)
         attribs.append(kCGLPFASupersample);
         
     if (closest)
         attribs.append(kCGLPFAClosestPolicy);
+
+    if (antialias) {
+        attribs.append(kCGLPFAMultisample);
+        attribs.append(kCGLPFASampleBuffers);
+        attribs.append(static_cast<CGLPixelFormatAttribute>(1));
+        attribs.append(kCGLPFASamples);
+        attribs.append(static_cast<CGLPixelFormatAttribute>(4));
+    }
         
     attribs.append(static_cast<CGLPixelFormatAttribute>(0));
 }
@@ -132,20 +140,23 @@
     //
     // If none of that works, we simply fail and set m_contextObj to 0.
 
-    setPixelFormat(attribs, 32, 32, !attrs.forceSoftwareRenderer, true, false);
+    bool useMultisampling = m_attrs.antialias;
+    
+    setPixelFormat(attribs, 32, 32, !attrs.forceSoftwareRenderer, true, false, useMultisampling);
     CGLChoosePixelFormat(attribs.data(), &pixelFormatObj, &numPixelFormats);
 
     if (numPixelFormats == 0) {
-        setPixelFormat(attribs, 32, 32, !attrs.forceSoftwareRenderer, false, false);
+        setPixelFormat(attribs, 32, 32, !attrs.forceSoftwareRenderer, false, false, useMultisampling);
         CGLChoosePixelFormat(attribs.data(), &pixelFormatObj, &numPixelFormats);
 
         if (numPixelFormats == 0) {
-            setPixelFormat(attribs, 32, 16, !attrs.forceSoftwareRenderer, false, false);
+            setPixelFormat(attribs, 32, 16, !attrs.forceSoftwareRenderer, false, false, useMultisampling);
             CGLChoosePixelFormat(attribs.data(), &pixelFormatObj, &numPixelFormats);
 
              if (!attrs.forceSoftwareRenderer && numPixelFormats == 0) {
-                 setPixelFormat(attribs, 32, 16, false, false, true);
+                 setPixelFormat(attribs, 32, 16, false, false, true, false);
                  CGLChoosePixelFormat(attribs.data(), &pixelFormatObj, &numPixelFormats);
+                 useMultisampling = false;
             }
         }
     }
@@ -183,6 +194,9 @@
         [m_webGLLayer.get() setName:@"WebGL Layer"];
 #endif    
     END_BLOCK_OBJC_EXCEPTIONS
+
+    if (useMultisampling)
+        ::glEnable(GL_MULTISAMPLE);
     
     // create a texture to render into
     ::glGenTextures(1, &m_texture);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to