Changeset 205682 in webkit


Ignore:
Timestamp:
Sep 8, 2016 6:06:47 PM (8 years ago)
Author:
commit-queue@webkit.org
Message:

Move the BitmapImage platform dependent code to a new file named NativeImage[CG|Cairo].cpp
https://bugs.webkit.org/show_bug.cgi?id=158684

Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2016-09-08
Reviewed by Simon Fraser.

Source/WebCore:

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):

Source/WebKit/mac:

  • DOM/DOM.mm:

(-[DOMNode getPreviewSnapshotImage:andRects:]):

  • Misc/WebCache.mm:

(+[WebCache imageForURL:]):
Replace BitmapImage::getCGImageRef() with BitmapImage::nativeImage().

Source/WebKit2:

  • 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().

Location:
trunk/Source
Files:
2 added
2 deleted
33 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r205679 r205682  
     12016-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
    11102016-09-08  Alex Christensen  <achristensen@webkit.org>
    2111
  • trunk/Source/WebCore/PlatformAppleWin.cmake

    r204599 r205682  
    5656    platform/graphics/ca/win/WKCACFViewLayerTreeHost.cpp
    5757
    58     platform/graphics/cg/BitmapImageCG.cpp
    5958    platform/graphics/cg/ColorCG.cpp
    6059    platform/graphics/cg/FloatPointCG.cpp
     
    7372    platform/graphics/cg/IntRectCG.cpp
    7473    platform/graphics/cg/IntSizeCG.cpp
     74    platform/graphics/cg/NativeImageCG.cpp
    7575    platform/graphics/cg/PDFDocumentImage.cpp
    7676    platform/graphics/cg/PathCG.cpp
  • trunk/Source/WebCore/PlatformEfl.cmake

    r205556 r205682  
    127127
    128128    platform/graphics/cairo/BackingStoreBackendCairoImpl.cpp
    129     platform/graphics/cairo/BitmapImageCairo.cpp
    130129    platform/graphics/cairo/CairoUtilities.cpp
    131130    platform/graphics/cairo/FontCairo.cpp
     
    136135    platform/graphics/cairo/ImageCairo.cpp
    137136    platform/graphics/cairo/IntRectCairo.cpp
     137    platform/graphics/cairo/NativeImageCairo.cpp
    138138    platform/graphics/cairo/PathCairo.cpp
    139139    platform/graphics/cairo/PatternCairo.cpp
  • trunk/Source/WebCore/PlatformGTK.cmake

    r205280 r205682  
    106106    platform/graphics/cairo/BackingStoreBackendCairoImpl.cpp
    107107    platform/graphics/cairo/BackingStoreBackendCairoX11.cpp
    108     platform/graphics/cairo/BitmapImageCairo.cpp
    109108    platform/graphics/cairo/CairoUtilities.cpp
    110109    platform/graphics/cairo/FloatRectCairo.cpp
     
    117116    platform/graphics/cairo/ImageCairo.cpp
    118117    platform/graphics/cairo/IntRectCairo.cpp
     118    platform/graphics/cairo/NativeImageCairo.cpp
    119119    platform/graphics/cairo/PathCairo.cpp
    120120    platform/graphics/cairo/PatternCairo.cpp
  • trunk/Source/WebCore/PlatformMac.cmake

    r205308 r205682  
    386386    platform/graphics/ca/cocoa/WebTiledBackingLayer.mm
    387387
    388     platform/graphics/cg/BitmapImageCG.cpp
    389388    platform/graphics/cg/ColorCG.cpp
    390389    platform/graphics/cg/FloatPointCG.cpp
     
    403402    platform/graphics/cg/IntRectCG.cpp
    404403    platform/graphics/cg/IntSizeCG.cpp
     404    platform/graphics/cg/NativeImageCG.cpp
    405405    platform/graphics/cg/PDFDocumentImage.cpp
    406406    platform/graphics/cg/PathCG.cpp
  • trunk/Source/WebCore/PlatformWinCairo.cmake

    r204483 r205682  
    2222    platform/graphics/PlatformDisplay.cpp
    2323
    24     platform/graphics/cairo/BitmapImageCairo.cpp
    2524    platform/graphics/cairo/CairoUtilities.cpp
    2625    platform/graphics/cairo/FloatRectCairo.cpp
     
    3231    platform/graphics/cairo/ImageCairo.cpp
    3332    platform/graphics/cairo/IntRectCairo.cpp
     33    platform/graphics/cairo/NativeImageCairo.cpp
    3434    platform/graphics/cairo/PathCairo.cpp
    3535    platform/graphics/cairo/PatternCairo.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r205660 r205682  
    14251425                376DCCE113B4F966002EBEFC /* TextRun.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 376DCCE013B4F966002EBEFC /* TextRun.cpp */; };
    14261426                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 */; };
    14281428                37919C230B7D188600A56998 /* PositionIterator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37919C210B7D188600A56998 /* PositionIterator.cpp */; };
    14291429                37919C240B7D188600A56998 /* PositionIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = 37919C220B7D188600A56998 /* PositionIterator.h */; settings = {ATTRIBUTES = (); }; };
     
    22752275                555B87EC1CAAF0AB00349425 /* ImageDecoderCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 555B87EA1CAAF0AB00349425 /* ImageDecoderCG.cpp */; };
    22762276                555B87ED1CAAF0AB00349425 /* ImageDecoderCG.h in Headers */ = {isa = PBXBuildFile; fileRef = 555B87EB1CAAF0AB00349425 /* ImageDecoderCG.h */; };
     2277                55A336F71D8209F40022C4C7 /* NativeImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 55A336F61D8209F40022C4C7 /* NativeImage.h */; };
    22772278                5709E8CD1D413D47003244AC /* WebKitSubtleCrypto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5709E8CA1D413CE3003244AC /* WebKitSubtleCrypto.cpp */; };
    22782279                5709E8CE1D413D5B003244AC /* JSWebKitSubtleCryptoCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FF8F661807460800132674 /* JSWebKitSubtleCryptoCustom.cpp */; };
     
    25142515                69A6CBAC1C6BE42C00B836E9 /* AccessibilitySVGElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 697101071C6BE1550018C7F1 /* AccessibilitySVGElement.cpp */; };
    25152516                69A6CBAD1C6BE42C00B836E9 /* AccessibilitySVGElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 697101081C6BE1550018C7F1 /* AccessibilitySVGElement.h */; };
    2516                 6B3480940EEF50D400AC1B41 /* NativeImagePtr.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, ); }; };
    25172518                6B693A2E1C51A82E00B03BEF /* ResourceLoadObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B693A2D1C51A82E00B03BEF /* ResourceLoadObserver.h */; settings = {ATTRIBUTES = (Private, ); }; };
    25182519                6B693A341C51A95D00B03BEF /* ResourceLoadObserver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6B693A331C51A95D00B03BEF /* ResourceLoadObserver.cpp */; };
     
    83558356                3772B09516535856000A49CA /* PopupOpeningObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PopupOpeningObserver.h; sourceTree = "<group>"; };
    83568357                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>"; };
    83588359                37919C210B7D188600A56998 /* PositionIterator.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = PositionIterator.cpp; sourceTree = "<group>"; };
    83598360                37919C220B7D188600A56998 /* PositionIterator.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PositionIterator.h; sourceTree = "<group>"; };
     
    92909291                555B87EA1CAAF0AB00349425 /* ImageDecoderCG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageDecoderCG.cpp; sourceTree = "<group>"; };
    92919292                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>"; };
    92929294                55D408F71A7C631800C78450 /* SVGImageClients.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGImageClients.h; sourceTree = "<group>"; };
    92939295                5709E8CA1D413CE3003244AC /* WebKitSubtleCrypto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebKitSubtleCrypto.cpp; sourceTree = "<group>"; };
     
    95559557                697101071C6BE1550018C7F1 /* AccessibilitySVGElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AccessibilitySVGElement.cpp; sourceTree = "<group>"; };
    95569558                697101081C6BE1550018C7F1 /* AccessibilitySVGElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilitySVGElement.h; sourceTree = "<group>"; };
    9557                 6B3480920EEF50D400AC1B41 /* NativeImagePtr.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>"; };
    95589560                6B693A2D1C51A82E00B03BEF /* ResourceLoadObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadObserver.h; sourceTree = "<group>"; };
    95599561                6B693A331C51A95D00B03BEF /* ResourceLoadObserver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceLoadObserver.cpp; sourceTree = "<group>"; };
     
    2050720509                        isa = PBXGroup;
    2050820510                        children = (
    20509                                 377A3A8F15EFCE9A0059F5C7 /* BitmapImageCG.cpp */,
    2051020511                                0FCF33230F2B9715004B6795 /* ColorCG.cpp */,
    2051120512                                B275352B0B053814002CE64F /* FloatPointCG.cpp */,
     
    2053420535                                B27535360B053814002CE64F /* PDFDocumentImage.cpp */,
    2053520536                                B27535370B053814002CE64F /* PDFDocumentImage.h */,
     20537                                377A3A8F15EFCE9A0059F5C7 /* NativeImageCG.cpp */,
    2053620538                                1FC40FB81655C5910040F29E /* SubimageCacheWithTimer.cpp */,
    2053720539                                1FC40FB71655C5910040F29E /* SubimageCacheWithTimer.h */,
     
    2072520727                                314BE3A41B3103FB00141982 /* NamedImageGeneratedImage.cpp */,
    2072620728                                314BE3A51B3103FB00141982 /* NamedImageGeneratedImage.h */,
    20727                                 6B3480920EEF50D400AC1B41 /* NativeImagePtr.h */,
     20729                                6B3480920EEF50D400AC1B41 /* NativeImage.h */,
    2072820730                                B27535520B053814002CE64F /* Path.cpp */,
    2072920731                                B27535530B053814002CE64F /* Path.h */,
     
    2076720769                                379919941200DDF400EA041C /* WOFFFileFormat.cpp */,
    2076820770                                379919951200DDF400EA041C /* WOFFFileFormat.h */,
     20771                                55A336F61D8209F40022C4C7 /* NativeImage.h */,
    2076920772                        );
    2077020773                        path = graphics;
     
    2570325706                                A81872230977D3C0005826D9 /* NamedNodeMap.h in Headers */,
    2570425707                                A818721E0977D3C0005826D9 /* NameNodeList.h in Headers */,
    25705                                 6B3480940EEF50D400AC1B41 /* NativeImagePtr.h in Headers */,
     25708                                6B3480940EEF50D400AC1B41 /* NativeImage.h in Headers */,
    2570625709                                83B2D1751B8BCD6A00A02E47 /* NativeNodeFilter.h in Headers */,
    2570725710                                E10B9B6C0B747599003ED890 /* NativeXPathNSResolver.h in Headers */,
     
    2578125784                                1A569D170D7E2B82007C3983 /* objc_runtime.h in Headers */,
    2578225785                                1A569D190D7E2B82007C3983 /* objc_utility.h in Headers */,
     25786                                55A336F71D8209F40022C4C7 /* NativeImage.h in Headers */,
    2578325787                                E16982551134629D00894115 /* ObjCRuntimeObject.h in Headers */,
    2578425788                                7E5D7A77161D3F8F00896C34 /* OESElementIndexUint.h in Headers */,
     
    2760027604                                FD31602612B0267600C1A359 /* BiquadProcessor.cpp in Sources */,
    2760127605                                A89943290B42338800D7C802 /* BitmapImage.cpp in Sources */,
    27602                                 377A3A9015EFCE9B0059F5C7 /* BitmapImageCG.cpp in Sources */,
     27606                                377A3A9015EFCE9B0059F5C7 /* NativeImageCG.cpp in Sources */,
    2760327607                                1AFFC4541D5E81CB00267A66 /* BlacklistUpdater.mm in Sources */,
    2760427608                                976D6C78122B8A3D001FD1F7 /* Blob.cpp in Sources */,
  • trunk/Source/WebCore/loader/cache/MemoryCache.h

    r200066 r205682  
    2626#define Cache_h
    2727
    28 #include "NativeImagePtr.h"
     28#include "NativeImage.h"
    2929#include "SecurityOriginHash.h"
    3030#include "SessionID.h"
  • trunk/Source/WebCore/loader/icon/IconDatabaseBase.h

    r198655 r205682  
    2727#define IconDatabaseBase_h
    2828
    29 #include "NativeImagePtr.h"
     29#include "NativeImage.h"
    3030#include <wtf/Forward.h>
    3131#include <wtf/Noncopyable.h>
  • trunk/Source/WebCore/page/mac/TextIndicatorWindow.mm

    r202611 r205682  
    163163    RetainPtr<CGImageRef> contentsImage;
    164164    if (indicatorWantsContentCrossfade(*_textIndicator))
    165         contentsImage = _textIndicator->contentImageWithHighlight()->getCGImageRef();
     165        contentsImage = _textIndicator->contentImageWithHighlight()->nativeImage();
    166166    else
    167         contentsImage = _textIndicator->contentImage()->getCGImageRef();
     167        contentsImage = _textIndicator->contentImage()->nativeImage();
    168168
    169169    RetainPtr<NSMutableArray> bounceLayers = adoptNS([[NSMutableArray alloc] init]);
     
    266266{
    267267    RetainPtr<CABasicAnimation> crossfadeAnimation = [CABasicAnimation animationWithKeyPath:@"contents"];
    268     RetainPtr<CGImageRef> contentsImage = textIndicator.contentImage()->getCGImageRef();
     268    RetainPtr<CGImageRef> contentsImage = textIndicator.contentImage()->nativeImage();
    269269    [crossfadeAnimation setToValue:(id)contentsImage.get()];
    270270    [crossfadeAnimation setFillMode:kCAFillModeForwards];
  • trunk/Source/WebCore/platform/graphics/BitmapImage.cpp

    r204205 r205682  
    7171    // Since we don't have a decoder, we can't figure out the image orientation.
    7272    // 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);
    7474    m_decodedSize = m_size.area() * 4;
    75    
     75
    7676    m_frames.grow(1);
    77     m_frames[0].m_hasAlpha = NativeImage::hasAlpha(image);
     77    m_frames[0].m_hasAlpha = nativeImageHasAlpha(image);
    7878    m_frames[0].m_haveMetadata = true;
    7979    m_frames[0].m_image = WTFMove(image);
     
    8686}
    8787
    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 
    10088bool BitmapImage::haveFrameImageAtIndex(size_t index)
    10189{
     
    10795
    10896    return m_frames[index].m_image;
    109 }
    110 
    111 bool BitmapImage::hasSingleSecurityOrigin() const
    112 {
    113     return true;
    11497}
    11598
     
    126109        // save the memory for the framebuffer data), so we don't need to clear
    127110        // 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);
    131112    }
    132113
     
    151132
    152133    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();
    155136
    156137    if (allFrameBytes > largeAnimationCutoff) {
     
    289270    // incomplete frames to be safe.
    290271    unsigned frameBytesCleared = 0;
    291     for (size_t i = 0; i < m_frames.size(); ++i) {
     272    for (auto& frame : m_frames) {
    292273        // NOTE: Don't call frameIsCompleteAtIndex() here, that will try to
    293274        // decode any uncached (i.e. never-decoded or
    294275        // 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);
    298278    }
    299279    destroyMetadataAndNotify(frameBytesCleared, ClearedSource::No);
     
    302282    int deltaBytes = 0;
    303283    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)) {
    306285            deltaBytes += bytes;
    307286            deltaBytes += m_decodedPropertiesSize;
     
    338317}
    339318
    340 String BitmapImage::filenameExtension() const
    341 {
    342     return m_source.filenameExtension();
    343 }
    344 
    345319size_t BitmapImage::frameCount()
    346320{
     
    367341}
    368342
    369 bool BitmapImage::ensureFrameIsCached(size_t index, ImageFrameCaching frameCaching)
     343bool BitmapImage::ensureFrameAtIndexIsCached(size_t index, ImageFrameCaching frameCaching)
    370344{
    371345    if (index >= frameCount())
     
    395369
    396370        // 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);
    399372        invalidatePlatformData();
    400373        m_decodedSize += sizeChange;
     
    409382    return m_frames[index].m_image;
    410383}
     384   
     385NativeImagePtr BitmapImage::nativeImage()
     386{
     387    return frameImageAtIndex(0);
     388}
     389
     390NativeImagePtr BitmapImage::nativeImageForCurrentFrame()
     391{
     392    return frameImageAtIndex(m_currentFrame);
     393}
     394   
     395#if USE(CG)
     396NativeImagePtr 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   
     410Vector<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
    411423
    412424bool BitmapImage::frameIsCompleteAtIndex(size_t index)
    413425{
    414     if (!ensureFrameIsCached(index, CacheMetadataOnly))
     426    if (!ensureFrameAtIndexIsCached(index, CacheMetadataOnly))
    415427        return false;
    416428
     
    420432float BitmapImage::frameDurationAtIndex(size_t index)
    421433{
    422     if (!ensureFrameIsCached(index, CacheMetadataOnly))
     434    if (!ensureFrameAtIndexIsCached(index, CacheMetadataOnly))
    423435        return 0;
    424436
     
    426438}
    427439
    428 NativeImagePtr BitmapImage::nativeImageForCurrentFrame()
    429 {
    430     return frameImageAtIndex(currentFrame());
    431 }
    432 
    433440bool BitmapImage::frameHasAlphaAtIndex(size_t index)
    434441{
    435     if (!ensureFrameIsCached(index, CacheMetadataOnly))
     442    if (!ensureFrameAtIndexIsCached(index, CacheMetadataOnly))
    436443        return true;
    437444
     
    449456ImageOrientation BitmapImage::frameOrientationAtIndex(size_t index)
    450457{
    451     if (!ensureFrameIsCached(index, CacheMetadataOnly))
     458    if (!ensureFrameAtIndexIsCached(index, CacheMetadataOnly))
    452459        return ImageOrientation();
    453460
     
    456463
    457464    return m_source.orientationAtIndex(index);
     465}
     466
     467Color 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();
    458491}
    459492
     
    479512}
    480513
     514void 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   
     545void 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
    481579bool BitmapImage::shouldAnimate()
    482580{
    483581    return (repetitionCount(false) != cAnimationNone && !m_animationFinished && imageObserver());
     582}
     583
     584bool BitmapImage::canAnimate()
     585{
     586    return shouldAnimate() && frameCount() > 1;
     587}
     588
     589void BitmapImage::clearTimer()
     590{
     591    m_frameTimer = nullptr;
     592}
     593
     594void BitmapImage::startTimer(double delay)
     595{
     596    ASSERT(!m_frameTimer);
     597    m_frameTimer = std::make_unique<Timer>(*this, &BitmapImage::advanceAnimation);
     598    m_frameTimer->startOneShot(delay);
    484599}
    485600
     
    580695    startTimer(0);
    581696}
    582 
    583 void BitmapImage::stopAnimation()
    584 {
    585     // This timer is used to animate all occurrences of this image. Don't invalidate
    586     // 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 
    636697
    637698void BitmapImage::advanceAnimation()
     
    684745}
    685746
    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;
     747void 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
     754void 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);
    715764}
    716765
  • trunk/Source/WebCore/platform/graphics/BitmapImage.h

    r201424 r205682  
    4848
    4949namespace 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 {
    6050
    6151class Timer;
    62 
    63 namespace NativeImage {
    64     IntSize size(const NativeImagePtr&);
    65     bool hasAlpha(const NativeImagePtr&);
    66     Color singlePixelSolidColor(const NativeImagePtr&);
    67 }
    6852
    6953// ================================================
     
    7660        : m_haveMetadata(false)
    7761        , m_isComplete(false)
    78         , m_hasAlpha(true)
     62        , m_hasAlpha(false)
    7963    {
    8064    }
    8165
    8266    ~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    }
    9083   
    9184    unsigned usedFrameBytes() const { return m_image ? m_frameBytes : 0; }
     
    9386    NativeImagePtr m_image;
    9487    ImageOrientation m_orientation { DefaultImageOrientation };
    95     SubsamplingLevel m_subsamplingLevel { 0 };
     88    SubsamplingLevel m_subsamplingLevel { DefaultSubsamplingLevel };
    9689    float m_duration { 0 };
    9790    bool m_haveMetadata : 1;
     
    10699
    107100class BitmapImage final : public Image {
    108     friend class GeneratedImage;
    109     friend class CrossfadeGeneratedImage;
    110     friend class GradientImage;
    111     friend class GraphicsContext;
    112101public:
    113102    static Ref<BitmapImage> create(NativeImagePtr&& nativeImage, ImageObserver* observer = nullptr)
     
    124113    virtual ~BitmapImage();
    125114   
    126     bool hasSingleSecurityOrigin() const override;
     115    bool hasSingleSecurityOrigin() const override { return true; }
    127116
    128117    // FloatSize due to override.
     
    135124
    136125    bool dataChanged(bool allDataReceived) override;
    137     String filenameExtension() const override;
     126    String filenameExtension() const override { return m_source.filenameExtension(); }
    138127
    139128    // It may look unusual that there is no start animation call as public API. This is because
     
    156145#endif
    157146
    158 #if USE(CG)
    159     WEBCORE_EXPORT CGImageRef getCGImageRef() override;
    160     CGImageRef getFirstCGImageRefOfSize(const IntSize&) override;
    161     RetainPtr<CFArrayRef> getCGImageArray() override;
    162 #endif
    163 
    164147#if PLATFORM(WIN)
    165148    bool getHBITMAP(HBITMAP) override;
     
    175158#endif
    176159
     160    WEBCORE_EXPORT NativeImagePtr nativeImage() override;
    177161    NativeImagePtr nativeImageForCurrentFrame() override;
     162#if USE(CG)
     163    NativeImagePtr nativeImageOfSize(const IntSize&) override;
     164    Vector<NativeImagePtr> framesNativeImages() override;
     165#endif
    178166    ImageOrientation orientationForCurrentFrame() override { return frameOrientationAtIndex(currentFrame()); }
    179167
     
    216204
    217205    NativeImagePtr frameImageAtIndex(size_t, float presentationScaleHint = 1);
    218     NativeImagePtr copyUnscaledFrameImageAtIndex(size_t);
    219206
    220207    bool haveFrameImageAtIndex(size_t);
     
    230217
    231218    // Called before accessing m_frames[index] for info without decoding. Returns false on index out of bounds.
    232     bool ensureFrameIsCached(size_t index, ImageFrameCaching = CacheMetadataAndFrame);
     219    bool ensureFrameAtIndexIsCached(size_t index, ImageFrameCaching = CacheMetadataAndFrame);
    233220
    234221    // Called to invalidate cached data. When |destroyAll| is true, we wipe out
  • trunk/Source/WebCore/platform/graphics/Icon.h

    r200530 r205682  
    2929
    3030#if PLATFORM(IOS)
    31 #include "NativeImagePtr.h"
     31#include "NativeImage.h"
    3232#include <CoreGraphics/CoreGraphics.h>
    3333#elif PLATFORM(MAC)
  • trunk/Source/WebCore/platform/graphics/Image.h

    r201561 r205682  
    3333#include "GraphicsTypes.h"
    3434#include "ImageOrientation.h"
    35 #include "NativeImagePtr.h"
     35#include "NativeImage.h"
    3636#include <wtf/Optional.h>
    3737#include <wtf/PassRefPtr.h>
     
    138138    enum TileRule { StretchTile, RoundTile, SpaceTile, RepeatTile };
    139139
     140    virtual NativeImagePtr nativeImage() { return nullptr; }
     141    virtual NativeImagePtr nativeImageOfSize(const IntSize&) { return nullptr; }
    140142    virtual NativeImagePtr nativeImageForCurrentFrame() { return nullptr; }
    141143    virtual ImageOrientation orientationForCurrentFrame() { return ImageOrientation(); }
     144    virtual Vector<NativeImagePtr> framesNativeImages() { return { }; }
    142145
    143146    // Accessors for native image formats.
     
    149152#if PLATFORM(COCOA)
    150153    virtual CFDataRef getTIFFRepresentation() { return nullptr; }
    151 #endif
    152 
    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; }
    157154#endif
    158155
  • trunk/Source/WebCore/platform/graphics/ImageSource.cpp

    r200939 r205682  
    9595{
    9696    if (!m_allowSubsampling || !allowSubsamplingOfFrameAtIndex(0))
    97         return 0;
     97        return DefaultSubsamplingLevel;
    9898   
    9999    // FIXME: this value was chosen to be appropriate for iOS since the image
     
    101101    // if image subsampling is enabled on other platform.
    102102    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) {
    106105        if (frameSizeAtIndex(0, level).area() < maximumImageAreaBeforeSubsampling)
    107106            return level;
    108107    }
    109108   
    110     return maxSubsamplingLevel;
     109    return MaxSubsamplingLevel;
    111110}
    112111
     
    149148IntSize ImageSource::size() const
    150149{
    151     return frameSizeAtIndex(0, 0);
     150    return frameSizeAtIndex(0, DefaultSubsamplingLevel);
    152151}
    153152
    154153IntSize ImageSource::sizeRespectingOrientation() const
    155154{
    156     return frameSizeAtIndex(0, 0, RespectImageOrientation);
     155    return frameSizeAtIndex(0, DefaultSubsamplingLevel, RespectImageOrientation);
    157156}
    158157
  • trunk/Source/WebCore/platform/graphics/ImageSource.h

    r204466 r205682  
    3030#include "ImageOrientation.h"
    3131#include "IntPoint.h"
    32 #include "NativeImagePtr.h"
     32#include "NativeImage.h"
    3333#include "TextStream.h"
    3434#include <wtf/Forward.h>
     
    6363
    6464// SubsamplingLevel. 0 is no subsampling, 1 is half dimensions on each axis etc.
    65 typedef short SubsamplingLevel;
     65using SubsamplingLevel = int;
     66
     67enum : SubsamplingLevel {
     68    NilSubsamplingLevel = -1,
     69    MinSubsamplingLevel = 0,
     70    MaxSubsamplingLevel = 3,
     71    DefaultSubsamplingLevel = MinSubsamplingLevel
     72};
    6673
    6774class ImageSource {
     
    131138   
    132139    // 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;
    134141   
    135142    // Return the number of bytes in the decoded frame. If the frame is not yet
    136143    // decoded then return 0.
    137     unsigned frameBytesAtIndex(size_t, SubsamplingLevel = 0) const;
     144    unsigned frameBytesAtIndex(size_t, SubsamplingLevel = DefaultSubsamplingLevel) const;
    138145   
    139146    float frameDurationAtIndex(size_t);
     
    142149    // Callers should not call this after calling clear() with a higher index;
    143150    // see comments on clear() above.
    144     NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = 0);
     151    NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = DefaultSubsamplingLevel);
    145152   
    146153private:
     
    154161    bool m_needsUpdateMetadata { false };
    155162    size_t m_frameCount { 0 };
    156     Optional<SubsamplingLevel> m_maximumSubsamplingLevel { 0 };
     163    Optional<SubsamplingLevel> m_maximumSubsamplingLevel { DefaultSubsamplingLevel };
    157164
    158165    // The default value of m_allowSubsampling should be the same as defaultImageSubsamplingEnabled in Settings.cpp
  • trunk/Source/WebCore/platform/graphics/MediaPlayer.h

    r201474 r205682  
    3737#include "LayoutRect.h"
    3838#include "MediaPlayerEnums.h"
    39 #include "NativeImagePtr.h"
     39#include "NativeImage.h"
    4040#include "PlatformLayer.h"
    4141#include "PlatformMediaResourceLoader.h"
  • trunk/Source/WebCore/platform/graphics/NativeImage.h

    r205681 r205682  
    11/*
    2  * Copyright (C) 2004, 2005, 2006 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2004, 2005, 2006, 2016 Apple Inc.  All rights reserved.
    33 * Copyright (C) 2007-2008 Torch Mobile, Inc.
    44 * Copyright (C) 2012 Company 100 Inc.
     
    2323 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    2424 * (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.
    2626 */
    2727
    28 #ifndef NativeImagePtr_h
    29 #define NativeImagePtr_h
     28#pragma once
     29
     30#include "GraphicsTypes.h"
     31#include "ImageOrientation.h"
    3032
    3133#if USE(CG)
     
    4042namespace WebCore {
    4143
     44class Color;
     45class FloatRect;
     46class IntSize;
     47class GraphicsContext;
     48
    4249#if USE(CG)
    4350typedef RetainPtr<CGImageRef> NativeImagePtr;
     
    4855#endif
    4956
     57IntSize nativeImageSize(const NativeImagePtr&);
     58bool nativeImageHasAlpha(const NativeImagePtr&);
     59Color nativeImageSinglePixelSolidColor(const NativeImagePtr&);
     60
     61float subsamplingScale(GraphicsContext&, const FloatRect& destRect, const FloatRect& srcRect);
     62
     63void drawNativeImage(const NativeImagePtr&, GraphicsContext&, const FloatRect&, const FloatRect&, const IntSize&, CompositeOperator, BlendMode, const ImageOrientation&);
     64void clearNativeImageSubImages(const NativeImagePtr&);
     65   
    5066}
    51 
    52 #endif
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm

    r205348 r205682  
    298298        return;
    299299
    300     m_pausedImage = image->getCGImageRef();
     300    m_pausedImage = image->nativeImage();
    301301    ASSERT(m_pausedImage);
    302302}
  • trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp

    r200967 r205682  
    158158{
    159159    if (m_size.isEmpty())
    160         m_size = frameSizeAtIndex(0, 0);
     160        m_size = frameSizeAtIndex(0);
    161161    return m_size;
    162162}
  • trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.h

    r199735 r205682  
    5858    Optional<IntPoint> hotSpot() const;
    5959   
    60     IntSize frameSizeAtIndex(size_t, SubsamplingLevel) const;
     60    IntSize frameSizeAtIndex(size_t, SubsamplingLevel = DefaultSubsamplingLevel) const;
    6161    bool frameIsCompleteAtIndex(size_t) const;
    6262    ImageOrientation orientationAtIndex(size_t) const;
  • trunk/Source/WebCore/platform/graphics/cg/PatternCG.cpp

    r201482 r205682  
    7373    // instead of custom patterns, and avoid tiling-edge pixel cracks.
    7474    if (m_repeatX && m_repeatY)
    75         return wkCGPatternCreateWithImageAndTransform(tileImage()->getCGImageRef(), patternTransform, wkPatternTilingConstantSpacing);
     75        return wkCGPatternCreateWithImageAndTransform(tileImage()->nativeImage().get(), patternTransform, wkPatternTilingConstantSpacing);
    7676
    7777    // If FLT_MAX should also be used for xStep or yStep, nothing is rendered. Using fractions of FLT_MAX also
     
    8484
    8585    // 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();
    8787
    8888    const CGPatternCallbacks patternCallbacks = { 0, patternCallback, patternReleaseCallback };
  • trunk/Source/WebCore/platform/graphics/cocoa/TextTrackRepresentationCocoa.mm

    r201463 r205682  
    130130{
    131131    if (auto representation = m_client.createTextTrackRepresentationImage())
    132         [m_layer.get() setContents:(id)representation->getCGImageRef()];
     132        [m_layer.get() setContents:(id)representation->nativeImage().get()];
    133133}
    134134
  • trunk/Source/WebCore/platform/graphics/mac/ImageMac.mm

    r205516 r205682  
    8080        return m_tiffRep.get();
    8181
    82     unsigned numFrames = frameCount();
     82    auto nativeImages = this->framesNativeImages();
    8383
    84     // If numFrames is zero, we know for certain this image doesn't have valid data
     84    // If framesImages.size() is zero, we know for certain this image doesn't have valid data
    8585    // Even though the call to CGImageDestinationCreateWithData will fail and we'll handle it gracefully,
    8686    // 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;
    9889
    9990    RetainPtr<CFMutableDataRef> data = adoptCF(CFDataCreateMutable(0, 0));
    100     RetainPtr<CGImageDestinationRef> destination = adoptCF(CGImageDestinationCreateWithData(data.get(), kUTTypeTIFF, numValidFrames, 0));
     91    RetainPtr<CGImageDestinationRef> destination = adoptCF(CGImageDestinationCreateWithData(data.get(), kUTTypeTIFF, nativeImages.size(), 0));
    10192
    10293    if (!destination)
    103         return 0;
     94        return nullptr;
    10495
    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);
    10798
    10899    CGImageDestinationFinalize(destination.get());
  • trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.mm

    r203739 r205682  
    143143            break;
    144144
    145         m_previewImage = image->getCGImageRef();
     145        m_previewImage = image->nativeImage();
    146146        if (!m_previewImage)
    147147            break;
     
    155155void MockRealtimeVideoSourceMac::updateSampleBuffer()
    156156{
    157     auto pixelBuffer = pixelBufferFromCGImage(imageBuffer()->copyImage()->getCGImageRef());
     157    auto pixelBuffer = pixelBufferFromCGImage(imageBuffer()->copyImage()->nativeImage().get());
    158158    auto sampleBuffer = CMSampleBufferFromPixelBuffer(pixelBuffer.get());
    159159   
  • trunk/Source/WebCore/platform/win/DragImageCGWin.cpp

    r198655 r205682  
    137137    CGContextSetFillColor(drawContext, white);
    138138    CGContextFillRect(drawContext, rect);
    139     if (auto srcImage = img->getCGImageRef()) {
     139    if (auto srcImage = img->nativeImage()) {
    140140        CGContextSetBlendMode(drawContext, kCGBlendModeNormal);
    141         CGContextDrawImage(drawContext, rect, srcImage);
     141        CGContextDrawImage(drawContext, rect, srcImage.get());
    142142    }
    143143    CGContextRelease(drawContext);
  • trunk/Source/WebKit/mac/ChangeLog

    r205592 r205682  
     12016-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
    1142016-09-07  Joseph Pecoraro  <pecoraro@apple.com>
    215
  • trunk/Source/WebKit/mac/DOM/DOM.mm

    r204717 r205682  
    562562    if (textIndicator) {
    563563        if (Image* image = textIndicator->contentImage())
    564             *cgImage = (CGImageRef)CFAutorelease(CGImageRetain(image->getCGImageRef()));
     564            *cgImage = image->nativeImage().autorelease();
    565565    }
    566566
  • trunk/Source/WebKit/mac/Misc/WebCache.mm

    r198655 r205682  
    205205    if (!cachedImage.hasImage())
    206206        return nullptr;
    207     return cachedImage.image()->getCGImageRef();
     207    return cachedImage.image()->nativeImage().get();
    208208}
    209209
  • trunk/Source/WebKit2/ChangeLog

    r205594 r205682  
     12016-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
    1242016-09-08  Zan Dobersek  <zdobersek@igalia.com>
    225
  • trunk/Source/WebKit2/UIProcess/API/C/cg/WKIconDatabaseCG.cpp

    r95901 r205682  
    3838{
    3939    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;
    4141}
    4242
     
    4444{
    4545    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));
    4758}
    4859
  • trunk/Source/WebKit2/UIProcess/WebIconDatabase.h

    r204668 r205682  
    3232#include <WebCore/IconDatabaseClient.h>
    3333#include <WebCore/IntSize.h>
    34 #include <WebCore/NativeImagePtr.h>
     34#include <WebCore/NativeImage.h>
    3535
    3636namespace API {
  • trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm

    r204886 r205682  
    41324132    if (!_positionInformation.linkIndicator.contentImage)
    41334133        return nullptr;
    4134     return [[[UIImage alloc] initWithCGImage:_positionInformation.linkIndicator.contentImage->getCGImageRef()] autorelease];
     4134    return [[[UIImage alloc] initWithCGImage:_positionInformation.linkIndicator.contentImage->nativeImage().get()] autorelease];
    41354135}
    41364136
  • trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp

    r204702 r205682  
    17311731static bool isAlmostSolidColor(BitmapImage* bitmap)
    17321732{
    1733     CGImageRef image = bitmap->getCGImageRef();
     1733    CGImageRef image = bitmap->nativeImage().get();
    17341734    ASSERT(CGImageGetBitsPerComponent(image) == 8);
    17351735
Note: See TracChangeset for help on using the changeset viewer.