Add OpenGL display mask to WebPage creation parameters.
authorpvollan@apple.com <pvollan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 May 2018 23:43:13 +0000 (23:43 +0000)
committerpvollan@apple.com <pvollan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 May 2018 23:43:13 +0000 (23:43 +0000)
https://bugs.webkit.org/show_bug.cgi?id=186163
<rdar://problem/40634504>

Reviewed by Brent Fulgham.

To make sure the OpenGL display mask is always available, include it in the WebPage creation parameters.
The OpenGL display mask is sent to the WebProcess when the platform display ID changes, but that is not
early enough in all cases. If the OpenGL display mask is not set, only OpenGL software rendering is offered
on some hardware configurations.
Source/WebCore:

No new tests, since it is not trivial to test whether OpenGL rendering is hardware accelerated.

* platform/PlatformScreen.h:
* platform/mac/PlatformScreenMac.mm:
(WebCore::displayID):

Source/WebKit:

* Shared/WebPageCreationParameters.cpp:
(WebKit::WebPageCreationParameters::encode const):
(WebKit::WebPageCreationParameters::decode):
* Shared/WebPageCreationParameters.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::creationParameters):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::m_credentialsMessenger):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/PlatformScreen.h
Source/WebCore/platform/mac/PlatformScreenMac.mm
Source/WebKit/ChangeLog
Source/WebKit/Shared/WebPageCreationParameters.cpp
Source/WebKit/Shared/WebPageCreationParameters.h
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/WebProcess/WebPage/WebPage.cpp

index cc8fc7b..71a2632 100644 (file)
@@ -1,3 +1,22 @@
+2018-05-31  Per Arne Vollan  <pvollan@apple.com>
+
+        Add OpenGL display mask to WebPage creation parameters.
+        https://bugs.webkit.org/show_bug.cgi?id=186163
+        <rdar://problem/40634504>
+
+        Reviewed by Brent Fulgham.
+
+        To make sure the OpenGL display mask is always available, include it in the WebPage creation parameters.
+        The OpenGL display mask is sent to the WebProcess when the platform display ID changes, but that is not
+        early enough in all cases. If the OpenGL display mask is not set, only OpenGL software rendering is offered
+        on some hardware configurations.
+        No new tests, since it is not trivial to test whether OpenGL rendering is hardware accelerated.
+
+        * platform/PlatformScreen.h:
+        * platform/mac/PlatformScreenMac.mm:
+        (WebCore::displayID):
+
 2018-05-31  Megan Gardner  <megan_gardner@apple.com>
 
         Add setting to allow override screen size to be disabled.
index 4d1d7fe..836516e 100644 (file)
@@ -81,7 +81,9 @@ WEBCORE_EXPORT CGColorSpaceRef screenColorSpace(Widget* = nullptr);
 #if PLATFORM(MAC)
 struct ScreenProperties;
 
-NSScreen *screen(NSWindow *);
+WEBCORE_EXPORT PlatformDisplayID displayID(NSScreen *);
+
+WEBCORE_EXPORT NSScreen *screen(NSWindow *);
 NSScreen *screen(PlatformDisplayID);
 
 FloatRect screenRectForDisplay(PlatformDisplayID);
index 04ec8c7..77b6731 100644 (file)
@@ -46,7 +46,7 @@ namespace WebCore {
 // These functions scale between screen and page coordinates because JavaScript/DOM operations
 // assume that the screen and the page share the same coordinate system.
 
-static PlatformDisplayID displayID(NSScreen *screen)
+PlatformDisplayID displayID(NSScreen *screen)
 {
     ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
     return [[[screen deviceDescription] objectForKey:@"NSScreenNumber"] intValue];
index a5238d7..098ea14 100644 (file)
@@ -1,3 +1,25 @@
+2018-05-31  Per Arne Vollan  <pvollan@apple.com>
+
+        Add OpenGL display mask to WebPage creation parameters.
+        https://bugs.webkit.org/show_bug.cgi?id=186163
+        <rdar://problem/40634504>
+
+        Reviewed by Brent Fulgham.
+
+        To make sure the OpenGL display mask is always available, include it in the WebPage creation parameters.
+        The OpenGL display mask is sent to the WebProcess when the platform display ID changes, but that is not
+        early enough in all cases. If the OpenGL display mask is not set, only OpenGL software rendering is offered
+        on some hardware configurations.
+
+        * Shared/WebPageCreationParameters.cpp:
+        (WebKit::WebPageCreationParameters::encode const):
+        (WebKit::WebPageCreationParameters::decode):
+        * Shared/WebPageCreationParameters.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::creationParameters):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::m_credentialsMessenger):
+
 2018-05-31  Brent Fulgham  <bfulgham@apple.com>
 
         Add a rule to allow reading files with prefix /private/var/db/CVMS/cvmsCodeSignObj
index 3b0b8aa..d2e5782 100644 (file)
@@ -119,6 +119,9 @@ void WebPageCreationParameters::encode(IPC::Encoder& encoder) const
 #if ENABLE(CONTENT_EXTENSIONS)
     encoder << contentRuleLists;
 #endif
+#if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
+    encoder << displayMask;
+#endif
 }
 
 std::optional<WebPageCreationParameters> WebPageCreationParameters::decode(IPC::Decoder& decoder)
@@ -343,6 +346,11 @@ std::optional<WebPageCreationParameters> WebPageCreationParameters::decode(IPC::
     parameters.contentRuleLists = WTFMove(*contentRuleLists);
 #endif
 
+#if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
+    if (!decoder.decode(parameters.displayMask))
+        return std::nullopt;
+#endif
+
     return WTFMove(parameters);
 }
 
index 06f7ab6..3cf656c 100644 (file)
@@ -185,6 +185,10 @@ struct WebPageCreationParameters {
 #if ENABLE(CONTENT_EXTENSIONS)
     Vector<std::pair<String, WebCompiledContentRuleListData>> contentRuleLists;
 #endif
+    
+#if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
+    CGOpenGLDisplayMask displayMask { 0 };
+#endif
 };
 
 } // namespace WebKit
index 3aca1f0..c43c1b3 100644 (file)
@@ -6150,6 +6150,12 @@ WebPageCreationParameters WebPageProxy::creationParameters()
     parameters.applicationManifest = m_configuration->applicationManifest() ? std::optional<WebCore::ApplicationManifest>(m_configuration->applicationManifest()->applicationManifest()) : std::nullopt;
 #endif
 
+#if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
+    auto screen = WebCore::screen(m_pageClient.platformWindow());
+    auto displayID = WebCore::displayID(screen);
+    parameters.displayMask = CGDisplayIDToOpenGLDisplayMask(displayID);
+#endif
+
     m_process->addWebUserContentControllerProxy(m_userContentController, parameters);
 
     return parameters;
index 8daa118..29ef661 100644 (file)
 #include <WebCore/FrameLoadRequest.h>
 #include <WebCore/FrameLoaderTypes.h>
 #include <WebCore/FrameView.h>
+#include <WebCore/GraphicsContext3D.h>
 #include <WebCore/HTMLAttachmentElement.h>
 #include <WebCore/HTMLFormElement.h>
 #include <WebCore/HTMLImageElement.h>
@@ -617,6 +618,10 @@ WebPage::WebPage(uint64_t pageID, WebPageCreationParameters&& parameters)
     setViewportConfigurationViewLayoutSize(parameters.viewportConfigurationViewLayoutSize);
     setMaximumUnobscuredSize(parameters.maximumUnobscuredSize);
 #endif
+    
+#if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
+    GraphicsContext3D::setOpenGLDisplayMask(parameters.displayMask);
+#endif
 }
 
 #if ENABLE(WEB_RTC)