Diff
Modified: trunk/Source/WebCore/platform/graphics/ConcreteImageBuffer.h (294535 => 294536)
--- trunk/Source/WebCore/platform/graphics/ConcreteImageBuffer.h 2022-05-20 07:14:48 UTC (rev 294535)
+++ trunk/Source/WebCore/platform/graphics/ConcreteImageBuffer.h 2022-05-20 07:17:02 UTC (rev 294536)
@@ -28,6 +28,7 @@
#include "Filter.h"
#include "FilterImage.h"
#include "FilterResults.h"
+#include "GraphicsContext.h"
#include "ImageBuffer.h"
#include "PixelBuffer.h"
@@ -169,17 +170,24 @@
void draw(GraphicsContext& destContext, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) override
{
+ FloatRect srcRectScaled = srcRect;
+ srcRectScaled.scale(resolutionScale());
+
if (auto* backend = ensureBackendCreated()) {
- flushDrawingContext();
- backend->draw(destContext, destRect, srcRect, options);
+ if (auto image = copyNativeImage(&destContext == &context() ? CopyBackingStore : DontCopyBackingStore))
+ destContext.drawNativeImage(*image, backendSize(), destRect, srcRectScaled, options);
+ backend->finalizeDrawIntoContext(destContext);
}
}
void drawPattern(GraphicsContext& destContext, const FloatRect& destRect, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& options) override
{
+ FloatRect adjustedSrcRect = srcRect;
+ adjustedSrcRect.scale(resolutionScale());
+
if (auto* backend = ensureBackendCreated()) {
- flushDrawingContext();
- backend->drawPattern(destContext, destRect, srcRect, patternTransform, phase, spacing, options);
+ if (auto image = copyImage(&destContext == &context() ? CopyBackingStore : DontCopyBackingStore))
+ image->drawPattern(destContext, destRect, adjustedSrcRect, patternTransform, phase, spacing, options);
}
}
@@ -203,13 +211,17 @@
void drawConsuming(GraphicsContext& destContext, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) override
{
+ FloatRect adjustedSrcRect = srcRect;
+ adjustedSrcRect.scale(resolutionScale());
+
ASSERT(&destContext != &context());
if (auto* backend = ensureBackendCreated()) {
- flushDrawingContext();
- backend->drawConsuming(destContext, destRect, srcRect, options);
+ auto backendSize = backend->backendSize();
+ if (auto image = sinkIntoNativeImage())
+ destContext.drawNativeImage(*image, backendSize, destRect, adjustedSrcRect, options);
}
}
-
+
void clipToMask(GraphicsContext& destContext, const FloatRect& destRect) override
{
if (auto* backend = ensureBackendCreated()) {
Modified: trunk/Source/WebCore/platform/graphics/ImageBufferBackend.cpp (294535 => 294536)
--- trunk/Source/WebCore/platform/graphics/ImageBufferBackend.cpp 2022-05-20 07:14:48 UTC (rev 294535)
+++ trunk/Source/WebCore/platform/graphics/ImageBufferBackend.cpp 2022-05-20 07:17:02 UTC (rev 294536)
@@ -65,11 +65,6 @@
return copyImage(DontCopyBackingStore, preserveResolution);
}
-void ImageBufferBackend::drawConsuming(GraphicsContext& destinationContext, const FloatRect& destinationRect, const FloatRect& sourceRect, const ImagePaintingOptions& options)
-{
- draw(destinationContext, destinationRect, sourceRect, options);
-}
-
void ImageBufferBackend::convertToLuminanceMask()
{
PixelBufferFormat format { AlphaPremultiplication::Unpremultiplied, PixelFormat::RGBA8, colorSpace() };
Modified: trunk/Source/WebCore/platform/graphics/ImageBufferBackend.h (294535 => 294536)
--- trunk/Source/WebCore/platform/graphics/ImageBufferBackend.h 2022-05-20 07:14:48 UTC (rev 294535)
+++ trunk/Source/WebCore/platform/graphics/ImageBufferBackend.h 2022-05-20 07:17:02 UTC (rev 294536)
@@ -108,15 +108,12 @@
virtual IntSize backendSize() const { return { }; }
+ virtual void finalizeDrawIntoContext(GraphicsContext&) { }
virtual RefPtr<NativeImage> copyNativeImage(BackingStoreCopy) const = 0;
virtual RefPtr<Image> copyImage(BackingStoreCopy, PreserveResolution) const = 0;
- WEBCORE_EXPORT virtual void draw(GraphicsContext&, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) = 0;
- WEBCORE_EXPORT virtual void drawPattern(GraphicsContext&, const FloatRect& destRect, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions&) = 0;
-
WEBCORE_EXPORT virtual RefPtr<NativeImage> sinkIntoNativeImage();
WEBCORE_EXPORT virtual RefPtr<Image> sinkIntoImage(PreserveResolution);
- WEBCORE_EXPORT virtual void drawConsuming(GraphicsContext& destContext, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&);
virtual void clipToMask(GraphicsContext&, const FloatRect&) { }
Modified: trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairoBackend.cpp (294535 => 294536)
--- trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairoBackend.cpp 2022-05-20 07:14:48 UTC (rev 294535)
+++ trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairoBackend.cpp 2022-05-20 07:17:02 UTC (rev 294536)
@@ -51,37 +51,6 @@
return BitmapImage::create(copyNativeImage(copyBehavior));
}
-void ImageBufferCairoBackend::draw(GraphicsContext& destContext, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
-{
- if (!destContext.hasPlatformContext()) {
- // If there's no platformContext, we're using threaded rendering, and all the operations must be done
- // through the GraphicsContext.
- auto image = copyImage(&destContext == &context() ? CopyBackingStore : DontCopyBackingStore);
- destContext.drawImage(*image, destRect, srcRect, options);
- return;
- }
-
- InterpolationQualityMaintainer interpolationQualityForThisScope(destContext, options.interpolationQuality());
- const auto& destinationContextState = destContext.state();
-
- if (auto image = copyNativeImage(&destContext == &context() ? CopyBackingStore : DontCopyBackingStore))
- drawPlatformImage(*destContext.platformContext(), image->platformImage().get(), destRect, srcRect, { options, destinationContextState.imageInterpolationQuality() }, destinationContextState.alpha(), WebCore::Cairo::ShadowState(destinationContextState));
-}
-
-void ImageBufferCairoBackend::drawPattern(GraphicsContext& destContext, const FloatRect& destRect, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& options)
-{
- if (!destContext.hasPlatformContext()) {
- // If there's no platformContext, we're using threaded rendering, and all the operations must be done
- // through the GraphicsContext.
- auto image = copyImage(DontCopyBackingStore);
- image->drawPattern(destContext, destRect, srcRect, patternTransform, phase, spacing, options);
- return;
- }
-
- if (auto image = copyNativeImage(&destContext == &context() ? CopyBackingStore : DontCopyBackingStore))
- Cairo::drawPattern(*destContext.platformContext(), image->platformImage().get(), logicalSize(), destRect, srcRect, patternTransform, phase, options);
-}
-
void ImageBufferCairoBackend::clipToMask(GraphicsContext& destContext, const FloatRect& destRect)
{
if (auto image = copyNativeImage(DontCopyBackingStore))
Modified: trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairoBackend.h (294535 => 294536)
--- trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairoBackend.h 2022-05-20 07:14:48 UTC (rev 294535)
+++ trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairoBackend.h 2022-05-20 07:17:02 UTC (rev 294536)
@@ -39,9 +39,6 @@
public:
RefPtr<Image> copyImage(BackingStoreCopy = CopyBackingStore, PreserveResolution = PreserveResolution::No) const override;
- void draw(GraphicsContext&, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) override;
- void drawPattern(GraphicsContext&, const FloatRect& destRect, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions&) override;
-
void clipToMask(GraphicsContext&, const FloatRect& destRect) override;
void transformToColorSpace(const DestinationColorSpace&) override;
Modified: trunk/Source/WebCore/platform/graphics/cg/ImageBufferCGBackend.cpp (294535 => 294536)
--- trunk/Source/WebCore/platform/graphics/cg/ImageBufferCGBackend.cpp 2022-05-20 07:14:48 UTC (rev 294535)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageBufferCGBackend.cpp 2022-05-20 07:17:02 UTC (rev 294536)
@@ -131,28 +131,6 @@
return createBitmapImageAfterScalingIfNeeded(sinkIntoNativeImage(), logicalSize(), backendSize, resolutionScale(), preserveResolution);
}
-void ImageBufferCGBackend::draw(GraphicsContext& destContext, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
-{
- prepareToDrawIntoContext(destContext);
-
- FloatRect srcRectScaled = srcRect;
- srcRectScaled.scale(resolutionScale());
-
- if (auto image = copyNativeImage(&destContext == &context() ? CopyBackingStore : DontCopyBackingStore))
- destContext.drawNativeImage(*image, backendSize(), destRect, srcRectScaled, options);
-}
-
-void ImageBufferCGBackend::drawPattern(GraphicsContext& destContext, const FloatRect& destRect, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& options)
-{
- prepareToDrawIntoContext(destContext);
-
- FloatRect adjustedSrcRect = srcRect;
- adjustedSrcRect.scale(resolutionScale());
-
- if (auto image = copyImage(&destContext == &context() ? CopyBackingStore : DontCopyBackingStore))
- image->drawPattern(destContext, destRect, adjustedSrcRect, patternTransform, phase, spacing, options);
-}
-
void ImageBufferCGBackend::clipToMask(GraphicsContext& destContext, const FloatRect& destRect)
{
auto nativeImage = copyNativeImage(DontCopyBackingStore);
@@ -248,10 +226,6 @@
return makeUnique<ThreadSafeImageBufferFlusherCG>(context().platformContext());
}
-void ImageBufferCGBackend::prepareToDrawIntoContext(GraphicsContext&)
-{
-}
-
bool ImageBufferCGBackend::originAtBottomLeftCorner() const
{
return isOriginAtBottomLeftCorner;
Modified: trunk/Source/WebCore/platform/graphics/cg/ImageBufferCGBackend.h (294535 => 294536)
--- trunk/Source/WebCore/platform/graphics/cg/ImageBufferCGBackend.h 2022-05-20 07:14:48 UTC (rev 294535)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageBufferCGBackend.h 2022-05-20 07:17:02 UTC (rev 294536)
@@ -41,12 +41,11 @@
static constexpr bool isOriginAtBottomLeftCorner = true;
protected:
+ using ImageBufferBackend::ImageBufferBackend;
+
RefPtr<Image> copyImage(BackingStoreCopy = CopyBackingStore, PreserveResolution = PreserveResolution::No) const override;
RefPtr<Image> sinkIntoImage(PreserveResolution) override;
- void draw(GraphicsContext&, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) override;
- void drawPattern(GraphicsContext&, const FloatRect& destRect, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions&) override;
-
void clipToMask(GraphicsContext&, const FloatRect& destRect) override;
String toDataURL(const String& mimeType, std::optional<double> quality, PreserveResolution) const override;
@@ -56,12 +55,8 @@
bool originAtBottomLeftCorner() const override;
- using ImageBufferBackend::ImageBufferBackend;
-
static RetainPtr<CGColorSpaceRef> contextColorSpace(const GraphicsContext&);
- virtual void prepareToDrawIntoContext(GraphicsContext&);
-
virtual RetainPtr<CGImageRef> copyCGImageForEncoding(CFStringRef destinationUTI, PreserveResolution) const;
};
Modified: trunk/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp (294535 => 294536)
--- trunk/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp 2022-05-20 07:14:48 UTC (rev 294535)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp 2022-05-20 07:17:02 UTC (rev 294536)
@@ -153,16 +153,6 @@
return m_surface->bytesPerRow();
}
-void ImageBufferIOSurfaceBackend::prepareToDrawIntoContext(GraphicsContext& destContext)
-{
- auto currentSeed = m_surface->seed();
- if (std::exchange(m_lastSeedWhenDrawingImage, currentSeed) == currentSeed)
- return;
-
- if (destContext.renderingMode() == RenderingMode::Unaccelerated)
- invalidateCachedNativeImage();
-}
-
void ImageBufferIOSurfaceBackend::invalidateCachedNativeImage() const
{
// Force QuartzCore to invalidate its cached CGImageRef for this IOSurface.
@@ -183,26 +173,14 @@
return NativeImage::create(IOSurface::sinkIntoImage(WTFMove(m_surface)));
}
-void ImageBufferIOSurfaceBackend::draw(GraphicsContext& destContext, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
+void ImageBufferIOSurfaceBackend::finalizeDrawIntoContext(GraphicsContext& destinationContext)
{
- ImageBufferCGBackend::draw(destContext, destRect, srcRect, options);
- // Accelerated to/from unaccelerated image buffers need complex caching. We trust that
+ // Accelerated to unaccelerated image buffers need complex caching. We trust that
// this is a one-off draw, and as such we clear the caches of the source image after each draw.
- if (destContext.renderingMode() != context().renderingMode())
+ if (destinationContext.renderingMode() == RenderingMode::Unaccelerated)
invalidateCachedNativeImage();
}
-void ImageBufferIOSurfaceBackend::drawConsuming(GraphicsContext& destContext, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
-{
- prepareToDrawIntoContext(destContext);
- FloatRect adjustedSrcRect = srcRect;
- adjustedSrcRect.scale(resolutionScale());
-
- auto backendSize = this->backendSize();
- if (auto image = sinkIntoNativeImage())
- destContext.drawNativeImage(*image, backendSize, destRect, adjustedSrcRect, options);
-}
-
RetainPtr<CGImageRef> ImageBufferIOSurfaceBackend::copyCGImageForEncoding(CFStringRef destinationUTI, PreserveResolution preserveResolution) const
{
if (m_requiresDrawAfterPutPixelBuffer) {
Modified: trunk/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.h (294535 => 294536)
--- trunk/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.h 2022-05-20 07:14:48 UTC (rev 294535)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.h 2022-05-20 07:17:02 UTC (rev 294536)
@@ -66,9 +66,6 @@
RefPtr<NativeImage> copyNativeImage(BackingStoreCopy = CopyBackingStore) const override;
RefPtr<NativeImage> sinkIntoNativeImage() override;
- void draw(GraphicsContext& destContext, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) override;
- void drawConsuming(GraphicsContext&, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) override;
-
std::optional<PixelBuffer> getPixelBuffer(const PixelBufferFormat& outputFormat, const IntRect&) const override;
void putPixelBuffer(const PixelBuffer&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) override;
@@ -88,11 +85,10 @@
// ImageBufferCGBackend overrides.
RetainPtr<CGImageRef> copyCGImageForEncoding(CFStringRef destinationUTI, PreserveResolution) const final;
- void prepareToDrawIntoContext(GraphicsContext& destinationContext) override;
+ void finalizeDrawIntoContext(GraphicsContext& destinationContext) override;
void invalidateCachedNativeImage() const;
std::unique_ptr<IOSurface> m_surface;
- IOSurfaceSeed m_lastSeedWhenDrawingImage { 0 };
mutable bool m_requiresDrawAfterPutPixelBuffer { false };
mutable std::optional<GraphicsContextCG> m_context;
Modified: trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h (294535 => 294536)
--- trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h 2022-05-20 07:14:48 UTC (rev 294535)
+++ trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h 2022-05-20 07:17:02 UTC (rev 294536)
@@ -147,7 +147,7 @@
WEBCORE_EXPORT IOSurfaceID surfaceID() const;
size_t bytesPerRow() const;
- IOSurfaceSeed seed() const;
+ WEBCORE_EXPORT IOSurfaceSeed seed() const;
WEBCORE_EXPORT bool isInUse() const;
Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h (294535 => 294536)
--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h 2022-05-20 07:14:48 UTC (rev 294535)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h 2022-05-20 07:17:02 UTC (rev 294536)
@@ -50,6 +50,7 @@
class RemoteImageBufferProxy : public WebCore::ConcreteImageBuffer<BackendType> {
using BaseConcreteImageBuffer = WebCore::ConcreteImageBuffer<BackendType>;
using BaseConcreteImageBuffer::m_backend;
+ using BaseConcreteImageBuffer::canMapBackingStore;
using BaseConcreteImageBuffer::m_renderingResourceIdentifier;
using BaseConcreteImageBuffer::resolutionScale;
@@ -174,10 +175,14 @@
return m_remoteRenderingBackendProxy->getDataForImageBuffer(mimeType, quality, m_renderingResourceIdentifier);
}
- RefPtr<WebCore::NativeImage> copyNativeImage(WebCore::BackingStoreCopy = WebCore::CopyBackingStore) const final
+ RefPtr<WebCore::NativeImage> copyNativeImage(WebCore::BackingStoreCopy copyBehavior = WebCore::CopyBackingStore) const final
{
if (UNLIKELY(!m_remoteRenderingBackendProxy))
return { };
+
+ if (canMapBackingStore())
+ return BaseConcreteImageBuffer::copyNativeImage(copyBehavior);
+
const_cast<RemoteImageBufferProxy*>(this)->flushDrawingContext();
auto bitmap = m_remoteRenderingBackendProxy->getShareableBitmap(m_renderingResourceIdentifier, WebCore::PreserveResolution::Yes);
if (!bitmap)
@@ -185,10 +190,14 @@
return WebCore::NativeImage::create(bitmap->createPlatformImage(WebCore::DontCopyBackingStore));
}
- RefPtr<WebCore::Image> copyImage(WebCore::BackingStoreCopy = WebCore::CopyBackingStore, WebCore::PreserveResolution preserveResolution = WebCore::PreserveResolution::No) const final
+ RefPtr<WebCore::Image> copyImage(WebCore::BackingStoreCopy copyBehavior = WebCore::CopyBackingStore, WebCore::PreserveResolution preserveResolution = WebCore::PreserveResolution::No) const final
{
if (UNLIKELY(!m_remoteRenderingBackendProxy))
return { };
+
+ if (canMapBackingStore())
+ return BaseConcreteImageBuffer::copyImage(copyBehavior, preserveResolution);
+
const_cast<RemoteImageBufferProxy*>(this)->flushDrawingContext();
auto bitmap = m_remoteRenderingBackendProxy->getShareableBitmap(m_renderingResourceIdentifier, preserveResolution);
if (!bitmap)
Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferRemoteIOSurfaceBackend.cpp (294535 => 294536)
--- trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferRemoteIOSurfaceBackend.cpp 2022-05-20 07:14:48 UTC (rev 294535)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferRemoteIOSurfaceBackend.cpp 2022-05-20 07:17:02 UTC (rev 294536)
@@ -118,16 +118,6 @@
return { };
}
-void ImageBufferRemoteIOSurfaceBackend::draw(GraphicsContext&, const FloatRect&, const FloatRect&, const ImagePaintingOptions&)
-{
- RELEASE_ASSERT_NOT_REACHED();
-}
-
-void ImageBufferRemoteIOSurfaceBackend::drawPattern(GraphicsContext&, const FloatRect&, const FloatRect&, const AffineTransform&, const FloatPoint&, const FloatSize&, const ImagePaintingOptions&)
-{
- RELEASE_ASSERT_NOT_REACHED();
-}
-
String ImageBufferRemoteIOSurfaceBackend::toDataURL(const String&, std::optional<double>, PreserveResolution) const
{
RELEASE_ASSERT_NOT_REACHED();
Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferRemoteIOSurfaceBackend.h (294535 => 294536)
--- trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferRemoteIOSurfaceBackend.h 2022-05-20 07:14:48 UTC (rev 294535)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferRemoteIOSurfaceBackend.h 2022-05-20 07:17:02 UTC (rev 294536)
@@ -61,8 +61,6 @@
WebCore::IntSize backendSize() const final;
RefPtr<WebCore::NativeImage> copyNativeImage(WebCore::BackingStoreCopy) const final;
RefPtr<WebCore::Image> copyImage(WebCore::BackingStoreCopy, WebCore::PreserveResolution) const final;
- void draw(WebCore::GraphicsContext&, const WebCore::FloatRect& destRect, const WebCore::FloatRect& srcRect, const WebCore::ImagePaintingOptions&) final;
- void drawPattern(WebCore::GraphicsContext&, const WebCore::FloatRect& destRect, const WebCore::FloatRect& srcRect, const WebCore::AffineTransform& patternTransform, const WebCore::FloatPoint& phase, const WebCore::FloatSize& spacing, const WebCore::ImagePaintingOptions&) final;
String toDataURL(const String& mimeType, std::optional<double> quality, WebCore::PreserveResolution) const final;
Vector<uint8_t> toData(const String& mimeType, std::optional<double> quality) const final;
std::optional<WebCore::PixelBuffer> getPixelBuffer(const WebCore::PixelBufferFormat& outputFormat, const WebCore::IntRect&) const final;
Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableMappedIOSurfaceBackend.cpp (294535 => 294536)
--- trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableMappedIOSurfaceBackend.cpp 2022-05-20 07:14:48 UTC (rev 294535)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableMappedIOSurfaceBackend.cpp 2022-05-20 07:17:02 UTC (rev 294536)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2021 Apple Inc. All rights reserved.
+ * Copyright (C) 2020-2022 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -83,6 +83,18 @@
m_surface->setOwnershipIdentity(resourceOwner);
}
+RefPtr<NativeImage> ImageBufferShareableMappedIOSurfaceBackend::copyNativeImage(BackingStoreCopy copyBehavior) const
+{
+ auto currentSeed = m_surface->seed();
+
+ // Invalidate the cached image before getting a new one because GPUProcess might
+ // have drawn something to the IOSurface since last time this function was called.
+ if (std::exchange(m_lastSeedWhenCopyingImage, currentSeed) != currentSeed)
+ invalidateCachedNativeImage();
+
+ return ImageBufferIOSurfaceBackend::copyNativeImage(copyBehavior);
+}
+
} // namespace WebKit
#endif // ENABLE(GPU_PROCESS) && HAVE(IOSURFACE)
Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableMappedIOSurfaceBackend.h (294535 => 294536)
--- trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableMappedIOSurfaceBackend.h 2022-05-20 07:14:48 UTC (rev 294535)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableMappedIOSurfaceBackend.h 2022-05-20 07:17:02 UTC (rev 294536)
@@ -37,8 +37,6 @@
namespace WebKit {
-class ShareableBitmap;
-
class ImageBufferShareableMappedIOSurfaceBackend final : public WebCore::ImageBufferIOSurfaceBackend, public ImageBufferBackendHandleSharing {
WTF_MAKE_ISO_ALLOCATED(ImageBufferShareableMappedIOSurfaceBackend);
WTF_MAKE_NONCOPYABLE(ImageBufferShareableMappedIOSurfaceBackend);
@@ -55,6 +53,10 @@
private:
// ImageBufferBackendSharing
ImageBufferBackendSharing* toBackendSharing() final { return this; }
+
+ RefPtr<WebCore::NativeImage> copyNativeImage(WebCore::BackingStoreCopy = WebCore::CopyBackingStore) const final;
+
+ mutable WebCore::IOSurfaceSeed m_lastSeedWhenCopyingImage { 0 };
};
} // namespace WebKit