Changeset 222151 in webkit
- Timestamp:
- Sep 18, 2017 9:24:59 AM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 added
- 22 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r222103 r222151 2449 2449 platform/graphics/Image.cpp 2450 2450 platform/graphics/ImageBuffer.cpp 2451 platform/graphics/ImageDecoder.cpp 2451 2452 platform/graphics/ImageFrame.cpp 2452 2453 platform/graphics/ImageFrameCache.cpp -
trunk/Source/WebCore/ChangeLog
r222150 r222151 1 2017-09-18 Jer Noble <jer.noble@apple.com> 2 3 Virtualize ImageDecoder 4 https://bugs.webkit.org/show_bug.cgi?id=176118 5 6 Reviewed by Eric Carlson. 7 8 Add an explicit, abstract base class ImageDecoder, and convert ImageDecoderCG to a true 9 subclass. This will allow multiple ImageDecoder subclasses to exist simultaneously at 10 runtime. 11 12 * CMakeLists.txt: 13 * WebCore.xcodeproj/project.pbxproj: 14 * platform/ImageDecoders.cmake: 15 * platform/graphics/ImageDecoder.cpp: Added. 16 (WebCore::ImageDecoder::create): 17 (WebCore::ImageDecoder::bytesDecodedToDetermineProperties): 18 * platform/graphics/ImageDecoder.h: Added. 19 (WebCore::ImageDecoder::isSizeAvailable): 20 (WebCore::ImageDecoder::isAllDataReceived const): 21 * platform/graphics/cg/ImageDecoderCG.cpp: 22 (WebCore::ImageDecoderCG::ImageDecoderCG): 23 (WebCore::ImageDecoderCG::bytesDecodedToDetermineProperties): 24 (WebCore::ImageDecoderCG::uti const): 25 (WebCore::ImageDecoderCG::filenameExtension const): 26 (WebCore::ImageDecoderCG::encodedDataStatus const): 27 (WebCore::ImageDecoderCG::frameCount const): 28 (WebCore::ImageDecoderCG::repetitionCount const): 29 (WebCore::ImageDecoderCG::hotSpot const): 30 (WebCore::ImageDecoderCG::frameSizeAtIndex const): 31 (WebCore::ImageDecoderCG::frameIsCompleteAtIndex const): 32 (WebCore::ImageDecoderCG::frameOrientationAtIndex const): 33 (WebCore::ImageDecoderCG::frameDurationAtIndex const): 34 (WebCore::ImageDecoderCG::frameAllowSubsamplingAtIndex const): 35 (WebCore::ImageDecoderCG::frameHasAlphaAtIndex const): 36 (WebCore::ImageDecoderCG::frameBytesAtIndex const): 37 (WebCore::ImageDecoderCG::createFrameImageAtIndex const): 38 (WebCore::ImageDecoderCG::setData): 39 (WebCore::ImageDecoder::ImageDecoder): Deleted. 40 (WebCore::ImageDecoder::bytesDecodedToDetermineProperties): Deleted. 41 (WebCore::ImageDecoder::uti const): Deleted. 42 (WebCore::ImageDecoder::filenameExtension const): Deleted. 43 (WebCore::ImageDecoder::encodedDataStatus const): Deleted. 44 (WebCore::ImageDecoder::frameCount const): Deleted. 45 (WebCore::ImageDecoder::repetitionCount const): Deleted. 46 (WebCore::ImageDecoder::hotSpot const): Deleted. 47 (WebCore::ImageDecoder::frameSizeAtIndex const): Deleted. 48 (WebCore::ImageDecoder::frameIsCompleteAtIndex const): Deleted. 49 (WebCore::ImageDecoder::frameOrientationAtIndex const): Deleted. 50 (WebCore::ImageDecoder::frameDurationAtIndex const): Deleted. 51 (WebCore::ImageDecoder::frameAllowSubsamplingAtIndex const): Deleted. 52 (WebCore::ImageDecoder::frameHasAlphaAtIndex const): Deleted. 53 (WebCore::ImageDecoder::frameBytesAtIndex const): Deleted. 54 (WebCore::ImageDecoder::createFrameImageAtIndex const): Deleted. 55 (WebCore::ImageDecoder::setData): Deleted. 56 * platform/graphics/cg/ImageDecoderCG.h: 57 (WebCore::ImageDecoderCG::create): 58 (WebCore::ImageDecoder::create): Deleted. 59 (WebCore::ImageDecoder::isSizeAvailable): Deleted. 60 (WebCore::ImageDecoder::isAllDataReceived const): Deleted. 61 (WebCore::ImageDecoder::clearFrameBufferCache): Deleted. 62 * platform/graphics/win/ImageDecoderDirect2D.cpp: 63 (WebCore::ImageDecoderDirect2D::ImageDecoderDirect2D): 64 (WebCore::ImageDecoderDirect2D::systemImagingFactory): 65 (WebCore::ImageDecoderDirect2D::bytesDecodedToDetermineProperties): 66 (WebCore::ImageDecoderDirect2D::filenameExtension const): 67 (WebCore::ImageDecoderDirect2D::isSizeAvailable const): 68 (WebCore::ImageDecoderDirect2D::encodedDataStatus const): 69 (WebCore::ImageDecoderDirect2D::size const): 70 (WebCore::ImageDecoderDirect2D::frameCount const): 71 (WebCore::ImageDecoderDirect2D::repetitionCount const): 72 (WebCore::ImageDecoderDirect2D::hotSpot const): 73 (WebCore::ImageDecoderDirect2D::frameSizeAtIndex const): 74 (WebCore::ImageDecoderDirect2D::frameIsCompleteAtIndex const): 75 (WebCore::ImageDecoderDirect2D::frameOrientationAtIndex const): 76 (WebCore::ImageDecoderDirect2D::frameDurationAtIndex const): 77 (WebCore::ImageDecoderDirect2D::frameAllowSubsamplingAtIndex const): 78 (WebCore::ImageDecoderDirect2D::frameHasAlphaAtIndex const): 79 (WebCore::ImageDecoderDirect2D::frameBytesAtIndex const): 80 (WebCore::ImageDecoderDirect2D::setTargetContext): 81 (WebCore::ImageDecoderDirect2D::createFrameImageAtIndex const): 82 (WebCore::ImageDecoderDirect2D::setData): 83 * platform/graphics/win/ImageDecoderDirect2D.h: 84 (WebCore::ImageDecoderDirect2D::create): 85 (WebCore::ImageDecoder::create): Deleted. 86 (WebCore::ImageDecoder::isAllDataReceived const): Deleted. 87 (WebCore::ImageDecoder::clearFrameBufferCache): Deleted. 88 * platform/image-decoders/ScalableImageDecoder.cpp: Renamed from Source/WebCore/platform/image-decoders/ImageDecoder.cpp. 89 (WebCore::ScalableImageDecoder::create): 90 (WebCore::ScalableImageDecoder::frameIsCompleteAtIndex const): 91 (WebCore::ScalableImageDecoder::frameHasAlphaAtIndex const): 92 (WebCore::ScalableImageDecoder::frameBytesAtIndex const): 93 (WebCore::ScalableImageDecoder::frameDurationAtIndex const): 94 (WebCore::ScalableImageDecoder::createFrameImageAtIndex): 95 (WebCore::ScalableImageDecoder::prepareScaleDataIfNecessary): 96 (WebCore::ScalableImageDecoder::upperBoundScaledX): 97 (WebCore::ScalableImageDecoder::lowerBoundScaledX): 98 (WebCore::ScalableImageDecoder::upperBoundScaledY): 99 (WebCore::ScalableImageDecoder::lowerBoundScaledY): 100 (WebCore::ScalableImageDecoder::scaledY): 101 * platform/image-decoders/ScalableImageDecoder.h: Renamed from Source/WebCore/platform/image-decoders/ImageDecoder.h. 102 (WebCore::ScalableImageDecoder::ScalableImageDecoder): 103 (WebCore::ScalableImageDecoder::~ScalableImageDecoder): 104 (WebCore::ScalableImageDecoder::premultiplyAlpha const): 105 (WebCore::ScalableImageDecoder::isAllDataReceived const): 106 (WebCore::ScalableImageDecoder::size const): 107 (WebCore::ScalableImageDecoder::scaledSize): 108 (WebCore::ScalableImageDecoder::setSize): 109 (WebCore::ScalableImageDecoder::setIgnoreGammaAndColorProfile): 110 (WebCore::ScalableImageDecoder::ignoresGammaAndColorProfile const): 111 (WebCore::ScalableImageDecoder::rgbColorProfile): 112 (WebCore::ScalableImageDecoder::subsamplingLevelForScale): 113 (WebCore::ScalableImageDecoder::inputDeviceColorProfile): 114 (WebCore::ScalableImageDecoder::setFailed): 115 (WebCore::ScalableImageDecoder::failed const): 116 * platform/image-decoders/bmp/BMPImageDecoder.cpp: 117 (WebCore::BMPImageDecoder::BMPImageDecoder): 118 (WebCore::BMPImageDecoder::setData): 119 (WebCore::BMPImageDecoder::setFailed): 120 * platform/image-decoders/bmp/BMPImageDecoder.h: 121 * platform/image-decoders/bmp/BMPImageReader.h: 122 * platform/image-decoders/gif/GIFImageDecoder.cpp: 123 (WebCore::GIFImageDecoder::GIFImageDecoder): 124 (WebCore::GIFImageDecoder::setData): 125 (WebCore::GIFImageDecoder::setSize): 126 (WebCore::GIFImageDecoder::setFailed): 127 * platform/image-decoders/gif/GIFImageDecoder.h: 128 * platform/image-decoders/ico/ICOImageDecoder.cpp: 129 (WebCore::ICOImageDecoder::ICOImageDecoder): 130 (WebCore::ICOImageDecoder::setData): 131 (WebCore::ICOImageDecoder::size): 132 (WebCore::ICOImageDecoder::setSize): 133 (WebCore::ICOImageDecoder::setFailed): 134 * platform/image-decoders/ico/ICOImageDecoder.h: 135 * platform/image-decoders/jpeg/JPEGImageDecoder.cpp: 136 (WebCore::JPEGImageDecoder::JPEGImageDecoder): 137 (WebCore::JPEGImageDecoder::setSize): 138 (WebCore::JPEGImageDecoder::setFailed): 139 * platform/image-decoders/jpeg/JPEGImageDecoder.h: 140 * platform/image-decoders/png/PNGImageDecoder.cpp: 141 (WebCore::PNGImageReader::decode): 142 (WebCore::PNGImageDecoder::PNGImageDecoder): 143 (WebCore::PNGImageDecoder::setSize): 144 (WebCore::PNGImageDecoder::frameBufferAtIndex): 145 (WebCore::PNGImageDecoder::setFailed): 146 * platform/image-decoders/png/PNGImageDecoder.h: 147 * platform/image-decoders/webp/WEBPImageDecoder.cpp: 148 (WebCore::WEBPImageDecoder::WEBPImageDecoder): 149 (WebCore::WEBPImageDecoder::decode): 150 * platform/image-decoders/webp/WEBPImageDecoder.h: 151 1 152 2017-09-18 Andy Estes <aestes@apple.com> 2 153 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r222091 r222151 6281 6281 CD127DEE14F3098400E84779 /* WebCoreFullScreenWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = CD127DEA14F3097900E84779 /* WebCoreFullScreenWindow.h */; settings = {ATTRIBUTES = (Private, ); }; }; 6282 6282 CD19A2681A13E700008D650E /* DiagnosticLoggingClient.h in Headers */ = {isa = PBXBuildFile; fileRef = CD19A2671A13E700008D650E /* DiagnosticLoggingClient.h */; settings = {ATTRIBUTES = (Private, ); }; }; 6283 CD19FEA81F573972000C42FB /* ImageDecoder.h in Headers */ = {isa = PBXBuildFile; fileRef = CD19FEA61F573972000C42FB /* ImageDecoder.h */; }; 6284 CD19FEA91F573972000C42FB /* ImageDecoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD19FEA71F573972000C42FB /* ImageDecoder.cpp */; }; 6283 6285 CD1E7347167BC78E009A885D /* TextTrackRepresentation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD1E7346167BC78E009A885D /* TextTrackRepresentation.cpp */; }; 6284 6286 CD225C0B1C46FBF400140761 /* WebCoreNSURLSession.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD225C091C46FBF400140761 /* WebCoreNSURLSession.mm */; }; … … 15025 15027 CD127DEB14F3097900E84779 /* WebCoreFullScreenWindow.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreFullScreenWindow.mm; sourceTree = "<group>"; }; 15026 15028 CD19A2671A13E700008D650E /* DiagnosticLoggingClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DiagnosticLoggingClient.h; sourceTree = "<group>"; }; 15029 CD19FEA61F573972000C42FB /* ImageDecoder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ImageDecoder.h; sourceTree = "<group>"; }; 15030 CD19FEA71F573972000C42FB /* ImageDecoder.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ImageDecoder.cpp; sourceTree = "<group>"; }; 15027 15031 CD1E7346167BC78E009A885D /* TextTrackRepresentation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextTrackRepresentation.cpp; sourceTree = "<group>"; }; 15028 15032 CD225C091C46FBF400140761 /* WebCoreNSURLSession.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreNSURLSession.mm; sourceTree = "<group>"; }; … … 23844 23848 B2A10B910B3818BD00099AA4 /* ImageBuffer.h */, 23845 23849 22BD9F7D1353625C009BD102 /* ImageBufferData.h */, 23850 CD19FEA61F573972000C42FB /* ImageDecoder.h */, 23851 CD19FEA71F573972000C42FB /* ImageDecoder.cpp */, 23846 23852 5576A5621D88A70800CCC04C /* ImageFrame.cpp */, 23847 23853 5576A5631D88A70800CCC04C /* ImageFrame.h */, … … 28480 28486 9479493A1E0459FA00018D85 /* JSDeprecatedCSSOMValueList.h in Headers */, 28481 28487 31FB1A66120A5D3F00DC02A0 /* JSDeviceMotionEvent.h in Headers */, 28488 CD19FEA81F573972000C42FB /* ImageDecoder.h in Headers */, 28482 28489 59A86008119DAFA100DEF1EF /* JSDeviceOrientationEvent.h in Headers */, 28483 28490 659DDC8309E198BA001BF3C6 /* JSDocument.h in Headers */, … … 31456 31463 E1B533471717D0A100F205F9 /* CachedSVGDocumentReference.cpp in Sources */, 31457 31464 1C0939EA1A13E12900B788E5 /* CachedSVGFont.cpp in Sources */, 31465 CD19FEA91F573972000C42FB /* ImageDecoder.cpp in Sources */, 31458 31466 0753860214489E9800B78452 /* CachedTextTrack.cpp in Sources */, 31459 31467 BCB16C270979C3BD00467741 /* CachedXSLStyleSheet.cpp in Sources */, -
trunk/Source/WebCore/platform/ImageDecoders.cmake
r221387 r222151 10 10 11 11 list(APPEND WebCore_SOURCES 12 platform/image-decoders/ ImageDecoder.cpp12 platform/image-decoders/ScalableImageDecoder.cpp 13 13 14 14 platform/image-decoders/bmp/BMPImageDecoder.cpp -
trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp
r220506 r222151 148 148 #endif 149 149 150 ImageDecoder ::ImageDecoder(SharedBuffer& data, AlphaOption, GammaAndColorProfileOption)150 ImageDecoderCG::ImageDecoderCG(SharedBuffer& data, AlphaOption, GammaAndColorProfileOption) 151 151 { 152 152 RetainPtr<CFStringRef> utiHint; … … 163 163 } 164 164 165 size_t ImageDecoder ::bytesDecodedToDetermineProperties()165 size_t ImageDecoderCG::bytesDecodedToDetermineProperties() const 166 166 { 167 167 // Measured by tracing malloc/calloc calls on Mac OS 10.6.6, x86_64. … … 174 174 } 175 175 176 String ImageDecoder ::uti() const176 String ImageDecoderCG::uti() const 177 177 { 178 178 return CGImageSourceGetType(m_nativeDecoder.get()); 179 179 } 180 180 181 String ImageDecoder ::filenameExtension() const181 String ImageDecoderCG::filenameExtension() const 182 182 { 183 183 return WebCore::preferredExtensionForImageSourceType(uti()); 184 184 } 185 185 186 EncodedDataStatus ImageDecoder ::encodedDataStatus() const186 EncodedDataStatus ImageDecoderCG::encodedDataStatus() const 187 187 { 188 188 String uti = this->uti(); … … 228 228 } 229 229 230 size_t ImageDecoder ::frameCount() const230 size_t ImageDecoderCG::frameCount() const 231 231 { 232 232 return CGImageSourceGetCount(m_nativeDecoder.get()); 233 233 } 234 234 235 RepetitionCount ImageDecoder ::repetitionCount() const235 RepetitionCount ImageDecoderCG::repetitionCount() const 236 236 { 237 237 RetainPtr<CFDictionaryRef> properties = adoptCF(CGImageSourceCopyProperties(m_nativeDecoder.get(), imageSourceOptions().get())); … … 269 269 } 270 270 271 std::optional<IntPoint> ImageDecoder ::hotSpot() const271 std::optional<IntPoint> ImageDecoderCG::hotSpot() const 272 272 { 273 273 RetainPtr<CFDictionaryRef> properties = adoptCF(CGImageSourceCopyPropertiesAtIndex(m_nativeDecoder.get(), 0, imageSourceOptions().get())); … … 290 290 } 291 291 292 IntSize ImageDecoder ::frameSizeAtIndex(size_t index, SubsamplingLevel subsamplingLevel) const292 IntSize ImageDecoderCG::frameSizeAtIndex(size_t index, SubsamplingLevel subsamplingLevel) const 293 293 { 294 294 RetainPtr<CFDictionaryRef> properties = adoptCF(CGImageSourceCopyPropertiesAtIndex(m_nativeDecoder.get(), index, imageSourceOptions(subsamplingLevel).get())); … … 310 310 } 311 311 312 bool ImageDecoder ::frameIsCompleteAtIndex(size_t index) const312 bool ImageDecoderCG::frameIsCompleteAtIndex(size_t index) const 313 313 { 314 314 ASSERT(frameCount()); … … 322 322 } 323 323 324 ImageOrientation ImageDecoder ::frameOrientationAtIndex(size_t index) const324 ImageOrientation ImageDecoderCG::frameOrientationAtIndex(size_t index) const 325 325 { 326 326 RetainPtr<CFDictionaryRef> properties = adoptCF(CGImageSourceCopyPropertiesAtIndex(m_nativeDecoder.get(), index, imageSourceOptions().get())); … … 331 331 } 332 332 333 float ImageDecoder ::frameDurationAtIndex(size_t index) const333 float ImageDecoderCG::frameDurationAtIndex(size_t index) const 334 334 { 335 335 float duration = 0; … … 365 365 } 366 366 367 bool ImageDecoder ::frameAllowSubsamplingAtIndex(size_t) const367 bool ImageDecoderCG::frameAllowSubsamplingAtIndex(size_t) const 368 368 { 369 369 RetainPtr<CFDictionaryRef> properties = adoptCF(CGImageSourceCopyPropertiesAtIndex(m_nativeDecoder.get(), 0, imageSourceOptions().get())); … … 387 387 } 388 388 389 bool ImageDecoder ::frameHasAlphaAtIndex(size_t index) const389 bool ImageDecoderCG::frameHasAlphaAtIndex(size_t index) const 390 390 { 391 391 if (!frameIsCompleteAtIndex(index)) … … 405 405 } 406 406 407 unsigned ImageDecoder ::frameBytesAtIndex(size_t index, SubsamplingLevel subsamplingLevel) const407 unsigned ImageDecoderCG::frameBytesAtIndex(size_t index, SubsamplingLevel subsamplingLevel) const 408 408 { 409 409 IntSize frameSize = frameSizeAtIndex(index, subsamplingLevel); … … 411 411 } 412 412 413 NativeImagePtr ImageDecoder ::createFrameImageAtIndex(size_t index, SubsamplingLevel subsamplingLevel, const DecodingOptions& decodingOptions) const413 NativeImagePtr ImageDecoderCG::createFrameImageAtIndex(size_t index, SubsamplingLevel subsamplingLevel, const DecodingOptions& decodingOptions) 414 414 { 415 415 LOG(Images, "ImageDecoder %p createFrameImageAtIndex %lu", this, index); … … 461 461 } 462 462 463 void ImageDecoder ::setData(SharedBuffer& data, bool allDataReceived)463 void ImageDecoderCG::setData(SharedBuffer& data, bool allDataReceived) 464 464 { 465 465 m_isAllDataReceived = allDataReceived; -
trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.h
r217246 r222151 26 26 #pragma once 27 27 28 #include "DecodingOptions.h" 29 #include "ImageOrientation.h" 30 #include "ImageTypes.h" 31 #include "IntPoint.h" 32 #include "IntSize.h" 33 #include "NativeImage.h" 34 #include <wtf/Optional.h> 35 #include <wtf/ThreadSafeRefCounted.h> 28 #include "ImageDecoder.h" 36 29 37 30 namespace WebCore { 38 39 class SharedBuffer; 40 41 class ImageDecoder : public ThreadSafeRefCounted<ImageDecoder> { 31 32 class ImageDecoderCG final : public ImageDecoder { 42 33 WTF_MAKE_FAST_ALLOCATED; 43 34 public: 44 ImageDecoder (SharedBuffer& data, AlphaOption, GammaAndColorProfileOption);35 ImageDecoderCG(SharedBuffer& data, AlphaOption, GammaAndColorProfileOption); 45 36 46 static Ref<ImageDecoder > create(SharedBuffer& data, AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption)37 static Ref<ImageDecoderCG> create(SharedBuffer& data, AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption) 47 38 { 48 return adoptRef(*new ImageDecoder (data, alphaOption, gammaAndColorProfileOption));39 return adoptRef(*new ImageDecoderCG(data, alphaOption, gammaAndColorProfileOption)); 49 40 } 50 41 51 s tatic size_t bytesDecodedToDetermineProperties();42 size_t bytesDecodedToDetermineProperties() const final; 52 43 53 EncodedDataStatus encodedDataStatus() const ;54 bool isSizeAvailable() { return encodedDataStatus() >= EncodedDataStatus::SizeAvailable; }55 size_t frameCount() const ;56 RepetitionCount repetitionCount() const ;57 String uti() const ;58 String filenameExtension() const ;59 std::optional<IntPoint> hotSpot() const ;44 EncodedDataStatus encodedDataStatus() const final; 45 IntSize size() const final { return IntSize(); } 46 size_t frameCount() const final; 47 RepetitionCount repetitionCount() const final; 48 String uti() const final; 49 String filenameExtension() const final; 50 std::optional<IntPoint> hotSpot() const final; 60 51 61 IntSize frameSizeAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default) const ;62 bool frameIsCompleteAtIndex(size_t) const ;63 ImageOrientation frameOrientationAtIndex(size_t) const ;64 65 float frameDurationAtIndex(size_t) const ;66 bool frameHasAlphaAtIndex(size_t) const ;67 bool frameAllowSubsamplingAtIndex(size_t) const ;68 unsigned frameBytesAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default) const ;69 70 NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingMode::Synchronous) const;71 72 void setData(SharedBuffer&, bool allDataReceived) ;73 bool isAllDataReceived() const { return m_isAllDataReceived; }74 void clearFrameBufferCache(size_t) { }75 52 IntSize frameSizeAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default) const final; 53 bool frameIsCompleteAtIndex(size_t) const final; 54 ImageOrientation frameOrientationAtIndex(size_t) const final; 55 56 float frameDurationAtIndex(size_t) const final; 57 bool frameHasAlphaAtIndex(size_t) const final; 58 bool frameAllowSubsamplingAtIndex(size_t) const final; 59 unsigned frameBytesAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default) const final; 60 61 NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingMode::Synchronous) final; 62 63 void setData(SharedBuffer&, bool allDataReceived) final; 64 bool isAllDataReceived() const final { return m_isAllDataReceived; } 65 void clearFrameBufferCache(size_t) final { } 66 76 67 protected: 77 68 bool m_isAllDataReceived { false }; -
trunk/Source/WebCore/platform/graphics/win/ImageDecoderDirect2D.cpp
r215710 r222151 42 42 namespace WebCore { 43 43 44 ImageDecoder ::ImageDecoder()45 { 46 } 47 48 IWICImagingFactory* ImageDecoder ::systemImagingFactory()44 ImageDecoderDirect2D::ImageDecoderDirect2D() 45 { 46 } 47 48 IWICImagingFactory* ImageDecoderDirect2D::systemImagingFactory() 49 49 { 50 50 static IWICImagingFactory* wicImagingFactory = nullptr; … … 57 57 } 58 58 59 size_t ImageDecoder ::bytesDecodedToDetermineProperties()59 size_t ImageDecoderDirect2D::bytesDecodedToDetermineProperties() 60 60 { 61 61 // Set to match value used for CoreGraphics. … … 63 63 } 64 64 65 String ImageDecoder ::filenameExtension() const65 String ImageDecoderDirect2D::filenameExtension() const 66 66 { 67 67 notImplemented(); … … 69 69 } 70 70 71 bool ImageDecoder ::isSizeAvailable() const71 bool ImageDecoderDirect2D::isSizeAvailable() const 72 72 { 73 73 return m_nativeDecoder ? true : false; 74 74 } 75 75 76 EncodedDataStatus ImageDecoder ::encodedDataStatus() const76 EncodedDataStatus ImageDecoderDirect2D::encodedDataStatus() const 77 77 { 78 78 notImplemented(); … … 80 80 } 81 81 82 IntSize ImageDecoder ::size() const82 IntSize ImageDecoderDirect2D::size() const 83 83 { 84 84 if (!m_nativeDecoder) … … 98 98 } 99 99 100 size_t ImageDecoder ::frameCount() const100 size_t ImageDecoderDirect2D::frameCount() const 101 101 { 102 102 if (!m_nativeDecoder) … … 111 111 } 112 112 113 RepetitionCount ImageDecoder ::repetitionCount() const113 RepetitionCount ImageDecoderDirect2D::repetitionCount() const 114 114 { 115 115 return RepetitionCountNone; 116 116 } 117 117 118 std::optional<IntPoint> ImageDecoder ::hotSpot() const118 std::optional<IntPoint> ImageDecoderDirect2D::hotSpot() const 119 119 { 120 120 return IntPoint(); 121 121 } 122 122 123 IntSize ImageDecoder ::frameSizeAtIndex(size_t index, SubsamplingLevel subsamplingLevel) const123 IntSize ImageDecoderDirect2D::frameSizeAtIndex(size_t index, SubsamplingLevel subsamplingLevel) const 124 124 { 125 125 if (!m_nativeDecoder) … … 139 139 } 140 140 141 bool ImageDecoder ::frameIsCompleteAtIndex(size_t index) const141 bool ImageDecoderDirect2D::frameIsCompleteAtIndex(size_t index) const 142 142 { 143 143 if (!m_nativeDecoder) … … 149 149 } 150 150 151 ImageOrientation ImageDecoder ::frameOrientationAtIndex(size_t index) const151 ImageOrientation ImageDecoderDirect2D::frameOrientationAtIndex(size_t index) const 152 152 { 153 153 notImplemented(); … … 155 155 } 156 156 157 float ImageDecoder ::frameDurationAtIndex(size_t index) const157 float ImageDecoderDirect2D::frameDurationAtIndex(size_t index) const 158 158 { 159 159 notImplemented(); … … 161 161 } 162 162 163 bool ImageDecoder ::frameAllowSubsamplingAtIndex(size_t) const163 bool ImageDecoderDirect2D::frameAllowSubsamplingAtIndex(size_t) const 164 164 { 165 165 notImplemented(); … … 167 167 } 168 168 169 bool ImageDecoder ::frameHasAlphaAtIndex(size_t index) const169 bool ImageDecoderDirect2D::frameHasAlphaAtIndex(size_t index) const 170 170 { 171 171 notImplemented(); … … 173 173 } 174 174 175 unsigned ImageDecoder ::frameBytesAtIndex(size_t index, SubsamplingLevel subsamplingLevel) const175 unsigned ImageDecoderDirect2D::frameBytesAtIndex(size_t index, SubsamplingLevel subsamplingLevel) const 176 176 { 177 177 if (!m_nativeDecoder) … … 182 182 } 183 183 184 void ImageDecoder ::setTargetContext(ID2D1RenderTarget* renderTarget)184 void ImageDecoderDirect2D::setTargetContext(ID2D1RenderTarget* renderTarget) 185 185 { 186 186 m_renderTarget = renderTarget; 187 187 } 188 188 189 NativeImagePtr ImageDecoder ::createFrameImageAtIndex(size_t index, SubsamplingLevel subsamplingLevel, const DecodingOptions&) const189 NativeImagePtr ImageDecoderDirect2D::createFrameImageAtIndex(size_t index, SubsamplingLevel subsamplingLevel, const DecodingOptions&) const 190 190 { 191 191 if (!m_nativeDecoder || !m_renderTarget) … … 214 214 } 215 215 216 void ImageDecoder ::setData(SharedBuffer& data, bool allDataReceived)216 void ImageDecoderDirect2D::setData(SharedBuffer& data, bool allDataReceived) 217 217 { 218 218 if (!allDataReceived) -
trunk/Source/WebCore/platform/graphics/win/ImageDecoderDirect2D.h
r217246 r222151 26 26 #pragma once 27 27 28 #if USE(DIRECT2D) 29 28 30 #include "COMPtr.h" 29 #include "ImageSource.h" 30 #include "IntSize.h" 31 #include "ImageDecoder.h" 31 32 #include <wtf/Optional.h> 32 33 … … 37 38 namespace WebCore { 38 39 39 class ImageDecoder : public ThreadSafeRefCounted<ImageDecoder>{40 class ImageDecoderDirect2D final : public ImageDecoder { 40 41 WTF_MAKE_FAST_ALLOCATED; 41 42 public: 42 ImageDecoder ();43 44 static Ref<ImageDecoder > create(SharedBuffer&, AlphaOption, GammaAndColorProfileOption)43 ImageDecoderDirect2D(); 44 45 static Ref<ImageDecoderDirect2D> create(SharedBuffer&, AlphaOption, GammaAndColorProfileOption) 45 46 { 46 return adoptRef(*new ImageDecoder ());47 return adoptRef(*new ImageDecoderDirect2D()); 47 48 } 48 49 49 50 static size_t bytesDecodedToDetermineProperties(); 50 51 String filenameExtension() const ;52 EncodedDataStatus encodedDataStatus() const ;53 bool isSizeAvailable() const ;54 51 52 String filenameExtension() const final; 53 EncodedDataStatus encodedDataStatus() const final; 54 bool isSizeAvailable() const final; 55 55 56 // Always original size, without subsampling. 56 IntSize size() const ;57 size_t frameCount() const ;57 IntSize size() const final; 58 size_t frameCount() const final; 58 59 59 RepetitionCount repetitionCount() const ;60 std::optional<IntPoint> hotSpot() const ;61 62 IntSize frameSizeAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default) const ;63 bool frameIsCompleteAtIndex(size_t) const ;64 ImageOrientation frameOrientationAtIndex(size_t) const ;65 66 float frameDurationAtIndex(size_t) const ;67 bool frameHasAlphaAtIndex(size_t) const ;68 bool frameAllowSubsamplingAtIndex(size_t) const ;69 unsigned frameBytesAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default) const ;70 71 NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingMode::Synchronous) const ;72 73 void setData(SharedBuffer&, bool allDataReceived) ;74 bool isAllDataReceived() const { return m_isAllDataReceived; }75 void clearFrameBufferCache(size_t) { }60 RepetitionCount repetitionCount() const final; 61 std::optional<IntPoint> hotSpot() const final; 62 63 IntSize frameSizeAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default) const final; 64 bool frameIsCompleteAtIndex(size_t) const final; 65 ImageOrientation frameOrientationAtIndex(size_t) const final; 66 67 float frameDurationAtIndex(size_t) const final; 68 bool frameHasAlphaAtIndex(size_t) const final; 69 bool frameAllowSubsamplingAtIndex(size_t) const final; 70 unsigned frameBytesAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default) const final; 71 72 NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingMode::Synchronous) const final; 73 74 void setData(SharedBuffer&, bool allDataReceived) final; 75 bool isAllDataReceived() const final { return m_isAllDataReceived; } 76 void clearFrameBufferCache(size_t) final { } 76 77 77 78 void setTargetContext(ID2D1RenderTarget*); … … 87 88 88 89 } 90 91 #endif -
trunk/Source/WebCore/platform/image-decoders/ScalableImageDecoder.cpp
r222150 r222151 22 22 23 23 #include "config.h" 24 #include " ImageDecoder.h"24 #include "ScalableImageDecoder.h" 25 25 26 26 #include "BMPImageDecoder.h" … … 99 99 } 100 100 101 RefPtr< ImageDecoder>ImageDecoder::create(SharedBuffer& data, AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption)101 RefPtr<ScalableImageDecoder> ScalableImageDecoder::create(SharedBuffer& data, AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption) 102 102 { 103 103 static const unsigned lengthOfLongestSignature = 14; // To wit: "RIFF????WEBPVP" … … 171 171 } 172 172 173 bool ImageDecoder::frameIsCompleteAtIndex(size_t index) 174 { 175 ImageFrame* buffer = frameBufferAtIndex(index); 173 bool ScalableImageDecoder::frameIsCompleteAtIndex(size_t index) const 174 { 175 // FIXME(176089): asking whether enough data has been appended for a decode 176 // operation to succeed should not require decoding the entire frame. 177 // This function should be implementable in a way that allows const. 178 ImageFrame* buffer = const_cast<ScalableImageDecoder*>(this)->frameBufferAtIndex(index); 176 179 return buffer && buffer->isComplete(); 177 180 } 178 181 179 bool ImageDecoder::frameHasAlphaAtIndex(size_t index) const182 bool ScalableImageDecoder::frameHasAlphaAtIndex(size_t index) const 180 183 { 181 184 if (m_frameBufferCache.size() <= index) … … 186 189 } 187 190 188 unsigned ImageDecoder::frameBytesAtIndex(size_t index) const191 unsigned ScalableImageDecoder::frameBytesAtIndex(size_t index, SubsamplingLevel) const 189 192 { 190 193 if (m_frameBufferCache.size() <= index) … … 194 197 } 195 198 196 float ImageDecoder::frameDurationAtIndex(size_t index) 197 { 198 ImageFrame* buffer = frameBufferAtIndex(index); 199 float ScalableImageDecoder::frameDurationAtIndex(size_t index) const 200 { 201 // FIXME(176089): asking for the duration of a sub-image should not require decoding 202 // the entire frame. This function should be implementable in a way that 203 // allows const. 204 ImageFrame* buffer = const_cast<ScalableImageDecoder*>(this)->frameBufferAtIndex(index); 199 205 if (!buffer || buffer->isInvalid()) 200 206 return 0; … … 210 216 } 211 217 212 NativeImagePtr ImageDecoder::createFrameImageAtIndex(size_t index, SubsamplingLevel, const DecodingOptions&)218 NativeImagePtr ScalableImageDecoder::createFrameImageAtIndex(size_t index, SubsamplingLevel, const DecodingOptions&) 213 219 { 214 220 // Zero-height images can cause problems for some ports. If we have an empty image dimension, just bail. … … 225 231 } 226 232 227 void ImageDecoder::prepareScaleDataIfNecessary()233 void ScalableImageDecoder::prepareScaleDataIfNecessary() 228 234 { 229 235 m_scaled = false; … … 243 249 } 244 250 245 int ImageDecoder::upperBoundScaledX(int origX, int searchStart)251 int ScalableImageDecoder::upperBoundScaledX(int origX, int searchStart) 246 252 { 247 253 return getScaledValue<UpperBound>(m_scaledColumns, origX, searchStart); 248 254 } 249 255 250 int ImageDecoder::lowerBoundScaledX(int origX, int searchStart)256 int ScalableImageDecoder::lowerBoundScaledX(int origX, int searchStart) 251 257 { 252 258 return getScaledValue<LowerBound>(m_scaledColumns, origX, searchStart); 253 259 } 254 260 255 int ImageDecoder::upperBoundScaledY(int origY, int searchStart)261 int ScalableImageDecoder::upperBoundScaledY(int origY, int searchStart) 256 262 { 257 263 return getScaledValue<UpperBound>(m_scaledRows, origY, searchStart); 258 264 } 259 265 260 int ImageDecoder::lowerBoundScaledY(int origY, int searchStart)266 int ScalableImageDecoder::lowerBoundScaledY(int origY, int searchStart) 261 267 { 262 268 return getScaledValue<LowerBound>(m_scaledRows, origY, searchStart); 263 269 } 264 270 265 int ImageDecoder::scaledY(int origY, int searchStart)271 int ScalableImageDecoder::scaledY(int origY, int searchStart) 266 272 { 267 273 return getScaledValue<Exact>(m_scaledRows, origY, searchStart); -
trunk/Source/WebCore/platform/image-decoders/ScalableImageDecoder.h
r222150 r222151 29 29 #pragma once 30 30 31 #include "ImageDecoder.h" 31 32 #include "ImageFrame.h" 32 33 #include "IntRect.h" 33 #include "IntSize.h"34 34 #include "SharedBuffer.h" 35 35 #include <wtf/Assertions.h> 36 #include <wtf/Optional.h>37 36 #include <wtf/RefPtr.h> 38 37 #include <wtf/Vector.h> … … 41 40 namespace WebCore { 42 41 43 // ImageDecoder is a base for all format-specific decoders42 // ScalableImageDecoder is a base for all format-specific decoders 44 43 // (e.g. JPEGImageDecoder). This base manages the ImageFrame cache. 45 44 // … … 47 46 // at decode time. Image decoders will downsample any images larger than 48 47 // |m_maxNumPixels|. FIXME: Not yet supported by all decoders. 49 class ImageDecoder : public ThreadSafeRefCounted<ImageDecoder>{50 WTF_MAKE_NONCOPYABLE( ImageDecoder); WTF_MAKE_FAST_ALLOCATED;48 class ScalableImageDecoder : public ImageDecoder { 49 WTF_MAKE_NONCOPYABLE(ScalableImageDecoder); WTF_MAKE_FAST_ALLOCATED; 51 50 public: 52 ImageDecoder(AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption)51 ScalableImageDecoder(AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption) 53 52 : m_premultiplyAlpha(alphaOption == AlphaOption::Premultiplied) 54 53 , m_ignoreGammaAndColorProfile(gammaAndColorProfileOption == GammaAndColorProfileOption::Ignored) … … 56 55 } 57 56 58 virtual ~ ImageDecoder()57 virtual ~ScalableImageDecoder() 59 58 { 60 59 } … … 62 61 // Returns nullptr if we can't sniff a supported type from the provided data (possibly 63 62 // because there isn't enough data yet). 64 static RefPtr<ImageDecoder> create(SharedBuffer& data, AlphaOption, GammaAndColorProfileOption); 65 66 virtual String filenameExtension() const = 0; 63 static RefPtr<ScalableImageDecoder> create(SharedBuffer& data, AlphaOption, GammaAndColorProfileOption); 67 64 68 65 bool premultiplyAlpha() const { return m_premultiplyAlpha; } 69 66 70 bool isAllDataReceived() const 67 bool isAllDataReceived() const override 71 68 { 72 69 ASSERT(!m_decodingSizeFromSetData); … … 74 71 } 75 72 76 v irtual void setData(SharedBuffer& data, bool allDataReceived)73 void setData(SharedBuffer& data, bool allDataReceived) override 77 74 { 78 75 if (m_encodedDataStatus == EncodedDataStatus::Error) … … 95 92 } 96 93 97 EncodedDataStatus encodedDataStatus() const { return m_encodedDataStatus; }98 99 bool isSizeAvailable() { return m_encodedDataStatus >= EncodedDataStatus::SizeAvailable; }100 101 virtual IntSize size(){ return isSizeAvailable() ? m_size : IntSize(); }94 EncodedDataStatus encodedDataStatus() const override { return m_encodedDataStatus; } 95 96 bool isSizeAvailable() const override { return m_encodedDataStatus >= EncodedDataStatus::SizeAvailable; } 97 98 IntSize size() const override { return isSizeAvailable() ? m_size : IntSize(); } 102 99 103 100 IntSize scaledSize() … … 111 108 // composites any smaller frames against previous frames to create full- 112 109 // size frames. 113 virtual IntSize frameSizeAtIndex(size_t, SubsamplingLevel)110 IntSize frameSizeAtIndex(size_t, SubsamplingLevel) const override 114 111 { 115 112 return size(); … … 131 128 // FIXME: Right now that has to be done by each subclass; factor the 132 129 // decode call out and use it here. 133 virtual size_t frameCount() const{ return 1; }134 135 virtual RepetitionCount repetitionCount() const{ return RepetitionCountNone; }130 size_t frameCount() const override { return 1; } 131 132 RepetitionCount repetitionCount() const override { return RepetitionCountNone; } 136 133 137 134 // Decodes as much of the requested frame as possible, and returns an 138 // ImageDecoder-owned pointer.135 // ScalableImageDecoder-owned pointer. 139 136 virtual ImageFrame* frameBufferAtIndex(size_t) = 0; 140 137 141 bool frameIsCompleteAtIndex(size_t) ;138 bool frameIsCompleteAtIndex(size_t) const override; 142 139 143 140 // Make the best effort guess to check if the requested frame has alpha channel. 144 bool frameHasAlphaAtIndex(size_t) const ;141 bool frameHasAlphaAtIndex(size_t) const override; 145 142 146 143 // Number of bytes in the decoded frame requested. Return 0 if not yet decoded. 147 unsigned frameBytesAtIndex(size_t ) const;148 149 float frameDurationAtIndex(size_t) ;150 151 NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingMode::Synchronous) ;144 unsigned frameBytesAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default) const override; 145 146 float frameDurationAtIndex(size_t) const override; 147 148 NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingMode::Synchronous) override; 152 149 153 150 void setIgnoreGammaAndColorProfile(bool flag) { m_ignoreGammaAndColorProfile = flag; } 154 151 bool ignoresGammaAndColorProfile() const { return m_ignoreGammaAndColorProfile; } 155 152 156 ImageOrientation frameOrientationAtIndex(size_t) const { return m_orientation; }157 158 bool frameAllowSubsamplingAtIndex(size_t) const { return false; }153 ImageOrientation frameOrientationAtIndex(size_t) const override { return m_orientation; } 154 155 bool frameAllowSubsamplingAtIndex(size_t) const override { return false; } 159 156 160 157 enum { ICCColorProfileHeaderLength = 128 }; … … 167 164 } 168 165 169 s tatic size_t bytesDecodedToDetermineProperties(){ return 0; }170 166 size_t bytesDecodedToDetermineProperties() const final { return 0; } 167 171 168 static SubsamplingLevel subsamplingLevelForScale(float, SubsamplingLevel) { return SubsamplingLevel::Default; } 172 169 … … 193 190 // data may be needed to decode future frames (e.g. due to GIF frame 194 191 // compositing). 195 v irtual void clearFrameBufferCache(size_t){ }192 void clearFrameBufferCache(size_t) override { } 196 193 197 194 // If the image has a cursor hot-spot, stores it in the argument 198 195 // and returns true. Otherwise returns false. 199 virtual std::optional<IntPoint> hotSpot() const{ return std::nullopt; }196 std::optional<IntPoint> hotSpot() const override { return std::nullopt; } 200 197 201 198 protected: -
trunk/Source/WebCore/platform/image-decoders/bmp/BMPImageDecoder.cpp
r219702 r222151 42 42 43 43 BMPImageDecoder::BMPImageDecoder(AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption) 44 : ImageDecoder(alphaOption, gammaAndColorProfileOption)44 : ScalableImageDecoder(alphaOption, gammaAndColorProfileOption) 45 45 , m_decodedOffset(0) 46 46 { … … 52 52 return; 53 53 54 ImageDecoder::setData(data, allDataReceived);54 ScalableImageDecoder::setData(data, allDataReceived); 55 55 if (m_reader) 56 56 m_reader->setData(&data); … … 74 74 { 75 75 m_reader = nullptr; 76 return ImageDecoder::setFailed();76 return ScalableImageDecoder::setFailed(); 77 77 } 78 78 -
trunk/Source/WebCore/platform/image-decoders/bmp/BMPImageDecoder.h
r215924 r222151 35 35 namespace WebCore { 36 36 37 38 class BMPImageDecoder final : publicImageDecoder {39 40 static Ref<ImageDecoder> create(AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption)41 42 43 37 // This class decodes the BMP image format. 38 class BMPImageDecoder final : public ScalableImageDecoder { 39 public: 40 static Ref<ScalableImageDecoder> create(AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption) 41 { 42 return adoptRef(*new BMPImageDecoder(alphaOption, gammaAndColorProfileOption)); 43 } 44 44 45 //ImageDecoder46 String filenameExtension() const override{ return ASCIILiteral("bmp"); }47 void setData(SharedBuffer&, bool allDataReceived) override;48 ImageFrame* frameBufferAtIndex(size_t index) override;49 // CAUTION: setFailed() deletes |m_reader|.Be careful to avoid50 51 52 bool setFailed() override;45 // ScalableImageDecoder 46 String filenameExtension() const final { return ASCIILiteral("bmp"); } 47 void setData(SharedBuffer&, bool allDataReceived) final; 48 ImageFrame* frameBufferAtIndex(size_t index) final; 49 // CAUTION: setFailed() deletes |m_reader|. Be careful to avoid 50 // accessing deleted memory, especially when calling this from inside 51 // BMPImageReader! 52 bool setFailed() final; 53 53 54 55 56 void tryDecodeSize(bool allDataReceived) override{ decode(true, allDataReceived); }54 private: 55 BMPImageDecoder(AlphaOption, GammaAndColorProfileOption); 56 void tryDecodeSize(bool allDataReceived) final { decode(true, allDataReceived); } 57 57 58 59 60 61 58 inline uint32_t readUint32(int offset) const 59 { 60 return BMPImageReader::readUint32(m_data.get(), m_decodedOffset + offset); 61 } 62 62 63 // Decodes the image.If |onlySize| is true, stops decoding after64 // calculating the image size.If decoding fails but there is no more65 66 63 // Decodes the image. If |onlySize| is true, stops decoding after 64 // calculating the image size. If decoding fails but there is no more 65 // data coming, sets the "decode failure" flag. 66 void decode(bool onlySize, bool allDataReceived); 67 67 68 // Decodes the image.If |onlySize| is true, stops decoding after69 // calculating the image size.Returns whether decoding succeeded.70 68 // Decodes the image. If |onlySize| is true, stops decoding after 69 // calculating the image size. Returns whether decoding succeeded. 70 bool decodeHelper(bool onlySize); 71 71 72 // Processes the file header at the beginning of the data.Sets73 // |*imgDataOffset| based on the header contents.Returns true if the74 75 72 // Processes the file header at the beginning of the data. Sets 73 // |*imgDataOffset| based on the header contents. Returns true if the 74 // file header could be decoded. 75 bool processFileHeader(size_t* imgDataOffset); 76 76 77 78 79 80 77 // An index into |m_data| representing how much we've already decoded. 78 // Note that this only tracks data _this_ class decodes; once the 79 // BMPImageReader takes over this will not be updated further. 80 size_t m_decodedOffset; 81 81 82 83 84 82 // The reader used to do most of the BMP decoding. 83 std::unique_ptr<BMPImageReader> m_reader; 84 }; 85 85 86 86 } // namespace WebCore -
trunk/Source/WebCore/platform/image-decoders/bmp/BMPImageReader.cpp
r219762 r222151 34 34 namespace WebCore { 35 35 36 BMPImageReader::BMPImageReader( ImageDecoder* parent, size_t decodedAndHeaderOffset, size_t imgDataOffset, bool usesAndMask)36 BMPImageReader::BMPImageReader(ScalableImageDecoder* parent, size_t decodedAndHeaderOffset, size_t imgDataOffset, bool usesAndMask) 37 37 : m_parent(parent) 38 38 , m_buffer(0) -
trunk/Source/WebCore/platform/image-decoders/bmp/BMPImageReader.h
r206156 r222151 29 29 */ 30 30 31 # ifndef BMPImageReader_h32 #define BMPImageReader_h 33 31 #pragma once 32 33 #include "ScalableImageDecoder.h" 34 34 #include <stdint.h> 35 #include "ImageDecoder.h"36 35 37 36 namespace WebCore { 38 37 39 // This class decodes a BMP image. It is used in the BMP and ICO decoders, 40 // which wrap it in the appropriate code to read file headers, etc. 41 class BMPImageReader { 42 WTF_MAKE_FAST_ALLOCATED; 43 public: 44 // Read a value from |data[offset]|, converting from little to native 45 // endianness. 46 static inline uint16_t readUint16(SharedBuffer* data, int offset) 47 { 48 uint16_t result; 49 memcpy(&result, &data->data()[offset], 2); 50 #if CPU(BIG_ENDIAN) 51 result = ((result & 0xff) << 8) | ((result & 0xff00) >> 8); 52 #endif 53 return result; 38 // This class decodes a BMP image. It is used in the BMP and ICO decoders, 39 // which wrap it in the appropriate code to read file headers, etc. 40 class BMPImageReader { 41 WTF_MAKE_FAST_ALLOCATED; 42 public: 43 // Read a value from |data[offset]|, converting from little to native 44 // endianness. 45 static inline uint16_t readUint16(SharedBuffer* data, int offset) 46 { 47 uint16_t result; 48 memcpy(&result, &data->data()[offset], 2); 49 #if CPU(BIG_ENDIAN) 50 result = ((result & 0xff) << 8) | ((result & 0xff00) >> 8); 51 #endif 52 return result; 53 } 54 55 static inline uint32_t readUint32(SharedBuffer* data, int offset) 56 { 57 uint32_t result; 58 memcpy(&result, &data->data()[offset], 4); 59 #if CPU(BIG_ENDIAN) 60 result = ((result & 0xff) << 24) | ((result & 0xff00) << 8) | ((result & 0xff0000) >> 8) | ((result & 0xff000000) >> 24); 61 #endif 62 return result; 63 } 64 65 // |parent| is the decoder that owns us. 66 // |startOffset| points to the start of the BMP within the file. 67 // |buffer| points at an empty ImageFrame that we'll initialize and 68 // fill with decoded data. 69 BMPImageReader(ScalableImageDecoder* parent, size_t decodedAndHeaderOffset, size_t imgDataOffset, bool usesAndMask); 70 71 void setBuffer(ImageFrame* buffer) { m_buffer = buffer; } 72 void setData(SharedBuffer* data) { m_data = data; } 73 74 // Does the actual decoding. If |onlySize| is true, decoding only 75 // progresses as far as necessary to get the image size. Returns 76 // whether decoding succeeded. 77 bool decodeBMP(bool onlySize); 78 79 private: 80 // The various BMP compression types. We don't currently decode all 81 // these. 82 enum CompressionType { 83 // Universal types 84 RGB = 0, 85 RLE8 = 1, 86 RLE4 = 2, 87 // Windows V3+ only 88 BITFIELDS = 3, 89 JPEG = 4, 90 PNG = 5, 91 // OS/2 2.x-only 92 HUFFMAN1D, // Stored in file as 3 93 RLE24, // Stored in file as 4 94 }; 95 enum AndMaskState { 96 None, 97 NotYetDecoded, 98 Decoding, 99 }; 100 enum ProcessingResult { 101 Success, 102 Failure, 103 InsufficientData, 104 }; 105 106 // These are based on the Windows BITMAPINFOHEADER and RGBTRIPLE 107 // structs, but with unnecessary entries removed. 108 struct BitmapInfoHeader { 109 uint32_t biSize; 110 int32_t biWidth; 111 int32_t biHeight; 112 uint16_t biBitCount; 113 CompressionType biCompression; 114 uint32_t biClrUsed; 115 }; 116 struct RGBTriple { 117 uint8_t rgbBlue; 118 uint8_t rgbGreen; 119 uint8_t rgbRed; 120 }; 121 122 inline uint16_t readUint16(int offset) const 123 { 124 return readUint16(m_data.get(), m_decodedOffset + offset); 125 } 126 127 inline uint32_t readUint32(int offset) const 128 { 129 return readUint32(m_data.get(), m_decodedOffset + offset); 130 } 131 132 // Determines the size of the BMP info header. Returns true if the size 133 // is valid. 134 bool readInfoHeaderSize(); 135 136 // Processes the BMP info header. Returns true if the info header could 137 // be decoded. 138 bool processInfoHeader(); 139 140 // Helper function for processInfoHeader() which does the actual reading 141 // of header values from the byte stream. Returns false on error. 142 bool readInfoHeader(); 143 144 // Returns true if this is a Windows V4+ BMP. 145 inline bool isWindowsV4Plus() const 146 { 147 // Windows V4 info header is 108 bytes. V5 is 124 bytes. 148 return (m_infoHeader.biSize == 108) || (m_infoHeader.biSize == 124); 149 } 150 151 // Returns false if consistency errors are found in the info header. 152 bool isInfoHeaderValid() const; 153 154 // For BI_BITFIELDS images, initializes the m_bitMasks[] and 155 // m_bitOffsets[] arrays. processInfoHeader() will initialize these for 156 // other compression types where needed. 157 bool processBitmasks(); 158 159 // For paletted images, allocates and initializes the m_colorTable[] 160 // array. 161 bool processColorTable(); 162 163 // Processes an RLE-encoded image. Returns true if the entire image was 164 // decoded. 165 bool processRLEData(); 166 167 // Processes a set of non-RLE-compressed pixels. Two cases: 168 // * inRLE = true: the data is inside an RLE-encoded bitmap. Tries to 169 // process |numPixels| pixels on the current row. 170 // * inRLE = false: the data is inside a non-RLE-encoded bitmap. 171 // |numPixels| is ignored. Expects |m_coord| to point at the 172 // beginning of the next row to be decoded. Tries to process as 173 // many complete rows as possible. Returns InsufficientData if 174 // there wasn't enough data to decode the whole image. 175 // 176 // This function returns a ProcessingResult instead of a bool so that it 177 // can avoid calling m_parent->setFailed(), which could lead to memory 178 // corruption since that will delete |this| but some callers still want 179 // to access member variables after this returns. 180 ProcessingResult processNonRLEData(bool inRLE, int numPixels); 181 182 // Returns true if the current y-coordinate plus |numRows| would be past 183 // the end of the image. Here "plus" means "toward the end of the 184 // image", so downwards for m_isTopDown images and upwards otherwise. 185 inline bool pastEndOfImage(int numRows) 186 { 187 return m_isTopDown ? ((m_coord.y() + numRows) >= m_parent->size().height()) : ((m_coord.y() - numRows) < 0); 188 } 189 190 // Returns the pixel data for the current X coordinate in a uint32_t. 191 // Assumes m_decodedOffset has been set to the beginning of the current 192 // row. 193 // NOTE: Only as many bytes of the return value as are needed to hold 194 // the pixel data will actually be set. 195 inline uint32_t readCurrentPixel(int bytesPerPixel) const 196 { 197 const int offset = m_coord.x() * bytesPerPixel; 198 switch (bytesPerPixel) { 199 case 2: 200 return readUint16(offset); 201 202 case 3: { 203 // It doesn't matter that we never set the most significant byte 204 // of the return value here in little-endian mode, the caller 205 // won't read it. 206 uint32_t pixel; 207 memcpy(&pixel, &m_data->data()[m_decodedOffset + offset], 3); 208 #if CPU(BIG_ENDIAN) 209 pixel = ((pixel & 0xff00) << 8) | ((pixel & 0xff0000) >> 8) | ((pixel & 0xff000000) >> 24); 210 #endif 211 return pixel; 54 212 } 55 213 56 static inline uint32_t readUint32(SharedBuffer* data, int offset) 57 { 58 uint32_t result; 59 memcpy(&result, &data->data()[offset], 4); 60 #if CPU(BIG_ENDIAN) 61 result = ((result & 0xff) << 24) | ((result & 0xff00) << 8) | ((result & 0xff0000) >> 8) | ((result & 0xff000000) >> 24); 62 #endif 63 return result; 214 case 4: 215 return readUint32(offset); 216 217 default: 218 ASSERT_NOT_REACHED(); 219 return 0; 64 220 } 65 66 // |parent| is the decoder that owns us. 67 // |startOffset| points to the start of the BMP within the file. 68 // |buffer| points at an empty ImageFrame that we'll initialize and 69 // fill with decoded data. 70 BMPImageReader(ImageDecoder* parent, size_t decodedAndHeaderOffset, size_t imgDataOffset, bool usesAndMask); 71 72 void setBuffer(ImageFrame* buffer) { m_buffer = buffer; } 73 void setData(SharedBuffer* data) { m_data = data; } 74 75 // Does the actual decoding. If |onlySize| is true, decoding only 76 // progresses as far as necessary to get the image size. Returns 77 // whether decoding succeeded. 78 bool decodeBMP(bool onlySize); 79 80 private: 81 // The various BMP compression types. We don't currently decode all 82 // these. 83 enum CompressionType { 84 // Universal types 85 RGB = 0, 86 RLE8 = 1, 87 RLE4 = 2, 88 // Windows V3+ only 89 BITFIELDS = 3, 90 JPEG = 4, 91 PNG = 5, 92 // OS/2 2.x-only 93 HUFFMAN1D, // Stored in file as 3 94 RLE24, // Stored in file as 4 95 }; 96 enum AndMaskState { 97 None, 98 NotYetDecoded, 99 Decoding, 100 }; 101 enum ProcessingResult { 102 Success, 103 Failure, 104 InsufficientData, 105 }; 106 107 // These are based on the Windows BITMAPINFOHEADER and RGBTRIPLE 108 // structs, but with unnecessary entries removed. 109 struct BitmapInfoHeader { 110 uint32_t biSize; 111 int32_t biWidth; 112 int32_t biHeight; 113 uint16_t biBitCount; 114 CompressionType biCompression; 115 uint32_t biClrUsed; 116 }; 117 struct RGBTriple { 118 uint8_t rgbBlue; 119 uint8_t rgbGreen; 120 uint8_t rgbRed; 121 }; 122 123 inline uint16_t readUint16(int offset) const 124 { 125 return readUint16(m_data.get(), m_decodedOffset + offset); 126 } 127 128 inline uint32_t readUint32(int offset) const 129 { 130 return readUint32(m_data.get(), m_decodedOffset + offset); 131 } 132 133 // Determines the size of the BMP info header. Returns true if the size 134 // is valid. 135 bool readInfoHeaderSize(); 136 137 // Processes the BMP info header. Returns true if the info header could 138 // be decoded. 139 bool processInfoHeader(); 140 141 // Helper function for processInfoHeader() which does the actual reading 142 // of header values from the byte stream. Returns false on error. 143 bool readInfoHeader(); 144 145 // Returns true if this is a Windows V4+ BMP. 146 inline bool isWindowsV4Plus() const 147 { 148 // Windows V4 info header is 108 bytes. V5 is 124 bytes. 149 return (m_infoHeader.biSize == 108) || (m_infoHeader.biSize == 124); 150 } 151 152 // Returns false if consistency errors are found in the info header. 153 bool isInfoHeaderValid() const; 154 155 // For BI_BITFIELDS images, initializes the m_bitMasks[] and 156 // m_bitOffsets[] arrays. processInfoHeader() will initialize these for 157 // other compression types where needed. 158 bool processBitmasks(); 159 160 // For paletted images, allocates and initializes the m_colorTable[] 161 // array. 162 bool processColorTable(); 163 164 // Processes an RLE-encoded image. Returns true if the entire image was 165 // decoded. 166 bool processRLEData(); 167 168 // Processes a set of non-RLE-compressed pixels. Two cases: 169 // * inRLE = true: the data is inside an RLE-encoded bitmap. Tries to 170 // process |numPixels| pixels on the current row. 171 // * inRLE = false: the data is inside a non-RLE-encoded bitmap. 172 // |numPixels| is ignored. Expects |m_coord| to point at the 173 // beginning of the next row to be decoded. Tries to process as 174 // many complete rows as possible. Returns InsufficientData if 175 // there wasn't enough data to decode the whole image. 176 // 177 // This function returns a ProcessingResult instead of a bool so that it 178 // can avoid calling m_parent->setFailed(), which could lead to memory 179 // corruption since that will delete |this| but some callers still want 180 // to access member variables after this returns. 181 ProcessingResult processNonRLEData(bool inRLE, int numPixels); 182 183 // Returns true if the current y-coordinate plus |numRows| would be past 184 // the end of the image. Here "plus" means "toward the end of the 185 // image", so downwards for m_isTopDown images and upwards otherwise. 186 inline bool pastEndOfImage(int numRows) 187 { 188 return m_isTopDown ? ((m_coord.y() + numRows) >= m_parent->size().height()) : ((m_coord.y() - numRows) < 0); 189 } 190 191 // Returns the pixel data for the current X coordinate in a uint32_t. 192 // Assumes m_decodedOffset has been set to the beginning of the current 193 // row. 194 // NOTE: Only as many bytes of the return value as are needed to hold 195 // the pixel data will actually be set. 196 inline uint32_t readCurrentPixel(int bytesPerPixel) const 197 { 198 const int offset = m_coord.x() * bytesPerPixel; 199 switch (bytesPerPixel) { 200 case 2: 201 return readUint16(offset); 202 203 case 3: { 204 // It doesn't matter that we never set the most significant byte 205 // of the return value here in little-endian mode, the caller 206 // won't read it. 207 uint32_t pixel; 208 memcpy(&pixel, &m_data->data()[m_decodedOffset + offset], 3); 209 #if CPU(BIG_ENDIAN) 210 pixel = ((pixel & 0xff00) << 8) | ((pixel & 0xff0000) >> 8) | ((pixel & 0xff000000) >> 24); 211 #endif 212 return pixel; 213 } 214 215 case 4: 216 return readUint32(offset); 217 218 default: 219 ASSERT_NOT_REACHED(); 220 return 0; 221 } 222 } 223 224 // Returns the value of the desired component (0, 1, 2, 3 == R, G, B, A) 225 // in the given pixel data. 226 inline unsigned getComponent(uint32_t pixel, int component) const 227 { 228 return ((pixel & m_bitMasks[component]) >> m_bitShiftsRight[component]) << m_bitShiftsLeft[component]; 229 } 230 231 inline unsigned getAlpha(uint32_t pixel) const 232 { 233 // For images without alpha, return alpha of 0xff. 234 return m_bitMasks[3] ? getComponent(pixel, 3) : 0xff; 235 } 236 237 // Sets the current pixel to the color given by |colorIndex|. This also 238 // increments the relevant local variables to move the current pixel 239 // right by one. 240 inline void setI(size_t colorIndex) 241 { 242 setPixel(m_colorTable[colorIndex].rgbRed, m_colorTable[colorIndex].rgbGreen, m_colorTable[colorIndex].rgbBlue, 0xff); 243 } 244 245 // Like setI(), but with the individual component values specified. 246 inline void setPixel(unsigned red, 247 unsigned green, 248 unsigned blue, 249 unsigned alpha) 250 { 251 m_buffer->backingStore()->setPixel(m_coord.x(), m_coord.y(), red, green, blue, alpha); 252 m_coord.move(1, 0); 253 } 254 255 // Fills pixels from the current X-coordinate up to, but not including, 256 // |endCoord| with the color given by the individual components. This 257 // also increments the relevant local variables to move the current 258 // pixel right to |endCoord|. 259 inline void fillRGBA(int endCoord, 260 unsigned red, 261 unsigned green, 262 unsigned blue, 263 unsigned alpha) 264 { 265 if (endCoord <= m_coord.x()) 266 return; 267 m_buffer->backingStore()->fillRect(IntRect(m_coord.x(), m_coord.y(), endCoord - m_coord.x(), 1), red, green, blue, alpha); 268 m_coord.setX(endCoord); 269 } 270 271 // Resets the relevant local variables to start drawing at the left edge 272 // of the "next" row, where "next" is above or below the current row 273 // depending on the value of |m_isTopDown|. 274 void moveBufferToNextRow(); 275 276 // The decoder that owns us. 277 ImageDecoder* m_parent; 278 279 // The destination for the pixel data. 280 ImageFrame* m_buffer; 281 282 // The file to decode. 283 RefPtr<SharedBuffer> m_data; 284 285 // An index into |m_data| representing how much we've already decoded. 286 size_t m_decodedOffset; 287 288 // The file offset at which the BMP info header starts. 289 size_t m_headerOffset; 290 291 // The file offset at which the actual image bits start. When decoding 292 // ICO files, this is set to 0, since it's not stored anywhere in a 293 // header; the reader functions expect the image data to start 294 // immediately after the header and (if necessary) color table. 295 size_t m_imgDataOffset; 296 297 // The BMP info header. 298 BitmapInfoHeader m_infoHeader; 299 300 // True if this is an OS/2 1.x (aka Windows 2.x) BMP. The struct 301 // layouts for this type of BMP are slightly different from the later, 302 // more common formats. 303 bool m_isOS21x; 304 305 // True if this is an OS/2 2.x BMP. The meanings of compression types 3 306 // and 4 for this type of BMP differ from Windows V3+ BMPs. 307 // 308 // This will be falsely negative in some cases, but only ones where the 309 // way we misinterpret the data is irrelevant. 310 bool m_isOS22x; 311 312 // True if the BMP is not vertically flipped, that is, the first line of 313 // raster data in the file is the top line of the image. 314 bool m_isTopDown; 315 316 // These flags get set to false as we finish each processing stage. 317 bool m_needToProcessBitmasks; 318 bool m_needToProcessColorTable; 319 320 // Masks/offsets for the color values for non-palette formats. These 321 // are bitwise, with array entries 0, 1, 2, 3 corresponding to R, G, B, 322 // A. 323 // 324 // The right/left shift values are meant to be applied after the masks. 325 // We need to right shift to compensate for the bitfields' offsets into 326 // the 32 bits of pixel data, and left shift to scale the color values 327 // up for fields with less than 8 bits of precision. Sadly, we can't 328 // just combine these into one shift value because the net shift amount 329 // could go either direction. (If only "<< -x" were equivalent to 330 // ">> x"...) 331 uint32_t m_bitMasks[4]; 332 int m_bitShiftsRight[4]; 333 int m_bitShiftsLeft[4]; 334 335 // The color palette, for paletted formats. 336 size_t m_tableSizeInBytes; 337 Vector<RGBTriple> m_colorTable; 338 339 // The coordinate to which we've decoded the image. 340 IntPoint m_coord; 341 342 // Variables that track whether we've seen pixels with alpha values != 0 343 // and == 0, respectively. See comments in processNonRLEData() on how 344 // these are used. 345 bool m_seenNonZeroAlphaPixel; 346 bool m_seenZeroAlphaPixel; 347 348 // ICOs store a 1bpp "mask" immediately after the main bitmap image data 349 // (and, confusingly, add its height to the biHeight value in the info 350 // header, thus doubling it). This variable tracks whether we have such 351 // a mask and if we've started decoding it yet. 352 AndMaskState m_andMaskState; 353 }; 221 } 222 223 // Returns the value of the desired component (0, 1, 2, 3 == R, G, B, A) 224 // in the given pixel data. 225 inline unsigned getComponent(uint32_t pixel, int component) const 226 { 227 return ((pixel & m_bitMasks[component]) >> m_bitShiftsRight[component]) << m_bitShiftsLeft[component]; 228 } 229 230 inline unsigned getAlpha(uint32_t pixel) const 231 { 232 // For images without alpha, return alpha of 0xff. 233 return m_bitMasks[3] ? getComponent(pixel, 3) : 0xff; 234 } 235 236 // Sets the current pixel to the color given by |colorIndex|. This also 237 // increments the relevant local variables to move the current pixel 238 // right by one. 239 inline void setI(size_t colorIndex) 240 { 241 setPixel(m_colorTable[colorIndex].rgbRed, m_colorTable[colorIndex].rgbGreen, m_colorTable[colorIndex].rgbBlue, 0xff); 242 } 243 244 // Like setI(), but with the individual component values specified. 245 inline void setPixel(unsigned red, unsigned green, unsigned blue, unsigned alpha) 246 { 247 m_buffer->backingStore()->setPixel(m_coord.x(), m_coord.y(), red, green, blue, alpha); 248 m_coord.move(1, 0); 249 } 250 251 // Fills pixels from the current X-coordinate up to, but not including, 252 // |endCoord| with the color given by the individual components. This 253 // also increments the relevant local variables to move the current 254 // pixel right to |endCoord|. 255 inline void fillRGBA(int endCoord, unsigned red, unsigned green, unsigned blue, unsigned alpha) 256 { 257 if (endCoord <= m_coord.x()) 258 return; 259 m_buffer->backingStore()->fillRect(IntRect(m_coord.x(), m_coord.y(), endCoord - m_coord.x(), 1), red, green, blue, alpha); 260 m_coord.setX(endCoord); 261 } 262 263 // Resets the relevant local variables to start drawing at the left edge 264 // of the "next" row, where "next" is above or below the current row 265 // depending on the value of |m_isTopDown|. 266 void moveBufferToNextRow(); 267 268 // The decoder that owns us. 269 ScalableImageDecoder* m_parent; 270 271 // The destination for the pixel data. 272 ImageFrame* m_buffer; 273 274 // The file to decode. 275 RefPtr<SharedBuffer> m_data; 276 277 // An index into |m_data| representing how much we've already decoded. 278 size_t m_decodedOffset; 279 280 // The file offset at which the BMP info header starts. 281 size_t m_headerOffset; 282 283 // The file offset at which the actual image bits start. When decoding 284 // ICO files, this is set to 0, since it's not stored anywhere in a 285 // header; the reader functions expect the image data to start 286 // immediately after the header and (if necessary) color table. 287 size_t m_imgDataOffset; 288 289 // The BMP info header. 290 BitmapInfoHeader m_infoHeader; 291 292 // True if this is an OS/2 1.x (aka Windows 2.x) BMP. The struct 293 // layouts for this type of BMP are slightly different from the later, 294 // more common formats. 295 bool m_isOS21x; 296 297 // True if this is an OS/2 2.x BMP. The meanings of compression types 3 298 // and 4 for this type of BMP differ from Windows V3+ BMPs. 299 // 300 // This will be falsely negative in some cases, but only ones where the 301 // way we misinterpret the data is irrelevant. 302 bool m_isOS22x; 303 304 // True if the BMP is not vertically flipped, that is, the first line of 305 // raster data in the file is the top line of the image. 306 bool m_isTopDown; 307 308 // These flags get set to false as we finish each processing stage. 309 bool m_needToProcessBitmasks; 310 bool m_needToProcessColorTable; 311 312 // Masks/offsets for the color values for non-palette formats. These 313 // are bitwise, with array entries 0, 1, 2, 3 corresponding to R, G, B, 314 // A. 315 // 316 // The right/left shift values are meant to be applied after the masks. 317 // We need to right shift to compensate for the bitfields' offsets into 318 // the 32 bits of pixel data, and left shift to scale the color values 319 // up for fields with less than 8 bits of precision. Sadly, we can't 320 // just combine these into one shift value because the net shift amount 321 // could go either direction. (If only "<< -x" were equivalent to 322 // ">> x"...) 323 uint32_t m_bitMasks[4]; 324 int m_bitShiftsRight[4]; 325 int m_bitShiftsLeft[4]; 326 327 // The color palette, for paletted formats. 328 size_t m_tableSizeInBytes; 329 Vector<RGBTriple> m_colorTable; 330 331 // The coordinate to which we've decoded the image. 332 IntPoint m_coord; 333 334 // Variables that track whether we've seen pixels with alpha values != 0 335 // and == 0, respectively. See comments in processNonRLEData() on how 336 // these are used. 337 bool m_seenNonZeroAlphaPixel; 338 bool m_seenZeroAlphaPixel; 339 340 // ICOs store a 1bpp "mask" immediately after the main bitmap image data 341 // (and, confusingly, add its height to the biHeight value in the info 342 // header, thus doubling it). This variable tracks whether we have such 343 // a mask and if we've started decoding it yet. 344 AndMaskState m_andMaskState; 345 }; 354 346 355 347 } // namespace WebCore 356 357 #endif -
trunk/Source/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp
r219762 r222151 33 33 34 34 GIFImageDecoder::GIFImageDecoder(AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption) 35 : ImageDecoder(alphaOption, gammaAndColorProfileOption)35 : ScalableImageDecoder(alphaOption, gammaAndColorProfileOption) 36 36 { 37 37 } … … 46 46 return; 47 47 48 ImageDecoder::setData(data, allDataReceived);48 ScalableImageDecoder::setData(data, allDataReceived); 49 49 if (m_reader) 50 50 m_reader->setData(&data); … … 53 53 bool GIFImageDecoder::setSize(const IntSize& size) 54 54 { 55 if ( ImageDecoder::encodedDataStatus() >= EncodedDataStatus::SizeAvailable && this->size() == size)55 if (ScalableImageDecoder::encodedDataStatus() >= EncodedDataStatus::SizeAvailable && this->size() == size) 56 56 return true; 57 57 58 if (! ImageDecoder::setSize(size))58 if (!ScalableImageDecoder::setSize(size)) 59 59 return false; 60 60 … … 116 116 { 117 117 m_reader = nullptr; 118 return ImageDecoder::setFailed();118 return ScalableImageDecoder::setFailed(); 119 119 } 120 120 -
trunk/Source/WebCore/platform/image-decoders/gif/GIFImageDecoder.h
r215924 r222151 26 26 #pragma once 27 27 28 #include " ImageDecoder.h"28 #include "ScalableImageDecoder.h" 29 29 #include <wtf/Lock.h> 30 30 … … 33 33 namespace WebCore { 34 34 35 36 class GIFImageDecoder final : publicImageDecoder {37 38 static Ref<ImageDecoder> create(AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption)39 40 41 35 // This class decodes the GIF image format. 36 class GIFImageDecoder final : public ScalableImageDecoder { 37 public: 38 static Ref<ScalableImageDecoder> create(AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption) 39 { 40 return adoptRef(*new GIFImageDecoder(alphaOption, gammaAndColorProfileOption)); 41 } 42 42 43 43 virtual ~GIFImageDecoder(); 44 44 45 45 enum GIFQuery { GIFFullQuery, GIFSizeQuery, GIFFrameCountQuery }; 46 46 47 //ImageDecoder48 String filenameExtension() const override{ return ASCIILiteral("gif"); }49 void setData(SharedBuffer& data, bool allDataReceived) override;50 bool setSize(const IntSize&) override;51 size_t frameCount() const override;52 RepetitionCount repetitionCount() const override;53 ImageFrame* frameBufferAtIndex(size_t index) override;54 // CAUTION: setFailed() deletes |m_reader|.Be careful to avoid55 56 57 bool setFailed() override;58 void clearFrameBufferCache(size_t clearBeforeFrame) override;47 // ScalableImageDecoder 48 String filenameExtension() const final { return ASCIILiteral("gif"); } 49 void setData(SharedBuffer& data, bool allDataReceived) final; 50 bool setSize(const IntSize&) final; 51 size_t frameCount() const final; 52 RepetitionCount repetitionCount() const final; 53 ImageFrame* frameBufferAtIndex(size_t index) final; 54 // CAUTION: setFailed() deletes |m_reader|. Be careful to avoid 55 // accessing deleted memory, especially when calling this from inside 56 // GIFImageReader! 57 bool setFailed() final; 58 void clearFrameBufferCache(size_t clearBeforeFrame) final; 59 59 60 61 62 63 60 // Callbacks from the GIF reader. 61 bool haveDecodedRow(unsigned frameIndex, const Vector<unsigned char>& rowBuffer, size_t width, size_t rowNumber, unsigned repeatCount, bool writeTransparentPixels); 62 bool frameComplete(unsigned frameIndex, unsigned frameDuration, ImageFrame::DisposalMethod); 63 void gifComplete(); 64 64 65 66 67 void tryDecodeSize(bool allDataReceived) override{ decode(0, GIFSizeQuery, allDataReceived); }65 private: 66 GIFImageDecoder(AlphaOption, GammaAndColorProfileOption); 67 void tryDecodeSize(bool allDataReceived) final { decode(0, GIFSizeQuery, allDataReceived); } 68 68 69 70 // including) |haltAtFrame|.Otherwise, decodes as much as is needed to71 // answer the query, ignoring bitmap data.If decoding fails but there72 73 69 // If the query is GIFFullQuery, decodes the image up to (but not 70 // including) |haltAtFrame|. Otherwise, decodes as much as is needed to 71 // answer the query, ignoring bitmap data. If decoding fails but there 72 // is no more data coming, sets the "decode failure" flag. 73 void decode(unsigned haltAtFrame, GIFQuery, bool allDataReceived); 74 74 75 76 77 78 75 // Called to initialize the frame buffer with the given index, based on 76 // the previous frame's disposal method. Returns true on success. On 77 // failure, this will mark the image as failed. 78 bool initFrameBuffer(unsigned frameIndex); 79 79 80 81 82 83 84 80 bool m_currentBufferSawAlpha; 81 mutable RepetitionCount m_repetitionCount { RepetitionCountOnce }; 82 std::unique_ptr<GIFImageReader> m_reader; 83 Lock m_decodeLock; 84 }; 85 85 86 86 } // namespace WebCore -
trunk/Source/WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp
r219702 r222151 46 46 47 47 ICOImageDecoder::ICOImageDecoder(AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption) 48 : ImageDecoder(alphaOption, gammaAndColorProfileOption)48 : ScalableImageDecoder(alphaOption, gammaAndColorProfileOption) 49 49 , m_decodedOffset(0) 50 50 { … … 60 60 return; 61 61 62 ImageDecoder::setData(data, allDataReceived);62 ScalableImageDecoder::setData(data, allDataReceived); 63 63 64 64 for (BMPReaders::iterator i(m_bmpReaders.begin()); i != m_bmpReaders.end(); ++i) { … … 70 70 } 71 71 72 IntSize ICOImageDecoder::size() 73 { 74 return m_frameSize.isEmpty() ? ImageDecoder::size() : m_frameSize;75 } 76 77 IntSize ICOImageDecoder::frameSizeAtIndex(size_t index, SubsamplingLevel) 72 IntSize ICOImageDecoder::size() const 73 { 74 return m_frameSize.isEmpty() ? ScalableImageDecoder::size() : m_frameSize; 75 } 76 77 IntSize ICOImageDecoder::frameSizeAtIndex(size_t index, SubsamplingLevel) const 78 78 { 79 79 return (index && (index < m_dirEntries.size())) ? m_dirEntries[index].m_size : size(); … … 84 84 // The size calculated inside the BMPImageReader had better match the one in 85 85 // the icon directory. 86 return m_frameSize.isEmpty() ? ImageDecoder::setSize(size) : ((size == m_frameSize) || setFailed());86 return m_frameSize.isEmpty() ? ScalableImageDecoder::setSize(size) : ((size == m_frameSize) || setFailed()); 87 87 } 88 88 … … 109 109 m_bmpReaders.clear(); 110 110 m_pngDecoders.clear(); 111 return ImageDecoder::setFailed();111 return ScalableImageDecoder::setFailed(); 112 112 } 113 113 -
trunk/Source/WebCore/platform/image-decoders/ico/ICOImageDecoder.h
r215924 r222151 34 34 35 35 namespace WebCore { 36 // This class decodes the ICO and CUR image formats.37 class ICOImageDecoder final : public ImageDecoder {38 public:39 static Ref<ImageDecoder> create(AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption)40 {41 return adoptRef(*new ICOImageDecoder(alphaOption, gammaAndColorProfileOption));42 }43 36 44 virtual ~ICOImageDecoder(); 37 // This class decodes the ICO and CUR image formats. 38 class ICOImageDecoder final : public ScalableImageDecoder { 39 public: 40 static Ref<ScalableImageDecoder> create(AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption) 41 { 42 return adoptRef(*new ICOImageDecoder(alphaOption, gammaAndColorProfileOption)); 43 } 45 44 46 // ImageDecoder 47 String filenameExtension() const override { return ASCIILiteral("ico"); } 48 void setData(SharedBuffer&, bool allDataReceived) override; 49 IntSize size() override; 50 IntSize frameSizeAtIndex(size_t, SubsamplingLevel) override; 51 bool setSize(const IntSize&) override; 52 size_t frameCount() const override; 53 ImageFrame* frameBufferAtIndex(size_t) override; 54 // CAUTION: setFailed() deletes all readers and decoders. Be careful to 55 // avoid accessing deleted memory, especially when calling this from 56 // inside BMPImageReader! 57 bool setFailed() override; 58 std::optional<IntPoint> hotSpot() const override; 45 virtual ~ICOImageDecoder(); 59 46 60 private: 61 enum ImageType { 62 Unknown, 63 BMP, 64 PNG, 65 }; 47 // ScalableImageDecoder 48 String filenameExtension() const final { return ASCIILiteral("ico"); } 49 void setData(SharedBuffer&, bool allDataReceived) final; 50 IntSize size() const final; 51 IntSize frameSizeAtIndex(size_t, SubsamplingLevel) const final; 52 bool setSize(const IntSize&) final; 53 size_t frameCount() const final; 54 ImageFrame* frameBufferAtIndex(size_t) final; 55 // CAUTION: setFailed() deletes all readers and decoders. Be careful to 56 // avoid accessing deleted memory, especially when calling this from 57 // inside BMPImageReader! 58 bool setFailed() final; 59 std::optional<IntPoint> hotSpot() const final; 66 60 67 enum FileType { 68 ICON = 1, 69 CURSOR = 2, 70 }; 71 72 struct IconDirectoryEntry { 73 IntSize m_size; 74 uint16_t m_bitCount; 75 IntPoint m_hotSpot; 76 uint32_t m_imageOffset; 77 }; 78 79 ICOImageDecoder(AlphaOption, GammaAndColorProfileOption); 80 void tryDecodeSize(bool allDataReceived) override { decode(0, true, allDataReceived); } 81 82 // Returns true if |a| is a preferable icon entry to |b|. 83 // Larger sizes, or greater bitdepths at the same size, are preferable. 84 static bool compareEntries(const IconDirectoryEntry& a, const IconDirectoryEntry& b); 85 86 inline uint16_t readUint16(int offset) const 87 { 88 return BMPImageReader::readUint16(m_data.get(), m_decodedOffset + offset); 89 } 90 91 inline uint32_t readUint32(int offset) const 92 { 93 return BMPImageReader::readUint32(m_data.get(), m_decodedOffset + offset); 94 } 95 96 // If the desired PNGImageDecoder exists, gives it the appropriate data. 97 void setDataForPNGDecoderAtIndex(size_t); 98 99 // Decodes the entry at |index|. If |onlySize| is true, stops decoding 100 // after calculating the image size. If decoding fails but there is no 101 // more data coming, sets the "decode failure" flag. 102 void decode(size_t index, bool onlySize, bool allDataReceived); 103 104 // Decodes the directory and directory entries at the beginning of the 105 // data, and initializes members. Returns true if all decoding 106 // succeeded. Once this returns true, all entries' sizes are known. 107 bool decodeDirectory(); 108 109 // Decodes the specified entry. 110 bool decodeAtIndex(size_t); 111 112 // Processes the ICONDIR at the beginning of the data. Returns true if 113 // the directory could be decoded. 114 bool processDirectory(); 115 116 // Processes the ICONDIRENTRY records after the directory. Keeps the 117 // "best" entry as the one we'll decode. Returns true if the entries 118 // could be decoded. 119 bool processDirectoryEntries(); 120 121 // Returns the hot-spot for |index|, returns std::nullopt if there is none. 122 std::optional<IntPoint> hotSpotAtIndex(size_t) const; 123 124 // Reads and returns a directory entry from the current offset into 125 // |data|. 126 IconDirectoryEntry readDirectoryEntry(); 127 128 // Determines whether the desired entry is a BMP or PNG. Returns true 129 // if the type could be determined. 130 ImageType imageTypeAtIndex(size_t); 131 132 // An index into |m_data| representing how much we've already decoded. 133 // Note that this only tracks data _this_ class decodes; once the 134 // BMPImageReader takes over this will not be updated further. 135 size_t m_decodedOffset; 136 137 // Which type of file (ICO/CUR) this is. 138 FileType m_fileType; 139 140 // The headers for the ICO. 141 typedef Vector<IconDirectoryEntry> IconDirectoryEntries; 142 IconDirectoryEntries m_dirEntries; 143 144 // The image decoders for the various frames. 145 typedef Vector<std::unique_ptr<BMPImageReader>> BMPReaders; 146 BMPReaders m_bmpReaders; 147 typedef Vector<RefPtr<ImageDecoder>> PNGDecoders; 148 PNGDecoders m_pngDecoders; 149 150 // Valid only while a BMPImageReader is decoding, this holds the size 151 // for the particular entry being decoded. 152 IntSize m_frameSize; 61 private: 62 enum ImageType { 63 Unknown, 64 BMP, 65 PNG, 153 66 }; 154 67 68 enum FileType { 69 ICON = 1, 70 CURSOR = 2, 71 }; 72 73 struct IconDirectoryEntry { 74 IntSize m_size; 75 uint16_t m_bitCount; 76 IntPoint m_hotSpot; 77 uint32_t m_imageOffset; 78 }; 79 80 ICOImageDecoder(AlphaOption, GammaAndColorProfileOption); 81 void tryDecodeSize(bool allDataReceived) final { decode(0, true, allDataReceived); } 82 83 // Returns true if |a| is a preferable icon entry to |b|. 84 // Larger sizes, or greater bitdepths at the same size, are preferable. 85 static bool compareEntries(const IconDirectoryEntry& a, const IconDirectoryEntry& b); 86 87 inline uint16_t readUint16(int offset) const 88 { 89 return BMPImageReader::readUint16(m_data.get(), m_decodedOffset + offset); 90 } 91 92 inline uint32_t readUint32(int offset) const 93 { 94 return BMPImageReader::readUint32(m_data.get(), m_decodedOffset + offset); 95 } 96 97 // If the desired PNGImageDecoder exists, gives it the appropriate data. 98 void setDataForPNGDecoderAtIndex(size_t); 99 100 // Decodes the entry at |index|. If |onlySize| is true, stops decoding 101 // after calculating the image size. If decoding fails but there is no 102 // more data coming, sets the "decode failure" flag. 103 void decode(size_t index, bool onlySize, bool allDataReceived); 104 105 // Decodes the directory and directory entries at the beginning of the 106 // data, and initializes members. Returns true if all decoding 107 // succeeded. Once this returns true, all entries' sizes are known. 108 bool decodeDirectory(); 109 110 // Decodes the specified entry. 111 bool decodeAtIndex(size_t); 112 113 // Processes the ICONDIR at the beginning of the data. Returns true if 114 // the directory could be decoded. 115 bool processDirectory(); 116 117 // Processes the ICONDIRENTRY records after the directory. Keeps the 118 // "best" entry as the one we'll decode. Returns true if the entries 119 // could be decoded. 120 bool processDirectoryEntries(); 121 122 // Returns the hot-spot for |index|, returns std::nullopt if there is none. 123 std::optional<IntPoint> hotSpotAtIndex(size_t) const; 124 125 // Reads and returns a directory entry from the current offset into 126 // |data|. 127 IconDirectoryEntry readDirectoryEntry(); 128 129 // Determines whether the desired entry is a BMP or PNG. Returns true 130 // if the type could be determined. 131 ImageType imageTypeAtIndex(size_t); 132 133 // An index into |m_data| representing how much we've already decoded. 134 // Note that this only tracks data _this_ class decodes; once the 135 // BMPImageReader takes over this will not be updated further. 136 size_t m_decodedOffset; 137 138 // Which type of file (ICO/CUR) this is. 139 FileType m_fileType; 140 141 // The headers for the ICO. 142 typedef Vector<IconDirectoryEntry> IconDirectoryEntries; 143 IconDirectoryEntries m_dirEntries; 144 145 // The image decoders for the various frames. 146 typedef Vector<std::unique_ptr<BMPImageReader>> BMPReaders; 147 BMPReaders m_bmpReaders; 148 typedef Vector<RefPtr<ScalableImageDecoder>> PNGDecoders; 149 PNGDecoders m_pngDecoders; 150 151 // Valid only while a BMPImageReader is decoding, this holds the size 152 // for the particular entry being decoded. 153 IntSize m_frameSize; 154 }; 155 155 156 } // namespace WebCore -
trunk/Source/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
r219762 r222151 503 503 504 504 JPEGImageDecoder::JPEGImageDecoder(AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption) 505 : ImageDecoder(alphaOption, gammaAndColorProfileOption)505 : ScalableImageDecoder(alphaOption, gammaAndColorProfileOption) 506 506 { 507 507 } … … 513 513 bool JPEGImageDecoder::setSize(const IntSize& size) 514 514 { 515 if (! ImageDecoder::setSize(size))515 if (!ScalableImageDecoder::setSize(size)) 516 516 return false; 517 517 … … 537 537 { 538 538 m_reader = nullptr; 539 return ImageDecoder::setFailed();539 return ScalableImageDecoder::setFailed(); 540 540 } 541 541 -
trunk/Source/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.h
r215924 r222151 27 27 #pragma once 28 28 29 #include " ImageDecoder.h"29 #include "ScalableImageDecoder.h" 30 30 #include <stdio.h> // Needed by jpeglib.h for FILE. 31 31 … … 42 42 43 43 // This class decodes the JPEG image format. 44 class JPEGImageDecoder final : public ImageDecoder {44 class JPEGImageDecoder final : public ScalableImageDecoder { 45 45 public: 46 static Ref< ImageDecoder> create(AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption)46 static Ref<ScalableImageDecoder> create(AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption) 47 47 { 48 48 return adoptRef(*new JPEGImageDecoder(alphaOption, gammaAndColorProfileOption)); … … 51 51 virtual ~JPEGImageDecoder(); 52 52 53 // ImageDecoder53 // ScalableImageDecoder 54 54 String filenameExtension() const override { return ASCIILiteral("jpg"); } 55 55 bool setSize(const IntSize&) override; … … 62 62 bool willDownSample() 63 63 { 64 ASSERT( ImageDecoder::encodedDataStatus() >= EncodedDataStatus::SizeAvailable);64 ASSERT(ScalableImageDecoder::encodedDataStatus() >= EncodedDataStatus::SizeAvailable); 65 65 return m_scaled; 66 66 } -
trunk/Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp
r219762 r222151 174 174 // merely want to check if we've managed to set the size, not 175 175 // (recursively) trigger additional decoding if we haven't. 176 if (sizeOnly ? decoder-> ImageDecoder::encodedDataStatus() >= EncodedDataStatus::SizeAvailable : decoder->isCompleteAtIndex(haltAtFrame))176 if (sizeOnly ? decoder->ScalableImageDecoder::encodedDataStatus() >= EncodedDataStatus::SizeAvailable : decoder->isCompleteAtIndex(haltAtFrame)) 177 177 return true; 178 178 } … … 203 203 204 204 PNGImageDecoder::PNGImageDecoder(AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption) 205 : ImageDecoder(alphaOption, gammaAndColorProfileOption)205 : ScalableImageDecoder(alphaOption, gammaAndColorProfileOption) 206 206 , m_doNothingOnFailure(false) 207 207 , m_currentFrame(0) … … 250 250 bool PNGImageDecoder::setSize(const IntSize& size) 251 251 { 252 if (! ImageDecoder::setSize(size))252 if (!ScalableImageDecoder::setSize(size)) 253 253 return false; 254 254 … … 260 260 { 261 261 #if ENABLE(APNG) 262 if ( ImageDecoder::encodedDataStatus() < EncodedDataStatus::SizeAvailable)262 if (ScalableImageDecoder::encodedDataStatus() < EncodedDataStatus::SizeAvailable) 263 263 return nullptr; 264 264 … … 284 284 return false; 285 285 m_reader = nullptr; 286 return ImageDecoder::setFailed();286 return ScalableImageDecoder::setFailed(); 287 287 } 288 288 -
trunk/Source/WebCore/platform/image-decoders/png/PNGImageDecoder.h
r215924 r222151 26 26 #pragma once 27 27 28 #include " ImageDecoder.h"28 #include "ScalableImageDecoder.h" 29 29 #if ENABLE(APNG) 30 30 #include <png.h> … … 36 36 37 37 // This class decodes the PNG image format. 38 class PNGImageDecoder final : public ImageDecoder {38 class PNGImageDecoder final : public ScalableImageDecoder { 39 39 public: 40 static Ref< ImageDecoder> create(AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption)40 static Ref<ScalableImageDecoder> create(AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption) 41 41 { 42 42 return adoptRef(*new PNGImageDecoder(alphaOption, gammaAndColorProfileOption)); … … 45 45 virtual ~PNGImageDecoder(); 46 46 47 // ImageDecoder47 // ScalableImageDecoder 48 48 String filenameExtension() const override { return ASCIILiteral("png"); } 49 49 #if ENABLE(APNG) -
trunk/Source/WebCore/platform/image-decoders/webp/WEBPImageDecoder.cpp
r219762 r222151 47 47 48 48 WEBPImageDecoder::WEBPImageDecoder(AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption) 49 : ImageDecoder(alphaOption, gammaAndColorProfileOption)49 : ScalableImageDecoder(alphaOption, gammaAndColorProfileOption) 50 50 , m_decoder(0) 51 51 , m_hasAlpha(false) … … 87 87 const size_t dataSize = m_data->size(); 88 88 89 if ( ImageDecoder::encodedDataStatus() < EncodedDataStatus::SizeAvailable) {89 if (ScalableImageDecoder::encodedDataStatus() < EncodedDataStatus::SizeAvailable) { 90 90 static const size_t imageHeaderSize = 30; 91 91 if (dataSize < imageHeaderSize) … … 109 109 } 110 110 111 ASSERT( ImageDecoder::encodedDataStatus() >= EncodedDataStatus::SizeAvailable);111 ASSERT(ScalableImageDecoder::encodedDataStatus() >= EncodedDataStatus::SizeAvailable); 112 112 if (onlySize) 113 113 return true; -
trunk/Source/WebCore/platform/image-decoders/webp/WEBPImageDecoder.h
r215924 r222151 29 29 #pragma once 30 30 31 #include " ImageDecoder.h"31 #include "ScalableImageDecoder.h" 32 32 33 33 #if USE(WEBP) … … 37 37 namespace WebCore { 38 38 39 class WEBPImageDecoder final : public ImageDecoder {39 class WEBPImageDecoder final : public ScalableImageDecoder { 40 40 public: 41 static Ref< ImageDecoder> create(AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption)41 static Ref<ScalableImageDecoder> create(AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption) 42 42 { 43 43 return adoptRef(*new WEBPImageDecoder(alphaOption, gammaAndColorProfileOption));
Note: See TracChangeset
for help on using the changeset viewer.