WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-225813-20210514121514.patch (text/plain), 72.25 KB, created by
Sam Weinig
on 2021-05-14 12:15:15 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Sam Weinig
Created:
2021-05-14 12:15:15 PDT
Size:
72.25 KB
patch
obsolete
>Index: Source/WebCore/ChangeLog >=================================================================== >--- Source/WebCore/ChangeLog (revision 277496) >+++ Source/WebCore/ChangeLog (working copy) >@@ -1,3 +1,109 @@ >+2021-05-14 Sam Weinig <weinig@apple.com> >+ >+ Use PixelBufferFormat to specify ImageBuffer::getPixelData destination format allowing for more control over data conversion >+ https://bugs.webkit.org/show_bug.cgi?id=225813 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ The reprevious signature of ImageBuffer::getPixelBuffer: >+ >+ ImageBuffer::getPixelBuffer(AlphaPremultiplication, const IntRect&); >+ >+ only allowed specifying the type of alpha premultiplication wanted, and hard coded >+ a pixel format of RGBA8 and color space of SRGB. To support accurate and efficient >+ access to pixel buffers with different pixel formats and color spaces we need to be >+ able to tell getPixelBuffer what we want up front, so that if the ImageBuffer already >+ has a DisplayP3 buffer, and we want DisplayP3 pixels, we don't first convert to SRGB >+ and then convert back to DisplayP3 (which would be slow and lose any out of gamut >+ data). The new signature allows us to specify the entire format triple: >+ >+ ImageBuffer::getPixelBuffer(const PixelBufferFormat&, const IntRect&); >+ >+ Additionally, ImageBuffer::putPixelBuffer() no longer needs to provide the source >+ AlphaPremultiplication either, as the PixelBuffer itself also contains that information. >+ >+ Now that we are passing color space information, we need to support color space conversion, >+ so PixelBufferConversion was updated to support color space conversion on CG platforms >+ using vImageConvert_AnyToAny. This is not currently excersised, but will be in a subsequent >+ change where canvas ImageData gains a color space setting, at which point it can be tested. >+ >+ We also don't currently support color space conversion on non-CG platforms. This won't >+ be a problem in the short term, as only CG platforms support DisplayP3, the only other >+ color space that can be specified currently, but as cleanup, we should add support for >+ color space conversion using the ColorConversion and ColorTransferFunction infrastructure >+ for other ports, moving the existing support for SRGB to/from LinearSRGB conversions from >+ ImageBufferCairoBackend and ImageBufferCairoImageSurfaceBackend. >+ >+ * html/ImageBitmap.cpp: >+ (WebCore::ImageBitmap::createPromise): >+ * html/canvas/CanvasRenderingContext2DBase.cpp: >+ (WebCore::CanvasRenderingContext2DBase::getImageData const): >+ (WebCore::CanvasRenderingContext2DBase::putImageData): >+ * page/PageConsoleClient.cpp: >+ (WebCore::PageConsoleClient::screenshot): >+ * platform/graphics/ConcreteImageBuffer.h: >+ (WebCore::ConcreteImageBuffer::putPixelBuffer): >+ * platform/graphics/ImageBuffer.h: >+ (WebCore::ImageBuffer::putPixelBuffer): >+ * platform/graphics/ImageBufferBackend.cpp: >+ (WebCore::ImageBufferBackend::convertToLuminanceMask): >+ (WebCore::ImageBufferBackend::getPixelBuffer const): >+ (WebCore::ImageBufferBackend::putPixelBuffer): >+ * platform/graphics/ImageBufferBackend.h: >+ * platform/graphics/PixelBufferConversion.cpp: >+ (WebCore::makeVImageCGImageFormat): >+ (WebCore::makeVImageBuffer): >+ (WebCore::convertImagePixelsAccelerated): >+ (WebCore::convertImagePixels): >+ * platform/graphics/ShadowBlur.cpp: >+ (WebCore::ShadowBlur::blurShadowBuffer): >+ * platform/graphics/cairo/ImageBufferCairoSurfaceBackend.cpp: >+ (WebCore::ImageBufferCairoSurfaceBackend::getPixelBuffer const): >+ (WebCore::ImageBufferCairoSurfaceBackend::putPixelBuffer): >+ * platform/graphics/cairo/ImageBufferCairoSurfaceBackend.h: >+ * platform/graphics/cg/ImageBufferCGBackend.cpp: >+ (WebCore::ImageBufferCGBackend::toCFData const): >+ * platform/graphics/cg/ImageBufferCGBitmapBackend.cpp: >+ (WebCore::ImageBufferCGBitmapBackend::getPixelBuffer const): >+ (WebCore::ImageBufferCGBitmapBackend::putPixelBuffer): >+ * platform/graphics/cg/ImageBufferCGBitmapBackend.h: >+ * platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp: >+ (WebCore::ImageBufferIOSurfaceBackend::getPixelBuffer const): >+ (WebCore::ImageBufferIOSurfaceBackend::putPixelBuffer): >+ * platform/graphics/cg/ImageBufferIOSurfaceBackend.h: >+ * platform/graphics/displaylists/DisplayListItems.cpp: >+ (WebCore::DisplayList::PutPixelBuffer::PutPixelBuffer): >+ (WebCore::DisplayList::PutPixelBuffer::swap): >+ (WebCore::DisplayList::operator<<): >+ * platform/graphics/displaylists/DisplayListItems.h: >+ (WebCore::DisplayList::GetPixelBuffer::GetPixelBuffer): >+ (WebCore::DisplayList::GetPixelBuffer::outputFormat const): >+ (WebCore::DisplayList::PutPixelBuffer::encode const): >+ (WebCore::DisplayList::PutPixelBuffer::decode): >+ (WebCore::DisplayList::PutPixelBuffer::inputFormat const): Deleted. >+ * platform/graphics/displaylists/DisplayListRecorder.cpp: >+ (WebCore::DisplayList::Recorder::getPixelBuffer): >+ (WebCore::DisplayList::Recorder::putPixelBuffer): >+ * platform/graphics/displaylists/DisplayListRecorder.h: >+ * platform/graphics/filters/FEColorMatrix.cpp: >+ (WebCore::FEColorMatrix::platformApplySoftware): >+ * platform/graphics/filters/FEDropShadow.cpp: >+ (WebCore::FEDropShadow::platformApplySoftware): >+ * platform/graphics/filters/FilterEffect.cpp: >+ (WebCore::FilterEffect::imageBufferResult): >+ (WebCore::FilterEffect::convertPixelBufferToColorSpace): >+ (WebCore::FilterEffect::convertImageBufferToColorSpace): >+ (WebCore::FilterEffect::copyConvertedPixelBufferToDestination): >+ (WebCore::FilterEffect::copyUnmultipliedResult): >+ (WebCore::FilterEffect::copyPremultipliedResult): >+ * platform/graphics/filters/FilterEffect.h: >+ * platform/graphics/win/ImageBufferDirect2DBackend.cpp: >+ (WebCore::ImageBufferDirect2DBackend::getPixelBuffer const): >+ (WebCore::ImageBufferDirect2DBackend::putPixelBuffer): >+ * platform/graphics/win/ImageBufferDirect2DBackend.h: >+ * rendering/shapes/Shape.cpp: >+ (WebCore::Shape::createRasterShape): >+ > 2021-05-14 Alex Christensen <achristensen@webkit.org> > > Resource Timing: secureConnectionStart == 0 when a connection is re-used >Index: Source/WebCore/bindings/js/SerializedScriptValue.cpp >=================================================================== >--- Source/WebCore/bindings/js/SerializedScriptValue.cpp (revision 277451) >+++ Source/WebCore/bindings/js/SerializedScriptValue.cpp (working copy) >@@ -1075,8 +1075,9 @@ private: > return; > } > >+ PixelBufferFormat format { AlphaPremultiplication::Premultiplied, PixelFormat::RGBA8, DestinationColorSpace::SRGB }; > const IntSize& logicalSize = buffer->logicalSize(); >- auto pixelBuffer = buffer->getPixelBuffer(AlphaPremultiplication::Premultiplied, { IntPoint::zero(), logicalSize }); >+ auto pixelBuffer = buffer->getPixelBuffer(format, { IntPoint::zero(), logicalSize }); > if (!pixelBuffer) { > code = SerializationReturnCode::ValidationError; > return; >@@ -3163,7 +3164,7 @@ private: > return JSValue(); > } > >- buffer->putPixelBuffer(AlphaPremultiplication::Premultiplied, imageData->pixelBuffer(), { IntPoint::zero(), logicalSize }); >+ buffer->putPixelBuffer(imageData->pixelBuffer(), { IntPoint::zero(), logicalSize }); > > auto bitmap = ImageBitmap::create(ImageBitmapBacking(WTFMove(buffer), OptionSet<SerializationState>::fromRaw(serializationState))); > return getJSValue(bitmap); >Index: Source/WebCore/html/ImageBitmap.cpp >=================================================================== >--- Source/WebCore/html/ImageBitmap.cpp (revision 277451) >+++ Source/WebCore/html/ImageBitmap.cpp (working copy) >@@ -807,7 +807,7 @@ void ImageBitmap::createPromise(ScriptEx > // resulting ImageBuffer directly. > auto alphaPremultiplication = alphaPremultiplicationForPremultiplyAlpha(options.premultiplyAlpha); > if (sourceRectangle.returnValue().location().isZero() && sourceRectangle.returnValue().size() == imageData->size() && sourceRectangle.returnValue().size() == outputSize && options.imageOrientation == ImageBitmapOptions::Orientation::None) { >- bitmapData->putPixelBuffer(AlphaPremultiplication::Unpremultiplied, imageData->pixelBuffer(), sourceRectangle.releaseReturnValue(), { }, alphaPremultiplication); >+ bitmapData->putPixelBuffer(imageData->pixelBuffer(), sourceRectangle.releaseReturnValue(), { }, alphaPremultiplication); > > auto imageBitmap = create(ImageBitmapBacking(WTFMove(bitmapData))); > // The result is implicitly origin-clean, and alpha premultiplication has already been handled. >@@ -822,7 +822,7 @@ void ImageBitmap::createPromise(ScriptEx > resolveWithBlankImageBuffer(scriptExecutionContext, true, WTFMove(promise)); > return; > } >- tempBitmapData->putPixelBuffer(AlphaPremultiplication::Unpremultiplied, imageData->pixelBuffer(), IntRect(0, 0, imageData->width(), imageData->height()), { }, alphaPremultiplication); >+ tempBitmapData->putPixelBuffer(imageData->pixelBuffer(), IntRect(0, 0, imageData->width(), imageData->height()), { }, alphaPremultiplication); > FloatRect destRect(FloatPoint(), outputSize); > bitmapData->context().drawImageBuffer(*tempBitmapData, destRect, sourceRectangle.releaseReturnValue(), { interpolationQualityForResizeQuality(options.resizeQuality), imageOrientationForOrientation(options.imageOrientation) }); > >Index: Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp >=================================================================== >--- Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp (revision 277451) >+++ Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp (working copy) >@@ -2199,7 +2199,8 @@ ExceptionOr<RefPtr<ImageData>> CanvasRen > if (!buffer) > return createEmptyImageData(imageDataRect.size()); > >- auto pixelBuffer = buffer->getPixelBuffer(AlphaPremultiplication::Unpremultiplied, imageDataRect); >+ PixelBufferFormat format { AlphaPremultiplication::Unpremultiplied, PixelFormat::RGBA8, DestinationColorSpace::SRGB }; >+ auto pixelBuffer = buffer->getPixelBuffer(format, imageDataRect); > if (!pixelBuffer) { > canvasBase().scriptExecutionContext()->addConsoleMessage(MessageSource::Rendering, MessageLevel::Error, > makeString("Unable to get image data from canvas. Requested size was ", imageDataRect.width(), " x ", imageDataRect.height())); >@@ -2246,7 +2247,7 @@ void CanvasRenderingContext2DBase::putIm > sourceRect.intersect(IntRect { 0, 0, data.width(), data.height() }); > > if (!sourceRect.isEmpty()) >- buffer->putPixelBuffer(AlphaPremultiplication::Unpremultiplied, data.pixelBuffer(), sourceRect, IntPoint { destOffset }); >+ buffer->putPixelBuffer(data.pixelBuffer(), sourceRect, IntPoint { destOffset }); > > didDraw(FloatRect { destRect }, { }); // ignore transform, shadow and clip > } >Index: Source/WebCore/page/PageConsoleClient.cpp >=================================================================== >--- Source/WebCore/page/PageConsoleClient.cpp (revision 277451) >+++ Source/WebCore/page/PageConsoleClient.cpp (working copy) >@@ -370,7 +370,7 @@ void PageConsoleClient::screenshot(JSC:: > auto sourceSize = imageData->size(); > if (auto imageBuffer = ImageBuffer::create(sourceSize, RenderingMode::Unaccelerated, 1, DestinationColorSpace::SRGB, PixelFormat::BGRA8)) { > IntRect sourceRect(IntPoint(), sourceSize); >- imageBuffer->putPixelBuffer(AlphaPremultiplication::Unpremultiplied, imageData->pixelBuffer(), sourceRect); >+ imageBuffer->putPixelBuffer(imageData->pixelBuffer(), sourceRect); > dataURL = imageBuffer->toDataURL("image/png"_s, WTF::nullopt, PreserveResolution::Yes); > } > } >Index: Source/WebCore/platform/graphics/ConcreteImageBuffer.h >=================================================================== >--- Source/WebCore/platform/graphics/ConcreteImageBuffer.h (revision 277451) >+++ Source/WebCore/platform/graphics/ConcreteImageBuffer.h (working copy) >@@ -230,7 +230,7 @@ protected: > return { }; > } > >- Optional<PixelBuffer> getPixelBuffer(AlphaPremultiplication outputFormat, const IntRect& srcRect) const override >+ Optional<PixelBuffer> getPixelBuffer(const PixelBufferFormat& outputFormat, const IntRect& srcRect) const override > { > if (auto* backend = ensureBackendCreated()) { > const_cast<ConcreteImageBuffer&>(*this).flushContext(); >@@ -239,11 +239,11 @@ protected: > return WTF::nullopt; > } > >- void putPixelBuffer(AlphaPremultiplication inputFormat, const PixelBuffer& pixelBuffer, const IntRect& srcRect, const IntPoint& destPoint = { }, AlphaPremultiplication destFormat = AlphaPremultiplication::Premultiplied) override >+ void putPixelBuffer(const PixelBuffer& pixelBuffer, const IntRect& srcRect, const IntPoint& destPoint = { }, AlphaPremultiplication destFormat = AlphaPremultiplication::Premultiplied) override > { > if (auto* backend = ensureBackendCreated()) { > flushContext(); >- backend->putPixelBuffer(inputFormat, pixelBuffer, srcRect, destPoint, destFormat); >+ backend->putPixelBuffer(pixelBuffer, srcRect, destPoint, destFormat); > } > } > >Index: Source/WebCore/platform/graphics/ImageBuffer.h >=================================================================== >--- Source/WebCore/platform/graphics/ImageBuffer.h (revision 277451) >+++ Source/WebCore/platform/graphics/ImageBuffer.h (working copy) >@@ -126,8 +126,8 @@ public: > 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(AlphaPremultiplication outputFormat, const IntRect& srcRect) const = 0; >- virtual void putPixelBuffer(AlphaPremultiplication inputFormat, const PixelBuffer&, const IntRect& srcRect, const IntPoint& destPoint = { }, AlphaPremultiplication destFormat = AlphaPremultiplication::Premultiplied) = 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; > > // FIXME: current implementations of this method have the restriction that they only work > // with textures that are RGB or RGBA format, and UNSIGNED_BYTE type. >Index: Source/WebCore/platform/graphics/ImageBufferBackend.cpp >=================================================================== >--- Source/WebCore/platform/graphics/ImageBufferBackend.cpp (revision 277451) >+++ Source/WebCore/platform/graphics/ImageBufferBackend.cpp (working copy) >@@ -70,7 +70,8 @@ void ImageBufferBackend::drawConsuming(G > > void ImageBufferBackend::convertToLuminanceMask() > { >- auto pixelBuffer = getPixelBuffer(AlphaPremultiplication::Unpremultiplied, logicalRect()); >+ PixelBufferFormat format { AlphaPremultiplication::Unpremultiplied, PixelFormat::RGBA8, DestinationColorSpace::SRGB }; >+ auto pixelBuffer = getPixelBuffer(format, logicalRect()); > if (!pixelBuffer) > return; > >@@ -88,7 +89,7 @@ void ImageBufferBackend::convertToLumina > pixelArray.set(pixelOffset + 3, luma); > } > >- putPixelBuffer(AlphaPremultiplication::Unpremultiplied, *pixelBuffer, logicalRect(), IntPoint::zero(), AlphaPremultiplication::Premultiplied); >+ putPixelBuffer(*pixelBuffer, logicalRect(), IntPoint::zero(), AlphaPremultiplication::Premultiplied); > } > > Vector<uint8_t> ImageBufferBackend::toBGRAData(void* data) const >@@ -113,12 +114,10 @@ Vector<uint8_t> ImageBufferBackend::toBG > return result; > } > >-Optional<PixelBuffer> ImageBufferBackend::getPixelBuffer(AlphaPremultiplication destinationAlphaFormat, const IntRect& sourceRect, void* data) const >+Optional<PixelBuffer> ImageBufferBackend::getPixelBuffer(const PixelBufferFormat& destinationFormat, const IntRect& sourceRect, void* data) const > { > auto sourceRectScaled = toBackendCoordinates(sourceRect); > >- PixelBufferFormat destinationFormat { destinationAlphaFormat, PixelFormat::RGBA8, DestinationColorSpace::SRGB }; >- > auto pixelBuffer = PixelBuffer::tryCreate(destinationFormat, sourceRectScaled.size()); > if (!pixelBuffer) > return WTF::nullopt; >@@ -158,15 +157,15 @@ Optional<PixelBuffer> ImageBufferBackend > return pixelBuffer; > } > >-void ImageBufferBackend::putPixelBuffer(AlphaPremultiplication sourceAlphaFormat, const PixelBuffer& pixelBuffer, const IntRect& sourceRect, const IntPoint& destinationPoint, AlphaPremultiplication destinationAlphaFormat, void* data) >+void ImageBufferBackend::putPixelBuffer(const PixelBuffer& sourcePixelBuffer, const IntRect& sourceRect, const IntPoint& destinationPoint, AlphaPremultiplication destinationAlphaFormat, void* data) > { > // FIXME: Add support for non-RGBA8 pixel formats. >- ASSERT(pixelBuffer.format().pixelFormat == PixelFormat::RGBA8); >+ ASSERT(sourcePixelBuffer.format().pixelFormat == PixelFormat::RGBA8); > > auto sourceRectScaled = toBackendCoordinates(sourceRect); > auto destinationPointScaled = toBackendCoordinates(destinationPoint); > >- IntRect sourceRectClipped = intersection({ IntPoint::zero(), pixelBuffer.size() }, sourceRectScaled); >+ IntRect sourceRectClipped = intersection({ IntPoint::zero(), sourcePixelBuffer.size() }, sourceRectScaled); > IntRect destinationRect = sourceRectClipped; > destinationRect.moveBy(destinationPointScaled); > >@@ -179,13 +178,13 @@ void ImageBufferBackend::putPixelBuffer( > destinationRect.intersect(backendRect()); > sourceRectClipped.setSize(destinationRect.size()); > >- unsigned sourceBytesPerRow = 4 * pixelBuffer.size().width(); >- const uint8_t* sourceRows = pixelBuffer.data().data() + sourceRectClipped.y() * sourceBytesPerRow + sourceRectClipped.x() * 4; >+ unsigned sourceBytesPerRow = 4 * sourcePixelBuffer.size().width(); >+ const uint8_t* sourceRows = sourcePixelBuffer.data().data() + sourceRectClipped.y() * sourceBytesPerRow + sourceRectClipped.x() * 4; > > unsigned destinationBytesPerRow = bytesPerRow(); > uint8_t* destinationRows = reinterpret_cast<uint8_t*>(data) + destinationRect.y() * destinationBytesPerRow + destinationRect.x() * 4; > >- PixelBufferFormat sourceFormat { sourceAlphaFormat, PixelFormat::RGBA8, DestinationColorSpace::SRGB }; >+ PixelBufferFormat sourceFormat = sourcePixelBuffer.format(); > PixelBufferFormat destinationFormat { destinationAlphaFormat, pixelFormat(), DestinationColorSpace::SRGB }; > > ConstPixelBufferConversionView source; >Index: Source/WebCore/platform/graphics/ImageBufferBackend.h >=================================================================== >--- Source/WebCore/platform/graphics/ImageBufferBackend.h (revision 277451) >+++ Source/WebCore/platform/graphics/ImageBufferBackend.h (working copy) >@@ -25,13 +25,12 @@ > > #pragma once > >-#include "AlphaPremultiplication.h" > #include "ColorSpace.h" > #include "FloatRect.h" > #include "GraphicsTypesGL.h" > #include "ImagePaintingOptions.h" > #include "IntRect.h" >-#include "PixelFormat.h" >+#include "PixelBufferFormat.h" > #include "PlatformLayer.h" > #include "RenderingMode.h" > #include <wtf/RefPtr.h> >@@ -109,8 +108,8 @@ public: > virtual Vector<uint8_t> toData(const String& mimeType, Optional<double> quality) const = 0; > virtual Vector<uint8_t> toBGRAData() const = 0; > >- virtual Optional<PixelBuffer> getPixelBuffer(AlphaPremultiplication outputFormat, const IntRect&) const = 0; >- virtual void putPixelBuffer(AlphaPremultiplication inputFormat, const PixelBuffer&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) = 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; > > virtual PlatformLayer* platformLayer() const { return nullptr; } > virtual bool copyToPlatformTexture(GraphicsContextGL&, GCGLenum, PlatformGLObject, GCGLenum, bool, bool) const { return false; } >@@ -150,8 +149,8 @@ protected: > > WEBCORE_EXPORT Vector<uint8_t> toBGRAData(void* data) const; > >- WEBCORE_EXPORT Optional<PixelBuffer> getPixelBuffer(AlphaPremultiplication outputFormat, const IntRect& srcRect, void* data) const; >- WEBCORE_EXPORT void putPixelBuffer(AlphaPremultiplication inputFormat, const PixelBuffer&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat, void* data); >+ 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); > > Parameters m_parameters; > }; >Index: Source/WebCore/platform/graphics/PixelBufferConversion.cpp >=================================================================== >--- Source/WebCore/platform/graphics/PixelBufferConversion.cpp (revision 277451) >+++ Source/WebCore/platform/graphics/PixelBufferConversion.cpp (working copy) >@@ -31,24 +31,65 @@ > #include "IntSize.h" > #include "PixelFormat.h" > >-#if USE(ACCELERATE) >+#if USE(ACCELERATE) && USE(CG) >+#include "ColorSpaceCG.h" > #include <Accelerate/Accelerate.h> > #endif > > namespace WebCore { > >-#if USE(ACCELERATE) >+#if USE(ACCELERATE) && USE(CG) >+ >+static inline vImage_CGImageFormat makeVImageCGImageFormat(const PixelBufferFormat& format) >+{ >+ auto [bitsPerComponent, bitsPerPixel, bitmapInfo] = [] (const PixelBufferFormat& format) -> std::tuple<unsigned, unsigned, CGBitmapInfo> { >+ switch (format.pixelFormat) { >+ case PixelFormat::RGBA8: >+ if (format.alphaFormat == AlphaPremultiplication::Premultiplied) >+ return std::make_tuple(8u, 32u, kCGBitmapByteOrder32Big | kCGImageAlphaPremultipliedLast); >+ else >+ return std::make_tuple(8u, 32u, kCGBitmapByteOrder32Big | kCGImageAlphaLast); >+ >+ case PixelFormat::BGRA8: >+ if (format.alphaFormat == AlphaPremultiplication::Premultiplied) >+ return std::make_tuple(8u, 32u, kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst); >+ else >+ return std::make_tuple(8u, 32u, kCGBitmapByteOrder32Little | kCGImageAlphaFirst); >+ >+ case PixelFormat::RGB10: >+ case PixelFormat::RGB10A8: >+ break; >+ } >+ >+ // We currently only support 8 bit pixel formats for these conversions. >+ >+ ASSERT_NOT_REACHED(); >+ return std::make_tuple(8u, 32u, kCGBitmapByteOrder32Little | kCGImageAlphaFirst); >+ }(format); >+ >+ vImage_CGImageFormat result; >+ >+ result.bitsPerComponent = bitsPerComponent; >+ result.bitsPerPixel = bitsPerPixel; >+ result.colorSpace = cachedCGColorSpace(format.colorSpace); >+ result.bitmapInfo = bitmapInfo; >+ result.version = 0; >+ result.decode = nullptr; >+ result.renderingIntent = kCGRenderingIntentDefault; >+ >+ return result; >+} > > template<typename View> static vImage_Buffer makeVImageBuffer(const View& view, const IntSize& size) > { >- vImage_Buffer vImageBuffer; >+ vImage_Buffer result; > >- vImageBuffer.height = static_cast<vImagePixelCount>(size.height()); >- vImageBuffer.width = static_cast<vImagePixelCount>(size.width()); >- vImageBuffer.rowBytes = view.bytesPerRow; >- vImageBuffer.data = const_cast<uint8_t*>(view.rows); >+ result.height = static_cast<vImagePixelCount>(size.height()); >+ result.width = static_cast<vImagePixelCount>(size.width()); >+ result.rowBytes = view.bytesPerRow; >+ result.data = const_cast<uint8_t*>(view.rows); > >- return vImageBuffer; >+ return result; > } > > static void convertImagePixelsAccelerated(const ConstPixelBufferConversionView& source, const PixelBufferConversionView& destination, const IntSize& destinationSize) >@@ -56,6 +97,22 @@ static void convertImagePixelsAccelerate > auto sourceVImageBuffer = makeVImageBuffer(source, destinationSize); > auto destinationVImageBuffer = makeVImageBuffer(destination, destinationSize); > >+ if (source.format.colorSpace != destination.format.colorSpace) { >+ // FIXME: Consider using vImageConvert_AnyToAny for all conversions, not just ones that need a color space conversion, >+ // after judiciously performance testing them against each other. >+ >+ auto sourceCGImageFormat = makeVImageCGImageFormat(source.format); >+ auto destinationCGImageFormat = makeVImageCGImageFormat(destination.format); >+ >+ vImage_Error converterCreateError = kvImageNoError; >+ auto converter = adoptCF(vImageConverter_CreateWithCGImageFormat(&sourceCGImageFormat, &destinationCGImageFormat, nullptr, kvImageNoFlags, &converterCreateError)); >+ ASSERT_WITH_MESSAGE_UNUSED(converterCreateError, converterCreateError != kvImageNoError, "vImageConverter creation failed with error: %zd", converterCreateError); >+ >+ vImage_Error converterConvertError = vImageConvert_AnyToAny(converter.get(), &sourceVImageBuffer, &destinationVImageBuffer, nullptr, kvImageNoFlags); >+ ASSERT_WITH_MESSAGE_UNUSED(converterConvertError, converterConvertError == kvImageNoError, "vImageConvert_AnyToAny failed conversion with error: %zd", converterConvertError); >+ return; >+ } >+ > if (source.format.alphaFormat != destination.format.alphaFormat) { > if (destination.format.alphaFormat == AlphaPremultiplication::Unpremultiplied) { > if (source.format.pixelFormat == PixelFormat::RGBA8) >@@ -184,10 +241,7 @@ void convertImagePixels(const ConstPixel > ASSERT(source.format.pixelFormat == PixelFormat::RGBA8 || source.format.pixelFormat == PixelFormat::BGRA8); > ASSERT(destination.format.pixelFormat == PixelFormat::RGBA8 || destination.format.pixelFormat == PixelFormat::BGRA8); > >- // We don't currently support converting pixel data between different color spaces. >- ASSERT(source.format.colorSpace == destination.format.colorSpace); >- >-#if USE(ACCELERATE) >+#if USE(ACCELERATE) && USE(CG) > if (source.format.alphaFormat == destination.format.alphaFormat && source.format.pixelFormat == destination.format.pixelFormat) { > // FIXME: Can thes both just use per-row memcpy? > if (source.format.alphaFormat == AlphaPremultiplication::Premultiplied) >@@ -197,6 +251,10 @@ void convertImagePixels(const ConstPixel > } else > convertImagePixelsAccelerated(source, destination, destinationSize); > #else >+ // FIXME: We don't currently support converting pixel data between different color spaces in the non-accelerated path. >+ // This could be added using conversion functions from ColorConversion.h. >+ ASSERT(source.format.colorSpace == destination.format.colorSpace); >+ > if (source.format.alphaFormat == destination.format.alphaFormat) { > if (source.format.pixelFormat == destination.format.pixelFormat) { > if (source.format.alphaFormat == AlphaPremultiplication::Premultiplied) >Index: Source/WebCore/platform/graphics/ShadowBlur.cpp >=================================================================== >--- Source/WebCore/platform/graphics/ShadowBlur.cpp (revision 277451) >+++ Source/WebCore/platform/graphics/ShadowBlur.cpp (working copy) >@@ -903,13 +903,14 @@ void ShadowBlur::blurShadowBuffer(ImageB > if (m_type != BlurShadow) > return; > >+ PixelBufferFormat format { AlphaPremultiplication::Unpremultiplied, PixelFormat::RGBA8, DestinationColorSpace::SRGB }; > IntRect blurRect(IntPoint(), templateSize); >- auto layerData = layerImage.getPixelBuffer(AlphaPremultiplication::Unpremultiplied, blurRect); >+ auto layerData = layerImage.getPixelBuffer(format, blurRect); > if (!layerData) > return; > > blurLayerImage(layerData->data().data(), blurRect.size(), blurRect.width() * 4); >- layerImage.putPixelBuffer(AlphaPremultiplication::Unpremultiplied, *layerData, blurRect); >+ layerImage.putPixelBuffer(*layerData, blurRect); > } > > void ShadowBlur::blurAndColorShadowBuffer(ImageBuffer& layerImage, const IntSize& templateSize) >Index: Source/WebCore/platform/graphics/cairo/ImageBufferCairoSurfaceBackend.cpp >=================================================================== >--- Source/WebCore/platform/graphics/cairo/ImageBufferCairoSurfaceBackend.cpp (revision 277451) >+++ Source/WebCore/platform/graphics/cairo/ImageBufferCairoSurfaceBackend.cpp (working copy) >@@ -120,14 +120,14 @@ Vector<uint8_t> ImageBufferCairoSurfaceB > return imageData; > } > >-Optional<PixelBuffer> ImageBufferCairoSurfaceBackend::getPixelBuffer(AlphaPremultiplication outputFormat, const IntRect& srcRect) const >+Optional<PixelBuffer> ImageBufferCairoSurfaceBackend::getPixelBuffer(PixelBufferFormat outputFormat, const IntRect& srcRect) const > { > return ImageBufferBackend::getPixelBuffer(outputFormat, srcRect, cairo_image_surface_get_data(m_surface.get())); > } > >-void ImageBufferCairoSurfaceBackend::putPixelBuffer(AlphaPremultiplication inputFormat, const PixelBuffer& pixelBuffer, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) >+void ImageBufferCairoSurfaceBackend::putPixelBuffer(const PixelBuffer& pixelBuffer, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) > { >- ImageBufferBackend::putPixelBuffer(inputFormat, pixelBuffer, srcRect, destPoint, destFormat, cairo_image_surface_get_data(m_surface.get())); >+ ImageBufferBackend::putPixelBuffer(pixelBuffer, srcRect, destPoint, destFormat, cairo_image_surface_get_data(m_surface.get())); > > IntRect srcRectScaled = toBackendCoordinates(srcRect); > IntPoint destPointScaled = toBackendCoordinates(destPoint); >Index: Source/WebCore/platform/graphics/cairo/ImageBufferCairoSurfaceBackend.h >=================================================================== >--- Source/WebCore/platform/graphics/cairo/ImageBufferCairoSurfaceBackend.h (revision 277451) >+++ Source/WebCore/platform/graphics/cairo/ImageBufferCairoSurfaceBackend.h (working copy) >@@ -45,8 +45,8 @@ public: > RefPtr<NativeImage> copyNativeImage(BackingStoreCopy) const override; > > Vector<uint8_t> toBGRAData() const override; >- Optional<PixelBuffer> getPixelBuffer(AlphaPremultiplication outputFormat, const IntRect&) const override; >- void putPixelBuffer(AlphaPremultiplication inputFormat, const PixelBuffer&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) override; >+ Optional<PixelBuffer> getPixelBuffer(PixelBufferFormat outputFormat, const IntRect&) const override; >+ void putPixelBuffer(const PixelBuffer&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) override; > > protected: > ImageBufferCairoSurfaceBackend(const Parameters&, RefPtr<cairo_surface_t>&&); >Index: Source/WebCore/platform/graphics/cg/ImageBufferCGBackend.cpp >=================================================================== >--- Source/WebCore/platform/graphics/cg/ImageBufferCGBackend.cpp (revision 277451) >+++ Source/WebCore/platform/graphics/cg/ImageBufferCGBackend.cpp (working copy) >@@ -183,7 +183,8 @@ RetainPtr<CFDataRef> ImageBufferCGBacken > > if (CFEqual(uti.get(), jpegUTI())) { > // JPEGs don't have an alpha channel, so we have to manually composite on top of black. >- auto pixelBuffer = getPixelBuffer(AlphaPremultiplication::Premultiplied, logicalRect()); >+ PixelBufferFormat format { AlphaPremultiplication::Premultiplied, PixelFormat::RGBA8, DestinationColorSpace::SRGB }; >+ auto pixelBuffer = getPixelBuffer(format, logicalRect()); > if (!pixelBuffer) > return nullptr; > >Index: Source/WebCore/platform/graphics/cg/ImageBufferCGBitmapBackend.cpp >=================================================================== >--- Source/WebCore/platform/graphics/cg/ImageBufferCGBitmapBackend.cpp (revision 277451) >+++ Source/WebCore/platform/graphics/cg/ImageBufferCGBitmapBackend.cpp (working copy) >@@ -159,14 +159,14 @@ Vector<uint8_t> ImageBufferCGBitmapBacke > return ImageBufferBackend::toBGRAData(m_data); > } > >-Optional<PixelBuffer> ImageBufferCGBitmapBackend::getPixelBuffer(AlphaPremultiplication outputFormat, const IntRect& srcRect) const >+Optional<PixelBuffer> ImageBufferCGBitmapBackend::getPixelBuffer(const PixelBufferFormat& outputFormat, const IntRect& srcRect) const > { > return ImageBufferBackend::getPixelBuffer(outputFormat, srcRect, m_data); > } > >-void ImageBufferCGBitmapBackend::putPixelBuffer(AlphaPremultiplication inputFormat, const PixelBuffer& pixelBuffer, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) >+void ImageBufferCGBitmapBackend::putPixelBuffer(const PixelBuffer& pixelBuffer, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) > { >- ImageBufferBackend::putPixelBuffer(inputFormat, pixelBuffer, srcRect, destPoint, destFormat, m_data); >+ ImageBufferBackend::putPixelBuffer(pixelBuffer, srcRect, destPoint, destFormat, m_data); > } > > } // namespace WebCore >Index: Source/WebCore/platform/graphics/cg/ImageBufferCGBitmapBackend.h >=================================================================== >--- Source/WebCore/platform/graphics/cg/ImageBufferCGBitmapBackend.h (revision 277451) >+++ Source/WebCore/platform/graphics/cg/ImageBufferCGBitmapBackend.h (working copy) >@@ -51,8 +51,8 @@ public: > > Vector<uint8_t> toBGRAData() const override; > >- Optional<PixelBuffer> getPixelBuffer(AlphaPremultiplication outputFormat, const IntRect&) const override; >- void putPixelBuffer(AlphaPremultiplication inputFormat, const PixelBuffer&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) override; >+ Optional<PixelBuffer> getPixelBuffer(const PixelBufferFormat& outputFormat, const IntRect&) const override; >+ void putPixelBuffer(const PixelBuffer&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) override; > > static constexpr bool isOriginAtUpperLeftCorner = true; > >Index: Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp >=================================================================== >--- Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp (revision 277451) >+++ Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp (working copy) >@@ -183,16 +183,16 @@ Vector<uint8_t> ImageBufferIOSurfaceBack > return ImageBufferBackend::toBGRAData(lock.surfaceBaseAddress()); > } > >-Optional<PixelBuffer> ImageBufferIOSurfaceBackend::getPixelBuffer(AlphaPremultiplication outputFormat, const IntRect& srcRect) const >+Optional<PixelBuffer> ImageBufferIOSurfaceBackend::getPixelBuffer(const PixelBufferFormat& outputFormat, const IntRect& srcRect) const > { > IOSurface::Locker lock(*m_surface); > return ImageBufferBackend::getPixelBuffer(outputFormat, srcRect, lock.surfaceBaseAddress()); > } > >-void ImageBufferIOSurfaceBackend::putPixelBuffer(AlphaPremultiplication inputFormat, const PixelBuffer& pixelBuffer, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) >+void ImageBufferIOSurfaceBackend::putPixelBuffer(const PixelBuffer& pixelBuffer, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) > { > IOSurface::Locker lock(*m_surface, IOSurface::Locker::AccessMode::ReadWrite); >- ImageBufferBackend::putPixelBuffer(inputFormat, pixelBuffer, srcRect, destPoint, destFormat, lock.surfaceBaseAddress()); >+ ImageBufferBackend::putPixelBuffer(pixelBuffer, srcRect, destPoint, destFormat, lock.surfaceBaseAddress()); > m_requiresDrawAfterPutPixelBuffer = true; > } > >Index: Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.h >=================================================================== >--- Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.h (revision 277451) >+++ Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.h (working copy) >@@ -63,8 +63,8 @@ public: > RetainPtr<CFDataRef> toCFData(const String& mimeType, Optional<double> quality, PreserveResolution) const override; > Vector<uint8_t> toBGRAData() const override; > >- Optional<PixelBuffer> getPixelBuffer(AlphaPremultiplication outputFormat, const IntRect&) const override; >- void putPixelBuffer(AlphaPremultiplication inputFormat, const PixelBuffer&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) override; >+ Optional<PixelBuffer> getPixelBuffer(const PixelBufferFormat& outputFormat, const IntRect&) const override; >+ void putPixelBuffer(const PixelBuffer&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) override; > > bool isInUse() const override; > void releaseGraphicsContext() override; >Index: Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp >=================================================================== >--- Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp (revision 277451) >+++ Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp (working copy) >@@ -775,20 +775,18 @@ static TextStream& operator<<(TextStream > return ts; > } > >-PutPixelBuffer::PutPixelBuffer(AlphaPremultiplication inputFormat, const PixelBuffer& pixelBuffer, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) >+PutPixelBuffer::PutPixelBuffer(const PixelBuffer& pixelBuffer, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) > : m_srcRect(srcRect) > , m_destPoint(destPoint) > , m_pixelBuffer(pixelBuffer.deepClone()) // This copy is actually required to preserve the semantics of putPixelBuffer(). >- , m_inputFormat(inputFormat) > , m_destFormat(destFormat) > { > } > >-PutPixelBuffer::PutPixelBuffer(AlphaPremultiplication inputFormat, PixelBuffer&& pixelBuffer, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) >+PutPixelBuffer::PutPixelBuffer(PixelBuffer&& pixelBuffer, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) > : m_srcRect(srcRect) > , m_destPoint(destPoint) > , m_pixelBuffer(WTFMove(pixelBuffer)) >- , m_inputFormat(inputFormat) > , m_destFormat(destFormat) > { > } >@@ -797,7 +795,6 @@ PutPixelBuffer::PutPixelBuffer(const Put > : m_srcRect(other.m_srcRect) > , m_destPoint(other.m_destPoint) > , m_pixelBuffer(other.m_pixelBuffer.deepClone()) >- , m_inputFormat(other.m_inputFormat) > , m_destFormat(other.m_destFormat) > { > } >@@ -814,13 +811,11 @@ void PutPixelBuffer::swap(PutPixelBuffer > std::swap(m_srcRect, other.m_srcRect); > std::swap(m_destPoint, other.m_destPoint); > std::swap(m_pixelBuffer, other.m_pixelBuffer); >- std::swap(m_inputFormat, other.m_inputFormat); > std::swap(m_destFormat, other.m_destFormat); > } > > static TextStream& operator<<(TextStream& ts, const PutPixelBuffer& item) > { >- ts.dumpProperty("inputFormat", item.inputFormat()); > ts.dumpProperty("pixelBufferSize", item.pixelBuffer().size()); > ts.dumpProperty("srcRect", item.srcRect()); > ts.dumpProperty("destPoint", item.destPoint()); >Index: Source/WebCore/platform/graphics/displaylists/DisplayListItems.h >=================================================================== >--- Source/WebCore/platform/graphics/displaylists/DisplayListItems.h (revision 277451) >+++ Source/WebCore/platform/graphics/displaylists/DisplayListItems.h (working copy) >@@ -1905,18 +1905,18 @@ public: > static constexpr bool isInlineItem = true; > static constexpr bool isDrawingItem = false; > >- GetPixelBuffer(WebCore::AlphaPremultiplication outputFormat, const WebCore::IntRect& srcRect) >+ GetPixelBuffer(WebCore::PixelBufferFormat outputFormat, const WebCore::IntRect& srcRect) > : m_srcRect(srcRect) > , m_outputFormat(outputFormat) > { > } > >- AlphaPremultiplication outputFormat() const { return m_outputFormat; } >+ PixelBufferFormat outputFormat() const { return m_outputFormat; } > IntRect srcRect() const { return m_srcRect; } > > private: > IntRect m_srcRect; >- AlphaPremultiplication m_outputFormat; >+ PixelBufferFormat m_outputFormat; > }; > > class PutPixelBuffer { >@@ -1925,8 +1925,8 @@ public: > static constexpr bool isInlineItem = false; > static constexpr bool isDrawingItem = true; > >- WEBCORE_EXPORT PutPixelBuffer(AlphaPremultiplication inputFormat, const PixelBuffer&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat); >- WEBCORE_EXPORT PutPixelBuffer(AlphaPremultiplication inputFormat, PixelBuffer&&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat); >+ WEBCORE_EXPORT PutPixelBuffer(const PixelBuffer&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat); >+ WEBCORE_EXPORT PutPixelBuffer(PixelBuffer&&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat); > > PutPixelBuffer(const PutPixelBuffer&); > PutPixelBuffer(PutPixelBuffer&&) = default; >@@ -1935,7 +1935,6 @@ public: > > void swap(PutPixelBuffer&); > >- AlphaPremultiplication inputFormat() const { return m_inputFormat; } > const PixelBuffer& pixelBuffer() const { return m_pixelBuffer; } > IntRect srcRect() const { return m_srcRect; } > IntPoint destPoint() const { return m_destPoint; } >@@ -1951,14 +1950,12 @@ private: > IntRect m_srcRect; > IntPoint m_destPoint; > PixelBuffer m_pixelBuffer; >- AlphaPremultiplication m_inputFormat; > AlphaPremultiplication m_destFormat; > }; > > template<class Encoder> > void PutPixelBuffer::encode(Encoder& encoder) const > { >- encoder << m_inputFormat; > encoder << m_pixelBuffer; > encoder << m_srcRect; > encoder << m_destPoint; >@@ -1968,16 +1965,11 @@ void PutPixelBuffer::encode(Encoder& enc > template<class Decoder> > Optional<PutPixelBuffer> PutPixelBuffer::decode(Decoder& decoder) > { >- Optional<AlphaPremultiplication> inputFormat; > Optional<PixelBuffer> pixelBuffer; > Optional<IntRect> srcRect; > Optional<IntPoint> destPoint; > Optional<AlphaPremultiplication> destFormat; > >- decoder >> inputFormat; >- if (!inputFormat) >- return WTF::nullopt; >- > decoder >> pixelBuffer; > if (!pixelBuffer) > return WTF::nullopt; >@@ -1994,7 +1986,7 @@ Optional<PutPixelBuffer> PutPixelBuffer: > if (!destFormat) > return WTF::nullopt; > >- return {{ *inputFormat, WTFMove(*pixelBuffer), *srcRect, *destPoint, *destFormat }}; >+ return {{ WTFMove(*pixelBuffer), *srcRect, *destPoint, *destFormat }}; > } > > #if ENABLE(VIDEO) >Index: Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp >=================================================================== >--- Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp (revision 277451) >+++ Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp (working copy) >@@ -55,14 +55,14 @@ Recorder::~Recorder() > LOG(DisplayLists, "Recorded display list:\n%s", m_displayList.description().data()); > } > >-void Recorder::getPixelBuffer(AlphaPremultiplication outputFormat, const IntRect& sourceRect) >+void Recorder::getPixelBuffer(const PixelBufferFormat& outputFormat, const IntRect& sourceRect) > { > append<GetPixelBuffer>(outputFormat, sourceRect); > } > >-void Recorder::putPixelBuffer(WebCore::AlphaPremultiplication inputFormat, const WebCore::PixelBuffer& pixelBuffer, const WebCore::IntRect& srcRect, const WebCore::IntPoint& destPoint, WebCore::AlphaPremultiplication destFormat) >+void Recorder::putPixelBuffer(const WebCore::PixelBuffer& pixelBuffer, const WebCore::IntRect& srcRect, const WebCore::IntPoint& destPoint, WebCore::AlphaPremultiplication destFormat) > { >- append<PutPixelBuffer>(inputFormat, pixelBuffer, srcRect, destPoint, destFormat); >+ append<PutPixelBuffer>(pixelBuffer, srcRect, destPoint, destFormat); > } > > static bool containsOnlyInlineStateChanges(const GraphicsContextStateChange& changes, GraphicsContextState::StateChangeFlags changeFlags) >Index: Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h >=================================================================== >--- Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h (revision 277451) >+++ Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h (working copy) >@@ -58,8 +58,8 @@ public: > WEBCORE_EXPORT Recorder(GraphicsContext&, DisplayList&, const GraphicsContextState&, const FloatRect& initialClip, const AffineTransform&, Delegate* = nullptr, DrawGlyphsRecorder::DrawGlyphsDeconstruction = DrawGlyphsRecorder::DrawGlyphsDeconstruction::Deconstruct); > WEBCORE_EXPORT virtual ~Recorder(); > >- WEBCORE_EXPORT void getPixelBuffer(AlphaPremultiplication outputFormat, const IntRect& sourceRect); >- WEBCORE_EXPORT void putPixelBuffer(AlphaPremultiplication inputFormat, const PixelBuffer&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat); >+ WEBCORE_EXPORT void getPixelBuffer(const PixelBufferFormat& outputFormat, const IntRect& sourceRect); >+ WEBCORE_EXPORT void putPixelBuffer(const PixelBuffer&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat); > > bool isEmpty() const { return m_displayList.isEmpty(); } > >Index: Source/WebCore/platform/graphics/filters/FEColorMatrix.cpp >=================================================================== >--- Source/WebCore/platform/graphics/filters/FEColorMatrix.cpp (revision 277451) >+++ Source/WebCore/platform/graphics/filters/FEColorMatrix.cpp (working copy) >@@ -285,8 +285,9 @@ void FEColorMatrix::platformApplySoftwar > if (inBuffer) > resultImage->context().drawImageBuffer(*inBuffer, drawingRegionOfInputImage(in->absolutePaintRect())); > >+ PixelBufferFormat format { AlphaPremultiplication::Unpremultiplied, PixelFormat::RGBA8, DestinationColorSpace::SRGB }; > IntRect imageRect(IntPoint(), resultImage->logicalSize()); >- auto pixelBuffer = resultImage->getPixelBuffer(AlphaPremultiplication::Unpremultiplied, imageRect); >+ auto pixelBuffer = resultImage->getPixelBuffer(format, imageRect); > if (!pixelBuffer) > return; > >@@ -313,7 +314,7 @@ void FEColorMatrix::platformApplySoftwar > break; > } > >- resultImage->putPixelBuffer(AlphaPremultiplication::Unpremultiplied, *pixelBuffer, imageRect); >+ resultImage->putPixelBuffer(*pixelBuffer, imageRect); > } > > static TextStream& operator<<(TextStream& ts, const ColorMatrixType& type) >Index: Source/WebCore/platform/graphics/filters/FEDropShadow.cpp >=================================================================== >--- Source/WebCore/platform/graphics/filters/FEDropShadow.cpp (revision 277451) >+++ Source/WebCore/platform/graphics/filters/FEDropShadow.cpp (working copy) >@@ -99,15 +99,16 @@ void FEDropShadow::platformApplySoftware > > ShadowBlur contextShadow(blurRadius, offset, m_shadowColor); > >+ PixelBufferFormat format { AlphaPremultiplication::Premultiplied, PixelFormat::RGBA8, DestinationColorSpace::SRGB }; > IntRect shadowArea(IntPoint(), resultImage->logicalSize()); >- auto pixelBuffer = resultImage->getPixelBuffer(AlphaPremultiplication::Premultiplied, shadowArea); >+ auto pixelBuffer = resultImage->getPixelBuffer(format, shadowArea); > if (!pixelBuffer) > return; > > auto& sourcePixelArray = pixelBuffer->data(); > contextShadow.blurLayerImage(sourcePixelArray.data(), pixelBuffer->size(), 4 * pixelBuffer->size().width()); > >- resultImage->putPixelBuffer(AlphaPremultiplication::Premultiplied, *pixelBuffer, shadowArea); >+ resultImage->putPixelBuffer(*pixelBuffer, shadowArea); > > resultContext.setCompositeOperation(CompositeOperator::SourceIn); > resultContext.fillRect(FloatRect(FloatPoint(), absolutePaintRect().size()), m_shadowColor); >Index: Source/WebCore/platform/graphics/filters/FilterEffect.cpp >=================================================================== >--- Source/WebCore/platform/graphics/filters/FilterEffect.cpp (revision 277451) >+++ Source/WebCore/platform/graphics/filters/FilterEffect.cpp (working copy) >@@ -279,9 +279,9 @@ ImageBuffer* FilterEffect::imageBufferRe > > IntRect destinationRect(IntPoint(), m_absolutePaintRect.size()); > if (m_premultipliedImageResult) >- m_imageBufferResult->putPixelBuffer(AlphaPremultiplication::Premultiplied, *m_premultipliedImageResult, destinationRect); >+ m_imageBufferResult->putPixelBuffer(*m_premultipliedImageResult, destinationRect); > else >- m_imageBufferResult->putPixelBuffer(AlphaPremultiplication::Unpremultiplied, *m_unmultipliedImageResult, destinationRect); >+ m_imageBufferResult->putPixelBuffer(*m_unmultipliedImageResult, destinationRect); > return m_imageBufferResult.get(); > } > >@@ -439,7 +439,7 @@ static void copyUnpremultiplyingAlpha(co > #endif > } > >-Optional<PixelBuffer> FilterEffect::convertPixelBufferToColorSpace(DestinationColorSpace targetColorSpace, PixelBuffer& pixelBuffer, AlphaPremultiplication outputFormat) >+Optional<PixelBuffer> FilterEffect::convertPixelBufferToColorSpace(DestinationColorSpace targetColorSpace, PixelBuffer& pixelBuffer) > { > // FIXME: Using an ImageBuffer to perform the color space conversion is unnecessary. We can do it directly. > >@@ -450,20 +450,26 @@ Optional<PixelBuffer> FilterEffect::conv > auto buffer = ImageBuffer::create(clampedSize, m_filter.renderingMode(), m_filter.filterScale(), operatingColorSpace(), PixelFormat::BGRA8); > if (!buffer) > return WTF::nullopt; >- buffer->putPixelBuffer(outputFormat, pixelBuffer, destinationRect); >- return convertImageBufferToColorSpace(targetColorSpace, *buffer, destinationRect, outputFormat); >+ buffer->putPixelBuffer(pixelBuffer, destinationRect); >+ return convertImageBufferToColorSpace(targetColorSpace, *buffer, destinationRect, pixelBuffer.format().alphaFormat); > } > >-Optional<PixelBuffer> FilterEffect::convertImageBufferToColorSpace(DestinationColorSpace targetColorSpace, ImageBuffer& inputBuffer, const IntRect& rect, AlphaPremultiplication outputFormat) >+Optional<PixelBuffer> FilterEffect::convertImageBufferToColorSpace(DestinationColorSpace targetColorSpace, ImageBuffer& inputBuffer, const IntRect& rect, AlphaPremultiplication outputAlphaFormat) > { >+ // FIXME: This can be done more directly using PixelBufferConversion. >+ > FloatSize clampedSize = ImageBuffer::clampedSize(rect.size()); >+ > // Create an ImageBuffer with the correct color space and utilize CG to handle color space conversion > auto convertedBuffer = ImageBuffer::create(clampedSize, m_filter.renderingMode(), m_filter.filterScale(), targetColorSpace, PixelFormat::BGRA8); > if (!convertedBuffer) > return WTF::nullopt; >+ > // Color space conversion happens internally when drawing from one image buffer to another > convertedBuffer->context().drawImageBuffer(inputBuffer, rect); >- return convertedBuffer->getPixelBuffer(outputFormat, rect); >+ >+ PixelBufferFormat format { outputAlphaFormat, PixelFormat::RGBA8, DestinationColorSpace::SRGB }; >+ return convertedBuffer->getPixelBuffer(format, rect); > } > > void FilterEffect::copyConvertedImageBufferToDestination(Uint8ClampedArray& destination, DestinationColorSpace colorSpace, AlphaPremultiplication outputFormat, const IntRect& destRect) >@@ -475,11 +481,11 @@ void FilterEffect::copyConvertedImageBuf > copyImageBytes(convertedPixelBuffer->data(), destination, destRect); > } > >-void FilterEffect::copyConvertedPixelBufferToDestination(Uint8ClampedArray& destination, PixelBuffer& pixelBuffer, DestinationColorSpace colorSpace, AlphaPremultiplication outputFormat, const IntRect& destRect) >+void FilterEffect::copyConvertedPixelBufferToDestination(Uint8ClampedArray& destination, PixelBuffer& pixelBuffer, DestinationColorSpace colorSpace, const IntRect& destRect) > { > // Converts the data stored in m_unmultipliedImageResult/m_premultipliedImageResult, > // whichever isn't null, and save to destination >- auto convertedPixelBuffer = convertPixelBufferToColorSpace(colorSpace, pixelBuffer, outputFormat); >+ auto convertedPixelBuffer = convertPixelBufferToColorSpace(colorSpace, pixelBuffer); > if (!convertedPixelBuffer) > return; > copyImageBytes(convertedPixelBuffer->data(), destination, destRect); >@@ -498,7 +504,8 @@ void FilterEffect::copyUnmultipliedResul > copyConvertedImageBufferToDestination(destination, *colorSpace, AlphaPremultiplication::Unpremultiplied, rect); > return; > } >- m_unmultipliedImageResult = m_imageBufferResult->getPixelBuffer(AlphaPremultiplication::Unpremultiplied, { IntPoint(), m_absolutePaintRect.size() }); >+ PixelBufferFormat format { AlphaPremultiplication::Unpremultiplied, PixelFormat::RGBA8, DestinationColorSpace::SRGB }; >+ m_unmultipliedImageResult = m_imageBufferResult->getPixelBuffer(format, { IntPoint(), m_absolutePaintRect.size() }); > if (!m_unmultipliedImageResult) > return; > } else { >@@ -513,7 +520,7 @@ void FilterEffect::copyUnmultipliedResul > } > } > if (requiresPixelBufferColorSpaceConversion(colorSpace)) { >- copyConvertedPixelBufferToDestination(destination, *m_unmultipliedImageResult, *colorSpace, AlphaPremultiplication::Unpremultiplied, rect); >+ copyConvertedPixelBufferToDestination(destination, *m_unmultipliedImageResult, *colorSpace, rect); > return; > } > copyImageBytes(m_unmultipliedImageResult->data(), destination, rect); >@@ -532,7 +539,8 @@ void FilterEffect::copyPremultipliedResu > copyConvertedImageBufferToDestination(destination, *colorSpace, AlphaPremultiplication::Premultiplied, rect); > return; > } >- m_premultipliedImageResult = m_imageBufferResult->getPixelBuffer(AlphaPremultiplication::Premultiplied, { IntPoint(), m_absolutePaintRect.size() }); >+ PixelBufferFormat format { AlphaPremultiplication::Premultiplied, PixelFormat::RGBA8, DestinationColorSpace::SRGB }; >+ m_premultipliedImageResult = m_imageBufferResult->getPixelBuffer(format, { IntPoint(), m_absolutePaintRect.size() }); > if (!m_premultipliedImageResult) > return; > } else { >@@ -548,7 +556,7 @@ void FilterEffect::copyPremultipliedResu > } > > if (requiresPixelBufferColorSpaceConversion(colorSpace)) { >- copyConvertedPixelBufferToDestination(destination, *m_premultipliedImageResult, *colorSpace, AlphaPremultiplication::Premultiplied, rect); >+ copyConvertedPixelBufferToDestination(destination, *m_premultipliedImageResult, *colorSpace, rect); > return; > } > copyImageBytes(m_premultipliedImageResult->data(), destination, rect); >Index: Source/WebCore/platform/graphics/filters/FilterEffect.h >=================================================================== >--- Source/WebCore/platform/graphics/filters/FilterEffect.h (revision 277451) >+++ Source/WebCore/platform/graphics/filters/FilterEffect.h (working copy) >@@ -204,10 +204,10 @@ private: > > void copyImageBytes(const Uint8ClampedArray& source, Uint8ClampedArray& destination, const IntRect&) const; > void copyConvertedImageBufferToDestination(Uint8ClampedArray&, DestinationColorSpace, AlphaPremultiplication, const IntRect&); >- void copyConvertedPixelBufferToDestination(Uint8ClampedArray&, PixelBuffer&, DestinationColorSpace, AlphaPremultiplication, const IntRect&); >+ void copyConvertedPixelBufferToDestination(Uint8ClampedArray&, PixelBuffer&, DestinationColorSpace, const IntRect&); > bool requiresPixelBufferColorSpaceConversion(Optional<DestinationColorSpace>); >- Optional<PixelBuffer> convertPixelBufferToColorSpace(DestinationColorSpace, PixelBuffer&, AlphaPremultiplication); > Optional<PixelBuffer> convertImageBufferToColorSpace(DestinationColorSpace, ImageBuffer&, const IntRect&, AlphaPremultiplication); >+ Optional<PixelBuffer> convertPixelBufferToColorSpace(DestinationColorSpace, PixelBuffer&); > > > Filter& m_filter; >Index: Source/WebCore/platform/graphics/win/ImageBufferDirect2DBackend.cpp >=================================================================== >--- Source/WebCore/platform/graphics/win/ImageBufferDirect2DBackend.cpp (revision 277451) >+++ Source/WebCore/platform/graphics/win/ImageBufferDirect2DBackend.cpp (working copy) >@@ -312,16 +312,16 @@ Vector<uint8_t> ImageBufferDirect2DBacke > return { }; > } > >-Optional<PixelBuffer> ImageBufferDirect2DBackend::getPixelBuffer(AlphaPremultiplication outputFormat, const IntRect& srcRect) const >+Optional<PixelBuffer> ImageBufferDirect2DBackend::getPixelBuffer(PixelBufferFormat outputFormat, const IntRect& srcRect) const > { > notImplemented(); > return ImageBufferBackend::getPixelBuffer(outputFormat, srcRect, nullptr); > } > >-void ImageBufferDirect2DBackend::putPixelBuffer(AlphaPremultiplication inputFormat, const PixelBuffer& pixelBuffer, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) >+void ImageBufferDirect2DBackend::putPixelBuffer(const PixelBuffer& pixelBuffer, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) > { > notImplemented(); >- ImageBufferBackend::putPixelBuffer(inputFormat, pixelBuffer, srcRect, destPoint, destFormat, nullptr); >+ ImageBufferBackend::putPixelBuffer(pixelBuffer, srcRect, destPoint, destFormat, nullptr); > } > > } // namespace WebCore >Index: Source/WebCore/platform/graphics/win/ImageBufferDirect2DBackend.h >=================================================================== >--- Source/WebCore/platform/graphics/win/ImageBufferDirect2DBackend.h (revision 277451) >+++ Source/WebCore/platform/graphics/win/ImageBufferDirect2DBackend.h (working copy) >@@ -53,8 +53,8 @@ public: > Vector<uint8_t> toData(const String& mimeType, Optional<double> quality) const override; > Vector<uint8_t> toBGRAData() const override; > >- Optional<PixelBuffer> getPixelBuffer(AlphaPremultiplication outputFormat, const IntRect&) const override; >- void putPixelBuffer(AlphaPremultiplication inputFormat, const PixelBuffer&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) override; >+ Optional<PixelBuffer> getPixelBuffer(PixelBufferFormat outputFormat, const IntRect&) const override; >+ void putPixelBuffer(const PixelBuffer&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) override; > > protected: > ImageBufferDirect2DBackend(const FloatSize& logicalSize, const IntSize& physicalSize, float resolutionScale, ColorSpace); >Index: Source/WebCore/rendering/shapes/Shape.cpp >=================================================================== >--- Source/WebCore/rendering/shapes/Shape.cpp (revision 277451) >+++ Source/WebCore/rendering/shapes/Shape.cpp (working copy) >@@ -197,7 +197,8 @@ std::unique_ptr<Shape> Shape::createRast > if (image) > graphicsContext.drawImage(*image, IntRect(IntPoint(), imageRect.size())); > >- auto pixelBuffer = imageBuffer->getPixelBuffer(AlphaPremultiplication::Unpremultiplied, { IntPoint(), imageRect.size() }); >+ PixelBufferFormat format { AlphaPremultiplication::Unpremultiplied, PixelFormat::RGBA8, DestinationColorSpace::SRGB }; >+ auto pixelBuffer = imageBuffer->getPixelBuffer(format, { IntPoint(), imageRect.size() }); > > // We could get to a value where PixelBuffer could be nullopt. A case where ImageRect.size() is huge, PixelBuffer::tryCreate > // can return a nullopt because data size has overflowed. Refer rdar://problem/61793884 >Index: Source/WebKit/ChangeLog >=================================================================== >--- Source/WebKit/ChangeLog (revision 277497) >+++ Source/WebKit/ChangeLog (working copy) >@@ -1,3 +1,29 @@ >+2021-05-14 Sam Weinig <weinig@apple.com> >+ >+ Use PixelBufferFormat to specify ImageBuffer::getPixelBuffer destination format allowing for more control over data conversion >+ https://bugs.webkit.org/show_bug.cgi?id=225813 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Update calls/implementations of getPixelBuffer/putPixelBuffer to adjust >+ to new signature. >+ >+ * GPUProcess/graphics/RemoteImageBuffer.h: >+ * Shared/RemoteLayerTree/CGDisplayListImageBufferBackend.cpp: >+ (WebKit::CGDisplayListImageBufferBackend::getPixelBuffer const): >+ (WebKit::CGDisplayListImageBufferBackend::putPixelBuffer): >+ * Shared/RemoteLayerTree/CGDisplayListImageBufferBackend.h: >+ * WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.cpp: >+ (WebKit::ImageBufferShareableBitmapBackend::getPixelBuffer const): >+ (WebKit::ImageBufferShareableBitmapBackend::putPixelBuffer): >+ * WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.h: >+ * WebProcess/GPU/graphics/RemoteImageBufferProxy.h: >+ (WebKit::RemoteImageBufferProxy::putPixelBuffer): >+ * WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.cpp: >+ (WebKit::ImageBufferShareableIOSurfaceBackend::getPixelBuffer const): >+ (WebKit::ImageBufferShareableIOSurfaceBackend::putPixelBuffer): >+ * WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.h: >+ > 2021-05-14 Alex Christensen <achristensen@webkit.org> > > Resource Timing: secureConnectionStart == 0 when a connection is re-used >Index: Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.h >=================================================================== >--- Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.h (revision 277451) >+++ Source/WebKit/GPUProcess/graphics/RemoteImageBuffer.h (working copy) >@@ -85,7 +85,7 @@ private: > > if (item.is<WebCore::DisplayList::PutPixelBuffer>()) { > auto& putPixelBufferItem = item.get<WebCore::DisplayList::PutPixelBuffer>(); >- putPixelBuffer(putPixelBufferItem.inputFormat(), putPixelBufferItem.pixelBuffer(), putPixelBufferItem.srcRect(), putPixelBufferItem.destPoint(), putPixelBufferItem.destFormat()); >+ putPixelBuffer(putPixelBufferItem.pixelBuffer(), putPixelBufferItem.srcRect(), putPixelBufferItem.destPoint(), putPixelBufferItem.destFormat()); > return true; > } > >Index: Source/WebKit/Shared/RemoteLayerTree/CGDisplayListImageBufferBackend.cpp >=================================================================== >--- Source/WebKit/Shared/RemoteLayerTree/CGDisplayListImageBufferBackend.cpp (revision 277451) >+++ Source/WebKit/Shared/RemoteLayerTree/CGDisplayListImageBufferBackend.cpp (working copy) >@@ -105,13 +105,13 @@ Vector<uint8_t> CGDisplayListImageBuffer > return { }; > } > >-Optional<WebCore::PixelBuffer> CGDisplayListImageBufferBackend::getPixelBuffer(WebCore::AlphaPremultiplication, const WebCore::IntRect&) const >+Optional<WebCore::PixelBuffer> CGDisplayListImageBufferBackend::getPixelBuffer(const WebCore::PixelBufferFormat&, const WebCore::IntRect&) const > { > ASSERT_NOT_REACHED(); > return { }; > } > >-void CGDisplayListImageBufferBackend::putPixelBuffer(WebCore::AlphaPremultiplication, const WebCore::PixelBuffer&, const WebCore::IntRect&, const WebCore::IntPoint&, WebCore::AlphaPremultiplication) >+void CGDisplayListImageBufferBackend::putPixelBuffer(const WebCore::PixelBuffer&, const WebCore::IntRect&, const WebCore::IntPoint&, WebCore::AlphaPremultiplication) > { > ASSERT_NOT_REACHED(); > } >Index: Source/WebKit/Shared/RemoteLayerTree/CGDisplayListImageBufferBackend.h >=================================================================== >--- Source/WebKit/Shared/RemoteLayerTree/CGDisplayListImageBufferBackend.h (revision 277451) >+++ Source/WebKit/Shared/RemoteLayerTree/CGDisplayListImageBufferBackend.h (working copy) >@@ -50,8 +50,8 @@ public: > // 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(WebCore::AlphaPremultiplication outputFormat, const WebCore::IntRect&) const override; >- void putPixelBuffer(WebCore::AlphaPremultiplication inputFormat, const WebCore::PixelBuffer&, const WebCore::IntRect& srcRect, const WebCore::IntPoint& destPoint, WebCore::AlphaPremultiplication destFormat) 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; > > static constexpr bool isOriginAtUpperLeftCorner = true; > >Index: Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.cpp >=================================================================== >--- Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.cpp (revision 277451) >+++ Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.cpp (working copy) >@@ -163,14 +163,14 @@ Vector<uint8_t> ImageBufferShareableBitm > return ImageBufferBackend::toBGRAData(m_bitmap->data()); > } > >-Optional<PixelBuffer> ImageBufferShareableBitmapBackend::getPixelBuffer(AlphaPremultiplication outputFormat, const IntRect& srcRect) const >+Optional<PixelBuffer> ImageBufferShareableBitmapBackend::getPixelBuffer(const PixelBufferFormat& outputFormat, const IntRect& srcRect) const > { > return ImageBufferBackend::getPixelBuffer(outputFormat, srcRect, m_bitmap->data()); > } > >-void ImageBufferShareableBitmapBackend::putPixelBuffer(AlphaPremultiplication inputFormat, const PixelBuffer& pixelBuffer, const IntRect& srcRect, const IntPoint& destPoint, WebCore::AlphaPremultiplication destFormat) >+void ImageBufferShareableBitmapBackend::putPixelBuffer(const PixelBuffer& pixelBuffer, const IntRect& srcRect, const IntPoint& destPoint, WebCore::AlphaPremultiplication destFormat) > { >- ImageBufferBackend::putPixelBuffer(inputFormat, pixelBuffer, srcRect, destPoint, destFormat, m_bitmap->data()); >+ ImageBufferBackend::putPixelBuffer(pixelBuffer, srcRect, destPoint, destFormat, m_bitmap->data()); > } > > } // namespace WebKit >Index: Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.h >=================================================================== >--- Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.h (revision 277451) >+++ Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.h (working copy) >@@ -59,8 +59,8 @@ public: > 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(WebCore::AlphaPremultiplication outputFormat, const WebCore::IntRect&) const override; >- void putPixelBuffer(WebCore::AlphaPremultiplication inputFormat, const WebCore::PixelBuffer&, const WebCore::IntRect& srcRect, const WebCore::IntPoint& destPoint, WebCore::AlphaPremultiplication destFormat) 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; > > private: > unsigned bytesPerRow() const override; >Index: Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h >=================================================================== >--- Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h (revision 277451) >+++ Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h (working copy) >@@ -194,12 +194,11 @@ protected: > return bitmap->createImage(); > } > >- Optional<WebCore::PixelBuffer> getPixelBuffer(WebCore::AlphaPremultiplication outputFormat, const WebCore::IntRect& srcRect) const override >+ Optional<WebCore::PixelBuffer> getPixelBuffer(const WebCore::PixelBufferFormat& destinationFormat, const WebCore::IntRect& srcRect) const override > { > if (UNLIKELY(!m_remoteRenderingBackendProxy)) > return WTF::nullopt; > >- WebCore::PixelBufferFormat destinationFormat { outputFormat, WebCore::PixelFormat::RGBA8, WebCore::DestinationColorSpace::SRGB }; > auto pixelBuffer = WebCore::PixelBuffer::tryCreate(destinationFormat, srcRect.size()); > if (!pixelBuffer) > return WTF::nullopt; >@@ -211,7 +210,7 @@ protected: > return WTF::nullopt; > > auto& mutableThis = const_cast<RemoteImageBufferProxy&>(*this); >- mutableThis.m_drawingContext.recorder().getPixelBuffer(outputFormat, srcRect); >+ mutableThis.m_drawingContext.recorder().getPixelBuffer(destinationFormat, srcRect); > mutableThis.flushDrawingContextAsync(); > > if (m_remoteRenderingBackendProxy->waitForGetPixelBufferToComplete(timeout)) >@@ -221,12 +220,12 @@ protected: > return pixelBuffer; > } > >- void putPixelBuffer(WebCore::AlphaPremultiplication inputFormat, const WebCore::PixelBuffer& pixelBuffer, const WebCore::IntRect& srcRect, const WebCore::IntPoint& destPoint = { }, WebCore::AlphaPremultiplication destFormat = WebCore::AlphaPremultiplication::Premultiplied) override >+ void putPixelBuffer(const WebCore::PixelBuffer& pixelBuffer, const WebCore::IntRect& srcRect, const WebCore::IntPoint& destPoint = { }, WebCore::AlphaPremultiplication destFormat = WebCore::AlphaPremultiplication::Premultiplied) override > { > // The math inside PixelBuffer::create() doesn't agree with the math inside ImageBufferBackend::putPixelBuffer() about how m_resolutionScale interacts with the data in the ImageBuffer. > // This means that putPixelBuffer() is only called when resolutionScale() == 1. > ASSERT(resolutionScale() == 1); >- m_drawingContext.recorder().putPixelBuffer(inputFormat, pixelBuffer, srcRect, destPoint, destFormat); >+ m_drawingContext.recorder().putPixelBuffer(pixelBuffer, srcRect, destPoint, destFormat); > } > > bool prefersPreparationForDisplay() override { return true; } >Index: Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.cpp >=================================================================== >--- Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.cpp (revision 277451) >+++ Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.cpp (working copy) >@@ -120,13 +120,13 @@ Vector<uint8_t> ImageBufferShareableIOSu > return { }; > } > >-Optional<PixelBuffer> ImageBufferShareableIOSurfaceBackend::getPixelBuffer(AlphaPremultiplication, const IntRect&) const >+Optional<PixelBuffer> ImageBufferShareableIOSurfaceBackend::getPixelBuffer(const PixelBufferFormat&, const IntRect&) const > { > RELEASE_ASSERT_NOT_REACHED(); > return { }; > } > >-void ImageBufferShareableIOSurfaceBackend::putPixelBuffer(AlphaPremultiplication, const PixelBuffer&, const IntRect&, const IntPoint&, AlphaPremultiplication) >+void ImageBufferShareableIOSurfaceBackend::putPixelBuffer(const PixelBuffer&, const IntRect&, const IntPoint&, AlphaPremultiplication) > { > RELEASE_ASSERT_NOT_REACHED(); > } >Index: Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.h >=================================================================== >--- Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.h (revision 277451) >+++ Source/WebKit/WebProcess/GPU/graphics/cocoa/ImageBufferShareableIOSurfaceBackend.h (working copy) >@@ -60,8 +60,8 @@ public: > 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(WebCore::AlphaPremultiplication outputFormat, const WebCore::IntRect&) const override; >- void putPixelBuffer(WebCore::AlphaPremultiplication inputFormat, const WebCore::PixelBuffer&, const WebCore::IntRect& srcRect, const WebCore::IntPoint& destPoint, WebCore::AlphaPremultiplication destFormat) 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; > > static constexpr bool isOriginAtUpperLeftCorner = true; > static constexpr bool canMapBackingStore = false;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 225813
:
428639
|
428642
|
428646
|
428647