<!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>[269708] trunk/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/269708">269708</a></dd>
<dt>Author</dt> <dd>said@apple.com</dd>
<dt>Date</dt> <dd>2020-11-11 16:59:50 -0800 (Wed, 11 Nov 2020)</dd>
</dl>

<h3>Log Message</h3>
<pre>[GPU Process] Cache the NativeImage in GPU Process and allow referencing it with its RemoteResourceIdentifier
https://bugs.webkit.org/show_bug.cgi?id=217596

Reviewed by Simon Fraser.

Source/WebCore:

In this patch all the drawImage functions will not be recorded as display
list items. Instead we are going to let them proceed till they reach lower
level calls such as drawNativeImage().

* Headers.cmake:
* WebCore.xcodeproj/project.pbxproj:
* platform/graphics/BitmapImage.cpp:
(WebCore::BitmapImage::subsamplingLevelForScaleFactor):
Because we no longer record DrawImage, calling BitmapImage::draw() is now
allowed even if the GraphicsContext is backed by a DisplayList::Recorder.
If the image sub-sampling is allowed, which we do for iOS, this function
is going to be called. We need to guard using the platformContext by calling
hasPlatformContext() first.

* platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::drawImage):
(WebCore::GraphicsContext::drawTiledImage):
We have to let these function proceed till they end up calling the
DOM rendering for SVGImage, PDFDocumentImage::draw for pdf image and
drawNativeImage for the rest.

* platform/graphics/ImageBuffer.h:
Make ImageBuffer a CanMakeWeakPtr so we can have a HashMap whose values
are of type WeakPtr<ImageBuffer>.

* platform/graphics/NativeImage.cpp:
(WebCore::NativeImage::create):
(WebCore::NativeImage::NativeImage):
(WebCore::NativeImage::~NativeImage):
* platform/graphics/NativeImage.h:
(WebCore::NativeImage::renderingResourceIdentifier const):
(WebCore::NativeImage::setObserver):
Add an observer to NativeImage whose job is to observe when it is being
destroyed. Add also an renderingResourceIdentifier so it can be used to
reference the NativeImage in a NativeImageHashMap.

* platform/graphics/NativeImageReference.h: Added.
This definition can be used to encode/decode a Ref<NativeImage> for IPC
messages.

* platform/graphics/displaylists/DisplayList.cpp:
(WebCore::DisplayList::m_nativeImages):
(WebCore::DisplayList::DisplayList::operator=):
(WebCore::DisplayList::DisplayList::clear):
* platform/graphics/displaylists/DisplayList.h:
(WebCore::DisplayList::DisplayList::nativeImages const):
(WebCore::DisplayList::DisplayList::cacheImageBuffer):
(WebCore::DisplayList::DisplayList::cacheNativeImage):
Add the ability to cache the NativeImage in DisplayList such that its
renderingResourceIdentifier can be used when recording DrawNativeImage
and m_nativeImages can be used to access the NativeImage when replaying
back DrawNativeImage.

* platform/graphics/displaylists/DisplayListItemBuffer.cpp:
(WebCore::DisplayList::ItemHandle::destroy):
* platform/graphics/displaylists/DisplayListItemType.cpp:
(WebCore::DisplayList::isInlineItem):
* platform/graphics/displaylists/DisplayListItems.cpp:
(WebCore::DisplayList::operator<<):
(WebCore::DisplayList::DrawNativeImage::apply const):
(WebCore::DisplayList::DrawNativeImage::DrawNativeImage): Deleted.
* platform/graphics/displaylists/DisplayListItems.h:
(WebCore::DisplayList::DrawImageBuffer::DrawImageBuffer):
(WebCore::DisplayList::DrawImageBuffer::imageBufferIdentifier const):
(WebCore::DisplayList::DrawNativeImage::DrawNativeImage):
(WebCore::DisplayList::DrawNativeImage::imageIdentifier const):
(WebCore::DisplayList::DrawImageBuffer::renderingResourceIdentifier const): Deleted.
(WebCore::DisplayList::DrawNativeImage::encode const): Deleted.
(WebCore::DisplayList::DrawNativeImage::decode): Deleted.
DrawNativeImage is an inline item now. No encoding/decoding is needed.

* platform/graphics/displaylists/DisplayListRecorder.cpp:
(WebCore::DisplayList::Recorder::drawImageBuffer):
(WebCore::DisplayList::Recorder::drawNativeImage):
* platform/graphics/displaylists/DisplayListRecorder.h:
(WebCore::DisplayList::Recorder::Delegate::cacheNativeImage):
Ask the DisplayList::Recorder::Delegate to cache the NativeImage.

* platform/graphics/displaylists/DisplayListReplayer.cpp:
(WebCore::DisplayList::Replayer::Replayer):
(WebCore::DisplayList::Replayer::applyItem):
* platform/graphics/displaylists/DisplayListReplayer.h:
Resolve the renderingResourceIdentifier of DrawNativeImage to a NativeImage
from the m_nativeImages before drawing it.

Source/WebKit:

Recorder::drawNativeImage() will ensure the NativeImage is cached before
recording the DrawNativeImage item with the renderingResourceIdentifier.

Because RemoteImageBufferProxy is a superclass of DisplayList::Recorder::
Delegate, it will ensure the NativeImage is cached in its RemoteResourceCacheProxy.

If the NativeImage is registered in RemoteResourceCacheProxy for the first
time, it is going to be sent as an IPC message to GPU. Upon receiving this
message, RemoteRenderingBackend will cache this NativeImage in its
RemoteResourceCache. This message has to be received for any NativeImage
only once for its entire life time.

When flushing the DisplayList of any ImageBuffer, RemoteImageBuffer will
ensure the NativeImages are cached in the RemoteResourceCache are passed
to DisplayList::Replayer so it can use them to get NativeImage for every
DrawNativeImage with the same renderingResourceIdentifier it was recorded
with.

When NativeImage is bing destroyed, its destructor will call its observer
virtual method releaseNativeImage(). RemoteResourceCacheProxy will be a
superclass NativeImage::Observer so its overriding method will be called.
When RemoteResourceCacheProxy::releaseNativeImage() is called it is going
to delete the NativeImage from RemoteResourceCacheProxy and is going to
send a message to GPU to delete the corresponding NativeImage from
RemoteResourceCache via RemoteRenderingBackend::releaseRemoteResource().

* GPUProcess/graphics/RemoteImageBuffer.h:
* GPUProcess/graphics/RemoteRenderingBackend.cpp:
(WebKit::RemoteRenderingBackend::cacheNativeImage):
(WebKit::RemoteRenderingBackend::decodeItem):
* GPUProcess/graphics/RemoteRenderingBackend.h:
* GPUProcess/graphics/RemoteRenderingBackend.messages.in:
* GPUProcess/graphics/RemoteResourceCache.cpp:
(WebKit::RemoteResourceCache::cacheNativeImage):
(WebKit::RemoteResourceCache::releaseRemoteResource):
* GPUProcess/graphics/RemoteResourceCache.h:
(WebKit::RemoteResourceCache::nativeImages const):
* Scripts/webkit/messages.py:
* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<Ref<NativeImage>>::encode):
(IPC::ArgumentCoder<Ref<NativeImage>>::decode):
* WebProcess/GPU/graphics/RemoteImageBufferProxy.h:
(WebKit::RemoteImageBufferProxy::~RemoteImageBufferProxy):
(WebKit::RemoteImageBufferProxy::RemoteImageBufferProxy):
* WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp:
(WebKit::RemoteRenderingBackendProxy::createImageBuffer):
(WebKit::RemoteRenderingBackendProxy::cacheNativeImage):
(WebKit::RemoteRenderingBackendProxy::releaseRemoteResource):
* WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h:
* WebProcess/GPU/graphics/RemoteResourceCacheProxy.cpp:
(WebKit::RemoteResourceCacheProxy::RemoteResourceCacheProxy):
(WebKit::RemoteResourceCacheProxy::cacheImageBuffer):
(WebKit::RemoteResourceCacheProxy::cachedImageBuffer):
(WebKit::RemoteResourceCacheProxy::cacheNativeImage):
(WebKit::RemoteResourceCacheProxy::releaseNativeImage):
* WebProcess/GPU/graphics/RemoteResourceCacheProxy.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreHeaderscmake">trunk/Source/WebCore/Headers.cmake</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsBitmapImagecpp">trunk/Source/WebCore/platform/graphics/BitmapImage.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGraphicsContextcpp">trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsImageBufferh">trunk/Source/WebCore/platform/graphics/ImageBuffer.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsNativeImagecpp">trunk/Source/WebCore/platform/graphics/NativeImage.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsNativeImageh">trunk/Source/WebCore/platform/graphics/NativeImage.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsdisplaylistsDisplayListcpp">trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsdisplaylistsDisplayListh">trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsdisplaylistsDisplayListItemBuffercpp">trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemBuffer.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsdisplaylistsDisplayListItemTypecpp">trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemType.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsdisplaylistsDisplayListItemscpp">trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsdisplaylistsDisplayListItemsh">trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsdisplaylistsDisplayListRecordercpp">trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsdisplaylistsDisplayListRecorderh">trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsdisplaylistsDisplayListReplayercpp">trunk/Source/WebCore/platform/graphics/displaylists/DisplayListReplayer.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsdisplaylistsDisplayListReplayerh">trunk/Source/WebCore/platform/graphics/displaylists/DisplayListReplayer.h</a></li>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitGPUProcessgraphicsRemoteImageBufferh">trunk/Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.h</a></li>
<li><a href="#trunkSourceWebKitGPUProcessgraphicsRemoteRenderingBackendcpp">trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp</a></li>
<li><a href="#trunkSourceWebKitGPUProcessgraphicsRemoteRenderingBackendh">trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h</a></li>
<li><a href="#trunkSourceWebKitGPUProcessgraphicsRemoteRenderingBackendmessagesin">trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.messages.in</a></li>
<li><a href="#trunkSourceWebKitGPUProcessgraphicsRemoteResourceCachecpp">trunk/Source/WebKit/GPUProcess/graphics/RemoteResourceCache.cpp</a></li>
<li><a href="#trunkSourceWebKitGPUProcessgraphicsRemoteResourceCacheh">trunk/Source/WebKit/GPUProcess/graphics/RemoteResourceCache.h</a></li>
<li><a href="#trunkSourceWebKitScriptswebkitmessagespy">trunk/Source/WebKit/Scripts/webkit/messages.py</a></li>
<li><a href="#trunkSourceWebKitSharedWebCoreArgumentCoderscpp">trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessGPUgraphicsRemoteImageBufferProxyh">trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h</a></li>
<li><a href="#trunkSourceWebKitWebProcessGPUgraphicsRemoteRenderingBackendProxycpp">trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessGPUgraphicsRemoteRenderingBackendProxyh">trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h</a></li>
<li><a href="#trunkSourceWebKitWebProcessGPUgraphicsRemoteResourceCacheProxycpp">trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteResourceCacheProxy.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessGPUgraphicsRemoteResourceCacheProxyh">trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteResourceCacheProxy.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformgraphicsNativeImageReferenceh">trunk/Source/WebCore/platform/graphics/NativeImageReference.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (269707 => 269708)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2020-11-12 00:37:55 UTC (rev 269707)
+++ trunk/Source/WebCore/ChangeLog      2020-11-12 00:59:50 UTC (rev 269708)
</span><span class="lines">@@ -1,3 +1,95 @@
</span><ins>+2020-11-11  Said Abou-Hallawa  <said@apple.com>
+
+        [GPU Process] Cache the NativeImage in GPU Process and allow referencing it with its RemoteResourceIdentifier
+        https://bugs.webkit.org/show_bug.cgi?id=217596
+
+        Reviewed by Simon Fraser.
+
+        In this patch all the drawImage functions will not be recorded as display
+        list items. Instead we are going to let them proceed till they reach lower
+        level calls such as drawNativeImage().
+
+        * Headers.cmake:
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/graphics/BitmapImage.cpp:
+        (WebCore::BitmapImage::subsamplingLevelForScaleFactor):
+        Because we no longer record DrawImage, calling BitmapImage::draw() is now
+        allowed even if the GraphicsContext is backed by a DisplayList::Recorder.
+        If the image sub-sampling is allowed, which we do for iOS, this function
+        is going to be called. We need to guard using the platformContext by calling
+        hasPlatformContext() first.
+
+        * platform/graphics/GraphicsContext.cpp:
+        (WebCore::GraphicsContext::drawImage):
+        (WebCore::GraphicsContext::drawTiledImage):
+        We have to let these function proceed till they end up calling the 
+        DOM rendering for SVGImage, PDFDocumentImage::draw for pdf image and 
+        drawNativeImage for the rest.
+
+        * platform/graphics/ImageBuffer.h:
+        Make ImageBuffer a CanMakeWeakPtr so we can have a HashMap whose values
+        are of type WeakPtr<ImageBuffer>.
+
+        * platform/graphics/NativeImage.cpp:
+        (WebCore::NativeImage::create):
+        (WebCore::NativeImage::NativeImage):
+        (WebCore::NativeImage::~NativeImage):
+        * platform/graphics/NativeImage.h:
+        (WebCore::NativeImage::renderingResourceIdentifier const):
+        (WebCore::NativeImage::setObserver):
+        Add an observer to NativeImage whose job is to observe when it is being
+        destroyed. Add also an renderingResourceIdentifier so it can be used to
+        reference the NativeImage in a NativeImageHashMap.
+
+        * platform/graphics/NativeImageReference.h: Added.
+        This definition can be used to encode/decode a Ref<NativeImage> for IPC
+        messages.
+
+        * platform/graphics/displaylists/DisplayList.cpp:
+        (WebCore::DisplayList::m_nativeImages):
+        (WebCore::DisplayList::DisplayList::operator=):
+        (WebCore::DisplayList::DisplayList::clear):
+        * platform/graphics/displaylists/DisplayList.h:
+        (WebCore::DisplayList::DisplayList::nativeImages const):
+        (WebCore::DisplayList::DisplayList::cacheImageBuffer):
+        (WebCore::DisplayList::DisplayList::cacheNativeImage):
+        Add the ability to cache the NativeImage in DisplayList such that its
+        renderingResourceIdentifier can be used when recording DrawNativeImage
+        and m_nativeImages can be used to access the NativeImage when replaying
+        back DrawNativeImage.
+
+        * platform/graphics/displaylists/DisplayListItemBuffer.cpp:
+        (WebCore::DisplayList::ItemHandle::destroy):
+        * platform/graphics/displaylists/DisplayListItemType.cpp:
+        (WebCore::DisplayList::isInlineItem):
+        * platform/graphics/displaylists/DisplayListItems.cpp:
+        (WebCore::DisplayList::operator<<):
+        (WebCore::DisplayList::DrawNativeImage::apply const):
+        (WebCore::DisplayList::DrawNativeImage::DrawNativeImage): Deleted.
+        * platform/graphics/displaylists/DisplayListItems.h:
+        (WebCore::DisplayList::DrawImageBuffer::DrawImageBuffer):
+        (WebCore::DisplayList::DrawImageBuffer::imageBufferIdentifier const):
+        (WebCore::DisplayList::DrawNativeImage::DrawNativeImage):
+        (WebCore::DisplayList::DrawNativeImage::imageIdentifier const):
+        (WebCore::DisplayList::DrawImageBuffer::renderingResourceIdentifier const): Deleted.
+        (WebCore::DisplayList::DrawNativeImage::encode const): Deleted.
+        (WebCore::DisplayList::DrawNativeImage::decode): Deleted.
+        DrawNativeImage is an inline item now. No encoding/decoding is needed.
+
+        * platform/graphics/displaylists/DisplayListRecorder.cpp:
+        (WebCore::DisplayList::Recorder::drawImageBuffer):
+        (WebCore::DisplayList::Recorder::drawNativeImage):
+        * platform/graphics/displaylists/DisplayListRecorder.h:
+        (WebCore::DisplayList::Recorder::Delegate::cacheNativeImage):
+        Ask the DisplayList::Recorder::Delegate to cache the NativeImage.
+
+        * platform/graphics/displaylists/DisplayListReplayer.cpp:
+        (WebCore::DisplayList::Replayer::Replayer):
+        (WebCore::DisplayList::Replayer::applyItem):
+        * platform/graphics/displaylists/DisplayListReplayer.h:
+        Resolve the renderingResourceIdentifier of DrawNativeImage to a NativeImage
+        from the m_nativeImages before drawing it.
+
</ins><span class="cx"> 2020-11-11  Sam Weinig  <weinig@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Remove unused ExperimentalNotificationsEnabled setting
</span></span></pre></div>
<a id="trunkSourceWebCoreHeaderscmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Headers.cmake (269707 => 269708)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Headers.cmake       2020-11-12 00:37:55 UTC (rev 269707)
+++ trunk/Source/WebCore/Headers.cmake  2020-11-12 00:59:50 UTC (rev 269708)
</span><span class="lines">@@ -1215,6 +1215,7 @@
</span><span class="cx">     platform/graphics/MediaPlayerPrivate.h
</span><span class="cx">     platform/graphics/MediaUsageInfo.h
</span><span class="cx">     platform/graphics/NativeImage.h
</span><ins>+    platform/graphics/NativeImageReference.h
</ins><span class="cx">     platform/graphics/OpenGLESShims.h
</span><span class="cx">     platform/graphics/OpenGLShims.h
</span><span class="cx">     platform/graphics/Path.h
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (269707 => 269708)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj   2020-11-12 00:37:55 UTC (rev 269707)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj      2020-11-12 00:59:50 UTC (rev 269708)
</span><span class="lines">@@ -2164,6 +2164,7 @@
</span><span class="cx">          7299BC6823D6A53E00CC6883 /* RenderingMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 7299BC6623D686C600CC6883 /* RenderingMode.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">          729D05302531424300422098 /* RenderingResourceIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 729D052E25313E2600422098 /* RenderingResourceIdentifier.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">          72A73BEF245A3F90001C9D03 /* AnimationFrameRate.h in Headers */ = {isa = PBXBuildFile; fileRef = 722A815C238FD50500C00583 /* AnimationFrameRate.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+               72AB9A21255A9FDE00E6EBF1 /* NativeImageReference.h in Headers */ = {isa = PBXBuildFile; fileRef = 72AB9A1F255A9EA600E6EBF1 /* NativeImageReference.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">           72BAC3AE23E1F0B0008D741C /* ImageBufferBackend.h in Headers */ = {isa = PBXBuildFile; fileRef = 72BAC3A523E17328008D741C /* ImageBufferBackend.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">          7553CFE8108F473F00EA281E /* TimelineRecordFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 7553CFE6108F473F00EA281E /* TimelineRecordFactory.h */; };
</span><span class="cx">          75793E840D0CE0B3007FC0AC /* MessageEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 75793E810D0CE0B3007FC0AC /* MessageEvent.h */; };
</span><span class="lines">@@ -9970,6 +9971,7 @@
</span><span class="cx">          7299BC6423D686A600CC6883 /* AlphaPremultiplication.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AlphaPremultiplication.h; sourceTree = "<group>"; };
</span><span class="cx">          7299BC6623D686C600CC6883 /* RenderingMode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RenderingMode.h; sourceTree = "<group>"; };
</span><span class="cx">          729D052E25313E2600422098 /* RenderingResourceIdentifier.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RenderingResourceIdentifier.h; sourceTree = "<group>"; };
</span><ins>+               72AB9A1F255A9EA600E6EBF1 /* NativeImageReference.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NativeImageReference.h; sourceTree = "<group>"; };
</ins><span class="cx">           72BAC3A423E17327008D741C /* ImageBufferBackend.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageBufferBackend.cpp; sourceTree = "<group>"; };
</span><span class="cx">          72BAC3A523E17328008D741C /* ImageBufferBackend.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageBufferBackend.h; sourceTree = "<group>"; };
</span><span class="cx">          72BAC3A623E17328008D741C /* PlatformImageBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformImageBuffer.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -26408,6 +26410,7 @@
</span><span class="cx">                          314BE3A51B3103FB00141982 /* NamedImageGeneratedImage.h */,
</span><span class="cx">                          7252396B254CADC200F5FB15 /* NativeImage.cpp */,
</span><span class="cx">                          55A336F61D8209F40022C4C7 /* NativeImage.h */,
</span><ins>+                               72AB9A1F255A9EA600E6EBF1 /* NativeImageReference.h */,
</ins><span class="cx">                           B27535520B053814002CE64F /* Path.cpp */,
</span><span class="cx">                          B27535530B053814002CE64F /* Path.h */,
</span><span class="cx">                          A88DD4880B4629B000C02990 /* PathTraversalState.cpp */,
</span><span class="lines">@@ -33442,6 +33445,7 @@
</span><span class="cx">                          A81872230977D3C0005826D9 /* NamedNodeMap.h in Headers */,
</span><span class="cx">                          A818721E0977D3C0005826D9 /* NameNodeList.h in Headers */,
</span><span class="cx">                          726D56E3253AE3660002EF90 /* NativeImage.h in Headers */,
</span><ins>+                               72AB9A21255A9FDE00E6EBF1 /* NativeImageReference.h in Headers */,
</ins><span class="cx">                           83B2D1751B8BCD6A00A02E47 /* NativeNodeFilter.h in Headers */,
</span><span class="cx">                          E10B9B6C0B747599003ED890 /* NativeXPathNSResolver.h in Headers */,
</span><span class="cx">                          93CCF0270AF6C52900018E89 /* NavigationAction.h in Headers */,
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsBitmapImagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/BitmapImage.cpp (269707 => 269708)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/BitmapImage.cpp   2020-11-12 00:37:55 UTC (rev 269707)
+++ trunk/Source/WebCore/platform/graphics/BitmapImage.cpp      2020-11-12 00:59:50 UTC (rev 269708)
</span><span class="lines">@@ -409,7 +409,7 @@
</span><span class="cx"> {
</span><span class="cx"> #if USE(CG)
</span><span class="cx">     // Never use subsampled images for drawing into PDF contexts.
</span><del>-    if (CGContextGetType(context.platformContext()) == kCGContextTypePDF)
</del><ins>+    if (context.hasPlatformContext() && CGContextGetType(context.platformContext()) == kCGContextTypePDF)
</ins><span class="cx">         return SubsamplingLevel::Default;
</span><span class="cx"> 
</span><span class="cx">     float scale = std::min(float(1), std::max(scaleFactor.width(), scaleFactor.height()));
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGraphicsContextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp (269707 => 269708)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp       2020-11-12 00:37:55 UTC (rev 269707)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp  2020-11-12 00:59:50 UTC (rev 269708)
</span><span class="lines">@@ -760,9 +760,6 @@
</span><span class="cx">     if (paintingDisabled())
</span><span class="cx">         return ImageDrawResult::DidNothing;
</span><span class="cx"> 
</span><del>-    if (m_impl)
-        return m_impl->drawImage(image, destination, source, options);
-
</del><span class="cx">     InterpolationQualityMaintainer interpolationQualityForThisScope(*this, options.interpolationQuality());
</span><span class="cx">     return image.draw(*this, destination, source, options);
</span><span class="cx"> }
</span><span class="lines">@@ -772,9 +769,6 @@
</span><span class="cx">     if (paintingDisabled())
</span><span class="cx">         return ImageDrawResult::DidNothing;
</span><span class="cx"> 
</span><del>-    if (m_impl)
-        return m_impl->drawTiledImage(image, destination, source, tileSize, spacing, options);
-
</del><span class="cx">     InterpolationQualityMaintainer interpolationQualityForThisScope(*this, options.interpolationQuality());
</span><span class="cx">     return image.drawTiled(*this, destination, source, tileSize, spacing, options);
</span><span class="cx"> }
</span><span class="lines">@@ -785,9 +779,6 @@
</span><span class="cx">     if (paintingDisabled())
</span><span class="cx">         return ImageDrawResult::DidNothing;
</span><span class="cx"> 
</span><del>-    if (m_impl)
-        return m_impl->drawTiledImage(image, destination, source, tileScaleFactor, hRule, vRule, options);
-
</del><span class="cx">     if (hRule == Image::StretchTile && vRule == Image::StretchTile) {
</span><span class="cx">         // Just do a scale.
</span><span class="cx">         return drawImage(image, destination, source, options);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsImageBufferh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ImageBuffer.h (269707 => 269708)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ImageBuffer.h     2020-11-12 00:37:55 UTC (rev 269707)
+++ trunk/Source/WebCore/platform/graphics/ImageBuffer.h        2020-11-12 00:59:50 UTC (rev 269708)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> #include "RenderingMode.h"
</span><span class="cx"> #include "RenderingResourceIdentifier.h"
</span><span class="cx"> #include <wtf/RefCounted.h>
</span><ins>+#include <wtf/WeakPtr.h>
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -39,7 +40,7 @@
</span><span class="cx"> class DrawingContext;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-class ImageBuffer : public RefCounted<ImageBuffer> {
</del><ins>+class ImageBuffer : public RefCounted<ImageBuffer>, public CanMakeWeakPtr<ImageBuffer> {
</ins><span class="cx"> public:
</span><span class="cx">     // Will return a null pointer on allocation failure.
</span><span class="cx">     WEBCORE_EXPORT static RefPtr<ImageBuffer> create(const FloatSize&, RenderingMode, ShouldUseDisplayList, RenderingPurpose, float resolutionScale = 1, ColorSpace = ColorSpace::SRGB, const HostWindow* = nullptr);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsNativeImagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/NativeImage.cpp (269707 => 269708)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/NativeImage.cpp   2020-11-12 00:37:55 UTC (rev 269707)
+++ trunk/Source/WebCore/platform/graphics/NativeImage.cpp      2020-11-12 00:59:50 UTC (rev 269708)
</span><span class="lines">@@ -37,9 +37,29 @@
</span><span class="cx">     return adoptRef(*new NativeImage(WTFMove(platformImage)));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+RefPtr<NativeImage> NativeImage::create(const PlatformImagePtr& platformImage, RenderingResourceIdentifier renderingResourceIdentifier)
+{
+    if (!platformImage)
+        return nullptr;
+    return adoptRef(*new NativeImage(platformImage, renderingResourceIdentifier));
+}
+
</ins><span class="cx"> NativeImage::NativeImage(PlatformImagePtr&& platformImage)
</span><span class="cx">     : m_platformImage(WTFMove(platformImage))
</span><ins>+    , m_renderingResourceIdentifier(RenderingResourceIdentifier::generate())
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+NativeImage::NativeImage(const PlatformImagePtr& platformImage, RenderingResourceIdentifier renderingResourceIdentifier)
+    : m_platformImage(platformImage)
+    , m_renderingResourceIdentifier(renderingResourceIdentifier)
+{
+}
+
+NativeImage::~NativeImage()
+{
+    if (m_observer)
+        m_observer->releaseNativeImage(m_renderingResourceIdentifier);
+}
+
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsNativeImageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/NativeImage.h (269707 => 269708)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/NativeImage.h     2020-11-12 00:37:55 UTC (rev 269707)
+++ trunk/Source/WebCore/platform/graphics/NativeImage.h        2020-11-12 00:59:50 UTC (rev 269708)
</span><span class="lines">@@ -30,27 +30,48 @@
</span><span class="cx"> #include "Color.h"
</span><span class="cx"> #include "IntSize.h"
</span><span class="cx"> #include "PlatformImage.h"
</span><ins>+#include "RenderingResourceIdentifier.h"
+#include <wtf/HashMap.h>
</ins><span class="cx"> #include <wtf/RefCounted.h>
</span><ins>+#include <wtf/WeakPtr.h>
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-class NativeImage : public RefCounted<NativeImage> {
</del><ins>+class NativeImage : public RefCounted<NativeImage>, public CanMakeWeakPtr<NativeImage> {
</ins><span class="cx">     WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><ins>+    class Observer {
+    public:
+        virtual ~Observer() = default;
+        virtual void releaseNativeImage(RenderingResourceIdentifier) = 0;
+    protected:
+        Observer() = default;
+    };
+
</ins><span class="cx">     static WEBCORE_EXPORT RefPtr<NativeImage> create(PlatformImagePtr&&);
</span><ins>+    static WEBCORE_EXPORT RefPtr<NativeImage> create(const PlatformImagePtr&, RenderingResourceIdentifier);
</ins><span class="cx"> 
</span><ins>+    WEBCORE_EXPORT ~NativeImage();
+
</ins><span class="cx">     const PlatformImagePtr& platformImage() const { return m_platformImage; }
</span><ins>+    RenderingResourceIdentifier renderingResourceIdentifier() const { return m_renderingResourceIdentifier; }
</ins><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT IntSize size() const;
</span><span class="cx">     bool hasAlpha() const;
</span><span class="cx">     Color singlePixelSolidColor() const;
</span><span class="cx"> 
</span><ins>+    void setObserver(Observer* observer) { m_observer = observer; }
</ins><span class="cx">     void clearSubimages();
</span><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     NativeImage(PlatformImagePtr&&);
</span><ins>+    NativeImage(const PlatformImagePtr&, RenderingResourceIdentifier);
</ins><span class="cx"> 
</span><span class="cx">     PlatformImagePtr m_platformImage;
</span><ins>+    Observer* m_observer { nullptr };
+    RenderingResourceIdentifier m_renderingResourceIdentifier;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><ins>+using NativeImageHashMap = HashMap<RenderingResourceIdentifier, Ref<NativeImage>>;
+
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsNativeImageReferenceh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/NativeImageReference.h (0 => 269708)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/NativeImageReference.h                            (rev 0)
+++ trunk/Source/WebCore/platform/graphics/NativeImageReference.h       2020-11-12 00:59:50 UTC (rev 269708)
</span><span class="lines">@@ -0,0 +1,37 @@
</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.
+ * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE 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 OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "NativeImage.h"
+
+namespace WebCore {
+
+using NativeImageReference = Ref<NativeImage>;
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsdisplaylistsDisplayListcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.cpp (269707 => 269708)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.cpp      2020-11-12 00:37:55 UTC (rev 269707)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.cpp 2020-11-12 00:59:50 UTC (rev 269708)
</span><span class="lines">@@ -52,6 +52,7 @@
</span><span class="cx"> 
</span><span class="cx"> DisplayList::DisplayList(DisplayList&& other)
</span><span class="cx">     : m_imageBuffers(std::exchange(other.m_imageBuffers, { }))
</span><ins>+    , m_nativeImages(std::exchange(other.m_nativeImages, { }))
</ins><span class="cx">     , m_items(std::exchange(other.m_items, nullptr))
</span><span class="cx">     , m_drawingItemExtents(std::exchange(other.m_drawingItemExtents, { }))
</span><span class="cx"> {
</span><span class="lines">@@ -68,6 +69,7 @@
</span><span class="cx"> DisplayList& DisplayList::operator=(DisplayList&& other)
</span><span class="cx"> {
</span><span class="cx">     m_imageBuffers = std::exchange(other.m_imageBuffers, { });
</span><ins>+    m_nativeImages = std::exchange(other.m_nativeImages, { });
</ins><span class="cx">     m_items = std::exchange(other.m_items, nullptr);
</span><span class="cx">     m_drawingItemExtents = std::exchange(other.m_drawingItemExtents, { });
</span><span class="cx">     return *this;
</span><span class="lines">@@ -79,6 +81,7 @@
</span><span class="cx">         m_items->clear();
</span><span class="cx">     m_drawingItemExtents.clear();
</span><span class="cx">     m_imageBuffers.clear();
</span><ins>+    m_nativeImages.clear();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool DisplayList::shouldDumpForFlags(AsTextFlags flags, ItemHandle item)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsdisplaylistsDisplayListh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.h (269707 => 269708)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.h        2020-11-12 00:37:55 UTC (rev 269707)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.h   2020-11-12 00:59:50 UTC (rev 269708)
</span><span class="lines">@@ -77,6 +77,7 @@
</span><span class="cx">     String asText(AsTextFlags) const;
</span><span class="cx"> 
</span><span class="cx">     const ImageBufferHashMap& imageBuffers() const { return m_imageBuffers; }
</span><ins>+    const NativeImageHashMap& nativeImages() const { return m_nativeImages; }
</ins><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT void setItemBufferClient(ItemBufferReadingClient*);
</span><span class="cx">     WEBCORE_EXPORT void setItemBufferClient(ItemBufferWritingClient*);
</span><span class="lines">@@ -153,14 +154,24 @@
</span><span class="cx">         m_drawingItemExtents.append(WTFMove(extent));
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    void cacheImageBuffer(Ref<WebCore::ImageBuffer>&& imageBuffer)
</del><ins>+    void cacheImageBuffer(WebCore::ImageBuffer& imageBuffer)
</ins><span class="cx">     {
</span><del>-        m_imageBuffers.add(imageBuffer->renderingResourceIdentifier(), WTFMove(imageBuffer));
</del><ins>+        m_imageBuffers.ensure(imageBuffer.renderingResourceIdentifier(), [&]() {
+            return makeRef(imageBuffer);
+        });
</ins><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    void cacheNativeImage(NativeImage& image)
+    {
+        m_nativeImages.ensure(image.renderingResourceIdentifier(), [&]() {
+            return makeRef(image);
+        });
+    }
+    
</ins><span class="cx">     static bool shouldDumpForFlags(AsTextFlags, ItemHandle);
</span><span class="cx"> 
</span><span class="cx">     ImageBufferHashMap m_imageBuffers;
</span><ins>+    NativeImageHashMap m_nativeImages;
</ins><span class="cx">     std::unique_ptr<ItemBuffer> m_items;
</span><span class="cx">     Vector<Optional<FloatRect>> m_drawingItemExtents;
</span><span class="cx">     bool m_tracksDrawingItemExtents { true };
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsdisplaylistsDisplayListItemBuffercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemBuffer.cpp (269707 => 269708)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemBuffer.cpp    2020-11-12 00:37:55 UTC (rev 269707)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemBuffer.cpp       2020-11-12 00:59:50 UTC (rev 269708)
</span><span class="lines">@@ -330,10 +330,6 @@
</span><span class="cx">         get<DrawLinesForText>().~DrawLinesForText();
</span><span class="cx">         return;
</span><span class="cx">     }
</span><del>-    case ItemType::DrawNativeImage: {
-        get<DrawNativeImage>().~DrawNativeImage();
-        return;
-    }
</del><span class="cx">     case ItemType::DrawPath: {
</span><span class="cx">         get<DrawPath>().~DrawPath();
</span><span class="cx">         return;
</span><span class="lines">@@ -440,6 +436,10 @@
</span><span class="cx">         static_assert(std::is_trivially_destructible<DrawImageBuffer>::value);
</span><span class="cx">         return;
</span><span class="cx">     }
</span><ins>+    case ItemType::DrawNativeImage: {
+        static_assert(std::is_trivially_destructible<DrawNativeImage>::value);
+        return;
+    }
</ins><span class="cx">     case ItemType::DrawLine: {
</span><span class="cx">         static_assert(std::is_trivially_destructible<DrawLine>::value);
</span><span class="cx">         return;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsdisplaylistsDisplayListItemTypecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemType.cpp (269707 => 269708)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemType.cpp      2020-11-12 00:37:55 UTC (rev 269707)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemType.cpp 2020-11-12 00:59:50 UTC (rev 269708)
</span><span class="lines">@@ -260,7 +260,6 @@
</span><span class="cx">     case ItemType::DrawGlyphs:
</span><span class="cx">     case ItemType::DrawImage:
</span><span class="cx">     case ItemType::DrawLinesForText:
</span><del>-    case ItemType::DrawNativeImage:
</del><span class="cx">     case ItemType::DrawPath:
</span><span class="cx">     case ItemType::DrawPattern:
</span><span class="cx">     case ItemType::DrawTiledImage:
</span><span class="lines">@@ -290,6 +289,7 @@
</span><span class="cx">     case ItemType::DrawDotsForDocumentMarker:
</span><span class="cx">     case ItemType::DrawEllipse:
</span><span class="cx">     case ItemType::DrawImageBuffer:
</span><ins>+    case ItemType::DrawNativeImage:
</ins><span class="cx">     case ItemType::DrawLine:
</span><span class="cx">     case ItemType::DrawRect:
</span><span class="cx">     case ItemType::EndTransparencyLayer:
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsdisplaylistsDisplayListItemscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp (269707 => 269708)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp 2020-11-12 00:37:55 UTC (rev 269707)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp    2020-11-12 00:59:50 UTC (rev 269708)
</span><span class="lines">@@ -457,29 +457,26 @@
</span><span class="cx"> 
</span><span class="cx"> static TextStream& operator<<(TextStream& ts, const DrawImageBuffer& item)
</span><span class="cx"> {
</span><del>-    ts.dumpProperty("rendering-resource-identifier", item.renderingResourceIdentifier());
</del><ins>+    ts.dumpProperty("image-buffer-identifier", item.imageBufferIdentifier());
</ins><span class="cx">     ts.dumpProperty("source-rect", item.source());
</span><span class="cx">     ts.dumpProperty("dest-rect", item.destinationRect());
</span><span class="cx">     return ts;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-DrawNativeImage::DrawNativeImage(NativeImage& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
-    : m_image(image)
-    , m_imageSize(imageSize)
-    , m_destinationRect(destRect)
-    , m_srcRect(srcRect)
-    , m_options(options)
</del><ins>+NO_RETURN_DUE_TO_ASSERT void DrawNativeImage::apply(GraphicsContext&) const
</ins><span class="cx"> {
</span><ins>+    ASSERT_NOT_REACHED();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void DrawNativeImage::apply(GraphicsContext& context) const
</del><ins>+void DrawNativeImage::apply(GraphicsContext& context, NativeImage& image) const
</ins><span class="cx"> {
</span><del>-    context.drawNativeImage(m_image, m_imageSize, m_destinationRect, m_srcRect, m_options);
</del><ins>+    context.drawNativeImage(image, m_imageSize, m_destinationRect, m_srcRect, m_options);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static TextStream& operator<<(TextStream& ts, const DrawNativeImage& item)
</span><span class="cx"> {
</span><span class="cx">     // FIXME: dump more stuff.
</span><ins>+    ts.dumpProperty("image-identifier", item.imageIdentifier());
</ins><span class="cx">     ts.dumpProperty("source-rect", item.source());
</span><span class="cx">     ts.dumpProperty("dest-rect", item.destinationRect());
</span><span class="cx">     return ts;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsdisplaylistsDisplayListItemsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h (269707 => 269708)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h   2020-11-12 00:37:55 UTC (rev 269707)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h      2020-11-12 00:59:50 UTC (rev 269708)
</span><span class="lines">@@ -1244,8 +1244,8 @@
</span><span class="cx">     static constexpr bool isInlineItem = true;
</span><span class="cx">     static constexpr bool isDrawingItem = true;
</span><span class="cx"> 
</span><del>-    DrawImageBuffer(RenderingResourceIdentifier renderingResourceIdentifier, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
-        : m_renderingResourceIdentifier(renderingResourceIdentifier)
</del><ins>+    DrawImageBuffer(RenderingResourceIdentifier imageBufferIdentifier, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
+        : m_imageBufferIdentifier(imageBufferIdentifier)
</ins><span class="cx">         , m_destinationRect(destRect)
</span><span class="cx">         , m_srcRect(srcRect)
</span><span class="cx">         , m_options(options)
</span><span class="lines">@@ -1252,7 +1252,7 @@
</span><span class="cx">     {
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    RenderingResourceIdentifier renderingResourceIdentifier() const { return m_renderingResourceIdentifier; }
</del><ins>+    RenderingResourceIdentifier imageBufferIdentifier() const { return m_imageBufferIdentifier; }
</ins><span class="cx">     FloatRect source() const { return m_srcRect; }
</span><span class="cx">     FloatRect destinationRect() const { return m_destinationRect; }
</span><span class="cx">     ImagePaintingOptions options() const { return m_options; }
</span><span class="lines">@@ -1265,7 +1265,7 @@
</span><span class="cx">     Optional<FloatRect> localBounds(const GraphicsContext&) const { return m_destinationRect; }
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    RenderingResourceIdentifier m_renderingResourceIdentifier;
</del><ins>+    RenderingResourceIdentifier m_imageBufferIdentifier;
</ins><span class="cx">     FloatRect m_destinationRect;
</span><span class="cx">     FloatRect m_srcRect;
</span><span class="cx">     ImagePaintingOptions m_options;
</span><span class="lines">@@ -1274,24 +1274,30 @@
</span><span class="cx"> class DrawNativeImage {
</span><span class="cx"> public:
</span><span class="cx">     static constexpr ItemType itemType = ItemType::DrawNativeImage;
</span><del>-    static constexpr bool isInlineItem = false;
</del><ins>+    static constexpr bool isInlineItem = true;
</ins><span class="cx">     static constexpr bool isDrawingItem = true;
</span><span class="cx"> 
</span><del>-    WEBCORE_EXPORT DrawNativeImage(NativeImage&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&);
</del><ins>+    DrawNativeImage(RenderingResourceIdentifier imageIdentifier, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
+        : m_imageIdentifier(imageIdentifier)
+        , m_imageSize(imageSize)
+        , m_destinationRect(destRect)
+        , m_srcRect(srcRect)
+        , m_options(options)
+    {
+    }
</ins><span class="cx"> 
</span><ins>+    RenderingResourceIdentifier imageIdentifier() const { return m_imageIdentifier; }
</ins><span class="cx">     const FloatRect& source() const { return m_srcRect; }
</span><span class="cx">     const FloatRect& destinationRect() const { return m_destinationRect; }
</span><span class="cx"> 
</span><del>-    void apply(GraphicsContext&) const;
</del><ins>+    NO_RETURN_DUE_TO_ASSERT void apply(GraphicsContext&) const;
+    void apply(GraphicsContext&, NativeImage&) const;
</ins><span class="cx"> 
</span><span class="cx">     Optional<FloatRect> globalBounds() const { return WTF::nullopt; }
</span><span class="cx">     Optional<FloatRect> localBounds(const GraphicsContext&) const { return m_destinationRect; }
</span><span class="cx"> 
</span><del>-    template<class Encoder> void encode(Encoder&) const;
-    template<class Decoder> static Optional<DrawNativeImage> decode(Decoder&);
-
</del><span class="cx"> private:
</span><del>-    Ref<NativeImage> m_image;
</del><ins>+    RenderingResourceIdentifier m_imageIdentifier;
</ins><span class="cx">     FloatSize m_imageSize;
</span><span class="cx">     FloatRect m_destinationRect;
</span><span class="cx">     FloatRect m_srcRect;
</span><span class="lines">@@ -1298,47 +1304,6 @@
</span><span class="cx">     ImagePaintingOptions m_options;
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-template<class Encoder>
-void DrawNativeImage::encode(Encoder& encoder) const
-{
-    encoder << m_image;
-    encoder << m_imageSize;
-    encoder << m_destinationRect;
-    encoder << m_srcRect;
-    encoder << m_options;
-}
-
-template<class Decoder>
-Optional<DrawNativeImage> DrawNativeImage::decode(Decoder& decoder)
-{
-    Optional<Ref<NativeImage>> image;
-    decoder >> image;
-    if (!image)
-        return WTF::nullopt;
-
-    Optional<FloatSize> imageSize;
-    decoder >> imageSize;
-    if (!imageSize)
-        return WTF::nullopt;
-
-    Optional<FloatRect> destinationRect;
-    decoder >> destinationRect;
-    if (!destinationRect)
-        return WTF::nullopt;
-
-    Optional<FloatRect> srcRect;
-    decoder >> srcRect;
-    if (!srcRect)
-        return WTF::nullopt;
-
-    Optional<ImagePaintingOptions> options;
-    decoder >> options;
-    if (!options)
-        return WTF::nullopt;
-
-    return {{ *image, *imageSize, *destinationRect, *srcRect, *options }};
-}
-
</del><span class="cx"> class DrawPattern {
</span><span class="cx"> public:
</span><span class="cx">     static constexpr ItemType itemType = ItemType::DrawPattern;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsdisplaylistsDisplayListRecordercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp (269707 => 269708)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp      2020-11-12 00:37:55 UTC (rev 269707)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp 2020-11-12 00:59:50 UTC (rev 269708)
</span><span class="lines">@@ -187,14 +187,17 @@
</span><span class="cx"> 
</span><span class="cx"> void Recorder::drawImageBuffer(WebCore::ImageBuffer& imageBuffer, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
</span><span class="cx"> {
</span><del>-    imageBuffer.flushDrawingContext();
-    m_displayList.cacheImageBuffer(makeRef(imageBuffer));
</del><ins>+    // FIXME: Call imageBuffer.flushDrawingContext() when <https://webkit.org/b/218773> is fixed.
+    m_displayList.cacheImageBuffer(imageBuffer);
</ins><span class="cx">     append<DrawImageBuffer>(imageBuffer.renderingResourceIdentifier(), destRect, srcRect, options);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Recorder::drawNativeImage(NativeImage& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
</span><span class="cx"> {
</span><del>-    append<DrawNativeImage>(image, imageSize, destRect, srcRect, options);
</del><ins>+    if (m_delegate)
+        m_delegate->cacheNativeImage(image);
+    m_displayList.cacheNativeImage(image);
+    append<DrawNativeImage>(image.renderingResourceIdentifier(), imageSize, destRect, srcRect, options);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Recorder::drawPattern(Image& image, const FloatRect& destRect, const FloatRect& tileRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& options)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsdisplaylistsDisplayListRecorderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h (269707 => 269708)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h        2020-11-12 00:37:55 UTC (rev 269707)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h   2020-11-12 00:59:50 UTC (rev 269708)
</span><span class="lines">@@ -66,6 +66,7 @@
</span><span class="cx">         virtual ~Delegate() { }
</span><span class="cx">         virtual void willAppendItemOfType(ItemType) { }
</span><span class="cx">         virtual void didAppendItemOfType(ItemType) { }
</span><ins>+        virtual void cacheNativeImage(NativeImage&) { }
</ins><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx"> private:
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsdisplaylistsDisplayListReplayercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListReplayer.cpp (269707 => 269708)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListReplayer.cpp      2020-11-12 00:37:55 UTC (rev 269707)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListReplayer.cpp 2020-11-12 00:59:50 UTC (rev 269708)
</span><span class="lines">@@ -34,10 +34,11 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> namespace DisplayList {
</span><span class="cx"> 
</span><del>-Replayer::Replayer(GraphicsContext& context, const DisplayList& displayList, const ImageBufferHashMap* imageBuffers, Delegate* delegate)
</del><ins>+Replayer::Replayer(GraphicsContext& context, const DisplayList& displayList, const ImageBufferHashMap* imageBuffers, const NativeImageHashMap* nativeImages, Delegate* delegate)
</ins><span class="cx">     : m_context(context)
</span><span class="cx">     , m_displayList(displayList)
</span><span class="cx">     , m_imageBuffers(imageBuffers ? *imageBuffers : m_displayList.imageBuffers())
</span><ins>+    , m_nativeImages(nativeImages ? *nativeImages : m_displayList.nativeImages())
</ins><span class="cx">     , m_delegate(delegate)
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="lines">@@ -51,10 +52,17 @@
</span><span class="cx"> 
</span><span class="cx">     if (item.is<DrawImageBuffer>()) {
</span><span class="cx">         auto& drawItem = item.get<DrawImageBuffer>();
</span><del>-        if (auto* imageBuffer = m_imageBuffers.get(drawItem.renderingResourceIdentifier()))
</del><ins>+        if (auto* imageBuffer = m_imageBuffers.get(drawItem.imageBufferIdentifier()))
</ins><span class="cx">             drawItem.apply(m_context, *imageBuffer);
</span><span class="cx">         return;
</span><span class="cx">     }
</span><ins>+    
+    if (item.is<DrawNativeImage>()) {
+        auto& drawItem = item.get<DrawNativeImage>();
+        if (auto* image = m_nativeImages.get(drawItem.imageIdentifier()))
+            drawItem.apply(m_context, *image);
+        return;
+    }
</ins><span class="cx"> 
</span><span class="cx">     item.apply(m_context);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsdisplaylistsDisplayListReplayerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListReplayer.h (269707 => 269708)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListReplayer.h        2020-11-12 00:37:55 UTC (rev 269707)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListReplayer.h   2020-11-12 00:59:50 UTC (rev 269708)
</span><span class="lines">@@ -42,7 +42,7 @@
</span><span class="cx">     WTF_MAKE_NONCOPYABLE(Replayer);
</span><span class="cx"> public:
</span><span class="cx">     class Delegate;
</span><del>-    WEBCORE_EXPORT Replayer(GraphicsContext&, const DisplayList&, const ImageBufferHashMap* = nullptr, Delegate* = nullptr);
</del><ins>+    WEBCORE_EXPORT Replayer(GraphicsContext&, const DisplayList&, const ImageBufferHashMap* = nullptr, const NativeImageHashMap* = nullptr, Delegate* = nullptr);
</ins><span class="cx">     WEBCORE_EXPORT ~Replayer();
</span><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT std::unique_ptr<DisplayList> replay(const FloatRect& initialClip = { }, bool trackReplayList = false);
</span><span class="lines">@@ -59,6 +59,7 @@
</span><span class="cx">     GraphicsContext& m_context;
</span><span class="cx">     const DisplayList& m_displayList;
</span><span class="cx">     const ImageBufferHashMap& m_imageBuffers;
</span><ins>+    const NativeImageHashMap& m_nativeImages;
</ins><span class="cx">     Delegate* m_delegate;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (269707 => 269708)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2020-11-12 00:37:55 UTC (rev 269707)
+++ trunk/Source/WebKit/ChangeLog       2020-11-12 00:59:50 UTC (rev 269708)
</span><span class="lines">@@ -1,3 +1,67 @@
</span><ins>+2020-11-11  Said Abou-Hallawa  <said@apple.com>
+
+        [GPU Process] Cache the NativeImage in GPU Process and allow referencing it with its RemoteResourceIdentifier
+        https://bugs.webkit.org/show_bug.cgi?id=217596
+
+        Reviewed by Simon Fraser.
+
+        Recorder::drawNativeImage() will ensure the NativeImage is cached before
+        recording the DrawNativeImage item with the renderingResourceIdentifier.
+
+        Because RemoteImageBufferProxy is a superclass of DisplayList::Recorder::
+        Delegate, it will ensure the NativeImage is cached in its RemoteResourceCacheProxy.
+
+        If the NativeImage is registered in RemoteResourceCacheProxy for the first
+        time, it is going to be sent as an IPC message to GPU. Upon receiving this
+        message, RemoteRenderingBackend will cache this NativeImage in its
+        RemoteResourceCache. This message has to be received for any NativeImage
+        only once for its entire life time.
+
+        When flushing the DisplayList of any ImageBuffer, RemoteImageBuffer will
+        ensure the NativeImages are cached in the RemoteResourceCache are passed
+        to DisplayList::Replayer so it can use them to get NativeImage for every
+        DrawNativeImage with the same renderingResourceIdentifier it was recorded
+        with.
+
+        When NativeImage is bing destroyed, its destructor will call its observer
+        virtual method releaseNativeImage(). RemoteResourceCacheProxy will be a
+        superclass NativeImage::Observer so its overriding method will be called.
+        When RemoteResourceCacheProxy::releaseNativeImage() is called it is going
+        to delete the NativeImage from RemoteResourceCacheProxy and is going to
+        send a message to GPU to delete the corresponding NativeImage from
+        RemoteResourceCache via RemoteRenderingBackend::releaseRemoteResource().
+
+        * GPUProcess/graphics/RemoteImageBuffer.h:
+        * GPUProcess/graphics/RemoteRenderingBackend.cpp:
+        (WebKit::RemoteRenderingBackend::cacheNativeImage):
+        (WebKit::RemoteRenderingBackend::decodeItem):
+        * GPUProcess/graphics/RemoteRenderingBackend.h:
+        * GPUProcess/graphics/RemoteRenderingBackend.messages.in:
+        * GPUProcess/graphics/RemoteResourceCache.cpp:
+        (WebKit::RemoteResourceCache::cacheNativeImage):
+        (WebKit::RemoteResourceCache::releaseRemoteResource):
+        * GPUProcess/graphics/RemoteResourceCache.h:
+        (WebKit::RemoteResourceCache::nativeImages const):
+        * Scripts/webkit/messages.py:
+        * Shared/WebCoreArgumentCoders.cpp:
+        (IPC::ArgumentCoder<Ref<NativeImage>>::encode):
+        (IPC::ArgumentCoder<Ref<NativeImage>>::decode):
+        * WebProcess/GPU/graphics/RemoteImageBufferProxy.h:
+        (WebKit::RemoteImageBufferProxy::~RemoteImageBufferProxy):
+        (WebKit::RemoteImageBufferProxy::RemoteImageBufferProxy):
+        * WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp:
+        (WebKit::RemoteRenderingBackendProxy::createImageBuffer):
+        (WebKit::RemoteRenderingBackendProxy::cacheNativeImage):
+        (WebKit::RemoteRenderingBackendProxy::releaseRemoteResource):
+        * WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h:
+        * WebProcess/GPU/graphics/RemoteResourceCacheProxy.cpp:
+        (WebKit::RemoteResourceCacheProxy::RemoteResourceCacheProxy):
+        (WebKit::RemoteResourceCacheProxy::cacheImageBuffer):
+        (WebKit::RemoteResourceCacheProxy::cachedImageBuffer):
+        (WebKit::RemoteResourceCacheProxy::cacheNativeImage):
+        (WebKit::RemoteResourceCacheProxy::releaseNativeImage):
+        * WebProcess/GPU/graphics/RemoteResourceCacheProxy.h:
+
</ins><span class="cx"> 2020-11-11  Chris Dumez  <cdumez@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Terminate WebProcesses if GPUProcess crashes more than twice in 30 seconds
</span></span></pre></div>
<a id="trunkSourceWebKitGPUProcessgraphicsRemoteImageBufferh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.h (269707 => 269708)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.h      2020-11-12 00:37:55 UTC (rev 269707)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.h 2020-11-12 00:59:50 UTC (rev 269708)
</span><span class="lines">@@ -70,7 +70,8 @@
</span><span class="cx">     {
</span><span class="cx">         if (!displayList.isEmpty()) {
</span><span class="cx">             const auto& imageBuffers = m_remoteRenderingBackend.remoteResourceCache().imageBuffers();
</span><del>-            WebCore::DisplayList::Replayer replayer { BaseConcreteImageBuffer::context(), displayList, &imageBuffers, this };
</del><ins>+            const auto& nativeImages = m_remoteRenderingBackend.remoteResourceCache().nativeImages();
+            WebCore::DisplayList::Replayer replayer { BaseConcreteImageBuffer::context(), displayList, &imageBuffers, &nativeImages, this };
</ins><span class="cx">             replayer.replay();
</span><span class="cx">         }
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceWebKitGPUProcessgraphicsRemoteRenderingBackendcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp (269707 => 269708)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp       2020-11-12 00:37:55 UTC (rev 269707)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp  2020-11-12 00:59:50 UTC (rev 269708)
</span><span class="lines">@@ -216,6 +216,11 @@
</span><span class="cx">     completionHandler(IPC::ImageDataReference(WTFMove(imageData)));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void RemoteRenderingBackend::cacheNativeImage(Ref<NativeImage>&& image)
+{
+    m_remoteResourceCache.cacheNativeImage(WTFMove(image));
+}
+
</ins><span class="cx"> void RemoteRenderingBackend::releaseRemoteResource(RenderingResourceIdentifier renderingResourceIdentifier)
</span><span class="cx"> {
</span><span class="cx">     m_remoteResourceCache.releaseRemoteResource(renderingResourceIdentifier);
</span><span class="lines">@@ -257,8 +262,6 @@
</span><span class="cx">         return decodeAndCreate<DisplayList::DrawImage>(data, length, handleLocation);
</span><span class="cx">     case DisplayList::ItemType::DrawLinesForText:
</span><span class="cx">         return decodeAndCreate<DisplayList::DrawLinesForText>(data, length, handleLocation);
</span><del>-    case DisplayList::ItemType::DrawNativeImage:
-        return decodeAndCreate<DisplayList::DrawNativeImage>(data, length, handleLocation);
</del><span class="cx">     case DisplayList::ItemType::DrawPath:
</span><span class="cx">         return decodeAndCreate<DisplayList::DrawPath>(data, length, handleLocation);
</span><span class="cx">     case DisplayList::ItemType::DrawPattern:
</span><span class="lines">@@ -301,6 +304,7 @@
</span><span class="cx">     case DisplayList::ItemType::DrawDotsForDocumentMarker:
</span><span class="cx">     case DisplayList::ItemType::DrawEllipse:
</span><span class="cx">     case DisplayList::ItemType::DrawImageBuffer:
</span><ins>+    case DisplayList::ItemType::DrawNativeImage:
</ins><span class="cx">     case DisplayList::ItemType::DrawLine:
</span><span class="cx">     case DisplayList::ItemType::DrawRect:
</span><span class="cx">     case DisplayList::ItemType::EndTransparencyLayer:
</span></span></pre></div>
<a id="trunkSourceWebKitGPUProcessgraphicsRemoteRenderingBackendh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h (269707 => 269708)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h 2020-11-12 00:37:55 UTC (rev 269707)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h    2020-11-12 00:59:50 UTC (rev 269708)
</span><span class="lines">@@ -45,6 +45,7 @@
</span><span class="cx"> class Item;
</span><span class="cx"> }
</span><span class="cx"> class FloatSize;
</span><ins>+class NativeImage;
</ins><span class="cx"> enum class ColorSpace : uint8_t;
</span><span class="cx"> enum class RenderingMode : bool;
</span><span class="cx"> }
</span><span class="lines">@@ -105,6 +106,7 @@
</span><span class="cx">     void createImageBuffer(const WebCore::FloatSize& logicalSize, WebCore::RenderingMode, float resolutionScale, WebCore::ColorSpace, WebCore::RenderingResourceIdentifier);
</span><span class="cx">     void wakeUpAndApplyDisplayList(WebCore::DisplayList::ItemBufferIdentifier initialIdentifier, uint64_t initialOffset, WebCore::RenderingResourceIdentifier destinationBufferIdentifier);
</span><span class="cx">     void getImageData(WebCore::AlphaPremultiplication outputFormat, WebCore::IntRect srcRect, WebCore::RenderingResourceIdentifier, CompletionHandler<void(IPC::ImageDataReference&&)>&&);
</span><ins>+    void cacheNativeImage(Ref<WebCore::NativeImage>&&);
</ins><span class="cx">     void releaseRemoteResource(WebCore::RenderingResourceIdentifier);
</span><span class="cx">     void didCreateSharedDisplayListHandle(WebCore::DisplayList::ItemBufferIdentifier, const SharedMemory::IPCHandle&, WebCore::RenderingResourceIdentifier destinationBufferIdentifier);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitGPUProcessgraphicsRemoteRenderingBackendmessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.messages.in (269707 => 269708)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.messages.in       2020-11-12 00:37:55 UTC (rev 269707)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.messages.in  2020-11-12 00:59:50 UTC (rev 269708)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx">     CreateImageBuffer(WebCore::FloatSize logicalSize, WebCore::RenderingMode renderingMode, float resolutionScale, WebCore::ColorSpace colorSpace, WebCore::RenderingResourceIdentifier renderingResourceIdentifier)
</span><span class="cx">     WakeUpAndApplyDisplayList(WebCore::DisplayList::ItemBufferIdentifier initialIdentifier, uint64_t initialOffset, WebCore::RenderingResourceIdentifier destinationBufferIdentifier)
</span><span class="cx">     GetImageData(enum:uint8_t WebCore::AlphaPremultiplication outputFormat, WebCore::IntRect srcRect, WebCore::RenderingResourceIdentifier renderingResourceIdentifier) -> (IPC::ImageDataReference imageData) Synchronous
</span><ins>+    CacheNativeImage(WebCore::NativeImageReference nativeImage)
</ins><span class="cx">     DidCreateSharedDisplayListHandle(WebCore::DisplayList::ItemBufferIdentifier identifier, WebKit::SharedMemory::IPCHandle handle, WebCore::RenderingResourceIdentifier destinationBufferIdentifier)
</span><span class="cx">     ReleaseRemoteResource(WebCore::RenderingResourceIdentifier renderingResourceIdentifier)
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKitGPUProcessgraphicsRemoteResourceCachecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteResourceCache.cpp (269707 => 269708)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/GPUProcess/graphics/RemoteResourceCache.cpp  2020-11-12 00:37:55 UTC (rev 269707)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteResourceCache.cpp     2020-11-12 00:59:50 UTC (rev 269708)
</span><span class="lines">@@ -42,10 +42,18 @@
</span><span class="cx">     return m_imageBuffers.get(renderingResourceIdentifier);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void RemoteResourceCache::cacheNativeImage(Ref<NativeImage>&& image)
+{
+    auto addResult = m_nativeImages.add(image->renderingResourceIdentifier(), WTFMove(image));
+    ASSERT_UNUSED(addResult, addResult.isNewEntry);
+}
+
</ins><span class="cx"> void RemoteResourceCache::releaseRemoteResource(RenderingResourceIdentifier renderingResourceIdentifier)
</span><span class="cx"> {
</span><span class="cx">     if (m_imageBuffers.remove(renderingResourceIdentifier))
</span><span class="cx">         return;
</span><ins>+    if (m_nativeImages.remove(renderingResourceIdentifier))
+        return;
</ins><span class="cx">     // Caching the remote resource should have happened before releasing it.
</span><span class="cx">     ASSERT_NOT_REACHED();
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKitGPUProcessgraphicsRemoteResourceCacheh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteResourceCache.h (269707 => 269708)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/GPUProcess/graphics/RemoteResourceCache.h    2020-11-12 00:37:55 UTC (rev 269707)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteResourceCache.h       2020-11-12 00:59:50 UTC (rev 269708)
</span><span class="lines">@@ -44,12 +44,15 @@
</span><span class="cx"> 
</span><span class="cx">     void cacheImageBuffer(Ref<WebCore::ImageBuffer>&&);
</span><span class="cx">     WebCore::ImageBuffer* cachedImageBuffer(WebCore::RenderingResourceIdentifier);
</span><ins>+    void cacheNativeImage(Ref<WebCore::NativeImage>&&);
</ins><span class="cx">     void releaseRemoteResource(WebCore::RenderingResourceIdentifier);
</span><span class="cx">     
</span><span class="cx">     const WebCore::ImageBufferHashMap& imageBuffers() const { return m_imageBuffers; }
</span><ins>+    const WebCore::NativeImageHashMap& nativeImages() const { return m_nativeImages; }
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     WebCore::ImageBufferHashMap m_imageBuffers;
</span><ins>+    WebCore::NativeImageHashMap m_nativeImages;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKitScriptswebkitmessagespy"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Scripts/webkit/messages.py (269707 => 269708)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Scripts/webkit/messages.py   2020-11-12 00:37:55 UTC (rev 269707)
+++ trunk/Source/WebKit/Scripts/webkit/messages.py      2020-11-12 00:59:50 UTC (rev 269708)
</span><span class="lines">@@ -218,7 +218,7 @@
</span><span class="cx">         'WebCore::PlaybackTargetClientContextIdentifier',
</span><span class="cx">         'WebCore::MediaPlayerIdentifier',
</span><span class="cx">         'WebCore::MediaSessionIdentifier',
</span><del>-        'WebCore::NativeImage',
</del><ins>+        'WebCore::NativeImageReference',
</ins><span class="cx">         'WebCore::PageIdentifier',
</span><span class="cx">         'WebCore::PluginLoadClientPolicy',
</span><span class="cx">         'WebCore::PointerID',
</span></span></pre></div>
<a id="trunkSourceWebKitSharedWebCoreArgumentCoderscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp (269707 => 269708)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp     2020-11-12 00:37:55 UTC (rev 269707)
+++ trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp        2020-11-12 00:59:50 UTC (rev 269708)
</span><span class="lines">@@ -1115,6 +1115,7 @@
</span><span class="cx">     ShareableBitmap::Handle handle;
</span><span class="cx">     bitmap->createHandle(handle);
</span><span class="cx"> 
</span><ins>+    encoder << image->renderingResourceIdentifier();
</ins><span class="cx">     encoder << handle;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1125,6 +1126,10 @@
</span><span class="cx">     if (!didCreateGraphicsContext.hasValue() || !didCreateGraphicsContext.value())
</span><span class="cx">         return WTF::nullopt;
</span><span class="cx"> 
</span><ins>+    RenderingResourceIdentifier renderingResourceIdentifier;
+    if (!decoder.decode(renderingResourceIdentifier))
+        return WTF::nullopt;
+    
</ins><span class="cx">     ShareableBitmap::Handle handle;
</span><span class="cx">     if (!decoder.decode(handle))
</span><span class="cx">         return WTF::nullopt;
</span><span class="lines">@@ -1141,6 +1146,10 @@
</span><span class="cx">     if (!nativeImage)
</span><span class="cx">         return WTF::nullopt;
</span><span class="cx"> 
</span><ins>+    nativeImage = NativeImage::create(nativeImage->platformImage(), renderingResourceIdentifier);
+    if (!nativeImage)
+        return WTF::nullopt;
+
</ins><span class="cx">     return makeRef(*nativeImage);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessGPUgraphicsRemoteImageBufferProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h (269707 => 269708)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h     2020-11-12 00:37:55 UTC (rev 269707)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h        2020-11-12 00:59:50 UTC (rev 269708)
</span><span class="lines">@@ -61,6 +61,7 @@
</span><span class="cx">         if (!m_remoteRenderingBackendProxy)
</span><span class="cx">             return;
</span><span class="cx">         flushDrawingContext();
</span><ins>+        m_remoteRenderingBackendProxy->remoteResourceCacheProxy().releaseImageBuffer(m_renderingResourceIdentifier);
</ins><span class="cx">         m_remoteRenderingBackendProxy->releaseRemoteResource(m_renderingResourceIdentifier);
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -81,6 +82,8 @@
</span><span class="cx">         , m_remoteRenderingBackendProxy(makeWeakPtr(remoteRenderingBackendProxy))
</span><span class="cx">     {
</span><span class="cx">         ASSERT(m_remoteRenderingBackendProxy);
</span><ins>+        m_remoteRenderingBackendProxy->remoteResourceCacheProxy().cacheImageBuffer(*this);
+
</ins><span class="cx">         m_drawingContext.displayList().setItemBufferClient(this);
</span><span class="cx">         m_drawingContext.displayList().setTracksDrawingItemExtents(false);
</span><span class="cx">     }
</span><span class="lines">@@ -181,6 +184,12 @@
</span><span class="cx">         displayList.clear();
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    void cacheNativeImage(WebCore::NativeImage& image) override
+    {
+        if (m_remoteRenderingBackendProxy)
+            m_remoteRenderingBackendProxy->remoteResourceCacheProxy().cacheNativeImage(image);
+    }
+
</ins><span class="cx">     WebCore::DisplayList::ItemBufferHandle createItemBuffer(size_t capacity) override
</span><span class="cx">     {
</span><span class="cx">         if (m_remoteRenderingBackendProxy)
</span><span class="lines">@@ -209,8 +218,6 @@
</span><span class="cx">             return IPC::Encoder::encodeSingleObject<WebCore::DisplayList::DrawImage>(item.get<WebCore::DisplayList::DrawImage>());
</span><span class="cx">         case WebCore::DisplayList::ItemType::DrawLinesForText:
</span><span class="cx">             return IPC::Encoder::encodeSingleObject<WebCore::DisplayList::DrawLinesForText>(item.get<WebCore::DisplayList::DrawLinesForText>());
</span><del>-        case WebCore::DisplayList::ItemType::DrawNativeImage:
-            return IPC::Encoder::encodeSingleObject<WebCore::DisplayList::DrawNativeImage>(item.get<WebCore::DisplayList::DrawNativeImage>());
</del><span class="cx">         case WebCore::DisplayList::ItemType::DrawPath:
</span><span class="cx">             return IPC::Encoder::encodeSingleObject<WebCore::DisplayList::DrawPath>(item.get<WebCore::DisplayList::DrawPath>());
</span><span class="cx">         case WebCore::DisplayList::ItemType::DrawPattern:
</span><span class="lines">@@ -253,6 +260,7 @@
</span><span class="cx">         case WebCore::DisplayList::ItemType::DrawDotsForDocumentMarker:
</span><span class="cx">         case WebCore::DisplayList::ItemType::DrawEllipse:
</span><span class="cx">         case WebCore::DisplayList::ItemType::DrawImageBuffer:
</span><ins>+        case WebCore::DisplayList::ItemType::DrawNativeImage:
</ins><span class="cx">         case WebCore::DisplayList::ItemType::DrawLine:
</span><span class="cx">         case WebCore::DisplayList::ItemType::DrawRect:
</span><span class="cx">         case WebCore::DisplayList::ItemType::EndTransparencyLayer:
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessGPUgraphicsRemoteRenderingBackendProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp (269707 => 269708)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp      2020-11-12 00:37:55 UTC (rev 269707)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp 2020-11-12 00:59:50 UTC (rev 269708)
</span><span class="lines">@@ -101,7 +101,6 @@
</span><span class="cx"> 
</span><span class="cx">     if (imageBuffer) {
</span><span class="cx">         send(Messages::RemoteRenderingBackend::CreateImageBuffer(size, renderingMode, resolutionScale, colorSpace, imageBuffer->renderingResourceIdentifier()), m_renderingBackendIdentifier);
</span><del>-        m_remoteResourceCacheProxy.cacheImageBuffer(imageBuffer->renderingResourceIdentifier(), imageBuffer.get());
</del><span class="cx">         return imageBuffer;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -139,9 +138,13 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void RemoteRenderingBackendProxy::cacheNativeImage(NativeImage& image)
+{
+    send(Messages::RemoteRenderingBackend::CacheNativeImage(makeRef(image)), m_renderingBackendIdentifier);
+}
+
</ins><span class="cx"> void RemoteRenderingBackendProxy::releaseRemoteResource(RenderingResourceIdentifier renderingResourceIdentifier)
</span><span class="cx"> {
</span><del>-    m_remoteResourceCacheProxy.releaseImageBuffer(renderingResourceIdentifier);
</del><span class="cx">     send(Messages::RemoteRenderingBackend::ReleaseRemoteResource(renderingResourceIdentifier), m_renderingBackendIdentifier);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessGPUgraphicsRemoteRenderingBackendProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h (269707 => 269708)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h        2020-11-12 00:37:55 UTC (rev 269707)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h   2020-11-12 00:59:50 UTC (rev 269708)
</span><span class="lines">@@ -77,6 +77,7 @@
</span><span class="cx">     RefPtr<WebCore::ImageData> getImageData(WebCore::AlphaPremultiplication outputFormat, const WebCore::IntRect& srcRect, WebCore::RenderingResourceIdentifier);
</span><span class="cx">     void submitDisplayList(const WebCore::DisplayList::DisplayList&, WebCore::RenderingResourceIdentifier destinationBufferIdentifier);
</span><span class="cx">     WebCore::DisplayList::FlushIdentifier flushDisplayListAndCommit(const WebCore::DisplayList::DisplayList&, WebCore::RenderingResourceIdentifier);
</span><ins>+    void cacheNativeImage(WebCore::NativeImage&);
</ins><span class="cx">     void releaseRemoteResource(WebCore::RenderingResourceIdentifier);
</span><span class="cx"> 
</span><span class="cx">     bool waitForImageBufferBackendWasCreated();
</span><span class="lines">@@ -91,7 +92,7 @@
</span><span class="cx">     void imageBufferBackendWasCreated(const WebCore::FloatSize& logicalSize, const WebCore::IntSize& backendSize, float resolutionScale, WebCore::ColorSpace, ImageBufferBackendHandle, WebCore::RenderingResourceIdentifier);
</span><span class="cx">     void flushDisplayListWasCommitted(WebCore::DisplayList::FlushIdentifier, WebCore::RenderingResourceIdentifier);
</span><span class="cx"> 
</span><del>-    RemoteResourceCacheProxy m_remoteResourceCacheProxy;
</del><ins>+    RemoteResourceCacheProxy m_remoteResourceCacheProxy { *this };
</ins><span class="cx">     HashMap<WebCore::DisplayList::ItemBufferIdentifier, RefPtr<DisplayListWriterHandle>> m_sharedDisplayListHandles;
</span><span class="cx">     Deque<WebCore::DisplayList::ItemBufferIdentifier> m_identifiersOfReusableHandles;
</span><span class="cx">     HashSet<WebCore::DisplayList::ItemBufferIdentifier> m_identifiersOfHandlesAvailableForWriting;
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessGPUgraphicsRemoteResourceCacheProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteResourceCacheProxy.cpp (269707 => 269708)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteResourceCacheProxy.cpp 2020-11-12 00:37:55 UTC (rev 269707)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteResourceCacheProxy.cpp    2020-11-12 00:59:50 UTC (rev 269708)
</span><span class="lines">@@ -29,20 +29,24 @@
</span><span class="cx"> #if ENABLE(GPU_PROCESS)
</span><span class="cx"> 
</span><span class="cx"> #include "RemoteRenderingBackendProxy.h"
</span><del>-#include <WebCore/ImageBuffer.h>
</del><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> using namespace WebCore;
</span><span class="cx"> 
</span><del>-void RemoteResourceCacheProxy::cacheImageBuffer(RenderingResourceIdentifier renderingResourceIdentifier, WebCore::ImageBuffer* imageBuffer)
</del><ins>+RemoteResourceCacheProxy::RemoteResourceCacheProxy(RemoteRenderingBackendProxy& remoteRenderingBackendProxy)
+    : m_remoteRenderingBackendProxy(remoteRenderingBackendProxy)
</ins><span class="cx"> {
</span><del>-    auto addResult = m_imageBuffers.add(renderingResourceIdentifier, imageBuffer);
</del><ins>+}
+
+void RemoteResourceCacheProxy::cacheImageBuffer(WebCore::ImageBuffer& imageBuffer)
+{
+    auto addResult = m_imageBuffers.add(imageBuffer.renderingResourceIdentifier(), makeWeakPtr(imageBuffer));
</ins><span class="cx">     ASSERT_UNUSED(addResult, addResult.isNewEntry);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> ImageBuffer* RemoteResourceCacheProxy::cachedImageBuffer(RenderingResourceIdentifier renderingResourceIdentifier)
</span><span class="cx"> {
</span><del>-    return m_imageBuffers.get(renderingResourceIdentifier);
</del><ins>+    return m_imageBuffers.get(renderingResourceIdentifier).get();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RemoteResourceCacheProxy::releaseImageBuffer(RenderingResourceIdentifier renderingResourceIdentifier)
</span><span class="lines">@@ -51,6 +55,28 @@
</span><span class="cx">     ASSERT_UNUSED(found, found);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void RemoteResourceCacheProxy::cacheNativeImage(NativeImage& image)
+{
+    m_nativeImages.ensure(image.renderingResourceIdentifier(), [&]() {
+        // Set itself as an observer to NativeImage, so releaseNativeImage()
+        // gets called when NativeImage is being deleleted.
+        image.setObserver(this);
+
+        // Tell the GPU process to cache this resource.
+        m_remoteRenderingBackendProxy.cacheNativeImage(image);
+        return makeWeakPtr(image);
+    });
+}
+
+void RemoteResourceCacheProxy::releaseNativeImage(RenderingResourceIdentifier renderingResourceIdentifier)
+{
+    if (!m_nativeImages.remove(renderingResourceIdentifier))
+        return;
+
+    // Tell the GPU process to remove this resource.
+    m_remoteRenderingBackendProxy.releaseRemoteResource(renderingResourceIdentifier);
+}
+
</ins><span class="cx"> } // namespace WebKit
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(GPU_PROCESS)
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessGPUgraphicsRemoteResourceCacheProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteResourceCacheProxy.h (269707 => 269708)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteResourceCacheProxy.h   2020-11-12 00:37:55 UTC (rev 269707)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteResourceCacheProxy.h      2020-11-12 00:59:50 UTC (rev 269708)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(GPU_PROCESS)
</span><span class="cx"> 
</span><ins>+#include <WebCore/NativeImage.h>
</ins><span class="cx"> #include <WebCore/RenderingResourceIdentifier.h>
</span><span class="cx"> #include <wtf/HashMap.h>
</span><span class="cx"> 
</span><span class="lines">@@ -36,18 +37,27 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><del>-class RemoteResourceCacheProxy {
</del><ins>+class RemoteRenderingBackendProxy;
+
+class RemoteResourceCacheProxy : public WebCore::NativeImage::Observer {
</ins><span class="cx"> public:
</span><del>-    RemoteResourceCacheProxy() = default;
</del><ins>+    RemoteResourceCacheProxy(RemoteRenderingBackendProxy&);
</ins><span class="cx"> 
</span><del>-    void cacheImageBuffer(WebCore::RenderingResourceIdentifier, WebCore::ImageBuffer*);
</del><ins>+    void cacheImageBuffer(WebCore::ImageBuffer&);
</ins><span class="cx">     WebCore::ImageBuffer* cachedImageBuffer(WebCore::RenderingResourceIdentifier);
</span><span class="cx">     void releaseImageBuffer(WebCore::RenderingResourceIdentifier);
</span><span class="cx"> 
</span><ins>+    void cacheNativeImage(WebCore::NativeImage&);
+
</ins><span class="cx"> private:
</span><del>-    using RemoteImageBufferProxyHashMap = HashMap<WebCore::RenderingResourceIdentifier, WebCore::ImageBuffer*>;
</del><ins>+    using ImageBufferHashMap = HashMap<WebCore::RenderingResourceIdentifier, WeakPtr<WebCore::ImageBuffer>>;
+    using NativeImageHashMap = HashMap<WebCore::RenderingResourceIdentifier, WeakPtr<WebCore::NativeImage>>;
+    
+    void releaseNativeImage(WebCore::RenderingResourceIdentifier) override;
</ins><span class="cx"> 
</span><del>-    RemoteImageBufferProxyHashMap m_imageBuffers;
</del><ins>+    ImageBufferHashMap m_imageBuffers;
+    NativeImageHashMap m_nativeImages;
+    RemoteRenderingBackendProxy& m_remoteRenderingBackendProxy;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre>
</div>
</div>

</body>
</html>