<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[284953] branches/safari-612-branch/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/284953">284953</a></dd>
<dt>Author</dt> <dd>alancoon@apple.com</dd>
<dt>Date</dt> <dd>2021-10-27 14:06:12 -0700 (Wed, 27 Oct 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>Cherry-pick <a href="http://trac.webkit.org/projects/webkit/changeset/283703">r283703</a>. rdar://problem/84629308

    ScopedEGLDefaultDisplay should be removed
    https://bugs.webkit.org/show_bug.cgi?id=231011

    Patch by Kimmo Kinnunen <kkinnunen@apple.com> on 2021-10-07
    Reviewed by Kenneth Russell.

    Source/WebCore:

    Hard-coding the code to EGL_DEFAULT_DISPLAY only and using the scoped
    holder is making the EGLDisplays harder to use than neccessary. The
    implementation target, e.g. the ability to call EGLTerminate, was also a bit
    more convoluted than needed.

    Move the "call EGLTerminate" logic from a bit convoluted refcount mechanism
    in ScopedEGLDefaultDisplay to the explicit GraphicsContextGLOpenGL::releaseResources().
    The callers are expected to do the refcounting anyway, as the existing client
    WebKit::ScopedWebGLRenderingResourcesRequest already did.

    Make GraphicsContextGLOpenGL::releaseResources() available on all platforms.
    It is implemented on all ANGLE implementations.
    Platforms can augment the implementation by implementing
    GraphicsContextGLOpenGL::platformReleaseResources(). For Cocoa, this function
    resets the currentContext cache that is used to optimize making context current.

    No new tests, refactor.

    * CMakeLists.txt:
    * Headers.cmake:
    * PlatformMac.cmake:
    * SourcesCocoa.txt:
    * WebCore.xcodeproj/project.pbxproj:
    * platform/graphics/angle/ANGLEUtilities.cpp: Renamed from Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLEEGLUtilities.h.
    (WebCore::platformIsANGLEAvailable):
    * platform/graphics/angle/ANGLEUtilities.h: Renamed from Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLEUtilities.h.
    Rename GraphicsContextGLANGLEUtilities to simpler and more descriptive ANGLEUtilities.
    Add the isANGLEAvailable to there.

    * platform/graphics/angle/GraphicsContextGLANGLE.cpp:
    (WebCore::GraphicsContextGLOpenGL::releaseResources):
    (WebCore::GraphicsContextGLOpenGL::platformReleaseResources):
    * platform/graphics/angle/GraphicsContextGLANGLEEGLUtilities.cpp: Removed.
    (WebCore::refDefaultDisplay): Deleted.
    (WebCore::unrefDefaultDisplayIfNeeded): Deleted.
    (WebCore::ScopedEGLDefaultDisplay::operator=): Deleted.
    (WebCore::ScopedEGLDefaultDisplay::ScopedEGLDefaultDisplay): Deleted.
    (WebCore::ScopedEGLDefaultDisplay::~ScopedEGLDefaultDisplay): Deleted.
    (WebCore::ScopedEGLDefaultDisplay::releaseAllResourcesIfUnused): Deleted.
    * platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm:
    (WebCore::platformIsANGLEAvailable):
    (WebCore::initializeEGLDisplay):
    (WebCore::GraphicsContextGLOpenGL::platformReleaseResources):
    (WebCore::isANGLEAvailable): Deleted.
    (WebCore::GraphicsContextGLOpenGL::releaseCurrentContext): Deleted.
    (WebCore::GraphicsContextGLOpenGL::releaseAllResourcesIfUnused): Deleted.
    * platform/graphics/opengl/GraphicsContextGLOpenGL.cpp:
    (WebCore::GraphicsContextGLOpenGL::releaseResources):
    (WebCore::GraphicsContextGLOpenGL::platformReleaseResources):
    * platform/graphics/opengl/GraphicsContextGLOpenGL.h:
    * platform/ios/wak/WebCoreThread.mm:

    Source/WebKit:

    Implement the release of WebGL resources with the amended
    GraphicsContextGLOpenGL::releaseResources() instead of
    previous separate function GraphicsContextGLOpenGL::releaseAllResources().

    Use the resource release code path universally, as
    GraphicsContextGLOpenGL::releaseResources() is now common code.

    * GPUProcess/graphics/ScopedWebGLRenderingResourcesRequest.cpp:
    (WebKit::ScopedWebGLRenderingResourcesRequest::scheduleFreeWebGLRenderingResources):
    (WebKit::ScopedWebGLRenderingResourcesRequest::freeWebGLRenderingResources):
    * GPUProcess/graphics/ScopedWebGLRenderingResourcesRequest.h:
    * GPUProcess/graphics/ScopedWebGLRenderingResourcesRequestCocoa.cpp: Removed.
    (WebKit::ScopedWebGLRenderingResourcesRequest::scheduleFreeWebGLRenderingResources): Deleted.
    (WebKit::ScopedWebGLRenderingResourcesRequest::freeWebGLRenderingResources): Deleted.
    * SourcesCocoa.txt:
    * WebKit.xcodeproj/project.pbxproj:

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@283703 268f45cc-cd09-0410-ab3c-d52691b4dbfc</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari612branchSourceWebCoreCMakeListstxt">branches/safari-612-branch/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#branchessafari612branchSourceWebCoreChangeLog">branches/safari-612-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari612branchSourceWebCoreHeaderscmake">branches/safari-612-branch/Source/WebCore/Headers.cmake</a></li>
<li><a href="#branchessafari612branchSourceWebCorePlatformMaccmake">branches/safari-612-branch/Source/WebCore/PlatformMac.cmake</a></li>
<li><a href="#branchessafari612branchSourceWebCoreSourcesCocoatxt">branches/safari-612-branch/Source/WebCore/SourcesCocoa.txt</a></li>
<li><a href="#branchessafari612branchSourceWebCoreWebCorexcodeprojprojectpbxproj">branches/safari-612-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#branchessafari612branchSourceWebCoreplatformgraphicsangleGraphicsContextGLANGLEcpp">branches/safari-612-branch/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp</a></li>
<li><a href="#branchessafari612branchSourceWebCoreplatformgraphicscocoaGraphicsContextGLOpenGLCocoamm">branches/safari-612-branch/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm</a></li>
<li><a href="#branchessafari612branchSourceWebCoreplatformgraphicsopenglGraphicsContextGLOpenGLcpp">branches/safari-612-branch/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.cpp</a></li>
<li><a href="#branchessafari612branchSourceWebCoreplatformgraphicsopenglGraphicsContextGLOpenGLh">branches/safari-612-branch/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h</a></li>
<li><a href="#branchessafari612branchSourceWebCoreplatformioswakWebCoreThreadmm">branches/safari-612-branch/Source/WebCore/platform/ios/wak/WebCoreThread.mm</a></li>
<li><a href="#branchessafari612branchSourceWebKitChangeLog">branches/safari-612-branch/Source/WebKit/ChangeLog</a></li>
<li><a href="#branchessafari612branchSourceWebKitGPUProcessgraphicsScopedWebGLRenderingResourcesRequestcpp">branches/safari-612-branch/Source/WebKit/GPUProcess/graphics/ScopedWebGLRenderingResourcesRequest.cpp</a></li>
<li><a href="#branchessafari612branchSourceWebKitGPUProcessgraphicsScopedWebGLRenderingResourcesRequesth">branches/safari-612-branch/Source/WebKit/GPUProcess/graphics/ScopedWebGLRenderingResourcesRequest.h</a></li>
<li><a href="#branchessafari612branchSourceWebKitSourcesCocoatxt">branches/safari-612-branch/Source/WebKit/SourcesCocoa.txt</a></li>
<li><a href="#branchessafari612branchSourceWebKitWebKitxcodeprojprojectpbxproj">branches/safari-612-branch/Source/WebKit/WebKit.xcodeproj/project.pbxproj</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#branchessafari612branchSourceWebCoreplatformgraphicsangleANGLEUtilitiescpp">branches/safari-612-branch/Source/WebCore/platform/graphics/angle/ANGLEUtilities.cpp</a></li>
<li><a href="#branchessafari612branchSourceWebCoreplatformgraphicsangleANGLEUtilitiesh">branches/safari-612-branch/Source/WebCore/platform/graphics/angle/ANGLEUtilities.h</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#branchessafari612branchSourceWebCoreplatformgraphicsangleGraphicsContextGLANGLEEGLUtilitiescpp">branches/safari-612-branch/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLEEGLUtilities.cpp</a></li>
<li><a href="#branchessafari612branchSourceWebCoreplatformgraphicsangleGraphicsContextGLANGLEEGLUtilitiesh">branches/safari-612-branch/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLEEGLUtilities.h</a></li>
<li><a href="#branchessafari612branchSourceWebCoreplatformgraphicsangleGraphicsContextGLANGLEUtilitiesh">branches/safari-612-branch/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLEUtilities.h</a></li>
<li><a href="#branchessafari612branchSourceWebKitGPUProcessgraphicsScopedWebGLRenderingResourcesRequestCocoacpp">branches/safari-612-branch/Source/WebKit/GPUProcess/graphics/ScopedWebGLRenderingResourcesRequestCocoa.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari612branchSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebCore/CMakeLists.txt (284952 => 284953)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebCore/CMakeLists.txt 2021-10-27 21:06:06 UTC (rev 284952)
+++ branches/safari-612-branch/Source/WebCore/CMakeLists.txt    2021-10-27 21:06:12 UTC (rev 284953)
</span><span class="lines">@@ -1644,9 +1644,9 @@
</span><span class="cx">             ${WEBCORE_DIR}/platform/graphics/angle
</span><span class="cx">         )
</span><span class="cx">         list(APPEND WebCore_SOURCES
</span><ins>+            platform/graphics/angle/ANGLEUtilities.cpp
</ins><span class="cx">             platform/graphics/angle/ExtensionsGLANGLE.cpp
</span><span class="cx">             platform/graphics/angle/GraphicsContextGLANGLE.cpp
</span><del>-            platform/graphics/angle/GraphicsContextGLANGLEEGLUtilities.cpp
</del><span class="cx">             platform/graphics/angle/TemporaryANGLESetting.cpp
</span><span class="cx">         )
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari612branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebCore/ChangeLog (284952 => 284953)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebCore/ChangeLog      2021-10-27 21:06:06 UTC (rev 284952)
+++ branches/safari-612-branch/Source/WebCore/ChangeLog 2021-10-27 21:06:12 UTC (rev 284953)
</span><span class="lines">@@ -1,5 +1,149 @@
</span><span class="cx"> 2021-10-26  Russell Epstein  <repstein@apple.com>
</span><span class="cx"> 
</span><ins>+        Cherry-pick r283703. rdar://problem/84629308
+
+    ScopedEGLDefaultDisplay should be removed
+    https://bugs.webkit.org/show_bug.cgi?id=231011
+    
+    Patch by Kimmo Kinnunen <kkinnunen@apple.com> on 2021-10-07
+    Reviewed by Kenneth Russell.
+    
+    Source/WebCore:
+    
+    Hard-coding the code to EGL_DEFAULT_DISPLAY only and using the scoped
+    holder is making the EGLDisplays harder to use than neccessary. The
+    implementation target, e.g. the ability to call EGLTerminate, was also a bit
+    more convoluted than needed.
+    
+    Move the "call EGLTerminate" logic from a bit convoluted refcount mechanism
+    in ScopedEGLDefaultDisplay to the explicit GraphicsContextGLOpenGL::releaseResources().
+    The callers are expected to do the refcounting anyway, as the existing client
+    WebKit::ScopedWebGLRenderingResourcesRequest already did.
+    
+    Make GraphicsContextGLOpenGL::releaseResources() available on all platforms.
+    It is implemented on all ANGLE implementations.
+    Platforms can augment the implementation by implementing
+    GraphicsContextGLOpenGL::platformReleaseResources(). For Cocoa, this function
+    resets the currentContext cache that is used to optimize making context current.
+    
+    No new tests, refactor.
+    
+    * CMakeLists.txt:
+    * Headers.cmake:
+    * PlatformMac.cmake:
+    * SourcesCocoa.txt:
+    * WebCore.xcodeproj/project.pbxproj:
+    * platform/graphics/angle/ANGLEUtilities.cpp: Renamed from Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLEEGLUtilities.h.
+    (WebCore::platformIsANGLEAvailable):
+    * platform/graphics/angle/ANGLEUtilities.h: Renamed from Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLEUtilities.h.
+    Rename GraphicsContextGLANGLEUtilities to simpler and more descriptive ANGLEUtilities.
+    Add the isANGLEAvailable to there.
+    
+    * platform/graphics/angle/GraphicsContextGLANGLE.cpp:
+    (WebCore::GraphicsContextGLOpenGL::releaseResources):
+    (WebCore::GraphicsContextGLOpenGL::platformReleaseResources):
+    * platform/graphics/angle/GraphicsContextGLANGLEEGLUtilities.cpp: Removed.
+    (WebCore::refDefaultDisplay): Deleted.
+    (WebCore::unrefDefaultDisplayIfNeeded): Deleted.
+    (WebCore::ScopedEGLDefaultDisplay::operator=): Deleted.
+    (WebCore::ScopedEGLDefaultDisplay::ScopedEGLDefaultDisplay): Deleted.
+    (WebCore::ScopedEGLDefaultDisplay::~ScopedEGLDefaultDisplay): Deleted.
+    (WebCore::ScopedEGLDefaultDisplay::releaseAllResourcesIfUnused): Deleted.
+    * platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm:
+    (WebCore::platformIsANGLEAvailable):
+    (WebCore::initializeEGLDisplay):
+    (WebCore::GraphicsContextGLOpenGL::platformReleaseResources):
+    (WebCore::isANGLEAvailable): Deleted.
+    (WebCore::GraphicsContextGLOpenGL::releaseCurrentContext): Deleted.
+    (WebCore::GraphicsContextGLOpenGL::releaseAllResourcesIfUnused): Deleted.
+    * platform/graphics/opengl/GraphicsContextGLOpenGL.cpp:
+    (WebCore::GraphicsContextGLOpenGL::releaseResources):
+    (WebCore::GraphicsContextGLOpenGL::platformReleaseResources):
+    * platform/graphics/opengl/GraphicsContextGLOpenGL.h:
+    * platform/ios/wak/WebCoreThread.mm:
+    
+    Source/WebKit:
+    
+    Implement the release of WebGL resources with the amended
+    GraphicsContextGLOpenGL::releaseResources() instead of
+    previous separate function GraphicsContextGLOpenGL::releaseAllResources().
+    
+    Use the resource release code path universally, as
+    GraphicsContextGLOpenGL::releaseResources() is now common code.
+    
+    * GPUProcess/graphics/ScopedWebGLRenderingResourcesRequest.cpp:
+    (WebKit::ScopedWebGLRenderingResourcesRequest::scheduleFreeWebGLRenderingResources):
+    (WebKit::ScopedWebGLRenderingResourcesRequest::freeWebGLRenderingResources):
+    * GPUProcess/graphics/ScopedWebGLRenderingResourcesRequest.h:
+    * GPUProcess/graphics/ScopedWebGLRenderingResourcesRequestCocoa.cpp: Removed.
+    (WebKit::ScopedWebGLRenderingResourcesRequest::scheduleFreeWebGLRenderingResources): Deleted.
+    (WebKit::ScopedWebGLRenderingResourcesRequest::freeWebGLRenderingResources): Deleted.
+    * SourcesCocoa.txt:
+    * WebKit.xcodeproj/project.pbxproj:
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@283703 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-10-07  Kimmo Kinnunen  <kkinnunen@apple.com>
+
+            ScopedEGLDefaultDisplay should be removed
+            https://bugs.webkit.org/show_bug.cgi?id=231011
+
+            Reviewed by Kenneth Russell.
+
+            Hard-coding the code to EGL_DEFAULT_DISPLAY only and using the scoped
+            holder is making the EGLDisplays harder to use than neccessary. The
+            implementation target, e.g. the ability to call EGLTerminate, was also a bit
+            more convoluted than needed.
+
+            Move the "call EGLTerminate" logic from a bit convoluted refcount mechanism
+            in ScopedEGLDefaultDisplay to the explicit GraphicsContextGLOpenGL::releaseResources().
+            The callers are expected to do the refcounting anyway, as the existing client
+            WebKit::ScopedWebGLRenderingResourcesRequest already did.
+
+            Make GraphicsContextGLOpenGL::releaseResources() available on all platforms.
+            It is implemented on all ANGLE implementations.
+            Platforms can augment the implementation by implementing
+            GraphicsContextGLOpenGL::platformReleaseResources(). For Cocoa, this function
+            resets the currentContext cache that is used to optimize making context current.
+
+            No new tests, refactor.
+
+            * CMakeLists.txt:
+            * Headers.cmake:
+            * PlatformMac.cmake:
+            * SourcesCocoa.txt:
+            * WebCore.xcodeproj/project.pbxproj:
+            * platform/graphics/angle/ANGLEUtilities.cpp: Renamed from Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLEEGLUtilities.h.
+            (WebCore::platformIsANGLEAvailable):
+            * platform/graphics/angle/ANGLEUtilities.h: Renamed from Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLEUtilities.h.
+            Rename GraphicsContextGLANGLEUtilities to simpler and more descriptive ANGLEUtilities.
+            Add the isANGLEAvailable to there.
+
+            * platform/graphics/angle/GraphicsContextGLANGLE.cpp:
+            (WebCore::GraphicsContextGLOpenGL::releaseResources):
+            (WebCore::GraphicsContextGLOpenGL::platformReleaseResources):
+            * platform/graphics/angle/GraphicsContextGLANGLEEGLUtilities.cpp: Removed.
+            (WebCore::refDefaultDisplay): Deleted.
+            (WebCore::unrefDefaultDisplayIfNeeded): Deleted.
+            (WebCore::ScopedEGLDefaultDisplay::operator=): Deleted.
+            (WebCore::ScopedEGLDefaultDisplay::ScopedEGLDefaultDisplay): Deleted.
+            (WebCore::ScopedEGLDefaultDisplay::~ScopedEGLDefaultDisplay): Deleted.
+            (WebCore::ScopedEGLDefaultDisplay::releaseAllResourcesIfUnused): Deleted.
+            * platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm:
+            (WebCore::platformIsANGLEAvailable):
+            (WebCore::initializeEGLDisplay):
+            (WebCore::GraphicsContextGLOpenGL::platformReleaseResources):
+            (WebCore::isANGLEAvailable): Deleted.
+            (WebCore::GraphicsContextGLOpenGL::releaseCurrentContext): Deleted.
+            (WebCore::GraphicsContextGLOpenGL::releaseAllResourcesIfUnused): Deleted.
+            * platform/graphics/opengl/GraphicsContextGLOpenGL.cpp:
+            (WebCore::GraphicsContextGLOpenGL::releaseResources):
+            (WebCore::GraphicsContextGLOpenGL::platformReleaseResources):
+            * platform/graphics/opengl/GraphicsContextGLOpenGL.h:
+            * platform/ios/wak/WebCoreThread.mm:
+
+2021-10-26  Russell Epstein  <repstein@apple.com>
+
</ins><span class="cx">         Cherry-pick r283301. rdar://problem/84629308
</span><span class="cx"> 
</span><span class="cx">     GPUP Cocoa GraphicsContextGLOpenGL should check for ANGLE presence
</span></span></pre></div>
<a id="branchessafari612branchSourceWebCoreHeaderscmake"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebCore/Headers.cmake (284952 => 284953)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebCore/Headers.cmake  2021-10-27 21:06:06 UTC (rev 284952)
+++ branches/safari-612-branch/Source/WebCore/Headers.cmake     2021-10-27 21:06:12 UTC (rev 284953)
</span><span class="lines">@@ -1357,8 +1357,8 @@
</span><span class="cx">     platform/graphics/WindRule.h
</span><span class="cx"> 
</span><span class="cx">     platform/graphics/angle/ANGLEHeaders.h
</span><ins>+    platform/graphics/angle/ANGLEUtilities.h
</ins><span class="cx">     platform/graphics/angle/ExtensionsGLANGLE.h
</span><del>-    platform/graphics/angle/GraphicsContextGLANGLEUtilities.h
</del><span class="cx"> 
</span><span class="cx">     platform/graphics/displaylists/DisplayList.h
</span><span class="cx">     platform/graphics/displaylists/DisplayListDrawGlyphsRecorder.h
</span></span></pre></div>
<a id="branchessafari612branchSourceWebCorePlatformMaccmake"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebCore/PlatformMac.cmake (284952 => 284953)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebCore/PlatformMac.cmake      2021-10-27 21:06:06 UTC (rev 284952)
+++ branches/safari-612-branch/Source/WebCore/PlatformMac.cmake 2021-10-27 21:06:12 UTC (rev 284953)
</span><span class="lines">@@ -602,7 +602,7 @@
</span><span class="cx">     platform/graphics/MIMETypeCache.h
</span><span class="cx">     platform/graphics/Model.h
</span><span class="cx"> 
</span><del>-    platform/graphics/angle/GraphicsContextGLANGLEEGLUtilities.h
</del><ins>+    platform/graphics/angle/ANGLEUtilities.h
</ins><span class="cx"> 
</span><span class="cx">     platform/graphics/avfoundation/AudioSourceProviderAVFObjC.h
</span><span class="cx">     platform/graphics/avfoundation/MediaPlaybackTargetCocoa.h
</span></span></pre></div>
<a id="branchessafari612branchSourceWebCoreSourcesCocoatxt"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebCore/SourcesCocoa.txt (284952 => 284953)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebCore/SourcesCocoa.txt       2021-10-27 21:06:06 UTC (rev 284952)
+++ branches/safari-612-branch/Source/WebCore/SourcesCocoa.txt  2021-10-27 21:06:12 UTC (rev 284953)
</span><span class="lines">@@ -595,7 +595,7 @@
</span><span class="cx"> // The following files aren't unified with others to prevent them from being merged
</span><span class="cx"> // with files that use the system OpenGL.
</span><span class="cx"> 
</span><ins>+platform/graphics/angle/ANGLEUtilities.cpp @no-unify
</ins><span class="cx"> platform/graphics/angle/ExtensionsGLANGLE.cpp @no-unify
</span><span class="cx"> platform/graphics/angle/GraphicsContextGLANGLE.cpp @no-unify
</span><del>-platform/graphics/angle/GraphicsContextGLANGLEEGLUtilities.cpp @no-unify
</del><span class="cx"> platform/graphics/angle/TemporaryANGLESetting.cpp @no-unify
</span></span></pre></div>
<a id="branchessafari612branchSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj (284952 => 284953)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj      2021-10-27 21:06:06 UTC (rev 284952)
+++ branches/safari-612-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-10-27 21:06:12 UTC (rev 284953)
</span><span class="lines">@@ -2318,13 +2318,11 @@
</span><span class="cx">          7AF9B20F18CFB5F400C64BEF /* JSVTTRegionList.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AF9B20B18CFB5F300C64BEF /* JSVTTRegionList.h */; };
</span><span class="cx">          7B10339E2549721700C8C1AC /* GraphicsContextGLCV.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B10339D2549720100C8C1AC /* GraphicsContextGLCV.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">          7B10339F2549721E00C8C1AC /* GraphicsContextGLCVANGLE.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B10339C2549720100C8C1AC /* GraphicsContextGLCVANGLE.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><del>-               7B45AB5025FB93BE00FD27F4 /* GraphicsContextGLANGLEEGLUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7B774C6225FB93550091395F /* GraphicsContextGLANGLEEGLUtilities.cpp */; };
-               7B45AB5525FBA9DE00FD27F4 /* GraphicsContextGLANGLEEGLUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B45AB5425FBA9DD00FD27F4 /* GraphicsContextGLANGLEEGLUtilities.h */; settings = {ATTRIBUTES = (Private, ); }; };
</del><ins>+                7B6094DD270C44BD0064835C /* ANGLEUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BB34A1625345CB200029D08 /* ANGLEUtilities.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">           7B6DC81925712E9200380C70 /* GraphicsContextGLIOSurfaceSwapChain.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B6DC81725712E9200380C70 /* GraphicsContextGLIOSurfaceSwapChain.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">          7B7311FB25C092B7003B2796 /* ScopedHighPerformanceGPURequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B7311FA25C092B7003B2796 /* ScopedHighPerformanceGPURequest.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">          7B8ED5F026F0C13D008AC023 /* CVUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B8ED5ED26F0C123008AC023 /* CVUtilities.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">          7B90417025501142006EEB8C /* RemoteGraphicsContextGLProxyBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B90416E25501109006EEB8C /* RemoteGraphicsContextGLProxyBase.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><del>-               7BB34A1725345CB200029D08 /* GraphicsContextGLANGLEUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BB34A1625345CB200029D08 /* GraphicsContextGLANGLEUtilities.h */; settings = {ATTRIBUTES = (Private, ); }; };
</del><span class="cx">           7BB34A48253776CA00029D08 /* GraphicsContextGLImageExtractor.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BB34A45253776C600029D08 /* GraphicsContextGLImageExtractor.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">          7BB680BA25BA1BE4002B8738 /* GraphicsChecksMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BB680B825BA1BE4002B8738 /* GraphicsChecksMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">          7BE7427381FA906FBB4F0F2C /* JSSVGGraphicsElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 950C4C02BED8936F818E2F99 /* JSSVGGraphicsElement.h */; };
</span><span class="lines">@@ -10463,20 +10461,19 @@
</span><span class="cx">          7B10339A2549720000C8C1AC /* GraphicsContextGLCVANGLE.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContextGLCVANGLE.cpp; sourceTree = "<group>"; };
</span><span class="cx">          7B10339C2549720100C8C1AC /* GraphicsContextGLCVANGLE.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GraphicsContextGLCVANGLE.h; sourceTree = "<group>"; };
</span><span class="cx">          7B10339D2549720100C8C1AC /* GraphicsContextGLCV.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GraphicsContextGLCV.h; sourceTree = "<group>"; };
</span><del>-               7B45AB5425FBA9DD00FD27F4 /* GraphicsContextGLANGLEEGLUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphicsContextGLANGLEEGLUtilities.h; sourceTree = "<group>"; };
</del><span class="cx">           7B64C0B4254C3B160006B4AF /* RemoteGraphicsContextGLProxyBaseCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = RemoteGraphicsContextGLProxyBaseCocoa.mm; sourceTree = "<group>"; };
</span><span class="cx">          7B6DC81525712E9100380C70 /* GraphicsContextGLIOSurfaceSwapChain.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContextGLIOSurfaceSwapChain.cpp; sourceTree = "<group>"; };
</span><span class="cx">          7B6DC81725712E9200380C70 /* GraphicsContextGLIOSurfaceSwapChain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphicsContextGLIOSurfaceSwapChain.h; sourceTree = "<group>"; };
</span><span class="cx">          7B7311FA25C092B7003B2796 /* ScopedHighPerformanceGPURequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScopedHighPerformanceGPURequest.h; sourceTree = "<group>"; };
</span><del>-               7B774C6225FB93550091395F /* GraphicsContextGLANGLEEGLUtilities.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContextGLANGLEEGLUtilities.cpp; sourceTree = "<group>"; };
</del><span class="cx">           7B8ED5ED26F0C123008AC023 /* CVUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CVUtilities.h; sourceTree = "<group>"; };
</span><span class="cx">          7B8ED5EF26F0C123008AC023 /* CVUtilities.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CVUtilities.mm; sourceTree = "<group>"; };
</span><span class="cx">          7B90416E25501109006EEB8C /* RemoteGraphicsContextGLProxyBase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteGraphicsContextGLProxyBase.h; sourceTree = "<group>"; };
</span><del>-               7BB34A1625345CB200029D08 /* GraphicsContextGLANGLEUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphicsContextGLANGLEUtilities.h; sourceTree = "<group>"; };
</del><ins>+                7BB34A1625345CB200029D08 /* ANGLEUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ANGLEUtilities.h; sourceTree = "<group>"; };
</ins><span class="cx">           7BB34A45253776C600029D08 /* GraphicsContextGLImageExtractor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GraphicsContextGLImageExtractor.h; sourceTree = "<group>"; };
</span><span class="cx">          7BB34A47253776C700029D08 /* GraphicsContextGLImageExtractor.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContextGLImageExtractor.cpp; sourceTree = "<group>"; };
</span><span class="cx">          7BB680B725BA1BE3002B8738 /* GraphicsChecksMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsChecksMac.cpp; sourceTree = "<group>"; };
</span><span class="cx">          7BB680B825BA1BE4002B8738 /* GraphicsChecksMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphicsChecksMac.h; sourceTree = "<group>"; };
</span><ins>+               7BCD42D8270599EF00EB2127 /* ANGLEUtilities.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ANGLEUtilities.cpp; sourceTree = "<group>"; };
</ins><span class="cx">           7BCD42DA2705C94900EB2127 /* ANGLEUtilitiesCocoa.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ANGLEUtilitiesCocoa.cpp; sourceTree = "<group>"; };
</span><span class="cx">          7BCD42DC2705C94900EB2127 /* ANGLEUtilitiesCocoa.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ANGLEUtilitiesCocoa.h; sourceTree = "<group>"; };
</span><span class="cx">          7BE7265B25763B8D00E85D98 /* RemoteGraphicsContextGLProxyBase.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteGraphicsContextGLProxyBase.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -22288,12 +22285,11 @@
</span><span class="cx">                  isa = PBXGroup;
</span><span class="cx">                  children = (
</span><span class="cx">                          27E3C806257F5E6E00C986AB /* ANGLEHeaders.h */,
</span><ins>+                               7BCD42D8270599EF00EB2127 /* ANGLEUtilities.cpp */,
+                               7BB34A1625345CB200029D08 /* ANGLEUtilities.h */,
</ins><span class="cx">                           6E27F243229C9F8400F1F632 /* ExtensionsGLANGLE.cpp */,
</span><span class="cx">                          6E27F244229C9F8D00F1F632 /* ExtensionsGLANGLE.h */,
</span><span class="cx">                          6E27F2422298CE4B00F1F632 /* GraphicsContextGLANGLE.cpp */,
</span><del>-                               7B774C6225FB93550091395F /* GraphicsContextGLANGLEEGLUtilities.cpp */,
-                               7B45AB5425FBA9DD00FD27F4 /* GraphicsContextGLANGLEEGLUtilities.h */,
-                               7BB34A1625345CB200029D08 /* GraphicsContextGLANGLEUtilities.h */,
</del><span class="cx">                           6E290861229DB950000986E2 /* TemporaryANGLESetting.cpp */,
</span><span class="cx">                          6E290863229DB970000986E2 /* TemporaryANGLESetting.h */,
</span><span class="cx">                  );
</span><span class="lines">@@ -31007,7 +31003,7 @@
</span><span class="cx">                          E7E0357224D4E196008DFEFB /* AnalyserOptions.h in Headers */,
</span><span class="cx">                          27E3C808257F5E6E00C986AB /* ANGLEHeaders.h in Headers */,
</span><span class="cx">                          31A795C71888BCB200382F90 /* ANGLEInstancedArrays.h in Headers */,
</span><del>-                               7BB34A1725345CB200029D08 /* ANGLEUtilities.h in Headers */,
</del><ins>+                                7B6094DD270C44BD0064835C /* ANGLEUtilities.h in Headers */,
</ins><span class="cx">                           49E912AB0EFAC906009D0CAF /* Animation.h in Headers */,
</span><span class="cx">                          71EFCEDC202B38A900D7C411 /* AnimationEffect.h in Headers */,
</span><span class="cx">                          71E2C42621C935280024F8C8 /* AnimationEffectPhase.h in Headers */,
</span><span class="lines">@@ -32225,7 +32221,6 @@
</span><span class="cx">                          B2A015A90AF6CD53006BCE0E /* GraphicsContext.h in Headers */,
</span><span class="cx">                          934907E4125BBBC8007F23A0 /* GraphicsContextCG.h in Headers */,
</span><span class="cx">                          313DE87023A96973008FC47B /* GraphicsContextGL.h in Headers */,
</span><del>-                               7B45AB5525FBA9DE00FD27F4 /* GraphicsContextGLANGLEEGLUtilities.h in Headers */,
</del><span class="cx">                           7C330A021DF8FAC600D3395C /* GraphicsContextGLAttributes.h in Headers */,
</span><span class="cx">                          7B10339E2549721700C8C1AC /* GraphicsContextGLCV.h in Headers */,
</span><span class="cx">                          7B10339F2549721E00C8C1AC /* GraphicsContextGLCVANGLE.h in Headers */,
</span><span class="lines">@@ -36068,7 +36063,6 @@
</span><span class="cx">                          51A9D9E9195B931F001B2B5C /* GamepadManager.cpp in Sources */,
</span><span class="cx">                          837964CF1F8DB69D00218EA0 /* GeolocationPositionDataIOS.mm in Sources */,
</span><span class="cx">                          6E72F54E229DCD1000B3E151 /* GraphicsContextGLANGLE.cpp in Sources */,
</span><del>-                               7B45AB5025FB93BE00FD27F4 /* GraphicsContextGLANGLEEGLUtilities.cpp in Sources */,
</del><span class="cx">                           7C3E510B18DF8F3500C112F7 /* HTMLConverter.mm in Sources */,
</span><span class="cx">                          A8D06B3A0A265DCD005E7203 /* HTMLNames.cpp in Sources */,
</span><span class="cx">                          1AC900C31943C0FC008625B5 /* HTTPHeaderNames.cpp in Sources */,
</span></span></pre></div>
<a id="branchessafari612branchSourceWebCoreplatformgraphicsangleANGLEUtilitiescppfromrev284952branchessafari612branchSourceWebCoreplatformgraphicsangleGraphicsContextGLANGLEEGLUtilitiesh"></a>
<div class="copfile"><h4>Copied: branches/safari-612-branch/Source/WebCore/platform/graphics/angle/ANGLEUtilities.cpp (from rev 284952, branches/safari-612-branch/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLEEGLUtilities.h) (0 => 284953)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebCore/platform/graphics/angle/ANGLEUtilities.cpp                             (rev 0)
+++ branches/safari-612-branch/Source/WebCore/platform/graphics/angle/ANGLEUtilities.cpp        2021-10-27 21:06:12 UTC (rev 284953)
</span><span class="lines">@@ -0,0 +1,42 @@
</span><ins>+/*
+ * 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. ``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
+ * 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 "ANGLEUtilities.h"
+
+#if ENABLE(WEBGL) && USE(ANGLE)
+
+namespace WebCore {
+
+#if !PLATFORM(COCOA)
+bool platformIsANGLEAvailable()
+{
+    return true;
+}
+#endif
+
+}
+
+#endif
</ins></span></pre></div>
<a id="branchessafari612branchSourceWebCoreplatformgraphicsangleANGLEUtilitieshfromrev284952branchessafari612branchSourceWebCoreplatformgraphicsangleGraphicsContextGLANGLEUtilitiesh"></a>
<div class="copfile"><h4>Copied: branches/safari-612-branch/Source/WebCore/platform/graphics/angle/ANGLEUtilities.h (from rev 284952, branches/safari-612-branch/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLEUtilities.h) (0 => 284953)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebCore/platform/graphics/angle/ANGLEUtilities.h                               (rev 0)
+++ branches/safari-612-branch/Source/WebCore/platform/graphics/angle/ANGLEUtilities.h  2021-10-27 21:06:12 UTC (rev 284953)
</span><span class="lines">@@ -0,0 +1,247 @@
</span><ins>+/*
+ * Copyright (C) 2020 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. ``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
+ * 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 ENABLE(WEBGL) && USE(ANGLE)
+
+#include "ANGLEHeaders.h"
+#include "GraphicsTypesGL.h"
+#include <wtf/Noncopyable.h>
+
+namespace WebCore {
+
+class ScopedRestoreTextureBinding {
+    WTF_MAKE_NONCOPYABLE(ScopedRestoreTextureBinding);
+public:
+    ScopedRestoreTextureBinding(GLenum bindingPointQuery, GLenum bindingPoint, bool condition = true)
+    {
+        ASSERT(bindingPoint != static_cast<GLenum>(0u));
+        if (condition) {
+            m_bindingPoint = bindingPoint;
+            gl::GetIntegerv(bindingPointQuery, reinterpret_cast<GLint*>(&m_bindingValue));
+        }
+    }
+
+    ~ScopedRestoreTextureBinding()
+    {
+        if (m_bindingPoint)
+            gl::BindTexture(m_bindingPoint, m_bindingValue);
+    }
+
+private:
+    GLenum m_bindingPoint { 0 };
+    GLuint m_bindingValue { 0u };
+};
+
+
+class ScopedBufferBinding {
+    WTF_MAKE_NONCOPYABLE(ScopedBufferBinding);
+public:
+    ScopedBufferBinding(GLenum bindingPoint, GLuint bindingValue, bool condition = true)
+    {
+        if (!condition)
+            return;
+        gl::GetIntegerv(query(bindingPoint), reinterpret_cast<GLint*>(&m_bindingValue));
+        if (bindingValue == m_bindingValue)
+            return;
+        m_bindingPoint = bindingPoint;
+        gl::BindBuffer(m_bindingPoint, bindingValue);
+    }
+
+    ~ScopedBufferBinding()
+    {
+        if (m_bindingPoint)
+            gl::BindBuffer(m_bindingPoint, m_bindingValue);
+    }
+
+private:
+    static constexpr GLenum query(GLenum bindingPoint)
+    {
+        if (bindingPoint == GL_PIXEL_PACK_BUFFER)
+            return GL_PIXEL_PACK_BUFFER_BINDING;
+        ASSERT(bindingPoint == GL_PIXEL_UNPACK_BUFFER);
+        return GL_PIXEL_UNPACK_BUFFER_BINDING;
+    }
+    GLint m_bindingPoint { 0 };
+    GLuint m_bindingValue { 0u };
+};
+class ScopedRestoreReadFramebufferBinding {
+    WTF_MAKE_NONCOPYABLE(ScopedRestoreReadFramebufferBinding);
+public:
+    ScopedRestoreReadFramebufferBinding(bool isForWebGL2, GLuint restoreValue)
+        : m_framebufferTarget(isForWebGL2 ? GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER)
+        , m_bindingValue(restoreValue)
+    {
+    }
+    ScopedRestoreReadFramebufferBinding(bool isForWebGL2, GLuint restoreValue, GLuint value)
+        : m_framebufferTarget(isForWebGL2 ? GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER)
+        , m_bindingValue(restoreValue)
+    {
+        bindFramebuffer(value);
+    }
+    void markBindingChanged()
+    {
+        m_bindingChanged = true;
+    }
+    void bindFramebuffer(GLuint bindingValue)
+    {
+        if (!m_bindingChanged && m_bindingValue == bindingValue)
+            return;
+        gl::BindFramebuffer(m_framebufferTarget, bindingValue);
+        m_bindingChanged = m_bindingValue != bindingValue;
+    }
+    GLuint framebufferTarget() const { return m_framebufferTarget; }
+    ~ScopedRestoreReadFramebufferBinding()
+    {
+        if (m_bindingChanged)
+            gl::BindFramebuffer(m_framebufferTarget, m_bindingValue);
+    }
+private:
+    const GLenum m_framebufferTarget;
+    GLuint m_bindingValue { 0u };
+    bool m_bindingChanged { false };
+};
+
+class ScopedPixelStorageMode {
+    WTF_MAKE_NONCOPYABLE(ScopedPixelStorageMode);
+public:
+    explicit ScopedPixelStorageMode(GLenum name, bool condition = true)
+        : m_name(condition ? name : 0)
+    {
+        if (m_name)
+            gl::GetIntegerv(m_name, &m_originalValue);
+    }
+    ScopedPixelStorageMode(GLenum name, GLint value, bool condition = true)
+        : m_name(condition ? name : 0)
+    {
+        if (m_name) {
+            gl::GetIntegerv(m_name, &m_originalValue);
+            pixelStore(value);
+        }
+    }
+    ~ScopedPixelStorageMode()
+    {
+        if (m_name && m_valueChanged)
+            gl::PixelStorei(m_name, m_originalValue);
+    }
+    void pixelStore(GLint value)
+    {
+        ASSERT(m_name);
+        if (!m_valueChanged && m_originalValue == value)
+            return;
+        gl::PixelStorei(m_name, value);
+        m_valueChanged = m_originalValue != value;
+    }
+    operator GLint() const
+    {
+        ASSERT(m_name && !m_valueChanged);
+        return m_originalValue;
+    }
+private:
+    const GLenum m_name;
+    bool m_valueChanged { false };
+    GLint m_originalValue { 0 };
+};
+
+class ScopedTexture {
+    WTF_MAKE_NONCOPYABLE(ScopedTexture);
+public:
+    ScopedTexture()
+    {
+        gl::GenTextures(1, &m_object);
+    }
+    ~ScopedTexture()
+    {
+        gl::DeleteTextures(1, &m_object);
+    }
+    operator GLuint() const
+    {
+        return m_object;
+    }
+private:
+    GLuint m_object { 0u };
+};
+
+class ScopedFramebuffer {
+    WTF_MAKE_NONCOPYABLE(ScopedFramebuffer);
+public:
+    ScopedFramebuffer()
+    {
+        gl::GenFramebuffers(1, &m_object);
+    }
+    ~ScopedFramebuffer()
+    {
+        gl::DeleteFramebuffers(1, &m_object);
+    }
+    operator GLuint() const
+    {
+        return m_object;
+    }
+private:
+    GLuint m_object { 0 };
+};
+
+class ScopedGLFence {
+    WTF_MAKE_NONCOPYABLE(ScopedGLFence);
+public:
+    ScopedGLFence() = default;
+    ScopedGLFence(ScopedGLFence&& other)
+        : m_object(std::exchange(other.m_object, { }))
+    {
+    }
+    ~ScopedGLFence() { reset(); }
+    ScopedGLFence& operator=(ScopedGLFence&& other)
+    {
+        if (this != &other) {
+            reset();
+            m_object = std::exchange(other.m_object, { });
+        }
+        return *this;
+    }
+    void reset()
+    {
+        if (m_object) {
+            gl::DeleteSync(m_object);
+            m_object = { };
+        }
+    }
+    void abandon() { m_object = { }; }
+    void fenceSync()
+    {
+        reset();
+        m_object = gl::FenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
+    }
+    operator GLsync() const { return m_object; }
+    operator bool() const { return m_object; }
+private:
+    GLsync m_object { };
+};
+
+bool platformIsANGLEAvailable();
+
+}
+
+#endif
</ins></span></pre></div>
<a id="branchessafari612branchSourceWebCoreplatformgraphicsangleGraphicsContextGLANGLEcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp (284952 => 284953)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp     2021-10-27 21:06:06 UTC (rev 284952)
+++ branches/safari-612-branch/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp        2021-10-27 21:06:12 UTC (rev 284953)
</span><span class="lines">@@ -30,8 +30,8 @@
</span><span class="cx"> #include "GraphicsContextGL.h"
</span><span class="cx"> 
</span><span class="cx"> #include "ANGLEHeaders.h"
</span><ins>+#include "ANGLEUtilities.h"
</ins><span class="cx"> #include "ExtensionsGLANGLE.h"
</span><del>-#include "GraphicsContextGLANGLEUtilities.h"
</del><span class="cx"> #include "GraphicsContextGLOpenGL.h"
</span><span class="cx"> #include "ImageBuffer.h"
</span><span class="cx"> #include "IntRect.h"
</span><span class="lines">@@ -75,6 +75,49 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+bool GraphicsContextGLOpenGL::releaseThreadResources(ReleaseThreadResourceBehavior releaseBehavior)
+{
+    platformReleaseThreadResources();
+
+    if (!platformIsANGLEAvailable())
+        return false;
+
+    // Unset the EGL current context, since the next access might be from another thread, and the
+    // context cannot be current on multiple threads.
+    if (releaseBehavior == ReleaseThreadResourceBehavior::ReleaseCurrentContext) {
+        if (EGL_GetCurrentContext() == EGL_NO_CONTEXT)
+            return true;
+        // At the time of writing, ANGLE does not flush on MakeCurrent. Since we are
+        // potentially switching threads, we should flush.
+        // Note: Here we assume also that ANGLE has only one platform context -- otherwise
+        // we would need to flush each EGL context that has been used.
+        gl::Flush();
+        EGLDisplay display = EGL_GetDisplay(EGL_DEFAULT_DISPLAY);
+        if (display == EGL_NO_DISPLAY)
+            return true;
+        return EGL_MakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+    }
+    if (releaseBehavior == ReleaseThreadResourceBehavior::TerminateAndReleaseThreadResources) {
+        EGLDisplay display = EGL_GetDisplay(EGL_DEFAULT_DISPLAY);
+        if (display != EGL_NO_DISPLAY) {
+            if (EGL_GetCurrentContext() != EGL_NO_CONTEXT) {
+                ASSERT_NOT_REACHED(); // All resources must have been destroyed.
+                EGL_MakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+            }
+            EGL_Terminate(display);
+        }
+    }
+    // Called when we do not know if we will ever see another call from this thread again.
+    // Unset the EGL current context by releasing whole EGL thread state.
+    return EGL_ReleaseThread();
+}
+
+#if !PLATFORM(COCOA)
+void GraphicsContextGLOpenGL::platformReleaseThreadResources()
+{
+}
+#endif
+
</ins><span class="cx"> std::optional<PixelBuffer> GraphicsContextGLOpenGL::readPixelsForPaintResults()
</span><span class="cx"> {
</span><span class="cx">     PixelBufferFormat format { AlphaPremultiplication::Unpremultiplied, PixelFormat::RGBA8, DestinationColorSpace::SRGB() };
</span></span></pre></div>
<a id="branchessafari612branchSourceWebCoreplatformgraphicsangleGraphicsContextGLANGLEEGLUtilitiescpp"></a>
<div class="delfile"><h4>Deleted: branches/safari-612-branch/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLEEGLUtilities.cpp (284952 => 284953)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLEEGLUtilities.cpp 2021-10-27 21:06:06 UTC (rev 284952)
+++ branches/safari-612-branch/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLEEGLUtilities.cpp    2021-10-27 21:06:12 UTC (rev 284953)
</span><span class="lines">@@ -1,91 +0,0 @@
</span><del>-/*
- * 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. ``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
- * 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 "GraphicsContextGLANGLEEGLUtilities.h"
-
-#include "ANGLEHeaders.h"
-#include <wtf/Assertions.h>
-
-#if ENABLE(WEBGL) && USE(ANGLE)
-
-namespace WebCore {
-
-static unsigned defaultDisplayRefCount;
-static void* defaultDisplay = nullptr;
-
-static void refDefaultDisplay(void* display)
-{
-    ASSERT(display != nullptr);
-    ASSERT(defaultDisplay == display || (!defaultDisplay && !defaultDisplayRefCount));
-    defaultDisplayRefCount++;
-    defaultDisplay = display;
-}
-
-static void unrefDefaultDisplayIfNeeded(void* display)
-{
-    if (!display)
-        return;
-    ASSERT(defaultDisplay == display);
-    ASSERT(defaultDisplayRefCount);
-    defaultDisplayRefCount--;
-}
-
-ScopedEGLDefaultDisplay& ScopedEGLDefaultDisplay::operator=(ScopedEGLDefaultDisplay&& other)
-{
-    if (this != &other) {
-        unrefDefaultDisplayIfNeeded(m_display);
-        m_display = std::exchange(other.m_display, nullptr);
-    }
-    return *this;
-}
-
-ScopedEGLDefaultDisplay::ScopedEGLDefaultDisplay(void* display)
-    : m_display(display)
-{
-    refDefaultDisplay(m_display);
-}
-
-ScopedEGLDefaultDisplay::~ScopedEGLDefaultDisplay()
-{
-    unrefDefaultDisplayIfNeeded(m_display);
-}
-
-void ScopedEGLDefaultDisplay::releaseAllResourcesIfUnused()
-{
-    if (defaultDisplayRefCount)
-        return;
-    if (defaultDisplay == nullptr)
-        return;
-    bool result = EGL_Terminate(defaultDisplay);
-    ASSERT_UNUSED(result, result);
-    result = EGL_ReleaseThread();
-    ASSERT_UNUSED(result, result);
-    defaultDisplay = nullptr;
-}
-
-}
-
-#endif
</del></span></pre></div>
<a id="branchessafari612branchSourceWebCoreplatformgraphicsangleGraphicsContextGLANGLEEGLUtilitiesh"></a>
<div class="delfile"><h4>Deleted: branches/safari-612-branch/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLEEGLUtilities.h (284952 => 284953)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLEEGLUtilities.h   2021-10-27 21:06:06 UTC (rev 284952)
+++ branches/safari-612-branch/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLEEGLUtilities.h      2021-10-27 21:06:12 UTC (rev 284953)
</span><span class="lines">@@ -1,62 +0,0 @@
</span><del>-/*
- * Copyright (C) 2020 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. ``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
- * 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 ENABLE(WEBGL) && USE(ANGLE)
-
-#include <algorithm>
-#include <wtf/Noncopyable.h>
-
-// Currently this not using ANGLE headers since this is exported header and we do not export ANGLE headers.
-
-namespace WebCore {
-
-class ScopedEGLDefaultDisplay {
-    WTF_MAKE_NONCOPYABLE(ScopedEGLDefaultDisplay);
-public:
-    static ScopedEGLDefaultDisplay adoptInitializedDisplay(void* display)
-    {
-        ASSERT(display != nullptr);
-        return ScopedEGLDefaultDisplay(display);
-    }
-    ScopedEGLDefaultDisplay() = default;
-    ScopedEGLDefaultDisplay(ScopedEGLDefaultDisplay&& other)
-        : m_display(std::exchange(other.m_display, nullptr))
-    {
-    }
-    ~ScopedEGLDefaultDisplay();
-    ScopedEGLDefaultDisplay& operator=(ScopedEGLDefaultDisplay&&);
-    operator void*() const { return m_display; }
-    operator bool() const { return m_display != nullptr; }
-    static void releaseAllResourcesIfUnused();
-private:
-    ScopedEGLDefaultDisplay(void*);
-    void* m_display { nullptr };
-};
-
-}
-
-#endif
</del></span></pre></div>
<a id="branchessafari612branchSourceWebCoreplatformgraphicsangleGraphicsContextGLANGLEUtilitiesh"></a>
<div class="delfile"><h4>Deleted: branches/safari-612-branch/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLEUtilities.h (284952 => 284953)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLEUtilities.h      2021-10-27 21:06:06 UTC (rev 284952)
+++ branches/safari-612-branch/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLEUtilities.h 2021-10-27 21:06:12 UTC (rev 284953)
</span><span class="lines">@@ -1,245 +0,0 @@
</span><del>-/*
- * Copyright (C) 2020 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. ``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
- * 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 ENABLE(WEBGL) && USE(ANGLE)
-
-#include "ANGLEHeaders.h"
-#include "GraphicsTypesGL.h"
-#include <wtf/Noncopyable.h>
-
-namespace WebCore {
-
-class ScopedRestoreTextureBinding {
-    WTF_MAKE_NONCOPYABLE(ScopedRestoreTextureBinding);
-public:
-    ScopedRestoreTextureBinding(GLenum bindingPointQuery, GLenum bindingPoint, bool condition = true)
-    {
-        ASSERT(bindingPoint != static_cast<GLenum>(0u));
-        if (condition) {
-            m_bindingPoint = bindingPoint;
-            gl::GetIntegerv(bindingPointQuery, reinterpret_cast<GLint*>(&m_bindingValue));
-        }
-    }
-
-    ~ScopedRestoreTextureBinding()
-    {
-        if (m_bindingPoint)
-            gl::BindTexture(m_bindingPoint, m_bindingValue);
-    }
-
-private:
-    GLenum m_bindingPoint { 0 };
-    GLuint m_bindingValue { 0u };
-};
-
-
-class ScopedBufferBinding {
-    WTF_MAKE_NONCOPYABLE(ScopedBufferBinding);
-public:
-    ScopedBufferBinding(GLenum bindingPoint, GLuint bindingValue, bool condition = true)
-    {
-        if (!condition)
-            return;
-        gl::GetIntegerv(query(bindingPoint), reinterpret_cast<GLint*>(&m_bindingValue));
-        if (bindingValue == m_bindingValue)
-            return;
-        m_bindingPoint = bindingPoint;
-        gl::BindBuffer(m_bindingPoint, bindingValue);
-    }
-
-    ~ScopedBufferBinding()
-    {
-        if (m_bindingPoint)
-            gl::BindBuffer(m_bindingPoint, m_bindingValue);
-    }
-
-private:
-    static constexpr GLenum query(GLenum bindingPoint)
-    {
-        if (bindingPoint == GL_PIXEL_PACK_BUFFER)
-            return GL_PIXEL_PACK_BUFFER_BINDING;
-        ASSERT(bindingPoint == GL_PIXEL_UNPACK_BUFFER);
-        return GL_PIXEL_UNPACK_BUFFER_BINDING;
-    }
-    GLint m_bindingPoint { 0 };
-    GLuint m_bindingValue { 0u };
-};
-class ScopedRestoreReadFramebufferBinding {
-    WTF_MAKE_NONCOPYABLE(ScopedRestoreReadFramebufferBinding);
-public:
-    ScopedRestoreReadFramebufferBinding(bool isForWebGL2, GLuint restoreValue)
-        : m_framebufferTarget(isForWebGL2 ? GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER)
-        , m_bindingValue(restoreValue)
-    {
-    }
-    ScopedRestoreReadFramebufferBinding(bool isForWebGL2, GLuint restoreValue, GLuint value)
-        : m_framebufferTarget(isForWebGL2 ? GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER)
-        , m_bindingValue(restoreValue)
-    {
-        bindFramebuffer(value);
-    }
-    void markBindingChanged()
-    {
-        m_bindingChanged = true;
-    }
-    void bindFramebuffer(GLuint bindingValue)
-    {
-        if (!m_bindingChanged && m_bindingValue == bindingValue)
-            return;
-        gl::BindFramebuffer(m_framebufferTarget, bindingValue);
-        m_bindingChanged = m_bindingValue != bindingValue;
-    }
-    GLuint framebufferTarget() const { return m_framebufferTarget; }
-    ~ScopedRestoreReadFramebufferBinding()
-    {
-        if (m_bindingChanged)
-            gl::BindFramebuffer(m_framebufferTarget, m_bindingValue);
-    }
-private:
-    const GLenum m_framebufferTarget;
-    GLuint m_bindingValue { 0u };
-    bool m_bindingChanged { false };
-};
-
-class ScopedPixelStorageMode {
-    WTF_MAKE_NONCOPYABLE(ScopedPixelStorageMode);
-public:
-    explicit ScopedPixelStorageMode(GLenum name, bool condition = true)
-        : m_name(condition ? name : 0)
-    {
-        if (m_name)
-            gl::GetIntegerv(m_name, &m_originalValue);
-    }
-    ScopedPixelStorageMode(GLenum name, GLint value, bool condition = true)
-        : m_name(condition ? name : 0)
-    {
-        if (m_name) {
-            gl::GetIntegerv(m_name, &m_originalValue);
-            pixelStore(value);
-        }
-    }
-    ~ScopedPixelStorageMode()
-    {
-        if (m_name && m_valueChanged)
-            gl::PixelStorei(m_name, m_originalValue);
-    }
-    void pixelStore(GLint value)
-    {
-        ASSERT(m_name);
-        if (!m_valueChanged && m_originalValue == value)
-            return;
-        gl::PixelStorei(m_name, value);
-        m_valueChanged = m_originalValue != value;
-    }
-    operator GLint() const
-    {
-        ASSERT(m_name && !m_valueChanged);
-        return m_originalValue;
-    }
-private:
-    const GLenum m_name;
-    bool m_valueChanged { false };
-    GLint m_originalValue { 0 };
-};
-
-class ScopedTexture {
-    WTF_MAKE_NONCOPYABLE(ScopedTexture);
-public:
-    ScopedTexture()
-    {
-        gl::GenTextures(1, &m_object);
-    }
-    ~ScopedTexture()
-    {
-        gl::DeleteTextures(1, &m_object);
-    }
-    operator GLuint() const
-    {
-        return m_object;
-    }
-private:
-    GLuint m_object { 0u };
-};
-
-class ScopedFramebuffer {
-    WTF_MAKE_NONCOPYABLE(ScopedFramebuffer);
-public:
-    ScopedFramebuffer()
-    {
-        gl::GenFramebuffers(1, &m_object);
-    }
-    ~ScopedFramebuffer()
-    {
-        gl::DeleteFramebuffers(1, &m_object);
-    }
-    operator GLuint() const
-    {
-        return m_object;
-    }
-private:
-    GLuint m_object { 0 };
-};
-
-class ScopedGLFence {
-    WTF_MAKE_NONCOPYABLE(ScopedGLFence);
-public:
-    ScopedGLFence() = default;
-    ScopedGLFence(ScopedGLFence&& other)
-        : m_object(std::exchange(other.m_object, { }))
-    {
-    }
-    ~ScopedGLFence() { reset(); }
-    ScopedGLFence& operator=(ScopedGLFence&& other)
-    {
-        if (this != &other) {
-            reset();
-            m_object = std::exchange(other.m_object, { });
-        }
-        return *this;
-    }
-    void reset()
-    {
-        if (m_object) {
-            gl::DeleteSync(m_object);
-            m_object = { };
-        }
-    }
-    void abandon() { m_object = { }; }
-    void fenceSync()
-    {
-        reset();
-        m_object = gl::FenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
-    }
-    operator GLsync() const { return m_object; }
-    operator bool() const { return m_object; }
-private:
-    GLsync m_object { };
-};
-
-}
-
-#endif
</del></span></pre></div>
<a id="branchessafari612branchSourceWebCoreplatformgraphicscocoaGraphicsContextGLOpenGLCocoamm"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm (284952 => 284953)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm        2021-10-27 21:06:06 UTC (rev 284952)
+++ branches/safari-612-branch/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm   2021-10-27 21:06:12 UTC (rev 284953)
</span><span class="lines">@@ -28,10 +28,10 @@
</span><span class="cx"> #if ENABLE(WEBGL)
</span><span class="cx"> #import "GraphicsContextGLOpenGL.h"
</span><span class="cx"> 
</span><ins>+#import "ANGLEUtilities.h"
</ins><span class="cx"> #import "ANGLEUtilitiesCocoa.h"
</span><span class="cx"> #import "CVUtilities.h"
</span><span class="cx"> #import "ExtensionsGLANGLE.h"
</span><del>-#import "GraphicsContextGLANGLEUtilities.h"
</del><span class="cx"> #import "GraphicsContextGLIOSurfaceSwapChain.h"
</span><span class="cx"> #import "GraphicsContextGLOpenGLManager.h"
</span><span class="cx"> #import "Logging.h"
</span><span class="lines">@@ -60,8 +60,10 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-static bool isANGLEAvailable()
</del><ins>+bool platformIsANGLEAvailable()
</ins><span class="cx"> {
</span><ins>+    // The ANGLE is weak linked in full, and the EGL_Initialize is explicitly weak linked above
+    // so that we can detect the case where ANGLE is not present.
</ins><span class="cx">     return !!EGL_Initialize;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -119,11 +121,11 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static ScopedEGLDefaultDisplay initializeEGLDisplay(const GraphicsContextGLAttributes& attrs)
</del><ins>+static EGLDisplay initializeEGLDisplay(const GraphicsContextGLAttributes& attrs)
</ins><span class="cx"> {
</span><del>-    if (!isANGLEAvailable()) {
</del><ins>+    if (!platformIsANGLEAvailable()) {
</ins><span class="cx">         WTFLogAlways("Failed to load ANGLE shared library.");
</span><del>-        return { };
</del><ins>+        return EGL_NO_DISPLAY;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     EGLint majorVersion = 0;
</span><span class="lines">@@ -166,7 +168,7 @@
</span><span class="cx"> 
</span><span class="cx">     if (EGL_Initialize(display, &majorVersion, &minorVersion) == EGL_FALSE) {
</span><span class="cx">         LOG(WebGL, "EGLDisplay Initialization failed.");
</span><del>-        return { };
</del><ins>+        return EGL_NO_DISPLAY;
</ins><span class="cx">     }
</span><span class="cx">     LOG(WebGL, "ANGLE initialised Major: %d Minor: %d", majorVersion, minorVersion);
</span><span class="cx">     if (shouldInitializeWithVolatileContextSupport) {
</span><span class="lines">@@ -175,7 +177,7 @@
</span><span class="cx">         ASSERT(checkVolatileContextSupportIfDeviceExists(display, "EGL_ANGLE_platform_device_context_volatile_eagl", "EGL_ANGLE_device_eagl", EGL_EAGL_CONTEXT_ANGLE));
</span><span class="cx">         ASSERT(checkVolatileContextSupportIfDeviceExists(display, "EGL_ANGLE_platform_device_context_volatile_cgl", "EGL_ANGLE_device_cgl", EGL_CGL_CONTEXT_ANGLE));
</span><span class="cx">     }
</span><del>-    return ScopedEGLDefaultDisplay::adoptInitializedDisplay(display);
</del><ins>+    return display;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static const unsigned statusCheckThreshold = 5;
</span><span class="lines">@@ -509,45 +511,6 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#if PLATFORM(IOS_FAMILY)
-bool GraphicsContextGLOpenGL::releaseCurrentContext(ReleaseBehavior releaseBehavior)
-{
-    if (!isANGLEAvailable())
-        return true;
-
-    // At the moment this function is relevant only when web thread lock owns the GraphicsContextGLOpenGL current context.
-    ASSERT(!isCurrentContextPredictable());
-
-    if (!EGL_BindAPI(EGL_OPENGL_ES_API))
-        return false;
-    if (EGL_GetCurrentContext() == EGL_NO_CONTEXT)
-        return true;
-
-    // At the time of writing, ANGLE does not flush on MakeCurrent. Since we are
-    // potentially switching threads, we should flush.
-    // Note: Here we assume also that ANGLE has only one platform context -- otherwise
-    // we would need to flush each EGL context that has been used.
-    gl::Flush();
-
-    // Unset the EGL current context, since the next access might be from another thread, and the
-    // context cannot be current on multiple threads.
-
-    if (releaseBehavior == ReleaseBehavior::ReleaseThreadResources) {
-        // Called when we do not know if we will ever see another call from this thread again.
-        // Unset the EGL current context by releasing whole EGL thread state.
-        // Theoretically ReleaseThread can reset the bound API, so the rest of the code mentions BindAPI/QueryAPI.
-        return EGL_ReleaseThread();
-    }
-    // On WebKit owned threads, WebKit is able to choose the time for the EGL cleanup.
-    // This is why we only unset the context.
-    // Note: At the time of writing the EGL cleanup is chosen to be not done at all.
-    EGLDisplay display = EGL_GetDisplay(EGL_DEFAULT_DISPLAY);
-    if (display == EGL_NO_DISPLAY)
-        return false;
-    return EGL_MakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
-}
-#endif
-
</del><span class="cx"> void GraphicsContextGLOpenGL::checkGPUStatus()
</span><span class="cx"> {
</span><span class="cx">     if (m_failNextStatusCheck) {
</span><span class="lines">@@ -830,11 +793,6 @@
</span><span class="cx">     return result;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GraphicsContextGLOpenGL::releaseAllResourcesIfUnused()
-{
-    ScopedEGLDefaultDisplay::releaseAllResourcesIfUnused();
-}
-
</del><span class="cx"> #if ENABLE(MEDIA_STREAM)
</span><span class="cx"> RefPtr<MediaSample> GraphicsContextGLOpenGL::paintCompositedResultsToMediaSample()
</span><span class="cx"> {
</span><span class="lines">@@ -850,6 +808,12 @@
</span><span class="cx">     return MediaSampleAVFObjC::createImageSample(WTFMove(*pixelBuffer), MediaSampleAVFObjC::VideoRotation::UpsideDown, true);
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><ins>+
+void GraphicsContextGLOpenGL::platformReleaseThreadResources()
+{
+    currentContext = nullptr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+}
+
</ins><span class="cx"> #endif // ENABLE(WEBGL)
</span></span></pre></div>
<a id="branchessafari612branchSourceWebCoreplatformgraphicsopenglGraphicsContextGLOpenGLcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.cpp (284952 => 284953)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.cpp   2021-10-27 21:06:06 UTC (rev 284952)
+++ branches/safari-612-branch/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.cpp      2021-10-27 21:06:12 UTC (rev 284953)
</span><span class="lines">@@ -76,6 +76,16 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if !USE(ANGLE)
</span><ins>+bool GraphicsContextGLOpenGL::releaseThreadResources(ReleaseThreadResourceBehavior)
+{
+}
+
+void GraphicsContextGLOpenGL::platformReleaseThreadResources()
+{
+}
+#endif
+
+#if !USE(ANGLE)
</ins><span class="cx"> bool GraphicsContextGLOpenGL::texImage2DResourceSafe(GCGLenum target, GCGLint level, GCGLenum internalformat, GCGLsizei width, GCGLsizei height, GCGLint border, GCGLenum format, GCGLenum type, GCGLint unpackAlignment)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(unpackAlignment == 1 || unpackAlignment == 2 || unpackAlignment == 4 || unpackAlignment == 8);
</span></span></pre></div>
<a id="branchessafari612branchSourceWebCoreplatformgraphicsopenglGraphicsContextGLOpenGLh"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h (284952 => 284953)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h     2021-10-27 21:06:06 UTC (rev 284952)
+++ branches/safari-612-branch/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h        2021-10-27 21:06:12 UTC (rev 284953)
</span><span class="lines">@@ -37,7 +37,6 @@
</span><span class="cx"> #include <wtf/UniqueRef.h>
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(COCOA)
</span><del>-#include "GraphicsContextGLANGLEEGLUtilities.h"
</del><span class="cx"> #include "IOSurface.h"
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -46,7 +45,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if USE(ANGLE)
</span><del>-#include "GraphicsContextGLANGLEUtilities.h"
</del><ins>+#include "ANGLEUtilities.h"
</ins><span class="cx"> #else
</span><span class="cx"> #include "ANGLEWebKitBridge.h"
</span><span class="cx"> #include "ExtensionsGLOpenGLCommon.h"
</span><span class="lines">@@ -119,17 +118,16 @@
</span><span class="cx"> #if USE(ANGLE)
</span><span class="cx">     static GCGLenum drawingBufferTextureTarget();
</span><span class="cx"> #endif
</span><del>-
-#if PLATFORM(IOS_FAMILY)
-    enum class ReleaseBehavior {
-        PreserveThreadResources,
-        ReleaseThreadResources
</del><ins>+    enum class ReleaseThreadResourceBehavior {
+        // Releases current context after GraphicsContextGLOpenGL calls done in the thread.
+        ReleaseCurrentContext,
+        // Releases all thread resources after GraphicsContextGLOpenGL calls done in the thread.
+        ReleaseThreadResources,
+        // Releases all global state. Should be used only after all depending objects have
+        // been released.
+        TerminateAndReleaseThreadResources
</ins><span class="cx">     };
</span><del>-    static bool releaseCurrentContext(ReleaseBehavior);
-#endif
-#if PLATFORM(COCOA)
-    static void releaseAllResourcesIfUnused();
-#endif
</del><ins>+    static bool releaseThreadResources(ReleaseThreadResourceBehavior);
</ins><span class="cx"> 
</span><span class="cx">     // With multisampling on, blit from multisampleFBO to regular FBO.
</span><span class="cx">     void prepareTexture();
</span><span class="lines">@@ -587,12 +585,15 @@
</span><span class="cx">     // Returns false if context should be lost due to timeout.
</span><span class="cx">     bool waitAndUpdateOldestFrame() WARN_UNUSED_RETURN;
</span><span class="cx"> #endif
</span><ins>+    // Platform specific behavior for releaseResources();
+    static void platformReleaseThreadResources();
</ins><span class="cx"> 
</span><ins>+
</ins><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx">     GraphicsContextGLIOSurfaceSwapChain* m_swapChain { nullptr };
</span><span class="cx">     // TODO: this should be removed once the context draws to a image buffer. See https://bugs.webkit.org/show_bug.cgi?id=218179 .
</span><span class="cx">     RetainPtr<WebGLLayer> m_webGLLayer;
</span><del>-    ScopedEGLDefaultDisplay m_displayObj;
</del><ins>+    EGLDisplay m_displayObj { nullptr };
</ins><span class="cx">     PlatformGraphicsContextGL m_contextObj { nullptr };
</span><span class="cx">     PlatformGraphicsContextGLConfig m_configObj { nullptr };
</span><span class="cx"> #endif // PLATFORM(COCOA)
</span></span></pre></div>
<a id="branchessafari612branchSourceWebCoreplatformioswakWebCoreThreadmm"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebCore/platform/ios/wak/WebCoreThread.mm (284952 => 284953)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebCore/platform/ios/wak/WebCoreThread.mm      2021-10-27 21:06:06 UTC (rev 284952)
+++ branches/safari-612-branch/Source/WebCore/platform/ios/wak/WebCoreThread.mm 2021-10-27 21:06:12 UTC (rev 284953)
</span><span class="lines">@@ -70,17 +70,20 @@
</span><span class="cx"> // as any client thread that calls into WebKit.
</span><span class="cx"> void ReleaseWebThreadGlobalState()
</span><span class="cx"> {
</span><del>-    // GraphicsContextGLOpenGL current context is owned by the web thread lock. Release the context
</del><ins>+    // ANGLE maintains thread global state for its current context.
+    // This is conceptually owned by the web thread lock. Release the context
</ins><span class="cx">     // before the lock is released.
</span><span class="cx"> 
</span><span class="cx">     // In single-threaded environments we do not need to unset the context, as there should not be access from
</span><span class="cx">     // multiple threads.
</span><span class="cx">     ASSERT(WebThreadIsEnabled());
</span><del>-    using ReleaseBehavior = WebCore::GraphicsContextGLOpenGL::ReleaseBehavior;
-    // For non-web threads, we don't know if we ever see another call from the thread.
-    ReleaseBehavior releaseBehavior =
-        WebThreadIsCurrent() ? ReleaseBehavior::PreserveThreadResources : ReleaseBehavior::ReleaseThreadResources;
-    WebCore::GraphicsContextGLOpenGL::releaseCurrentContext(releaseBehavior);
</del><ins>+    using ReleaseThreadResourceBehavior = WebCore::GraphicsContextGLOpenGL::ReleaseThreadResourceBehavior;
+    // For web thread, just release the context as we know we will see calls to it again.
+    // For non-web threads, e.g. third-party client threads, we don't know if we ever see another call from the
+    // thread, so we also release the thread resources.
+    ReleaseThreadResourceBehavior releaseBehavior =
+        WebThreadIsCurrent() ? ReleaseThreadResourceBehavior::ReleaseCurrentContext : ReleaseThreadResourceBehavior::ReleaseThreadResources;
+    WebCore::GraphicsContextGLOpenGL::releaseThreadResources(releaseBehavior);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="branchessafari612branchSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebKit/ChangeLog (284952 => 284953)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebKit/ChangeLog       2021-10-27 21:06:06 UTC (rev 284952)
+++ branches/safari-612-branch/Source/WebKit/ChangeLog  2021-10-27 21:06:12 UTC (rev 284953)
</span><span class="lines">@@ -1,3 +1,112 @@
</span><ins>+2021-10-26  Russell Epstein  <repstein@apple.com>
+
+        Cherry-pick r283703. rdar://problem/84629308
+
+    ScopedEGLDefaultDisplay should be removed
+    https://bugs.webkit.org/show_bug.cgi?id=231011
+    
+    Patch by Kimmo Kinnunen <kkinnunen@apple.com> on 2021-10-07
+    Reviewed by Kenneth Russell.
+    
+    Source/WebCore:
+    
+    Hard-coding the code to EGL_DEFAULT_DISPLAY only and using the scoped
+    holder is making the EGLDisplays harder to use than neccessary. The
+    implementation target, e.g. the ability to call EGLTerminate, was also a bit
+    more convoluted than needed.
+    
+    Move the "call EGLTerminate" logic from a bit convoluted refcount mechanism
+    in ScopedEGLDefaultDisplay to the explicit GraphicsContextGLOpenGL::releaseResources().
+    The callers are expected to do the refcounting anyway, as the existing client
+    WebKit::ScopedWebGLRenderingResourcesRequest already did.
+    
+    Make GraphicsContextGLOpenGL::releaseResources() available on all platforms.
+    It is implemented on all ANGLE implementations.
+    Platforms can augment the implementation by implementing
+    GraphicsContextGLOpenGL::platformReleaseResources(). For Cocoa, this function
+    resets the currentContext cache that is used to optimize making context current.
+    
+    No new tests, refactor.
+    
+    * CMakeLists.txt:
+    * Headers.cmake:
+    * PlatformMac.cmake:
+    * SourcesCocoa.txt:
+    * WebCore.xcodeproj/project.pbxproj:
+    * platform/graphics/angle/ANGLEUtilities.cpp: Renamed from Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLEEGLUtilities.h.
+    (WebCore::platformIsANGLEAvailable):
+    * platform/graphics/angle/ANGLEUtilities.h: Renamed from Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLEUtilities.h.
+    Rename GraphicsContextGLANGLEUtilities to simpler and more descriptive ANGLEUtilities.
+    Add the isANGLEAvailable to there.
+    
+    * platform/graphics/angle/GraphicsContextGLANGLE.cpp:
+    (WebCore::GraphicsContextGLOpenGL::releaseResources):
+    (WebCore::GraphicsContextGLOpenGL::platformReleaseResources):
+    * platform/graphics/angle/GraphicsContextGLANGLEEGLUtilities.cpp: Removed.
+    (WebCore::refDefaultDisplay): Deleted.
+    (WebCore::unrefDefaultDisplayIfNeeded): Deleted.
+    (WebCore::ScopedEGLDefaultDisplay::operator=): Deleted.
+    (WebCore::ScopedEGLDefaultDisplay::ScopedEGLDefaultDisplay): Deleted.
+    (WebCore::ScopedEGLDefaultDisplay::~ScopedEGLDefaultDisplay): Deleted.
+    (WebCore::ScopedEGLDefaultDisplay::releaseAllResourcesIfUnused): Deleted.
+    * platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm:
+    (WebCore::platformIsANGLEAvailable):
+    (WebCore::initializeEGLDisplay):
+    (WebCore::GraphicsContextGLOpenGL::platformReleaseResources):
+    (WebCore::isANGLEAvailable): Deleted.
+    (WebCore::GraphicsContextGLOpenGL::releaseCurrentContext): Deleted.
+    (WebCore::GraphicsContextGLOpenGL::releaseAllResourcesIfUnused): Deleted.
+    * platform/graphics/opengl/GraphicsContextGLOpenGL.cpp:
+    (WebCore::GraphicsContextGLOpenGL::releaseResources):
+    (WebCore::GraphicsContextGLOpenGL::platformReleaseResources):
+    * platform/graphics/opengl/GraphicsContextGLOpenGL.h:
+    * platform/ios/wak/WebCoreThread.mm:
+    
+    Source/WebKit:
+    
+    Implement the release of WebGL resources with the amended
+    GraphicsContextGLOpenGL::releaseResources() instead of
+    previous separate function GraphicsContextGLOpenGL::releaseAllResources().
+    
+    Use the resource release code path universally, as
+    GraphicsContextGLOpenGL::releaseResources() is now common code.
+    
+    * GPUProcess/graphics/ScopedWebGLRenderingResourcesRequest.cpp:
+    (WebKit::ScopedWebGLRenderingResourcesRequest::scheduleFreeWebGLRenderingResources):
+    (WebKit::ScopedWebGLRenderingResourcesRequest::freeWebGLRenderingResources):
+    * GPUProcess/graphics/ScopedWebGLRenderingResourcesRequest.h:
+    * GPUProcess/graphics/ScopedWebGLRenderingResourcesRequestCocoa.cpp: Removed.
+    (WebKit::ScopedWebGLRenderingResourcesRequest::scheduleFreeWebGLRenderingResources): Deleted.
+    (WebKit::ScopedWebGLRenderingResourcesRequest::freeWebGLRenderingResources): Deleted.
+    * SourcesCocoa.txt:
+    * WebKit.xcodeproj/project.pbxproj:
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@283703 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-10-07  Kimmo Kinnunen  <kkinnunen@apple.com>
+
+            ScopedEGLDefaultDisplay should be removed
+            https://bugs.webkit.org/show_bug.cgi?id=231011
+
+            Reviewed by Kenneth Russell.
+
+            Implement the release of WebGL resources with the amended
+            GraphicsContextGLOpenGL::releaseResources() instead of
+            previous separate function GraphicsContextGLOpenGL::releaseAllResources().
+
+            Use the resource release code path universally, as
+            GraphicsContextGLOpenGL::releaseResources() is now common code.
+
+            * GPUProcess/graphics/ScopedWebGLRenderingResourcesRequest.cpp:
+            (WebKit::ScopedWebGLRenderingResourcesRequest::scheduleFreeWebGLRenderingResources):
+            (WebKit::ScopedWebGLRenderingResourcesRequest::freeWebGLRenderingResources):
+            * GPUProcess/graphics/ScopedWebGLRenderingResourcesRequest.h:
+            * GPUProcess/graphics/ScopedWebGLRenderingResourcesRequestCocoa.cpp: Removed.
+            (WebKit::ScopedWebGLRenderingResourcesRequest::scheduleFreeWebGLRenderingResources): Deleted.
+            (WebKit::ScopedWebGLRenderingResourcesRequest::freeWebGLRenderingResources): Deleted.
+            * SourcesCocoa.txt:
+            * WebKit.xcodeproj/project.pbxproj:
+
</ins><span class="cx"> 2021-10-26  Alan Coon  <alancoon@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Cherry-pick r284344. rdar://problem/84625558
</span></span></pre></div>
<a id="branchessafari612branchSourceWebKitGPUProcessgraphicsScopedWebGLRenderingResourcesRequestcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebKit/GPUProcess/graphics/ScopedWebGLRenderingResourcesRequest.cpp (284952 => 284953)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebKit/GPUProcess/graphics/ScopedWebGLRenderingResourcesRequest.cpp    2021-10-27 21:06:06 UTC (rev 284952)
+++ branches/safari-612-branch/Source/WebKit/GPUProcess/graphics/ScopedWebGLRenderingResourcesRequest.cpp       2021-10-27 21:06:12 UTC (rev 284953)
</span><span class="lines">@@ -26,20 +26,38 @@
</span><span class="cx"> #include "config.h"
</span><span class="cx"> #include "ScopedWebGLRenderingResourcesRequest.h"
</span><span class="cx"> 
</span><ins>+#if ENABLE(GPU_PROCESS) && ENABLE(WEBGL)
+
+#include "RemoteGraphicsContextGL.h"
+#include "StreamConnectionWorkQueue.h"
+#include <WebCore/GraphicsContextGL.h>
+#include <wtf/RunLoop.h>
+#include <wtf/Seconds.h>
+
</ins><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><span class="cx"> std::atomic<unsigned> ScopedWebGLRenderingResourcesRequest::s_requests;
</span><ins>+static constexpr Seconds freeWebGLRenderingResourcesTimeout = 1_s;
+static bool didScheduleFreeWebGLRenderingResources;
</ins><span class="cx"> 
</span><del>-#if !PLATFORM(COCOA)
-
</del><span class="cx"> void ScopedWebGLRenderingResourcesRequest::scheduleFreeWebGLRenderingResources()
</span><span class="cx"> {
</span><ins>+    if (didScheduleFreeWebGLRenderingResources)
+        return;
+    RunLoop::main().dispatchAfter(freeWebGLRenderingResourcesTimeout, freeWebGLRenderingResources);
+    didScheduleFreeWebGLRenderingResources = true;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ScopedWebGLRenderingResourcesRequest::freeWebGLRenderingResources()
</span><span class="cx"> {
</span><ins>+    didScheduleFreeWebGLRenderingResources = false;
+    if (s_requests)
+        return;
+    remoteGraphicsContextGLStreamWorkQueue().dispatch([] {
+        WebCore::GraphicsContextGLOpenGL::releaseThreadResources(WebCore::GraphicsContextGLOpenGL::ReleaseThreadResourceBehavior::TerminateAndReleaseThreadResources);
+    });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+}
+
</ins><span class="cx"> #endif
</span><del>-
-}
</del></span></pre></div>
<a id="branchessafari612branchSourceWebKitGPUProcessgraphicsScopedWebGLRenderingResourcesRequesth"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebKit/GPUProcess/graphics/ScopedWebGLRenderingResourcesRequest.h (284952 => 284953)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebKit/GPUProcess/graphics/ScopedWebGLRenderingResourcesRequest.h      2021-10-27 21:06:06 UTC (rev 284952)
+++ branches/safari-612-branch/Source/WebKit/GPUProcess/graphics/ScopedWebGLRenderingResourcesRequest.h 2021-10-27 21:06:12 UTC (rev 284953)
</span><span class="lines">@@ -25,6 +25,8 @@
</span><span class="cx"> 
</span><span class="cx"> #pragma once
</span><span class="cx"> 
</span><ins>+#if ENABLE(GPU_PROCESS) && ENABLE(WEBGL)
+
</ins><span class="cx"> #include "ScopedRenderingResourcesRequest.h"
</span><span class="cx"> #include <atomic>
</span><span class="cx"> #include <wtf/StdLibExtras.h>
</span><span class="lines">@@ -82,3 +84,5 @@
</span><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span><ins>+
+#endif
</ins></span></pre></div>
<a id="branchessafari612branchSourceWebKitGPUProcessgraphicsScopedWebGLRenderingResourcesRequestCocoacpp"></a>
<div class="delfile"><h4>Deleted: branches/safari-612-branch/Source/WebKit/GPUProcess/graphics/ScopedWebGLRenderingResourcesRequestCocoa.cpp (284952 => 284953)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebKit/GPUProcess/graphics/ScopedWebGLRenderingResourcesRequestCocoa.cpp       2021-10-27 21:06:06 UTC (rev 284952)
+++ branches/safari-612-branch/Source/WebKit/GPUProcess/graphics/ScopedWebGLRenderingResourcesRequestCocoa.cpp  2021-10-27 21:06:12 UTC (rev 284953)
</span><span class="lines">@@ -1,60 +0,0 @@
</span><del>-/*
- * 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 "ScopedWebGLRenderingResourcesRequest.h"
-
-#if PLATFORM(COCOA)
-
-#include "RemoteGraphicsContextGL.h"
-#include "StreamConnectionWorkQueue.h"
-#include <WebCore/GraphicsContextGL.h>
-#include <wtf/RunLoop.h>
-#include <wtf/Seconds.h>
-
-namespace WebKit {
-
-static constexpr Seconds freeWebGLRenderingResourcesTimeout = 1_s;
-static bool didScheduleFreeWebGLRenderingResources;
-
-void ScopedWebGLRenderingResourcesRequest::scheduleFreeWebGLRenderingResources()
-{
-    if (didScheduleFreeWebGLRenderingResources)
-        return;
-    RunLoop::main().dispatchAfter(freeWebGLRenderingResourcesTimeout, freeWebGLRenderingResources);
-    didScheduleFreeWebGLRenderingResources = true;
-}
-
-void ScopedWebGLRenderingResourcesRequest::freeWebGLRenderingResources()
-{
-    didScheduleFreeWebGLRenderingResources = false;
-    if (s_requests)
-        return;
-    remoteGraphicsContextGLStreamWorkQueue().dispatch(GraphicsContextGLOpenGL::releaseAllResourcesIfUnused);
-}
-
-}
-
-#endif
</del></span></pre></div>
<a id="branchessafari612branchSourceWebKitSourcesCocoatxt"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebKit/SourcesCocoa.txt (284952 => 284953)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebKit/SourcesCocoa.txt        2021-10-27 21:06:06 UTC (rev 284952)
+++ branches/safari-612-branch/Source/WebKit/SourcesCocoa.txt   2021-10-27 21:06:12 UTC (rev 284953)
</span><span class="lines">@@ -62,7 +62,6 @@
</span><span class="cx"> GPUProcess/cocoa/GPUProcessCocoa.mm
</span><span class="cx"> GPUProcess/graphics/RemoteGraphicsContextGLCocoa.cpp
</span><span class="cx"> GPUProcess/graphics/ScopedRenderingResourcesRequestCocoa.mm @no-unify
</span><del>-GPUProcess/graphics/ScopedWebGLRenderingResourcesRequestCocoa.cpp
</del><span class="cx"> GPUProcess/ios/GPUProcessIOS.mm
</span><span class="cx"> GPUProcess/mac/GPUProcessMac.mm
</span><span class="cx"> GPUProcess/mac/LocalAudioSessionRoutingArbitrator.cpp
</span></span></pre></div>
<a id="branchessafari612branchSourceWebKitWebKitxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebKit/WebKit.xcodeproj/project.pbxproj (284952 => 284953)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebKit/WebKit.xcodeproj/project.pbxproj        2021-10-27 21:06:06 UTC (rev 284952)
+++ branches/safari-612-branch/Source/WebKit/WebKit.xcodeproj/project.pbxproj   2021-10-27 21:06:12 UTC (rev 284953)
</span><span class="lines">@@ -4714,7 +4714,6 @@
</span><span class="cx">          7BCF70CC2614935F00E4FB70 /* ScopedWebGLRenderingResourcesRequest.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ScopedWebGLRenderingResourcesRequest.cpp; sourceTree = "<group>"; };
</span><span class="cx">          7BCF70CD2614935F00E4FB70 /* ScopedRenderingResourcesRequest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ScopedRenderingResourcesRequest.h; sourceTree = "<group>"; };
</span><span class="cx">          7BCF70CE2614935F00E4FB70 /* ScopedWebGLRenderingResourcesRequest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ScopedWebGLRenderingResourcesRequest.h; sourceTree = "<group>"; };
</span><del>-               7BCF70CF261497E600E4FB70 /* ScopedWebGLRenderingResourcesRequestCocoa.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ScopedWebGLRenderingResourcesRequestCocoa.cpp; sourceTree = "<group>"; };
</del><span class="cx">           7BE726572574F67200E85D98 /* RemoteGraphicsContextGLProxyFunctionsGenerated.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteGraphicsContextGLProxyFunctionsGenerated.cpp; sourceTree = "<group>"; };
</span><span class="cx">          7BE72668257680EF00E85D98 /* RemoteGraphicsContextGLCocoa.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteGraphicsContextGLCocoa.cpp; sourceTree = "<group>"; };
</span><span class="cx">          7C065F291C8CD95F00C2D950 /* WebUserContentControllerDataTypes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebUserContentControllerDataTypes.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -9052,7 +9051,6 @@
</span><span class="cx">                          7BCF70CB2614935E00E4FB70 /* ScopedRenderingResourcesRequestCocoa.mm */,
</span><span class="cx">                          7BCF70CC2614935F00E4FB70 /* ScopedWebGLRenderingResourcesRequest.cpp */,
</span><span class="cx">                          7BCF70CE2614935F00E4FB70 /* ScopedWebGLRenderingResourcesRequest.h */,
</span><del>-                               7BCF70CF261497E600E4FB70 /* ScopedWebGLRenderingResourcesRequestCocoa.cpp */,
</del><span class="cx">                   );
</span><span class="cx">                  path = graphics;
</span><span class="cx">                  sourceTree = "<group>";
</span></span></pre>
</div>
</div>

</body>
</html>