| Differences between
and this patch
- a/Source/WebCore/ChangeLog +210 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2016-07-12  Said Abou-Hallawa  <sabouhallawa@apple.com>
2
3
        Split the pixel data of ImageFrame to a separate class
4
        https://bugs.webkit.org/show_bug.cgi?id=159679
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Move the pixel data manipulation part in ImageFrame into a separate class
9
        and then make it optional (allocated on demand).
10
11
        * CMakeLists.txt:
12
        * PlatformEfl.cmake:
13
        * PlatformGTK.cmake:
14
        * PlatformWinCairo.cmake:
15
        * WebCore.xcodeproj/project.pbxproj:
16
        * platform/graphics/BitmapPixels.h: Added.
17
        (WebCore::BitmapPixels::create):
18
        (WebCore::BitmapPixels::BitmapPixels):
19
        (WebCore::BitmapPixels::width):
20
        (WebCore::BitmapPixels::height):
21
        (WebCore::BitmapPixels::setSize):
22
        (WebCore::BitmapPixels::at):
23
        (WebCore::BitmapPixels::clear):
24
        (WebCore::BitmapPixels::clearRect):
25
        (WebCore::BitmapPixels::repeatFirstRow):
26
        (WebCore::BitmapPixels::setRGBA):
27
        (WebCore::BitmapPixels::overRGBA):
28
        (WebCore::BitmapPixels::inBounds):
29
        * platform/graphics/Color.cpp:
30
        (WebCore::multiply255):
31
        (WebCore::divide255):
32
        (WebCore::divideCeil):
33
        (WebCore::premultipliedChannel):
34
        (WebCore::unpremultipliedChannel):
35
        (WebCore::makePremultipliedRGBA):
36
        (WebCore::makeUnPremultipliedRGBA):
37
        * platform/graphics/Color.h:
38
        * platform/graphics/ImageFrameData.h:
39
        (WebCore::ImageFrameData::pixels):
40
        (WebCore::ImageFrameData::hasPixels):
41
        * platform/image-decoders/ImageDecoder.cpp:
42
        (WebCore::ImageFrame::operator=):
43
        (WebCore::ImageFrame::clearPixelData):
44
        (WebCore::ImageFrame::zeroFillPixelData):
45
        (WebCore::ImageFrame::zeroFillFrameRect):
46
        (WebCore::ImageFrame::copyBitmapData):
47
        (WebCore::ImageFrame::setSize):
48
        (WebCore::ImageFrame::copyRowNTimes):
49
        * platform/image-decoders/ImageDecoder.h:
50
        (WebCore::ImageFrame::asNewNativeImage):
51
        (WebCore::ImageFrame::setRGBA):
52
        (WebCore::ImageFrame::getAddr):
53
        (WebCore::ImageFrame::hasPixelData):
54
        (WebCore::ImageFrame::overRGBA):
55
        (WebCore::ImageFrame::width):
56
        (WebCore::ImageFrame::height):
57
        (WebCore::ImageFrame::copyRowNTimes): Deleted.
58
        (WebCore::ImageFrame::fixPointUnsignedMultiply): Deleted.
59
        (WebCore::ImageFrame::divide255): Deleted.
60
        * platform/image-decoders/cairo/BitmapPixelsCairo.cpp: Renamed from Source/WebCore/platform/image-decoders/cairo/ImageDecoderCairo.cpp.
61
        (WebCore::BitmapPixels::image):
62
63
2016-07-11  Said Abou-Hallawa  <sabouhallawa@apple,com>
64
65
        Rename FrameData to ImageFrameData and move it to a separate file
66
        https://bugs.webkit.org/show_bug.cgi?id=155444
67
68
        Reviewed by NOBODY (OOPS!).
69
70
        Move ImageFrameData to a separate file so it can be cached by ImageSource
71
        and will still be consumed by BitmapImage. Make the data members of ImageFrameData
72
        be private and add getters to return their values.
73
74
        No new tests -- Code refactoring, no behavior change.
75
76
        * CMakeLists.txt:
77
        * WebCore.xcodeproj/project.pbxproj:
78
        * platform/graphics/BitmapImage.cpp:
79
        (WebCore::BitmapImage::BitmapImage):
80
        (WebCore::BitmapImage::haveFrameImageAtIndex):
81
        (WebCore::BitmapImage::destroyDecodedData):
82
        (WebCore::BitmapImage::destroyDecodedDataIfNecessary):
83
        (WebCore::BitmapImage::cacheFrame):
84
        (WebCore::BitmapImage::dataChanged):
85
        (WebCore::BitmapImage::ensureFrameIsCached):
86
        (WebCore::BitmapImage::frameImageAtIndex):
87
        (WebCore::BitmapImage::frameIsCompleteAtIndex):
88
        (WebCore::BitmapImage::frameDurationAtIndex):
89
        (WebCore::BitmapImage::frameHasAlphaAtIndex):
90
        (WebCore::BitmapImage::frameOrientationAtIndex):
91
        (WebCore::BitmapImage::singlePixelSolidColor):
92
        (WebCore::BitmapImage::isAlmostSolidColor):
93
        * platform/graphics/BitmapImage.h:
94
        (WebCore::FrameData::FrameData): Deleted.
95
        (WebCore::FrameData::~FrameData): Deleted.
96
        (WebCore::FrameData::usedFrameBytes): Deleted.
97
        * platform/graphics/ImageSource.cpp:
98
        (WebCore::ImageSource::createFrameDataAtIndex):
99
        * platform/graphics/ImageSource.h:
100
        * platform/graphics/imageFrameData.cpp: Added.
101
        (WebCore::ImageFrameData::ImageFrameData):
102
        (WebCore::ImageFrameData::~ImageFrameData):
103
        (WebCore::ImageFrameData::clearSubImages):
104
        (WebCore::ImageFrameData::clear):
105
        (WebCore::ImageFrameData::singlePixelSolidColor):
106
        (WebCore::ImageFrameData::isAlmostSolidColor):
107
        * platform/graphics/imageFrameData.h: Added.
108
        (WebCore::ImageFrameData::status):
109
        (WebCore::ImageFrameData::isComplete):
110
        (WebCore::ImageFrameData::size):
111
        (WebCore::ImageFrameData::frameBytes):
112
        (WebCore::ImageFrameData::image):
113
        (WebCore::ImageFrameData::orientation):
114
        (WebCore::ImageFrameData::subsamplingLevel):
115
        (WebCore::ImageFrameData::duration):
116
        (WebCore::ImageFrameData::hasAlpha):
117
        (WebCore::ImageFrameData::hasImage):
118
        (WebCore::ImageFrameData::hasMetadata):
119
120
2016-06-24  Said Abou-Hallawa  <sabouhallawa@apple,com>
121
122
        Introduce PlatformImage and make it is a wrapper for NativeImagePtr
123
        https://bugs.webkit.org/show_bug.cgi?id=158684
124
125
        Reviewed by NOBODY (OOPS!).
126
127
        The main purpose of this refactoring is to move the platform image dependent
128
        code from BitmapImage to PlatformImage. PlatformImage is responsible of 
129
        drawing the image and answering NativeImagePtr questions when an ImageDecoder
130
        is not available. Apart from drawing the image, the query functions will be
131
        called only when constructing a FrameData so we will keep everything as a
132
        NativeImagePtr. But we will cast the NativeImagePtr to PlatformImage when
133
        a platform dependent function is needed.
134
135
        No new tests -- Code refactoring, no behavior change.
136
137
        * PlatformAppleWin.cmake:
138
        * PlatformEfl.cmake:
139
        * PlatformGTK.cmake:
140
        * PlatformMac.cmake:
141
        * PlatformWinCairo.cmake:
142
        * WebCore.xcodeproj/project.pbxproj:
143
        * bindings/objc/DOM.mm:
144
        (-[DOMNode getPreviewSnapshotImage:andRects:]):
145
        * page/mac/TextIndicatorWindow.mm:
146
        (-[WebTextIndicatorView initWithFrame:textIndicator:margin:offset:]):
147
        (createContentCrossfadeAnimation):
148
        * platform/graphics/BitmapImage.cpp:
149
        (WebCore::BitmapImage::BitmapImage):
150
        (WebCore::BitmapImage::destroyDecodedData):
151
        (WebCore::BitmapImage::destroyDecodedDataIfNecessary):
152
        (WebCore::BitmapImage::dataChanged):
153
        (WebCore::BitmapImage::frameImageAtIndex):
154
        (WebCore::BitmapImage::nativeImage):
155
        (WebCore::BitmapImage::nativeImageOfSize):
156
        (WebCore::BitmapImage::nativeImageForCurrentFrame):
157
        (WebCore::BitmapImage::framesNativeImages):
158
        (WebCore::BitmapImage::singlePixelSolidColor):
159
        (WebCore::BitmapImage::isAlmostSolidColor):
160
        (WebCore::BitmapImage::draw):
161
        * platform/graphics/BitmapImage.h:
162
        (WebCore::FrameData::FrameData):
163
        m_hasAlpha can be initialized with false because it is accessed only in
164
        BitmapImage::frameHasAlphaAtIndex() and it is guarded by m_haveMetadata.
165
        Both m_haveMetadata and m_hasAlpha are set in BitmapImage constructor
166
        and in BitmapImage::cacheFrame().
167
168
        (WebCore::FrameData::~FrameData):
169
        (WebCore::FrameData::clear):
170
        * platform/graphics/Image.h:
171
        (WebCore::Image::nativeImage):
172
        (WebCore::Image::nativeImageOfSize):
173
        (WebCore::Image::framesNativeImages):
174
        (WebCore::Image::getCGImageRef): Deleted.
175
        (WebCore::Image::getFirstCGImageRefOfSize): Deleted.
176
        (WebCore::Image::getCGImageArray): Deleted.
177
        * platform/graphics/PlatformImage.h: Added.
178
        (WebCore::PlatformImage::PlatformImage):
179
        (WebCore::PlatformImage::isNil):
180
        (WebCore::PlatformImage::cgImageRef):
181
        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
182
        (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::updateDisplayMode):
183
        * platform/graphics/cairo/PlatformImageCairo.cpp: Renamed from Source/WebCore/platform/graphics/cairo/BitmapImageCairo.cpp.
184
        (WebCore::PlatformImage::clearSubImages):
185
        (WebCore::PlatformImage::size):
186
        (WebCore::PlatformImage::hasAlpha):
187
        (WebCore::PlatformImage::singlePixelSolidColor):
188
        (WebCore::PlatformImage::isAlmostSolidColor):
189
        (WebCore::PlatformImage::subsamplingScale):
190
        (WebCore::PlatformImage::draw):
191
        * platform/graphics/cg/BitmapImageCG.cpp: Removed.
192
        * platform/graphics/cg/PatternCG.cpp:
193
        (WebCore::Pattern::createPlatformPattern):
194
        * platform/graphics/cg/PlatformImageCG.cpp: Added.
195
        (WebCore::PlatformImage::clearSubImages):
196
        (WebCore::PlatformImage::size):
197
        (WebCore::PlatformImage::hasAlpha):
198
        (WebCore::PlatformImage::singlePixelSolidColor):
199
        (WebCore::PlatformImage::isAlmostSolidColor): Moved from PluginView.cpp since PlatformImage is what this function belongs to.
200
        (WebCore::PlatformImage::subsamplingScale): Returns the sub-sampling scale based on the context scaling.
201
        (WebCore::PlatformImage::draw):
202
        * platform/graphics/cocoa/TextTrackRepresentationCocoa.mm:
203
        (TextTrackRepresentationCocoa::update):
204
        * platform/graphics/mac/ImageMac.mm:
205
        (WebCore::BitmapImage::getTIFFRepresentation):
206
        * platform/mediastream/mac/MockRealtimeVideoSourceMac.mm:
207
        (WebCore::MockRealtimeVideoSourceMac::updatePlatformLayer):
208
        * platform/win/DragImageCGWin.cpp:
209
        (WebCore::createDragImageFromImage):
210
1
2016-07-11  Sam Weinig  <sam@webkit.org>
211
2016-07-11  Sam Weinig  <sam@webkit.org>
2
212
3
        Speech Synthesis: getting list of voices no longer works
213
        Speech Synthesis: getting list of voices no longer works
- a/Source/WebKit/mac/ChangeLog +10 lines
Lines 1-3 a/Source/WebKit/mac/ChangeLog_sec1
1
2016-07-11  Said Abou-Hallawa  <sabouhallawa@apple,com>
2
3
        Introduce PlatformImage and make it is a wrapper for NativeImagePtr
4
        https://bugs.webkit.org/show_bug.cgi?id=158684
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        * Misc/WebCache.mm:
9
        (+[WebCache imageForURL:]):
10
1
2016-07-11  Enrica Casucci  <enrica@apple.com>
11
2016-07-11  Enrica Casucci  <enrica@apple.com>
2
12
3
        Add synthetic click origin to WKNavigationAction.
13
        Add synthetic click origin to WKNavigationAction.
- a/Source/WebKit2/ChangeLog +22 lines
Lines 1-3 a/Source/WebKit2/ChangeLog_sec1
1
2016-07-11  Said Abou-Hallawa  <sabouhallawa@apple,com>
2
3
        Introduce PlatformImage and make it is a wrapper for NativeImagePtr
4
        https://bugs.webkit.org/show_bug.cgi?id=158684
5
6
        Reviewed by NOBODY (OOPS!).
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/ios/WKContentViewInteraction.mm:
16
        (-[WKContentView _presentationSnapshotForPreviewItemController:]):
17
        * WebProcess/Plugins/PluginView.cpp:
18
        (WebKit::PluginView::pluginSnapshotTimerFired):
19
        
20
        (WebKit::isAlmostSolidColor): Deleted.
21
        Move the static function isAlmostSolidColor to PlatformImage::isAlmostSolidColor().
22
1
2016-07-11  Chris Dumez  <cdumez@apple.com>
23
2016-07-11  Chris Dumez  <cdumez@apple.com>
2
24
3
        [WK2][iOS] Intermittent crash in [UIApplication beginBackgroundTaskWithName] expiration handler
25
        [WK2][iOS] Intermittent crash in [UIApplication beginBackgroundTaskWithName] expiration handler
- a/Source/WebCore/CMakeLists.txt +1 lines
Lines 2226-2231 set(WebCore_SOURCES a/Source/WebCore/CMakeLists.txt_sec1
2226
    platform/graphics/ISOVTTCue.cpp
2226
    platform/graphics/ISOVTTCue.cpp
2227
    platform/graphics/Image.cpp
2227
    platform/graphics/Image.cpp
2228
    platform/graphics/ImageBuffer.cpp
2228
    platform/graphics/ImageBuffer.cpp
2229
    platform/graphics/ImageFrameData.cpp
2229
    platform/graphics/ImageOrientation.cpp
2230
    platform/graphics/ImageOrientation.cpp
2230
    platform/graphics/ImageSource.cpp
2231
    platform/graphics/ImageSource.cpp
2231
    platform/graphics/IntPoint.cpp
2232
    platform/graphics/IntPoint.cpp
- a/Source/WebCore/PlatformAppleWin.cmake -1 / +1 lines
Lines 55-61 list(APPEND WebCore_SOURCES a/Source/WebCore/PlatformAppleWin.cmake_sec1
55
    platform/graphics/ca/win/WebTiledBackingLayerWin.cpp
55
    platform/graphics/ca/win/WebTiledBackingLayerWin.cpp
56
    platform/graphics/ca/win/WKCACFViewLayerTreeHost.cpp
56
    platform/graphics/ca/win/WKCACFViewLayerTreeHost.cpp
57
57
58
    platform/graphics/cg/BitmapImageCG.cpp
59
    platform/graphics/cg/ColorCG.cpp
58
    platform/graphics/cg/ColorCG.cpp
60
    platform/graphics/cg/FloatPointCG.cpp
59
    platform/graphics/cg/FloatPointCG.cpp
61
    platform/graphics/cg/FloatRectCG.cpp
60
    platform/graphics/cg/FloatRectCG.cpp
Lines 75-80 list(APPEND WebCore_SOURCES a/Source/WebCore/PlatformAppleWin.cmake_sec2
75
    platform/graphics/cg/PDFDocumentImage.cpp
74
    platform/graphics/cg/PDFDocumentImage.cpp
76
    platform/graphics/cg/PathCG.cpp
75
    platform/graphics/cg/PathCG.cpp
77
    platform/graphics/cg/PatternCG.cpp
76
    platform/graphics/cg/PatternCG.cpp
77
    platform/graphics/cg/PlatformImageCG.cpp
78
    platform/graphics/cg/SubimageCacheWithTimer.cpp
78
    platform/graphics/cg/SubimageCacheWithTimer.cpp
79
    platform/graphics/cg/TransformationMatrixCG.cpp
79
    platform/graphics/cg/TransformationMatrixCG.cpp
80
80
- a/Source/WebCore/PlatformEfl.cmake -3 / +3 lines
Lines 122-128 list(APPEND WebCore_SOURCES a/Source/WebCore/PlatformEfl.cmake_sec1
122
    platform/graphics/PlatformDisplay.cpp
122
    platform/graphics/PlatformDisplay.cpp
123
123
124
    platform/graphics/cairo/BackingStoreBackendCairoImpl.cpp
124
    platform/graphics/cairo/BackingStoreBackendCairoImpl.cpp
125
    platform/graphics/cairo/BitmapImageCairo.cpp
126
    platform/graphics/cairo/CairoUtilities.cpp
125
    platform/graphics/cairo/CairoUtilities.cpp
127
    platform/graphics/cairo/FontCairo.cpp
126
    platform/graphics/cairo/FontCairo.cpp
128
    platform/graphics/cairo/FontCairoHarfbuzzNG.cpp
127
    platform/graphics/cairo/FontCairoHarfbuzzNG.cpp
Lines 134-139 list(APPEND WebCore_SOURCES a/Source/WebCore/PlatformEfl.cmake_sec2
134
    platform/graphics/cairo/PathCairo.cpp
133
    platform/graphics/cairo/PathCairo.cpp
135
    platform/graphics/cairo/PatternCairo.cpp
134
    platform/graphics/cairo/PatternCairo.cpp
136
    platform/graphics/cairo/PlatformContextCairo.cpp
135
    platform/graphics/cairo/PlatformContextCairo.cpp
136
    platform/graphics/cairo/PlatformImageCairo.cpp
137
    platform/graphics/cairo/PlatformPathCairo.cpp
137
    platform/graphics/cairo/PlatformPathCairo.cpp
138
    platform/graphics/cairo/RefPtrCairo.cpp
138
    platform/graphics/cairo/RefPtrCairo.cpp
139
    platform/graphics/cairo/TransformationMatrixCairo.cpp
139
    platform/graphics/cairo/TransformationMatrixCairo.cpp
Lines 179-187 list(APPEND WebCore_SOURCES a/Source/WebCore/PlatformEfl.cmake_sec3
179
    platform/graphics/x11/PlatformDisplayX11.cpp
179
    platform/graphics/x11/PlatformDisplayX11.cpp
180
    platform/graphics/x11/XUniqueResource.cpp
180
    platform/graphics/x11/XUniqueResource.cpp
181
181
182
    platform/image-encoders/JPEGImageEncoder.cpp
182
    platform/image-decoders/cairo/BitmapPixelsCairo.cpp
183
183
184
    platform/image-decoders/cairo/ImageDecoderCairo.cpp
184
    platform/image-encoders/JPEGImageEncoder.cpp
185
185
186
    platform/network/efl/NetworkStateNotifierEfl.cpp
186
    platform/network/efl/NetworkStateNotifierEfl.cpp
187
187
- a/Source/WebCore/PlatformGTK.cmake -2 / +2 lines
Lines 101-107 list(APPEND WebCore_SOURCES a/Source/WebCore/PlatformGTK.cmake_sec1
101
101
102
    platform/graphics/cairo/BackingStoreBackendCairoImpl.cpp
102
    platform/graphics/cairo/BackingStoreBackendCairoImpl.cpp
103
    platform/graphics/cairo/BackingStoreBackendCairoX11.cpp
103
    platform/graphics/cairo/BackingStoreBackendCairoX11.cpp
104
    platform/graphics/cairo/BitmapImageCairo.cpp
105
    platform/graphics/cairo/CairoUtilities.cpp
104
    platform/graphics/cairo/CairoUtilities.cpp
106
    platform/graphics/cairo/FloatRectCairo.cpp
105
    platform/graphics/cairo/FloatRectCairo.cpp
107
    platform/graphics/cairo/FontCairo.cpp
106
    platform/graphics/cairo/FontCairo.cpp
Lines 115-120 list(APPEND WebCore_SOURCES a/Source/WebCore/PlatformGTK.cmake_sec2
115
    platform/graphics/cairo/PathCairo.cpp
114
    platform/graphics/cairo/PathCairo.cpp
116
    platform/graphics/cairo/PatternCairo.cpp
115
    platform/graphics/cairo/PatternCairo.cpp
117
    platform/graphics/cairo/PlatformContextCairo.cpp
116
    platform/graphics/cairo/PlatformContextCairo.cpp
117
    platform/graphics/cairo/PlatformImageCairo.cpp
118
    platform/graphics/cairo/PlatformPathCairo.cpp
118
    platform/graphics/cairo/PlatformPathCairo.cpp
119
    platform/graphics/cairo/RefPtrCairo.cpp
119
    platform/graphics/cairo/RefPtrCairo.cpp
120
    platform/graphics/cairo/TransformationMatrixCairo.cpp
120
    platform/graphics/cairo/TransformationMatrixCairo.cpp
Lines 149-155 list(APPEND WebCore_SOURCES a/Source/WebCore/PlatformGTK.cmake_sec3
149
    platform/gtk/TemporaryLinkStubs.cpp
149
    platform/gtk/TemporaryLinkStubs.cpp
150
    platform/gtk/UserAgentGtk.cpp
150
    platform/gtk/UserAgentGtk.cpp
151
151
152
    platform/image-decoders/cairo/ImageDecoderCairo.cpp
152
    platform/image-decoders/cairo/BitmapPixelsCairo.cpp
153
153
154
    platform/mediastream/gtk/SDPProcessorScriptResourceGtk.cpp
154
    platform/mediastream/gtk/SDPProcessorScriptResourceGtk.cpp
155
155
- a/Source/WebCore/PlatformMac.cmake -1 / +1 lines
Lines 397-403 list(APPEND WebCore_SOURCES a/Source/WebCore/PlatformMac.cmake_sec1
397
    platform/graphics/ca/cocoa/WebSystemBackdropLayer.mm
397
    platform/graphics/ca/cocoa/WebSystemBackdropLayer.mm
398
    platform/graphics/ca/cocoa/WebTiledBackingLayer.mm
398
    platform/graphics/ca/cocoa/WebTiledBackingLayer.mm
399
399
400
    platform/graphics/cg/BitmapImageCG.cpp
401
    platform/graphics/cg/ColorCG.cpp
400
    platform/graphics/cg/ColorCG.cpp
402
    platform/graphics/cg/FloatPointCG.cpp
401
    platform/graphics/cg/FloatPointCG.cpp
403
    platform/graphics/cg/FloatRectCG.cpp
402
    platform/graphics/cg/FloatRectCG.cpp
Lines 417-422 list(APPEND WebCore_SOURCES a/Source/WebCore/PlatformMac.cmake_sec2
417
    platform/graphics/cg/PDFDocumentImage.cpp
416
    platform/graphics/cg/PDFDocumentImage.cpp
418
    platform/graphics/cg/PathCG.cpp
417
    platform/graphics/cg/PathCG.cpp
419
    platform/graphics/cg/PatternCG.cpp
418
    platform/graphics/cg/PatternCG.cpp
419
    platform/graphics/cg/PlatformImageCG.cpp
420
    platform/graphics/cg/SubimageCacheWithTimer.cpp
420
    platform/graphics/cg/SubimageCacheWithTimer.cpp
421
    platform/graphics/cg/TransformationMatrixCG.cpp
421
    platform/graphics/cg/TransformationMatrixCG.cpp
422
422
- a/Source/WebCore/PlatformWinCairo.cmake -2 / +2 lines
Lines 21-27 list(APPEND WebCore_SOURCES a/Source/WebCore/PlatformWinCairo.cmake_sec1
21
    platform/graphics/GLContext.cpp
21
    platform/graphics/GLContext.cpp
22
    platform/graphics/PlatformDisplay.cpp
22
    platform/graphics/PlatformDisplay.cpp
23
23
24
    platform/graphics/cairo/BitmapImageCairo.cpp
25
    platform/graphics/cairo/CairoUtilities.cpp
24
    platform/graphics/cairo/CairoUtilities.cpp
26
    platform/graphics/cairo/FloatRectCairo.cpp
25
    platform/graphics/cairo/FloatRectCairo.cpp
27
    platform/graphics/cairo/FontCairo.cpp
26
    platform/graphics/cairo/FontCairo.cpp
Lines 34-39 list(APPEND WebCore_SOURCES a/Source/WebCore/PlatformWinCairo.cmake_sec2
34
    platform/graphics/cairo/PathCairo.cpp
33
    platform/graphics/cairo/PathCairo.cpp
35
    platform/graphics/cairo/PatternCairo.cpp
34
    platform/graphics/cairo/PatternCairo.cpp
36
    platform/graphics/cairo/PlatformContextCairo.cpp
35
    platform/graphics/cairo/PlatformContextCairo.cpp
36
    platform/graphics/cairo/PlatformImageCairo.cpp
37
    platform/graphics/cairo/PlatformPathCairo.cpp
37
    platform/graphics/cairo/PlatformPathCairo.cpp
38
    platform/graphics/cairo/RefPtrCairo.cpp
38
    platform/graphics/cairo/RefPtrCairo.cpp
39
    platform/graphics/cairo/TransformationMatrixCairo.cpp
39
    platform/graphics/cairo/TransformationMatrixCairo.cpp
Lines 46-52 list(APPEND WebCore_SOURCES a/Source/WebCore/PlatformWinCairo.cmake_sec3
46
    platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp
46
    platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp
47
    platform/graphics/win/SimpleFontDataCairoWin.cpp
47
    platform/graphics/win/SimpleFontDataCairoWin.cpp
48
48
49
    platform/image-decoders/cairo/ImageDecoderCairo.cpp
49
    platform/image-decoders/cairo/BitmapPixelsCairo.cpp
50
50
51
    platform/network/NetworkStorageSessionStub.cpp
51
    platform/network/NetworkStorageSessionStub.cpp
52
52
- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj -4 / +20 lines
Lines 1484-1490 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec1
1484
		375CD232119D43C800A2A859 /* Hyphenation.h in Headers */ = {isa = PBXBuildFile; fileRef = 375CD231119D43C800A2A859 /* Hyphenation.h */; };
1484
		375CD232119D43C800A2A859 /* Hyphenation.h in Headers */ = {isa = PBXBuildFile; fileRef = 375CD231119D43C800A2A859 /* Hyphenation.h */; };
1485
		376DCCE113B4F966002EBEFC /* TextRun.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 376DCCE013B4F966002EBEFC /* TextRun.cpp */; };
1485
		376DCCE113B4F966002EBEFC /* TextRun.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 376DCCE013B4F966002EBEFC /* TextRun.cpp */; };
1486
		3774ABA50FA21EB400AD7DE9 /* OverlapTestRequestClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 3774ABA30FA21EB400AD7DE9 /* OverlapTestRequestClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
1486
		3774ABA50FA21EB400AD7DE9 /* OverlapTestRequestClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 3774ABA30FA21EB400AD7DE9 /* OverlapTestRequestClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
1487
		377A3A9015EFCE9B0059F5C7 /* BitmapImageCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 377A3A8F15EFCE9A0059F5C7 /* BitmapImageCG.cpp */; };
1487
		377A3A9015EFCE9B0059F5C7 /* PlatformImageCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 377A3A8F15EFCE9A0059F5C7 /* PlatformImageCG.cpp */; };
1488
		37919C230B7D188600A56998 /* PositionIterator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37919C210B7D188600A56998 /* PositionIterator.cpp */; };
1488
		37919C230B7D188600A56998 /* PositionIterator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37919C210B7D188600A56998 /* PositionIterator.cpp */; };
1489
		37919C240B7D188600A56998 /* PositionIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = 37919C220B7D188600A56998 /* PositionIterator.h */; settings = {ATTRIBUTES = (); }; };
1489
		37919C240B7D188600A56998 /* PositionIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = 37919C220B7D188600A56998 /* PositionIterator.h */; settings = {ATTRIBUTES = (); }; };
1490
		3792917A1985EF3900F4B661 /* CredentialBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 379291781985EF3900F4B661 /* CredentialBase.h */; settings = {ATTRIBUTES = (Private, ); }; };
1490
		3792917A1985EF3900F4B661 /* CredentialBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 379291781985EF3900F4B661 /* CredentialBase.h */; settings = {ATTRIBUTES = (Private, ); }; };
Lines 2325-2334 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec2
2325
		53ED3FDF167A88E7006762E6 /* JSInternalSettingsGenerated.h in Headers */ = {isa = PBXBuildFile; fileRef = 53ED3FDD167A88E7006762E6 /* JSInternalSettingsGenerated.h */; };
2325
		53ED3FDF167A88E7006762E6 /* JSInternalSettingsGenerated.h in Headers */ = {isa = PBXBuildFile; fileRef = 53ED3FDD167A88E7006762E6 /* JSInternalSettingsGenerated.h */; };
2326
		53EF766B16530A61004CBE49 /* SettingsMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 53EF766A16530A61004CBE49 /* SettingsMacros.h */; };
2326
		53EF766B16530A61004CBE49 /* SettingsMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 53EF766A16530A61004CBE49 /* SettingsMacros.h */; };
2327
		53EF766C16531994004CBE49 /* SettingsMacros.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 53EF766A16530A61004CBE49 /* SettingsMacros.h */; };
2327
		53EF766C16531994004CBE49 /* SettingsMacros.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 53EF766A16530A61004CBE49 /* SettingsMacros.h */; };
2328
		5504E4CB1D3557B200FE5088 /* BitmapPixels.h in Headers */ = {isa = PBXBuildFile; fileRef = 5504E4CA1D35532D00FE5088 /* BitmapPixels.h */; settings = {ATTRIBUTES = (Private, ); }; };
2328
		550A0BC9085F6039007353D6 /* QualifiedName.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 550A0BC7085F6039007353D6 /* QualifiedName.cpp */; };
2329
		550A0BC9085F6039007353D6 /* QualifiedName.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 550A0BC7085F6039007353D6 /* QualifiedName.cpp */; };
2329
		550A0BCA085F6039007353D6 /* QualifiedName.h in Headers */ = {isa = PBXBuildFile; fileRef = 550A0BC8085F6039007353D6 /* QualifiedName.h */; settings = {ATTRIBUTES = (Private, ); }; };
2330
		550A0BCA085F6039007353D6 /* QualifiedName.h in Headers */ = {isa = PBXBuildFile; fileRef = 550A0BC8085F6039007353D6 /* QualifiedName.h */; settings = {ATTRIBUTES = (Private, ); }; };
2330
		555B87EC1CAAF0AB00349425 /* ImageDecoderCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 555B87EA1CAAF0AB00349425 /* ImageDecoderCG.cpp */; };
2331
		555B87EC1CAAF0AB00349425 /* ImageDecoderCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 555B87EA1CAAF0AB00349425 /* ImageDecoderCG.cpp */; };
2331
		555B87ED1CAAF0AB00349425 /* ImageDecoderCG.h in Headers */ = {isa = PBXBuildFile; fileRef = 555B87EB1CAAF0AB00349425 /* ImageDecoderCG.h */; };
2332
		555B87ED1CAAF0AB00349425 /* ImageDecoderCG.h in Headers */ = {isa = PBXBuildFile; fileRef = 555B87EB1CAAF0AB00349425 /* ImageDecoderCG.h */; };
2333
		5574F0871D02790900B9F14C /* PlatformImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 5574F0851D02744400B9F14C /* PlatformImage.h */; settings = {ATTRIBUTES = (Private, ); }; };
2334
		55CBA6A11D1DF2E100451860 /* ImageFrameData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 55CBA69F1D1DF2E100451860 /* ImageFrameData.cpp */; };
2335
		55CBA6A21D1DF2E100451860 /* ImageFrameData.h in Headers */ = {isa = PBXBuildFile; fileRef = 55CBA6A01D1DF2E100451860 /* ImageFrameData.h */; settings = {ATTRIBUTES = (Private, ); }; };
2332
		572A7F211C6E5719009C6149 /* SimulatedClick.h in Headers */ = {isa = PBXBuildFile; fileRef = 572A7F201C6E5719009C6149 /* SimulatedClick.h */; };
2336
		572A7F211C6E5719009C6149 /* SimulatedClick.h in Headers */ = {isa = PBXBuildFile; fileRef = 572A7F201C6E5719009C6149 /* SimulatedClick.h */; };
2333
		572A7F231C6E5A66009C6149 /* SimulatedClick.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 572A7F221C6E5A66009C6149 /* SimulatedClick.cpp */; };
2337
		572A7F231C6E5A66009C6149 /* SimulatedClick.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 572A7F221C6E5A66009C6149 /* SimulatedClick.cpp */; };
2334
		57EF5E601D20C83900171E60 /* TextCodecReplacement.h in Headers */ = {isa = PBXBuildFile; fileRef = 57EF5E5F1D20C83900171E60 /* TextCodecReplacement.h */; };
2338
		57EF5E601D20C83900171E60 /* TextCodecReplacement.h in Headers */ = {isa = PBXBuildFile; fileRef = 57EF5E5F1D20C83900171E60 /* TextCodecReplacement.h */; };
Lines 9061-9067 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec3
9061
		376DCCE013B4F966002EBEFC /* TextRun.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextRun.cpp; sourceTree = "<group>"; };
9065
		376DCCE013B4F966002EBEFC /* TextRun.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextRun.cpp; sourceTree = "<group>"; };
9062
		3772B09516535856000A49CA /* PopupOpeningObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PopupOpeningObserver.h; sourceTree = "<group>"; };
9066
		3772B09516535856000A49CA /* PopupOpeningObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PopupOpeningObserver.h; sourceTree = "<group>"; };
9063
		3774ABA30FA21EB400AD7DE9 /* OverlapTestRequestClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OverlapTestRequestClient.h; sourceTree = "<group>"; };
9067
		3774ABA30FA21EB400AD7DE9 /* OverlapTestRequestClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OverlapTestRequestClient.h; sourceTree = "<group>"; };
9064
		377A3A8F15EFCE9A0059F5C7 /* BitmapImageCG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BitmapImageCG.cpp; sourceTree = "<group>"; };
9068
		377A3A8F15EFCE9A0059F5C7 /* PlatformImageCG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformImageCG.cpp; sourceTree = "<group>"; };
9065
		37919C210B7D188600A56998 /* PositionIterator.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = PositionIterator.cpp; sourceTree = "<group>"; };
9069
		37919C210B7D188600A56998 /* PositionIterator.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = PositionIterator.cpp; sourceTree = "<group>"; };
9066
		37919C220B7D188600A56998 /* PositionIterator.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PositionIterator.h; sourceTree = "<group>"; };
9070
		37919C220B7D188600A56998 /* PositionIterator.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PositionIterator.h; sourceTree = "<group>"; };
9067
		379291781985EF3900F4B661 /* CredentialBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CredentialBase.h; sourceTree = "<group>"; };
9071
		379291781985EF3900F4B661 /* CredentialBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CredentialBase.h; sourceTree = "<group>"; };
Lines 9989-9998 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec4
9989
		53ED3FDC167A88E7006762E6 /* JSInternalSettingsGenerated.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSInternalSettingsGenerated.cpp; sourceTree = "<group>"; };
9993
		53ED3FDC167A88E7006762E6 /* JSInternalSettingsGenerated.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSInternalSettingsGenerated.cpp; sourceTree = "<group>"; };
9990
		53ED3FDD167A88E7006762E6 /* JSInternalSettingsGenerated.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSInternalSettingsGenerated.h; sourceTree = "<group>"; };
9994
		53ED3FDD167A88E7006762E6 /* JSInternalSettingsGenerated.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSInternalSettingsGenerated.h; sourceTree = "<group>"; };
9991
		53EF766A16530A61004CBE49 /* SettingsMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingsMacros.h; sourceTree = "<group>"; };
9995
		53EF766A16530A61004CBE49 /* SettingsMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingsMacros.h; sourceTree = "<group>"; };
9996
		5504E4CA1D35532D00FE5088 /* BitmapPixels.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BitmapPixels.h; sourceTree = "<group>"; };
9992
		550A0BC7085F6039007353D6 /* QualifiedName.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = QualifiedName.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
9997
		550A0BC7085F6039007353D6 /* QualifiedName.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = QualifiedName.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
9993
		550A0BC8085F6039007353D6 /* QualifiedName.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = QualifiedName.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
9998
		550A0BC8085F6039007353D6 /* QualifiedName.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = QualifiedName.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
9994
		555B87EA1CAAF0AB00349425 /* ImageDecoderCG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageDecoderCG.cpp; sourceTree = "<group>"; };
9999
		555B87EA1CAAF0AB00349425 /* ImageDecoderCG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageDecoderCG.cpp; sourceTree = "<group>"; };
9995
		555B87EB1CAAF0AB00349425 /* ImageDecoderCG.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageDecoderCG.h; sourceTree = "<group>"; };
10000
		555B87EB1CAAF0AB00349425 /* ImageDecoderCG.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageDecoderCG.h; sourceTree = "<group>"; };
10001
		5574F0851D02744400B9F14C /* PlatformImage.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PlatformImage.h; sourceTree = "<group>"; };
10002
		55CBA69F1D1DF2E100451860 /* ImageFrameData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageFrameData.cpp; sourceTree = "<group>"; };
10003
		55CBA6A01D1DF2E100451860 /* ImageFrameData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageFrameData.h; sourceTree = "<group>"; };
9996
		55D408F71A7C631800C78450 /* SVGImageClients.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGImageClients.h; sourceTree = "<group>"; };
10004
		55D408F71A7C631800C78450 /* SVGImageClients.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGImageClients.h; sourceTree = "<group>"; };
9997
		572A7F201C6E5719009C6149 /* SimulatedClick.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimulatedClick.h; sourceTree = "<group>"; };
10005
		572A7F201C6E5719009C6149 /* SimulatedClick.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimulatedClick.h; sourceTree = "<group>"; };
9998
		572A7F221C6E5A66009C6149 /* SimulatedClick.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SimulatedClick.cpp; sourceTree = "<group>"; };
10006
		572A7F221C6E5A66009C6149 /* SimulatedClick.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SimulatedClick.cpp; sourceTree = "<group>"; };
Lines 22024-22030 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec5
22024
		B27535290B053814002CE64F /* cg */ = {
22032
		B27535290B053814002CE64F /* cg */ = {
22025
			isa = PBXGroup;
22033
			isa = PBXGroup;
22026
			children = (
22034
			children = (
22027
				377A3A8F15EFCE9A0059F5C7 /* BitmapImageCG.cpp */,
22028
				0FCF33230F2B9715004B6795 /* ColorCG.cpp */,
22035
				0FCF33230F2B9715004B6795 /* ColorCG.cpp */,
22029
				B275352B0B053814002CE64F /* FloatPointCG.cpp */,
22036
				B275352B0B053814002CE64F /* FloatPointCG.cpp */,
22030
				B275352C0B053814002CE64F /* FloatRectCG.cpp */,
22037
				B275352C0B053814002CE64F /* FloatRectCG.cpp */,
Lines 22051-22056 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec6
22051
				A80A38FD0E50CC8200A25EBC /* PatternCG.cpp */,
22058
				A80A38FD0E50CC8200A25EBC /* PatternCG.cpp */,
22052
				B27535360B053814002CE64F /* PDFDocumentImage.cpp */,
22059
				B27535360B053814002CE64F /* PDFDocumentImage.cpp */,
22053
				B27535370B053814002CE64F /* PDFDocumentImage.h */,
22060
				B27535370B053814002CE64F /* PDFDocumentImage.h */,
22061
				377A3A8F15EFCE9A0059F5C7 /* PlatformImageCG.cpp */,
22054
				1FC40FB81655C5910040F29E /* SubimageCacheWithTimer.cpp */,
22062
				1FC40FB81655C5910040F29E /* SubimageCacheWithTimer.cpp */,
22055
				1FC40FB71655C5910040F29E /* SubimageCacheWithTimer.h */,
22063
				1FC40FB71655C5910040F29E /* SubimageCacheWithTimer.h */,
22056
				B275352A0B053814002CE64F /* TransformationMatrixCG.cpp */,
22064
				B275352A0B053814002CE64F /* TransformationMatrixCG.cpp */,
Lines 22118-22123 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec7
22118
				BEF29EE91715DD0900C4B4C9 /* AudioTrackPrivate.h */,
22126
				BEF29EE91715DD0900C4B4C9 /* AudioTrackPrivate.h */,
22119
				A89943270B42338700D7C802 /* BitmapImage.cpp */,
22127
				A89943270B42338700D7C802 /* BitmapImage.cpp */,
22120
				A89943260B42338700D7C802 /* BitmapImage.h */,
22128
				A89943260B42338700D7C802 /* BitmapImage.h */,
22129
				5504E4CA1D35532D00FE5088 /* BitmapPixels.h */,
22121
				CDDE02E918B3DFC700CF7FF1 /* CDMSession.h */,
22130
				CDDE02E918B3DFC700CF7FF1 /* CDMSession.h */,
22122
				B27535380B053814002CE64F /* Color.cpp */,
22131
				B27535380B053814002CE64F /* Color.cpp */,
22123
				B27535390B053814002CE64F /* Color.h */,
22132
				B27535390B053814002CE64F /* Color.h */,
Lines 22202-22207 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec8
22202
				43D2597613C816F400608559 /* ImageBuffer.cpp */,
22211
				43D2597613C816F400608559 /* ImageBuffer.cpp */,
22203
				B2A10B910B3818BD00099AA4 /* ImageBuffer.h */,
22212
				B2A10B910B3818BD00099AA4 /* ImageBuffer.h */,
22204
				22BD9F7D1353625C009BD102 /* ImageBufferData.h */,
22213
				22BD9F7D1353625C009BD102 /* ImageBufferData.h */,
22214
				55CBA69F1D1DF2E100451860 /* ImageFrameData.cpp */,
22215
				55CBA6A01D1DF2E100451860 /* ImageFrameData.h */,
22205
				BC7F44A70B9E324E00A9D081 /* ImageObserver.h */,
22216
				BC7F44A70B9E324E00A9D081 /* ImageObserver.h */,
22206
				A8748D7412CC3F89001FBA41 /* ImageOrientation.cpp */,
22217
				A8748D7412CC3F89001FBA41 /* ImageOrientation.cpp */,
22207
				A8748D6612CC3763001FBA41 /* ImageOrientation.h */,
22218
				A8748D6612CC3763001FBA41 /* ImageOrientation.h */,
Lines 22251-22256 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec9
22251
				2D5002FA1B56D7990020AAF7 /* PathUtilities.h */,
22262
				2D5002FA1B56D7990020AAF7 /* PathUtilities.h */,
22252
				A8FA6E5C0E4CFDED00D5CF49 /* Pattern.cpp */,
22263
				A8FA6E5C0E4CFDED00D5CF49 /* Pattern.cpp */,
22253
				A8FA6E5B0E4CFDED00D5CF49 /* Pattern.h */,
22264
				A8FA6E5B0E4CFDED00D5CF49 /* Pattern.h */,
22265
				5574F0851D02744400B9F14C /* PlatformImage.h */,
22254
				0562F9601573F88F0031CA16 /* PlatformLayer.h */,
22266
				0562F9601573F88F0031CA16 /* PlatformLayer.h */,
22255
				CEEFCD7B19DB33DC003876D7 /* PlatformMediaResourceLoader.h */,
22267
				CEEFCD7B19DB33DC003876D7 /* PlatformMediaResourceLoader.h */,
22256
				072847E216EBC5B00043CFA4 /* PlatformTextTrack.h */,
22268
				072847E216EBC5B00043CFA4 /* PlatformTextTrack.h */,
Lines 26018-26023 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec10
26018
				85E711B90AC5D5350053270F /* DOMHTMLMapElementInternal.h in Headers */,
26030
				85E711B90AC5D5350053270F /* DOMHTMLMapElementInternal.h in Headers */,
26019
				BC51579F0C03BBD3008BB0EE /* DOMHTMLMarqueeElement.h in Headers */,
26031
				BC51579F0C03BBD3008BB0EE /* DOMHTMLMarqueeElement.h in Headers */,
26020
				BC5156EA0C03B741008BB0EE /* DOMHTMLMarqueeElementInternal.h in Headers */,
26032
				BC5156EA0C03B741008BB0EE /* DOMHTMLMarqueeElementInternal.h in Headers */,
26033
				5574F0871D02790900B9F14C /* PlatformImage.h in Headers */,
26021
				2DEC66551C82D0410099846A /* DOMHTMLMediaElement.h in Headers */,
26034
				2DEC66551C82D0410099846A /* DOMHTMLMediaElement.h in Headers */,
26022
				2DEC66511C82D0160099846A /* DOMHTMLMediaElementInternal.h in Headers */,
26035
				2DEC66511C82D0160099846A /* DOMHTMLMediaElementInternal.h in Headers */,
26023
				85BA4D130AA688680088052D /* DOMHTMLMenuElement.h in Headers */,
26036
				85BA4D130AA688680088052D /* DOMHTMLMenuElement.h in Headers */,
Lines 26459-26464 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec11
26459
				D359D78A129CA2710006E5D2 /* HTMLDetailsElement.h in Headers */,
26472
				D359D78A129CA2710006E5D2 /* HTMLDetailsElement.h in Headers */,
26460
				A8EA79FA0A1916DF00A8EF5F /* HTMLDirectoryElement.h in Headers */,
26473
				A8EA79FA0A1916DF00A8EF5F /* HTMLDirectoryElement.h in Headers */,
26461
				A8EA7CB70A192B9C00A8EF5F /* HTMLDivElement.h in Headers */,
26474
				A8EA7CB70A192B9C00A8EF5F /* HTMLDivElement.h in Headers */,
26475
				55CBA6A21D1DF2E100451860 /* ImageFrameData.h in Headers */,
26462
				A8EA79F70A1916DF00A8EF5F /* HTMLDListElement.h in Headers */,
26476
				A8EA79F70A1916DF00A8EF5F /* HTMLDListElement.h in Headers */,
26463
				93F198E508245E59001E9ABC /* HTMLDocument.h in Headers */,
26477
				93F198E508245E59001E9ABC /* HTMLDocument.h in Headers */,
26464
				977B3867122883E900B81FF8 /* HTMLDocumentParser.h in Headers */,
26478
				977B3867122883E900B81FF8 /* HTMLDocumentParser.h in Headers */,
Lines 28359-28364 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec12
28359
				B22279930D00BF220071B782 /* SVGAnimateMotionElement.h in Headers */,
28373
				B22279930D00BF220071B782 /* SVGAnimateMotionElement.h in Headers */,
28360
				B22279950D00BF220071B782 /* SVGAnimateTransformElement.h in Headers */,
28374
				B22279950D00BF220071B782 /* SVGAnimateTransformElement.h in Headers */,
28361
				B22279980D00BF220071B782 /* SVGAnimationElement.h in Headers */,
28375
				B22279980D00BF220071B782 /* SVGAnimationElement.h in Headers */,
28376
				5504E4CB1D3557B200FE5088 /* BitmapPixels.h in Headers */,
28362
				439D334513A6911C00C20F4F /* SVGAnimatorFactory.h in Headers */,
28377
				439D334513A6911C00C20F4F /* SVGAnimatorFactory.h in Headers */,
28363
				08FB3F8413BC754C0099FC18 /* SVGAttributeToPropertyMap.h in Headers */,
28378
				08FB3F8413BC754C0099FC18 /* SVGAttributeToPropertyMap.h in Headers */,
28364
				B222799C0D00BF220071B782 /* SVGCircleElement.h in Headers */,
28379
				B222799C0D00BF220071B782 /* SVGCircleElement.h in Headers */,
Lines 29411-29417 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec13
29411
				FDC54F041399B0DA008D9117 /* BiquadFilterNode.cpp in Sources */,
29426
				FDC54F041399B0DA008D9117 /* BiquadFilterNode.cpp in Sources */,
29412
				FD31602612B0267600C1A359 /* BiquadProcessor.cpp in Sources */,
29427
				FD31602612B0267600C1A359 /* BiquadProcessor.cpp in Sources */,
29413
				A89943290B42338800D7C802 /* BitmapImage.cpp in Sources */,
29428
				A89943290B42338800D7C802 /* BitmapImage.cpp in Sources */,
29414
				377A3A9015EFCE9B0059F5C7 /* BitmapImageCG.cpp in Sources */,
29429
				377A3A9015EFCE9B0059F5C7 /* PlatformImageCG.cpp in Sources */,
29415
				976D6C78122B8A3D001FD1F7 /* Blob.cpp in Sources */,
29430
				976D6C78122B8A3D001FD1F7 /* Blob.cpp in Sources */,
29416
				2EDEF1F3121B0EFC00726DB2 /* BlobData.cpp in Sources */,
29431
				2EDEF1F3121B0EFC00726DB2 /* BlobData.cpp in Sources */,
29417
				E1D31CDC19196020001005A3 /* BlobDataFileReference.cpp in Sources */,
29432
				E1D31CDC19196020001005A3 /* BlobDataFileReference.cpp in Sources */,
Lines 29774-29779 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec14
29774
				2E2D99E810E2BC1C00496337 /* DOMBlob.mm in Sources */,
29789
				2E2D99E810E2BC1C00496337 /* DOMBlob.mm in Sources */,
29775
				85089CD80A98C42800A275AA /* DOMCDATASection.mm in Sources */,
29790
				85089CD80A98C42800A275AA /* DOMCDATASection.mm in Sources */,
29776
				85ACA9870A9B520300671E90 /* DOMCharacterData.mm in Sources */,
29791
				85ACA9870A9B520300671E90 /* DOMCharacterData.mm in Sources */,
29792
				55CBA6A11D1DF2E100451860 /* ImageFrameData.cpp in Sources */,
29777
				85089CDA0A98C42800A275AA /* DOMComment.mm in Sources */,
29793
				85089CDA0A98C42800A275AA /* DOMComment.mm in Sources */,
29778
				978D07BE145A0F6C0096908D /* DOMCoreException.cpp in Sources */,
29794
				978D07BE145A0F6C0096908D /* DOMCoreException.cpp in Sources */,
29779
				858C38A60AA8F20400B187A4 /* DOMCounter.mm in Sources */,
29795
				858C38A60AA8F20400B187A4 /* DOMCounter.mm in Sources */,
- a/Source/WebCore/bindings/objc/DOM.mm -1 / +1 lines
Lines 606-612 - (void)getPreviewSnapshotImage:(CGImageRef*)cgImage andRects:(NSArray **)rects a/Source/WebCore/bindings/objc/DOM.mm_sec1
606
606
607
    if (textIndicator) {
607
    if (textIndicator) {
608
        if (Image* image = textIndicator->contentImage())
608
        if (Image* image = textIndicator->contentImage())
609
            *cgImage = (CGImageRef)CFAutorelease(CGImageRetain(image->getCGImageRef()));
609
            *cgImage = image->nativeImage().autorelease();
610
    }
610
    }
611
611
612
    RetainPtr<NSMutableArray> rectArray = adoptNS([[NSMutableArray alloc] init]);
612
    RetainPtr<NSMutableArray> rectArray = adoptNS([[NSMutableArray alloc] init]);
- a/Source/WebCore/page/mac/TextIndicatorWindow.mm -3 / +3 lines
Lines 162-170 - (instancetype)initWithFrame:(NSRect)frame textIndicator:(PassRefPtr<TextIndica a/Source/WebCore/page/mac/TextIndicatorWindow.mm_sec1
162
    contentsImageLogicalSize.scale(1 / _textIndicator->contentImageScaleFactor());
162
    contentsImageLogicalSize.scale(1 / _textIndicator->contentImageScaleFactor());
163
    RetainPtr<CGImageRef> contentsImage;
163
    RetainPtr<CGImageRef> contentsImage;
164
    if (indicatorWantsContentCrossfade(*_textIndicator))
164
    if (indicatorWantsContentCrossfade(*_textIndicator))
165
        contentsImage = _textIndicator->contentImageWithHighlight()->getCGImageRef();
165
        contentsImage = _textIndicator->contentImageWithHighlight()->nativeImage();
166
    else
166
    else
167
        contentsImage = _textIndicator->contentImage()->getCGImageRef();
167
        contentsImage = _textIndicator->contentImage()->nativeImage();
168
168
169
    RetainPtr<NSMutableArray> bounceLayers = adoptNS([[NSMutableArray alloc] init]);
169
    RetainPtr<NSMutableArray> bounceLayers = adoptNS([[NSMutableArray alloc] init]);
170
170
Lines 265-271 static RetainPtr<CAKeyframeAnimation> createBounceAnimation(CFTimeInterval durat a/Source/WebCore/page/mac/TextIndicatorWindow.mm_sec2
265
static RetainPtr<CABasicAnimation> createContentCrossfadeAnimation(CFTimeInterval duration, TextIndicator& textIndicator)
265
static RetainPtr<CABasicAnimation> createContentCrossfadeAnimation(CFTimeInterval duration, TextIndicator& textIndicator)
266
{
266
{
267
    RetainPtr<CABasicAnimation> crossfadeAnimation = [CABasicAnimation animationWithKeyPath:@"contents"];
267
    RetainPtr<CABasicAnimation> crossfadeAnimation = [CABasicAnimation animationWithKeyPath:@"contents"];
268
    RetainPtr<CGImageRef> contentsImage = textIndicator.contentImage()->getCGImageRef();
268
    RetainPtr<CGImageRef> contentsImage = textIndicator.contentImage()->nativeImage();
269
    [crossfadeAnimation setToValue:(id)contentsImage.get()];
269
    [crossfadeAnimation setToValue:(id)contentsImage.get()];
270
    [crossfadeAnimation setFillMode:kCAFillModeForwards];
270
    [crossfadeAnimation setFillMode:kCAFillModeForwards];
271
    [crossfadeAnimation setRemovedOnCompletion:NO];
271
    [crossfadeAnimation setRemovedOnCompletion:NO];
- a/Source/WebCore/platform/graphics/BitmapImage.cpp -62 / +113 lines
Lines 68-82 BitmapImage::BitmapImage(NativeImagePtr&& image, ImageObserver* observer) a/Source/WebCore/platform/graphics/BitmapImage.cpp_sec1
68
    , m_haveFrameCount(true)
68
    , m_haveFrameCount(true)
69
    , m_animationFinishedWhenCatchingUp(false)
69
    , m_animationFinishedWhenCatchingUp(false)
70
{
70
{
71
    m_frames.reserveInitialCapacity(1);
72
    m_frames.uncheckedAppend(WTFMove(image));
73
    
71
    // Since we don't have a decoder, we can't figure out the image orientation.
74
    // Since we don't have a decoder, we can't figure out the image orientation.
72
    // Set m_sizeRespectingOrientation to be the same as m_size so it's not 0x0.
75
    // Set m_sizeRespectingOrientation to be the same as m_size so it's not 0x0.
73
    m_sizeRespectingOrientation = m_size = NativeImage::size(image);
76
    m_sizeRespectingOrientation = m_size = m_frames[0].size();
74
    m_decodedSize = m_size.area() * 4;
77
    m_decodedSize = m_size.area() * 4;
75
    
76
    m_frames.grow(1);
77
    m_frames[0].m_hasAlpha = NativeImage::hasAlpha(image);
78
    m_frames[0].m_haveMetadata = true;
79
    m_frames[0].m_image = WTFMove(image);
80
}
78
}
81
79
82
BitmapImage::~BitmapImage()
80
BitmapImage::~BitmapImage()
Lines 105-111 bool BitmapImage::haveFrameImageAtIndex(size_t index) a/Source/WebCore/platform/graphics/BitmapImage.cpp_sec2
105
    if (index >= m_frames.size())
103
    if (index >= m_frames.size())
106
        return false;
104
        return false;
107
105
108
    return m_frames[index].m_image;
106
    return m_frames[index].hasImage();
109
}
107
}
110
108
111
bool BitmapImage::hasSingleSecurityOrigin() const
109
bool BitmapImage::hasSingleSecurityOrigin() const
Lines 125-133 void BitmapImage::destroyDecodedData(bool destroyAll) a/Source/WebCore/platform/graphics/BitmapImage.cpp_sec3
125
        // The underlying frame isn't actually changing (we're just trying to
123
        // The underlying frame isn't actually changing (we're just trying to
126
        // save the memory for the framebuffer data), so we don't need to clear
124
        // save the memory for the framebuffer data), so we don't need to clear
127
        // the metadata.
125
        // the metadata.
128
        unsigned frameBytes = m_frames[i].m_frameBytes;
126
        frameBytesCleared += m_frames[i].clear(ImageFrameData::Caching::Metadata);
129
        if (m_frames[i].clear(false))
130
            frameBytesCleared += frameBytes;
131
    }
127
    }
132
128
133
    m_source.clear(destroyAll, clearBeforeFrame, data(), m_allDataReceived);
129
    m_source.clear(destroyAll, clearBeforeFrame, data(), m_allDataReceived);
Lines 150-157 void BitmapImage::destroyDecodedDataIfNecessary(bool destroyAll) a/Source/WebCore/platform/graphics/BitmapImage.cpp_sec4
150
        return;
146
        return;
151
147
152
    unsigned allFrameBytes = 0;
148
    unsigned allFrameBytes = 0;
153
    for (size_t i = 0; i < m_frames.size(); ++i)
149
    for (auto& frame : m_frames)
154
        allFrameBytes += m_frames[i].usedFrameBytes();
150
        allFrameBytes += frame.frameBytes();
155
151
156
    if (allFrameBytes > largeAnimationCutoff) {
152
    if (allFrameBytes > largeAnimationCutoff) {
157
        LOG(Images, "BitmapImage %p destroyDecodedDataIfNecessary destroyingData: allFrameBytes=%u cutoff=%u", this, allFrameBytes, largeAnimationCutoff);
153
        LOG(Images, "BitmapImage %p destroyDecodedDataIfNecessary destroyingData: allFrameBytes=%u cutoff=%u", this, allFrameBytes, largeAnimationCutoff);
Lines 177-183 void BitmapImage::destroyMetadataAndNotify(unsigned frameBytesCleared, ClearedSo a/Source/WebCore/platform/graphics/BitmapImage.cpp_sec5
177
        imageObserver()->decodedSizeChanged(this, -safeCast<int>(frameBytesCleared));
173
        imageObserver()->decodedSizeChanged(this, -safeCast<int>(frameBytesCleared));
178
}
174
}
179
175
180
void BitmapImage::cacheFrame(size_t index, SubsamplingLevel subsamplingLevel, ImageFrameCaching frameCaching)
176
void BitmapImage::cacheFrame(size_t index, SubsamplingLevel subsamplingLevel, ImageFrameData::Caching caching)
181
{
177
{
182
    size_t numFrames = frameCount();
178
    size_t numFrames = frameCount();
183
    ASSERT(m_decodedSize == 0 || numFrames > 1);
179
    ASSERT(m_decodedSize == 0 || numFrames > 1);
Lines 185-209 void BitmapImage::cacheFrame(size_t index, SubsamplingLevel subsamplingLevel, Im a/Source/WebCore/platform/graphics/BitmapImage.cpp_sec6
185
    if (m_frames.size() < numFrames)
181
    if (m_frames.size() < numFrames)
186
        m_frames.grow(numFrames);
182
        m_frames.grow(numFrames);
187
183
188
    if (frameCaching == CacheMetadataAndFrame) {
184
    m_frames[index] = m_source.createFrameDataAtIndex(index, subsamplingLevel, caching);
189
        m_frames[index].m_image = m_source.createFrameImageAtIndex(index, subsamplingLevel);
190
        m_frames[index].m_subsamplingLevel = subsamplingLevel;
191
    }
192
193
    m_frames[index].m_orientation = m_source.orientationAtIndex(index);
194
    m_frames[index].m_haveMetadata = true;
195
    m_frames[index].m_isComplete = m_source.frameIsCompleteAtIndex(index);
196
185
197
    if (repetitionCount(false) != cAnimationNone)
186
    LOG(Images, "BitmapImage %p cacheFrame %lu (%s%u bytes, complete %d)", this, index, caching == ImageFrameData::Caching::Metadata ? "metadata only, " : "", m_frames[index].frameBytes(), m_frames[index].isComplete());
198
        m_frames[index].m_duration = m_source.frameDurationAtIndex(index);
199
187
200
    m_frames[index].m_hasAlpha = m_source.frameHasAlphaAtIndex(index);
188
    if (m_frames[index].hasImage()) {
201
    m_frames[index].m_frameBytes = m_source.frameBytesAtIndex(index, subsamplingLevel);
189
        int deltaBytes = safeCast<int>(m_frames[index].frameBytes());
202
203
    LOG(Images, "BitmapImage %p cacheFrame %lu (%s%u bytes, complete %d)", this, index, frameCaching == CacheMetadataOnly ? "metadata only, " : "", m_frames[index].m_frameBytes, m_frames[index].m_isComplete);
204
205
    if (m_frames[index].m_image) {
206
        int deltaBytes = safeCast<int>(m_frames[index].m_frameBytes);
207
        m_decodedSize += deltaBytes;
190
        m_decodedSize += deltaBytes;
208
        // The fully-decoded frame will subsume the partially decoded data used
191
        // The fully-decoded frame will subsume the partially decoded data used
209
        // to determine image properties.
192
        // to determine image properties.
Lines 288-308 bool BitmapImage::dataChanged(bool allDataReceived) a/Source/WebCore/platform/graphics/BitmapImage.cpp_sec7
288
    // frame affected by appending new data here. Thus we have to clear all the
271
    // frame affected by appending new data here. Thus we have to clear all the
289
    // incomplete frames to be safe.
272
    // incomplete frames to be safe.
290
    unsigned frameBytesCleared = 0;
273
    unsigned frameBytesCleared = 0;
291
    for (size_t i = 0; i < m_frames.size(); ++i) {
274
    for (auto& frame : m_frames) {
292
        // NOTE: Don't call frameIsCompleteAtIndex() here, that will try to
275
        // NOTE: Don't call frameIsCompleteAtIndex() here, that will try to
293
        // decode any uncached (i.e. never-decoded or
276
        // decode any uncached (i.e. never-decoded or
294
        // cleared-on-a-previous-pass) frames!
277
        // cleared-on-a-previous-pass) frames!
295
        unsigned frameBytes = m_frames[i].m_frameBytes;
278
        if (frame.hasMetadata() && !frame.isComplete())
296
        if (m_frames[i].m_haveMetadata && !m_frames[i].m_isComplete)
279
            frameBytesCleared += frame.clear(ImageFrameData::Caching::Empty);
297
            frameBytesCleared += (m_frames[i].clear(true) ? frameBytes : 0);
298
    }
280
    }
299
    destroyMetadataAndNotify(frameBytesCleared, ClearedSource::No);
281
    destroyMetadataAndNotify(frameBytesCleared, ClearedSource::No);
300
#else
282
#else
301
    // FIXME: why is this different for iOS?
283
    // FIXME: why is this different for iOS?
302
    int deltaBytes = 0;
284
    int deltaBytes = 0;
303
    if (!m_frames.isEmpty()) {
285
    if (!m_frames.isEmpty()) {
304
        int bytes = m_frames[m_frames.size() - 1].m_frameBytes;
286
        if (int bytes = m_frames[m_frames.size() - 1].clear(ImageFrameData::Caching::Empty)) {
305
        if (m_frames[m_frames.size() - 1].clear(true)) {
306
            deltaBytes += bytes;
287
            deltaBytes += bytes;
307
            deltaBytes += m_decodedPropertiesSize;
288
            deltaBytes += m_decodedPropertiesSize;
308
            m_decodedPropertiesSize = 0;
289
            m_decodedPropertiesSize = 0;
Lines 366-380 bool BitmapImage::isSizeAvailable() a/Source/WebCore/platform/graphics/BitmapImage.cpp_sec8
366
    return m_sizeAvailable;
347
    return m_sizeAvailable;
367
}
348
}
368
349
369
bool BitmapImage::ensureFrameIsCached(size_t index, ImageFrameCaching frameCaching)
350
bool BitmapImage::ensureFrameIsCached(size_t index, ImageFrameData::Caching caching)
370
{
351
{
371
    if (index >= frameCount())
352
    if (index >= frameCount())
372
        return false;
353
        return false;
373
354
374
    if (index >= m_frames.size()
355
    if (index >= m_frames.size()
375
        || (frameCaching == CacheMetadataAndFrame && !m_frames[index].m_image)
356
        || (caching == ImageFrameData::Caching::MetadataAndImage && !m_frames[index].hasImage())
376
        || (frameCaching == CacheMetadataOnly && !m_frames[index].m_haveMetadata))
357
        || (caching == ImageFrameData::Caching::Metadata && !m_frames[index].hasMetadata()))
377
        cacheFrame(index, 0, frameCaching);
358
        cacheFrame(index, 0, caching);
378
359
379
    return true;
360
    return true;
380
}
361
}
Lines 388-397 NativeImagePtr BitmapImage::frameImageAtIndex(size_t index, float presentationSc a/Source/WebCore/platform/graphics/BitmapImage.cpp_sec9
388
369
389
    // We may have cached a frame with a higher subsampling level, in which case we need to
370
    // We may have cached a frame with a higher subsampling level, in which case we need to
390
    // re-decode with a lower level.
371
    // re-decode with a lower level.
391
    if (index < m_frames.size() && m_frames[index].m_image && subsamplingLevel < m_frames[index].m_subsamplingLevel) {
372
    if (index < m_frames.size() && m_frames[index].hasImage() && subsamplingLevel < m_frames[index].subsamplingLevel()) {
392
        // If the image is already cached, but at too small a size, re-decode a larger version.
373
        // If the image is already cached, but at too small a size, re-decode a larger version.
393
        int sizeChange = -m_frames[index].m_frameBytes;
374
        int sizeChange = -m_frames[index].clear(ImageFrameData::Caching::Empty);
394
        m_frames[index].clear(true);
395
        invalidatePlatformData();
375
        invalidatePlatformData();
396
        m_decodedSize += sizeChange;
376
        m_decodedSize += sizeChange;
397
        if (imageObserver())
377
        if (imageObserver())
Lines 399-438 NativeImagePtr BitmapImage::frameImageAtIndex(size_t index, float presentationSc a/Source/WebCore/platform/graphics/BitmapImage.cpp_sec10
399
    }
379
    }
400
380
401
    // If we haven't fetched a frame yet, do so.
381
    // If we haven't fetched a frame yet, do so.
402
    if (index >= m_frames.size() || !m_frames[index].m_image)
382
    if (index >= m_frames.size() || !m_frames[index].hasImage())
403
        cacheFrame(index, subsamplingLevel, CacheMetadataAndFrame);
383
        cacheFrame(index, subsamplingLevel, ImageFrameData::Caching::MetadataAndImage);
384
385
    return m_frames[index].image();
386
}
387
    
388
NativeImagePtr BitmapImage::nativeImage()
389
{
390
    return frameImageAtIndex(0);
391
}
392
    
393
NativeImagePtr BitmapImage::nativeImageOfSize(const IntSize& size)
394
{
395
    size_t count = frameCount();
396
    
397
    for (size_t i = 0; i < count; ++i) {
398
        auto image = frameImageAtIndex(i);
399
        if (image && PlatformImage(image).size() == size)
400
            return image;
401
    }
402
    
403
    // Fallback to the first frame image if we can't find the right size
404
    return frameImageAtIndex(0);
405
}
406
    
407
NativeImagePtr BitmapImage::nativeImageForCurrentFrame()
408
{
409
    return frameImageAtIndex(m_currentFrame);
410
}
404
411
405
    return m_frames[index].m_image;
412
Vector<NativeImagePtr> BitmapImage::framesNativeImages()
413
{
414
    Vector<NativeImagePtr> images;
415
    size_t count = frameCount();
416
    
417
    for (size_t i = 0; i < count; ++i) {
418
        if (auto image = frameImageAtIndex(i))
419
            images.append(image);
420
    }
421
    
422
    return images;
406
}
423
}
407
424
408
bool BitmapImage::frameIsCompleteAtIndex(size_t index)
425
bool BitmapImage::frameIsCompleteAtIndex(size_t index)
409
{
426
{
410
    if (!ensureFrameIsCached(index, CacheMetadataOnly))
427
    if (!ensureFrameIsCached(index, ImageFrameData::Caching::Metadata))
411
        return false;
428
        return false;
412
429
413
    return m_frames[index].m_isComplete;
430
    return m_frames[index].isComplete();
414
}
431
}
415
432
416
float BitmapImage::frameDurationAtIndex(size_t index)
433
float BitmapImage::frameDurationAtIndex(size_t index)
417
{
434
{
418
    if (!ensureFrameIsCached(index, CacheMetadataOnly))
435
    if (!ensureFrameIsCached(index, ImageFrameData::Caching::Metadata))
419
        return 0;
436
        return 0;
420
437
421
    return m_frames[index].m_duration;
438
    return m_frames[index].duration();
422
}
423
424
NativeImagePtr BitmapImage::nativeImageForCurrentFrame()
425
{
426
    return frameImageAtIndex(currentFrame());
427
}
439
}
428
440
429
bool BitmapImage::frameHasAlphaAtIndex(size_t index)
441
bool BitmapImage::frameHasAlphaAtIndex(size_t index)
430
{
442
{
431
    if (!ensureFrameIsCached(index, CacheMetadataOnly))
443
    if (!ensureFrameIsCached(index, ImageFrameData::Caching::Metadata))
432
        return true;
444
        return true;
433
445
434
    if (m_frames[index].m_haveMetadata)
446
    if (m_frames[index].hasMetadata())
435
        return m_frames[index].m_hasAlpha;
447
        return m_frames[index].hasAlpha();
436
448
437
    return m_source.frameHasAlphaAtIndex(index);
449
    return m_source.frameHasAlphaAtIndex(index);
438
}
450
}
Lines 444-454 bool BitmapImage::currentFrameKnownToBeOpaque() a/Source/WebCore/platform/graphics/BitmapImage.cpp_sec11
444
456
445
ImageOrientation BitmapImage::frameOrientationAtIndex(size_t index)
457
ImageOrientation BitmapImage::frameOrientationAtIndex(size_t index)
446
{
458
{
447
    if (!ensureFrameIsCached(index, CacheMetadataOnly))
459
    if (!ensureFrameIsCached(index, ImageFrameData::Caching::Metadata))
448
        return ImageOrientation();
460
        return ImageOrientation();
449
461
450
    if (m_frames[index].m_haveMetadata)
462
    if (m_frames[index].hasMetadata())
451
        return m_frames[index].m_orientation;
463
        return m_frames[index].orientation();
452
464
453
    return m_source.orientationAtIndex(index);
465
    return m_source.orientationAtIndex(index);
454
}
466
}
Lines 700-716 Color BitmapImage::singlePixelSolidColor() a/Source/WebCore/platform/graphics/BitmapImage.cpp_sec12
700
        return Color();
712
        return Color();
701
    
713
    
702
    ASSERT(m_frames.size());
714
    ASSERT(m_frames.size());
703
    m_solidColor = NativeImage::singlePixelSolidColor(m_frames[0].m_image.get());
715
    m_solidColor = m_frames[0].singlePixelSolidColor();
704
    
716
    
705
    ASSERT(m_solidColor);
717
    ASSERT(m_solidColor);
706
    return m_solidColor.value();
718
    return m_solidColor.value();
707
}
719
}
708
    
720
    
721
bool BitmapImage::isAlmostSolidColor()
722
{
723
    if (frameCount() != 1)
724
        return false;
725
726
    return ensureFrameIsCached(0) && m_frames[0].isAlmostSolidColor();
727
}
728
    
709
bool BitmapImage::canAnimate()
729
bool BitmapImage::canAnimate()
710
{
730
{
711
    return shouldAnimate() && frameCount() > 1;
731
    return shouldAnimate() && frameCount() > 1;
712
}
732
}
713
733
734
void BitmapImage::draw(GraphicsContext& context, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator op, BlendMode mode, ImageOrientationDescription description)
735
{
736
    if (destRect.isEmpty() || srcRect.isEmpty())
737
        return;
738
739
#if PLATFORM(IOS)
740
    startAnimation(DoNotCatchUp);
741
#else
742
    startAnimation();
743
#endif
744
    
745
    Color color = singlePixelSolidColor();
746
    if (color.isValid()) {
747
        fillWithSolidColor(context, destRect, color, op);
748
        return;
749
    }
750
    
751
    auto image = frameImageAtIndex(m_currentFrame, PlatformImage::subsamplingScale(context, destRect, srcRect));
752
    if (!image) // If it's too early we won't have an image yet.
753
        return;
754
    
755
    ImageOrientation orientation(description.imageOrientation());
756
    if (description.respectImageOrientation() == RespectImageOrientation)
757
        orientation = frameOrientationAtIndex(m_currentFrame);
758
    
759
    PlatformImage(image).draw(context, destRect, srcRect, m_size, op, mode, orientation);
760
    
761
    if (imageObserver())
762
        imageObserver()->didDraw(this);
763
}
764
    
714
void BitmapImage::dump(TextStream& ts) const
765
void BitmapImage::dump(TextStream& ts) const
715
{
766
{
716
    Image::dump(ts);
767
    Image::dump(ts);
- a/Source/WebCore/platform/graphics/BitmapImage.h -66 / +11 lines
Lines 28-38 a/Source/WebCore/platform/graphics/BitmapImage.h_sec1
28
#ifndef BitmapImage_h
28
#ifndef BitmapImage_h
29
#define BitmapImage_h
29
#define BitmapImage_h
30
30
31
#include "Image.h"
32
#include "Color.h"
31
#include "Color.h"
32
#include "Image.h"
33
#include "ImageFrameData.h"
33
#include "ImageOrientation.h"
34
#include "ImageOrientation.h"
34
#include "ImageSource.h"
35
#include "ImageSource.h"
35
#include "IntSize.h"
36
#include "IntSize.h"
37
#include "PlatformImage.h"
36
38
37
#if USE(CG) || USE(APPKIT)
39
#if USE(CG) || USE(APPKIT)
38
#include <wtf/RetainPtr.h>
40
#include <wtf/RetainPtr.h>
Lines 47-109 typedef struct HBITMAP__ *HBITMAP; a/Source/WebCore/platform/graphics/BitmapImage.h_sec2
47
#endif
49
#endif
48
50
49
namespace WebCore {
51
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
52
61
class Timer;
53
class Timer;
62
54
63
namespace NativeImage {
64
    IntSize size(const NativeImagePtr&);
65
    bool hasAlpha(const NativeImagePtr&);
66
    Color singlePixelSolidColor(const NativeImagePtr&);
67
}
68
69
// ================================================
70
// FrameData Class
71
// ================================================
72
73
struct FrameData {
74
public:
75
    FrameData()
76
        : m_haveMetadata(false)
77
        , m_isComplete(false)
78
        , m_hasAlpha(true)
79
    {
80
    }
81
82
    ~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);
90
    
91
    unsigned usedFrameBytes() const { return m_image ? m_frameBytes : 0; }
92
93
    NativeImagePtr m_image;
94
    ImageOrientation m_orientation { DefaultImageOrientation };
95
    SubsamplingLevel m_subsamplingLevel { 0 };
96
    float m_duration { 0 };
97
    bool m_haveMetadata : 1;
98
    bool m_isComplete : 1;
99
    bool m_hasAlpha : 1;
100
    unsigned m_frameBytes { 0 };
101
};
102
103
// =================================================
104
// BitmapImage Class
105
// =================================================
106
107
class BitmapImage final : public Image {
55
class BitmapImage final : public Image {
108
    friend class GeneratedImage;
56
    friend class GeneratedImage;
109
    friend class CrossfadeGeneratedImage;
57
    friend class CrossfadeGeneratedImage;
Lines 155-166 public: a/Source/WebCore/platform/graphics/BitmapImage.h_sec3
155
    CFDataRef getTIFFRepresentation() override;
103
    CFDataRef getTIFFRepresentation() override;
156
#endif
104
#endif
157
105
158
#if USE(CG)
159
    WEBCORE_EXPORT CGImageRef getCGImageRef() override;
160
    CGImageRef getFirstCGImageRefOfSize(const IntSize&) override;
161
    RetainPtr<CFArrayRef> getCGImageArray() override;
162
#endif
163
164
#if PLATFORM(WIN)
106
#if PLATFORM(WIN)
165
    bool getHBITMAP(HBITMAP) override;
107
    bool getHBITMAP(HBITMAP) override;
166
    bool getHBITMAPOfSize(HBITMAP, const IntSize*) override;
108
    bool getHBITMAPOfSize(HBITMAP, const IntSize*) override;
Lines 174-181 public: a/Source/WebCore/platform/graphics/BitmapImage.h_sec4
174
    Evas_Object* getEvasObject(Evas*) override;
116
    Evas_Object* getEvasObject(Evas*) override;
175
#endif
117
#endif
176
118
119
    WEBCORE_EXPORT NativeImagePtr nativeImage() override;
120
    NativeImagePtr nativeImageOfSize(const IntSize&) override;
177
    NativeImagePtr nativeImageForCurrentFrame() override;
121
    NativeImagePtr nativeImageForCurrentFrame() override;
178
    ImageOrientation orientationForCurrentFrame() override { return frameOrientationAtIndex(currentFrame()); }
122
    ImageOrientation orientationForCurrentFrame() override { return frameOrientationAtIndex(currentFrame()); }
123
    Vector<NativeImagePtr> framesNativeImages() override;
124
    
125
    WEBCORE_EXPORT bool isAlmostSolidColor();
179
126
180
    bool currentFrameKnownToBeOpaque() override;
127
    bool currentFrameKnownToBeOpaque() override;
181
128
Lines 215-221 protected: a/Source/WebCore/platform/graphics/BitmapImage.h_sec5
215
    size_t frameCount();
162
    size_t frameCount();
216
163
217
    NativeImagePtr frameImageAtIndex(size_t, float presentationScaleHint = 1);
164
    NativeImagePtr frameImageAtIndex(size_t, float presentationScaleHint = 1);
218
    NativeImagePtr copyUnscaledFrameImageAtIndex(size_t);
219
165
220
    bool haveFrameImageAtIndex(size_t);
166
    bool haveFrameImageAtIndex(size_t);
221
167
Lines 225-235 protected: a/Source/WebCore/platform/graphics/BitmapImage.h_sec6
225
    ImageOrientation frameOrientationAtIndex(size_t);
171
    ImageOrientation frameOrientationAtIndex(size_t);
226
172
227
    // Decodes and caches a frame. Never accessed except internally.
173
    // Decodes and caches a frame. Never accessed except internally.
228
    enum ImageFrameCaching { CacheMetadataOnly, CacheMetadataAndFrame };
174
    void cacheFrame(size_t index, SubsamplingLevel, ImageFrameData::Caching = ImageFrameData::Caching::MetadataAndImage);
229
    void cacheFrame(size_t index, SubsamplingLevel, ImageFrameCaching = CacheMetadataAndFrame);
230
175
231
    // Called before accessing m_frames[index] for info without decoding. Returns false on index out of bounds.
176
    // 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);
177
    bool ensureFrameIsCached(size_t index, ImageFrameData::Caching = ImageFrameData::Caching::MetadataAndImage);
233
178
234
    // Called to invalidate cached data. When |destroyAll| is true, we wipe out
179
    // Called to invalidate cached data. When |destroyAll| is true, we wipe out
235
    // the entire frame buffer cache and tell the image source to destroy
180
    // the entire frame buffer cache and tell the image source to destroy
Lines 292-298 private: a/Source/WebCore/platform/graphics/BitmapImage.h_sec7
292
    mutable IntSize m_sizeRespectingOrientation;
237
    mutable IntSize m_sizeRespectingOrientation;
293
238
294
    size_t m_currentFrame { 0 }; // The index of the current frame of animation.
239
    size_t m_currentFrame { 0 }; // The index of the current frame of animation.
295
    Vector<FrameData, 1> m_frames; // An array of the cached frames of the animation. We have to ref frames to pin them in the cache.
240
    Vector<ImageFrameData, 1> m_frames; // An array of the cached frames of the animation. We have to ref frames to pin them in the cache.
296
241
297
    std::unique_ptr<Timer> m_frameTimer;
242
    std::unique_ptr<Timer> m_frameTimer;
298
    int m_repetitionCount { cAnimationNone }; // How many total animation loops we should do. This will be cAnimationNone if this image type is incapable of animation.
243
    int m_repetitionCount { cAnimationNone }; // How many total animation loops we should do. This will be cAnimationNone if this image type is incapable of animation.
- a/Source/WebCore/platform/graphics/BitmapPixels.h +173 lines
Line 0 a/Source/WebCore/platform/graphics/BitmapPixels.h_sec1
1
/*
2
 * Copyright (C) 2016 Apple Inc.  All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#pragma once
27
28
#include "Color.h"
29
#include "IntRect.h"
30
#include "IntSize.h"
31
#include "NativeImagePtr.h"
32
33
#include <wtf/Vector.h>
34
35
namespace WebCore {
36
37
class BitmapPixels {
38
public:
39
    static std::unique_ptr<BitmapPixels> create(const IntSize& size, bool premultiplyAlpha)
40
    {
41
        return std::make_unique<BitmapPixels>(size, premultiplyAlpha);
42
    }
43
44
    static std::unique_ptr<BitmapPixels> create(const BitmapPixels& other)
45
    {
46
        return std::make_unique<BitmapPixels>(other);
47
    }
48
49
    BitmapPixels(const IntSize& size, bool premultiplyAlpha = true)
50
        : m_premultiplyAlpha(premultiplyAlpha)
51
    {
52
        ASSERT(!size.isEmpty());
53
        setSize(size);
54
    }
55
56
    BitmapPixels(const BitmapPixels& other)
57
    {
58
        if (this == &other)
59
            return;
60
        
61
        m_backingStore = other.m_backingStore;
62
        m_pixels = m_backingStore.data();
63
        m_size = other.m_size;
64
        m_premultiplyAlpha = other.m_premultiplyAlpha;
65
    }
66
67
    int width() const { return m_size.width(); }
68
    int height() const { return m_size.height(); }
69
70
    NativeImagePtr image() const;
71
72
    bool setSize(const IntSize& size)
73
    {
74
        if (!m_backingStore.tryReserveCapacity(size.area()))
75
            return false;
76
        
77
        m_backingStore.resize(size.area());
78
        m_pixels = m_backingStore.data();
79
        m_size = size;
80
        clear();
81
        return true;
82
    }
83
84
    RGBA32* at(int x, int y) const
85
    {
86
        return m_pixels + y * m_size.width() + x;
87
    }
88
89
    void clear()
90
    {
91
        memset(m_pixels, 0, m_size.area() * sizeof(RGBA32));
92
    }
93
94
    void clearRect(const IntRect& rect)
95
    {
96
        if (rect.isEmpty() || inBounds(rect))
97
            return;
98
        
99
        size_t rectWidthInBytes = rect.width() * sizeof(RGBA32);
100
        RGBA32* start = at(rect.x(), rect.y());
101
        for (int i = 0; i < rect.height(); ++i) {
102
            memset(start, 0, rectWidthInBytes);
103
            start += m_size.width();
104
        }
105
    }
106
107
    void repeatFirstRow(const IntRect& rect)
108
    {
109
        if (rect.isEmpty() || inBounds(rect))
110
            return;
111
        
112
        size_t rectWidthInBytes = rect.width() * sizeof(RGBA32);
113
        RGBA32* src = at(rect.x(), rect.y());
114
        RGBA32* dest = src + m_size.width();
115
        for (int i = 1; i < rect.height(); ++i) {
116
            memcpy(dest, src, rectWidthInBytes);
117
            dest += m_size.width();
118
        }
119
    }
120
121
    void setRGBA(int x, int y, unsigned r, unsigned g, unsigned b, unsigned a)
122
    {
123
        setRGBA(at(x, y), r, g, b, a);
124
    }
125
126
    void setRGBA(RGBA32* dest, unsigned r, unsigned g, unsigned b, unsigned a)
127
    {
128
        if (!m_premultiplyAlpha || a >= 255)
129
            *dest = makeRGBA(r, g, b, a);
130
        else if (!a)
131
            *dest = 0;
132
        else
133
            *dest = makePremultipliedRGBA(r, g, b, a);
134
    }
135
136
    void overRGBA(RGBA32* dest, unsigned r, unsigned g, unsigned b, unsigned a)
137
    {
138
        if (!a)
139
            return;
140
        
141
        if (a >= 255 || !alphaChannel(*dest)) {
142
            setRGBA(dest, r, g, b, a);
143
            return;
144
        }
145
        
146
        if (!m_premultiplyAlpha)
147
            *dest = makePremultipliedRGBA(redChannel(*dest), greenChannel(*dest), blueChannel(*dest), alphaChannel(*dest));
148
        
149
        RGBA32 src = makeRGBA(r, g, b, a);
150
        *dest = Color(*dest).blend(src).rgb();
151
        
152
        if (!m_premultiplyAlpha)
153
            *dest = makeUnPremultipliedRGBA(redChannel(*dest), greenChannel(*dest), blueChannel(*dest), alphaChannel(*dest));
154
    }
155
156
    bool inBounds(const IntPoint& point) const
157
    {
158
        return IntRect(IntPoint(), m_size).contains(point);
159
    }
160
161
    bool inBounds(const IntRect& rect) const
162
    {
163
        return IntRect(IntPoint(), m_size).contains(rect);
164
    }
165
166
private:
167
    Vector<RGBA32> m_backingStore;
168
    RGBA32* m_pixels { nullptr };
169
    IntSize m_size;
170
    bool m_premultiplyAlpha { true };
171
};
172
173
}
- a/Source/WebCore/platform/graphics/Color.cpp +44 lines
Lines 49-54 const RGBA32 Color::transparent; a/Source/WebCore/platform/graphics/Color.cpp_sec1
49
static const RGBA32 lightenedBlack = 0xFF545454;
49
static const RGBA32 lightenedBlack = 0xFF545454;
50
static const RGBA32 darkenedWhite = 0xFFABABAB;
50
static const RGBA32 darkenedWhite = 0xFFABABAB;
51
51
52
static inline unsigned multiply255(unsigned c)
53
{
54
    // c * 255
55
    //   = c * (256 - 1)
56
    //   = c * 256 - c
57
    return (c << 8) - c;
58
}
59
60
static inline unsigned divide255(unsigned c)
61
{
62
    // c / 255
63
    //   = c / 256 * (1 + 1 / 255)
64
    //   = (c + c / 255) / 256
65
    //   = (c + (c + c / 255) / 256) / 256
66
    //   = (c + c / 256 + c / (255 x 256)) / 256
67
    //  ~= (c + c / 256 + 1) / 256
68
    return (c + (c >> 8) + 1) >> 8;
69
}
70
    
71
static inline unsigned divideCeil(unsigned c, unsigned d)
72
{
73
    return (c + d - 1) / d;
74
}
75
    
76
static inline unsigned premultipliedChannel(unsigned c, unsigned a)
77
{
78
    return divide255(c * a);
79
}
80
81
static inline unsigned unpremultipliedChannel(unsigned c, unsigned a)
82
{
83
    return divideCeil(multiply255(c), a);
84
}
85
    
52
RGBA32 makeRGB(int r, int g, int b)
86
RGBA32 makeRGB(int r, int g, int b)
53
{
87
{
54
    return 0xFF000000 | std::max(0, std::min(r, 255)) << 16 | std::max(0, std::min(g, 255)) << 8 | std::max(0, std::min(b, 255));
88
    return 0xFF000000 | std::max(0, std::min(r, 255)) << 16 | std::max(0, std::min(g, 255)) << 8 | std::max(0, std::min(b, 255));
Lines 59-64 RGBA32 makeRGBA(int r, int g, int b, int a) a/Source/WebCore/platform/graphics/Color.cpp_sec2
59
    return std::max(0, std::min(a, 255)) << 24 | std::max(0, std::min(r, 255)) << 16 | std::max(0, std::min(g, 255)) << 8 | std::max(0, std::min(b, 255));
93
    return std::max(0, std::min(a, 255)) << 24 | std::max(0, std::min(r, 255)) << 16 | std::max(0, std::min(g, 255)) << 8 | std::max(0, std::min(b, 255));
60
}
94
}
61
95
96
RGBA32 makePremultipliedRGBA(int r, int g, int b, int a)
97
{
98
    return makeRGBA(premultipliedChannel(r, a), premultipliedChannel(g, a), premultipliedChannel(b, a), a);
99
}
100
    
101
RGBA32 makeUnPremultipliedRGBA(int r, int g, int b, int a)
102
{
103
    return makeRGBA(unpremultipliedChannel(r, a), unpremultipliedChannel(g, a), unpremultipliedChannel(b, a), a);
104
}
105
    
62
static int colorFloatToRGBAByte(float f)
106
static int colorFloatToRGBAByte(float f)
63
{
107
{
64
    // We use lroundf and 255 instead of nextafterf(256, 0) to match CG's rounding
108
    // We use lroundf and 255 instead of nextafterf(256, 0) to match CG's rounding
- a/Source/WebCore/platform/graphics/Color.h +2 lines
Lines 54-59 typedef unsigned RGBA32; // Deprecated: Type for an RGBA quadruplet. Use RGBA cl a/Source/WebCore/platform/graphics/Color.h_sec1
54
54
55
WEBCORE_EXPORT RGBA32 makeRGB(int r, int g, int b);
55
WEBCORE_EXPORT RGBA32 makeRGB(int r, int g, int b);
56
WEBCORE_EXPORT RGBA32 makeRGBA(int r, int g, int b, int a);
56
WEBCORE_EXPORT RGBA32 makeRGBA(int r, int g, int b, int a);
57
WEBCORE_EXPORT RGBA32 makePremultipliedRGBA(int r, int g, int b, int a);
58
WEBCORE_EXPORT RGBA32 makeUnPremultipliedRGBA(int r, int g, int b, int a);
57
59
58
WEBCORE_EXPORT RGBA32 colorWithOverrideAlpha(RGBA32 color, float overrideAlpha);
60
WEBCORE_EXPORT RGBA32 colorWithOverrideAlpha(RGBA32 color, float overrideAlpha);
59
WEBCORE_EXPORT RGBA32 colorWithOverrideAlpha(RGBA32 color, Optional<float> overrideAlpha);
61
WEBCORE_EXPORT RGBA32 colorWithOverrideAlpha(RGBA32 color, Optional<float> overrideAlpha);
- a/Source/WebCore/platform/graphics/Image.h -6 / +5 lines
Lines 137-144 public: a/Source/WebCore/platform/graphics/Image.h_sec1
137
137
138
    enum TileRule { StretchTile, RoundTile, SpaceTile, RepeatTile };
138
    enum TileRule { StretchTile, RoundTile, SpaceTile, RepeatTile };
139
139
140
    virtual NativeImagePtr nativeImage() { return nullptr; }
141
    virtual NativeImagePtr nativeImageOfSize(const IntSize&) { return nullptr; }
140
    virtual NativeImagePtr nativeImageForCurrentFrame() { return nullptr; }
142
    virtual NativeImagePtr nativeImageForCurrentFrame() { return nullptr; }
141
    virtual ImageOrientation orientationForCurrentFrame() { return ImageOrientation(); }
143
    virtual ImageOrientation orientationForCurrentFrame() { return ImageOrientation(); }
144
    virtual Vector<NativeImagePtr> framesNativeImages() { return { }; }
142
145
143
    // Accessors for native image formats.
146
    // Accessors for native image formats.
144
147
Lines 150-161 public: a/Source/WebCore/platform/graphics/Image.h_sec2
150
    virtual CFDataRef getTIFFRepresentation() { return nullptr; }
153
    virtual CFDataRef getTIFFRepresentation() { return nullptr; }
151
#endif
154
#endif
152
155
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
#endif
158
159
#if PLATFORM(WIN)
156
#if PLATFORM(WIN)
160
    virtual bool getHBITMAP(HBITMAP) { return false; }
157
    virtual bool getHBITMAP(HBITMAP) { return false; }
161
    virtual bool getHBITMAPOfSize(HBITMAP, const IntSize*) { return false; }
158
    virtual bool getHBITMAPOfSize(HBITMAP, const IntSize*) { return false; }
Lines 179-184 public: a/Source/WebCore/platform/graphics/Image.h_sec3
179
#if !ASSERT_DISABLED
176
#if !ASSERT_DISABLED
180
    virtual bool notSolidColor() { return true; }
177
    virtual bool notSolidColor() { return true; }
181
#endif
178
#endif
179
    
180
    virtual void layoutIfNeeded() { }
182
181
183
    virtual void dump(TextStream&) const;
182
    virtual void dump(TextStream&) const;
184
183
- a/Source/WebCore/platform/graphics/ImageFrameData.cpp +137 lines
Line 0 a/Source/WebCore/platform/graphics/ImageFrameData.cpp_sec1
1
/*
2
 * Copyright (C) 2016 Apple Inc.  All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#include "config.h"
27
#include "ImageFrameData.h"
28
29
#include "Color.h"
30
31
#if USE(CG)
32
#include "ImageDecoderCG.h"
33
#else
34
#include "ImageDecoder.h"
35
#endif
36
37
#include "PlatformImage.h"
38
39
namespace WebCore {
40
41
ImageFrameData::ImageFrameData()
42
{
43
}
44
45
ImageFrameData::ImageFrameData(NativeImagePtr&& image)
46
    : m_status(DecodingStatus::Complete)
47
    , m_image(WTFMove(image))
48
{
49
    m_size = PlatformImage(m_image).size();
50
    m_hasAlpha = PlatformImage(m_image).hasAlpha();
51
}
52
53
ImageFrameData::ImageFrameData(ImageDecoder& decoder, size_t index, SubsamplingLevel subsamplingLevel, Caching frameCaching)
54
{
55
    ASSERT(frameCaching == Caching::Metadata || frameCaching == Caching::MetadataAndImage);
56
    
57
    if (frameCaching == Caching::Image || frameCaching == Caching::MetadataAndImage) {
58
        m_image = decoder.createFrameImageAtIndex(index, subsamplingLevel);
59
        m_subsamplingLevel = subsamplingLevel;
60
    }
61
    
62
    if (frameCaching == Caching::Metadata || frameCaching == Caching::MetadataAndImage) {
63
        m_orientation = decoder.orientationAtIndex(index);
64
        m_status = decoder.frameIsCompleteAtIndex(index) ? DecodingStatus::Complete : DecodingStatus::Partial;
65
        
66
        if (decoder.repetitionCount() != cAnimationNone)
67
            m_duration = decoder.frameDurationAtIndex(index);
68
        
69
        m_hasAlpha = decoder.frameHasAlphaAtIndex(index);
70
        m_size = decoder.frameSizeAtIndex(index, subsamplingLevel);
71
    }
72
}
73
74
ImageFrameData::~ImageFrameData()
75
{
76
    clearSubImages();
77
}
78
    
79
ImageFrameData& ImageFrameData::operator=(const ImageFrameData& other)
80
{
81
    if (this == &other)
82
        return *this;
83
84
    m_status = other.m_status;
85
    m_size = other.m_size;
86
    m_image = other.m_image;
87
    
88
    m_pixels = other.pixels() ? BitmapPixels::create(*other.pixels()) : nullptr;
89
    
90
    m_orientation = other.m_orientation;
91
    m_subsamplingLevel = other.m_subsamplingLevel;
92
    m_duration = other.m_duration;
93
    m_hasAlpha = other.m_hasAlpha;
94
    return *this;
95
}
96
97
void ImageFrameData::clearSubImages()
98
{
99
    if (!m_image)
100
        return;
101
    
102
    PlatformImage(m_image).clearSubImages();
103
}
104
105
unsigned ImageFrameData::clear(Caching frameCaching)
106
{
107
    ASSERT(frameCaching == Caching::Empty || frameCaching == Caching::Metadata);
108
    
109
    unsigned frameBytes = this->frameBytes();
110
    
111
    clearSubImages();
112
    
113
    if (frameCaching == Caching::Empty)
114
        *this = ImageFrameData();
115
    else
116
        m_image = nullptr;
117
    
118
    return frameBytes;
119
}
120
121
Color ImageFrameData::singlePixelSolidColor() const
122
{
123
    if (!hasImage() || m_size != IntSize(1, 1))
124
        return Color();
125
    
126
    return PlatformImage(m_image).singlePixelSolidColor();
127
}
128
129
bool ImageFrameData::isAlmostSolidColor() const
130
{
131
    if (!hasImage())
132
        return false;
133
    
134
    return PlatformImage(m_image).isAlmostSolidColor();
135
}
136
    
137
}
- a/Source/WebCore/platform/graphics/ImageFrameData.h +95 lines
Line 0 a/Source/WebCore/platform/graphics/ImageFrameData.h_sec1
1
/*
2
 * Copyright (C) 2016 Apple Inc.  All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#pragma once
27
28
#include "BitmapPixels.h"
29
#include "ImageOrientation.h"
30
#include "IntSize.h"
31
#include "NativeImagePtr.h"
32
33
namespace WebCore {
34
35
class Color;
36
class ImageDecoder;
37
38
// SubsamplingLevel. 0 is no subsampling, 1 is half dimensions on each axis etc.
39
using SubsamplingLevel = uint8_t;
40
41
enum : SubsamplingLevel {
42
    MinSubsamplingLevel = 0,
43
    MaxSubsamplingLevel = 3,
44
    DefaultSubsamplingLevel = MinSubsamplingLevel
45
};
46
47
class ImageFrameData {
48
public:
49
    enum class Caching { Empty, Metadata, Image, MetadataAndImage };
50
    enum class DecodingStatus { Empty, Partial, Complete };
51
    
52
    ImageFrameData();
53
    ImageFrameData(NativeImagePtr&&);
54
    ImageFrameData(ImageDecoder&, size_t index, SubsamplingLevel = DefaultSubsamplingLevel, Caching = Caching::MetadataAndImage);
55
    ImageFrameData(const ImageFrameData& other) { operator=(other); }
56
57
    ~ImageFrameData();
58
59
    ImageFrameData& operator=(const ImageFrameData& other);
60
    
61
    unsigned clear(Caching);
62
    Color singlePixelSolidColor() const;
63
    bool isAlmostSolidColor() const;
64
    
65
    DecodingStatus status() const { return m_status; }
66
    bool isComplete() const { return m_status == DecodingStatus::Complete; }
67
    IntSize size() const { return m_size; }
68
    unsigned frameBytes() const { return hasImage() ? m_size.area() * 4 : 0; }
69
    NativeImagePtr image() const { return m_image; }
70
    BitmapPixels* pixels() const { return m_pixels ? m_pixels.get() : nullptr; }
71
    
72
    ImageOrientation orientation() const { return m_orientation; }
73
    SubsamplingLevel subsamplingLevel() const { return m_subsamplingLevel; }
74
    float duration() const { return m_duration; }
75
    
76
    bool hasAlpha() const { return m_hasAlpha; }
77
    bool hasImage() const { return m_image; }
78
    bool hasMetadata() const { return !m_size.isEmpty(); }
79
    bool hasPixels() const { return pixels(); }
80
    
81
private:
82
    void clearSubImages();
83
    
84
    DecodingStatus m_status { DecodingStatus::Empty };
85
    IntSize m_size;
86
    NativeImagePtr m_image;
87
    std::unique_ptr<BitmapPixels> m_pixels;
88
    
89
    ImageOrientation m_orientation { DefaultImageOrientation };
90
    SubsamplingLevel m_subsamplingLevel { 0 };
91
    float m_duration { 0 };
92
    bool m_hasAlpha { true };
93
};
94
    
95
}
- a/Source/WebCore/platform/graphics/ImageSource.cpp +5 lines
Lines 224-229 NativeImagePtr ImageSource::createFrameImageAtIndex(size_t index, SubsamplingLev a/Source/WebCore/platform/graphics/ImageSource.cpp_sec1
224
    return initialized() ? m_decoder->createFrameImageAtIndex(index, subsamplingLevel) : nullptr;
224
    return initialized() ? m_decoder->createFrameImageAtIndex(index, subsamplingLevel) : nullptr;
225
}
225
}
226
226
227
ImageFrameData ImageSource::createFrameDataAtIndex(size_t index, SubsamplingLevel subsamplingLevel, ImageFrameData::Caching caching)
228
{
229
    return initialized() ? ImageFrameData(*m_decoder, index, subsamplingLevel, caching) : ImageFrameData();
230
}
231
    
227
void ImageSource::dump(TextStream& ts) const
232
void ImageSource::dump(TextStream& ts) const
228
{
233
{
229
    if (m_allowSubsampling)
234
    if (m_allowSubsampling)
- a/Source/WebCore/platform/graphics/ImageSource.h -6 / +5 lines
Lines 27-32 a/Source/WebCore/platform/graphics/ImageSource.h_sec1
27
#ifndef ImageSource_h
27
#ifndef ImageSource_h
28
#define ImageSource_h
28
#define ImageSource_h
29
29
30
#include "ImageFrameData.h"
30
#include "ImageOrientation.h"
31
#include "ImageOrientation.h"
31
#include "IntPoint.h"
32
#include "IntPoint.h"
32
#include "NativeImagePtr.h"
33
#include "NativeImagePtr.h"
Lines 63-71 const int cAnimationLoopOnce = 0; a/Source/WebCore/platform/graphics/ImageSource.h_sec2
63
const int cAnimationLoopInfinite = -1;
64
const int cAnimationLoopInfinite = -1;
64
const int cAnimationNone = -2;
65
const int cAnimationNone = -2;
65
66
66
// SubsamplingLevel. 0 is no subsampling, 1 is half dimensions on each axis etc.
67
typedef short SubsamplingLevel;
68
69
class ImageSource {
67
class ImageSource {
70
    WTF_MAKE_NONCOPYABLE(ImageSource);
68
    WTF_MAKE_NONCOPYABLE(ImageSource);
71
    friend class BitmapImage;
69
    friend class BitmapImage;
Lines 132-149 public: a/Source/WebCore/platform/graphics/ImageSource.h_sec3
132
    bool allowSubsamplingOfFrameAtIndex(size_t) const;
130
    bool allowSubsamplingOfFrameAtIndex(size_t) const;
133
    
131
    
134
    // Size of optionally subsampled frame.
132
    // Size of optionally subsampled frame.
135
    IntSize frameSizeAtIndex(size_t, SubsamplingLevel = 0, RespectImageOrientationEnum = DoNotRespectImageOrientation) const;
133
    IntSize frameSizeAtIndex(size_t, SubsamplingLevel = DefaultSubsamplingLevel, RespectImageOrientationEnum = DoNotRespectImageOrientation) const;
136
    
134
    
137
    // Return the number of bytes in the decoded frame. If the frame is not yet
135
    // Return the number of bytes in the decoded frame. If the frame is not yet
138
    // decoded then return 0.
136
    // decoded then return 0.
139
    unsigned frameBytesAtIndex(size_t, SubsamplingLevel = 0) const;
137
    unsigned frameBytesAtIndex(size_t, SubsamplingLevel = DefaultSubsamplingLevel) const;
140
    
138
    
141
    float frameDurationAtIndex(size_t);
139
    float frameDurationAtIndex(size_t);
142
    ImageOrientation orientationAtIndex(size_t) const; // EXIF image orientation
140
    ImageOrientation orientationAtIndex(size_t) const; // EXIF image orientation
143
    
141
    
144
    // Callers should not call this after calling clear() with a higher index;
142
    // Callers should not call this after calling clear() with a higher index;
145
    // see comments on clear() above.
143
    // see comments on clear() above.
146
    NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = 0);
144
    NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = DefaultSubsamplingLevel);
145
    ImageFrameData createFrameDataAtIndex(size_t, SubsamplingLevel = DefaultSubsamplingLevel, ImageFrameData::Caching = ImageFrameData::Caching::MetadataAndImage);
147
    
146
    
148
private:
147
private:
149
    void clearFrameBufferCache(size_t);
148
    void clearFrameBufferCache(size_t);
- a/Source/WebCore/platform/graphics/PlatformImage.h +64 lines
Line 0 a/Source/WebCore/platform/graphics/PlatformImage.h_sec1
1
/*
2
 * Copyright (C) 2016 Apple Inc.  All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#pragma once
27
28
#include "GraphicsTypes.h"
29
#include "ImageOrientation.h"
30
#include "NativeImagePtr.h"
31
32
namespace WebCore {
33
34
class Color;
35
class FloatRect;
36
class IntSize;
37
class GraphicsContext;
38
39
class PlatformImage {
40
public:
41
    PlatformImage(const NativeImagePtr& image)
42
        : m_image(image)
43
    {
44
    }
45
46
    bool isNil() const { return !m_image; }
47
    void clearSubImages();
48
49
    IntSize size() const;
50
    bool hasAlpha() const;
51
    Color singlePixelSolidColor() const;
52
    bool isAlmostSolidColor() const;
53
    void draw(GraphicsContext&, const FloatRect& destRect, const FloatRect& srcRect, const IntSize& srcSize, CompositeOperator, BlendMode, const ImageOrientation&) const;
54
55
    static float subsamplingScale(GraphicsContext&, const FloatRect& destRect, const FloatRect& srcRect);
56
57
private:
58
#if USE(CG)
59
    CGImageRef cgImageRef() const { return m_image ? m_image.get() : nullptr; }
60
#endif
61
    NativeImagePtr m_image;
62
};
63
64
}
- a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm -1 / +1 lines
Lines 212-218 void MediaPlayerPrivateMediaStreamAVFObjC::updateDisplayMode() a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm_sec1
212
                    continue;
212
                    continue;
213
                }
213
                }
214
214
215
                m_pausedImage = image->getCGImageRef();
215
                m_pausedImage = image->nativeImageForCurrentFrame();
216
                if (!m_pausedImage) {
216
                if (!m_pausedImage) {
217
                    m_displayMode = PaintItBlack;
217
                    m_displayMode = PaintItBlack;
218
                    continue;
218
                    continue;
- a/Source/WebCore/platform/graphics/cairo/BitmapImageCairo.cpp -142 lines
Lines 1-142 a/Source/WebCore/platform/graphics/cairo/BitmapImageCairo.cpp_sec1
1
/*
2
 * Copyright (C) 2004, 2005, 2006 Apple Inc.  All rights reserved.
3
 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
4
 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
5
 *
6
 * Redistribution and use in source and binary forms, with or without
7
 * modification, are permitted provided that the following conditions
8
 * are met:
9
 * 1. Redistributions of source code must retain the above copyright
10
 *    notice, this list of conditions and the following disclaimer.
11
 * 2. Redistributions in binary form must reproduce the above copyright
12
 *    notice, this list of conditions and the following disclaimer in the
13
 *    documentation and/or other materials provided with the distribution.
14
 *
15
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
16
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
19
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
26
 */
27
28
#include "config.h"
29
#include "BitmapImage.h"
30
31
#if USE(CAIRO)
32
33
#include "CairoUtilities.h"
34
#include "ImageObserver.h"
35
#include "PlatformContextCairo.h"
36
#include "Timer.h"
37
#include <cairo.h>
38
39
namespace WebCore {
40
41
namespace NativeImage {
42
43
IntSize size(const RefPtr<cairo_surface_t>& image)
44
{
45
    return cairoSurfaceSize(image.get());
46
}
47
48
bool hasAlpha(const RefPtr<cairo_surface_t>& image)
49
{
50
    return cairo_surface_get_content(image.get()) != CAIRO_CONTENT_COLOR;
51
}
52
53
Color singlePixelSolidColor(const RefPtr<cairo_surface_t>& image)
54
{
55
    ASSERT(image);
56
    
57
    if (NativeImage::size(image) != IntSize(1, 1))
58
        return Color();
59
60
    if (cairo_surface_get_type(image.get()) != CAIRO_SURFACE_TYPE_IMAGE)
61
        return Color();
62
63
    RGBA32* pixel = reinterpret_cast_ptr<RGBA32*>(cairo_image_surface_get_data(image.get()));
64
    return colorFromPremultipliedARGB(*pixel);
65
}
66
67
}
68
69
void BitmapImage::draw(GraphicsContext& context, const FloatRect& dst, const FloatRect& src, CompositeOperator op,
70
    BlendMode blendMode, ImageOrientationDescription description)
71
{
72
    if (!dst.width() || !dst.height() || !src.width() || !src.height())
73
        return;
74
75
    startAnimation();
76
77
    auto surface = frameImageAtIndex(m_currentFrame);
78
    if (!surface) // If it's too early we won't have an image yet.
79
        return;
80
81
    Color color = singlePixelSolidColor();
82
    if (color.isValid()) {
83
        fillWithSolidColor(context, dst, color, op);
84
        return;
85
    }
86
87
    context.save();
88
89
    // Set the compositing operation.
90
    if (op == CompositeSourceOver && blendMode == BlendModeNormal && !frameHasAlphaAtIndex(m_currentFrame))
91
        context.setCompositeOperation(CompositeCopy);
92
    else
93
        context.setCompositeOperation(op, blendMode);
94
95
#if ENABLE(IMAGE_DECODER_DOWN_SAMPLING)
96
    IntSize scaledSize = cairoSurfaceSize(surface.get());
97
    FloatRect adjustedSrcRect = adjustSourceRectForDownSampling(src, scaledSize);
98
#else
99
    FloatRect adjustedSrcRect(src);
100
#endif
101
102
    ImageOrientation frameOrientation(description.imageOrientation());
103
    if (description.respectImageOrientation() == RespectImageOrientation)
104
        frameOrientation = frameOrientationAtIndex(m_currentFrame);
105
106
    FloatRect dstRect = dst;
107
108
    if (frameOrientation != DefaultImageOrientation) {
109
        // ImageOrientation expects the origin to be at (0, 0).
110
        context.translate(dstRect.x(), dstRect.y());
111
        dstRect.setLocation(FloatPoint());
112
        context.concatCTM(frameOrientation.transformFromDefault(dstRect.size()));
113
        if (frameOrientation.usesWidthAsHeight()) {
114
            // The destination rectangle will have it's width and height already reversed for the orientation of
115
            // the image, as it was needed for page layout, so we need to reverse it back here.
116
            dstRect = FloatRect(dstRect.x(), dstRect.y(), dstRect.height(), dstRect.width());
117
        }
118
    }
119
120
    context.platformContext()->drawSurfaceToContext(surface.get(), dstRect, adjustedSrcRect, context);
121
122
    context.restore();
123
124
    if (imageObserver())
125
        imageObserver()->didDraw(this);
126
}
127
128
bool FrameData::clear(bool clearMetadata)
129
{
130
    if (clearMetadata)
131
        m_haveMetadata = false;
132
133
    if (m_image) {
134
        m_image = nullptr;
135
        return true;
136
    }
137
    return false;
138
}
139
140
} // namespace WebCore
141
142
#endif // USE(CAIRO)
- a/Source/WebCore/platform/graphics/cairo/PlatformImageCairo.cpp +111 lines
Line 0 a/Source/WebCore/platform/graphics/cairo/PlatformImageCairo.cpp_sec1
1
/*
2
 * Copyright (C) 2016 Apple Inc.  All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#include "config.h"
27
#include "PlatformImage.h"
28
29
#if USE(CAIRO)
30
31
#include "CairoUtilities.h"
32
#include "PlatformContextCairo.h"
33
#include <cairo.h>
34
35
namespace WebCore {
36
37
void PlatformImage::clearSubImages()
38
{
39
}
40
41
IntSize PlatformImage::size() const
42
{
43
    return isNil() ? IntSize() : cairoSurfaceSize(m_image.get());
44
}
45
46
bool PlatformImage::hasAlpha() const
47
{
48
    return isNil() || cairo_surface_get_content(m_image.get()) != CAIRO_CONTENT_COLOR;
49
}
50
51
Color PlatformImage::singlePixelSolidColor() const
52
{
53
    if (isNil() || size() != IntSize(1, 1))
54
        return Color();
55
56
    if (cairo_surface_get_type(m_image.get()) != CAIRO_SURFACE_TYPE_IMAGE)
57
        return Color();
58
59
    RGBA32* pixel = reinterpret_cast_ptr<RGBA32*>(cairo_image_surface_get_data(m_image.get()));
60
    return colorFromPremultipliedARGB(*pixel);
61
}
62
63
bool PlatformImage::isAlmostSolidColor() const
64
{
65
    return false;
66
}
67
68
float PlatformImage::subsamplingScale(GraphicsContext&, const FloatRect&, const FloatRect&)
69
{
70
    return 1;
71
}
72
73
void PlatformImage::draw(GraphicsContext& context, const FloatRect& destRect, const FloatRect& srcRect, const IntSize&, CompositeOperator op, BlendMode mode, const ImageOrientation& orientation) const
74
{
75
    context.save();
76
    
77
    // Set the compositing operation.
78
    if (op == CompositeSourceOver && mode == BlendModeNormal && !hasAlpha())
79
        context.setCompositeOperation(CompositeCopy);
80
    else
81
        context.setCompositeOperation(op, mode);
82
        
83
#if ENABLE(IMAGE_DECODER_DOWN_SAMPLING)
84
    IntSize scaledSize = cairoSurfaceSize(m_image.get());
85
    FloatRect adjustedSrcRect = adjustSourceRectForDownSampling(srcRect, scaledSize);
86
#else
87
    FloatRect adjustedSrcRect(srcRect);
88
#endif
89
        
90
    FloatRect adjustedDestRect = destRect;
91
        
92
    if (orientation != DefaultImageOrientation) {
93
        // ImageOrientation expects the origin to be at (0, 0).
94
        context.translate(destRect.x(), destRect.y());
95
        adjustedDestRect.setLocation(FloatPoint());
96
        context.concatCTM(orientation.transformFromDefault(adjustedDestRect.size()));
97
        if (orientation.usesWidthAsHeight()) {
98
            // The destination rectangle will have it's width and height already reversed for the orientation of
99
            // the image, as it was needed for page layout, so we need to reverse it back here.
100
            adjustedDestRect.setSize(adjustedDestRect.size().transposedSize());
101
        }
102
    }
103
104
    context.platformContext()->drawSurfaceToContext(m_image.get(), adjustedDestRect, adjustedSrcRect, context);
105
106
    context.restore();
107
}
108
109
} // namespace WebCore
110
111
#endif // USE(CAIRO)
- a/Source/WebCore/platform/graphics/cg/BitmapImageCG.cpp -206 lines
Lines 1-206 a/Source/WebCore/platform/graphics/cg/BitmapImageCG.cpp_sec1
1
/*
2
 * Copyright (C) 2004, 2005, 2006 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
24
 */
25
26
#include "config.h"
27
#include "BitmapImage.h"
28
29
#if USE(CG)
30
31
#include "CoreGraphicsSPI.h"
32
#include "FloatConversion.h"
33
#include "GeometryUtilities.h"
34
#include "GraphicsContextCG.h"
35
#include "ImageObserver.h"
36
#include "SubimageCacheWithTimer.h"
37
#include <wtf/RetainPtr.h>
38
39
#if USE(APPKIT)
40
#include <ApplicationServices/ApplicationServices.h>
41
#endif
42
43
#if PLATFORM(COCOA)
44
#include "WebCoreSystemInterface.h"
45
#endif
46
47
#if PLATFORM(WIN)
48
#include <WebKitSystemInterface/WebKitSystemInterface.h>
49
#endif
50
51
namespace WebCore {
52
53
namespace NativeImage {
54
55
IntSize size(const RetainPtr<CGImageRef>& image)
56
{
57
    ASSERT(image);
58
    return IntSize(CGImageGetWidth(image.get()), CGImageGetHeight(image.get()));
59
}
60
61
bool hasAlpha(const RetainPtr<CGImageRef>&)
62
{
63
    // FIXME: Answer correctly the question: does the CGImageRef have alpha channnel?
64
    return true;
65
}
66
    
67
Color singlePixelSolidColor(const RetainPtr<CGImageRef>& image)
68
{
69
    ASSERT(image);
70
    
71
    if (NativeImage::size(image) != IntSize(1, 1))
72
        return Color();
73
    
74
    unsigned char pixel[4]; // RGBA
75
    auto bitmapContext = adoptCF(CGBitmapContextCreate(pixel, 1, 1, 8, sizeof(pixel), sRGBColorSpaceRef(),
76
        kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big));
77
78
    if (!bitmapContext)
79
        return Color();
80
    
81
    CGContextSetBlendMode(bitmapContext.get(), kCGBlendModeCopy);
82
    CGContextDrawImage(bitmapContext.get(), CGRectMake(0, 0, 1, 1), image.get());
83
    
84
    if (!pixel[3])
85
        return Color(0, 0, 0, 0);
86
87
    return Color(pixel[0] * 255 / pixel[3], pixel[1] * 255 / pixel[3], pixel[2] * 255 / pixel[3], pixel[3]);
88
}
89
90
}
91
92
bool FrameData::clear(bool clearMetadata)
93
{
94
    if (clearMetadata)
95
        m_haveMetadata = false;
96
97
    m_subsamplingLevel = 0;
98
99
    if (m_image) {
100
#if CACHE_SUBIMAGES
101
        subimageCache().clearImage(m_image.get());
102
#endif
103
        m_image = nullptr;
104
        return true;
105
    }
106
    return false;
107
}
108
109
CGImageRef BitmapImage::getCGImageRef()
110
{
111
    return frameImageAtIndex(0).get();
112
}
113
114
CGImageRef BitmapImage::getFirstCGImageRefOfSize(const IntSize& size)
115
{
116
    size_t count = frameCount();
117
    for (size_t i = 0; i < count; ++i) {
118
        CGImageRef cgImage = frameImageAtIndex(i).get();
119
        if (cgImage && IntSize(CGImageGetWidth(cgImage), CGImageGetHeight(cgImage)) == size)
120
            return cgImage;
121
    }
122
123
    // Fallback to the default CGImageRef if we can't find the right size
124
    return getCGImageRef();
125
}
126
127
RetainPtr<CFArrayRef> BitmapImage::getCGImageArray()
128
{
129
    size_t count = frameCount();
130
    if (!count)
131
        return nullptr;
132
    
133
    CFMutableArrayRef array = CFArrayCreateMutable(NULL, count, &kCFTypeArrayCallBacks);
134
    for (size_t i = 0; i < count; ++i) {
135
        if (CGImageRef currFrame = frameImageAtIndex(i).get())
136
            CFArrayAppendValue(array, currFrame);
137
    }
138
    return adoptCF(array);
139
}
140
141
void BitmapImage::draw(GraphicsContext& ctxt, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator compositeOp, BlendMode blendMode, ImageOrientationDescription description)
142
{
143
#if PLATFORM(IOS)
144
    startAnimation(DoNotCatchUp);
145
#else
146
    startAnimation();
147
#endif
148
149
    RetainPtr<CGImageRef> image;
150
    // Never use subsampled images for drawing into PDF contexts.
151
    if (wkCGContextIsPDFContext(ctxt.platformContext()))
152
        image = copyUnscaledFrameImageAtIndex(m_currentFrame);
153
    else {
154
        CGRect transformedDestinationRect = CGRectApplyAffineTransform(destRect, CGContextGetCTM(ctxt.platformContext()));
155
        float subsamplingScale = std::min<float>(1, std::max(transformedDestinationRect.size.width / srcRect.width(), transformedDestinationRect.size.height / srcRect.height()));
156
157
        image = frameImageAtIndex(m_currentFrame, subsamplingScale);
158
    }
159
160
    if (!image) // If it's too early we won't have an image yet.
161
        return;
162
    
163
    Color color = singlePixelSolidColor();
164
    if (color.isValid()) {
165
        fillWithSolidColor(ctxt, destRect, color, compositeOp);
166
        return;
167
    }
168
169
    // Subsampling may have given us an image that is smaller than size().
170
    IntSize imageSize(CGImageGetWidth(image.get()), CGImageGetHeight(image.get()));
171
    
172
    // srcRect is in the coordinates of the unsubsampled image, so we have to map it to the subsampled image.
173
    FloatRect scaledSrcRect = srcRect;
174
    if (imageSize != m_size) {
175
        FloatRect originalImageBounds(FloatPoint(), m_size);
176
        FloatRect subsampledImageBounds(FloatPoint(), imageSize);
177
        scaledSrcRect = mapRect(srcRect, originalImageBounds, subsampledImageBounds);
178
    }
179
    
180
    ImageOrientation orientation;
181
    if (description.respectImageOrientation() == RespectImageOrientation)
182
        orientation = frameOrientationAtIndex(m_currentFrame);
183
184
    ctxt.drawNativeImage(image, imageSize, destRect, scaledSrcRect, compositeOp, blendMode, orientation);
185
186
    if (imageObserver())
187
        imageObserver()->didDraw(this);
188
}
189
190
RetainPtr<CGImageRef> BitmapImage::copyUnscaledFrameImageAtIndex(size_t index)
191
{
192
    if (index >= frameCount())
193
        return nullptr;
194
195
    if (index >= m_frames.size() || !m_frames[index].m_image)
196
        cacheFrame(index, 0);
197
198
    if (!m_frames[index].m_subsamplingLevel)
199
        return m_frames[index].m_image;
200
201
    return m_source.createFrameImageAtIndex(index);
202
}
203
204
}
205
206
#endif // USE(CG)
- a/Source/WebCore/platform/graphics/cg/PatternCG.cpp -2 / +2 lines
Lines 72-78 CGPatternRef Pattern::createPlatformPattern(const AffineTransform& userSpaceTran a/Source/WebCore/platform/graphics/cg/PatternCG.cpp_sec1
72
    // If we're repeating in both directions, we can use image-backed patterns
72
    // If we're repeating in both directions, we can use image-backed patterns
73
    // instead of custom patterns, and avoid tiling-edge pixel cracks.
73
    // instead of custom patterns, and avoid tiling-edge pixel cracks.
74
    if (m_repeatX && m_repeatY)
74
    if (m_repeatX && m_repeatY)
75
        return wkCGPatternCreateWithImageAndTransform(tileImage()->getCGImageRef(), patternTransform, wkPatternTilingConstantSpacing);
75
        return wkCGPatternCreateWithImageAndTransform(tileImage()->nativeImage().get(), patternTransform, wkPatternTilingConstantSpacing);
76
76
77
    // If FLT_MAX should also be used for xStep or yStep, nothing is rendered. Using fractions of FLT_MAX also
77
    // If FLT_MAX should also be used for xStep or yStep, nothing is rendered. Using fractions of FLT_MAX also
78
    // result in nothing being rendered.
78
    // result in nothing being rendered.
Lines 83-89 CGPatternRef Pattern::createPlatformPattern(const AffineTransform& userSpaceTran a/Source/WebCore/platform/graphics/cg/PatternCG.cpp_sec2
83
    CGFloat yStep = m_repeatY ? tileRect.height() : (1 << 22);
83
    CGFloat yStep = m_repeatY ? tileRect.height() : (1 << 22);
84
84
85
    // The pattern will release the CGImageRef when it's done rendering in patternReleaseCallback
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
    const CGPatternCallbacks patternCallbacks = { 0, patternCallback, patternReleaseCallback };
88
    const CGPatternCallbacks patternCallbacks = { 0, patternCallback, patternReleaseCallback };
89
    return CGPatternCreate(platformImage, tileRect, patternTransform, xStep, yStep, kCGPatternTilingConstantSpacing, TRUE, &patternCallbacks);
89
    return CGPatternCreate(platformImage, tileRect, patternTransform, xStep, yStep, kCGPatternTilingConstantSpacing, TRUE, &patternCallbacks);
- a/Source/WebCore/platform/graphics/cg/PlatformImageCG.cpp +171 lines
Line 0 a/Source/WebCore/platform/graphics/cg/PlatformImageCG.cpp_sec1
1
/*
2
 * Copyright (C) 2016 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#include "config.h"
27
#include "PlatformImage.h"
28
29
#if USE(CG)
30
31
#include "Color.h"
32
#include "CoreGraphicsSPI.h"
33
#include "FloatRect.h"
34
#include "GeometryUtilities.h"
35
#include "GraphicsContextCG.h"
36
#include "IntSize.h"
37
#include "SubimageCacheWithTimer.h"
38
39
#if PLATFORM(WIN)
40
#include <WebKitSystemInterface/WebKitSystemInterface.h>
41
#endif
42
43
namespace WebCore {
44
    
45
void PlatformImage::clearSubImages()
46
{
47
#if CACHE_SUBIMAGES
48
    if (!isNil())
49
        subimageCache().clearImage(cgImageRef());
50
#endif
51
}
52
53
IntSize PlatformImage::size() const
54
{
55
    return isNil() ? IntSize() : IntSize(CGImageGetWidth(cgImageRef()), CGImageGetHeight(cgImageRef()));
56
}
57
58
bool PlatformImage::hasAlpha() const
59
{
60
    // FIXME: Answer correctly the question: does the CGImageRef have alpha channnel?
61
    return true;
62
}
63
64
Color PlatformImage::singlePixelSolidColor() const
65
{
66
    if (isNil() || size() != IntSize(1, 1))
67
        return Color();
68
    
69
    unsigned char pixel[4]; // RGBA
70
    auto bitmapContext = adoptCF(CGBitmapContextCreate(pixel, 1, 1, 8, sizeof(pixel), sRGBColorSpaceRef(),
71
        kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big));
72
    
73
    if (!bitmapContext)
74
        return Color();
75
    
76
    CGContextSetBlendMode(bitmapContext.get(), kCGBlendModeCopy);
77
    CGContextDrawImage(bitmapContext.get(), CGRectMake(0, 0, 1, 1), cgImageRef());
78
    
79
    if (!pixel[3])
80
        return Color(0, 0, 0, 0);
81
    
82
    return Color(pixel[0] * 255 / pixel[3], pixel[1] * 255 / pixel[3], pixel[2] * 255 / pixel[3], pixel[3]);
83
}
84
    
85
bool PlatformImage::isAlmostSolidColor() const
86
{
87
    CGImageRef image = cgImageRef();
88
    ASSERT(CGImageGetBitsPerComponent(image) == 8);
89
    
90
    CGBitmapInfo imageInfo = CGImageGetBitmapInfo(image);
91
    if (!(imageInfo & kCGBitmapByteOrder32Little) || (imageInfo & kCGBitmapAlphaInfoMask) != kCGImageAlphaPremultipliedFirst) {
92
        // FIXME: Consider being able to handle other pixel formats.
93
        ASSERT_NOT_REACHED();
94
        return false;
95
    }
96
    
97
    size_t width = CGImageGetWidth(image);
98
    size_t height = CGImageGetHeight(image);
99
    size_t bytesPerRow = CGImageGetBytesPerRow(image);
100
    
101
    RetainPtr<CFDataRef> provider = adoptCF(CGDataProviderCopyData(CGImageGetDataProvider(image)));
102
    const UInt8* data = CFDataGetBytePtr(provider.get());
103
    
104
    // Overlay a grid of sampling dots on top of a grayscale version of the image.
105
    // For the interior points, calculate the difference in luminance among the sample point
106
    // and its surrounds points, scaled by transparency.
107
    const unsigned sampleRows = 7;
108
    const unsigned sampleCols = 7;
109
    // FIXME: Refine the proper number of samples, and accommodate different aspect ratios.
110
    if (width < sampleCols || height < sampleRows)
111
        return false;
112
    
113
    // Ensure that the last row/column land on the image perimeter.
114
    const float strideWidth = static_cast<float>(width - 1) / (sampleCols - 1);
115
    const float strideHeight = static_cast<float>(height - 1) / (sampleRows - 1);
116
    float samples[sampleRows][sampleCols];
117
    
118
    // Find the luminance of the sample points.
119
    float y = 0;
120
    const UInt8* row = data;
121
    for (unsigned i = 0; i < sampleRows; ++i) {
122
        float x = 0;
123
        for (unsigned j = 0; j < sampleCols; ++j) {
124
            const UInt8* p0 = row + (static_cast<int>(x + .5)) * 4;
125
            // R G B A
126
            samples[i][j] = (0.2125 * *p0 + 0.7154 * *(p0+1) + 0.0721 * *(p0+2)) * *(p0+3) / 255;
127
            x += strideWidth;
128
        }
129
        y += strideHeight;
130
        row = data + (static_cast<int>(y + .5)) * bytesPerRow;
131
    }
132
    
133
    // Determine the image score.
134
    float accumScore = 0;
135
    for (unsigned i = 1; i < sampleRows - 1; ++i) {
136
        for (unsigned j = 1; j < sampleCols - 1; ++j) {
137
            float diff = samples[i - 1][j] + samples[i + 1][j] + samples[i][j - 1] + samples[i][j + 1] - 4 * samples[i][j];
138
            accumScore += diff * diff;
139
        }
140
    }
141
    
142
    // The score for a given sample can be within the range of 0 and 255^2.
143
    return accumScore < 2500 * (sampleRows - 2) * (sampleCols - 2);
144
}
145
146
float PlatformImage::subsamplingScale(GraphicsContext& context, const FloatRect& destRect, const FloatRect& srcRect)
147
{
148
    // Never use subsampled images for drawing into PDF contexts.
149
    if (wkCGContextIsPDFContext(context.platformContext()))
150
        return 1;
151
    
152
    CGRect transformedDestinationRect = CGRectApplyAffineTransform(destRect, CGContextGetCTM(context.platformContext()));
153
    return std::min<float>(1, std::max(transformedDestinationRect.size.width / srcRect.width(), transformedDestinationRect.size.height / srcRect.height()));
154
}
155
156
void PlatformImage::draw(GraphicsContext& context, const FloatRect& destRect, const FloatRect& srcRect, const IntSize& srcSize, CompositeOperator op, BlendMode mode, const ImageOrientation& orientation) const
157
{
158
    // Subsampling may have given us an image that is smaller than size().
159
    IntSize subsampledImageSize = size();
160
    
161
    // srcRect is in the coordinates of the unsubsampled image, so we have to map it to the subsampled image.
162
    FloatRect adjustedSrcRect = srcRect;
163
    if (subsampledImageSize != srcSize)
164
        adjustedSrcRect = mapRect(srcRect, FloatRect({ }, srcSize), FloatRect({ }, subsampledImageSize));
165
    
166
    context.drawNativeImage(m_image, subsampledImageSize, destRect, adjustedSrcRect, op, mode, orientation);
167
}
168
    
169
}
170
171
#endif // USE(CG)
- a/Source/WebCore/platform/graphics/cocoa/TextTrackRepresentationCocoa.mm -1 / +1 lines
Lines 129-135 TextTrackRepresentationCocoa::~TextTrackRepresentationCocoa() a/Source/WebCore/platform/graphics/cocoa/TextTrackRepresentationCocoa.mm_sec1
129
void TextTrackRepresentationCocoa::update()
129
void TextTrackRepresentationCocoa::update()
130
{
130
{
131
    if (auto representation = m_client.createTextTrackRepresentationImage())
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
135
void TextTrackRepresentationCocoa::setContentScale(float scale)
135
void TextTrackRepresentationCocoa::setContentScale(float scale)
- a/Source/WebCore/platform/graphics/mac/ImageMac.mm -17 / +8 lines
Lines 85-115 CFDataRef BitmapImage::getTIFFRepresentation() a/Source/WebCore/platform/graphics/mac/ImageMac.mm_sec1
85
    if (m_tiffRep)
85
    if (m_tiffRep)
86
        return m_tiffRep.get();
86
        return m_tiffRep.get();
87
87
88
    unsigned numFrames = frameCount();
88
    auto nativeImages = this->framesNativeImages();
89
89
90
    // If numFrames is zero, we know for certain this image doesn't have valid data
90
    // If framesImages.size() is zero, we know for certain this image doesn't have valid data
91
    // Even though the call to CGImageDestinationCreateWithData will fail and we'll handle it gracefully,
91
    // Even though the call to CGImageDestinationCreateWithData will fail and we'll handle it gracefully,
92
    // in certain circumstances that call will spam the console with an error message
92
    // in certain circumstances that call will spam the console with an error message
93
    if (!numFrames)
93
    if (!nativeImages.size())
94
        return 0;
94
        return nullptr;
95
96
    Vector<CGImageRef> images;
97
    for (unsigned i = 0; i < numFrames; ++i ) {
98
        CGImageRef cgImage = frameImageAtIndex(i).get();
99
        if (cgImage)
100
            images.append(cgImage);
101
    }
102
103
    unsigned numValidFrames = images.size();
104
95
105
    RetainPtr<CFMutableDataRef> data = adoptCF(CFDataCreateMutable(0, 0));
96
    RetainPtr<CFMutableDataRef> data = adoptCF(CFDataCreateMutable(0, 0));
106
    RetainPtr<CGImageDestinationRef> destination = adoptCF(CGImageDestinationCreateWithData(data.get(), kUTTypeTIFF, numValidFrames, 0));
97
    RetainPtr<CGImageDestinationRef> destination = adoptCF(CGImageDestinationCreateWithData(data.get(), kUTTypeTIFF, nativeImages.size(), 0));
107
98
108
    if (!destination)
99
    if (!destination)
109
        return 0;
100
        return nullptr;
110
101
111
    for (unsigned i = 0; i < numValidFrames; ++i)
102
    for (auto nativeImage : nativeImages)
112
        CGImageDestinationAddImage(destination.get(), images[i], 0);
103
        CGImageDestinationAddImage(destination.get(), nativeImage.get(), 0);
113
104
114
    CGImageDestinationFinalize(destination.get());
105
    CGImageDestinationFinalize(destination.get());
115
106
- a/Source/WebCore/platform/image-decoders/ImageDecoder.cpp -25 / +15 lines
Lines 142-147 ImageFrame& ImageFrame::operator=(const ImageFrame& other) a/Source/WebCore/platform/image-decoders/ImageDecoder.cpp_sec1
142
        return *this;
142
        return *this;
143
143
144
    copyBitmapData(other);
144
    copyBitmapData(other);
145
    setHasAlpha(other.m_hasAlpha);
145
    setOriginalFrameRect(other.originalFrameRect());
146
    setOriginalFrameRect(other.originalFrameRect());
146
    setStatus(other.status());
147
    setStatus(other.status());
147
    setDuration(other.duration());
148
    setDuration(other.duration());
Lines 152-159 ImageFrame& ImageFrame::operator=(const ImageFrame& other) a/Source/WebCore/platform/image-decoders/ImageDecoder.cpp_sec2
152
153
153
void ImageFrame::clearPixelData()
154
void ImageFrame::clearPixelData()
154
{
155
{
155
    m_backingStore.clear();
156
    m_pixels = nullptr;
156
    m_bytes = 0;
157
    m_status = FrameEmpty;
157
    m_status = FrameEmpty;
158
    // NOTE: Do not reset other members here; clearFrameBufferCache() calls this
158
    // NOTE: Do not reset other members here; clearFrameBufferCache() calls this
159
    // to free the bitmap data, but other functions like initFrameBuffer() and
159
    // to free the bitmap data, but other functions like initFrameBuffer() and
Lines 163-186 void ImageFrame::clearPixelData() a/Source/WebCore/platform/image-decoders/ImageDecoder.cpp_sec3
163
163
164
void ImageFrame::zeroFillPixelData()
164
void ImageFrame::zeroFillPixelData()
165
{
165
{
166
    memset(m_bytes, 0, m_size.width() * m_size.height() * sizeof(PixelData));
166
    m_pixels.clear();
167
    m_hasAlpha = true;
167
    m_hasAlpha = true;
168
}
168
}
169
169
170
void ImageFrame::zeroFillFrameRect(const IntRect& rect)
170
void ImageFrame::zeroFillFrameRect(const IntRect& rect)
171
{
171
{
172
    ASSERT(IntRect(IntPoint(), m_size).contains(rect));
173
174
    if (rect.isEmpty())
172
    if (rect.isEmpty())
175
        return;
173
        return;
176
174
177
    size_t rectWidthInBytes = rect.width() * sizeof(PixelData);
175
    m_pixels.clearRect(rect);
178
    PixelData* start = m_bytes + (rect.y() * width()) + rect.x();
179
    for (int i = 0; i < rect.height(); ++i) {
180
        memset(start, 0, rectWidthInBytes);
181
        start += width();
182
    }
183
184
    setHasAlpha(true);
176
    setHasAlpha(true);
185
}
177
}
186
178
Lines 189-213 bool ImageFrame::copyBitmapData(const ImageFrame& other) a/Source/WebCore/platform/image-decoders/ImageDecoder.cpp_sec4
189
    if (this == &other)
181
    if (this == &other)
190
        return true;
182
        return true;
191
183
192
    m_backingStore = other.m_backingStore;
184
    if (other.m_pixels)
193
    m_bytes = m_backingStore.data();
185
        m_pixels = BitmapPixels::create(*other.m_pixels);
194
    m_size = other.m_size;
186
    else
195
    setHasAlpha(other.m_hasAlpha);
187
        m_pixels = nullptr;
196
    return true;
188
    return true;
197
}
189
}
198
190
199
bool ImageFrame::setSize(int newWidth, int newHeight)
191
bool ImageFrame::setSize(int newWidth, int newHeight)
200
{
192
{
201
    ASSERT(!width() && !height());
193
    ASSERT(!m_pixels);
202
    size_t backingStoreSize = newWidth * newHeight;
194
    m_pixels = BitmapPixels::create(IntSize(newWidth, newHeight), m_premultiplyAlpha);
203
    if (!m_backingStore.tryReserveCapacity(backingStoreSize))
195
    return m_pixels;
204
        return false;
196
}
205
    m_backingStore.resize(backingStoreSize);
206
    m_bytes = m_backingStore.data();
207
    m_size = IntSize(newWidth, newHeight);
208
197
209
    zeroFillPixelData();
198
void ImageFrame::copyRowNTimes(int startX, int endX, int startY, int endY)
210
    return true;
199
{
200
    m_pixels->repeatFirstRow(IntRect(startX, startY, endX -startX , endY - startY));
211
}
201
}
212
202
213
bool ImageFrame::hasAlpha() const
203
bool ImageFrame::hasAlpha() const
- a/Source/WebCore/platform/image-decoders/ImageDecoder.h -82 / +15 lines
Lines 28-33 a/Source/WebCore/platform/image-decoders/ImageDecoder.h_sec1
28
28
29
#pragma once
29
#pragma once
30
30
31
#include "BitmapPixels.h"
31
#include "IntRect.h"
32
#include "IntRect.h"
32
#include "ImageSource.h"
33
#include "ImageSource.h"
33
#include "PlatformScreen.h"
34
#include "PlatformScreen.h"
Lines 57-63 using ColorProfile = Vector<char>; a/Source/WebCore/platform/image-decoders/ImageDecoder.h_sec2
57
            DisposeOverwritePrevious  // Clear frame to previous framebuffer
58
            DisposeOverwritePrevious  // Clear frame to previous framebuffer
58
                                      // contents
59
                                      // contents
59
        };
60
        };
60
        typedef unsigned PixelData;
61
61
62
        ImageFrame();
62
        ImageFrame();
63
63
Lines 80-96 using ColorProfile = Vector<char>; a/Source/WebCore/platform/image-decoders/ImageDecoder.h_sec3
80
        // Copies the pixel data at [(startX, startY), (endX, startY)) to the
80
        // Copies the pixel data at [(startX, startY), (endX, startY)) to the
81
        // same X-coordinates on each subsequent row up to but not including
81
        // same X-coordinates on each subsequent row up to but not including
82
        // endY.
82
        // endY.
83
        void copyRowNTimes(int startX, int endX, int startY, int endY)
83
        void copyRowNTimes(int startX, int endX, int startY, int endY);
84
        {
85
            ASSERT(startX < width());
86
            ASSERT(endX <= width());
87
            ASSERT(startY < height());
88
            ASSERT(endY <= height());
89
            const int rowBytes = (endX - startX) * sizeof(PixelData);
90
            const PixelData* const startAddr = getAddr(startX, startY);
91
            for (int destY = startY + 1; destY < endY; ++destY)
92
                memcpy(getAddr(startX, destY), startAddr, rowBytes);
93
        }
94
84
95
        // Allocates space for the pixel data.  Must be called before any pixels
85
        // Allocates space for the pixel data.  Must be called before any pixels
96
        // are written.  Must only be called once.  Returns whether allocation
86
        // are written.  Must only be called once.  Returns whether allocation
Lines 100-106 using ColorProfile = Vector<char>; a/Source/WebCore/platform/image-decoders/ImageDecoder.h_sec4
100
        // Returns a caller-owned pointer to the underlying native image data.
90
        // Returns a caller-owned pointer to the underlying native image data.
101
        // (Actual use: This pointer will be owned by BitmapImage and freed in
91
        // (Actual use: This pointer will be owned by BitmapImage and freed in
102
        // FrameData::clear()).
92
        // FrameData::clear()).
103
        NativeImagePtr asNewNativeImage() const;
93
        NativeImagePtr asNewNativeImage() const { return m_pixels.image(); }
104
94
105
        bool hasAlpha() const;
95
        bool hasAlpha() const;
106
        const IntRect& originalFrameRect() const { return m_originalFrameRect; }
96
        const IntRect& originalFrameRect() const { return m_originalFrameRect; }
Lines 119-219 using ColorProfile = Vector<char>; a/Source/WebCore/platform/image-decoders/ImageDecoder.h_sec5
119
109
120
        inline void setRGBA(int x, int y, unsigned r, unsigned g, unsigned b, unsigned a)
110
        inline void setRGBA(int x, int y, unsigned r, unsigned g, unsigned b, unsigned a)
121
        {
111
        {
122
            setRGBA(getAddr(x, y), r, g, b, a);
112
            m_pixels.setRGBA(x, y, r, g, b, a);
123
        }
113
        }
124
114
125
        inline PixelData* getAddr(int x, int y)
115
        inline RGBA32* getAddr(int x, int y)
126
        {
116
        {
127
            return m_bytes + (y * width()) + x;
117
            return m_pixels.at(x, y);
128
        }
118
        }
129
119
130
        inline bool hasPixelData() const
120
        inline bool hasPixelData() const
131
        {
121
        {
132
            return m_bytes;
122
            return m_pixels.get();
133
        }
134
135
        // Use fix point multiplier instead of integer division or floating point math.
136
        // This multipler produces exactly the same result for all values in range 0 - 255.
137
        static const unsigned fixPointShift = 24;
138
        static const unsigned fixPointMult = static_cast<unsigned>(1.0 / 255.0 * (1 << fixPointShift)) + 1;
139
        // Multiplies unsigned value by fixpoint value and converts back to unsigned.
140
        static unsigned fixPointUnsignedMultiply(unsigned fixed, unsigned v)
141
        {
142
            return  (fixed * v) >> fixPointShift;
143
        }
123
        }
144
124
145
        inline void setRGBA(PixelData* dest, unsigned r, unsigned g, unsigned b, unsigned a)
125
        inline void setRGBA(RGBA32* dest, unsigned r, unsigned g, unsigned b, unsigned a)
146
        {
126
        {
147
            if (m_premultiplyAlpha && a < 255) {
127
            m_pixels.setRGBA(dest, r, g, b, a);
148
                if (!a) {
149
                    *dest = 0;
150
                    return;
151
                }
152
153
                unsigned alphaMult = a * fixPointMult;
154
                r = fixPointUnsignedMultiply(r, alphaMult);
155
                g = fixPointUnsignedMultiply(g, alphaMult);
156
                b = fixPointUnsignedMultiply(b, alphaMult);
157
            }
158
            *dest = (a << 24 | r << 16 | g << 8 | b);
159
        }
128
        }
160
129
161
#if ENABLE(APNG)
130
#if ENABLE(APNG)
162
        static inline unsigned divide255(unsigned a)
131
        inline void overRGBA(RGBA32* dest, unsigned r, unsigned g, unsigned b, unsigned a)
163
        {
164
            return (a + (a >> 8) + 1) >> 8;
165
        }
166
167
        inline void overRGBA(PixelData* dest, unsigned r, unsigned g, unsigned b, unsigned a)
168
        {
132
        {
169
            if (!a)
133
            m_pixels.overRGBA(dest, r, g, b, a);
170
                return;
171
172
            if (a < 255) {
173
                unsigned aDest = ((*dest) >> 24) & 255;
174
                if (aDest) {
175
                    unsigned rDest = ((*dest) >> 16) & 255;
176
                    unsigned gDest = ((*dest) >> 8) & 255;
177
                    unsigned bDest = (*dest) & 255;
178
                    unsigned aAux = 255 - a;
179
                    if (!m_premultiplyAlpha) {
180
                        rDest = divide255(rDest * aDest);
181
                        gDest = divide255(gDest * aDest);
182
                        bDest = divide255(bDest * aDest);
183
                    }
184
                    r = divide255(r * a + rDest * aAux);
185
                    g = divide255(g * a + gDest * aAux);
186
                    b = divide255(b * a + bDest * aAux);
187
                    a += divide255(aDest * aAux);
188
                    if (!m_premultiplyAlpha) {
189
                        r = (r * 255 + a - 1) / a;
190
                        g = (g * 255 + a - 1) / a;
191
                        b = (b * 255 + a - 1) / a;
192
                    }
193
                } else if (m_premultiplyAlpha) {
194
                    r = divide255(r * a);
195
                    g = divide255(g * a);
196
                    b = divide255(b * a);
197
                }
198
            }
199
            *dest = (a << 24 | r << 16 | g << 8 | b);
200
        }
134
        }
201
#endif
135
#endif
202
136
203
    private:
137
    private:
204
        int width() const
138
        int width() const
205
        {
139
        {
206
            return m_size.width();
140
            return m_pixels.width();
207
        }
141
        }
208
142
209
        int height() const
143
        int height() const
210
        {
144
        {
211
            return m_size.height();
145
            return m_pixels.height();
212
        }
146
        }
213
147
214
        Vector<PixelData> m_backingStore;
148
        BitmapPixels m_pixels;
215
        PixelData* m_bytes; // The memory is backed by m_backingStore.
149
216
        IntSize m_size;
217
        // FIXME: Do we need m_colorProfile anymore?
150
        // FIXME: Do we need m_colorProfile anymore?
218
        ColorProfile m_colorProfile;
151
        ColorProfile m_colorProfile;
219
        bool m_hasAlpha;
152
        bool m_hasAlpha;
- a/Source/WebCore/platform/image-decoders/cairo/BitmapPixelsCairo.cpp +40 lines
Line 0 a/Source/WebCore/platform/image-decoders/cairo/BitmapPixelsCairo.cpp_sec1
1
/*
2
 * Copyright (C) 2016 Apple Inc.  All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
24
 */
25
26
#include "config.h"
27
#include "BitmapPixels.h"
28
29
#include <cairo.h>
30
31
namespace WebCore {
32
33
NativeImagePtr BitmapPixels::image() const
34
{
35
    return adoptRef(cairo_image_surface_create_for_data(
36
        reinterpret_cast<unsigned char*>(const_cast<PixelData*>(m_pixels)),
37
        CAIRO_FORMAT_ARGB32, width(), height(), width() * sizeof(RGBA32)));
38
}
39
40
} // namespace WebCore
- a/Source/WebCore/platform/image-decoders/cairo/ImageDecoderCairo.cpp -40 lines
Lines 1-40 a/Source/WebCore/platform/image-decoders/cairo/ImageDecoderCairo.cpp_sec1
1
/*
2
 * Copyright (C) 2006 Apple Inc.  All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
24
 */
25
26
#include "config.h"
27
#include "ImageDecoder.h"
28
29
#include <cairo.h>
30
31
namespace WebCore {
32
33
NativeImagePtr ImageFrame::asNewNativeImage() const
34
{
35
    return adoptRef(cairo_image_surface_create_for_data(
36
        reinterpret_cast<unsigned char*>(const_cast<PixelData*>(m_bytes)),
37
        CAIRO_FORMAT_ARGB32, width(), height(), width() * sizeof(PixelData)));
38
}
39
40
} // namespace WebCore
- a/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.mm -1 / +1 lines
Lines 87-93 void MockRealtimeVideoSourceMac::updatePlatformLayer() const a/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.mm_sec1
87
        if (!image)
87
        if (!image)
88
            break;
88
            break;
89
89
90
        m_previewImage = image->getCGImageRef();
90
        m_previewImage = image->nativeImage();
91
        if (!m_previewImage)
91
        if (!m_previewImage)
92
            break;
92
            break;
93
93
- a/Source/WebCore/platform/win/DragImageCGWin.cpp -2 / +2 lines
Lines 136-144 DragImageRef createDragImageFromImage(Image* img, ImageOrientationDescription) a/Source/WebCore/platform/win/DragImageCGWin.cpp_sec1
136
    CGContextScaleCTM(drawContext, 1, -1);
136
    CGContextScaleCTM(drawContext, 1, -1);
137
    CGContextSetFillColor(drawContext, white);
137
    CGContextSetFillColor(drawContext, white);
138
    CGContextFillRect(drawContext, rect);
138
    CGContextFillRect(drawContext, rect);
139
    if (auto srcImage = img->getCGImageRef()) {
139
    if (auto srcImage = img->nativeImage()) {
140
        CGContextSetBlendMode(drawContext, kCGBlendModeNormal);
140
        CGContextSetBlendMode(drawContext, kCGBlendModeNormal);
141
        CGContextDrawImage(drawContext, rect, srcImage);
141
        CGContextDrawImage(drawContext, rect, srcImage.get());
142
    }
142
    }
143
    CGContextRelease(drawContext);
143
    CGContextRelease(drawContext);
144
144
- a/Source/WebKit/mac/Misc/WebCache.mm -1 / +1 lines
Lines 204-210 + (CGImageRef)imageForURL:(NSURL *)url a/Source/WebKit/mac/Misc/WebCache.mm_sec1
204
    WebCore::CachedImage& cachedImage = downcast<WebCore::CachedImage>(*cachedResource);
204
    WebCore::CachedImage& cachedImage = downcast<WebCore::CachedImage>(*cachedResource);
205
    if (!cachedImage.hasImage())
205
    if (!cachedImage.hasImage())
206
        return nullptr;
206
        return nullptr;
207
    return cachedImage.image()->getCGImageRef();
207
    return cachedImage.image()->nativeImage().get();
208
}
208
}
209
209
210
#endif // PLATFORM(IOS)
210
#endif // PLATFORM(IOS)
- a/Source/WebKit2/UIProcess/API/C/cg/WKIconDatabaseCG.cpp -2 / +13 lines
Lines 37-48 using namespace WebCore; a/Source/WebKit2/UIProcess/API/C/cg/WKIconDatabaseCG.cpp_sec1
37
CGImageRef WKIconDatabaseTryGetCGImageForURL(WKIconDatabaseRef iconDatabaseRef, WKURLRef urlRef, WKSize size)
37
CGImageRef WKIconDatabaseTryGetCGImageForURL(WKIconDatabaseRef iconDatabaseRef, WKURLRef urlRef, WKSize size)
38
{
38
{
39
    Image* image = toImpl(iconDatabaseRef)->imageForPageURL(toWTFString(urlRef));
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
43
CFArrayRef WKIconDatabaseTryCopyCGImageArrayForURL(WKIconDatabaseRef iconDatabaseRef, WKURLRef urlRef)
43
CFArrayRef WKIconDatabaseTryCopyCGImageArrayForURL(WKIconDatabaseRef iconDatabaseRef, WKURLRef urlRef)
44
{
44
{
45
    Image* image = toImpl(iconDatabaseRef)->imageForPageURL(toWTFString(urlRef));
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
- a/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm -1 / +1 lines
Lines 4071-4077 - (UIImage *)_presentationSnapshotForPreviewItemController:(UIPreviewItemControl a/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm_sec1
4071
{
4071
{
4072
    if (!_positionInformation.linkIndicator.contentImage)
4072
    if (!_positionInformation.linkIndicator.contentImage)
4073
        return nullptr;
4073
        return nullptr;
4074
    return [[[UIImage alloc] initWithCGImage:_positionInformation.linkIndicator.contentImage->getCGImageRef()] autorelease];
4074
    return [[[UIImage alloc] initWithCGImage:_positionInformation.linkIndicator.contentImage->nativeImage().get()] autorelease];
4075
}
4075
}
4076
4076
4077
- (NSArray *)_presentationRectsForPreviewItemController:(UIPreviewItemController *)controller
4077
- (NSArray *)_presentationRectsForPreviewItemController:(UIPreviewItemController *)controller
- a/Source/WebKit2/WebProcess/Plugins/PluginView.cpp -64 / +1 lines
Lines 1727-1795 void PluginView::windowedPluginVisibilityDidChange(bool isVisible, uint64_t wind a/Source/WebKit2/WebProcess/Plugins/PluginView.cpp_sec1
1727
}
1727
}
1728
#endif
1728
#endif
1729
1729
1730
#if PLATFORM(COCOA)
1731
static bool isAlmostSolidColor(BitmapImage* bitmap)
1732
{
1733
    CGImageRef image = bitmap->getCGImageRef();
1734
    ASSERT(CGImageGetBitsPerComponent(image) == 8);
1735
1736
    CGBitmapInfo imageInfo = CGImageGetBitmapInfo(image);
1737
    if (!(imageInfo & kCGBitmapByteOrder32Little) || (imageInfo & kCGBitmapAlphaInfoMask) != kCGImageAlphaPremultipliedFirst) {
1738
        // FIXME: Consider being able to handle other pixel formats.
1739
        ASSERT_NOT_REACHED();
1740
        return false;
1741
    }
1742
1743
    size_t width = CGImageGetWidth(image);
1744
    size_t height = CGImageGetHeight(image);
1745
    size_t bytesPerRow = CGImageGetBytesPerRow(image);
1746
1747
    RetainPtr<CFDataRef> provider = adoptCF(CGDataProviderCopyData(CGImageGetDataProvider(image)));
1748
    const UInt8* data = CFDataGetBytePtr(provider.get());
1749
1750
    // Overlay a grid of sampling dots on top of a grayscale version of the image.
1751
    // For the interior points, calculate the difference in luminance among the sample point
1752
    // and its surrounds points, scaled by transparency.
1753
    const unsigned sampleRows = 7;
1754
    const unsigned sampleCols = 7;
1755
    // FIXME: Refine the proper number of samples, and accommodate different aspect ratios.
1756
    if (width < sampleCols || height < sampleRows)
1757
        return false;
1758
1759
    // Ensure that the last row/column land on the image perimeter.
1760
    const float strideWidth = static_cast<float>(width - 1) / (sampleCols - 1);
1761
    const float strideHeight = static_cast<float>(height - 1) / (sampleRows - 1);
1762
    float samples[sampleRows][sampleCols];
1763
1764
    // Find the luminance of the sample points.
1765
    float y = 0;
1766
    const UInt8* row = data;
1767
    for (unsigned i = 0; i < sampleRows; ++i) {
1768
        float x = 0;
1769
        for (unsigned j = 0; j < sampleCols; ++j) {
1770
            const UInt8* p0 = row + (static_cast<int>(x + .5)) * 4;
1771
            // R G B A
1772
            samples[i][j] = (0.2125 * *p0 + 0.7154 * *(p0+1) + 0.0721 * *(p0+2)) * *(p0+3) / 255;
1773
            x += strideWidth;
1774
        }
1775
        y += strideHeight;
1776
        row = data + (static_cast<int>(y + .5)) * bytesPerRow;
1777
    }
1778
1779
    // Determine the image score.
1780
    float accumScore = 0;
1781
    for (unsigned i = 1; i < sampleRows - 1; ++i) {
1782
        for (unsigned j = 1; j < sampleCols - 1; ++j) {
1783
            float diff = samples[i - 1][j] + samples[i + 1][j] + samples[i][j - 1] + samples[i][j + 1] - 4 * samples[i][j];
1784
            accumScore += diff * diff;
1785
        }
1786
    }
1787
1788
    // The score for a given sample can be within the range of 0 and 255^2.
1789
    return accumScore < 2500 * (sampleRows - 2) * (sampleCols - 2);
1790
}
1791
#endif
1792
1793
void PluginView::pluginSnapshotTimerFired()
1730
void PluginView::pluginSnapshotTimerFired()
1794
{
1731
{
1795
#if ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC)
1732
#if ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC)
Lines 1809-1815 void PluginView::pluginSnapshotTimerFired() a/Source/WebKit2/WebProcess/Plugins/PluginView.cpp_sec2
1809
1746
1810
        if (snapshotImage) {
1747
        if (snapshotImage) {
1811
#if ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC)
1748
#if ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC)
1812
            bool snapshotIsAlmostSolidColor = isAlmostSolidColor(downcast<BitmapImage>(snapshotImage.get()));
1749
            bool snapshotIsAlmostSolidColor = static_pointer_cast<BitmapImage>(snapshotImage)->isAlmostSolidColor();
1813
            snapshotFound = !snapshotIsAlmostSolidColor;
1750
            snapshotFound = !snapshotIsAlmostSolidColor;
1814
#endif
1751
#endif
1815
1752

Return to Bug 159679