Title: [283955] trunk/Source/WebKit
Revision
283955
Author
mmaxfi...@apple.com
Date
2021-10-11 17:48:22 -0700 (Mon, 11 Oct 2021)

Log Message

[GPU Process] Unique RenderingResourceIdentifiers Part 5: Migrate RemoteResourceCache to QualifiedRenderingResourceIdentifier
https://bugs.webkit.org/show_bug.cgi?id=231407
<rdar://problem/84010479>

Reviewed by Said Abou-Hallawa.

This pushes QualifiedRenderingResourceIdentifier down into RemoteResourceCache, but doesn't go all the way.
This patch augments RemoteResourceCache's API to accept QualifiedRenderingResourceIdentifiers, and also
migrates RemoteResourceCache::m_resourceUseCounters to use QualifiedRenderingResourceIdentifiers.

RemoteResourceCache::m_imageBuffers, RemoteResourceCache::m_nativeImages, and RemoteResourceCache::m_fonts
are WebCore typedefs, and are passed to WebCore's display list replaying code, but that code should have no
notion of process identifiers. Therefore, in order to make those members hold data that WebCore doesn't
understand, I'm going to have to wrap an opaque class around them and pass that class around instead of
the raw HashMaps. I'll do that in another patch.

No new tests because there is no behavior change.

* GPUProcess/graphics/RemoteGraphicsContextGL.cpp:
(WebKit::RemoteGraphicsContextGL::paintPixelBufferToImageBuffer):
* GPUProcess/graphics/RemoteRenderingBackend.cpp:
(WebKit::RemoteRenderingBackend::RemoteRenderingBackend):
(WebKit::RemoteRenderingBackend::createImageBufferWithQualifiedIdentifier):
(WebKit::RemoteRenderingBackend::ReplayerDelegate::ReplayerDelegate):
(WebKit::RemoteRenderingBackend::ReplayerDelegate::recordResourceUse):
(WebKit::RemoteRenderingBackend::submit):
(WebKit::RemoteRenderingBackend::nextDestinationImageBufferAfterApplyingDisplayLists):
(WebKit::RemoteRenderingBackend::wakeUpAndApplyDisplayListWithQualifiedIdentifier):
(WebKit::RemoteRenderingBackend::getDataURLForImageBufferWithQualifiedIdentifier):
(WebKit::RemoteRenderingBackend::getDataForImageBufferWithQualifiedIdentifier):
(WebKit::RemoteRenderingBackend::getShareableBitmapForImageBufferWithQualifiedIdentifier):
(WebKit::RemoteRenderingBackend::cacheNativeImageWithQualifiedIdentifier):
(WebKit::RemoteRenderingBackend::cacheFontWithQualifiedIdentifier):
(WebKit::RemoteRenderingBackend::releaseRemoteResourceWithQualifiedIdentifier):
(WebKit::RemoteRenderingBackend::finalizeRenderingUpdate):
* GPUProcess/graphics/RemoteRenderingBackend.h:
* GPUProcess/graphics/RemoteResourceCache.cpp:
(WebKit::RemoteResourceCache::RemoteResourceCache):
(WebKit::RemoteResourceCache::cacheImageBuffer):
(WebKit::RemoteResourceCache::cachedImageBuffer const):
(WebKit::RemoteResourceCache::cacheNativeImage):
(WebKit::RemoteResourceCache::cachedNativeImage const):
(WebKit::RemoteResourceCache::cacheFont):
(WebKit::RemoteResourceCache::cachedFont const):
(WebKit::RemoteResourceCache::ensureResourceUseCounter):
(WebKit::RemoteResourceCache::maybeRemoveResource):
(WebKit::RemoteResourceCache::recordResourceUse):
(WebKit::RemoteResourceCache::releaseRemoteResource):
* GPUProcess/graphics/RemoteResourceCache.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (283954 => 283955)


--- trunk/Source/WebKit/ChangeLog	2021-10-12 00:33:18 UTC (rev 283954)
+++ trunk/Source/WebKit/ChangeLog	2021-10-12 00:48:22 UTC (rev 283955)
@@ -1,3 +1,55 @@
+2021-10-11  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        [GPU Process] Unique RenderingResourceIdentifiers Part 5: Migrate RemoteResourceCache to QualifiedRenderingResourceIdentifier
+        https://bugs.webkit.org/show_bug.cgi?id=231407
+        <rdar://problem/84010479>
+
+        Reviewed by Said Abou-Hallawa.
+
+        This pushes QualifiedRenderingResourceIdentifier down into RemoteResourceCache, but doesn't go all the way.
+        This patch augments RemoteResourceCache's API to accept QualifiedRenderingResourceIdentifiers, and also
+        migrates RemoteResourceCache::m_resourceUseCounters to use QualifiedRenderingResourceIdentifiers.
+
+        RemoteResourceCache::m_imageBuffers, RemoteResourceCache::m_nativeImages, and RemoteResourceCache::m_fonts
+        are WebCore typedefs, and are passed to WebCore's display list replaying code, but that code should have no
+        notion of process identifiers. Therefore, in order to make those members hold data that WebCore doesn't
+        understand, I'm going to have to wrap an opaque class around them and pass that class around instead of
+        the raw HashMaps. I'll do that in another patch.
+
+        No new tests because there is no behavior change.
+
+        * GPUProcess/graphics/RemoteGraphicsContextGL.cpp:
+        (WebKit::RemoteGraphicsContextGL::paintPixelBufferToImageBuffer):
+        * GPUProcess/graphics/RemoteRenderingBackend.cpp:
+        (WebKit::RemoteRenderingBackend::RemoteRenderingBackend):
+        (WebKit::RemoteRenderingBackend::createImageBufferWithQualifiedIdentifier):
+        (WebKit::RemoteRenderingBackend::ReplayerDelegate::ReplayerDelegate):
+        (WebKit::RemoteRenderingBackend::ReplayerDelegate::recordResourceUse):
+        (WebKit::RemoteRenderingBackend::submit):
+        (WebKit::RemoteRenderingBackend::nextDestinationImageBufferAfterApplyingDisplayLists):
+        (WebKit::RemoteRenderingBackend::wakeUpAndApplyDisplayListWithQualifiedIdentifier):
+        (WebKit::RemoteRenderingBackend::getDataURLForImageBufferWithQualifiedIdentifier):
+        (WebKit::RemoteRenderingBackend::getDataForImageBufferWithQualifiedIdentifier):
+        (WebKit::RemoteRenderingBackend::getShareableBitmapForImageBufferWithQualifiedIdentifier):
+        (WebKit::RemoteRenderingBackend::cacheNativeImageWithQualifiedIdentifier):
+        (WebKit::RemoteRenderingBackend::cacheFontWithQualifiedIdentifier):
+        (WebKit::RemoteRenderingBackend::releaseRemoteResourceWithQualifiedIdentifier):
+        (WebKit::RemoteRenderingBackend::finalizeRenderingUpdate):
+        * GPUProcess/graphics/RemoteRenderingBackend.h:
+        * GPUProcess/graphics/RemoteResourceCache.cpp:
+        (WebKit::RemoteResourceCache::RemoteResourceCache):
+        (WebKit::RemoteResourceCache::cacheImageBuffer):
+        (WebKit::RemoteResourceCache::cachedImageBuffer const):
+        (WebKit::RemoteResourceCache::cacheNativeImage):
+        (WebKit::RemoteResourceCache::cachedNativeImage const):
+        (WebKit::RemoteResourceCache::cacheFont):
+        (WebKit::RemoteResourceCache::cachedFont const):
+        (WebKit::RemoteResourceCache::ensureResourceUseCounter):
+        (WebKit::RemoteResourceCache::maybeRemoveResource):
+        (WebKit::RemoteResourceCache::recordResourceUse):
+        (WebKit::RemoteResourceCache::releaseRemoteResource):
+        * GPUProcess/graphics/RemoteResourceCache.h:
+
 2021-10-11  Wenson Hsieh  <wenson_hs...@apple.com>
 
         Introduce RemoteDisplayListRecorderProxy and RemoteDisplayListRecorder

Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp (283954 => 283955)


--- trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp	2021-10-12 00:33:18 UTC (rev 283954)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp	2021-10-12 00:48:22 UTC (rev 283955)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2020 Apple Inc. All rights reserved.
+ * Copyright (C) 2020-2021 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -232,7 +232,7 @@
     Condition conditionVariable;
     bool isFinished = false;
     m_renderingBackend->dispatch([&, contextAttributes = m_context->contextAttributes()]() mutable {
-        if (auto imageBuffer = m_renderingBackend->remoteResourceCache().cachedImageBuffer(target.object())) {
+        if (auto imageBuffer = m_renderingBackend->remoteResourceCache().cachedImageBuffer(target)) {
             // Here we do not try to play back pending commands for imageBuffer. Currently this call is only made for empty
             // image buffers and there's no good way to add display lists.
             if (pixelBuffer)

Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp (283954 => 283955)


--- trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp	2021-10-12 00:33:18 UTC (rev 283954)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp	2021-10-12 00:48:22 UTC (rev 283955)
@@ -82,6 +82,7 @@
 
 RemoteRenderingBackend::RemoteRenderingBackend(GPUConnectionToWebProcess& gpuConnectionToWebProcess, RemoteRenderingBackendCreationParameters&& creationParameters)
     : m_workQueue(WorkQueue::create("RemoteRenderingBackend work queue", WorkQueue::Type::Serial, WorkQueue::QOS::UserInteractive))
+    , m_remoteResourceCache(gpuConnectionToWebProcess.webProcessIdentifier())
     , m_gpuConnectionToWebProcess(gpuConnectionToWebProcess)
     , m_renderingBackendIdentifier(creationParameters.identifier)
     , m_resumeDisplayListSemaphore(WTFMove(creationParameters.resumeDisplayListSemaphore))
@@ -187,7 +188,7 @@
         return;
     }
 
-    m_remoteResourceCache.cacheImageBuffer(*imageBuffer);
+    m_remoteResourceCache.cacheImageBuffer(*imageBuffer, imageBufferResourceIdentifier);
     updateRenderingResourceRequest();
 
     if (m_pendingWakeupInfo && m_pendingWakeupInfo->shouldPerformWakeup(imageBufferResourceIdentifier))
@@ -194,9 +195,10 @@
         resumeFromPendingWakeupInformation();
 }
 
-RemoteRenderingBackend::ReplayerDelegate::ReplayerDelegate(WebCore::ImageBuffer& destination, RemoteRenderingBackend& remoteRenderingBackend)
+RemoteRenderingBackend::ReplayerDelegate::ReplayerDelegate(WebCore::ImageBuffer& destination, RemoteRenderingBackend& remoteRenderingBackend, ProcessIdentifier webProcessIdentifier)
     : m_destination(destination)
     , m_remoteRenderingBackend(remoteRenderingBackend)
+    , m_webProcessIdentifier(webProcessIdentifier)
 {
 }
 
@@ -223,7 +225,7 @@
 
 void RemoteRenderingBackend::ReplayerDelegate::recordResourceUse(RenderingResourceIdentifier renderingResourceIdentifier)
 {
-    m_remoteRenderingBackend.remoteResourceCache().recordResourceUse(renderingResourceIdentifier);
+    m_remoteRenderingBackend.remoteResourceCache().recordResourceUse({ renderingResourceIdentifier, m_webProcessIdentifier });
 }
 
 DisplayList::ReplayResult RemoteRenderingBackend::submit(const DisplayList::DisplayList& displayList, ImageBuffer& destination)
@@ -231,7 +233,7 @@
     if (displayList.isEmpty())
         return { };
 
-    ReplayerDelegate replayerDelegate(destination, *this);
+    ReplayerDelegate replayerDelegate(destination, *this, m_gpuConnectionToWebProcess->webProcessIdentifier());
 
     return WebCore::DisplayList::Replayer {
         destination.context(),
@@ -279,7 +281,7 @@
         MESSAGE_CHECK_WITH_RETURN_VALUE(offset <= handle.sharedMemory().size(), nullptr, "Out-of-bounds offset into shared display list handle");
 
         if (result.reasonForStopping == DisplayList::StopReplayReason::ChangeDestinationImageBuffer) {
-            destination = m_remoteResourceCache.cachedImageBuffer(*result.nextDestinationImageBuffer);
+            destination = m_remoteResourceCache.cachedImageBuffer({ *result.nextDestinationImageBuffer, m_gpuConnectionToWebProcess->webProcessIdentifier() });
             if (!destination) {
                 ASSERT(!m_pendingWakeupInfo);
                 m_pendingWakeupInfo = {{
@@ -327,7 +329,7 @@
             auto newDestinationIdentifier = makeObjectIdentifier<RenderingResourceIdentifierType>(resumeReadingInfo->destination);
             MESSAGE_CHECK_WITH_RETURN_VALUE(newDestinationIdentifier.isValid(), nullptr, "Invalid image buffer destination when resuming display list processing");
 
-            destination = m_remoteResourceCache.cachedImageBuffer(newDestinationIdentifier);
+            destination = m_remoteResourceCache.cachedImageBuffer({ newDestinationIdentifier, m_gpuConnectionToWebProcess->webProcessIdentifier() });
             MESSAGE_CHECK_WITH_RETURN_VALUE(destination, nullptr, "Missing image buffer destination when resuming display list processing");
 
             offset = resumeReadingInfo->offset;
@@ -352,7 +354,7 @@
 
     updateLastKnownState(RemoteRenderingBackendState::BeganReplayingDisplayList);
 
-    RefPtr destinationImageBuffer = m_remoteResourceCache.cachedImageBuffer(destinationImageBufferIdentifier.object());
+    RefPtr destinationImageBuffer = m_remoteResourceCache.cachedImageBuffer(destinationImageBufferIdentifier);
     MESSAGE_CHECK(destinationImageBuffer, "Missing destination image buffer");
 
     auto initialHandle = m_sharedDisplayListHandles.get(itemBufferIdentifier);
@@ -472,7 +474,7 @@
     ASSERT(!RunLoop::isMain());
 
     String urlString;
-    if (auto imageBuffer = m_remoteResourceCache.cachedImageBuffer(renderingResourceIdentifier.object()))
+    if (auto imageBuffer = m_remoteResourceCache.cachedImageBuffer(renderingResourceIdentifier))
         urlString = imageBuffer->toDataURL(mimeType, quality, preserveResolution);
     completionHandler(WTFMove(urlString));
 }
@@ -489,7 +491,7 @@
     ASSERT(!RunLoop::isMain());
 
     Vector<uint8_t> data;
-    if (auto imageBuffer = m_remoteResourceCache.cachedImageBuffer(renderingResourceIdentifier.object()))
+    if (auto imageBuffer = m_remoteResourceCache.cachedImageBuffer(renderingResourceIdentifier))
         data = "" quality);
     completionHandler(WTFMove(data));
 }
@@ -507,7 +509,7 @@
 
     ShareableBitmap::Handle handle;
     [&]() {
-        auto imageBuffer = m_remoteResourceCache.cachedImageBuffer(identifier.object());
+        auto imageBuffer = m_remoteResourceCache.cachedImageBuffer(identifier);
         if (!imageBuffer)
             return;
         auto image = imageBuffer->copyNativeImage(WebCore::BackingStoreCopy::DontCopyBackingStore);
@@ -546,7 +548,7 @@
     if (!image)
         return;
 
-    m_remoteResourceCache.cacheNativeImage(*image);
+    m_remoteResourceCache.cacheNativeImage(*image, nativeImageResourceIdentifier);
 
     if (m_pendingWakeupInfo && m_pendingWakeupInfo->shouldPerformWakeup(nativeImageResourceIdentifier))
         resumeFromPendingWakeupInformation();
@@ -564,7 +566,7 @@
 {
     ASSERT(!RunLoop::isMain());
 
-    m_remoteResourceCache.cacheFont(WTFMove(font));
+    m_remoteResourceCache.cacheFont(WTFMove(font), fontResourceIdentifier);
     if (m_pendingWakeupInfo && m_pendingWakeupInfo->shouldPerformWakeup(fontResourceIdentifier))
         resumeFromPendingWakeupInformation();
 }
@@ -585,7 +587,7 @@
 void RemoteRenderingBackend::releaseRemoteResourceWithQualifiedIdentifier(QualifiedRenderingResourceIdentifier renderingResourceIdentifier, uint64_t useCount)
 {
     ASSERT(!RunLoop::isMain());
-    auto success = m_remoteResourceCache.releaseRemoteResource(renderingResourceIdentifier.object(), useCount);
+    auto success = m_remoteResourceCache.releaseRemoteResource(renderingResourceIdentifier, useCount);
     MESSAGE_CHECK(success, "Resource is being released before being cached.");
     updateRenderingResourceRequest();
 }
@@ -593,7 +595,7 @@
 void RemoteRenderingBackend::finalizeRenderingUpdate(RenderingUpdateID renderingUpdateID)
 {
     auto shouldPerformWakeup = [&] {
-        return m_remoteResourceCache.cachedImageBuffer(m_pendingWakeupInfo->destinationImageBufferIdentifier.object()) && m_sharedDisplayListHandles.contains(m_pendingWakeupInfo->itemBufferIdentifier);
+        return m_remoteResourceCache.cachedImageBuffer(m_pendingWakeupInfo->destinationImageBufferIdentifier) && m_sharedDisplayListHandles.contains(m_pendingWakeupInfo->itemBufferIdentifier);
     };
 
     if (m_pendingWakeupInfo && shouldPerformWakeup())

Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h (283954 => 283955)


--- trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h	2021-10-12 00:33:18 UTC (rev 283954)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h	2021-10-12 00:48:22 UTC (rev 283955)
@@ -43,6 +43,7 @@
 #include <WebCore/DisplayList.h>
 #include <WebCore/DisplayListItems.h>
 #include <WebCore/DisplayListReplayer.h>
+#include <WebCore/ProcessIdentifier.h>
 #include <wtf/WeakPtr.h>
 
 namespace WebCore {
@@ -167,7 +168,7 @@
 
     class ReplayerDelegate : public WebCore::DisplayList::Replayer::Delegate {
     public:
-        ReplayerDelegate(WebCore::ImageBuffer&, RemoteRenderingBackend&);
+        ReplayerDelegate(WebCore::ImageBuffer&, RemoteRenderingBackend&, WebCore::ProcessIdentifier webProcessIdentifier);
 
     private:
         bool apply(WebCore::DisplayList::ItemHandle, WebCore::GraphicsContext&) final;
@@ -177,6 +178,7 @@
 
         WebCore::ImageBuffer& m_destination;
         RemoteRenderingBackend& m_remoteRenderingBackend;
+        WebCore::ProcessIdentifier m_webProcessIdentifier;
     };
 
     struct PendingWakeupInformation {

Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteResourceCache.cpp (283954 => 283955)


--- trunk/Source/WebKit/GPUProcess/graphics/RemoteResourceCache.cpp	2021-10-12 00:33:18 UTC (rev 283954)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteResourceCache.cpp	2021-10-12 00:48:22 UTC (rev 283955)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2020 Apple Inc. All rights reserved.
+ * Copyright (C) 2020-2021 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -31,8 +31,14 @@
 namespace WebKit {
 using namespace WebCore;
 
+RemoteResourceCache::RemoteResourceCache(ProcessIdentifier webProcessIdentifier)
+    : m_webProcessIdentifier(webProcessIdentifier)
+{
+}
+
 RemoteResourceCache::RemoteResourceCache(RemoteResourceCache&& other)
-    : m_imageBuffers(WTFMove(other.m_imageBuffers))
+    : m_webProcessIdentifier(other.m_webProcessIdentifier)
+    , m_imageBuffers(WTFMove(other.m_imageBuffers))
     , m_nativeImages(WTFMove(other.m_nativeImages))
     , m_fonts(WTFMove(other.m_fonts))
     , m_resourceUseCounters(WTFMove(other.m_resourceUseCounters))
@@ -40,48 +46,53 @@
     updateHasActiveDrawables();
 }
 
-void RemoteResourceCache::cacheImageBuffer(Ref<ImageBuffer>&& imageBuffer)
+void RemoteResourceCache::cacheImageBuffer(Ref<ImageBuffer>&& imageBuffer, QualifiedRenderingResourceIdentifier renderingResourceIdentifier)
 {
-    auto renderingResourceIdentifier = imageBuffer->renderingResourceIdentifier();
-    m_imageBuffers.add(renderingResourceIdentifier, WTFMove(imageBuffer));
+    ASSERT(renderingResourceIdentifier.object() == imageBuffer->renderingResourceIdentifier());
+    ASSERT(renderingResourceIdentifier.processIdentifier() == m_webProcessIdentifier);
+    m_imageBuffers.add(renderingResourceIdentifier.object(), WTFMove(imageBuffer));
     updateHasActiveDrawables();
 
     ensureResourceUseCounter(renderingResourceIdentifier);
 }
 
-ImageBuffer* RemoteResourceCache::cachedImageBuffer(RenderingResourceIdentifier renderingResourceIdentifier) const
+ImageBuffer* RemoteResourceCache::cachedImageBuffer(QualifiedRenderingResourceIdentifier renderingResourceIdentifier) const
 {
-    return m_imageBuffers.get(renderingResourceIdentifier);
+    ASSERT(renderingResourceIdentifier.processIdentifier() == m_webProcessIdentifier);
+    return m_imageBuffers.get(renderingResourceIdentifier.object());
 }
 
-void RemoteResourceCache::cacheNativeImage(Ref<NativeImage>&& image)
+void RemoteResourceCache::cacheNativeImage(Ref<NativeImage>&& image, QualifiedRenderingResourceIdentifier renderingResourceIdentifier)
 {
-    auto renderingResourceIdentifier = image->renderingResourceIdentifier();
-    m_nativeImages.add(renderingResourceIdentifier, WTFMove(image));
+    ASSERT(renderingResourceIdentifier.object() == image->renderingResourceIdentifier());
+    ASSERT(renderingResourceIdentifier.processIdentifier() == m_webProcessIdentifier);
+    m_nativeImages.add(renderingResourceIdentifier.object(), WTFMove(image));
     updateHasActiveDrawables();
 
     ensureResourceUseCounter(renderingResourceIdentifier);
 }
 
-NativeImage* RemoteResourceCache::cachedNativeImage(RenderingResourceIdentifier renderingResourceIdentifier) const
+NativeImage* RemoteResourceCache::cachedNativeImage(QualifiedRenderingResourceIdentifier renderingResourceIdentifier) const
 {
-    return m_nativeImages.get(renderingResourceIdentifier);
+    ASSERT(renderingResourceIdentifier.processIdentifier() == m_webProcessIdentifier);
+    return m_nativeImages.get(renderingResourceIdentifier.object());
 }
 
-void RemoteResourceCache::cacheFont(Ref<Font>&& font)
+void RemoteResourceCache::cacheFont(Ref<Font>&& font, QualifiedRenderingResourceIdentifier renderingResourceIdentifier)
 {
-    auto renderingResourceIdentifier = font->renderingResourceIdentifier();
-    m_fonts.add(renderingResourceIdentifier, WTFMove(font));
+    ASSERT(renderingResourceIdentifier.object() == font->renderingResourceIdentifier());
+    ASSERT(renderingResourceIdentifier.processIdentifier() == m_webProcessIdentifier);
+    m_fonts.add(renderingResourceIdentifier.object(), WTFMove(font));
 
     ensureResourceUseCounter(renderingResourceIdentifier);
 }
 
-Font* RemoteResourceCache::cachedFont(RenderingResourceIdentifier renderingResourceIdentifier) const
+Font* RemoteResourceCache::cachedFont(QualifiedRenderingResourceIdentifier renderingResourceIdentifier) const
 {
-    return m_fonts.get(renderingResourceIdentifier);
+    return m_fonts.get(renderingResourceIdentifier.object());
 }
 
-void RemoteResourceCache::ensureResourceUseCounter(RenderingResourceIdentifier renderingResourceIdentifier)
+void RemoteResourceCache::ensureResourceUseCounter(QualifiedRenderingResourceIdentifier renderingResourceIdentifier)
 {
     auto result = m_resourceUseCounters.add(renderingResourceIdentifier, ResourceUseCounter { });
     if (!result.isNewEntry) {
@@ -97,7 +108,7 @@
     m_fonts.clear();
 }
 
-bool RemoteResourceCache::maybeRemoveResource(RenderingResourceIdentifier renderingResourceIdentifier, ResourceUseCountersMap::iterator& iterator)
+bool RemoteResourceCache::maybeRemoveResource(QualifiedRenderingResourceIdentifier renderingResourceIdentifier, ResourceUseCountersMap::iterator& iterator)
 {
     auto& value = iterator->value;
     if (value.state == ResourceState::Alive || value.useOrPendingCount < 0)
@@ -138,11 +149,11 @@
 
     m_resourceUseCounters.remove(iterator);
 
-    if (m_imageBuffers.remove(renderingResourceIdentifier) || m_nativeImages.remove(renderingResourceIdentifier)) {
+    if (m_imageBuffers.remove(renderingResourceIdentifier.object()) || m_nativeImages.remove(renderingResourceIdentifier.object())) {
         updateHasActiveDrawables();
         return true;
     }
-    if (m_fonts.remove(renderingResourceIdentifier))
+    if (m_fonts.remove(renderingResourceIdentifier.object()))
         return true;
 
     // Caching the remote resource should have happened before releasing it.
@@ -149,7 +160,7 @@
     return false;
 }
 
-void RemoteResourceCache::recordResourceUse(RenderingResourceIdentifier renderingResourceIdentifier)
+void RemoteResourceCache::recordResourceUse(QualifiedRenderingResourceIdentifier renderingResourceIdentifier)
 {
     auto iterator = m_resourceUseCounters.find(renderingResourceIdentifier);
 
@@ -161,7 +172,7 @@
     maybeRemoveResource(renderingResourceIdentifier, iterator);
 }
 
-bool RemoteResourceCache::releaseRemoteResource(RenderingResourceIdentifier renderingResourceIdentifier, uint64_t useCount)
+bool RemoteResourceCache::releaseRemoteResource(QualifiedRenderingResourceIdentifier renderingResourceIdentifier, uint64_t useCount)
 {
     auto iterator = m_resourceUseCounters.find(renderingResourceIdentifier);
     if (iterator == m_resourceUseCounters.end())

Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteResourceCache.h (283954 => 283955)


--- trunk/Source/WebKit/GPUProcess/graphics/RemoteResourceCache.h	2021-10-12 00:33:18 UTC (rev 283954)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteResourceCache.h	2021-10-12 00:48:22 UTC (rev 283955)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2020 Apple Inc.  All rights reserved.
+ * Copyright (C) 2020-2021 Apple Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -27,9 +27,11 @@
 
 #if ENABLE(GPU_PROCESS)
 
+#include "QualifiedRenderingResourceIdentifier.h"
 #include <WebCore/Font.h>
 #include <WebCore/ImageBuffer.h>
 #include <WebCore/NativeImage.h>
+#include <WebCore/ProcessIdentifier.h>
 #include <WebCore/RenderingResourceIdentifier.h>
 #include <wtf/HashMap.h>
 
@@ -39,18 +41,18 @@
 
 class RemoteResourceCache {
 public:
-    RemoteResourceCache() = default;
+    RemoteResourceCache(WebCore::ProcessIdentifier webProcessIdentifier);
     RemoteResourceCache(RemoteResourceCache&&);
 
-    void cacheImageBuffer(Ref<WebCore::ImageBuffer>&&);
-    WebCore::ImageBuffer* cachedImageBuffer(WebCore::RenderingResourceIdentifier) const;
-    void cacheNativeImage(Ref<WebCore::NativeImage>&&);
-    WebCore::NativeImage* cachedNativeImage(WebCore::RenderingResourceIdentifier) const;
-    void cacheFont(Ref<WebCore::Font>&&);
-    WebCore::Font* cachedFont(WebCore::RenderingResourceIdentifier) const;
+    void cacheImageBuffer(Ref<WebCore::ImageBuffer>&&, QualifiedRenderingResourceIdentifier);
+    WebCore::ImageBuffer* cachedImageBuffer(QualifiedRenderingResourceIdentifier) const;
+    void cacheNativeImage(Ref<WebCore::NativeImage>&&, QualifiedRenderingResourceIdentifier);
+    WebCore::NativeImage* cachedNativeImage(QualifiedRenderingResourceIdentifier) const;
+    void cacheFont(Ref<WebCore::Font>&&, QualifiedRenderingResourceIdentifier);
+    WebCore::Font* cachedFont(QualifiedRenderingResourceIdentifier) const;
     void deleteAllFonts();
-    bool releaseRemoteResource(WebCore::RenderingResourceIdentifier, uint64_t useCount);
-    void recordResourceUse(WebCore::RenderingResourceIdentifier);
+    bool releaseRemoteResource(QualifiedRenderingResourceIdentifier, uint64_t useCount);
+    void recordResourceUse(QualifiedRenderingResourceIdentifier);
 
     const WebCore::ImageBufferHashMap& imageBuffers() const { return m_imageBuffers; }
     const WebCore::NativeImageHashMap& nativeImages() const { return m_nativeImages; }
@@ -78,13 +80,15 @@
         ResourceState state { ResourceState::Alive };
         int64_t useOrPendingCount { 0 };
     };
-    using ResourceUseCountersMap = HashMap<WebCore::RenderingResourceIdentifier, ResourceUseCounter>;
+    using ResourceUseCountersMap = HashMap<QualifiedRenderingResourceIdentifier, ResourceUseCounter>;
 
-    bool maybeRemoveResource(WebCore::RenderingResourceIdentifier, ResourceUseCountersMap::iterator&);
-    void ensureResourceUseCounter(WebCore::RenderingResourceIdentifier);
+    bool maybeRemoveResource(QualifiedRenderingResourceIdentifier, ResourceUseCountersMap::iterator&);
+    void ensureResourceUseCounter(QualifiedRenderingResourceIdentifier);
 
     void updateHasActiveDrawables();
 
+    WebCore::ProcessIdentifier m_webProcessIdentifier;
+
     WebCore::ImageBufferHashMap m_imageBuffers;
     WebCore::NativeImageHashMap m_nativeImages;
     WebCore::FontRenderingResourceMap m_fonts;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to