Changeset 267016 in webkit
- Timestamp:
- Sep 14, 2020 9:22:29 AM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r267014 r267016 1 2020-09-14 Said Abou-Hallawa <sabouhallawa@apple.com> 2 3 [CG] Cache the last status of the image encoded data 4 https://bugs.webkit.org/show_bug.cgi?id=216104 5 6 Reviewed by Youenn Fablet. 7 8 Cache the last status of the image encoded data such that early decisions 9 can be made without calling system functions. 10 11 * platform/graphics/cg/ImageDecoderCG.cpp: 12 (WebCore::ImageDecoderCG::encodedDataStatus const): 13 * platform/graphics/cg/ImageDecoderCG.h: 14 1 15 2020-09-14 Chris Dumez <cdumez@apple.com> 2 16 -
trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp
r266827 r267016 226 226 EncodedDataStatus ImageDecoderCG::encodedDataStatus() const 227 227 { 228 if (m_encodedDataStatus == EncodedDataStatus::Error || m_encodedDataStatus == EncodedDataStatus::Complete) 229 return m_encodedDataStatus; 230 231 // The image source UTI can be changed while receiving more encoded data. 228 232 String uti = this->uti(); 229 233 if (uti.isEmpty()) 230 234 return EncodedDataStatus::Unknown; 231 235 236 if (!isSupportedImageType(uti)) { 237 m_encodedDataStatus = EncodedDataStatus::Error; 238 return m_encodedDataStatus; 239 } 240 232 241 switch (CGImageSourceGetStatus(m_nativeDecoder.get())) { 233 242 case kCGImageStatusUnknownType: 234 return EncodedDataStatus::Error; 243 m_encodedDataStatus = EncodedDataStatus::Error; 244 break; 235 245 236 246 case kCGImageStatusUnexpectedEOF: … … 239 249 // Ragnaros yells: TOO SOON! You have awakened me TOO SOON, Executus! 240 250 if (!m_isAllDataReceived) 241 return EncodedDataStatus::Unknown; 242 243 return EncodedDataStatus::Error; 251 m_encodedDataStatus = EncodedDataStatus::Unknown; 252 else 253 m_encodedDataStatus = EncodedDataStatus::Error; 254 break; 244 255 245 256 case kCGImageStatusIncomplete: { 246 if ( !isSupportedImageType(uti))247 return EncodedDataStatus::Error;248 249 RetainPtr<CFDictionaryRef>image0Properties = adoptCF(CGImageSourceCopyPropertiesAtIndex(m_nativeDecoder.get(), 0, imageSourceOptions().get()));250 if (!image0Properties )251 returnEncodedDataStatus::TypeAvailable;252 253 if (!CFDictionaryContainsKey(image0Properties.get(), kCGImagePropertyPixelWidth) || !CFDictionaryContainsKey(image0Properties.get(), kCGImagePropertyPixelHeight))254 return EncodedDataStatus::TypeAvailable; 255 256 return EncodedDataStatus::SizeAvailable;257 if (m_encodedDataStatus == EncodedDataStatus::SizeAvailable) 258 break; 259 260 auto image0Properties = adoptCF(CGImageSourceCopyPropertiesAtIndex(m_nativeDecoder.get(), 0, imageSourceOptions().get())); 261 if (!image0Properties || !CFDictionaryContainsKey(image0Properties.get(), kCGImagePropertyPixelWidth) || !CFDictionaryContainsKey(image0Properties.get(), kCGImagePropertyPixelHeight)) { 262 m_encodedDataStatus = EncodedDataStatus::TypeAvailable; 263 break; 264 } 265 266 m_encodedDataStatus = EncodedDataStatus::SizeAvailable; 267 break; 257 268 } 258 269 259 270 case kCGImageStatusComplete: 260 if (!isSupportedImageType(uti)) 261 return EncodedDataStatus::Error; 262 263 return EncodedDataStatus::Complete; 271 m_encodedDataStatus = EncodedDataStatus::Complete; 272 break; 264 273 } 265 274 266 ASSERT_NOT_REACHED(); 267 return EncodedDataStatus::Unknown; 275 return m_encodedDataStatus; 268 276 } 269 277 -
trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.h
r260415 r267016 70 70 private: 71 71 bool m_isAllDataReceived { false }; 72 mutable EncodedDataStatus m_encodedDataStatus { EncodedDataStatus::Unknown }; 72 73 RetainPtr<CGImageSourceRef> m_nativeDecoder; 73 74 };
Note: See TracChangeset
for help on using the changeset viewer.