Changeset 205682 in webkit
- Timestamp:
- Sep 8, 2016 6:06:47 PM (8 years ago)
- Location:
- trunk/Source
- Files:
-
- 2 added
- 2 deleted
- 33 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r205679 r205682 1 2016-09-08 Said Abou-Hallawa <sabouhallawa@apple.com> 2 3 Move the BitmapImage platform dependent code to a new file named NativeImage[CG|Cairo].cpp 4 https://bugs.webkit.org/show_bug.cgi?id=158684 5 6 Reviewed by Simon Fraser. 7 8 This is a refactoring patch. It moves the BitmapImage platform dependent 9 code from BitmapImage to NativeImage[CG|Cairo].cpp. The new APIs are 10 responsible of drawing a NativeImagePtr and answering some metadata queries. 11 12 No new tests -- Code refactoring, no behavior change. 13 14 * PlatformAppleWin.cmake: 15 * PlatformEfl.cmake: 16 * PlatformGTK.cmake: 17 * PlatformMac.cmake: 18 * PlatformWinCairo.cmake: 19 * WebCore.xcodeproj/project.pbxproj: 20 * loader/cache/MemoryCache.h: 21 * loader/icon/IconDatabaseBase.h: 22 * page/mac/TextIndicatorWindow.mm: 23 (-[WebTextIndicatorView initWithFrame:textIndicator:margin:offset:]): 24 (createContentCrossfadeAnimation): 25 * platform/graphics/BitmapImage.cpp: 26 (WebCore::BitmapImage::BitmapImage): 27 (WebCore::BitmapImage::destroyDecodedData): 28 (WebCore::BitmapImage::destroyDecodedDataIfNecessary): 29 (WebCore::BitmapImage::dataChanged): 30 (WebCore::BitmapImage::ensureFrameAtIndexIsCached): 31 (WebCore::BitmapImage::frameImageAtIndex): 32 (WebCore::BitmapImage::nativeImage): 33 (WebCore::BitmapImage::nativeImageForCurrentFrame): 34 (WebCore::BitmapImage::nativeImageOfSize): 35 (WebCore::BitmapImage::framesNativeImages): 36 (WebCore::BitmapImage::frameIsCompleteAtIndex): 37 (WebCore::BitmapImage::frameDurationAtIndex): 38 (WebCore::BitmapImage::frameHasAlphaAtIndex): 39 (WebCore::BitmapImage::frameOrientationAtIndex): 40 (WebCore::BitmapImage::singlePixelSolidColor): 41 (WebCore::BitmapImage::draw): 42 (WebCore::BitmapImage::drawPattern): 43 (WebCore::BitmapImage::canAnimate): 44 (WebCore::BitmapImage::clearTimer): 45 (WebCore::BitmapImage::startTimer): 46 (WebCore::BitmapImage::stopAnimation): 47 (WebCore::BitmapImage::resetAnimation): 48 (WebCore::BitmapImage::hasSingleSecurityOrigin): Deleted. 49 (WebCore::BitmapImage::filenameExtension): Deleted. 50 (WebCore::BitmapImage::ensureFrameIsCached): Deleted. 51 * platform/graphics/BitmapImage.h: 52 (WebCore::FrameData::FrameData): 53 m_hasAlpha can be initialized with false because it is accessed only in 54 BitmapImage::frameHasAlphaAtIndex() and it is guarded by m_haveMetadata. 55 Both m_haveMetadata and m_hasAlpha are set in BitmapImage constructor 56 and in BitmapImage::cacheFrame(). 57 58 (WebCore::FrameData::~FrameData): 59 (WebCore::FrameData::clear): 60 * platform/graphics/Icon.h: 61 * platform/graphics/Image.h: 62 (WebCore::Image::nativeImage): 63 (WebCore::Image::nativeImageOfSize): 64 (WebCore::Image::framesNativeImages): 65 (WebCore::Image::orientationForCurrentFrame): Deleted. 66 (WebCore::Image::getCGImageRef): Deleted. 67 (WebCore::Image::getFirstCGImageRefOfSize): Deleted. 68 (WebCore::Image::getCGImageArray): Deleted. 69 * platform/graphics/ImageSource.cpp: 70 (WebCore::ImageSource::calculateMaximumSubsamplingLevel): 71 (WebCore::ImageSource::size): 72 (WebCore::ImageSource::sizeRespectingOrientation): 73 * platform/graphics/ImageSource.h: 74 * platform/graphics/MediaPlayer.h: 75 * platform/graphics/NativeImage.h: Added. 76 * platform/graphics/NativeImagePtr.h: Removed. 77 * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: 78 (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::updatePausedImage): 79 * platform/graphics/cairo/BitmapImageCairo.cpp: Removed. 80 * platform/graphics/cairo/NativeImageCairo.cpp: Added. 81 (WebCore::nativeImageSize): 82 (WebCore::nativeImageHasAlpha): 83 (WebCore::nativeImageSinglePixelSolidColor): 84 (WebCore::subsamplingScale): 85 (WebCore::drawNativeImage): 86 (WebCore::clearNativeImageSubImages): 87 * platform/graphics/cg/BitmapImageCG.cpp: Removed. 88 * platform/graphics/cg/ImageDecoderCG.cpp: 89 (WebCore::ImageDecoder::size): 90 * platform/graphics/cg/ImageDecoderCG.h: 91 * platform/graphics/cg/NativeImageCG.cpp: Added. 92 (WebCore::nativeImageSize): 93 (WebCore::nativeImageHasAlpha): 94 (WebCore::nativeImageSinglePixelSolidColor): 95 (WebCore::subsamplingScale): 96 (WebCore::drawNativeImage): 97 (WebCore::clearNativeImageSubImages): 98 * platform/graphics/cg/PatternCG.cpp: 99 (WebCore::Pattern::createPlatformPattern): 100 * platform/graphics/cocoa/TextTrackRepresentationCocoa.mm: 101 (TextTrackRepresentationCocoa::update): 102 * platform/graphics/mac/ImageMac.mm: 103 (WebCore::BitmapImage::getTIFFRepresentation): 104 * platform/mediastream/mac/MockRealtimeVideoSourceMac.mm: 105 (WebCore::MockRealtimeVideoSourceMac::updatePlatformLayer): 106 (WebCore::MockRealtimeVideoSourceMac::updateSampleBuffer): 107 * platform/win/DragImageCGWin.cpp: 108 (WebCore::createDragImageFromImage): 109 1 110 2016-09-08 Alex Christensen <achristensen@webkit.org> 2 111 -
trunk/Source/WebCore/PlatformAppleWin.cmake
r204599 r205682 56 56 platform/graphics/ca/win/WKCACFViewLayerTreeHost.cpp 57 57 58 platform/graphics/cg/BitmapImageCG.cpp59 58 platform/graphics/cg/ColorCG.cpp 60 59 platform/graphics/cg/FloatPointCG.cpp … … 73 72 platform/graphics/cg/IntRectCG.cpp 74 73 platform/graphics/cg/IntSizeCG.cpp 74 platform/graphics/cg/NativeImageCG.cpp 75 75 platform/graphics/cg/PDFDocumentImage.cpp 76 76 platform/graphics/cg/PathCG.cpp -
trunk/Source/WebCore/PlatformEfl.cmake
r205556 r205682 127 127 128 128 platform/graphics/cairo/BackingStoreBackendCairoImpl.cpp 129 platform/graphics/cairo/BitmapImageCairo.cpp130 129 platform/graphics/cairo/CairoUtilities.cpp 131 130 platform/graphics/cairo/FontCairo.cpp … … 136 135 platform/graphics/cairo/ImageCairo.cpp 137 136 platform/graphics/cairo/IntRectCairo.cpp 137 platform/graphics/cairo/NativeImageCairo.cpp 138 138 platform/graphics/cairo/PathCairo.cpp 139 139 platform/graphics/cairo/PatternCairo.cpp -
trunk/Source/WebCore/PlatformGTK.cmake
r205280 r205682 106 106 platform/graphics/cairo/BackingStoreBackendCairoImpl.cpp 107 107 platform/graphics/cairo/BackingStoreBackendCairoX11.cpp 108 platform/graphics/cairo/BitmapImageCairo.cpp109 108 platform/graphics/cairo/CairoUtilities.cpp 110 109 platform/graphics/cairo/FloatRectCairo.cpp … … 117 116 platform/graphics/cairo/ImageCairo.cpp 118 117 platform/graphics/cairo/IntRectCairo.cpp 118 platform/graphics/cairo/NativeImageCairo.cpp 119 119 platform/graphics/cairo/PathCairo.cpp 120 120 platform/graphics/cairo/PatternCairo.cpp -
trunk/Source/WebCore/PlatformMac.cmake
r205308 r205682 386 386 platform/graphics/ca/cocoa/WebTiledBackingLayer.mm 387 387 388 platform/graphics/cg/BitmapImageCG.cpp389 388 platform/graphics/cg/ColorCG.cpp 390 389 platform/graphics/cg/FloatPointCG.cpp … … 403 402 platform/graphics/cg/IntRectCG.cpp 404 403 platform/graphics/cg/IntSizeCG.cpp 404 platform/graphics/cg/NativeImageCG.cpp 405 405 platform/graphics/cg/PDFDocumentImage.cpp 406 406 platform/graphics/cg/PathCG.cpp -
trunk/Source/WebCore/PlatformWinCairo.cmake
r204483 r205682 22 22 platform/graphics/PlatformDisplay.cpp 23 23 24 platform/graphics/cairo/BitmapImageCairo.cpp25 24 platform/graphics/cairo/CairoUtilities.cpp 26 25 platform/graphics/cairo/FloatRectCairo.cpp … … 32 31 platform/graphics/cairo/ImageCairo.cpp 33 32 platform/graphics/cairo/IntRectCairo.cpp 33 platform/graphics/cairo/NativeImageCairo.cpp 34 34 platform/graphics/cairo/PathCairo.cpp 35 35 platform/graphics/cairo/PatternCairo.cpp -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r205660 r205682 1425 1425 376DCCE113B4F966002EBEFC /* TextRun.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 376DCCE013B4F966002EBEFC /* TextRun.cpp */; }; 1426 1426 3774ABA50FA21EB400AD7DE9 /* OverlapTestRequestClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 3774ABA30FA21EB400AD7DE9 /* OverlapTestRequestClient.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1427 377A3A9015EFCE9B0059F5C7 /* BitmapImageCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 377A3A8F15EFCE9A0059F5C7 /* BitmapImageCG.cpp */; };1427 377A3A9015EFCE9B0059F5C7 /* NativeImageCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 377A3A8F15EFCE9A0059F5C7 /* NativeImageCG.cpp */; }; 1428 1428 37919C230B7D188600A56998 /* PositionIterator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37919C210B7D188600A56998 /* PositionIterator.cpp */; }; 1429 1429 37919C240B7D188600A56998 /* PositionIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = 37919C220B7D188600A56998 /* PositionIterator.h */; settings = {ATTRIBUTES = (); }; }; … … 2275 2275 555B87EC1CAAF0AB00349425 /* ImageDecoderCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 555B87EA1CAAF0AB00349425 /* ImageDecoderCG.cpp */; }; 2276 2276 555B87ED1CAAF0AB00349425 /* ImageDecoderCG.h in Headers */ = {isa = PBXBuildFile; fileRef = 555B87EB1CAAF0AB00349425 /* ImageDecoderCG.h */; }; 2277 55A336F71D8209F40022C4C7 /* NativeImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 55A336F61D8209F40022C4C7 /* NativeImage.h */; }; 2277 2278 5709E8CD1D413D47003244AC /* WebKitSubtleCrypto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5709E8CA1D413CE3003244AC /* WebKitSubtleCrypto.cpp */; }; 2278 2279 5709E8CE1D413D5B003244AC /* JSWebKitSubtleCryptoCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FF8F661807460800132674 /* JSWebKitSubtleCryptoCustom.cpp */; }; … … 2514 2515 69A6CBAC1C6BE42C00B836E9 /* AccessibilitySVGElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 697101071C6BE1550018C7F1 /* AccessibilitySVGElement.cpp */; }; 2515 2516 69A6CBAD1C6BE42C00B836E9 /* AccessibilitySVGElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 697101081C6BE1550018C7F1 /* AccessibilitySVGElement.h */; }; 2516 6B3480940EEF50D400AC1B41 /* NativeImage Ptr.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B3480920EEF50D400AC1B41 /* NativeImagePtr.h */; settings = {ATTRIBUTES = (Private, ); }; };2517 6B3480940EEF50D400AC1B41 /* NativeImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B3480920EEF50D400AC1B41 /* NativeImage.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2517 2518 6B693A2E1C51A82E00B03BEF /* ResourceLoadObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B693A2D1C51A82E00B03BEF /* ResourceLoadObserver.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2518 2519 6B693A341C51A95D00B03BEF /* ResourceLoadObserver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6B693A331C51A95D00B03BEF /* ResourceLoadObserver.cpp */; }; … … 8355 8356 3772B09516535856000A49CA /* PopupOpeningObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PopupOpeningObserver.h; sourceTree = "<group>"; }; 8356 8357 3774ABA30FA21EB400AD7DE9 /* OverlapTestRequestClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OverlapTestRequestClient.h; sourceTree = "<group>"; }; 8357 377A3A8F15EFCE9A0059F5C7 /* BitmapImageCG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BitmapImageCG.cpp; sourceTree = "<group>"; };8358 377A3A8F15EFCE9A0059F5C7 /* NativeImageCG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NativeImageCG.cpp; sourceTree = "<group>"; }; 8358 8359 37919C210B7D188600A56998 /* PositionIterator.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = PositionIterator.cpp; sourceTree = "<group>"; }; 8359 8360 37919C220B7D188600A56998 /* PositionIterator.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PositionIterator.h; sourceTree = "<group>"; }; … … 9290 9291 555B87EA1CAAF0AB00349425 /* ImageDecoderCG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageDecoderCG.cpp; sourceTree = "<group>"; }; 9291 9292 555B87EB1CAAF0AB00349425 /* ImageDecoderCG.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageDecoderCG.h; sourceTree = "<group>"; }; 9293 55A336F61D8209F40022C4C7 /* NativeImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NativeImage.h; sourceTree = "<group>"; }; 9292 9294 55D408F71A7C631800C78450 /* SVGImageClients.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGImageClients.h; sourceTree = "<group>"; }; 9293 9295 5709E8CA1D413CE3003244AC /* WebKitSubtleCrypto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebKitSubtleCrypto.cpp; sourceTree = "<group>"; }; … … 9555 9557 697101071C6BE1550018C7F1 /* AccessibilitySVGElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AccessibilitySVGElement.cpp; sourceTree = "<group>"; }; 9556 9558 697101081C6BE1550018C7F1 /* AccessibilitySVGElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilitySVGElement.h; sourceTree = "<group>"; }; 9557 6B3480920EEF50D400AC1B41 /* NativeImage Ptr.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = NativeImagePtr.h; sourceTree = "<group>"; };9559 6B3480920EEF50D400AC1B41 /* NativeImage.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = NativeImage.h; sourceTree = "<group>"; }; 9558 9560 6B693A2D1C51A82E00B03BEF /* ResourceLoadObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadObserver.h; sourceTree = "<group>"; }; 9559 9561 6B693A331C51A95D00B03BEF /* ResourceLoadObserver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceLoadObserver.cpp; sourceTree = "<group>"; }; … … 20507 20509 isa = PBXGroup; 20508 20510 children = ( 20509 377A3A8F15EFCE9A0059F5C7 /* BitmapImageCG.cpp */,20510 20511 0FCF33230F2B9715004B6795 /* ColorCG.cpp */, 20511 20512 B275352B0B053814002CE64F /* FloatPointCG.cpp */, … … 20534 20535 B27535360B053814002CE64F /* PDFDocumentImage.cpp */, 20535 20536 B27535370B053814002CE64F /* PDFDocumentImage.h */, 20537 377A3A8F15EFCE9A0059F5C7 /* NativeImageCG.cpp */, 20536 20538 1FC40FB81655C5910040F29E /* SubimageCacheWithTimer.cpp */, 20537 20539 1FC40FB71655C5910040F29E /* SubimageCacheWithTimer.h */, … … 20725 20727 314BE3A41B3103FB00141982 /* NamedImageGeneratedImage.cpp */, 20726 20728 314BE3A51B3103FB00141982 /* NamedImageGeneratedImage.h */, 20727 6B3480920EEF50D400AC1B41 /* NativeImage Ptr.h */,20729 6B3480920EEF50D400AC1B41 /* NativeImage.h */, 20728 20730 B27535520B053814002CE64F /* Path.cpp */, 20729 20731 B27535530B053814002CE64F /* Path.h */, … … 20767 20769 379919941200DDF400EA041C /* WOFFFileFormat.cpp */, 20768 20770 379919951200DDF400EA041C /* WOFFFileFormat.h */, 20771 55A336F61D8209F40022C4C7 /* NativeImage.h */, 20769 20772 ); 20770 20773 path = graphics; … … 25703 25706 A81872230977D3C0005826D9 /* NamedNodeMap.h in Headers */, 25704 25707 A818721E0977D3C0005826D9 /* NameNodeList.h in Headers */, 25705 6B3480940EEF50D400AC1B41 /* NativeImage Ptr.h in Headers */,25708 6B3480940EEF50D400AC1B41 /* NativeImage.h in Headers */, 25706 25709 83B2D1751B8BCD6A00A02E47 /* NativeNodeFilter.h in Headers */, 25707 25710 E10B9B6C0B747599003ED890 /* NativeXPathNSResolver.h in Headers */, … … 25781 25784 1A569D170D7E2B82007C3983 /* objc_runtime.h in Headers */, 25782 25785 1A569D190D7E2B82007C3983 /* objc_utility.h in Headers */, 25786 55A336F71D8209F40022C4C7 /* NativeImage.h in Headers */, 25783 25787 E16982551134629D00894115 /* ObjCRuntimeObject.h in Headers */, 25784 25788 7E5D7A77161D3F8F00896C34 /* OESElementIndexUint.h in Headers */, … … 27600 27604 FD31602612B0267600C1A359 /* BiquadProcessor.cpp in Sources */, 27601 27605 A89943290B42338800D7C802 /* BitmapImage.cpp in Sources */, 27602 377A3A9015EFCE9B0059F5C7 /* BitmapImageCG.cpp in Sources */,27606 377A3A9015EFCE9B0059F5C7 /* NativeImageCG.cpp in Sources */, 27603 27607 1AFFC4541D5E81CB00267A66 /* BlacklistUpdater.mm in Sources */, 27604 27608 976D6C78122B8A3D001FD1F7 /* Blob.cpp in Sources */, -
trunk/Source/WebCore/loader/cache/MemoryCache.h
r200066 r205682 26 26 #define Cache_h 27 27 28 #include "NativeImage Ptr.h"28 #include "NativeImage.h" 29 29 #include "SecurityOriginHash.h" 30 30 #include "SessionID.h" -
trunk/Source/WebCore/loader/icon/IconDatabaseBase.h
r198655 r205682 27 27 #define IconDatabaseBase_h 28 28 29 #include "NativeImage Ptr.h"29 #include "NativeImage.h" 30 30 #include <wtf/Forward.h> 31 31 #include <wtf/Noncopyable.h> -
trunk/Source/WebCore/page/mac/TextIndicatorWindow.mm
r202611 r205682 163 163 RetainPtr<CGImageRef> contentsImage; 164 164 if (indicatorWantsContentCrossfade(*_textIndicator)) 165 contentsImage = _textIndicator->contentImageWithHighlight()-> getCGImageRef();165 contentsImage = _textIndicator->contentImageWithHighlight()->nativeImage(); 166 166 else 167 contentsImage = _textIndicator->contentImage()-> getCGImageRef();167 contentsImage = _textIndicator->contentImage()->nativeImage(); 168 168 169 169 RetainPtr<NSMutableArray> bounceLayers = adoptNS([[NSMutableArray alloc] init]); … … 266 266 { 267 267 RetainPtr<CABasicAnimation> crossfadeAnimation = [CABasicAnimation animationWithKeyPath:@"contents"]; 268 RetainPtr<CGImageRef> contentsImage = textIndicator.contentImage()-> getCGImageRef();268 RetainPtr<CGImageRef> contentsImage = textIndicator.contentImage()->nativeImage(); 269 269 [crossfadeAnimation setToValue:(id)contentsImage.get()]; 270 270 [crossfadeAnimation setFillMode:kCAFillModeForwards]; -
trunk/Source/WebCore/platform/graphics/BitmapImage.cpp
r204205 r205682 71 71 // Since we don't have a decoder, we can't figure out the image orientation. 72 72 // Set m_sizeRespectingOrientation to be the same as m_size so it's not 0x0. 73 m_sizeRespectingOrientation = m_size = NativeImage::size(image);73 m_sizeRespectingOrientation = m_size = nativeImageSize(image); 74 74 m_decodedSize = m_size.area() * 4; 75 75 76 76 m_frames.grow(1); 77 m_frames[0].m_hasAlpha = NativeImage::hasAlpha(image);77 m_frames[0].m_hasAlpha = nativeImageHasAlpha(image); 78 78 m_frames[0].m_haveMetadata = true; 79 79 m_frames[0].m_image = WTFMove(image); … … 86 86 } 87 87 88 void BitmapImage::clearTimer()89 {90 m_frameTimer = nullptr;91 }92 93 void BitmapImage::startTimer(double delay)94 {95 ASSERT(!m_frameTimer);96 m_frameTimer = std::make_unique<Timer>(*this, &BitmapImage::advanceAnimation);97 m_frameTimer->startOneShot(delay);98 }99 100 88 bool BitmapImage::haveFrameImageAtIndex(size_t index) 101 89 { … … 107 95 108 96 return m_frames[index].m_image; 109 }110 111 bool BitmapImage::hasSingleSecurityOrigin() const112 {113 return true;114 97 } 115 98 … … 126 109 // save the memory for the framebuffer data), so we don't need to clear 127 110 // the metadata. 128 unsigned frameBytes = m_frames[i].m_frameBytes; 129 if (m_frames[i].clear(false)) 130 frameBytesCleared += frameBytes; 111 frameBytesCleared += m_frames[i].clear(false); 131 112 } 132 113 … … 151 132 152 133 unsigned allFrameBytes = 0; 153 for ( size_t i = 0; i < m_frames.size(); ++i)154 allFrameBytes += m_frames[i].usedFrameBytes();134 for (auto& frame : m_frames) 135 allFrameBytes += frame.usedFrameBytes(); 155 136 156 137 if (allFrameBytes > largeAnimationCutoff) { … … 289 270 // incomplete frames to be safe. 290 271 unsigned frameBytesCleared = 0; 291 for ( size_t i = 0; i < m_frames.size(); ++i) {272 for (auto& frame : m_frames) { 292 273 // NOTE: Don't call frameIsCompleteAtIndex() here, that will try to 293 274 // decode any uncached (i.e. never-decoded or 294 275 // cleared-on-a-previous-pass) frames! 295 unsigned frameBytes = m_frames[i].m_frameBytes; 296 if (m_frames[i].m_haveMetadata && !m_frames[i].m_isComplete) 297 frameBytesCleared += (m_frames[i].clear(true) ? frameBytes : 0); 276 if (frame.m_haveMetadata && !frame.m_isComplete) 277 frameBytesCleared += frame.clear(true); 298 278 } 299 279 destroyMetadataAndNotify(frameBytesCleared, ClearedSource::No); … … 302 282 int deltaBytes = 0; 303 283 if (!m_frames.isEmpty()) { 304 int bytes = m_frames[m_frames.size() - 1].m_frameBytes; 305 if (m_frames[m_frames.size() - 1].clear(true)) { 284 if (int bytes = m_frames[m_frames.size() - 1].clear(true)) { 306 285 deltaBytes += bytes; 307 286 deltaBytes += m_decodedPropertiesSize; … … 338 317 } 339 318 340 String BitmapImage::filenameExtension() const341 {342 return m_source.filenameExtension();343 }344 345 319 size_t BitmapImage::frameCount() 346 320 { … … 367 341 } 368 342 369 bool BitmapImage::ensureFrame IsCached(size_t index, ImageFrameCaching frameCaching)343 bool BitmapImage::ensureFrameAtIndexIsCached(size_t index, ImageFrameCaching frameCaching) 370 344 { 371 345 if (index >= frameCount()) … … 395 369 396 370 // If the image is already cached, but at too small a size, re-decode a larger version. 397 int sizeChange = -m_frames[index].m_frameBytes; 398 m_frames[index].clear(true); 371 int sizeChange = -m_frames[index].clear(true); 399 372 invalidatePlatformData(); 400 373 m_decodedSize += sizeChange; … … 409 382 return m_frames[index].m_image; 410 383 } 384 385 NativeImagePtr BitmapImage::nativeImage() 386 { 387 return frameImageAtIndex(0); 388 } 389 390 NativeImagePtr BitmapImage::nativeImageForCurrentFrame() 391 { 392 return frameImageAtIndex(m_currentFrame); 393 } 394 395 #if USE(CG) 396 NativeImagePtr BitmapImage::nativeImageOfSize(const IntSize& size) 397 { 398 size_t count = frameCount(); 399 400 for (size_t i = 0; i < count; ++i) { 401 auto image = frameImageAtIndex(i); 402 if (image && nativeImageSize(image) == size) 403 return image; 404 } 405 406 // Fallback to the first frame image if we can't find the right size 407 return frameImageAtIndex(0); 408 } 409 410 Vector<NativeImagePtr> BitmapImage::framesNativeImages() 411 { 412 Vector<NativeImagePtr> images; 413 size_t count = frameCount(); 414 415 for (size_t i = 0; i < count; ++i) { 416 if (auto image = frameImageAtIndex(i)) 417 images.append(image); 418 } 419 420 return images; 421 } 422 #endif 411 423 412 424 bool BitmapImage::frameIsCompleteAtIndex(size_t index) 413 425 { 414 if (!ensureFrame IsCached(index, CacheMetadataOnly))426 if (!ensureFrameAtIndexIsCached(index, CacheMetadataOnly)) 415 427 return false; 416 428 … … 420 432 float BitmapImage::frameDurationAtIndex(size_t index) 421 433 { 422 if (!ensureFrame IsCached(index, CacheMetadataOnly))434 if (!ensureFrameAtIndexIsCached(index, CacheMetadataOnly)) 423 435 return 0; 424 436 … … 426 438 } 427 439 428 NativeImagePtr BitmapImage::nativeImageForCurrentFrame()429 {430 return frameImageAtIndex(currentFrame());431 }432 433 440 bool BitmapImage::frameHasAlphaAtIndex(size_t index) 434 441 { 435 if (!ensureFrame IsCached(index, CacheMetadataOnly))442 if (!ensureFrameAtIndexIsCached(index, CacheMetadataOnly)) 436 443 return true; 437 444 … … 449 456 ImageOrientation BitmapImage::frameOrientationAtIndex(size_t index) 450 457 { 451 if (!ensureFrame IsCached(index, CacheMetadataOnly))458 if (!ensureFrameAtIndexIsCached(index, CacheMetadataOnly)) 452 459 return ImageOrientation(); 453 460 … … 456 463 457 464 return m_source.orientationAtIndex(index); 465 } 466 467 Color BitmapImage::singlePixelSolidColor() 468 { 469 // If the image size is not available yet or if the image will be animating don't use the solid color optimization. 470 if (frameCount() != 1) 471 return Color(); 472 473 if (m_solidColor) 474 return m_solidColor.value(); 475 476 // If the frame image is not loaded, first use the decoder to get the size of the image. 477 if (!haveFrameImageAtIndex(0) && m_source.frameSizeAtIndex(0) != IntSize(1, 1)) { 478 m_solidColor = Color(); 479 return m_solidColor.value(); 480 } 481 482 // Cache the frame image. The size will be calculated from the NativeImagePtr. 483 if (!ensureFrameAtIndexIsCached(0)) 484 return Color(); 485 486 ASSERT(m_frames.size()); 487 m_solidColor = nativeImageSinglePixelSolidColor(m_frames[0].m_image); 488 489 ASSERT(m_solidColor); 490 return m_solidColor.value(); 458 491 } 459 492 … … 479 512 } 480 513 514 void BitmapImage::draw(GraphicsContext& context, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator op, BlendMode mode, ImageOrientationDescription description) 515 { 516 if (destRect.isEmpty() || srcRect.isEmpty()) 517 return; 518 519 #if PLATFORM(IOS) 520 startAnimation(DoNotCatchUp); 521 #else 522 startAnimation(); 523 #endif 524 525 Color color = singlePixelSolidColor(); 526 if (color.isValid()) { 527 fillWithSolidColor(context, destRect, color, op); 528 return; 529 } 530 531 auto image = frameImageAtIndex(m_currentFrame, subsamplingScale(context, destRect, srcRect)); 532 if (!image) // If it's too early we won't have an image yet. 533 return; 534 535 ImageOrientation orientation(description.imageOrientation()); 536 if (description.respectImageOrientation() == RespectImageOrientation) 537 orientation = frameOrientationAtIndex(m_currentFrame); 538 539 drawNativeImage(image, context, destRect, srcRect, m_size, op, mode, orientation); 540 541 if (imageObserver()) 542 imageObserver()->didDraw(this); 543 } 544 545 void BitmapImage::drawPattern(GraphicsContext& ctxt, const FloatRect& tileRect, const AffineTransform& transform, const FloatPoint& phase, const FloatSize& spacing, CompositeOperator op, const FloatRect& destRect, BlendMode blendMode) 546 { 547 if (tileRect.isEmpty()) 548 return; 549 550 if (!ctxt.drawLuminanceMask()) { 551 Image::drawPattern(ctxt, tileRect, transform, phase, spacing, op, destRect, blendMode); 552 return; 553 } 554 555 if (!m_cachedImage) { 556 auto buffer = ImageBuffer::createCompatibleBuffer(expandedIntSize(tileRect.size()), ColorSpaceSRGB, ctxt); 557 if (!buffer) 558 return; 559 560 ImageObserver* observer = imageObserver(); 561 562 // Temporarily reset image observer, we don't want to receive any changeInRect() calls due to this relayout. 563 setImageObserver(nullptr); 564 565 draw(buffer->context(), tileRect, tileRect, op, blendMode, ImageOrientationDescription()); 566 567 setImageObserver(observer); 568 buffer->convertToLuminanceMask(); 569 570 m_cachedImage = buffer->copyImage(DontCopyBackingStore, Unscaled); 571 if (!m_cachedImage) 572 return; 573 } 574 575 ctxt.setDrawLuminanceMask(false); 576 m_cachedImage->drawPattern(ctxt, tileRect, transform, phase, spacing, op, destRect, blendMode); 577 } 578 481 579 bool BitmapImage::shouldAnimate() 482 580 { 483 581 return (repetitionCount(false) != cAnimationNone && !m_animationFinished && imageObserver()); 582 } 583 584 bool BitmapImage::canAnimate() 585 { 586 return shouldAnimate() && frameCount() > 1; 587 } 588 589 void BitmapImage::clearTimer() 590 { 591 m_frameTimer = nullptr; 592 } 593 594 void BitmapImage::startTimer(double delay) 595 { 596 ASSERT(!m_frameTimer); 597 m_frameTimer = std::make_unique<Timer>(*this, &BitmapImage::advanceAnimation); 598 m_frameTimer->startOneShot(delay); 484 599 } 485 600 … … 580 695 startTimer(0); 581 696 } 582 583 void BitmapImage::stopAnimation()584 {585 // This timer is used to animate all occurrences of this image. Don't invalidate586 // the timer unless all renderers have stopped drawing.587 clearTimer();588 }589 590 void BitmapImage::resetAnimation()591 {592 stopAnimation();593 m_currentFrame = 0;594 m_repetitionsComplete = 0;595 m_desiredFrameStartTime = 0;596 m_animationFinished = false;597 598 // For extremely large animations, when the animation is reset, we just throw everything away.599 destroyDecodedDataIfNecessary(true);600 }601 602 void BitmapImage::drawPattern(GraphicsContext& ctxt, const FloatRect& tileRect, const AffineTransform& transform,603 const FloatPoint& phase, const FloatSize& spacing, CompositeOperator op, const FloatRect& destRect, BlendMode blendMode)604 {605 if (tileRect.isEmpty())606 return;607 608 if (!ctxt.drawLuminanceMask()) {609 Image::drawPattern(ctxt, tileRect, transform, phase, spacing, op, destRect, blendMode);610 return;611 }612 if (!m_cachedImage) {613 auto buffer = ImageBuffer::createCompatibleBuffer(expandedIntSize(tileRect.size()), ColorSpaceSRGB, ctxt);614 if (!buffer)615 return;616 617 ImageObserver* observer = imageObserver();618 619 // Temporarily reset image observer, we don't want to receive any changeInRect() calls due to this relayout.620 setImageObserver(nullptr);621 622 draw(buffer->context(), tileRect, tileRect, op, blendMode, ImageOrientationDescription());623 624 setImageObserver(observer);625 buffer->convertToLuminanceMask();626 627 m_cachedImage = buffer->copyImage(DontCopyBackingStore, Unscaled);628 if (!m_cachedImage)629 return;630 }631 632 ctxt.setDrawLuminanceMask(false);633 m_cachedImage->drawPattern(ctxt, tileRect, transform, phase, spacing, op, destRect, blendMode);634 }635 636 697 637 698 void BitmapImage::advanceAnimation() … … 684 745 } 685 746 686 Color BitmapImage::singlePixelSolidColor() 687 { 688 // If the image size is not available yet or if the image will be animating don't use the solid color optimization. 689 if (frameCount() != 1) 690 return Color(); 691 692 if (m_solidColor) 693 return m_solidColor.value(); 694 695 // If the frame image is not loaded, first use the decoder to get the size of the image. 696 if (!haveFrameImageAtIndex(0) && m_source.frameSizeAtIndex(0, 0) != IntSize(1, 1)) { 697 m_solidColor = Color(); 698 return m_solidColor.value(); 699 } 700 701 // Cache the frame image. The size will be calculated from the NativeImagePtr. 702 if (!ensureFrameIsCached(0)) 703 return Color(); 704 705 ASSERT(m_frames.size()); 706 m_solidColor = NativeImage::singlePixelSolidColor(m_frames[0].m_image.get()); 707 708 ASSERT(m_solidColor); 709 return m_solidColor.value(); 710 } 711 712 bool BitmapImage::canAnimate() 713 { 714 return shouldAnimate() && frameCount() > 1; 747 void BitmapImage::stopAnimation() 748 { 749 // This timer is used to animate all occurrences of this image. Don't invalidate 750 // the timer unless all renderers have stopped drawing. 751 clearTimer(); 752 } 753 754 void BitmapImage::resetAnimation() 755 { 756 stopAnimation(); 757 m_currentFrame = 0; 758 m_repetitionsComplete = 0; 759 m_desiredFrameStartTime = 0; 760 m_animationFinished = false; 761 762 // For extremely large animations, when the animation is reset, we just throw everything away. 763 destroyDecodedDataIfNecessary(true); 715 764 } 716 765 -
trunk/Source/WebCore/platform/graphics/BitmapImage.h
r201424 r205682 48 48 49 49 namespace WebCore { 50 struct FrameData;51 }52 53 namespace WTF {54 template<> struct VectorTraits<WebCore::FrameData> : public SimpleClassVectorTraits {55 static const bool canInitializeWithMemset = false; // Not all FrameData members initialize to 0.56 };57 }58 59 namespace WebCore {60 50 61 51 class Timer; 62 63 namespace NativeImage {64 IntSize size(const NativeImagePtr&);65 bool hasAlpha(const NativeImagePtr&);66 Color singlePixelSolidColor(const NativeImagePtr&);67 }68 52 69 53 // ================================================ … … 76 60 : m_haveMetadata(false) 77 61 , m_isComplete(false) 78 , m_hasAlpha( true)62 , m_hasAlpha(false) 79 63 { 80 64 } 81 65 82 66 ~FrameData() 83 { 84 clear(true); 85 } 86 87 // Clear the cached image data on the frame, and (optionally) the metadata. 88 // Returns whether there was cached image data to clear. 89 bool clear(bool clearMetadata); 67 { 68 clearNativeImageSubImages(m_image); 69 } 70 71 unsigned clear(bool clearMetadata) 72 { 73 unsigned frameBytes = usedFrameBytes(); 74 75 if (clearMetadata) 76 m_haveMetadata = false; 77 78 m_subsamplingLevel = DefaultSubsamplingLevel; 79 m_image = nullptr; 80 81 return frameBytes; 82 } 90 83 91 84 unsigned usedFrameBytes() const { return m_image ? m_frameBytes : 0; } … … 93 86 NativeImagePtr m_image; 94 87 ImageOrientation m_orientation { DefaultImageOrientation }; 95 SubsamplingLevel m_subsamplingLevel { 0};88 SubsamplingLevel m_subsamplingLevel { DefaultSubsamplingLevel }; 96 89 float m_duration { 0 }; 97 90 bool m_haveMetadata : 1; … … 106 99 107 100 class BitmapImage final : public Image { 108 friend class GeneratedImage;109 friend class CrossfadeGeneratedImage;110 friend class GradientImage;111 friend class GraphicsContext;112 101 public: 113 102 static Ref<BitmapImage> create(NativeImagePtr&& nativeImage, ImageObserver* observer = nullptr) … … 124 113 virtual ~BitmapImage(); 125 114 126 bool hasSingleSecurityOrigin() const override ;115 bool hasSingleSecurityOrigin() const override { return true; } 127 116 128 117 // FloatSize due to override. … … 135 124 136 125 bool dataChanged(bool allDataReceived) override; 137 String filenameExtension() const override ;126 String filenameExtension() const override { return m_source.filenameExtension(); } 138 127 139 128 // It may look unusual that there is no start animation call as public API. This is because … … 156 145 #endif 157 146 158 #if USE(CG)159 WEBCORE_EXPORT CGImageRef getCGImageRef() override;160 CGImageRef getFirstCGImageRefOfSize(const IntSize&) override;161 RetainPtr<CFArrayRef> getCGImageArray() override;162 #endif163 164 147 #if PLATFORM(WIN) 165 148 bool getHBITMAP(HBITMAP) override; … … 175 158 #endif 176 159 160 WEBCORE_EXPORT NativeImagePtr nativeImage() override; 177 161 NativeImagePtr nativeImageForCurrentFrame() override; 162 #if USE(CG) 163 NativeImagePtr nativeImageOfSize(const IntSize&) override; 164 Vector<NativeImagePtr> framesNativeImages() override; 165 #endif 178 166 ImageOrientation orientationForCurrentFrame() override { return frameOrientationAtIndex(currentFrame()); } 179 167 … … 216 204 217 205 NativeImagePtr frameImageAtIndex(size_t, float presentationScaleHint = 1); 218 NativeImagePtr copyUnscaledFrameImageAtIndex(size_t);219 206 220 207 bool haveFrameImageAtIndex(size_t); … … 230 217 231 218 // Called before accessing m_frames[index] for info without decoding. Returns false on index out of bounds. 232 bool ensureFrame IsCached(size_t index, ImageFrameCaching = CacheMetadataAndFrame);219 bool ensureFrameAtIndexIsCached(size_t index, ImageFrameCaching = CacheMetadataAndFrame); 233 220 234 221 // Called to invalidate cached data. When |destroyAll| is true, we wipe out -
trunk/Source/WebCore/platform/graphics/Icon.h
r200530 r205682 29 29 30 30 #if PLATFORM(IOS) 31 #include "NativeImage Ptr.h"31 #include "NativeImage.h" 32 32 #include <CoreGraphics/CoreGraphics.h> 33 33 #elif PLATFORM(MAC) -
trunk/Source/WebCore/platform/graphics/Image.h
r201561 r205682 33 33 #include "GraphicsTypes.h" 34 34 #include "ImageOrientation.h" 35 #include "NativeImage Ptr.h"35 #include "NativeImage.h" 36 36 #include <wtf/Optional.h> 37 37 #include <wtf/PassRefPtr.h> … … 138 138 enum TileRule { StretchTile, RoundTile, SpaceTile, RepeatTile }; 139 139 140 virtual NativeImagePtr nativeImage() { return nullptr; } 141 virtual NativeImagePtr nativeImageOfSize(const IntSize&) { return nullptr; } 140 142 virtual NativeImagePtr nativeImageForCurrentFrame() { return nullptr; } 141 143 virtual ImageOrientation orientationForCurrentFrame() { return ImageOrientation(); } 144 virtual Vector<NativeImagePtr> framesNativeImages() { return { }; } 142 145 143 146 // Accessors for native image formats. … … 149 152 #if PLATFORM(COCOA) 150 153 virtual CFDataRef getTIFFRepresentation() { return nullptr; } 151 #endif152 153 #if USE(CG)154 virtual CGImageRef getCGImageRef() { return nullptr; }155 virtual CGImageRef getFirstCGImageRefOfSize(const IntSize&) { return nullptr; }156 virtual RetainPtr<CFArrayRef> getCGImageArray() { return nullptr; }157 154 #endif 158 155 -
trunk/Source/WebCore/platform/graphics/ImageSource.cpp
r200939 r205682 95 95 { 96 96 if (!m_allowSubsampling || !allowSubsamplingOfFrameAtIndex(0)) 97 return 0;97 return DefaultSubsamplingLevel; 98 98 99 99 // FIXME: this value was chosen to be appropriate for iOS since the image … … 101 101 // if image subsampling is enabled on other platform. 102 102 const int maximumImageAreaBeforeSubsampling = 5 * 1024 * 1024; 103 const SubsamplingLevel maxSubsamplingLevel = 3; 104 105 for (SubsamplingLevel level = 0; level < maxSubsamplingLevel; ++level) { 103 104 for (SubsamplingLevel level = MinSubsamplingLevel; level < MaxSubsamplingLevel; ++level) { 106 105 if (frameSizeAtIndex(0, level).area() < maximumImageAreaBeforeSubsampling) 107 106 return level; 108 107 } 109 108 110 return maxSubsamplingLevel;109 return MaxSubsamplingLevel; 111 110 } 112 111 … … 149 148 IntSize ImageSource::size() const 150 149 { 151 return frameSizeAtIndex(0, 0);150 return frameSizeAtIndex(0, DefaultSubsamplingLevel); 152 151 } 153 152 154 153 IntSize ImageSource::sizeRespectingOrientation() const 155 154 { 156 return frameSizeAtIndex(0, 0, RespectImageOrientation);155 return frameSizeAtIndex(0, DefaultSubsamplingLevel, RespectImageOrientation); 157 156 } 158 157 -
trunk/Source/WebCore/platform/graphics/ImageSource.h
r204466 r205682 30 30 #include "ImageOrientation.h" 31 31 #include "IntPoint.h" 32 #include "NativeImage Ptr.h"32 #include "NativeImage.h" 33 33 #include "TextStream.h" 34 34 #include <wtf/Forward.h> … … 63 63 64 64 // SubsamplingLevel. 0 is no subsampling, 1 is half dimensions on each axis etc. 65 typedef short SubsamplingLevel; 65 using SubsamplingLevel = int; 66 67 enum : SubsamplingLevel { 68 NilSubsamplingLevel = -1, 69 MinSubsamplingLevel = 0, 70 MaxSubsamplingLevel = 3, 71 DefaultSubsamplingLevel = MinSubsamplingLevel 72 }; 66 73 67 74 class ImageSource { … … 131 138 132 139 // Size of optionally subsampled frame. 133 IntSize frameSizeAtIndex(size_t, SubsamplingLevel = 0, RespectImageOrientationEnum = DoNotRespectImageOrientation) const;140 IntSize frameSizeAtIndex(size_t, SubsamplingLevel = DefaultSubsamplingLevel, RespectImageOrientationEnum = DoNotRespectImageOrientation) const; 134 141 135 142 // Return the number of bytes in the decoded frame. If the frame is not yet 136 143 // decoded then return 0. 137 unsigned frameBytesAtIndex(size_t, SubsamplingLevel = 0) const;144 unsigned frameBytesAtIndex(size_t, SubsamplingLevel = DefaultSubsamplingLevel) const; 138 145 139 146 float frameDurationAtIndex(size_t); … … 142 149 // Callers should not call this after calling clear() with a higher index; 143 150 // see comments on clear() above. 144 NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = 0);151 NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = DefaultSubsamplingLevel); 145 152 146 153 private: … … 154 161 bool m_needsUpdateMetadata { false }; 155 162 size_t m_frameCount { 0 }; 156 Optional<SubsamplingLevel> m_maximumSubsamplingLevel { 0};163 Optional<SubsamplingLevel> m_maximumSubsamplingLevel { DefaultSubsamplingLevel }; 157 164 158 165 // The default value of m_allowSubsampling should be the same as defaultImageSubsamplingEnabled in Settings.cpp -
trunk/Source/WebCore/platform/graphics/MediaPlayer.h
r201474 r205682 37 37 #include "LayoutRect.h" 38 38 #include "MediaPlayerEnums.h" 39 #include "NativeImage Ptr.h"39 #include "NativeImage.h" 40 40 #include "PlatformLayer.h" 41 41 #include "PlatformMediaResourceLoader.h" -
trunk/Source/WebCore/platform/graphics/NativeImage.h
r205681 r205682 1 1 /* 2 * Copyright (C) 2004, 2005, 2006 Apple Inc. All rights reserved.2 * Copyright (C) 2004, 2005, 2006, 2016 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2007-2008 Torch Mobile, Inc. 4 4 * Copyright (C) 2012 Company 100 Inc. … … 23 23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 26 */ 27 27 28 #ifndef NativeImagePtr_h 29 #define NativeImagePtr_h 28 #pragma once 29 30 #include "GraphicsTypes.h" 31 #include "ImageOrientation.h" 30 32 31 33 #if USE(CG) … … 40 42 namespace WebCore { 41 43 44 class Color; 45 class FloatRect; 46 class IntSize; 47 class GraphicsContext; 48 42 49 #if USE(CG) 43 50 typedef RetainPtr<CGImageRef> NativeImagePtr; … … 48 55 #endif 49 56 57 IntSize nativeImageSize(const NativeImagePtr&); 58 bool nativeImageHasAlpha(const NativeImagePtr&); 59 Color nativeImageSinglePixelSolidColor(const NativeImagePtr&); 60 61 float subsamplingScale(GraphicsContext&, const FloatRect& destRect, const FloatRect& srcRect); 62 63 void drawNativeImage(const NativeImagePtr&, GraphicsContext&, const FloatRect&, const FloatRect&, const IntSize&, CompositeOperator, BlendMode, const ImageOrientation&); 64 void clearNativeImageSubImages(const NativeImagePtr&); 65 50 66 } 51 52 #endif -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm
r205348 r205682 298 298 return; 299 299 300 m_pausedImage = image-> getCGImageRef();300 m_pausedImage = image->nativeImage(); 301 301 ASSERT(m_pausedImage); 302 302 } -
trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp
r200967 r205682 158 158 { 159 159 if (m_size.isEmpty()) 160 m_size = frameSizeAtIndex(0 , 0);160 m_size = frameSizeAtIndex(0); 161 161 return m_size; 162 162 } -
trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.h
r199735 r205682 58 58 Optional<IntPoint> hotSpot() const; 59 59 60 IntSize frameSizeAtIndex(size_t, SubsamplingLevel ) const;60 IntSize frameSizeAtIndex(size_t, SubsamplingLevel = DefaultSubsamplingLevel) const; 61 61 bool frameIsCompleteAtIndex(size_t) const; 62 62 ImageOrientation orientationAtIndex(size_t) const; -
trunk/Source/WebCore/platform/graphics/cg/PatternCG.cpp
r201482 r205682 73 73 // instead of custom patterns, and avoid tiling-edge pixel cracks. 74 74 if (m_repeatX && m_repeatY) 75 return wkCGPatternCreateWithImageAndTransform(tileImage()-> getCGImageRef(), patternTransform, wkPatternTilingConstantSpacing);75 return wkCGPatternCreateWithImageAndTransform(tileImage()->nativeImage().get(), patternTransform, wkPatternTilingConstantSpacing); 76 76 77 77 // If FLT_MAX should also be used for xStep or yStep, nothing is rendered. Using fractions of FLT_MAX also … … 84 84 85 85 // The pattern will release the CGImageRef when it's done rendering in patternReleaseCallback 86 CGImageRef platformImage = CGImageRetain(tileImage()->getCGImageRef());86 CGImageRef platformImage = tileImage()->nativeImage().leakRef(); 87 87 88 88 const CGPatternCallbacks patternCallbacks = { 0, patternCallback, patternReleaseCallback }; -
trunk/Source/WebCore/platform/graphics/cocoa/TextTrackRepresentationCocoa.mm
r201463 r205682 130 130 { 131 131 if (auto representation = m_client.createTextTrackRepresentationImage()) 132 [m_layer.get() setContents:(id)representation-> getCGImageRef()];132 [m_layer.get() setContents:(id)representation->nativeImage().get()]; 133 133 } 134 134 -
trunk/Source/WebCore/platform/graphics/mac/ImageMac.mm
r205516 r205682 80 80 return m_tiffRep.get(); 81 81 82 unsigned numFrames = frameCount();82 auto nativeImages = this->framesNativeImages(); 83 83 84 // If numFramesis zero, we know for certain this image doesn't have valid data84 // If framesImages.size() is zero, we know for certain this image doesn't have valid data 85 85 // Even though the call to CGImageDestinationCreateWithData will fail and we'll handle it gracefully, 86 86 // in certain circumstances that call will spam the console with an error message 87 if (!numFrames) 88 return 0; 89 90 Vector<CGImageRef> images; 91 for (unsigned i = 0; i < numFrames; ++i ) { 92 CGImageRef cgImage = frameImageAtIndex(i).get(); 93 if (cgImage) 94 images.append(cgImage); 95 } 96 97 unsigned numValidFrames = images.size(); 87 if (!nativeImages.size()) 88 return nullptr; 98 89 99 90 RetainPtr<CFMutableDataRef> data = adoptCF(CFDataCreateMutable(0, 0)); 100 RetainPtr<CGImageDestinationRef> destination = adoptCF(CGImageDestinationCreateWithData(data.get(), kUTTypeTIFF, n umValidFrames, 0));91 RetainPtr<CGImageDestinationRef> destination = adoptCF(CGImageDestinationCreateWithData(data.get(), kUTTypeTIFF, nativeImages.size(), 0)); 101 92 102 93 if (!destination) 103 return 0;94 return nullptr; 104 95 105 for ( unsigned i = 0; i < numValidFrames; ++i)106 CGImageDestinationAddImage(destination.get(), images[i], 0);96 for (auto nativeImage : nativeImages) 97 CGImageDestinationAddImage(destination.get(), nativeImage.get(), 0); 107 98 108 99 CGImageDestinationFinalize(destination.get()); -
trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.mm
r203739 r205682 143 143 break; 144 144 145 m_previewImage = image-> getCGImageRef();145 m_previewImage = image->nativeImage(); 146 146 if (!m_previewImage) 147 147 break; … … 155 155 void MockRealtimeVideoSourceMac::updateSampleBuffer() 156 156 { 157 auto pixelBuffer = pixelBufferFromCGImage(imageBuffer()->copyImage()-> getCGImageRef());157 auto pixelBuffer = pixelBufferFromCGImage(imageBuffer()->copyImage()->nativeImage().get()); 158 158 auto sampleBuffer = CMSampleBufferFromPixelBuffer(pixelBuffer.get()); 159 159 -
trunk/Source/WebCore/platform/win/DragImageCGWin.cpp
r198655 r205682 137 137 CGContextSetFillColor(drawContext, white); 138 138 CGContextFillRect(drawContext, rect); 139 if (auto srcImage = img-> getCGImageRef()) {139 if (auto srcImage = img->nativeImage()) { 140 140 CGContextSetBlendMode(drawContext, kCGBlendModeNormal); 141 CGContextDrawImage(drawContext, rect, srcImage );141 CGContextDrawImage(drawContext, rect, srcImage.get()); 142 142 } 143 143 CGContextRelease(drawContext); -
trunk/Source/WebKit/mac/ChangeLog
r205592 r205682 1 2016-09-08 Said Abou-Hallawa <sabouhallawa@apple.com> 2 3 Move the BitmapImage platform dependent code to a new file named NativeImage[CG|Cairo].cpp 4 https://bugs.webkit.org/show_bug.cgi?id=158684 5 6 Reviewed by Simon Fraser. 7 8 * DOM/DOM.mm: 9 (-[DOMNode getPreviewSnapshotImage:andRects:]): 10 * Misc/WebCache.mm: 11 (+[WebCache imageForURL:]): 12 Replace BitmapImage::getCGImageRef() with BitmapImage::nativeImage(). 13 1 14 2016-09-07 Joseph Pecoraro <pecoraro@apple.com> 2 15 -
trunk/Source/WebKit/mac/DOM/DOM.mm
r204717 r205682 562 562 if (textIndicator) { 563 563 if (Image* image = textIndicator->contentImage()) 564 *cgImage = (CGImageRef)CFAutorelease(CGImageRetain(image->getCGImageRef()));564 *cgImage = image->nativeImage().autorelease(); 565 565 } 566 566 -
trunk/Source/WebKit/mac/Misc/WebCache.mm
r198655 r205682 205 205 if (!cachedImage.hasImage()) 206 206 return nullptr; 207 return cachedImage.image()-> getCGImageRef();207 return cachedImage.image()->nativeImage().get(); 208 208 } 209 209 -
trunk/Source/WebKit2/ChangeLog
r205594 r205682 1 2016-09-08 Said Abou-Hallawa <sabouhallawa@apple.com> 2 3 Move the BitmapImage platform dependent code to a new file named NativeImage[CG|Cairo].cpp 4 https://bugs.webkit.org/show_bug.cgi?id=158684 5 6 Reviewed by Simon Fraser. 7 8 * UIProcess/API/C/cg/WKIconDatabaseCG.cpp: 9 (WKIconDatabaseTryGetCGImageForURL): 10 (WKIconDatabaseTryCopyCGImageArrayForURL): 11 It was the only place in the code which uses BitmapImage::getCGImageArray(). 12 Call BitmapImage::framesNativeImages() instead and form the returned 13 Vector<NativeImagePtr> build the CFArrayRef. 14 15 * UIProcess/WebIconDatabase.h: 16 Include "NativeImage.h" instead of "NativeImagePtr.h". 17 18 * UIProcess/ios/WKContentViewInteraction.mm: 19 (-[WKContentView _presentationSnapshotForPreviewItemController:]): 20 * WebProcess/Plugins/PluginView.cpp: 21 (WebKit::isAlmostSolidColor): 22 Call BitmapImage::getCGImageRef() instead of calling BitmapImage::nativeImage(). 23 1 24 2016-09-08 Zan Dobersek <zdobersek@igalia.com> 2 25 -
trunk/Source/WebKit2/UIProcess/API/C/cg/WKIconDatabaseCG.cpp
r95901 r205682 38 38 { 39 39 Image* image = toImpl(iconDatabaseRef)->imageForPageURL(toWTFString(urlRef)); 40 return image ? image-> getFirstCGImageRefOfSize(IntSize(static_cast<int>(size.width), static_cast<int>(size.height))) : 0;40 return image ? image->nativeImageOfSize(IntSize(static_cast<int>(size.width), static_cast<int>(size.height))).get() : nullptr; 41 41 } 42 42 … … 44 44 { 45 45 Image* image = toImpl(iconDatabaseRef)->imageForPageURL(toWTFString(urlRef)); 46 return image ? image->getCGImageArray().leakRef() : 0; 46 if (!image) 47 return nullptr; 48 49 auto nativeImages = image->framesNativeImages(); 50 if (!nativeImages.size()) 51 return nullptr; 52 53 CFMutableArrayRef array = CFArrayCreateMutable(nullptr, nativeImages.size(), &kCFTypeArrayCallBacks); 54 for (auto nativeImage : nativeImages) 55 CFArrayAppendValue(array, nativeImage.get()); 56 57 return static_cast<CFArrayRef>(CFRetain(array)); 47 58 } 48 59 -
trunk/Source/WebKit2/UIProcess/WebIconDatabase.h
r204668 r205682 32 32 #include <WebCore/IconDatabaseClient.h> 33 33 #include <WebCore/IntSize.h> 34 #include <WebCore/NativeImage Ptr.h>34 #include <WebCore/NativeImage.h> 35 35 36 36 namespace API { -
trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm
r204886 r205682 4132 4132 if (!_positionInformation.linkIndicator.contentImage) 4133 4133 return nullptr; 4134 return [[[UIImage alloc] initWithCGImage:_positionInformation.linkIndicator.contentImage-> getCGImageRef()] autorelease];4134 return [[[UIImage alloc] initWithCGImage:_positionInformation.linkIndicator.contentImage->nativeImage().get()] autorelease]; 4135 4135 } 4136 4136 -
trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp
r204702 r205682 1731 1731 static bool isAlmostSolidColor(BitmapImage* bitmap) 1732 1732 { 1733 CGImageRef image = bitmap-> getCGImageRef();1733 CGImageRef image = bitmap->nativeImage().get(); 1734 1734 ASSERT(CGImageGetBitsPerComponent(image) == 8); 1735 1735
Note: See TracChangeset
for help on using the changeset viewer.