-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move image metadata queries to a separate class named BitmapImageMetadata #23295
Conversation
EWS run on previous version of this PR (hash c2532d9) |
c2532d9
to
1277112
Compare
EWS run on previous version of this PR (hash 1277112) |
1277112
to
5049602
Compare
EWS run on previous version of this PR (hash 5049602) |
5049602
to
a47de8d
Compare
EWS run on previous version of this PR (hash a47de8d) |
a47de8d
to
b6ed46a
Compare
EWS run on previous version of this PR (hash b6ed46a) |
b6ed46a
to
fd814ac
Compare
EWS run on previous version of this PR (hash fd814ac) |
β¦data https://bugs.webkit.org/show_bug.cgi?id=268127 rdar://121643757 Reviewed by NOBODY (OOPS!). ImageSource will delegate the image metadata queries to BitmapImageMetadata. The metadata is retrieved either from the ImageDecoder for from the ImageFrame of the primary index of the image. * Source/WebCore/Headers.cmake: * Source/WebCore/Sources.txt: * Source/WebCore/WebCore.xcodeproj/project.pbxproj: * Source/WebCore/platform/graphics/BitmapImage.cpp: (WebCore::BitmapImage::preTransformedNativeImageForCurrentFrame): (WebCore::BitmapImage::draw): (WebCore::BitmapImage::notSolidColor): Deleted. (WebCore::BitmapImage::colorSpace): Deleted. * Source/WebCore/platform/graphics/BitmapImage.h: * Source/WebCore/platform/graphics/BitmapImageMetadata.cpp: Added. (WebCore::BitmapImageMetadata::BitmapImageMetadata): (WebCore::BitmapImageMetadata::imageMetadata const): (WebCore::BitmapImageMetadata::primaryNativeImageMetadata const): (WebCore::BitmapImageMetadata::primaryImageFrameMetadata const): (WebCore::BitmapImageMetadata::encodedDataStatus const): (WebCore::BitmapImageMetadata::size const): (WebCore::BitmapImageMetadata::densityCorrectedSize const): (WebCore::BitmapImageMetadata::orientation const): (WebCore::BitmapImageMetadata::primaryFrameIndex const): (WebCore::BitmapImageMetadata::frameCount const): (WebCore::BitmapImageMetadata::repetitionCount const): (WebCore::BitmapImageMetadata::colorSpace const): (WebCore::BitmapImageMetadata::singlePixelSolidColor const): (WebCore::BitmapImageMetadata::uti const): (WebCore::BitmapImageMetadata::filenameExtension const): (WebCore::BitmapImageMetadata::accessibilityDescription const): (WebCore::BitmapImageMetadata::hotSpot const): (WebCore::BitmapImageMetadata::maximumSubsamplingLevel const): (WebCore::BitmapImageMetadata::dump const): * Source/WebCore/platform/graphics/BitmapImageMetadata.h: Added. (WebCore::BitmapImageMetadata::clear): (WebCore::BitmapImageMetadata::source const): * Source/WebCore/platform/graphics/Image.cpp: (WebCore::Image::drawPattern): (WebCore::Image::drawTiled): * Source/WebCore/platform/graphics/Image.h: (WebCore::Image::preTransformedNativeImageForCurrentFrame): (WebCore::Image::singlePixelSolidColor const): * Source/WebCore/platform/graphics/ImageFrame.cpp: (WebCore::ImageFrame::size const): Deleted. (WebCore::ImageFrame::singlePixelSolidColor const): Deleted. * Source/WebCore/platform/graphics/ImageFrame.h: (WebCore::ImageFrame::size const): * Source/WebCore/platform/graphics/ImageSource.cpp: (WebCore::ImageSource::ImageSource): (WebCore::ImageSource::dataChanged): (WebCore::ImageSource::encodedDataStatusChanged): (WebCore::ImageSource::encodedDataStatus const): (WebCore::ImageSource::size const): (WebCore::ImageSource::sourceSize const): (WebCore::ImageSource::frameCount const): (WebCore::ImageSource::notSolidColor const): (WebCore::ImageSource::singlePixelSolidColor const): (WebCore::ImageSource::clearMetadata): Deleted. (WebCore::ImageSource::metadataCacheIfNeeded): Deleted. (WebCore::ImageSource::firstFrameMetadataCacheIfNeeded): Deleted. (WebCore::ImageSource::encodedDataStatus): Deleted. (WebCore::ImageSource::frameCount): Deleted. (WebCore::ImageSource::primaryFrameIndex): Deleted. (WebCore::ImageSource::repetitionCount): Deleted. (WebCore::ImageSource::uti): Deleted. (WebCore::ImageSource::filenameExtension): Deleted. (WebCore::ImageSource::accessibilityDescription): Deleted. (WebCore::ImageSource::hotSpot): Deleted. (WebCore::ImageSource::orientation): Deleted. (WebCore::ImageSource::densityCorrectedSize): Deleted. (WebCore::ImageSource::size): Deleted. (WebCore::ImageSource::sourceSize): Deleted. (WebCore::ImageSource::singlePixelSolidColor): Deleted. (WebCore::ImageSource::maximumSubsamplingLevel): Deleted. * Source/WebCore/platform/graphics/ImageSource.h: * Source/WebCore/platform/graphics/NativeImage.h: * Source/WebCore/platform/graphics/cairo/NativeImageCairo.cpp: (WebCore::NativeImage::singlePixelSolidColor const): * Source/WebCore/platform/graphics/cg/NativeImageCG.cpp: (WebCore::NativeImage::singlePixelSolidColor const):
fd814ac
to
5d5ba2e
Compare
EWS run on current version of this PR (hash 5d5ba2e) |
auto image = nativeImageForCurrentFrame(); | ||
if (!image) | ||
return image; | ||
auto nativeImage = nativeImageForCurrentFrame(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use an explicit smart pointer type instead of auto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be fixed in BitmapImageSource::preTransformedNativeImageAtIndex()
in #20916.
|
||
FloatRect destRect(FloatPoint(), correctedSizeFloat); | ||
FloatRect sourceRect(FloatPoint(), sourceSize); | ||
auto buffer = ImageBuffer::create(size, RenderingPurpose::Unspecified, 1, DestinationColorSpace::SRGB(), PixelFormat::BGRA8); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Smart pointer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be fixed in BitmapImageSource::preTransformedNativeImageAtIndex()
in #20916
if (m_cachedFlags.contains(cachedFlag)) | ||
return cachedValue; | ||
|
||
auto decoder = source().m_decoder; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Smart pointer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be fixed in #20916.
|
||
cachedValue = (*decoder.*functor)(); | ||
m_cachedFlags.add(cachedFlag); | ||
source().didDecodeProperties(decoder->bytesDecodedToDetermineProperties()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You likely want protectedSource()
here, which returns a smart pointer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be fixed in #20916.
if (m_cachedFlags.contains(cachedFlag)) | ||
return cachedValue; | ||
|
||
auto nativeImage = const_cast<ImageSource&>(source()).frameImageAtIndexCacheIfNeeded(primaryFrameIndex()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Smart pointer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be fixed in #20916.
if (m_cachedFlags.contains(CachedFlag::MaximumSubsamplingLevel)) | ||
return m_maximumSubsamplingLevel; | ||
|
||
auto decoder = source().m_decoder; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Smart pointer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be fixed in #20916.
void dump(TextStream&) const; | ||
|
||
private: | ||
enum class CachedFlag { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
: uint16_t
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be fixed in #20916.
MaximumSubsamplingLevel = 1 << 13, | ||
}; | ||
|
||
ImageSource& source() const { return *m_source.get(); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be named protectedSource()
and return a RefPtr given that the m_source
is a ThreadSafeWeakPtr and ThreadSafeWeakPtr::get() returns a smart pointer.
Ref<ImageSource> protectedSource() const { return m_source.get().releaseNonNull(); }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be fixed in #20916.
@@ -170,7 +170,7 @@ void Image::fillWithSolidColor(GraphicsContext& ctxt, const FloatRect& dstRect, | |||
|
|||
void Image::drawPattern(GraphicsContext& ctxt, const FloatRect& destRect, const FloatRect& tileRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, ImagePaintingOptions options) | |||
{ | |||
auto tileImage = preTransformedNativeImageForCurrentFrame(options.orientation() == ImageOrientation::Orientation::FromImage); | |||
auto tileImage = preTransformedNativeImageForCurrentFrame(options.orientation()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Smart pointer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be fixed in #20916.
WEBCORE_EXPORT unsigned frameCount() const; | ||
RepetitionCount repetitionCount() const { return m_metadata.repetitionCount(); } | ||
DestinationColorSpace colorSpace() const { return m_metadata.colorSpace(); } | ||
bool notSolidColor() const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
notSolidColor()
is an odd name for a boolean getter. We usually use a prefix, per coding style. E.g. isNotSolidColor()
. The double negative is also not great, not sure if this is avoidable. Maybe hasSolidColor()
and we reverse the bool?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be fixed in #20916.
5d5ba2e
5d5ba2e