-
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
Remove BitmapImage::updateFromSettings() #22844
Remove BitmapImage::updateFromSettings() #22844
Conversation
EWS run on previous version of this PR (hash f54003d) |
f54003d
to
dc1efb9
Compare
EWS run on previous version of this PR (hash dc1efb9) |
dc1efb9
to
bb150b2
Compare
EWS run on previous version of this PR (hash bb150b2) |
@@ -393,7 +385,7 @@ bool BitmapImage::canUseAsyncDecodingForLargeImages() const | |||
|
|||
bool BitmapImage::shouldUseAsyncDecodingForAnimatedImages() const | |||
{ | |||
return canAnimate() && m_allowAnimatedImageAsyncDecoding && (shouldUseAsyncDecodingForTesting() || m_source->canUseAsyncDecoding()); |
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.
Can you explain why we no longer need m_allowAnimatedImageAsyncDecoding
and no longer consult shouldUseAsyncDecodingForTesting()
?
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.
Because they are consulted in RenderBoxModelObject::decodingModeForImageDraw()
. This makes the DecodingMode for the animated images and the large images are done the same way,
LOG(Images, "BitmapImage::%s - %p - url: %s [subsamplingLevel = %d scaleFactorForDrawing = (%.4f, %.4f)]", __FUNCTION__, this, sourceURL().string().utf8().data(), static_cast<int>(m_currentSubsamplingLevel), scaleFactorForDrawing.width(), scaleFactorForDrawing.height()); | ||
|
||
RefPtr<NativeImage> image; | ||
if (options.decodingMode() == DecodingMode::Asynchronous) { | ||
ASSERT(!m_currentFrame || !canAnimate()); | ||
if (!canAnimate() && options.decodingMode() == DecodingMode::Asynchronous) { |
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.
Can you explain this change, is it a change of behavior?
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.
We used to pass DecodingMode::Synchronous for animated images always in RenderBoxModelObject::decodingModeForImageDraw()
auto* bitmapImage = dynamicDowncast<BitmapImage>(image);
if (!bitmapImage || bitmapImage->canAnimate()) {
// The DecodingMode for the current frame has to be Synchronous. The DecodingMode
// for the next frame will be calculated in BitmapImage::internalStartAnimation().
return DecodingMode::Synchronous;
}
This is to avoid going through the then part of this if-statement. The else part of this if- statement was handling the async for animated images through BitmapImage::internalStartAnimation()
if (shouldUseAsyncDecodingForAnimatedImages()) {
...
m_source->requestFrameAsyncDecodingAtIndex
}
This change fix this unclear behavior by making RenderBoxModelObject::decodingModeForImageDraw()
passes the correct DecodingMode from the beginning. So this is not a behavior change.
// Force repaint if showDebugBackground() is on. | ||
if (m_showDebugBackground) | ||
imageObserver()->changedInRect(*this); |
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.
Can you explain why we no longer need this?
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.
The animated image wants to advance to the next frame. But we do not advance to the next frame util it is fully decoded. In this case, the decoding takes too much time. The timer fire but the frame is not ready yet. So we have to wait till the decoding is complete and once we receive imageFrameAvailableAtIndex()
from the work queue, we draw this frame.
The deleted code was showing a yellow rectangle in this case even though the current frame is rendered. So do we really need to show the yellow rectangle in this case? I do not think so. But I can put back.
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.
OK, I agree we don't want the yellow rectangle in this case.
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.
Since this is a behavior change, I think it is worth mentioning in the commit message.
return DecodingMode::Synchronous; | ||
} | ||
|
||
// Some document types force synchronous decoding. |
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.
This comment should move up with the document().isImageDocument()
check.
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 do not quite understand your review here. I think we can even remove this comment since it does not add much.
if (bitmapImage->currentFrameIndex()) | ||
return DecodingMode::Asynchronous; | ||
|
||
return defaultDecodingMode(); |
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.
To clarify, this is a behavior change for the first frame, is that right? Whereas before, we would always sync decode the first frame of an animated image, but now we will check e.g. if it's visible in the viewport to determine whether to sync decode?
If that's right, please mention this (and any other intended behavior changes) in the commit message.
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.
Yes it is a behavior change. And I think it is the only behavior change in this PR. But I think it's the correct behavior. I think the old behavior was done because it was easier to do it this way. There should not be a reason for disallowing us from async decoding the first frame of an animated image.
I will add a comment about this in the commit message.
bb150b2
to
8f3509f
Compare
EWS run on current version of this PR (hash 8f3509f) |
8f3509f
to
4a88ce6
Compare
https://bugs.webkit.org/show_bug.cgi?id=267607 rdar://121077174 Reviewed by Cameron McCormack. Calculate all the image painting options before calling BitmapImage::draw(). Remove all the calls to BitmapImage::updateFromSettings() and pass the calculated AllowImageSubsampling and ShowDebugBackground through ImagePaintingOptions. The first frame of an animated image had to be decoded synchronously. In fact this restriction is not needed. The rules to decode the static image and the first frame of an animated image should be the same. Late decoded frames of an animated images was showing a yellow rectangle if showDebugBackground is enabled. This is not really needed since the animation does not advance until the next frame is fully decoded. * Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp: (WebCore::CanvasRenderingContext2DBase::drawImage): * Source/WebCore/platform/graphics/BitmapImage.cpp: (WebCore::BitmapImage::draw): (WebCore::BitmapImage::shouldUseAsyncDecodingForAnimatedImages const): (WebCore::BitmapImage::subsamplingLevelForScaleFactor): (WebCore::BitmapImage::internalStartAnimation): (WebCore::BitmapImage::advanceAnimation): (WebCore::BitmapImage::decode): (WebCore::BitmapImage::updateFromSettings): Deleted. * Source/WebCore/platform/graphics/BitmapImage.h: * Source/WebCore/platform/graphics/ImagePaintingOptions.h: (WebCore::ImagePaintingOptions::allowImageSubsampling const): (WebCore::ImagePaintingOptions::showDebugBackground const): (WebCore::ImagePaintingOptions::setOption): * Source/WebCore/platform/graphics/ImageTypes.h: * Source/WebCore/rendering/BackgroundPainter.cpp: (WebCore::BackgroundPainter::paintFillLayer): * Source/WebCore/rendering/RenderBoxModelObject.cpp: (WebCore::RenderBoxModelObject::decodingModeForImageDraw const): * Source/WebCore/rendering/RenderImage.cpp: (WebCore::RenderImage::paintIntoRect): * Source/WebCore/rendering/svg/RenderSVGImage.cpp: (WebCore::RenderSVGImage::paintIntoRect): * Source/WebCore/testing/Internals.cpp: (WebCore::Internals::imageFrameIndex): Canonical link: https://commits.webkit.org/273528@main
4a88ce6
to
0c6288b
Compare
Committed 273528@main (0c6288b): https://commits.webkit.org/273528@main Reviewed commits have been landed. Closing PR #22844 and removing active labels. |
0c6288b
8f3509f
π wincairoπ§ͺ wpe-wk2π§ͺ gtk-wk2π tvπ watch