Diff
Modified: trunk/Source/WebCore/ChangeLog (293845 => 293846)
--- trunk/Source/WebCore/ChangeLog 2022-05-05 17:27:25 UTC (rev 293845)
+++ trunk/Source/WebCore/ChangeLog 2022-05-05 18:00:15 UTC (rev 293846)
@@ -1,3 +1,17 @@
+2022-05-05 Said Abou-Hallawa <[email protected]>
+
+ [GPU Process] NativeImage should share the ShareableBitmap data when it's sent to GPU Process
+ https://bugs.webkit.org/show_bug.cgi?id=239874
+ rdar://92031359
+
+ Reviewed by Simon Fraser.
+
+ * Headers.cmake:
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/graphics/BackingStoreCopy.h: Added.
+ * platform/graphics/ImageBufferBackend.h:
+ (): Deleted.
+
2022-05-05 Jer Noble <[email protected]>
[WK2][Cocoa] Remove use of CVPixelBufferConformer from WebContent process in MediaPlayerPrivateRemote::nativeImageForCurrentTime()
Modified: trunk/Source/WebCore/Headers.cmake (293845 => 293846)
--- trunk/Source/WebCore/Headers.cmake 2022-05-05 17:27:25 UTC (rev 293845)
+++ trunk/Source/WebCore/Headers.cmake 2022-05-05 18:00:15 UTC (rev 293846)
@@ -1439,6 +1439,7 @@
platform/graphics/AnimationFrameRate.h
platform/graphics/AudioTrackPrivate.h
platform/graphics/AudioTrackPrivateClient.h
+ platform/graphics/CopyImageOptions.h
platform/graphics/BifurcatedGraphicsContext.h
platform/graphics/BitmapImage.h
platform/graphics/Color.h
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (293845 => 293846)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2022-05-05 17:27:25 UTC (rev 293845)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2022-05-05 18:00:15 UTC (rev 293846)
@@ -2370,6 +2370,7 @@
72B8B0362753441400F752AA /* FilterImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 72435EF4273D07670005E7EE /* FilterImage.h */; settings = {ATTRIBUTES = (Private, ); }; };
72BAC3AE23E1F0B0008D741C /* ImageBufferBackend.h in Headers */ = {isa = PBXBuildFile; fileRef = 72BAC3A523E17328008D741C /* ImageBufferBackend.h */; settings = {ATTRIBUTES = (Private, ); }; };
72D73644278461A000398663 /* FilterResults.h in Headers */ = {isa = PBXBuildFile; fileRef = 7211B5D6276536820076FEF8 /* FilterResults.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 72E5768B281B2B5500A75432 /* CopyImageOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 72E5768A281B292600A75432 /* CopyImageOptions.h */; settings = {ATTRIBUTES = (Private, ); }; };
72F667E1260C26AC00EE36AD /* DiagnosticLoggingDomain.h in Headers */ = {isa = PBXBuildFile; fileRef = 72F667DF260C264400EE36AD /* DiagnosticLoggingDomain.h */; settings = {ATTRIBUTES = (Private, ); }; };
72F7E746279B8F7500D82D2D /* SourceImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 72F7E744279B8F7400D82D2D /* SourceImage.h */; settings = {ATTRIBUTES = (Private, ); }; };
72FD30AC27E3217B0023CDAC /* SourceBrush.h in Headers */ = {isa = PBXBuildFile; fileRef = 72FD30AA27E3217B0023CDAC /* SourceBrush.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -11464,6 +11465,7 @@
72C18A3F230B04B7006847C7 /* ImagePaintingOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ImagePaintingOptions.h; sourceTree = "<group>"; };
72E417611A2E8D2F004C562A /* JSEXTsRGB.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSEXTsRGB.cpp; sourceTree = "<group>"; };
72E417621A2E8D2F004C562A /* JSEXTsRGB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSEXTsRGB.h; sourceTree = "<group>"; };
+ 72E5768A281B292600A75432 /* CopyImageOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CopyImageOptions.h; sourceTree = "<group>"; };
72EA09F723FCCB3D008504A5 /* DisplayListImageBuffer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DisplayListImageBuffer.h; sourceTree = "<group>"; };
72EA09F923FCCC6A008504A5 /* DisplayListDrawingContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DisplayListDrawingContext.h; sourceTree = "<group>"; };
72F1AD9F1A3904C300014E18 /* EXTFragDepth.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EXTFragDepth.cpp; sourceTree = "<group>"; };
@@ -29100,6 +29102,7 @@
72BAC3A723E17328008D741C /* ConcreteImageBuffer.h */,
CDAD1A5827AFBF3900699285 /* ContentTypeUtilities.cpp */,
CDAD1A5727AFBF3900699285 /* ContentTypeUtilities.h */,
+ 72E5768A281B292600A75432 /* CopyImageOptions.h */,
2D2FC0541460CD6F00263633 /* CrossfadeGeneratedImage.cpp */,
2D2FC0551460CD6F00263633 /* CrossfadeGeneratedImage.h */,
A8CB41020E85B8A50032C4F0 /* DashArray.h */,
@@ -34161,6 +34164,7 @@
7A5699702086C619000E0433 /* CookieRequestHeaderFieldProxy.h in Headers */,
33D0212D131DB37B004091A8 /* CookieStorage.h in Headers */,
5120BBAF1F1CECE700EFEBF1 /* CookieStorageObserver.h in Headers */,
+ 72E5768B281B2B5500A75432 /* CopyImageOptions.h in Headers */,
3F8020351E9E47BF00DEC61D /* CoreAudioCaptureDevice.h in Headers */,
3F8020371E9E47C500DEC61D /* CoreAudioCaptureDeviceManager.h in Headers */,
41FCCC3B2746675600892AD6 /* CoreAudioCaptureSource.h in Headers */,
Added: trunk/Source/WebCore/platform/graphics/CopyImageOptions.h (0 => 293846)
--- trunk/Source/WebCore/platform/graphics/CopyImageOptions.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/CopyImageOptions.h 2022-05-05 18:00:15 UTC (rev 293846)
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 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
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+namespace WebCore {
+
+enum BackingStoreCopy {
+ CopyBackingStore, // Guarantee subsequent draws don't affect the copy.
+ DontCopyBackingStore // Subsequent draws may affect the copy.
+};
+
+enum class ShouldInterpolate : bool {
+ Yes, // Apply a pixel-smoothing algorithm to the image.
+ No // Edges of the image may appear pixelated.
+};
+
+} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/ImageBufferBackend.h (293845 => 293846)
--- trunk/Source/WebCore/platform/graphics/ImageBufferBackend.h 2022-05-05 17:27:25 UTC (rev 293845)
+++ trunk/Source/WebCore/platform/graphics/ImageBufferBackend.h 2022-05-05 18:00:15 UTC (rev 293846)
@@ -25,6 +25,7 @@
#pragma once
+#include "CopyImageOptions.h"
#include "DestinationColorSpace.h"
#include "FloatRect.h"
#include "GraphicsTypesGL.h"
@@ -52,11 +53,6 @@
class NativeImage;
class PixelBuffer;
-enum BackingStoreCopy {
- CopyBackingStore, // Guarantee subsequent draws don't affect the copy.
- DontCopyBackingStore // Subsequent draws may affect the copy.
-};
-
enum class PreserveResolution : uint8_t {
No,
Yes,
Modified: trunk/Source/WebKit/ChangeLog (293845 => 293846)
--- trunk/Source/WebKit/ChangeLog 2022-05-05 17:27:25 UTC (rev 293845)
+++ trunk/Source/WebKit/ChangeLog 2022-05-05 18:00:15 UTC (rev 293846)
@@ -1,3 +1,29 @@
+2022-05-05 Said Abou-Hallawa <[email protected]>
+
+ [GPU Process] NativeImage should share the ShareableBitmap data when it's sent to GPU Process
+ https://bugs.webkit.org/show_bug.cgi?id=239874
+ rdar://92031359
+
+ Reviewed by Simon Fraser.
+
+ Instead of allocating a new memory buffer in GPUProcess and copying the
+ ShareableBitmap data to it, we can create a PlatformImage that directly
+ references this data. This will make all the NativeImages data be attributed
+ to WebProcess.
+
+ * GPUProcess/graphics/RemoteRenderingBackend.cpp:
+ (WebKit::RemoteRenderingBackend::cacheNativeImageWithQualifiedIdentifier):
+ * Shared/ShareableBitmap.h:
+ (WebKit::ShareableBitmap::createPlatformImage):
+ * Shared/cg/ShareableBitmapCG.cpp:
+ (WebKit::ShareableBitmap::makeCGImage):
+ (WebKit::ShareableBitmap::createPlatformImage):
+ (WebKit::ShareableBitmap::createCGImage const):
+ (WebKit::ShareableBitmap::releaseDataProviderData): Deleted.
+ * WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.cpp:
+ (WebKit::ImageBufferShareableBitmapBackend::copyNativeImage const):
+ * WebProcess/GPU/graphics/RemoteImageBufferProxy.h:
+
2022-05-05 Jer Noble <[email protected]>
[WK2][Cocoa] Remove use of CVPixelBufferConformer from WebContent process in MediaPlayerPrivateRemote::nativeImageForCurrentTime()
Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp (293845 => 293846)
--- trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp 2022-05-05 17:27:25 UTC (rev 293845)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp 2022-05-05 18:00:15 UTC (rev 293846)
@@ -347,11 +347,11 @@
if (!bitmap)
return;
- auto image = NativeImage::create(bitmap->createPlatformImage(), nativeImageResourceIdentifier.object());
+ auto image = NativeImage::create(bitmap->createPlatformImage(DontCopyBackingStore, ShouldInterpolate::Yes), nativeImageResourceIdentifier.object());
if (!image)
return;
- m_remoteResourceCache.cacheNativeImage(*image, nativeImageResourceIdentifier);
+ m_remoteResourceCache.cacheNativeImage(image.releaseNonNull(), nativeImageResourceIdentifier);
}
void RemoteRenderingBackend::cacheFont(Ref<Font>&& font)
Modified: trunk/Source/WebKit/Shared/ShareableBitmap.h (293845 => 293846)
--- trunk/Source/WebKit/Shared/ShareableBitmap.h 2022-05-05 17:27:25 UTC (rev 293845)
+++ trunk/Source/WebKit/Shared/ShareableBitmap.h 2022-05-05 18:00:15 UTC (rev 293846)
@@ -26,6 +26,7 @@
#pragma once
#include "SharedMemory.h"
+#include <WebCore/CopyImageOptions.h>
#include <WebCore/DestinationColorSpace.h>
#include <WebCore/IntRect.h>
#include <WebCore/PlatformImage.h>
@@ -114,9 +115,9 @@
// This creates a CGImageRef that directly references the shared bitmap data.
// This is only safe to use when we know that the contents of the shareable bitmap won't change.
- RetainPtr<CGImageRef> makeCGImage();
+ RetainPtr<CGImageRef> makeCGImage(WebCore::ShouldInterpolate = WebCore::ShouldInterpolate::No);
- WebCore::PlatformImagePtr createPlatformImage() { return makeCGImageCopy(); }
+ WebCore::PlatformImagePtr createPlatformImage(WebCore::BackingStoreCopy = WebCore::CopyBackingStore, WebCore::ShouldInterpolate = WebCore::ShouldInterpolate::No);
#elif USE(CAIRO)
// This creates a BitmapImage that directly references the shared bitmap data.
// This is only safe to use when we know that the contents of the shareable bitmap won't change.
@@ -123,7 +124,7 @@
RefPtr<cairo_surface_t> createPersistentCairoSurface();
RefPtr<cairo_surface_t> createCairoSurface();
- WebCore::PlatformImagePtr createPlatformImage() { return createCairoSurface(); }
+ WebCore::PlatformImagePtr createPlatformImage(WebCore::BackingStoreCopy = WebCore::CopyBackingStore, WebCore::ShouldInterpolate = WebCore::ShouldInterpolate::No) { return createCairoSurface(); }
#endif
private:
@@ -130,9 +131,8 @@
ShareableBitmap(const WebCore::IntSize&, Configuration, Ref<SharedMemory>&&);
#if USE(CG)
- RetainPtr<CGImageRef> createCGImage(CGDataProviderRef) const;
+ RetainPtr<CGImageRef> createCGImage(CGDataProviderRef, WebCore::ShouldInterpolate) const;
static void releaseBitmapContextData(void* typelessBitmap, void* typelessData);
- static void releaseDataProviderData(void* typelessBitmap, const void* typelessData, size_t);
#endif
#if USE(CAIRO)
Modified: trunk/Source/WebKit/Shared/cg/ShareableBitmapCG.cpp (293845 => 293846)
--- trunk/Source/WebKit/Shared/cg/ShareableBitmapCG.cpp 2022-05-05 17:27:25 UTC (rev 293845)
+++ trunk/Source/WebKit/Shared/cg/ShareableBitmapCG.cpp 2022-05-05 18:00:15 UTC (rev 293846)
@@ -171,16 +171,33 @@
return adoptCF(CGBitmapContextCreateImage(graphicsContext->platformContext()));
}
-RetainPtr<CGImageRef> ShareableBitmap::makeCGImage()
+RetainPtr<CGImageRef> ShareableBitmap::makeCGImage(ShouldInterpolate shouldInterpolate)
{
- ref(); // Balanced by deref in releaseDataProviderData.
verifyImageBufferIsBigEnough(data(), sizeInBytes());
- RetainPtr<CGDataProvider> dataProvider = adoptCF(CGDataProviderCreateWithData(this, data(), sizeInBytes(), releaseDataProviderData));
- return createCGImage(dataProvider.get());
+
+ auto dataProvider = adoptCF(CGDataProviderCreateWithData(this, data(), sizeInBytes(), [](void* typelessBitmap, const void* typelessData, size_t) {
+ auto* bitmap = static_cast<ShareableBitmap*>(typelessBitmap);
+ ASSERT_UNUSED(typelessData, bitmap->data() == typelessData);
+ bitmap->deref();
+ }));
+
+ if (!dataProvider)
+ return nullptr;
+
+ ref(); // Balanced by deref above.
+
+ return createCGImage(dataProvider.get(), shouldInterpolate);
}
-RetainPtr<CGImageRef> ShareableBitmap::createCGImage(CGDataProviderRef dataProvider) const
+PlatformImagePtr ShareableBitmap::createPlatformImage(BackingStoreCopy copyBehavior, ShouldInterpolate shouldInterpolate)
{
+ if (copyBehavior == CopyBackingStore)
+ return makeCGImageCopy();
+ return makeCGImage(shouldInterpolate);
+}
+
+RetainPtr<CGImageRef> ShareableBitmap::createCGImage(CGDataProviderRef dataProvider, ShouldInterpolate shouldInterpolate) const
+{
ASSERT_ARG(dataProvider, dataProvider);
auto bitsPerPixel = calculateBytesPerPixel(m_configuration) * 8;
if (bitsPerPixel.hasOverflowed())
@@ -190,8 +207,7 @@
if (bytesPerRow.hasOverflowed())
return nullptr;
- RetainPtr<CGImageRef> image = adoptCF(CGImageCreate(m_size.width(), m_size.height(), bitsPerPixel / 4, bitsPerPixel, bytesPerRow, colorSpace(m_configuration), bitmapInfo(m_configuration), dataProvider, 0, false, kCGRenderingIntentDefault));
- return image;
+ return adoptCF(CGImageCreate(m_size.width(), m_size.height(), bitsPerPixel / 4, bitsPerPixel, bytesPerRow, colorSpace(m_configuration), bitmapInfo(m_configuration), dataProvider, 0, shouldInterpolate == ShouldInterpolate::Yes ? true : false, kCGRenderingIntentDefault));
}
void ShareableBitmap::releaseBitmapContextData(void* typelessBitmap, void* typelessData)
@@ -202,13 +218,6 @@
bitmap->deref(); // Balanced by ref in createGraphicsContext.
}
-void ShareableBitmap::releaseDataProviderData(void* typelessBitmap, const void* typelessData, size_t)
-{
- ShareableBitmap* bitmap = static_cast<ShareableBitmap*>(typelessBitmap);
- ASSERT_UNUSED(typelessData, bitmap->data() == typelessData);
- bitmap->deref(); // Balanced by ref in createCGImage.
-}
-
RefPtr<Image> ShareableBitmap::createImage()
{
if (auto platformImage = makeCGImage())
Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.cpp (293845 => 293846)
--- trunk/Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.cpp 2022-05-05 17:27:25 UTC (rev 293845)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.cpp 2022-05-05 18:00:15 UTC (rev 293846)
@@ -148,9 +148,9 @@
}
#endif
-RefPtr<NativeImage> ImageBufferShareableBitmapBackend::copyNativeImage(BackingStoreCopy) const
+RefPtr<NativeImage> ImageBufferShareableBitmapBackend::copyNativeImage(BackingStoreCopy copyBehavior) const
{
- return NativeImage::create(m_bitmap->createPlatformImage());
+ return NativeImage::create(m_bitmap->createPlatformImage(copyBehavior));
}
RefPtr<Image> ImageBufferShareableBitmapBackend::copyImage(BackingStoreCopy, PreserveResolution) const
Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h (293845 => 293846)
--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h 2022-05-05 17:27:25 UTC (rev 293845)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h 2022-05-05 18:00:15 UTC (rev 293846)
@@ -174,7 +174,7 @@
return m_remoteRenderingBackendProxy->getDataForImageBuffer(mimeType, quality, m_renderingResourceIdentifier);
}
- RefPtr<WebCore::NativeImage> copyNativeImage(WebCore::BackingStoreCopy = WebCore::BackingStoreCopy::CopyBackingStore) const final
+ RefPtr<WebCore::NativeImage> copyNativeImage(WebCore::BackingStoreCopy = WebCore::CopyBackingStore) const final
{
if (UNLIKELY(!m_remoteRenderingBackendProxy))
return { };
@@ -182,10 +182,10 @@
auto bitmap = m_remoteRenderingBackendProxy->getShareableBitmap(m_renderingResourceIdentifier, WebCore::PreserveResolution::Yes);
if (!bitmap)
return { };
- return WebCore::NativeImage::create(bitmap->createPlatformImage());
+ return WebCore::NativeImage::create(bitmap->createPlatformImage(WebCore::DontCopyBackingStore));
}
- RefPtr<WebCore::Image> copyImage(WebCore::BackingStoreCopy = WebCore::BackingStoreCopy::CopyBackingStore, WebCore::PreserveResolution preserveResolution = WebCore::PreserveResolution::No) const final
+ RefPtr<WebCore::Image> copyImage(WebCore::BackingStoreCopy = WebCore::CopyBackingStore, WebCore::PreserveResolution preserveResolution = WebCore::PreserveResolution::No) const final
{
if (UNLIKELY(!m_remoteRenderingBackendProxy))
return { };