Title: [267016] trunk/Source/WebCore
- Revision
- 267016
- Author
- [email protected]
- Date
- 2020-09-14 09:22:29 -0700 (Mon, 14 Sep 2020)
Log Message
[CG] Cache the last status of the image encoded data
https://bugs.webkit.org/show_bug.cgi?id=216104
Patch by Said Abou-Hallawa <[email protected]> on 2020-09-14
Reviewed by Youenn Fablet.
Cache the last status of the image encoded data such that early decisions
can be made without calling system functions.
* platform/graphics/cg/ImageDecoderCG.cpp:
(WebCore::ImageDecoderCG::encodedDataStatus const):
* platform/graphics/cg/ImageDecoderCG.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (267015 => 267016)
--- trunk/Source/WebCore/ChangeLog 2020-09-14 16:19:14 UTC (rev 267015)
+++ trunk/Source/WebCore/ChangeLog 2020-09-14 16:22:29 UTC (rev 267016)
@@ -1,3 +1,17 @@
+2020-09-14 Said Abou-Hallawa <[email protected]>
+
+ [CG] Cache the last status of the image encoded data
+ https://bugs.webkit.org/show_bug.cgi?id=216104
+
+ Reviewed by Youenn Fablet.
+
+ Cache the last status of the image encoded data such that early decisions
+ can be made without calling system functions.
+
+ * platform/graphics/cg/ImageDecoderCG.cpp:
+ (WebCore::ImageDecoderCG::encodedDataStatus const):
+ * platform/graphics/cg/ImageDecoderCG.h:
+
2020-09-14 Chris Dumez <[email protected]>
Add proper support for AudioContextOptions.sampleRate
Modified: trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp (267015 => 267016)
--- trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp 2020-09-14 16:19:14 UTC (rev 267015)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp 2020-09-14 16:22:29 UTC (rev 267016)
@@ -225,13 +225,23 @@
EncodedDataStatus ImageDecoderCG::encodedDataStatus() const
{
+ if (m_encodedDataStatus == EncodedDataStatus::Error || m_encodedDataStatus == EncodedDataStatus::Complete)
+ return m_encodedDataStatus;
+
+ // The image source UTI can be changed while receiving more encoded data.
String uti = this->uti();
if (uti.isEmpty())
return EncodedDataStatus::Unknown;
+ if (!isSupportedImageType(uti)) {
+ m_encodedDataStatus = EncodedDataStatus::Error;
+ return m_encodedDataStatus;
+ }
+
switch (CGImageSourceGetStatus(m_nativeDecoder.get())) {
case kCGImageStatusUnknownType:
- return EncodedDataStatus::Error;
+ m_encodedDataStatus = EncodedDataStatus::Error;
+ break;
case kCGImageStatusUnexpectedEOF:
case kCGImageStatusInvalidData:
@@ -238,33 +248,31 @@
case kCGImageStatusReadingHeader:
// Ragnaros yells: TOO SOON! You have awakened me TOO SOON, Executus!
if (!m_isAllDataReceived)
- return EncodedDataStatus::Unknown;
+ m_encodedDataStatus = EncodedDataStatus::Unknown;
+ else
+ m_encodedDataStatus = EncodedDataStatus::Error;
+ break;
- return EncodedDataStatus::Error;
-
case kCGImageStatusIncomplete: {
- if (!isSupportedImageType(uti))
- return EncodedDataStatus::Error;
+ if (m_encodedDataStatus == EncodedDataStatus::SizeAvailable)
+ break;
- RetainPtr<CFDictionaryRef> image0Properties = adoptCF(CGImageSourceCopyPropertiesAtIndex(m_nativeDecoder.get(), 0, imageSourceOptions().get()));
- if (!image0Properties)
- return EncodedDataStatus::TypeAvailable;
-
- if (!CFDictionaryContainsKey(image0Properties.get(), kCGImagePropertyPixelWidth) || !CFDictionaryContainsKey(image0Properties.get(), kCGImagePropertyPixelHeight))
- return EncodedDataStatus::TypeAvailable;
-
- return EncodedDataStatus::SizeAvailable;
+ auto image0Properties = adoptCF(CGImageSourceCopyPropertiesAtIndex(m_nativeDecoder.get(), 0, imageSourceOptions().get()));
+ if (!image0Properties || !CFDictionaryContainsKey(image0Properties.get(), kCGImagePropertyPixelWidth) || !CFDictionaryContainsKey(image0Properties.get(), kCGImagePropertyPixelHeight)) {
+ m_encodedDataStatus = EncodedDataStatus::TypeAvailable;
+ break;
+ }
+
+ m_encodedDataStatus = EncodedDataStatus::SizeAvailable;
+ break;
}
case kCGImageStatusComplete:
- if (!isSupportedImageType(uti))
- return EncodedDataStatus::Error;
-
- return EncodedDataStatus::Complete;
+ m_encodedDataStatus = EncodedDataStatus::Complete;
+ break;
}
- ASSERT_NOT_REACHED();
- return EncodedDataStatus::Unknown;
+ return m_encodedDataStatus;
}
size_t ImageDecoderCG::frameCount() const
Modified: trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.h (267015 => 267016)
--- trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.h 2020-09-14 16:19:14 UTC (rev 267015)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.h 2020-09-14 16:22:29 UTC (rev 267016)
@@ -69,6 +69,7 @@
private:
bool m_isAllDataReceived { false };
+ mutable EncodedDataStatus m_encodedDataStatus { EncodedDataStatus::Unknown };
RetainPtr<CGImageSourceRef> m_nativeDecoder;
};
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes