haikuwebkit/Source/WebCore/platform/wpe
Sam Weinig 8827b78b01 Convert DestinationColorSpace from an enum to class wrapping a platform color space (CGColorSpaceRef for CG ports, etc.)
https://bugs.webkit.org/show_bug.cgi?id=226143

Reviewed by Darin Adler.

Source/WebCore:

Replace enumeration based DestinationColorSpace with a struct wrapping
a platform color space (CGColorSpaceRef for CG ports, etc.). For ports
that don't have a platform level color space type, a builtin PlatformColorSpace
type is provided that is just the old enum renamed to PlatformColorSpace::Name.

The goal of this change is to unify the currently bifurcated concept of an
ImageBuffer's color space, which previosly could either be based on the
DestinationColorSpace (and reflected in the colorSpace() member function),
or (for CG ports) based on a CGColorSpaceRef, with the colorSpace() function
returning sRGB even if the ImageBuffer was not.

* Headers.cmake:
* Modules/async-clipboard/ClipboardItemBindingsDataSource.cpp:
(WebCore::ClipboardItemBindingsDataSource::ClipboardItemTypeLoader::sanitizeDataIfNeeded):
* Modules/mediasession/MediaMetadata.cpp:
(WebCore::ArtworkImageLoader::notifyFinished):
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/SerializedScriptValue.cpp:
(WebCore::CloneSerializer::dumpImageBitmap):
(WebCore::CloneDeserializer::readImageBitmap):
* css/CSSFilterImageValue.cpp:
(WebCore::CSSFilterImageValue::image):
* html/CustomPaintCanvas.cpp:
(WebCore::CustomPaintCanvas::copiedImage const):
* html/CustomPaintImage.cpp:
(WebCore::CustomPaintImage::drawPattern):
* html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::toMediaSample):
(WebCore::HTMLCanvasElement::createImageBuffer const):
* html/HTMLVideoElement.cpp:
(WebCore::HTMLVideoElement::createBufferForPainting const):
* html/HTMLVideoElement.h:
* html/ImageBitmap.cpp:
(WebCore::ImageBitmap::createImageBuffer):
(WebCore::ImageBitmap::createPromise):
* html/OffscreenCanvas.cpp:
(WebCore::OffscreenCanvas::commitToPlaceholderCanvas):
* html/canvas/CanvasRenderingContext.cpp:
(WebCore::CanvasRenderingContext::colorSpace const):
* html/canvas/CanvasRenderingContext.h:
* html/canvas/CanvasRenderingContext2D.cpp:
* html/canvas/ImageBitmapRenderingContext.cpp:
(WebCore::ImageBitmapRenderingContext::setOutputBitmap):
* html/canvas/PredefinedColorSpace.cpp:
(WebCore::toDestinationColorSpace):
(WebCore::toPredefinedColorSpace):
* html/canvas/PredefinedColorSpace.h:
* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::LRUImageBufferCache::imageBuffer):
* html/shadow/MediaControlTextTrackContainerElement.cpp:
(WebCore::MediaControlTextTrackContainerElement::createTextTrackRepresentationImage):
* inspector/InspectorCanvas.cpp:
(WebCore::InspectorCanvas::indexForData):
(WebCore::InspectorCanvas::buildArrayForCanvasPattern):
* page/Chrome.cpp:
(WebCore::Chrome::createImageBuffer const):
* page/Chrome.h:
* page/ChromeClient.h:
(WebCore::ChromeClient::createImageBuffer const):
* page/FrameSnapshotting.cpp:
(WebCore::snapshotFrameRectWithClip):
* page/PageColorSampler.cpp:
(WebCore::sampleColor):
* page/PageConsoleClient.cpp:
(WebCore::PageConsoleClient::screenshot):
* platform/HostWindow.h:
* platform/PlatformColorSpace.h: Added.
(WebCore::PlatformColorSpace::get const):
* platform/PlatformScreen.h:
* platform/ScreenProperties.h:
(WebCore::ScreenProperties::encode const):
(WebCore::ScreenData::encode const):
(WebCore::ScreenData::decode):
* platform/graphics/BitmapImage.cpp:
(WebCore::BitmapImage::preTransformedNativeImageForCurrentFrame):
(WebCore::BitmapImage::drawPattern):
* platform/graphics/Color.cpp:
(WebCore::Color::toColorComponentsInColorSpace const):
* platform/graphics/Color.h:
* platform/graphics/ColorConversion.cpp:
(WebCore::converColorComponents):
* platform/graphics/ColorConversion.h:
* platform/graphics/ColorSpace.cpp:
* platform/graphics/ColorSpace.h:
* platform/graphics/ConcreteImageBuffer.h:
(WebCore::ConcreteImageBuffer::create):
* platform/graphics/CrossfadeGeneratedImage.cpp:
(WebCore::CrossfadeGeneratedImage::drawPattern):
* platform/graphics/DestinationColorSpace.cpp: Added.
(WebCore::DestinationColorSpace::SRGB):
(WebCore::DestinationColorSpace::LinearSRGB):
(WebCore::DestinationColorSpace::DisplayP3):
(WebCore::DestinationColorSpace::DestinationColorSpace):
(WebCore::operator==):
(WebCore::operator!=):
(WebCore::operator<<):
* platform/graphics/DestinationColorSpace.h: Added.
(WebCore::DestinationColorSpace::platformColorSpace const):
(WebCore::DestinationColorSpace::encode const):
(WebCore::DestinationColorSpace::decode):
* platform/graphics/GradientImage.cpp:
(WebCore::GradientImage::drawPattern):
* platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::clipToDrawingCommands):
* platform/graphics/GraphicsContext.h:
* platform/graphics/GraphicsContextImpl.h:
* platform/graphics/ImageBuffer.cpp:
(WebCore::ImageBuffer::create):
(WebCore::ImageBuffer::createCompatibleBuffer):
(WebCore::ImageBuffer::copyRectToBuffer):
* platform/graphics/ImageBuffer.h:
* platform/graphics/ImageBufferBackend.cpp:
(WebCore::ImageBufferBackend::getPixelBuffer const):
(WebCore::ImageBufferBackend::putPixelBuffer):
* platform/graphics/ImageBufferBackend.h:
(WebCore::ImageBufferBackend::transformColorSpace):
(WebCore::ImageBufferBackend::colorSpace const):
* platform/graphics/PixelBuffer.h:
(WebCore::PixelBuffer::decode):
* platform/graphics/PixelBufferConversion.cpp:
(WebCore::makeVImageCGImageFormat):
* platform/graphics/PixelBufferFormat.h:
(WebCore::PixelBufferFormat::decode):
* platform/graphics/RemoteVideoSample.cpp:
(WebCore::transferBGRAPixelBufferToIOSurface):
(WebCore::RemoteVideoSample::create):
(WebCore::RemoteVideoSample::RemoteVideoSample):
(WebCore::RemoteVideoSample::surface const):
* platform/graphics/RemoteVideoSample.h:
* platform/graphics/ShadowBlur.cpp:
(WebCore::ScratchBuffer::getScratchBuffer):
(WebCore::ShadowBlur::drawRectShadowWithoutTiling):
(WebCore::ShadowBlur::drawInsetShadowWithoutTiling):
(WebCore::ShadowBlur::drawRectShadowWithTiling):
(WebCore::ShadowBlur::drawInsetShadowWithTiling):
(WebCore::ShadowBlur::blurShadowBuffer):
(WebCore::ShadowBlur::drawShadowLayer):
* platform/graphics/angle/GraphicsContextGLANGLE.cpp:
(WebCore::GraphicsContextGLOpenGL::readPixelsForPaintResults):
* platform/graphics/cairo/ImageBufferCairoBackend.cpp:
(WebCore::ImageBufferCairoBackend::transformColorSpace):
* platform/graphics/cairo/ImageBufferCairoBackend.h:
* platform/graphics/cg/ColorCG.cpp:
(WebCore::convertToCGCompatibleComponents):
(WebCore::createCGColor):
(WebCore::platformConvertColorComponents):
* platform/graphics/cg/ColorSpaceCG.h:
(WebCore::cachedCGColorSpace): Deleted.
* platform/graphics/cg/GraphicsContextGLCG.cpp:
(WebCore::GraphicsContextGLOpenGL::paintToCanvas):
* platform/graphics/cg/IOSurfacePool.cpp:
(WebCore::surfaceMatchesParameters):
(WebCore::IOSurfacePool::takeSurface):
* platform/graphics/cg/IOSurfacePool.h:
* platform/graphics/cg/ImageBufferCGBackend.cpp:
(WebCore::createBitmapImageAfterScalingIfNeeded):
(WebCore::ImageBufferCGBackend::copyCGImageForEncoding const):
* platform/graphics/cg/ImageBufferCGBitmapBackend.cpp:
(WebCore::ImageBufferCGBitmapBackend::create):
(WebCore::ImageBufferCGBitmapBackend::copyNativeImage const):
* platform/graphics/cg/ImageBufferCGBitmapBackend.h:
* platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp:
(WebCore::ImageBufferIOSurfaceBackend::create):
* platform/graphics/cg/ImageBufferIOSurfaceBackend.h:
* platform/graphics/cg/ImageBufferUtilitiesCG.cpp:
(WebCore::encode):
* platform/graphics/cg/NativeImageCG.cpp:
(WebCore::NativeImage::singlePixelSolidColor const):
* platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm:
(WebCore::GraphicsContextGLOpenGL::allocateAndBindDisplayBufferBacking):
* platform/graphics/cocoa/IOSurface.h:
* platform/graphics/cocoa/IOSurface.mm:
(WebCore::IOSurface::surfaceFromPool):
(WebCore::IOSurface::create):
(WebCore::IOSurface::createFromSendRight):
(WebCore::IOSurface::createFromSurface):
(WebCore::IOSurface::createFromImage):
(WebCore::IOSurface::createFromPixelBuffer):
(WebCore::IOSurface::IOSurface):
(WebCore::IOSurface::ensurePlatformContext):
(WebCore::IOSurface::migrateColorSpaceToProperties):
* platform/graphics/coreimage/FilterEffectRendererCoreImage.mm:
(WebCore::FilterEffectRendererCoreImage::renderToImageBuffer):
* platform/graphics/cv/ImageTransferSessionVT.mm:
(WebCore::ImageTransferSessionVT::createPixelBuffer):
* platform/graphics/cv/PixelBufferConformerCV.cpp:
(WebCore::PixelBufferConformerCV::createImageFromPixelBuffer):
* platform/graphics/displaylists/DisplayListImageBuffer.h:
(WebCore::DisplayList::ImageBuffer::create):
* platform/graphics/displaylists/DisplayListItemBuffer.cpp:
(WebCore::DisplayList::ItemHandle::destroy):
* platform/graphics/displaylists/DisplayListItems.h:
(WebCore::DisplayList::BeginClipToDrawingCommands::BeginClipToDrawingCommands):
(WebCore::DisplayList::BeginClipToDrawingCommands::colorSpace const):
(WebCore::DisplayList::BeginClipToDrawingCommands::encode const):
(WebCore::DisplayList::BeginClipToDrawingCommands::decode):
(WebCore::DisplayList::GetPixelBuffer::GetPixelBuffer):
(WebCore::DisplayList::GetPixelBuffer::outputFormat const):
(WebCore::DisplayList::GetPixelBuffer::encode const):
(WebCore::DisplayList::GetPixelBuffer::decode):
* platform/graphics/displaylists/DisplayListRecorder.cpp:
(WebCore::DisplayList::Recorder::clipToDrawingCommands):
* platform/graphics/displaylists/DisplayListRecorder.h:
* platform/graphics/filters/FEDisplacementMap.cpp:
(WebCore::FEDisplacementMap::setResultColorSpace):
* platform/graphics/filters/FEDisplacementMap.h:
* platform/graphics/filters/FEFlood.h:
* platform/graphics/filters/FETile.cpp:
(WebCore::FETile::platformApplySoftware):
* platform/graphics/filters/FilterEffect.cpp:
(WebCore::FilterEffect::convertPixelBufferToColorSpace):
(WebCore::FilterEffect::convertImageBufferToColorSpace):
(WebCore::FilterEffect::copyConvertedImageBufferToDestination):
(WebCore::FilterEffect::copyConvertedPixelBufferToDestination):
(WebCore::FilterEffect::requiresPixelBufferColorSpaceConversion):
(WebCore::FilterEffect::transformResultColorSpace):
* platform/graphics/filters/FilterEffect.h:
(WebCore::FilterEffect::operatingColorSpace const):
(WebCore::FilterEffect::setOperatingColorSpace):
(WebCore::FilterEffect::resultColorSpace const):
(WebCore::FilterEffect::setResultColorSpace):
* platform/graphics/filters/SourceGraphic.h:
(WebCore::SourceGraphic::SourceGraphic):
* platform/gtk/PlatformScreenGtk.cpp:
(WebCore::screenColorSpace):
* platform/ios/PlatformScreenIOS.mm:
(WebCore::screenColorSpace):
(WebCore::collectScreenProperties):
* platform/mac/PlatformScreenMac.mm:
(WebCore::collectScreenProperties):
(WebCore::screenColorSpace):
* platform/mac/ThemeMac.mm:
(WebCore::ThemeMac::drawCellOrFocusRingWithViewIntoContext):
* platform/mediastream/mac/ScreenDisplayCapturerMac.mm:
(WebCore::ScreenDisplayCapturerMac::createDisplayStream):
* platform/mock/MockRealtimeVideoSource.cpp:
(WebCore::MockRealtimeVideoSource::imageBuffer const):
* platform/playstation/PlatformScreenPlayStation.cpp:
(WebCore::screenColorSpace):
* platform/win/PlatformScreenWin.cpp:
(WebCore::screenColorSpace):
* platform/wpe/PlatformScreenWPE.cpp:
(WebCore::screenColorSpace):
* platform/xr/PlatformXR.h:
(PlatformXR::Device::FrameData::LayerData::decode):
* rendering/CSSFilter.cpp:
(WebCore::CSSFilter::buildReferenceFilter):
(WebCore::CSSFilter::build):
(WebCore::CSSFilter::allocateBackingStoreIfNeeded):
(WebCore::CSSFilter::apply):
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::paintFillLayerExtended):
* rendering/RenderLayerBacking.cpp:
(WebCore::patternForDescription):
* rendering/RenderThemeIOS.mm:
(WebCore::RenderThemeIOS::paintSystemPreviewBadge):
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::paintProgressBar):
* rendering/shapes/Shape.cpp:
(WebCore::Shape::createRasterShape):
* rendering/svg/RenderSVGResourceClipper.cpp:
(WebCore::RenderSVGResourceClipper::applyClippingToContext):
* rendering/svg/RenderSVGResourceFilter.cpp:
(WebCore::RenderSVGResourceFilter::buildPrimitives const):
(WebCore::RenderSVGResourceFilter::applyResource):
(WebCore::RenderSVGResourceFilter::postApplyResource):
* rendering/svg/RenderSVGResourceGradient.cpp:
(WebCore::createMaskAndSwapContextForTextGradient):
* rendering/svg/RenderSVGResourceMasker.cpp:
(WebCore::RenderSVGResourceMasker::applyResource):
(WebCore::RenderSVGResourceMasker::drawContentIntoMaskImage):
* rendering/svg/RenderSVGResourceMasker.h:
* rendering/svg/RenderSVGResourcePattern.cpp:
(WebCore::RenderSVGResourcePattern::createTileImage const):
* rendering/svg/SVGRenderingContext.cpp:
(WebCore::SVGRenderingContext::createImageBuffer):
(WebCore::SVGRenderingContext::bufferForeground):
* rendering/svg/SVGRenderingContext.h:
* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::nativeImage):
(WebCore::SVGImage::drawPatternForContainer):
* svg/graphics/filters/SVGFEImage.cpp:
(WebCore::FEImage::platformApplySoftware):

Source/WebCore/PAL:

* pal/spi/cg/CoreGraphicsSPI.h:
Add addional SPI for working with CGColorSpaceRefs.

Source/WebKit:

- Update ImageBuffer subclass signatures to use "const DestinationColorSpace&" to
  conform to the base class.
- Replace ColorSpaceData with Optional<DestinationColorSpace>. No reason to have two
  types that are the same.
- Give all ports a color space configuration for ShareableBitmap now that there is
  a common class for representing color space.
- Update DisplayList decoding to account for BeginClipToDrawingCommands and GetPixelBuffer
  no longer being inlineable due to now having non-trivial destructors due to
  DestinationColorSpace member.

* GPUProcess/graphics/RemoteImageBuffer.h:
(WebKit::RemoteImageBuffer::create):
* GPUProcess/graphics/RemoteRenderingBackend.cpp:
(WebKit::RemoteRenderingBackend::createImageBuffer):
* GPUProcess/graphics/RemoteRenderingBackend.h:
* GPUProcess/media/RemoteImageDecoderAVFProxy.cpp:
(WebKit::RemoteImageDecoderAVFProxy::createFrameImageAtIndex):
* GPUProcess/media/RemoteImageDecoderAVFProxy.h:
* GPUProcess/media/RemoteImageDecoderAVFProxy.messages.in:
* Shared/RemoteLayerTree/RemoteLayerBackingStore.mm:
(WebKit::RemoteLayerBackingStore::swapToValidFrontBuffer):
(WebKit::RemoteLayerBackingStore::applyBackingStoreToLayer):
* Shared/ShareableBitmap.cpp:
(WebKit::ShareableBitmap::Configuration::encode const):
(WebKit::ShareableBitmap::Configuration::decode):
* Shared/ShareableBitmap.h:
* Shared/WebCoreArgumentCoders.h:
* Shared/WebPageCreationParameters.cpp:
(WebKit::WebPageCreationParameters::decode):
* Shared/WebPageCreationParameters.h:
* Shared/cg/ShareableBitmapCG.cpp:
(WebKit::colorSpace):
* Shared/mac/ColorSpaceData.h: Removed.
* Shared/mac/ColorSpaceData.mm: Removed.
* SourcesCocoa.txt:
* UIProcess/API/ios/WKWebViewIOS.mm:
(-[WKWebView _takeViewSnapshot]):
(-[WKWebView _snapshotRect:intoImageOfWidth:completionHandler:]):
* UIProcess/Cocoa/WebViewImpl.h:
* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::colorSpace):
* UIProcess/PageClient.h:
* UIProcess/RemoteLayerTree/RemoteLayerTreeHost.mm:
(WebKit::recursivelyMapIOSurfaceBackingStore):
* UIProcess/WebPageProxy.h:
* UIProcess/mac/PageClientImplMac.h:
* UIProcess/mac/PageClientImplMac.mm:
(WebKit::PageClientImpl::colorSpace):
* UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm:
* UIProcess/mac/WebPageProxyMac.mm:
(WebKit::WebPageProxy::colorSpace):
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.cpp:
(WebKit::ImageBufferShareableBitmapBackend::configuration):
* WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp:
(WebKit::RemoteGraphicsContextGLProxy::prepareForDisplay):
* WebProcess/GPU/graphics/RemoteImageBufferProxy.h:
(WebKit::RemoteImageBufferProxy::create):
* WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp:
(WebKit::RemoteRenderingBackendProxy::createImageBuffer):
* WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h:
* WebProcess/GPU/graphics/cocoa/ImageBufferShareableMappedIOSurfaceBackend.cpp:
(WebKit::ImageBufferShareableMappedIOSurfaceBackend::create):
* WebProcess/GPU/media/RemoteImageDecoderAVF.cpp:
(WebKit::RemoteImageDecoderAVF::createFrameImageAtIndex):
* WebProcess/GPU/media/cocoa/MediaPlayerPrivateRemoteCocoa.mm:
(WebKit::MediaPlayerPrivateRemote::nativeImageForCurrentTime):
(WebKit::MediaPlayerPrivateRemote::pixelBufferForCurrentTime):
* WebProcess/Plugins/PDF/PDFPlugin.mm:
(WebKit::PDFPlugin::PDFPlugin):
* WebProcess/WebCoreSupport/ShareableBitmapUtilities.cpp:
(WebKit::createShareableBitmap):
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::createImageBuffer const):
* WebProcess/WebCoreSupport/WebChromeClient.h:
* WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:
(WebKit::convertDragImageToBitmap):
* WebProcess/WebPage/DrawingArea.h:
(WebKit::DrawingArea::setColorSpace):
* WebProcess/WebPage/DrawingArea.messages.in:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::snapshotOptionsToBitmapConfiguration):
* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
(WebKit::TiledCoreAnimationDrawingArea::TiledCoreAnimationDrawingArea):
(WebKit::TiledCoreAnimationDrawingArea::setColorSpace):

Source/WebKitLegacy/mac:

* WebCoreSupport/WebContextMenuClient.mm:
(WebContextMenuClient::imageForCurrentSharingServicePickerItem):
Update for new DestinationColorSpace class.

Tools:

* TestWebKitAPI/Tests/WebCore/cg/DisplayListTestsCG.cpp:
(TestWebKitAPI::TEST):
Upate test to use new DestinationColorSpace type.


Canonical link: https://commits.webkit.org/238099@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277986 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-25 01:26:18 +00:00
..
PlatformScreenWPE.cpp Convert DestinationColorSpace from an enum to class wrapping a platform color space (CGColorSpaceRef for CG ports, etc.) 2021-05-25 01:26:18 +00:00