Source/WebCore/ChangeLog

 12020-11-01 Said Abou-Hallawa <said@apple.com>
 2
 3 [GPU Process] Control the life cycle of the platform image by a new class named NativeImage
 4 https://bugs.webkit.org/show_bug.cgi?id=218427
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * Headers.cmake:
 9 * Sources.txt:
 10 * WebCore.xcodeproj/project.pbxproj:
 11 * html/HTMLVideoElement.cpp:
 12 (WebCore::HTMLVideoElement::nativeImageForCurrentTime):
 13 * html/HTMLVideoElement.h:
 14 * html/canvas/CanvasRenderingContext2DBase.cpp:
 15 (WebCore::CanvasRenderingContext2DBase::drawImage):
 16 * page/mac/TextIndicatorWindow.mm:
 17 (-[WebTextIndicatorView initWithFrame:textIndicator:margin:offset:]):
 18 (createContentCrossfadeAnimation):
 19 * platform/graphics/BitmapImage.cpp:
 20 (WebCore::BitmapImage::BitmapImage):
 21 (WebCore::BitmapImage::frameImageAtIndexCacheIfNeeded):
 22 (WebCore::BitmapImage::nativeImage):
 23 (WebCore::BitmapImage::nativeImageForCurrentFrame):
 24 (WebCore::BitmapImage::preTransformedNativeImageForCurrentFrame):
 25 (WebCore::BitmapImage::nativeImageOfSize):
 26 (WebCore::BitmapImage::framesNativeImages):
 27 (WebCore::drawNativeImage):
 28 (WebCore::BitmapImage::draw):
 29 * platform/graphics/BitmapImage.h:
 30 * platform/graphics/ConcreteImageBuffer.h:
 31 * platform/graphics/GraphicsContext.cpp:
 32 (WebCore::GraphicsContext::drawNativeImage):
 33 * platform/graphics/GraphicsContext.h:
 34 (WebCore::GraphicsContext::drawNativeImage):
 35 (WebCore::GraphicsContext::drawPlatformImage):
 36 * platform/graphics/GraphicsContextGLImageExtractor.h:
 37 * platform/graphics/GraphicsContextImpl.h:
 38 * platform/graphics/Icon.h:
 39 * platform/graphics/Image.h:
 40 (WebCore::Image::nativeImage):
 41 (WebCore::Image::nativeImageForCurrentFrame):
 42 (WebCore::Image::preTransformedNativeImageForCurrentFrame):
 43 (WebCore::Image::nativeImageOfSize):
 44 * platform/graphics/ImageBackingStore.h:
 45 * platform/graphics/ImageBuffer.cpp:
 46 (WebCore::ImageBuffer::sinkIntoNativeImage):
 47 * platform/graphics/ImageBuffer.h:
 48 * platform/graphics/ImageBufferBackend.cpp:
 49 (WebCore::ImageBufferBackend::sinkIntoNativeImage):
 50 * platform/graphics/ImageBufferBackend.h:
 51 * platform/graphics/ImageDecoder.h:
 52 * platform/graphics/ImageFrame.cpp:
 53 (WebCore::ImageFrame::clearImage):
 54 (WebCore::ImageFrame::singlePixelSolidColor const):
 55 * platform/graphics/ImageFrame.h:
 56 (WebCore::ImageFrame::nativeImage const):
 57 * platform/graphics/ImageSource.cpp:
 58 (WebCore::ImageSource::ImageSource):
 59 (WebCore::ImageSource::setNativeImage):
 60 (WebCore::ImageSource::cacheMetadataAtIndex):
 61 (WebCore::ImageSource::cachePlatformImageAtIndex):
 62 (WebCore::ImageSource::cachePlatformImageAtIndexAsync):
 63 (WebCore::ImageSource::startAsyncDecodingQueue):
 64 (WebCore::ImageSource::frameAtIndexCacheIfNeeded):
 65 (WebCore::ImageSource::createFrameImageAtIndex):
 66 (WebCore::ImageSource::frameImageAtIndex):
 67 (WebCore::ImageSource::frameImageAtIndexCacheIfNeeded):
 68 (WebCore::ImageSource::cacheNativeImageAtIndex): Deleted.
 69 (WebCore::ImageSource::cacheNativeImageAtIndexAsync): Deleted.
 70 * platform/graphics/ImageSource.h:
 71 (WebCore::ImageSource::create):
 72 * platform/graphics/MediaPlayer.cpp:
 73 (WebCore::MediaPlayer::nativeImageForCurrentTime):
 74 * platform/graphics/MediaPlayer.h:
 75 * platform/graphics/MediaPlayerPrivate.h:
 76 (WebCore::MediaPlayerPrivateInterface::nativeImageForCurrentTime):
 77 * platform/graphics/NativeImage.cpp: Copied from Source/WebCore/platform/graphics/NativeImagePtr.h.
 78 (WebCore::NativeImage::create):
 79 (WebCore::NativeImage::NativeImage):
 80 (WebCore::NativeImage::~NativeImage):
 81 * platform/graphics/NativeImage.h:
 82 (WebCore::NativeImage::renderingResourceIdentifier const):
 83 (WebCore::NativeImage::isNull const):
 84 (WebCore::NativeImage::platformImage):
 85 (WebCore::NativeImage::platformImage const):
 86 (WebCore::NativeImage::size const):
 87 (WebCore::NativeImage::setObserver):
 88 * platform/graphics/PlatformImagePtr.h: Renamed from Source/WebCore/platform/graphics/NativeImagePtr.h.
 89 * platform/graphics/VideoLayerManager.h:
 90 * platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.h:
 91 * platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.mm:
 92 (WebCore::ImageDecoderAVFObjC::createFrameImageAtIndex):
 93 * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
 94 * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
 95 (WebCore::MediaPlayerPrivateAVFoundationObjC::updateVideoFullscreenInlineImage):
 96 (WebCore::MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenLayer):
 97 (WebCore::MediaPlayerPrivateAVFoundationObjC::updateLastImage):
 98 (WebCore::MediaPlayerPrivateAVFoundationObjC::paintWithVideoOutput):
 99 (WebCore::MediaPlayerPrivateAVFoundationObjC::nativeImageForCurrentTime):
 100 * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
 101 * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
 102 (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::nativeImageForCurrentTime):
 103 (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::updateLastImage):
 104 (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::paintCurrentFrameInContext):
 105 (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setVideoFullscreenLayer):
 106 * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h:
 107 * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
 108 (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::setVideoFullscreenLayer):
 109 (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::updateCurrentFrameImage):
 110 (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::paintCurrentFrameInContext):
 111 * platform/graphics/avfoundation/objc/VideoLayerManagerObjC.h:
 112 * platform/graphics/avfoundation/objc/VideoLayerManagerObjC.mm:
 113 (WebCore::VideoLayerManagerObjC::setVideoFullscreenLayer):
 114 (WebCore::VideoLayerManagerObjC::updateVideoFullscreenInlineImage):
 115 * platform/graphics/ca/GraphicsLayerCA.cpp:
 116 (WebCore::GraphicsLayerCA::updateContentsImage):
 117 * platform/graphics/ca/GraphicsLayerCA.h:
 118 * platform/graphics/cairo/GraphicsContextCairo.cpp:
 119 (WebCore::GraphicsContext::drawPlatformImage):
 120 (WebCore::GraphicsContext::platformDrawNativeImage): Deleted.
 121 * platform/graphics/cairo/GraphicsContextImplCairo.cpp:
 122 (WebCore::GraphicsContextImplCairo::drawNativeImage):
 123 (WebCore::GraphicsContextImplCairo::drawPlatformImage):
 124 (WebCore::GraphicsContextImplCairo::drawPattern):
 125 (WebCore::GraphicsContextImplCairo::clipToImageBuffer):
 126 * platform/graphics/cairo/GraphicsContextImplCairo.h:
 127 * platform/graphics/cairo/ImageBufferCairoSurfaceBackend.cpp:
 128 (WebCore::ImageBufferCairoSurfaceBackend::copyNativeImage const):
 129 (WebCore::ImageBufferCairoSurfaceBackend::cairoSurfaceCoerceToImage const):
 130 * platform/graphics/cairo/ImageBufferCairoSurfaceBackend.h:
 131 * platform/graphics/cairo/NativeImageCairo.cpp:
 132 (WebCore::NativeImage::size):
 133 (WebCore::NativeImage::hasAlpha const):
 134 (WebCore::NativeImage::singlePixelSolidColor const):
 135 (WebCore::NativeImage::clearSubimages):
 136 (WebCore::nativeImageSize): Deleted.
 137 (WebCore::nativeImageHasAlpha): Deleted.
 138 (WebCore::nativeImageSinglePixelSolidColor): Deleted.
 139 (WebCore::drawNativeImage): Deleted.
 140 (WebCore::clearNativeImageSubimages): Deleted.
 141 * platform/graphics/cg/GraphicsContextCG.cpp:
 142 (WebCore::GraphicsContext::drawPlatformImage):
 143 (WebCore::GraphicsContext::drawPattern):
 144 (WebCore::GraphicsContext::clipToImageBuffer):
 145 (WebCore::GraphicsContext::platformDrawNativeImage): Deleted.
 146 * platform/graphics/cg/GraphicsContextGLCG.cpp:
 147 (WebCore::GraphicsContextGLImageExtractor::extractImage):
 148 (WebCore::GraphicsContextGLOpenGL::paintToCanvas):
 149 * platform/graphics/cg/ImageBufferCGBackend.cpp:
 150 (WebCore::createCroppedImageIfNecessary):
 151 (WebCore::createBitmapImageAfterScalingIfNeeded):
 152 (WebCore::ImageBufferCGBackend::copyImage const):
 153 (WebCore::ImageBufferCGBackend::draw):
 154 (WebCore::ImageBufferCGBackend::toCFData const):
 155 * platform/graphics/cg/ImageBufferCGBitmapBackend.cpp:
 156 (WebCore::ImageBufferCGBitmapBackend::copyNativeImage const):
 157 * platform/graphics/cg/ImageBufferCGBitmapBackend.h:
 158 * platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp:
 159 (WebCore::ImageBufferIOSurfaceBackend::copyNativeImage const):
 160 (WebCore::ImageBufferIOSurfaceBackend::sinkIntoNativeImage):
 161 (WebCore::ImageBufferIOSurfaceBackend::drawConsuming):
 162 * platform/graphics/cg/ImageBufferIOSurfaceBackend.h:
 163 * platform/graphics/cg/ImageDecoderCG.cpp:
 164 (WebCore::ImageDecoderCG::createFrameImageAtIndex):
 165 * platform/graphics/cg/ImageDecoderCG.h:
 166 * platform/graphics/cg/NativeImageCG.cpp:
 167 (WebCore::NativeImage::size):
 168 (WebCore::NativeImage::hasAlpha const):
 169 (WebCore::NativeImage::singlePixelSolidColor const):
 170 (WebCore::NativeImage::clearSubimages):
 171 (WebCore::nativeImageSize): Deleted.
 172 (WebCore::nativeImageHasAlpha): Deleted.
 173 (WebCore::nativeImageSinglePixelSolidColor): Deleted.
 174 (WebCore::clearNativeImageSubimages): Deleted.
 175 * platform/graphics/cg/PatternCG.cpp:
 176 (WebCore::Pattern::createPlatformPattern const):
 177 * platform/graphics/coreimage/FilterEffectRendererCoreImage.mm:
 178 (WebCore::FilterEffectRendererCoreImage::imageForSourceGraphic):
 179 * platform/graphics/displaylists/DisplayList.h:
 180 * platform/graphics/displaylists/DisplayListItems.cpp:
 181 (WebCore::DisplayList::Item::sizeInBytes):
 182 (WebCore::DisplayList::DrawNativeImage::DrawNativeImage):
 183 (WebCore::DisplayList::DrawNativeImage::apply const):
 184 (WebCore::DisplayList::operator<<):
 185 (WebCore::DisplayList::DrawPlatformImage::DrawPlatformImage):
 186 (WebCore::DisplayList::DrawPlatformImage::apply const):
 187 * platform/graphics/displaylists/DisplayListItems.h:
 188 (WebCore::DisplayList::DrawNativeImage::create):
 189 (WebCore::DisplayList::DrawNativeImage::renderingResourceIdentifier const):
 190 (WebCore::DisplayList::DrawNativeImage::imageSize const):
 191 (WebCore::DisplayList::DrawNativeImage::options const):
 192 (WebCore::DisplayList::DrawNativeImage::encode const):
 193 (WebCore::DisplayList::DrawNativeImage::decode):
 194 (WebCore::DisplayList::DrawPlatformImage::create):
 195 (WebCore::DisplayList::DrawPlatformImage::source const):
 196 (WebCore::DisplayList::DrawPlatformImage::destinationRect const):
 197 (WebCore::DisplayList::DrawPlatformImage::encode const):
 198 (WebCore::DisplayList::DrawPlatformImage::decode):
 199 (WebCore::DisplayList::Item::encode const):
 200 (WebCore::DisplayList::Item::decode):
 201 * platform/graphics/displaylists/DisplayListRecorder.cpp:
 202 (WebCore::DisplayList::Recorder::drawNativeImage):
 203 (WebCore::DisplayList::Recorder::drawPlatformImage):
 204 * platform/graphics/displaylists/DisplayListRecorder.h:
 205 (WebCore::DisplayList::Recorder::Delegate::lockRemoteNativeImage):
 206 * platform/graphics/gstreamer/ImageDecoderGStreamer.cpp:
 207 (WebCore::ImageDecoderGStreamer::createFrameImageAtIndex):
 208 * platform/graphics/gstreamer/ImageDecoderGStreamer.h:
 209 * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
 210 (WebCore::MediaPlayerPrivateGStreamer::nativeImageForCurrentTime):
 211 * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:
 212 * platform/graphics/ios/IconIOS.mm:
 213 (WebCore::Icon::Icon):
 214 (WebCore::Icon::createIconForImage):
 215 (WebCore::Icon::paint):
 216 * platform/graphics/mac/ImageMac.mm:
 217 (WebCore::BitmapImage::tiffRepresentation):
 218 * platform/graphics/nicosia/NicosiaImageBufferPipe.cpp:
 219 (Nicosia::NicosiaImageBufferPipeSource::handle):
 220 * platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp:
 221 (Nicosia::CairoOperationRecorder::drawNativeImage):
 222 (Nicosia::CairoOperationRecorder::drawPlatformImage):
 223 (Nicosia::CairoOperationRecorder::drawPattern):
 224 (Nicosia::CairoOperationRecorder::clipToImageBuffer):
 225 * platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.h:
 226 * platform/graphics/texmap/BitmapTextureGL.cpp:
 227 (WebCore::BitmapTextureGL::updateContents):
 228 * platform/graphics/texmap/GraphicsLayerTextureMapper.cpp:
 229 (WebCore::GraphicsLayerTextureMapper::GraphicsLayerTextureMapper):
 230 (WebCore::GraphicsLayerTextureMapper::setContentsToImage):
 231 * platform/graphics/texmap/GraphicsLayerTextureMapper.h:
 232 * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
 233 (WebCore::CoordinatedGraphicsLayer::CoordinatedGraphicsLayer):
 234 (WebCore::CoordinatedGraphicsLayer::setContentsToImage):
 235 (WebCore::CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly):
 236 * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
 237 * platform/graphics/win/GraphicsContextDirect2D.cpp:
 238 (WebCore::GraphicsContext::drawPlatformImage):
 239 (WebCore::GraphicsContext::platformDrawNativeImage): Deleted.
 240 * platform/graphics/win/GraphicsContextImplDirect2D.cpp:
 241 (WebCore::GraphicsContextImplDirect2D::drawNativeImage):
 242 (WebCore::GraphicsContextImplDirect2D::drawPlatformImage):
 243 * platform/graphics/win/GraphicsContextImplDirect2D.h:
 244 * platform/graphics/win/ImageBufferDirect2DBackend.cpp:
 245 (WebCore::ImageBufferDirect2DBackend::create):
 246 (WebCore::ImageBufferDirect2DBackend::ImageBufferDirect2DBackend):
 247 (WebCore::ImageBufferDirect2DBackend::copyNativeImage const):
 248 (WebCore::createCroppedImageIfNecessary):
 249 (WebCore::ImageBufferDirect2DBackend::copyImage const):
 250 (WebCore::ImageBufferDirect2DBackend::sinkIntoImage):
 251 (WebCore::ImageBufferDirect2DBackend::compatibleBitmap):
 252 * platform/graphics/win/ImageBufferDirect2DBackend.h:
 253 * platform/graphics/win/ImageCGWin.cpp:
 254 (WebCore::BitmapImage::drawFrameMatchingSourceSize):
 255 * platform/graphics/win/ImageCairoWin.cpp:
 256 (WebCore::BitmapImage::drawFrameMatchingSourceSize):
 257 * platform/graphics/win/ImageDecoderDirect2D.cpp:
 258 (WebCore::ImageDecoderDirect2D::createFrameImageAtIndex):
 259 * platform/graphics/win/ImageDecoderDirect2D.h:
 260 * platform/graphics/win/NativeImageDirect2D.cpp:
 261 (WebCore::NativeImage::size):
 262 (WebCore::NativeImage::hasAlpha const):
 263 (WebCore::NativeImage::singlePixelSolidColor const):
 264 (WebCore::NativeImage::clearSubimages):
 265 (WebCore::nativeImageSize): Deleted.
 266 (WebCore::nativeImageHasAlpha): Deleted.
 267 (WebCore::nativeImageSinglePixelSolidColor): Deleted.
 268 (WebCore::drawNativeImage): Deleted.
 269 (WebCore::clearNativeImageSubimages): Deleted.
 270 * platform/image-decoders/ScalableImageDecoder.cpp:
 271 (WebCore::ScalableImageDecoder::createFrameImageAtIndex):
 272 * platform/image-decoders/ScalableImageDecoder.h:
 273 * platform/image-decoders/cairo/ImageBackingStoreCairo.cpp:
 274 (WebCore::ImageBackingStore::image const):
 275 * platform/mediastream/mac/DisplayCaptureSourceCocoa.cpp:
 276 (WebCore::DisplayCaptureSourceCocoa::emitFrame):
 277 * platform/mediastream/mac/DisplayCaptureSourceCocoa.h:
 278 * platform/mediastream/mac/MockRealtimeVideoSourceMac.mm:
 279 (WebCore::MockRealtimeVideoSourceMac::updateSampleBuffer):
 280 * platform/win/DragImageCGWin.cpp:
 281 (WebCore::createDragImageFromImage):
 282 * rendering/RenderThemeIOS.mm:
 283 (WebCore::RenderThemeIOS::paintSystemPreviewBadge):
 284 * svg/graphics/SVGImage.cpp:
 285 (WebCore::SVGImage::nativeImageForCurrentFrame):
 286 (WebCore::SVGImage::nativeImage):
 287 * svg/graphics/SVGImage.h:
 288 * svg/graphics/SVGImageForContainer.cpp:
 289 (WebCore::SVGImageForContainer::nativeImageForCurrentFrame):
 290 * svg/graphics/SVGImageForContainer.h:
 291
12922020-11-01 Mason Xiao <me@masonx.ca>
2293
3294 REGRESSION (r252689): box-shadow with inset and negative spread renders incorrectly

Source/WebKit/ChangeLog

 12020-11-01 Said Abou-Hallawa <said@apple.com>
 2
 3 [GPU Process] Control the life cycle of the platform image by a new class named NativeImage
 4 https://bugs.webkit.org/show_bug.cgi?id=218427
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * Scripts/webkit/messages.py:
 9 * Shared/API/c/cg/WKImageCG.cpp:
 10 (WKImageCreateFromCGImage):
 11 * Shared/WebCoreArgumentCoders.cpp:
 12 (IPC::encodePlatformImage):
 13 (IPC::decodePlatformImage):
 14 (IPC::encodeOptionalPlatformImage):
 15 (IPC::decodeOptionalPlatformImage):
 16 (IPC::ArgumentCoder<PlatformImagePtr>::encode):
 17 (IPC::ArgumentCoder<PlatformImagePtr>::decode):
 18 (IPC::encodeNativeImage): Deleted.
 19 (IPC::decodeNativeImage): Deleted.
 20 (IPC::encodeOptionalNativeImage): Deleted.
 21 (IPC::decodeOptionalNativeImage): Deleted.
 22 (IPC::ArgumentCoder<NativeImagePtr>::encode): Deleted.
 23 (IPC::ArgumentCoder<NativeImagePtr>::decode): Deleted.
 24 * Shared/WebCoreArgumentCoders.h:
 25 * Shared/cg/ShareableBitmapCG.cpp:
 26 (WebKit::ShareableBitmap::createImage):
 27 * UIProcess/API/glib/IconDatabase.cpp:
 28 (WebKit::IconDatabase::loadIconForPageURL):
 29 (WebKit::IconDatabase::setIconForPageURL):
 30 * UIProcess/API/glib/IconDatabase.h:
 31 * UIProcess/ios/DragDropInteractionState.mm:
 32 (WebKit::uiImageForImage):
 33 * UIProcess/ios/WKContentViewInteraction.mm:
 34 (-[WKContentView _deliverDelayedDropPreviewIfPossible:]):
 35 (uiImageForImage):
 36 (-[WKContentView _handleDropByInsertingImagePlaceholders:session:]):
 37 (-[WKContentView _presentationSnapshotForPreviewItemController:]):
 38 * WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.cpp:
 39 (WebKit::ImageBufferShareableBitmapBackend::copyNativeImage const):
 40 * WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.h:
 41 * WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
 42 (WebKit::MediaPlayerPrivateRemote::nativeImageForCurrentTime):
 43 * WebProcess/GPU/media/MediaPlayerPrivateRemote.h:
 44 * WebProcess/Plugins/PluginView.cpp:
 45 (WebKit::isAlmostSolidColor):
 46
1472020-11-01 Sam Weinig <weinig@apple.com>
248
349 Remove remaining alternative preference setting mechanisms from LayoutTests

Source/WebKitLegacy/mac/ChangeLog

 12020-11-01 Said Abou-Hallawa <said@apple.com>
 2
 3 [GPU Process] Control the life cycle of the platform image by a new class named NativeImage
 4 https://bugs.webkit.org/show_bug.cgi?id=218427
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * DOM/DOM.mm:
 9 (-[DOMNode getPreviewSnapshotImage:andRects:]):
 10 * Misc/WebCache.mm:
 11 (+[WebCache imageForURL:]):
 12 * WebView/WebView.mm:
 13 (-[WebUITextIndicatorData initWithImage:textIndicatorData:scale:]):
 14
1152020-10-28 Sam Weinig <weinig@apple.com>
216
317 [Testing] Remove requirement of adding new SPI for each preference that needs testing

Source/WebCore/Headers.cmake

@@set(WebCore_PRIVATE_FRAMEWORK_HEADERS
12041204 platform/graphics/MediaPlayerPrivate.h
12051205 platform/graphics/MediaUsageInfo.h
12061206 platform/graphics/NativeImage.h
1207  platform/graphics/NativeImagePtr.h
12081207 platform/graphics/OpenGLESShims.h
12091208 platform/graphics/OpenGLShims.h
12101209 platform/graphics/Path.h

@@set(WebCore_PRIVATE_FRAMEWORK_HEADERS
12131212 platform/graphics/PlatformDisplay.h
12141213 platform/graphics/PlatformImageBuffer.h
12151214 platform/graphics/PlatformImageBufferBackend.h
 1215 platform/graphics/PlatformImagePtr.h
12161216 platform/graphics/PlatformLayer.h
12171217 platform/graphics/PlatformMediaResourceLoader.h
12181218 platform/graphics/PlatformTextTrack.h

Source/WebCore/Sources.txt

@@platform/graphics/LayoutSize.cpp
19391939platform/graphics/MIMETypeCache.cpp
19401940platform/graphics/MediaPlayer.cpp
19411941platform/graphics/NamedImageGeneratedImage.cpp
 1942platform/graphics/NativeImage.cpp
19421943platform/graphics/Path.cpp
19431944platform/graphics/PathTraversalState.cpp
19441945platform/graphics/PathUtilities.cpp

Source/WebCore/WebCore.xcodeproj/project.pbxproj

21572157 724ED3321A3A8B2300F5F13C /* JSEXTBlendMinMax.h in Headers */ = {isa = PBXBuildFile; fileRef = 724ED3301A3A8B2300F5F13C /* JSEXTBlendMinMax.h */; };
21582158 724EE5501DC80D7F00A91FFB /* ActivityState.h in Headers */ = {isa = PBXBuildFile; fileRef = 724EE54E1DC7F25B00A91FFB /* ActivityState.h */; settings = {ATTRIBUTES = (Private, ); }; };
21592159 724EE5511DC80D8400A91FFB /* ActivityStateChangeObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 724EE54F1DC7F25B00A91FFB /* ActivityStateChangeObserver.h */; settings = {ATTRIBUTES = (Private, ); }; };
2160  726D56E2253AE28D0002EF90 /* NativeImagePtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 726D56E1253AE0430002EF90 /* NativeImagePtr.h */; settings = {ATTRIBUTES = (Private, ); }; };
 2160 726D56E2253AE28D0002EF90 /* PlatformImagePtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 726D56E1253AE0430002EF90 /* PlatformImagePtr.h */; settings = {ATTRIBUTES = (Private, ); }; };
21612161 726D56E3253AE3660002EF90 /* NativeImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 55A336F61D8209F40022C4C7 /* NativeImage.h */; settings = {ATTRIBUTES = (Private, ); }; };
21622162 727A7F3A24078B84004D2931 /* ImageBufferIOSurfaceBackend.h in Headers */ = {isa = PBXBuildFile; fileRef = 72BAC3AB23E1E544008D741C /* ImageBufferIOSurfaceBackend.h */; settings = {ATTRIBUTES = (Private, ); }; };
21632163 7299BC6723D6A53200CC6883 /* AlphaPremultiplication.h in Headers */ = {isa = PBXBuildFile; fileRef = 7299BC6423D686A600CC6883 /* AlphaPremultiplication.h */; settings = {ATTRIBUTES = (Private, ); }; };

99369936 724ED3301A3A8B2300F5F13C /* JSEXTBlendMinMax.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSEXTBlendMinMax.h; sourceTree = "<group>"; };
99379937 724EE54E1DC7F25B00A91FFB /* ActivityState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ActivityState.h; sourceTree = "<group>"; };
99389938 724EE54F1DC7F25B00A91FFB /* ActivityStateChangeObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ActivityStateChangeObserver.h; sourceTree = "<group>"; };
 9939 7252396B254CADC200F5FB15 /* NativeImage.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = NativeImage.cpp; sourceTree = "<group>"; };
99399940 7266F0132241BCE200833975 /* SVGPropertyAnimatorFactory.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGPropertyAnimatorFactory.h; sourceTree = "<group>"; };
99409941 7266F0142241BFB200833975 /* SVGPrimitivePropertyAnimatorImpl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGPrimitivePropertyAnimatorImpl.h; sourceTree = "<group>"; };
99419942 7266F0152241C09800833975 /* SVGPrimitivePropertyAnimator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGPrimitivePropertyAnimator.h; sourceTree = "<group>"; };

99469947 7266F0282243120300833975 /* SVGAnimationAdditiveListFunctionImpl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGAnimationAdditiveListFunctionImpl.h; sourceTree = "<group>"; };
99479948 7266F029224312B100833975 /* SVGAnimationAdditiveListFunction.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGAnimationAdditiveListFunction.h; sourceTree = "<group>"; };
99489949 7266F02A2243149B00833975 /* SVGAnimatedPropertyList.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedPropertyList.h; sourceTree = "<group>"; };
9949  726D56E1253AE0430002EF90 /* NativeImagePtr.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NativeImagePtr.h; sourceTree = "<group>"; };
 9950 726D56E1253AE0430002EF90 /* PlatformImagePtr.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PlatformImagePtr.h; sourceTree = "<group>"; };
99509951 727AFED11A2EA6A0000442E8 /* EXTsRGB.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EXTsRGB.cpp; sourceTree = "<group>"; };
99519952 727AFED21A2EA6A0000442E8 /* EXTsRGB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EXTsRGB.h; sourceTree = "<group>"; };
99529953 727AFED31A2EA6A0000442E8 /* EXTsRGB.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = EXTsRGB.idl; sourceTree = "<group>"; };

2636126362 07B93FF923B92AAA0036F8EA /* MIMETypeCache.h */,
2636226363 314BE3A41B3103FB00141982 /* NamedImageGeneratedImage.cpp */,
2636326364 314BE3A51B3103FB00141982 /* NamedImageGeneratedImage.h */,
 26365 7252396B254CADC200F5FB15 /* NativeImage.cpp */,
2636426366 55A336F61D8209F40022C4C7 /* NativeImage.h */,
26365  726D56E1253AE0430002EF90 /* NativeImagePtr.h */,
2636626367 B27535520B053814002CE64F /* Path.cpp */,
2636726368 B27535530B053814002CE64F /* Path.h */,
2636826369 A88DD4880B4629B000C02990 /* PathTraversalState.cpp */,

2637326374 A8FA6E5B0E4CFDED00D5CF49 /* Pattern.h */,
2637426375 72BAC3A623E17328008D741C /* PlatformImageBuffer.h */,
2637526376 550640AD240756DA00AAE045 /* PlatformImageBufferBackend.h */,
 26377 726D56E1253AE0430002EF90 /* PlatformImagePtr.h */,
2637626378 0562F9601573F88F0031CA16 /* PlatformLayer.h */,
2637726379 CEEFCD7B19DB33DC003876D7 /* PlatformMediaResourceLoader.h */,
2637826380 072847E216EBC5B00043CFA4 /* PlatformTextTrack.h */,

3338433386 A81872230977D3C0005826D9 /* NamedNodeMap.h in Headers */,
3338533387 A818721E0977D3C0005826D9 /* NameNodeList.h in Headers */,
3338633388 726D56E3253AE3660002EF90 /* NativeImage.h in Headers */,
33387  726D56E2253AE28D0002EF90 /* NativeImagePtr.h in Headers */,
3338833389 83B2D1751B8BCD6A00A02E47 /* NativeNodeFilter.h in Headers */,
3338933390 E10B9B6C0B747599003ED890 /* NativeXPathNSResolver.h in Headers */,
3339033391 93CCF0270AF6C52900018E89 /* NavigationAction.h in Headers */,

3361033611 A723F77B1484CA4C008C6DBE /* PlatformExportMacros.h in Headers */,
3361133612 515BE1951D54F5FB00DD7C68 /* PlatformGamepad.h in Headers */,
3361233613 550640AF2407582D00AAE045 /* PlatformImageBufferBackend.h in Headers */,
 33614 726D56E2253AE28D0002EF90 /* PlatformImagePtr.h in Headers */,
3361333615 935C476809AC4D4300A6AAB4 /* PlatformKeyboardEvent.h in Headers */,
3361433616 0562F9611573F88F0031CA16 /* PlatformLayer.h in Headers */,
3361533617 F544F78915CFB2A800AF33A8 /* PlatformLocale.h in Headers */,

Source/WebCore/html/HTMLVideoElement.cpp

@@bool HTMLVideoElement::hasAvailableVideoFrame() const
323323 return player()->hasVideo() && player()->hasAvailableVideoFrame();
324324}
325325
326 NativeImagePtr HTMLVideoElement::nativeImageForCurrentTime()
 326RefPtr<NativeImage> HTMLVideoElement::nativeImageForCurrentTime()
327327{
328328 if (!player())
329329 return nullptr;

Source/WebCore/html/HTMLVideoElement.h

@@public:
7575 // Used by canvas to gain raw pixel access
7676 void paintCurrentFrameInContext(GraphicsContext&, const FloatRect&);
7777
78  NativeImagePtr nativeImageForCurrentTime();
 78 RefPtr<NativeImage> nativeImageForCurrentTime();
7979
8080 // Used by WebGL to do GPU-GPU textures copy if possible.
8181 // See more details at MediaPlayer::copyVideoTextureToPlatformTexture() defined in Source/WebCore/platform/graphics/MediaPlayer.h.

Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp

@@ExceptionOr<void> CanvasRenderingContext2DBase::drawImage(HTMLVideoElement& vide
16351635 checkOrigin(&video);
16361636
16371637#if USE(CG)
1638  if (NativeImagePtr image = video.nativeImageForCurrentTime()) {
1639  c->drawNativeImage(image, FloatSize(video.videoWidth(), video.videoHeight()), dstRect, srcRect);
 1638 if (auto image = video.nativeImageForCurrentTime()) {
 1639 c->drawNativeImage(*image, FloatSize(video.videoWidth(), video.videoHeight()), dstRect, srcRect);
16401640 if (rectContainsCanvas(dstRect))
16411641 didDrawEntireCanvas();
16421642 else

Source/WebCore/page/mac/TextIndicatorWindow.mm

@@static bool indicatorWantsManualAnimation(const TextIndicator& indicator)
161161
162162 FloatSize contentsImageLogicalSize = _textIndicator->contentImage()->size();
163163 contentsImageLogicalSize.scale(1 / _textIndicator->contentImageScaleFactor());
164  RetainPtr<CGImageRef> contentsImage;
 164 RefPtr<NativeImage> contentsImage;
165165 if (indicatorWantsContentCrossfade(*_textIndicator))
166166 contentsImage = _textIndicator->contentImageWithHighlight()->nativeImage();
167167 else

@@static RetainPtr<CAKeyframeAnimation> createBounceAnimation(CFTimeInterval durat
266266static RetainPtr<CABasicAnimation> createContentCrossfadeAnimation(CFTimeInterval duration, TextIndicator& textIndicator)
267267{
268268 RetainPtr<CABasicAnimation> crossfadeAnimation = [CABasicAnimation animationWithKeyPath:@"contents"];
269  RetainPtr<CGImageRef> contentsImage = textIndicator.contentImage()->nativeImage();
 269 RetainPtr<CGImageRef> contentsImage = textIndicator.contentImage()->nativeImage()->platformImage();
270270 [crossfadeAnimation setToValue:(__bridge id)contentsImage.get()];
271271 [crossfadeAnimation setFillMode:kCAFillModeForwards];
272272 [crossfadeAnimation setRemovedOnCompletion:NO];

Source/WebCore/platform/graphics/BitmapImage.cpp

@@BitmapImage::BitmapImage(ImageObserver* observer)
5252{
5353}
5454
55 BitmapImage::BitmapImage(NativeImagePtr&& image, ImageObserver* observer)
 55BitmapImage::BitmapImage(RefPtr<NativeImage>&& image, ImageObserver* observer)
5656 : Image(observer)
5757 , m_source(ImageSource::create(WTFMove(image)))
5858{

@@void BitmapImage::setCurrentFrameDecodingStatusIfNecessary(DecodingStatus decodi
128128 m_currentFrameDecodingStatus = decodingStatus;
129129}
130130
131 NativeImagePtr BitmapImage::frameImageAtIndexCacheIfNeeded(size_t index, SubsamplingLevel subsamplingLevel, const GraphicsContext* targetContext)
 131RefPtr<NativeImage> BitmapImage::frameImageAtIndexCacheIfNeeded(size_t index, SubsamplingLevel subsamplingLevel, const GraphicsContext* targetContext)
132132{
133133 if (!frameHasFullSizeNativeImageAtIndex(index, subsamplingLevel)) {
134134 LOG(Images, "BitmapImage::%s - %p - url: %s [subsamplingLevel was %d, resampling]", __FUNCTION__, this, sourceURL().string().utf8().data(), static_cast<int>(frameSubsamplingLevelAtIndex(index)));

@@NativeImagePtr BitmapImage::frameImageAtIndexCacheIfNeeded(size_t index, Subsamp
142142 return m_source->frameImageAtIndexCacheIfNeeded(index, subsamplingLevel);
143143}
144144
145 NativeImagePtr BitmapImage::nativeImage(const GraphicsContext* targetContext)
 145RefPtr<NativeImage> BitmapImage::nativeImage(const GraphicsContext* targetContext)
146146{
147147 return frameImageAtIndexCacheIfNeeded(0, SubsamplingLevel::Default, targetContext);
148148}
149149
150 NativeImagePtr BitmapImage::nativeImageForCurrentFrame(const GraphicsContext* targetContext)
 150RefPtr<NativeImage> BitmapImage::nativeImageForCurrentFrame(const GraphicsContext* targetContext)
151151{
152152 return frameImageAtIndexCacheIfNeeded(m_currentFrame, SubsamplingLevel::Default, targetContext);
153153}
154154
155 NativeImagePtr BitmapImage::preTransformedNativeImageForCurrentFrame(bool respectOrientation, const GraphicsContext* targetContext)
 155RefPtr<NativeImage> BitmapImage::preTransformedNativeImageForCurrentFrame(bool respectOrientation, const GraphicsContext* targetContext)
156156{
157157 auto image = nativeImageForCurrentFrame(targetContext);
158158

@@NativeImagePtr BitmapImage::preTransformedNativeImageForCurrentFrame(bool respec
171171 FloatRect destRect(FloatPoint(), correctedSizeFloat);
172172 FloatRect sourceRect(FloatPoint(), sourceSize);
173173
174  buffer->context().drawNativeImage(image, sourceSize, destRect, sourceRect, { orientation });
 174 buffer->context().drawNativeImage(*image, sourceSize, destRect, sourceRect, { orientation });
175175 return ImageBuffer::sinkIntoNativeImage(WTFMove(buffer));
176176}
177177
178178#if USE(CG)
179 NativeImagePtr BitmapImage::nativeImageOfSize(const IntSize& size, const GraphicsContext* targetContext)
 179RefPtr<NativeImage> BitmapImage::nativeImageOfSize(const IntSize& size, const GraphicsContext* targetContext)
180180{
181181 size_t count = frameCount();
182182
183183 for (size_t i = 0; i < count; ++i) {
184184 auto image = frameImageAtIndexCacheIfNeeded(i, SubsamplingLevel::Default, targetContext);
185  if (image && nativeImageSize(image) == size)
 185 if (image && image->size() == size)
186186 return image;
187187 }
188188

@@NativeImagePtr BitmapImage::nativeImageOfSize(const IntSize& size, const Graphic
190190 return frameImageAtIndexCacheIfNeeded(0, SubsamplingLevel::Default, targetContext);
191191}
192192
193 Vector<NativeImagePtr> BitmapImage::framesNativeImages()
 193Vector<RefPtr<NativeImage>> BitmapImage::framesNativeImages()
194194{
195  Vector<NativeImagePtr> images;
 195 Vector<RefPtr<NativeImage>> images;
196196 size_t count = frameCount();
197197
198198 for (size_t i = 0; i < count; ++i) {
199199 if (auto image = frameImageAtIndexCacheIfNeeded(i))
200  images.append(image);
 200 images.append(WTFMove(image));
201201 }
202202
203203 return images;

@@bool BitmapImage::notSolidColor()
211211}
212212#endif // ASSERT_ENABLED
213213
214 static inline void drawNativeImage(const NativeImagePtr& image, GraphicsContext& context, const FloatRect& destRect, const FloatRect& srcRect, const IntSize& srcSize, const ImagePaintingOptions& options)
 214static inline void drawNativeImage(NativeImage& image, GraphicsContext& context, const FloatRect& destRect, const FloatRect& srcRect, const IntSize& srcSize, const ImagePaintingOptions& options)
215215{
216216 // Subsampling may have given us an image that is smaller than size().
217  IntSize subsampledImageSize = nativeImageSize(image);
 217 IntSize subsampledImageSize = image.size();
218218 if (options.orientation().usesWidthAsHeight())
219219 subsampledImageSize = subsampledImageSize.transposedSize();
220220

@@ImageDrawResult BitmapImage::draw(GraphicsContext& context, const FloatRect& des
246246 m_currentSubsamplingLevel = m_allowSubsampling ? subsamplingLevelForScaleFactor(context, scaleFactorForDrawing) : SubsamplingLevel::Default;
247247 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());
248248
249  NativeImagePtr image;
 249 RefPtr<NativeImage> image;
250250 if (options.decodingMode() == DecodingMode::Asynchronous) {
251251 ASSERT(!canAnimate());
252252 ASSERT(!m_currentFrame || m_animationFinished);

@@ImageDrawResult BitmapImage::draw(GraphicsContext& context, const FloatRect& des
322322 auto orientation = options.orientation();
323323 if (orientation == ImageOrientation::FromImage) {
324324 orientation = frameOrientationAtIndex(m_currentFrame);
325  drawNativeImage(image, context, destRect, srcRect, IntSize(sourceSize(orientation)), { options, orientation });
 325 drawNativeImage(*image, context, destRect, srcRect, IntSize(sourceSize(orientation)), { options, orientation });
326326 } else
327  drawNativeImage(image, context, destRect, srcRect, IntSize(sourceSize(orientation)), options);
 327 drawNativeImage(*image, context, destRect, srcRect, IntSize(sourceSize(orientation)), options);
328328
329329 m_currentFrameDecodingStatus = frameDecodingStatusAtIndex(m_currentFrame);
330330

Source/WebCore/platform/graphics/BitmapImage.h

@@class Timer;
5353
5454class BitmapImage final : public Image {
5555public:
56  static Ref<BitmapImage> create(NativeImagePtr&& nativeImage, ImageObserver* observer = nullptr)
 56 static Ref<BitmapImage> create(PlatformImagePtr&& platformImage, ImageObserver* observer = nullptr)
 57 {
 58 return adoptRef(*new BitmapImage(NativeImage::create(WTFMove(platformImage)), observer));
 59 }
 60 static Ref<BitmapImage> create(RefPtr<NativeImage>&& nativeImage, ImageObserver* observer = nullptr)
5761 {
5862 return adoptRef(*new BitmapImage(WTFMove(nativeImage), observer));
5963 }

@@public:
135139#endif
136140#endif
137141
138  WEBCORE_EXPORT NativeImagePtr nativeImage(const GraphicsContext* = nullptr) override;
139  NativeImagePtr nativeImageForCurrentFrame(const GraphicsContext* = nullptr) override;
140  NativeImagePtr preTransformedNativeImageForCurrentFrame(bool respectOrientation, const GraphicsContext* = nullptr) override;
 142 WEBCORE_EXPORT RefPtr<NativeImage> nativeImage(const GraphicsContext* = nullptr) override;
 143 RefPtr<NativeImage> nativeImageForCurrentFrame(const GraphicsContext* = nullptr) override;
 144 RefPtr<NativeImage> preTransformedNativeImageForCurrentFrame(bool respectOrientation, const GraphicsContext* = nullptr) override;
141145#if USE(CG)
142  NativeImagePtr nativeImageOfSize(const IntSize&, const GraphicsContext* = nullptr) override;
143  Vector<NativeImagePtr> framesNativeImages();
 146 RefPtr<NativeImage> nativeImageOfSize(const IntSize&, const GraphicsContext* = nullptr) override;
 147 Vector<RefPtr<NativeImage>> framesNativeImages();
144148#endif
145149
146150 void imageFrameAvailableAtIndex(size_t);
147151 void decode(Function<void()>&&);
148152
149153private:
150  WEBCORE_EXPORT BitmapImage(NativeImagePtr&&, ImageObserver* = nullptr);
 154 WEBCORE_EXPORT BitmapImage(RefPtr<NativeImage>&&, ImageObserver* = nullptr);
151155 WEBCORE_EXPORT BitmapImage(ImageObserver* = nullptr);
152156
153  NativeImagePtr frameImageAtIndex(size_t index) { return m_source->frameImageAtIndex(index); }
154  NativeImagePtr frameImageAtIndexCacheIfNeeded(size_t, SubsamplingLevel = SubsamplingLevel::Default, const GraphicsContext* = nullptr);
 157 RefPtr<NativeImage> frameImageAtIndex(size_t index) { return m_source->frameImageAtIndex(index); }
 158 RefPtr<NativeImage> frameImageAtIndexCacheIfNeeded(size_t, SubsamplingLevel = SubsamplingLevel::Default, const GraphicsContext* = nullptr);
155159
156160 // Called to invalidate cached data. When |destroyAll| is true, we wipe out
157161 // the entire frame buffer cache and tell the image source to destroy

@@private:
198202#endif
199203
200204#if PLATFORM(COCOA)
201  RetainPtr<CFDataRef> tiffRepresentation(const Vector<NativeImagePtr>&);
 205 RetainPtr<CFDataRef> tiffRepresentation(const Vector<RefPtr<NativeImage>>&);
202206#endif
203207
204208 void clearTimer();

Source/WebCore/platform/graphics/ConcreteImageBuffer.h

@@protected:
115115 return m_backend ? m_backend->externalMemoryCost() : 0;
116116 }
117117
118  NativeImagePtr copyNativeImage(BackingStoreCopy copyBehavior = CopyBackingStore) const override
 118 RefPtr<NativeImage> copyNativeImage(BackingStoreCopy copyBehavior = CopyBackingStore) const override
119119 {
120120 if (auto* backend = ensureBackendCreated()) {
121121 const_cast<ConcreteImageBuffer&>(*this).flushDrawingContext();

@@protected:
149149 }
150150 }
151151
152  NativeImagePtr sinkIntoNativeImage() override
 152 RefPtr<NativeImage> sinkIntoNativeImage() override
153153 {
154154 if (auto* backend = ensureBackendCreated()) {
155155 flushDrawingContext();

Source/WebCore/platform/graphics/GraphicsContext.cpp

@@void GraphicsContext::drawBidiText(const FontCascade& font, const TextRun& run,
731731 bidiRuns.clear();
732732}
733733
734 void GraphicsContext::drawNativeImage(const NativeImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
 734void GraphicsContext::drawNativeImage(NativeImage& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
735735{
736736 if (paintingDisabled())
737737 return;
738738
739  if (m_impl) {
740  m_impl->drawNativeImage(image, imageSize, destRect, srcRect, options);
 739 if (m_impl && m_impl->drawNativeImage(image, imageSize, destRect, srcRect, options))
741740 return;
742  }
743741
744  platformDrawNativeImage(image, imageSize, destRect, srcRect, options);
 742 drawPlatformImage(image.platformImage(), imageSize, destRect, srcRect, options);
745743}
746744
747745ImageDrawResult GraphicsContext::drawImage(Image& image, const FloatPoint& destination, const ImagePaintingOptions& imagePaintingOptions)

Source/WebCore/platform/graphics/GraphicsContext.h

@@public:
379379
380380 WEBCORE_EXPORT void strokeRect(const FloatRect&, float lineWidth);
381381
382  WEBCORE_EXPORT void drawNativeImage(const NativeImagePtr&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& = { });
 382 WEBCORE_EXPORT void drawNativeImage(NativeImage&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& = { });
 383 WEBCORE_EXPORT void drawPlatformImage(const PlatformImagePtr&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& = { });
383384
384385 WEBCORE_EXPORT ImageDrawResult drawImage(Image&, const FloatPoint& destination, const ImagePaintingOptions& = { ImageOrientation::FromImage });
385386 WEBCORE_EXPORT ImageDrawResult drawImage(Image&, const FloatRect& destination, const ImagePaintingOptions& = { ImageOrientation::FromImage });

@@private:
650651
651652 void platformFillRoundedRect(const FloatRoundedRect&, const Color&);
652653
653  void platformDrawNativeImage(const NativeImagePtr&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&);
654 
655654 FloatRect computeLineBoundsAndAntialiasingModeForText(const FloatRect&, bool printing, Color&);
656655
657656 float dashedLineCornerWidthForStrokeWidth(float) const;

Source/WebCore/platform/graphics/GraphicsContextGLImageExtractor.h

@@private:
5959#if USE(CAIRO)
6060 RefPtr<cairo_surface_t> m_imageSurface;
6161#elif USE(CG)
62  RetainPtr<CGImageRef> m_cgImage;
63  RetainPtr<CGImageRef> m_decodedImage;
 62 RefPtr<NativeImage> m_cgImage;
 63 RefPtr<NativeImage> m_decodedImage;
6464 RetainPtr<CFDataRef> m_pixelData;
6565 UniqueArray<uint8_t> m_formalizedRGBA8Data;
6666#endif

Source/WebCore/platform/graphics/GraphicsContextImpl.h

@@public:
7474 virtual ImageDrawResult drawTiledImage(Image&, const FloatRect& destination, const FloatRect& source, const FloatSize& tileScaleFactor, Image::TileRule hRule, Image::TileRule vRule, const ImagePaintingOptions&) = 0;
7575
7676 virtual bool drawImageBuffer(ImageBuffer&, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions&) = 0;
77  virtual void drawNativeImage(const NativeImagePtr&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) = 0;
 77 virtual bool drawNativeImage(NativeImage&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) = 0;
 78 virtual void drawPlatformImage(const PlatformImagePtr&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) = 0;
7879 virtual void drawPattern(Image&, const FloatRect& destRect, const FloatRect& srcRect, const AffineTransform&, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions&) = 0;
7980
8081 virtual void drawRect(const FloatRect&, float borderThickness) = 0;

Source/WebCore/platform/graphics/Icon.h

2727#include <wtf/RetainPtr.h>
2828
2929#if PLATFORM(IOS_FAMILY)
30 #include "NativeImage.h"
 30#include "PlatformImagePtr.h"
3131#include <CoreGraphics/CoreGraphics.h>
3232#elif PLATFORM(MAC)
3333OBJC_CLASS NSImage;

@@public:
5454
5555#if PLATFORM(IOS_FAMILY)
5656 // FIXME: Make this work for non-iOS ports and remove the PLATFORM(IOS_FAMILY)-guard.
57  WEBCORE_EXPORT static RefPtr<Icon> createIconForImage(const NativeImagePtr&);
 57 WEBCORE_EXPORT static RefPtr<Icon> createIconForImage(const PlatformImagePtr&);
5858#endif
5959
6060#if PLATFORM(MAC)

@@public:
6464
6565private:
6666#if PLATFORM(IOS_FAMILY)
67  Icon(const RetainPtr<CGImageRef>&);
 67 Icon(const PlatformImagePtr&);
6868 RetainPtr<CGImageRef> m_cgImage;
6969#elif PLATFORM(MAC)
7070 Icon(NSImage*);

Source/WebCore/platform/graphics/Image.h

3434#include "ImageOrientation.h"
3535#include "ImagePaintingOptions.h"
3636#include "ImageTypes.h"
37 #include "NativeImagePtr.h"
 37#include "NativeImage.h"
3838#include "Timer.h"
3939#include <wtf/EnumTraits.h>
4040#include <wtf/Optional.h>

@@public:
153153
154154 enum TileRule { StretchTile, RoundTile, SpaceTile, RepeatTile };
155155
156  virtual NativeImagePtr nativeImage(const GraphicsContext* = nullptr) { return nullptr; }
157  virtual NativeImagePtr nativeImageForCurrentFrame(const GraphicsContext* = nullptr) { return nullptr; }
158  virtual NativeImagePtr preTransformedNativeImageForCurrentFrame(bool = true, const GraphicsContext* = nullptr) { return nullptr; }
159  virtual NativeImagePtr nativeImageOfSize(const IntSize&, const GraphicsContext* = nullptr) { return nullptr; }
 156 virtual RefPtr<NativeImage> nativeImage(const GraphicsContext* = nullptr) { return nullptr; }
 157 virtual RefPtr<NativeImage> nativeImageForCurrentFrame(const GraphicsContext* = nullptr) { return nullptr; }
 158 virtual RefPtr<NativeImage> preTransformedNativeImageForCurrentFrame(bool = true, const GraphicsContext* = nullptr) { return nullptr; }
 159 virtual RefPtr<NativeImage> nativeImageOfSize(const IntSize&, const GraphicsContext* = nullptr) { return nullptr; }
160160
161161 // Accessors for native image formats.
162162

Source/WebCore/platform/graphics/ImageBackingStore.h

@@public:
5252 return std::unique_ptr<ImageBackingStore>(new ImageBackingStore(other));
5353 }
5454
55  NativeImagePtr image() const;
 55 PlatformImagePtr image() const;
5656
5757 bool setSize(const IntSize& size)
5858 {

Source/WebCore/platform/graphics/ImageBuffer.cpp

@@std::unique_ptr<ImageBuffer> ImageBuffer::copyRectToBuffer(const FloatRect& rect
188188 return buffer;
189189}
190190
191 NativeImagePtr ImageBuffer::sinkIntoNativeImage(std::unique_ptr<ImageBuffer> imageBuffer)
 191RefPtr<NativeImage> ImageBuffer::sinkIntoNativeImage(std::unique_ptr<ImageBuffer> imageBuffer)
192192{
193193 return imageBuffer->sinkIntoNativeImage();
194194}

Source/WebCore/platform/graphics/ImageBuffer.h

@@public:
7979 virtual size_t memoryCost() const = 0;
8080 virtual size_t externalMemoryCost() const = 0;
8181
82  virtual NativeImagePtr copyNativeImage(BackingStoreCopy = CopyBackingStore) const = 0;
 82 virtual RefPtr<NativeImage> copyNativeImage(BackingStoreCopy = CopyBackingStore) const = 0;
8383 virtual RefPtr<Image> copyImage(BackingStoreCopy = CopyBackingStore, PreserveResolution = PreserveResolution::No) const = 0;
8484
8585 // Create an image buffer compatible with the context and copy rect from this buffer into this new one.

@@public:
8888 virtual void draw(GraphicsContext&, const FloatRect& destRect, const FloatRect& srcRect = FloatRect(0, 0, -1, -1), const ImagePaintingOptions& = { }) = 0;
8989 virtual void drawPattern(GraphicsContext&, const FloatRect& destRect, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& = { }) = 0;
9090
91  static NativeImagePtr sinkIntoNativeImage(std::unique_ptr<ImageBuffer>);
 91 static RefPtr<NativeImage> sinkIntoNativeImage(std::unique_ptr<ImageBuffer>);
9292
9393 WEBCORE_EXPORT static RefPtr<Image> sinkIntoImage(std::unique_ptr<ImageBuffer>, PreserveResolution = PreserveResolution::No);
9494 static void drawConsuming(std::unique_ptr<ImageBuffer>, GraphicsContext&, const FloatRect& destRect, const FloatRect& srcRect = FloatRect(0, 0, -1, -1), const ImagePaintingOptions& = { });

@@public:
111111protected:
112112 ImageBuffer() = default;
113113
114  virtual NativeImagePtr sinkIntoNativeImage() = 0;
 114 virtual RefPtr<NativeImage> sinkIntoNativeImage() = 0;
115115 virtual RefPtr<Image> sinkIntoImage(PreserveResolution = PreserveResolution::No) = 0;
116116 virtual void drawConsuming(GraphicsContext&, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) = 0;
117117};

Source/WebCore/platform/graphics/ImageBufferBackend.cpp

@@IntSize ImageBufferBackend::calculateBackendSize(const FloatSize& size, float re
5858 return backendSize;
5959}
6060
61 NativeImagePtr ImageBufferBackend::sinkIntoNativeImage()
 61RefPtr<NativeImage> ImageBufferBackend::sinkIntoNativeImage()
6262{
6363 return copyNativeImage(DontCopyBackingStore);
6464}

Source/WebCore/platform/graphics/ImageBufferBackend.h

3131#include "GraphicsTypesGL.h"
3232#include "ImagePaintingOptions.h"
3333#include "IntRect.h"
34 #include "NativeImagePtr.h"
 34#include "NativeImage.h"
3535#include "PlatformLayer.h"
3636#include <wtf/RefPtr.h>
3737#include <wtf/Vector.h>

@@public:
7777 virtual size_t memoryCost() const { return 4 * m_backendSize.area().unsafeGet(); }
7878 virtual size_t externalMemoryCost() const { return 0; }
7979
80  virtual NativeImagePtr copyNativeImage(BackingStoreCopy) const = 0;
 80 virtual RefPtr<NativeImage> copyNativeImage(BackingStoreCopy) const = 0;
8181 virtual RefPtr<Image> copyImage(BackingStoreCopy, PreserveResolution) const = 0;
8282
8383 WEBCORE_EXPORT virtual void draw(GraphicsContext&, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) = 0;
8484 WEBCORE_EXPORT virtual void drawPattern(GraphicsContext&, const FloatRect& destRect, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions&) = 0;
8585
86  WEBCORE_EXPORT virtual NativeImagePtr sinkIntoNativeImage();
 86 WEBCORE_EXPORT virtual RefPtr<NativeImage> sinkIntoNativeImage();
8787 WEBCORE_EXPORT virtual RefPtr<Image> sinkIntoImage(PreserveResolution);
8888 WEBCORE_EXPORT virtual void drawConsuming(GraphicsContext& destContext, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&);
8989

Source/WebCore/platform/graphics/ImageDecoder.h

3030#include "ImageTypes.h"
3131#include "IntPoint.h"
3232#include "IntSize.h"
33 #include "NativeImage.h"
 33#include "PlatformImagePtr.h"
3434#include <wtf/Optional.h>
3535#include <wtf/Seconds.h>
3636#include <wtf/text/WTFString.h>

@@public:
7474 virtual bool frameAllowSubsamplingAtIndex(size_t) const = 0;
7575 virtual unsigned frameBytesAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default) const = 0;
7676
77  virtual NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingOptions(DecodingMode::Synchronous)) = 0;
 77 virtual PlatformImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingOptions(DecodingMode::Synchronous)) = 0;
7878
7979 virtual void setExpectedContentSize(long long) { }
8080 virtual void setData(SharedBuffer&, bool allDataReceived) = 0;

Source/WebCore/platform/graphics/ImageFrame.cpp

@@unsigned ImageFrame::clearImage()
8282
8383 unsigned frameBytes = this->frameBytes();
8484
85  clearNativeImageSubimages(m_nativeImage);
 85 m_nativeImage->clearSubimages();
8686 m_nativeImage = nullptr;
8787 m_decodingOptions = DecodingOptions();
8888

@@Color ImageFrame::singlePixelSolidColor() const
121121 if (!hasNativeImage() || m_size != IntSize(1, 1))
122122 return Color();
123123
124  return nativeImageSinglePixelSolidColor(m_nativeImage);
 124 return m_nativeImage->singlePixelSolidColor();
125125}
126126
127127}

Source/WebCore/platform/graphics/ImageFrame.h

@@public:
6363 unsigned frameBytes() const { return hasNativeImage() ? (size().area() * sizeof(uint32_t)).unsafeGet() : 0; }
6464 SubsamplingLevel subsamplingLevel() const { return m_subsamplingLevel; }
6565
66  NativeImagePtr nativeImage() const { return m_nativeImage; }
 66 RefPtr<NativeImage> nativeImage() const { return m_nativeImage; }
6767
6868 void setOrientation(ImageOrientation orientation) { m_orientation = orientation; };
6969 ImageOrientation orientation() const { return m_orientation; }

@@private:
8888 DecodingStatus m_decodingStatus { DecodingStatus::Invalid };
8989 IntSize m_size;
9090
91  NativeImagePtr m_nativeImage;
 91 RefPtr<NativeImage> m_nativeImage;
9292 SubsamplingLevel m_subsamplingLevel { SubsamplingLevel::Default };
9393 DecodingOptions m_decodingOptions;
9494

Source/WebCore/platform/graphics/ImageSource.cpp

@@ImageSource::ImageSource(BitmapImage* image, AlphaOption alphaOption, GammaAndCo
4949{
5050}
5151
52 ImageSource::ImageSource(NativeImagePtr&& nativeImage)
 52ImageSource::ImageSource(RefPtr<NativeImage>&& nativeImage)
5353 : m_runLoop(RunLoop::current())
5454{
5555 m_frameCount = 1;

@@void ImageSource::growFrames()
235235 m_frames.grow(newSize);
236236}
237237
238 void ImageSource::setNativeImage(NativeImagePtr&& nativeImage)
 238void ImageSource::setNativeImage(RefPtr<NativeImage>&& nativeImage)
239239{
240240 ASSERT(m_frames.size() == 1);
241241 ImageFrame& frame = m_frames[0];

@@void ImageSource::setNativeImage(NativeImagePtr&& nativeImage)
245245 frame.m_nativeImage = WTFMove(nativeImage);
246246
247247 frame.m_decodingStatus = DecodingStatus::Complete;
248  frame.m_size = nativeImageSize(frame.m_nativeImage);
249  frame.m_hasAlpha = nativeImageHasAlpha(frame.m_nativeImage);
 248 frame.m_size = frame.m_nativeImage->size();
 249 frame.m_hasAlpha = frame.m_nativeImage->hasAlpha();
250250}
251251
252252void ImageSource::cacheMetadataAtIndex(size_t index, SubsamplingLevel subsamplingLevel, DecodingStatus decodingStatus)

@@void ImageSource::cacheMetadataAtIndex(size_t index, SubsamplingLevel subsamplin
267267
268268 if (frame.m_decodingOptions.hasSizeForDrawing()) {
269269 ASSERT(frame.hasNativeImage());
270  frame.m_size = nativeImageSize(frame.nativeImage());
 270 frame.m_size = frame.nativeImage()->size();
271271 } else
272272 frame.m_size = m_decoder->frameSizeAtIndex(index, subsamplingLevel);
273273

@@void ImageSource::cacheMetadataAtIndex(size_t index, SubsamplingLevel subsamplin
279279 frame.m_duration = m_decoder->frameDurationAtIndex(index);
280280}
281281
282 void ImageSource::cacheNativeImageAtIndex(NativeImagePtr&& nativeImage, size_t index, SubsamplingLevel subsamplingLevel, const DecodingOptions& decodingOptions, DecodingStatus decodingStatus)
 282void ImageSource::cachePlatformImageAtIndex(PlatformImagePtr&& platformImage, size_t index, SubsamplingLevel subsamplingLevel, const DecodingOptions& decodingOptions, DecodingStatus decodingStatus)
283283{
284284 ASSERT(index < m_frames.size());
285285 ImageFrame& frame = m_frames[index];

@@void ImageSource::cacheNativeImageAtIndex(NativeImagePtr&& nativeImage, size_t i
293293 return;
294294
295295 // Move the new image to the cache.
296  frame.m_nativeImage = WTFMove(nativeImage);
 296 frame.m_nativeImage = NativeImage::create(WTFMove(platformImage));
297297 frame.m_decodingOptions = decodingOptions;
298298 cacheMetadataAtIndex(index, subsamplingLevel, decodingStatus);
299299

@@void ImageSource::cacheNativeImageAtIndex(NativeImagePtr&& nativeImage, size_t i
301301 decodedSizeIncreased(frame.frameBytes());
302302}
303303
304 void ImageSource::cacheNativeImageAtIndexAsync(NativeImagePtr&& nativeImage, size_t index, SubsamplingLevel subsamplingLevel, const DecodingOptions& decodingOptions, DecodingStatus decodingStatus)
 304void ImageSource::cachePlatformImageAtIndexAsync(PlatformImagePtr&& platformImage, size_t index, SubsamplingLevel subsamplingLevel, const DecodingOptions& decodingOptions, DecodingStatus decodingStatus)
305305{
306306 if (!isDecoderAvailable())
307307 return;

@@void ImageSource::cacheNativeImageAtIndexAsync(NativeImagePtr&& nativeImage, siz
309309 ASSERT(index < m_frames.size());
310310
311311 // Clean the old native image and set a new one
312  cacheNativeImageAtIndex(WTFMove(nativeImage), index, subsamplingLevel, decodingOptions, decodingStatus);
 312 cachePlatformImageAtIndex(WTFMove(platformImage), index, subsamplingLevel, decodingOptions, decodingStatus);
313313 LOG(Images, "ImageSource::%s - %p - url: %s [frame %ld has been cached]", __FUNCTION__, this, sourceURL().string().utf8().data(), index);
314314
315315 // Notify the image with the readiness of the new frame NativeImage.

@@void ImageSource::startAsyncDecodingQueue()
362362 startingTime = MonotonicTime::now();
363363
364364 // Get the frame NativeImage on the decoding thread.
365  NativeImagePtr nativeImage = protectedDecoder->createFrameImageAtIndex(frameRequest.index, frameRequest.subsamplingLevel, frameRequest.decodingOptions);
366  if (nativeImage)
 365 auto platformImage = protectedDecoder->createFrameImageAtIndex(frameRequest.index, frameRequest.subsamplingLevel, frameRequest.decodingOptions);
 366 if (platformImage)
367367 LOG(Images, "ImageSource::%s - %p - url: %s [frame %ld has been decoded]", __FUNCTION__, protectedThis.ptr(), sourceURL.utf8().data(), frameRequest.index);
368368 else {
369369 LOG(Images, "ImageSource::%s - %p - url: %s [decoding for frame %ld has failed]", __FUNCTION__, protectedThis.ptr(), sourceURL.utf8().data(), frameRequest.index);

@@void ImageSource::startAsyncDecodingQueue()
375375 sleep(minDecodingDuration - (MonotonicTime::now() - startingTime));
376376
377377 // Update the cached frames on the creation thread to avoid updating the MemoryCache from a different thread.
378  callOnMainThread([protectedThis, protectedDecodingQueue, protectedDecoder, sourceURL = sourceURL.isolatedCopy(), nativeImage = WTFMove(nativeImage), frameRequest] () mutable {
 378 callOnMainThread([protectedThis, protectedDecodingQueue, protectedDecoder, sourceURL = sourceURL.isolatedCopy(), platformImage = WTFMove(platformImage), frameRequest] () mutable {
379379 // The queue may have been closed if after we got the frame NativeImage, stopAsyncDecodingQueue() was called.
380380 if (protectedDecodingQueue.ptr() == protectedThis->m_decodingQueue && protectedDecoder.ptr() == protectedThis->m_decoder) {
381381 ASSERT(protectedThis->m_frameCommitQueue.first() == frameRequest);
382382 protectedThis->m_frameCommitQueue.removeFirst();
383  protectedThis->cacheNativeImageAtIndexAsync(WTFMove(nativeImage), frameRequest.index, frameRequest.subsamplingLevel, frameRequest.decodingOptions, frameRequest.decodingStatus);
 383 protectedThis->cachePlatformImageAtIndexAsync(WTFMove(platformImage), frameRequest.index, frameRequest.subsamplingLevel, frameRequest.decodingOptions, frameRequest.decodingStatus);
384384 } else
385385 LOG(Images, "ImageSource::%s - %p - url: %s [frame %ld will not cached]", __FUNCTION__, protectedThis.ptr(), sourceURL.utf8().data(), frameRequest.index);
386386 });

@@const ImageFrame& ImageSource::frameAtIndexCacheIfNeeded(size_t index, ImageFram
454454 if (frame.hasFullSizeNativeImage(subsamplingLevel))
455455 break;
456456 // We have to perform synchronous image decoding in this code.
457  NativeImagePtr nativeImage = m_decoder->createFrameImageAtIndex(index, subsamplingLevelValue);
 457 auto platformImage = m_decoder->createFrameImageAtIndex(index, subsamplingLevelValue);
458458 // Clean the old native image and set a new one.
459  cacheNativeImageAtIndex(WTFMove(nativeImage), index, subsamplingLevelValue, DecodingOptions(DecodingMode::Synchronous));
 459 cachePlatformImageAtIndex(WTFMove(platformImage), index, subsamplingLevelValue, DecodingOptions(DecodingMode::Synchronous));
460460 break;
461461 }
462462

@@void ImageSource::setTargetContext(const GraphicsContext* targetContext)
697697}
698698#endif
699699
700 NativeImagePtr ImageSource::createFrameImageAtIndex(size_t index, SubsamplingLevel subsamplingLevel)
 700RefPtr<NativeImage> ImageSource::createFrameImageAtIndex(size_t index, SubsamplingLevel subsamplingLevel)
701701{
702  return isDecoderAvailable() ? m_decoder->createFrameImageAtIndex(index, subsamplingLevel) : nullptr;
 702 if (!isDecoderAvailable())
 703 return nullptr;
 704 return NativeImage::create(m_decoder->createFrameImageAtIndex(index, subsamplingLevel));
703705}
704706
705 NativeImagePtr ImageSource::frameImageAtIndex(size_t index)
 707RefPtr<NativeImage> ImageSource::frameImageAtIndex(size_t index)
706708{
707  return frameMetadataAtIndex<NativeImagePtr>(index, (&ImageFrame::nativeImage));
 709 return frameMetadataAtIndex<RefPtr<NativeImage>>(index, (&ImageFrame::nativeImage));
708710}
709711
710 NativeImagePtr ImageSource::frameImageAtIndexCacheIfNeeded(size_t index, SubsamplingLevel subsamplingLevel)
 712RefPtr<NativeImage> ImageSource::frameImageAtIndexCacheIfNeeded(size_t index, SubsamplingLevel subsamplingLevel)
711713{
712  return frameMetadataAtIndexCacheIfNeeded<NativeImagePtr>(index, (&ImageFrame::nativeImage), nullptr, ImageFrame::Caching::MetadataAndImage, subsamplingLevel);
 714 return frameMetadataAtIndexCacheIfNeeded<RefPtr<NativeImage>>(index, (&ImageFrame::nativeImage), nullptr, ImageFrame::Caching::MetadataAndImage, subsamplingLevel);
713715}
714716
715717void ImageSource::dump(TextStream& ts)

Source/WebCore/platform/graphics/ImageSource.h

@@public:
5252 return adoptRef(*new ImageSource(image, alphaOption, gammaAndColorProfileOption));
5353 }
5454
55  static Ref<ImageSource> create(NativeImagePtr&& nativeImage)
 55 static Ref<ImageSource> create(RefPtr<NativeImage>&& nativeImage)
5656 {
5757 return adoptRef(*new ImageSource(WTFMove(nativeImage)));
5858 }

@@public:
125125#if USE(DIRECT2D)
126126 void setTargetContext(const GraphicsContext*);
127127#endif
128  NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default);
129  NativeImagePtr frameImageAtIndex(size_t);
130  NativeImagePtr frameImageAtIndexCacheIfNeeded(size_t, SubsamplingLevel = SubsamplingLevel::Default);
 128 RefPtr<NativeImage> createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default);
 129 RefPtr<NativeImage> frameImageAtIndex(size_t);
 130 RefPtr<NativeImage> frameImageAtIndexCacheIfNeeded(size_t, SubsamplingLevel = SubsamplingLevel::Default);
131131
132132private:
133133 ImageSource(BitmapImage*, AlphaOption = AlphaOption::Premultiplied, GammaAndColorProfileOption = GammaAndColorProfileOption::Applied);
134  ImageSource(NativeImagePtr&&);
 134 ImageSource(RefPtr<NativeImage>&&);
135135
136136 template<typename T, T (ImageDecoder::*functor)() const>
137137 T metadata(const T& defaultValue, Optional<T>* cachedValue = nullptr);

@@private:
152152 void decodedSizeReset(unsigned decodedSize);
153153 void encodedDataStatusChanged(EncodedDataStatus);
154154
155  void setNativeImage(NativeImagePtr&&);
 155 void setNativeImage(RefPtr<NativeImage>&&);
156156 void cacheMetadataAtIndex(size_t, SubsamplingLevel, DecodingStatus = DecodingStatus::Invalid);
157  void cacheNativeImageAtIndex(NativeImagePtr&&, size_t, SubsamplingLevel, const DecodingOptions&, DecodingStatus = DecodingStatus::Invalid);
158  void cacheNativeImageAtIndexAsync(NativeImagePtr&&, size_t, SubsamplingLevel, const DecodingOptions&, DecodingStatus);
 157 void cachePlatformImageAtIndex(PlatformImagePtr&&, size_t, SubsamplingLevel, const DecodingOptions&, DecodingStatus = DecodingStatus::Invalid);
 158 void cachePlatformImageAtIndexAsync(PlatformImagePtr&&, size_t, SubsamplingLevel, const DecodingOptions&, DecodingStatus);
159159
160160 struct ImageFrameRequest;
161161 static const int BufferSize = 8;

Source/WebCore/platform/graphics/MediaPlayer.cpp

@@bool MediaPlayer::copyVideoTextureToPlatformTexture(GraphicsContextGLOpenGL* con
985985 return m_private->copyVideoTextureToPlatformTexture(context, texture, target, level, internalFormat, format, type, premultiplyAlpha, flipY);
986986}
987987
988 NativeImagePtr MediaPlayer::nativeImageForCurrentTime()
 988RefPtr<NativeImage> MediaPlayer::nativeImageForCurrentTime()
989989{
990990 return m_private->nativeImageForCurrentTime();
991991}

Source/WebCore/platform/graphics/MediaPlayer.h

@@public:
430430
431431 bool copyVideoTextureToPlatformTexture(GraphicsContextGLOpenGL*, PlatformGLObject texture, GCGLenum target, GCGLint level, GCGLenum internalFormat, GCGLenum format, GCGLenum type, bool premultiplyAlpha, bool flipY);
432432
433  NativeImagePtr nativeImageForCurrentTime();
 433 RefPtr<NativeImage> nativeImageForCurrentTime();
434434
435435 using MediaPlayerEnums::NetworkState;
436436 NetworkState networkState();

Source/WebCore/platform/graphics/MediaPlayerPrivate.h

@@public:
161161
162162 virtual void paintCurrentFrameInContext(GraphicsContext& c, const FloatRect& r) { paint(c, r); }
163163 virtual bool copyVideoTextureToPlatformTexture(GraphicsContextGLOpenGL*, PlatformGLObject, GCGLenum, GCGLint, GCGLenum, GCGLenum, GCGLenum, bool, bool) { return false; }
164  virtual NativeImagePtr nativeImageForCurrentTime() { return nullptr; }
 164 virtual RefPtr<NativeImage> nativeImageForCurrentTime() { return nullptr; }
165165
166166 virtual void setPreload(MediaPlayer::Preload) { }
167167

Source/WebCore/platform/graphics/NativeImage.cpp

 1/*
 2 * Copyright (C) 2020 Apple Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "NativeImage.h"
 28
 29#include <wtf/NeverDestroyed.h>
 30
 31namespace WebCore {
 32
 33Ref<NativeImage> NativeImage::create(PlatformImagePtr& platformImage)
 34{
 35 return adoptRef(*new NativeImage(platformImage));
 36}
 37
 38Ref<NativeImage> NativeImage::create(PlatformImagePtr&& platformImage)
 39{
 40 return adoptRef(*new NativeImage(WTFMove(platformImage)));
 41}
 42
 43NativeImage::NativeImage(PlatformImagePtr& platformImage)
 44 : m_platformImage(platformImage)
 45{
 46}
 47
 48NativeImage::NativeImage(PlatformImagePtr&& platformImage)
 49 : m_platformImage(WTFMove(platformImage))
 50{
 51}
 52
 53NativeImage::~NativeImage()
 54{
 55 if (m_observer && m_platformImage)
 56 m_observer->nativeImageWillBeDeleted(m_renderingResourceIdentifier);
 57}
 58
 59} // namespace WebCore

Source/WebCore/platform/graphics/NativeImage.h

2727
2828#pragma once
2929
30 #include "NativeImagePtr.h"
 30#include "IntSize.h"
 31#include "PlatformImagePtr.h"
 32#include "RenderingResourceIdentifier.h"
 33#include <wtf/RefCounted.h>
3134
3235namespace WebCore {
3336
3437class Color;
35 class IntSize;
3638
37 WEBCORE_EXPORT IntSize nativeImageSize(const NativeImagePtr&);
38 bool nativeImageHasAlpha(const NativeImagePtr&);
39 Color nativeImageSinglePixelSolidColor(const NativeImagePtr&);
40 void clearNativeImageSubimages(const NativeImagePtr&);
 39class NativeImage : public RefCounted<NativeImage> {
 40public:
 41 class Observer {
 42 public:
 43 virtual ~Observer() = default;
 44 virtual void nativeImageWillBeDeleted(RenderingResourceIdentifier) = 0;
 45 protected:
 46 Observer() = default;
 47 };
4148
42 }
 49 static WEBCORE_EXPORT Ref<NativeImage> create(PlatformImagePtr&);
 50 static WEBCORE_EXPORT Ref<NativeImage> create(PlatformImagePtr&&);
 51 static WEBCORE_EXPORT IntSize size(const PlatformImagePtr&);
 52
 53 WEBCORE_EXPORT ~NativeImage();
 54
 55 RenderingResourceIdentifier renderingResourceIdentifier() const { return m_renderingResourceIdentifier; }
 56
 57 bool isNull() const { return !m_platformImage; }
 58 PlatformImagePtr& platformImage() { return m_platformImage; }
 59 const PlatformImagePtr& platformImage() const { return m_platformImage; }
 60
 61 IntSize size() const { return size(m_platformImage); }
 62 bool hasAlpha() const;
 63 Color singlePixelSolidColor() const;
 64
 65 void setObserver(Observer* observer) { m_observer = observer; }
 66 void clearSubimages();
 67
 68private:
 69 NativeImage(PlatformImagePtr&);
 70 NativeImage(PlatformImagePtr&&);
 71
 72 PlatformImagePtr m_platformImage;
 73 Observer* m_observer { nullptr };
 74 RenderingResourceIdentifier m_renderingResourceIdentifier { RenderingResourceIdentifier::generate() };
 75};
 76
 77} // namespace WebCore

Source/WebCore/platform/graphics/NativeImagePtr.h

1 /*
2  * Copyright (C) 2020 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #pragma once
27 
28 #if USE(CG)
29 #include <wtf/RetainPtr.h>
30 typedef struct CGImage* CGImageRef;
31 #elif USE(CAIRO)
32 #include "RefPtrCairo.h"
33 #elif USE(WINGDI)
34 #include "SharedBitmap.h"
35 #endif
36 
37 namespace WebCore {
38 
39 #if USE(CG)
40 typedef RetainPtr<CGImageRef> NativeImagePtr;
41 #elif USE(DIRECT2D)
42 typedef COMPtr<ID2D1Bitmap> NativeImagePtr;
43 #elif USE(CAIRO)
44 typedef RefPtr<cairo_surface_t> NativeImagePtr;
45 #elif USE(WINGDI)
46 typedef RefPtr<SharedBitmap> NativeImagePtr;
47 #endif
48 
49 }

Source/WebCore/platform/graphics/PlatformImagePtr.h

 1/*
 2 * Copyright (C) 2020 Apple Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#pragma once
 27
 28#if USE(CG)
 29#include <wtf/RetainPtr.h>
 30typedef struct CGImage* CGImageRef;
 31#elif USE(CAIRO)
 32#include "RefPtrCairo.h"
 33#elif USE(WINGDI)
 34#include "SharedBitmap.h"
 35#endif
 36
 37namespace WebCore {
 38
 39#if USE(CG)
 40using PlatformImagePtr = RetainPtr<CGImageRef>;
 41#elif USE(DIRECT2D)
 42using PlatformImagePtr = COMPtr<ID2D1Bitmap>;
 43#elif USE(CAIRO)
 44using PlatformImagePtr = RefPtr<cairo_surface_t>;
 45#elif USE(WINGDI)
 46using PlatformImagePtr = RefPtr<SharedBitmap>;
 47#endif
 48
 49}

Source/WebCore/platform/graphics/VideoLayerManager.h

@@public:
4444
4545#if ENABLE(VIDEO_PRESENTATION_MODE)
4646 virtual PlatformLayer* videoFullscreenLayer() const = 0;
47  virtual void setVideoFullscreenLayer(PlatformLayer*, WTF::Function<void()>&& completionHandler, NativeImagePtr) = 0;
 47 virtual void setVideoFullscreenLayer(PlatformLayer*, WTF::Function<void()>&& completionHandler, PlatformImagePtr) = 0;
4848 virtual FloatRect videoFullscreenFrame() const = 0;
4949 virtual void setVideoFullscreenFrame(FloatRect) = 0;
50  virtual void updateVideoFullscreenInlineImage(NativeImagePtr) = 0;
 50 virtual void updateVideoFullscreenInlineImage(PlatformImagePtr) = 0;
5151#endif
5252
5353 virtual bool requiresTextTrackRepresentation() const = 0;

Source/WebCore/platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.h

@@public:
8282 bool frameAllowSubsamplingAtIndex(size_t) const final;
8383 unsigned frameBytesAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default) const final;
8484
85  NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingOptions(DecodingMode::Synchronous)) final;
 85 PlatformImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingOptions(DecodingMode::Synchronous)) final;
8686
8787 void setExpectedContentSize(long long) final;
8888 void setData(SharedBuffer&, bool allDataReceived) final;

Source/WebCore/platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.mm

@@unsigned ImageDecoderAVFObjC::frameBytesAtIndex(size_t index, SubsamplingLevel s
567567 return (frameSize.area() * 4).unsafeGet();
568568}
569569
570 NativeImagePtr ImageDecoderAVFObjC::createFrameImageAtIndex(size_t index, SubsamplingLevel, const DecodingOptions&)
 570PlatformImagePtr ImageDecoderAVFObjC::createFrameImageAtIndex(size_t index, SubsamplingLevel, const DecodingOptions&)
571571{
572572 LockHolder holder { m_sampleGeneratorLock };
573573

Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h

@@private:
252252 bool updateLastPixelBuffer();
253253 bool videoOutputHasAvailableFrame();
254254 void paintWithVideoOutput(GraphicsContext&, const FloatRect&);
255  NativeImagePtr nativeImageForCurrentTime() final;
 255 RefPtr<NativeImage> nativeImageForCurrentTime() final;
256256 void waitForVideoOutputMediaDataWillChange();
257257
258258 bool copyVideoTextureToPlatformTexture(GraphicsContextGLOpenGL*, PlatformGLObject, GCGLenum target, GCGLint level, GCGLenum internalFormat, GCGLenum format, GCGLenum type, bool premultiplyAlpha, bool flipY) final;

@@private:
343343 RetainPtr<AVPlayerItemVideoOutput> m_videoOutput;
344344 RetainPtr<WebCoreAVFPullDelegate> m_videoOutputDelegate;
345345 RetainPtr<CVPixelBufferRef> m_lastPixelBuffer;
346  RetainPtr<CGImageRef> m_lastImage;
 346 RefPtr<NativeImage> m_lastImage;
347347 std::unique_ptr<ImageRotationSessionVT> m_imageRotationSession;
348348 std::unique_ptr<VideoTextureCopierCV> m_videoTextureCopier;
349349 std::unique_ptr<PixelBufferConformerCV> m_pixelBufferConformer;

Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm

@@PlatformLayer* MediaPlayerPrivateAVFoundationObjC::platformLayer() const
11271127void MediaPlayerPrivateAVFoundationObjC::updateVideoFullscreenInlineImage()
11281128{
11291129 updateLastImage(UpdateType::UpdateSynchronously);
1130  m_videoLayerManager->updateVideoFullscreenInlineImage(m_lastImage);
 1130 m_videoLayerManager->updateVideoFullscreenInlineImage(m_lastImage ? m_lastImage->platformImage() : nullptr);
11311131}
11321132
11331133RetainPtr<PlatformLayer> MediaPlayerPrivateAVFoundationObjC::createVideoFullscreenLayer()

@@void MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenLayer(PlatformLayer*
11391139{
11401140 if (videoFullscreenLayer)
11411141 updateLastImage(UpdateType::UpdateSynchronously);
1142  m_videoLayerManager->setVideoFullscreenLayer(videoFullscreenLayer, WTFMove(completionHandler), m_lastImage);
 1142 m_videoLayerManager->setVideoFullscreenLayer(videoFullscreenLayer, WTFMove(completionHandler), m_lastImage ? m_lastImage->platformImage() : nullptr);
11431143 updateDisableExternalPlayback();
11441144}
11451145

@@void MediaPlayerPrivateAVFoundationObjC::updateLastImage(UpdateType type)
22932293
22942294 MonotonicTime start = MonotonicTime::now();
22952295
2296  m_lastImage = m_pixelBufferConformer->createImageFromPixelBuffer(m_lastPixelBuffer.get());
 2296 m_lastImage = NativeImage::create(m_pixelBufferConformer->createImageFromPixelBuffer(m_lastPixelBuffer.get()));
22972297
22982298 INFO_LOG(LOGIDENTIFIER, "creating buffer took ", (MonotonicTime::now() - start).seconds());
22992299}

@@void MediaPlayerPrivateAVFoundationObjC::paintWithVideoOutput(GraphicsContext& c
23142314
23152315 INFO_LOG(LOGIDENTIFIER);
23162316
2317  FloatRect imageRect(0, 0, CGImageGetWidth(m_lastImage.get()), CGImageGetHeight(m_lastImage.get()));
2318  context.drawNativeImage(m_lastImage.get(), imageRect.size(), outputRect, imageRect);
 2317 FloatRect imageRect({ 0, 0 }, m_lastImage->size());
 2318 context.drawNativeImage(*m_lastImage, imageRect.size(), outputRect, imageRect);
23192319
23202320 // If we have created an AVAssetImageGenerator in the past due to m_videoOutput not having an available
23212321 // video frame, destroy it now that it is no longer needed.

@@bool MediaPlayerPrivateAVFoundationObjC::copyVideoTextureToPlatformTexture(Graph
23412341 return m_videoTextureCopier->copyImageToPlatformTexture(m_lastPixelBuffer.get(), width, height, outputTexture, outputTarget, level, internalFormat, format, type, premultiplyAlpha, flipY);
23422342}
23432343
2344 NativeImagePtr MediaPlayerPrivateAVFoundationObjC::nativeImageForCurrentTime()
 2344RefPtr<NativeImage> MediaPlayerPrivateAVFoundationObjC::nativeImageForCurrentTime()
23452345{
23462346 updateLastImage();
23472347 return m_lastImage;

Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h

@@private:
215215
216216 bool didLoadingProgress() const override;
217217
218  NativeImagePtr nativeImageForCurrentTime() override;
 218 RefPtr<NativeImage> nativeImageForCurrentTime() override;
219219 bool updateLastPixelBuffer();
220220 bool updateLastImage();
221221 void paint(GraphicsContext&, const FloatRect&) override;

@@private:
301301 RetainPtr<id> m_performTaskObserver;
302302 RetainPtr<AVStreamSession> m_streamSession;
303303 RetainPtr<CVPixelBufferRef> m_lastPixelBuffer;
304  RetainPtr<CGImageRef> m_lastImage;
 304 RefPtr<NativeImage> m_lastImage;
305305 std::unique_ptr<PixelBufferConformerCV> m_rgbConformer;
306306 RefPtr<WebCoreDecompressionSession> m_decompressionSession;
307307 Deque<RetainPtr<id>> m_sizeChangeObservers;

Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm

@@bool MediaPlayerPrivateMediaSourceAVFObjC::didLoadingProgress() const
564564 return loadingProgressed;
565565}
566566
567 NativeImagePtr MediaPlayerPrivateMediaSourceAVFObjC::nativeImageForCurrentTime()
 567RefPtr<NativeImage> MediaPlayerPrivateMediaSourceAVFObjC::nativeImageForCurrentTime()
568568{
569569 updateLastImage();
570  return m_lastImage.get();
 570 return m_lastImage;
571571}
572572
573573bool MediaPlayerPrivateMediaSourceAVFObjC::updateLastPixelBuffer()

@@bool MediaPlayerPrivateMediaSourceAVFObjC::updateLastImage()
607607 m_rgbConformer = makeUnique<PixelBufferConformerCV>((__bridge CFDictionaryRef)attributes);
608608 }
609609
610  m_lastImage = m_rgbConformer->createImageFromPixelBuffer(m_lastPixelBuffer.get());
 610 m_lastImage = NativeImage::create(m_rgbConformer->createImageFromPixelBuffer(m_lastPixelBuffer.get()));
611611 return true;
612612}
613613

@@void MediaPlayerPrivateMediaSourceAVFObjC::paintCurrentFrameInContext(GraphicsCo
626626 return;
627627
628628 GraphicsContextStateSaver stateSaver(context);
629  FloatRect imageRect(0, 0, CGImageGetWidth(image.get()), CGImageGetHeight(image.get()));
630  context.drawNativeImage(image, imageRect.size(), outputRect, imageRect);
 629 FloatRect imageRect({ 0, 0 }, image->size());
 630 context.drawNativeImage(*image, imageRect.size(), outputRect, imageRect);
631631}
632632
633633bool MediaPlayerPrivateMediaSourceAVFObjC::copyVideoTextureToPlatformTexture(GraphicsContextGLOpenGL* context, PlatformGLObject outputTexture, GCGLenum outputTarget, GCGLint level, GCGLenum internalFormat, GCGLenum format, GCGLenum type, bool premultiplyAlpha, bool flipY)

@@RetainPtr<PlatformLayer> MediaPlayerPrivateMediaSourceAVFObjC::createVideoFullsc
12191219void MediaPlayerPrivateMediaSourceAVFObjC::setVideoFullscreenLayer(PlatformLayer *videoFullscreenLayer, WTF::Function<void()>&& completionHandler)
12201220{
12211221 updateLastImage();
1222  m_videoLayerManager->setVideoFullscreenLayer(videoFullscreenLayer, WTFMove(completionHandler), m_lastImage);
 1222 m_videoLayerManager->setVideoFullscreenLayer(videoFullscreenLayer, WTFMove(completionHandler), m_lastImage ? m_lastImage->platformImage() : nullptr);
12231223}
12241224
12251225void MediaPlayerPrivateMediaSourceAVFObjC::setVideoFullscreenFrame(FloatRect frame)

Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h

@@private:
232232 CurrentFramePainter() = default;
233233 void reset();
234234
235  RetainPtr<CGImageRef> cgImage;
 235 RefPtr<NativeImage> cgImage;
236236 RefPtr<MediaSample> mediaSample;
237237 std::unique_ptr<PixelBufferConformerCV> pixelBufferConformer;
238238 };

Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm

@@RetainPtr<PlatformLayer> MediaPlayerPrivateMediaStreamAVFObjC::createVideoFullsc
762762void MediaPlayerPrivateMediaStreamAVFObjC::setVideoFullscreenLayer(PlatformLayer* videoFullscreenLayer, WTF::Function<void()>&& completionHandler)
763763{
764764 updateCurrentFrameImage();
765  m_videoLayerManager->setVideoFullscreenLayer(videoFullscreenLayer, WTFMove(completionHandler), m_imagePainter.cgImage);
 765 m_videoLayerManager->setVideoFullscreenLayer(videoFullscreenLayer, WTFMove(completionHandler), m_imagePainter.cgImage ? m_imagePainter.cgImage->platformImage() : nullptr);
766766}
767767
768768void MediaPlayerPrivateMediaStreamAVFObjC::setVideoFullscreenFrame(FloatRect frame)

@@void MediaPlayerPrivateMediaStreamAVFObjC::updateCurrentFrameImage()
955955 return;
956956
957957 auto pixelBuffer = static_cast<CVPixelBufferRef>(CMSampleBufferGetImageBuffer(m_imagePainter.mediaSample->platformSample().sample.cmSampleBuffer));
958  m_imagePainter.cgImage = m_imagePainter.pixelBufferConformer->createImageFromPixelBuffer(pixelBuffer);
 958 m_imagePainter.cgImage = NativeImage::create(m_imagePainter.pixelBufferConformer->createImageFromPixelBuffer(pixelBuffer));
959959}
960960
961961void MediaPlayerPrivateMediaStreamAVFObjC::paintCurrentFrameInContext(GraphicsContext& context, const FloatRect& destRect)

@@void MediaPlayerPrivateMediaStreamAVFObjC::paintCurrentFrameInContext(GraphicsCo
975975 if (!m_imagePainter.cgImage || !m_imagePainter.mediaSample)
976976 return;
977977
978  auto image = m_imagePainter.cgImage.get();
979  FloatRect imageRect(0, 0, CGImageGetWidth(image), CGImageGetHeight(image));
 978 auto& image = m_imagePainter.cgImage;
 979 FloatRect imageRect({ 0, 0 }, image->size());
980980 if (!m_videoTransform)
981981 m_videoTransform = videoTransformationMatrix(*m_imagePainter.mediaSample);
982982 AffineTransform videoTransform = *m_videoTransform;
983983 FloatRect transformedDestRect = videoTransform.inverse().valueOr(AffineTransform()).mapRect(destRect);
984984 context.concatCTM(videoTransform);
985  context.drawNativeImage(image, imageRect.size(), transformedDestRect, imageRect);
 985 context.drawNativeImage(*image, imageRect.size(), transformedDestRect, imageRect);
986986}
987987
988988void MediaPlayerPrivateMediaStreamAVFObjC::acceleratedRenderingStateChanged()

Source/WebCore/platform/graphics/avfoundation/objc/VideoLayerManagerObjC.h

@@public:
6363
6464#if ENABLE(VIDEO_PRESENTATION_MODE)
6565 WEBCORE_EXPORT PlatformLayer* videoFullscreenLayer() const final;
66  WEBCORE_EXPORT void setVideoFullscreenLayer(PlatformLayer*, WTF::Function<void()>&& completionHandler, NativeImagePtr) final;
 66 WEBCORE_EXPORT void setVideoFullscreenLayer(PlatformLayer*, WTF::Function<void()>&& completionHandler, PlatformImagePtr) final;
6767 WEBCORE_EXPORT FloatRect videoFullscreenFrame() const final;
6868 WEBCORE_EXPORT void setVideoFullscreenFrame(FloatRect) final;
69  WEBCORE_EXPORT void updateVideoFullscreenInlineImage(NativeImagePtr) final;
 69 WEBCORE_EXPORT void updateVideoFullscreenInlineImage(PlatformImagePtr) final;
7070#endif
7171
7272 WEBCORE_EXPORT bool requiresTextTrackRepresentation() const final;

Source/WebCore/platform/graphics/avfoundation/objc/VideoLayerManagerObjC.mm

@@PlatformLayer* VideoLayerManagerObjC::videoFullscreenLayer() const
103103 return m_videoFullscreenLayer.get();
104104}
105105
106 void VideoLayerManagerObjC::setVideoFullscreenLayer(PlatformLayer *videoFullscreenLayer, WTF::Function<void()>&& completionHandler, NativeImagePtr currentImage)
 106void VideoLayerManagerObjC::setVideoFullscreenLayer(PlatformLayer *videoFullscreenLayer, WTF::Function<void()>&& completionHandler, PlatformImagePtr currentImage)
107107{
108108 if (m_videoFullscreenLayer == videoFullscreenLayer) {
109109 completionHandler();

@@void VideoLayerManagerObjC::setVideoFullscreenFrame(FloatRect videoFullscreenFra
167167 syncTextTrackBounds();
168168}
169169
170 void VideoLayerManagerObjC::updateVideoFullscreenInlineImage(NativeImagePtr image)
 170void VideoLayerManagerObjC::updateVideoFullscreenInlineImage(PlatformImagePtr image)
171171{
172172 if (m_videoInlineLayer)
173173 [m_videoInlineLayer setContents:(__bridge id)image.get()];

Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp

@@void GraphicsLayerCA::updateContentsImage()
25932593 // FIXME: maybe only do trilinear if the image is being scaled down,
25942594 // but then what if the layer size changes?
25952595 m_contentsLayer->setMinificationFilter(PlatformCALayer::Trilinear);
2596  m_contentsLayer->setContents(m_pendingContentsImage.get());
 2596 m_contentsLayer->setContents(m_pendingContentsImage->platformImage().get());
25972597 m_pendingContentsImage = nullptr;
25982598
25992599 if (m_layerClones) {

Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h

@@class DisplayList;
4646
4747class FloatRoundedRect;
4848class Image;
 49class NativeImage;
4950class TransformState;
5051
5152class GraphicsLayerCA : public GraphicsLayer, public PlatformCALayerClient {

@@private:
600601
601602 Color m_contentsSolidColor;
602603
603  RetainPtr<CGImageRef> m_uncorrectedContentsImage;
604  RetainPtr<CGImageRef> m_pendingContentsImage;
 604 RefPtr<NativeImage> m_uncorrectedContentsImage;
 605 RefPtr<NativeImage> m_pendingContentsImage;
605606
606607 Vector<LayerPropertyAnimation> m_animations;
607608 Vector<LayerPropertyAnimation> m_baseValueTransformAnimations;

Source/WebCore/platform/graphics/cairo/CairoOperations.cpp

4545#include "GraphicsContextPlatformPrivateCairo.h"
4646#include "Image.h"
4747#include "ImageBuffer.h"
 48#include "NativeImage.h"
4849#include "Path.h"
4950#include "PlatformContextCairo.h"
5051#include "ShadowBlur.h"

@@enum PathDrawingStyle {
174175
175176static void drawShadowLayerBuffer(PlatformContextCairo& platformContext, ImageBuffer& layerImage, const FloatPoint& layerOrigin, const FloatSize& layerSize, const ShadowState& shadowState)
176177{
177  if (auto surface = layerImage.copyNativeImage(DontCopyBackingStore)) {
178  drawNativeImage(platformContext, surface.get(), FloatRect(roundedIntPoint(layerOrigin), layerSize), FloatRect(FloatPoint(), layerSize), { shadowState.globalCompositeOperator }, shadowState.globalAlpha, ShadowState());
 178 if (auto nativeImage = layerImage.copyNativeImage(DontCopyBackingStore)) {
 179 drawNativeImage(platformContext, *nativeImage, FloatRect(roundedIntPoint(layerOrigin), layerSize), FloatRect(FloatPoint(), layerSize), { shadowState.globalCompositeOperator }, shadowState.globalAlpha, ShadowState());
179180 }
180181}
181182
182183// FIXME: This is mostly same as drawShadowLayerBuffer, so we should merge two.
183184static void drawShadowImage(PlatformContextCairo& platformContext, ImageBuffer& layerImage, const FloatRect& destRect, const FloatRect& srcRect, const ShadowState& shadowState)
184185{
185  if (auto surface = layerImage.copyNativeImage(DontCopyBackingStore)) {
186  drawNativeImage(platformContext, surface.get(), destRect, srcRect, { shadowState.globalCompositeOperator }, shadowState.globalAlpha, ShadowState());
 186 if (auto nativeImage = layerImage.copyNativeImage(DontCopyBackingStore)) {
 187 drawNativeImage(platformContext, *nativeImage, destRect, srcRect, { shadowState.globalCompositeOperator }, shadowState.globalAlpha, ShadowState());
187188 }
188189}
189190

@@static void fillShadowBuffer(PlatformContextCairo& platformContext, ImageBuffer&
191192{
192193 save(platformContext);
193194
194  if (auto surface = layerImage.copyNativeImage(DontCopyBackingStore))
195  clipToImageBuffer(platformContext, surface.get(), FloatRect(layerOrigin, expandedIntSize(layerSize)));
 195 if (auto nativeImage = layerImage.copyNativeImage(DontCopyBackingStore))
 196 clipToImageBuffer(platformContext, nativeImage->platformImage().get(), FloatRect(layerOrigin, expandedIntSize(layerSize)));
196197
197198 FillSource fillSource;
198199 fillSource.globalAlpha = shadowState.globalAlpha;

@@void drawGlyphs(PlatformContextCairo& platformContext, const FillSource& fillSou
860861 cairo_restore(cr);
861862}
862863
863 void drawNativeImage(PlatformContextCairo& platformContext, cairo_surface_t* surface, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options, float globalAlpha, const ShadowState& shadowState)
 864void drawNativeImage(PlatformContextCairo& platformContext, NativeImage& nativeImage, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options, float globalAlpha, const ShadowState& shadowState)
 865{
 866 if (auto surface = nativeImage.platformImage())
 867 drawPlatformImage(platformContext, surface.get(), destRect, srcRect, options, globalAlpha, shadowState);
 868}
 869
 870void drawPlatformImage(PlatformContextCairo& platformContext, cairo_surface_t* surface, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options, float globalAlpha, const ShadowState& shadowState)
864871{
865872 platformContext.save();
866873

Source/WebCore/platform/graphics/cairo/CairoOperations.h

@@void clearRect(PlatformContextCairo&, const FloatRect&);
143143
144144void 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);
145145
146 void drawNativeImage(PlatformContextCairo&, cairo_surface_t*, const FloatRect&, const FloatRect&, const ImagePaintingOptions&, float, const ShadowState&);
 146void drawNativeImage(PlatformContextCairo&, NativeImage&, const FloatRect&, const FloatRect&, const ImagePaintingOptions&, float, const ShadowState&);
 147void drawPlatformImage(PlatformContextCairo&, cairo_surface_t*, const FloatRect&, const FloatRect&, const ImagePaintingOptions&, float, const ShadowState&);
147148void drawPattern(PlatformContextCairo&, cairo_surface_t*, const IntSize&, const FloatRect&, const FloatRect&, const AffineTransform&, const FloatPoint&, const ImagePaintingOptions&);
148149WEBCORE_EXPORT void drawSurface(PlatformContextCairo&, cairo_surface_t*, const FloatRect&, const FloatRect&, InterpolationQuality, float, const ShadowState&, OrientationSizing operationSizing = OrientationSizing::Normal);
149150

Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp

@@void GraphicsContext::drawRect(const FloatRect& rect, float borderThickness)
123123 Cairo::drawRect(*platformContext(), rect, borderThickness, state.fillColor, state.strokeStyle, state.strokeColor);
124124}
125125
126 void GraphicsContext::platformDrawNativeImage(const NativeImagePtr& image, const FloatSize&, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
 126void GraphicsContext::drawPlatformImage(const PlatformImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
127127{
128128 if (paintingDisabled())
129129 return;
130130
 131 if (m_impl) {
 132 m_impl->drawPlatformImage(image, imageSize, destRect, srcRect, options);
 133 return;
 134 }
 135
131136 ASSERT(hasPlatformContext());
132137 auto& state = this->state();
133  Cairo::drawNativeImage(*platformContext(), image.get(), destRect, srcRect, { options, state.imageInterpolationQuality }, state.alpha, Cairo::ShadowState(state));
 138 Cairo::drawPlatformImage(*platformContext(), image.get(), destRect, srcRect, { options, state.imageInterpolationQuality }, state.alpha, Cairo::ShadowState(state));
134139}
135140
136141// This is only used to draw borders, so we should not draw shadows.

@@void GraphicsContext::clipToImageBuffer(ImageBuffer& buffer, const FloatRect& de
266271 }
267272
268273 ASSERT(hasPlatformContext());
269  if (auto surface = buffer.copyNativeImage(DontCopyBackingStore))
270  Cairo::clipToImageBuffer(*platformContext(), surface.get(), destRect);
 274 if (auto nativeImage = buffer.copyNativeImage(DontCopyBackingStore))
 275 Cairo::clipToImageBuffer(*platformContext(), nativeImage->platformImage().get(), destRect);
271276}
272277
273278IntRect GraphicsContext::clipBounds() const

@@void GraphicsContext::drawPattern(Image& image, const FloatRect& destRect, const
681686 }
682687
683688 ASSERT(hasPlatformContext());
684  if (auto surface = image.nativeImageForCurrentFrame())
685  Cairo::drawPattern(*platformContext(), surface.get(), IntSize(image.size()), destRect, tileRect, patternTransform, phase, options);
 689 if (auto nativeImage = image.nativeImageForCurrentFrame())
 690 Cairo::drawPattern(*platformContext(), nativeImage->platformImage().get(), IntSize(image.size()), destRect, tileRect, patternTransform, phase, options);
686691}
687692
688693void GraphicsContext::setPlatformShouldAntialias(bool enable)

Source/WebCore/platform/graphics/cairo/GraphicsContextGLCairo.cpp

@@bool GraphicsContextGLImageExtractor::extractImage(bool premultiplyAlpha, bool i
5656 source->setData(m_image->data(), true);
5757 if (!source->frameCount())
5858 return false;
59  m_imageSurface = source->createFrameImageAtIndex(0);
 59 m_imageSurface = source->createFrameImageAtIndex(0)->platformImage();
6060 } else {
61  m_imageSurface = m_image->nativeImageForCurrentFrame();
 61 m_imageSurface = m_image->nativeImageForCurrentFrame()->platformImage();
6262 // 1. For texImage2D with HTMLVideoElment input, assume no PremultiplyAlpha had been applied and the alpha value is 0xFF for each pixel,
6363 // which is true at present and may be changed in the future and needs adjustment accordingly.
6464 // 2. For texImage2D with HTMLCanvasElement input in which Alpha is already Premultiplied in this port,

Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.cpp

@@bool GraphicsContextImplCairo::drawImageBuffer(ImageBuffer&, const FloatRect&, c
285285 return false;
286286}
287287
288 void GraphicsContextImplCairo::drawNativeImage(const NativeImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
 288bool GraphicsContextImplCairo::drawNativeImage(NativeImage&, const FloatSize&, const FloatRect&, const FloatRect&, const ImagePaintingOptions&)
 289{
 290 // FIXME: Not implemented.
 291 return false;
 292}
 293
 294void GraphicsContextImplCairo::drawPlatformImage(const PlatformImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
289295{
290296 UNUSED_PARAM(imageSize);
291297 auto& state = graphicsContext().state();
292  Cairo::drawNativeImage(m_platformContext, image.get(), destRect, srcRect, { options, state.imageInterpolationQuality }, state.alpha, Cairo::ShadowState(state));
 298 Cairo::drawPlatformImage(m_platformContext, image.get(), destRect, srcRect, { options, state.imageInterpolationQuality }, state.alpha, Cairo::ShadowState(state));
293299}
294300
295301void GraphicsContextImplCairo::drawPattern(Image& image, const FloatRect& destRect, const FloatRect& tileRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize&, const ImagePaintingOptions& options)
296302{
297303 if (auto surface = image.nativeImageForCurrentFrame())
298  Cairo::drawPattern(m_platformContext, surface.get(), IntSize(image.size()), destRect, tileRect, patternTransform, phase, options);
 304 Cairo::drawPattern(m_platformContext, surface->platformImage().get(), IntSize(image.size()), destRect, tileRect, patternTransform, phase, options);
299305}
300306
301307void GraphicsContextImplCairo::drawRect(const FloatRect& rect, float borderThickness)

@@IntRect GraphicsContextImplCairo::clipBounds()
421427void GraphicsContextImplCairo::clipToImageBuffer(ImageBuffer& buffer, const FloatRect& destRect)
422428{
423429 if (auto surface = buffer.copyNativeImage(DontCopyBackingStore))
424  Cairo::clipToImageBuffer(m_platformContext, surface.get(), destRect);
 430 Cairo::clipToImageBuffer(m_platformContext, surface->platformImage().get(), destRect);
425431}
426432
427433void GraphicsContextImplCairo::applyDeviceScaleFactor(float)

Source/WebCore/platform/graphics/cairo/GraphicsContextImplCairo.h

@@public:
7676 ImageDrawResult drawTiledImage(Image&, const FloatRect&, const FloatRect&, const FloatSize&, Image::TileRule, Image::TileRule, const ImagePaintingOptions&) override;
7777
7878 bool drawImageBuffer(ImageBuffer&, const FloatRect&, const FloatRect&, const ImagePaintingOptions&) override;
79  void drawNativeImage(const NativeImagePtr&, const FloatSize&, const FloatRect&, const FloatRect&, const ImagePaintingOptions&) override;
 79 bool drawNativeImage(NativeImage&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) override;
 80 void drawPlatformImage(const PlatformImagePtr&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) override;
8081 void drawPattern(Image&, const FloatRect&, const FloatRect&, const AffineTransform&, const FloatPoint&, const FloatSize&, const ImagePaintingOptions&) override;
8182
8283 void drawRect(const FloatRect&, float) override;

Source/WebCore/platform/graphics/cairo/ImageBufferCairoBackend.cpp

@@void ImageBufferCairoBackend::draw(GraphicsContext& destContext, const FloatRect
6666 const auto& destinationContextState = destContext.state();
6767
6868 if (auto image = copyNativeImage(&destContext == &context() ? CopyBackingStore : DontCopyBackingStore))
69  drawNativeImage(*destContext.platformContext(), image.get(), destRect, srcRect, { options, destinationContextState.imageInterpolationQuality }, destinationContextState.alpha, WebCore::Cairo::ShadowState(destinationContextState));
 69 drawNativeImage(*destContext.platformContext(), *image, destRect, srcRect, { options, destinationContextState.imageInterpolationQuality }, destinationContextState.alpha, WebCore::Cairo::ShadowState(destinationContextState));
7070}
7171
7272void ImageBufferCairoBackend::drawPattern(GraphicsContext& destContext, const FloatRect& destRect, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& options)

@@void ImageBufferCairoBackend::drawPattern(GraphicsContext& destContext, const Fl
8080 }
8181
8282 if (auto image = copyNativeImage(&destContext == &context() ? CopyBackingStore : DontCopyBackingStore))
83  Cairo::drawPattern(*destContext.platformContext(), image.get(), m_logicalSize, destRect, srcRect, patternTransform, phase, options);
 83 Cairo::drawPattern(*destContext.platformContext(), image->platformImage().get(), m_logicalSize, destRect, srcRect, patternTransform, phase, options);
8484}
8585
8686void ImageBufferCairoBackend::transformColorSpace(ColorSpace srcColorSpace, ColorSpace destColorSpace)

Source/WebCore/platform/graphics/cairo/ImageBufferCairoSurfaceBackend.cpp

@@unsigned ImageBufferCairoSurfaceBackend::bytesPerRow() const
6464 return cairo_image_surface_get_stride(m_surface.get());
6565}
6666
67 NativeImagePtr ImageBufferCairoSurfaceBackend::copyNativeImage(BackingStoreCopy copyBehavior) const
 67RefPtr<NativeImage> ImageBufferCairoSurfaceBackend::copyNativeImage(BackingStoreCopy copyBehavior) const
6868{
6969 switch (copyBehavior) {
7070 case CopyBackingStore: {

@@NativeImagePtr ImageBufferCairoSurfaceBackend::copyNativeImage(BackingStoreCopy
7777 cairo_set_source_surface(cr.get(), m_surface.get(), 0, 0);
7878 cairo_paint(cr.get());
7979
80  return copy;
 80 return NativeImage::create(WTFMove(copy));
8181 }
8282
8383 case DontCopyBackingStore:
84  return m_surface;
 84 return NativeImage::create(m_surface);
8585 }
8686
8787 ASSERT_NOT_REACHED();
8888 return nullptr;
8989}
9090
91 NativeImagePtr ImageBufferCairoSurfaceBackend::cairoSurfaceCoerceToImage() const
 91RefPtr<NativeImage> ImageBufferCairoSurfaceBackend::cairoSurfaceCoerceToImage() const
9292{
9393 BackingStoreCopy copyBehavior;
9494 if (cairo_surface_get_type(m_surface.get()) == CAIRO_SURFACE_TYPE_IMAGE && cairo_surface_get_content(m_surface.get()) == CAIRO_CONTENT_COLOR_ALPHA)

@@NativeImagePtr ImageBufferCairoSurfaceBackend::cairoSurfaceCoerceToImage() const
100100
101101Vector<uint8_t> ImageBufferCairoSurfaceBackend::toBGRAData() const
102102{
103  auto surface = cairoSurfaceCoerceToImage();
 103 auto nativeImage = cairoSurfaceCoerceToImage();
 104 auto surface = nativeImage ? nativeImage->platformImage() : nullptr;
104105 cairo_surface_flush(surface.get());
105106
106107 Vector<uint8_t> imageData;

Source/WebCore/platform/graphics/cairo/ImageBufferCairoSurfaceBackend.h

@@class ImageBufferCairoSurfaceBackend : public ImageBufferCairoBackend {
4040public:
4141 GraphicsContext& context() const override;
4242
43  NativeImagePtr copyNativeImage(BackingStoreCopy) const override;
 43 RefPtr<NativeImage> copyNativeImage(BackingStoreCopy) const override;
4444
4545 Vector<uint8_t> toBGRAData() const override;
4646 RefPtr<ImageData> getImageData(AlphaPremultiplication outputFormat, const IntRect&) const override;

@@public:
4949protected:
5050 ImageBufferCairoSurfaceBackend(const FloatSize& logicalSize, const IntSize& backendSize, float resolutionScale, ColorSpace, RefPtr<cairo_surface_t>&&);
5151
52  NativeImagePtr cairoSurfaceCoerceToImage() const;
 52 RefPtr<NativeImage> cairoSurfaceCoerceToImage() const;
5353 unsigned bytesPerRow() const override;
5454
5555 mutable RefPtr<cairo_surface_t> m_surface;

Source/WebCore/platform/graphics/cairo/NativeImageCairo.cpp

3535
3636namespace WebCore {
3737
38 IntSize nativeImageSize(const NativeImagePtr& image)
 38IntSize NativeImage::size(const PlatformImagePtr& platformImage)
3939{
40  return image ? cairoSurfaceSize(image.get()) : IntSize();
 40 return platformImage ? cairoSurfaceSize(platformImage.get()) : IntSize();
4141}
4242
43 bool nativeImageHasAlpha(const NativeImagePtr& image)
 43bool NativeImage::hasAlpha() const
4444{
45  return !image || cairo_surface_get_content(image.get()) != CAIRO_CONTENT_COLOR;
 45 return !m_platformImage || cairo_surface_get_content(m_platformImage.get()) != CAIRO_CONTENT_COLOR;
4646}
4747
48 Color nativeImageSinglePixelSolidColor(const NativeImagePtr& image)
 48Color NativeImage::singlePixelSolidColor() const
4949{
50  if (!image || nativeImageSize(image) != IntSize(1, 1))
 50 if (!m_platformImage || size() != IntSize(1, 1))
5151 return Color();
5252
53  if (cairo_surface_get_type(image.get()) != CAIRO_SURFACE_TYPE_IMAGE)
 53 if (cairo_surface_get_type(m_platformImage.get()) != CAIRO_SURFACE_TYPE_IMAGE)
5454 return Color();
5555
56  unsigned* pixel = reinterpret_cast_ptr<unsigned*>(cairo_image_surface_get_data(image.get()));
 56 unsigned* pixel = reinterpret_cast_ptr<unsigned*>(cairo_image_surface_get_data(m_platformImage.get()));
5757 return unpremultiplied(asSRGBA(PackedColor::ARGB { *pixel }));
5858}
5959
60 void drawNativeImage(const NativeImagePtr& image, GraphicsContext& context, const FloatRect& destRect, const FloatRect& srcRect, const IntSize& imageSize, const ImagePaintingOptions& options)
61 {
62  context.drawNativeImage(image, imageSize, destRect, srcRect, options);
63 }
64 
65 void clearNativeImageSubimages(const NativeImagePtr&)
 60void NativeImage::clearSubimages()
6661{
6762}
6863

Source/WebCore/platform/graphics/cairo/PatternCairo.cpp

@@namespace WebCore {
3535
3636cairo_pattern_t* Pattern::createPlatformPattern(const AffineTransform&) const
3737{
38  RefPtr<cairo_surface_t> surface = tileImage().nativeImageForCurrentFrame();
39  if (!surface)
 38 auto nativeImage = tileImage().nativeImageForCurrentFrame();
 39 if (!nativeImage || nativeImage->isNull())
4040 return nullptr;
4141
 42 auto& surface = nativeImage->platformImage();
 43
4244 cairo_pattern_t* pattern = cairo_pattern_create_for_surface(surface.get());
4345
4446 // cairo merges patter space and user space itself

Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp

@@void GraphicsContext::restorePlatformState()
280280 m_data->m_userToDeviceTransformKnownToBeIdentity = false;
281281}
282282
283 void GraphicsContext::platformDrawNativeImage(const RetainPtr<CGImageRef>& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
 283void GraphicsContext::drawPlatformImage(const PlatformImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
284284{
285285 if (paintingDisabled())
286286 return;
287287
 288 if (m_impl) {
 289 m_impl->drawPlatformImage(image, imageSize, destRect, srcRect, options);
 290 return;
 291 }
 292
288293#if !LOG_DISABLED
289294 MonotonicTime startTime = MonotonicTime::now();
290295#endif

@@void GraphicsContext::drawPattern(Image& image, const FloatRect& destRect, const
447452
448453 auto tileImage = image.preTransformedNativeImageForCurrentFrame(options.orientation() == ImageOrientation::FromImage);
449454
450  float h = CGImageGetHeight(tileImage.get());
 455 float h = CGImageGetHeight(tileImage->platformImage().get());
451456
452457 RetainPtr<CGImageRef> subImage;
453458 FloatSize imageSize = image.size();
454459 if (tileRect.size() == imageSize)
455  subImage = tileImage;
 460 subImage = tileImage->platformImage();
456461 else {
457462 // Copying a sub-image out of a partially-decoded image stops the decoding of the original image. It should never happen
458463 // because sub-images are only used for border-image, which only renders when the image is fully decoded.
459464 ASSERT(h == image.height());
460  subImage = adoptCF(CGImageCreateWithImageInRect(tileImage.get(), tileRect));
 465 subImage = adoptCF(CGImageCreateWithImageInRect(tileImage->platformImage().get(), tileRect));
461466 }
462467
463468 // If we need to paint gaps between tiles because we have a partially loaded image or non-zero spacing,
464469 // fall back to the less efficient CGPattern-based mechanism.
465470 float scaledTileWidth = tileRect.width() * narrowPrecisionToFloat(patternTransform.a());
466  float w = CGImageGetWidth(tileImage.get());
 471 float w = CGImageGetWidth(tileImage->platformImage().get());
467472 if (w == image.size().width() && h == image.size().height() && !spacing.width() && !spacing.height()) {
468473 // FIXME: CG seems to snap the images to integral sizes. When we care (e.g. with border-image-repeat: round),
469474 // we should tile all but the last, and stetch the last image to fit.

@@void GraphicsContext::clipToImageBuffer(ImageBuffer& buffer, const FloatRect& de
512517 }
513518
514519 FloatSize bufferDestinationSize = destinationRect.size();
515  RetainPtr<CGImageRef> image = buffer.copyNativeImage(DontCopyBackingStore);
 520 auto nativeImage = buffer.copyNativeImage(DontCopyBackingStore);
 521 RetainPtr<CGImageRef> image = nativeImage ? nativeImage->platformImage() : nullptr;
516522
517523 CGContextRef context = platformContext();
518524 // FIXME: This image needs to be grayscale to be used as an alpha mask here.

Source/WebCore/platform/graphics/cg/GraphicsContextGLCG.cpp

@@bool GraphicsContextGLImageExtractor::extractImage(bool premultiplyAlpha, bool i
338338 if (!m_cgImage)
339339 return false;
340340
341  m_imageWidth = CGImageGetWidth(m_cgImage.get());
342  m_imageHeight = CGImageGetHeight(m_cgImage.get());
 341 RetainPtr<CGImageRef> image = m_cgImage->platformImage();
 342 m_imageWidth = CGImageGetWidth(image.get());
 343 m_imageHeight = CGImageGetHeight(image.get());
343344 if (!m_imageWidth || !m_imageHeight)
344345 return false;
345346

@@bool GraphicsContextGLImageExtractor::extractImage(bool premultiplyAlpha, bool i
347348 // so, re-render it into an RGB color space. The image re-packing
348349 // code requires color data, not color table indices, for the
349350 // image data.
350  CGColorSpaceRef colorSpace = CGImageGetColorSpace(m_cgImage.get());
 351 CGColorSpaceRef colorSpace = CGImageGetColorSpace(image.get());
351352 CGColorSpaceModel model = CGColorSpaceGetModel(colorSpace);
352353 if (model == kCGColorSpaceModelIndexed) {
353354 RetainPtr<CGContextRef> bitmapContext;

@@bool GraphicsContextGLImageExtractor::extractImage(bool premultiplyAlpha, bool i
362363
363364 CGContextSetBlendMode(bitmapContext.get(), kCGBlendModeCopy);
364365 CGContextSetInterpolationQuality(bitmapContext.get(), kCGInterpolationNone);
365  CGContextDrawImage(bitmapContext.get(), CGRectMake(0, 0, m_imageWidth, m_imageHeight), m_cgImage.get());
 366 CGContextDrawImage(bitmapContext.get(), CGRectMake(0, 0, m_imageWidth, m_imageHeight), image.get());
366367
367368 // Now discard the original CG image and replace it with a copy from the bitmap context.
368  m_decodedImage = adoptCF(CGBitmapContextCreateImage(bitmapContext.get()));
369  m_cgImage = m_decodedImage.get();
 369 m_decodedImage = NativeImage::create(CGBitmapContextCreateImage(bitmapContext.get()));
 370 m_cgImage = m_decodedImage;
370371 }
371372
372  size_t bitsPerComponent = CGImageGetBitsPerComponent(m_cgImage.get());
373  size_t bitsPerPixel = CGImageGetBitsPerPixel(m_cgImage.get());
 373 if (!m_cgImage)
 374 return false;
 375
 376 image = m_cgImage->platformImage();
 377 size_t bitsPerComponent = CGImageGetBitsPerComponent(image.get());
 378 size_t bitsPerPixel = CGImageGetBitsPerPixel(image.get());
374379 if (bitsPerComponent != 8 && bitsPerComponent != 16)
375380 return false;
376381 if (bitsPerPixel % bitsPerComponent)
377382 return false;
378383 size_t componentsPerPixel = bitsPerPixel / bitsPerComponent;
379384
380  CGBitmapInfo bitInfo = CGImageGetBitmapInfo(m_cgImage.get());
 385 CGBitmapInfo bitInfo = CGImageGetBitmapInfo(image.get());
381386 bool bigEndianSource = false;
382387 // These could technically be combined into one large switch
383388 // statement, but we prefer not to so that we fail fast if we

@@bool GraphicsContextGLImageExtractor::extractImage(bool premultiplyAlpha, bool i
419424
420425 m_alphaOp = AlphaOp::DoNothing;
421426 AlphaFormat alphaFormat = AlphaFormatNone;
422  switch (CGImageGetAlphaInfo(m_cgImage.get())) {
 427 switch (CGImageGetAlphaInfo(image.get())) {
423428 case kCGImageAlphaPremultipliedFirst:
424429 if (!premultiplyAlpha)
425430 m_alphaOp = AlphaOp::DoUnmultiply;

@@bool GraphicsContextGLImageExtractor::extractImage(bool premultiplyAlpha, bool i
463468 if (m_imageSourceFormat == DataFormat::NumFormats)
464469 return false;
465470
466  m_pixelData = adoptCF(CGDataProviderCopyData(CGImageGetDataProvider(m_cgImage.get())));
 471 m_pixelData = adoptCF(CGDataProviderCopyData(CGImageGetDataProvider(image.get())));
467472 if (!m_pixelData)
468473 return false;
469474
470475 m_imagePixelData = reinterpret_cast<const void*>(CFDataGetBytePtr(m_pixelData.get()));
471476
472477 unsigned srcUnpackAlignment = 0;
473  size_t bytesPerRow = CGImageGetBytesPerRow(m_cgImage.get());
 478 size_t bytesPerRow = CGImageGetBytesPerRow(image.get());
474479 unsigned padding = bytesPerRow - bitsPerPixel / 8 * m_imageWidth;
475480 if (padding) {
476481 srcUnpackAlignment = padding + 1;

@@void GraphicsContextGLOpenGL::paintToCanvas(const unsigned char* imagePixels, co
543548 context.scale(FloatSize(1, -1));
544549 context.translate(0, -imageSize.height());
545550 context.setImageInterpolationQuality(InterpolationQuality::DoNotInterpolate);
546  context.drawNativeImage(cgImage, imageSize, canvasRect, FloatRect(FloatPoint(), imageSize), { CompositeOperator::Copy });
 551 context.drawPlatformImage(cgImage, imageSize, canvasRect, FloatRect(FloatPoint(), imageSize), { CompositeOperator::Copy });
547552}
548553
549554} // namespace WebCore

Source/WebCore/platform/graphics/cg/ImageBufferCGBackend.cpp

@@void ImageBufferCGBackend::setupContext()
6767 context().applyDeviceScaleFactor(m_resolutionScale);
6868}
6969
70 static RetainPtr<CGImageRef> createCroppedImageIfNecessary(CGImageRef image, const IntSize& backendSize)
 70static RefPtr<NativeImage> createCroppedImageIfNecessary(RefPtr<NativeImage>&& image, const IntSize& backendSize)
7171{
72  if (image && (CGImageGetWidth(image) != static_cast<size_t>(backendSize.width()) || CGImageGetHeight(image) != static_cast<size_t>(backendSize.height())))
73  return adoptCF(CGImageCreateWithImageInRect(image, CGRectMake(0, 0, backendSize.width(), backendSize.height())));
74  return image;
 72 if (image && image->size() != backendSize)
 73 return NativeImage::create(CGImageCreateWithImageInRect(image->platformImage().get(), CGRectMake(0, 0, backendSize.width(), backendSize.height())));
 74 return WTFMove(image);
7575}
7676
77 static RefPtr<Image> createBitmapImageAfterScalingIfNeeded(RetainPtr<CGImageRef>&& image, const IntSize& logicalSize, const IntSize& backendSize, float resolutionScale, PreserveResolution preserveResolution)
 77static RefPtr<Image> createBitmapImageAfterScalingIfNeeded(RefPtr<NativeImage>&& image, const IntSize& logicalSize, const IntSize& backendSize, float resolutionScale, PreserveResolution preserveResolution)
7878{
7979 if (resolutionScale == 1 || preserveResolution == PreserveResolution::Yes)
80  image = createCroppedImageIfNecessary(image.get(), backendSize);
 80 image = createCroppedImageIfNecessary(WTFMove(image), backendSize);
8181 else {
8282 auto context = adoptCF(CGBitmapContextCreate(0, logicalSize.width(), logicalSize.height(), 8, 4 * logicalSize.width(), sRGBColorSpaceRef(), kCGImageAlphaPremultipliedLast));
8383 CGContextSetBlendMode(context.get(), kCGBlendModeCopy);
8484 CGContextClipToRect(context.get(), FloatRect(FloatPoint::zero(), logicalSize));
8585 FloatSize imageSizeInUserSpace = logicalSize;
86  CGContextDrawImage(context.get(), FloatRect(FloatPoint::zero(), imageSizeInUserSpace), image.get());
87  image = adoptCF(CGBitmapContextCreateImage(context.get()));
 86 CGContextDrawImage(context.get(), FloatRect(FloatPoint::zero(), imageSizeInUserSpace), image->platformImage().get());
 87 image = NativeImage::create(CGBitmapContextCreateImage(context.get()));
8888 }
8989
9090 if (!image)

@@static RefPtr<Image> createBitmapImageAfterScalingIfNeeded(RetainPtr<CGImageRef>
9595
9696RefPtr<Image> ImageBufferCGBackend::copyImage(BackingStoreCopy copyBehavior, PreserveResolution preserveResolution) const
9797{
98  NativeImagePtr image;
 98 RefPtr<NativeImage> image;
9999 if (m_resolutionScale == 1 || preserveResolution == PreserveResolution::Yes)
100100 image = copyNativeImage(copyBehavior);
101101 else

@@void ImageBufferCGBackend::draw(GraphicsContext& destContext, const FloatRect& d
114114 srcRectScaled.scale(m_resolutionScale);
115115
116116 if (auto image = copyNativeImage(&destContext == &context() ? CopyBackingStore : DontCopyBackingStore))
117  destContext.drawNativeImage(image.get(), m_backendSize, destRect, srcRectScaled, options);
 117 destContext.drawNativeImage(*image, m_backendSize, destRect, srcRectScaled, options);
118118}
119119
120120void ImageBufferCGBackend::drawPattern(GraphicsContext& destContext, const FloatRect& destRect, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& options)

@@RetainPtr<CFDataRef> ImageBufferCGBackend::toCFData(const String& mimeType, Opti
138138 auto uti = utiFromImageBufferMIMEType(mimeType);
139139 ASSERT(uti);
140140
141  RetainPtr<CGImageRef> image;
 141 RefPtr<NativeImage> image;
142142 RefPtr<Uint8ClampedArray> protectedPixelArray;
143143
144144 if (CFEqual(uti.get(), jpegUTI())) {

@@RetainPtr<CFDataRef> ImageBufferCGBackend::toCFData(const String& mimeType, Opti
156156 if (!dataProvider)
157157 return nullptr;
158158
159  image = adoptCF(CGImageCreate(pixelArrayDimensions.width(), pixelArrayDimensions.height(), 8, 32, 4 * pixelArrayDimensions.width(), sRGBColorSpaceRef(), kCGBitmapByteOrderDefault | kCGImageAlphaNoneSkipLast, dataProvider.get(), 0, false, kCGRenderingIntentDefault));
 159 image = NativeImage::create(CGImageCreate(pixelArrayDimensions.width(), pixelArrayDimensions.height(), 8, 32, 4 * pixelArrayDimensions.width(), sRGBColorSpaceRef(), kCGBitmapByteOrderDefault | kCGImageAlphaNoneSkipLast, dataProvider.get(), 0, false, kCGRenderingIntentDefault));
160160 } else if (m_resolutionScale == 1 || preserveResolution == PreserveResolution::Yes) {
161161 image = copyNativeImage(CopyBackingStore);
162162 image = createCroppedImageIfNecessary(image.get(), backendSize());

@@RetainPtr<CFDataRef> ImageBufferCGBackend::toCFData(const String& mimeType, Opti
165165 auto context = adoptCF(CGBitmapContextCreate(0, backendSize().width(), backendSize().height(), 8, 4 * backendSize().width(), sRGBColorSpaceRef(), kCGImageAlphaPremultipliedLast));
166166 CGContextSetBlendMode(context.get(), kCGBlendModeCopy);
167167 CGContextClipToRect(context.get(), CGRectMake(0, 0, backendSize().width(), backendSize().height()));
168  CGContextDrawImage(context.get(), CGRectMake(0, 0, backendSize().width(), backendSize().height()), image.get());
169  image = adoptCF(CGBitmapContextCreateImage(context.get()));
 168 CGContextDrawImage(context.get(), CGRectMake(0, 0, backendSize().width(), backendSize().height()), image->platformImage().get());
 169 image = NativeImage::create(CGBitmapContextCreateImage(context.get()));
170170 }
171171
172172 auto cfData = adoptCF(CFDataCreateMutable(kCFAllocatorDefault, 0));
173  if (!encodeImage(image.get(), uti.get(), quality, cfData.get()))
 173 if (!encodeImage(image->platformImage().get(), uti.get(), quality, cfData.get()))
174174 return nullptr;
175175
176176 return WTFMove(cfData);

Source/WebCore/platform/graphics/cg/ImageBufferCGBitmapBackend.cpp

@@GraphicsContext& ImageBufferCGBitmapBackend::context() const
107107 return *m_context;
108108}
109109
110 NativeImagePtr ImageBufferCGBitmapBackend::copyNativeImage(BackingStoreCopy copyBehavior) const
 110RefPtr<NativeImage> ImageBufferCGBitmapBackend::copyNativeImage(BackingStoreCopy copyBehavior) const
111111{
112112 switch (copyBehavior) {
113113 case CopyBackingStore:
114  return adoptCF(CGBitmapContextCreateImage(context().platformContext()));
 114 return NativeImage::create(CGBitmapContextCreateImage(context().platformContext()));
115115
116116 case DontCopyBackingStore:
117  return adoptCF(CGImageCreate(
 117 return NativeImage::create(CGImageCreate(
118118 m_backendSize.width(), m_backendSize.height(), 8, 32, bytesPerRow(),
119119 cachedCGColorSpace(m_colorSpace), DefaultBitmapInfo, m_dataProvider.get(),
120120 0, true, kCGRenderingIntentDefault));

Source/WebCore/platform/graphics/cg/ImageBufferCGBitmapBackend.h

@@public:
4242
4343 GraphicsContext& context() const override;
4444
45  NativeImagePtr copyNativeImage(BackingStoreCopy = CopyBackingStore) const override;
 45 RefPtr<NativeImage> copyNativeImage(BackingStoreCopy = CopyBackingStore) const override;
4646
4747 Vector<uint8_t> toBGRAData() const override;
4848

Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp

@@ColorFormat ImageBufferIOSurfaceBackend::backendColorFormat() const
135135 return ColorFormat::BGRA;
136136}
137137
138 NativeImagePtr ImageBufferIOSurfaceBackend::copyNativeImage(BackingStoreCopy) const
 138RefPtr<NativeImage> ImageBufferIOSurfaceBackend::copyNativeImage(BackingStoreCopy) const
139139{
140  return m_surface->createImage();
 140 return NativeImage::create(m_surface->createImage());
141141}
142142
143 NativeImagePtr ImageBufferIOSurfaceBackend::sinkIntoNativeImage()
 143RefPtr<NativeImage> ImageBufferIOSurfaceBackend::sinkIntoNativeImage()
144144{
145  return IOSurface::sinkIntoImage(WTFMove(m_surface));
 145 return NativeImage::create(IOSurface::sinkIntoImage(WTFMove(m_surface)));
146146}
147147
148148void ImageBufferIOSurfaceBackend::drawConsuming(GraphicsContext& destContext, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)

@@void ImageBufferIOSurfaceBackend::drawConsuming(GraphicsContext& destContext, co
151151 adjustedSrcRect.scale(m_resolutionScale);
152152
153153 if (auto image = sinkIntoNativeImage())
154  destContext.drawNativeImage(image.get(), m_backendSize, destRect, adjustedSrcRect, options);
 154 destContext.drawNativeImage(*image, m_backendSize, destRect, adjustedSrcRect, options);
155155}
156156
157157RetainPtr<CFDataRef> ImageBufferIOSurfaceBackend::toCFData(const String& mimeType, Optional<double> quality, PreserveResolution preserveResolution) const

Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.h

@@public:
5151 size_t memoryCost() const override;
5252 size_t externalMemoryCost() const override;
5353
54  NativeImagePtr copyNativeImage(BackingStoreCopy = CopyBackingStore) const override;
55  NativeImagePtr sinkIntoNativeImage() override;
 54 RefPtr<NativeImage> copyNativeImage(BackingStoreCopy = CopyBackingStore) const override;
 55 RefPtr<NativeImage> sinkIntoNativeImage() override;
5656
5757 void drawConsuming(GraphicsContext&, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) override;
5858

Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp

@@unsigned ImageDecoderCG::frameBytesAtIndex(size_t index, SubsamplingLevel subsam
492492 return (frameSize.area() * 4).unsafeGet();
493493}
494494
495 NativeImagePtr ImageDecoderCG::createFrameImageAtIndex(size_t index, SubsamplingLevel subsamplingLevel, const DecodingOptions& decodingOptions)
 495PlatformImagePtr ImageDecoderCG::createFrameImageAtIndex(size_t index, SubsamplingLevel subsamplingLevel, const DecodingOptions& decodingOptions)
496496{
497497 LOG(Images, "ImageDecoder %p createFrameImageAtIndex %lu", this, index);
498498 RetainPtr<CFDictionaryRef> options;

Source/WebCore/platform/graphics/cg/ImageDecoderCG.h

@@public:
6262 bool frameAllowSubsamplingAtIndex(size_t) const final;
6363 unsigned frameBytesAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default) const final;
6464
65  NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingOptions(DecodingMode::Synchronous)) final;
 65 PlatformImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingOptions(DecodingMode::Synchronous)) final;
6666
6767 void setData(SharedBuffer&, bool allDataReceived) final;
6868 bool isAllDataReceived() const final { return m_isAllDataReceived; }

Source/WebCore/platform/graphics/cg/NativeImageCG.cpp

3737
3838namespace WebCore {
3939
40 IntSize nativeImageSize(const NativeImagePtr& image)
 40IntSize NativeImage::size(const PlatformImagePtr& platformImage)
4141{
42  return image ? IntSize(CGImageGetWidth(image.get()), CGImageGetHeight(image.get())) : IntSize();
 42 return platformImage ? IntSize(CGImageGetWidth(platformImage.get()), CGImageGetHeight(platformImage.get())) : IntSize();
4343}
4444
45 bool nativeImageHasAlpha(const NativeImagePtr& image)
 45bool NativeImage::hasAlpha() const
4646{
47  CGImageAlphaInfo info = CGImageGetAlphaInfo(image.get());
 47 CGImageAlphaInfo info = CGImageGetAlphaInfo(m_platformImage.get());
4848 return (info >= kCGImageAlphaPremultipliedLast) && (info <= kCGImageAlphaFirst);
4949}
5050
51 Color nativeImageSinglePixelSolidColor(const NativeImagePtr& image)
 51Color NativeImage::singlePixelSolidColor() const
5252{
53  if (!image || nativeImageSize(image) != IntSize(1, 1))
 53 if (!m_platformImage || size() != IntSize(1, 1))
5454 return Color();
5555
5656 unsigned char pixel[4]; // RGBA

@@Color nativeImageSinglePixelSolidColor(const NativeImagePtr& image)
6060 return Color();
6161
6262 CGContextSetBlendMode(bitmapContext.get(), kCGBlendModeCopy);
63  CGContextDrawImage(bitmapContext.get(), CGRectMake(0, 0, 1, 1), image.get());
 63 CGContextDrawImage(bitmapContext.get(), CGRectMake(0, 0, 1, 1), m_platformImage.get());
6464
6565 if (!pixel[3])
6666 return Color::transparentBlack;

@@Color nativeImageSinglePixelSolidColor(const NativeImagePtr& image)
6868 return clampToComponentBytes<SRGBA>(pixel[0] * 255 / pixel[3], pixel[1] * 255 / pixel[3], pixel[2] * 255 / pixel[3], pixel[3]);
6969}
7070
71 void clearNativeImageSubimages(const NativeImagePtr& image)
 71void NativeImage::clearSubimages()
7272{
7373#if CACHE_SUBIMAGES
74  if (image)
75  SubimageCacheWithTimer::clearImage(image.get());
 74 if (m_platformImage)
 75 SubimageCacheWithTimer::clearImage(m_platformImage.get());
7676#endif
7777}
7878

Source/WebCore/platform/graphics/cg/PatternCG.cpp

@@CGPatternRef Pattern::createPlatformPattern(const AffineTransform& userSpaceTran
6363 patternTransform.scaleNonUniform(1, -1);
6464 patternTransform.translate(0, -tileRect.height());
6565
 66 PlatformImagePtr platformImage;
 67 if (auto nativeImage = tileImage().nativeImage())
 68 platformImage = nativeImage->platformImage();
 69
 70 if (!platformImage)
 71 return nullptr;
 72
6673 // If we're repeating in both directions, we can use image-backed patterns
6774 // instead of custom patterns, and avoid tiling-edge pixel cracks.
6875 if (m_repeatX && m_repeatY)
69  return CGPatternCreateWithImage2(tileImage().nativeImage().get(), patternTransform, kCGPatternTilingConstantSpacing);
 76 return CGPatternCreateWithImage2(platformImage.get(), patternTransform, kCGPatternTilingConstantSpacing);
7077
7178 // If FLT_MAX should also be used for xStep or yStep, nothing is rendered. Using fractions of FLT_MAX also
7279 // result in nothing being rendered.

@@CGPatternRef Pattern::createPlatformPattern(const AffineTransform& userSpaceTran
7784 CGFloat yStep = m_repeatY ? tileRect.height() : (1 << 22);
7885
7986 // The pattern will release the CGImageRef when it's done rendering in patternReleaseCallback
80  CGImageRef platformImage = tileImage().nativeImage().leakRef();
 87 CGImageRef image = platformImage.leakRef();
8188
8289 const CGPatternCallbacks patternCallbacks = { 0, patternCallback, patternReleaseCallback };
83  return CGPatternCreate(platformImage, tileRect, patternTransform, xStep, yStep, kCGPatternTilingConstantSpacing, TRUE, &patternCallbacks);
 90 return CGPatternCreate(image, tileRect, patternTransform, xStep, yStep, kCGPatternTilingConstantSpacing, TRUE, &patternCallbacks);
8491}
8592
8693}

Source/WebCore/platform/graphics/coreimage/FilterEffectRendererCoreImage.mm

@@RetainPtr<CIImage> FilterEffectRendererCoreImage::imageForSourceGraphic(SourceGr
177177 if (is<AcceleratedImageBuffer>(*sourceImage))
178178 return [CIImage imageWithIOSurface:downcast<AcceleratedImageBuffer>(*sourceImage).surface().surface()];
179179
180  return [CIImage imageWithCGImage:sourceImage->copyNativeImage().get()];
 180 return [CIImage imageWithCGImage:sourceImage->copyNativeImage()->platformImage().get()];
181181}
182182
183183RetainPtr<CIImage> FilterEffectRendererCoreImage::imageForFEColorMatrix(const FEColorMatrix& effect, const Vector<RetainPtr<CIImage>>& inputImages)

Source/WebCore/platform/graphics/displaylists/DisplayList.h

@@enum class ItemType : uint8_t {
6868 DrawTiledScaledImage,
6969 DrawImageBuffer,
7070 DrawNativeImage,
 71 DrawPlatformImage,
7172 DrawPattern,
7273 DrawRect,
7374 DrawLine,

Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp

@@size_t Item::sizeInBytes(const Item& item)
118118 return sizeof(downcast<DrawImageBuffer>(item));
119119 case ItemType::DrawNativeImage:
120120 return sizeof(downcast<DrawNativeImage>(item));
 121 case ItemType::DrawPlatformImage:
 122 return sizeof(downcast<DrawPlatformImage>(item));
121123 case ItemType::DrawPattern:
122124 return sizeof(downcast<DrawPattern>(item));
123125 case ItemType::DrawRect:

@@static TextStream& operator<<(TextStream& ts, const DrawImageBuffer& item)
859861 return ts;
860862}
861863
862 DrawNativeImage::DrawNativeImage(const NativeImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
 864DrawNativeImage::DrawNativeImage(RenderingResourceIdentifier renderingResourceIdentifier, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
863865 : DrawingItem(ItemType::DrawNativeImage)
864  , m_image(image)
 866 , m_renderingResourceIdentifier(renderingResourceIdentifier)
865867 , m_imageSize(imageSize)
866868 , m_destinationRect(destRect)
867869 , m_srcRect(srcRect)

@@DrawNativeImage::DrawNativeImage(const NativeImagePtr& image, const FloatSize& i
871873
872874DrawNativeImage::~DrawNativeImage() = default;
873875
874 void DrawNativeImage::apply(GraphicsContext& context) const
 876void DrawNativeImage::apply(GraphicsContext&) const
875877{
876  context.drawNativeImage(m_image, m_imageSize, m_destinationRect, m_srcRect, m_options);
 878 // Should be handled by the delegate.
 879 ASSERT_NOT_REACHED();
877880}
878881
879882static TextStream& operator<<(TextStream& ts, const DrawNativeImage& item)
 883{
 884 ts << static_cast<const DrawingItem&>(item);
 885 // FIXME: dump more stuff.
 886 ts.dumpProperty("remote-resource-identifier", item.renderingResourceIdentifier());
 887 ts.dumpProperty("source-rect", item.source());
 888 ts.dumpProperty("dest-rect", item.destinationRect());
 889 return ts;
 890}
 891
 892DrawPlatformImage::DrawPlatformImage(const PlatformImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
 893 : DrawingItem(ItemType::DrawPlatformImage)
 894 , m_image(image)
 895 , m_imageSize(imageSize)
 896 , m_destinationRect(destRect)
 897 , m_srcRect(srcRect)
 898 , m_options(options)
 899{
 900}
 901
 902DrawPlatformImage::~DrawPlatformImage() = default;
 903
 904void DrawPlatformImage::apply(GraphicsContext& context) const
 905{
 906 context.drawPlatformImage(m_image, m_imageSize, m_destinationRect, m_srcRect, m_options);
 907}
 908
 909static TextStream& operator<<(TextStream& ts, const DrawPlatformImage& item)
880910{
881911 ts << static_cast<const DrawingItem&>(item);
882912 // FIXME: dump more stuff.

@@static TextStream& operator<<(TextStream& ts, const ItemType& type)
16771707 case ItemType::DrawTiledScaledImage: ts << "draw-tiled-scaled-image"; break;
16781708 case ItemType::DrawImageBuffer: ts << "draw-image-buffer"; break;
16791709 case ItemType::DrawNativeImage: ts << "draw-native-image"; break;
 1710 case ItemType::DrawPlatformImage: ts << "draw-platform-image"; break;
16801711 case ItemType::DrawPattern: ts << "draw-pattern"; break;
16811712 case ItemType::DrawRect: ts << "draw-rect"; break;
16821713 case ItemType::DrawLine: ts << "draw-line"; break;

@@TextStream& operator<<(TextStream& ts, const Item& item)
18001831 case ItemType::DrawNativeImage:
18011832 ts << downcast<DrawNativeImage>(item);
18021833 break;
 1834 case ItemType::DrawPlatformImage:
 1835 ts << downcast<DrawPlatformImage>(item);
 1836 break;
18031837 case ItemType::DrawPattern:
18041838 ts << downcast<DrawPattern>(item);
18051839 break;

Source/WebCore/platform/graphics/displaylists/DisplayListItems.h

@@Optional<Ref<DrawImageBuffer>> DrawImageBuffer::decode(Decoder& decoder)
17011701
17021702class DrawNativeImage : public DrawingItem {
17031703public:
1704  static Ref<DrawNativeImage> create(const NativeImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
 1704 static Ref<DrawNativeImage> create(RenderingResourceIdentifier renderingResourceIdentifier, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
17051705 {
1706  return adoptRef(*new DrawNativeImage(image, imageSize, destRect, srcRect, options));
 1706 return adoptRef(*new DrawNativeImage(renderingResourceIdentifier, imageSize, destRect, srcRect, options));
17071707 }
17081708
17091709 WEBCORE_EXPORT virtual ~DrawNativeImage();
17101710
 1711 RenderingResourceIdentifier renderingResourceIdentifier() const { return m_renderingResourceIdentifier; }
 1712 FloatSize imageSize() const { return m_imageSize; }
17111713 FloatRect source() const { return m_srcRect; }
17121714 FloatRect destinationRect() const { return m_destinationRect; }
 1715 ImagePaintingOptions options() const { return m_options; }
17131716
17141717 template<class Encoder> void encode(Encoder&) const;
17151718 template<class Decoder> static Optional<Ref<DrawNativeImage>> decode(Decoder&);
17161719
17171720private:
1718  WEBCORE_EXPORT DrawNativeImage(const NativeImagePtr&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&);
 1721 WEBCORE_EXPORT DrawNativeImage(RenderingResourceIdentifier, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&);
17191722
17201723 void apply(GraphicsContext&) const override;
17211724
17221725 Optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_destinationRect; }
17231726
1724  NativeImagePtr m_image;
 1727 RenderingResourceIdentifier m_renderingResourceIdentifier;
17251728 FloatSize m_imageSize;
17261729 FloatRect m_destinationRect;
17271730 FloatRect m_srcRect;

@@private:
17311734template<class Encoder>
17321735void DrawNativeImage::encode(Encoder& encoder) const
17331736{
1734  encoder << m_image;
 1737 encoder << m_renderingResourceIdentifier;
17351738 encoder << m_imageSize;
17361739 encoder << m_destinationRect;
17371740 encoder << m_srcRect;

@@void DrawNativeImage::encode(Encoder& encoder) const
17411744template<class Decoder>
17421745Optional<Ref<DrawNativeImage>> DrawNativeImage::decode(Decoder& decoder)
17431746{
1744  Optional<NativeImagePtr> image;
 1747 Optional<RenderingResourceIdentifier> renderingResourceIdentifier;
 1748 decoder >> renderingResourceIdentifier;
 1749 if (!renderingResourceIdentifier)
 1750 return WTF::nullopt;
 1751
 1752 Optional<FloatSize> imageSize;
 1753 decoder >> imageSize;
 1754 if (!imageSize)
 1755 return WTF::nullopt;
 1756
 1757 Optional<FloatRect> destinationRect;
 1758 decoder >> destinationRect;
 1759 if (!destinationRect)
 1760 return WTF::nullopt;
 1761
 1762 Optional<FloatRect> srcRect;
 1763 decoder >> srcRect;
 1764 if (!srcRect)
 1765 return WTF::nullopt;
 1766
 1767 Optional<ImagePaintingOptions> options;
 1768 decoder >> options;
 1769 if (!options)
 1770 return WTF::nullopt;
 1771
 1772 return DrawNativeImage::create(*renderingResourceIdentifier, *imageSize, *destinationRect, *srcRect, *options);
 1773}
 1774
 1775class DrawPlatformImage : public DrawingItem {
 1776public:
 1777 static Ref<DrawPlatformImage> create(const PlatformImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
 1778 {
 1779 return adoptRef(*new DrawPlatformImage(image, imageSize, destRect, srcRect, options));
 1780 }
 1781
 1782 WEBCORE_EXPORT virtual ~DrawPlatformImage();
 1783
 1784 FloatRect source() const { return m_srcRect; }
 1785 FloatRect destinationRect() const { return m_destinationRect; }
 1786
 1787 template<class Encoder> void encode(Encoder&) const;
 1788 template<class Decoder> static Optional<Ref<DrawPlatformImage>> decode(Decoder&);
 1789
 1790private:
 1791 WEBCORE_EXPORT DrawPlatformImage(const PlatformImagePtr&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&);
 1792
 1793 void apply(GraphicsContext&) const override;
 1794
 1795 Optional<FloatRect> localBounds(const GraphicsContext&) const override { return m_destinationRect; }
 1796
 1797 PlatformImagePtr m_image;
 1798 FloatSize m_imageSize;
 1799 FloatRect m_destinationRect;
 1800 FloatRect m_srcRect;
 1801 ImagePaintingOptions m_options;
 1802};
 1803
 1804template<class Encoder>
 1805void DrawPlatformImage::encode(Encoder& encoder) const
 1806{
 1807 encoder << m_image;
 1808 encoder << m_imageSize;
 1809 encoder << m_destinationRect;
 1810 encoder << m_srcRect;
 1811 encoder << m_options;
 1812}
 1813
 1814template<class Decoder>
 1815Optional<Ref<DrawPlatformImage>> DrawPlatformImage::decode(Decoder& decoder)
 1816{
 1817 Optional<PlatformImagePtr> image;
17451818 decoder >> image;
17461819 if (!image)
17471820 return WTF::nullopt;

@@Optional<Ref<DrawNativeImage>> DrawNativeImage::decode(Decoder& decoder)
17661839 if (!options)
17671840 return WTF::nullopt;
17681841
1769  return DrawNativeImage::create(*image, *imageSize, *destinationRect, *srcRect, *options);
 1842 return DrawPlatformImage::create(*image, *imageSize, *destinationRect, *srcRect, *options);
17701843}
17711844
17721845class DrawPattern : public DrawingItem {

@@void Item::encode(Encoder& encoder) const
33323405 case ItemType::DrawNativeImage:
33333406 encoder << downcast<DrawNativeImage>(*this);
33343407 break;
 3408 case ItemType::DrawPlatformImage:
 3409 encoder << downcast<DrawPlatformImage>(*this);
 3410 break;
33353411 case ItemType::DrawPattern:
33363412 encoder << downcast<DrawPattern>(*this);
33373413 break;

@@Optional<Ref<Item>> Item::decode(Decoder& decoder)
35533629 if (auto item = DrawNativeImage::decode(decoder))
35543630 return static_reference_cast<Item>(WTFMove(*item));
35553631 break;
 3632 case ItemType::DrawPlatformImage:
 3633 if (auto item = DrawPlatformImage::decode(decoder))
 3634 return static_reference_cast<Item>(WTFMove(*item));
 3635 break;
35563636 case ItemType::DrawPattern:
35573637 if (auto item = DrawPattern::decode(decoder))
35583638 return static_reference_cast<Item>(WTFMove(*item));

@@SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawTiledImage)
37273807SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawTiledScaledImage)
37283808SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawImageBuffer)
37293809SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawNativeImage)
 3810SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawPlatformImage)
37303811SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawPattern)
37313812SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawRect)
37323813SPECIALIZE_TYPE_TRAITS_DISPLAYLIST_ITEM(DrawLine)

@@template<> struct EnumTraits<WebCore::DisplayList::ItemType> {
37983879 WebCore::DisplayList::ItemType::DrawTiledScaledImage,
37993880 WebCore::DisplayList::ItemType::DrawImageBuffer,
38003881 WebCore::DisplayList::ItemType::DrawNativeImage,
 3882 WebCore::DisplayList::ItemType::DrawPlatformImage,
38013883 WebCore::DisplayList::ItemType::DrawPattern,
38023884 WebCore::DisplayList::ItemType::DrawRect,
38033885 WebCore::DisplayList::ItemType::DrawLine,

Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp

@@bool Recorder::drawImageBuffer(WebCore::ImageBuffer& imageBuffer, const FloatRec
194194 return true;
195195}
196196
197 void Recorder::drawNativeImage(const NativeImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
 197bool Recorder::drawNativeImage(NativeImage& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
198198{
199  appendItemAndUpdateExtent(DrawNativeImage::create(image, imageSize, destRect, srcRect, options));
 199 if (!m_delegate || !m_delegate->lockRemoteNativeImage(image))
 200 return false;
 201
 202 appendItemAndUpdateExtent(DrawNativeImage::create(image.renderingResourceIdentifier(), imageSize, destRect, srcRect, options));
 203 return true;
 204}
 205
 206void Recorder::drawPlatformImage(const PlatformImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
 207{
 208 appendItemAndUpdateExtent(DrawPlatformImage::create(image, imageSize, destRect, srcRect, options));
200209}
201210
202211void Recorder::drawPattern(Image& image, const FloatRect& destRect, const FloatRect& tileRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& options)

Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h

@@public:
6666 public:
6767 virtual ~Delegate() { }
6868 virtual bool lockRemoteImageBuffer(WebCore::ImageBuffer&) { return false; }
 69 virtual bool lockRemoteNativeImage(NativeImage&) { return false; }
6970 virtual void willAppendItem(const Item&) { };
7071 virtual void didAppendItem(const Item&) { };
7172 };

@@private:
108109 ImageDrawResult drawTiledImage(Image&, const FloatRect& destination, const FloatRect& source, const FloatSize& tileScaleFactor, Image::TileRule hRule, Image::TileRule vRule, const ImagePaintingOptions&) override;
109110
110111 bool drawImageBuffer(WebCore::ImageBuffer&, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions&) override;
111  void drawNativeImage(const NativeImagePtr&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) override;
 112 bool drawNativeImage(NativeImage&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) override;
 113 void drawPlatformImage(const PlatformImagePtr&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) override;
112114 void drawPattern(Image&, const FloatRect& destRect, const FloatRect& srcRect, const AffineTransform&, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions&) override;
113115
114116 void drawRect(const FloatRect&, float borderThickness) override;

Source/WebCore/platform/graphics/gstreamer/ImageDecoderGStreamer.cpp

@@public:
4646 return adoptRef(*new ImageDecoderGStreamerSample(WTFMove(sample), presentationSize));
4747 }
4848
49  NativeImagePtr image() const
 49 PlatformImagePtr image() const
5050 {
5151 if (!m_image)
5252 return nullptr;
53  return m_image->image().nativeImage();
 53 return m_image->image().nativeImage()->platformImage();
5454 }
5555 void dropImage() { m_image = nullptr; }
5656

@@unsigned ImageDecoderGStreamer::frameBytesAtIndex(size_t index, SubsamplingLevel
179179 return (frameSize.area() * 4).unsafeGet();
180180}
181181
182 NativeImagePtr ImageDecoderGStreamer::createFrameImageAtIndex(size_t index, SubsamplingLevel, const DecodingOptions&)
 182PlatformImagePtr ImageDecoderGStreamer::createFrameImageAtIndex(size_t index, SubsamplingLevel, const DecodingOptions&)
183183{
184184 LockHolder holder { m_sampleGeneratorLock };
185185

Source/WebCore/platform/graphics/gstreamer/ImageDecoderGStreamer.h

@@public:
6767 bool frameAllowSubsamplingAtIndex(size_t index) const final { return index <= m_sampleData.size(); }
6868 unsigned frameBytesAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default) const final;
6969
70  NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingOptions(DecodingMode::Synchronous)) final;
 70 PlatformImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingOptions(DecodingMode::Synchronous)) final;
7171
7272 void setExpectedContentSize(long long) final { }
7373 void setData(SharedBuffer&, bool allDataReceived) final;

Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp

@@bool MediaPlayerPrivateGStreamer::copyVideoTextureToPlatformTexture(GraphicsCont
32153215 return m_videoTextureCopier->copyVideoTextureToPlatformTexture(*layerBuffer.get(), size, outputTexture, outputTarget, level, internalFormat, format, type, flipY, m_videoSourceOrientation);
32163216}
32173217
3218 NativeImagePtr MediaPlayerPrivateGStreamer::nativeImageForCurrentTime()
 3218RefPtr<NativeImage> MediaPlayerPrivateGStreamer::nativeImageForCurrentTime()
32193219{
32203220 return nullptr;
32213221}

Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h

@@public:
216216
217217#if USE(GSTREAMER_GL)
218218 bool copyVideoTextureToPlatformTexture(GraphicsContextGLOpenGL*, PlatformGLObject, GCGLenum, GCGLint, GCGLenum, GCGLenum, GCGLenum, bool, bool) override;
219  NativeImagePtr nativeImageForCurrentTime() override;
 219 RefPtr<NativeImage> nativeImageForCurrentTime() override;
220220#endif
221221
222222 void updateEnabledVideoTrack();

Source/WebCore/platform/graphics/gtk/ImageGtk.cpp

@@Ref<Image> Image::loadPlatformResource(const char* name)
5656
5757GdkPixbuf* BitmapImage::getGdkPixbuf()
5858{
59  RefPtr<cairo_surface_t> surface = nativeImageForCurrentFrame();
 59 auto nativeImage = nativeImageForCurrentFrame();
 60 if (!nativeImage || nativeImage->isNull())
 61 return nullptr;
 62 auto& surface = nativeImage->platformImage();
6063 return surface ? cairoSurfaceToGdkPixbuf(surface.get()) : 0;
6164}
6265

Source/WebCore/platform/graphics/ios/IconIOS.mm

3333
3434namespace WebCore {
3535
36 Icon::Icon(const NativeImagePtr& image)
 36Icon::Icon(const PlatformImagePtr& image)
3737 : m_cgImage(image)
3838{
3939}

@@RefPtr<Icon> Icon::createIconForFiles(const Vector<String>& /*filenames*/)
4747 return nullptr;
4848}
4949
50 RefPtr<Icon> Icon::createIconForImage(const RetainPtr<CGImageRef>& image)
 50RefPtr<Icon> Icon::createIconForImage(const PlatformImagePtr& image)
5151{
5252 if (!image)
5353 return nullptr;

@@void Icon::paint(GraphicsContext& context, const FloatRect& destRect)
6868 FloatRect srcRect(FloatPoint(), size);
6969
7070 context.setImageInterpolationQuality(InterpolationQuality::High);
71  context.drawNativeImage(m_cgImage.get(), size, destRect, srcRect);
 71 context.drawPlatformImage(m_cgImage, size, destRect, srcRect);
7272}
7373
7474}

Source/WebCore/platform/graphics/mac/ImageMac.mm

@@Ref<Image> Image::loadPlatformResource(const char *name)
7474 return Image::nullImage();
7575}
7676
77 RetainPtr<CFDataRef> BitmapImage::tiffRepresentation(const Vector<NativeImagePtr>& nativeImages)
 77RetainPtr<CFDataRef> BitmapImage::tiffRepresentation(const Vector<RefPtr<NativeImage>>& nativeImages)
7878{
7979 // If nativeImages.size() is zero, we know for certain this image doesn't have valid data
8080 // Even though the call to CGImageDestinationCreateWithData will fail and we'll handle it gracefully,

@@RetainPtr<CFDataRef> BitmapImage::tiffRepresentation(const Vector<NativeImagePtr
8989 return nullptr;
9090
9191 for (const auto& nativeImage : nativeImages)
92  CGImageDestinationAddImage(destination.get(), nativeImage.get(), 0);
 92 CGImageDestinationAddImage(destination.get(), nativeImage->platformImage().get(), 0);
9393
9494 CGImageDestinationFinalize(destination.get());
9595 return data;

Source/WebCore/platform/graphics/nicosia/NicosiaImageBufferPipe.cpp

@@void NicosiaImageBufferPipeSource::handle(std::unique_ptr<ImageBuffer>&& buffer)
109109 return;
110110
111111 auto nativeImage = ImageBuffer::sinkIntoNativeImage(WTFMove(m_imageBuffer));
112  auto size = nativeImageSize(nativeImage);
 112 if (!nativeImage)
 113 return;
 114
 115 auto size = nativeImage->size();
113116
114  texture->reset(size, nativeImageHasAlpha(nativeImage) ? BitmapTexture::SupportsAlpha : BitmapTexture::NoFlag);
 117 texture->reset(size, nativeImage->hasAlpha() ? BitmapTexture::SupportsAlpha : BitmapTexture::NoFlag);
115118#if USE(CAIRO)
116  auto* surface = nativeImage.get();
 119 auto* surface = nativeImage->platformImage().get();
117120 auto* imageData = reinterpret_cast<const char*>(cairo_image_surface_get_data(surface));
118121 texture->updateContents(imageData, IntRect(IntPoint(), size), IntPoint(), cairo_image_surface_get_stride(surface));
119122#else

Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp

@@bool CairoOperationRecorder::drawImageBuffer(ImageBuffer&, const FloatRect&, con
555555 return false;
556556}
557557
558 void CairoOperationRecorder::drawNativeImage(const NativeImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
 558bool CairoOperationRecorder::drawNativeImage(NativeImage&, const FloatSize&, const FloatRect&, const FloatRect&, const ImagePaintingOptions&)
559559{
560  struct DrawNativeImage final : PaintingOperation, OperationData<RefPtr<cairo_surface_t>, FloatRect, FloatRect, ImagePaintingOptions, float, Cairo::ShadowState> {
561  virtual ~DrawNativeImage() = default;
 560 // FIXME: Not implemented.
 561 return false;
 562}
 563
 564void CairoOperationRecorder::drawPlatformImage(const PlatformImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
 565{
 566 struct DrawPlatformImage final : PaintingOperation, OperationData<RefPtr<cairo_surface_t>, FloatRect, FloatRect, ImagePaintingOptions, float, Cairo::ShadowState> {
 567 virtual ~DrawPlatformImage() = default;
562568
563569 void execute(PaintingOperationReplay& replayer) override
564570 {
565  Cairo::drawNativeImage(contextForReplay(replayer), arg<0>().get(), arg<1>(), arg<2>(), arg<3>(), arg<4>(), arg<5>());
 571 Cairo::drawPlatformImage(contextForReplay(replayer), arg<0>().get(), arg<1>(), arg<2>(), arg<3>(), arg<4>(), arg<5>());
566572 }
567573
568574 void dump(TextStream& ts) override
569575 {
570  ts << indent << "DrawNativeImage<>\n";
 576 ts << indent << "DrawPlatformImage<>\n";
571577 }
572578 };
573579
574580 UNUSED_PARAM(imageSize);
575581 auto& state = graphicsContext().state();
576  append(createCommand<DrawNativeImage>(RefPtr<cairo_surface_t>(image.get()), destRect, srcRect, ImagePaintingOptions(options, state.imageInterpolationQuality), state.alpha, Cairo::ShadowState(state)));
 582 append(createCommand<DrawPlatformImage>(RefPtr<cairo_surface_t>(image.get()), destRect, srcRect, ImagePaintingOptions(options, state.imageInterpolationQuality), state.alpha, Cairo::ShadowState(state)));
577583}
578584
579585void CairoOperationRecorder::drawPattern(Image& image, const FloatRect& destRect, const FloatRect& tileRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& options)

@@void CairoOperationRecorder::drawPattern(Image& image, const FloatRect& destRect
594600
595601 UNUSED_PARAM(spacing);
596602 if (auto surface = image.nativeImageForCurrentFrame())
597  append(createCommand<DrawPattern>(WTFMove(surface), IntSize(image.size()), destRect, tileRect, patternTransform, phase, options));
 603 append(createCommand<DrawPattern>(WTFMove(surface->platformImage()), IntSize(image.size()), destRect, tileRect, patternTransform, phase, options));
598604}
599605
600606void CairoOperationRecorder::drawRect(const FloatRect& rect, float borderThickness)

@@void CairoOperationRecorder::clipToImageBuffer(ImageBuffer& buffer, const FloatR
10791085 return;
10801086
10811087 if (auto surface = image->nativeImageForCurrentFrame())
1082  append(createCommand<ClipToImageBuffer>(RefPtr<cairo_surface_t>(surface.get()), destRect));
 1088 append(createCommand<ClipToImageBuffer>(RefPtr<cairo_surface_t>(surface->platformImage().get()), destRect));
10831089}
10841090
10851091void CairoOperationRecorder::applyDeviceScaleFactor(float)

Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.h

@@private:
6969 WebCore::ImageDrawResult drawTiledImage(WebCore::Image&, const WebCore::FloatRect&, const WebCore::FloatRect&, const WebCore::FloatSize&, WebCore::Image::TileRule, WebCore::Image::TileRule, const WebCore::ImagePaintingOptions&) override;
7070
7171 bool drawImageBuffer(WebCore::ImageBuffer&, const WebCore::FloatRect& destination, const WebCore::FloatRect& source, const WebCore::ImagePaintingOptions&) override;
72  void drawNativeImage(const WebCore::NativeImagePtr&, const WebCore::FloatSize&, const WebCore::FloatRect&, const WebCore::FloatRect&, const WebCore::ImagePaintingOptions&) override;
 72 bool drawNativeImage(WebCore::NativeImage&, const WebCore::FloatSize& selfSize, const WebCore::FloatRect& destRect, const WebCore::FloatRect& srcRect, const WebCore::ImagePaintingOptions&) override;
 73 void drawPlatformImage(const WebCore::PlatformImagePtr&, const WebCore::FloatSize& selfSize, const WebCore::FloatRect& destRect, const WebCore::FloatRect& srcRect, const WebCore::ImagePaintingOptions&) override;
7374 void drawPattern(WebCore::Image&, const WebCore::FloatRect&, const WebCore::FloatRect&, const WebCore::AffineTransform&, const WebCore::FloatPoint&, const WebCore::FloatSize&, const WebCore::ImagePaintingOptions&) override;
7475
7576 void drawRect(const WebCore::FloatRect&, float) override;

Source/WebCore/platform/graphics/texmap/BitmapTextureGL.cpp

@@void BitmapTextureGL::updateContents(Image* image, const IntRect& targetRect, co
151151{
152152 if (!image)
153153 return;
154  NativeImagePtr frameImage = image->nativeImageForCurrentFrame();
 154 auto frameImage = image->nativeImageForCurrentFrame();
155155 if (!frameImage)
156156 return;
157157

@@void BitmapTextureGL::updateContents(Image* image, const IntRect& targetRect, co
159159 const char* imageData;
160160
161161#if USE(CAIRO)
162  cairo_surface_t* surface = frameImage.get();
 162 cairo_surface_t* surface = frameImage->platformImage().get();
163163 imageData = reinterpret_cast<const char*>(cairo_image_surface_get_data(surface));
164164 bytesPerLine = cairo_image_surface_get_stride(surface);
165165#elif USE(DIRECT2D)

Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp

@@Ref<GraphicsLayer> GraphicsLayer::create(GraphicsLayerFactory* factory, Graphics
3939
4040GraphicsLayerTextureMapper::GraphicsLayerTextureMapper(Type layerType, GraphicsLayerClient& client)
4141 : GraphicsLayer(layerType, client)
42  , m_compositedNativeImagePtr(0)
4342 , m_changeMask(NoChanges)
4443 , m_needsDisplay(false)
4544 , m_debugBorderWidth(0)

@@void GraphicsLayerTextureMapper::setContentsToImage(Image* image)
294293{
295294 if (image) {
296295 // Make the decision about whether the image has changed.
297  // This code makes the assumption that pointer equality on a NativeImagePtr is a valid way to tell if the image is changed.
 296 // This code makes the assumption that pointer equality on a PlatformImagePtr is a valid way to tell if the image is changed.
298297 // This assumption is true for the GTK+ port.
299  NativeImagePtr newNativeImagePtr = image->nativeImageForCurrentFrame();
300  if (!newNativeImagePtr)
 298 auto newNativeImage = image->nativeImageForCurrentFrame();
 299 if (!newNativeImage)
301300 return;
302301
303  if (newNativeImagePtr == m_compositedNativeImagePtr)
 302 if (newNativeImage == m_compositedNativeImage)
304303 return;
305304
306  m_compositedNativeImagePtr = newNativeImagePtr;
 305 m_compositedNativeImage = newNativeImage;
307306 if (!m_compositedImage)
308307 m_compositedImage = TextureMapperTiledBackingStore::create();
309308 m_compositedImage->setContentsToImage(image);
310309 m_compositedImage->updateContentsScale(pageScaleFactor() * deviceScaleFactor());
311310 } else {
312  m_compositedNativeImagePtr = nullptr;
 311 m_compositedNativeImage = nullptr;
313312 m_compositedImage = nullptr;
314313 }
315314

Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h

2525#include "GraphicsLayer.h"
2626#include "GraphicsLayerClient.h"
2727#include "Image.h"
 28#include "NativeImage.h"
2829#include "TextureMapperLayer.h"
2930#include "TextureMapperPlatformLayer.h"
3031#include "TextureMapperTiledBackingStore.h"

@@private:
155156 TextureMapperLayer m_layer;
156157 std::unique_ptr<TextureMapperLayer> m_backdropLayer;
157158 RefPtr<TextureMapperTiledBackingStore> m_compositedImage;
158  NativeImagePtr m_compositedNativeImagePtr;
 159 RefPtr<NativeImage> m_compositedNativeImage;
159160 RefPtr<TextureMapperTiledBackingStore> m_backingStore;
160161
161162 int m_changeMask;

Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp

@@CoordinatedGraphicsLayer::CoordinatedGraphicsLayer(Type layerType, GraphicsLayer
138138 , m_pendingVisibleRectAdjustment(false)
139139 , m_shouldUpdatePlatformLayer(false)
140140 , m_coordinator(0)
141  , m_compositedNativeImagePtr(0)
142141 , m_animationStartedTimer(*this, &CoordinatedGraphicsLayer::animationStartedTimerFired)
143142 , m_requestPendingTileCreationTimer(RunLoop::main(), this, &CoordinatedGraphicsLayer::requestPendingTileCreationTimerFired)
144143{

@@void CoordinatedGraphicsLayer::setShowRepaintCounter(bool show)
585584
586585void CoordinatedGraphicsLayer::setContentsToImage(Image* image)
587586{
588  NativeImagePtr nativeImagePtr = image ? image->nativeImageForCurrentFrame() : nullptr;
589  if (m_compositedImage == image && m_compositedNativeImagePtr == nativeImagePtr)
 587 auto nativeImage = image ? image->nativeImageForCurrentFrame() : nullptr;
 588 if (m_compositedImage == image && m_compositedNativeImage == nativeImage)
590589 return;
591590
592591 m_compositedImage = image;
593  m_compositedNativeImagePtr = nativeImagePtr;
 592 m_compositedNativeImage = nativeImage;
594593
595594 GraphicsLayer::setContentsToImage(image);
596595 notifyFlushRequired();

@@void CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly()
849848 m_nicosia.delta.animatedBackingStoreClientChanged = true;
850849
851850 // Determine image backing presence according to the composited image source.
852  if (m_compositedNativeImagePtr) {
 851 if (m_compositedNativeImage) {
853852 ASSERT(m_compositedImage);
854853 auto& image = *m_compositedImage;
855854 uintptr_t imageID = reinterpret_cast<uintptr_t>(&image);
856  uintptr_t nativeImageID = reinterpret_cast<uintptr_t>(m_compositedNativeImagePtr.get());
 855 uintptr_t nativeImageID = reinterpret_cast<uintptr_t>(m_compositedNativeImage->platformImage().get());
857856
858857 // Respawn the ImageBacking object if the underlying image changed.
859858 if (m_nicosia.imageBacking) {

Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h

@@private:
223223 } m_needsDisplay;
224224
225225 RefPtr<Image> m_compositedImage;
226  NativeImagePtr m_compositedNativeImagePtr;
 226 RefPtr<NativeImage> m_compositedNativeImage;
227227
228228 Timer m_animationStartedTimer;
229229 RunLoop::Timer<CoordinatedGraphicsLayer> m_requestPendingTileCreationTimer;

Source/WebCore/platform/graphics/win/GraphicsContextDirect2D.cpp

@@void GraphicsContext::restorePlatformState()
207207 Direct2D::restore(*platformContext());
208208}
209209
210 void GraphicsContext::platformDrawNativeImage(const COMPtr<ID2D1Bitmap>& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
 210void GraphicsContext::drawPlatformImage(const COMPtr<ID2D1Bitmap>& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
211211{
212212 if (paintingDisabled())
213213 return;
214214
 215 if (m_impl) {
 216 m_impl->drawPlatformImage(image, imageSize, destRect, srcRect, options);
 217 return;
 218 }
 219
215220 ASSERT(hasPlatformContext());
216221 auto& state = this->state();
217222 Direct2D::drawNativeImage(*platformContext(), image.get(), imageSize, destRect, srcRect, options, state.alpha, Direct2D::ShadowState(state));

Source/WebCore/platform/graphics/win/GraphicsContextImplDirect2D.cpp

@@ImageDrawResult GraphicsContextImplDirect2D::drawTiledImage(Image& image, const
283283 return GraphicsContextImpl::drawTiledImageImpl(graphicsContext(), image, destination, source, tileScaleFactor, hRule, vRule, imagePaintingOptions);
284284}
285285
286 void GraphicsContextImplDirect2D::drawNativeImage(const NativeImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
 286void GraphicsContextImplDirect2D::drawNativeImage(const NativeImage& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
 287{
 288 drawPlatformImage(image.platformImage(), imageSize, destRect, srcRect, options);
 289}
 290
 291void GraphicsContextImplDirect2D::drawPlatformImage(const PlatformImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
287292{
288293 auto& state = graphicsContext().state();
289294 Direct2D::drawNativeImage(m_platformContext, image.get(), imageSize, destRect, srcRect, options, state.alpha, Direct2D::ShadowState(state));

Source/WebCore/platform/graphics/win/GraphicsContextImplDirect2D.h

@@public:
7171 ImageDrawResult drawImage(Image&, const FloatRect&, const FloatRect&, const ImagePaintingOptions&) override;
7272 ImageDrawResult drawTiledImage(Image&, const FloatRect&, const FloatPoint&, const FloatSize&, const FloatSize&, const ImagePaintingOptions&) override;
7373 ImageDrawResult drawTiledImage(Image&, const FloatRect&, const FloatRect&, const FloatSize&, Image::TileRule, Image::TileRule, const ImagePaintingOptions&) override;
74  void drawNativeImage(const NativeImagePtr&, const FloatSize&, const FloatRect&, const FloatRect&, const ImagePaintingOptions&) override;
 74
 75 bool drawImageBuffer(ImageBuffer&, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions&) override;
 76 bool drawNativeImage(NativeImage&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) override;
 77 void drawPlatformImage(const PlatformImagePtr&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) override;
7578 void drawPattern(Image&, const FloatRect&, const FloatRect&, const AffineTransform&, const FloatPoint&, const FloatSize&, const ImagePaintingOptions&) override;
7679
7780 void drawRect(const FloatRect&, float) override;

Source/WebCore/platform/graphics/win/ImageBufferDirect2DBackend.cpp

@@std::unique_ptr<ImageBufferDirect2DBackend> ImageBufferDirect2DBackend::create(c
6464 if (!bitmapContext)
6565 return;
6666
67  NativeImagePtr bitmap;
 67 PlatformImagePtr bitmap;
6868 HRESULT hr = bitmapContext->GetBitmap(&bitmap);
6969 if (!SUCCEEDED(hr))
7070 return;

@@std::unique_ptr<ImageBufferDirect2DBackend> ImageBufferDirect2DBackend::create(c
9090 return ImageBufferDirect2DBackend::create(size, 1, ColorSpace::SRGB, nullptr);
9191}
9292
93 ImageBufferDirect2DBackend::ImageBufferDirect2DBackend(const FloatSize& logicalSize, const IntSize& backendSize, float resolutionScale, ColorSpace colorSpace, std::unique_ptr<PlatformContextDirect2D>&& platformContext, std::unique_ptr<GraphicsContext>&& context, NativeImagePtr&& bitmap)
 93ImageBufferDirect2DBackend::ImageBufferDirect2DBackend(const FloatSize& logicalSize, const IntSize& backendSize, float resolutionScale, ColorSpace colorSpace, std::unique_ptr<PlatformContextDirect2D>&& platformContext, std::unique_ptr<GraphicsContext>&& context, PlatformImagePtr&& bitmap)
9494 : ImageBufferCGBackend(logicalSize, backendSize, resolutionScale, colorSpace)
9595 , m_platformContext(WTFMove(platformContext))
9696 , m_context(WTFMove(context))

@@void ImageBufferDirect2DBackend::flushContext()
108108 context().flush();
109109}
110110
111 NativeImagePtr ImageBufferDirect2DBackend::copyNativeImage(BackingStoreCopy copyBehavior) const
 111RefPtr<NativeImage> ImageBufferDirect2DBackend::copyNativeImage(BackingStoreCopy copyBehavior) const
112112{
113113 COMPtr<ID2D1BitmapRenderTarget> bitmapTarget;
114114 HRESULT hr = context().platformContext()->renderTarget()->QueryInterface(&bitmapTarget);

@@NativeImagePtr ImageBufferDirect2DBackend::copyNativeImage(BackingStoreCopy copy
133133
134134 }
135135
136  return image;
 136 return NativeImage::create(WTFMove(image));
137137}
138138
139 static NativeImagePtr createCroppedImageIfNecessary(ID2D1BitmapRenderTarget* bitmapTarget, ID2D1Bitmap* image, const IntSize& bounds)
 139static PlatformImagePtr createCroppedImageIfNecessary(ID2D1BitmapRenderTarget* bitmapTarget, ID2D1Bitmap* image, const IntSize& bounds)
140140{
141141 FloatSize imageSize = image ? nativeImageSize(image) : FloatSize();
142142

@@static RefPtr<Image> createBitmapImageAfterScalingIfNeeded(ID2D1BitmapRenderTarg
170170
171171RefPtr<Image> ImageBufferDirect2DBackend::copyImage(BackingStoreCopy copyBehavior, PreserveResolution preserveResolution) const
172172{
173  NativeImagePtr image;
 173 PlatformImagePtr image;
174174 if (m_resolutionScale == 1 || preserveResolution == PreserveResolution::Yes)
175  image = copyNativeImage(copyBehavior);
 175 image = copyNativeImage(copyBehavior)->platformImage();
176176 else
177  image = copyNativeImage(DontCopyBackingStore);
 177 image = copyNativeImage(DontCopyBackingStore)->platformImage();
178178
179179 auto bitmapTarget = reinterpret_cast<ID2D1BitmapRenderTarget*>(context().platformContext());
180180 return createBitmapImageAfterScalingIfNeeded(bitmapTarget, WTFMove(image), internalSize(), resolutionScale(), preserveResolution);

@@RefPtr<Image> ImageBufferDirect2DBackend::sinkIntoImage(PreserveResolution prese
187187 if (!SUCCEEDED(hr))
188188 return nullptr;
189189
190  NativeImagePtr image = copyNativeImage(DontCopyBackingStore);
 190 PlatformImagePtr image = copyNativeImage(DontCopyBackingStore)->platformImage();
191191 return createBitmapImageAfterScalingIfNeeded(bitmapTarget.get(), WTFMove(image), internalSize(), resolutionScale(), preserveResolution);
192192}
193193
194 NativeImagePtr ImageBufferDirect2DBackend::compatibleBitmap(ID2D1RenderTarget* renderTarget)
 194PlatformImagePtr ImageBufferDirect2DBackend::compatibleBitmap(ID2D1RenderTarget* renderTarget)
195195{
196196 loadDataToBitmapIfNeeded();
197197

Source/WebCore/platform/graphics/win/ImageBufferDirect2DBackend.h

@@public:
4242 GraphicsContext& context() const override;
4343 void flushContext() override;
4444
45  NativeImagePtr copyNativeImage(BackingStoreCopy = CopyBackingStore) const override;
 45 RefPtr<NativeImage> copyNativeImage(BackingStoreCopy = CopyBackingStore) const override;
4646 RefPtr<Image> copyImage(BackingStoreCopy, PreserveResolution) const override;
4747
4848 RefPtr<Image> sinkIntoImage(PreserveResolution) override;

@@protected:
5959
6060 std::unique_ptr<PlatformContextDirect2D> m_platformContext;
6161 std::unique_ptr<GraphicsContext> m_context;
62  NativeImagePtr m_bitmap;
 62 PlatformImagePtr m_bitmap;
6363};
6464
6565} // namespace WebCore

Source/WebCore/platform/graphics/win/ImageCGWin.cpp

@@RefPtr<BitmapImage> BitmapImage::create(HBITMAP hBitmap)
5757 // The BitmapImage takes ownership of this.
5858 RetainPtr<CGImageRef> cgImage = adoptCF(CGBitmapContextCreateImage(bitmapContext.get()));
5959
60  return adoptRef(new BitmapImage(WTFMove(cgImage)));
 60 return BitmapImage::create(WTFMove(cgImage));
6161}
6262
6363bool BitmapImage::getHBITMAPOfSize(HBITMAP bmp, const IntSize* size)

@@void BitmapImage::drawFrameMatchingSourceSize(GraphicsContext& ctxt, const Float
9191{
9292 size_t frames = frameCount();
9393 for (size_t i = 0; i < frames; ++i) {
94  CGImageRef image = frameImageAtIndex(i).get();
95  if (image && CGImageGetHeight(image) == static_cast<size_t>(srcSize.height()) && CGImageGetWidth(image) == static_cast<size_t>(srcSize.width())) {
 94 auto image = frameImageAtIndex(i);
 95 if (image && image->size() == srcSize) {
9696 size_t currentFrame = m_currentFrame;
9797 m_currentFrame = i;
9898 draw(ctxt, dstRect, FloatRect(0.0f, 0.0f, srcSize.width(), srcSize.height()), { compositeOp });

Source/WebCore/platform/graphics/win/ImageCairoWin.cpp

@@void BitmapImage::drawFrameMatchingSourceSize(GraphicsContext& ctxt, const Float
9393{
9494 size_t frames = frameCount();
9595 for (size_t i = 0; i < frames; ++i) {
96  auto surface = frameImageAtIndex(i);
97  if (!surface)
 96 auto nativeImage = frameImageAtIndex(i);
 97 if (!nativeImage || nativeImage->size() != srcSize)
9898 continue;
9999
100  if (cairo_image_surface_get_height(surface.get()) == static_cast<size_t>(srcSize.height()) && cairo_image_surface_get_width(surface.get()) == static_cast<size_t>(srcSize.width())) {
101  size_t currentFrame = m_currentFrame;
102  m_currentFrame = i;
103  draw(ctxt, dstRect, FloatRect(0.0f, 0.0f, srcSize.width(), srcSize.height()), { compositeOp });
104  m_currentFrame = currentFrame;
105  return;
106  }
 100 size_t currentFrame = m_currentFrame;
 101 m_currentFrame = i;
 102 draw(ctxt, dstRect, FloatRect(0.0f, 0.0f, srcSize.width(), srcSize.height()), { compositeOp });
 103 m_currentFrame = currentFrame;
 104 return;
107105 }
108106
109107 // No image of the correct size was found, fallback to drawing the current frame

Source/WebCore/platform/graphics/win/ImageDecoderDirect2D.cpp

@@void ImageDecoderDirect2D::setTargetContext(ID2D1RenderTarget* renderTarget)
240240 m_renderTarget = renderTarget;
241241}
242242
243 NativeImagePtr ImageDecoderDirect2D::createFrameImageAtIndex(size_t index, SubsamplingLevel subsamplingLevel, const DecodingOptions&)
 243PlatformImagePtr ImageDecoderDirect2D::createFrameImageAtIndex(size_t index, SubsamplingLevel subsamplingLevel, const DecodingOptions&)
244244{
245245 if (!m_nativeDecoder)
246246 return nullptr;

Source/WebCore/platform/graphics/win/ImageDecoderDirect2D.h

@@public:
7070 bool frameAllowSubsamplingAtIndex(size_t) const final;
7171 unsigned frameBytesAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default) const final;
7272
73  NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingOptions(DecodingMode::Synchronous)) final;
 73 PlatformImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingOptions(DecodingMode::Synchronous)) final;
7474
7575 void setData(SharedBuffer&, bool allDataReceived) final;
7676 bool isAllDataReceived() const final { return m_isAllDataReceived; }

Source/WebCore/platform/graphics/win/NativeImageDirect2D.cpp

@@static IWICImagingFactory* imagingFactory()
5050 return imagingFactory;
5151}
5252
53 IntSize nativeImageSize(const NativeImagePtr& image)
 53IntSize NativeImage::size(const PlatformImagePtr& platformImage)
5454{
55  UINT width = 0;
56  UINT height = 0;
57  if (!image)
58  return { };
59 
60  return image->GetPixelSize();
 55 return platformImage ? platformImage->GetPixelSize() : IntSize();
6156}
6257
63 bool nativeImageHasAlpha(const NativeImagePtr& image)
 58bool NativeImage::hasAlpha() const
6459{
65  if (!image)
 60 if (!m_platformImage)
6661 return false;
6762
68  D2D1_PIXEL_FORMAT pixelFormat = image->GetPixelFormat();
 63 D2D1_PIXEL_FORMAT pixelFormat = m_platformImage->GetPixelFormat();
6964 return pixelFormat.alphaMode != D2D1_ALPHA_MODE_IGNORE;
7065}
7166
72 Color nativeImageSinglePixelSolidColor(const NativeImagePtr& image)
 67Color NativeImage::singlePixelSolidColor() const
7368{
74  if (!image || nativeImageSize(image) != IntSize(1, 1))
 69 if (!m_platformImage || size() != IntSize(1, 1))
7570 return Color();
7671
7772 notImplemented();
78 
7973 return Color();
8074}
8175
82 void drawNativeImage(const NativeImagePtr& image, GraphicsContext& context, const FloatRect& destRect, const FloatRect& srcRect, const IntSize& srcSize, const ImagePaintingOptions& options)
83 {
84  auto* platformContext = context.platformContext();
85 
86  // Subsampling may have given us an image that is smaller than size().
87  IntSize subsampledImageSize = nativeImageSize(image);
88 
89  // srcRect is in the coordinates of the unsubsampled image, so we have to map it to the subsampled image.
90  FloatRect adjustedSrcRect = srcRect;
91  if (subsampledImageSize != srcSize)
92  adjustedSrcRect = mapRect(srcRect, FloatRect({ }, srcSize), FloatRect({ }, subsampledImageSize));
93 
94  auto& state = context.state();
95  Direct2D::drawNativeImage(*platformContext, image.get(), subsampledImageSize, destRect, adjustedSrcRect, options, state.alpha, Direct2D::ShadowState(state));
96 }
97 
98 void clearNativeImageSubimages(const NativeImagePtr& image)
 76void NativeImage::clearSubimages()
9977{
10078 notImplemented();
101 
10279#if CACHE_SUBIMAGES
103  if (image)
104  subimageCache().clearImage(image.get());
 80 if (m_platformImage)
 81 SubimageCacheWithTimer::clearImage(m_platformImage.get());
10582#endif
10683}
10784
108 
10985}

Source/WebCore/platform/gtk/CursorGtk.cpp

@@static GRefPtr<GdkCursor> createCustomCursor(Image* image, const IntPoint& hotSp
6363 IntPoint effectiveHotSpot = determineHotSpot(image, hotSpot);
6464 return adoptGRef(gdk_cursor_new_from_texture(texture.get(), effectiveHotSpot.x(), effectiveHotSpot.y(), fallbackCursor().get()));
6565#else
66  RefPtr<cairo_surface_t> surface = image->nativeImageForCurrentFrame();
67  if (!surface)
 66 auto nativeImage = image->nativeImageForCurrentFrame();
 67 if (!nativeImage || nativeImage->isNull())
6868 return nullptr;
6969
 70 auto& surface = nativeImage->platformImage();
7071 IntPoint effectiveHotSpot = determineHotSpot(image, hotSpot);
7172 return adoptGRef(gdk_cursor_new_from_surface(gdk_display_get_default(), surface.get(), effectiveHotSpot.x(), effectiveHotSpot.y()));
7273#endif // USE(GTK4)

Source/WebCore/platform/gtk/DragImageGtk.cpp

@@DragImageRef dissolveDragImageToFraction(DragImageRef image, float fraction)
8686
8787DragImageRef createDragImageFromImage(Image* image, ImageOrientation)
8888{
89  return image->nativeImageForCurrentFrame();
 89 return image->nativeImageForCurrentFrame()->platformImage();
9090}
9191
9292DragImageRef createDragImageIconForCachedImageFilename(const String&)

Source/WebCore/platform/image-decoders/ScalableImageDecoder.cpp

@@Seconds ScalableImageDecoder::frameDurationAtIndex(size_t index) const
204204 return duration;
205205}
206206
207 NativeImagePtr ScalableImageDecoder::createFrameImageAtIndex(size_t index, SubsamplingLevel, const DecodingOptions&)
 207PlatformImagePtr ScalableImageDecoder::createFrameImageAtIndex(size_t index, SubsamplingLevel, const DecodingOptions&)
208208{
209209 LockHolder lockHolder(m_mutex);
210210 // Zero-height images can cause problems for some ports. If we have an empty image dimension, just bail.

Source/WebCore/platform/image-decoders/ScalableImageDecoder.h

@@public:
144144
145145 Seconds frameDurationAtIndex(size_t) const final;
146146
147  NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingOptions(DecodingMode::Synchronous)) override;
 147 PlatformImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingOptions(DecodingMode::Synchronous)) override;
148148
149149 void setIgnoreGammaAndColorProfile(bool flag) { m_ignoreGammaAndColorProfile = flag; }
150150 bool ignoresGammaAndColorProfile() const { return m_ignoreGammaAndColorProfile; }

Source/WebCore/platform/image-decoders/cairo/ImageBackingStoreCairo.cpp

3030
3131namespace WebCore {
3232
33 NativeImagePtr ImageBackingStore::image() const
 33PlatformImagePtr ImageBackingStore::image() const
3434{
3535 m_pixels->ref();
3636 RefPtr<cairo_surface_t> surface = adoptRef(cairo_image_surface_create_for_data(

Source/WebCore/platform/mediastream/mac/DisplayCaptureSourceCocoa.cpp

@@void DisplayCaptureSourceCocoa::emitFrame()
239239
240240 return IntSize(IOSurfaceGetWidth(surface.get()), IOSurfaceGetHeight(surface.get()));
241241 },
242  [](RetainPtr<CGImageRef> image) -> IntSize {
 242 [](RefPtr<NativeImage> image) -> IntSize {
243243 if (!image)
244244 return { };
245245
246  return IntSize(CGImageGetWidth(image.get()), CGImageGetHeight(image.get()));
 246 return image->size();
247247 }
248248 );
249249

@@void DisplayCaptureSourceCocoa::emitFrame()
263263
264264 return m_imageTransferSession->createMediaSample(surface.get(), sampleTime, size());
265265 },
266  [this, sampleTime](RetainPtr<CGImageRef> image) -> RefPtr<MediaSample> {
 266 [this, sampleTime](RefPtr<NativeImage> image) -> RefPtr<MediaSample> {
267267 if (!image)
268268 return nullptr;
269269
270  return m_imageTransferSession->createMediaSample(image.get(), sampleTime, size());
 270 return m_imageTransferSession->createMediaSample(image->platformImage().get(), sampleTime, size());
271271 }
272272 );
273273

Source/WebCore/platform/mediastream/mac/DisplayCaptureSourceCocoa.h

@@class PixelBufferConformerCV;
5252
5353class DisplayCaptureSourceCocoa final : public RealtimeMediaSource {
5454public:
55  using DisplayFrameType = WTF::Variant<RetainPtr<CGImageRef>, RetainPtr<IOSurfaceRef>>;
 55 using DisplayFrameType = WTF::Variant<RefPtr<NativeImage>, RetainPtr<IOSurfaceRef>>;
5656 class Capturer
5757#if !RELEASE_LOG_DISABLED
5858 : public LoggerHelper

Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.mm

@@void MockRealtimeVideoSourceMac::updateSampleBuffer()
9191 if (!m_imageTransferSession)
9292 m_imageTransferSession = ImageTransferSessionVT::create(preferedPixelBufferFormat());
9393
 94 PlatformImagePtr platformImage;
 95 if (auto nativeImage = imageBuffer->copyImage()->nativeImage())
 96 platformImage = nativeImage->platformImage();
 97
9498 auto sampleTime = MediaTime::createWithDouble((elapsedTime() + 100_ms).seconds());
95  auto sampleBuffer = m_imageTransferSession->createMediaSample(imageBuffer->copyImage()->nativeImage().get(), sampleTime, size(), sampleRotation());
 99 auto sampleBuffer = m_imageTransferSession->createMediaSample(platformImage.get(), sampleTime, size(), sampleRotation());
96100 if (!sampleBuffer)
97101 return;
98102

Source/WebCore/platform/win/DragImageCGWin.cpp

@@DragImageRef createDragImageFromImage(Image* img, ImageOrientation)
139139 CGContextSetFillColor(drawContext, white);
140140 CGContextFillRect(drawContext, rect);
141141 if (auto srcImage = img->nativeImage()) {
142  CGContextSetBlendMode(drawContext, kCGBlendModeNormal);
143  CGContextDrawImage(drawContext, rect, srcImage.get());
 142 if (auto platformImage = srcImage->platformImage()) {
 143 CGContextSetBlendMode(drawContext, kCGBlendModeNormal);
 144 CGContextDrawImage(drawContext, rect, platformImage.get());
 145 }
144146 }
145147 CGContextRelease(drawContext);
146148

Source/WebCore/platform/win/DragImageCairoWin.cpp

@@DragImageRef createDragImageFromImage(Image* img, ImageOrientation)
162162 cairo_set_source_rgb(cr, 1.0, 0.0, 1.0);
163163 cairo_fill_preserve(cr);
164164
165  RefPtr<cairo_surface_t> surface = img->nativeImageForCurrentFrame();
166  if (surface) {
 165 auto nativeImage = img->nativeImageForCurrentFrame();
 166 if (nativeImage && !nativeImage->isNull()) {
 167 auto& surface = nativeImage->platformImage();
167168 // Draw the image.
168169 cairo_set_source_surface(cr, surface.get(), 0.0, 0.0);
169170 cairo_paint(cr);

Source/WebCore/rendering/RenderThemeIOS.mm

@@void RenderThemeIOS::paintSystemPreviewBadge(Image& image, const PaintInfo& pain
18401840 CGRect insetBadgeRect = CGRectMake(rect.width() - badgeDimension - badgeOffset, badgeOffset, badgeDimension, badgeDimension);
18411841 CGRect badgeRect = CGRectMake(0, 0, badgeDimension, badgeDimension);
18421842
1843  CIImage *inputImage = [CIImage imageWithCGImage:image.nativeImage().get()];
 1843 CIImage *inputImage = [CIImage imageWithCGImage:image.nativeImage()->platformImage().get()];
18441844
18451845 // Create a circle to be used for the clipping path in the badge, as well as the drop shadow.
18461846 RetainPtr<CGPathRef> circle = adoptCF(CGPathCreateWithRoundedRect(absoluteBadgeRect, badgeDimension / 2, badgeDimension / 2, nullptr));

Source/WebCore/svg/graphics/SVGImage.cpp

@@ImageDrawResult SVGImage::drawForContainer(GraphicsContext& context, const Float
209209}
210210
211211#if USE(CAIRO)
212 // Passes ownership of the native image to the caller so NativeImagePtr needs
 212// Passes ownership of the native image to the caller so NativeImage needs
213213// to be a smart pointer type.
214 NativeImagePtr SVGImage::nativeImageForCurrentFrame(const GraphicsContext*)
 214RefPtr<NativeImage> SVGImage::nativeImageForCurrentFrame(const GraphicsContext*)
215215{
216216 if (!m_page)
217217 return nullptr;

@@NativeImagePtr SVGImage::nativeImageForCurrentFrame(const GraphicsContext*)
229229#endif
230230
231231#if USE(DIRECT2D)
232 NativeImagePtr SVGImage::nativeImage(const GraphicsContext* targetContext)
 232RefPtr<NativeImage> SVGImage::nativeImage(const GraphicsContext* targetContext)
233233{
234234 ASSERT(targetContext);
235235 if (!m_page || !targetContext)

Source/WebCore/svg/graphics/SVGImage.h

@@public:
6363 void scheduleStartAnimation();
6464
6565#if USE(CAIRO)
66  NativeImagePtr nativeImageForCurrentFrame(const GraphicsContext* = nullptr) final;
 66 RefPtr<NativeImage> nativeImageForCurrentFrame(const GraphicsContext* = nullptr) final;
6767#endif
6868#if USE(DIRECT2D)
69  NativeImagePtr nativeImage(const GraphicsContext* = nullptr) final;
 69 RefPtr<NativeImage> nativeImage(const GraphicsContext* = nullptr) final;
7070#endif
7171
7272 Page* internalPage() { return m_page.get(); }

Source/WebCore/svg/graphics/SVGImageForContainer.cpp

@@void SVGImageForContainer::drawPattern(GraphicsContext& context, const FloatRect
4545 m_image->drawPatternForContainer(context, m_containerSize, m_containerZoom, m_initialFragmentURL, srcRect, patternTransform, phase, spacing, dstRect, options);
4646}
4747
48 NativeImagePtr SVGImageForContainer::nativeImageForCurrentFrame(const GraphicsContext* targetContext)
 48RefPtr<NativeImage> SVGImageForContainer::nativeImageForCurrentFrame(const GraphicsContext* targetContext)
4949{
5050 return m_image->nativeImageForCurrentFrame(targetContext);
5151}

Source/WebCore/svg/graphics/SVGImageForContainer.h

@@public:
6060 // FIXME: Implement this to be less conservative.
6161 bool currentFrameKnownToBeOpaque() const final { return false; }
6262
63  NativeImagePtr nativeImageForCurrentFrame(const GraphicsContext* = nullptr) final;
 63 RefPtr<NativeImage> nativeImageForCurrentFrame(const GraphicsContext* = nullptr) final;
6464
6565private:
6666 SVGImageForContainer(SVGImage* image, const FloatSize& containerSize, float containerZoom, const URL& initialFragmentURL)

Source/WebKit/Scripts/webkit/messages.py

@@def types_that_cannot_be_forward_declared():
217217 'WebCore::PlaybackTargetClientContextIdentifier',
218218 'WebCore::MediaPlayerIdentifier',
219219 'WebCore::MediaSessionIdentifier',
220  'WebCore::NativeImagePtr',
 220 'WebCore::PlatformImagePtr',
221221 'WebCore::PageIdentifier',
222222 'WebCore::PluginLoadClientPolicy',
223223 'WebCore::PointerID',

Source/WebKit/Shared/API/c/cg/WKImageCG.cpp

@@WKImageRef WKImageCreateFromCGImage(CGImageRef imageRef, WKImageOptions options)
5555
5656 WebCore::FloatRect rect(WebCore::FloatPoint(0, 0), imageSize);
5757 graphicsContext->clearRect(rect);
58  graphicsContext->drawNativeImage(imageRef, imageSize, rect, rect);
 58 graphicsContext->drawPlatformImage(imageRef, imageSize, rect, rect);
5959 return toAPI(webImage.leakRef());
6060}
6161

Source/WebKit/Shared/WebCoreArgumentCoders.cpp

@@bool ArgumentCoder<ImageHandle>::decode(Decoder& decoder, ImageHandle& imageHand
11001100 return true;
11011101}
11021102
1103 static void encodeNativeImage(Encoder& encoder, const NativeImagePtr& image)
 1103static void encodePlatformImage(Encoder& encoder, const PlatformImagePtr& platformImage)
11041104{
1105  auto imageSize = nativeImageSize(image);
 1105 auto imageSize = NativeImage::size(platformImage);
11061106 auto bitmap = ShareableBitmap::createShareable(imageSize, { });
11071107 auto graphicsContext = bitmap->createGraphicsContext();
11081108 encoder << !!graphicsContext;
11091109 if (!graphicsContext)
11101110 return;
11111111
1112  graphicsContext->drawNativeImage(image, imageSize, FloatRect({ }, imageSize), FloatRect({ }, imageSize));
 1112 graphicsContext->drawPlatformImage(platformImage, imageSize, FloatRect({ }, imageSize), FloatRect({ }, imageSize));
11131113
11141114 ShareableBitmap::Handle handle;
11151115 bitmap->createHandle(handle);

@@static void encodeNativeImage(Encoder& encoder, const NativeImagePtr& image)
11171117 encoder << handle;
11181118}
11191119
1120 static WARN_UNUSED_RETURN bool decodeNativeImage(Decoder& decoder, NativeImagePtr& nativeImage)
 1120static WARN_UNUSED_RETURN bool decodePlatformImage(Decoder& decoder, PlatformImagePtr& platformImage)
11211121{
11221122 Optional<bool> didCreateGraphicsContext;
11231123 decoder >> didCreateGraphicsContext;

@@static WARN_UNUSED_RETURN bool decodeNativeImage(Decoder& decoder, NativeImagePt
11361136 if (!image)
11371137 return false;
11381138
1139  nativeImage = image->nativeImage();
1140  if (!nativeImage)
 1139 platformImage = image->nativeImage()->platformImage();
 1140 if (!platformImage)
11411141 return false;
11421142
11431143 return true;
11441144}
11451145
1146 static void encodeOptionalNativeImage(Encoder& encoder, const NativeImagePtr& image)
 1146static void encodeOptionalPlatformImage(Encoder& encoder, const PlatformImagePtr& platformImage)
11471147{
1148  bool hasImage = !!image;
 1148 bool hasImage = !!platformImage;
11491149 encoder << hasImage;
11501150
11511151 if (hasImage)
1152  encodeNativeImage(encoder, image);
 1152 encodePlatformImage(encoder, platformImage);
11531153}
11541154
1155 static WARN_UNUSED_RETURN bool decodeOptionalNativeImage(Decoder& decoder, NativeImagePtr& image)
 1155static WARN_UNUSED_RETURN bool decodeOptionalPlatformImage(Decoder& decoder, PlatformImagePtr& platformImage)
11561156{
1157  image = nullptr;
 1157 platformImage = nullptr;
11581158
11591159 bool hasImage;
11601160 if (!decoder.decode(hasImage))

@@static WARN_UNUSED_RETURN bool decodeOptionalNativeImage(Decoder& decoder, Nativ
11631163 if (!hasImage)
11641164 return true;
11651165
1166  return decodeNativeImage(decoder, image);
 1166 return decodePlatformImage(decoder, platformImage);
11671167}
11681168
1169 void ArgumentCoder<NativeImagePtr>::encode(Encoder& encoder, const NativeImagePtr& image)
 1169void ArgumentCoder<PlatformImagePtr>::encode(Encoder& encoder, const PlatformImagePtr& platformImage)
11701170{
1171  encodeOptionalNativeImage(encoder, image);
 1171 encodeOptionalPlatformImage(encoder, platformImage);
11721172}
11731173
1174 bool ArgumentCoder<NativeImagePtr>::decode(Decoder& decoder, NativeImagePtr& image)
 1174bool ArgumentCoder<PlatformImagePtr>::decode(Decoder& decoder, PlatformImagePtr& platformImage)
11751175{
1176  return decodeOptionalNativeImage(decoder, image);
 1176 return decodeOptionalPlatformImage(decoder, platformImage);
11771177}
11781178
11791179void ArgumentCoder<Ref<Font>>::encode(Encoder& encoder, const Ref<WebCore::Font>& font)

Source/WebKit/Shared/WebCoreArgumentCoders.h

3434#include <WebCore/IndexedDB.h>
3535#include <WebCore/InputMode.h>
3636#include <WebCore/MediaSelectionOption.h>
37 #include <WebCore/NativeImagePtr.h>
 37#include <WebCore/NativeImage.h>
3838#include <WebCore/NetworkLoadMetrics.h>
3939#include <WebCore/NotificationDirection.h>
4040#include <WebCore/RealtimeMediaSource.h>

@@template<> struct ArgumentCoder<WebCore::ImageHandle> {
419419 static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::ImageHandle&);
420420};
421421
422 template<> struct ArgumentCoder<WebCore::NativeImagePtr> {
423  static void encode(Encoder&, const WebCore::NativeImagePtr&);
424  static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::NativeImagePtr&);
 422template<> struct ArgumentCoder<WebCore::PlatformImagePtr> {
 423 static void encode(Encoder&, const WebCore::PlatformImagePtr&);
 424 static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::PlatformImagePtr&);
425425};
426426
427427template<> struct ArgumentCoder<WebCore::ResourceRequest> {

Source/WebKit/Shared/cg/ShareableBitmapCG.cpp

@@void ShareableBitmap::releaseDataProviderData(void* typelessBitmap, const void*
185185
186186RefPtr<Image> ShareableBitmap::createImage()
187187{
188  RetainPtr<CGImageRef> platformImage = makeCGImage();
189  if (!platformImage)
190  return nullptr;
191 
192  return BitmapImage::create(WTFMove(platformImage));
 188 if (auto platformImage = makeCGImage())
 189 return BitmapImage::create(WTFMove(platformImage));
 190 return nullptr;
193191}
194192
195193} // namespace WebKit

Source/WebKit/UIProcess/API/glib/IconDatabase.cpp

@@void IconDatabase::checkIconURLAndSetPageURLIfNeeded(const String& iconURL, cons
543543 });
544544}
545545
546 void IconDatabase::loadIconForPageURL(const String& pageURL, AllowDatabaseWrite allowDatabaseWrite, CompletionHandler<void(NativeImagePtr&&)>&& completionHandler)
 546void IconDatabase::loadIconForPageURL(const String& pageURL, AllowDatabaseWrite allowDatabaseWrite, CompletionHandler<void(PlatformImagePtr&&)>&& completionHandler)
547547{
548548 ASSERT(isMainThread());
549549

@@void IconDatabase::loadIconForPageURL(const String& pageURL, AllowDatabaseWrite
562562 LockHolder lockHolder(m_loadedIconsLock);
563563 if (!m_loadedIcons.contains(iconURL)) {
564564 iconData = this->iconData(iconID.value());
565  m_loadedIcons.set(iconURL, std::make_pair<NativeImagePtr, MonotonicTime>(nullptr, { }));
 565 m_loadedIcons.set(iconURL, std::make_pair<PlatformImagePtr, MonotonicTime>(nullptr, { }));
566566 }
567567 }
568568 bool canWriteToDatabase = m_allowDatabaseWrite == AllowDatabaseWrite::Yes && allowDatabaseWrite == AllowDatabaseWrite::Yes;

@@void IconDatabase::loadIconForPageURL(const String& pageURL, AllowDatabaseWrite
587587 return;
588588 }
589589
590  auto addResult = m_loadedIcons.set(iconURL, std::make_pair<NativeImagePtr, MonotonicTime>(nullptr, MonotonicTime::now()));
 590 auto addResult = m_loadedIcons.set(iconURL, std::make_pair<PlatformImagePtr, MonotonicTime>(nullptr, MonotonicTime::now()));
591591 if (!iconData.isEmpty()) {
592592 auto image = BitmapImage::create();
593593 if (image->setData(SharedBuffer::create(WTFMove(iconData)), true) < EncodedDataStatus::SizeAvailable) {
594594 completionHandler(nullptr);
595595 return;
596596 }
597  addResult.iterator->value.first = image->nativeImageForCurrentFrame();
 597 addResult.iterator->value.first = image->nativeImageForCurrentFrame()->platformImage();
598598 }
599599
600600 auto icon = addResult.iterator->value.first;

@@void IconDatabase::setIconForPageURL(const String& iconURL, const unsigned char*
622622 bool result = true;
623623 {
624624 LockHolder lockHolder(m_loadedIconsLock);
625  auto addResult = m_loadedIcons.set(iconURL, std::make_pair<NativeImagePtr, MonotonicTime>(nullptr, { }));
 625 auto addResult = m_loadedIcons.set(iconURL, std::make_pair<PlatformImagePtr, MonotonicTime>(nullptr, { }));
626626 if (iconDataSize) {
627627 auto image = BitmapImage::create();
628628 if (image->setData(SharedBuffer::create(iconData, iconDataSize), true) < EncodedDataStatus::SizeAvailable)
629629 result = false;
630630 else
631  addResult.iterator->value.first = image->nativeImageForCurrentFrame();
 631 addResult.iterator->value.first = image->nativeImageForCurrentFrame()->platformImage();
632632 }
633633 }
634634 startClearLoadedIconsTimer();

Source/WebKit/UIProcess/API/glib/IconDatabase.h

@@public:
4444 void invalidate();
4545
4646 void checkIconURLAndSetPageURLIfNeeded(const String& iconURL, const String& pageURL, AllowDatabaseWrite, CompletionHandler<void(bool, bool)>&&);
47  void loadIconForPageURL(const String&, AllowDatabaseWrite, CompletionHandler<void(WebCore::NativeImagePtr&&)>&&);
 47 void loadIconForPageURL(const String&, AllowDatabaseWrite, CompletionHandler<void(WebCore::PlatformImagePtr&&)>&&);
4848 String iconURLForPageURL(const String&);
4949 void setIconForPageURL(const String& iconURL, const unsigned char*, size_t, const String& pageURL, AllowDatabaseWrite, CompletionHandler<void(bool)>&&);
5050 void clear(CompletionHandler<void()>&&);

@@private:
7171 WebCore::SQLiteDatabase m_db;
7272 HashMap<String, String> m_pageURLToIconURLMap;
7373 Lock m_pageURLToIconURLMapLock;
74  HashMap<String, std::pair<WebCore::NativeImagePtr, MonotonicTime>> m_loadedIcons;
 74 HashMap<String, std::pair<WebCore::PlatformImagePtr, MonotonicTime>> m_loadedIcons;
7575 Lock m_loadedIconsLock;
7676
7777 std::unique_ptr<WebCore::SQLiteStatement> m_iconIDForIconURLStatement;

Source/WebKit/UIProcess/ios/DragDropInteractionState.mm

@@static RetainPtr<UIImage> uiImageForImage(Image* image)
8686 if (!image)
8787 return nullptr;
8888
89  auto cgImage = image->nativeImage();
90  if (!cgImage)
 89 auto nativeImage = image->nativeImage();
 90 if (!nativeImage || nativeImage->isNull())
9191 return nullptr;
9292
93  return adoptNS([[UIImage alloc] initWithCGImage:cgImage.get()]);
 93 return adoptNS([[UIImage alloc] initWithCGImage:nativeImage->platformImage().get()]);
9494}
9595
9696static bool shouldUseDragImageToCreatePreviewForDragSource(const DragSourceState& source)

Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

@@static NSArray<NSItemProvider *> *extractItemProvidersFromDropSession(id <UIDrop
75037503 return;
75047504
75057505 auto unselectedSnapshotImage = snapshotWithoutSelection->nativeImage();
7506  if (!unselectedSnapshotImage)
 7506 if (!unselectedSnapshotImage || unselectedSnapshotImage->isNull())
75077507 return;
75087508
75097509 if (!_dropAnimationCount)
75107510 return;
75117511
7512  auto unselectedContentImageForEditDrag = adoptNS([[UIImage alloc] initWithCGImage:unselectedSnapshotImage.get() scale:_page->deviceScaleFactor() orientation:UIImageOrientationUp]);
 7512 auto unselectedContentImageForEditDrag = adoptNS([[UIImage alloc] initWithCGImage:unselectedSnapshotImage->platformImage().get() scale:_page->deviceScaleFactor() orientation:UIImageOrientationUp]);
75137513 _unselectedContentSnapshot = adoptNS([[UIImageView alloc] initWithImage:unselectedContentImageForEditDrag.get()]);
75147514 [_unselectedContentSnapshot setFrame:data->contentImageWithoutSelectionRectInRootViewCoordinates];
75157515

@@static RetainPtr<UIImage> uiImageForImage(WebCore::Image* image)
77327732 if (!image)
77337733 return nil;
77347734
7735  auto cgImage = image->nativeImage();
7736  if (!cgImage)
 7735 auto nativeImage = image->nativeImage();
 7736 if (!nativeImage || nativeImage->isNull())
77377737 return nil;
77387738
7739  return adoptNS([[UIImage alloc] initWithCGImage:cgImage.get()]);
 7739 return adoptNS([[UIImage alloc] initWithCGImage:nativeImage->platformImage().get()]);
77407740}
77417741
77427742// FIXME: This should be merged with createTargetedDragPreview in DragDropInteractionState.

@@static Vector<WebCore::IntSize> sizesOfPlaceholderElementsToInsertWhenDroppingIt
79917991 }
79927992
79937993 auto unselectedSnapshotImage = snapshotWithoutSelection->nativeImage();
7994  if (!unselectedSnapshotImage) {
 7994 if (!unselectedSnapshotImage || unselectedSnapshotImage->isNull()) {
79957995 RELEASE_LOG(DragAndDrop, "Failed to animate image placeholders: could not decode unselected content image.");
79967996 state.clearAllDelayedItemPreviewProviders();
79977997 return;
79987998 }
79997999
8000  auto unselectedContentImageForEditDrag = adoptNS([[UIImage alloc] initWithCGImage:unselectedSnapshotImage.get() scale:protectedSelf->_page->deviceScaleFactor() orientation:UIImageOrientationUp]);
 8000 auto unselectedContentImageForEditDrag = adoptNS([[UIImage alloc] initWithCGImage:unselectedSnapshotImage->platformImage().get() scale:protectedSelf->_page->deviceScaleFactor() orientation:UIImageOrientationUp]);
80018001 auto snapshotView = adoptNS([[UIImageView alloc] initWithImage:unselectedContentImageForEditDrag.get()]);
80028002 [snapshotView setFrame:data->contentImageWithoutSelectionRectInRootViewCoordinates];
80038003 [protectedSelf addSubview:snapshotView.get()];

@@static UIMenu *menuFromLegacyPreviewOrDefaultActions(UIViewController *previewVi
1004110041{
1004210042 if (!_positionInformation.linkIndicator.contentImage)
1004310043 return nullptr;
10044  return [[[UIImage alloc] initWithCGImage:_positionInformation.linkIndicator.contentImage->nativeImage().get()] autorelease];
 10044
 10045 auto nativeImage = _positionInformation.linkIndicator.contentImage->nativeImage();
 10046 if (!nativeImage || nativeImage->isNull())
 10047 return nullptr;
 10048
 10049 return [[[UIImage alloc] initWithCGImage:nativeImage->platformImage().get()] autorelease];
1004510050}
1004610051
1004710052- (NSArray *)_presentationRectsForPreviewItemController:(UIPreviewItemController *)controller

Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.cpp

@@ImageBufferBackendHandle ImageBufferShareableBitmapBackend::createImageBufferBac
9696 return ImageBufferBackendHandle(WTFMove(handle));
9797}
9898
99 NativeImagePtr ImageBufferShareableBitmapBackend::copyNativeImage(BackingStoreCopy) const
 99RefPtr<NativeImage> ImageBufferShareableBitmapBackend::copyNativeImage(BackingStoreCopy) const
100100{
101101#if USE(CG)
102  return m_bitmap->makeCGImageCopy();
 102 return NativeImage::create(m_bitmap->makeCGImageCopy());
103103#elif USE(DIRECT2D)
104104 return nullptr;
105105#elif USE(CAIRO)
106  return m_bitmap->createCairoSurface();
 106 return NativeImage::create(m_bitmap->createCairoSurface());
107107#endif
108108}
109109

Source/WebKit/WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.h

@@public:
5252
5353 WebCore::GraphicsContext& context() const override { return *m_context; }
5454
55  WebCore::NativeImagePtr copyNativeImage(WebCore::BackingStoreCopy = WebCore::CopyBackingStore) const override;
 55 RefPtr<WebCore::NativeImage> copyNativeImage(WebCore::BackingStoreCopy = WebCore::CopyBackingStore) const override;
5656 RefPtr<WebCore::Image> copyImage(WebCore::BackingStoreCopy = WebCore::CopyBackingStore, WebCore::PreserveResolution = WebCore::PreserveResolution::No) const override;
5757
5858 Vector<uint8_t> toBGRAData() const override;

Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp

@@bool MediaPlayerPrivateRemote::copyVideoTextureToPlatformTexture(GraphicsContext
811811 return false;
812812}
813813
814 NativeImagePtr MediaPlayerPrivateRemote::nativeImageForCurrentTime()
 814RefPtr<NativeImage> MediaPlayerPrivateRemote::nativeImageForCurrentTime()
815815{
816816 notImplemented();
817817 return nullptr;

Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h

@@private:
263263 void paint(WebCore::GraphicsContext&, const WebCore::FloatRect&) final;
264264 void paintCurrentFrameInContext(WebCore::GraphicsContext&, const WebCore::FloatRect&) final;
265265 bool copyVideoTextureToPlatformTexture(WebCore::GraphicsContextGLOpenGL*, PlatformGLObject, GCGLenum, GCGLint, GCGLenum, GCGLenum, GCGLenum, bool, bool) final;
266  WebCore::NativeImagePtr nativeImageForCurrentTime() final;
 266 RefPtr<WebCore::NativeImage> nativeImageForCurrentTime() final;
267267
268268 WebCore::MediaPlayerIdentifier identifier() const final;
269269

Source/WebKit/WebProcess/Plugins/PluginView.cpp

@@void PluginView::didFailLoad(WebFrame* webFrame, bool wasCancelled)
16831683#if PLATFORM(COCOA)
16841684static bool isAlmostSolidColor(BitmapImage* bitmap)
16851685{
1686  CGImageRef image = bitmap->nativeImage().get();
 1686 CGImageRef image = bitmap->nativeImage()->platformImage().get();
16871687 ASSERT(CGImageGetBitsPerComponent(image) == 8);
16881688
16891689 CGBitmapInfo imageInfo = CGImageGetBitmapInfo(image);

Source/WebKitLegacy/mac/DOM/DOM.mm

@@id <DOMEventTarget> kit(EventTarget* target)
536536
537537 if (textIndicator) {
538538 if (Image* image = textIndicator->contentImage())
539  *cgImage = image->nativeImage().autorelease();
 539 *cgImage = image->nativeImage()->platformImage().autorelease();
540540 }
541541
542542 if (!*cgImage) {

Source/WebKitLegacy/mac/Misc/WebCache.mm

@@class DefaultStorageSessionProvider : public WebCore::StorageSessionProvider {
171171 WebCore::CachedResource* cachedResource = WebCore::MemoryCache::singleton().resourceForRequest(request, PAL::SessionID::defaultSessionID());
172172 if (!is<WebCore::CachedImage>(cachedResource))
173173 return nullptr;
174  WebCore::CachedImage& cachedImage = downcast<WebCore::CachedImage>(*cachedResource);
 174
 175 auto& cachedImage = downcast<WebCore::CachedImage>(*cachedResource);
175176 if (!cachedImage.hasImage())
176177 return nullptr;
177  return cachedImage.image()->nativeImage().get();
 178
 179 auto nativeImage = cachedImage.image()->nativeImage();
 180 if (!nativeImage)
 181 return nullptr;
 182
 183 return nativeImage->platformImage().get();
178184}
179185
180186#endif // PLATFORM(IOS_FAMILY)

Source/WebKitLegacy/mac/WebView/WebView.mm

@@private:
845845 _textRectsInBoundingRectCoordinates = createNSArray(indicatorData.textRectsInBoundingRectCoordinates).leakRef();
846846 _contentImageScaleFactor = indicatorData.contentImageScaleFactor;
847847 if (indicatorData.contentImageWithHighlight)
848  _contentImageWithHighlight = [PAL::allocUIImageInstance() initWithCGImage:indicatorData.contentImageWithHighlight.get()->nativeImage().get() scale:scale orientation:UIImageOrientationDownMirrored];
 848 _contentImageWithHighlight = [PAL::allocUIImageInstance() initWithCGImage:indicatorData.contentImageWithHighlight.get()->nativeImage()->platformImage().get() scale:scale orientation:UIImageOrientationDownMirrored];
849849 if (indicatorData.contentImage)
850  _contentImage = [PAL::allocUIImageInstance() initWithCGImage:indicatorData.contentImage.get()->nativeImage().get() scale:scale orientation:UIImageOrientationUp];
 850 _contentImage = [PAL::allocUIImageInstance() initWithCGImage:indicatorData.contentImage.get()->nativeImage()->platformImage().get() scale:scale orientation:UIImageOrientationUp];
851851
852852 if (indicatorData.contentImageWithoutSelection) {
853853 auto nativeImage = indicatorData.contentImageWithoutSelection.get()->nativeImage();
854854 if (nativeImage) {
855  _contentImageWithoutSelection = [PAL::allocUIImageInstance() initWithCGImage:nativeImage.get() scale:scale orientation:UIImageOrientationUp];
 855 _contentImageWithoutSelection = [PAL::allocUIImageInstance() initWithCGImage:nativeImage->platformImage().get() scale:scale orientation:UIImageOrientationUp];
856856 _contentImageWithoutSelectionRectInRootViewCoordinates = indicatorData.contentImageWithoutSelectionRectInRootViewCoordinates;
857857 }
858858 }