Title: [292469] trunk
Revision
292469
Author
simon.fra...@apple.com
Date
2022-04-06 08:22:41 -0700 (Wed, 06 Apr 2022)

Log Message

Unify the two ImageBuffer::create() functions, passing RenderingPurpose everywhere
https://bugs.webkit.org/show_bug.cgi?id=238851

Reviewed by Said Abou-Hallawa.

I need to extend RenderingPurpose flags to distinguish layer backing store buffers from
other kinds of buffers. Before doing so, collapse the two ImageBuffer::create() functions
together by combining RenderingMode and ShouldUseDisplayList into OptionSet<ImageBufferOptions>,
and passing RenderingPurpose everywhere.

Always passing RenderingPurpose is revealing, because it finds call sites in the
web process that can trigger accelerated buffers (e.g. webkit.org/b/238846).

Source/WebCore:

* Modules/async-clipboard/ClipboardItemBindingsDataSource.cpp:
(WebCore::ClipboardItemBindingsDataSource::ClipboardItemTypeLoader::sanitizeDataIfNeeded):
* Modules/mediasession/MediaMetadata.cpp:
(WebCore::ArtworkImageLoader::notifyFinished):
* css/CSSFilterImageValue.cpp:
(WebCore::CSSFilterImageValue::image):
* html/CustomPaintCanvas.cpp:
(WebCore::CustomPaintCanvas::copiedImage const):
* html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::createImageBuffer const):
* html/HTMLVideoElement.cpp:
(WebCore::HTMLVideoElement::createBufferForPainting const):
* html/ImageBitmap.cpp:
(WebCore::ImageBitmap::createImageBuffer):
* html/canvas/ImageBitmapRenderingContext.cpp:
(WebCore::ImageBitmapRenderingContext::setOutputBitmap):
* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::LRUImageBufferCache::imageBuffer):
* html/shadow/MediaControlTextTrackContainerElement.cpp:
(WebCore::MediaControlTextTrackContainerElement::createTextTrackRepresentationImage):
* inspector/InspectorCanvas.cpp:
(WebCore::InspectorCanvas::indexForData):
* page/FrameSnapshotting.cpp:
(WebCore::snapshotFrameRectWithClip):
* page/PageConsoleClient.cpp:
(WebCore::PageConsoleClient::screenshot):
* platform/graphics/BitmapImage.cpp:
(WebCore::BitmapImage::preTransformedNativeImageForCurrentFrame):
* platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::createImageBuffer const):
* platform/graphics/ImageBuffer.cpp:
(WebCore::ImageBuffer::create):
* platform/graphics/ImageBuffer.h:
(WebCore::ImageBuffer::create):
* platform/graphics/RenderingMode.h:
* platform/graphics/ShadowBlur.cpp:
(WebCore::ScratchBuffer::WTF_REQUIRES_LOCK):
(WebCore::ShadowBlur::drawRectShadowWithoutTiling):
(WebCore::ShadowBlur::drawInsetShadowWithoutTiling):
(WebCore::ShadowBlur::drawRectShadowWithTiling):
(WebCore::ShadowBlur::drawInsetShadowWithTiling):
(WebCore::ShadowBlur::drawShadowLayer):
* platform/graphics/SourceImage.cpp:
(WebCore::SourceImage::imageBuffer const):
* platform/graphics/filters/FilterImage.cpp:
(WebCore::FilterImage::imageBufferFromPixelBuffer):
(WebCore::getConvertedPixelBuffer):
* platform/graphics/filters/software/FETileSoftwareApplier.cpp:
(WebCore::FETileSoftwareApplier::apply const):
* platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.cpp:
(Nicosia::GCGLANGLELayer::swapBuffersIfNeeded):
* platform/graphics/texmap/BitmapTexture.cpp:
(WebCore::BitmapTexture::updateContents):
* platform/mock/MockRealtimeVideoSource.cpp:
(WebCore::MockRealtimeVideoSource::imageBuffer const):
* rendering/shapes/Shape.cpp:
(WebCore::Shape::createRasterShape):
* rendering/svg/RenderSVGResourceClipper.cpp:
(WebCore::RenderSVGResourceClipper::applyClippingToContext):
* svg/SVGFEImageElement.cpp:
(WebCore::createImageBuffer):
* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::nativeImage):

Source/WebKitLegacy/mac:

* WebCoreSupport/WebContextMenuClient.mm:
(WebContextMenuClient::imageForCurrentSharingServicePickerItem):

Tools:

* TestWebKitAPI/Tests/WebCore/ImageBufferTests.cpp:
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebCore/cg/DisplayListTestsCG.cpp:
(TestWebKitAPI::TEST):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (292468 => 292469)


--- trunk/Source/WebCore/ChangeLog	2022-04-06 15:20:50 UTC (rev 292468)
+++ trunk/Source/WebCore/ChangeLog	2022-04-06 15:22:41 UTC (rev 292469)
@@ -1,3 +1,82 @@
+2022-04-06  Simon Fraser  <simon.fra...@apple.com>
+
+        Unify the two ImageBuffer::create() functions, passing RenderingPurpose everywhere
+        https://bugs.webkit.org/show_bug.cgi?id=238851
+
+        Reviewed by Said Abou-Hallawa.
+
+        I need to extend RenderingPurpose flags to distinguish layer backing store buffers from
+        other kinds of buffers. Before doing so, collapse the two ImageBuffer::create() functions
+        together by combining RenderingMode and ShouldUseDisplayList into OptionSet<ImageBufferOptions>,
+        and passing RenderingPurpose everywhere.
+        
+        Always passing RenderingPurpose is revealing, because it finds call sites in the
+        web process that can trigger accelerated buffers (e.g. webkit.org/b/238846).
+
+        * Modules/async-clipboard/ClipboardItemBindingsDataSource.cpp:
+        (WebCore::ClipboardItemBindingsDataSource::ClipboardItemTypeLoader::sanitizeDataIfNeeded):
+        * Modules/mediasession/MediaMetadata.cpp:
+        (WebCore::ArtworkImageLoader::notifyFinished):
+        * css/CSSFilterImageValue.cpp:
+        (WebCore::CSSFilterImageValue::image):
+        * html/CustomPaintCanvas.cpp:
+        (WebCore::CustomPaintCanvas::copiedImage const):
+        * html/HTMLCanvasElement.cpp:
+        (WebCore::HTMLCanvasElement::createImageBuffer const):
+        * html/HTMLVideoElement.cpp:
+        (WebCore::HTMLVideoElement::createBufferForPainting const):
+        * html/ImageBitmap.cpp:
+        (WebCore::ImageBitmap::createImageBuffer):
+        * html/canvas/ImageBitmapRenderingContext.cpp:
+        (WebCore::ImageBitmapRenderingContext::setOutputBitmap):
+        * html/canvas/WebGLRenderingContextBase.cpp:
+        (WebCore::WebGLRenderingContextBase::LRUImageBufferCache::imageBuffer):
+        * html/shadow/MediaControlTextTrackContainerElement.cpp:
+        (WebCore::MediaControlTextTrackContainerElement::createTextTrackRepresentationImage):
+        * inspector/InspectorCanvas.cpp:
+        (WebCore::InspectorCanvas::indexForData):
+        * page/FrameSnapshotting.cpp:
+        (WebCore::snapshotFrameRectWithClip):
+        * page/PageConsoleClient.cpp:
+        (WebCore::PageConsoleClient::screenshot):
+        * platform/graphics/BitmapImage.cpp:
+        (WebCore::BitmapImage::preTransformedNativeImageForCurrentFrame):
+        * platform/graphics/GraphicsContext.cpp:
+        (WebCore::GraphicsContext::createImageBuffer const):
+        * platform/graphics/ImageBuffer.cpp:
+        (WebCore::ImageBuffer::create):
+        * platform/graphics/ImageBuffer.h:
+        (WebCore::ImageBuffer::create):
+        * platform/graphics/RenderingMode.h:
+        * platform/graphics/ShadowBlur.cpp:
+        (WebCore::ScratchBuffer::WTF_REQUIRES_LOCK):
+        (WebCore::ShadowBlur::drawRectShadowWithoutTiling):
+        (WebCore::ShadowBlur::drawInsetShadowWithoutTiling):
+        (WebCore::ShadowBlur::drawRectShadowWithTiling):
+        (WebCore::ShadowBlur::drawInsetShadowWithTiling):
+        (WebCore::ShadowBlur::drawShadowLayer):
+        * platform/graphics/SourceImage.cpp:
+        (WebCore::SourceImage::imageBuffer const):
+        * platform/graphics/filters/FilterImage.cpp:
+        (WebCore::FilterImage::imageBufferFromPixelBuffer):
+        (WebCore::getConvertedPixelBuffer):
+        * platform/graphics/filters/software/FETileSoftwareApplier.cpp:
+        (WebCore::FETileSoftwareApplier::apply const):
+        * platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.cpp:
+        (Nicosia::GCGLANGLELayer::swapBuffersIfNeeded):
+        * platform/graphics/texmap/BitmapTexture.cpp:
+        (WebCore::BitmapTexture::updateContents):
+        * platform/mock/MockRealtimeVideoSource.cpp:
+        (WebCore::MockRealtimeVideoSource::imageBuffer const):
+        * rendering/shapes/Shape.cpp:
+        (WebCore::Shape::createRasterShape):
+        * rendering/svg/RenderSVGResourceClipper.cpp:
+        (WebCore::RenderSVGResourceClipper::applyClippingToContext):
+        * svg/SVGFEImageElement.cpp:
+        (WebCore::createImageBuffer):
+        * svg/graphics/SVGImage.cpp:
+        (WebCore::SVGImage::nativeImage):
+
 2022-04-06  Oriol Brufau  <obru...@igalia.com>
 
         [css] Turn -webkit-border-image into a shorthand

Modified: trunk/Source/WebCore/Modules/async-clipboard/ClipboardItemBindingsDataSource.cpp (292468 => 292469)


--- trunk/Source/WebCore/Modules/async-clipboard/ClipboardItemBindingsDataSource.cpp	2022-04-06 15:20:50 UTC (rev 292468)
+++ trunk/Source/WebCore/Modules/async-clipboard/ClipboardItemBindingsDataSource.cpp	2022-04-06 15:22:41 UTC (rev 292469)
@@ -289,7 +289,7 @@
 
         auto bitmapImage = BitmapImage::create();
         bitmapImage->setData(WTFMove(bufferToSanitize), true);
-        auto imageBuffer = ImageBuffer::create(bitmapImage->size(), RenderingMode::Unaccelerated, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
+        auto imageBuffer = ImageBuffer::create(bitmapImage->size(), RenderingPurpose::Unspecified, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
         if (!imageBuffer) {
             m_data = { nullString() };
             return;

Modified: trunk/Source/WebCore/Modules/mediasession/MediaMetadata.cpp (292468 => 292469)


--- trunk/Source/WebCore/Modules/mediasession/MediaMetadata.cpp	2022-04-06 15:20:50 UTC (rev 292468)
+++ trunk/Source/WebCore/Modules/mediasession/MediaMetadata.cpp	2022-04-06 15:22:41 UTC (rev 292469)
@@ -80,7 +80,7 @@
     RefPtr<FragmentedSharedBuffer> bufferToSanitize = m_cachedImage->image()->data();
     auto bitmapImage = BitmapImage::create();
     bitmapImage->setData(WTFMove(bufferToSanitize), true);
-    auto imageBuffer = ImageBuffer::create(bitmapImage->size(), RenderingMode::Unaccelerated, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
+    auto imageBuffer = ImageBuffer::create(bitmapImage->size(), RenderingPurpose::Unspecified, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
     if (!imageBuffer) {
         m_callback(nullptr);
         return;

Modified: trunk/Source/WebCore/css/CSSFilterImageValue.cpp (292468 => 292469)


--- trunk/Source/WebCore/css/CSSFilterImageValue.cpp	2022-04-06 15:20:50 UTC (rev 292468)
+++ trunk/Source/WebCore/css/CSSFilterImageValue.cpp	2022-04-06 15:22:41 UTC (rev 292469)
@@ -114,9 +114,8 @@
     if (!image)
         return &Image::nullImage();
 
-    // Transform Image into ImageBuffer.
     auto renderingMode = renderer.page().acceleratedFiltersEnabled() ? RenderingMode::Accelerated : RenderingMode::Unaccelerated;
-    auto sourceImage = ImageBuffer::create(size, renderingMode, ShouldUseDisplayList::No, RenderingPurpose::DOM, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8, { renderer.hostWindow() });
+    auto sourceImage = ImageBuffer::create(size, RenderingPurpose::DOM, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8, bufferOptionsForRendingMode(renderingMode), { renderer.hostWindow() });
     if (!sourceImage)
         return &Image::nullImage();
 

Modified: trunk/Source/WebCore/html/CustomPaintCanvas.cpp (292468 => 292469)


--- trunk/Source/WebCore/html/CustomPaintCanvas.cpp	2022-04-06 15:20:50 UTC (rev 292468)
+++ trunk/Source/WebCore/html/CustomPaintCanvas.cpp	2022-04-06 15:22:41 UTC (rev 292469)
@@ -92,7 +92,7 @@
     if (!width() || !height())
         return nullptr;
 
-    m_copiedBuffer = ImageBuffer::create(size(), RenderingMode::Unaccelerated, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8, nullptr);
+    m_copiedBuffer = ImageBuffer::create(size(), RenderingPurpose::Unspecified, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
     if (!m_copiedBuffer)
         return nullptr;
 

Modified: trunk/Source/WebCore/html/HTMLCanvasElement.cpp (292468 => 292469)


--- trunk/Source/WebCore/html/HTMLCanvasElement.cpp	2022-04-06 15:20:50 UTC (rev 292468)
+++ trunk/Source/WebCore/html/HTMLCanvasElement.cpp	2022-04-06 15:22:41 UTC (rev 292469)
@@ -886,9 +886,12 @@
 
     auto hostWindow = (document().view() && document().view()->root()) ? document().view()->root()->hostWindow() : nullptr;
 
-    auto renderingMode = shouldAccelerate(area) ? RenderingMode::Accelerated : RenderingMode::Unaccelerated;
+    OptionSet<ImageBufferOptions> bufferOptions;
+    if (shouldAccelerate(area))
+        bufferOptions.add(ImageBufferOptions::Accelerated);
     // FIXME: Add a new setting for DisplayList drawing on canvas.
-    auto useDisplayList = m_usesDisplayListDrawing.value_or(document().settings().displayListDrawingEnabled()) ? ShouldUseDisplayList::Yes : ShouldUseDisplayList::No;
+    if (m_usesDisplayListDrawing.value_or(document().settings().displayListDrawingEnabled()))
+        bufferOptions.add(ImageBufferOptions::UseDisplayList);
 
     auto [colorSpace, pixelFormat] = [&] {
         if (m_context)
@@ -896,7 +899,7 @@
         return std::pair { DestinationColorSpace::SRGB(), PixelFormat::BGRA8 };
     }();
 
-    setImageBuffer(ImageBuffer::create(size(), renderingMode, useDisplayList, RenderingPurpose::Canvas, 1, colorSpace, pixelFormat, hostWindow));
+    setImageBuffer(ImageBuffer::create(size(), RenderingPurpose::Canvas, 1, colorSpace, pixelFormat, bufferOptions, { hostWindow }));
 
 #if USE(IOSURFACE_CANVAS_BACKING_STORE)
     if (m_context && m_context->is2d()) {

Modified: trunk/Source/WebCore/html/HTMLVideoElement.cpp (292468 => 292469)


--- trunk/Source/WebCore/html/HTMLVideoElement.cpp	2022-04-06 15:20:50 UTC (rev 292468)
+++ trunk/Source/WebCore/html/HTMLVideoElement.cpp	2022-04-06 15:22:41 UTC (rev 292469)
@@ -297,8 +297,12 @@
 RefPtr<ImageBuffer> HTMLVideoElement::createBufferForPainting(const FloatSize& size, RenderingMode renderingMode, const DestinationColorSpace& colorSpace, PixelFormat pixelFormat) const
 {
     auto* hostWindow = document().view() && document().view()->root() ? document().view()->root()->hostWindow() : nullptr;
-    auto shouldUseDisplayList = document().settings().displayListDrawingEnabled() ? ShouldUseDisplayList::Yes : ShouldUseDisplayList::No;
-    return ImageBuffer::create(size, renderingMode, shouldUseDisplayList, RenderingPurpose::MediaPainting, 1, colorSpace, pixelFormat, hostWindow);
+
+    auto bufferOptions = bufferOptionsForRendingMode(renderingMode);
+    if (document().settings().displayListDrawingEnabled())
+        bufferOptions.add(ImageBufferOptions::UseDisplayList);
+
+    return ImageBuffer::create(size, RenderingPurpose::MediaPainting, 1, colorSpace, pixelFormat, bufferOptions, { hostWindow });
 }
 
 void HTMLVideoElement::paintCurrentFrameInContext(GraphicsContext& context, const FloatRect& destRect)

Modified: trunk/Source/WebCore/html/ImageBitmap.cpp (292468 => 292469)


--- trunk/Source/WebCore/html/ImageBitmap.cpp	2022-04-06 15:20:50 UTC (rev 292468)
+++ trunk/Source/WebCore/html/ImageBitmap.cpp	2022-04-06 15:22:41 UTC (rev 292469)
@@ -89,16 +89,18 @@
 #endif
     }
 
+    auto bufferOptions = bufferOptionsForRendingMode(renderingMode);
+
     if (scriptExecutionContext.isDocument()) {
         auto& document = downcast<Document>(scriptExecutionContext);
         if (document.view() && document.view()->root()) {
             auto hostWindow = document.view()->root()->hostWindow();
-            return ImageBuffer::create(size, renderingMode, ShouldUseDisplayList::No, RenderingPurpose::Canvas, resolutionScale, *imageBufferColorSpace, PixelFormat::BGRA8, hostWindow);
+            return ImageBuffer::create(size, RenderingPurpose::Canvas, resolutionScale, *imageBufferColorSpace, PixelFormat::BGRA8, bufferOptions, { hostWindow });
         }
     }
 
     // FIXME <https://webkit.org/b/218482> Enable worker based ImageBitmap and OffscreenCanvas drawing to use GPU Process rendering
-    return ImageBuffer::create(size, renderingMode, resolutionScale, *imageBufferColorSpace, PixelFormat::BGRA8);
+    return ImageBuffer::create(size, RenderingPurpose::Unspecified, resolutionScale, *imageBufferColorSpace, PixelFormat::BGRA8, bufferOptions);
 }
 
 void ImageBitmap::createPromise(ScriptExecutionContext& scriptExecutionContext, ImageBitmap::Source&& source, ImageBitmapOptions&& options, ImageBitmap::Promise&& promise)

Modified: trunk/Source/WebCore/html/canvas/ImageBitmapRenderingContext.cpp (292468 => 292469)


--- trunk/Source/WebCore/html/canvas/ImageBitmapRenderingContext.cpp	2022-04-06 15:20:50 UTC (rev 292468)
+++ trunk/Source/WebCore/html/canvas/ImageBitmapRenderingContext.cpp	2022-04-06 15:22:41 UTC (rev 292469)
@@ -95,7 +95,9 @@
         // only reason I can think of is toDataURL(), but that doesn't seem like
         // a good enough argument to waste memory.
 
-        canvas()->setImageBufferAndMarkDirty(ImageBuffer::create(FloatSize(canvas()->width(), canvas()->height()), bufferRenderingMode, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8));
+        // FIXME: This needs to use RenderingPurpose::Canvas to avoid accelerated buffers in the WebContent process (webkit.org/b/238846).
+        auto buffer = ImageBuffer::create(FloatSize(canvas()->width(), canvas()->height()), RenderingPurpose::Unspecified, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8, bufferOptionsForRendingMode(bufferRenderingMode));
+        canvas()->setImageBufferAndMarkDirty(WTFMove(buffer));
 
         // 1.4. Set the output bitmap's origin-clean flag to true.
 

Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp (292468 => 292469)


--- trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp	2022-04-06 15:20:50 UTC (rev 292468)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp	2022-04-06 15:22:41 UTC (rev 292469)
@@ -7837,7 +7837,7 @@
     }
 
     // FIXME (149423): Should this ImageBuffer be unconditionally unaccelerated?
-    auto temp = ImageBuffer::create(size, RenderingMode::Unaccelerated, 1, colorSpace, PixelFormat::BGRA8);
+    auto temp = ImageBuffer::create(size, RenderingPurpose::Unspecified, 1, colorSpace, PixelFormat::BGRA8);
     if (!temp)
         return nullptr;
     ASSERT(m_buffers.size() > 0);

Modified: trunk/Source/WebCore/html/shadow/MediaControlTextTrackContainerElement.cpp (292468 => 292469)


--- trunk/Source/WebCore/html/shadow/MediaControlTextTrackContainerElement.cpp	2022-04-06 15:20:50 UTC (rev 292468)
+++ trunk/Source/WebCore/html/shadow/MediaControlTextTrackContainerElement.cpp	2022-04-06 15:22:41 UTC (rev 292469)
@@ -420,7 +420,7 @@
     IntRect paintingRect = IntRect(IntPoint(), layer->size());
 
     // FIXME (149422): This buffer should not be unconditionally unaccelerated.
-    auto buffer = ImageBuffer::create(paintingRect.size(), RenderingMode::Unaccelerated, deviceScaleFactor, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
+    auto buffer = ImageBuffer::create(paintingRect.size(), RenderingPurpose::Unspecified, deviceScaleFactor, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
     if (!buffer)
         return nullptr;
 

Modified: trunk/Source/WebCore/inspector/InspectorCanvas.cpp (292468 => 292469)


--- trunk/Source/WebCore/inspector/InspectorCanvas.cpp	2022-04-06 15:20:50 UTC (rev 292468)
+++ trunk/Source/WebCore/inspector/InspectorCanvas.cpp	2022-04-06 15:22:41 UTC (rev 292469)
@@ -1098,7 +1098,7 @@
             if (CachedImage* cachedImage = imageElement->cachedImage()) {
                 Image* image = cachedImage->image();
                 if (image && image != &Image::nullImage()) {
-                    auto imageBuffer = ImageBuffer::create(image->size(), RenderingMode::Unaccelerated, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
+                    auto imageBuffer = ImageBuffer::create(image->size(), RenderingPurpose::Unspecified, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
                     imageBuffer->context().drawImage(*image, FloatPoint(0, 0));
                     dataURL = imageBuffer->toDataURL("image/png"_s);
                 }
@@ -1112,7 +1112,7 @@
 
             unsigned videoWidth = videoElement->videoWidth();
             unsigned videoHeight = videoElement->videoHeight();
-            auto imageBuffer = ImageBuffer::create(FloatSize(videoWidth, videoHeight), RenderingMode::Unaccelerated, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
+            auto imageBuffer = ImageBuffer::create(FloatSize(videoWidth, videoHeight), RenderingPurpose::Unspecified, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
             if (imageBuffer) {
                 videoElement->paintCurrentFrameInContext(imageBuffer->context(), FloatRect(0, 0, videoWidth, videoHeight));
                 dataURL = imageBuffer->toDataURL("image/png"_s);
@@ -1149,7 +1149,7 @@
             if (auto* cachedImage = cssImageValue->image()) {
                 auto* image = cachedImage->image();
                 if (image && image != &Image::nullImage()) {
-                    auto imageBuffer = ImageBuffer::create(image->size(), RenderingMode::Unaccelerated, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
+                    auto imageBuffer = ImageBuffer::create(image->size(), RenderingPurpose::Unspecified, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
                     imageBuffer->context().drawImage(*image, FloatPoint(0, 0));
                     dataURL = imageBuffer->toDataURL("image/png"_s);
                 }

Modified: trunk/Source/WebCore/page/FrameSnapshotting.cpp (292468 => 292469)


--- trunk/Source/WebCore/page/FrameSnapshotting.cpp	2022-04-06 15:20:50 UTC (rev 292468)
+++ trunk/Source/WebCore/page/FrameSnapshotting.cpp	2022-04-06 15:22:41 UTC (rev 292469)
@@ -114,7 +114,7 @@
     if (options.flags.contains(SnapshotFlags::PaintWithIntegralScaleFactor))
         scaleFactor = ceilf(scaleFactor);
 
-    auto buffer = ImageBuffer::create(imageRect.size(), RenderingMode::Unaccelerated, scaleFactor, options.colorSpace, options.pixelFormat);
+    auto buffer = ImageBuffer::create(imageRect.size(), RenderingPurpose::Unspecified, scaleFactor, options.colorSpace, options.pixelFormat);
     if (!buffer)
         return nullptr;
     buffer->context().translate(-imageRect.x(), -imageRect.y());

Modified: trunk/Source/WebCore/page/PageConsoleClient.cpp (292468 => 292469)


--- trunk/Source/WebCore/page/PageConsoleClient.cpp	2022-04-06 15:20:50 UTC (rev 292468)
+++ trunk/Source/WebCore/page/PageConsoleClient.cpp	2022-04-06 15:22:41 UTC (rev 292469)
@@ -348,7 +348,7 @@
                         if (auto* cachedImage = imageElement.cachedImage()) {
                             auto* image = cachedImage->image();
                             if (image && image != &Image::nullImage()) {
-                                snapshot = ImageBuffer::create(image->size(), RenderingMode::Unaccelerated, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
+                                snapshot = ImageBuffer::create(image->size(), RenderingPurpose::Unspecified, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
                                 snapshot->context().drawImage(*image, FloatPoint(0, 0));
                             }
                         }
@@ -365,7 +365,7 @@
                         auto& videoElement = downcast<HTMLVideoElement>(*node);
                         unsigned videoWidth = videoElement.videoWidth();
                         unsigned videoHeight = videoElement.videoHeight();
-                        snapshot = ImageBuffer::create(FloatSize(videoWidth, videoHeight), RenderingMode::Unaccelerated, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
+                        snapshot = ImageBuffer::create(FloatSize(videoWidth, videoHeight), RenderingPurpose::Unspecified, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
                         videoElement.paintCurrentFrameInContext(snapshot->context(), FloatRect(0, 0, videoWidth, videoHeight));
                     }
 #endif
@@ -390,7 +390,7 @@
             target = possibleTarget;
             if (UNLIKELY(InspectorInstrumentation::hasFrontends())) {
                 auto sourceSize = imageData->size();
-                if (auto imageBuffer = ImageBuffer::create(sourceSize, RenderingMode::Unaccelerated, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8)) {
+                if (auto imageBuffer = ImageBuffer::create(sourceSize, RenderingPurpose::Unspecified, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8)) {
                     IntRect sourceRect(IntPoint(), sourceSize);
                     imageBuffer->putPixelBuffer(imageData->pixelBuffer(), sourceRect);
                     dataURL = imageBuffer->toDataURL("image/png"_s, std::nullopt, PreserveResolution::Yes);

Modified: trunk/Source/WebCore/platform/graphics/BitmapImage.cpp (292468 => 292469)


--- trunk/Source/WebCore/platform/graphics/BitmapImage.cpp	2022-04-06 15:20:50 UTC (rev 292468)
+++ trunk/Source/WebCore/platform/graphics/BitmapImage.cpp	2022-04-06 15:22:41 UTC (rev 292469)
@@ -160,7 +160,7 @@
         return image;
 
     auto correctedSizeFloat = correctedSize ? FloatSize(correctedSize.value()) : size();
-    auto buffer = ImageBuffer::create(correctedSizeFloat, RenderingMode::Unaccelerated, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
+    auto buffer = ImageBuffer::create(correctedSizeFloat, RenderingPurpose::Unspecified, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
     if (!buffer)
         return image;
 

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp (292468 => 292469)


--- trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp	2022-04-06 15:20:50 UTC (rev 292468)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp	2022-04-06 15:22:41 UTC (rev 292469)
@@ -198,10 +198,13 @@
 
 RefPtr<ImageBuffer> GraphicsContext::createImageBuffer(const FloatSize& size, float resolutionScale, const DestinationColorSpace& colorSpace, std::optional<RenderingMode> renderingMode, std::optional<RenderingMethod> renderingMethod) const
 {
+    auto bufferOptions = bufferOptionsForRendingMode(renderingMode.value_or(this->renderingMode()));
+
     if (!renderingMethod || *renderingMethod == RenderingMethod::Local)
-        return ImageBuffer::create(size, renderingMode.value_or(this->renderingMode()), resolutionScale, colorSpace, PixelFormat::BGRA8);
+        return ImageBuffer::create(size, RenderingPurpose::Unspecified, resolutionScale, colorSpace, PixelFormat::BGRA8, bufferOptions);
 
-    return ImageBuffer::create(size, renderingMode.value_or(this->renderingMode()), ShouldUseDisplayList::Yes, RenderingPurpose::Unspecified, resolutionScale, colorSpace, PixelFormat::BGRA8);
+    bufferOptions.add(ImageBufferOptions::UseDisplayList);
+    return ImageBuffer::create(size, RenderingPurpose::Unspecified, resolutionScale, colorSpace, PixelFormat::BGRA8, bufferOptions);
 }
 
 RefPtr<ImageBuffer> GraphicsContext::createScaledImageBuffer(const FloatSize& size, const FloatSize& scale, const DestinationColorSpace& colorSpace, std::optional<RenderingMode> renderingMode, std::optional<RenderingMethod> renderingMethod) const

Modified: trunk/Source/WebCore/platform/graphics/ImageBuffer.cpp (292468 => 292469)


--- trunk/Source/WebCore/platform/graphics/ImageBuffer.cpp	2022-04-06 15:20:50 UTC (rev 292468)
+++ trunk/Source/WebCore/platform/graphics/ImageBuffer.cpp	2022-04-06 15:22:41 UTC (rev 292469)
@@ -37,13 +37,13 @@
 static const float MaxClampedLength = 4096;
 static const float MaxClampedArea = MaxClampedLength * MaxClampedLength;
 
-RefPtr<ImageBuffer> ImageBuffer::create(const FloatSize& size, RenderingMode renderingMode, ShouldUseDisplayList shouldUseDisplayList, RenderingPurpose purpose, float resolutionScale, const DestinationColorSpace& colorSpace, PixelFormat pixelFormat, const CreationContext& creationContext)
+RefPtr<ImageBuffer> ImageBuffer::create(const FloatSize& size, RenderingPurpose purpose, float resolutionScale, const DestinationColorSpace& colorSpace, PixelFormat pixelFormat, OptionSet<ImageBufferOptions> options, const CreationContext& creationContext)
 {
     RefPtr<ImageBuffer> imageBuffer;
     
-    // Give ShouldUseDisplayList a higher precedence since it is a debug option.
-    if (shouldUseDisplayList == ShouldUseDisplayList::Yes) {
-        if (renderingMode == RenderingMode::Accelerated)
+    // Give UseDisplayList a higher precedence since it is a debug option.
+    if (options.contains(ImageBufferOptions::UseDisplayList)) {
+        if (options.contains(ImageBufferOptions::Accelerated))
             imageBuffer = DisplayListAcceleratedImageBuffer::create(size, resolutionScale, colorSpace, pixelFormat, creationContext);
         
         if (!imageBuffer)
@@ -50,20 +50,15 @@
             imageBuffer = DisplayListUnacceleratedImageBuffer::create(size, resolutionScale, colorSpace, pixelFormat, creationContext);
     }
     
-    if (creationContext.hostWindow && !imageBuffer)
+    if (creationContext.hostWindow && !imageBuffer) {
+        auto renderingMode = options.contains(ImageBufferOptions::Accelerated) ? RenderingMode::Accelerated : RenderingMode::Unaccelerated;
         imageBuffer = creationContext.hostWindow->createImageBuffer(size, renderingMode, purpose, resolutionScale, colorSpace, pixelFormat);
+    }
 
-    if (!imageBuffer)
-        imageBuffer = ImageBuffer::create(size, renderingMode, resolutionScale, colorSpace, pixelFormat, creationContext);
+    if (imageBuffer)
+        return imageBuffer;
 
-    return imageBuffer;
-}
-
-RefPtr<ImageBuffer> ImageBuffer::create(const FloatSize& size, RenderingMode renderingMode, float resolutionScale, const DestinationColorSpace& colorSpace, PixelFormat pixelFormat, const CreationContext& creationContext)
-{
-    RefPtr<ImageBuffer> imageBuffer;
-    
-    if (renderingMode == RenderingMode::Accelerated)
+    if (options.contains(ImageBufferOptions::Accelerated))
         imageBuffer = AcceleratedImageBuffer::create(size, resolutionScale, colorSpace, pixelFormat, creationContext);
     
     if (!imageBuffer)

Modified: trunk/Source/WebCore/platform/graphics/ImageBuffer.h (292468 => 292469)


--- trunk/Source/WebCore/platform/graphics/ImageBuffer.h	2022-04-06 15:20:50 UTC (rev 292468)
+++ trunk/Source/WebCore/platform/graphics/ImageBuffer.h	2022-04-06 15:22:41 UTC (rev 292469)
@@ -31,6 +31,7 @@
 #include "ImageBufferBackend.h"
 #include "RenderingMode.h"
 #include "RenderingResourceIdentifier.h"
+#include <wtf/OptionSet.h>
 #include <wtf/RefCounted.h>
 #include <wtf/WeakPtr.h>
 
@@ -42,6 +43,11 @@
 class IOSurfacePool;
 #endif
 
+enum class ImageBufferOptions : uint8_t {
+    Accelerated     = 1 << 0,
+    UseDisplayList  = 1 << 1
+};
+
 class ImageBuffer : public ThreadSafeRefCounted<ImageBuffer, WTF::DestructionThread::Main>, public CanMakeWeakPtr<ImageBuffer> {
 public:
     struct CreationContext {
@@ -63,8 +69,7 @@
     };
 
     // Will return a null pointer on allocation failure.
-    WEBCORE_EXPORT static RefPtr<ImageBuffer> create(const FloatSize&, RenderingMode, ShouldUseDisplayList, RenderingPurpose, float resolutionScale, const DestinationColorSpace&, PixelFormat, const CreationContext& = { });
-    WEBCORE_EXPORT static RefPtr<ImageBuffer> create(const FloatSize&, RenderingMode, float resolutionScale, const DestinationColorSpace&, PixelFormat, const CreationContext& = { });
+    WEBCORE_EXPORT static RefPtr<ImageBuffer> create(const FloatSize&, RenderingPurpose, float resolutionScale, const DestinationColorSpace&, PixelFormat, OptionSet<ImageBufferOptions> = { }, const CreationContext& = { });
 
     RefPtr<ImageBuffer> clone() const;
 
@@ -157,4 +162,11 @@
     virtual void drawConsuming(GraphicsContext&, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) = 0;
 };
 
+inline OptionSet<ImageBufferOptions> bufferOptionsForRendingMode(RenderingMode renderingMode)
+{
+    if (renderingMode == RenderingMode::Accelerated)
+        return { ImageBufferOptions::Accelerated };
+    return { };
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/RenderingMode.h (292468 => 292469)


--- trunk/Source/WebCore/platform/graphics/RenderingMode.h	2022-04-06 15:20:50 UTC (rev 292468)
+++ trunk/Source/WebCore/platform/graphics/RenderingMode.h	2022-04-06 15:22:41 UTC (rev 292469)
@@ -34,7 +34,6 @@
     MediaPainting
 };
 
-enum class ShouldUseDisplayList : bool { No, Yes };
 enum class RenderingMode : bool { Unaccelerated, Accelerated };
 enum class RenderingMethod : bool { Local, DisplayList };
 

Modified: trunk/Source/WebCore/platform/graphics/ShadowBlur.cpp (292468 => 292469)


--- trunk/Source/WebCore/platform/graphics/ShadowBlur.cpp	2022-04-06 15:20:50 UTC (rev 292468)
+++ trunk/Source/WebCore/platform/graphics/ShadowBlur.cpp	2022-04-06 15:22:41 UTC (rev 292469)
@@ -85,7 +85,7 @@
         clearScratchBuffer();
 
         // ShadowBlur is not used with accelerated drawing, so it's OK to make an unconditionally unaccelerated buffer.
-        m_imageBuffer = ImageBuffer::create(roundedSize, RenderingMode::Unaccelerated, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
+        m_imageBuffer = ImageBuffer::create(roundedSize, RenderingPurpose::Unspecified, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
         return m_imageBuffer;
     }
 
@@ -606,7 +606,7 @@
 
 void ShadowBlur::drawRectShadowWithoutTiling(const AffineTransform&, const FloatRoundedRect& shadowedRect, const LayerImageProperties& layerImageProperties, const DrawBufferCallback& drawBuffer)
 {
-    auto layerImage = ImageBuffer::create(expandedIntSize(layerImageProperties.layerSize), RenderingMode::Unaccelerated, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
+    auto layerImage = ImageBuffer::create(expandedIntSize(layerImageProperties.layerSize), RenderingPurpose::Unspecified, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
     if (!layerImage)
         return;
 
@@ -634,7 +634,7 @@
 
 void ShadowBlur::drawInsetShadowWithoutTiling(const AffineTransform&, const FloatRect& fullRect, const FloatRoundedRect& holeRect, const LayerImageProperties& layerImageProperties, const DrawBufferCallback& drawBuffer)
 {
-    auto layerImage = ImageBuffer::create(expandedIntSize(layerImageProperties.layerSize), RenderingMode::Unaccelerated, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
+    auto layerImage = ImageBuffer::create(expandedIntSize(layerImageProperties.layerSize), RenderingPurpose::Unspecified, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
     if (!layerImage)
         return;
 
@@ -710,7 +710,7 @@
     UNUSED_PARAM(layerImageProperties);
 #endif
 
-    if (auto layerImageBuffer = ImageBuffer::create(templateSize, RenderingMode::Unaccelerated, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8))
+    if (auto layerImageBuffer = ImageBuffer::create(templateSize, RenderingPurpose::Unspecified, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8))
         drawRectShadowWithTilingWithLayerImageBuffer(*layerImageBuffer, transform, shadowedRect, templateSize, edgeSize, drawImage, fillRect, templateShadow);
 }
 
@@ -764,7 +764,7 @@
     }
 #endif
 
-    if (auto layerImageBuffer = ImageBuffer::create(templateSize, RenderingMode::Unaccelerated, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8))
+    if (auto layerImageBuffer = ImageBuffer::create(templateSize, RenderingPurpose::Unspecified, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8))
         drawInsetShadowWithTilingWithLayerImageBuffer(*layerImageBuffer, transform, fullRect, holeRect, templateSize, edgeSize, drawImage, fillRectWithHole, templateBounds, templateHole);
 }
 
@@ -923,7 +923,7 @@
 
     adjustBlurRadius(transform);
 
-    auto layerImage = ImageBuffer::create(expandedIntSize(layerImageProperties->layerSize), RenderingMode::Unaccelerated, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
+    auto layerImage = ImageBuffer::create(expandedIntSize(layerImageProperties->layerSize), RenderingPurpose::Unspecified, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
     if (!layerImage)
         return;
 

Modified: trunk/Source/WebCore/platform/graphics/SourceImage.cpp (292468 => 292469)


--- trunk/Source/WebCore/platform/graphics/SourceImage.cpp	2022-04-06 15:20:50 UTC (rev 292468)
+++ trunk/Source/WebCore/platform/graphics/SourceImage.cpp	2022-04-06 15:22:41 UTC (rev 292469)
@@ -87,7 +87,7 @@
         auto nativeImage = std::get<Ref<NativeImage>>(m_imageVariant);
 
         auto rect = FloatRect { { }, nativeImage->size() };
-        auto imageBuffer = ImageBuffer::create(nativeImage->size(), RenderingMode::Unaccelerated, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
+        auto imageBuffer = ImageBuffer::create(nativeImage->size(), RenderingPurpose::Unspecified, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
         if (!imageBuffer)
             return nullptr;
 

Modified: trunk/Source/WebCore/platform/graphics/filters/FilterImage.cpp (292468 => 292469)


--- trunk/Source/WebCore/platform/graphics/filters/FilterImage.cpp	2022-04-06 15:20:50 UTC (rev 292468)
+++ trunk/Source/WebCore/platform/graphics/filters/FilterImage.cpp	2022-04-06 15:22:41 UTC (rev 292469)
@@ -99,7 +99,9 @@
     if (m_imageBuffer)
         return m_imageBuffer.get();
 
-    m_imageBuffer = ImageBuffer::create(m_absoluteImageRect.size(), m_renderingMode, 1, m_colorSpace, PixelFormat::BGRA8);
+    // FIXME: This needs to use a specific RenderingPurpose to avoid accelerated buffers in the WebContent process (webkit.org/b/238848).
+    // FIXME: Test
+    m_imageBuffer = ImageBuffer::create(m_absoluteImageRect.size(), RenderingPurpose::Unspecified, 1, m_colorSpace, PixelFormat::BGRA8, bufferOptionsForRendingMode(m_renderingMode));
     if (!m_imageBuffer)
         return nullptr;
 
@@ -170,7 +172,7 @@
 static std::optional<PixelBuffer> getConvertedPixelBuffer(ImageBuffer& imageBuffer, AlphaPremultiplication alphaFormat, const IntRect& sourceRect, DestinationColorSpace colorSpace)
 {
     auto clampedSize = ImageBuffer::clampedSize(sourceRect.size());
-    auto convertedImageBuffer = ImageBuffer::create(clampedSize, RenderingMode::Unaccelerated, 1, colorSpace, PixelFormat::BGRA8);
+    auto convertedImageBuffer = ImageBuffer::create(clampedSize, RenderingPurpose::Unspecified, 1, colorSpace, PixelFormat::BGRA8);
     
     if (!convertedImageBuffer)
         return std::nullopt;
@@ -187,7 +189,7 @@
     auto clampedSize = ImageBuffer::clampedSize(sourceRect.size());
 
     auto& sourceColorSpace = sourcePixelBuffer.format().colorSpace;
-    auto imageBuffer = ImageBuffer::create(clampedSize, RenderingMode::Unaccelerated, 1, sourceColorSpace, PixelFormat::BGRA8);
+    auto imageBuffer = ImageBuffer::create(clampedSize, RenderingPurpose::Unspecified, 1, sourceColorSpace, PixelFormat::BGRA8);
     if (!imageBuffer)
         return std::nullopt;
 

Modified: trunk/Source/WebCore/platform/graphics/filters/software/FETileSoftwareApplier.cpp (292468 => 292469)


--- trunk/Source/WebCore/platform/graphics/filters/software/FETileSoftwareApplier.cpp	2022-04-06 15:20:50 UTC (rev 292468)
+++ trunk/Source/WebCore/platform/graphics/filters/software/FETileSoftwareApplier.cpp	2022-04-06 15:22:41 UTC (rev 292469)
@@ -49,7 +49,7 @@
     auto maxResultRect = result.maxEffectRect(filter);
     maxResultRect.scale(filter.filterScale());
 
-    auto tileImage = ImageBuffer::create(tileRect.size(), filter.renderingMode(), 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
+    auto tileImage = ImageBuffer::create(tileRect.size(), RenderingPurpose::Unspecified, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8, bufferOptionsForRendingMode(filter.renderingMode()));
     if (!tileImage)
         return false;
 

Modified: trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.cpp (292468 => 292469)


--- trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.cpp	2022-04-06 15:20:50 UTC (rev 292468)
+++ trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.cpp	2022-04-06 15:22:41 UTC (rev 292469)
@@ -73,7 +73,7 @@
 #endif
 
     // Fallback path, read back texture to main memory
-    RefPtr<WebCore::ImageBuffer> imageBuffer = ImageBuffer::create(size, RenderingMode::Unaccelerated, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
+    RefPtr<WebCore::ImageBuffer> imageBuffer = ImageBuffer::create(size, RenderingPurpose::Unspecified, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
     if (!imageBuffer)
         return;
     m_context.paintRenderingResultsToCanvas(*imageBuffer.get());

Modified: trunk/Source/WebCore/platform/graphics/texmap/BitmapTexture.cpp (292468 => 292469)


--- trunk/Source/WebCore/platform/graphics/texmap/BitmapTexture.cpp	2022-04-06 15:20:50 UTC (rev 292468)
+++ trunk/Source/WebCore/platform/graphics/texmap/BitmapTexture.cpp	2022-04-06 15:22:41 UTC (rev 292469)
@@ -38,7 +38,7 @@
 {
     // Making an unconditionally unaccelerated buffer here is OK because this code
     // isn't used by any platforms that respect the accelerated bit.
-    auto imageBuffer = ImageBuffer::create(targetRect.size(), RenderingMode::Unaccelerated, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
+    auto imageBuffer = ImageBuffer::create(targetRect.size(), RenderingPurpose::Unspecified, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
     if (!imageBuffer)
         return;
 

Modified: trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp (292468 => 292469)


--- trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp	2022-04-06 15:20:50 UTC (rev 292468)
+++ trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp	2022-04-06 15:22:41 UTC (rev 292469)
@@ -473,7 +473,7 @@
     if (m_imageBuffer)
         return m_imageBuffer.get();
 
-    m_imageBuffer = ImageBuffer::create(captureSize(), RenderingMode::Unaccelerated, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
+    m_imageBuffer = ImageBuffer::create(captureSize(), RenderingPurpose::Unspecified, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
     if (!m_imageBuffer)
         return nullptr;
 

Modified: trunk/Source/WebCore/rendering/shapes/Shape.cpp (292468 => 292469)


--- trunk/Source/WebCore/rendering/shapes/Shape.cpp	2022-04-06 15:20:50 UTC (rev 292468)
+++ trunk/Source/WebCore/rendering/shapes/Shape.cpp	2022-04-06 15:22:41 UTC (rev 292469)
@@ -181,7 +181,7 @@
     IntRect marginRect = snappedIntRect(marginR);
     auto intervals = makeUnique<RasterShapeIntervals>(marginRect.height(), -marginRect.y());
     // FIXME (149420): This buffer should not be unconditionally unaccelerated.
-    auto imageBuffer = ImageBuffer::create(imageRect.size(), RenderingMode::Unaccelerated, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
+    auto imageBuffer = ImageBuffer::create(imageRect.size(), RenderingPurpose::Unspecified, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
 
     auto createShape = [&]() {
         auto rasterShape = makeUnique<RasterShape>(WTFMove(intervals), marginRect.size());

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGResourceClipper.cpp (292468 => 292469)


--- trunk/Source/WebCore/rendering/svg/RenderSVGResourceClipper.cpp	2022-04-06 15:20:50 UTC (rev 292468)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGResourceClipper.cpp	2022-04-06 15:22:41 UTC (rev 292469)
@@ -162,7 +162,7 @@
 
     if (!clipperData.isValidForGeometry(objectBoundingBox, clippedContentBounds, absoluteTransform)) {
         // FIXME (149469): This image buffer should not be unconditionally unaccelerated. Making it match the context breaks nested clipping, though.
-        auto maskImage = context.createScaledImageBuffer(clippedContentBounds, scale, DestinationColorSpace::SRGB(), RenderingMode::Unaccelerated);
+        auto maskImage = context.createScaledImageBuffer(clippedContentBounds, scale, DestinationColorSpace::SRGB(), RenderingMode::Unaccelerated); // FIXME
         if (!maskImage)
             return false;
 

Modified: trunk/Source/WebCore/svg/SVGFEImageElement.cpp (292468 => 292469)


--- trunk/Source/WebCore/svg/SVGFEImageElement.cpp	2022-04-06 15:20:50 UTC (rev 292468)
+++ trunk/Source/WebCore/svg/SVGFEImageElement.cpp	2022-04-06 15:22:41 UTC (rev 292469)
@@ -199,8 +199,7 @@
         return nullptr;
 
     auto clampingScale = clampingScaleForImageBufferSize(scaledRect.size());
-
-    auto imageBuffer = ImageBuffer::create(scaledRect.size() * clampingScale, RenderingMode::Unaccelerated, ShouldUseDisplayList::No, RenderingPurpose::DOM, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8, hostWindow);
+    auto imageBuffer = ImageBuffer::create(scaledRect.size() * clampingScale, RenderingPurpose::DOM, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8, { }, { hostWindow });
     if (!imageBuffer)
         return nullptr;
 

Modified: trunk/Source/WebCore/svg/graphics/SVGImage.cpp (292468 => 292469)


--- trunk/Source/WebCore/svg/graphics/SVGImage.cpp	2022-04-06 15:20:50 UTC (rev 292468)
+++ trunk/Source/WebCore/svg/graphics/SVGImage.cpp	2022-04-06 15:22:41 UTC (rev 292469)
@@ -203,14 +203,15 @@
     if (!m_page)
         return nullptr;
 
-    bool acceleratedDrawingEnabled = m_page->settings().acceleratedDrawingEnabled();
-    auto renderingMode = acceleratedDrawingEnabled ? RenderingMode::Accelerated : RenderingMode::Unaccelerated;
+    OptionSet<ImageBufferOptions> bufferOptions;
+    if (m_page->settings().acceleratedDrawingEnabled())
+        bufferOptions.add(ImageBufferOptions::Accelerated);
 
     HostWindow* hostWindow = nullptr;
     if (auto contentRenderer = embeddedContentBox())
         hostWindow = contentRenderer->hostWindow();
 
-    auto imageBuffer = ImageBuffer::create(size(), renderingMode, ShouldUseDisplayList::No, RenderingPurpose::DOM, 1, colorSpace, PixelFormat::BGRA8, hostWindow);
+    auto imageBuffer = ImageBuffer::create(size(), RenderingPurpose::DOM, 1, colorSpace, PixelFormat::BGRA8, bufferOptions, { hostWindow });
     if (!imageBuffer)
         return nullptr;
 

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (292468 => 292469)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2022-04-06 15:20:50 UTC (rev 292468)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2022-04-06 15:22:41 UTC (rev 292469)
@@ -1,3 +1,21 @@
+2022-04-06  Simon Fraser  <simon.fra...@apple.com>
+
+        Unify the two ImageBuffer::create() functions, passing RenderingPurpose everywhere
+        https://bugs.webkit.org/show_bug.cgi?id=238851
+
+        Reviewed by Said Abou-Hallawa.
+
+        I need to extend RenderingPurpose flags to distinguish layer backing store buffers from
+        other kinds of buffers. Before doing so, collapse the two ImageBuffer::create() functions
+        together by combining RenderingMode and ShouldUseDisplayList into OptionSet<ImageBufferOptions>,
+        and passing RenderingPurpose everywhere.
+        
+        Always passing RenderingPurpose is revealing, because it finds call sites in the
+        web process that can trigger accelerated buffers (e.g. webkit.org/b/238846).
+
+        * WebCoreSupport/WebContextMenuClient.mm:
+        (WebContextMenuClient::imageForCurrentSharingServicePickerItem):
+
 2022-04-05  Chris Dumez  <cdu...@apple.com>
 
         Mark String(const char*) constructor as explicit

Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebContextMenuClient.mm (292468 => 292469)


--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebContextMenuClient.mm	2022-04-06 15:20:50 UTC (rev 292468)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebContextMenuClient.mm	2022-04-06 15:22:41 UTC (rev 292469)
@@ -214,7 +214,7 @@
         return nil;
 
     // This is effectively a snapshot, and will be painted in an unaccelerated fashion in line with FrameSnapshotting.
-    auto buffer = ImageBuffer::create(rect.size(), RenderingMode::Unaccelerated, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
+    auto buffer = ImageBuffer::create(rect.size(), RenderingPurpose::Unspecified, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8);
     if (!buffer)
         return nil;
 

Modified: trunk/Tools/ChangeLog (292468 => 292469)


--- trunk/Tools/ChangeLog	2022-04-06 15:20:50 UTC (rev 292468)
+++ trunk/Tools/ChangeLog	2022-04-06 15:22:41 UTC (rev 292469)
@@ -1,3 +1,23 @@
+2022-04-06  Simon Fraser  <simon.fra...@apple.com>
+
+        Unify the two ImageBuffer::create() functions, passing RenderingPurpose everywhere
+        https://bugs.webkit.org/show_bug.cgi?id=238851
+
+        Reviewed by Said Abou-Hallawa.
+
+        I need to extend RenderingPurpose flags to distinguish layer backing store buffers from
+        other kinds of buffers. Before doing so, collapse the two ImageBuffer::create() functions
+        together by combining RenderingMode and ShouldUseDisplayList into OptionSet<ImageBufferOptions>,
+        and passing RenderingPurpose everywhere.
+        
+        Always passing RenderingPurpose is revealing, because it finds call sites in the
+        web process that can trigger accelerated buffers (e.g. webkit.org/b/238846).
+
+        * TestWebKitAPI/Tests/WebCore/ImageBufferTests.cpp:
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/Tests/WebCore/cg/DisplayListTestsCG.cpp:
+        (TestWebKitAPI::TEST):
+
 2022-04-06  Youenn Fablet  <you...@apple.com>
 
         In case of COOP-based process swap, we need to make sure the document gets controlled by its matching service worker registration

Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/ImageBufferTests.cpp (292468 => 292469)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/ImageBufferTests.cpp	2022-04-06 15:20:50 UTC (rev 292468)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/ImageBufferTests.cpp	2022-04-06 15:22:41 UTC (rev 292469)
@@ -55,10 +55,10 @@
     auto pixelFormat = PixelFormat::BGRA8;
     FloatSize size { 1.f, 1.f };
     float scale = 1.f;
-    RefPtr<ImageBuffer> unaccelerated = ImageBuffer::create(size, RenderingMode::Unaccelerated, scale, colorSpace, pixelFormat, nullptr);
-    RefPtr<ImageBuffer> accelerated = ImageBuffer::create(size, RenderingMode::Accelerated, scale, colorSpace, pixelFormat, nullptr);
-    RefPtr<ImageBuffer> displayListAccelerated = ImageBuffer::create(size, RenderingMode::Unaccelerated, ShouldUseDisplayList::Yes, RenderingPurpose::Unspecified, scale, colorSpace, pixelFormat, nullptr);
-    RefPtr<ImageBuffer> displayListUnaccelerated = ImageBuffer::create(size, RenderingMode::Accelerated, ShouldUseDisplayList::Yes, RenderingPurpose::Unspecified, scale, colorSpace, pixelFormat, nullptr);
+    RefPtr<ImageBuffer> unaccelerated = ImageBuffer::create(size, RenderingPurpose::Unspecified, scale, colorSpace, pixelFormat);
+    RefPtr<ImageBuffer> accelerated = ImageBuffer::create(size, RenderingPurpose::Unspecified, scale, colorSpace, pixelFormat, { ImageBufferOptions::Accelerated });
+    RefPtr<ImageBuffer> displayListAccelerated = ImageBuffer::create(size, RenderingPurpose::Unspecified, scale, colorSpace, pixelFormat, { ImageBufferOptions::UseDisplayList });
+    RefPtr<ImageBuffer> displayListUnaccelerated = ImageBuffer::create(size, RenderingPurpose::Unspecified, scale, colorSpace, pixelFormat, { ImageBufferOptions::Accelerated, ImageBufferOptions::UseDisplayList });
 
     EXPECT_NE(nullptr, accelerated);
     EXPECT_NE(nullptr, unaccelerated);
@@ -72,8 +72,8 @@
     auto pixelFormat = PixelFormat::BGRA8;
     FloatSize logicalSize { 392, 44 };
     float scale = 1.91326535;
-    auto frontImageBuffer = ImageBuffer::create(logicalSize, RenderingMode::Accelerated, scale, colorSpace, pixelFormat, nullptr);
-    auto backImageBuffer = ImageBuffer::create(logicalSize, RenderingMode::Accelerated, scale, colorSpace, pixelFormat, nullptr);
+    auto frontImageBuffer = ImageBuffer::create(logicalSize, RenderingPurpose::Unspecified, scale, colorSpace, pixelFormat, { ImageBufferOptions::Accelerated });
+    auto backImageBuffer = ImageBuffer::create(logicalSize, RenderingPurpose::Unspecified, scale, colorSpace, pixelFormat, { ImageBufferOptions::Accelerated });
     
     auto strokeRect = FloatRect { { }, logicalSize };
     strokeRect.inflate(-0.5);
@@ -131,7 +131,7 @@
 
     {
         // Make potential accelerated drawing backend instantiate roughly the global structures needed for this test.
-        auto accelerated = ImageBuffer::create(logicalSize, RenderingMode::Accelerated, scale, colorSpace, pixelFormat, nullptr);
+        auto accelerated = ImageBuffer::create(logicalSize, RenderingPurpose::Unspecified, scale, colorSpace, pixelFormat, { ImageBufferOptions::Accelerated });
         auto fillRect = FloatRect { { }, logicalSize };
         accelerated->context().fillRect(fillRect, Color::green);
         EXPECT_TRUE(imageBufferPixelIs(Color::green, *accelerated, fillRect.maxX() - 1, fillRect.maxY() - 1));
@@ -141,13 +141,13 @@
     auto lastFootprint = initialFootprint;
     EXPECT_GT(lastFootprint, 0u);
 
-    auto accelerated = ImageBuffer::create(logicalSize, RenderingMode::Accelerated, scale, colorSpace, pixelFormat, nullptr);
+    auto accelerated = ImageBuffer::create(logicalSize, RenderingPurpose::Unspecified, scale, colorSpace, pixelFormat, { ImageBufferOptions::Accelerated });
     auto fillRect = FloatRect { { }, logicalSize };
     accelerated->context().fillRect(fillRect, Color::green);
     accelerated->flushContext();
     EXPECT_TRUE(memoryFootprintChangedBy(lastFootprint, logicalSizeBytes, footprintError));
 
-    auto unaccelerated = ImageBuffer::create(logicalSize, RenderingMode::Unaccelerated, scale, colorSpace, pixelFormat, nullptr);
+    auto unaccelerated = ImageBuffer::create(logicalSize, RenderingPurpose::Unspecified, scale, colorSpace, pixelFormat);
     unaccelerated->context().fillRect(fillRect, Color::yellow);
     EXPECT_TRUE(imageBufferPixelIs(Color::yellow, *unaccelerated, fillRect.maxX() - 1, fillRect.maxY() - 1));
     EXPECT_TRUE(memoryFootprintChangedBy(lastFootprint, logicalSizeBytes, footprintError));

Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/cg/DisplayListTestsCG.cpp (292468 => 292469)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/cg/DisplayListTestsCG.cpp	2022-04-06 15:20:50 UTC (rev 292468)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/cg/DisplayListTestsCG.cpp	2022-04-06 15:22:41 UTC (rev 292469)
@@ -73,7 +73,7 @@
     }
 
     {
-        auto imageBuffer = ImageBuffer::create({ 100, 100 }, RenderingMode::Unaccelerated, 1, colorSpace, PixelFormat::BGRA8);
+        auto imageBuffer = ImageBuffer::create({ 100, 100 }, RenderingPurpose::Unspecified, 1, colorSpace, PixelFormat::BGRA8);
         LocalResourceHeap resourceHeap;
         resourceHeap.add(imageBufferIdentifier, imageBuffer.releaseNonNull());
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to