Title: [277763] trunk/Source
Revision
277763
Author
wei...@apple.com
Date
2021-05-19 17:13:42 -0700 (Wed, 19 May 2021)

Log Message

Remove ImageBuffer::toBGRA() and replace its uses with the more general ImageBuffer::getPixelBuffer()
https://bugs.webkit.org/show_bug.cgi?id=225976

Reviewed by Said Abou-Hallawa.

Source/WebCore:

Removes ImageBuffer::toBGRA() and replaces it with the more verbose (but also more clear)
ImageBuffer::getPixelBuffer(). There were only two users of toBGRA(), MediaSample creation
from a <canvas> and PageColorSampler. For MediaSample, we likely should not be doing
readback this way, and should instead try to keep the data in the GPU process / on the GPU
when possible / necessary.

* html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::toMediaSample):
Update calls to pass imageBuffer and share call to makeRenderingResultsAvailable().

* page/PageColorSampler.cpp:
(WebCore::sampleColor):
Update ot use getPixelBuffer().

* platform/graphics/avfoundation/objc/MediaSampleAVFObjC.h:
* platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm:
(WebCore::MediaSampleAVFObjC::createImageSample):
Update MediaSampleAVFObjC to use getPixelBuffer directly().

* platform/graphics/gstreamer/MediaSampleGStreamer.cpp:
(WebCore::MediaSampleGStreamer::createImageSample):
* platform/graphics/gstreamer/MediaSampleGStreamer.h:
(WebCore::MediaSampleGStreamer::createImageSample):
* platform/mediastream/gstreamer/MockRealtimeVideoSourceGStreamer.cpp:
(WebCore::MockRealtimeVideoSourceGStreamer::updateSampleBuffer):
Update MediaSampleGStreamer to use getPixelBuffer directly().

* platform/MediaSample.h:
Use #pragma once.

* platform/graphics/ConcreteImageBuffer.h:
* platform/graphics/ImageBuffer.h:
* platform/graphics/ImageBufferBackend.cpp:
(WebCore::ImageBufferBackend::toBGRAData const): Deleted.
* platform/graphics/ImageBufferBackend.h:
* platform/graphics/cairo/ImageBufferCairoSurfaceBackend.cpp:
(WebCore::ImageBufferCairoSurfaceBackend::toBGRAData const): Deleted.
* platform/graphics/cairo/ImageBufferCairoSurfaceBackend.h:
* platform/graphics/cg/ImageBufferCGBitmapBackend.cpp:
(WebCore::ImageBufferCGBitmapBackend::toBGRAData const): Deleted.
* platform/graphics/cg/ImageBufferCGBitmapBackend.h:
* platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp:
(WebCore::ImageBufferIOSurfaceBackend::toBGRAData const): Deleted.
* platform/graphics/cg/ImageBufferIOSurfaceBackend.h:
* platform/graphics/win/ImageBufferDirect2DBackend.cpp:
(WebCore::ImageBufferDirect2DBackend::toBGRAData const): Deleted.
* platform/graphics/win/ImageBufferDirect2DBackend.h:
Remove toBGRA().

Source/WebKit:

Remove ImageBuffer::toBGRA().

* GPUProcess/graphics/RemoteRenderingBackend.cpp:
(WebKit::RemoteRenderingBackend::getBGRADataForImageBuffer): Deleted.
* GPUProcess/graphics/RemoteRenderingBackend.h:
* GPUProcess/graphics/RemoteRenderingBackend.messages.in:
* Shared/RemoteLayerTree/CGDisplayListImageBufferBackend.cpp:
(WebKit::CGDisplayListImageBufferBackend::toBGRAData const): Deleted.
* Shared/RemoteLayerTree/CGDisplayListImageBufferBackend.h:
* WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.cpp:
(WebKit::ImageBufferShareableBitmapBackend::toBGRAData const): Deleted.
* WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.h:
* WebProcess/GPU/graphics/RemoteImageBufferProxy.h:
* WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp:
(WebKit::RemoteRenderingBackendProxy::getBGRADataForImageBuffer): Deleted.
* WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h:
* WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.cpp:
(WebKit::ImageBufferShareableIOSurfaceBackend::toBGRAData const): Deleted.
* WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (277762 => 277763)


--- trunk/Source/WebCore/ChangeLog	2021-05-20 00:05:57 UTC (rev 277762)
+++ trunk/Source/WebCore/ChangeLog	2021-05-20 00:13:42 UTC (rev 277763)
@@ -1,3 +1,59 @@
+2021-05-19  Sam Weinig  <wei...@apple.com>
+
+        Remove ImageBuffer::toBGRA() and replace its uses with the more general ImageBuffer::getPixelBuffer()
+        https://bugs.webkit.org/show_bug.cgi?id=225976
+
+        Reviewed by Said Abou-Hallawa.
+
+        Removes ImageBuffer::toBGRA() and replaces it with the more verbose (but also more clear)
+        ImageBuffer::getPixelBuffer(). There were only two users of toBGRA(), MediaSample creation
+        from a <canvas> and PageColorSampler. For MediaSample, we likely should not be doing
+        readback this way, and should instead try to keep the data in the GPU process / on the GPU
+        when possible / necessary.
+
+        * html/HTMLCanvasElement.cpp:
+        (WebCore::HTMLCanvasElement::toMediaSample):
+        Update calls to pass imageBuffer and share call to makeRenderingResultsAvailable().
+
+        * page/PageColorSampler.cpp:
+        (WebCore::sampleColor):
+        Update ot use getPixelBuffer().
+
+        * platform/graphics/avfoundation/objc/MediaSampleAVFObjC.h:
+        * platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm:
+        (WebCore::MediaSampleAVFObjC::createImageSample):
+        Update MediaSampleAVFObjC to use getPixelBuffer directly().
+
+        * platform/graphics/gstreamer/MediaSampleGStreamer.cpp:
+        (WebCore::MediaSampleGStreamer::createImageSample):
+        * platform/graphics/gstreamer/MediaSampleGStreamer.h:
+        (WebCore::MediaSampleGStreamer::createImageSample):
+        * platform/mediastream/gstreamer/MockRealtimeVideoSourceGStreamer.cpp:
+        (WebCore::MockRealtimeVideoSourceGStreamer::updateSampleBuffer):
+        Update MediaSampleGStreamer to use getPixelBuffer directly().
+
+        * platform/MediaSample.h:
+        Use #pragma once.
+
+        * platform/graphics/ConcreteImageBuffer.h:
+        * platform/graphics/ImageBuffer.h:
+        * platform/graphics/ImageBufferBackend.cpp:
+        (WebCore::ImageBufferBackend::toBGRAData const): Deleted.
+        * platform/graphics/ImageBufferBackend.h:
+        * platform/graphics/cairo/ImageBufferCairoSurfaceBackend.cpp:
+        (WebCore::ImageBufferCairoSurfaceBackend::toBGRAData const): Deleted.
+        * platform/graphics/cairo/ImageBufferCairoSurfaceBackend.h:
+        * platform/graphics/cg/ImageBufferCGBitmapBackend.cpp:
+        (WebCore::ImageBufferCGBitmapBackend::toBGRAData const): Deleted.
+        * platform/graphics/cg/ImageBufferCGBitmapBackend.h:
+        * platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp:
+        (WebCore::ImageBufferIOSurfaceBackend::toBGRAData const): Deleted.
+        * platform/graphics/cg/ImageBufferIOSurfaceBackend.h:
+        * platform/graphics/win/ImageBufferDirect2DBackend.cpp:
+        (WebCore::ImageBufferDirect2DBackend::toBGRAData const): Deleted.
+        * platform/graphics/win/ImageBufferDirect2DBackend.h:
+        Remove toBGRA().
+
 2021-05-19  Cameron McCormack  <hey...@apple.com>
 
         Remove unused GraphicsContextImpl constructor arguments

Modified: trunk/Source/WebCore/html/HTMLCanvasElement.cpp (277762 => 277763)


--- trunk/Source/WebCore/html/HTMLCanvasElement.cpp	2021-05-20 00:05:57 UTC (rev 277762)
+++ trunk/Source/WebCore/html/HTMLCanvasElement.cpp	2021-05-20 00:13:42 UTC (rev 277763)
@@ -813,6 +813,7 @@
 
 RefPtr<MediaSample> HTMLCanvasElement::toMediaSample()
 {
+#if PLATFORM(COCOA) || USE(GSTREAMER)
     auto* imageBuffer = buffer();
     if (!imageBuffer)
         return nullptr;
@@ -819,12 +820,20 @@
     if (RuntimeEnabledFeatures::sharedFeatures().webAPIStatisticsEnabled())
         ResourceLoadObserver::shared().logCanvasRead(document());
 
+    makeRenderingResultsAvailable();
+
+    // FIXME: This can likely be optimized quite a bit, especially in the cases where
+    // the ImageBuffer is backed by GPU memory already and/or is in the GPU process by
+    // specializing toMediaSample() in ImageBufferBackend to not use getPixelBuffer().
+    auto pixelBuffer = imageBuffer->getPixelBuffer({ AlphaPremultiplication::Unpremultiplied, PixelFormat::BGRA8, DestinationColorSpace::SRGB }, { { }, imageBuffer->logicalSize() });
+    if (!pixelBuffer)
+        return nullptr;
+
 #if PLATFORM(COCOA)
-    makeRenderingResultsAvailable();
-    return MediaSampleAVFObjC::createImageSample(imageBuffer->toBGRAData(), width(), height());
+    return MediaSampleAVFObjC::createImageSample(WTFMove(*pixelBuffer));
 #elif USE(GSTREAMER)
-    makeRenderingResultsAvailable();
-    return MediaSampleGStreamer::createImageSample(imageBuffer->toBGRAData(), size());
+    return MediaSampleGStreamer::createImageSample(WTFMove(*pixelBuffer));
+#endif
 #else
     return nullptr;
 #endif

Modified: trunk/Source/WebCore/page/PageColorSampler.cpp (277762 => 277763)


--- trunk/Source/WebCore/page/PageColorSampler.cpp	2021-05-20 00:05:57 UTC (rev 277762)
+++ trunk/Source/WebCore/page/PageColorSampler.cpp	2021-05-20 00:13:42 UTC (rev 277763)
@@ -41,6 +41,7 @@
 #include "IntSize.h"
 #include "Node.h"
 #include "Page.h"
+#include "PixelBuffer.h"
 #include "RegistrableDomain.h"
 #include "RenderImage.h"
 #include "RenderObject.h"
@@ -103,7 +104,13 @@
     if (!snapshot)
         return WTF::nullopt;
 
-    auto snapshotData = snapshot->toBGRAData();
+    auto pixelBuffer = snapshot->getPixelBuffer({ AlphaPremultiplication::Unpremultiplied, PixelFormat::BGRA8, DestinationColorSpace::SRGB }, { { }, snapshot->logicalSize() });
+    if (!pixelBuffer)
+        return WTF::nullopt;
+
+    ASSERT(pixelBuffer->data().length() <= 4);
+
+    auto snapshotData = pixelBuffer->data().data();
     return convertColor<Lab<float>>(SRGBA<uint8_t> { snapshotData[2], snapshotData[1], snapshotData[0], snapshotData[3] });
 }
 

Modified: trunk/Source/WebCore/platform/MediaSample.h (277762 => 277763)


--- trunk/Source/WebCore/platform/MediaSample.h	2021-05-20 00:05:57 UTC (rev 277762)
+++ trunk/Source/WebCore/platform/MediaSample.h	2021-05-20 00:13:42 UTC (rev 277763)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-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
@@ -23,8 +23,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef MediaSample_h
-#define MediaSample_h
+#pragma once
 
 #include "FloatSize.h"
 #include <_javascript_Core/TypedArrays.h>
@@ -152,5 +151,3 @@
 };
 
 } // namespace WTF
-
-#endif

Modified: trunk/Source/WebCore/platform/graphics/ConcreteImageBuffer.h (277762 => 277763)


--- trunk/Source/WebCore/platform/graphics/ConcreteImageBuffer.h	2021-05-20 00:05:57 UTC (rev 277762)
+++ trunk/Source/WebCore/platform/graphics/ConcreteImageBuffer.h	2021-05-20 00:13:42 UTC (rev 277763)
@@ -221,15 +221,6 @@
         return { };
     }
 
-    Vector<uint8_t> toBGRAData() const override
-    {
-        if (auto* backend = ensureBackendCreated()) {
-            const_cast<ConcreteImageBuffer&>(*this).flushContext();
-            return backend->toBGRAData();
-        }
-        return { };
-    }
-
     Optional<PixelBuffer> getPixelBuffer(const PixelBufferFormat& outputFormat, const IntRect& srcRect) const override
     {
         if (auto* backend = ensureBackendCreated()) {

Modified: trunk/Source/WebCore/platform/graphics/ImageBuffer.h (277762 => 277763)


--- trunk/Source/WebCore/platform/graphics/ImageBuffer.h	2021-05-20 00:05:57 UTC (rev 277762)
+++ trunk/Source/WebCore/platform/graphics/ImageBuffer.h	2021-05-20 00:13:42 UTC (rev 277763)
@@ -124,7 +124,6 @@
 
     virtual String toDataURL(const String& mimeType, Optional<double> quality = WTF::nullopt, PreserveResolution = PreserveResolution::No) const = 0;
     virtual Vector<uint8_t> toData(const String& mimeType, Optional<double> quality = WTF::nullopt) const = 0;
-    virtual Vector<uint8_t> toBGRAData() const = 0;
 
     virtual Optional<PixelBuffer> getPixelBuffer(const PixelBufferFormat& outputFormat, const IntRect& srcRect) const = 0;
     virtual void putPixelBuffer(const PixelBuffer&, const IntRect& srcRect, const IntPoint& destPoint = { }, AlphaPremultiplication destFormat = AlphaPremultiplication::Premultiplied) = 0;
@@ -133,7 +132,7 @@
     // with textures that are RGB or RGBA format, and UNSIGNED_BYTE type.
     virtual bool copyToPlatformTexture(GraphicsContextGL&, GCGLenum, PlatformGLObject, GCGLenum, bool, bool) const = 0;
     virtual PlatformLayer* platformLayer() const = 0;
-    
+
 protected:
     ImageBuffer() = default;
 

Modified: trunk/Source/WebCore/platform/graphics/ImageBufferBackend.cpp (277762 => 277763)


--- trunk/Source/WebCore/platform/graphics/ImageBufferBackend.cpp	2021-05-20 00:05:57 UTC (rev 277762)
+++ trunk/Source/WebCore/platform/graphics/ImageBufferBackend.cpp	2021-05-20 00:13:42 UTC (rev 277763)
@@ -92,28 +92,6 @@
     putPixelBuffer(*pixelBuffer, logicalRect(), IntPoint::zero(), AlphaPremultiplication::Premultiplied);
 }
 
-Vector<uint8_t> ImageBufferBackend::toBGRAData(void* data) const
-{
-    Vector<uint8_t> result(4 * logicalSize().area().unsafeGet());
-
-    PixelBufferFormat sourceFormat { AlphaPremultiplication::Premultiplied, pixelFormat(), DestinationColorSpace::SRGB };
-    PixelBufferFormat destinationFormat { AlphaPremultiplication::Unpremultiplied, PixelFormat::BGRA8, DestinationColorSpace::SRGB };
-
-    ConstPixelBufferConversionView source;
-    source.format = sourceFormat;
-    source.bytesPerRow = bytesPerRow();
-    source.rows = reinterpret_cast<const uint8_t*>(data);
-    
-    PixelBufferConversionView destination;
-    destination.format = destinationFormat;
-    destination.bytesPerRow = logicalSize().width() * 4;
-    destination.rows = result.data();
-
-    convertImagePixels(source, destination, logicalSize());
-
-    return result;
-}
-
 Optional<PixelBuffer> ImageBufferBackend::getPixelBuffer(const PixelBufferFormat& destinationFormat, const IntRect& sourceRect, void* data) const
 {
     ASSERT(PixelBuffer::supportedPixelFormat(destinationFormat.pixelFormat));

Modified: trunk/Source/WebCore/platform/graphics/ImageBufferBackend.h (277762 => 277763)


--- trunk/Source/WebCore/platform/graphics/ImageBufferBackend.h	2021-05-20 00:05:57 UTC (rev 277762)
+++ trunk/Source/WebCore/platform/graphics/ImageBufferBackend.h	2021-05-20 00:13:42 UTC (rev 277763)
@@ -106,7 +106,6 @@
 
     virtual String toDataURL(const String& mimeType, Optional<double> quality, PreserveResolution) const = 0;
     virtual Vector<uint8_t> toData(const String& mimeType, Optional<double> quality) const = 0;
-    virtual Vector<uint8_t> toBGRAData() const = 0;
 
     virtual Optional<PixelBuffer> getPixelBuffer(const PixelBufferFormat& outputFormat, const IntRect&) const = 0;
     virtual void putPixelBuffer(const PixelBuffer&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) = 0;
@@ -147,8 +146,6 @@
     IntRect logicalRect() const { return IntRect(IntPoint::zero(), logicalSize()); };
     IntRect backendRect() const { return IntRect(IntPoint::zero(), backendSize()); };
 
-    WEBCORE_EXPORT Vector<uint8_t> toBGRAData(void* data) const;
-
     WEBCORE_EXPORT Optional<PixelBuffer> getPixelBuffer(const PixelBufferFormat& outputFormat, const IntRect& srcRect, void* data) const;
     WEBCORE_EXPORT void putPixelBuffer(const PixelBuffer&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat, void* data);
 

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.h (277762 => 277763)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.h	2021-05-20 00:05:57 UTC (rev 277762)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.h	2021-05-20 00:13:42 UTC (rev 277763)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-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
@@ -32,12 +32,14 @@
 
 namespace WebCore {
 
+class PixelBuffer;
+
 class WEBCORE_EXPORT MediaSampleAVFObjC : public MediaSample {
 public:
     static Ref<MediaSampleAVFObjC> create(CMSampleBufferRef sample, uint64_t trackID) { return adoptRef(*new MediaSampleAVFObjC(sample, trackID)); }
     static Ref<MediaSampleAVFObjC> create(CMSampleBufferRef sample, AtomString trackID) { return adoptRef(*new MediaSampleAVFObjC(sample, trackID)); }
     static Ref<MediaSampleAVFObjC> create(CMSampleBufferRef sample, VideoRotation rotation = VideoRotation::None, bool mirrored = false) { return adoptRef(*new MediaSampleAVFObjC(sample, rotation, mirrored)); }
-    static RefPtr<MediaSampleAVFObjC> createImageSample(Vector<uint8_t>&&, unsigned width, unsigned height);
+    static RefPtr<MediaSampleAVFObjC> createImageSample(PixelBuffer&&);
 
     WEBCORE_EXPORT static void setAsDisplayImmediately(MediaSample&);
     static RetainPtr<CMSampleBufferRef> cloneSampleBufferAndSetAsDisplayImmediately(CMSampleBufferRef);

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm (277762 => 277763)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm	2021-05-20 00:05:57 UTC (rev 277762)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm	2021-05-20 00:13:42 UTC (rev 277763)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-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
@@ -26,6 +26,7 @@
 #import "config.h"
 #import "MediaSampleAVFObjC.h"
 
+#import "PixelBuffer.h"
 #import "PixelBufferConformerCV.h"
 #import <_javascript_Core/JSCInlines.h>
 #import <_javascript_Core/TypedArrayInlines.h>
@@ -41,31 +42,38 @@
 
 namespace WebCore {
 
-static void deallocateVectorBuffer(void* array, const void*)
+RefPtr<MediaSampleAVFObjC> MediaSampleAVFObjC::createImageSample(PixelBuffer&& pixelBuffer)
 {
-    WTF::VectorMalloc::free(array);
-}
+    auto size = pixelBuffer.size();
+    auto width = size.width();
+    auto height = size.height();
 
-RefPtr<MediaSampleAVFObjC> MediaSampleAVFObjC::createImageSample(Vector<uint8_t>&& array, unsigned width, unsigned height)
-{
-    CVPixelBufferRef pixelBufferRaw = nullptr;
-    auto data = ""
-    auto status = CVPixelBufferCreateWithBytes(kCFAllocatorDefault, width, height, kCVPixelFormatType_32BGRA, data, width * 4, deallocateVectorBuffer, data, nullptr, &pixelBufferRaw);
-    auto pixelBuffer = adoptCF(pixelBufferRaw);
-    if (!pixelBuffer) {
-        deallocateVectorBuffer(data, nullptr);
+    auto data = ""
+    auto dataBaseAddress = data->data();
+    auto leakedData = &data.leakRef();
+    
+    auto derefBuffer = [] (void* context, const void*) {
+        static_cast<JSC::Uint8ClampedArray*>(context)->deref();
+    };
+
+    CVPixelBufferRef cvPixelBufferRaw = nullptr;
+    auto status = CVPixelBufferCreateWithBytes(kCFAllocatorDefault, width, height, kCVPixelFormatType_32BGRA, dataBaseAddress, width * 4, derefBuffer, leakedData, nullptr, &cvPixelBufferRaw);
+
+    auto cvPixelBuffer = adoptCF(cvPixelBufferRaw);
+    if (!cvPixelBuffer) {
+        derefBuffer(leakedData, nullptr);
         return nullptr;
     }
     ASSERT_UNUSED(status, !status);
 
     CMVideoFormatDescriptionRef formatDescriptionRaw = nullptr;
-    status = CMVideoFormatDescriptionCreateForImageBuffer(kCFAllocatorDefault, pixelBuffer.get(), &formatDescriptionRaw);
+    status = CMVideoFormatDescriptionCreateForImageBuffer(kCFAllocatorDefault, cvPixelBuffer.get(), &formatDescriptionRaw);
     ASSERT(!status);
     auto formatDescription = adoptCF(formatDescriptionRaw);
 
     CMSampleTimingInfo sampleTimingInformation = { kCMTimeInvalid, kCMTimeInvalid, kCMTimeInvalid };
     CMSampleBufferRef sampleBufferRaw = nullptr;
-    status = CMSampleBufferCreateReadyWithImageBuffer(kCFAllocatorDefault, pixelBuffer.get(), formatDescription.get(), &sampleTimingInformation, &sampleBufferRaw);
+    status = CMSampleBufferCreateReadyWithImageBuffer(kCFAllocatorDefault, cvPixelBuffer.get(), formatDescription.get(), &sampleTimingInformation, &sampleBufferRaw);
     ASSERT(!status);
     auto sampleBuffer = adoptCF(sampleBufferRaw);
 

Modified: trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairoSurfaceBackend.cpp (277762 => 277763)


--- trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairoSurfaceBackend.cpp	2021-05-20 00:05:57 UTC (rev 277762)
+++ trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairoSurfaceBackend.cpp	2021-05-20 00:13:42 UTC (rev 277763)
@@ -103,23 +103,6 @@
     return copyNativeImage(copyBehavior);
 }
 
-Vector<uint8_t> ImageBufferCairoSurfaceBackend::toBGRAData() const
-{
-    auto nativeImage = cairoSurfaceCoerceToImage();
-    auto surface = nativeImage ? nativeImage->platformImage() : nullptr;
-    cairo_surface_flush(surface.get());
-
-    Vector<uint8_t> imageData;
-    if (cairo_surface_status(surface.get()))
-        return imageData;
-
-    auto pixels = cairo_image_surface_get_data(surface.get());
-    imageData.append(pixels, cairo_image_surface_get_stride(surface.get()) *
-        cairo_image_surface_get_height(surface.get()));
-
-    return imageData;
-}
-
 Optional<PixelBuffer> ImageBufferCairoSurfaceBackend::getPixelBuffer(const PixelBufferFormat& outputFormat, const IntRect& srcRect) const
 {
     return ImageBufferBackend::getPixelBuffer(outputFormat, srcRect, cairo_image_surface_get_data(m_surface.get()));

Modified: trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairoSurfaceBackend.h (277762 => 277763)


--- trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairoSurfaceBackend.h	2021-05-20 00:05:57 UTC (rev 277762)
+++ trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairoSurfaceBackend.h	2021-05-20 00:13:42 UTC (rev 277763)
@@ -44,7 +44,6 @@
 
     RefPtr<NativeImage> copyNativeImage(BackingStoreCopy) const override;
 
-    Vector<uint8_t> toBGRAData() const override;
     Optional<PixelBuffer> getPixelBuffer(const PixelBufferFormat& outputFormat, const IntRect&) const override;
     void putPixelBuffer(const PixelBuffer&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) override;
 

Modified: trunk/Source/WebCore/platform/graphics/cg/ImageBufferCGBitmapBackend.cpp (277762 => 277763)


--- trunk/Source/WebCore/platform/graphics/cg/ImageBufferCGBitmapBackend.cpp	2021-05-20 00:05:57 UTC (rev 277762)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageBufferCGBitmapBackend.cpp	2021-05-20 00:13:42 UTC (rev 277763)
@@ -154,11 +154,6 @@
     return nullptr;
 }
 
-Vector<uint8_t> ImageBufferCGBitmapBackend::toBGRAData() const
-{
-    return ImageBufferBackend::toBGRAData(m_data);
-}
-
 Optional<PixelBuffer> ImageBufferCGBitmapBackend::getPixelBuffer(const PixelBufferFormat& outputFormat, const IntRect& srcRect) const
 {
     return ImageBufferBackend::getPixelBuffer(outputFormat, srcRect, m_data);

Modified: trunk/Source/WebCore/platform/graphics/cg/ImageBufferCGBitmapBackend.h (277762 => 277763)


--- trunk/Source/WebCore/platform/graphics/cg/ImageBufferCGBitmapBackend.h	2021-05-20 00:05:57 UTC (rev 277762)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageBufferCGBitmapBackend.h	2021-05-20 00:13:42 UTC (rev 277763)
@@ -49,8 +49,6 @@
 
     RefPtr<NativeImage> copyNativeImage(BackingStoreCopy = CopyBackingStore) const override;
 
-    Vector<uint8_t> toBGRAData() const override;
-
     Optional<PixelBuffer> getPixelBuffer(const PixelBufferFormat& outputFormat, const IntRect&) const override;
     void putPixelBuffer(const PixelBuffer&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) override;
 

Modified: trunk/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp (277762 => 277763)


--- trunk/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp	2021-05-20 00:05:57 UTC (rev 277762)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp	2021-05-20 00:13:42 UTC (rev 277763)
@@ -177,12 +177,6 @@
     return ImageBufferCGBackend::copyCGImageForEncoding(destinationUTI, preserveResolution);
 }
 
-Vector<uint8_t> ImageBufferIOSurfaceBackend::toBGRAData() const
-{
-    IOSurface::Locker lock(*m_surface);
-    return ImageBufferBackend::toBGRAData(lock.surfaceBaseAddress());
-}
-
 Optional<PixelBuffer> ImageBufferIOSurfaceBackend::getPixelBuffer(const PixelBufferFormat& outputFormat, const IntRect& srcRect) const
 {
     IOSurface::Locker lock(*m_surface);

Modified: trunk/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.h (277762 => 277763)


--- trunk/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.h	2021-05-20 00:05:57 UTC (rev 277762)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.h	2021-05-20 00:13:42 UTC (rev 277763)
@@ -60,7 +60,6 @@
 
     void drawConsuming(GraphicsContext&, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) override;
 
-    Vector<uint8_t> toBGRAData() const override;
 
     Optional<PixelBuffer> getPixelBuffer(const PixelBufferFormat& outputFormat, const IntRect&) const override;
     void putPixelBuffer(const PixelBuffer&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) override;

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaSampleGStreamer.cpp (277762 => 277763)


--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaSampleGStreamer.cpp	2021-05-20 00:05:57 UTC (rev 277762)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaSampleGStreamer.cpp	2021-05-20 00:13:42 UTC (rev 277763)
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2016 Metrological Group B.V.
  * Copyright (C) 2016, 2017, 2018 Igalia S.L
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -22,7 +23,7 @@
 #include "MediaSampleGStreamer.h"
 
 #include "GStreamerCommon.h"
-
+#include "PixelBuffer.h"
 #include <_javascript_Core/JSCInlines.h>
 #include <_javascript_Core/TypedArrayInlines.h>
 #include <algorithm>
@@ -97,14 +98,19 @@
     return adoptRef(*gstreamerMediaSample);
 }
 
-Ref<MediaSampleGStreamer> MediaSampleGStreamer::createImageSample(Vector<uint8_t>&& bgraData, const IntSize& size, const IntSize& destinationSize, double frameRate)
+Ref<MediaSampleGStreamer> MediaSampleGStreamer::createImageSample(PixelBuffer&& pixelBuffer, const IntSize& destinationSize, double frameRate)
 {
     ensureGStreamerInitialized();
+    
+    auto size = pixelBuffer.size();
 
-    size_t sizeInBytes = bgraData.sizeInBytes();
-    auto* data = ""
-    auto buffer = adoptGRef(gst_buffer_new_wrapped_full(GST_MEMORY_FLAG_READONLY, data, sizeInBytes, 0, sizeInBytes, data, [](gpointer data) {
-        WTF::VectorMalloc::free(data);
+    auto data = ""
+    auto sizeInBytes = data->byteLength();
+    auto dataBaseAddress = data->data();
+    auto leakedData = &data.leakRef();
+
+    auto buffer = adoptGRef(gst_buffer_new_wrapped_full(GST_MEMORY_FLAG_READONLY, dataBaseAddress, sizeInBytes, 0, sizeInBytes, leakedData, [](gpointer userData) {
+        static_cast<JSC::Uint8ClampedArray*>(userData)->deref();
     }));
 
     auto width = size.width();

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaSampleGStreamer.h (277762 => 277763)


--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaSampleGStreamer.h	2021-05-20 00:05:57 UTC (rev 277762)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaSampleGStreamer.h	2021-05-20 00:13:42 UTC (rev 277763)
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2016 Metrological Group B.V.
  * Copyright (C) 2016, 2017, 2018 Igalia S.L
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -29,6 +30,8 @@
 
 namespace WebCore {
 
+class PixelBuffer;
+
 class MediaSampleGStreamer : public MediaSample {
 public:
     static Ref<MediaSampleGStreamer> create(GRefPtr<GstSample>&& sample, const FloatSize& presentationSize, const AtomString& trackId)
@@ -37,7 +40,7 @@
     }
 
     static Ref<MediaSampleGStreamer> createFakeSample(GstCaps*, MediaTime pts, MediaTime dts, MediaTime duration, const FloatSize& presentationSize, const AtomString& trackId);
-    static Ref<MediaSampleGStreamer> createImageSample(Vector<uint8_t>&&, const IntSize& originalSize, const IntSize& destinationSize = { }, double frameRate = 1);
+    static Ref<MediaSampleGStreamer> createImageSample(PixelBuffer&&, const IntSize& destinationSize = { }, double frameRate = 1);
 
     void extendToTheBeginning();
     MediaTime presentationTime() const override { return m_pts; }

Modified: trunk/Source/WebCore/platform/graphics/win/ImageBufferDirect2DBackend.cpp (277762 => 277763)


--- trunk/Source/WebCore/platform/graphics/win/ImageBufferDirect2DBackend.cpp	2021-05-20 00:05:57 UTC (rev 277762)
+++ trunk/Source/WebCore/platform/graphics/win/ImageBufferDirect2DBackend.cpp	2021-05-20 00:13:42 UTC (rev 277763)
@@ -306,12 +306,6 @@
     return { };
 }
 
-Vector<uint8_t> ImageBufferDirect2DBackend::toBGRAData() const
-{
-    notImplemented();
-    return { };
-}
-
 Optional<PixelBuffer> ImageBufferDirect2DBackend::getPixelBuffer(const PixelBufferFormat& outputFormat, const IntRect& srcRect) const
 {
     notImplemented();

Modified: trunk/Source/WebCore/platform/graphics/win/ImageBufferDirect2DBackend.h (277762 => 277763)


--- trunk/Source/WebCore/platform/graphics/win/ImageBufferDirect2DBackend.h	2021-05-20 00:05:57 UTC (rev 277762)
+++ trunk/Source/WebCore/platform/graphics/win/ImageBufferDirect2DBackend.h	2021-05-20 00:13:42 UTC (rev 277763)
@@ -51,7 +51,6 @@
 
     String toDataURL(const String& mimeType, Optional<double> quality, PreserveResolution) const override;
     Vector<uint8_t> toData(const String& mimeType, Optional<double> quality) const override;
-    Vector<uint8_t> toBGRAData() const override;
 
     Optional<PixelBuffer> getPixelBuffer(const PixelBufferFormat& outputFormat, const IntRect&) const override;
     void putPixelBuffer(const PixelBuffer&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) override;

Modified: trunk/Source/WebCore/platform/mediastream/gstreamer/MockRealtimeVideoSourceGStreamer.cpp (277762 => 277763)


--- trunk/Source/WebCore/platform/mediastream/gstreamer/MockRealtimeVideoSourceGStreamer.cpp	2021-05-20 00:05:57 UTC (rev 277762)
+++ trunk/Source/WebCore/platform/mediastream/gstreamer/MockRealtimeVideoSourceGStreamer.cpp	2021-05-20 00:13:42 UTC (rev 277763)
@@ -3,6 +3,7 @@
  * Copyright (C) 2020 Igalia S.L.
  * Author: Thibault Saunier <tsaun...@igalia.com>
  * Author: Alejandro G. Castro <a...@igalia.com>
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -27,6 +28,7 @@
 
 #include "MediaSampleGStreamer.h"
 #include "MockRealtimeMediaSourceCenter.h"
+#include "PixelBuffer.h"
 
 namespace WebCore {
 
@@ -65,7 +67,11 @@
     if (!imageBuffer)
         return;
 
-    auto sample = MediaSampleGStreamer::createImageSample(imageBuffer->toBGRAData(), captureSize(), size(), frameRate());
+    auto pixelBuffer = imageBuffer->getPixelBuffer({ AlphaPremultiplication::Unpremultiplied, PixelFormat::BGRA8, DestinationColorSpace::SRGB }, { { }, imageBuffer->logicalSize() });
+    if (!pixelBuffer)
+        return;
+
+    auto sample = MediaSampleGStreamer::createImageSample(WTFMove(*pixelBuffer), size(), frameRate());
     sample->offsetTimestampsBy(MediaTime::createWithDouble((elapsedTime() + 100_ms).seconds()));
     dispatchMediaSampleToObservers(sample.get());
 }

Modified: trunk/Source/WebKit/ChangeLog (277762 => 277763)


--- trunk/Source/WebKit/ChangeLog	2021-05-20 00:05:57 UTC (rev 277762)
+++ trunk/Source/WebKit/ChangeLog	2021-05-20 00:13:42 UTC (rev 277763)
@@ -1,3 +1,30 @@
+2021-05-19  Sam Weinig  <wei...@apple.com>
+
+        Remove ImageBuffer::toBGRA() and replace its uses with the more general ImageBuffer::getPixelBuffer()
+        https://bugs.webkit.org/show_bug.cgi?id=225976
+
+        Reviewed by Said Abou-Hallawa.
+
+        Remove ImageBuffer::toBGRA().
+
+        * GPUProcess/graphics/RemoteRenderingBackend.cpp:
+        (WebKit::RemoteRenderingBackend::getBGRADataForImageBuffer): Deleted.
+        * GPUProcess/graphics/RemoteRenderingBackend.h:
+        * GPUProcess/graphics/RemoteRenderingBackend.messages.in:
+        * Shared/RemoteLayerTree/CGDisplayListImageBufferBackend.cpp:
+        (WebKit::CGDisplayListImageBufferBackend::toBGRAData const): Deleted.
+        * Shared/RemoteLayerTree/CGDisplayListImageBufferBackend.h:
+        * WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.cpp:
+        (WebKit::ImageBufferShareableBitmapBackend::toBGRAData const): Deleted.
+        * WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.h:
+        * WebProcess/GPU/graphics/RemoteImageBufferProxy.h:
+        * WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp:
+        (WebKit::RemoteRenderingBackendProxy::getBGRADataForImageBuffer): Deleted.
+        * WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h:
+        * WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.cpp:
+        (WebKit::ImageBufferShareableIOSurfaceBackend::toBGRAData const): Deleted.
+        * WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.h:
+
 2021-05-19  Chris Dumez  <cdu...@apple.com>
 
         Simplify and make InjectedBundle::initialize() more robust

Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp (277762 => 277763)


--- trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp	2021-05-20 00:05:57 UTC (rev 277762)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp	2021-05-20 00:13:42 UTC (rev 277763)
@@ -404,16 +404,6 @@
     completionHandler(WTFMove(data));
 }
 
-void RemoteRenderingBackend::getBGRADataForImageBuffer(WebCore::RenderingResourceIdentifier renderingResourceIdentifier, CompletionHandler<void(Vector<uint8_t>&&)>&& completionHandler)
-{
-    ASSERT(!RunLoop::isMain());
-
-    Vector<uint8_t> data;
-    if (auto imageBuffer = m_remoteResourceCache.cachedImageBuffer(renderingResourceIdentifier))
-        data = ""
-    completionHandler(WTFMove(data));
-}
-
 void RemoteRenderingBackend::getShareableBitmapForImageBuffer(WebCore::RenderingResourceIdentifier identifier, WebCore::PreserveResolution preserveResolution, CompletionHandler<void(ShareableBitmap::Handle&&)>&& completionHandler)
 {
     ASSERT(!RunLoop::isMain());

Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h (277762 => 277763)


--- trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h	2021-05-20 00:05:57 UTC (rev 277762)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h	2021-05-20 00:13:42 UTC (rev 277763)
@@ -129,7 +129,6 @@
     void destroyGetPixelBufferSharedMemory();
     void getDataURLForImageBuffer(const String& mimeType, Optional<double> quality, WebCore::PreserveResolution, WebCore::RenderingResourceIdentifier, CompletionHandler<void(String&&)>&&);
     void getDataForImageBuffer(const String& mimeType, Optional<double> quality, WebCore::RenderingResourceIdentifier, CompletionHandler<void(Vector<uint8_t>&&)>&&);
-    void getBGRADataForImageBuffer(WebCore::RenderingResourceIdentifier, CompletionHandler<void(Vector<uint8_t>&&)>&&);
     void getShareableBitmapForImageBuffer(WebCore::RenderingResourceIdentifier, WebCore::PreserveResolution, CompletionHandler<void(ShareableBitmap::Handle&&)>&&);
     void cacheNativeImage(const ShareableBitmap::Handle&, WebCore::RenderingResourceIdentifier);
     void cacheFont(Ref<WebCore::Font>&&);

Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.messages.in (277762 => 277763)


--- trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.messages.in	2021-05-20 00:05:57 UTC (rev 277762)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.messages.in	2021-05-20 00:13:42 UTC (rev 277763)
@@ -31,7 +31,6 @@
     DestroyGetPixelBufferSharedMemory()
     GetDataURLForImageBuffer(String mimeType, Optional<double> quality, enum:uint8_t WebCore::PreserveResolution preserveResolution, WebCore::RenderingResourceIdentifier renderingResourceIdentifier) -> (String urlString) Synchronous
     GetDataForImageBuffer(String mimeType, Optional<double> quality, WebCore::RenderingResourceIdentifier renderingResourceIdentifier) -> (Vector<uint8_t> data) Synchronous
-    GetBGRADataForImageBuffer(WebCore::RenderingResourceIdentifier renderingResourceIdentifier) -> (Vector<uint8_t> data) Synchronous
     GetShareableBitmapForImageBuffer(WebCore::RenderingResourceIdentifier imageBuffer, enum:uint8_t WebCore::PreserveResolution preserveResolution) -> (WebKit::ShareableBitmap::Handle handle) Synchronous
     CacheNativeImage(WebKit::ShareableBitmap::Handle handle, WebCore::RenderingResourceIdentifier renderingResourceIdentifier)
     CacheFont(IPC::FontReference font)

Modified: trunk/Source/WebKit/Shared/RemoteLayerTree/CGDisplayListImageBufferBackend.cpp (277762 => 277763)


--- trunk/Source/WebKit/Shared/RemoteLayerTree/CGDisplayListImageBufferBackend.cpp	2021-05-20 00:05:57 UTC (rev 277762)
+++ trunk/Source/WebKit/Shared/RemoteLayerTree/CGDisplayListImageBufferBackend.cpp	2021-05-20 00:13:42 UTC (rev 277763)
@@ -99,12 +99,6 @@
     return nullptr;
 }
 
-Vector<uint8_t> CGDisplayListImageBufferBackend::toBGRAData() const
-{
-    ASSERT_NOT_REACHED();
-    return { };
-}
-
 Optional<WebCore::PixelBuffer> CGDisplayListImageBufferBackend::getPixelBuffer(const WebCore::PixelBufferFormat&, const WebCore::IntRect&) const
 {
     ASSERT_NOT_REACHED();

Modified: trunk/Source/WebKit/Shared/RemoteLayerTree/CGDisplayListImageBufferBackend.h (277762 => 277763)


--- trunk/Source/WebKit/Shared/RemoteLayerTree/CGDisplayListImageBufferBackend.h	2021-05-20 00:05:57 UTC (rev 277762)
+++ trunk/Source/WebKit/Shared/RemoteLayerTree/CGDisplayListImageBufferBackend.h	2021-05-20 00:13:42 UTC (rev 277763)
@@ -49,7 +49,6 @@
 
     // NOTE: These all ASSERT_NOT_REACHED().
     RefPtr<WebCore::NativeImage> copyNativeImage(WebCore::BackingStoreCopy = WebCore::CopyBackingStore) const override;
-    Vector<uint8_t> toBGRAData() const override;
     Optional<WebCore::PixelBuffer> getPixelBuffer(const WebCore::PixelBufferFormat& outputFormat, const WebCore::IntRect&) const override;
     void putPixelBuffer(const WebCore::PixelBuffer&, const WebCore::IntRect& srcRect, const WebCore::IntPoint& destPoint, WebCore::AlphaPremultiplication destFormat) override;
 

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.cpp (277762 => 277763)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.cpp	2021-05-20 00:05:57 UTC (rev 277762)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.cpp	2021-05-20 00:13:42 UTC (rev 277763)
@@ -158,11 +158,6 @@
     return m_bitmap->createImage();
 }
 
-Vector<uint8_t> ImageBufferShareableBitmapBackend::toBGRAData() const
-{
-    return ImageBufferBackend::toBGRAData(m_bitmap->data());
-}
-
 Optional<PixelBuffer> ImageBufferShareableBitmapBackend::getPixelBuffer(const PixelBufferFormat& outputFormat, const IntRect& srcRect) const
 {
     return ImageBufferBackend::getPixelBuffer(outputFormat, srcRect, m_bitmap->data());

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.h (277762 => 277763)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.h	2021-05-20 00:05:57 UTC (rev 277762)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.h	2021-05-20 00:13:42 UTC (rev 277763)
@@ -58,7 +58,6 @@
     RefPtr<WebCore::NativeImage> copyNativeImage(WebCore::BackingStoreCopy = WebCore::CopyBackingStore) const override;
     RefPtr<WebCore::Image> copyImage(WebCore::BackingStoreCopy = WebCore::CopyBackingStore, WebCore::PreserveResolution = WebCore::PreserveResolution::No) const override;
 
-    Vector<uint8_t> toBGRAData() const override;
     Optional<WebCore::PixelBuffer> getPixelBuffer(const WebCore::PixelBufferFormat& outputFormat, const WebCore::IntRect&) const override;
     void putPixelBuffer(const WebCore::PixelBuffer&, const WebCore::IntRect& srcRect, const WebCore::IntPoint& destPoint, WebCore::AlphaPremultiplication destFormat) override;
 

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h (277762 => 277763)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h	2021-05-20 00:05:57 UTC (rev 277762)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h	2021-05-20 00:13:42 UTC (rev 277763)
@@ -165,13 +165,6 @@
         return m_remoteRenderingBackendProxy->getDataForImageBuffer(mimeType, quality, m_renderingResourceIdentifier);
     }
 
-    Vector<uint8_t> toBGRAData() const override
-    {
-        if (UNLIKELY(!m_remoteRenderingBackendProxy))
-            return { };
-
-        return m_remoteRenderingBackendProxy->getBGRADataForImageBuffer(m_renderingResourceIdentifier);
-    }
     RefPtr<WebCore::NativeImage> copyNativeImage(WebCore::BackingStoreCopy = WebCore::BackingStoreCopy::CopyBackingStore) const override
     {
         if (UNLIKELY(!m_remoteRenderingBackendProxy))

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp (277762 => 277763)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp	2021-05-20 00:05:57 UTC (rev 277762)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp	2021-05-20 00:13:42 UTC (rev 277763)
@@ -219,15 +219,6 @@
     return data;
 }
 
-Vector<uint8_t> RemoteRenderingBackendProxy::getBGRADataForImageBuffer(RenderingResourceIdentifier renderingResourceIdentifier)
-{
-    sendDeferredWakeupMessageIfNeeded();
-
-    Vector<uint8_t> data;
-    sendSync(Messages::RemoteRenderingBackend::GetBGRADataForImageBuffer(renderingResourceIdentifier), Messages::RemoteRenderingBackend::GetBGRADataForImageBuffer::Reply(data), renderingBackendIdentifier(), 1_s);
-    return data;
-}
-
 RefPtr<ShareableBitmap> RemoteRenderingBackendProxy::getShareableBitmap(RenderingResourceIdentifier imageBuffer, PreserveResolution preserveResolution)
 {
     sendDeferredWakeupMessageIfNeeded();

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h (277762 => 277763)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h	2021-05-20 00:05:57 UTC (rev 277762)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h	2021-05-20 00:13:42 UTC (rev 277763)
@@ -95,7 +95,6 @@
     RefPtr<WebCore::ImageBuffer> createImageBuffer(const WebCore::FloatSize&, WebCore::RenderingMode, float resolutionScale, WebCore::DestinationColorSpace, WebCore::PixelFormat);
     String getDataURLForImageBuffer(const String& mimeType, Optional<double> quality, WebCore::PreserveResolution, WebCore::RenderingResourceIdentifier);
     Vector<uint8_t> getDataForImageBuffer(const String& mimeType, Optional<double> quality, WebCore::RenderingResourceIdentifier);
-    Vector<uint8_t> getBGRADataForImageBuffer(WebCore::RenderingResourceIdentifier);
     WebCore::DisplayList::FlushIdentifier flushDisplayListAndCommit(const WebCore::DisplayList::DisplayList&, WebCore::RenderingResourceIdentifier);
     RefPtr<ShareableBitmap> getShareableBitmap(WebCore::RenderingResourceIdentifier, WebCore::PreserveResolution);
     void cacheNativeImage(const ShareableBitmap::Handle&, WebCore::RenderingResourceIdentifier);

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.cpp (277762 => 277763)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.cpp	2021-05-20 00:05:57 UTC (rev 277762)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.cpp	2021-05-20 00:13:42 UTC (rev 277763)
@@ -114,12 +114,6 @@
     return { };
 }
 
-Vector<uint8_t> ImageBufferShareableIOSurfaceBackend::toBGRAData() const
-{
-    RELEASE_ASSERT_NOT_REACHED();
-    return { };
-}
-
 Optional<PixelBuffer> ImageBufferShareableIOSurfaceBackend::getPixelBuffer(const PixelBufferFormat&, const IntRect&) const
 {
     RELEASE_ASSERT_NOT_REACHED();

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.h (277762 => 277763)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.h	2021-05-20 00:05:57 UTC (rev 277762)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.h	2021-05-20 00:13:42 UTC (rev 277763)
@@ -59,7 +59,6 @@
     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&) override;
     String toDataURL(const String& mimeType, Optional<double> quality, WebCore::PreserveResolution) const override;
     Vector<uint8_t> toData(const String& mimeType, Optional<double> quality) const override;
-    Vector<uint8_t> toBGRAData() const override;
     Optional<WebCore::PixelBuffer> getPixelBuffer(const WebCore::PixelBufferFormat& outputFormat, const WebCore::IntRect&) const override;
     void putPixelBuffer(const WebCore::PixelBuffer&, const WebCore::IntRect& srcRect, const WebCore::IntPoint& destPoint, WebCore::AlphaPremultiplication destFormat) override;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to