Diff
Modified: trunk/Source/WebCore/ChangeLog (205681 => 205682)
--- trunk/Source/WebCore/ChangeLog 2016-09-09 00:55:43 UTC (rev 205681)
+++ trunk/Source/WebCore/ChangeLog 2016-09-09 01:06:47 UTC (rev 205682)
@@ -1,3 +1,112 @@
+2016-09-08 Said Abou-Hallawa <[email protected]>
+
+ Move the BitmapImage platform dependent code to a new file named NativeImage[CG|Cairo].cpp
+ https://bugs.webkit.org/show_bug.cgi?id=158684
+
+ Reviewed by Simon Fraser.
+
+ This is a refactoring patch. It moves the BitmapImage platform dependent
+ code from BitmapImage to NativeImage[CG|Cairo].cpp. The new APIs are
+ responsible of drawing a NativeImagePtr and answering some metadata queries.
+
+ No new tests -- Code refactoring, no behavior change.
+
+ * PlatformAppleWin.cmake:
+ * PlatformEfl.cmake:
+ * PlatformGTK.cmake:
+ * PlatformMac.cmake:
+ * PlatformWinCairo.cmake:
+ * WebCore.xcodeproj/project.pbxproj:
+ * loader/cache/MemoryCache.h:
+ * loader/icon/IconDatabaseBase.h:
+ * page/mac/TextIndicatorWindow.mm:
+ (-[WebTextIndicatorView initWithFrame:textIndicator:margin:offset:]):
+ (createContentCrossfadeAnimation):
+ * platform/graphics/BitmapImage.cpp:
+ (WebCore::BitmapImage::BitmapImage):
+ (WebCore::BitmapImage::destroyDecodedData):
+ (WebCore::BitmapImage::destroyDecodedDataIfNecessary):
+ (WebCore::BitmapImage::dataChanged):
+ (WebCore::BitmapImage::ensureFrameAtIndexIsCached):
+ (WebCore::BitmapImage::frameImageAtIndex):
+ (WebCore::BitmapImage::nativeImage):
+ (WebCore::BitmapImage::nativeImageForCurrentFrame):
+ (WebCore::BitmapImage::nativeImageOfSize):
+ (WebCore::BitmapImage::framesNativeImages):
+ (WebCore::BitmapImage::frameIsCompleteAtIndex):
+ (WebCore::BitmapImage::frameDurationAtIndex):
+ (WebCore::BitmapImage::frameHasAlphaAtIndex):
+ (WebCore::BitmapImage::frameOrientationAtIndex):
+ (WebCore::BitmapImage::singlePixelSolidColor):
+ (WebCore::BitmapImage::draw):
+ (WebCore::BitmapImage::drawPattern):
+ (WebCore::BitmapImage::canAnimate):
+ (WebCore::BitmapImage::clearTimer):
+ (WebCore::BitmapImage::startTimer):
+ (WebCore::BitmapImage::stopAnimation):
+ (WebCore::BitmapImage::resetAnimation):
+ (WebCore::BitmapImage::hasSingleSecurityOrigin): Deleted.
+ (WebCore::BitmapImage::filenameExtension): Deleted.
+ (WebCore::BitmapImage::ensureFrameIsCached): Deleted.
+ * platform/graphics/BitmapImage.h:
+ (WebCore::FrameData::FrameData):
+ m_hasAlpha can be initialized with false because it is accessed only in
+ BitmapImage::frameHasAlphaAtIndex() and it is guarded by m_haveMetadata.
+ Both m_haveMetadata and m_hasAlpha are set in BitmapImage constructor
+ and in BitmapImage::cacheFrame().
+
+ (WebCore::FrameData::~FrameData):
+ (WebCore::FrameData::clear):
+ * platform/graphics/Icon.h:
+ * platform/graphics/Image.h:
+ (WebCore::Image::nativeImage):
+ (WebCore::Image::nativeImageOfSize):
+ (WebCore::Image::framesNativeImages):
+ (WebCore::Image::orientationForCurrentFrame): Deleted.
+ (WebCore::Image::getCGImageRef): Deleted.
+ (WebCore::Image::getFirstCGImageRefOfSize): Deleted.
+ (WebCore::Image::getCGImageArray): Deleted.
+ * platform/graphics/ImageSource.cpp:
+ (WebCore::ImageSource::calculateMaximumSubsamplingLevel):
+ (WebCore::ImageSource::size):
+ (WebCore::ImageSource::sizeRespectingOrientation):
+ * platform/graphics/ImageSource.h:
+ * platform/graphics/MediaPlayer.h:
+ * platform/graphics/NativeImage.h: Added.
+ * platform/graphics/NativeImagePtr.h: Removed.
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
+ (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::updatePausedImage):
+ * platform/graphics/cairo/BitmapImageCairo.cpp: Removed.
+ * platform/graphics/cairo/NativeImageCairo.cpp: Added.
+ (WebCore::nativeImageSize):
+ (WebCore::nativeImageHasAlpha):
+ (WebCore::nativeImageSinglePixelSolidColor):
+ (WebCore::subsamplingScale):
+ (WebCore::drawNativeImage):
+ (WebCore::clearNativeImageSubImages):
+ * platform/graphics/cg/BitmapImageCG.cpp: Removed.
+ * platform/graphics/cg/ImageDecoderCG.cpp:
+ (WebCore::ImageDecoder::size):
+ * platform/graphics/cg/ImageDecoderCG.h:
+ * platform/graphics/cg/NativeImageCG.cpp: Added.
+ (WebCore::nativeImageSize):
+ (WebCore::nativeImageHasAlpha):
+ (WebCore::nativeImageSinglePixelSolidColor):
+ (WebCore::subsamplingScale):
+ (WebCore::drawNativeImage):
+ (WebCore::clearNativeImageSubImages):
+ * platform/graphics/cg/PatternCG.cpp:
+ (WebCore::Pattern::createPlatformPattern):
+ * platform/graphics/cocoa/TextTrackRepresentationCocoa.mm:
+ (TextTrackRepresentationCocoa::update):
+ * platform/graphics/mac/ImageMac.mm:
+ (WebCore::BitmapImage::getTIFFRepresentation):
+ * platform/mediastream/mac/MockRealtimeVideoSourceMac.mm:
+ (WebCore::MockRealtimeVideoSourceMac::updatePlatformLayer):
+ (WebCore::MockRealtimeVideoSourceMac::updateSampleBuffer):
+ * platform/win/DragImageCGWin.cpp:
+ (WebCore::createDragImageFromImage):
+
2016-09-08 Alex Christensen <[email protected]>
URLParser: Parsing empty URLs with a base URL should return the base URL
Modified: trunk/Source/WebCore/PlatformAppleWin.cmake (205681 => 205682)
--- trunk/Source/WebCore/PlatformAppleWin.cmake 2016-09-09 00:55:43 UTC (rev 205681)
+++ trunk/Source/WebCore/PlatformAppleWin.cmake 2016-09-09 01:06:47 UTC (rev 205682)
@@ -55,7 +55,6 @@
platform/graphics/ca/win/WebTiledBackingLayerWin.cpp
platform/graphics/ca/win/WKCACFViewLayerTreeHost.cpp
- platform/graphics/cg/BitmapImageCG.cpp
platform/graphics/cg/ColorCG.cpp
platform/graphics/cg/FloatPointCG.cpp
platform/graphics/cg/FloatRectCG.cpp
@@ -72,6 +71,7 @@
platform/graphics/cg/IntPointCG.cpp
platform/graphics/cg/IntRectCG.cpp
platform/graphics/cg/IntSizeCG.cpp
+ platform/graphics/cg/NativeImageCG.cpp
platform/graphics/cg/PDFDocumentImage.cpp
platform/graphics/cg/PathCG.cpp
platform/graphics/cg/PatternCG.cpp
Modified: trunk/Source/WebCore/PlatformEfl.cmake (205681 => 205682)
--- trunk/Source/WebCore/PlatformEfl.cmake 2016-09-09 00:55:43 UTC (rev 205681)
+++ trunk/Source/WebCore/PlatformEfl.cmake 2016-09-09 01:06:47 UTC (rev 205682)
@@ -126,7 +126,6 @@
platform/graphics/PlatformDisplay.cpp
platform/graphics/cairo/BackingStoreBackendCairoImpl.cpp
- platform/graphics/cairo/BitmapImageCairo.cpp
platform/graphics/cairo/CairoUtilities.cpp
platform/graphics/cairo/FontCairo.cpp
platform/graphics/cairo/FontCairoHarfbuzzNG.cpp
@@ -135,6 +134,7 @@
platform/graphics/cairo/ImageBufferCairo.cpp
platform/graphics/cairo/ImageCairo.cpp
platform/graphics/cairo/IntRectCairo.cpp
+ platform/graphics/cairo/NativeImageCairo.cpp
platform/graphics/cairo/PathCairo.cpp
platform/graphics/cairo/PatternCairo.cpp
platform/graphics/cairo/PlatformContextCairo.cpp
Modified: trunk/Source/WebCore/PlatformGTK.cmake (205681 => 205682)
--- trunk/Source/WebCore/PlatformGTK.cmake 2016-09-09 00:55:43 UTC (rev 205681)
+++ trunk/Source/WebCore/PlatformGTK.cmake 2016-09-09 01:06:47 UTC (rev 205682)
@@ -105,7 +105,6 @@
platform/graphics/cairo/BackingStoreBackendCairoImpl.cpp
platform/graphics/cairo/BackingStoreBackendCairoX11.cpp
- platform/graphics/cairo/BitmapImageCairo.cpp
platform/graphics/cairo/CairoUtilities.cpp
platform/graphics/cairo/FloatRectCairo.cpp
platform/graphics/cairo/FontCairo.cpp
@@ -116,6 +115,7 @@
platform/graphics/cairo/ImageBufferCairo.cpp
platform/graphics/cairo/ImageCairo.cpp
platform/graphics/cairo/IntRectCairo.cpp
+ platform/graphics/cairo/NativeImageCairo.cpp
platform/graphics/cairo/PathCairo.cpp
platform/graphics/cairo/PatternCairo.cpp
platform/graphics/cairo/PlatformContextCairo.cpp
Modified: trunk/Source/WebCore/PlatformMac.cmake (205681 => 205682)
--- trunk/Source/WebCore/PlatformMac.cmake 2016-09-09 00:55:43 UTC (rev 205681)
+++ trunk/Source/WebCore/PlatformMac.cmake 2016-09-09 01:06:47 UTC (rev 205682)
@@ -385,7 +385,6 @@
platform/graphics/ca/cocoa/WebSystemBackdropLayer.mm
platform/graphics/ca/cocoa/WebTiledBackingLayer.mm
- platform/graphics/cg/BitmapImageCG.cpp
platform/graphics/cg/ColorCG.cpp
platform/graphics/cg/FloatPointCG.cpp
platform/graphics/cg/FloatRectCG.cpp
@@ -402,6 +401,7 @@
platform/graphics/cg/IntPointCG.cpp
platform/graphics/cg/IntRectCG.cpp
platform/graphics/cg/IntSizeCG.cpp
+ platform/graphics/cg/NativeImageCG.cpp
platform/graphics/cg/PDFDocumentImage.cpp
platform/graphics/cg/PathCG.cpp
platform/graphics/cg/PatternCG.cpp
Modified: trunk/Source/WebCore/PlatformWinCairo.cmake (205681 => 205682)
--- trunk/Source/WebCore/PlatformWinCairo.cmake 2016-09-09 00:55:43 UTC (rev 205681)
+++ trunk/Source/WebCore/PlatformWinCairo.cmake 2016-09-09 01:06:47 UTC (rev 205682)
@@ -21,7 +21,6 @@
platform/graphics/GLContext.cpp
platform/graphics/PlatformDisplay.cpp
- platform/graphics/cairo/BitmapImageCairo.cpp
platform/graphics/cairo/CairoUtilities.cpp
platform/graphics/cairo/FloatRectCairo.cpp
platform/graphics/cairo/FontCairo.cpp
@@ -31,6 +30,7 @@
platform/graphics/cairo/ImageBufferCairo.cpp
platform/graphics/cairo/ImageCairo.cpp
platform/graphics/cairo/IntRectCairo.cpp
+ platform/graphics/cairo/NativeImageCairo.cpp
platform/graphics/cairo/PathCairo.cpp
platform/graphics/cairo/PatternCairo.cpp
platform/graphics/cairo/PlatformContextCairo.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (205681 => 205682)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-09-09 00:55:43 UTC (rev 205681)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-09-09 01:06:47 UTC (rev 205682)
@@ -1424,7 +1424,7 @@
375CD232119D43C800A2A859 /* Hyphenation.h in Headers */ = {isa = PBXBuildFile; fileRef = 375CD231119D43C800A2A859 /* Hyphenation.h */; };
376DCCE113B4F966002EBEFC /* TextRun.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 376DCCE013B4F966002EBEFC /* TextRun.cpp */; };
3774ABA50FA21EB400AD7DE9 /* OverlapTestRequestClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 3774ABA30FA21EB400AD7DE9 /* OverlapTestRequestClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
- 377A3A9015EFCE9B0059F5C7 /* BitmapImageCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 377A3A8F15EFCE9A0059F5C7 /* BitmapImageCG.cpp */; };
+ 377A3A9015EFCE9B0059F5C7 /* NativeImageCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 377A3A8F15EFCE9A0059F5C7 /* NativeImageCG.cpp */; };
37919C230B7D188600A56998 /* PositionIterator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37919C210B7D188600A56998 /* PositionIterator.cpp */; };
37919C240B7D188600A56998 /* PositionIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = 37919C220B7D188600A56998 /* PositionIterator.h */; settings = {ATTRIBUTES = (); }; };
3792917A1985EF3900F4B661 /* CredentialBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 379291781985EF3900F4B661 /* CredentialBase.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -2274,6 +2274,7 @@
550A0BCA085F6039007353D6 /* QualifiedName.h in Headers */ = {isa = PBXBuildFile; fileRef = 550A0BC8085F6039007353D6 /* QualifiedName.h */; settings = {ATTRIBUTES = (Private, ); }; };
555B87EC1CAAF0AB00349425 /* ImageDecoderCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 555B87EA1CAAF0AB00349425 /* ImageDecoderCG.cpp */; };
555B87ED1CAAF0AB00349425 /* ImageDecoderCG.h in Headers */ = {isa = PBXBuildFile; fileRef = 555B87EB1CAAF0AB00349425 /* ImageDecoderCG.h */; };
+ 55A336F71D8209F40022C4C7 /* NativeImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 55A336F61D8209F40022C4C7 /* NativeImage.h */; };
5709E8CD1D413D47003244AC /* WebKitSubtleCrypto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5709E8CA1D413CE3003244AC /* WebKitSubtleCrypto.cpp */; };
5709E8CE1D413D5B003244AC /* JSWebKitSubtleCryptoCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FF8F661807460800132674 /* JSWebKitSubtleCryptoCustom.cpp */; };
5709E8CF1D413D9A003244AC /* WebKitSubtleCrypto.h in Headers */ = {isa = PBXBuildFile; fileRef = 5709E8CB1D413CE3003244AC /* WebKitSubtleCrypto.h */; };
@@ -2513,7 +2514,7 @@
65FEA86909833ADE00BED4AB /* Page.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65FEA86809833ADE00BED4AB /* Page.cpp */; };
69A6CBAC1C6BE42C00B836E9 /* AccessibilitySVGElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 697101071C6BE1550018C7F1 /* AccessibilitySVGElement.cpp */; };
69A6CBAD1C6BE42C00B836E9 /* AccessibilitySVGElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 697101081C6BE1550018C7F1 /* AccessibilitySVGElement.h */; };
- 6B3480940EEF50D400AC1B41 /* NativeImagePtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B3480920EEF50D400AC1B41 /* NativeImagePtr.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 6B3480940EEF50D400AC1B41 /* NativeImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B3480920EEF50D400AC1B41 /* NativeImage.h */; settings = {ATTRIBUTES = (Private, ); }; };
6B693A2E1C51A82E00B03BEF /* ResourceLoadObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B693A2D1C51A82E00B03BEF /* ResourceLoadObserver.h */; settings = {ATTRIBUTES = (Private, ); }; };
6B693A341C51A95D00B03BEF /* ResourceLoadObserver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6B693A331C51A95D00B03BEF /* ResourceLoadObserver.cpp */; };
6C4C96DE1AD4483500365A50 /* JSReadableStreamDefaultController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6C4C96DA1AD4483500365A50 /* JSReadableStreamDefaultController.cpp */; };
@@ -8354,7 +8355,7 @@
376DCCE013B4F966002EBEFC /* TextRun.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextRun.cpp; sourceTree = "<group>"; };
3772B09516535856000A49CA /* PopupOpeningObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PopupOpeningObserver.h; sourceTree = "<group>"; };
3774ABA30FA21EB400AD7DE9 /* OverlapTestRequestClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OverlapTestRequestClient.h; sourceTree = "<group>"; };
- 377A3A8F15EFCE9A0059F5C7 /* BitmapImageCG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BitmapImageCG.cpp; sourceTree = "<group>"; };
+ 377A3A8F15EFCE9A0059F5C7 /* NativeImageCG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NativeImageCG.cpp; sourceTree = "<group>"; };
37919C210B7D188600A56998 /* PositionIterator.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = PositionIterator.cpp; sourceTree = "<group>"; };
37919C220B7D188600A56998 /* PositionIterator.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PositionIterator.h; sourceTree = "<group>"; };
379291781985EF3900F4B661 /* CredentialBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CredentialBase.h; sourceTree = "<group>"; };
@@ -9289,6 +9290,7 @@
550A0BC8085F6039007353D6 /* QualifiedName.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = QualifiedName.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
555B87EA1CAAF0AB00349425 /* ImageDecoderCG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageDecoderCG.cpp; sourceTree = "<group>"; };
555B87EB1CAAF0AB00349425 /* ImageDecoderCG.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageDecoderCG.h; sourceTree = "<group>"; };
+ 55A336F61D8209F40022C4C7 /* NativeImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NativeImage.h; sourceTree = "<group>"; };
55D408F71A7C631800C78450 /* SVGImageClients.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGImageClients.h; sourceTree = "<group>"; };
5709E8CA1D413CE3003244AC /* WebKitSubtleCrypto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebKitSubtleCrypto.cpp; sourceTree = "<group>"; };
5709E8CB1D413CE3003244AC /* WebKitSubtleCrypto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitSubtleCrypto.h; sourceTree = "<group>"; };
@@ -9554,7 +9556,7 @@
65FEA86809833ADE00BED4AB /* Page.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Page.cpp; sourceTree = "<group>"; };
697101071C6BE1550018C7F1 /* AccessibilitySVGElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AccessibilitySVGElement.cpp; sourceTree = "<group>"; };
697101081C6BE1550018C7F1 /* AccessibilitySVGElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilitySVGElement.h; sourceTree = "<group>"; };
- 6B3480920EEF50D400AC1B41 /* NativeImagePtr.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = NativeImagePtr.h; sourceTree = "<group>"; };
+ 6B3480920EEF50D400AC1B41 /* NativeImage.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = NativeImage.h; sourceTree = "<group>"; };
6B693A2D1C51A82E00B03BEF /* ResourceLoadObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadObserver.h; sourceTree = "<group>"; };
6B693A331C51A95D00B03BEF /* ResourceLoadObserver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceLoadObserver.cpp; sourceTree = "<group>"; };
6C4C96DA1AD4483500365A50 /* JSReadableStreamDefaultController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSReadableStreamDefaultController.cpp; sourceTree = "<group>"; };
@@ -20506,7 +20508,6 @@
B27535290B053814002CE64F /* cg */ = {
isa = PBXGroup;
children = (
- 377A3A8F15EFCE9A0059F5C7 /* BitmapImageCG.cpp */,
0FCF33230F2B9715004B6795 /* ColorCG.cpp */,
B275352B0B053814002CE64F /* FloatPointCG.cpp */,
B275352C0B053814002CE64F /* FloatRectCG.cpp */,
@@ -20533,6 +20534,7 @@
A80A38FD0E50CC8200A25EBC /* PatternCG.cpp */,
B27535360B053814002CE64F /* PDFDocumentImage.cpp */,
B27535370B053814002CE64F /* PDFDocumentImage.h */,
+ 377A3A8F15EFCE9A0059F5C7 /* NativeImageCG.cpp */,
1FC40FB81655C5910040F29E /* SubimageCacheWithTimer.cpp */,
1FC40FB71655C5910040F29E /* SubimageCacheWithTimer.h */,
B275352A0B053814002CE64F /* TransformationMatrixCG.cpp */,
@@ -20724,7 +20726,7 @@
CDDC1E7918A952F30027A9D4 /* MediaSourcePrivateClient.h */,
314BE3A41B3103FB00141982 /* NamedImageGeneratedImage.cpp */,
314BE3A51B3103FB00141982 /* NamedImageGeneratedImage.h */,
- 6B3480920EEF50D400AC1B41 /* NativeImagePtr.h */,
+ 6B3480920EEF50D400AC1B41 /* NativeImage.h */,
B27535520B053814002CE64F /* Path.cpp */,
B27535530B053814002CE64F /* Path.h */,
A88DD4880B4629B000C02990 /* PathTraversalState.cpp */,
@@ -20766,6 +20768,7 @@
501BAAA813950E2C00F7ACEB /* WindRule.h */,
379919941200DDF400EA041C /* WOFFFileFormat.cpp */,
379919951200DDF400EA041C /* WOFFFileFormat.h */,
+ 55A336F61D8209F40022C4C7 /* NativeImage.h */,
);
path = graphics;
sourceTree = "<group>";
@@ -25702,7 +25705,7 @@
314BE3A71B3103FB00141982 /* NamedImageGeneratedImage.h in Headers */,
A81872230977D3C0005826D9 /* NamedNodeMap.h in Headers */,
A818721E0977D3C0005826D9 /* NameNodeList.h in Headers */,
- 6B3480940EEF50D400AC1B41 /* NativeImagePtr.h in Headers */,
+ 6B3480940EEF50D400AC1B41 /* NativeImage.h in Headers */,
83B2D1751B8BCD6A00A02E47 /* NativeNodeFilter.h in Headers */,
E10B9B6C0B747599003ED890 /* NativeXPathNSResolver.h in Headers */,
93CCF0270AF6C52900018E89 /* NavigationAction.h in Headers */,
@@ -25780,6 +25783,7 @@
1A569D150D7E2B82007C3983 /* objc_instance.h in Headers */,
1A569D170D7E2B82007C3983 /* objc_runtime.h in Headers */,
1A569D190D7E2B82007C3983 /* objc_utility.h in Headers */,
+ 55A336F71D8209F40022C4C7 /* NativeImage.h in Headers */,
E16982551134629D00894115 /* ObjCRuntimeObject.h in Headers */,
7E5D7A77161D3F8F00896C34 /* OESElementIndexUint.h in Headers */,
9001774112E0347800648462 /* OESStandardDerivatives.h in Headers */,
@@ -27599,7 +27603,7 @@
FDC54F041399B0DA008D9117 /* BiquadFilterNode.cpp in Sources */,
FD31602612B0267600C1A359 /* BiquadProcessor.cpp in Sources */,
A89943290B42338800D7C802 /* BitmapImage.cpp in Sources */,
- 377A3A9015EFCE9B0059F5C7 /* BitmapImageCG.cpp in Sources */,
+ 377A3A9015EFCE9B0059F5C7 /* NativeImageCG.cpp in Sources */,
1AFFC4541D5E81CB00267A66 /* BlacklistUpdater.mm in Sources */,
976D6C78122B8A3D001FD1F7 /* Blob.cpp in Sources */,
2EDEF1F3121B0EFC00726DB2 /* BlobData.cpp in Sources */,
Modified: trunk/Source/WebCore/loader/cache/MemoryCache.h (205681 => 205682)
--- trunk/Source/WebCore/loader/cache/MemoryCache.h 2016-09-09 00:55:43 UTC (rev 205681)
+++ trunk/Source/WebCore/loader/cache/MemoryCache.h 2016-09-09 01:06:47 UTC (rev 205682)
@@ -25,7 +25,7 @@
#ifndef Cache_h
#define Cache_h
-#include "NativeImagePtr.h"
+#include "NativeImage.h"
#include "SecurityOriginHash.h"
#include "SessionID.h"
#include "Timer.h"
Modified: trunk/Source/WebCore/loader/icon/IconDatabaseBase.h (205681 => 205682)
--- trunk/Source/WebCore/loader/icon/IconDatabaseBase.h 2016-09-09 00:55:43 UTC (rev 205681)
+++ trunk/Source/WebCore/loader/icon/IconDatabaseBase.h 2016-09-09 01:06:47 UTC (rev 205682)
@@ -26,7 +26,7 @@
#ifndef IconDatabaseBase_h
#define IconDatabaseBase_h
-#include "NativeImagePtr.h"
+#include "NativeImage.h"
#include <wtf/Forward.h>
#include <wtf/Noncopyable.h>
#include <wtf/PassRefPtr.h>
Modified: trunk/Source/WebCore/page/mac/TextIndicatorWindow.mm (205681 => 205682)
--- trunk/Source/WebCore/page/mac/TextIndicatorWindow.mm 2016-09-09 00:55:43 UTC (rev 205681)
+++ trunk/Source/WebCore/page/mac/TextIndicatorWindow.mm 2016-09-09 01:06:47 UTC (rev 205682)
@@ -162,9 +162,9 @@
contentsImageLogicalSize.scale(1 / _textIndicator->contentImageScaleFactor());
RetainPtr<CGImageRef> contentsImage;
if (indicatorWantsContentCrossfade(*_textIndicator))
- contentsImage = _textIndicator->contentImageWithHighlight()->getCGImageRef();
+ contentsImage = _textIndicator->contentImageWithHighlight()->nativeImage();
else
- contentsImage = _textIndicator->contentImage()->getCGImageRef();
+ contentsImage = _textIndicator->contentImage()->nativeImage();
RetainPtr<NSMutableArray> bounceLayers = adoptNS([[NSMutableArray alloc] init]);
@@ -265,7 +265,7 @@
static RetainPtr<CABasicAnimation> createContentCrossfadeAnimation(CFTimeInterval duration, TextIndicator& textIndicator)
{
RetainPtr<CABasicAnimation> crossfadeAnimation = [CABasicAnimation animationWithKeyPath:@"contents"];
- RetainPtr<CGImageRef> contentsImage = textIndicator.contentImage()->getCGImageRef();
+ RetainPtr<CGImageRef> contentsImage = textIndicator.contentImage()->nativeImage();
[crossfadeAnimation setToValue:(id)contentsImage.get()];
[crossfadeAnimation setFillMode:kCAFillModeForwards];
[crossfadeAnimation setRemovedOnCompletion:NO];
Modified: trunk/Source/WebCore/platform/graphics/BitmapImage.cpp (205681 => 205682)
--- trunk/Source/WebCore/platform/graphics/BitmapImage.cpp 2016-09-09 00:55:43 UTC (rev 205681)
+++ trunk/Source/WebCore/platform/graphics/BitmapImage.cpp 2016-09-09 01:06:47 UTC (rev 205682)
@@ -70,11 +70,11 @@
{
// Since we don't have a decoder, we can't figure out the image orientation.
// Set m_sizeRespectingOrientation to be the same as m_size so it's not 0x0.
- m_sizeRespectingOrientation = m_size = NativeImage::size(image);
+ m_sizeRespectingOrientation = m_size = nativeImageSize(image);
m_decodedSize = m_size.area() * 4;
-
+
m_frames.grow(1);
- m_frames[0].m_hasAlpha = NativeImage::hasAlpha(image);
+ m_frames[0].m_hasAlpha = nativeImageHasAlpha(image);
m_frames[0].m_haveMetadata = true;
m_frames[0].m_image = WTFMove(image);
}
@@ -85,18 +85,6 @@
stopAnimation();
}
-void BitmapImage::clearTimer()
-{
- m_frameTimer = nullptr;
-}
-
-void BitmapImage::startTimer(double delay)
-{
- ASSERT(!m_frameTimer);
- m_frameTimer = std::make_unique<Timer>(*this, &BitmapImage::advanceAnimation);
- m_frameTimer->startOneShot(delay);
-}
-
bool BitmapImage::haveFrameImageAtIndex(size_t index)
{
if (index >= frameCount())
@@ -108,11 +96,6 @@
return m_frames[index].m_image;
}
-bool BitmapImage::hasSingleSecurityOrigin() const
-{
- return true;
-}
-
void BitmapImage::destroyDecodedData(bool destroyAll)
{
unsigned frameBytesCleared = 0;
@@ -125,9 +108,7 @@
// The underlying frame isn't actually changing (we're just trying to
// save the memory for the framebuffer data), so we don't need to clear
// the metadata.
- unsigned frameBytes = m_frames[i].m_frameBytes;
- if (m_frames[i].clear(false))
- frameBytesCleared += frameBytes;
+ frameBytesCleared += m_frames[i].clear(false);
}
m_source.clear(destroyAll, clearBeforeFrame, data(), m_allDataReceived);
@@ -150,8 +131,8 @@
return;
unsigned allFrameBytes = 0;
- for (size_t i = 0; i < m_frames.size(); ++i)
- allFrameBytes += m_frames[i].usedFrameBytes();
+ for (auto& frame : m_frames)
+ allFrameBytes += frame.usedFrameBytes();
if (allFrameBytes > largeAnimationCutoff) {
LOG(Images, "BitmapImage %p destroyDecodedDataIfNecessary destroyingData: allFrameBytes=%u cutoff=%u", this, allFrameBytes, largeAnimationCutoff);
@@ -288,13 +269,12 @@
// frame affected by appending new data here. Thus we have to clear all the
// incomplete frames to be safe.
unsigned frameBytesCleared = 0;
- for (size_t i = 0; i < m_frames.size(); ++i) {
+ for (auto& frame : m_frames) {
// NOTE: Don't call frameIsCompleteAtIndex() here, that will try to
// decode any uncached (i.e. never-decoded or
// cleared-on-a-previous-pass) frames!
- unsigned frameBytes = m_frames[i].m_frameBytes;
- if (m_frames[i].m_haveMetadata && !m_frames[i].m_isComplete)
- frameBytesCleared += (m_frames[i].clear(true) ? frameBytes : 0);
+ if (frame.m_haveMetadata && !frame.m_isComplete)
+ frameBytesCleared += frame.clear(true);
}
destroyMetadataAndNotify(frameBytesCleared, ClearedSource::No);
#else
@@ -301,8 +281,7 @@
// FIXME: why is this different for iOS?
int deltaBytes = 0;
if (!m_frames.isEmpty()) {
- int bytes = m_frames[m_frames.size() - 1].m_frameBytes;
- if (m_frames[m_frames.size() - 1].clear(true)) {
+ if (int bytes = m_frames[m_frames.size() - 1].clear(true)) {
deltaBytes += bytes;
deltaBytes += m_decodedPropertiesSize;
m_decodedPropertiesSize = 0;
@@ -337,11 +316,6 @@
return isSizeAvailable();
}
-String BitmapImage::filenameExtension() const
-{
- return m_source.filenameExtension();
-}
-
size_t BitmapImage::frameCount()
{
if (!m_haveFrameCount) {
@@ -366,7 +340,7 @@
return m_sizeAvailable;
}
-bool BitmapImage::ensureFrameIsCached(size_t index, ImageFrameCaching frameCaching)
+bool BitmapImage::ensureFrameAtIndexIsCached(size_t index, ImageFrameCaching frameCaching)
{
if (index >= frameCount())
return false;
@@ -394,8 +368,7 @@
LOG(Images, " subsamplingLevel was %d, resampling", m_frames[index].m_subsamplingLevel);
// If the image is already cached, but at too small a size, re-decode a larger version.
- int sizeChange = -m_frames[index].m_frameBytes;
- m_frames[index].clear(true);
+ int sizeChange = -m_frames[index].clear(true);
invalidatePlatformData();
m_decodedSize += sizeChange;
if (imageObserver())
@@ -408,10 +381,49 @@
return m_frames[index].m_image;
}
+
+NativeImagePtr BitmapImage::nativeImage()
+{
+ return frameImageAtIndex(0);
+}
+NativeImagePtr BitmapImage::nativeImageForCurrentFrame()
+{
+ return frameImageAtIndex(m_currentFrame);
+}
+
+#if USE(CG)
+NativeImagePtr BitmapImage::nativeImageOfSize(const IntSize& size)
+{
+ size_t count = frameCount();
+
+ for (size_t i = 0; i < count; ++i) {
+ auto image = frameImageAtIndex(i);
+ if (image && nativeImageSize(image) == size)
+ return image;
+ }
+
+ // Fallback to the first frame image if we can't find the right size
+ return frameImageAtIndex(0);
+}
+
+Vector<NativeImagePtr> BitmapImage::framesNativeImages()
+{
+ Vector<NativeImagePtr> images;
+ size_t count = frameCount();
+
+ for (size_t i = 0; i < count; ++i) {
+ if (auto image = frameImageAtIndex(i))
+ images.append(image);
+ }
+
+ return images;
+}
+#endif
+
bool BitmapImage::frameIsCompleteAtIndex(size_t index)
{
- if (!ensureFrameIsCached(index, CacheMetadataOnly))
+ if (!ensureFrameAtIndexIsCached(index, CacheMetadataOnly))
return false;
return m_frames[index].m_isComplete;
@@ -419,20 +431,15 @@
float BitmapImage::frameDurationAtIndex(size_t index)
{
- if (!ensureFrameIsCached(index, CacheMetadataOnly))
+ if (!ensureFrameAtIndexIsCached(index, CacheMetadataOnly))
return 0;
return m_frames[index].m_duration;
}
-NativeImagePtr BitmapImage::nativeImageForCurrentFrame()
-{
- return frameImageAtIndex(currentFrame());
-}
-
bool BitmapImage::frameHasAlphaAtIndex(size_t index)
{
- if (!ensureFrameIsCached(index, CacheMetadataOnly))
+ if (!ensureFrameAtIndexIsCached(index, CacheMetadataOnly))
return true;
if (m_frames[index].m_haveMetadata)
@@ -448,7 +455,7 @@
ImageOrientation BitmapImage::frameOrientationAtIndex(size_t index)
{
- if (!ensureFrameIsCached(index, CacheMetadataOnly))
+ if (!ensureFrameAtIndexIsCached(index, CacheMetadataOnly))
return ImageOrientation();
if (m_frames[index].m_haveMetadata)
@@ -457,6 +464,32 @@
return m_source.orientationAtIndex(index);
}
+Color BitmapImage::singlePixelSolidColor()
+{
+ // If the image size is not available yet or if the image will be animating don't use the solid color optimization.
+ if (frameCount() != 1)
+ return Color();
+
+ if (m_solidColor)
+ return m_solidColor.value();
+
+ // If the frame image is not loaded, first use the decoder to get the size of the image.
+ if (!haveFrameImageAtIndex(0) && m_source.frameSizeAtIndex(0) != IntSize(1, 1)) {
+ m_solidColor = Color();
+ return m_solidColor.value();
+ }
+
+ // Cache the frame image. The size will be calculated from the NativeImagePtr.
+ if (!ensureFrameAtIndexIsCached(0))
+ return Color();
+
+ ASSERT(m_frames.size());
+ m_solidColor = nativeImageSinglePixelSolidColor(m_frames[0].m_image);
+
+ ASSERT(m_solidColor);
+ return m_solidColor.value();
+}
+
#if !ASSERT_DISABLED
bool BitmapImage::notSolidColor()
{
@@ -478,11 +511,93 @@
return m_repetitionCount;
}
+void BitmapImage::draw(GraphicsContext& context, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator op, BlendMode mode, ImageOrientationDescription description)
+{
+ if (destRect.isEmpty() || srcRect.isEmpty())
+ return;
+
+#if PLATFORM(IOS)
+ startAnimation(DoNotCatchUp);
+#else
+ startAnimation();
+#endif
+
+ Color color = singlePixelSolidColor();
+ if (color.isValid()) {
+ fillWithSolidColor(context, destRect, color, op);
+ return;
+ }
+
+ auto image = frameImageAtIndex(m_currentFrame, subsamplingScale(context, destRect, srcRect));
+ if (!image) // If it's too early we won't have an image yet.
+ return;
+
+ ImageOrientation orientation(description.imageOrientation());
+ if (description.respectImageOrientation() == RespectImageOrientation)
+ orientation = frameOrientationAtIndex(m_currentFrame);
+
+ drawNativeImage(image, context, destRect, srcRect, m_size, op, mode, orientation);
+
+ if (imageObserver())
+ imageObserver()->didDraw(this);
+}
+
+void BitmapImage::drawPattern(GraphicsContext& ctxt, const FloatRect& tileRect, const AffineTransform& transform, const FloatPoint& phase, const FloatSize& spacing, CompositeOperator op, const FloatRect& destRect, BlendMode blendMode)
+{
+ if (tileRect.isEmpty())
+ return;
+
+ if (!ctxt.drawLuminanceMask()) {
+ Image::drawPattern(ctxt, tileRect, transform, phase, spacing, op, destRect, blendMode);
+ return;
+ }
+
+ if (!m_cachedImage) {
+ auto buffer = ImageBuffer::createCompatibleBuffer(expandedIntSize(tileRect.size()), ColorSpaceSRGB, ctxt);
+ if (!buffer)
+ return;
+
+ ImageObserver* observer = imageObserver();
+
+ // Temporarily reset image observer, we don't want to receive any changeInRect() calls due to this relayout.
+ setImageObserver(nullptr);
+
+ draw(buffer->context(), tileRect, tileRect, op, blendMode, ImageOrientationDescription());
+
+ setImageObserver(observer);
+ buffer->convertToLuminanceMask();
+
+ m_cachedImage = buffer->copyImage(DontCopyBackingStore, Unscaled);
+ if (!m_cachedImage)
+ return;
+ }
+
+ ctxt.setDrawLuminanceMask(false);
+ m_cachedImage->drawPattern(ctxt, tileRect, transform, phase, spacing, op, destRect, blendMode);
+}
+
bool BitmapImage::shouldAnimate()
{
return (repetitionCount(false) != cAnimationNone && !m_animationFinished && imageObserver());
}
+bool BitmapImage::canAnimate()
+{
+ return shouldAnimate() && frameCount() > 1;
+}
+
+void BitmapImage::clearTimer()
+{
+ m_frameTimer = nullptr;
+}
+
+void BitmapImage::startTimer(double delay)
+{
+ ASSERT(!m_frameTimer);
+ m_frameTimer = std::make_unique<Timer>(*this, &BitmapImage::advanceAnimation);
+ m_frameTimer->startOneShot(delay);
+}
+
void BitmapImage::startAnimation(CatchUpAnimation catchUpIfNecessary)
{
if (m_frameTimer || !shouldAnimate() || frameCount() <= 1)
@@ -580,60 +695,6 @@
startTimer(0);
}
-void BitmapImage::stopAnimation()
-{
- // This timer is used to animate all occurrences of this image. Don't invalidate
- // the timer unless all renderers have stopped drawing.
- clearTimer();
-}
-
-void BitmapImage::resetAnimation()
-{
- stopAnimation();
- m_currentFrame = 0;
- m_repetitionsComplete = 0;
- m_desiredFrameStartTime = 0;
- m_animationFinished = false;
-
- // For extremely large animations, when the animation is reset, we just throw everything away.
- destroyDecodedDataIfNecessary(true);
-}
-
-void BitmapImage::drawPattern(GraphicsContext& ctxt, const FloatRect& tileRect, const AffineTransform& transform,
- const FloatPoint& phase, const FloatSize& spacing, CompositeOperator op, const FloatRect& destRect, BlendMode blendMode)
-{
- if (tileRect.isEmpty())
- return;
-
- if (!ctxt.drawLuminanceMask()) {
- Image::drawPattern(ctxt, tileRect, transform, phase, spacing, op, destRect, blendMode);
- return;
- }
- if (!m_cachedImage) {
- auto buffer = ImageBuffer::createCompatibleBuffer(expandedIntSize(tileRect.size()), ColorSpaceSRGB, ctxt);
- if (!buffer)
- return;
-
- ImageObserver* observer = imageObserver();
-
- // Temporarily reset image observer, we don't want to receive any changeInRect() calls due to this relayout.
- setImageObserver(nullptr);
-
- draw(buffer->context(), tileRect, tileRect, op, blendMode, ImageOrientationDescription());
-
- setImageObserver(observer);
- buffer->convertToLuminanceMask();
-
- m_cachedImage = buffer->copyImage(DontCopyBackingStore, Unscaled);
- if (!m_cachedImage)
- return;
- }
-
- ctxt.setDrawLuminanceMask(false);
- m_cachedImage->drawPattern(ctxt, tileRect, transform, phase, spacing, op, destRect, blendMode);
-}
-
-
void BitmapImage::advanceAnimation()
{
internalAdvanceAnimation();
@@ -683,36 +744,24 @@
return advancedAnimation;
}
-Color BitmapImage::singlePixelSolidColor()
+void BitmapImage::stopAnimation()
{
- // If the image size is not available yet or if the image will be animating don't use the solid color optimization.
- if (frameCount() != 1)
- return Color();
-
- if (m_solidColor)
- return m_solidColor.value();
+ // This timer is used to animate all occurrences of this image. Don't invalidate
+ // the timer unless all renderers have stopped drawing.
+ clearTimer();
+}
- // If the frame image is not loaded, first use the decoder to get the size of the image.
- if (!haveFrameImageAtIndex(0) && m_source.frameSizeAtIndex(0, 0) != IntSize(1, 1)) {
- m_solidColor = Color();
- return m_solidColor.value();
- }
+void BitmapImage::resetAnimation()
+{
+ stopAnimation();
+ m_currentFrame = 0;
+ m_repetitionsComplete = 0;
+ m_desiredFrameStartTime = 0;
+ m_animationFinished = false;
- // Cache the frame image. The size will be calculated from the NativeImagePtr.
- if (!ensureFrameIsCached(0))
- return Color();
-
- ASSERT(m_frames.size());
- m_solidColor = NativeImage::singlePixelSolidColor(m_frames[0].m_image.get());
-
- ASSERT(m_solidColor);
- return m_solidColor.value();
+ // For extremely large animations, when the animation is reset, we just throw everything away.
+ destroyDecodedDataIfNecessary(true);
}
-
-bool BitmapImage::canAnimate()
-{
- return shouldAnimate() && frameCount() > 1;
-}
void BitmapImage::dump(TextStream& ts) const
{
Modified: trunk/Source/WebCore/platform/graphics/BitmapImage.h (205681 => 205682)
--- trunk/Source/WebCore/platform/graphics/BitmapImage.h 2016-09-09 00:55:43 UTC (rev 205681)
+++ trunk/Source/WebCore/platform/graphics/BitmapImage.h 2016-09-09 01:06:47 UTC (rev 205682)
@@ -47,25 +47,9 @@
#endif
namespace WebCore {
- struct FrameData;
-}
-namespace WTF {
- template<> struct VectorTraits<WebCore::FrameData> : public SimpleClassVectorTraits {
- static const bool canInitializeWithMemset = false; // Not all FrameData members initialize to 0.
- };
-}
-
-namespace WebCore {
-
class Timer;
-namespace NativeImage {
- IntSize size(const NativeImagePtr&);
- bool hasAlpha(const NativeImagePtr&);
- Color singlePixelSolidColor(const NativeImagePtr&);
-}
-
// ================================================
// FrameData Class
// ================================================
@@ -75,24 +59,33 @@
FrameData()
: m_haveMetadata(false)
, m_isComplete(false)
- , m_hasAlpha(true)
+ , m_hasAlpha(false)
{
}
~FrameData()
- {
- clear(true);
+ {
+ clearNativeImageSubImages(m_image);
}
- // Clear the cached image data on the frame, and (optionally) the metadata.
- // Returns whether there was cached image data to clear.
- bool clear(bool clearMetadata);
+ unsigned clear(bool clearMetadata)
+ {
+ unsigned frameBytes = usedFrameBytes();
+
+ if (clearMetadata)
+ m_haveMetadata = false;
+
+ m_subsamplingLevel = DefaultSubsamplingLevel;
+ m_image = nullptr;
+
+ return frameBytes;
+ }
unsigned usedFrameBytes() const { return m_image ? m_frameBytes : 0; }
NativeImagePtr m_image;
ImageOrientation m_orientation { DefaultImageOrientation };
- SubsamplingLevel m_subsamplingLevel { 0 };
+ SubsamplingLevel m_subsamplingLevel { DefaultSubsamplingLevel };
float m_duration { 0 };
bool m_haveMetadata : 1;
bool m_isComplete : 1;
@@ -105,10 +98,6 @@
// =================================================
class BitmapImage final : public Image {
- friend class GeneratedImage;
- friend class CrossfadeGeneratedImage;
- friend class GradientImage;
- friend class GraphicsContext;
public:
static Ref<BitmapImage> create(NativeImagePtr&& nativeImage, ImageObserver* observer = nullptr)
{
@@ -123,7 +112,7 @@
#endif
virtual ~BitmapImage();
- bool hasSingleSecurityOrigin() const override;
+ bool hasSingleSecurityOrigin() const override { return true; }
// FloatSize due to override.
FloatSize size() const override;
@@ -134,7 +123,7 @@
unsigned decodedSize() const { return m_decodedSize; }
bool dataChanged(bool allDataReceived) override;
- String filenameExtension() const override;
+ String filenameExtension() const override { return m_source.filenameExtension(); }
// It may look unusual that there is no start animation call as public API. This is because
// we start and stop animating lazily. Animation begins whenever someone draws the image. It will
@@ -155,12 +144,6 @@
CFDataRef getTIFFRepresentation() override;
#endif
-#if USE(CG)
- WEBCORE_EXPORT CGImageRef getCGImageRef() override;
- CGImageRef getFirstCGImageRefOfSize(const IntSize&) override;
- RetainPtr<CFArrayRef> getCGImageArray() override;
-#endif
-
#if PLATFORM(WIN)
bool getHBITMAP(HBITMAP) override;
bool getHBITMAPOfSize(HBITMAP, const IntSize*) override;
@@ -174,7 +157,12 @@
Evas_Object* getEvasObject(Evas*) override;
#endif
+ WEBCORE_EXPORT NativeImagePtr nativeImage() override;
NativeImagePtr nativeImageForCurrentFrame() override;
+#if USE(CG)
+ NativeImagePtr nativeImageOfSize(const IntSize&) override;
+ Vector<NativeImagePtr> framesNativeImages() override;
+#endif
ImageOrientation orientationForCurrentFrame() override { return frameOrientationAtIndex(currentFrame()); }
bool currentFrameKnownToBeOpaque() override;
@@ -215,7 +203,6 @@
size_t frameCount();
NativeImagePtr frameImageAtIndex(size_t, float presentationScaleHint = 1);
- NativeImagePtr copyUnscaledFrameImageAtIndex(size_t);
bool haveFrameImageAtIndex(size_t);
@@ -229,7 +216,7 @@
void cacheFrame(size_t index, SubsamplingLevel, ImageFrameCaching = CacheMetadataAndFrame);
// Called before accessing m_frames[index] for info without decoding. Returns false on index out of bounds.
- bool ensureFrameIsCached(size_t index, ImageFrameCaching = CacheMetadataAndFrame);
+ bool ensureFrameAtIndexIsCached(size_t index, ImageFrameCaching = CacheMetadataAndFrame);
// Called to invalidate cached data. When |destroyAll| is true, we wipe out
// the entire frame buffer cache and tell the image source to destroy
Modified: trunk/Source/WebCore/platform/graphics/Icon.h (205681 => 205682)
--- trunk/Source/WebCore/platform/graphics/Icon.h 2016-09-09 00:55:43 UTC (rev 205681)
+++ trunk/Source/WebCore/platform/graphics/Icon.h 2016-09-09 01:06:47 UTC (rev 205682)
@@ -28,7 +28,7 @@
#include <wtf/Vector.h>
#if PLATFORM(IOS)
-#include "NativeImagePtr.h"
+#include "NativeImage.h"
#include <CoreGraphics/CoreGraphics.h>
#elif PLATFORM(MAC)
OBJC_CLASS NSImage;
Modified: trunk/Source/WebCore/platform/graphics/Image.h (205681 => 205682)
--- trunk/Source/WebCore/platform/graphics/Image.h 2016-09-09 00:55:43 UTC (rev 205681)
+++ trunk/Source/WebCore/platform/graphics/Image.h 2016-09-09 01:06:47 UTC (rev 205682)
@@ -32,7 +32,7 @@
#include "FloatSize.h"
#include "GraphicsTypes.h"
#include "ImageOrientation.h"
-#include "NativeImagePtr.h"
+#include "NativeImage.h"
#include <wtf/Optional.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
@@ -137,8 +137,11 @@
enum TileRule { StretchTile, RoundTile, SpaceTile, RepeatTile };
+ virtual NativeImagePtr nativeImage() { return nullptr; }
+ virtual NativeImagePtr nativeImageOfSize(const IntSize&) { return nullptr; }
virtual NativeImagePtr nativeImageForCurrentFrame() { return nullptr; }
virtual ImageOrientation orientationForCurrentFrame() { return ImageOrientation(); }
+ virtual Vector<NativeImagePtr> framesNativeImages() { return { }; }
// Accessors for native image formats.
@@ -150,12 +153,6 @@
virtual CFDataRef getTIFFRepresentation() { return nullptr; }
#endif
-#if USE(CG)
- virtual CGImageRef getCGImageRef() { return nullptr; }
- virtual CGImageRef getFirstCGImageRefOfSize(const IntSize&) { return nullptr; }
- virtual RetainPtr<CFArrayRef> getCGImageArray() { return nullptr; }
-#endif
-
#if PLATFORM(WIN)
virtual bool getHBITMAP(HBITMAP) { return false; }
virtual bool getHBITMAPOfSize(HBITMAP, const IntSize*) { return false; }
Modified: trunk/Source/WebCore/platform/graphics/ImageSource.cpp (205681 => 205682)
--- trunk/Source/WebCore/platform/graphics/ImageSource.cpp 2016-09-09 00:55:43 UTC (rev 205681)
+++ trunk/Source/WebCore/platform/graphics/ImageSource.cpp 2016-09-09 01:06:47 UTC (rev 205682)
@@ -94,20 +94,19 @@
SubsamplingLevel ImageSource::calculateMaximumSubsamplingLevel() const
{
if (!m_allowSubsampling || !allowSubsamplingOfFrameAtIndex(0))
- return 0;
+ return DefaultSubsamplingLevel;
// FIXME: this value was chosen to be appropriate for iOS since the image
// subsampling is only enabled by default on iOS. Choose a different value
// if image subsampling is enabled on other platform.
const int maximumImageAreaBeforeSubsampling = 5 * 1024 * 1024;
- const SubsamplingLevel maxSubsamplingLevel = 3;
-
- for (SubsamplingLevel level = 0; level < maxSubsamplingLevel; ++level) {
+
+ for (SubsamplingLevel level = MinSubsamplingLevel; level < MaxSubsamplingLevel; ++level) {
if (frameSizeAtIndex(0, level).area() < maximumImageAreaBeforeSubsampling)
return level;
}
- return maxSubsamplingLevel;
+ return MaxSubsamplingLevel;
}
void ImageSource::updateMetadata()
@@ -148,12 +147,12 @@
IntSize ImageSource::size() const
{
- return frameSizeAtIndex(0, 0);
+ return frameSizeAtIndex(0, DefaultSubsamplingLevel);
}
IntSize ImageSource::sizeRespectingOrientation() const
{
- return frameSizeAtIndex(0, 0, RespectImageOrientation);
+ return frameSizeAtIndex(0, DefaultSubsamplingLevel, RespectImageOrientation);
}
size_t ImageSource::frameCount()
Modified: trunk/Source/WebCore/platform/graphics/ImageSource.h (205681 => 205682)
--- trunk/Source/WebCore/platform/graphics/ImageSource.h 2016-09-09 00:55:43 UTC (rev 205681)
+++ trunk/Source/WebCore/platform/graphics/ImageSource.h 2016-09-09 01:06:47 UTC (rev 205682)
@@ -29,7 +29,7 @@
#include "ImageOrientation.h"
#include "IntPoint.h"
-#include "NativeImagePtr.h"
+#include "NativeImage.h"
#include "TextStream.h"
#include <wtf/Forward.h>
#include <wtf/Noncopyable.h>
@@ -62,8 +62,15 @@
const int cAnimationNone = -2;
// SubsamplingLevel. 0 is no subsampling, 1 is half dimensions on each axis etc.
-typedef short SubsamplingLevel;
+using SubsamplingLevel = int;
+enum : SubsamplingLevel {
+ NilSubsamplingLevel = -1,
+ MinSubsamplingLevel = 0,
+ MaxSubsamplingLevel = 3,
+ DefaultSubsamplingLevel = MinSubsamplingLevel
+};
+
class ImageSource {
WTF_MAKE_NONCOPYABLE(ImageSource);
friend class BitmapImage;
@@ -130,11 +137,11 @@
bool allowSubsamplingOfFrameAtIndex(size_t) const;
// Size of optionally subsampled frame.
- IntSize frameSizeAtIndex(size_t, SubsamplingLevel = 0, RespectImageOrientationEnum = DoNotRespectImageOrientation) const;
+ IntSize frameSizeAtIndex(size_t, SubsamplingLevel = DefaultSubsamplingLevel, RespectImageOrientationEnum = DoNotRespectImageOrientation) const;
// Return the number of bytes in the decoded frame. If the frame is not yet
// decoded then return 0.
- unsigned frameBytesAtIndex(size_t, SubsamplingLevel = 0) const;
+ unsigned frameBytesAtIndex(size_t, SubsamplingLevel = DefaultSubsamplingLevel) const;
float frameDurationAtIndex(size_t);
ImageOrientation orientationAtIndex(size_t) const; // EXIF image orientation
@@ -141,7 +148,7 @@
// Callers should not call this after calling clear() with a higher index;
// see comments on clear() above.
- NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = 0);
+ NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = DefaultSubsamplingLevel);
private:
void clearFrameBufferCache(size_t);
@@ -153,7 +160,7 @@
bool m_needsUpdateMetadata { false };
size_t m_frameCount { 0 };
- Optional<SubsamplingLevel> m_maximumSubsamplingLevel { 0 };
+ Optional<SubsamplingLevel> m_maximumSubsamplingLevel { DefaultSubsamplingLevel };
// The default value of m_allowSubsampling should be the same as defaultImageSubsamplingEnabled in Settings.cpp
#if PLATFORM(IOS)
Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.h (205681 => 205682)
--- trunk/Source/WebCore/platform/graphics/MediaPlayer.h 2016-09-09 00:55:43 UTC (rev 205681)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.h 2016-09-09 01:06:47 UTC (rev 205682)
@@ -36,7 +36,7 @@
#include "URL.h"
#include "LayoutRect.h"
#include "MediaPlayerEnums.h"
-#include "NativeImagePtr.h"
+#include "NativeImage.h"
#include "PlatformLayer.h"
#include "PlatformMediaResourceLoader.h"
#include "PlatformMediaSession.h"
Copied: trunk/Source/WebCore/platform/graphics/NativeImage.h (from rev 205681, trunk/Source/WebCore/platform/graphics/NativeImagePtr.h) (0 => 205682)
--- trunk/Source/WebCore/platform/graphics/NativeImage.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/NativeImage.h 2016-09-09 01:06:47 UTC (rev 205682)
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2004, 2005, 2006, 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2007-2008 Torch Mobile, Inc.
+ * Copyright (C) 2012 Company 100 Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "GraphicsTypes.h"
+#include "ImageOrientation.h"
+
+#if USE(CG)
+#include <wtf/RetainPtr.h>
+typedef struct CGImage* CGImageRef;
+#elif USE(CAIRO)
+#include "RefPtrCairo.h"
+#elif USE(WINGDI)
+#include "SharedBitmap.h"
+#endif
+
+namespace WebCore {
+
+class Color;
+class FloatRect;
+class IntSize;
+class GraphicsContext;
+
+#if USE(CG)
+typedef RetainPtr<CGImageRef> NativeImagePtr;
+#elif USE(CAIRO)
+typedef RefPtr<cairo_surface_t> NativeImagePtr;
+#elif USE(WINGDI)
+typedef RefPtr<SharedBitmap> NativeImagePtr;
+#endif
+
+IntSize nativeImageSize(const NativeImagePtr&);
+bool nativeImageHasAlpha(const NativeImagePtr&);
+Color nativeImageSinglePixelSolidColor(const NativeImagePtr&);
+
+float subsamplingScale(GraphicsContext&, const FloatRect& destRect, const FloatRect& srcRect);
+
+void drawNativeImage(const NativeImagePtr&, GraphicsContext&, const FloatRect&, const FloatRect&, const IntSize&, CompositeOperator, BlendMode, const ImageOrientation&);
+void clearNativeImageSubImages(const NativeImagePtr&);
+
+}
Deleted: trunk/Source/WebCore/platform/graphics/NativeImagePtr.h (205681 => 205682)
--- trunk/Source/WebCore/platform/graphics/NativeImagePtr.h 2016-09-09 00:55:43 UTC (rev 205681)
+++ trunk/Source/WebCore/platform/graphics/NativeImagePtr.h 2016-09-09 01:06:47 UTC (rev 205682)
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2006 Apple Inc. All rights reserved.
- * Copyright (C) 2007-2008 Torch Mobile, Inc.
- * Copyright (C) 2012 Company 100 Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef NativeImagePtr_h
-#define NativeImagePtr_h
-
-#if USE(CG)
-#include <wtf/RetainPtr.h>
-typedef struct CGImage* CGImageRef;
-#elif USE(CAIRO)
-#include "RefPtrCairo.h"
-#elif USE(WINGDI)
-#include "SharedBitmap.h"
-#endif
-
-namespace WebCore {
-
-#if USE(CG)
-typedef RetainPtr<CGImageRef> NativeImagePtr;
-#elif USE(CAIRO)
-typedef RefPtr<cairo_surface_t> NativeImagePtr;
-#elif USE(WINGDI)
-typedef RefPtr<SharedBitmap> NativeImagePtr;
-#endif
-
-}
-
-#endif
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm (205681 => 205682)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm 2016-09-09 00:55:43 UTC (rev 205681)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm 2016-09-09 01:06:47 UTC (rev 205682)
@@ -297,7 +297,7 @@
if (!image)
return;
- m_pausedImage = image->getCGImageRef();
+ m_pausedImage = image->nativeImage();
ASSERT(m_pausedImage);
}
Deleted: trunk/Source/WebCore/platform/graphics/cairo/BitmapImageCairo.cpp (205681 => 205682)
--- trunk/Source/WebCore/platform/graphics/cairo/BitmapImageCairo.cpp 2016-09-09 00:55:43 UTC (rev 205681)
+++ trunk/Source/WebCore/platform/graphics/cairo/BitmapImageCairo.cpp 2016-09-09 01:06:47 UTC (rev 205682)
@@ -1,142 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2006 Apple Inc. All rights reserved.
- * Copyright (C) 2007 Alp Toker <[email protected]>
- * Copyright (C) 2009 Dirk Schulze <[email protected]>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "BitmapImage.h"
-
-#if USE(CAIRO)
-
-#include "CairoUtilities.h"
-#include "ImageObserver.h"
-#include "PlatformContextCairo.h"
-#include "Timer.h"
-#include <cairo.h>
-
-namespace WebCore {
-
-namespace NativeImage {
-
-IntSize size(const RefPtr<cairo_surface_t>& image)
-{
- return cairoSurfaceSize(image.get());
-}
-
-bool hasAlpha(const RefPtr<cairo_surface_t>& image)
-{
- return cairo_surface_get_content(image.get()) != CAIRO_CONTENT_COLOR;
-}
-
-Color singlePixelSolidColor(const RefPtr<cairo_surface_t>& image)
-{
- ASSERT(image);
-
- if (NativeImage::size(image) != IntSize(1, 1))
- return Color();
-
- if (cairo_surface_get_type(image.get()) != CAIRO_SURFACE_TYPE_IMAGE)
- return Color();
-
- RGBA32* pixel = reinterpret_cast_ptr<RGBA32*>(cairo_image_surface_get_data(image.get()));
- return colorFromPremultipliedARGB(*pixel);
-}
-
-}
-
-void BitmapImage::draw(GraphicsContext& context, const FloatRect& dst, const FloatRect& src, CompositeOperator op,
- BlendMode blendMode, ImageOrientationDescription description)
-{
- if (!dst.width() || !dst.height() || !src.width() || !src.height())
- return;
-
- startAnimation();
-
- auto surface = frameImageAtIndex(m_currentFrame);
- if (!surface) // If it's too early we won't have an image yet.
- return;
-
- Color color = singlePixelSolidColor();
- if (color.isValid()) {
- fillWithSolidColor(context, dst, color, op);
- return;
- }
-
- context.save();
-
- // Set the compositing operation.
- if (op == CompositeSourceOver && blendMode == BlendModeNormal && !frameHasAlphaAtIndex(m_currentFrame))
- context.setCompositeOperation(CompositeCopy);
- else
- context.setCompositeOperation(op, blendMode);
-
-#if ENABLE(IMAGE_DECODER_DOWN_SAMPLING)
- IntSize scaledSize = cairoSurfaceSize(surface.get());
- FloatRect adjustedSrcRect = adjustSourceRectForDownSampling(src, scaledSize);
-#else
- FloatRect adjustedSrcRect(src);
-#endif
-
- ImageOrientation frameOrientation(description.imageOrientation());
- if (description.respectImageOrientation() == RespectImageOrientation)
- frameOrientation = frameOrientationAtIndex(m_currentFrame);
-
- FloatRect dstRect = dst;
-
- if (frameOrientation != DefaultImageOrientation) {
- // ImageOrientation expects the origin to be at (0, 0).
- context.translate(dstRect.x(), dstRect.y());
- dstRect.setLocation(FloatPoint());
- context.concatCTM(frameOrientation.transformFromDefault(dstRect.size()));
- if (frameOrientation.usesWidthAsHeight()) {
- // The destination rectangle will have it's width and height already reversed for the orientation of
- // the image, as it was needed for page layout, so we need to reverse it back here.
- dstRect = FloatRect(dstRect.x(), dstRect.y(), dstRect.height(), dstRect.width());
- }
- }
-
- context.platformContext()->drawSurfaceToContext(surface.get(), dstRect, adjustedSrcRect, context);
-
- context.restore();
-
- if (imageObserver())
- imageObserver()->didDraw(this);
-}
-
-bool FrameData::clear(bool clearMetadata)
-{
- if (clearMetadata)
- m_haveMetadata = false;
-
- if (m_image) {
- m_image = nullptr;
- return true;
- }
- return false;
-}
-
-} // namespace WebCore
-
-#endif // USE(CAIRO)
Added: trunk/Source/WebCore/platform/graphics/cairo/NativeImageCairo.cpp (0 => 205682)
--- trunk/Source/WebCore/platform/graphics/cairo/NativeImageCairo.cpp (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cairo/NativeImageCairo.cpp 2016-09-09 01:06:47 UTC (rev 205682)
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "NativeImage.h"
+
+#if USE(CAIRO)
+
+#include "CairoUtilities.h"
+#include "PlatformContextCairo.h"
+#include <cairo.h>
+
+namespace WebCore {
+
+IntSize nativeImageSize(const NativeImagePtr& image)
+{
+ return image ? cairoSurfaceSize(image.get()) : IntSize();
+}
+
+bool nativeImageHasAlpha(const NativeImagePtr& image)
+{
+ return !image || cairo_surface_get_content(image.get()) != CAIRO_CONTENT_COLOR;
+}
+
+Color nativeImageSinglePixelSolidColor(const NativeImagePtr& image)
+{
+ if (!image || nativeImageSize(image) != IntSize(1, 1))
+ return Color();
+
+ if (cairo_surface_get_type(image.get()) != CAIRO_SURFACE_TYPE_IMAGE)
+ return Color();
+
+ RGBA32* pixel = reinterpret_cast_ptr<RGBA32*>(cairo_image_surface_get_data(image.get()));
+ return colorFromPremultipliedARGB(*pixel);
+}
+
+float subsamplingScale(GraphicsContext&, const FloatRect&, const FloatRect&)
+{
+ return 1;
+}
+
+void drawNativeImage(const NativeImagePtr& image, GraphicsContext& context, const FloatRect& destRect, const FloatRect& srcRect, const IntSize&, CompositeOperator op, BlendMode mode, const ImageOrientation& orientation)
+{
+ context.save();
+
+ // Set the compositing operation.
+ if (op == CompositeSourceOver && mode == BlendModeNormal && !nativeImageHasAlpha(image))
+ context.setCompositeOperation(CompositeCopy);
+ else
+ context.setCompositeOperation(op, mode);
+
+#if ENABLE(IMAGE_DECODER_DOWN_SAMPLING)
+ IntSize scaledSize = nativeImageSize(image);
+ FloatRect adjustedSrcRect = adjustSourceRectForDownSampling(srcRect, scaledSize);
+#else
+ FloatRect adjustedSrcRect(srcRect);
+#endif
+
+ FloatRect adjustedDestRect = destRect;
+
+ if (orientation != DefaultImageOrientation) {
+ // ImageOrientation expects the origin to be at (0, 0).
+ context.translate(destRect.x(), destRect.y());
+ adjustedDestRect.setLocation(FloatPoint());
+ context.concatCTM(orientation.transformFromDefault(adjustedDestRect.size()));
+ if (orientation.usesWidthAsHeight()) {
+ // The destination rectangle will have it's width and height already reversed for the orientation of
+ // the image, as it was needed for page layout, so we need to reverse it back here.
+ adjustedDestRect.setSize(adjustedDestRect.size().transposedSize());
+ }
+ }
+
+ context.platformContext()->drawSurfaceToContext(image.get(), adjustedDestRect, adjustedSrcRect, context);
+ context.restore();
+}
+
+void clearNativeImageSubImages(const NativeImagePtr&)
+{
+}
+
+} // namespace WebCore
+
+#endif // USE(CAIRO)
Deleted: trunk/Source/WebCore/platform/graphics/cg/BitmapImageCG.cpp (205681 => 205682)
--- trunk/Source/WebCore/platform/graphics/cg/BitmapImageCG.cpp 2016-09-09 00:55:43 UTC (rev 205681)
+++ trunk/Source/WebCore/platform/graphics/cg/BitmapImageCG.cpp 2016-09-09 01:06:47 UTC (rev 205682)
@@ -1,206 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2006 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "BitmapImage.h"
-
-#if USE(CG)
-
-#include "CoreGraphicsSPI.h"
-#include "FloatConversion.h"
-#include "GeometryUtilities.h"
-#include "GraphicsContextCG.h"
-#include "ImageObserver.h"
-#include "SubimageCacheWithTimer.h"
-#include <wtf/RetainPtr.h>
-
-#if USE(APPKIT)
-#include <ApplicationServices/ApplicationServices.h>
-#endif
-
-#if PLATFORM(COCOA)
-#include "WebCoreSystemInterface.h"
-#endif
-
-#if PLATFORM(WIN)
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
-#endif
-
-namespace WebCore {
-
-namespace NativeImage {
-
-IntSize size(const RetainPtr<CGImageRef>& image)
-{
- ASSERT(image);
- return IntSize(CGImageGetWidth(image.get()), CGImageGetHeight(image.get()));
-}
-
-bool hasAlpha(const RetainPtr<CGImageRef>&)
-{
- // FIXME: Answer correctly the question: does the CGImageRef have alpha channnel?
- return true;
-}
-
-Color singlePixelSolidColor(const RetainPtr<CGImageRef>& image)
-{
- ASSERT(image);
-
- if (NativeImage::size(image) != IntSize(1, 1))
- return Color();
-
- unsigned char pixel[4]; // RGBA
- auto bitmapContext = adoptCF(CGBitmapContextCreate(pixel, 1, 1, 8, sizeof(pixel), sRGBColorSpaceRef(),
- kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big));
-
- if (!bitmapContext)
- return Color();
-
- CGContextSetBlendMode(bitmapContext.get(), kCGBlendModeCopy);
- CGContextDrawImage(bitmapContext.get(), CGRectMake(0, 0, 1, 1), image.get());
-
- if (!pixel[3])
- return Color(0, 0, 0, 0);
-
- return Color(pixel[0] * 255 / pixel[3], pixel[1] * 255 / pixel[3], pixel[2] * 255 / pixel[3], pixel[3]);
-}
-
-}
-
-bool FrameData::clear(bool clearMetadata)
-{
- if (clearMetadata)
- m_haveMetadata = false;
-
- m_subsamplingLevel = 0;
-
- if (m_image) {
-#if CACHE_SUBIMAGES
- subimageCache().clearImage(m_image.get());
-#endif
- m_image = nullptr;
- return true;
- }
- return false;
-}
-
-CGImageRef BitmapImage::getCGImageRef()
-{
- return frameImageAtIndex(0).get();
-}
-
-CGImageRef BitmapImage::getFirstCGImageRefOfSize(const IntSize& size)
-{
- size_t count = frameCount();
- for (size_t i = 0; i < count; ++i) {
- CGImageRef cgImage = frameImageAtIndex(i).get();
- if (cgImage && IntSize(CGImageGetWidth(cgImage), CGImageGetHeight(cgImage)) == size)
- return cgImage;
- }
-
- // Fallback to the default CGImageRef if we can't find the right size
- return getCGImageRef();
-}
-
-RetainPtr<CFArrayRef> BitmapImage::getCGImageArray()
-{
- size_t count = frameCount();
- if (!count)
- return nullptr;
-
- CFMutableArrayRef array = CFArrayCreateMutable(NULL, count, &kCFTypeArrayCallBacks);
- for (size_t i = 0; i < count; ++i) {
- if (CGImageRef currFrame = frameImageAtIndex(i).get())
- CFArrayAppendValue(array, currFrame);
- }
- return adoptCF(array);
-}
-
-void BitmapImage::draw(GraphicsContext& ctxt, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator compositeOp, BlendMode blendMode, ImageOrientationDescription description)
-{
-#if PLATFORM(IOS)
- startAnimation(DoNotCatchUp);
-#else
- startAnimation();
-#endif
-
- RetainPtr<CGImageRef> image;
- // Never use subsampled images for drawing into PDF contexts.
- if (wkCGContextIsPDFContext(ctxt.platformContext()))
- image = copyUnscaledFrameImageAtIndex(m_currentFrame);
- else {
- CGRect transformedDestinationRect = CGRectApplyAffineTransform(destRect, CGContextGetCTM(ctxt.platformContext()));
- float subsamplingScale = std::min<float>(1, std::max(transformedDestinationRect.size.width / srcRect.width(), transformedDestinationRect.size.height / srcRect.height()));
-
- image = frameImageAtIndex(m_currentFrame, subsamplingScale);
- }
-
- if (!image) // If it's too early we won't have an image yet.
- return;
-
- Color color = singlePixelSolidColor();
- if (color.isValid()) {
- fillWithSolidColor(ctxt, destRect, color, compositeOp);
- return;
- }
-
- // Subsampling may have given us an image that is smaller than size().
- IntSize imageSize(CGImageGetWidth(image.get()), CGImageGetHeight(image.get()));
-
- // srcRect is in the coordinates of the unsubsampled image, so we have to map it to the subsampled image.
- FloatRect scaledSrcRect = srcRect;
- if (imageSize != m_size) {
- FloatRect originalImageBounds(FloatPoint(), m_size);
- FloatRect subsampledImageBounds(FloatPoint(), imageSize);
- scaledSrcRect = mapRect(srcRect, originalImageBounds, subsampledImageBounds);
- }
-
- ImageOrientation orientation;
- if (description.respectImageOrientation() == RespectImageOrientation)
- orientation = frameOrientationAtIndex(m_currentFrame);
-
- ctxt.drawNativeImage(image, imageSize, destRect, scaledSrcRect, compositeOp, blendMode, orientation);
-
- if (imageObserver())
- imageObserver()->didDraw(this);
-}
-
-RetainPtr<CGImageRef> BitmapImage::copyUnscaledFrameImageAtIndex(size_t index)
-{
- if (index >= frameCount())
- return nullptr;
-
- if (index >= m_frames.size() || !m_frames[index].m_image)
- cacheFrame(index, 0);
-
- if (!m_frames[index].m_subsamplingLevel)
- return m_frames[index].m_image;
-
- return m_source.createFrameImageAtIndex(index);
-}
-
-}
-
-#endif // USE(CG)
Modified: trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp (205681 => 205682)
--- trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp 2016-09-09 00:55:43 UTC (rev 205681)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp 2016-09-09 01:06:47 UTC (rev 205682)
@@ -157,7 +157,7 @@
IntSize ImageDecoder::size() const
{
if (m_size.isEmpty())
- m_size = frameSizeAtIndex(0, 0);
+ m_size = frameSizeAtIndex(0);
return m_size;
}
Modified: trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.h (205681 => 205682)
--- trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.h 2016-09-09 00:55:43 UTC (rev 205681)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.h 2016-09-09 01:06:47 UTC (rev 205682)
@@ -57,7 +57,7 @@
int repetitionCount() const;
Optional<IntPoint> hotSpot() const;
- IntSize frameSizeAtIndex(size_t, SubsamplingLevel) const;
+ IntSize frameSizeAtIndex(size_t, SubsamplingLevel = DefaultSubsamplingLevel) const;
bool frameIsCompleteAtIndex(size_t) const;
ImageOrientation orientationAtIndex(size_t) const;
Added: trunk/Source/WebCore/platform/graphics/cg/NativeImageCG.cpp (0 => 205682)
--- trunk/Source/WebCore/platform/graphics/cg/NativeImageCG.cpp (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cg/NativeImageCG.cpp 2016-09-09 01:06:47 UTC (rev 205682)
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "NativeImage.h"
+
+#if USE(CG)
+
+#include "Color.h"
+#include "CoreGraphicsSPI.h"
+#include "FloatRect.h"
+#include "GeometryUtilities.h"
+#include "GraphicsContextCG.h"
+#include "IntSize.h"
+#include "SubimageCacheWithTimer.h"
+
+#if PLATFORM(WIN)
+#include <WebKitSystemInterface/WebKitSystemInterface.h>
+#endif
+
+namespace WebCore {
+
+IntSize nativeImageSize(const NativeImagePtr& image)
+{
+ return image ? IntSize(CGImageGetWidth(image.get()), CGImageGetHeight(image.get())) : IntSize();
+}
+
+bool nativeImageHasAlpha(const NativeImagePtr&)
+{
+ // FIXME: Answer correctly the question: does the CGImageRef have alpha channnel?
+ return true;
+}
+
+Color nativeImageSinglePixelSolidColor(const NativeImagePtr& image)
+{
+ if (!image || nativeImageSize(image) != IntSize(1, 1))
+ return Color();
+
+ unsigned char pixel[4]; // RGBA
+ auto bitmapContext = adoptCF(CGBitmapContextCreate(pixel, 1, 1, 8, sizeof(pixel), sRGBColorSpaceRef(), kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big));
+
+ if (!bitmapContext)
+ return Color();
+
+ CGContextSetBlendMode(bitmapContext.get(), kCGBlendModeCopy);
+ CGContextDrawImage(bitmapContext.get(), CGRectMake(0, 0, 1, 1), image.get());
+
+ if (!pixel[3])
+ return Color(0, 0, 0, 0);
+
+ return Color(pixel[0] * 255 / pixel[3], pixel[1] * 255 / pixel[3], pixel[2] * 255 / pixel[3], pixel[3]);
+}
+
+float subsamplingScale(GraphicsContext& context, const FloatRect& destRect, const FloatRect& srcRect)
+{
+ // Never use subsampled images for drawing into PDF contexts.
+ if (wkCGContextIsPDFContext(context.platformContext()))
+ return 1;
+
+ CGRect transformedDestinationRect = CGRectApplyAffineTransform(destRect, CGContextGetCTM(context.platformContext()));
+ return std::min<float>(1, std::max(transformedDestinationRect.size.width / srcRect.width(), transformedDestinationRect.size.height / srcRect.height()));
+}
+
+void drawNativeImage(const NativeImagePtr& image, GraphicsContext& context, const FloatRect& destRect, const FloatRect& srcRect, const IntSize& srcSize, CompositeOperator op, BlendMode mode, const ImageOrientation& orientation)
+{
+ // Subsampling may have given us an image that is smaller than size().
+ IntSize subsampledImageSize = nativeImageSize(image);
+
+ // srcRect is in the coordinates of the unsubsampled image, so we have to map it to the subsampled image.
+ FloatRect adjustedSrcRect = srcRect;
+ if (subsampledImageSize != srcSize)
+ adjustedSrcRect = mapRect(srcRect, FloatRect({ }, srcSize), FloatRect({ }, subsampledImageSize));
+
+ context.drawNativeImage(image, subsampledImageSize, destRect, adjustedSrcRect, op, mode, orientation);
+}
+
+void clearNativeImageSubImages(const NativeImagePtr& image)
+{
+#if CACHE_SUBIMAGES
+ if (image)
+ subimageCache().clearImage(image.get());
+#endif
+}
+
+}
+
+#endif // USE(CG)
Modified: trunk/Source/WebCore/platform/graphics/cg/PatternCG.cpp (205681 => 205682)
--- trunk/Source/WebCore/platform/graphics/cg/PatternCG.cpp 2016-09-09 00:55:43 UTC (rev 205681)
+++ trunk/Source/WebCore/platform/graphics/cg/PatternCG.cpp 2016-09-09 01:06:47 UTC (rev 205682)
@@ -72,7 +72,7 @@
// If we're repeating in both directions, we can use image-backed patterns
// instead of custom patterns, and avoid tiling-edge pixel cracks.
if (m_repeatX && m_repeatY)
- return wkCGPatternCreateWithImageAndTransform(tileImage()->getCGImageRef(), patternTransform, wkPatternTilingConstantSpacing);
+ return wkCGPatternCreateWithImageAndTransform(tileImage()->nativeImage().get(), patternTransform, wkPatternTilingConstantSpacing);
// If FLT_MAX should also be used for xStep or yStep, nothing is rendered. Using fractions of FLT_MAX also
// result in nothing being rendered.
@@ -83,7 +83,7 @@
CGFloat yStep = m_repeatY ? tileRect.height() : (1 << 22);
// The pattern will release the CGImageRef when it's done rendering in patternReleaseCallback
- CGImageRef platformImage = CGImageRetain(tileImage()->getCGImageRef());
+ CGImageRef platformImage = tileImage()->nativeImage().leakRef();
const CGPatternCallbacks patternCallbacks = { 0, patternCallback, patternReleaseCallback };
return CGPatternCreate(platformImage, tileRect, patternTransform, xStep, yStep, kCGPatternTilingConstantSpacing, TRUE, &patternCallbacks);
Modified: trunk/Source/WebCore/platform/graphics/cocoa/TextTrackRepresentationCocoa.mm (205681 => 205682)
--- trunk/Source/WebCore/platform/graphics/cocoa/TextTrackRepresentationCocoa.mm 2016-09-09 00:55:43 UTC (rev 205681)
+++ trunk/Source/WebCore/platform/graphics/cocoa/TextTrackRepresentationCocoa.mm 2016-09-09 01:06:47 UTC (rev 205682)
@@ -129,7 +129,7 @@
void TextTrackRepresentationCocoa::update()
{
if (auto representation = m_client.createTextTrackRepresentationImage())
- [m_layer.get() setContents:(id)representation->getCGImageRef()];
+ [m_layer.get() setContents:(id)representation->nativeImage().get()];
}
void TextTrackRepresentationCocoa::setContentScale(float scale)
Modified: trunk/Source/WebCore/platform/graphics/mac/ImageMac.mm (205681 => 205682)
--- trunk/Source/WebCore/platform/graphics/mac/ImageMac.mm 2016-09-09 00:55:43 UTC (rev 205681)
+++ trunk/Source/WebCore/platform/graphics/mac/ImageMac.mm 2016-09-09 01:06:47 UTC (rev 205682)
@@ -79,31 +79,22 @@
if (m_tiffRep)
return m_tiffRep.get();
- unsigned numFrames = frameCount();
+ auto nativeImages = this->framesNativeImages();
- // If numFrames is zero, we know for certain this image doesn't have valid data
+ // If framesImages.size() is zero, we know for certain this image doesn't have valid data
// Even though the call to CGImageDestinationCreateWithData will fail and we'll handle it gracefully,
// in certain circumstances that call will spam the console with an error message
- if (!numFrames)
- return 0;
+ if (!nativeImages.size())
+ return nullptr;
- Vector<CGImageRef> images;
- for (unsigned i = 0; i < numFrames; ++i ) {
- CGImageRef cgImage = frameImageAtIndex(i).get();
- if (cgImage)
- images.append(cgImage);
- }
-
- unsigned numValidFrames = images.size();
-
RetainPtr<CFMutableDataRef> data = "" 0));
- RetainPtr<CGImageDestinationRef> destination = adoptCF(CGImageDestinationCreateWithData(data.get(), kUTTypeTIFF, numValidFrames, 0));
+ RetainPtr<CGImageDestinationRef> destination = adoptCF(CGImageDestinationCreateWithData(data.get(), kUTTypeTIFF, nativeImages.size(), 0));
if (!destination)
- return 0;
+ return nullptr;
- for (unsigned i = 0; i < numValidFrames; ++i)
- CGImageDestinationAddImage(destination.get(), images[i], 0);
+ for (auto nativeImage : nativeImages)
+ CGImageDestinationAddImage(destination.get(), nativeImage.get(), 0);
CGImageDestinationFinalize(destination.get());
Modified: trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.mm (205681 => 205682)
--- trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.mm 2016-09-09 00:55:43 UTC (rev 205681)
+++ trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.mm 2016-09-09 01:06:47 UTC (rev 205682)
@@ -142,7 +142,7 @@
if (!image)
break;
- m_previewImage = image->getCGImageRef();
+ m_previewImage = image->nativeImage();
if (!m_previewImage)
break;
@@ -154,7 +154,7 @@
void MockRealtimeVideoSourceMac::updateSampleBuffer()
{
- auto pixelBuffer = pixelBufferFromCGImage(imageBuffer()->copyImage()->getCGImageRef());
+ auto pixelBuffer = pixelBufferFromCGImage(imageBuffer()->copyImage()->nativeImage().get());
auto sampleBuffer = CMSampleBufferFromPixelBuffer(pixelBuffer.get());
mediaDataUpdated(MediaSampleAVFObjC::create(sampleBuffer.get()));
Modified: trunk/Source/WebCore/platform/win/DragImageCGWin.cpp (205681 => 205682)
--- trunk/Source/WebCore/platform/win/DragImageCGWin.cpp 2016-09-09 00:55:43 UTC (rev 205681)
+++ trunk/Source/WebCore/platform/win/DragImageCGWin.cpp 2016-09-09 01:06:47 UTC (rev 205682)
@@ -136,9 +136,9 @@
CGContextScaleCTM(drawContext, 1, -1);
CGContextSetFillColor(drawContext, white);
CGContextFillRect(drawContext, rect);
- if (auto srcImage = img->getCGImageRef()) {
+ if (auto srcImage = img->nativeImage()) {
CGContextSetBlendMode(drawContext, kCGBlendModeNormal);
- CGContextDrawImage(drawContext, rect, srcImage);
+ CGContextDrawImage(drawContext, rect, srcImage.get());
}
CGContextRelease(drawContext);
Modified: trunk/Source/WebKit/mac/ChangeLog (205681 => 205682)
--- trunk/Source/WebKit/mac/ChangeLog 2016-09-09 00:55:43 UTC (rev 205681)
+++ trunk/Source/WebKit/mac/ChangeLog 2016-09-09 01:06:47 UTC (rev 205682)
@@ -1,3 +1,16 @@
+2016-09-08 Said Abou-Hallawa <[email protected]>
+
+ Move the BitmapImage platform dependent code to a new file named NativeImage[CG|Cairo].cpp
+ https://bugs.webkit.org/show_bug.cgi?id=158684
+
+ Reviewed by Simon Fraser.
+
+ * DOM/DOM.mm:
+ (-[DOMNode getPreviewSnapshotImage:andRects:]):
+ * Misc/WebCache.mm:
+ (+[WebCache imageForURL:]):
+ Replace BitmapImage::getCGImageRef() with BitmapImage::nativeImage().
+
2016-09-07 Joseph Pecoraro <[email protected]>
[Mac] Address some clang static analyzer warnings in WebKit
Modified: trunk/Source/WebKit/mac/DOM/DOM.mm (205681 => 205682)
--- trunk/Source/WebKit/mac/DOM/DOM.mm 2016-09-09 00:55:43 UTC (rev 205681)
+++ trunk/Source/WebKit/mac/DOM/DOM.mm 2016-09-09 01:06:47 UTC (rev 205682)
@@ -561,7 +561,7 @@
if (textIndicator) {
if (Image* image = textIndicator->contentImage())
- *cgImage = (CGImageRef)CFAutorelease(CGImageRetain(image->getCGImageRef()));
+ *cgImage = image->nativeImage().autorelease();
}
RetainPtr<NSMutableArray> rectArray = adoptNS([[NSMutableArray alloc] init]);
Modified: trunk/Source/WebKit/mac/Misc/WebCache.mm (205681 => 205682)
--- trunk/Source/WebKit/mac/Misc/WebCache.mm 2016-09-09 00:55:43 UTC (rev 205681)
+++ trunk/Source/WebKit/mac/Misc/WebCache.mm 2016-09-09 01:06:47 UTC (rev 205682)
@@ -204,7 +204,7 @@
WebCore::CachedImage& cachedImage = downcast<WebCore::CachedImage>(*cachedResource);
if (!cachedImage.hasImage())
return nullptr;
- return cachedImage.image()->getCGImageRef();
+ return cachedImage.image()->nativeImage().get();
}
#endif // PLATFORM(IOS)
Modified: trunk/Source/WebKit2/ChangeLog (205681 => 205682)
--- trunk/Source/WebKit2/ChangeLog 2016-09-09 00:55:43 UTC (rev 205681)
+++ trunk/Source/WebKit2/ChangeLog 2016-09-09 01:06:47 UTC (rev 205682)
@@ -1,3 +1,26 @@
+2016-09-08 Said Abou-Hallawa <[email protected]>
+
+ Move the BitmapImage platform dependent code to a new file named NativeImage[CG|Cairo].cpp
+ https://bugs.webkit.org/show_bug.cgi?id=158684
+
+ Reviewed by Simon Fraser.
+
+ * UIProcess/API/C/cg/WKIconDatabaseCG.cpp:
+ (WKIconDatabaseTryGetCGImageForURL):
+ (WKIconDatabaseTryCopyCGImageArrayForURL):
+ It was the only place in the code which uses BitmapImage::getCGImageArray().
+ Call BitmapImage::framesNativeImages() instead and form the returned
+ Vector<NativeImagePtr> build the CFArrayRef.
+
+ * UIProcess/WebIconDatabase.h:
+ Include "NativeImage.h" instead of "NativeImagePtr.h".
+
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView _presentationSnapshotForPreviewItemController:]):
+ * WebProcess/Plugins/PluginView.cpp:
+ (WebKit::isAlmostSolidColor):
+ Call BitmapImage::getCGImageRef() instead of calling BitmapImage::nativeImage().
+
2016-09-08 Zan Dobersek <[email protected]>
Move webkit2gtk.pc.in, webkit2gtk-web-extension.pc.in files under Source/WebKit2/gtk/
Modified: trunk/Source/WebKit2/UIProcess/API/C/cg/WKIconDatabaseCG.cpp (205681 => 205682)
--- trunk/Source/WebKit2/UIProcess/API/C/cg/WKIconDatabaseCG.cpp 2016-09-09 00:55:43 UTC (rev 205681)
+++ trunk/Source/WebKit2/UIProcess/API/C/cg/WKIconDatabaseCG.cpp 2016-09-09 01:06:47 UTC (rev 205682)
@@ -37,12 +37,23 @@
CGImageRef WKIconDatabaseTryGetCGImageForURL(WKIconDatabaseRef iconDatabaseRef, WKURLRef urlRef, WKSize size)
{
Image* image = toImpl(iconDatabaseRef)->imageForPageURL(toWTFString(urlRef));
- return image ? image->getFirstCGImageRefOfSize(IntSize(static_cast<int>(size.width), static_cast<int>(size.height))) : 0;
+ return image ? image->nativeImageOfSize(IntSize(static_cast<int>(size.width), static_cast<int>(size.height))).get() : nullptr;
}
CFArrayRef WKIconDatabaseTryCopyCGImageArrayForURL(WKIconDatabaseRef iconDatabaseRef, WKURLRef urlRef)
{
Image* image = toImpl(iconDatabaseRef)->imageForPageURL(toWTFString(urlRef));
- return image ? image->getCGImageArray().leakRef() : 0;
+ if (!image)
+ return nullptr;
+
+ auto nativeImages = image->framesNativeImages();
+ if (!nativeImages.size())
+ return nullptr;
+
+ CFMutableArrayRef array = CFArrayCreateMutable(nullptr, nativeImages.size(), &kCFTypeArrayCallBacks);
+ for (auto nativeImage : nativeImages)
+ CFArrayAppendValue(array, nativeImage.get());
+
+ return static_cast<CFArrayRef>(CFRetain(array));
}
Modified: trunk/Source/WebKit2/UIProcess/WebIconDatabase.h (205681 => 205682)
--- trunk/Source/WebKit2/UIProcess/WebIconDatabase.h 2016-09-09 00:55:43 UTC (rev 205681)
+++ trunk/Source/WebKit2/UIProcess/WebIconDatabase.h 2016-09-09 01:06:47 UTC (rev 205682)
@@ -31,7 +31,7 @@
#include "WebIconDatabaseClient.h"
#include <WebCore/IconDatabaseClient.h>
#include <WebCore/IntSize.h>
-#include <WebCore/NativeImagePtr.h>
+#include <WebCore/NativeImage.h>
namespace API {
class Data;
Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (205681 => 205682)
--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm 2016-09-09 00:55:43 UTC (rev 205681)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm 2016-09-09 01:06:47 UTC (rev 205682)
@@ -4131,7 +4131,7 @@
{
if (!_positionInformation.linkIndicator.contentImage)
return nullptr;
- return [[[UIImage alloc] initWithCGImage:_positionInformation.linkIndicator.contentImage->getCGImageRef()] autorelease];
+ return [[[UIImage alloc] initWithCGImage:_positionInformation.linkIndicator.contentImage->nativeImage().get()] autorelease];
}
- (NSArray *)_presentationRectsForPreviewItemController:(UIPreviewItemController *)controller
Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp (205681 => 205682)
--- trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp 2016-09-09 00:55:43 UTC (rev 205681)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp 2016-09-09 01:06:47 UTC (rev 205682)
@@ -1730,7 +1730,7 @@
#if PLATFORM(COCOA)
static bool isAlmostSolidColor(BitmapImage* bitmap)
{
- CGImageRef image = bitmap->getCGImageRef();
+ CGImageRef image = bitmap->nativeImage().get();
ASSERT(CGImageGetBitsPerComponent(image) == 8);
CGBitmapInfo imageInfo = CGImageGetBitmapInfo(image);