Diff
Modified: trunk/LayoutTests/ChangeLog (286422 => 286423)
--- trunk/LayoutTests/ChangeLog 2021-12-02 14:11:50 UTC (rev 286422)
+++ trunk/LayoutTests/ChangeLog 2021-12-02 14:15:29 UTC (rev 286423)
@@ -1,3 +1,16 @@
+2021-12-02 Kimmo Kinnunen <kkinnu...@apple.com>
+
+ GraphicsContextGLANGLE should not have Cocoa Mac specific display reconfiguration code
+ https://bugs.webkit.org/show_bug.cgi?id=233695
+
+ Reviewed by Antti Koivisto.
+
+ Change the test to account for the behavior change
+ where the simulated context change event is delivered
+ only to the context being tested, not to all contexts.
+
+ * fast/canvas/webgl/webglcontextchangedevent.html:
+
2021-12-02 Youenn Fablet <you...@apple.com>
Add support for NavigationPreloadManager
Modified: trunk/LayoutTests/fast/canvas/webgl/webglcontextchangedevent.html (286422 => 286423)
--- trunk/LayoutTests/fast/canvas/webgl/webglcontextchangedevent.html 2021-12-02 14:11:50 UTC (rev 286422)
+++ trunk/LayoutTests/fast/canvas/webgl/webglcontextchangedevent.html 2021-12-02 14:15:29 UTC (rev 286423)
@@ -39,10 +39,12 @@
gl.clear(gl.COLOR_BUFFER_BIT);
});
- let gl = document.querySelector("canvas").getContext("webgl");
- if (window.internals)
- window.internals.simulateEventForWebGLContext("ContextChange", gl);
- else
+ document.querySelectorAll("canvas").forEach((c) => {
+ let gl = c.getContext("webgl");
+ if (window.internals)
+ window.internals.simulateEventForWebGLContext("ContextChange", gl);
+ });
+ if (!window.internals)
log("To run the test, trigger a GPU change manually.");
}
Modified: trunk/Source/WebCore/ChangeLog (286422 => 286423)
--- trunk/Source/WebCore/ChangeLog 2021-12-02 14:11:50 UTC (rev 286422)
+++ trunk/Source/WebCore/ChangeLog 2021-12-02 14:15:29 UTC (rev 286423)
@@ -1,5 +1,58 @@
2021-12-02 Kimmo Kinnunen <kkinnu...@apple.com>
+ GraphicsContextGLANGLE should not have Cocoa Mac specific display reconfiguration code
+ https://bugs.webkit.org/show_bug.cgi?id=233695
+
+ Reviewed by Antti Koivisto.
+
+ Move code to observe Mac display reconfiguration
+ away from GraphicsContextGLANGLE to GraphicsContextGLCocoa.
+ Apply the display reconfiguration listener only for
+ WebProcessGraphicsContextGLCocoa, it is not needed for the
+ GPU process contexts.
+
+ Move the listener notification code away from GraphicsContextGLOpenGLManager
+ into its own class. This way GraphicsContextGLOpenGLManager does not need
+ to know Mac specific interfaces. Later on, GraphicsContextGLOpenGLManager can
+ be removed altogether.
+
+ Changes behavior so that simulateEventForTesting invokes the simulated context
+ change only for the context being tested. This simplifies the implementation.
+
+ No new tests, refactor.
+
+ * PlatformMac.cmake:
+ * SourcesCocoa.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/graphics/GraphicsContextGLAttributes.h:
+ (WebCore::GraphicsContextGLAttributes::effectivePowerPreference const):
+ * platform/graphics/angle/GraphicsContextGLANGLE.cpp:
+ (WebCore::GraphicsContextGLANGLE::simulateEventForTesting):
+ * platform/graphics/angle/GraphicsContextGLANGLE.h:
+ * platform/graphics/cocoa/GraphicsContextGLCocoa.h:
+ * platform/graphics/cocoa/GraphicsContextGLCocoa.mm:
+ (WebCore::initializeEGLDisplay):
+ (WebCore::GraphicsContextGLCocoa::create):
+ (WebCore::GraphicsContextGLCocoa::GraphicsContextGLCocoa):
+ (WebCore::GraphicsContextGLCocoa::~GraphicsContextGLCocoa):
+ (WebCore::GraphicsContextGLANGLE::GraphicsContextGLANGLE):
+ (WebCore::GraphicsContextGLCocoa::setContextVisibility):
+ (WebCore::GraphicsContextGLCocoa::updateContextOnDisplayReconfiguration):
+ (WebCore::GraphicsContextGLANGLE::setContextVisibility): Deleted.
+ (WebCore::GraphicsContextGLANGLE::displayWasReconfigured): Deleted.
+ * platform/graphics/cocoa/WebProcessGraphicsContextGLCocoa.mm:
+ * platform/graphics/mac/DisplayConfigurationMonitor.cpp: Copied from Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLManager.h.
+ (WebCore::DisplayConfigurationMonitor::singleton):
+ (WebCore::DisplayConfigurationMonitor::addClient):
+ (WebCore::DisplayConfigurationMonitor::removeClient):
+ (WebCore::DisplayConfigurationMonitor::dispatchDisplayWasReconfigured):
+ * platform/graphics/mac/DisplayConfigurationMonitor.h: Copied from Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLManager.h.
+ * platform/graphics/opengl/GraphicsContextGLOpenGLManager.cpp:
+ (WebCore::GraphicsContextGLOpenGLManager::displayWasReconfigured): Deleted.
+ * platform/graphics/opengl/GraphicsContextGLOpenGLManager.h:
+
+2021-12-02 Kimmo Kinnunen <kkinnu...@apple.com>
+
REGRESSION(r286209) [GTK][WPE] crashes in offscreen canvas tests that try to create a GL context
https://bugs.webkit.org/show_bug.cgi?id=233712
Modified: trunk/Source/WebCore/PlatformMac.cmake (286422 => 286423)
--- trunk/Source/WebCore/PlatformMac.cmake 2021-12-02 14:11:50 UTC (rev 286422)
+++ trunk/Source/WebCore/PlatformMac.cmake 2021-12-02 14:15:29 UTC (rev 286423)
@@ -343,6 +343,7 @@
platform/graphics/mac/ColorMac.mm
platform/graphics/mac/ComplexTextControllerCoreText.mm
+ platform/graphics/mac/DisplayConfigurationMonitor.cpp
platform/graphics/mac/FloatPointMac.mm
platform/graphics/mac/FloatSizeMac.mm
platform/graphics/mac/FontCustomPlatformData.cpp
@@ -671,6 +672,7 @@
platform/graphics/cv/PixelBufferConformerCV.h
platform/graphics/mac/ColorMac.h
+ platform/graphics/mac/DisplayConfigurationMonitor.h
platform/graphics/mac/FontCustomPlatformData.h
platform/graphics/mac/GraphicsChecksMac.h
platform/graphics/mac/ScopedHighPerformanceGPURequest.h
Modified: trunk/Source/WebCore/SourcesCocoa.txt (286422 => 286423)
--- trunk/Source/WebCore/SourcesCocoa.txt 2021-12-02 14:11:50 UTC (rev 286422)
+++ trunk/Source/WebCore/SourcesCocoa.txt 2021-12-02 14:15:29 UTC (rev 286423)
@@ -412,6 +412,7 @@
platform/graphics/ios/IconIOS.mm
platform/graphics/mac/ColorMac.mm
platform/graphics/mac/ComplexTextControllerCoreText.mm
+platform/graphics/mac/DisplayConfigurationMonitor.cpp
platform/graphics/mac/FloatPointMac.mm
platform/graphics/mac/FloatSizeMac.mm
platform/graphics/mac/FontCustomPlatformData.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (286422 => 286423)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-12-02 14:11:50 UTC (rev 286422)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-12-02 14:15:29 UTC (rev 286423)
@@ -2376,6 +2376,7 @@
7BB680BA25BA1BE4002B8738 /* GraphicsChecksMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BB680B825BA1BE4002B8738 /* GraphicsChecksMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
7BDDA31F274FA0210038659E /* GraphicsContextGLCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BDDA31D274F9DA50038659E /* GraphicsContextGLCocoa.h */; settings = {ATTRIBUTES = (Private, ); }; };
7BE7427381FA906FBB4F0F2C /* JSSVGGraphicsElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 950C4C02BED8936F818E2F99 /* JSSVGGraphicsElement.h */; };
+ 7BFF59F42757726700773D39 /* DisplayConfigurationMonitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BFF59EF275771E800773D39 /* DisplayConfigurationMonitor.h */; settings = {ATTRIBUTES = (Private, ); }; };
7C029C6E2493C8F800268204 /* ColorTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C029C6D2493C8F800268204 /* ColorTypes.h */; settings = {ATTRIBUTES = (Private, ); }; };
7C1843FE1C8B7283002EB973 /* Autofill.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C1843FC1C8B7283002EB973 /* Autofill.h */; settings = {ATTRIBUTES = (Private, ); }; };
7C193BBB1F5E0EED0088F3E6 /* CanvasDirection.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C193BB61F5E0EB90088F3E6 /* CanvasDirection.h */; };
@@ -11382,6 +11383,8 @@
7BDDA31C274F9DA40038659E /* GraphicsContextGLCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GraphicsContextGLCocoa.mm; sourceTree = "<group>"; };
7BDDA31D274F9DA50038659E /* GraphicsContextGLCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphicsContextGLCocoa.h; sourceTree = "<group>"; };
7BE7265B25763B8D00E85D98 /* RemoteGraphicsContextGLProxyBase.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteGraphicsContextGLProxyBase.cpp; sourceTree = "<group>"; };
+ 7BFF59EF275771E800773D39 /* DisplayConfigurationMonitor.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; path = DisplayConfigurationMonitor.h; sourceTree = "<group>"; };
+ 7BFF59F1275771E800773D39 /* DisplayConfigurationMonitor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayConfigurationMonitor.cpp; sourceTree = "<group>"; };
7C011F3D24FAD360005BEF10 /* Settings.cpp.erb */ = {isa = PBXFileReference; lastKnownFileType = text; path = Settings.cpp.erb; sourceTree = "<group>"; };
7C011F3E24FAD360005BEF10 /* InternalSettingsGenerated.cpp.erb */ = {isa = PBXFileReference; lastKnownFileType = text; path = InternalSettingsGenerated.cpp.erb; sourceTree = "<group>"; };
7C011F3F24FAD360005BEF10 /* InternalSettingsGenerated.idl.erb */ = {isa = PBXFileReference; lastKnownFileType = text; path = InternalSettingsGenerated.idl.erb; sourceTree = "<group>"; };
@@ -28436,6 +28439,8 @@
EDE3A4FF0C7A430600956A37 /* ColorMac.h */,
B275354A0B053814002CE64F /* ColorMac.mm */,
37C238201098C84200EF9F72 /* ComplexTextControllerCoreText.mm */,
+ 7BFF59F1275771E800773D39 /* DisplayConfigurationMonitor.cpp */,
+ 7BFF59EF275771E800773D39 /* DisplayConfigurationMonitor.h */,
B275354B0B053814002CE64F /* FloatPointMac.mm */,
B275354D0B053814002CE64F /* FloatSizeMac.mm */,
B2AFFC750D00A5C10030074D /* FontCustomPlatformData.cpp */,
@@ -33876,6 +33881,7 @@
F47A09D120A93A9700240FAE /* DisabledAdaptations.h in Headers */,
7EDAAFC919A2CCDC0034DFD1 /* DiskCacheMonitorCocoa.h in Headers */,
07BB1E7027176CD9001DF289 /* DisplayCaptureSourceCocoa.h in Headers */,
+ 7BFF59F42757726700773D39 /* DisplayConfigurationMonitor.h in Headers */,
0FE5FBD31C3DD51E0007A2CA /* DisplayList.h in Headers */,
55AD09402408964000DE4D2F /* DisplayListDrawingContext.h in Headers */,
55AD093E2408963500DE4D2F /* DisplayListImageBuffer.h in Headers */,
Modified: trunk/Source/WebCore/platform/graphics/GraphicsContextGLAttributes.h (286422 => 286423)
--- trunk/Source/WebCore/platform/graphics/GraphicsContextGLAttributes.h 2021-12-02 14:11:50 UTC (rev 286422)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContextGLAttributes.h 2021-12-02 14:15:29 UTC (rev 286423)
@@ -68,6 +68,12 @@
#if ENABLE(WEBXR)
bool xrCompatible { false };
#endif
+ PowerPreference effectivePowerPreference() const
+ {
+ if (forceRequestForHighPerformanceGPU)
+ return PowerPreference::HighPerformance;
+ return powerPreference;
+ }
};
}
Modified: trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp (286422 => 286423)
--- trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp 2021-12-02 14:11:50 UTC (rev 286422)
+++ trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp 2021-12-02 14:15:29 UTC (rev 286423)
@@ -2915,9 +2915,7 @@
void GraphicsContextGLANGLE::simulateEventForTesting(SimulatedEventForTesting event)
{
if (event == SimulatedEventForTesting::ContextChange) {
-#if PLATFORM(COCOA)
- GraphicsContextGLOpenGLManager::sharedManager().displayWasReconfigured();
-#endif
+ dispatchContextChangedNotification();
return;
}
if (event == SimulatedEventForTesting::GPUStatusFailure) {
Modified: trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.h (286422 => 286423)
--- trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.h 2021-12-02 14:11:50 UTC (rev 286422)
+++ trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.h 2021-12-02 14:15:29 UTC (rev 286423)
@@ -38,9 +38,6 @@
#include "IOSurface.h"
#endif
-#if PLATFORM(MAC)
-#include "ScopedHighPerformanceGPURequest.h"
-#endif
#if USE(NICOSIA)
namespace Nicosia {
@@ -348,7 +345,6 @@
void paintRenderingResultsToCanvas(ImageBuffer&) final;
std::optional<PixelBuffer> paintRenderingResultsToPixelBuffer() final;
void paintCompositedResultsToCanvas(ImageBuffer&) final;
- void setContextVisibility(bool) final;
void prepareForDisplay() override;
void forceContextLost();
@@ -357,9 +353,6 @@
std::optional<PixelBuffer> readRenderingResultsForPainting();
std::optional<PixelBuffer> readCompositedResultsForPainting();
-#if PLATFORM(COCOA)
- void displayWasReconfigured();
-#endif
unsigned textureSeed(GCGLuint texture);
constexpr static EGLNativeDisplayType defaultDisplay = EGL_DEFAULT_DISPLAY;
@@ -444,10 +437,6 @@
std::unique_ptr<IOSurface> m_displayBufferBacking;
void* m_displayBufferPbuffer { nullptr };
#endif
-#if PLATFORM(MAC)
- bool m_switchesGPUOnDisplayReconfiguration { false };
- ScopedHighPerformanceGPURequest m_highPerformanceGPURequest;
-#endif
#if USE(COORDINATED_GRAPHICS)
GCGLuint m_compositorTexture { 0 };
GCGLuint m_intermediateTexture { 0 };
Modified: trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.h (286422 => 286423)
--- trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.h 2021-12-02 14:11:50 UTC (rev 286422)
+++ trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.h 2021-12-02 14:15:29 UTC (rev 286423)
@@ -36,6 +36,10 @@
}
#endif
+#if PLATFORM(MAC)
+#include "ScopedHighPerformanceGPURequest.h"
+#endif
+
namespace WebCore {
class WEBCORE_EXPORT GraphicsContextGLCocoa : public GraphicsContextGLANGLE {
@@ -66,7 +70,11 @@
#if ENABLE(MEDIA_STREAM)
RefPtr<MediaSample> paintCompositedResultsToMediaSample() final;
#endif
+ void setContextVisibility(bool) final;
+#if PLATFORM(MAC)
+ void updateContextOnDisplayReconfiguration();
+#endif
protected:
GraphicsContextGLCocoa(WebCore::GraphicsContextGLAttributes&&);
bool isValid() const;
@@ -74,6 +82,10 @@
#if ENABLE(VIDEO)
std::unique_ptr<GraphicsContextGLCVCocoa> m_cv;
#endif
+#if PLATFORM(MAC)
+ bool m_switchesGPUOnDisplayReconfiguration { false };
+ ScopedHighPerformanceGPURequest m_highPerformanceGPURequest;
+#endif
friend class GraphicsContextGLCVCocoa;
};
Modified: trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm (286422 => 286423)
--- trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm 2021-12-02 14:11:50 UTC (rev 286422)
+++ trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm 2021-12-02 14:15:29 UTC (rev 286423)
@@ -153,7 +153,7 @@
displayAttributes.append(EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE);
// These properties are defined for EGL_ANGLE_power_preference as EGLContext attributes,
// but Metal backend uses EGLDisplay attributes.
- auto powerPreference = attrs.forceRequestForHighPerformanceGPU ? GraphicsContextGLAttributes::PowerPreference::HighPerformance : attrs.powerPreference;
+ auto powerPreference = attrs.effectivePowerPreference();
if (powerPreference == GraphicsContextGLAttributes::PowerPreference::LowPower) {
displayAttributes.append(EGL_POWER_PREFERENCE_ANGLE);
displayAttributes.append(EGL_LOW_POWER_ANGLE);
@@ -194,7 +194,7 @@
}
#endif
-RefPtr<GraphicsContextGLCocoa> GraphicsContextGLCocoa::create(WebCore::GraphicsContextGLAttributes&& attributes)
+RefPtr<GraphicsContextGLCocoa> GraphicsContextGLCocoa::create(GraphicsContextGLAttributes&& attributes)
{
auto context = adoptRef(*new GraphicsContextGLCocoa(WTFMove(attributes)));
if (!context->isValid())
@@ -202,6 +202,18 @@
return context;
}
+GraphicsContextGLCocoa::GraphicsContextGLCocoa(GraphicsContextGLAttributes&& creationAttributes)
+ : GraphicsContextGLANGLE(WTFMove(creationAttributes))
+{
+ if (!isValid())
+ return;
+#if PLATFORM(MAC)
+ auto attributes = contextAttributes();
+ if (!attributes.useMetal && attributes.effectivePowerPreference() == GraphicsContextGLPowerPreference::HighPerformance)
+ m_switchesGPUOnDisplayReconfiguration = true;
+#endif
+}
+
GraphicsContextGLCocoa::~GraphicsContextGLCocoa() = default;
IOSurface* GraphicsContextGLCocoa::displayBuffer()
@@ -214,11 +226,6 @@
return m_swapChain.markDisplayBufferInUse();
}
-GraphicsContextGLCocoa::GraphicsContextGLCocoa(WebCore::GraphicsContextGLAttributes&& attributes)
- : GraphicsContextGLANGLE(WTFMove(attributes))
-{
-}
-
// FIXME: Below is functionality that should be moved to GraphicsContextGLCocoa to simplify the base class.
GraphicsContextGLANGLE::GraphicsContextGLANGLE(GraphicsContextGLAttributes attrs)
@@ -255,14 +262,12 @@
// display reconfiguration callback. Upon this, we update the CGL contexts inside ANGLE.
const char *displayExtensions = EGL_QueryString(m_displayObj, EGL_EXTENSIONS);
bool supportsPowerPreference = strstr(displayExtensions, "EGL_ANGLE_power_preference");
- if (supportsPowerPreference) {
- m_switchesGPUOnDisplayReconfiguration = attrs.powerPreference == GraphicsContextGLPowerPreference::HighPerformance
- || attrs.forceRequestForHighPerformanceGPU;
- } else {
+ if (!supportsPowerPreference) {
+ attrs.forceRequestForHighPerformanceGPU = false;
if (attrs.powerPreference == GraphicsContextGLPowerPreference::HighPerformance) {
attrs.powerPreference = GraphicsContextGLPowerPreference::Default;
- setContextAttributes(attrs);
}
+ setContextAttributes(attrs);
}
}
#endif
@@ -506,7 +511,7 @@
restartStatus = 0;
}
-void GraphicsContextGLANGLE::setContextVisibility(bool isVisible)
+void GraphicsContextGLCocoa::setContextVisibility(bool isVisible)
{
#if PLATFORM(MAC)
if (!m_switchesGPUOnDisplayReconfiguration)
@@ -520,14 +525,14 @@
#endif
}
-void GraphicsContextGLANGLE::displayWasReconfigured()
+#if PLATFORM(MAC)
+void GraphicsContextGLCocoa::updateContextOnDisplayReconfiguration()
{
-#if PLATFORM(MAC)
if (m_switchesGPUOnDisplayReconfiguration)
EGL_HandleGPUSwitchANGLE(m_displayObj);
-#endif
dispatchContextChangedNotification();
}
+#endif
bool GraphicsContextGLANGLE::reshapeDisplayBufferBacking()
{
Modified: trunk/Source/WebCore/platform/graphics/cocoa/WebProcessGraphicsContextGLCocoa.mm (286422 => 286423)
--- trunk/Source/WebCore/platform/graphics/cocoa/WebProcessGraphicsContextGLCocoa.mm 2021-12-02 14:11:50 UTC (rev 286422)
+++ trunk/Source/WebCore/platform/graphics/cocoa/WebProcessGraphicsContextGLCocoa.mm 2021-12-02 14:15:29 UTC (rev 286423)
@@ -32,6 +32,10 @@
#import "WebGLLayer.h"
#import <wtf/BlockObjCExceptions.h>
+#if PLATFORM(MAC)
+#import "DisplayConfigurationMonitor.h"
+#endif
+
namespace WebCore {
namespace {
@@ -48,24 +52,46 @@
}
// GraphicsContextGL type that is used when WebGL is run in-process in WebContent process.
-class WebProcessGraphicsContextGLCocoa final : public GraphicsContextGLCocoa {
+class WebProcessGraphicsContextGLCocoa final : public GraphicsContextGLCocoa
+#if PLATFORM(MAC)
+ , private DisplayConfigurationMonitor::Client
+#endif
+
+{
public:
- ~WebProcessGraphicsContextGLCocoa() = default;
+ ~WebProcessGraphicsContextGLCocoa();
bool isValid() const { return GraphicsContextGLCocoa::isValid() && m_webGLLayer; }
// GraphicsContextGLCocoa overrides.
PlatformLayer* platformLayer() const final { return reinterpret_cast<CALayer*>(m_webGLLayer.get()); }
void prepareForDisplay() final;
private:
- WebProcessGraphicsContextGLCocoa(GraphicsContextGLAttributes&& attributes)
- : GraphicsContextGLCocoa(WTFMove(attributes))
- , m_webGLLayer(createWebGLLayer(contextAttributes()))
- {
- }
+#if PLATFORM(MAC)
+ // DisplayConfigurationMonitor::Client overrides.
+ void displayWasReconfigured() final;
+#endif
+
+ WebProcessGraphicsContextGLCocoa(GraphicsContextGLAttributes&&);
RetainPtr<WebGLLayer> m_webGLLayer;
friend RefPtr<GraphicsContextGL> WebCore::createWebProcessGraphicsContextGL(const GraphicsContextGLAttributes&);
};
+WebProcessGraphicsContextGLCocoa::WebProcessGraphicsContextGLCocoa(GraphicsContextGLAttributes&& attributes)
+ : GraphicsContextGLCocoa(WTFMove(attributes))
+ , m_webGLLayer(createWebGLLayer(contextAttributes()))
+{
+#if PLATFORM(MAC)
+ DisplayConfigurationMonitor::singleton().addClient(*this);
+#endif
+}
+
+WebProcessGraphicsContextGLCocoa::~WebProcessGraphicsContextGLCocoa()
+{
+#if PLATFORM(MAC)
+ DisplayConfigurationMonitor::singleton().removeClient(*this);
+#endif
+}
+
void WebProcessGraphicsContextGLCocoa::prepareForDisplay()
{
GraphicsContextGLCocoa::prepareForDisplay();
@@ -78,8 +104,15 @@
END_BLOCK_OBJC_EXCEPTIONS
}
+#if PLATFORM(MAC)
+void WebProcessGraphicsContextGLCocoa::displayWasReconfigured()
+{
+ updateContextOnDisplayReconfiguration();
}
+#endif
+}
+
RefPtr<GraphicsContextGL> createWebProcessGraphicsContextGL(const GraphicsContextGLAttributes& attributes)
{
// Make space for the incoming context if we're full.
Copied: trunk/Source/WebCore/platform/graphics/mac/DisplayConfigurationMonitor.cpp (from rev 286422, trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLManager.h) (0 => 286423)
--- trunk/Source/WebCore/platform/graphics/mac/DisplayConfigurationMonitor.cpp (rev 0)
+++ trunk/Source/WebCore/platform/graphics/mac/DisplayConfigurationMonitor.cpp 2021-12-02 14:15:29 UTC (rev 286423)
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2021 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 met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "DisplayConfigurationMonitor.h"
+
+#if PLATFORM(MAC)
+
+#include <wtf/ThreadAssertions.h>
+
+namespace WebCore {
+
+DisplayConfigurationMonitor::Client::Client() = default;
+
+DisplayConfigurationMonitor::Client::~Client() = default;
+
+DisplayConfigurationMonitor::DisplayConfigurationMonitor() = default;
+
+DisplayConfigurationMonitor::~DisplayConfigurationMonitor() = default;
+
+DisplayConfigurationMonitor& DisplayConfigurationMonitor::singleton()
+{
+ assertIsMainThread();
+ static NeverDestroyed<DisplayConfigurationMonitor> instance;
+ return instance;
+}
+
+void DisplayConfigurationMonitor::addClient(Client& client)
+{
+ ASSERT(!m_clients.contains(&client));
+ m_clients.append(&client);
+}
+
+void DisplayConfigurationMonitor::removeClient(Client& client)
+{
+ ASSERT(m_clients.contains(&client));
+ m_clients.removeFirst(&client);
+}
+
+void DisplayConfigurationMonitor::dispatchDisplayWasReconfigured(CGDisplayChangeSummaryFlags flags)
+{
+ if (!(flags & kCGDisplaySetModeFlag))
+ return;
+ for (auto* client : copyToVector(m_clients))
+ client->displayWasReconfigured();
+}
+
+}
+
+#endif
Copied: trunk/Source/WebCore/platform/graphics/mac/DisplayConfigurationMonitor.h (from rev 286422, trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLManager.h) (0 => 286423)
--- trunk/Source/WebCore/platform/graphics/mac/DisplayConfigurationMonitor.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/mac/DisplayConfigurationMonitor.h 2021-12-02 14:15:29 UTC (rev 286423)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2021 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 met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if PLATFORM(MAC)
+
+#include <CoreGraphics/CGDisplayConfiguration.h>
+#include <wtf/NeverDestroyed.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+class DisplayConfigurationMonitor {
+public:
+ ~DisplayConfigurationMonitor();
+ WEBCORE_EXPORT static DisplayConfigurationMonitor& singleton();
+
+ class Client {
+ public:
+ Client();
+ virtual ~Client();
+ virtual void displayWasReconfigured() = 0;
+ };
+ void addClient(Client&);
+ void removeClient(Client&);
+
+ WEBCORE_EXPORT void dispatchDisplayWasReconfigured(CGDisplayChangeSummaryFlags);
+private:
+ DisplayConfigurationMonitor();
+ Vector<Client*> m_clients;
+ friend NeverDestroyed<DisplayConfigurationMonitor>;
+};
+
+}
+#endif
Modified: trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLManager.cpp (286422 => 286423)
--- trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLManager.cpp 2021-12-02 14:11:50 UTC (rev 286422)
+++ trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLManager.cpp 2021-12-02 14:15:29 UTC (rev 286423)
@@ -43,23 +43,6 @@
return s_manager;
}
-#if PLATFORM(MAC)
-void GraphicsContextGLOpenGLManager::displayWasReconfigured(CGDirectDisplayID, CGDisplayChangeSummaryFlags flags, void*)
-{
- LOG(WebGL, "GraphicsContextGLOpenGLManager::displayWasReconfigured");
- if (flags & kCGDisplaySetModeFlag)
- GraphicsContextGLOpenGLManager::sharedManager().displayWasReconfigured();
-}
-#endif
-
-#if PLATFORM(COCOA)
-void GraphicsContextGLOpenGLManager::displayWasReconfigured()
-{
- for (const auto& context : m_contexts)
- context->displayWasReconfigured();
-}
-#endif
-
void GraphicsContextGLOpenGLManager::addContext(GraphicsContextGLType* context)
{
ASSERT(context);
Modified: trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLManager.h (286422 => 286423)
--- trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLManager.h 2021-12-02 14:11:50 UTC (rev 286422)
+++ trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLManager.h 2021-12-02 14:15:29 UTC (rev 286423)
@@ -28,10 +28,6 @@
#include <wtf/HashSet.h>
#include <wtf/Vector.h>
-#if PLATFORM(MAC)
-#include <CoreGraphics/CGDisplayConfiguration.h>
-#endif
-
namespace WebCore {
const unsigned MaxContexts = 16;
@@ -59,13 +55,6 @@
void recycleContextIfNecessary();
bool hasTooManyContexts() const { return m_contexts.size() >= MaxContexts; }
-#if PLATFORM(MAC)
- WEBCORE_EXPORT static void displayWasReconfigured(CGDirectDisplayID, CGDisplayChangeSummaryFlags, void*);
-#endif
-#if PLATFORM(COCOA)
- void displayWasReconfigured();
-#endif
-
private:
GraphicsContextGLOpenGLManager() = default;
Modified: trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapper.h (286422 => 286423)
--- trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapper.h 2021-12-02 14:11:50 UTC (rev 286422)
+++ trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapper.h 2021-12-02 14:15:29 UTC (rev 286423)
@@ -54,6 +54,9 @@
#if ENABLE(MEDIA_STREAM)
RefPtr<MediaSample> paintCompositedResultsToMediaSample() final;
#endif
+#if USE(ANGLE)
+ void setContextVisibility(bool) final;
+#endif
protected:
GraphicsContextGLTextureMapper(WebCore::GraphicsContextGLAttributes&&);
Modified: trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.cpp (286422 => 286423)
--- trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.cpp 2021-12-02 14:11:50 UTC (rev 286422)
+++ trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.cpp 2021-12-02 14:15:29 UTC (rev 286423)
@@ -172,7 +172,7 @@
{
}
-void GraphicsContextGLANGLE::setContextVisibility(bool)
+void GraphicsContextGLTextureMapper::setContextVisibility(bool)
{
}
Modified: trunk/Source/WebKit/ChangeLog (286422 => 286423)
--- trunk/Source/WebKit/ChangeLog 2021-12-02 14:11:50 UTC (rev 286422)
+++ trunk/Source/WebKit/ChangeLog 2021-12-02 14:15:29 UTC (rev 286423)
@@ -1,3 +1,20 @@
+2021-12-02 Kimmo Kinnunen <kkinnu...@apple.com>
+
+ GraphicsContextGLANGLE should not have Cocoa Mac specific display reconfiguration code
+ https://bugs.webkit.org/show_bug.cgi?id=233695
+
+ Reviewed by Antti Koivisto.
+
+ Previous GraphicsContextGLANGLE::displayWasReconfigured()
+ was renamed to updateContextOnDisplayReconfiguration().
+ The displayWasReconfigured() was taken into use in the notification interface
+ DisplayConfigurationMonitor::Client::displayWasReconfigured().
+
+ * GPUProcess/graphics/RemoteGraphicsContextGL.cpp:
+ (WebKit::RemoteGraphicsContextGL::displayWasReconfigured):
+ * WebProcess/cocoa/WebProcessCocoa.mm:
+ (WebKit::WebProcess::displayConfigurationChanged):
+
2021-12-02 Youenn Fablet <you...@apple.com>
Add support for NavigationPreloadManager
Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp (286422 => 286423)
--- trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp 2021-12-02 14:11:50 UTC (rev 286422)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp 2021-12-02 14:15:29 UTC (rev 286423)
@@ -107,7 +107,7 @@
assertIsMainRunLoop();
remoteGraphicsContextGLStreamWorkQueue().dispatch([protectedThis = Ref { *this }]() {
assertIsCurrent(protectedThis->m_streamThread);
- protectedThis->m_context->displayWasReconfigured();
+ protectedThis->m_context->updateContextOnDisplayReconfiguration();
});
}
#endif
Modified: trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (286422 => 286423)
--- trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm 2021-12-02 14:11:50 UTC (rev 286422)
+++ trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm 2021-12-02 14:15:29 UTC (rev 286423)
@@ -139,7 +139,7 @@
#import "AppKitSPI.h"
#import "WKAccessibilityWebPageObjectMac.h"
#import "WebSwitchingGPUClient.h"
-#import <WebCore/GraphicsContextGLOpenGLManager.h>
+#import <WebCore/DisplayConfigurationMonitor.h>
#import <WebCore/ScrollbarThemeMac.h>
#import <pal/spi/cf/CoreTextSPI.h>
#import <pal/spi/mac/HIServicesSPI.h>
@@ -971,9 +971,9 @@
[NSScrollerImpPair _updateAllScrollerImpPairsForNewRecommendedScrollerStyle:style];
}
-void WebProcess::displayConfigurationChanged(CGDirectDisplayID displayID, CGDisplayChangeSummaryFlags flags)
+void WebProcess::displayConfigurationChanged(CGDirectDisplayID, CGDisplayChangeSummaryFlags flags)
{
- GraphicsContextGLOpenGLManager::displayWasReconfigured(displayID, flags, nullptr);
+ DisplayConfigurationMonitor::singleton().dispatchDisplayWasReconfigured(flags);
}
#endif