Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteDisplayListRecorder.cpp (283964 => 283965)
--- trunk/Source/WebKit/GPUProcess/graphics/RemoteDisplayListRecorder.cpp 2021-10-12 02:57:31 UTC (rev 283964)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteDisplayListRecorder.cpp 2021-10-12 03:05:02 UTC (rev 283965)
@@ -33,9 +33,10 @@
namespace WebKit {
using namespace WebCore;
-RemoteDisplayListRecorder::RemoteDisplayListRecorder(ImageBuffer& imageBuffer, QualifiedRenderingResourceIdentifier imageBufferIdentifier, RemoteRenderingBackend& renderingBackend)
+RemoteDisplayListRecorder::RemoteDisplayListRecorder(ImageBuffer& imageBuffer, QualifiedRenderingResourceIdentifier imageBufferIdentifier, ProcessIdentifier webProcessIdentifier, RemoteRenderingBackend& renderingBackend)
: m_imageBuffer(imageBuffer)
, m_imageBufferIdentifier(imageBufferIdentifier)
+ , m_webProcessIdentifier(webProcessIdentifier)
, m_renderingBackend(renderingBackend)
{
}
@@ -172,16 +173,23 @@
handleItem(DisplayList::ClipOut(rect));
}
-void RemoteDisplayListRecorder::clipToImageBuffer(WebCore::RenderingResourceIdentifier imageBufferIdentifier, const WebCore::FloatRect& destinationRect)
+void RemoteDisplayListRecorder::clipToImageBuffer(RenderingResourceIdentifier imageBufferIdentifier, const WebCore::FloatRect& destinationRect)
{
- RefPtr imageBuffer = resourceCache().cachedImageBuffer(imageBufferIdentifier);
+ // Immediately turn the RenderingResourceIdentifier (which is error-prone) to a QualifiedRenderingResourceIdentifier,
+ // and use a helper function to make sure that don't accidentally use the RenderingResourceIdentifier (because the helper function can't see it).
+ clipToImageBufferWithQualifiedIdentifier({ imageBufferIdentifier, m_webProcessIdentifier }, destinationRect);
+}
+
+void RemoteDisplayListRecorder::clipToImageBufferWithQualifiedIdentifier(QualifiedRenderingResourceIdentifier imageBufferIdentifier, const WebCore::FloatRect& destinationRect)
+{
+ RefPtr imageBuffer = resourceCache().cachedImageBuffer(imageBufferIdentifier.object());
if (!imageBuffer) {
ASSERT_NOT_REACHED();
return;
}
- handleItem(DisplayList::ClipToImageBuffer(imageBufferIdentifier, destinationRect), *imageBuffer);
- resourceCache().recordResourceUse(imageBufferIdentifier);
+ handleItem(DisplayList::ClipToImageBuffer(imageBufferIdentifier.object(), destinationRect), *imageBuffer);
+ resourceCache().recordResourceUse(imageBufferIdentifier.object());
}
void RemoteDisplayListRecorder::clipOutToPath(const Path& path)
@@ -225,38 +233,59 @@
void RemoteDisplayListRecorder::drawImageBuffer(RenderingResourceIdentifier imageBufferIdentifier, const FloatRect& destinationRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
{
- RefPtr imageBuffer = resourceCache().cachedImageBuffer(imageBufferIdentifier);
+ // Immediately turn the RenderingResourceIdentifier (which is error-prone) to a QualifiedRenderingResourceIdentifier,
+ // and use a helper function to make sure that don't accidentally use the RenderingResourceIdentifier (because the helper function can't see it).
+ drawImageBufferWithQualifiedIdentifier({ imageBufferIdentifier, m_webProcessIdentifier }, destinationRect, srcRect, options);
+}
+
+void RemoteDisplayListRecorder::drawImageBufferWithQualifiedIdentifier(QualifiedRenderingResourceIdentifier imageBufferIdentifier, const FloatRect& destinationRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
+{
+ RefPtr imageBuffer = resourceCache().cachedImageBuffer(imageBufferIdentifier.object());
if (!imageBuffer) {
ASSERT_NOT_REACHED();
return;
}
- handleItem(DisplayList::DrawImageBuffer(imageBufferIdentifier, destinationRect, srcRect, options), *imageBuffer);
- resourceCache().recordResourceUse(imageBufferIdentifier);
+ handleItem(DisplayList::DrawImageBuffer(imageBufferIdentifier.object(), destinationRect, srcRect, options), *imageBuffer);
+ resourceCache().recordResourceUse(imageBufferIdentifier.object());
}
void RemoteDisplayListRecorder::drawNativeImage(RenderingResourceIdentifier imageIdentifier, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
{
- RefPtr image = resourceCache().cachedNativeImage(imageIdentifier);
+ // Immediately turn the RenderingResourceIdentifier (which is error-prone) to a QualifiedRenderingResourceIdentifier,
+ // and use a helper function to make sure that don't accidentally use the RenderingResourceIdentifier (because the helper function can't see it).
+ drawNativeImageWithQualifiedIdentifier({ imageIdentifier, m_webProcessIdentifier }, imageSize, destRect, srcRect, options);
+}
+
+void RemoteDisplayListRecorder::drawNativeImageWithQualifiedIdentifier(QualifiedRenderingResourceIdentifier imageIdentifier, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
+{
+ RefPtr image = resourceCache().cachedNativeImage(imageIdentifier.object());
if (!image) {
ASSERT_NOT_REACHED();
return;
}
- handleItem(DisplayList::DrawNativeImage(imageIdentifier, imageSize, destRect, srcRect, options), *image);
- resourceCache().recordResourceUse(imageIdentifier);
+ handleItem(DisplayList::DrawNativeImage(imageIdentifier.object(), imageSize, destRect, srcRect, options), *image);
+ resourceCache().recordResourceUse(imageIdentifier.object());
}
void RemoteDisplayListRecorder::drawPattern(RenderingResourceIdentifier imageIdentifier, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& tileRect, const AffineTransform& transform, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& options)
{
- RefPtr image = resourceCache().cachedNativeImage(imageIdentifier);
+ // Immediately turn the RenderingResourceIdentifier (which is error-prone) to a QualifiedRenderingResourceIdentifier,
+ // and use a helper function to make sure that don't accidentally use the RenderingResourceIdentifier (because the helper function can't see it).
+ drawPatternWithQualifiedIdentifier({ imageIdentifier, m_webProcessIdentifier }, imageSize, destRect, tileRect, transform, phase, spacing, options);
+}
+
+void RemoteDisplayListRecorder::drawPatternWithQualifiedIdentifier(QualifiedRenderingResourceIdentifier imageIdentifier, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& tileRect, const AffineTransform& transform, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& options)
+{
+ RefPtr image = resourceCache().cachedNativeImage(imageIdentifier.object());
if (!image) {
ASSERT_NOT_REACHED();
return;
}
- handleItem(DisplayList::DrawPattern(imageIdentifier, imageSize, destRect, tileRect, transform, phase, spacing, options), *image);
- resourceCache().recordResourceUse(imageIdentifier);
+ handleItem(DisplayList::DrawPattern(imageIdentifier.object(), imageSize, destRect, tileRect, transform, phase, spacing, options), *image);
+ resourceCache().recordResourceUse(imageIdentifier.object());
}
void RemoteDisplayListRecorder::beginTransparencyLayer(float opacity)
Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteDisplayListRecorder.h (283964 => 283965)
--- trunk/Source/WebKit/GPUProcess/graphics/RemoteDisplayListRecorder.h 2021-10-12 02:57:31 UTC (rev 283964)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteDisplayListRecorder.h 2021-10-12 03:05:02 UTC (rev 283965)
@@ -33,6 +33,7 @@
#include "StreamMessageReceiver.h"
#include "StreamServerConnection.h"
#include <WebCore/DisplayListItems.h>
+#include <WebCore/ProcessIdentifier.h>
#include <wtf/RefCounted.h>
#include <wtf/WeakPtr.h>
@@ -43,9 +44,9 @@
class RemoteDisplayListRecorder : public IPC::StreamMessageReceiver, public CanMakeWeakPtr<RemoteDisplayListRecorder> {
public:
- static Ref<RemoteDisplayListRecorder> create(WebCore::ImageBuffer& imageBuffer, QualifiedRenderingResourceIdentifier imageBufferIdentifier, RemoteRenderingBackend& renderingBackend)
+ static Ref<RemoteDisplayListRecorder> create(WebCore::ImageBuffer& imageBuffer, QualifiedRenderingResourceIdentifier imageBufferIdentifier, WebCore::ProcessIdentifier webProcessIdentifier, RemoteRenderingBackend& renderingBackend)
{
- auto instance = adoptRef(*new RemoteDisplayListRecorder(imageBuffer, imageBufferIdentifier, renderingBackend));
+ auto instance = adoptRef(*new RemoteDisplayListRecorder(imageBuffer, imageBufferIdentifier, webProcessIdentifier, renderingBackend));
instance->startListeningForIPC();
return instance;
}
@@ -124,8 +125,13 @@
void flushContext(WebCore::GraphicsContextFlushIdentifier);
private:
- RemoteDisplayListRecorder(WebCore::ImageBuffer&, QualifiedRenderingResourceIdentifier, RemoteRenderingBackend&);
+ RemoteDisplayListRecorder(WebCore::ImageBuffer&, QualifiedRenderingResourceIdentifier, WebCore::ProcessIdentifier webProcessIdentifier, RemoteRenderingBackend&);
+ void clipToImageBufferWithQualifiedIdentifier(QualifiedRenderingResourceIdentifier, const WebCore::FloatRect& destinationRect);
+ void drawImageBufferWithQualifiedIdentifier(QualifiedRenderingResourceIdentifier imageBufferIdentifier, const WebCore::FloatRect& destinationRect, const WebCore::FloatRect& srcRect, const WebCore::ImagePaintingOptions&);
+ void drawNativeImageWithQualifiedIdentifier(QualifiedRenderingResourceIdentifier imageIdentifier, const WebCore::FloatSize& imageSize, const WebCore::FloatRect& destRect, const WebCore::FloatRect& srcRect, const WebCore::ImagePaintingOptions&);
+ void drawPatternWithQualifiedIdentifier(QualifiedRenderingResourceIdentifier imageIdentifier, const WebCore::FloatSize& imageSize, const WebCore::FloatRect& destRect, const WebCore::FloatRect& tileRect, const WebCore::AffineTransform&, const WebCore::FloatPoint&, const WebCore::FloatSize& spacing, const WebCore::ImagePaintingOptions&);
+
RemoteResourceCache& resourceCache();
WebCore::GraphicsContext& drawingContext();
@@ -143,6 +149,7 @@
Ref<WebCore::ImageBuffer> m_imageBuffer;
QualifiedRenderingResourceIdentifier m_imageBufferIdentifier;
+ WebCore::ProcessIdentifier m_webProcessIdentifier;
Ref<RemoteRenderingBackend> m_renderingBackend;
RefPtr<WebCore::ImageBuffer> m_maskImageBuffer;
bool m_isListeningForIPC { false };