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-218427-20201101213819.patch (text/plain), 229.78 KB, created by
Said Abou-Hallawa
on 2020-11-01 21:38:21 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Said Abou-Hallawa
Created:
2020-11-01 21:38:21 PST
Size:
229.78 KB
patch
obsolete
>Subversion Revision: 269242 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 89398b11b1e0e98887fd92c6f9e72a08f2f1b8fa..a259a42fa27fe7f728f7748bfab70e901bb0d298 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,294 @@ >+2020-11-01 Said Abou-Hallawa <said@apple.com> >+ >+ [GPU Process] Control the life cycle of the platform image by a new class named NativeImage >+ https://bugs.webkit.org/show_bug.cgi?id=218427 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * Headers.cmake: >+ * Sources.txt: >+ * WebCore.xcodeproj/project.pbxproj: >+ * html/HTMLVideoElement.cpp: >+ (WebCore::HTMLVideoElement::nativeImageForCurrentTime): >+ * html/HTMLVideoElement.h: >+ * html/canvas/CanvasRenderingContext2DBase.cpp: >+ (WebCore::CanvasRenderingContext2DBase::drawImage): >+ * page/mac/TextIndicatorWindow.mm: >+ (-[WebTextIndicatorView initWithFrame:textIndicator:margin:offset:]): >+ (createContentCrossfadeAnimation): >+ * platform/graphics/BitmapImage.cpp: >+ (WebCore::BitmapImage::BitmapImage): >+ (WebCore::BitmapImage::frameImageAtIndexCacheIfNeeded): >+ (WebCore::BitmapImage::nativeImage): >+ (WebCore::BitmapImage::nativeImageForCurrentFrame): >+ (WebCore::BitmapImage::preTransformedNativeImageForCurrentFrame): >+ (WebCore::BitmapImage::nativeImageOfSize): >+ (WebCore::BitmapImage::framesNativeImages): >+ (WebCore::drawNativeImage): >+ (WebCore::BitmapImage::draw): >+ * platform/graphics/BitmapImage.h: >+ * platform/graphics/ConcreteImageBuffer.h: >+ * platform/graphics/GraphicsContext.cpp: >+ (WebCore::GraphicsContext::drawNativeImage): >+ * platform/graphics/GraphicsContext.h: >+ (WebCore::GraphicsContext::drawNativeImage): >+ (WebCore::GraphicsContext::drawPlatformImage): >+ * platform/graphics/GraphicsContextGLImageExtractor.h: >+ * platform/graphics/GraphicsContextImpl.h: >+ * platform/graphics/Icon.h: >+ * platform/graphics/Image.h: >+ (WebCore::Image::nativeImage): >+ (WebCore::Image::nativeImageForCurrentFrame): >+ (WebCore::Image::preTransformedNativeImageForCurrentFrame): >+ (WebCore::Image::nativeImageOfSize): >+ * platform/graphics/ImageBackingStore.h: >+ * platform/graphics/ImageBuffer.cpp: >+ (WebCore::ImageBuffer::sinkIntoNativeImage): >+ * platform/graphics/ImageBuffer.h: >+ * platform/graphics/ImageBufferBackend.cpp: >+ (WebCore::ImageBufferBackend::sinkIntoNativeImage): >+ * platform/graphics/ImageBufferBackend.h: >+ * platform/graphics/ImageDecoder.h: >+ * platform/graphics/ImageFrame.cpp: >+ (WebCore::ImageFrame::clearImage): >+ (WebCore::ImageFrame::singlePixelSolidColor const): >+ * platform/graphics/ImageFrame.h: >+ (WebCore::ImageFrame::nativeImage const): >+ * platform/graphics/ImageSource.cpp: >+ (WebCore::ImageSource::ImageSource): >+ (WebCore::ImageSource::setNativeImage): >+ (WebCore::ImageSource::cacheMetadataAtIndex): >+ (WebCore::ImageSource::cachePlatformImageAtIndex): >+ (WebCore::ImageSource::cachePlatformImageAtIndexAsync): >+ (WebCore::ImageSource::startAsyncDecodingQueue): >+ (WebCore::ImageSource::frameAtIndexCacheIfNeeded): >+ (WebCore::ImageSource::createFrameImageAtIndex): >+ (WebCore::ImageSource::frameImageAtIndex): >+ (WebCore::ImageSource::frameImageAtIndexCacheIfNeeded): >+ (WebCore::ImageSource::cacheNativeImageAtIndex): Deleted. >+ (WebCore::ImageSource::cacheNativeImageAtIndexAsync): Deleted. >+ * platform/graphics/ImageSource.h: >+ (WebCore::ImageSource::create): >+ * platform/graphics/MediaPlayer.cpp: >+ (WebCore::MediaPlayer::nativeImageForCurrentTime): >+ * platform/graphics/MediaPlayer.h: >+ * platform/graphics/MediaPlayerPrivate.h: >+ (WebCore::MediaPlayerPrivateInterface::nativeImageForCurrentTime): >+ * platform/graphics/NativeImage.cpp: Copied from Source/WebCore/platform/graphics/NativeImagePtr.h. >+ (WebCore::NativeImage::create): >+ (WebCore::NativeImage::NativeImage): >+ (WebCore::NativeImage::~NativeImage): >+ * platform/graphics/NativeImage.h: >+ (WebCore::NativeImage::renderingResourceIdentifier const): >+ (WebCore::NativeImage::isNull const): >+ (WebCore::NativeImage::platformImage): >+ (WebCore::NativeImage::platformImage const): >+ (WebCore::NativeImage::size const): >+ (WebCore::NativeImage::setObserver): >+ * platform/graphics/PlatformImagePtr.h: Renamed from Source/WebCore/platform/graphics/NativeImagePtr.h. >+ * platform/graphics/VideoLayerManager.h: >+ * platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.h: >+ * platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.mm: >+ (WebCore::ImageDecoderAVFObjC::createFrameImageAtIndex): >+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h: >+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: >+ (WebCore::MediaPlayerPrivateAVFoundationObjC::updateVideoFullscreenInlineImage): >+ (WebCore::MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenLayer): >+ (WebCore::MediaPlayerPrivateAVFoundationObjC::updateLastImage): >+ (WebCore::MediaPlayerPrivateAVFoundationObjC::paintWithVideoOutput): >+ (WebCore::MediaPlayerPrivateAVFoundationObjC::nativeImageForCurrentTime): >+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h: >+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm: >+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::nativeImageForCurrentTime): >+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::updateLastImage): >+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::paintCurrentFrameInContext): >+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setVideoFullscreenLayer): >+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h: >+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: >+ (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::setVideoFullscreenLayer): >+ (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::updateCurrentFrameImage): >+ (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::paintCurrentFrameInContext): >+ * platform/graphics/avfoundation/objc/VideoLayerManagerObjC.h: >+ * platform/graphics/avfoundation/objc/VideoLayerManagerObjC.mm: >+ (WebCore::VideoLayerManagerObjC::setVideoFullscreenLayer): >+ (WebCore::VideoLayerManagerObjC::updateVideoFullscreenInlineImage): >+ * platform/graphics/ca/GraphicsLayerCA.cpp: >+ (WebCore::GraphicsLayerCA::updateContentsImage): >+ * platform/graphics/ca/GraphicsLayerCA.h: >+ * platform/graphics/cairo/GraphicsContextCairo.cpp: >+ (WebCore::GraphicsContext::drawPlatformImage): >+ (WebCore::GraphicsContext::platformDrawNativeImage): Deleted. >+ * platform/graphics/cairo/GraphicsContextImplCairo.cpp: >+ (WebCore::GraphicsContextImplCairo::drawNativeImage): >+ (WebCore::GraphicsContextImplCairo::drawPlatformImage): >+ (WebCore::GraphicsContextImplCairo::drawPattern): >+ (WebCore::GraphicsContextImplCairo::clipToImageBuffer): >+ * platform/graphics/cairo/GraphicsContextImplCairo.h: >+ * platform/graphics/cairo/ImageBufferCairoSurfaceBackend.cpp: >+ (WebCore::ImageBufferCairoSurfaceBackend::copyNativeImage const): >+ (WebCore::ImageBufferCairoSurfaceBackend::cairoSurfaceCoerceToImage const): >+ * platform/graphics/cairo/ImageBufferCairoSurfaceBackend.h: >+ * platform/graphics/cairo/NativeImageCairo.cpp: >+ (WebCore::NativeImage::size): >+ (WebCore::NativeImage::hasAlpha const): >+ (WebCore::NativeImage::singlePixelSolidColor const): >+ (WebCore::NativeImage::clearSubimages): >+ (WebCore::nativeImageSize): Deleted. >+ (WebCore::nativeImageHasAlpha): Deleted. >+ (WebCore::nativeImageSinglePixelSolidColor): Deleted. >+ (WebCore::drawNativeImage): Deleted. >+ (WebCore::clearNativeImageSubimages): Deleted. >+ * platform/graphics/cg/GraphicsContextCG.cpp: >+ (WebCore::GraphicsContext::drawPlatformImage): >+ (WebCore::GraphicsContext::drawPattern): >+ (WebCore::GraphicsContext::clipToImageBuffer): >+ (WebCore::GraphicsContext::platformDrawNativeImage): Deleted. >+ * platform/graphics/cg/GraphicsContextGLCG.cpp: >+ (WebCore::GraphicsContextGLImageExtractor::extractImage): >+ (WebCore::GraphicsContextGLOpenGL::paintToCanvas): >+ * platform/graphics/cg/ImageBufferCGBackend.cpp: >+ (WebCore::createCroppedImageIfNecessary): >+ (WebCore::createBitmapImageAfterScalingIfNeeded): >+ (WebCore::ImageBufferCGBackend::copyImage const): >+ (WebCore::ImageBufferCGBackend::draw): >+ (WebCore::ImageBufferCGBackend::toCFData const): >+ * platform/graphics/cg/ImageBufferCGBitmapBackend.cpp: >+ (WebCore::ImageBufferCGBitmapBackend::copyNativeImage const): >+ * platform/graphics/cg/ImageBufferCGBitmapBackend.h: >+ * platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp: >+ (WebCore::ImageBufferIOSurfaceBackend::copyNativeImage const): >+ (WebCore::ImageBufferIOSurfaceBackend::sinkIntoNativeImage): >+ (WebCore::ImageBufferIOSurfaceBackend::drawConsuming): >+ * platform/graphics/cg/ImageBufferIOSurfaceBackend.h: >+ * platform/graphics/cg/ImageDecoderCG.cpp: >+ (WebCore::ImageDecoderCG::createFrameImageAtIndex): >+ * platform/graphics/cg/ImageDecoderCG.h: >+ * platform/graphics/cg/NativeImageCG.cpp: >+ (WebCore::NativeImage::size): >+ (WebCore::NativeImage::hasAlpha const): >+ (WebCore::NativeImage::singlePixelSolidColor const): >+ (WebCore::NativeImage::clearSubimages): >+ (WebCore::nativeImageSize): Deleted. >+ (WebCore::nativeImageHasAlpha): Deleted. >+ (WebCore::nativeImageSinglePixelSolidColor): Deleted. >+ (WebCore::clearNativeImageSubimages): Deleted. >+ * platform/graphics/cg/PatternCG.cpp: >+ (WebCore::Pattern::createPlatformPattern const): >+ * platform/graphics/coreimage/FilterEffectRendererCoreImage.mm: >+ (WebCore::FilterEffectRendererCoreImage::imageForSourceGraphic): >+ * platform/graphics/displaylists/DisplayList.h: >+ * platform/graphics/displaylists/DisplayListItems.cpp: >+ (WebCore::DisplayList::Item::sizeInBytes): >+ (WebCore::DisplayList::DrawNativeImage::DrawNativeImage): >+ (WebCore::DisplayList::DrawNativeImage::apply const): >+ (WebCore::DisplayList::operator<<): >+ (WebCore::DisplayList::DrawPlatformImage::DrawPlatformImage): >+ (WebCore::DisplayList::DrawPlatformImage::apply const): >+ * platform/graphics/displaylists/DisplayListItems.h: >+ (WebCore::DisplayList::DrawNativeImage::create): >+ (WebCore::DisplayList::DrawNativeImage::renderingResourceIdentifier const): >+ (WebCore::DisplayList::DrawNativeImage::imageSize const): >+ (WebCore::DisplayList::DrawNativeImage::options const): >+ (WebCore::DisplayList::DrawNativeImage::encode const): >+ (WebCore::DisplayList::DrawNativeImage::decode): >+ (WebCore::DisplayList::DrawPlatformImage::create): >+ (WebCore::DisplayList::DrawPlatformImage::source const): >+ (WebCore::DisplayList::DrawPlatformImage::destinationRect const): >+ (WebCore::DisplayList::DrawPlatformImage::encode const): >+ (WebCore::DisplayList::DrawPlatformImage::decode): >+ (WebCore::DisplayList::Item::encode const): >+ (WebCore::DisplayList::Item::decode): >+ * platform/graphics/displaylists/DisplayListRecorder.cpp: >+ (WebCore::DisplayList::Recorder::drawNativeImage): >+ (WebCore::DisplayList::Recorder::drawPlatformImage): >+ * platform/graphics/displaylists/DisplayListRecorder.h: >+ (WebCore::DisplayList::Recorder::Delegate::lockRemoteNativeImage): >+ * platform/graphics/gstreamer/ImageDecoderGStreamer.cpp: >+ (WebCore::ImageDecoderGStreamer::createFrameImageAtIndex): >+ * platform/graphics/gstreamer/ImageDecoderGStreamer.h: >+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: >+ (WebCore::MediaPlayerPrivateGStreamer::nativeImageForCurrentTime): >+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h: >+ * platform/graphics/ios/IconIOS.mm: >+ (WebCore::Icon::Icon): >+ (WebCore::Icon::createIconForImage): >+ (WebCore::Icon::paint): >+ * platform/graphics/mac/ImageMac.mm: >+ (WebCore::BitmapImage::tiffRepresentation): >+ * platform/graphics/nicosia/NicosiaImageBufferPipe.cpp: >+ (Nicosia::NicosiaImageBufferPipeSource::handle): >+ * platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp: >+ (Nicosia::CairoOperationRecorder::drawNativeImage): >+ (Nicosia::CairoOperationRecorder::drawPlatformImage): >+ (Nicosia::CairoOperationRecorder::drawPattern): >+ (Nicosia::CairoOperationRecorder::clipToImageBuffer): >+ * platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.h: >+ * platform/graphics/texmap/BitmapTextureGL.cpp: >+ (WebCore::BitmapTextureGL::updateContents): >+ * platform/graphics/texmap/GraphicsLayerTextureMapper.cpp: >+ (WebCore::GraphicsLayerTextureMapper::GraphicsLayerTextureMapper): >+ (WebCore::GraphicsLayerTextureMapper::setContentsToImage): >+ * platform/graphics/texmap/GraphicsLayerTextureMapper.h: >+ * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp: >+ (WebCore::CoordinatedGraphicsLayer::CoordinatedGraphicsLayer): >+ (WebCore::CoordinatedGraphicsLayer::setContentsToImage): >+ (WebCore::CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly): >+ * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h: >+ * platform/graphics/win/GraphicsContextDirect2D.cpp: >+ (WebCore::GraphicsContext::drawPlatformImage): >+ (WebCore::GraphicsContext::platformDrawNativeImage): Deleted. >+ * platform/graphics/win/GraphicsContextImplDirect2D.cpp: >+ (WebCore::GraphicsContextImplDirect2D::drawNativeImage): >+ (WebCore::GraphicsContextImplDirect2D::drawPlatformImage): >+ * platform/graphics/win/GraphicsContextImplDirect2D.h: >+ * platform/graphics/win/ImageBufferDirect2DBackend.cpp: >+ (WebCore::ImageBufferDirect2DBackend::create): >+ (WebCore::ImageBufferDirect2DBackend::ImageBufferDirect2DBackend): >+ (WebCore::ImageBufferDirect2DBackend::copyNativeImage const): >+ (WebCore::createCroppedImageIfNecessary): >+ (WebCore::ImageBufferDirect2DBackend::copyImage const): >+ (WebCore::ImageBufferDirect2DBackend::sinkIntoImage): >+ (WebCore::ImageBufferDirect2DBackend::compatibleBitmap): >+ * platform/graphics/win/ImageBufferDirect2DBackend.h: >+ * platform/graphics/win/ImageCGWin.cpp: >+ (WebCore::BitmapImage::drawFrameMatchingSourceSize): >+ * platform/graphics/win/ImageCairoWin.cpp: >+ (WebCore::BitmapImage::drawFrameMatchingSourceSize): >+ * platform/graphics/win/ImageDecoderDirect2D.cpp: >+ (WebCore::ImageDecoderDirect2D::createFrameImageAtIndex): >+ * platform/graphics/win/ImageDecoderDirect2D.h: >+ * platform/graphics/win/NativeImageDirect2D.cpp: >+ (WebCore::NativeImage::size): >+ (WebCore::NativeImage::hasAlpha const): >+ (WebCore::NativeImage::singlePixelSolidColor const): >+ (WebCore::NativeImage::clearSubimages): >+ (WebCore::nativeImageSize): Deleted. >+ (WebCore::nativeImageHasAlpha): Deleted. >+ (WebCore::nativeImageSinglePixelSolidColor): Deleted. >+ (WebCore::drawNativeImage): Deleted. >+ (WebCore::clearNativeImageSubimages): Deleted. >+ * platform/image-decoders/ScalableImageDecoder.cpp: >+ (WebCore::ScalableImageDecoder::createFrameImageAtIndex): >+ * platform/image-decoders/ScalableImageDecoder.h: >+ * platform/image-decoders/cairo/ImageBackingStoreCairo.cpp: >+ (WebCore::ImageBackingStore::image const): >+ * platform/mediastream/mac/DisplayCaptureSourceCocoa.cpp: >+ (WebCore::DisplayCaptureSourceCocoa::emitFrame): >+ * platform/mediastream/mac/DisplayCaptureSourceCocoa.h: >+ * platform/mediastream/mac/MockRealtimeVideoSourceMac.mm: >+ (WebCore::MockRealtimeVideoSourceMac::updateSampleBuffer): >+ * platform/win/DragImageCGWin.cpp: >+ (WebCore::createDragImageFromImage): >+ * rendering/RenderThemeIOS.mm: >+ (WebCore::RenderThemeIOS::paintSystemPreviewBadge): >+ * svg/graphics/SVGImage.cpp: >+ (WebCore::SVGImage::nativeImageForCurrentFrame): >+ (WebCore::SVGImage::nativeImage): >+ * svg/graphics/SVGImage.h: >+ * svg/graphics/SVGImageForContainer.cpp: >+ (WebCore::SVGImageForContainer::nativeImageForCurrentFrame): >+ * svg/graphics/SVGImageForContainer.h: >+ > 2020-11-01 Mason Xiao <me@masonx.ca> > > REGRESSION (r252689): box-shadow with inset and negative spread renders incorrectly >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 244035cf9ccd9bf27070b118f870af1934a79f00..0afaa90709d870f24649f0a7342b118dcc5b783e 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,49 @@ >+2020-11-01 Said Abou-Hallawa <said@apple.com> >+ >+ [GPU Process] Control the life cycle of the platform image by a new class named NativeImage >+ https://bugs.webkit.org/show_bug.cgi?id=218427 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * Scripts/webkit/messages.py: >+ * Shared/API/c/cg/WKImageCG.cpp: >+ (WKImageCreateFromCGImage): >+ * Shared/WebCoreArgumentCoders.cpp: >+ (IPC::encodePlatformImage): >+ (IPC::decodePlatformImage): >+ (IPC::encodeOptionalPlatformImage): >+ (IPC::decodeOptionalPlatformImage): >+ (IPC::ArgumentCoder<PlatformImagePtr>::encode): >+ (IPC::ArgumentCoder<PlatformImagePtr>::decode): >+ (IPC::encodeNativeImage): Deleted. >+ (IPC::decodeNativeImage): Deleted. >+ (IPC::encodeOptionalNativeImage): Deleted. >+ (IPC::decodeOptionalNativeImage): Deleted. >+ (IPC::ArgumentCoder<NativeImagePtr>::encode): Deleted. >+ (IPC::ArgumentCoder<NativeImagePtr>::decode): Deleted. >+ * Shared/WebCoreArgumentCoders.h: >+ * Shared/cg/ShareableBitmapCG.cpp: >+ (WebKit::ShareableBitmap::createImage): >+ * UIProcess/API/glib/IconDatabase.cpp: >+ (WebKit::IconDatabase::loadIconForPageURL): >+ (WebKit::IconDatabase::setIconForPageURL): >+ * UIProcess/API/glib/IconDatabase.h: >+ * UIProcess/ios/DragDropInteractionState.mm: >+ (WebKit::uiImageForImage): >+ * UIProcess/ios/WKContentViewInteraction.mm: >+ (-[WKContentView _deliverDelayedDropPreviewIfPossible:]): >+ (uiImageForImage): >+ (-[WKContentView _handleDropByInsertingImagePlaceholders:session:]): >+ (-[WKContentView _presentationSnapshotForPreviewItemController:]): >+ * WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.cpp: >+ (WebKit::ImageBufferShareableBitmapBackend::copyNativeImage const): >+ * WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.h: >+ * WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp: >+ (WebKit::MediaPlayerPrivateRemote::nativeImageForCurrentTime): >+ * WebProcess/GPU/media/MediaPlayerPrivateRemote.h: >+ * WebProcess/Plugins/PluginView.cpp: >+ (WebKit::isAlmostSolidColor): >+ > 2020-11-01 Sam Weinig <weinig@apple.com> > > Remove remaining alternative preference setting mechanisms from LayoutTests >diff --git a/Source/WebKitLegacy/mac/ChangeLog b/Source/WebKitLegacy/mac/ChangeLog >index 9f6f5c075ba9f95494b449199cf8c896cd8bcfb5..8a67d8e23a33d9173d7bad1dc12d5be918a0265c 100644 >--- a/Source/WebKitLegacy/mac/ChangeLog >+++ b/Source/WebKitLegacy/mac/ChangeLog >@@ -1,3 +1,17 @@ >+2020-11-01 Said Abou-Hallawa <said@apple.com> >+ >+ [GPU Process] Control the life cycle of the platform image by a new class named NativeImage >+ https://bugs.webkit.org/show_bug.cgi?id=218427 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * DOM/DOM.mm: >+ (-[DOMNode getPreviewSnapshotImage:andRects:]): >+ * Misc/WebCache.mm: >+ (+[WebCache imageForURL:]): >+ * WebView/WebView.mm: >+ (-[WebUITextIndicatorData initWithImage:textIndicatorData:scale:]): >+ > 2020-10-28 Sam Weinig <weinig@apple.com> > > [Testing] Remove requirement of adding new SPI for each preference that needs testing >diff --git a/Source/WebCore/Headers.cmake b/Source/WebCore/Headers.cmake >index 406e04e9f5501050e8ba7ef11aa41b0bbbbec0c3..76a9dc1cd888e17e8083c73b80006e58c34a59ff 100644 >--- a/Source/WebCore/Headers.cmake >+++ b/Source/WebCore/Headers.cmake >@@ -1204,7 +1204,6 @@ set(WebCore_PRIVATE_FRAMEWORK_HEADERS > platform/graphics/MediaPlayerPrivate.h > platform/graphics/MediaUsageInfo.h > platform/graphics/NativeImage.h >- platform/graphics/NativeImagePtr.h > platform/graphics/OpenGLESShims.h > platform/graphics/OpenGLShims.h > platform/graphics/Path.h >@@ -1213,6 +1212,7 @@ set(WebCore_PRIVATE_FRAMEWORK_HEADERS > platform/graphics/PlatformDisplay.h > platform/graphics/PlatformImageBuffer.h > platform/graphics/PlatformImageBufferBackend.h >+ platform/graphics/PlatformImagePtr.h > platform/graphics/PlatformLayer.h > platform/graphics/PlatformMediaResourceLoader.h > platform/graphics/PlatformTextTrack.h >diff --git a/Source/WebCore/Sources.txt b/Source/WebCore/Sources.txt >index 63771b040587a9485f44608f8c1283ef76c615f9..f7be25a60074b7c42c3b086d55dd61ac0315d2b8 100644 >--- a/Source/WebCore/Sources.txt >+++ b/Source/WebCore/Sources.txt >@@ -1939,6 +1939,7 @@ platform/graphics/LayoutSize.cpp > platform/graphics/MIMETypeCache.cpp > platform/graphics/MediaPlayer.cpp > platform/graphics/NamedImageGeneratedImage.cpp >+platform/graphics/NativeImage.cpp > platform/graphics/Path.cpp > platform/graphics/PathTraversalState.cpp > platform/graphics/PathUtilities.cpp >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index 8657287b9c6c86e33337627449aa5eff17e44a05..9f0c534deebf49625ae6104f874c179de87edf26 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -2157,7 +2157,7 @@ > 724ED3321A3A8B2300F5F13C /* JSEXTBlendMinMax.h in Headers */ = {isa = PBXBuildFile; fileRef = 724ED3301A3A8B2300F5F13C /* JSEXTBlendMinMax.h */; }; > 724EE5501DC80D7F00A91FFB /* ActivityState.h in Headers */ = {isa = PBXBuildFile; fileRef = 724EE54E1DC7F25B00A91FFB /* ActivityState.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 724EE5511DC80D8400A91FFB /* ActivityStateChangeObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 724EE54F1DC7F25B00A91FFB /* ActivityStateChangeObserver.h */; settings = {ATTRIBUTES = (Private, ); }; }; >- 726D56E2253AE28D0002EF90 /* NativeImagePtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 726D56E1253AE0430002EF90 /* NativeImagePtr.h */; settings = {ATTRIBUTES = (Private, ); }; }; >+ 726D56E2253AE28D0002EF90 /* PlatformImagePtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 726D56E1253AE0430002EF90 /* PlatformImagePtr.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 726D56E3253AE3660002EF90 /* NativeImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 55A336F61D8209F40022C4C7 /* NativeImage.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 727A7F3A24078B84004D2931 /* ImageBufferIOSurfaceBackend.h in Headers */ = {isa = PBXBuildFile; fileRef = 72BAC3AB23E1E544008D741C /* ImageBufferIOSurfaceBackend.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 7299BC6723D6A53200CC6883 /* AlphaPremultiplication.h in Headers */ = {isa = PBXBuildFile; fileRef = 7299BC6423D686A600CC6883 /* AlphaPremultiplication.h */; settings = {ATTRIBUTES = (Private, ); }; }; >@@ -9936,6 +9936,7 @@ > 724ED3301A3A8B2300F5F13C /* JSEXTBlendMinMax.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSEXTBlendMinMax.h; sourceTree = "<group>"; }; > 724EE54E1DC7F25B00A91FFB /* ActivityState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ActivityState.h; sourceTree = "<group>"; }; > 724EE54F1DC7F25B00A91FFB /* ActivityStateChangeObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ActivityStateChangeObserver.h; sourceTree = "<group>"; }; >+ 7252396B254CADC200F5FB15 /* NativeImage.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = NativeImage.cpp; sourceTree = "<group>"; }; > 7266F0132241BCE200833975 /* SVGPropertyAnimatorFactory.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGPropertyAnimatorFactory.h; sourceTree = "<group>"; }; > 7266F0142241BFB200833975 /* SVGPrimitivePropertyAnimatorImpl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGPrimitivePropertyAnimatorImpl.h; sourceTree = "<group>"; }; > 7266F0152241C09800833975 /* SVGPrimitivePropertyAnimator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGPrimitivePropertyAnimator.h; sourceTree = "<group>"; }; >@@ -9946,7 +9947,7 @@ > 7266F0282243120300833975 /* SVGAnimationAdditiveListFunctionImpl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGAnimationAdditiveListFunctionImpl.h; sourceTree = "<group>"; }; > 7266F029224312B100833975 /* SVGAnimationAdditiveListFunction.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGAnimationAdditiveListFunction.h; sourceTree = "<group>"; }; > 7266F02A2243149B00833975 /* SVGAnimatedPropertyList.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedPropertyList.h; sourceTree = "<group>"; }; >- 726D56E1253AE0430002EF90 /* NativeImagePtr.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NativeImagePtr.h; sourceTree = "<group>"; }; >+ 726D56E1253AE0430002EF90 /* PlatformImagePtr.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PlatformImagePtr.h; sourceTree = "<group>"; }; > 727AFED11A2EA6A0000442E8 /* EXTsRGB.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EXTsRGB.cpp; sourceTree = "<group>"; }; > 727AFED21A2EA6A0000442E8 /* EXTsRGB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EXTsRGB.h; sourceTree = "<group>"; }; > 727AFED31A2EA6A0000442E8 /* EXTsRGB.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = EXTsRGB.idl; sourceTree = "<group>"; }; >@@ -26361,8 +26362,8 @@ > 07B93FF923B92AAA0036F8EA /* MIMETypeCache.h */, > 314BE3A41B3103FB00141982 /* NamedImageGeneratedImage.cpp */, > 314BE3A51B3103FB00141982 /* NamedImageGeneratedImage.h */, >+ 7252396B254CADC200F5FB15 /* NativeImage.cpp */, > 55A336F61D8209F40022C4C7 /* NativeImage.h */, >- 726D56E1253AE0430002EF90 /* NativeImagePtr.h */, > B27535520B053814002CE64F /* Path.cpp */, > B27535530B053814002CE64F /* Path.h */, > A88DD4880B4629B000C02990 /* PathTraversalState.cpp */, >@@ -26373,6 +26374,7 @@ > A8FA6E5B0E4CFDED00D5CF49 /* Pattern.h */, > 72BAC3A623E17328008D741C /* PlatformImageBuffer.h */, > 550640AD240756DA00AAE045 /* PlatformImageBufferBackend.h */, >+ 726D56E1253AE0430002EF90 /* PlatformImagePtr.h */, > 0562F9601573F88F0031CA16 /* PlatformLayer.h */, > CEEFCD7B19DB33DC003876D7 /* PlatformMediaResourceLoader.h */, > 072847E216EBC5B00043CFA4 /* PlatformTextTrack.h */, >@@ -33384,7 +33386,6 @@ > A81872230977D3C0005826D9 /* NamedNodeMap.h in Headers */, > A818721E0977D3C0005826D9 /* NameNodeList.h in Headers */, > 726D56E3253AE3660002EF90 /* NativeImage.h in Headers */, >- 726D56E2253AE28D0002EF90 /* NativeImagePtr.h in Headers */, > 83B2D1751B8BCD6A00A02E47 /* NativeNodeFilter.h in Headers */, > E10B9B6C0B747599003ED890 /* NativeXPathNSResolver.h in Headers */, > 93CCF0270AF6C52900018E89 /* NavigationAction.h in Headers */, >@@ -33610,6 +33611,7 @@ > A723F77B1484CA4C008C6DBE /* PlatformExportMacros.h in Headers */, > 515BE1951D54F5FB00DD7C68 /* PlatformGamepad.h in Headers */, > 550640AF2407582D00AAE045 /* PlatformImageBufferBackend.h in Headers */, >+ 726D56E2253AE28D0002EF90 /* PlatformImagePtr.h in Headers */, > 935C476809AC4D4300A6AAB4 /* PlatformKeyboardEvent.h in Headers */, > 0562F9611573F88F0031CA16 /* PlatformLayer.h in Headers */, > F544F78915CFB2A800AF33A8 /* PlatformLocale.h in Headers */, >diff --git a/Source/WebCore/html/HTMLVideoElement.cpp b/Source/WebCore/html/HTMLVideoElement.cpp >index 0e781003917e6fd2a22680376567148789957d85..618cc528af25c6ca0f5d32f8ce10c9d2ef36e76f 100644 >--- a/Source/WebCore/html/HTMLVideoElement.cpp >+++ b/Source/WebCore/html/HTMLVideoElement.cpp >@@ -323,7 +323,7 @@ bool HTMLVideoElement::hasAvailableVideoFrame() const > return player()->hasVideo() && player()->hasAvailableVideoFrame(); > } > >-NativeImagePtr HTMLVideoElement::nativeImageForCurrentTime() >+RefPtr<NativeImage> HTMLVideoElement::nativeImageForCurrentTime() > { > if (!player()) > return nullptr; >diff --git a/Source/WebCore/html/HTMLVideoElement.h b/Source/WebCore/html/HTMLVideoElement.h >index a663881afd26bdfe0e0d0d7f19f0a67b35f38e9f..2c1e5d9972c1c876cb933df85ab8b364be013187 100644 >--- a/Source/WebCore/html/HTMLVideoElement.h >+++ b/Source/WebCore/html/HTMLVideoElement.h >@@ -75,7 +75,7 @@ public: > // Used by canvas to gain raw pixel access > void paintCurrentFrameInContext(GraphicsContext&, const FloatRect&); > >- NativeImagePtr nativeImageForCurrentTime(); >+ RefPtr<NativeImage> nativeImageForCurrentTime(); > > // Used by WebGL to do GPU-GPU textures copy if possible. > // See more details at MediaPlayer::copyVideoTextureToPlatformTexture() defined in Source/WebCore/platform/graphics/MediaPlayer.h. >diff --git a/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp b/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp >index 6a80b84600e0a2bb055523955fe9cc60a9aec3cb..77e604fd9601e5289837bd2f925905d1e26ae210 100644 >--- a/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp >+++ b/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp >@@ -1635,8 +1635,8 @@ ExceptionOr<void> CanvasRenderingContext2DBase::drawImage(HTMLVideoElement& vide > checkOrigin(&video); > > #if USE(CG) >- if (NativeImagePtr image = video.nativeImageForCurrentTime()) { >- c->drawNativeImage(image, FloatSize(video.videoWidth(), video.videoHeight()), dstRect, srcRect); >+ if (auto image = video.nativeImageForCurrentTime()) { >+ c->drawNativeImage(*image, FloatSize(video.videoWidth(), video.videoHeight()), dstRect, srcRect); > if (rectContainsCanvas(dstRect)) > didDrawEntireCanvas(); > else >diff --git a/Source/WebCore/page/mac/TextIndicatorWindow.mm b/Source/WebCore/page/mac/TextIndicatorWindow.mm >index 17ba51fe0e6ce71d8c9c58a0b07382f66cefbe08..61f823feb303fead38e1254dfbe109c60e3ad0dd 100644 >--- a/Source/WebCore/page/mac/TextIndicatorWindow.mm >+++ b/Source/WebCore/page/mac/TextIndicatorWindow.mm >@@ -161,7 +161,7 @@ static bool indicatorWantsManualAnimation(const TextIndicator& indicator) > > FloatSize contentsImageLogicalSize = _textIndicator->contentImage()->size(); > contentsImageLogicalSize.scale(1 / _textIndicator->contentImageScaleFactor()); >- RetainPtr<CGImageRef> contentsImage; >+ RefPtr<NativeImage> contentsImage; > if (indicatorWantsContentCrossfade(*_textIndicator)) > contentsImage = _textIndicator->contentImageWithHighlight()->nativeImage(); > else >@@ -266,7 +266,7 @@ static RetainPtr<CAKeyframeAnimation> createBounceAnimation(CFTimeInterval durat > static RetainPtr<CABasicAnimation> createContentCrossfadeAnimation(CFTimeInterval duration, TextIndicator& textIndicator) > { > RetainPtr<CABasicAnimation> crossfadeAnimation = [CABasicAnimation animationWithKeyPath:@"contents"]; >- RetainPtr<CGImageRef> contentsImage = textIndicator.contentImage()->nativeImage(); >+ RetainPtr<CGImageRef> contentsImage = textIndicator.contentImage()->nativeImage()->platformImage(); > [crossfadeAnimation setToValue:(__bridge id)contentsImage.get()]; > [crossfadeAnimation setFillMode:kCAFillModeForwards]; > [crossfadeAnimation setRemovedOnCompletion:NO]; >diff --git a/Source/WebCore/platform/graphics/BitmapImage.cpp b/Source/WebCore/platform/graphics/BitmapImage.cpp >index b3b5cf89476604c43d9f4857762e5532783fda17..843f1fe18fc8fb367e226a791443415dedf7b5d5 100644 >--- a/Source/WebCore/platform/graphics/BitmapImage.cpp >+++ b/Source/WebCore/platform/graphics/BitmapImage.cpp >@@ -52,7 +52,7 @@ BitmapImage::BitmapImage(ImageObserver* observer) > { > } > >-BitmapImage::BitmapImage(NativeImagePtr&& image, ImageObserver* observer) >+BitmapImage::BitmapImage(RefPtr<NativeImage>&& image, ImageObserver* observer) > : Image(observer) > , m_source(ImageSource::create(WTFMove(image))) > { >@@ -128,7 +128,7 @@ void BitmapImage::setCurrentFrameDecodingStatusIfNecessary(DecodingStatus decodi > m_currentFrameDecodingStatus = decodingStatus; > } > >-NativeImagePtr BitmapImage::frameImageAtIndexCacheIfNeeded(size_t index, SubsamplingLevel subsamplingLevel, const GraphicsContext* targetContext) >+RefPtr<NativeImage> BitmapImage::frameImageAtIndexCacheIfNeeded(size_t index, SubsamplingLevel subsamplingLevel, const GraphicsContext* targetContext) > { > if (!frameHasFullSizeNativeImageAtIndex(index, subsamplingLevel)) { > LOG(Images, "BitmapImage::%s - %p - url: %s [subsamplingLevel was %d, resampling]", __FUNCTION__, this, sourceURL().string().utf8().data(), static_cast<int>(frameSubsamplingLevelAtIndex(index))); >@@ -142,17 +142,17 @@ NativeImagePtr BitmapImage::frameImageAtIndexCacheIfNeeded(size_t index, Subsamp > return m_source->frameImageAtIndexCacheIfNeeded(index, subsamplingLevel); > } > >-NativeImagePtr BitmapImage::nativeImage(const GraphicsContext* targetContext) >+RefPtr<NativeImage> BitmapImage::nativeImage(const GraphicsContext* targetContext) > { > return frameImageAtIndexCacheIfNeeded(0, SubsamplingLevel::Default, targetContext); > } > >-NativeImagePtr BitmapImage::nativeImageForCurrentFrame(const GraphicsContext* targetContext) >+RefPtr<NativeImage> BitmapImage::nativeImageForCurrentFrame(const GraphicsContext* targetContext) > { > return frameImageAtIndexCacheIfNeeded(m_currentFrame, SubsamplingLevel::Default, targetContext); > } > >-NativeImagePtr BitmapImage::preTransformedNativeImageForCurrentFrame(bool respectOrientation, const GraphicsContext* targetContext) >+RefPtr<NativeImage> BitmapImage::preTransformedNativeImageForCurrentFrame(bool respectOrientation, const GraphicsContext* targetContext) > { > auto image = nativeImageForCurrentFrame(targetContext); > >@@ -171,18 +171,18 @@ NativeImagePtr BitmapImage::preTransformedNativeImageForCurrentFrame(bool respec > FloatRect destRect(FloatPoint(), correctedSizeFloat); > FloatRect sourceRect(FloatPoint(), sourceSize); > >- buffer->context().drawNativeImage(image, sourceSize, destRect, sourceRect, { orientation }); >+ buffer->context().drawNativeImage(*image, sourceSize, destRect, sourceRect, { orientation }); > return ImageBuffer::sinkIntoNativeImage(WTFMove(buffer)); > } > > #if USE(CG) >-NativeImagePtr BitmapImage::nativeImageOfSize(const IntSize& size, const GraphicsContext* targetContext) >+RefPtr<NativeImage> BitmapImage::nativeImageOfSize(const IntSize& size, const GraphicsContext* targetContext) > { > size_t count = frameCount(); > > for (size_t i = 0; i < count; ++i) { > auto image = frameImageAtIndexCacheIfNeeded(i, SubsamplingLevel::Default, targetContext); >- if (image && nativeImageSize(image) == size) >+ if (image && image->size() == size) > return image; > } > >@@ -190,14 +190,14 @@ NativeImagePtr BitmapImage::nativeImageOfSize(const IntSize& size, const Graphic > return frameImageAtIndexCacheIfNeeded(0, SubsamplingLevel::Default, targetContext); > } > >-Vector<NativeImagePtr> BitmapImage::framesNativeImages() >+Vector<RefPtr<NativeImage>> BitmapImage::framesNativeImages() > { >- Vector<NativeImagePtr> images; >+ Vector<RefPtr<NativeImage>> images; > size_t count = frameCount(); > > for (size_t i = 0; i < count; ++i) { > if (auto image = frameImageAtIndexCacheIfNeeded(i)) >- images.append(image); >+ images.append(WTFMove(image)); > } > > return images; >@@ -211,10 +211,10 @@ bool BitmapImage::notSolidColor() > } > #endif // ASSERT_ENABLED > >-static inline void drawNativeImage(const NativeImagePtr& image, GraphicsContext& context, const FloatRect& destRect, const FloatRect& srcRect, const IntSize& srcSize, const ImagePaintingOptions& options) >+static inline void drawNativeImage(NativeImage& image, GraphicsContext& context, const FloatRect& destRect, const FloatRect& srcRect, const IntSize& srcSize, const ImagePaintingOptions& options) > { > // Subsampling may have given us an image that is smaller than size(). >- IntSize subsampledImageSize = nativeImageSize(image); >+ IntSize subsampledImageSize = image.size(); > if (options.orientation().usesWidthAsHeight()) > subsampledImageSize = subsampledImageSize.transposedSize(); > >@@ -246,7 +246,7 @@ ImageDrawResult BitmapImage::draw(GraphicsContext& context, const FloatRect& des > m_currentSubsamplingLevel = m_allowSubsampling ? subsamplingLevelForScaleFactor(context, scaleFactorForDrawing) : SubsamplingLevel::Default; > LOG(Images, "BitmapImage::%s - %p - url: %s [subsamplingLevel = %d scaleFactorForDrawing = (%.4f, %.4f)]", __FUNCTION__, this, sourceURL().string().utf8().data(), static_cast<int>(m_currentSubsamplingLevel), scaleFactorForDrawing.width(), scaleFactorForDrawing.height()); > >- NativeImagePtr image; >+ RefPtr<NativeImage> image; > if (options.decodingMode() == DecodingMode::Asynchronous) { > ASSERT(!canAnimate()); > ASSERT(!m_currentFrame || m_animationFinished); >@@ -322,9 +322,9 @@ ImageDrawResult BitmapImage::draw(GraphicsContext& context, const FloatRect& des > auto orientation = options.orientation(); > if (orientation == ImageOrientation::FromImage) { > orientation = frameOrientationAtIndex(m_currentFrame); >- drawNativeImage(image, context, destRect, srcRect, IntSize(sourceSize(orientation)), { options, orientation }); >+ drawNativeImage(*image, context, destRect, srcRect, IntSize(sourceSize(orientation)), { options, orientation }); > } else >- drawNativeImage(image, context, destRect, srcRect, IntSize(sourceSize(orientation)), options); >+ drawNativeImage(*image, context, destRect, srcRect, IntSize(sourceSize(orientation)), options); > > m_currentFrameDecodingStatus = frameDecodingStatusAtIndex(m_currentFrame); > >diff --git a/Source/WebCore/platform/graphics/BitmapImage.h b/Source/WebCore/platform/graphics/BitmapImage.h >index 4e7348c200027e00156b7c5a1fda34368ac7c123..43181ff99d2594198816dd9566d794917b44ceeb 100644 >--- a/Source/WebCore/platform/graphics/BitmapImage.h >+++ b/Source/WebCore/platform/graphics/BitmapImage.h >@@ -53,7 +53,11 @@ class Timer; > > class BitmapImage final : public Image { > public: >- static Ref<BitmapImage> create(NativeImagePtr&& nativeImage, ImageObserver* observer = nullptr) >+ static Ref<BitmapImage> create(PlatformImagePtr&& platformImage, ImageObserver* observer = nullptr) >+ { >+ return adoptRef(*new BitmapImage(NativeImage::create(WTFMove(platformImage)), observer)); >+ } >+ static Ref<BitmapImage> create(RefPtr<NativeImage>&& nativeImage, ImageObserver* observer = nullptr) > { > return adoptRef(*new BitmapImage(WTFMove(nativeImage), observer)); > } >@@ -135,23 +139,23 @@ public: > #endif > #endif > >- WEBCORE_EXPORT NativeImagePtr nativeImage(const GraphicsContext* = nullptr) override; >- NativeImagePtr nativeImageForCurrentFrame(const GraphicsContext* = nullptr) override; >- NativeImagePtr preTransformedNativeImageForCurrentFrame(bool respectOrientation, const GraphicsContext* = nullptr) override; >+ WEBCORE_EXPORT RefPtr<NativeImage> nativeImage(const GraphicsContext* = nullptr) override; >+ RefPtr<NativeImage> nativeImageForCurrentFrame(const GraphicsContext* = nullptr) override; >+ RefPtr<NativeImage> preTransformedNativeImageForCurrentFrame(bool respectOrientation, const GraphicsContext* = nullptr) override; > #if USE(CG) >- NativeImagePtr nativeImageOfSize(const IntSize&, const GraphicsContext* = nullptr) override; >- Vector<NativeImagePtr> framesNativeImages(); >+ RefPtr<NativeImage> nativeImageOfSize(const IntSize&, const GraphicsContext* = nullptr) override; >+ Vector<RefPtr<NativeImage>> framesNativeImages(); > #endif > > void imageFrameAvailableAtIndex(size_t); > void decode(Function<void()>&&); > > private: >- WEBCORE_EXPORT BitmapImage(NativeImagePtr&&, ImageObserver* = nullptr); >+ WEBCORE_EXPORT BitmapImage(RefPtr<NativeImage>&&, ImageObserver* = nullptr); > WEBCORE_EXPORT BitmapImage(ImageObserver* = nullptr); > >- NativeImagePtr frameImageAtIndex(size_t index) { return m_source->frameImageAtIndex(index); } >- NativeImagePtr frameImageAtIndexCacheIfNeeded(size_t, SubsamplingLevel = SubsamplingLevel::Default, const GraphicsContext* = nullptr); >+ RefPtr<NativeImage> frameImageAtIndex(size_t index) { return m_source->frameImageAtIndex(index); } >+ RefPtr<NativeImage> frameImageAtIndexCacheIfNeeded(size_t, SubsamplingLevel = SubsamplingLevel::Default, const GraphicsContext* = nullptr); > > // Called to invalidate cached data. When |destroyAll| is true, we wipe out > // the entire frame buffer cache and tell the image source to destroy >@@ -198,7 +202,7 @@ private: > #endif > > #if PLATFORM(COCOA) >- RetainPtr<CFDataRef> tiffRepresentation(const Vector<NativeImagePtr>&); >+ RetainPtr<CFDataRef> tiffRepresentation(const Vector<RefPtr<NativeImage>>&); > #endif > > void clearTimer(); >diff --git a/Source/WebCore/platform/graphics/ConcreteImageBuffer.h b/Source/WebCore/platform/graphics/ConcreteImageBuffer.h >index 8697395fa4c8d0851c7b7790406e61c918fcea50..9e2709dd3b20859fa89c72923c1a9234c3078d2f 100644 >--- a/Source/WebCore/platform/graphics/ConcreteImageBuffer.h >+++ b/Source/WebCore/platform/graphics/ConcreteImageBuffer.h >@@ -115,7 +115,7 @@ protected: > return m_backend ? m_backend->externalMemoryCost() : 0; > } > >- NativeImagePtr copyNativeImage(BackingStoreCopy copyBehavior = CopyBackingStore) const override >+ RefPtr<NativeImage> copyNativeImage(BackingStoreCopy copyBehavior = CopyBackingStore) const override > { > if (auto* backend = ensureBackendCreated()) { > const_cast<ConcreteImageBuffer&>(*this).flushDrawingContext(); >@@ -149,7 +149,7 @@ protected: > } > } > >- NativeImagePtr sinkIntoNativeImage() override >+ RefPtr<NativeImage> sinkIntoNativeImage() override > { > if (auto* backend = ensureBackendCreated()) { > flushDrawingContext(); >diff --git a/Source/WebCore/platform/graphics/GraphicsContext.cpp b/Source/WebCore/platform/graphics/GraphicsContext.cpp >index 1c0089ded0ee7513c18f94d32fa375dee68ff92e..ee76981dceb0f9b7a79a6e30116fa5b530632c2a 100644 >--- a/Source/WebCore/platform/graphics/GraphicsContext.cpp >+++ b/Source/WebCore/platform/graphics/GraphicsContext.cpp >@@ -731,17 +731,15 @@ void GraphicsContext::drawBidiText(const FontCascade& font, const TextRun& run, > bidiRuns.clear(); > } > >-void GraphicsContext::drawNativeImage(const NativeImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) >+void GraphicsContext::drawNativeImage(NativeImage& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) > { > if (paintingDisabled()) > return; > >- if (m_impl) { >- m_impl->drawNativeImage(image, imageSize, destRect, srcRect, options); >+ if (m_impl && m_impl->drawNativeImage(image, imageSize, destRect, srcRect, options)) > return; >- } > >- platformDrawNativeImage(image, imageSize, destRect, srcRect, options); >+ drawPlatformImage(image.platformImage(), imageSize, destRect, srcRect, options); > } > > ImageDrawResult GraphicsContext::drawImage(Image& image, const FloatPoint& destination, const ImagePaintingOptions& imagePaintingOptions) >diff --git a/Source/WebCore/platform/graphics/GraphicsContext.h b/Source/WebCore/platform/graphics/GraphicsContext.h >index 0d1ca92d6045eb37a78d3e1897c26f42b9c76f3a..6143300c88b2d7ebcd9edb5c6cf3efa8bf9d3701 100644 >--- a/Source/WebCore/platform/graphics/GraphicsContext.h >+++ b/Source/WebCore/platform/graphics/GraphicsContext.h >@@ -379,7 +379,8 @@ public: > > WEBCORE_EXPORT void strokeRect(const FloatRect&, float lineWidth); > >- WEBCORE_EXPORT void drawNativeImage(const NativeImagePtr&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& = { }); >+ WEBCORE_EXPORT void drawNativeImage(NativeImage&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& = { }); >+ WEBCORE_EXPORT void drawPlatformImage(const PlatformImagePtr&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& = { }); > > WEBCORE_EXPORT ImageDrawResult drawImage(Image&, const FloatPoint& destination, const ImagePaintingOptions& = { ImageOrientation::FromImage }); > WEBCORE_EXPORT ImageDrawResult drawImage(Image&, const FloatRect& destination, const ImagePaintingOptions& = { ImageOrientation::FromImage }); >@@ -650,8 +651,6 @@ private: > > void platformFillRoundedRect(const FloatRoundedRect&, const Color&); > >- void platformDrawNativeImage(const NativeImagePtr&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&); >- > FloatRect computeLineBoundsAndAntialiasingModeForText(const FloatRect&, bool printing, Color&); > > float dashedLineCornerWidthForStrokeWidth(float) const; >diff --git a/Source/WebCore/platform/graphics/GraphicsContextGLImageExtractor.h b/Source/WebCore/platform/graphics/GraphicsContextGLImageExtractor.h >index bb9b0c9fb1e639d99f9837fe06df0ac70296c972..f4b52ac5a37e6c6ad94dc6a7bca6765be608d7f9 100644 >--- a/Source/WebCore/platform/graphics/GraphicsContextGLImageExtractor.h >+++ b/Source/WebCore/platform/graphics/GraphicsContextGLImageExtractor.h >@@ -59,8 +59,8 @@ private: > #if USE(CAIRO) > RefPtr<cairo_surface_t> m_imageSurface; > #elif USE(CG) >- RetainPtr<CGImageRef> m_cgImage; >- RetainPtr<CGImageRef> m_decodedImage; >+ RefPtr<NativeImage> m_cgImage; >+ RefPtr<NativeImage> m_decodedImage; > RetainPtr<CFDataRef> m_pixelData; > UniqueArray<uint8_t> m_formalizedRGBA8Data; > #endif >diff --git a/Source/WebCore/platform/graphics/GraphicsContextImpl.h b/Source/WebCore/platform/graphics/GraphicsContextImpl.h >index 3536d2f3b73cd488e98ec2e9fde248f8238c39ce..44d51c9a6817c15f862a198d512296bef9772988 100644 >--- a/Source/WebCore/platform/graphics/GraphicsContextImpl.h >+++ b/Source/WebCore/platform/graphics/GraphicsContextImpl.h >@@ -74,7 +74,8 @@ public: > virtual ImageDrawResult drawTiledImage(Image&, const FloatRect& destination, const FloatRect& source, const FloatSize& tileScaleFactor, Image::TileRule hRule, Image::TileRule vRule, const ImagePaintingOptions&) = 0; > > virtual bool drawImageBuffer(ImageBuffer&, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions&) = 0; >- virtual void drawNativeImage(const NativeImagePtr&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) = 0; >+ virtual bool drawNativeImage(NativeImage&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) = 0; >+ virtual void drawPlatformImage(const PlatformImagePtr&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) = 0; > virtual void drawPattern(Image&, const FloatRect& destRect, const FloatRect& srcRect, const AffineTransform&, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions&) = 0; > > virtual void drawRect(const FloatRect&, float borderThickness) = 0; >diff --git a/Source/WebCore/platform/graphics/Icon.h b/Source/WebCore/platform/graphics/Icon.h >index b5960ad5ff7c4da56df4f5a4a79add9884136d7d..5c28681d441c90b1ec4e1d190bfd0aaf0f1dccd8 100644 >--- a/Source/WebCore/platform/graphics/Icon.h >+++ b/Source/WebCore/platform/graphics/Icon.h >@@ -27,7 +27,7 @@ > #include <wtf/RetainPtr.h> > > #if PLATFORM(IOS_FAMILY) >-#include "NativeImage.h" >+#include "PlatformImagePtr.h" > #include <CoreGraphics/CoreGraphics.h> > #elif PLATFORM(MAC) > OBJC_CLASS NSImage; >@@ -54,7 +54,7 @@ public: > > #if PLATFORM(IOS_FAMILY) > // FIXME: Make this work for non-iOS ports and remove the PLATFORM(IOS_FAMILY)-guard. >- WEBCORE_EXPORT static RefPtr<Icon> createIconForImage(const NativeImagePtr&); >+ WEBCORE_EXPORT static RefPtr<Icon> createIconForImage(const PlatformImagePtr&); > #endif > > #if PLATFORM(MAC) >@@ -64,7 +64,7 @@ public: > > private: > #if PLATFORM(IOS_FAMILY) >- Icon(const RetainPtr<CGImageRef>&); >+ Icon(const PlatformImagePtr&); > RetainPtr<CGImageRef> m_cgImage; > #elif PLATFORM(MAC) > Icon(NSImage*); >diff --git a/Source/WebCore/platform/graphics/Image.h b/Source/WebCore/platform/graphics/Image.h >index 4b9beed8657eeb9fab4d45ccadd108afb0d23fab..436b37d6c8ec6f00f4feb4dd36f4a2923c7f96ea 100644 >--- a/Source/WebCore/platform/graphics/Image.h >+++ b/Source/WebCore/platform/graphics/Image.h >@@ -34,7 +34,7 @@ > #include "ImageOrientation.h" > #include "ImagePaintingOptions.h" > #include "ImageTypes.h" >-#include "NativeImagePtr.h" >+#include "NativeImage.h" > #include "Timer.h" > #include <wtf/EnumTraits.h> > #include <wtf/Optional.h> >@@ -153,10 +153,10 @@ public: > > enum TileRule { StretchTile, RoundTile, SpaceTile, RepeatTile }; > >- virtual NativeImagePtr nativeImage(const GraphicsContext* = nullptr) { return nullptr; } >- virtual NativeImagePtr nativeImageForCurrentFrame(const GraphicsContext* = nullptr) { return nullptr; } >- virtual NativeImagePtr preTransformedNativeImageForCurrentFrame(bool = true, const GraphicsContext* = nullptr) { return nullptr; } >- virtual NativeImagePtr nativeImageOfSize(const IntSize&, const GraphicsContext* = nullptr) { return nullptr; } >+ virtual RefPtr<NativeImage> nativeImage(const GraphicsContext* = nullptr) { return nullptr; } >+ virtual RefPtr<NativeImage> nativeImageForCurrentFrame(const GraphicsContext* = nullptr) { return nullptr; } >+ virtual RefPtr<NativeImage> preTransformedNativeImageForCurrentFrame(bool = true, const GraphicsContext* = nullptr) { return nullptr; } >+ virtual RefPtr<NativeImage> nativeImageOfSize(const IntSize&, const GraphicsContext* = nullptr) { return nullptr; } > > // Accessors for native image formats. > >diff --git a/Source/WebCore/platform/graphics/ImageBackingStore.h b/Source/WebCore/platform/graphics/ImageBackingStore.h >index a175dda54a634e9f7838598d0edab0c8628249aa..918bcb3aeb42e43f637422f3b96bf1f81715ab66 100644 >--- a/Source/WebCore/platform/graphics/ImageBackingStore.h >+++ b/Source/WebCore/platform/graphics/ImageBackingStore.h >@@ -52,7 +52,7 @@ public: > return std::unique_ptr<ImageBackingStore>(new ImageBackingStore(other)); > } > >- NativeImagePtr image() const; >+ PlatformImagePtr image() const; > > bool setSize(const IntSize& size) > { >diff --git a/Source/WebCore/platform/graphics/ImageBuffer.cpp b/Source/WebCore/platform/graphics/ImageBuffer.cpp >index e3bbb4263aa0731ff0381995b5de5bd3a5558be1..26ddc9b67ede57e95388cfe9ce0cca65399b0092 100644 >--- a/Source/WebCore/platform/graphics/ImageBuffer.cpp >+++ b/Source/WebCore/platform/graphics/ImageBuffer.cpp >@@ -188,7 +188,7 @@ std::unique_ptr<ImageBuffer> ImageBuffer::copyRectToBuffer(const FloatRect& rect > return buffer; > } > >-NativeImagePtr ImageBuffer::sinkIntoNativeImage(std::unique_ptr<ImageBuffer> imageBuffer) >+RefPtr<NativeImage> ImageBuffer::sinkIntoNativeImage(std::unique_ptr<ImageBuffer> imageBuffer) > { > return imageBuffer->sinkIntoNativeImage(); > } >diff --git a/Source/WebCore/platform/graphics/ImageBuffer.h b/Source/WebCore/platform/graphics/ImageBuffer.h >index e736af820a5ced63ae75176a2994232bdadf2a47..90788ee35ff7f1b6c6d875e45bccc594f8f80373 100644 >--- a/Source/WebCore/platform/graphics/ImageBuffer.h >+++ b/Source/WebCore/platform/graphics/ImageBuffer.h >@@ -79,7 +79,7 @@ public: > virtual size_t memoryCost() const = 0; > virtual size_t externalMemoryCost() const = 0; > >- virtual NativeImagePtr copyNativeImage(BackingStoreCopy = CopyBackingStore) const = 0; >+ virtual RefPtr<NativeImage> copyNativeImage(BackingStoreCopy = CopyBackingStore) const = 0; > virtual RefPtr<Image> copyImage(BackingStoreCopy = CopyBackingStore, PreserveResolution = PreserveResolution::No) const = 0; > > // Create an image buffer compatible with the context and copy rect from this buffer into this new one. >@@ -88,7 +88,7 @@ public: > virtual void draw(GraphicsContext&, const FloatRect& destRect, const FloatRect& srcRect = FloatRect(0, 0, -1, -1), const ImagePaintingOptions& = { }) = 0; > virtual void drawPattern(GraphicsContext&, const FloatRect& destRect, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& = { }) = 0; > >- static NativeImagePtr sinkIntoNativeImage(std::unique_ptr<ImageBuffer>); >+ static RefPtr<NativeImage> sinkIntoNativeImage(std::unique_ptr<ImageBuffer>); > > WEBCORE_EXPORT static RefPtr<Image> sinkIntoImage(std::unique_ptr<ImageBuffer>, PreserveResolution = PreserveResolution::No); > static void drawConsuming(std::unique_ptr<ImageBuffer>, GraphicsContext&, const FloatRect& destRect, const FloatRect& srcRect = FloatRect(0, 0, -1, -1), const ImagePaintingOptions& = { }); >@@ -111,7 +111,7 @@ public: > protected: > ImageBuffer() = default; > >- virtual NativeImagePtr sinkIntoNativeImage() = 0; >+ virtual RefPtr<NativeImage> sinkIntoNativeImage() = 0; > virtual RefPtr<Image> sinkIntoImage(PreserveResolution = PreserveResolution::No) = 0; > virtual void drawConsuming(GraphicsContext&, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) = 0; > }; >diff --git a/Source/WebCore/platform/graphics/ImageBufferBackend.cpp b/Source/WebCore/platform/graphics/ImageBufferBackend.cpp >index 4173a9bf0949ec3d2d67e8017bd70f251f6983a1..f1f367c06a2a0c9d9913c9c9236c19736ede59a2 100644 >--- a/Source/WebCore/platform/graphics/ImageBufferBackend.cpp >+++ b/Source/WebCore/platform/graphics/ImageBufferBackend.cpp >@@ -58,7 +58,7 @@ IntSize ImageBufferBackend::calculateBackendSize(const FloatSize& size, float re > return backendSize; > } > >-NativeImagePtr ImageBufferBackend::sinkIntoNativeImage() >+RefPtr<NativeImage> ImageBufferBackend::sinkIntoNativeImage() > { > return copyNativeImage(DontCopyBackingStore); > } >diff --git a/Source/WebCore/platform/graphics/ImageBufferBackend.h b/Source/WebCore/platform/graphics/ImageBufferBackend.h >index cb5872567f0883b5bd02e0eecb8cefdbe710a8ec..ed3f8b5bcf58e4278567d186fb65c8401627c8fa 100644 >--- a/Source/WebCore/platform/graphics/ImageBufferBackend.h >+++ b/Source/WebCore/platform/graphics/ImageBufferBackend.h >@@ -31,7 +31,7 @@ > #include "GraphicsTypesGL.h" > #include "ImagePaintingOptions.h" > #include "IntRect.h" >-#include "NativeImagePtr.h" >+#include "NativeImage.h" > #include "PlatformLayer.h" > #include <wtf/RefPtr.h> > #include <wtf/Vector.h> >@@ -77,13 +77,13 @@ public: > virtual size_t memoryCost() const { return 4 * m_backendSize.area().unsafeGet(); } > virtual size_t externalMemoryCost() const { return 0; } > >- virtual NativeImagePtr copyNativeImage(BackingStoreCopy) const = 0; >+ virtual RefPtr<NativeImage> copyNativeImage(BackingStoreCopy) const = 0; > virtual RefPtr<Image> copyImage(BackingStoreCopy, PreserveResolution) const = 0; > > WEBCORE_EXPORT virtual void draw(GraphicsContext&, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) = 0; > WEBCORE_EXPORT virtual void drawPattern(GraphicsContext&, const FloatRect& destRect, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions&) = 0; > >- WEBCORE_EXPORT virtual NativeImagePtr sinkIntoNativeImage(); >+ WEBCORE_EXPORT virtual RefPtr<NativeImage> sinkIntoNativeImage(); > WEBCORE_EXPORT virtual RefPtr<Image> sinkIntoImage(PreserveResolution); > WEBCORE_EXPORT virtual void drawConsuming(GraphicsContext& destContext, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&); > >diff --git a/Source/WebCore/platform/graphics/ImageDecoder.h b/Source/WebCore/platform/graphics/ImageDecoder.h >index 7104d07194f38159b33bea6aaed885d709bd9817..e4aa52443575d45da64abb59aeb6912bdda5b7ce 100644 >--- a/Source/WebCore/platform/graphics/ImageDecoder.h >+++ b/Source/WebCore/platform/graphics/ImageDecoder.h >@@ -30,7 +30,7 @@ > #include "ImageTypes.h" > #include "IntPoint.h" > #include "IntSize.h" >-#include "NativeImage.h" >+#include "PlatformImagePtr.h" > #include <wtf/Optional.h> > #include <wtf/Seconds.h> > #include <wtf/text/WTFString.h> >@@ -74,7 +74,7 @@ public: > virtual bool frameAllowSubsamplingAtIndex(size_t) const = 0; > virtual unsigned frameBytesAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default) const = 0; > >- virtual NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingOptions(DecodingMode::Synchronous)) = 0; >+ virtual PlatformImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingOptions(DecodingMode::Synchronous)) = 0; > > virtual void setExpectedContentSize(long long) { } > virtual void setData(SharedBuffer&, bool allDataReceived) = 0; >diff --git a/Source/WebCore/platform/graphics/ImageFrame.cpp b/Source/WebCore/platform/graphics/ImageFrame.cpp >index 83b78b6ec006fc5477452ffd081527b2dd916184..cc3b6360295ce0c5b9db141504ceca626edba4d1 100644 >--- a/Source/WebCore/platform/graphics/ImageFrame.cpp >+++ b/Source/WebCore/platform/graphics/ImageFrame.cpp >@@ -82,7 +82,7 @@ unsigned ImageFrame::clearImage() > > unsigned frameBytes = this->frameBytes(); > >- clearNativeImageSubimages(m_nativeImage); >+ m_nativeImage->clearSubimages(); > m_nativeImage = nullptr; > m_decodingOptions = DecodingOptions(); > >@@ -121,7 +121,7 @@ Color ImageFrame::singlePixelSolidColor() const > if (!hasNativeImage() || m_size != IntSize(1, 1)) > return Color(); > >- return nativeImageSinglePixelSolidColor(m_nativeImage); >+ return m_nativeImage->singlePixelSolidColor(); > } > > } >diff --git a/Source/WebCore/platform/graphics/ImageFrame.h b/Source/WebCore/platform/graphics/ImageFrame.h >index 54a9c9df33b4d33b1275f9146ff8842e37c00071..aa73ae36389ec2fac421ec35c3e6c671811e7bb3 100644 >--- a/Source/WebCore/platform/graphics/ImageFrame.h >+++ b/Source/WebCore/platform/graphics/ImageFrame.h >@@ -63,7 +63,7 @@ public: > unsigned frameBytes() const { return hasNativeImage() ? (size().area() * sizeof(uint32_t)).unsafeGet() : 0; } > SubsamplingLevel subsamplingLevel() const { return m_subsamplingLevel; } > >- NativeImagePtr nativeImage() const { return m_nativeImage; } >+ RefPtr<NativeImage> nativeImage() const { return m_nativeImage; } > > void setOrientation(ImageOrientation orientation) { m_orientation = orientation; }; > ImageOrientation orientation() const { return m_orientation; } >@@ -88,7 +88,7 @@ private: > DecodingStatus m_decodingStatus { DecodingStatus::Invalid }; > IntSize m_size; > >- NativeImagePtr m_nativeImage; >+ RefPtr<NativeImage> m_nativeImage; > SubsamplingLevel m_subsamplingLevel { SubsamplingLevel::Default }; > DecodingOptions m_decodingOptions; > >diff --git a/Source/WebCore/platform/graphics/ImageSource.cpp b/Source/WebCore/platform/graphics/ImageSource.cpp >index f8e2028c3c3b3f616c6a1378a94efdfc4e5b1949..148021ceee455aebb305dff35613ec47433f5530 100644 >--- a/Source/WebCore/platform/graphics/ImageSource.cpp >+++ b/Source/WebCore/platform/graphics/ImageSource.cpp >@@ -49,7 +49,7 @@ ImageSource::ImageSource(BitmapImage* image, AlphaOption alphaOption, GammaAndCo > { > } > >-ImageSource::ImageSource(NativeImagePtr&& nativeImage) >+ImageSource::ImageSource(RefPtr<NativeImage>&& nativeImage) > : m_runLoop(RunLoop::current()) > { > m_frameCount = 1; >@@ -235,7 +235,7 @@ void ImageSource::growFrames() > m_frames.grow(newSize); > } > >-void ImageSource::setNativeImage(NativeImagePtr&& nativeImage) >+void ImageSource::setNativeImage(RefPtr<NativeImage>&& nativeImage) > { > ASSERT(m_frames.size() == 1); > ImageFrame& frame = m_frames[0]; >@@ -245,8 +245,8 @@ void ImageSource::setNativeImage(NativeImagePtr&& nativeImage) > frame.m_nativeImage = WTFMove(nativeImage); > > frame.m_decodingStatus = DecodingStatus::Complete; >- frame.m_size = nativeImageSize(frame.m_nativeImage); >- frame.m_hasAlpha = nativeImageHasAlpha(frame.m_nativeImage); >+ frame.m_size = frame.m_nativeImage->size(); >+ frame.m_hasAlpha = frame.m_nativeImage->hasAlpha(); > } > > void ImageSource::cacheMetadataAtIndex(size_t index, SubsamplingLevel subsamplingLevel, DecodingStatus decodingStatus) >@@ -267,7 +267,7 @@ void ImageSource::cacheMetadataAtIndex(size_t index, SubsamplingLevel subsamplin > > if (frame.m_decodingOptions.hasSizeForDrawing()) { > ASSERT(frame.hasNativeImage()); >- frame.m_size = nativeImageSize(frame.nativeImage()); >+ frame.m_size = frame.nativeImage()->size(); > } else > frame.m_size = m_decoder->frameSizeAtIndex(index, subsamplingLevel); > >@@ -279,7 +279,7 @@ void ImageSource::cacheMetadataAtIndex(size_t index, SubsamplingLevel subsamplin > frame.m_duration = m_decoder->frameDurationAtIndex(index); > } > >-void ImageSource::cacheNativeImageAtIndex(NativeImagePtr&& nativeImage, size_t index, SubsamplingLevel subsamplingLevel, const DecodingOptions& decodingOptions, DecodingStatus decodingStatus) >+void ImageSource::cachePlatformImageAtIndex(PlatformImagePtr&& platformImage, size_t index, SubsamplingLevel subsamplingLevel, const DecodingOptions& decodingOptions, DecodingStatus decodingStatus) > { > ASSERT(index < m_frames.size()); > ImageFrame& frame = m_frames[index]; >@@ -293,7 +293,7 @@ void ImageSource::cacheNativeImageAtIndex(NativeImagePtr&& nativeImage, size_t i > return; > > // Move the new image to the cache. >- frame.m_nativeImage = WTFMove(nativeImage); >+ frame.m_nativeImage = NativeImage::create(WTFMove(platformImage)); > frame.m_decodingOptions = decodingOptions; > cacheMetadataAtIndex(index, subsamplingLevel, decodingStatus); > >@@ -301,7 +301,7 @@ void ImageSource::cacheNativeImageAtIndex(NativeImagePtr&& nativeImage, size_t i > decodedSizeIncreased(frame.frameBytes()); > } > >-void ImageSource::cacheNativeImageAtIndexAsync(NativeImagePtr&& nativeImage, size_t index, SubsamplingLevel subsamplingLevel, const DecodingOptions& decodingOptions, DecodingStatus decodingStatus) >+void ImageSource::cachePlatformImageAtIndexAsync(PlatformImagePtr&& platformImage, size_t index, SubsamplingLevel subsamplingLevel, const DecodingOptions& decodingOptions, DecodingStatus decodingStatus) > { > if (!isDecoderAvailable()) > return; >@@ -309,7 +309,7 @@ void ImageSource::cacheNativeImageAtIndexAsync(NativeImagePtr&& nativeImage, siz > ASSERT(index < m_frames.size()); > > // Clean the old native image and set a new one >- cacheNativeImageAtIndex(WTFMove(nativeImage), index, subsamplingLevel, decodingOptions, decodingStatus); >+ cachePlatformImageAtIndex(WTFMove(platformImage), index, subsamplingLevel, decodingOptions, decodingStatus); > LOG(Images, "ImageSource::%s - %p - url: %s [frame %ld has been cached]", __FUNCTION__, this, sourceURL().string().utf8().data(), index); > > // Notify the image with the readiness of the new frame NativeImage. >@@ -362,8 +362,8 @@ void ImageSource::startAsyncDecodingQueue() > startingTime = MonotonicTime::now(); > > // Get the frame NativeImage on the decoding thread. >- NativeImagePtr nativeImage = protectedDecoder->createFrameImageAtIndex(frameRequest.index, frameRequest.subsamplingLevel, frameRequest.decodingOptions); >- if (nativeImage) >+ auto platformImage = protectedDecoder->createFrameImageAtIndex(frameRequest.index, frameRequest.subsamplingLevel, frameRequest.decodingOptions); >+ if (platformImage) > LOG(Images, "ImageSource::%s - %p - url: %s [frame %ld has been decoded]", __FUNCTION__, protectedThis.ptr(), sourceURL.utf8().data(), frameRequest.index); > else { > LOG(Images, "ImageSource::%s - %p - url: %s [decoding for frame %ld has failed]", __FUNCTION__, protectedThis.ptr(), sourceURL.utf8().data(), frameRequest.index); >@@ -375,12 +375,12 @@ void ImageSource::startAsyncDecodingQueue() > sleep(minDecodingDuration - (MonotonicTime::now() - startingTime)); > > // Update the cached frames on the creation thread to avoid updating the MemoryCache from a different thread. >- callOnMainThread([protectedThis, protectedDecodingQueue, protectedDecoder, sourceURL = sourceURL.isolatedCopy(), nativeImage = WTFMove(nativeImage), frameRequest] () mutable { >+ callOnMainThread([protectedThis, protectedDecodingQueue, protectedDecoder, sourceURL = sourceURL.isolatedCopy(), platformImage = WTFMove(platformImage), frameRequest] () mutable { > // The queue may have been closed if after we got the frame NativeImage, stopAsyncDecodingQueue() was called. > if (protectedDecodingQueue.ptr() == protectedThis->m_decodingQueue && protectedDecoder.ptr() == protectedThis->m_decoder) { > ASSERT(protectedThis->m_frameCommitQueue.first() == frameRequest); > protectedThis->m_frameCommitQueue.removeFirst(); >- protectedThis->cacheNativeImageAtIndexAsync(WTFMove(nativeImage), frameRequest.index, frameRequest.subsamplingLevel, frameRequest.decodingOptions, frameRequest.decodingStatus); >+ protectedThis->cachePlatformImageAtIndexAsync(WTFMove(platformImage), frameRequest.index, frameRequest.subsamplingLevel, frameRequest.decodingOptions, frameRequest.decodingStatus); > } else > LOG(Images, "ImageSource::%s - %p - url: %s [frame %ld will not cached]", __FUNCTION__, protectedThis.ptr(), sourceURL.utf8().data(), frameRequest.index); > }); >@@ -454,9 +454,9 @@ const ImageFrame& ImageSource::frameAtIndexCacheIfNeeded(size_t index, ImageFram > if (frame.hasFullSizeNativeImage(subsamplingLevel)) > break; > // We have to perform synchronous image decoding in this code. >- NativeImagePtr nativeImage = m_decoder->createFrameImageAtIndex(index, subsamplingLevelValue); >+ auto platformImage = m_decoder->createFrameImageAtIndex(index, subsamplingLevelValue); > // Clean the old native image and set a new one. >- cacheNativeImageAtIndex(WTFMove(nativeImage), index, subsamplingLevelValue, DecodingOptions(DecodingMode::Synchronous)); >+ cachePlatformImageAtIndex(WTFMove(platformImage), index, subsamplingLevelValue, DecodingOptions(DecodingMode::Synchronous)); > break; > } > >@@ -697,19 +697,21 @@ void ImageSource::setTargetContext(const GraphicsContext* targetContext) > } > #endif > >-NativeImagePtr ImageSource::createFrameImageAtIndex(size_t index, SubsamplingLevel subsamplingLevel) >+RefPtr<NativeImage> ImageSource::createFrameImageAtIndex(size_t index, SubsamplingLevel subsamplingLevel) > { >- return isDecoderAvailable() ? m_decoder->createFrameImageAtIndex(index, subsamplingLevel) : nullptr; >+ if (!isDecoderAvailable()) >+ return nullptr; >+ return NativeImage::create(m_decoder->createFrameImageAtIndex(index, subsamplingLevel)); > } > >-NativeImagePtr ImageSource::frameImageAtIndex(size_t index) >+RefPtr<NativeImage> ImageSource::frameImageAtIndex(size_t index) > { >- return frameMetadataAtIndex<NativeImagePtr>(index, (&ImageFrame::nativeImage)); >+ return frameMetadataAtIndex<RefPtr<NativeImage>>(index, (&ImageFrame::nativeImage)); > } > >-NativeImagePtr ImageSource::frameImageAtIndexCacheIfNeeded(size_t index, SubsamplingLevel subsamplingLevel) >+RefPtr<NativeImage> ImageSource::frameImageAtIndexCacheIfNeeded(size_t index, SubsamplingLevel subsamplingLevel) > { >- return frameMetadataAtIndexCacheIfNeeded<NativeImagePtr>(index, (&ImageFrame::nativeImage), nullptr, ImageFrame::Caching::MetadataAndImage, subsamplingLevel); >+ return frameMetadataAtIndexCacheIfNeeded<RefPtr<NativeImage>>(index, (&ImageFrame::nativeImage), nullptr, ImageFrame::Caching::MetadataAndImage, subsamplingLevel); > } > > void ImageSource::dump(TextStream& ts) >diff --git a/Source/WebCore/platform/graphics/ImageSource.h b/Source/WebCore/platform/graphics/ImageSource.h >index d98ec0e7f6e52ce5589edd99b42c7ad63cedf01d..a6f4ab13deefda3652bb933cb2e262a5fcb6032c 100644 >--- a/Source/WebCore/platform/graphics/ImageSource.h >+++ b/Source/WebCore/platform/graphics/ImageSource.h >@@ -52,7 +52,7 @@ public: > return adoptRef(*new ImageSource(image, alphaOption, gammaAndColorProfileOption)); > } > >- static Ref<ImageSource> create(NativeImagePtr&& nativeImage) >+ static Ref<ImageSource> create(RefPtr<NativeImage>&& nativeImage) > { > return adoptRef(*new ImageSource(WTFMove(nativeImage))); > } >@@ -125,13 +125,13 @@ public: > #if USE(DIRECT2D) > void setTargetContext(const GraphicsContext*); > #endif >- NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default); >- NativeImagePtr frameImageAtIndex(size_t); >- NativeImagePtr frameImageAtIndexCacheIfNeeded(size_t, SubsamplingLevel = SubsamplingLevel::Default); >+ RefPtr<NativeImage> createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default); >+ RefPtr<NativeImage> frameImageAtIndex(size_t); >+ RefPtr<NativeImage> frameImageAtIndexCacheIfNeeded(size_t, SubsamplingLevel = SubsamplingLevel::Default); > > private: > ImageSource(BitmapImage*, AlphaOption = AlphaOption::Premultiplied, GammaAndColorProfileOption = GammaAndColorProfileOption::Applied); >- ImageSource(NativeImagePtr&&); >+ ImageSource(RefPtr<NativeImage>&&); > > template<typename T, T (ImageDecoder::*functor)() const> > T metadata(const T& defaultValue, Optional<T>* cachedValue = nullptr); >@@ -152,10 +152,10 @@ private: > void decodedSizeReset(unsigned decodedSize); > void encodedDataStatusChanged(EncodedDataStatus); > >- void setNativeImage(NativeImagePtr&&); >+ void setNativeImage(RefPtr<NativeImage>&&); > void cacheMetadataAtIndex(size_t, SubsamplingLevel, DecodingStatus = DecodingStatus::Invalid); >- void cacheNativeImageAtIndex(NativeImagePtr&&, size_t, SubsamplingLevel, const DecodingOptions&, DecodingStatus = DecodingStatus::Invalid); >- void cacheNativeImageAtIndexAsync(NativeImagePtr&&, size_t, SubsamplingLevel, const DecodingOptions&, DecodingStatus); >+ void cachePlatformImageAtIndex(PlatformImagePtr&&, size_t, SubsamplingLevel, const DecodingOptions&, DecodingStatus = DecodingStatus::Invalid); >+ void cachePlatformImageAtIndexAsync(PlatformImagePtr&&, size_t, SubsamplingLevel, const DecodingOptions&, DecodingStatus); > > struct ImageFrameRequest; > static const int BufferSize = 8; >diff --git a/Source/WebCore/platform/graphics/MediaPlayer.cpp b/Source/WebCore/platform/graphics/MediaPlayer.cpp >index 7aaa1efb3a5e353616b229bb5a3f270ad5ca10cf..59567d0c39932b0e7b17fb65c72e76dfa7f196b4 100644 >--- a/Source/WebCore/platform/graphics/MediaPlayer.cpp >+++ b/Source/WebCore/platform/graphics/MediaPlayer.cpp >@@ -985,7 +985,7 @@ bool MediaPlayer::copyVideoTextureToPlatformTexture(GraphicsContextGLOpenGL* con > return m_private->copyVideoTextureToPlatformTexture(context, texture, target, level, internalFormat, format, type, premultiplyAlpha, flipY); > } > >-NativeImagePtr MediaPlayer::nativeImageForCurrentTime() >+RefPtr<NativeImage> MediaPlayer::nativeImageForCurrentTime() > { > return m_private->nativeImageForCurrentTime(); > } >diff --git a/Source/WebCore/platform/graphics/MediaPlayer.h b/Source/WebCore/platform/graphics/MediaPlayer.h >index 33c1dca88241020f4fd1df62f56f0ace7608f8a8..a0578ae03e707c8556964a536e9ab64a53e85ca5 100644 >--- a/Source/WebCore/platform/graphics/MediaPlayer.h >+++ b/Source/WebCore/platform/graphics/MediaPlayer.h >@@ -430,7 +430,7 @@ public: > > bool copyVideoTextureToPlatformTexture(GraphicsContextGLOpenGL*, PlatformGLObject texture, GCGLenum target, GCGLint level, GCGLenum internalFormat, GCGLenum format, GCGLenum type, bool premultiplyAlpha, bool flipY); > >- NativeImagePtr nativeImageForCurrentTime(); >+ RefPtr<NativeImage> nativeImageForCurrentTime(); > > using MediaPlayerEnums::NetworkState; > NetworkState networkState(); >diff --git a/Source/WebCore/platform/graphics/MediaPlayerPrivate.h b/Source/WebCore/platform/graphics/MediaPlayerPrivate.h >index c36c2f55558a6f73c6e754379a343114038b0b91..7e90cdddfc8701bbcda72d94ae4db8f0da010dbf 100644 >--- a/Source/WebCore/platform/graphics/MediaPlayerPrivate.h >+++ b/Source/WebCore/platform/graphics/MediaPlayerPrivate.h >@@ -161,7 +161,7 @@ public: > > virtual void paintCurrentFrameInContext(GraphicsContext& c, const FloatRect& r) { paint(c, r); } > virtual bool copyVideoTextureToPlatformTexture(GraphicsContextGLOpenGL*, PlatformGLObject, GCGLenum, GCGLint, GCGLenum, GCGLenum, GCGLenum, bool, bool) { return false; } >- virtual NativeImagePtr nativeImageForCurrentTime() { return nullptr; } >+ virtual RefPtr<NativeImage> nativeImageForCurrentTime() { return nullptr; } > > virtual void setPreload(MediaPlayer::Preload) { } > >diff --git a/Source/WebCore/platform/graphics/NativeImage.cpp b/Source/WebCore/platform/graphics/NativeImage.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..e88e14e4dd840d18f70e19b263339ed9dbb54d74 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/NativeImage.cpp >@@ -0,0 +1,49 @@ >+/* >+ * Copyright (C) 2020 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "NativeImage.h" >+ >+#include <wtf/NeverDestroyed.h> >+ >+namespace WebCore { >+ >+Ref<NativeImage> NativeImage::create(PlatformImagePtr&& platformImage) >+{ >+ return adoptRef(*new NativeImage(WTFMove(platformImage))); >+} >+ >+NativeImage::NativeImage(PlatformImagePtr&& platformImage) >+ : m_platformImage(WTFMove(platformImage)) >+{ >+} >+ >+NativeImage::~NativeImage() >+{ >+ if (m_observer && m_platformImage) >+ m_observer->nativeImageWillBeDeleted(m_renderingResourceIdentifier); >+} >+ >+} // namespace WebCore >diff --git a/Source/WebCore/platform/graphics/NativeImage.h b/Source/WebCore/platform/graphics/NativeImage.h >index 0334759607f8f20de3124859a6f0f09451e18e5b..327482456e9c35051d68536f4532a20eb20ee835 100644 >--- a/Source/WebCore/platform/graphics/NativeImage.h >+++ b/Source/WebCore/platform/graphics/NativeImage.h >@@ -27,16 +27,49 @@ > > #pragma once > >-#include "NativeImagePtr.h" >+#include "IntSize.h" >+#include "PlatformImagePtr.h" >+#include "RenderingResourceIdentifier.h" >+#include <wtf/RefCounted.h> > > namespace WebCore { > > class Color; >-class IntSize; > >-WEBCORE_EXPORT IntSize nativeImageSize(const NativeImagePtr&); >-bool nativeImageHasAlpha(const NativeImagePtr&); >-Color nativeImageSinglePixelSolidColor(const NativeImagePtr&); >-void clearNativeImageSubimages(const NativeImagePtr&); >+class NativeImage : public RefCounted<NativeImage> { >+public: >+ class Observer { >+ public: >+ virtual ~Observer() = default; >+ virtual void nativeImageWillBeDeleted(RenderingResourceIdentifier) = 0; >+ protected: >+ Observer() = default; >+ }; > >-} >+ static WEBCORE_EXPORT Ref<NativeImage> create(PlatformImagePtr&&); >+ static WEBCORE_EXPORT IntSize size(const PlatformImagePtr&); >+ >+ WEBCORE_EXPORT ~NativeImage(); >+ >+ RenderingResourceIdentifier renderingResourceIdentifier() const { return m_renderingResourceIdentifier; } >+ >+ bool isNull() const { return !m_platformImage; } >+ PlatformImagePtr& platformImage() { return m_platformImage; } >+ const PlatformImagePtr& platformImage() const { return m_platformImage; } >+ >+ IntSize size() const { return size(m_platformImage); } >+ bool hasAlpha() const; >+ Color singlePixelSolidColor() const; >+ >+ void setObserver(Observer* observer) { m_observer = observer; } >+ void clearSubimages(); >+ >+private: >+ NativeImage(PlatformImagePtr&&); >+ >+ PlatformImagePtr m_platformImage; >+ Observer* m_observer { nullptr }; >+ RenderingResourceIdentifier m_renderingResourceIdentifier { RenderingResourceIdentifier::generate() }; >+}; >+ >+} // namespace WebCore >diff --git a/Source/WebCore/platform/graphics/NativeImagePtr.h b/Source/WebCore/platform/graphics/NativeImagePtr.h >deleted file mode 100644 >index 3d77a898d398736411174f19f7514071d07c9582..0000000000000000000000000000000000000000 >--- a/Source/WebCore/platform/graphics/NativeImagePtr.h >+++ /dev/null >@@ -1,49 +0,0 @@ >-/* >- * Copyright (C) 2020 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#pragma once >- >-#if USE(CG) >-#include <wtf/RetainPtr.h> >-typedef struct CGImage* CGImageRef; >-#elif USE(CAIRO) >-#include "RefPtrCairo.h" >-#elif USE(WINGDI) >-#include "SharedBitmap.h" >-#endif >- >-namespace WebCore { >- >-#if USE(CG) >-typedef RetainPtr<CGImageRef> NativeImagePtr; >-#elif USE(DIRECT2D) >-typedef COMPtr<ID2D1Bitmap> NativeImagePtr; >-#elif USE(CAIRO) >-typedef RefPtr<cairo_surface_t> NativeImagePtr; >-#elif USE(WINGDI) >-typedef RefPtr<SharedBitmap> NativeImagePtr; >-#endif >- >-} >diff --git a/Source/WebCore/platform/graphics/PlatformImagePtr.h b/Source/WebCore/platform/graphics/PlatformImagePtr.h >new file mode 100644 >index 0000000000000000000000000000000000000000..192d07f944e9e398fcf524fa19ef045911013d10 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/PlatformImagePtr.h >@@ -0,0 +1,49 @@ >+/* >+ * Copyright (C) 2020 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if USE(CG) >+#include <wtf/RetainPtr.h> >+typedef struct CGImage* CGImageRef; >+#elif USE(CAIRO) >+#include "RefPtrCairo.h" >+#elif USE(WINGDI) >+#include "SharedBitmap.h" >+#endif >+ >+namespace WebCore { >+ >+#if USE(CG) >+using PlatformImagePtr = RetainPtr<CGImageRef>; >+#elif USE(DIRECT2D) >+using PlatformImagePtr = COMPtr<ID2D1Bitmap>; >+#elif USE(CAIRO) >+using PlatformImagePtr = RefPtr<cairo_surface_t>; >+#elif USE(WINGDI) >+using PlatformImagePtr = RefPtr<SharedBitmap>; >+#endif >+ >+} >diff --git a/Source/WebCore/platform/graphics/VideoLayerManager.h b/Source/WebCore/platform/graphics/VideoLayerManager.h >index 1b07f86f393178f4cf7fe83a81478084ebf22831..ad3c1bb79aedcaae3e797fd8fb2d6aaa86ed33ca 100644 >--- a/Source/WebCore/platform/graphics/VideoLayerManager.h >+++ b/Source/WebCore/platform/graphics/VideoLayerManager.h >@@ -44,10 +44,10 @@ public: > > #if ENABLE(VIDEO_PRESENTATION_MODE) > virtual PlatformLayer* videoFullscreenLayer() const = 0; >- virtual void setVideoFullscreenLayer(PlatformLayer*, WTF::Function<void()>&& completionHandler, NativeImagePtr) = 0; >+ virtual void setVideoFullscreenLayer(PlatformLayer*, WTF::Function<void()>&& completionHandler, PlatformImagePtr) = 0; > virtual FloatRect videoFullscreenFrame() const = 0; > virtual void setVideoFullscreenFrame(FloatRect) = 0; >- virtual void updateVideoFullscreenInlineImage(NativeImagePtr) = 0; >+ virtual void updateVideoFullscreenInlineImage(PlatformImagePtr) = 0; > #endif > > virtual bool requiresTextTrackRepresentation() const = 0; >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.h b/Source/WebCore/platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.h >index 8a5f5870a353573d869766939154d97b722cfc30..fb3bfcdc2be1e781664a2419493e95ba53787eea 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.h >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.h >@@ -82,7 +82,7 @@ public: > bool frameAllowSubsamplingAtIndex(size_t) const final; > unsigned frameBytesAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default) const final; > >- NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingOptions(DecodingMode::Synchronous)) final; >+ PlatformImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingOptions(DecodingMode::Synchronous)) final; > > void setExpectedContentSize(long long) final; > void setData(SharedBuffer&, bool allDataReceived) final; >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.mm b/Source/WebCore/platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.mm >index 25bf159de44534916f90abd0753a11556ac512b7..8cdfc71b64503de33316359cd339dd0d3484b159 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.mm >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.mm >@@ -567,7 +567,7 @@ unsigned ImageDecoderAVFObjC::frameBytesAtIndex(size_t index, SubsamplingLevel s > return (frameSize.area() * 4).unsafeGet(); > } > >-NativeImagePtr ImageDecoderAVFObjC::createFrameImageAtIndex(size_t index, SubsamplingLevel, const DecodingOptions&) >+PlatformImagePtr ImageDecoderAVFObjC::createFrameImageAtIndex(size_t index, SubsamplingLevel, const DecodingOptions&) > { > LockHolder holder { m_sampleGeneratorLock }; > >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h >index 6a6fd7183ae89d38582b611dd7016a53ae9c1ea6..26b3d78fe1b0ce6d476d2a5e73875e390e3ede83 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h >@@ -252,7 +252,7 @@ private: > bool updateLastPixelBuffer(); > bool videoOutputHasAvailableFrame(); > void paintWithVideoOutput(GraphicsContext&, const FloatRect&); >- NativeImagePtr nativeImageForCurrentTime() final; >+ RefPtr<NativeImage> nativeImageForCurrentTime() final; > void waitForVideoOutputMediaDataWillChange(); > > bool copyVideoTextureToPlatformTexture(GraphicsContextGLOpenGL*, PlatformGLObject, GCGLenum target, GCGLint level, GCGLenum internalFormat, GCGLenum format, GCGLenum type, bool premultiplyAlpha, bool flipY) final; >@@ -343,7 +343,7 @@ private: > RetainPtr<AVPlayerItemVideoOutput> m_videoOutput; > RetainPtr<WebCoreAVFPullDelegate> m_videoOutputDelegate; > RetainPtr<CVPixelBufferRef> m_lastPixelBuffer; >- RetainPtr<CGImageRef> m_lastImage; >+ RefPtr<NativeImage> m_lastImage; > std::unique_ptr<ImageRotationSessionVT> m_imageRotationSession; > std::unique_ptr<VideoTextureCopierCV> m_videoTextureCopier; > std::unique_ptr<PixelBufferConformerCV> m_pixelBufferConformer; >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm >index f2948816edde79e78a1931d5bc6d3eceeb5d847f..3abba92e509a214049d50416d652401c4618799f 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm >@@ -1127,7 +1127,7 @@ PlatformLayer* MediaPlayerPrivateAVFoundationObjC::platformLayer() const > void MediaPlayerPrivateAVFoundationObjC::updateVideoFullscreenInlineImage() > { > updateLastImage(UpdateType::UpdateSynchronously); >- m_videoLayerManager->updateVideoFullscreenInlineImage(m_lastImage); >+ m_videoLayerManager->updateVideoFullscreenInlineImage(m_lastImage ? m_lastImage->platformImage() : nullptr); > } > > RetainPtr<PlatformLayer> MediaPlayerPrivateAVFoundationObjC::createVideoFullscreenLayer() >@@ -1139,7 +1139,7 @@ void MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenLayer(PlatformLayer* > { > if (videoFullscreenLayer) > updateLastImage(UpdateType::UpdateSynchronously); >- m_videoLayerManager->setVideoFullscreenLayer(videoFullscreenLayer, WTFMove(completionHandler), m_lastImage); >+ m_videoLayerManager->setVideoFullscreenLayer(videoFullscreenLayer, WTFMove(completionHandler), m_lastImage ? m_lastImage->platformImage() : nullptr); > updateDisableExternalPlayback(); > } > >@@ -2293,7 +2293,7 @@ void MediaPlayerPrivateAVFoundationObjC::updateLastImage(UpdateType type) > > MonotonicTime start = MonotonicTime::now(); > >- m_lastImage = m_pixelBufferConformer->createImageFromPixelBuffer(m_lastPixelBuffer.get()); >+ m_lastImage = NativeImage::create(m_pixelBufferConformer->createImageFromPixelBuffer(m_lastPixelBuffer.get())); > > INFO_LOG(LOGIDENTIFIER, "creating buffer took ", (MonotonicTime::now() - start).seconds()); > } >@@ -2314,8 +2314,8 @@ void MediaPlayerPrivateAVFoundationObjC::paintWithVideoOutput(GraphicsContext& c > > INFO_LOG(LOGIDENTIFIER); > >- FloatRect imageRect(0, 0, CGImageGetWidth(m_lastImage.get()), CGImageGetHeight(m_lastImage.get())); >- context.drawNativeImage(m_lastImage.get(), imageRect.size(), outputRect, imageRect); >+ FloatRect imageRect({ 0, 0 }, m_lastImage->size()); >+ context.drawNativeImage(*m_lastImage, imageRect.size(), outputRect, imageRect); > > // If we have created an AVAssetImageGenerator in the past due to m_videoOutput not having an available > // video frame, destroy it now that it is no longer needed. >@@ -2341,7 +2341,7 @@ bool MediaPlayerPrivateAVFoundationObjC::copyVideoTextureToPlatformTexture(Graph > return m_videoTextureCopier->copyImageToPlatformTexture(m_lastPixelBuffer.get(), width, height, outputTexture, outputTarget, level, internalFormat, format, type, premultiplyAlpha, flipY); > } > >-NativeImagePtr MediaPlayerPrivateAVFoundationObjC::nativeImageForCurrentTime() >+RefPtr<NativeImage> MediaPlayerPrivateAVFoundationObjC::nativeImageForCurrentTime() > { > updateLastImage(); > return m_lastImage; >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h >index e7bf7a767330a6727f06321614de1b0a3807f9ab..a0af9b874cae82abd3f80910f6ba29d9e394b507 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h >@@ -215,7 +215,7 @@ private: > > bool didLoadingProgress() const override; > >- NativeImagePtr nativeImageForCurrentTime() override; >+ RefPtr<NativeImage> nativeImageForCurrentTime() override; > bool updateLastPixelBuffer(); > bool updateLastImage(); > void paint(GraphicsContext&, const FloatRect&) override; >@@ -301,7 +301,7 @@ private: > RetainPtr<id> m_performTaskObserver; > RetainPtr<AVStreamSession> m_streamSession; > RetainPtr<CVPixelBufferRef> m_lastPixelBuffer; >- RetainPtr<CGImageRef> m_lastImage; >+ RefPtr<NativeImage> m_lastImage; > std::unique_ptr<PixelBufferConformerCV> m_rgbConformer; > RefPtr<WebCoreDecompressionSession> m_decompressionSession; > Deque<RetainPtr<id>> m_sizeChangeObservers; >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm >index 925bf4e1f90b54c42866c2658059c611acc1bb0e..8bc48fa3e324525675d9e8c88df9f3ac17440889 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm >@@ -564,10 +564,10 @@ bool MediaPlayerPrivateMediaSourceAVFObjC::didLoadingProgress() const > return loadingProgressed; > } > >-NativeImagePtr MediaPlayerPrivateMediaSourceAVFObjC::nativeImageForCurrentTime() >+RefPtr<NativeImage> MediaPlayerPrivateMediaSourceAVFObjC::nativeImageForCurrentTime() > { > updateLastImage(); >- return m_lastImage.get(); >+ return m_lastImage; > } > > bool MediaPlayerPrivateMediaSourceAVFObjC::updateLastPixelBuffer() >@@ -607,7 +607,7 @@ bool MediaPlayerPrivateMediaSourceAVFObjC::updateLastImage() > m_rgbConformer = makeUnique<PixelBufferConformerCV>((__bridge CFDictionaryRef)attributes); > } > >- m_lastImage = m_rgbConformer->createImageFromPixelBuffer(m_lastPixelBuffer.get()); >+ m_lastImage = NativeImage::create(m_rgbConformer->createImageFromPixelBuffer(m_lastPixelBuffer.get())); > return true; > } > >@@ -626,8 +626,8 @@ void MediaPlayerPrivateMediaSourceAVFObjC::paintCurrentFrameInContext(GraphicsCo > return; > > GraphicsContextStateSaver stateSaver(context); >- FloatRect imageRect(0, 0, CGImageGetWidth(image.get()), CGImageGetHeight(image.get())); >- context.drawNativeImage(image, imageRect.size(), outputRect, imageRect); >+ FloatRect imageRect({ 0, 0 }, image->size()); >+ context.drawNativeImage(*image, imageRect.size(), outputRect, imageRect); > } > > bool MediaPlayerPrivateMediaSourceAVFObjC::copyVideoTextureToPlatformTexture(GraphicsContextGLOpenGL* context, PlatformGLObject outputTexture, GCGLenum outputTarget, GCGLint level, GCGLenum internalFormat, GCGLenum format, GCGLenum type, bool premultiplyAlpha, bool flipY) >@@ -1219,7 +1219,7 @@ RetainPtr<PlatformLayer> MediaPlayerPrivateMediaSourceAVFObjC::createVideoFullsc > void MediaPlayerPrivateMediaSourceAVFObjC::setVideoFullscreenLayer(PlatformLayer *videoFullscreenLayer, WTF::Function<void()>&& completionHandler) > { > updateLastImage(); >- m_videoLayerManager->setVideoFullscreenLayer(videoFullscreenLayer, WTFMove(completionHandler), m_lastImage); >+ m_videoLayerManager->setVideoFullscreenLayer(videoFullscreenLayer, WTFMove(completionHandler), m_lastImage ? m_lastImage->platformImage() : nullptr); > } > > void MediaPlayerPrivateMediaSourceAVFObjC::setVideoFullscreenFrame(FloatRect frame) >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h >index 088f1d92c97f3925bf9a9bc0b2379d350bdbbca9..878096adbd6e25d43186beeb0badf468f86ce4c9 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h >@@ -232,7 +232,7 @@ private: > CurrentFramePainter() = default; > void reset(); > >- RetainPtr<CGImageRef> cgImage; >+ RefPtr<NativeImage> cgImage; > RefPtr<MediaSample> mediaSample; > std::unique_ptr<PixelBufferConformerCV> pixelBufferConformer; > }; >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm >index 989fb89da2ab38d1f1c17d5afd1ca82260227cb4..9a536db92b2e042d87814a9eeaaa93eec83898bf 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm >@@ -762,7 +762,7 @@ RetainPtr<PlatformLayer> MediaPlayerPrivateMediaStreamAVFObjC::createVideoFullsc > void MediaPlayerPrivateMediaStreamAVFObjC::setVideoFullscreenLayer(PlatformLayer* videoFullscreenLayer, WTF::Function<void()>&& completionHandler) > { > updateCurrentFrameImage(); >- m_videoLayerManager->setVideoFullscreenLayer(videoFullscreenLayer, WTFMove(completionHandler), m_imagePainter.cgImage); >+ m_videoLayerManager->setVideoFullscreenLayer(videoFullscreenLayer, WTFMove(completionHandler), m_imagePainter.cgImage ? m_imagePainter.cgImage->platformImage() : nullptr); > } > > void MediaPlayerPrivateMediaStreamAVFObjC::setVideoFullscreenFrame(FloatRect frame) >@@ -955,7 +955,7 @@ void MediaPlayerPrivateMediaStreamAVFObjC::updateCurrentFrameImage() > return; > > auto pixelBuffer = static_cast<CVPixelBufferRef>(CMSampleBufferGetImageBuffer(m_imagePainter.mediaSample->platformSample().sample.cmSampleBuffer)); >- m_imagePainter.cgImage = m_imagePainter.pixelBufferConformer->createImageFromPixelBuffer(pixelBuffer); >+ m_imagePainter.cgImage = NativeImage::create(m_imagePainter.pixelBufferConformer->createImageFromPixelBuffer(pixelBuffer)); > } > > void MediaPlayerPrivateMediaStreamAVFObjC::paintCurrentFrameInContext(GraphicsContext& context, const FloatRect& destRect) >@@ -975,14 +975,14 @@ void MediaPlayerPrivateMediaStreamAVFObjC::paintCurrentFrameInContext(GraphicsCo > if (!m_imagePainter.cgImage || !m_imagePainter.mediaSample) > return; > >- auto image = m_imagePainter.cgImage.get(); >- FloatRect imageRect(0, 0, CGImageGetWidth(image), CGImageGetHeight(image)); >+ auto& image = m_imagePainter.cgImage; >+ FloatRect imageRect({ 0, 0 }, image->size()); > if (!m_videoTransform) > m_videoTransform = videoTransformationMatrix(*m_imagePainter.mediaSample); > AffineTransform videoTransform = *m_videoTransform; > FloatRect transformedDestRect = videoTransform.inverse().valueOr(AffineTransform()).mapRect(destRect); > context.concatCTM(videoTransform); >- context.drawNativeImage(image, imageRect.size(), transformedDestRect, imageRect); >+ context.drawNativeImage(*image, imageRect.size(), transformedDestRect, imageRect); > } > > void MediaPlayerPrivateMediaStreamAVFObjC::acceleratedRenderingStateChanged() >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/VideoLayerManagerObjC.h b/Source/WebCore/platform/graphics/avfoundation/objc/VideoLayerManagerObjC.h >index 99d85b3f2dc8e78a56d2b9117dcfb3cf80bf7585..b69b10708967f875db80aec9d09c36cdb3ac2db3 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/VideoLayerManagerObjC.h >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/VideoLayerManagerObjC.h >@@ -63,10 +63,10 @@ public: > > #if ENABLE(VIDEO_PRESENTATION_MODE) > WEBCORE_EXPORT PlatformLayer* videoFullscreenLayer() const final; >- WEBCORE_EXPORT void setVideoFullscreenLayer(PlatformLayer*, WTF::Function<void()>&& completionHandler, NativeImagePtr) final; >+ WEBCORE_EXPORT void setVideoFullscreenLayer(PlatformLayer*, WTF::Function<void()>&& completionHandler, PlatformImagePtr) final; > WEBCORE_EXPORT FloatRect videoFullscreenFrame() const final; > WEBCORE_EXPORT void setVideoFullscreenFrame(FloatRect) final; >- WEBCORE_EXPORT void updateVideoFullscreenInlineImage(NativeImagePtr) final; >+ WEBCORE_EXPORT void updateVideoFullscreenInlineImage(PlatformImagePtr) final; > #endif > > WEBCORE_EXPORT bool requiresTextTrackRepresentation() const final; >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/VideoLayerManagerObjC.mm b/Source/WebCore/platform/graphics/avfoundation/objc/VideoLayerManagerObjC.mm >index f67953d6313b7d9b62ac6d1a6e656b808847704d..f118db5c3c5cbebede411ea54d5eaf6eca2af7c3 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/VideoLayerManagerObjC.mm >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/VideoLayerManagerObjC.mm >@@ -103,7 +103,7 @@ PlatformLayer* VideoLayerManagerObjC::videoFullscreenLayer() const > return m_videoFullscreenLayer.get(); > } > >-void VideoLayerManagerObjC::setVideoFullscreenLayer(PlatformLayer *videoFullscreenLayer, WTF::Function<void()>&& completionHandler, NativeImagePtr currentImage) >+void VideoLayerManagerObjC::setVideoFullscreenLayer(PlatformLayer *videoFullscreenLayer, WTF::Function<void()>&& completionHandler, PlatformImagePtr currentImage) > { > if (m_videoFullscreenLayer == videoFullscreenLayer) { > completionHandler(); >@@ -167,7 +167,7 @@ void VideoLayerManagerObjC::setVideoFullscreenFrame(FloatRect videoFullscreenFra > syncTextTrackBounds(); > } > >-void VideoLayerManagerObjC::updateVideoFullscreenInlineImage(NativeImagePtr image) >+void VideoLayerManagerObjC::updateVideoFullscreenInlineImage(PlatformImagePtr image) > { > if (m_videoInlineLayer) > [m_videoInlineLayer setContents:(__bridge id)image.get()]; >diff --git a/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp b/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp >index c0069bdcfbd61ff7658eacd106082ae0c6fd20d2..3c8f7c02a399d1afd87d6ef76cee1b03f1eca3c4 100644 >--- a/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp >+++ b/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp >@@ -2593,7 +2593,7 @@ void GraphicsLayerCA::updateContentsImage() > // FIXME: maybe only do trilinear if the image is being scaled down, > // but then what if the layer size changes? > m_contentsLayer->setMinificationFilter(PlatformCALayer::Trilinear); >- m_contentsLayer->setContents(m_pendingContentsImage.get()); >+ m_contentsLayer->setContents(m_pendingContentsImage->platformImage().get()); > m_pendingContentsImage = nullptr; > > if (m_layerClones) { >diff --git a/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h b/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h >index 885f799f6f11d4f9551f55ac46fce3ce4e8ce961..aef3c268f5d124d479e6dffad8c3473dc99e6a3a 100644 >--- a/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h >+++ b/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h >@@ -46,6 +46,7 @@ class DisplayList; > > class FloatRoundedRect; > class Image; >+class NativeImage; > class TransformState; > > class GraphicsLayerCA : public GraphicsLayer, public PlatformCALayerClient { >@@ -600,8 +601,8 @@ private: > > Color m_contentsSolidColor; > >- RetainPtr<CGImageRef> m_uncorrectedContentsImage; >- RetainPtr<CGImageRef> m_pendingContentsImage; >+ RefPtr<NativeImage> m_uncorrectedContentsImage; >+ RefPtr<NativeImage> m_pendingContentsImage; > > Vector<LayerPropertyAnimation> m_animations; > Vector<LayerPropertyAnimation> m_baseValueTransformAnimations; >diff --git a/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp b/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp >index 9a57ebe2d55a079c37f1cab96a7fb73f5bf439ba..b8f745ab70d0e1c33b2e248fa55a7123add75b50 100644 >--- a/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp >+++ b/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp >@@ -174,16 +174,16 @@ enum PathDrawingStyle { > > static void drawShadowLayerBuffer(PlatformContextCairo& platformContext, ImageBuffer& layerImage, const FloatPoint& layerOrigin, const FloatSize& layerSize, const ShadowState& shadowState) > { >- if (auto surface = layerImage.copyNativeImage(DontCopyBackingStore)) { >- drawNativeImage(platformContext, surface.get(), FloatRect(roundedIntPoint(layerOrigin), layerSize), FloatRect(FloatPoint(), layerSize), { shadowState.globalCompositeOperator }, shadowState.globalAlpha, ShadowState()); >+ if (auto nativeImage = layerImage.copyNativeImage(DontCopyBackingStore)) { >+ drawNativeImage(platformContext, *nativeImage, FloatRect(roundedIntPoint(layerOrigin), layerSize), FloatRect(FloatPoint(), layerSize), { shadowState.globalCompositeOperator }, shadowState.globalAlpha, ShadowState()); > } > } > > // FIXME: This is mostly same as drawShadowLayerBuffer, so we should merge two. > static void drawShadowImage(PlatformContextCairo& platformContext, ImageBuffer& layerImage, const FloatRect& destRect, const FloatRect& srcRect, const ShadowState& shadowState) > { >- if (auto surface = layerImage.copyNativeImage(DontCopyBackingStore)) { >- drawNativeImage(platformContext, surface.get(), destRect, srcRect, { shadowState.globalCompositeOperator }, shadowState.globalAlpha, ShadowState()); >+ if (auto nativeImage = layerImage.copyNativeImage(DontCopyBackingStore)) { >+ drawNativeImage(platformContext, *nativeImage, destRect, srcRect, { shadowState.globalCompositeOperator }, shadowState.globalAlpha, ShadowState()); > } > } > >@@ -860,7 +860,13 @@ void drawGlyphs(PlatformContextCairo& platformContext, const FillSource& fillSou > cairo_restore(cr); > } > >-void drawNativeImage(PlatformContextCairo& platformContext, cairo_surface_t* surface, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options, float globalAlpha, const ShadowState& shadowState) >+void drawNativeImage(PlatformContextCairo& platformContext, nativeImage& nativeImage, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options, float globalAlpha, const ShadowState& shadowState) >+{ >+ if (auto surface = nativeImage.platformImage()) >+ drawPlatformImage(platformContext, surface->get(), destRect, srcRect, options, globalAlpha, shadowState); >+} >+ >+void drawPlatformImage(PlatformContextCairo& platformContext, cairo_surface_t* surface, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options, float globalAlpha, const ShadowState& shadowState) > { > platformContext.save(); > >diff --git a/Source/WebCore/platform/graphics/cairo/CairoOperations.h b/Source/WebCore/platform/graphics/cairo/CairoOperations.h >index 505c0af47d7a0a50e9c19066dd93de5961d6691a..c888121495a2e2d92f0c34cecf6660a46f9af69b 100644 >--- a/Source/WebCore/platform/graphics/cairo/CairoOperations.h >+++ b/Source/WebCore/platform/graphics/cairo/CairoOperations.h >@@ -143,7 +143,8 @@ void clearRect(PlatformContextCairo&, const FloatRect&); > > void drawGlyphs(PlatformContextCairo&, const FillSource&, const StrokeSource&, const ShadowState&, const FloatPoint&, cairo_scaled_font_t*, double, const Vector<cairo_glyph_t>&, float, TextDrawingModeFlags, float, const FloatSize&, const Color&, FontSmoothingMode); > >-void drawNativeImage(PlatformContextCairo&, cairo_surface_t*, const FloatRect&, const FloatRect&, const ImagePaintingOptions&, float, const ShadowState&); >+void drawNativeImage(PlatformContextCairo&, NativeImage&, const FloatRect&, const FloatRect&, const ImagePaintingOptions&, float, const ShadowState&); >+void drawPlatformImage(PlatformContextCairo&, cairo_surface_t*, const FloatRect&, const FloatRect&, const ImagePaintingOptions&, float, const ShadowState&); > void drawPattern(PlatformContextCairo&, cairo_surface_t*, const IntSize&, const FloatRect&, const FloatRect&, const AffineTransform&, const FloatPoint&, const ImagePaintingOptions&); > WEBCORE_EXPORT void drawSurface(PlatformContextCairo&, cairo_surface_t*, const FloatRect&, const FloatRect&, InterpolationQuality, float, const ShadowState&, OrientationSizing operationSizing = OrientationSizing::Normal); > >diff --git a/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp b/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp >index 9d408f6e5e78f0c7076820d06a55ba5c558248c3..deac8c83f83220e6b153aea0ad0ba0a3ae7a9161 100644 >--- a/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp >+++ b/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp >@@ -123,14 +123,19 @@ void GraphicsContext::drawRect(const FloatRect& rect, float borderThickness) > Cairo::drawRect(*platformContext(), rect, borderThickness, state.fillColor, state.strokeStyle, state.strokeColor); > } > >-void GraphicsContext::platformDrawNativeImage(const NativeImagePtr& image, const FloatSize&, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) >+void GraphicsContext::drawPlatformImage(const PlatformImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) > { > if (paintingDisabled()) > return; > >+ if (m_impl) { >+ m_impl->drawPlatformImage(image, imageSize, destRect, srcRect, options); >+ return; >+ } >+ > ASSERT(hasPlatformContext()); > auto& state = this->state(); >- Cairo::drawNativeImage(*platformContext(), image.get(), destRect, srcRect, { options, state.imageInterpolationQuality }, state.alpha, Cairo::ShadowState(state)); >+ Cairo::drawPlatformImage(*platformContext(), image.get(), destRect, srcRect, { options, state.imageInterpolationQuality }, state.alpha, Cairo::ShadowState(state)); > } > > // This is only used to draw borders, so we should not draw shadows. >diff --git a/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp b/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp >index 8ef4f786b7249142456eff1f0ad8216cc9055367..586518926373a0c227609fbe67d08f19081e625e 100644 >--- a/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp >+++ b/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp >@@ -285,17 +285,22 @@ bool GraphicsContextImplCairo::drawImageBuffer(ImageBuffer&, const FloatRect&, c > return false; > } > >-void GraphicsContextImplCairo::drawNativeImage(const NativeImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) >+bool GraphicsContextImplCairo::drawNativeImage(NativeImage& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) >+{ >+ drawPlatformImage(image.platformImage(), imageSize, destRect, srcRect, options); >+} >+ >+void GraphicsContextImplCairo::drawPlatformImage(const PlatformImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) > { > UNUSED_PARAM(imageSize); > auto& state = graphicsContext().state(); >- Cairo::drawNativeImage(m_platformContext, image.get(), destRect, srcRect, { options, state.imageInterpolationQuality }, state.alpha, Cairo::ShadowState(state)); >+ Cairo::drawPlatformImage(m_platformContext, image.get(), destRect, srcRect, { options, state.imageInterpolationQuality }, state.alpha, Cairo::ShadowState(state)); > } > > void GraphicsContextImplCairo::drawPattern(Image& image, const FloatRect& destRect, const FloatRect& tileRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize&, const ImagePaintingOptions& options) > { > if (auto surface = image.nativeImageForCurrentFrame()) >- Cairo::drawPattern(m_platformContext, surface.get(), IntSize(image.size()), destRect, tileRect, patternTransform, phase, options); >+ Cairo::drawPattern(m_platformContext, surface->platformImage().get(), IntSize(image.size()), destRect, tileRect, patternTransform, phase, options); > } > > void GraphicsContextImplCairo::drawRect(const FloatRect& rect, float borderThickness) >@@ -421,7 +426,7 @@ IntRect GraphicsContextImplCairo::clipBounds() > void GraphicsContextImplCairo::clipToImageBuffer(ImageBuffer& buffer, const FloatRect& destRect) > { > if (auto surface = buffer.copyNativeImage(DontCopyBackingStore)) >- Cairo::clipToImageBuffer(m_platformContext, surface.get(), destRect); >+ Cairo::clipToImageBuffer(m_platformContext, surface->platformImage().get(), destRect); > } > > void GraphicsContextImplCairo::applyDeviceScaleFactor(float) >diff --git a/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.h b/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.h >index 1c827130c2a5fe28f7535e1945a33dc968620514..b9fa24f957ded877856f98f96ec8b872a0028b6e 100644 >--- a/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.h >+++ b/Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.h >@@ -76,7 +76,8 @@ public: > ImageDrawResult drawTiledImage(Image&, const FloatRect&, const FloatRect&, const FloatSize&, Image::TileRule, Image::TileRule, const ImagePaintingOptions&) override; > > bool drawImageBuffer(ImageBuffer&, const FloatRect&, const FloatRect&, const ImagePaintingOptions&) override; >- void drawNativeImage(const NativeImagePtr&, const FloatSize&, const FloatRect&, const FloatRect&, const ImagePaintingOptions&) override; >+ bool drawNativeImage(NativeImage&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) override; >+ void drawPlatformImage(const PlatformImagePtr&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) override; > void drawPattern(Image&, const FloatRect&, const FloatRect&, const AffineTransform&, const FloatPoint&, const FloatSize&, const ImagePaintingOptions&) override; > > void drawRect(const FloatRect&, float) override; >diff --git a/Source/WebCore/platform/graphics/cairo/ImageBufferCairoSurfaceBackend.cpp b/Source/WebCore/platform/graphics/cairo/ImageBufferCairoSurfaceBackend.cpp >index 4f1f75726aa83d84adbb372aef76dfc4c8ef7b85..1d225063aa1f3a9522eac222e7a76ff91f74c353 100644 >--- a/Source/WebCore/platform/graphics/cairo/ImageBufferCairoSurfaceBackend.cpp >+++ b/Source/WebCore/platform/graphics/cairo/ImageBufferCairoSurfaceBackend.cpp >@@ -64,7 +64,7 @@ unsigned ImageBufferCairoSurfaceBackend::bytesPerRow() const > return cairo_image_surface_get_stride(m_surface.get()); > } > >-NativeImagePtr ImageBufferCairoSurfaceBackend::copyNativeImage(BackingStoreCopy copyBehavior) const >+RefPtr<NativeImage> ImageBufferCairoSurfaceBackend::copyNativeImage(BackingStoreCopy copyBehavior) const > { > switch (copyBehavior) { > case CopyBackingStore: { >@@ -77,18 +77,18 @@ NativeImagePtr ImageBufferCairoSurfaceBackend::copyNativeImage(BackingStoreCopy > cairo_set_source_surface(cr.get(), m_surface.get(), 0, 0); > cairo_paint(cr.get()); > >- return copy; >+ return NativeImage::create(copy); > } > > case DontCopyBackingStore: >- return m_surface; >+ return NativeImage::create(m_surface); > } > > ASSERT_NOT_REACHED(); > return nullptr; > } > >-NativeImagePtr ImageBufferCairoSurfaceBackend::cairoSurfaceCoerceToImage() const >+RefPtr<NativeImage> ImageBufferCairoSurfaceBackend::cairoSurfaceCoerceToImage() const > { > BackingStoreCopy copyBehavior; > if (cairo_surface_get_type(m_surface.get()) == CAIRO_SURFACE_TYPE_IMAGE && cairo_surface_get_content(m_surface.get()) == CAIRO_CONTENT_COLOR_ALPHA) >@@ -100,7 +100,8 @@ NativeImagePtr ImageBufferCairoSurfaceBackend::cairoSurfaceCoerceToImage() const > > Vector<uint8_t> ImageBufferCairoSurfaceBackend::toBGRAData() const > { >- auto surface = cairoSurfaceCoerceToImage(); >+ auto nativeImage = cairoSurfaceCoerceToImage(); >+ auto surface = nativeImage ? nativeImage->platformImage() : nullptr; > cairo_surface_flush(surface.get()); > > Vector<uint8_t> imageData; >diff --git a/Source/WebCore/platform/graphics/cairo/ImageBufferCairoSurfaceBackend.h b/Source/WebCore/platform/graphics/cairo/ImageBufferCairoSurfaceBackend.h >index a69d5ee0ff63f7795825dc6766d6d16b7261d65e..2bb4022650cf9c01b46a22f8136ff0cbf5eb2410 100644 >--- a/Source/WebCore/platform/graphics/cairo/ImageBufferCairoSurfaceBackend.h >+++ b/Source/WebCore/platform/graphics/cairo/ImageBufferCairoSurfaceBackend.h >@@ -40,7 +40,7 @@ class ImageBufferCairoSurfaceBackend : public ImageBufferCairoBackend { > public: > GraphicsContext& context() const override; > >- NativeImagePtr copyNativeImage(BackingStoreCopy) const override; >+ RefPtr<NativeImage> copyNativeImage(BackingStoreCopy) const override; > > Vector<uint8_t> toBGRAData() const override; > RefPtr<ImageData> getImageData(AlphaPremultiplication outputFormat, const IntRect&) const override; >@@ -49,7 +49,7 @@ public: > protected: > ImageBufferCairoSurfaceBackend(const FloatSize& logicalSize, const IntSize& backendSize, float resolutionScale, ColorSpace, RefPtr<cairo_surface_t>&&); > >- NativeImagePtr cairoSurfaceCoerceToImage() const; >+ RefPtr<NativeImage> cairoSurfaceCoerceToImage() const; > unsigned bytesPerRow() const override; > > mutable RefPtr<cairo_surface_t> m_surface; >diff --git a/Source/WebCore/platform/graphics/cairo/NativeImageCairo.cpp b/Source/WebCore/platform/graphics/cairo/NativeImageCairo.cpp >index 05c0f81cb34190cb373bd8434158b4d03301ab04..115e0bd0c968d1116d9991567cdcbc49291e392a 100644 >--- a/Source/WebCore/platform/graphics/cairo/NativeImageCairo.cpp >+++ b/Source/WebCore/platform/graphics/cairo/NativeImageCairo.cpp >@@ -35,34 +35,29 @@ > > namespace WebCore { > >-IntSize nativeImageSize(const NativeImagePtr& image) >+IntSize NativeImage::size(const PlatformImagePtr& platformImage) > { >- return image ? cairoSurfaceSize(image.get()) : IntSize(); >+ return platformImage ? cairoSurfaceSize(platformImage.get()) : IntSize(); > } > >-bool nativeImageHasAlpha(const NativeImagePtr& image) >+bool NativeImage::hasAlpha() const > { >- return !image || cairo_surface_get_content(image.get()) != CAIRO_CONTENT_COLOR; >+ return !m_platformImage || cairo_surface_get_content(m_platformImage.get()) != CAIRO_CONTENT_COLOR; > } > >-Color nativeImageSinglePixelSolidColor(const NativeImagePtr& image) >+Color NativeImage::singlePixelSolidColor() const > { >- if (!image || nativeImageSize(image) != IntSize(1, 1)) >+ if (!m_platformImage || size() != IntSize(1, 1)) > return Color(); > >- if (cairo_surface_get_type(image.get()) != CAIRO_SURFACE_TYPE_IMAGE) >+ if (cairo_surface_get_type(m_platformImage.get()) != CAIRO_SURFACE_TYPE_IMAGE) > return Color(); > >- unsigned* pixel = reinterpret_cast_ptr<unsigned*>(cairo_image_surface_get_data(image.get())); >+ unsigned* pixel = reinterpret_cast_ptr<unsigned*>(cairo_image_surface_get_data(m_platformImage.get())); > return unpremultiplied(asSRGBA(PackedColor::ARGB { *pixel })); > } > >-void drawNativeImage(const NativeImagePtr& image, GraphicsContext& context, const FloatRect& destRect, const FloatRect& srcRect, const IntSize& imageSize, const ImagePaintingOptions& options) >-{ >- context.drawNativeImage(image, imageSize, destRect, srcRect, options); >-} >- >-void clearNativeImageSubimages(const NativeImagePtr&) >+void NativeImage::clearSubimages() > { > } > >diff --git a/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp b/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp >index cf8ec29b5ce64a52017b75d090b5f926fd56012a..0a1990aeac293ed10980289852e24ae8e6fc6ea7 100644 >--- a/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp >+++ b/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp >@@ -280,11 +280,16 @@ void GraphicsContext::restorePlatformState() > m_data->m_userToDeviceTransformKnownToBeIdentity = false; > } > >-void GraphicsContext::platformDrawNativeImage(const RetainPtr<CGImageRef>& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) >+void GraphicsContext::drawPlatformImage(const PlatformImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) > { > if (paintingDisabled()) > return; > >+ if (m_impl) { >+ m_impl->drawPlatformImage(image, imageSize, destRect, srcRect, options); >+ return; >+ } >+ > #if !LOG_DISABLED > MonotonicTime startTime = MonotonicTime::now(); > #endif >@@ -447,23 +452,23 @@ void GraphicsContext::drawPattern(Image& image, const FloatRect& destRect, const > > auto tileImage = image.preTransformedNativeImageForCurrentFrame(options.orientation() == ImageOrientation::FromImage); > >- float h = CGImageGetHeight(tileImage.get()); >+ float h = CGImageGetHeight(tileImage->platformImage().get()); > > RetainPtr<CGImageRef> subImage; > FloatSize imageSize = image.size(); > if (tileRect.size() == imageSize) >- subImage = tileImage; >+ subImage = tileImage->platformImage(); > else { > // Copying a sub-image out of a partially-decoded image stops the decoding of the original image. It should never happen > // because sub-images are only used for border-image, which only renders when the image is fully decoded. > ASSERT(h == image.height()); >- subImage = adoptCF(CGImageCreateWithImageInRect(tileImage.get(), tileRect)); >+ subImage = adoptCF(CGImageCreateWithImageInRect(tileImage->platformImage().get(), tileRect)); > } > > // If we need to paint gaps between tiles because we have a partially loaded image or non-zero spacing, > // fall back to the less efficient CGPattern-based mechanism. > float scaledTileWidth = tileRect.width() * narrowPrecisionToFloat(patternTransform.a()); >- float w = CGImageGetWidth(tileImage.get()); >+ float w = CGImageGetWidth(tileImage->platformImage().get()); > if (w == image.size().width() && h == image.size().height() && !spacing.width() && !spacing.height()) { > // FIXME: CG seems to snap the images to integral sizes. When we care (e.g. with border-image-repeat: round), > // we should tile all but the last, and stetch the last image to fit. >@@ -512,7 +517,8 @@ void GraphicsContext::clipToImageBuffer(ImageBuffer& buffer, const FloatRect& de > } > > FloatSize bufferDestinationSize = destinationRect.size(); >- RetainPtr<CGImageRef> image = buffer.copyNativeImage(DontCopyBackingStore); >+ auto nativeImage = buffer.copyNativeImage(DontCopyBackingStore); >+ RetainPtr<CGImageRef> image = nativeImage ? nativeImage->platformImage() : nullptr; > > CGContextRef context = platformContext(); > // FIXME: This image needs to be grayscale to be used as an alpha mask here. >diff --git a/Source/WebCore/platform/graphics/cg/GraphicsContextGLCG.cpp b/Source/WebCore/platform/graphics/cg/GraphicsContextGLCG.cpp >index bb91dec91224d4197eca81bbdbc4e0567e43c04d..04039469135c35555242ec5b9f7a2f86309c200a 100644 >--- a/Source/WebCore/platform/graphics/cg/GraphicsContextGLCG.cpp >+++ b/Source/WebCore/platform/graphics/cg/GraphicsContextGLCG.cpp >@@ -338,8 +338,9 @@ bool GraphicsContextGLImageExtractor::extractImage(bool premultiplyAlpha, bool i > if (!m_cgImage) > return false; > >- m_imageWidth = CGImageGetWidth(m_cgImage.get()); >- m_imageHeight = CGImageGetHeight(m_cgImage.get()); >+ RetainPtr<CGImageRef> image = m_cgImage->platformImage(); >+ m_imageWidth = CGImageGetWidth(image.get()); >+ m_imageHeight = CGImageGetHeight(image.get()); > if (!m_imageWidth || !m_imageHeight) > return false; > >@@ -347,7 +348,7 @@ bool GraphicsContextGLImageExtractor::extractImage(bool premultiplyAlpha, bool i > // so, re-render it into an RGB color space. The image re-packing > // code requires color data, not color table indices, for the > // image data. >- CGColorSpaceRef colorSpace = CGImageGetColorSpace(m_cgImage.get()); >+ CGColorSpaceRef colorSpace = CGImageGetColorSpace(image.get()); > CGColorSpaceModel model = CGColorSpaceGetModel(colorSpace); > if (model == kCGColorSpaceModelIndexed) { > RetainPtr<CGContextRef> bitmapContext; >@@ -362,22 +363,26 @@ bool GraphicsContextGLImageExtractor::extractImage(bool premultiplyAlpha, bool i > > CGContextSetBlendMode(bitmapContext.get(), kCGBlendModeCopy); > CGContextSetInterpolationQuality(bitmapContext.get(), kCGInterpolationNone); >- CGContextDrawImage(bitmapContext.get(), CGRectMake(0, 0, m_imageWidth, m_imageHeight), m_cgImage.get()); >+ CGContextDrawImage(bitmapContext.get(), CGRectMake(0, 0, m_imageWidth, m_imageHeight), image.get()); > > // Now discard the original CG image and replace it with a copy from the bitmap context. >- m_decodedImage = adoptCF(CGBitmapContextCreateImage(bitmapContext.get())); >- m_cgImage = m_decodedImage.get(); >+ m_decodedImage = NativeImage::create(CGBitmapContextCreateImage(bitmapContext.get())); >+ m_cgImage = m_decodedImage; > } > >- size_t bitsPerComponent = CGImageGetBitsPerComponent(m_cgImage.get()); >- size_t bitsPerPixel = CGImageGetBitsPerPixel(m_cgImage.get()); >+ if (!m_cgImage) >+ return false; >+ >+ image = m_cgImage->platformImage(); >+ size_t bitsPerComponent = CGImageGetBitsPerComponent(image.get()); >+ size_t bitsPerPixel = CGImageGetBitsPerPixel(image.get()); > if (bitsPerComponent != 8 && bitsPerComponent != 16) > return false; > if (bitsPerPixel % bitsPerComponent) > return false; > size_t componentsPerPixel = bitsPerPixel / bitsPerComponent; > >- CGBitmapInfo bitInfo = CGImageGetBitmapInfo(m_cgImage.get()); >+ CGBitmapInfo bitInfo = CGImageGetBitmapInfo(image.get()); > bool bigEndianSource = false; > // These could technically be combined into one large switch > // statement, but we prefer not to so that we fail fast if we >@@ -419,7 +424,7 @@ bool GraphicsContextGLImageExtractor::extractImage(bool premultiplyAlpha, bool i > > m_alphaOp = AlphaOp::DoNothing; > AlphaFormat alphaFormat = AlphaFormatNone; >- switch (CGImageGetAlphaInfo(m_cgImage.get())) { >+ switch (CGImageGetAlphaInfo(image.get())) { > case kCGImageAlphaPremultipliedFirst: > if (!premultiplyAlpha) > m_alphaOp = AlphaOp::DoUnmultiply; >@@ -463,14 +468,14 @@ bool GraphicsContextGLImageExtractor::extractImage(bool premultiplyAlpha, bool i > if (m_imageSourceFormat == DataFormat::NumFormats) > return false; > >- m_pixelData = adoptCF(CGDataProviderCopyData(CGImageGetDataProvider(m_cgImage.get()))); >+ m_pixelData = adoptCF(CGDataProviderCopyData(CGImageGetDataProvider(image.get()))); > if (!m_pixelData) > return false; > > m_imagePixelData = reinterpret_cast<const void*>(CFDataGetBytePtr(m_pixelData.get())); > > unsigned srcUnpackAlignment = 0; >- size_t bytesPerRow = CGImageGetBytesPerRow(m_cgImage.get()); >+ size_t bytesPerRow = CGImageGetBytesPerRow(image.get()); > unsigned padding = bytesPerRow - bitsPerPixel / 8 * m_imageWidth; > if (padding) { > srcUnpackAlignment = padding + 1; >@@ -543,7 +548,7 @@ void GraphicsContextGLOpenGL::paintToCanvas(const unsigned char* imagePixels, co > context.scale(FloatSize(1, -1)); > context.translate(0, -imageSize.height()); > context.setImageInterpolationQuality(InterpolationQuality::DoNotInterpolate); >- context.drawNativeImage(cgImage, imageSize, canvasRect, FloatRect(FloatPoint(), imageSize), { CompositeOperator::Copy }); >+ context.drawPlatformImage(cgImage, imageSize, canvasRect, FloatRect(FloatPoint(), imageSize), { CompositeOperator::Copy }); > } > > } // namespace WebCore >diff --git a/Source/WebCore/platform/graphics/cg/ImageBufferCGBackend.cpp b/Source/WebCore/platform/graphics/cg/ImageBufferCGBackend.cpp >index 5b20d892ed8bbcf601816a63676a00f1fa5c17b3..54b878b43476e19bd6f6171f8b49627763e0fb1b 100644 >--- a/Source/WebCore/platform/graphics/cg/ImageBufferCGBackend.cpp >+++ b/Source/WebCore/platform/graphics/cg/ImageBufferCGBackend.cpp >@@ -67,24 +67,24 @@ void ImageBufferCGBackend::setupContext() > context().applyDeviceScaleFactor(m_resolutionScale); > } > >-static RetainPtr<CGImageRef> createCroppedImageIfNecessary(CGImageRef image, const IntSize& backendSize) >+static RefPtr<NativeImage> createCroppedImageIfNecessary(RefPtr<NativeImage>&& image, const IntSize& backendSize) > { >- if (image && (CGImageGetWidth(image) != static_cast<size_t>(backendSize.width()) || CGImageGetHeight(image) != static_cast<size_t>(backendSize.height()))) >- return adoptCF(CGImageCreateWithImageInRect(image, CGRectMake(0, 0, backendSize.width(), backendSize.height()))); >- return image; >+ if (image && image->size() != backendSize) >+ return NativeImage::create(CGImageCreateWithImageInRect(image->platformImage().get(), CGRectMake(0, 0, backendSize.width(), backendSize.height()))); >+ return WTFMove(image); > } > >-static RefPtr<Image> createBitmapImageAfterScalingIfNeeded(RetainPtr<CGImageRef>&& image, const IntSize& logicalSize, const IntSize& backendSize, float resolutionScale, PreserveResolution preserveResolution) >+static RefPtr<Image> createBitmapImageAfterScalingIfNeeded(RefPtr<NativeImage>&& image, const IntSize& logicalSize, const IntSize& backendSize, float resolutionScale, PreserveResolution preserveResolution) > { > if (resolutionScale == 1 || preserveResolution == PreserveResolution::Yes) >- image = createCroppedImageIfNecessary(image.get(), backendSize); >+ image = createCroppedImageIfNecessary(WTFMove(image), backendSize); > else { > auto context = adoptCF(CGBitmapContextCreate(0, logicalSize.width(), logicalSize.height(), 8, 4 * logicalSize.width(), sRGBColorSpaceRef(), kCGImageAlphaPremultipliedLast)); > CGContextSetBlendMode(context.get(), kCGBlendModeCopy); > CGContextClipToRect(context.get(), FloatRect(FloatPoint::zero(), logicalSize)); > FloatSize imageSizeInUserSpace = logicalSize; >- CGContextDrawImage(context.get(), FloatRect(FloatPoint::zero(), imageSizeInUserSpace), image.get()); >- image = adoptCF(CGBitmapContextCreateImage(context.get())); >+ CGContextDrawImage(context.get(), FloatRect(FloatPoint::zero(), imageSizeInUserSpace), image->platformImage().get()); >+ image = NativeImage::create(CGBitmapContextCreateImage(context.get())); > } > > if (!image) >@@ -95,7 +95,7 @@ static RefPtr<Image> createBitmapImageAfterScalingIfNeeded(RetainPtr<CGImageRef> > > RefPtr<Image> ImageBufferCGBackend::copyImage(BackingStoreCopy copyBehavior, PreserveResolution preserveResolution) const > { >- NativeImagePtr image; >+ RefPtr<NativeImage> image; > if (m_resolutionScale == 1 || preserveResolution == PreserveResolution::Yes) > image = copyNativeImage(copyBehavior); > else >@@ -114,7 +114,7 @@ void ImageBufferCGBackend::draw(GraphicsContext& destContext, const FloatRect& d > srcRectScaled.scale(m_resolutionScale); > > if (auto image = copyNativeImage(&destContext == &context() ? CopyBackingStore : DontCopyBackingStore)) >- destContext.drawNativeImage(image.get(), m_backendSize, destRect, srcRectScaled, options); >+ destContext.drawNativeImage(*image, m_backendSize, destRect, srcRectScaled, options); > } > > void ImageBufferCGBackend::drawPattern(GraphicsContext& destContext, const FloatRect& destRect, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& options) >@@ -138,7 +138,7 @@ RetainPtr<CFDataRef> ImageBufferCGBackend::toCFData(const String& mimeType, Opti > auto uti = utiFromImageBufferMIMEType(mimeType); > ASSERT(uti); > >- RetainPtr<CGImageRef> image; >+ RefPtr<NativeImage> image; > RefPtr<Uint8ClampedArray> protectedPixelArray; > > if (CFEqual(uti.get(), jpegUTI())) { >@@ -156,7 +156,7 @@ RetainPtr<CFDataRef> ImageBufferCGBackend::toCFData(const String& mimeType, Opti > if (!dataProvider) > return nullptr; > >- image = adoptCF(CGImageCreate(pixelArrayDimensions.width(), pixelArrayDimensions.height(), 8, 32, 4 * pixelArrayDimensions.width(), sRGBColorSpaceRef(), kCGBitmapByteOrderDefault | kCGImageAlphaNoneSkipLast, dataProvider.get(), 0, false, kCGRenderingIntentDefault)); >+ image = NativeImage::create(CGImageCreate(pixelArrayDimensions.width(), pixelArrayDimensions.height(), 8, 32, 4 * pixelArrayDimensions.width(), sRGBColorSpaceRef(), kCGBitmapByteOrderDefault | kCGImageAlphaNoneSkipLast, dataProvider.get(), 0, false, kCGRenderingIntentDefault)); > } else if (m_resolutionScale == 1 || preserveResolution == PreserveResolution::Yes) { > image = copyNativeImage(CopyBackingStore); > image = createCroppedImageIfNecessary(image.get(), backendSize()); >@@ -165,12 +165,12 @@ RetainPtr<CFDataRef> ImageBufferCGBackend::toCFData(const String& mimeType, Opti > auto context = adoptCF(CGBitmapContextCreate(0, backendSize().width(), backendSize().height(), 8, 4 * backendSize().width(), sRGBColorSpaceRef(), kCGImageAlphaPremultipliedLast)); > CGContextSetBlendMode(context.get(), kCGBlendModeCopy); > CGContextClipToRect(context.get(), CGRectMake(0, 0, backendSize().width(), backendSize().height())); >- CGContextDrawImage(context.get(), CGRectMake(0, 0, backendSize().width(), backendSize().height()), image.get()); >- image = adoptCF(CGBitmapContextCreateImage(context.get())); >+ CGContextDrawImage(context.get(), CGRectMake(0, 0, backendSize().width(), backendSize().height()), image->platformImage().get()); >+ image = NativeImage::create(CGBitmapContextCreateImage(context.get())); > } > > auto cfData = adoptCF(CFDataCreateMutable(kCFAllocatorDefault, 0)); >- if (!encodeImage(image.get(), uti.get(), quality, cfData.get())) >+ if (!encodeImage(image->platformImage().get(), uti.get(), quality, cfData.get())) > return nullptr; > > return WTFMove(cfData); >diff --git a/Source/WebCore/platform/graphics/cg/ImageBufferCGBitmapBackend.cpp b/Source/WebCore/platform/graphics/cg/ImageBufferCGBitmapBackend.cpp >index ffef66330d1fbe26c4c8f023ff94e78852c6c920..356eb5263374070883a293d650c6854b47efd925 100644 >--- a/Source/WebCore/platform/graphics/cg/ImageBufferCGBitmapBackend.cpp >+++ b/Source/WebCore/platform/graphics/cg/ImageBufferCGBitmapBackend.cpp >@@ -107,14 +107,14 @@ GraphicsContext& ImageBufferCGBitmapBackend::context() const > return *m_context; > } > >-NativeImagePtr ImageBufferCGBitmapBackend::copyNativeImage(BackingStoreCopy copyBehavior) const >+RefPtr<NativeImage> ImageBufferCGBitmapBackend::copyNativeImage(BackingStoreCopy copyBehavior) const > { > switch (copyBehavior) { > case CopyBackingStore: >- return adoptCF(CGBitmapContextCreateImage(context().platformContext())); >+ return NativeImage::create(CGBitmapContextCreateImage(context().platformContext())); > > case DontCopyBackingStore: >- return adoptCF(CGImageCreate( >+ return NativeImage::create(CGImageCreate( > m_backendSize.width(), m_backendSize.height(), 8, 32, bytesPerRow(), > cachedCGColorSpace(m_colorSpace), DefaultBitmapInfo, m_dataProvider.get(), > 0, true, kCGRenderingIntentDefault)); >diff --git a/Source/WebCore/platform/graphics/cg/ImageBufferCGBitmapBackend.h b/Source/WebCore/platform/graphics/cg/ImageBufferCGBitmapBackend.h >index b9bd7f1bab47ff7c797434833c27a54973108285..7d233d222785ad3ddf063c4a8648fdfface7cf99 100644 >--- a/Source/WebCore/platform/graphics/cg/ImageBufferCGBitmapBackend.h >+++ b/Source/WebCore/platform/graphics/cg/ImageBufferCGBitmapBackend.h >@@ -42,7 +42,7 @@ public: > > GraphicsContext& context() const override; > >- NativeImagePtr copyNativeImage(BackingStoreCopy = CopyBackingStore) const override; >+ RefPtr<NativeImage> copyNativeImage(BackingStoreCopy = CopyBackingStore) const override; > > Vector<uint8_t> toBGRAData() const override; > >diff --git a/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp b/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp >index dbc3b7eb8b3d1ad88d0ab3f0eef90a7c8d85e030..a9d5485a261b5a0df53d2b89710ae837fbf9b1ae 100644 >--- a/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp >+++ b/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp >@@ -135,14 +135,14 @@ ColorFormat ImageBufferIOSurfaceBackend::backendColorFormat() const > return ColorFormat::BGRA; > } > >-NativeImagePtr ImageBufferIOSurfaceBackend::copyNativeImage(BackingStoreCopy) const >+RefPtr<NativeImage> ImageBufferIOSurfaceBackend::copyNativeImage(BackingStoreCopy) const > { >- return m_surface->createImage(); >+ return NativeImage::create(m_surface->createImage()); > } > >-NativeImagePtr ImageBufferIOSurfaceBackend::sinkIntoNativeImage() >+RefPtr<NativeImage> ImageBufferIOSurfaceBackend::sinkIntoNativeImage() > { >- return IOSurface::sinkIntoImage(WTFMove(m_surface)); >+ return NativeImage::create(IOSurface::sinkIntoImage(WTFMove(m_surface))); > } > > void ImageBufferIOSurfaceBackend::drawConsuming(GraphicsContext& destContext, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) >@@ -151,7 +151,7 @@ void ImageBufferIOSurfaceBackend::drawConsuming(GraphicsContext& destContext, co > adjustedSrcRect.scale(m_resolutionScale); > > if (auto image = sinkIntoNativeImage()) >- destContext.drawNativeImage(image.get(), m_backendSize, destRect, adjustedSrcRect, options); >+ destContext.drawNativeImage(*image, m_backendSize, destRect, adjustedSrcRect, options); > } > > RetainPtr<CFDataRef> ImageBufferIOSurfaceBackend::toCFData(const String& mimeType, Optional<double> quality, PreserveResolution preserveResolution) const >diff --git a/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.h b/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.h >index 323094ea795c5d2483c884403124a9040cc740fb..f509eee65a722e1201ffc0fb577cfb82bfec690c 100644 >--- a/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.h >+++ b/Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.h >@@ -51,8 +51,8 @@ public: > size_t memoryCost() const override; > size_t externalMemoryCost() const override; > >- NativeImagePtr copyNativeImage(BackingStoreCopy = CopyBackingStore) const override; >- NativeImagePtr sinkIntoNativeImage() override; >+ RefPtr<NativeImage> copyNativeImage(BackingStoreCopy = CopyBackingStore) const override; >+ RefPtr<NativeImage> sinkIntoNativeImage() override; > > void drawConsuming(GraphicsContext&, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) override; > >diff --git a/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp b/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp >index 890a071810923f75ba0e2293c46bea87445aba0c..cdaf15c109dc797297e9b10294370a1e27506ffc 100644 >--- a/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp >+++ b/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp >@@ -492,7 +492,7 @@ unsigned ImageDecoderCG::frameBytesAtIndex(size_t index, SubsamplingLevel subsam > return (frameSize.area() * 4).unsafeGet(); > } > >-NativeImagePtr ImageDecoderCG::createFrameImageAtIndex(size_t index, SubsamplingLevel subsamplingLevel, const DecodingOptions& decodingOptions) >+PlatformImagePtr ImageDecoderCG::createFrameImageAtIndex(size_t index, SubsamplingLevel subsamplingLevel, const DecodingOptions& decodingOptions) > { > LOG(Images, "ImageDecoder %p createFrameImageAtIndex %lu", this, index); > RetainPtr<CFDictionaryRef> options; >diff --git a/Source/WebCore/platform/graphics/cg/ImageDecoderCG.h b/Source/WebCore/platform/graphics/cg/ImageDecoderCG.h >index 4679251135951cd1b538bddf1ece54506ddf6b3b..8ba3009d3b6b634973baf8e9a19057313d551675 100644 >--- a/Source/WebCore/platform/graphics/cg/ImageDecoderCG.h >+++ b/Source/WebCore/platform/graphics/cg/ImageDecoderCG.h >@@ -62,7 +62,7 @@ public: > bool frameAllowSubsamplingAtIndex(size_t) const final; > unsigned frameBytesAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default) const final; > >- NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingOptions(DecodingMode::Synchronous)) final; >+ PlatformImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingOptions(DecodingMode::Synchronous)) final; > > void setData(SharedBuffer&, bool allDataReceived) final; > bool isAllDataReceived() const final { return m_isAllDataReceived; } >diff --git a/Source/WebCore/platform/graphics/cg/NativeImageCG.cpp b/Source/WebCore/platform/graphics/cg/NativeImageCG.cpp >index 400d6ef0a4577d5d7cc5bd9cb646a5badebdadc2..f2fce4aa4b771dae3fb42d5dbe3aa11fb0e6a12f 100644 >--- a/Source/WebCore/platform/graphics/cg/NativeImageCG.cpp >+++ b/Source/WebCore/platform/graphics/cg/NativeImageCG.cpp >@@ -37,20 +37,20 @@ > > namespace WebCore { > >-IntSize nativeImageSize(const NativeImagePtr& image) >+IntSize NativeImage::size(const PlatformImagePtr& platformImage) > { >- return image ? IntSize(CGImageGetWidth(image.get()), CGImageGetHeight(image.get())) : IntSize(); >+ return platformImage ? IntSize(CGImageGetWidth(platformImage.get()), CGImageGetHeight(platformImage.get())) : IntSize(); > } > >-bool nativeImageHasAlpha(const NativeImagePtr& image) >+bool NativeImage::hasAlpha() const > { >- CGImageAlphaInfo info = CGImageGetAlphaInfo(image.get()); >+ CGImageAlphaInfo info = CGImageGetAlphaInfo(m_platformImage.get()); > return (info >= kCGImageAlphaPremultipliedLast) && (info <= kCGImageAlphaFirst); > } > >-Color nativeImageSinglePixelSolidColor(const NativeImagePtr& image) >+Color NativeImage::singlePixelSolidColor() const > { >- if (!image || nativeImageSize(image) != IntSize(1, 1)) >+ if (!m_platformImage || size() != IntSize(1, 1)) > return Color(); > > unsigned char pixel[4]; // RGBA >@@ -60,7 +60,7 @@ Color nativeImageSinglePixelSolidColor(const NativeImagePtr& image) > return Color(); > > CGContextSetBlendMode(bitmapContext.get(), kCGBlendModeCopy); >- CGContextDrawImage(bitmapContext.get(), CGRectMake(0, 0, 1, 1), image.get()); >+ CGContextDrawImage(bitmapContext.get(), CGRectMake(0, 0, 1, 1), m_platformImage.get()); > > if (!pixel[3]) > return Color::transparentBlack; >@@ -68,11 +68,11 @@ Color nativeImageSinglePixelSolidColor(const NativeImagePtr& image) > return clampToComponentBytes<SRGBA>(pixel[0] * 255 / pixel[3], pixel[1] * 255 / pixel[3], pixel[2] * 255 / pixel[3], pixel[3]); > } > >-void clearNativeImageSubimages(const NativeImagePtr& image) >+void NativeImage::clearSubimages() > { > #if CACHE_SUBIMAGES >- if (image) >- SubimageCacheWithTimer::clearImage(image.get()); >+ if (m_platformImage) >+ SubimageCacheWithTimer::clearImage(m_platformImage.get()); > #endif > } > >diff --git a/Source/WebCore/platform/graphics/cg/PatternCG.cpp b/Source/WebCore/platform/graphics/cg/PatternCG.cpp >index cbf624f6273c3b57ab9f3dbcc5ab17d5e3196d4a..6954c566570ad7ae6c1e760f0787d3770acaa694 100644 >--- a/Source/WebCore/platform/graphics/cg/PatternCG.cpp >+++ b/Source/WebCore/platform/graphics/cg/PatternCG.cpp >@@ -63,10 +63,17 @@ CGPatternRef Pattern::createPlatformPattern(const AffineTransform& userSpaceTran > patternTransform.scaleNonUniform(1, -1); > patternTransform.translate(0, -tileRect.height()); > >+ PlatformImagePtr platformImage; >+ if (auto nativeImage = tileImage().nativeImage()) >+ platformImage = nativeImage->platformImage(); >+ >+ if (!platformImage) >+ return nullptr; >+ > // If we're repeating in both directions, we can use image-backed patterns > // instead of custom patterns, and avoid tiling-edge pixel cracks. > if (m_repeatX && m_repeatY) >- return CGPatternCreateWithImage2(tileImage().nativeImage().get(), patternTransform, kCGPatternTilingConstantSpacing); >+ return CGPatternCreateWithImage2(platformImage.get(), patternTransform, kCGPatternTilingConstantSpacing); > > // If FLT_MAX should also be used for xStep or yStep, nothing is rendered. Using fractions of FLT_MAX also > // result in nothing being rendered. >@@ -77,10 +84,10 @@ CGPatternRef Pattern::createPlatformPattern(const AffineTransform& userSpaceTran > CGFloat yStep = m_repeatY ? tileRect.height() : (1 << 22); > > // The pattern will release the CGImageRef when it's done rendering in patternReleaseCallback >- CGImageRef platformImage = tileImage().nativeImage().leakRef(); >+ CGImageRef image = platformImage.leakRef(); > > const CGPatternCallbacks patternCallbacks = { 0, patternCallback, patternReleaseCallback }; >- return CGPatternCreate(platformImage, tileRect, patternTransform, xStep, yStep, kCGPatternTilingConstantSpacing, TRUE, &patternCallbacks); >+ return CGPatternCreate(image, tileRect, patternTransform, xStep, yStep, kCGPatternTilingConstantSpacing, TRUE, &patternCallbacks); > } > > } >diff --git a/Source/WebCore/platform/graphics/coreimage/FilterEffectRendererCoreImage.mm b/Source/WebCore/platform/graphics/coreimage/FilterEffectRendererCoreImage.mm >index 513f455cad8e5e6052728d347c393d9f447fe388..2fab69e03326c37b4c3c1c983d94089a218c239b 100644 >--- a/Source/WebCore/platform/graphics/coreimage/FilterEffectRendererCoreImage.mm >+++ b/Source/WebCore/platform/graphics/coreimage/FilterEffectRendererCoreImage.mm >@@ -177,7 +177,7 @@ RetainPtr<CIImage> FilterEffectRendererCoreImage::imageForSourceGraphic(SourceGr > if (is<AcceleratedImageBuffer>(*sourceImage)) > return [CIImage imageWithIOSurface:downcast<AcceleratedImageBuffer>(*sourceImage).surface().surface()]; > >- return [CIImage imageWithCGImage:sourceImage->copyNativeImage().get()]; >+ return [CIImage imageWithCGImage:sourceImage->copyNativeImage()->platformImage().get()]; > } > > RetainPtr<CIImage> FilterEffectRendererCoreImage::imageForFEColorMatrix(const FEColorMatrix& effect, const Vector<RetainPtr<CIImage>>& inputImages) >diff --git a/Source/WebCore/platform/graphics/displaylists/DisplayList.h b/Source/WebCore/platform/graphics/displaylists/DisplayList.h >index d6be274c68deefb4c0d5361be6481524032c9f41..1dd4a24af2e887339237e9a0da130dd6b26413db 100644 >--- a/Source/WebCore/platform/graphics/displaylists/DisplayList.h >+++ b/Source/WebCore/platform/graphics/displaylists/DisplayList.h >@@ -68,6 +68,7 @@ enum class ItemType : uint8_t { > DrawTiledScaledImage, > DrawImageBuffer, > DrawNativeImage, >+ DrawPlatformImage, > DrawPattern, > DrawRect, > DrawLine, >diff --git a/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp b/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp >index 47c762e1a6197d6c8b8c45fa9cfdc05a03dee51b..12056228a970a779c8366f93921e96d2c358d98f 100644 >--- a/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp >+++ b/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp >@@ -118,6 +118,8 @@ size_t Item::sizeInBytes(const Item& item) > return sizeof(downcast<DrawImageBuffer>(item)); > case ItemType::DrawNativeImage: > return sizeof(downcast<DrawNativeImage>(item)); >+ case ItemType::DrawPlatformImage: >+ return sizeof(downcast<DrawPlatformImage>(item)); > case ItemType::DrawPattern: > return sizeof(downcast<DrawPattern>(item)); > case ItemType::DrawRect: >@@ -859,9 +861,9 @@ static TextStream& operator<<(TextStream& ts, const DrawImageBuffer& item) > return ts; > } > >-DrawNativeImage::DrawNativeImage(const NativeImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) >+DrawNativeImage::DrawNativeImage(RenderingResourceIdentifier renderingResourceIdentifier, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) > : DrawingItem(ItemType::DrawNativeImage) >- , m_image(image) >+ , m_renderingResourceIdentifier(renderingResourceIdentifier) > , m_imageSize(imageSize) > , m_destinationRect(destRect) > , m_srcRect(srcRect) >@@ -871,12 +873,40 @@ DrawNativeImage::DrawNativeImage(const NativeImagePtr& image, const FloatSize& i > > DrawNativeImage::~DrawNativeImage() = default; > >-void DrawNativeImage::apply(GraphicsContext& context) const >+void DrawNativeImage::apply(GraphicsContext&) const > { >- context.drawNativeImage(m_image, m_imageSize, m_destinationRect, m_srcRect, m_options); >+ // Should be handled by the delegate. >+ ASSERT_NOT_REACHED(); > } > > static TextStream& operator<<(TextStream& ts, const DrawNativeImage& item) >+{ >+ ts << static_cast<const DrawingItem&>(item); >+ // FIXME: dump more stuff. >+ ts.dumpProperty("remote-resource-identifier", item.renderingResourceIdentifier()); >+ ts.dumpProperty("source-rect", item.source()); >+ ts.dumpProperty("dest-rect", item.destinationRect()); >+ return ts; >+} >+ >+DrawPlatformImage::DrawPlatformImage(const PlatformImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) >+ : DrawingItem(ItemType::DrawPlatformImage) >+ , m_image(image) >+ , m_imageSize(imageSize) >+ , m_destinationRect(destRect) >+ , m_srcRect(srcRect) >+ , m_options(options) >+{ >+} >+ >+DrawPlatformImage::~DrawPlatformImage() = default; >+ >+void DrawPlatformImage::apply(GraphicsContext& context) const >+{ >+ context.drawPlatformImage(m_image, m_imageSize, m_destinationRect, m_srcRect, m_options); >+} >+ >+static TextStream& operator<<(TextStream& ts, const DrawPlatformImage& item) > { > ts << static_cast<const DrawingItem&>(item); > // FIXME: dump more stuff. >@@ -1677,6 +1707,7 @@ static TextStream& operator<<(TextStream& ts, const ItemType& type) > case ItemType::DrawTiledScaledImage: ts << "draw-tiled-scaled-image"; break; > case ItemType::DrawImageBuffer: ts << "draw-image-buffer"; break; > case ItemType::DrawNativeImage: ts << "draw-native-image"; break; >+ case ItemType::DrawPlatformImage: ts << "draw-platform-image"; break; > case ItemType::DrawPattern: ts << "draw-pattern"; break; > case ItemType::DrawRect: ts << "draw-rect"; break; > case ItemType::DrawLine: ts << "draw-line"; break; >@@ -1800,6 +1831,9 @@ TextStream& operator<<(TextStream& ts, const Item& item) > case ItemType::DrawNativeImage: > ts << downcast<DrawNativeImage>(item); > break; >+ case ItemType::DrawPlatformImage: >+ ts << downcast<DrawPlatformImage>(item); >+ break; > case ItemType::DrawPattern: > ts << downcast<DrawPattern>(item); > break; >diff --git a/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h b/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h >index f015be5e86606ecc2f6ce857c1f71167694fe8e3..7b7e9a0e70dec72f8293334c4b9d56a4d32f0248 100644 >--- a/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h >+++ b/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h >@@ -1701,27 +1701,30 @@ Optional<Ref<DrawImageBuffer>> DrawImageBuffer::decode(Decoder& decoder) > > class DrawNativeImage : public DrawingItem { > public: >- static Ref<DrawNativeImage> create(const NativeImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) >+ static Ref<DrawNativeImage> create(RenderingResourceIdentifier renderingResourceIdentifier, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) > { >- return adoptRef(*new DrawNativeImage(image, imageSize, destRect, srcRect, options)); >+ return adoptRef(*new DrawNativeImage(renderingResourceIdentifier, imageSize, destRect, srcRect, options)); > } > > WEBCORE_EXPORT virtual ~DrawNativeImage(); > >+ RenderingResourceIdentifier renderingResourceIdentifier() const { return m_renderingResourceIdentifier; } >+ FloatSize imageSize() const { return m_imageSize; } > FloatRect source() const { return m_srcRect; } > FloatRect destinationRect() const { return m_destinationRect; } >+ ImagePaintingOptions options() const { return m_options; } > > template<class Encoder> void encode(Encoder&) const; > template<class Decoder> static Optional<Ref<DrawNativeImage>> decode(Decoder&); > > private: >- WEBCORE_EXPORT DrawNativeImage(const NativeImagePtr&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&); >+ WEBCORE_EXPORT DrawNativeImage(RenderingResourceIdentifier, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&); > > void apply(GraphicsContext&) const override; > > Optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_destinationRect; } > >- NativeImagePtr m_image; >+ RenderingResourceIdentifier m_renderingResourceIdentifier; > FloatSize m_imageSize; > FloatRect m_destinationRect; > FloatRect m_srcRect; >@@ -1731,7 +1734,7 @@ private: > template<class Encoder> > void DrawNativeImage::encode(Encoder& encoder) const > { >- encoder << m_image; >+ encoder << m_renderingResourceIdentifier; > encoder << m_imageSize; > encoder << m_destinationRect; > encoder << m_srcRect; >@@ -1741,7 +1744,77 @@ void DrawNativeImage::encode(Encoder& encoder) const > template<class Decoder> > Optional<Ref<DrawNativeImage>> DrawNativeImage::decode(Decoder& decoder) > { >- Optional<NativeImagePtr> image; >+ Optional<RenderingResourceIdentifier> renderingResourceIdentifier; >+ decoder >> renderingResourceIdentifier; >+ if (!renderingResourceIdentifier) >+ return WTF::nullopt; >+ >+ Optional<FloatSize> imageSize; >+ decoder >> imageSize; >+ if (!imageSize) >+ return WTF::nullopt; >+ >+ Optional<FloatRect> destinationRect; >+ decoder >> destinationRect; >+ if (!destinationRect) >+ return WTF::nullopt; >+ >+ Optional<FloatRect> srcRect; >+ decoder >> srcRect; >+ if (!srcRect) >+ return WTF::nullopt; >+ >+ Optional<ImagePaintingOptions> options; >+ decoder >> options; >+ if (!options) >+ return WTF::nullopt; >+ >+ return DrawNativeImage::create(*renderingResourceIdentifier, *imageSize, *destinationRect, *srcRect, *options); >+} >+ >+class DrawPlatformImage : public DrawingItem { >+public: >+ static Ref<DrawPlatformImage> create(const PlatformImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) >+ { >+ return adoptRef(*new DrawPlatformImage(image, imageSize, destRect, srcRect, options)); >+ } >+ >+ WEBCORE_EXPORT virtual ~DrawPlatformImage(); >+ >+ FloatRect source() const { return m_srcRect; } >+ FloatRect destinationRect() const { return m_destinationRect; } >+ >+ template<class Encoder> void encode(Encoder&) const; >+ template<class Decoder> static Optional<Ref<DrawPlatformImage>> decode(Decoder&); >+ >+private: >+ WEBCORE_EXPORT DrawPlatformImage(const PlatformImagePtr&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&); >+ >+ void apply(GraphicsContext&) const override; >+ >+ Optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_destinationRect; } >+ >+ PlatformImagePtr m_image; >+ FloatSize m_imageSize; >+ FloatRect m_destinationRect; >+ FloatRect m_srcRect; >+ ImagePaintingOptions m_options; >+}; >+ >+template<class Encoder> >+void DrawPlatformImage::encode(Encoder& encoder) const >+{ >+ encoder << m_image; >+ encoder << m_imageSize; >+ encoder << m_destinationRect; >+ encoder << m_srcRect; >+ encoder << m_options; >+} >+ >+template<class Decoder> >+Optional<Ref<DrawPlatformImage>> DrawPlatformImage::decode(Decoder& decoder) >+{ >+ Optional<PlatformImagePtr> image; > decoder >> image; > if (!image) > return WTF::nullopt; >@@ -1766,7 +1839,7 @@ Optional<Ref<DrawNativeImage>> DrawNativeImage::decode(Decoder& decoder) > if (!options) > return WTF::nullopt; > >- return DrawNativeImage::create(*image, *imageSize, *destinationRect, *srcRect, *options); >+ return DrawPlatformImage::create(*image, *imageSize, *destinationRect, *srcRect, *options); > } > > class DrawPattern : public DrawingItem { >@@ -3332,6 +3405,9 @@ void Item::encode(Encoder& encoder) const > case ItemType::DrawNativeImage: > encoder << downcast<DrawNativeImage>(*this); > break; >+ case ItemType::DrawPlatformImage: >+ encoder << downcast<DrawPlatformImage>(*this); >+ break; > case ItemType::DrawPattern: > encoder << downcast<DrawPattern>(*this); > break; >@@ -3553,6 +3629,10 @@ Optional<Ref<Item>> Item::decode(Decoder& decoder) > if (auto item = DrawNativeImage::decode(decoder)) > return static_reference_cast<Item>(WTFMove(*item)); > break; >+ case ItemType::DrawPlatformImage: >+ if (auto item = DrawPlatformImage::decode(decoder)) >+ return static_reference_cast<Item>(WTFMove(*item)); >+ break; > case ItemType::DrawPattern: > if (auto item = DrawPattern::decode(decoder)) > return static_reference_cast<Item>(WTFMove(*item)); >@@ -3727,6 +3807,7 @@ SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawTiledImage) > SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawTiledScaledImage) > SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawImageBuffer) > SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawNativeImage) >+SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawPlatformImage) > SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawPattern) > SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawRect) > SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawLine) >@@ -3798,6 +3879,7 @@ template<> struct EnumTraits<WebCore::DisplayList::ItemType> { > WebCore::DisplayList::ItemType::DrawTiledScaledImage, > WebCore::DisplayList::ItemType::DrawImageBuffer, > WebCore::DisplayList::ItemType::DrawNativeImage, >+ WebCore::DisplayList::ItemType::DrawPlatformImage, > WebCore::DisplayList::ItemType::DrawPattern, > WebCore::DisplayList::ItemType::DrawRect, > WebCore::DisplayList::ItemType::DrawLine, >diff --git a/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp b/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp >index d142c3779cb993e7372bb8b8887fcc4c752fe989..40fcaaaa4536fb5055f394245fd06cb9cd9fc51f 100644 >--- a/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp >+++ b/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp >@@ -194,9 +194,18 @@ bool Recorder::drawImageBuffer(WebCore::ImageBuffer& imageBuffer, const FloatRec > return true; > } > >-void Recorder::drawNativeImage(const NativeImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) >+bool Recorder::drawNativeImage(NativeImage& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) > { >- appendItemAndUpdateExtent(DrawNativeImage::create(image, imageSize, destRect, srcRect, options)); >+ if (!m_delegate || !m_delegate->lockRemoteNativeImage(image)) >+ return false; >+ >+ appendItemAndUpdateExtent(DrawNativeImage::create(image.renderingResourceIdentifier(), imageSize, destRect, srcRect, options)); >+ return true; >+} >+ >+void Recorder::drawPlatformImage(const PlatformImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) >+{ >+ appendItemAndUpdateExtent(DrawPlatformImage::create(image, imageSize, destRect, srcRect, options)); > } > > void Recorder::drawPattern(Image& image, const FloatRect& destRect, const FloatRect& tileRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& options) >diff --git a/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h b/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h >index 31c8c896378c0cafbb211289597cee28b4fa75d2..b88956a99b2b995cc83070ba937b716746884511 100644 >--- a/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h >+++ b/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h >@@ -66,6 +66,7 @@ public: > public: > virtual ~Delegate() { } > virtual bool lockRemoteImageBuffer(WebCore::ImageBuffer&) { return false; } >+ virtual bool lockRemoteNativeImage(NativeImage&) { return false; } > virtual void willAppendItem(const Item&) { }; > virtual void didAppendItem(const Item&) { }; > }; >@@ -108,7 +109,8 @@ private: > ImageDrawResult drawTiledImage(Image&, const FloatRect& destination, const FloatRect& source, const FloatSize& tileScaleFactor, Image::TileRule hRule, Image::TileRule vRule, const ImagePaintingOptions&) override; > > bool drawImageBuffer(WebCore::ImageBuffer&, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions&) override; >- void drawNativeImage(const NativeImagePtr&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) override; >+ bool drawNativeImage(NativeImage&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) override; >+ void drawPlatformImage(const PlatformImagePtr&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) override; > void drawPattern(Image&, const FloatRect& destRect, const FloatRect& srcRect, const AffineTransform&, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions&) override; > > void drawRect(const FloatRect&, float borderThickness) override; >diff --git a/Source/WebCore/platform/graphics/gstreamer/ImageDecoderGStreamer.cpp b/Source/WebCore/platform/graphics/gstreamer/ImageDecoderGStreamer.cpp >index dc994b731fa8954ef8803adc28f4f271eff589b7..c0aae3a7d49ef2b7d57a916514e60f9896d7d6e5 100644 >--- a/Source/WebCore/platform/graphics/gstreamer/ImageDecoderGStreamer.cpp >+++ b/Source/WebCore/platform/graphics/gstreamer/ImageDecoderGStreamer.cpp >@@ -46,11 +46,11 @@ public: > return adoptRef(*new ImageDecoderGStreamerSample(WTFMove(sample), presentationSize)); > } > >- NativeImagePtr image() const >+ PlatformImagePtr image() const > { > if (!m_image) > return nullptr; >- return m_image->image().nativeImage(); >+ return m_image->image().nativeImage()->platformImage(); > } > void dropImage() { m_image = nullptr; } > >@@ -179,7 +179,7 @@ unsigned ImageDecoderGStreamer::frameBytesAtIndex(size_t index, SubsamplingLevel > return (frameSize.area() * 4).unsafeGet(); > } > >-NativeImagePtr ImageDecoderGStreamer::createFrameImageAtIndex(size_t index, SubsamplingLevel, const DecodingOptions&) >+PlatformImagePtr ImageDecoderGStreamer::createFrameImageAtIndex(size_t index, SubsamplingLevel, const DecodingOptions&) > { > LockHolder holder { m_sampleGeneratorLock }; > >diff --git a/Source/WebCore/platform/graphics/gstreamer/ImageDecoderGStreamer.h b/Source/WebCore/platform/graphics/gstreamer/ImageDecoderGStreamer.h >index 6e2ea0797bd3cfd3e9d450084968e8d333959a7d..5869d8c86a4194d3e388ec920e5257e782691ab7 100644 >--- a/Source/WebCore/platform/graphics/gstreamer/ImageDecoderGStreamer.h >+++ b/Source/WebCore/platform/graphics/gstreamer/ImageDecoderGStreamer.h >@@ -67,7 +67,7 @@ public: > bool frameAllowSubsamplingAtIndex(size_t index) const final { return index <= m_sampleData.size(); } > unsigned frameBytesAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default) const final; > >- NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingOptions(DecodingMode::Synchronous)) final; >+ PlatformImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingOptions(DecodingMode::Synchronous)) final; > > void setExpectedContentSize(long long) final { } > void setData(SharedBuffer&, bool allDataReceived) final; >diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp >index c4ce12db70fb09d8bb9b22e110d2b73f5e679218..f1f87fbe3ea459cecc625be6c54e36a0aa005a00 100644 >--- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp >+++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp >@@ -3215,7 +3215,7 @@ bool MediaPlayerPrivateGStreamer::copyVideoTextureToPlatformTexture(GraphicsCont > return m_videoTextureCopier->copyVideoTextureToPlatformTexture(*layerBuffer.get(), size, outputTexture, outputTarget, level, internalFormat, format, type, flipY, m_videoSourceOrientation); > } > >-NativeImagePtr MediaPlayerPrivateGStreamer::nativeImageForCurrentTime() >+RefPtr<NativeImage> MediaPlayerPrivateGStreamer::nativeImageForCurrentTime() > { > return nullptr; > } >diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h >index 18e6d688667d7c32c15e8fcfde7dbc499b51daeb..0ab2c6c914bfe3cad6127ed96062e737908ad109 100644 >--- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h >+++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h >@@ -216,7 +216,7 @@ public: > > #if USE(GSTREAMER_GL) > bool copyVideoTextureToPlatformTexture(GraphicsContextGLOpenGL*, PlatformGLObject, GCGLenum, GCGLint, GCGLenum, GCGLenum, GCGLenum, bool, bool) override; >- NativeImagePtr nativeImageForCurrentTime() override; >+ RefPtr<NativeImage> nativeImageForCurrentTime() override; > #endif > > void updateEnabledVideoTrack(); >diff --git a/Source/WebCore/platform/graphics/ios/IconIOS.mm b/Source/WebCore/platform/graphics/ios/IconIOS.mm >index 8136c1fff45b9a3177a968bb6f62b2df8907da55..c24795f509a336ef0d7b171d266446caaef2100b 100644 >--- a/Source/WebCore/platform/graphics/ios/IconIOS.mm >+++ b/Source/WebCore/platform/graphics/ios/IconIOS.mm >@@ -33,7 +33,7 @@ > > namespace WebCore { > >-Icon::Icon(const NativeImagePtr& image) >+Icon::Icon(const PlatformImagePtr& image) > : m_cgImage(image) > { > } >@@ -47,7 +47,7 @@ RefPtr<Icon> Icon::createIconForFiles(const Vector<String>& /*filenames*/) > return nullptr; > } > >-RefPtr<Icon> Icon::createIconForImage(const RetainPtr<CGImageRef>& image) >+RefPtr<Icon> Icon::createIconForImage(const PlatformImagePtr& image) > { > if (!image) > return nullptr; >@@ -68,7 +68,7 @@ void Icon::paint(GraphicsContext& context, const FloatRect& destRect) > FloatRect srcRect(FloatPoint(), size); > > context.setImageInterpolationQuality(InterpolationQuality::High); >- context.drawNativeImage(m_cgImage.get(), size, destRect, srcRect); >+ context.drawPlatformImage(m_cgImage, size, destRect, srcRect); > } > > } >diff --git a/Source/WebCore/platform/graphics/mac/ImageMac.mm b/Source/WebCore/platform/graphics/mac/ImageMac.mm >index 6908f107632e89018ca90e990f344877b94b6fb9..9bb502890c6988f37ebddb9235213c5b4fe52bc8 100644 >--- a/Source/WebCore/platform/graphics/mac/ImageMac.mm >+++ b/Source/WebCore/platform/graphics/mac/ImageMac.mm >@@ -74,7 +74,7 @@ Ref<Image> Image::loadPlatformResource(const char *name) > return Image::nullImage(); > } > >-RetainPtr<CFDataRef> BitmapImage::tiffRepresentation(const Vector<NativeImagePtr>& nativeImages) >+RetainPtr<CFDataRef> BitmapImage::tiffRepresentation(const Vector<RefPtr<NativeImage>>& nativeImages) > { > // If nativeImages.size() is zero, we know for certain this image doesn't have valid data > // Even though the call to CGImageDestinationCreateWithData will fail and we'll handle it gracefully, >@@ -89,7 +89,7 @@ RetainPtr<CFDataRef> BitmapImage::tiffRepresentation(const Vector<NativeImagePtr > return nullptr; > > for (const auto& nativeImage : nativeImages) >- CGImageDestinationAddImage(destination.get(), nativeImage.get(), 0); >+ CGImageDestinationAddImage(destination.get(), nativeImage->platformImage().get(), 0); > > CGImageDestinationFinalize(destination.get()); > return data; >diff --git a/Source/WebCore/platform/graphics/nicosia/NicosiaImageBufferPipe.cpp b/Source/WebCore/platform/graphics/nicosia/NicosiaImageBufferPipe.cpp >index 6298cf36073c7ae44f43c6b564422b37b86cf107..fc2cbb68eb2c401bfb1770afbacc968529690872 100644 >--- a/Source/WebCore/platform/graphics/nicosia/NicosiaImageBufferPipe.cpp >+++ b/Source/WebCore/platform/graphics/nicosia/NicosiaImageBufferPipe.cpp >@@ -109,11 +109,14 @@ void NicosiaImageBufferPipeSource::handle(std::unique_ptr<ImageBuffer>&& buffer) > return; > > auto nativeImage = ImageBuffer::sinkIntoNativeImage(WTFMove(m_imageBuffer)); >- auto size = nativeImageSize(nativeImage); >+ if (!nativeImage) >+ return; >+ >+ auto size = nativeImage->size(); > >- texture->reset(size, nativeImageHasAlpha(nativeImage) ? BitmapTexture::SupportsAlpha : BitmapTexture::NoFlag); >+ texture->reset(size, nativeImage->hasAlpha() ? BitmapTexture::SupportsAlpha : BitmapTexture::NoFlag); > #if USE(CAIRO) >- auto* surface = nativeImage.get(); >+ auto* surface = nativeImage->platformImage().get(); > auto* imageData = reinterpret_cast<const char*>(cairo_image_surface_get_data(surface)); > texture->updateContents(imageData, IntRect(IntPoint(), size), IntPoint(), cairo_image_surface_get_stride(surface)); > #else >diff --git a/Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp b/Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp >index a2c9e093fc14ba5c1e829c4b24e16540037a4455..2e9eec8ff46ef494fd9b31e00b99e7e448ed33f1 100644 >--- a/Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp >+++ b/Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp >@@ -555,25 +555,31 @@ bool CairoOperationRecorder::drawImageBuffer(ImageBuffer&, const FloatRect&, con > return false; > } > >-void CairoOperationRecorder::drawNativeImage(const NativeImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) >+bool CairoOperationRecorder::drawNativeImage(NativeImage&, const FloatSize&, const FloatRect&, const FloatRect&, const ImagePaintingOptions&) > { >- struct DrawNativeImage final : PaintingOperation, OperationData<RefPtr<cairo_surface_t>, FloatRect, FloatRect, ImagePaintingOptions, float, Cairo::ShadowState> { >- virtual ~DrawNativeImage() = default; >+ // FIXME: Not implemented. >+ return false; >+} >+ >+void CairoOperationRecorder::drawPlatformImage(const PlatformImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) >+{ >+ struct DrawPlatformImage final : PaintingOperation, OperationData<RefPtr<cairo_surface_t>, FloatRect, FloatRect, ImagePaintingOptions, float, Cairo::ShadowState> { >+ virtual ~DrawPlatformImage() = default; > > void execute(PaintingOperationReplay& replayer) override > { >- Cairo::drawNativeImage(contextForReplay(replayer), arg<0>().get(), arg<1>(), arg<2>(), arg<3>(), arg<4>(), arg<5>()); >+ Cairo::drawPlatformImage(contextForReplay(replayer), arg<0>().get(), arg<1>(), arg<2>(), arg<3>(), arg<4>(), arg<5>()); > } > > void dump(TextStream& ts) override > { >- ts << indent << "DrawNativeImage<>\n"; >+ ts << indent << "DrawPlatformImage<>\n"; > } > }; > > UNUSED_PARAM(imageSize); > auto& state = graphicsContext().state(); >- append(createCommand<DrawNativeImage>(RefPtr<cairo_surface_t>(image.get()), destRect, srcRect, ImagePaintingOptions(options, state.imageInterpolationQuality), state.alpha, Cairo::ShadowState(state))); >+ append(createCommand<DrawPlatformImage>(RefPtr<cairo_surface_t>(image.get()), destRect, srcRect, ImagePaintingOptions(options, state.imageInterpolationQuality), state.alpha, Cairo::ShadowState(state))); > } > > void CairoOperationRecorder::drawPattern(Image& image, const FloatRect& destRect, const FloatRect& tileRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& options) >@@ -594,7 +600,7 @@ void CairoOperationRecorder::drawPattern(Image& image, const FloatRect& destRect > > UNUSED_PARAM(spacing); > if (auto surface = image.nativeImageForCurrentFrame()) >- append(createCommand<DrawPattern>(WTFMove(surface), IntSize(image.size()), destRect, tileRect, patternTransform, phase, options)); >+ append(createCommand<DrawPattern>(WTFMove(surface->platformImage()), IntSize(image.size()), destRect, tileRect, patternTransform, phase, options)); > } > > void CairoOperationRecorder::drawRect(const FloatRect& rect, float borderThickness) >@@ -1079,7 +1085,7 @@ void CairoOperationRecorder::clipToImageBuffer(ImageBuffer& buffer, const FloatR > return; > > if (auto surface = image->nativeImageForCurrentFrame()) >- append(createCommand<ClipToImageBuffer>(RefPtr<cairo_surface_t>(surface.get()), destRect)); >+ append(createCommand<ClipToImageBuffer>(RefPtr<cairo_surface_t>(surface->platformImage().get()), destRect)); > } > > void CairoOperationRecorder::applyDeviceScaleFactor(float) >diff --git a/Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.h b/Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.h >index 38093d4135b4d7b6511a16087aff13f603ed13ba..d884a1f2c795a773ce7fadbd74d9005c253277e9 100644 >--- a/Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.h >+++ b/Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.h >@@ -69,7 +69,8 @@ private: > WebCore::ImageDrawResult drawTiledImage(WebCore::Image&, const WebCore::FloatRect&, const WebCore::FloatRect&, const WebCore::FloatSize&, WebCore::Image::TileRule, WebCore::Image::TileRule, const WebCore::ImagePaintingOptions&) override; > > bool drawImageBuffer(WebCore::ImageBuffer&, const WebCore::FloatRect& destination, const WebCore::FloatRect& source, const WebCore::ImagePaintingOptions&) override; >- void drawNativeImage(const WebCore::NativeImagePtr&, const WebCore::FloatSize&, const WebCore::FloatRect&, const WebCore::FloatRect&, const WebCore::ImagePaintingOptions&) override; >+ bool drawNativeImage(WebCore::NativeImage&, const WebCore::FloatSize& selfSize, const WebCore::FloatRect& destRect, const WebCore::FloatRect& srcRect, const WebCore::ImagePaintingOptions&) override; >+ void drawPlatformImage(const WebCore::PlatformImagePtr&, const WebCore::FloatSize& selfSize, const WebCore::FloatRect& destRect, const WebCore::FloatRect& srcRect, const WebCore::ImagePaintingOptions&) override; > void drawPattern(WebCore::Image&, const WebCore::FloatRect&, const WebCore::FloatRect&, const WebCore::AffineTransform&, const WebCore::FloatPoint&, const WebCore::FloatSize&, const WebCore::ImagePaintingOptions&) override; > > void drawRect(const WebCore::FloatRect&, float) override; >diff --git a/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.cpp b/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.cpp >index 826d2da5bdeeb6795fd07f151424180c8ab5d0c9..a611092ec91470092260d8b04b7ca351c76f46ff 100644 >--- a/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.cpp >+++ b/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.cpp >@@ -151,7 +151,7 @@ void BitmapTextureGL::updateContents(Image* image, const IntRect& targetRect, co > { > if (!image) > return; >- NativeImagePtr frameImage = image->nativeImageForCurrentFrame(); >+ auto frameImage = image->nativeImageForCurrentFrame(); > if (!frameImage) > return; > >@@ -159,7 +159,7 @@ void BitmapTextureGL::updateContents(Image* image, const IntRect& targetRect, co > const char* imageData; > > #if USE(CAIRO) >- cairo_surface_t* surface = frameImage.get(); >+ cairo_surface_t* surface = frameImage->platformImage().get(); > imageData = reinterpret_cast<const char*>(cairo_image_surface_get_data(surface)); > bytesPerLine = cairo_image_surface_get_stride(surface); > #elif USE(DIRECT2D) >diff --git a/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp b/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp >index 2abf4382d300f4e1d3321931ea99da444fa1e38f..0ddfa964a1eb0bec5c63fbd90f1a1258e519b47c 100644 >--- a/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp >+++ b/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp >@@ -39,7 +39,6 @@ Ref<GraphicsLayer> GraphicsLayer::create(GraphicsLayerFactory* factory, Graphics > > GraphicsLayerTextureMapper::GraphicsLayerTextureMapper(Type layerType, GraphicsLayerClient& client) > : GraphicsLayer(layerType, client) >- , m_compositedNativeImagePtr(0) > , m_changeMask(NoChanges) > , m_needsDisplay(false) > , m_debugBorderWidth(0) >@@ -294,26 +293,26 @@ void GraphicsLayerTextureMapper::setContentsToImage(Image* image) > { > if (image) { > // Make the decision about whether the image has changed. >- // This code makes the assumption that pointer equality on a NativeImagePtr is a valid way to tell if the image is changed. >+ // This code makes the assumption that pointer equality on a PlatformImagePtr is a valid way to tell if the image is changed. > // This assumption is true for the GTK+ port. >- NativeImagePtr newNativeImagePtr = image->nativeImageForCurrentFrame(); >- if (!newNativeImagePtr) >+ auto newNativeImage = image->nativeImageForCurrentFrame(); >+ if (!newNativeImage) > return; > >- if (newNativeImagePtr == m_compositedNativeImagePtr) >+ if (newNativeImage == m_compositedNativeImage) > return; > >- m_compositedNativeImagePtr = newNativeImagePtr; >+ m_compositedNativeImage = newNativeImage; > if (!m_compositedImage) > m_compositedImage = TextureMapperTiledBackingStore::create(); > m_compositedImage->setContentsToImage(image); > m_compositedImage->updateContentsScale(pageScaleFactor() * deviceScaleFactor()); > } else { >- m_compositedNativeImagePtr = nullptr; >+ m_compositedNativeImage = nullptr; > m_compositedImage = nullptr; > } > >- setContentsToPlatformLayer(m_compositedImage.get(), ContentsLayerPurpose::Image); >+ setContentsToPlatformLayer(m_compositedImage->platformImage().get(), ContentsLayerPurpose::Image); > notifyChange(ContentChange); > GraphicsLayer::setContentsToImage(image); > } >diff --git a/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h b/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h >index 3b3a4833015c5c79cd6e6c930e2b577f414f4154..58f4f365d257347729327afbcad18c7c14c3ee9f 100644 >--- a/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h >+++ b/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h >@@ -25,6 +25,7 @@ > #include "GraphicsLayer.h" > #include "GraphicsLayerClient.h" > #include "Image.h" >+#include "NativeImage.h" > #include "TextureMapperLayer.h" > #include "TextureMapperPlatformLayer.h" > #include "TextureMapperTiledBackingStore.h" >@@ -155,7 +156,7 @@ private: > TextureMapperLayer m_layer; > std::unique_ptr<TextureMapperLayer> m_backdropLayer; > RefPtr<TextureMapperTiledBackingStore> m_compositedImage; >- NativeImagePtr m_compositedNativeImagePtr; >+ RefPtr<NativeImage> m_compositedNativeImage; > RefPtr<TextureMapperTiledBackingStore> m_backingStore; > > int m_changeMask; >diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp >index d52c5db07760ef7cf15f09c28378fcfd4d80d953..7133924c91b927f9101ab096cab366270c4481a0 100644 >--- a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp >+++ b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp >@@ -138,7 +138,6 @@ CoordinatedGraphicsLayer::CoordinatedGraphicsLayer(Type layerType, GraphicsLayer > , m_pendingVisibleRectAdjustment(false) > , m_shouldUpdatePlatformLayer(false) > , m_coordinator(0) >- , m_compositedNativeImagePtr(0) > , m_animationStartedTimer(*this, &CoordinatedGraphicsLayer::animationStartedTimerFired) > , m_requestPendingTileCreationTimer(RunLoop::main(), this, &CoordinatedGraphicsLayer::requestPendingTileCreationTimerFired) > { >@@ -585,12 +584,12 @@ void CoordinatedGraphicsLayer::setShowRepaintCounter(bool show) > > void CoordinatedGraphicsLayer::setContentsToImage(Image* image) > { >- NativeImagePtr nativeImagePtr = image ? image->nativeImageForCurrentFrame() : nullptr; >- if (m_compositedImage == image && m_compositedNativeImagePtr == nativeImagePtr) >+ auto nativeImage = image ? image->nativeImageForCurrentFrame() : nullptr; >+ if (m_compositedImage == image && m_compositedNativeImage == nativeImage) > return; > > m_compositedImage = image; >- m_compositedNativeImagePtr = nativeImagePtr; >+ m_compositedNativeImage = nativeImage; > > GraphicsLayer::setContentsToImage(image); > notifyFlushRequired(); >@@ -849,11 +848,11 @@ void CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly() > m_nicosia.delta.animatedBackingStoreClientChanged = true; > > // Determine image backing presence according to the composited image source. >- if (m_compositedNativeImagePtr) { >+ if (m_compositedNativeImage) { > ASSERT(m_compositedImage); > auto& image = *m_compositedImage; > uintptr_t imageID = reinterpret_cast<uintptr_t>(&image); >- uintptr_t nativeImageID = reinterpret_cast<uintptr_t>(m_compositedNativeImagePtr.get()); >+ uintptr_t nativeImageID = reinterpret_cast<uintptr_t>(m_compositedNativeImage->platformImage().get()); > > // Respawn the ImageBacking object if the underlying image changed. > if (m_nicosia.imageBacking) { >diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h >index ee8f57879ada6c91f0399192ef95c924ece13e41..9f0e1496bdcc5d2db6a9e66b024235d3724a6258 100644 >--- a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h >+++ b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h >@@ -223,7 +223,7 @@ private: > } m_needsDisplay; > > RefPtr<Image> m_compositedImage; >- NativeImagePtr m_compositedNativeImagePtr; >+ RefPtr<NativeImage> m_compositedNativeImage; > > Timer m_animationStartedTimer; > RunLoop::Timer<CoordinatedGraphicsLayer> m_requestPendingTileCreationTimer; >diff --git a/Source/WebCore/platform/graphics/win/GraphicsContextDirect2D.cpp b/Source/WebCore/platform/graphics/win/GraphicsContextDirect2D.cpp >index 57ba858ff99c2db29f5d91492e6aac8ed974ec99..1780729388465c96e809063a38eaba4be1437eaa 100644 >--- a/Source/WebCore/platform/graphics/win/GraphicsContextDirect2D.cpp >+++ b/Source/WebCore/platform/graphics/win/GraphicsContextDirect2D.cpp >@@ -207,11 +207,16 @@ void GraphicsContext::restorePlatformState() > Direct2D::restore(*platformContext()); > } > >-void GraphicsContext::platformDrawNativeImage(const COMPtr<ID2D1Bitmap>& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) >+void GraphicsContext::drawPlatformImage(const COMPtr<ID2D1Bitmap>& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) > { > if (paintingDisabled()) > return; > >+ if (m_impl) { >+ m_impl->drawPlatformImage(image, imageSize, destRect, srcRect, options); >+ return; >+ } >+ > ASSERT(hasPlatformContext()); > auto& state = this->state(); > Direct2D::drawNativeImage(*platformContext(), image.get(), imageSize, destRect, srcRect, options, state.alpha, Direct2D::ShadowState(state)); >diff --git a/Source/WebCore/platform/graphics/win/GraphicsContextImplDirect2D.cpp b/Source/WebCore/platform/graphics/win/GraphicsContextImplDirect2D.cpp >index c53d8bf85c09938829248f82ddd91c9de33c0783..a56a3b419d5ed4c43e4f6f1ba8aca560364c0b6b 100644 >--- a/Source/WebCore/platform/graphics/win/GraphicsContextImplDirect2D.cpp >+++ b/Source/WebCore/platform/graphics/win/GraphicsContextImplDirect2D.cpp >@@ -283,7 +283,12 @@ ImageDrawResult GraphicsContextImplDirect2D::drawTiledImage(Image& image, const > return GraphicsContextImpl::drawTiledImageImpl(graphicsContext(), image, destination, source, tileScaleFactor, hRule, vRule, imagePaintingOptions); > } > >-void GraphicsContextImplDirect2D::drawNativeImage(const NativeImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) >+void GraphicsContextImplDirect2D::drawNativeImage(const NativeImage& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) >+{ >+ drawPlatformImage(image.platformImage(), imageSize, destRect, srcRect, options); >+} >+ >+void GraphicsContextImplDirect2D::drawPlatformImage(const PlatformImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) > { > auto& state = graphicsContext().state(); > Direct2D::drawNativeImage(m_platformContext, image.get(), imageSize, destRect, srcRect, options, state.alpha, Direct2D::ShadowState(state)); >diff --git a/Source/WebCore/platform/graphics/win/GraphicsContextImplDirect2D.h b/Source/WebCore/platform/graphics/win/GraphicsContextImplDirect2D.h >index 95eb370b75bade039d6f94872aeaf4cf1e5e53cc..5f90ff1f1b9f02bb317b163df73613c26fb5da4c 100644 >--- a/Source/WebCore/platform/graphics/win/GraphicsContextImplDirect2D.h >+++ b/Source/WebCore/platform/graphics/win/GraphicsContextImplDirect2D.h >@@ -71,7 +71,10 @@ public: > ImageDrawResult drawImage(Image&, const FloatRect&, const FloatRect&, const ImagePaintingOptions&) override; > ImageDrawResult drawTiledImage(Image&, const FloatRect&, const FloatPoint&, const FloatSize&, const FloatSize&, const ImagePaintingOptions&) override; > ImageDrawResult drawTiledImage(Image&, const FloatRect&, const FloatRect&, const FloatSize&, Image::TileRule, Image::TileRule, const ImagePaintingOptions&) override; >- void drawNativeImage(const NativeImagePtr&, const FloatSize&, const FloatRect&, const FloatRect&, const ImagePaintingOptions&) override; >+ >+ bool drawImageBuffer(ImageBuffer&, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions&) override; >+ bool drawNativeImage(NativeImage&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) override; >+ void drawPlatformImage(const PlatformImagePtr&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) override; > void drawPattern(Image&, const FloatRect&, const FloatRect&, const AffineTransform&, const FloatPoint&, const FloatSize&, const ImagePaintingOptions&) override; > > void drawRect(const FloatRect&, float) override; >diff --git a/Source/WebCore/platform/graphics/win/ImageBufferDirect2DBackend.cpp b/Source/WebCore/platform/graphics/win/ImageBufferDirect2DBackend.cpp >index 7d248e6d58d98c928e3acef22e697b64e81c5c94..656cb14e7288f23a8917f22889da73e9bc94a3b8 100644 >--- a/Source/WebCore/platform/graphics/win/ImageBufferDirect2DBackend.cpp >+++ b/Source/WebCore/platform/graphics/win/ImageBufferDirect2DBackend.cpp >@@ -64,7 +64,7 @@ std::unique_ptr<ImageBufferDirect2DBackend> ImageBufferDirect2DBackend::create(c > if (!bitmapContext) > return; > >- NativeImagePtr bitmap; >+ PlatformImagePtr bitmap; > HRESULT hr = bitmapContext->GetBitmap(&bitmap); > if (!SUCCEEDED(hr)) > return; >@@ -90,7 +90,7 @@ std::unique_ptr<ImageBufferDirect2DBackend> ImageBufferDirect2DBackend::create(c > return ImageBufferDirect2DBackend::create(size, 1, ColorSpace::SRGB, nullptr); > } > >-ImageBufferDirect2DBackend::ImageBufferDirect2DBackend(const FloatSize& logicalSize, const IntSize& backendSize, float resolutionScale, ColorSpace colorSpace, std::unique_ptr<PlatformContextDirect2D>&& platformContext, std::unique_ptr<GraphicsContext>&& context, NativeImagePtr&& bitmap) >+ImageBufferDirect2DBackend::ImageBufferDirect2DBackend(const FloatSize& logicalSize, const IntSize& backendSize, float resolutionScale, ColorSpace colorSpace, std::unique_ptr<PlatformContextDirect2D>&& platformContext, std::unique_ptr<GraphicsContext>&& context, PlatformImagePtr&& bitmap) > : ImageBufferCGBackend(logicalSize, backendSize, resolutionScale, colorSpace) > , m_platformContext(WTFMove(platformContext)) > , m_context(WTFMove(context)) >@@ -108,7 +108,7 @@ void ImageBufferDirect2DBackend::flushContext() > context().flush(); > } > >-NativeImagePtr ImageBufferDirect2DBackend::copyNativeImage(BackingStoreCopy copyBehavior) const >+RefPtr<NativeImage> ImageBufferDirect2DBackend::copyNativeImage(BackingStoreCopy copyBehavior) const > { > COMPtr<ID2D1BitmapRenderTarget> bitmapTarget; > HRESULT hr = context().platformContext()->renderTarget()->QueryInterface(&bitmapTarget); >@@ -133,10 +133,10 @@ NativeImagePtr ImageBufferDirect2DBackend::copyNativeImage(BackingStoreCopy copy > > } > >- return image; >+ return NativeImage::create(WTFMove(image)); > } > >-static NativeImagePtr createCroppedImageIfNecessary(ID2D1BitmapRenderTarget* bitmapTarget, ID2D1Bitmap* image, const IntSize& bounds) >+static PlatformImagePtr createCroppedImageIfNecessary(ID2D1BitmapRenderTarget* bitmapTarget, ID2D1Bitmap* image, const IntSize& bounds) > { > FloatSize imageSize = image ? nativeImageSize(image) : FloatSize(); > >@@ -170,11 +170,11 @@ static RefPtr<Image> createBitmapImageAfterScalingIfNeeded(ID2D1BitmapRenderTarg > > RefPtr<Image> ImageBufferDirect2DBackend::copyImage(BackingStoreCopy copyBehavior, PreserveResolution preserveResolution) const > { >- NativeImagePtr image; >+ PlatformImagePtr image; > if (m_resolutionScale == 1 || preserveResolution == PreserveResolution::Yes) >- image = copyNativeImage(copyBehavior); >+ image = copyNativeImage(copyBehavior)->platformImage(); > else >- image = copyNativeImage(DontCopyBackingStore); >+ image = copyNativeImage(DontCopyBackingStore)->platformImage(); > > auto bitmapTarget = reinterpret_cast<ID2D1BitmapRenderTarget*>(context().platformContext()); > return createBitmapImageAfterScalingIfNeeded(bitmapTarget, WTFMove(image), internalSize(), resolutionScale(), preserveResolution); >@@ -187,11 +187,11 @@ RefPtr<Image> ImageBufferDirect2DBackend::sinkIntoImage(PreserveResolution prese > if (!SUCCEEDED(hr)) > return nullptr; > >- NativeImagePtr image = copyNativeImage(DontCopyBackingStore); >+ PlatformImagePtr image = copyNativeImage(DontCopyBackingStore)->platformImage(); > return createBitmapImageAfterScalingIfNeeded(bitmapTarget.get(), WTFMove(image), internalSize(), resolutionScale(), preserveResolution); > } > >-NativeImagePtr ImageBufferDirect2DBackend::compatibleBitmap(ID2D1RenderTarget* renderTarget) >+PlatformImagePtr ImageBufferDirect2DBackend::compatibleBitmap(ID2D1RenderTarget* renderTarget) > { > loadDataToBitmapIfNeeded(); > >diff --git a/Source/WebCore/platform/graphics/win/ImageBufferDirect2DBackend.h b/Source/WebCore/platform/graphics/win/ImageBufferDirect2DBackend.h >index cef39ea79211d5f18df650499479246c457dc261..1d574aeecdb9d2280214f1c0caf5fc5600911446 100644 >--- a/Source/WebCore/platform/graphics/win/ImageBufferDirect2DBackend.h >+++ b/Source/WebCore/platform/graphics/win/ImageBufferDirect2DBackend.h >@@ -42,7 +42,7 @@ public: > GraphicsContext& context() const override; > void flushContext() override; > >- NativeImagePtr copyNativeImage(BackingStoreCopy = CopyBackingStore) const override; >+ RefPtr<NativeImage> copyNativeImage(BackingStoreCopy = CopyBackingStore) const override; > RefPtr<Image> copyImage(BackingStoreCopy, PreserveResolution) const override; > > RefPtr<Image> sinkIntoImage(PreserveResolution) override; >@@ -59,7 +59,7 @@ protected: > > std::unique_ptr<PlatformContextDirect2D> m_platformContext; > std::unique_ptr<GraphicsContext> m_context; >- NativeImagePtr m_bitmap; >+ PlatformImagePtr m_bitmap; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/platform/graphics/win/ImageCGWin.cpp b/Source/WebCore/platform/graphics/win/ImageCGWin.cpp >index 74d36dfd58c376e84f93b9d4e92133d553cd3a4b..903c52d330b3b9cc55b5daa6533c0a31f4e42d29 100644 >--- a/Source/WebCore/platform/graphics/win/ImageCGWin.cpp >+++ b/Source/WebCore/platform/graphics/win/ImageCGWin.cpp >@@ -91,8 +91,8 @@ void BitmapImage::drawFrameMatchingSourceSize(GraphicsContext& ctxt, const Float > { > size_t frames = frameCount(); > for (size_t i = 0; i < frames; ++i) { >- CGImageRef image = frameImageAtIndex(i).get(); >- if (image && CGImageGetHeight(image) == static_cast<size_t>(srcSize.height()) && CGImageGetWidth(image) == static_cast<size_t>(srcSize.width())) { >+ auto image = frameImageAtIndex(i); >+ if (image && image->size() == srcSize) { > size_t currentFrame = m_currentFrame; > m_currentFrame = i; > draw(ctxt, dstRect, FloatRect(0.0f, 0.0f, srcSize.width(), srcSize.height()), { compositeOp }); >diff --git a/Source/WebCore/platform/graphics/win/ImageCairoWin.cpp b/Source/WebCore/platform/graphics/win/ImageCairoWin.cpp >index d4eafc599a00f23957892e3caa2e85ebce3805c0..ccaebe6442d10f8369678bbb4077d6d8a4c97c01 100644 >--- a/Source/WebCore/platform/graphics/win/ImageCairoWin.cpp >+++ b/Source/WebCore/platform/graphics/win/ImageCairoWin.cpp >@@ -93,7 +93,11 @@ void BitmapImage::drawFrameMatchingSourceSize(GraphicsContext& ctxt, const Float > { > size_t frames = frameCount(); > for (size_t i = 0; i < frames; ++i) { >- auto surface = frameImageAtIndex(i); >+ auto nativeImage = frameImageAtIndex(i); >+ if (!nativeImage) >+ continue; >+ >+ auto surface = nativeImage.platformImage(); > if (!surface) > continue; > >diff --git a/Source/WebCore/platform/graphics/win/ImageDecoderDirect2D.cpp b/Source/WebCore/platform/graphics/win/ImageDecoderDirect2D.cpp >index 21c19ec63b54690fcc29cd806d3477da6964dc35..77b1a4a18881c0b5a223970cf01476e1e91e624a 100644 >--- a/Source/WebCore/platform/graphics/win/ImageDecoderDirect2D.cpp >+++ b/Source/WebCore/platform/graphics/win/ImageDecoderDirect2D.cpp >@@ -240,7 +240,7 @@ void ImageDecoderDirect2D::setTargetContext(ID2D1RenderTarget* renderTarget) > m_renderTarget = renderTarget; > } > >-NativeImagePtr ImageDecoderDirect2D::createFrameImageAtIndex(size_t index, SubsamplingLevel subsamplingLevel, const DecodingOptions&) >+PlatformImagePtr ImageDecoderDirect2D::createFrameImageAtIndex(size_t index, SubsamplingLevel subsamplingLevel, const DecodingOptions&) > { > if (!m_nativeDecoder) > return nullptr; >diff --git a/Source/WebCore/platform/graphics/win/ImageDecoderDirect2D.h b/Source/WebCore/platform/graphics/win/ImageDecoderDirect2D.h >index 76d7aca93e392427b265354caf2e32eeaccf17e0..c0dcafd6954c57deb39204e9fbb06ad0b1c9112d 100644 >--- a/Source/WebCore/platform/graphics/win/ImageDecoderDirect2D.h >+++ b/Source/WebCore/platform/graphics/win/ImageDecoderDirect2D.h >@@ -70,7 +70,7 @@ public: > bool frameAllowSubsamplingAtIndex(size_t) const final; > unsigned frameBytesAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default) const final; > >- NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingOptions(DecodingMode::Synchronous)) final; >+ PlatformImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingOptions(DecodingMode::Synchronous)) final; > > void setData(SharedBuffer&, bool allDataReceived) final; > bool isAllDataReceived() const final { return m_isAllDataReceived; } >diff --git a/Source/WebCore/platform/graphics/win/NativeImageDirect2D.cpp b/Source/WebCore/platform/graphics/win/NativeImageDirect2D.cpp >index 90f78c238f18f99bc509c1e309183fcaf8a48c9f..eac7cbe617b9b7f95aaf67cab959969c9d9ca0f9 100644 >--- a/Source/WebCore/platform/graphics/win/NativeImageDirect2D.cpp >+++ b/Source/WebCore/platform/graphics/win/NativeImageDirect2D.cpp >@@ -50,60 +50,36 @@ static IWICImagingFactory* imagingFactory() > return imagingFactory; > } > >-IntSize nativeImageSize(const NativeImagePtr& image) >+IntSize NativeImage::size(const PlatformImagePtr& platformImage) > { >- UINT width = 0; >- UINT height = 0; >- if (!image) >- return { }; >- >- return image->GetPixelSize(); >+ return platformImage ? platformImage->GetPixelSize() : IntSize(); > } > >-bool nativeImageHasAlpha(const NativeImagePtr& image) >+bool NativeImage::hasAlpha() const > { >- if (!image) >+ if (!m_platformImage) > return false; > >- D2D1_PIXEL_FORMAT pixelFormat = image->GetPixelFormat(); >+ D2D1_PIXEL_FORMAT pixelFormat = m_platformImage->GetPixelFormat(); > return pixelFormat.alphaMode != D2D1_ALPHA_MODE_IGNORE; > } > >-Color nativeImageSinglePixelSolidColor(const NativeImagePtr& image) >+Color NativeImage::singlePixelSolidColor() const > { >- if (!image || nativeImageSize(image) != IntSize(1, 1)) >+ if (!m_platformImage || size() != IntSize(1, 1)) > return Color(); > > notImplemented(); >- > return Color(); > } > >-void drawNativeImage(const NativeImagePtr& image, GraphicsContext& context, const FloatRect& destRect, const FloatRect& srcRect, const IntSize& srcSize, const ImagePaintingOptions& options) >-{ >- auto* platformContext = context.platformContext(); >- >- // Subsampling may have given us an image that is smaller than size(). >- IntSize subsampledImageSize = nativeImageSize(image); >- >- // srcRect is in the coordinates of the unsubsampled image, so we have to map it to the subsampled image. >- FloatRect adjustedSrcRect = srcRect; >- if (subsampledImageSize != srcSize) >- adjustedSrcRect = mapRect(srcRect, FloatRect({ }, srcSize), FloatRect({ }, subsampledImageSize)); >- >- auto& state = context.state(); >- Direct2D::drawNativeImage(*platformContext, image.get(), subsampledImageSize, destRect, adjustedSrcRect, options, state.alpha, Direct2D::ShadowState(state)); >-} >- >-void clearNativeImageSubimages(const NativeImagePtr& image) >+void NativeImage::clearSubimages() > { > notImplemented(); >- > #if CACHE_SUBIMAGES >- if (image) >- subimageCache().clearImage(image.get()); >+ if (m_platformImage) >+ SubimageCacheWithTimer::clearImage(m_platformImage.get()); > #endif > } > >- > } >diff --git a/Source/WebCore/platform/image-decoders/ScalableImageDecoder.cpp b/Source/WebCore/platform/image-decoders/ScalableImageDecoder.cpp >index 73b51eb85369cae8f978151041fea1c2df5a8831..74a60cb8378e21b3e4362d1827e70b51f5ef50c8 100644 >--- a/Source/WebCore/platform/image-decoders/ScalableImageDecoder.cpp >+++ b/Source/WebCore/platform/image-decoders/ScalableImageDecoder.cpp >@@ -204,7 +204,7 @@ Seconds ScalableImageDecoder::frameDurationAtIndex(size_t index) const > return duration; > } > >-NativeImagePtr ScalableImageDecoder::createFrameImageAtIndex(size_t index, SubsamplingLevel, const DecodingOptions&) >+PlatformImagePtr ScalableImageDecoder::createFrameImageAtIndex(size_t index, SubsamplingLevel, const DecodingOptions&) > { > LockHolder lockHolder(m_mutex); > // Zero-height images can cause problems for some ports. If we have an empty image dimension, just bail. >diff --git a/Source/WebCore/platform/image-decoders/ScalableImageDecoder.h b/Source/WebCore/platform/image-decoders/ScalableImageDecoder.h >index 88c90b6e8a2d34c90220dda96d4fcf757632088f..283222ec3bb3857473acb97d7e5104f72ed4bbbe 100644 >--- a/Source/WebCore/platform/image-decoders/ScalableImageDecoder.h >+++ b/Source/WebCore/platform/image-decoders/ScalableImageDecoder.h >@@ -144,7 +144,7 @@ public: > > Seconds frameDurationAtIndex(size_t) const final; > >- NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingOptions(DecodingMode::Synchronous)) override; >+ PlatformImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingOptions(DecodingMode::Synchronous)) override; > > void setIgnoreGammaAndColorProfile(bool flag) { m_ignoreGammaAndColorProfile = flag; } > bool ignoresGammaAndColorProfile() const { return m_ignoreGammaAndColorProfile; } >diff --git a/Source/WebCore/platform/image-decoders/cairo/ImageBackingStoreCairo.cpp b/Source/WebCore/platform/image-decoders/cairo/ImageBackingStoreCairo.cpp >index b835a69cbc45b7b892e0e7bfa19ff01995becb50..60120374f9c43168a6521b69c54afbe2a00f55f7 100644 >--- a/Source/WebCore/platform/image-decoders/cairo/ImageBackingStoreCairo.cpp >+++ b/Source/WebCore/platform/image-decoders/cairo/ImageBackingStoreCairo.cpp >@@ -30,7 +30,7 @@ > > namespace WebCore { > >-NativeImagePtr ImageBackingStore::image() const >+PlatformImagePtr ImageBackingStore::image() const > { > m_pixels->ref(); > RefPtr<cairo_surface_t> surface = adoptRef(cairo_image_surface_create_for_data( >diff --git a/Source/WebCore/platform/mediastream/mac/DisplayCaptureSourceCocoa.cpp b/Source/WebCore/platform/mediastream/mac/DisplayCaptureSourceCocoa.cpp >index 98194d143e0d2cfd0b96140ebe76af031fa181c2..3f4e4dcf42c0fa93ef9ab62dd22a97c513870663 100644 >--- a/Source/WebCore/platform/mediastream/mac/DisplayCaptureSourceCocoa.cpp >+++ b/Source/WebCore/platform/mediastream/mac/DisplayCaptureSourceCocoa.cpp >@@ -239,11 +239,11 @@ void DisplayCaptureSourceCocoa::emitFrame() > > return IntSize(IOSurfaceGetWidth(surface.get()), IOSurfaceGetHeight(surface.get())); > }, >- [](RetainPtr<CGImageRef> image) -> IntSize { >+ [](RefPtr<NativeImage> image) -> IntSize { > if (!image) > return { }; > >- return IntSize(CGImageGetWidth(image.get()), CGImageGetHeight(image.get())); >+ return image->size(); > } > ); > >@@ -263,11 +263,11 @@ void DisplayCaptureSourceCocoa::emitFrame() > > return m_imageTransferSession->createMediaSample(surface.get(), sampleTime, size()); > }, >- [this, sampleTime](RetainPtr<CGImageRef> image) -> RefPtr<MediaSample> { >+ [this, sampleTime](RefPtr<NativeImage> image) -> RefPtr<MediaSample> { > if (!image) > return nullptr; > >- return m_imageTransferSession->createMediaSample(image.get(), sampleTime, size()); >+ return m_imageTransferSession->createMediaSample(image->platformImage().get(), sampleTime, size()); > } > ); > >diff --git a/Source/WebCore/platform/mediastream/mac/DisplayCaptureSourceCocoa.h b/Source/WebCore/platform/mediastream/mac/DisplayCaptureSourceCocoa.h >index ffc14bca65f618e2cabe5e8eeb2ded643740def4..0b6b244a48493d2a5ec4deb23382338aaac678dc 100644 >--- a/Source/WebCore/platform/mediastream/mac/DisplayCaptureSourceCocoa.h >+++ b/Source/WebCore/platform/mediastream/mac/DisplayCaptureSourceCocoa.h >@@ -52,7 +52,7 @@ class PixelBufferConformerCV; > > class DisplayCaptureSourceCocoa final : public RealtimeMediaSource { > public: >- using DisplayFrameType = WTF::Variant<RetainPtr<CGImageRef>, RetainPtr<IOSurfaceRef>>; >+ using DisplayFrameType = WTF::Variant<RefPtr<NativeImage>, RetainPtr<IOSurfaceRef>>; > class Capturer > #if !RELEASE_LOG_DISABLED > : public LoggerHelper >diff --git a/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.mm b/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.mm >index 3f6cb6ed5dfa38c26b35edc77c9193935e58d230..b059a3251d8b9657ba9014c44f8063af827b1d43 100644 >--- a/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.mm >+++ b/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.mm >@@ -91,8 +91,12 @@ void MockRealtimeVideoSourceMac::updateSampleBuffer() > if (!m_imageTransferSession) > m_imageTransferSession = ImageTransferSessionVT::create(preferedPixelBufferFormat()); > >+ PlatformImagePtr platformImage; >+ if (auto nativeImage = imageBuffer->copyImage()->nativeImage()) >+ platformImage = nativeImage->platformImage(); >+ > auto sampleTime = MediaTime::createWithDouble((elapsedTime() + 100_ms).seconds()); >- auto sampleBuffer = m_imageTransferSession->createMediaSample(imageBuffer->copyImage()->nativeImage().get(), sampleTime, size(), sampleRotation()); >+ auto sampleBuffer = m_imageTransferSession->createMediaSample(platformImage.get(), sampleTime, size(), sampleRotation()); > if (!sampleBuffer) > return; > >diff --git a/Source/WebCore/platform/win/DragImageCGWin.cpp b/Source/WebCore/platform/win/DragImageCGWin.cpp >index 1dbed365456e2283ad4e0adaa1b7c75c9377c2f1..34ed9ef8cf4f866ca03fdca9304a96096bc65b9e 100644 >--- a/Source/WebCore/platform/win/DragImageCGWin.cpp >+++ b/Source/WebCore/platform/win/DragImageCGWin.cpp >@@ -139,8 +139,10 @@ DragImageRef createDragImageFromImage(Image* img, ImageOrientation) > CGContextSetFillColor(drawContext, white); > CGContextFillRect(drawContext, rect); > if (auto srcImage = img->nativeImage()) { >- CGContextSetBlendMode(drawContext, kCGBlendModeNormal); >- CGContextDrawImage(drawContext, rect, srcImage.get()); >+ if (auto platformImage = srcImage->platformImage()) { >+ CGContextSetBlendMode(drawContext, kCGBlendModeNormal); >+ CGContextDrawImage(drawContext, rect, platformImage.get()); >+ } > } > CGContextRelease(drawContext); > >diff --git a/Source/WebCore/platform/win/DragImageCairoWin.cpp b/Source/WebCore/platform/win/DragImageCairoWin.cpp >index 3a5e00be6718b118629868bafbac797ce6fe07b5..c0ed3c1dabee4ab3a3d787a4687a651ef3fa7382 100644 >--- a/Source/WebCore/platform/win/DragImageCairoWin.cpp >+++ b/Source/WebCore/platform/win/DragImageCairoWin.cpp >@@ -162,8 +162,9 @@ DragImageRef createDragImageFromImage(Image* img, ImageOrientation) > cairo_set_source_rgb(cr, 1.0, 0.0, 1.0); > cairo_fill_preserve(cr); > >- RefPtr<cairo_surface_t> surface = img->nativeImageForCurrentFrame(); >- if (surface) { >+ NativeImage nativeImage = img->nativeImageForCurrentFrame(); >+ if (nativeImage && !nativeImage->isNull()) { >+ auto& surface = nativeImage->platformImage(); > // Draw the image. > cairo_set_source_surface(cr, surface.get(), 0.0, 0.0); > cairo_paint(cr); >diff --git a/Source/WebCore/rendering/RenderThemeIOS.mm b/Source/WebCore/rendering/RenderThemeIOS.mm >index 491ad90d050d393eb6ab556c77fd10e374373fa2..111a4b2c355c07b949596246df2217639af4ab7e 100644 >--- a/Source/WebCore/rendering/RenderThemeIOS.mm >+++ b/Source/WebCore/rendering/RenderThemeIOS.mm >@@ -1840,7 +1840,7 @@ void RenderThemeIOS::paintSystemPreviewBadge(Image& image, const PaintInfo& pain > CGRect insetBadgeRect = CGRectMake(rect.width() - badgeDimension - badgeOffset, badgeOffset, badgeDimension, badgeDimension); > CGRect badgeRect = CGRectMake(0, 0, badgeDimension, badgeDimension); > >- CIImage *inputImage = [CIImage imageWithCGImage:image.nativeImage().get()]; >+ CIImage *inputImage = [CIImage imageWithCGImage:image.nativeImage()->platformImage().get()]; > > // Create a circle to be used for the clipping path in the badge, as well as the drop shadow. > RetainPtr<CGPathRef> circle = adoptCF(CGPathCreateWithRoundedRect(absoluteBadgeRect, badgeDimension / 2, badgeDimension / 2, nullptr)); >diff --git a/Source/WebCore/svg/graphics/SVGImage.cpp b/Source/WebCore/svg/graphics/SVGImage.cpp >index 63edf12e213330df2dacb9654025653163b40bc1..b060d72829cb71d30b6bf285a33bb78eca79a930 100644 >--- a/Source/WebCore/svg/graphics/SVGImage.cpp >+++ b/Source/WebCore/svg/graphics/SVGImage.cpp >@@ -209,9 +209,9 @@ ImageDrawResult SVGImage::drawForContainer(GraphicsContext& context, const Float > } > > #if USE(CAIRO) >-// Passes ownership of the native image to the caller so NativeImagePtr needs >+// Passes ownership of the native image to the caller so NativeImage needs > // to be a smart pointer type. >-NativeImagePtr SVGImage::nativeImageForCurrentFrame(const GraphicsContext*) >+RefPtr<NativeImage> SVGImage::nativeImageForCurrentFrame(const GraphicsContext*) > { > if (!m_page) > return nullptr; >@@ -229,7 +229,7 @@ NativeImagePtr SVGImage::nativeImageForCurrentFrame(const GraphicsContext*) > #endif > > #if USE(DIRECT2D) >-NativeImagePtr SVGImage::nativeImage(const GraphicsContext* targetContext) >+RefPtr<NativeImage> SVGImage::nativeImage(const GraphicsContext* targetContext) > { > ASSERT(targetContext); > if (!m_page || !targetContext) >diff --git a/Source/WebCore/svg/graphics/SVGImage.h b/Source/WebCore/svg/graphics/SVGImage.h >index d7aa8dd131afe38f5cebcba4f7a887bac59e8d28..2825f9d3898d8f24b74178045e8bda98e005447c 100644 >--- a/Source/WebCore/svg/graphics/SVGImage.h >+++ b/Source/WebCore/svg/graphics/SVGImage.h >@@ -63,10 +63,10 @@ public: > void scheduleStartAnimation(); > > #if USE(CAIRO) >- NativeImagePtr nativeImageForCurrentFrame(const GraphicsContext* = nullptr) final; >+ RefPtr<NativeImage> nativeImageForCurrentFrame(const GraphicsContext* = nullptr) final; > #endif > #if USE(DIRECT2D) >- NativeImagePtr nativeImage(const GraphicsContext* = nullptr) final; >+ RefPtr<NativeImage> nativeImage(const GraphicsContext* = nullptr) final; > #endif > > Page* internalPage() { return m_page.get(); } >diff --git a/Source/WebCore/svg/graphics/SVGImageForContainer.cpp b/Source/WebCore/svg/graphics/SVGImageForContainer.cpp >index eaefc31e47d02151d690c5cd65f5e831b31af365..0028d76df593e3194b4e937e204b9cb7378d27e2 100644 >--- a/Source/WebCore/svg/graphics/SVGImageForContainer.cpp >+++ b/Source/WebCore/svg/graphics/SVGImageForContainer.cpp >@@ -45,7 +45,7 @@ void SVGImageForContainer::drawPattern(GraphicsContext& context, const FloatRect > m_image->drawPatternForContainer(context, m_containerSize, m_containerZoom, m_initialFragmentURL, srcRect, patternTransform, phase, spacing, dstRect, options); > } > >-NativeImagePtr SVGImageForContainer::nativeImageForCurrentFrame(const GraphicsContext* targetContext) >+RefPtr<NativeImage> SVGImageForContainer::nativeImageForCurrentFrame(const GraphicsContext* targetContext) > { > return m_image->nativeImageForCurrentFrame(targetContext); > } >diff --git a/Source/WebCore/svg/graphics/SVGImageForContainer.h b/Source/WebCore/svg/graphics/SVGImageForContainer.h >index e644f7acf30ec224df8515d87f72c2ae1bb34a5c..01b2f1bafa95053c592257370f2b8f2f5794a4ab 100644 >--- a/Source/WebCore/svg/graphics/SVGImageForContainer.h >+++ b/Source/WebCore/svg/graphics/SVGImageForContainer.h >@@ -60,7 +60,7 @@ public: > // FIXME: Implement this to be less conservative. > bool currentFrameKnownToBeOpaque() const final { return false; } > >- NativeImagePtr nativeImageForCurrentFrame(const GraphicsContext* = nullptr) final; >+ RefPtr<NativeImage> nativeImageForCurrentFrame(const GraphicsContext* = nullptr) final; > > private: > SVGImageForContainer(SVGImage* image, const FloatSize& containerSize, float containerZoom, const URL& initialFragmentURL) >diff --git a/Source/WebKit/Scripts/webkit/messages.py b/Source/WebKit/Scripts/webkit/messages.py >index 99111a7890b5785f4e1062d688206547d52503bd..11bf8fe2ef408bae916d4fe06a7f43d599dddb3f 100644 >--- a/Source/WebKit/Scripts/webkit/messages.py >+++ b/Source/WebKit/Scripts/webkit/messages.py >@@ -217,7 +217,7 @@ def types_that_cannot_be_forward_declared(): > 'WebCore::PlaybackTargetClientContextIdentifier', > 'WebCore::MediaPlayerIdentifier', > 'WebCore::MediaSessionIdentifier', >- 'WebCore::NativeImagePtr', >+ 'WebCore::PlatformImagePtr', > 'WebCore::PageIdentifier', > 'WebCore::PluginLoadClientPolicy', > 'WebCore::PointerID', >diff --git a/Source/WebKit/Shared/API/c/cg/WKImageCG.cpp b/Source/WebKit/Shared/API/c/cg/WKImageCG.cpp >index db08c4318ae855c8bc578192df861a815ab0b239..e5713e301f6026bcb6db621f4ef4b7e10f65196d 100644 >--- a/Source/WebKit/Shared/API/c/cg/WKImageCG.cpp >+++ b/Source/WebKit/Shared/API/c/cg/WKImageCG.cpp >@@ -55,7 +55,7 @@ WKImageRef WKImageCreateFromCGImage(CGImageRef imageRef, WKImageOptions options) > > WebCore::FloatRect rect(WebCore::FloatPoint(0, 0), imageSize); > graphicsContext->clearRect(rect); >- graphicsContext->drawNativeImage(imageRef, imageSize, rect, rect); >+ graphicsContext->drawPlatformImage(imageRef, imageSize, rect, rect); > return toAPI(webImage.leakRef()); > } > >diff --git a/Source/WebKit/Shared/WebCoreArgumentCoders.cpp b/Source/WebKit/Shared/WebCoreArgumentCoders.cpp >index 3379596be69d924ae0ca6d8f9f1ffb01b20c3d6c..5ee93355d736a5eda01ece4b4cc55b28cc08091d 100644 >--- a/Source/WebKit/Shared/WebCoreArgumentCoders.cpp >+++ b/Source/WebKit/Shared/WebCoreArgumentCoders.cpp >@@ -1100,16 +1100,16 @@ bool ArgumentCoder<ImageHandle>::decode(Decoder& decoder, ImageHandle& imageHand > return true; > } > >-static void encodeNativeImage(Encoder& encoder, const NativeImagePtr& image) >+static void encodePlatformImage(Encoder& encoder, const PlatformImagePtr& platformImage) > { >- auto imageSize = nativeImageSize(image); >+ auto imageSize = NativeImage::size(platformImage); > auto bitmap = ShareableBitmap::createShareable(imageSize, { }); > auto graphicsContext = bitmap->createGraphicsContext(); > encoder << !!graphicsContext; > if (!graphicsContext) > return; > >- graphicsContext->drawNativeImage(image, imageSize, FloatRect({ }, imageSize), FloatRect({ }, imageSize)); >+ graphicsContext->drawPlatformImage(platformImage, imageSize, FloatRect({ }, imageSize), FloatRect({ }, imageSize)); > > ShareableBitmap::Handle handle; > bitmap->createHandle(handle); >@@ -1117,7 +1117,7 @@ static void encodeNativeImage(Encoder& encoder, const NativeImagePtr& image) > encoder << handle; > } > >-static WARN_UNUSED_RETURN bool decodeNativeImage(Decoder& decoder, NativeImagePtr& nativeImage) >+static WARN_UNUSED_RETURN bool decodePlatformImage(Decoder& decoder, PlatformImagePtr& platformImage) > { > Optional<bool> didCreateGraphicsContext; > decoder >> didCreateGraphicsContext; >@@ -1136,25 +1136,25 @@ static WARN_UNUSED_RETURN bool decodeNativeImage(Decoder& decoder, NativeImagePt > if (!image) > return false; > >- nativeImage = image->nativeImage(); >- if (!nativeImage) >+ platformImage = image->nativeImage()->platformImage(); >+ if (!platformImage) > return false; > > return true; > } > >-static void encodeOptionalNativeImage(Encoder& encoder, const NativeImagePtr& image) >+static void encodeOptionalPlatformImage(Encoder& encoder, const PlatformImagePtr& platformImage) > { >- bool hasImage = !!image; >+ bool hasImage = !!platformImage; > encoder << hasImage; > > if (hasImage) >- encodeNativeImage(encoder, image); >+ encodePlatformImage(encoder, platformImage); > } > >-static WARN_UNUSED_RETURN bool decodeOptionalNativeImage(Decoder& decoder, NativeImagePtr& image) >+static WARN_UNUSED_RETURN bool decodeOptionalPlatformImage(Decoder& decoder, PlatformImagePtr& platformImage) > { >- image = nullptr; >+ platformImage = nullptr; > > bool hasImage; > if (!decoder.decode(hasImage)) >@@ -1163,17 +1163,17 @@ static WARN_UNUSED_RETURN bool decodeOptionalNativeImage(Decoder& decoder, Nativ > if (!hasImage) > return true; > >- return decodeNativeImage(decoder, image); >+ return decodePlatformImage(decoder, platformImage); > } > >-void ArgumentCoder<NativeImagePtr>::encode(Encoder& encoder, const NativeImagePtr& image) >+void ArgumentCoder<PlatformImagePtr>::encode(Encoder& encoder, const PlatformImagePtr& platformImage) > { >- encodeOptionalNativeImage(encoder, image); >+ encodeOptionalPlatformImage(encoder, platformImage); > } > >-bool ArgumentCoder<NativeImagePtr>::decode(Decoder& decoder, NativeImagePtr& image) >+bool ArgumentCoder<PlatformImagePtr>::decode(Decoder& decoder, PlatformImagePtr& platformImage) > { >- return decodeOptionalNativeImage(decoder, image); >+ return decodeOptionalPlatformImage(decoder, platformImage); > } > > void ArgumentCoder<Ref<Font>>::encode(Encoder& encoder, const Ref<WebCore::Font>& font) >diff --git a/Source/WebKit/Shared/WebCoreArgumentCoders.h b/Source/WebKit/Shared/WebCoreArgumentCoders.h >index abca0240b6da94f83585baf19cb496b09b92b8e3..f91cb912a2942fdcb0d59672c478bc4f8bb9671f 100644 >--- a/Source/WebKit/Shared/WebCoreArgumentCoders.h >+++ b/Source/WebKit/Shared/WebCoreArgumentCoders.h >@@ -34,7 +34,7 @@ > #include <WebCore/IndexedDB.h> > #include <WebCore/InputMode.h> > #include <WebCore/MediaSelectionOption.h> >-#include <WebCore/NativeImagePtr.h> >+#include <WebCore/NativeImage.h> > #include <WebCore/NetworkLoadMetrics.h> > #include <WebCore/NotificationDirection.h> > #include <WebCore/RealtimeMediaSource.h> >@@ -419,9 +419,9 @@ template<> struct ArgumentCoder<WebCore::ImageHandle> { > static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::ImageHandle&); > }; > >-template<> struct ArgumentCoder<WebCore::NativeImagePtr> { >- static void encode(Encoder&, const WebCore::NativeImagePtr&); >- static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::NativeImagePtr&); >+template<> struct ArgumentCoder<WebCore::PlatformImagePtr> { >+ static void encode(Encoder&, const WebCore::PlatformImagePtr&); >+ static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::PlatformImagePtr&); > }; > > template<> struct ArgumentCoder<WebCore::ResourceRequest> { >diff --git a/Source/WebKit/Shared/cg/ShareableBitmapCG.cpp b/Source/WebKit/Shared/cg/ShareableBitmapCG.cpp >index 959da83d5f6988b211588da7ddb4ff183dce7d60..36534820af5a2283c6e6a06e7433177b903de0a1 100644 >--- a/Source/WebKit/Shared/cg/ShareableBitmapCG.cpp >+++ b/Source/WebKit/Shared/cg/ShareableBitmapCG.cpp >@@ -185,11 +185,9 @@ void ShareableBitmap::releaseDataProviderData(void* typelessBitmap, const void* > > RefPtr<Image> ShareableBitmap::createImage() > { >- RetainPtr<CGImageRef> platformImage = makeCGImage(); >- if (!platformImage) >- return nullptr; >- >- return BitmapImage::create(WTFMove(platformImage)); >+ if (auto platformImage = makeCGImage()) >+ return BitmapImage::create(WTFMove(platformImage)); >+ return nullptr; > } > > } // namespace WebKit >diff --git a/Source/WebKit/UIProcess/API/glib/IconDatabase.cpp b/Source/WebKit/UIProcess/API/glib/IconDatabase.cpp >index bb8965458867eb2a0fc4ec857f3475a4e825a35c..e6300948aa88d71b5377e4ac107c9068599907c8 100644 >--- a/Source/WebKit/UIProcess/API/glib/IconDatabase.cpp >+++ b/Source/WebKit/UIProcess/API/glib/IconDatabase.cpp >@@ -543,7 +543,7 @@ void IconDatabase::checkIconURLAndSetPageURLIfNeeded(const String& iconURL, cons > }); > } > >-void IconDatabase::loadIconForPageURL(const String& pageURL, AllowDatabaseWrite allowDatabaseWrite, CompletionHandler<void(NativeImagePtr&&)>&& completionHandler) >+void IconDatabase::loadIconForPageURL(const String& pageURL, AllowDatabaseWrite allowDatabaseWrite, CompletionHandler<void(RefPtr<NativeImage>&&)>&& completionHandler) > { > ASSERT(isMainThread()); > >@@ -562,7 +562,7 @@ void IconDatabase::loadIconForPageURL(const String& pageURL, AllowDatabaseWrite > LockHolder lockHolder(m_loadedIconsLock); > if (!m_loadedIcons.contains(iconURL)) { > iconData = this->iconData(iconID.value()); >- m_loadedIcons.set(iconURL, std::make_pair<NativeImagePtr, MonotonicTime>(nullptr, { })); >+ m_loadedIcons.set(iconURL, std::make_pair<RefPtr<NativeImage>, MonotonicTime>(nullptr, { })); > } > } > bool canWriteToDatabase = m_allowDatabaseWrite == AllowDatabaseWrite::Yes && allowDatabaseWrite == AllowDatabaseWrite::Yes; >@@ -587,7 +587,7 @@ void IconDatabase::loadIconForPageURL(const String& pageURL, AllowDatabaseWrite > return; > } > >- auto addResult = m_loadedIcons.set(iconURL, std::make_pair<NativeImagePtr, MonotonicTime>(nullptr, MonotonicTime::now())); >+ auto addResult = m_loadedIcons.set(iconURL, std::make_pair<RefPtr<NativeImage>, MonotonicTime>(nullptr, MonotonicTime::now())); > if (!iconData.isEmpty()) { > auto image = BitmapImage::create(); > if (image->setData(SharedBuffer::create(WTFMove(iconData)), true) < EncodedDataStatus::SizeAvailable) { >@@ -622,7 +622,7 @@ void IconDatabase::setIconForPageURL(const String& iconURL, const unsigned char* > bool result = true; > { > LockHolder lockHolder(m_loadedIconsLock); >- auto addResult = m_loadedIcons.set(iconURL, std::make_pair<NativeImagePtr, MonotonicTime>(nullptr, { })); >+ auto addResult = m_loadedIcons.set(iconURL, std::make_pair<RefPtr<NativeImage>, MonotonicTime>(nullptr, { })); > if (iconDataSize) { > auto image = BitmapImage::create(); > if (image->setData(SharedBuffer::create(iconData, iconDataSize), true) < EncodedDataStatus::SizeAvailable) >diff --git a/Source/WebKit/UIProcess/API/glib/IconDatabase.h b/Source/WebKit/UIProcess/API/glib/IconDatabase.h >index 9612f99c2cfb7c51364e81ec8cf109e6318e039b..5c769017f9e4de1876cd4af5e17ccd1cc1ad6cc9 100644 >--- a/Source/WebKit/UIProcess/API/glib/IconDatabase.h >+++ b/Source/WebKit/UIProcess/API/glib/IconDatabase.h >@@ -44,7 +44,7 @@ public: > void invalidate(); > > void checkIconURLAndSetPageURLIfNeeded(const String& iconURL, const String& pageURL, AllowDatabaseWrite, CompletionHandler<void(bool, bool)>&&); >- void loadIconForPageURL(const String&, AllowDatabaseWrite, CompletionHandler<void(WebCore::NativeImagePtr&&)>&&); >+ void loadIconForPageURL(const String&, AllowDatabaseWrite, CompletionHandler<void(RefPtr<WebCore::NativeImage>&&)>&&); > String iconURLForPageURL(const String&); > void setIconForPageURL(const String& iconURL, const unsigned char*, size_t, const String& pageURL, AllowDatabaseWrite, CompletionHandler<void(bool)>&&); > void clear(CompletionHandler<void()>&&); >@@ -71,7 +71,7 @@ private: > WebCore::SQLiteDatabase m_db; > HashMap<String, String> m_pageURLToIconURLMap; > Lock m_pageURLToIconURLMapLock; >- HashMap<String, std::pair<WebCore::NativeImagePtr, MonotonicTime>> m_loadedIcons; >+ HashMap<String, std::pair<RefPtr<WebCore::NativeImage>, MonotonicTime>> m_loadedIcons; > Lock m_loadedIconsLock; > > std::unique_ptr<WebCore::SQLiteStatement> m_iconIDForIconURLStatement; >diff --git a/Source/WebKit/UIProcess/ios/DragDropInteractionState.mm b/Source/WebKit/UIProcess/ios/DragDropInteractionState.mm >index e48fce470c10adffa62e477b7839363c25e98029..bf03e43f0fd91e73da809dc32d144539a14f4812 100644 >--- a/Source/WebKit/UIProcess/ios/DragDropInteractionState.mm >+++ b/Source/WebKit/UIProcess/ios/DragDropInteractionState.mm >@@ -86,11 +86,11 @@ static RetainPtr<UIImage> uiImageForImage(Image* image) > if (!image) > return nullptr; > >- auto cgImage = image->nativeImage(); >- if (!cgImage) >+ auto nativeImage = image->nativeImage(); >+ if (!nativeImage || nativeImage->isNull()) > return nullptr; > >- return adoptNS([[UIImage alloc] initWithCGImage:cgImage.get()]); >+ return adoptNS([[UIImage alloc] initWithCGImage:nativeImage->platformImage().get()]); > } > > static bool shouldUseDragImageToCreatePreviewForDragSource(const DragSourceState& source) >diff --git a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >index dd89c0f0afa82b130d5242ed1c99d6e2bbf55889..944b5a7b1ccda3bab0aee7eb67f96d78ead91e89 100644 >--- a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >+++ b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >@@ -7503,13 +7503,13 @@ static NSArray<NSItemProvider *> *extractItemProvidersFromDropSession(id <UIDrop > return; > > auto unselectedSnapshotImage = snapshotWithoutSelection->nativeImage(); >- if (!unselectedSnapshotImage) >+ if (!unselectedSnapshotImage || unselectedSnapshotImage->isNull()) > return; > > if (!_dropAnimationCount) > return; > >- auto unselectedContentImageForEditDrag = adoptNS([[UIImage alloc] initWithCGImage:unselectedSnapshotImage.get() scale:_page->deviceScaleFactor() orientation:UIImageOrientationUp]); >+ auto unselectedContentImageForEditDrag = adoptNS([[UIImage alloc] initWithCGImage:unselectedSnapshotImage->platformImage().get() scale:_page->deviceScaleFactor() orientation:UIImageOrientationUp]); > _unselectedContentSnapshot = adoptNS([[UIImageView alloc] initWithImage:unselectedContentImageForEditDrag.get()]); > [_unselectedContentSnapshot setFrame:data->contentImageWithoutSelectionRectInRootViewCoordinates]; > >@@ -7732,11 +7732,11 @@ static RetainPtr<UIImage> uiImageForImage(WebCore::Image* image) > if (!image) > return nil; > >- auto cgImage = image->nativeImage(); >- if (!cgImage) >+ auto nativeImage = image->nativeImage(); >+ if (!nativeImage || nativeImage->isNull()) > return nil; > >- return adoptNS([[UIImage alloc] initWithCGImage:cgImage.get()]); >+ return adoptNS([[UIImage alloc] initWithCGImage:nativeImage->platformImage().get()]); > } > > // FIXME: This should be merged with createTargetedDragPreview in DragDropInteractionState. >@@ -7991,13 +7991,13 @@ static Vector<WebCore::IntSize> sizesOfPlaceholderElementsToInsertWhenDroppingIt > } > > auto unselectedSnapshotImage = snapshotWithoutSelection->nativeImage(); >- if (!unselectedSnapshotImage) { >+ if (!unselectedSnapshotImage || unselectedSnapshotImage->isNull()) { > RELEASE_LOG(DragAndDrop, "Failed to animate image placeholders: could not decode unselected content image."); > state.clearAllDelayedItemPreviewProviders(); > return; > } > >- auto unselectedContentImageForEditDrag = adoptNS([[UIImage alloc] initWithCGImage:unselectedSnapshotImage.get() scale:protectedSelf->_page->deviceScaleFactor() orientation:UIImageOrientationUp]); >+ auto unselectedContentImageForEditDrag = adoptNS([[UIImage alloc] initWithCGImage:unselectedSnapshotImage->platformImage().get() scale:protectedSelf->_page->deviceScaleFactor() orientation:UIImageOrientationUp]); > auto snapshotView = adoptNS([[UIImageView alloc] initWithImage:unselectedContentImageForEditDrag.get()]); > [snapshotView setFrame:data->contentImageWithoutSelectionRectInRootViewCoordinates]; > [protectedSelf addSubview:snapshotView.get()]; >@@ -10041,7 +10041,12 @@ static UIMenu *menuFromLegacyPreviewOrDefaultActions(UIViewController *previewVi > { > if (!_positionInformation.linkIndicator.contentImage) > return nullptr; >- return [[[UIImage alloc] initWithCGImage:_positionInformation.linkIndicator.contentImage->nativeImage().get()] autorelease]; >+ >+ auto nativeImage = _positionInformation.linkIndicator.contentImage->nativeImage(); >+ if (!nativeImage || nativeImage->isNull()) >+ return nullptr; >+ >+ return [[[UIImage alloc] initWithCGImage:nativeImage->platformImage().get()] autorelease]; > } > > - (NSArray *)_presentationRectsForPreviewItemController:(UIPreviewItemController *)controller >diff --git a/Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.cpp b/Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.cpp >index e76c0638c7da2a04f1e089bc4d490f224b87d216..acef007933e2f2cd0e67b242ef0105a2b143b4bc 100644 >--- a/Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.cpp >+++ b/Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.cpp >@@ -96,10 +96,10 @@ ImageBufferBackendHandle ImageBufferShareableBitmapBackend::createImageBufferBac > return ImageBufferBackendHandle(WTFMove(handle)); > } > >-NativeImagePtr ImageBufferShareableBitmapBackend::copyNativeImage(BackingStoreCopy) const >+RefPtr<NativeImage> ImageBufferShareableBitmapBackend::copyNativeImage(BackingStoreCopy) const > { > #if USE(CG) >- return m_bitmap->makeCGImageCopy(); >+ return NativeImage::create(m_bitmap->makeCGImageCopy()); > #elif USE(DIRECT2D) > return nullptr; > #elif USE(CAIRO) >diff --git a/Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.h b/Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.h >index 05c109cd2026d15f80eb832ad9f1b7ba33bb9557..9e24ab99ebc675ce201a5939728c619dba595ec3 100644 >--- a/Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.h >+++ b/Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.h >@@ -52,7 +52,7 @@ public: > > WebCore::GraphicsContext& context() const override { return *m_context; } > >- WebCore::NativeImagePtr copyNativeImage(WebCore::BackingStoreCopy = WebCore::CopyBackingStore) const override; >+ RefPtr<WebCore::NativeImage> copyNativeImage(WebCore::BackingStoreCopy = WebCore::CopyBackingStore) const override; > RefPtr<WebCore::Image> copyImage(WebCore::BackingStoreCopy = WebCore::CopyBackingStore, WebCore::PreserveResolution = WebCore::PreserveResolution::No) const override; > > Vector<uint8_t> toBGRAData() const override; >diff --git a/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp b/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp >index ca0252a46e2c071ffd534b833dbb4555867ed583..79a2114ba249702cc5547ffa13b33c39608649b5 100644 >--- a/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp >+++ b/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp >@@ -811,7 +811,7 @@ bool MediaPlayerPrivateRemote::copyVideoTextureToPlatformTexture(GraphicsContext > return false; > } > >-NativeImagePtr MediaPlayerPrivateRemote::nativeImageForCurrentTime() >+RefPtr<NativeImage> MediaPlayerPrivateRemote::nativeImageForCurrentTime() > { > notImplemented(); > return nullptr; >diff --git a/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h b/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h >index 5f85df8519e1a31e6283da8fb008a135b213e343..0d7552f493f0742412a6be297396216dc95f581a 100644 >--- a/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h >+++ b/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h >@@ -263,7 +263,7 @@ private: > void paint(WebCore::GraphicsContext&, const WebCore::FloatRect&) final; > void paintCurrentFrameInContext(WebCore::GraphicsContext&, const WebCore::FloatRect&) final; > bool copyVideoTextureToPlatformTexture(WebCore::GraphicsContextGLOpenGL*, PlatformGLObject, GCGLenum, GCGLint, GCGLenum, GCGLenum, GCGLenum, bool, bool) final; >- WebCore::NativeImagePtr nativeImageForCurrentTime() final; >+ RefPtr<WebCore::NativeImage> nativeImageForCurrentTime() final; > > WebCore::MediaPlayerIdentifier identifier() const final; > >diff --git a/Source/WebKit/WebProcess/Plugins/PluginView.cpp b/Source/WebKit/WebProcess/Plugins/PluginView.cpp >index 81cb31b85ff2685100b942f8ecd65187cd428381..929760e2df6be3cb27d0e5ef6fec233ff79819e0 100644 >--- a/Source/WebKit/WebProcess/Plugins/PluginView.cpp >+++ b/Source/WebKit/WebProcess/Plugins/PluginView.cpp >@@ -1683,7 +1683,7 @@ void PluginView::didFailLoad(WebFrame* webFrame, bool wasCancelled) > #if PLATFORM(COCOA) > static bool isAlmostSolidColor(BitmapImage* bitmap) > { >- CGImageRef image = bitmap->nativeImage().get(); >+ CGImageRef image = bitmap->nativeImage()->platformImage().get(); > ASSERT(CGImageGetBitsPerComponent(image) == 8); > > CGBitmapInfo imageInfo = CGImageGetBitmapInfo(image); >diff --git a/Source/WebKitLegacy/mac/DOM/DOM.mm b/Source/WebKitLegacy/mac/DOM/DOM.mm >index 5b8cb6c38c7a5b16674bf14ac0120c35fdf3adf6..7aa004a6169eb40204db224d6edc226f272748cf 100644 >--- a/Source/WebKitLegacy/mac/DOM/DOM.mm >+++ b/Source/WebKitLegacy/mac/DOM/DOM.mm >@@ -536,7 +536,7 @@ id <DOMEventTarget> kit(EventTarget* target) > > if (textIndicator) { > if (Image* image = textIndicator->contentImage()) >- *cgImage = image->nativeImage().autorelease(); >+ *cgImage = image->nativeImage()->platformImage().autorelease(); > } > > if (!*cgImage) { >diff --git a/Source/WebKitLegacy/mac/Misc/WebCache.mm b/Source/WebKitLegacy/mac/Misc/WebCache.mm >index d817699675ecfbb9c2367935c22c57c78a4a34f1..fd096ddf950cbfe8163b13675acdde317b9f31f2 100644 >--- a/Source/WebKitLegacy/mac/Misc/WebCache.mm >+++ b/Source/WebKitLegacy/mac/Misc/WebCache.mm >@@ -171,10 +171,16 @@ class DefaultStorageSessionProvider : public WebCore::StorageSessionProvider { > WebCore::CachedResource* cachedResource = WebCore::MemoryCache::singleton().resourceForRequest(request, PAL::SessionID::defaultSessionID()); > if (!is<WebCore::CachedImage>(cachedResource)) > return nullptr; >- WebCore::CachedImage& cachedImage = downcast<WebCore::CachedImage>(*cachedResource); >+ >+ auto& cachedImage = downcast<WebCore::CachedImage>(*cachedResource); > if (!cachedImage.hasImage()) > return nullptr; >- return cachedImage.image()->nativeImage().get(); >+ >+ auto nativeImage = cachedImage.image()->nativeImage(); >+ if (!nativeImage) >+ return nullptr; >+ >+ return nativeImage->platformImage().get(); > } > > #endif // PLATFORM(IOS_FAMILY) >diff --git a/Source/WebKitLegacy/mac/WebView/WebView.mm b/Source/WebKitLegacy/mac/WebView/WebView.mm >index b60e326f10bf5ce3ca6fa3f40b1aa8e0979d4237..63e952d7e2c14ec913c179a5a2c67de7537ad0fd 100644 >--- a/Source/WebKitLegacy/mac/WebView/WebView.mm >+++ b/Source/WebKitLegacy/mac/WebView/WebView.mm >@@ -845,14 +845,14 @@ private: > _textRectsInBoundingRectCoordinates = createNSArray(indicatorData.textRectsInBoundingRectCoordinates).leakRef(); > _contentImageScaleFactor = indicatorData.contentImageScaleFactor; > if (indicatorData.contentImageWithHighlight) >- _contentImageWithHighlight = [PAL::allocUIImageInstance() initWithCGImage:indicatorData.contentImageWithHighlight.get()->nativeImage().get() scale:scale orientation:UIImageOrientationDownMirrored]; >+ _contentImageWithHighlight = [PAL::allocUIImageInstance() initWithCGImage:indicatorData.contentImageWithHighlight.get()->nativeImage()->platformImage().get() scale:scale orientation:UIImageOrientationDownMirrored]; > if (indicatorData.contentImage) >- _contentImage = [PAL::allocUIImageInstance() initWithCGImage:indicatorData.contentImage.get()->nativeImage().get() scale:scale orientation:UIImageOrientationUp]; >+ _contentImage = [PAL::allocUIImageInstance() initWithCGImage:indicatorData.contentImage.get()->nativeImage()->platformImage().get() scale:scale orientation:UIImageOrientationUp]; > > if (indicatorData.contentImageWithoutSelection) { > auto nativeImage = indicatorData.contentImageWithoutSelection.get()->nativeImage(); > if (nativeImage) { >- _contentImageWithoutSelection = [PAL::allocUIImageInstance() initWithCGImage:nativeImage.get() scale:scale orientation:UIImageOrientationUp]; >+ _contentImageWithoutSelection = [PAL::allocUIImageInstance() initWithCGImage:nativeImage->platformImage().get() scale:scale orientation:UIImageOrientationUp]; > _contentImageWithoutSelectionRectInRootViewCoordinates = indicatorData.contentImageWithoutSelectionRectInRootViewCoordinates; > } > }
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
Flags:
ews-feeder
:
commit-queue-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 218427
:
412868
|
412877
|
412879
|
412880
|
412881
|
412885
|
412887
|
412890
|
412891
|
412893
|
412894
|
413507
|
413508
|
413511
|
413517
|
413518
|
413521
|
413566
|
413639
|
413645