Skip to content

Commit

Permalink
Decouple BitmapImage sources and main functions into separate classes
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=265363
rdar://118819338

Reviewed by Cameron McCormack.

The BitmapImage and ImageSource manage the operations and the queries of the
bitmap image. The current interface and the code structure of these two classes
and the relationship between them make it difficult and risky to hack.

This purpose of this refactor is to provide a clearer interface and to build a
a better class hierarchy and association. This will allow distributing the
operations among better encapsulated classes.

Here is the new class hierarchy and association:

  Image: The super class for all kinds of images in WebKit.

  ImageAdapter: It converts an Image to a platform specific format.

  ImageDecoder: A super class for the system and WebKit image decoders

  ImageSource: A super class BitmapImage source. It can be from a CachedImage or
  from a NativeImage.

  BitmapImageSource: Receives the encoded data of an image and provides all the
  frames decoded NativeImage and metadata. It holds and coordinates the interactions
  amog BitmapImage, ImageFrameAnimator and ImageFrameWorkQueue.

  NativeImageSource: It wraps an already created NativeImage in a BitmapImage.

  ImageFrameAnimator: It advances the current frame index of an animated image when.
  its timer fires. The timer is set with the duration of the frame. It requests
  decoding the NativeImage asynchronously if this is allowed.

  ImageFrameWorkQueue: It decodes the NativeImage of an ImageFrame asynchronously
  on a separate WorkQueue. Once the NativeImage is ready, it asks BitmapImageSource
  to cache it on the main thread. BitmapImageSource will notifies the observer
  that a new frame is ready for rendering.

  BitmapImage: This is a sub-class of Image which mainly handles the layout and
  the drawing of a bitmap image to a GraphicsContext.

An important change of this PR is the DecodingMode and AllowImageSubsampling are
calculated in advance before calling BitmapImage::draw(). So Settings are no
longer passed or updated by BitmapImage before calling its draw() method.

* LayoutTests/fast/images/async-image-background-image-repeated.html:
Make the frame decoding duration time longer than the animation duration time so
the decoding always finishes after the animation timer fires.

* LayoutTests/fast/images/async-image-composited-show.html:
Make this test do the decoding asynchronously. The debug settings were missing.

* LayoutTests/fast/images/async-image-intersect-different-size-for-drawing-expected.txt:
If the decodingMode is Synchronous, no sizeForDrawing should be set.

* LayoutTests/fast/images/decode-render-animated-image-expected.html:
* LayoutTests/fast/images/decode-render-animated-image.html:
Make the test relies solely on the `decode()` method instead of the mix between
the debug event "webkitImageFrameReady" and the `decode()` method.

* LayoutTests/platform/ios-wk2/fast/images/async-image-intersect-different-size-for-drawing-expected.txt:
If the decodingMode is Synchronous, no sizeForDrawing should be set.

* LayoutTests/platform/mac-wk1/TestExpectations:
* LayoutTests/platform/mac-wk2/TestExpectations:
* Source/WebCore/Modules/webcodecs/WebCodecsVideoFrame.cpp:
(WebCore::WebCodecsVideoFrame::create):
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/html/ImageBitmap.cpp:
* Source/WebCore/loader/ImageLoader.cpp:
(WebCore::ImageLoader::decode):
* Source/WebCore/loader/cache/CachedImage.cpp:
(WebCore::CachedImage::removeAllClientsWaitingForAsyncDecoding):
(WebCore::CachedImage::CachedImageObserver::canDestroyDecodedData const):
(WebCore::CachedImage::canDestroyDecodedData const):
(WebCore::CachedImage::CachedImageObserver::canDestroyDecodedData): Deleted.
(WebCore::CachedImage::canDestroyDecodedData): Deleted.
* Source/WebCore/loader/cache/CachedImage.h:
* Source/WebCore/loader/cache/CachedImageClient.h:
(WebCore::CachedImageClient::canDestroyDecodedData const):
(WebCore::CachedImageClient::canDestroyDecodedData): Deleted.
* Source/WebCore/platform/cocoa/DragImageCocoa.mm:
(WebCore::createDragImageFromImage):
* Source/WebCore/platform/graphics/BitmapImage.cpp:
(WebCore::BitmapImage::create):
(WebCore::BitmapImage::BitmapImage):
(WebCore::BitmapImage::dataChanged):
(WebCore::BitmapImage::destroyDecodedData):
(WebCore::BitmapImage::draw):
(WebCore::BitmapImage::drawPattern):
(WebCore::BitmapImage::dump const):
(WebCore::BitmapImage::~BitmapImage): Deleted.
(WebCore::BitmapImage::destroyDecodedDataIfNecessary): Deleted.
(WebCore::BitmapImage::setCurrentFrameDecodingStatusIfNecessary): Deleted.
(WebCore::BitmapImage::nativeImageAtIndexCacheIfNeeded): Deleted.
(WebCore::BitmapImage::nativeImage): Deleted.
(WebCore::BitmapImage::nativeImageForCurrentFrame): Deleted.
(WebCore::BitmapImage::preTransformedNativeImageForCurrentFrame): Deleted.
(WebCore::BitmapImage::notSolidColor): Deleted.
(WebCore::drawNativeImage): Deleted.
(WebCore::BitmapImage::shouldAnimate const): Deleted.
(WebCore::BitmapImage::canAnimate const): Deleted.
(WebCore::BitmapImage::canUseAsyncDecodingForLargeImages const): Deleted.
(WebCore::BitmapImage::shouldUseAsyncDecodingForAnimatedImages const): Deleted.
(WebCore::BitmapImage::clearTimer): Deleted.
(WebCore::BitmapImage::startTimer): Deleted.
(WebCore::BitmapImage::subsamplingLevelForScaleFactor): Deleted.
(WebCore::BitmapImage::canDestroyDecodedData): Deleted.
(WebCore::BitmapImage::internalStartAnimation): Deleted.
(WebCore::BitmapImage::advanceAnimation): Deleted.
(WebCore::BitmapImage::internalAdvanceAnimation): Deleted.
(WebCore::BitmapImage::isAnimating const): Deleted.
(WebCore::BitmapImage::stopAnimation): Deleted.
(WebCore::BitmapImage::resetAnimation): Deleted.
(WebCore::BitmapImage::decode): Deleted.
(WebCore::BitmapImage::callDecodingCallbacks): Deleted.
(WebCore::BitmapImage::imageFrameAvailableAtIndex): Deleted.
(WebCore::BitmapImage::colorSpace): Deleted.
(WebCore::BitmapImage::decodeCountForTesting const): Deleted.
(WebCore::BitmapImage::lastDecodingOptions const): Deleted.
* Source/WebCore/platform/graphics/BitmapImage.h:
* Source/WebCore/platform/graphics/BitmapImageSource.cpp: Added.
(WebCore::BitmapImageSource::create):
(WebCore::BitmapImageSource::BitmapImageSource):
(WebCore::BitmapImageSource::decoder const):
(WebCore::BitmapImageSource::frameAnimator const):
(WebCore::BitmapImageSource::workQueue const):
(WebCore::BitmapImageSource::encodedDataStatusChanged):
(WebCore::BitmapImageSource::dataChanged):
(WebCore::BitmapImageSource::destroyDecodedData):
(WebCore::BitmapImageSource::decodedSizeChanged):
(WebCore::BitmapImageSource::decodedSizeIncreased):
(WebCore::BitmapImageSource::decodedSizeDecreased):
(WebCore::BitmapImageSource::decodedSizeReset):
(WebCore::BitmapImageSource::destroyNativeImageAtIndex):
(WebCore::BitmapImageSource::canDestroyDecodedData const):
(WebCore::BitmapImageSource::didDecodeProperties):
(WebCore::BitmapImageSource::clearFrameBufferCache):
(WebCore::BitmapImageSource::setData):
(WebCore::BitmapImageSource::resetData):
(WebCore::BitmapImageSource::startAnimation):
(WebCore::BitmapImageSource::stopAnimation):
(WebCore::BitmapImageSource::resetAnimation):
(WebCore::BitmapImageSource::isAnimated const):
(WebCore::BitmapImageSource::isAnimating const):
(WebCore::BitmapImageSource::isAnimationAllowed const):
(WebCore::BitmapImageSource::hasEverAnimated const):
(WebCore::BitmapImageSource::isLargeForDecoding const):
(WebCore::BitmapImageSource::isDecodingWorkQueueIdle const):
(WebCore::BitmapImageSource::stopDecodingWorkQueue):
(WebCore::BitmapImageSource::isPendingDecodingAtIndex const):
(WebCore::BitmapImageSource::isCompatibleWithOptionsAtIndex const):
(WebCore::BitmapImageSource::decode):
(WebCore::BitmapImageSource::callDecodeCallbacks):
(WebCore::BitmapImageSource::imageFrameAtIndexAvailable):
(WebCore::BitmapImageSource::imageFrameDecodeAtIndexHasFinished):
(WebCore::BitmapImageSource::currentFrameIndex const):
(WebCore::BitmapImageSource::cacheMetadataAtIndex):
(WebCore::BitmapImageSource::cacheNativeImageAtIndex):
(WebCore::BitmapImageSource::frameAtIndex const):
(WebCore::BitmapImageSource::frameAtIndexCacheIfNeeded):
(WebCore::BitmapImageSource::requestNativeImageAtIndex):
(WebCore::BitmapImageSource::requestNativeImageAtIndexIfNeeded):
(WebCore::BitmapImageSource::nativeImageAtIndexCacheIfNeeded):
(WebCore::BitmapImageSource::nativeImageAtIndexRequestIfNeeded):
(WebCore::BitmapImageSource::nativeImageAtIndexForDrawing):
(WebCore::BitmapImageSource::currentNativeImageForDrawing):
(WebCore::BitmapImageSource::nativeImageAtIndex):
(WebCore::BitmapImageSource::preTransformedNativeImageAtIndex):
(WebCore::BitmapImageSource::imageMetadata const):
(WebCore::BitmapImageSource::primaryNativeImageMetadata const):
(WebCore::BitmapImageSource::primaryImageFrameMetadata const):
(WebCore::BitmapImageSource::encodedDataStatus const):
(WebCore::BitmapImageSource::size const):
(WebCore::BitmapImageSource::sourceSize const):
(WebCore::BitmapImageSource::densityCorrectedSize const):
(WebCore::BitmapImageSource::orientation const):
(WebCore::BitmapImageSource::primaryFrameIndex const):
(WebCore::BitmapImageSource::frameCount const):
(WebCore::BitmapImageSource::repetitionCount const):
(WebCore::BitmapImageSource::colorSpace const):
(WebCore::BitmapImageSource::singlePixelSolidColor const):
(WebCore::BitmapImageSource::uti const):
(WebCore::BitmapImageSource::filenameExtension const):
(WebCore::BitmapImageSource::accessibilityDescription const):
(WebCore::BitmapImageSource::hotSpot const):
(WebCore::BitmapImageSource::maximumSubsamplingLevel const):
(WebCore::BitmapImageSource::subsamplingLevelForScaleFactor):
(WebCore::BitmapImageSource::frameSizeAtIndex const):
(WebCore::BitmapImageSource::frameDurationAtIndex const):
(WebCore::BitmapImageSource::frameOrientationAtIndex const):
(WebCore::BitmapImageSource::frameDecodingStatusAtIndex const):
(WebCore::BitmapImageSource::sourceUTF8 const):
(WebCore::BitmapImageSource::setMinimumDecodingDurationForTesting):
(WebCore::BitmapImageSource::dump const):
* Source/WebCore/platform/graphics/BitmapImageSource.h: Added.
(WebCore::BitmapImageSource::decodedSize const):
(WebCore::BitmapImageSource::nativeImageAtIndexCacheIfNeeded):
(WebCore::BitmapImageSource::decodeCountForTesting const):
* Source/WebCore/platform/graphics/Image.cpp:
(WebCore::Image::drawPattern):
(WebCore::Image::drawTiled):
* Source/WebCore/platform/graphics/Image.h:
(WebCore::Image::frameCount const):
(WebCore::Image::nativeImageAtIndex):
(WebCore::Image::currentNativeImage):
(WebCore::Image::currentPreTransformedNativeImage):
(WebCore::Image::hasSolidColor):
(WebCore::Image::singlePixelSolidColor const):
(WebCore::Image::nativeImageForCurrentFrame): Deleted.
(WebCore::Image::preTransformedNativeImageForCurrentFrame): Deleted.
(WebCore::Image::nativeImageAtIndexCacheIfNeeded): Deleted.
(WebCore::Image::notSolidColor): Deleted.
* Source/WebCore/platform/graphics/ImageAdapter.cpp:
(WebCore::ImageAdapter::nativeImageOfSize):
(WebCore::ImageAdapter::allNativeImages):
* Source/WebCore/platform/graphics/ImageDecoder.h:
(WebCore::ImageDecoder::frameOrientationAtIndex const):
(WebCore::ImageDecoder::densityCorrectedSizeAtIndex const):
* Source/WebCore/platform/graphics/ImageFrame.cpp:
(WebCore::ImageFrame::ImageFrame):
(WebCore::ImageFrame::size const): Deleted.
(WebCore::ImageFrame::singlePixelSolidColor const): Deleted.
* Source/WebCore/platform/graphics/ImageFrame.h:
(WebCore::ImageFrame::setSize):
(WebCore::ImageFrame::size const):
(WebCore::ImageFrame::decodingOptions const):
* Source/WebCore/platform/graphics/ImageFrameAnimator.cpp: Added.
(WebCore::ImageFrameAnimator::create):
(WebCore::ImageFrameAnimator::ImageFrameAnimator):
(WebCore::ImageFrameAnimator::~ImageFrameAnimator):
(WebCore::ImageFrameAnimator::destroyDecodedData):
(WebCore::ImageFrameAnimator::startTimer):
(WebCore::ImageFrameAnimator::clearTimer):
(WebCore::ImageFrameAnimator::timerFired):
(WebCore::ImageFrameAnimator::imageFrameDecodeAtIndexHasFinished):
(WebCore::ImageFrameAnimator::startAnimation):
(WebCore::ImageFrameAnimator::advanceAnimation):
(WebCore::ImageFrameAnimator::stopAnimation):
(WebCore::ImageFrameAnimator::resetAnimation):
(WebCore::ImageFrameAnimator::isAnimationAllowed const):
(WebCore::ImageFrameAnimator::sourceUTF8 const):
(WebCore::ImageFrameAnimator::dump const):
* Source/WebCore/platform/graphics/ImageFrameAnimator.h: Added.
(WebCore::ImageFrameAnimator::isAnimating const):
(WebCore::ImageFrameAnimator::hasEverAnimated const):
(WebCore::ImageFrameAnimator::currentFrameIndex const):
(WebCore::ImageFrameAnimator::nextFrameIndex const):
* Source/WebCore/platform/graphics/ImageFrameWorkQueue.cpp: Added.
(WebCore::ImageFrameWorkQueue::create):
(WebCore::ImageFrameWorkQueue::ImageFrameWorkQueue):
(WebCore::ImageFrameWorkQueue::requestQueue):
(WebCore::ImageFrameWorkQueue::start):
(WebCore::ImageFrameWorkQueue::dispatch):
(WebCore::ImageFrameWorkQueue::stop):
(WebCore::ImageFrameWorkQueue::isPendingDecodingAtIndex const):
(WebCore::ImageFrameWorkQueue::dump const):
* Source/WebCore/platform/graphics/ImageFrameWorkQueue.h: Added.
(WebCore::ImageFrameWorkQueue::isIdle const):
(WebCore::ImageFrameWorkQueue::setMinimumDecodingDurationForTesting):
(WebCore::ImageFrameWorkQueue::protectedSource const):
(WebCore::ImageFrameWorkQueue::decodeQueue):
(WebCore::ImageFrameWorkQueue::minimumDecodingDurationForTesting const):
* Source/WebCore/platform/graphics/ImageObserver.h:
(WebCore::ImageObserver::canDestroyDecodedData const):
* Source/WebCore/platform/graphics/ImageSource.cpp:
(WebCore::ImageSource::primaryNativeImageForDrawing):
(WebCore::ImageSource::currentNativeImageForDrawing):
(WebCore::ImageSource::hasSolidColor const):
(WebCore::ImageSource::ImageSource): Deleted.
(WebCore::ImageSource::~ImageSource): Deleted.
(WebCore::ImageSource::ensureDecoderAvailable): Deleted.
(WebCore::ImageSource::setData): Deleted.
(WebCore::ImageSource::resetData): Deleted.
(WebCore::ImageSource::dataChanged): Deleted.
(WebCore::ImageSource::isAllDataReceived): Deleted.
(WebCore::ImageSource::destroyDecodedData): Deleted.
(WebCore::ImageSource::destroyIncompleteDecodedData): Deleted.
(WebCore::ImageSource::clearFrameBufferCache): Deleted.
(WebCore::ImageSource::encodedDataStatusChanged): Deleted.
(WebCore::ImageSource::decodedSizeChanged): Deleted.
(WebCore::ImageSource::decodedSizeIncreased): Deleted.
(WebCore::ImageSource::decodedSizeDecreased): Deleted.
(WebCore::ImageSource::decodedSizeReset): Deleted.
(WebCore::ImageSource::didDecodeProperties): Deleted.
(WebCore::ImageSource::growFrames): Deleted.
(WebCore::ImageSource::setNativeImage): Deleted.
(WebCore::ImageSource::cacheMetadataAtIndex): Deleted.
(WebCore::ImageSource::cachePlatformImageAtIndex): Deleted.
(WebCore::ImageSource::cachePlatformImageAtIndexAsync): Deleted.
(WebCore::ImageSource::decodingQueue): Deleted.
(WebCore::ImageSource::frameRequestQueue): Deleted.
(WebCore::ImageSource::canUseAsyncDecoding): Deleted.
(WebCore::ImageSource::startAsyncDecodingQueue): Deleted.
(WebCore::ImageSource::requestFrameAsyncDecodingAtIndex): Deleted.
(WebCore::ImageSource::isAsyncDecodingQueueIdle const): Deleted.
(WebCore::ImageSource::stopAsyncDecodingQueue): Deleted.
(WebCore::ImageSource::frameAtIndexCacheIfNeeded): Deleted.
(WebCore::ImageSource::clearMetadata): Deleted.
(WebCore::ImageSource::sourceURL const): Deleted.
(WebCore::ImageSource::mimeType const): Deleted.
(WebCore::ImageSource::expectedContentLength const): 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.
(WebCore::ImageSource::frameIsBeingDecodedAndIsCompatibleWithOptionsAtIndex): Deleted.
(WebCore::ImageSource::frameDecodingStatusAtIndex): Deleted.
(WebCore::ImageSource::frameHasAlphaAtIndex): Deleted.
(WebCore::ImageSource::frameHasFullSizeNativeImageAtIndex): Deleted.
(WebCore::ImageSource::frameHasDecodedNativeImageCompatibleWithOptionsAtIndex): Deleted.
(WebCore::ImageSource::frameSubsamplingLevelAtIndex): Deleted.
(WebCore::ImageSource::frameSizeAtIndex): Deleted.
(WebCore::ImageSource::frameBytesAtIndex): Deleted.
(WebCore::ImageSource::frameDurationAtIndex): Deleted.
(WebCore::ImageSource::frameOrientationAtIndex): Deleted.
(WebCore::ImageSource::createFrameImageAtIndex): Deleted.
(WebCore::ImageSource::frameImageAtIndex): Deleted.
(WebCore::ImageSource::frameImageAtIndexCacheIfNeeded): Deleted.
(WebCore::ImageSource::dump): Deleted.
* Source/WebCore/platform/graphics/ImageSource.h:
(WebCore::ImageSource::dataChanged):
(WebCore::ImageSource::destroyDecodedData):
(WebCore::ImageSource::startAnimation):
(WebCore::ImageSource::stopAnimation):
(WebCore::ImageSource::resetAnimation):
(WebCore::ImageSource::isAnimated const):
(WebCore::ImageSource::isAnimating const):
(WebCore::ImageSource::hasEverAnimated const):
(WebCore::ImageSource::isLargeForDecoding const):
(WebCore::ImageSource::stopDecodingWorkQueue):
(WebCore::ImageSource::decode):
(WebCore::ImageSource::currentFrameIndex const):
(WebCore::ImageSource::currentImageFrame):
(WebCore::ImageSource::currentNativeImage):
(WebCore::ImageSource::currentPreTransformedNativeImage):
(WebCore::ImageSource::nativeImageAtIndex):
(WebCore::ImageSource::sourceSize const):
(WebCore::ImageSource::hasDensityCorrectedSize const):
(WebCore::ImageSource::orientation const):
(WebCore::ImageSource::primaryFrameIndex const):
(WebCore::ImageSource::frameCount const):
(WebCore::ImageSource::uti const):
(WebCore::ImageSource::filenameExtension const):
(WebCore::ImageSource::accessibilityDescription const):
(WebCore::ImageSource::hotSpot const):
(WebCore::ImageSource::subsamplingLevelForScaleFactor):
(WebCore::ImageSource::frameDurationAtIndex const):
(WebCore::ImageSource::frameOrientationAtIndex const):
(WebCore::ImageSource::frameDecodingStatusAtIndex const):
(WebCore::ImageSource::decodeCountForTesting const):
(WebCore::ImageSource::setMinimumDecodingDurationForTesting):
(WebCore::ImageSource::setClearDecoderAfterAsyncFrameRequestForTesting):
(WebCore::ImageSource::setAsyncDecodingEnabledForTesting):
(WebCore::ImageSource::isAsyncDecodingEnabledForTesting const):
(WebCore::ImageSource::dump const):
(): Deleted.
* Source/WebCore/platform/graphics/NativeImage.h:
* Source/WebCore/platform/graphics/NativeImageSource.cpp: Copied from Source/WebCore/platform/graphics/ImageAdapter.cpp.
(WebCore::NativeImageSource::create):
(WebCore::NativeImageSource::NativeImageSource):
(WebCore::NativeImageSource::dump const):
* Source/WebCore/platform/graphics/NativeImageSource.h: Copied from Source/WebCore/platform/graphics/ImageAdapter.cpp.
* Source/WebCore/platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.h:
* Source/WebCore/platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.mm:
(WebCore::ImageDecoderAVFObjC::frameMetadataAtIndex const): Deleted.
(WebCore::ImageDecoderAVFObjC::frameAllowSubsamplingAtIndex const): Deleted.
* Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::setContentsToImage):
* Source/WebCore/platform/graphics/cairo/GraphicsContextGLCairo.cpp:
(WebCore::GraphicsContextGLImageExtractor::extractImage):
* Source/WebCore/platform/graphics/cairo/NativeImageCairo.cpp:
(WebCore::NativeImage::singlePixelSolidColor const):
* Source/WebCore/platform/graphics/cg/GraphicsContextGLCG.cpp:
(WebCore::GraphicsContextGLImageExtractor::extractImage):
* Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp:
(WebCore::ImageDecoderCG::frameOrientationAtIndex const):
(WebCore::ImageDecoderCG::densityCorrectedSizeAtIndex const):
(WebCore::ImageDecoderCG::frameMetadataAtIndex const): Deleted.
(WebCore::ImageDecoderCG::frameAllowSubsamplingAtIndex const): Deleted.
* Source/WebCore/platform/graphics/cg/ImageDecoderCG.h:
* Source/WebCore/platform/graphics/cg/NativeImageCG.cpp:
(WebCore::NativeImage::singlePixelSolidColor const):
* Source/WebCore/platform/graphics/gstreamer/ImageDecoderGStreamer.cpp:
(WebCore::ImageDecoderGStreamer::uti const): Deleted.
(WebCore::ImageDecoderGStreamer::frameMetadataAtIndex const): Deleted.
* Source/WebCore/platform/graphics/gstreamer/ImageDecoderGStreamer.h:
* Source/WebCore/platform/graphics/gtk/ImageAdapterGtk.cpp:
(WebCore::ImageAdapter::gdkPixbuf):
(WebCore::ImageAdapter::gdkTexture):
* Source/WebCore/platform/graphics/mac/ImageAdapterMac.mm:
(WebCore::ImageAdapter::snapshotNSImage):
* Source/WebCore/platform/graphics/skia/GraphicsContextGLSkia.cpp:
(WebCore::GraphicsContextGLImageExtractor::extractImage):
* Source/WebCore/platform/graphics/skia/NativeImageSkia.cpp:
(WebCore::NativeImage::singlePixelSolidColor const):
* Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp:
(WebCore::GraphicsLayerTextureMapper::setContentsToImage):
* Source/WebCore/platform/graphics/texmap/TextureMapperTile.cpp:
(WebCore::TextureMapperTile::updateContents):
* Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
(WebCore::CoordinatedGraphicsLayer::setContentsToImage):
* Source/WebCore/platform/gtk/DragImageGtk.cpp:
(WebCore::createDragImageFromImage):
* Source/WebCore/platform/image-decoders/ScalableImageDecoder.h:
* Source/WebCore/platform/win/cairo/DragImageWinCairo.cpp:
(WebCore::createDragImageFromImage):
* Source/WebCore/rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::decodingModeForImageDraw const):
* Source/WebCore/rendering/RenderElement.h:
* Source/WebCore/rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::isDirectlyCompositedImage const):
(WebCore::RenderLayerBacking::isUnscaledBitmapOnly const):
* Source/WebCore/svg/SVGFEImageElement.cpp:
(WebCore::SVGFEImageElement::createFilterEffect const):
* Source/WebCore/svg/graphics/SVGImageForContainer.cpp:
(WebCore::SVGImageForContainer::currentNativeImage):
(WebCore::SVGImageForContainer::nativeImageForCurrentFrame): Deleted.
* Source/WebCore/svg/graphics/SVGImageForContainer.h:
* Source/WebCore/testing/Internals.cpp:
(WebCore::Internals::setImageFrameDecodingDuration):
(WebCore::Internals::imageLastDecodingOptions):
* Source/WebKit/UIProcess/API/glib/IconDatabase.cpp:
(WebKit::IconDatabase::loadIconForPageURL):
(WebKit::IconDatabase::setIconForPageURL):
* Source/WebKit/UIProcess/API/wpe/WPEWebView.cpp:
(WKWPE::View::setCursor):
* Source/WebKit/WebProcess/GPU/media/RemoteImageDecoderAVF.cpp:
(WebKit::RemoteImageDecoderAVF::frameMetadataAtIndex const): Deleted.
(WebKit::RemoteImageDecoderAVF::frameAllowSubsamplingAtIndex const): Deleted.
* Source/WebKit/WebProcess/GPU/media/RemoteImageDecoderAVF.h:
* Tools/TestWebKitAPI/Tests/WebCore/SVGImageCasts.cpp:

Canonical link: https://commits.webkit.org/276827@main
  • Loading branch information
shallawa authored and Said Abou-Hallawa committed Mar 29, 2024
1 parent d113ccd commit 8b78e07
Show file tree
Hide file tree
Showing 70 changed files with 2,192 additions and 1,832 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@
var image = new Image();
image.onload = function() {
// Force async image decoding for this image.
if (window.internals)
if (window.internals) {
internals.setAsyncDecodingEnabledForTesting(image, true);
internals.setImageFrameDecodingDuration(image, 1.0);
}

// Change the background of the elements.
var elements = document.getElementsByClassName("image-background");
Expand Down
20 changes: 8 additions & 12 deletions LayoutTests/fast/images/async-image-composited-show.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@
background-repeat: no-repeat;
z-index: 0;
}
body {
opacity: 0;
background: rgba(0, 0, 0, 0);
}
body.background-loaded {
opacity: 1;
}
</style>
<body>
<div class="container">
Expand All @@ -29,23 +22,26 @@
<script>
if (window.testRunner) {
internals.clearMemoryCache();
internals.settings.setWebkitImageReadyEventEnabled(true);
internals.settings.setLargeImageAsyncDecodingEnabled(true);
testRunner.waitUntilDone();
}

var image = new Image();
image.onload = function() {
// Force very long async image decoding for this image.
if (window.internals)
internals.setImageFrameDecodingDuration(image, 5000);
if (window.internals) {
internals.setAsyncDecodingEnabledForTesting(image, true);
internals.setImageFrameDecodingDuration(image, 1.0);
}

// Change the background of the element.
let element = document.querySelector(".composited");
element.style.backgroundImage = 'url(' + image.src + ')';

// Show the body element and end the test.
document.body.classList.add("background-loaded");
testRunner.notifyDone();
element.addEventListener("webkitImageFrameReady", function() {
testRunner.notifyDone();
}, false);
};
image.src = "resources/green-400x400.png";
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE


decodingOptions = { decodingMode : Asynchronous, sizeForDrawing : { 500, 500 } }
decodingOptions = { decodingMode : Synchronous, sizeForDrawing : { 1000, 1000 } }
decodingOptions = { decodingMode : Synchronous }
PASS successfullyParsed is true

TEST COMPLETE
Expand Down
18 changes: 15 additions & 3 deletions LayoutTests/fast/images/decode-render-animated-image-expected.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
<style>
div {
.box {
width: 100px;
height: 100px;
display: inline-block;
}
.red-background {
background-color: red;
}
.green-background {
background-color: green;
}
.blue-background {
background-color: blue;
}
</style>
<body>
<p>This tests calling decode() for a animated image which is also an element in the DOM tree.</p>
<div></div>
<p>This tests calling decode() for a animated image which is also an element in the DOM tree.</p>
<div class="box red-background"></div>
<div class="box green-background"></div>
<div class="box blue-background"></div>
<div class="box red-background"></div>
</body>
54 changes: 24 additions & 30 deletions LayoutTests/fast/images/decode-render-animated-image.html
Original file line number Diff line number Diff line change
@@ -1,55 +1,49 @@
<style>
div {
width: 100px;
height: 100px;
}
canvas {
width: 100px;
height: 100px;
background-color: black;
}
img {
max-width: 100%;
max-height: 100%;
}
</style>
<body>
<p>This tests calling decode() for a animated image which is also an element in the DOM tree.</p>
<canvas></canvas>
<canvas id="canvas1"></canvas>
<canvas id="canvas2"></canvas>
<canvas id="canvas3"></canvas>
<canvas id="canvas4"></canvas>
<div></div>
<script>
if (window.internals && window.testRunner) {
internals.clearMemoryCache();
internals.settings.setAnimatedImageDebugCanvasDrawingEnabled(true);
internals.settings.setWebkitImageReadyEventEnabled(true);
testRunner.waitUntilDone();
}

var image = new Image;
var parent = document.querySelector("div");
parent.appendChild(image);

image.onload = (() => {
if (window.internals && window.testRunner) {
// Force layout and display so the image gets drawn. The image will draw its red frame.
document.body.offsetHeight;
testRunner.display();
function drawImageInCanvas(image, canvasId) {
var canvas = document.querySelector(canvasId);
var context = canvas.getContext("2d");
context.drawImage(image, 0, 0, canvas.width, canvas.height);
}

// Wait till decoding the next (green) frame finishes and the animation advances to it.
image.addEventListener("webkitImageFrameReady", function() {
setTimeout(function() {
// Request decoding the next (blue) frame. Wait till decoding finishes and the
// animation advances to it.
image.decode().then(() => {
var canvas = document.querySelector("canvas");
var context = canvas.getContext("2d");
context.drawImage(image, 0, 0, canvas.width, canvas.height);
parent.remove();
testRunner.notifyDone();
});
}, 0);
});
}
image.onload = (() => {
image.decode().then(() => {
drawImageInCanvas(image, "#canvas1");
return image.decode();
}).then(() => {
drawImageInCanvas(image, "#canvas2");
return image.decode();
}).then(() => {
drawImageInCanvas(image, "#canvas3");
return image.decode();
}).then(() => {
drawImageInCanvas(image, "#canvas4");
parent.remove();
testRunner.notifyDone();
});
});
image.src = "resources/animated-red-green-blue-repeat-2.gif";
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE


decodingOptions = { decodingMode : Asynchronous, sizeForDrawing : { 1000, 1000 } }
decodingOptions = { decodingMode : Synchronous, sizeForDrawing : { 2000, 2000 } }
decodingOptions = { decodingMode : Synchronous }
PASS successfullyParsed is true

TEST COMPLETE
Expand Down
1 change: 1 addition & 0 deletions LayoutTests/platform/mac-wk1/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -1474,6 +1474,7 @@ http/tests/inspector/network/fetch-response-body-304.html [ Skip ]
# Async image decoding is WK2 only
fast/images/async-image-background-change.html
fast/images/async-image-src-change.html
fast/images/async-image-composited-show.html
http/tests/multipart/multipart-async-image.html

css3/masking/mask-repeat-space-padding.html [ ImageOnlyFailure ]
Expand Down
2 changes: 0 additions & 2 deletions LayoutTests/platform/mac-wk2/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -1054,8 +1054,6 @@ webkit.org/b/208577 [ Release ] fast/hidpi/image-srcset-relative-svg-canvas.html

webkit.org/b/208590 [ Debug ] fast/events/beforeunload-prompt.html [ Pass Crash ]

webkit.org/b/208889 fast/images/decode-render-animated-image.html [ Pass ImageOnlyFailure ]

webkit.org/b/209006 imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/execution-timing/085.html [ Pass Failure ]

webkit.org/b/209077 svg/custom/object-sizing-explicit-width.xhtml [ Pass Failure ]
Expand Down
6 changes: 3 additions & 3 deletions Source/WebCore/Modules/webcodecs/WebCodecsVideoFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ ExceptionOr<Ref<WebCodecsVideoFrame>> WebCodecsVideoFrame::create(ScriptExecutio
if (!init.timestamp)
return Exception { ExceptionCode::TypeError, "timestamp is not provided"_s };

auto image = imageElement->cachedImage()->image()->nativeImageForCurrentFrame();
auto image = imageElement->cachedImage()->image()->currentNativeImage();
if (!image)
return Exception { ExceptionCode::InvalidStateError, "Image element has no video frame"_s };

Expand All @@ -181,7 +181,7 @@ ExceptionOr<Ref<WebCodecsVideoFrame>> WebCodecsVideoFrame::create(ScriptExecutio
if (!init.timestamp)
return Exception { ExceptionCode::TypeError, "timestamp is not provided"_s };

auto image = imageElement->cachedImage()->image()->nativeImageForCurrentFrame();
auto image = imageElement->cachedImage()->image()->currentNativeImage();
if (!image)
return Exception { ExceptionCode::InvalidStateError, "Image element has no video frame"_s };

Expand All @@ -191,7 +191,7 @@ ExceptionOr<Ref<WebCodecsVideoFrame>> WebCodecsVideoFrame::create(ScriptExecutio
if (!init.timestamp)
return Exception { ExceptionCode::TypeError, "timestamp is not provided"_s };

auto image = cssImage->image()->image()->nativeImageForCurrentFrame();
auto image = cssImage->image()->image()->currentNativeImage();
if (!image)
return Exception { ExceptionCode::InvalidStateError, "CSS Image has no video frame"_s };

Expand Down
4 changes: 4 additions & 0 deletions Source/WebCore/Sources.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2247,6 +2247,7 @@ platform/graphics/AlphaPremultiplication.cpp
platform/graphics/AnimationFrameRate.cpp
platform/graphics/BifurcatedGraphicsContext.cpp
platform/graphics/BitmapImage.cpp
platform/graphics/BitmapImageSource.cpp
platform/graphics/ByteArrayPixelBuffer.cpp
platform/graphics/CachedSubimage.cpp
platform/graphics/CodecUtilities.cpp
Expand Down Expand Up @@ -2318,6 +2319,8 @@ platform/graphics/ImageBufferBackend.cpp
platform/graphics/ImageBufferPipe.cpp
platform/graphics/ImageDecoder.cpp
platform/graphics/ImageFrame.cpp
platform/graphics/ImageFrameAnimator.cpp
platform/graphics/ImageFrameWorkQueue.cpp
platform/graphics/ImagePaintingOptions.cpp
platform/graphics/ImageSource.cpp
platform/graphics/InbandGenericCue.cpp
Expand All @@ -2338,6 +2341,7 @@ platform/graphics/Model.cpp
platform/graphics/NamedImageGeneratedImage.cpp
platform/graphics/NullImageBufferBackend.cpp
platform/graphics/NativeImage.cpp
platform/graphics/NativeImageSource.cpp
platform/graphics/Path.cpp
platform/graphics/PathImpl.cpp
platform/graphics/PathSegment.cpp
Expand Down
18 changes: 18 additions & 0 deletions Source/WebCore/WebCore.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2807,6 +2807,7 @@
7272D337292F818E00F74D99 /* FilterStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = 7272D336292F767D00F74D99 /* FilterStyle.h */; settings = {ATTRIBUTES = (Private, ); }; };
727610562988B09800897621 /* ApplePayButtonPart.h in Headers */ = {isa = PBXBuildFile; fileRef = 72F8898A29887AB900A6E07A /* ApplePayButtonPart.h */; settings = {ATTRIBUTES = (Private, ); }; };
727A7F3A24078B84004D2931 /* ImageBufferIOSurfaceBackend.h in Headers */ = {isa = PBXBuildFile; fileRef = 72BAC3AB23E1E544008D741C /* ImageBufferIOSurfaceBackend.h */; settings = {ATTRIBUTES = (Private, ); }; };
72854E692B6987B700E0181A /* NativeImageSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 72854E5D2B6987B300E0181A /* NativeImageSource.h */; };
7287A84029879CF2004A50E2 /* SearchFieldResultsPart.h in Headers */ = {isa = PBXBuildFile; fileRef = 7287A83A29879695004A50E2 /* SearchFieldResultsPart.h */; settings = {ATTRIBUTES = (Private, ); }; };
728D4791279A48B700BA7C0E /* FilterEffectApplier.h in Headers */ = {isa = PBXBuildFile; fileRef = 72A13A9F274C5CC700E2A88E /* FilterEffectApplier.h */; settings = {ATTRIBUTES = (Private, ); }; };
72963B6D29510A38004FF6FB /* TextAreaPart.h in Headers */ = {isa = PBXBuildFile; fileRef = 72963B6C29510287004FF6FB /* TextAreaPart.h */; settings = {ATTRIBUTES = (Private, ); }; };
Expand Down Expand Up @@ -13092,6 +13093,14 @@
727AFED31A2EA6A0000442E8 /* EXTsRGB.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = EXTsRGB.idl; sourceTree = "<group>"; };
728168B22AA024B9005864CB /* SVGResourceImage.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SVGResourceImage.cpp; sourceTree = "<group>"; };
728168B32AA024B9005864CB /* SVGResourceImage.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGResourceImage.h; sourceTree = "<group>"; };
72854E5C2B6987B300E0181A /* ImageFrameAnimator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageFrameAnimator.cpp; sourceTree = "<group>"; };
72854E5D2B6987B300E0181A /* NativeImageSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NativeImageSource.h; sourceTree = "<group>"; };
72854E5E2B6987B300E0181A /* ImageFrameAnimator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageFrameAnimator.h; sourceTree = "<group>"; };
72854E602B6987B400E0181A /* ImageFrameWorkQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageFrameWorkQueue.cpp; sourceTree = "<group>"; };
72854E612B6987B400E0181A /* NativeImageSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NativeImageSource.cpp; sourceTree = "<group>"; };
72854E622B6987B500E0181A /* ImageFrameWorkQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageFrameWorkQueue.h; sourceTree = "<group>"; };
72854E662B6987B600E0181A /* BitmapImageSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BitmapImageSource.h; sourceTree = "<group>"; };
72854E672B6987B600E0181A /* BitmapImageSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BitmapImageSource.cpp; sourceTree = "<group>"; };
7287A83A29879695004A50E2 /* SearchFieldResultsPart.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SearchFieldResultsPart.h; sourceTree = "<group>"; };
7287A83B298797E9004A50E2 /* SearchFieldResultsMac.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = SearchFieldResultsMac.mm; sourceTree = "<group>"; };
7287A83C298797E9004A50E2 /* SearchFieldResultsMac.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SearchFieldResultsMac.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -32584,6 +32593,8 @@
2DD87149265F4365005F997C /* BifurcatedGraphicsContext.h */,
A89943270B42338700D7C802 /* BitmapImage.cpp */,
A89943260B42338700D7C802 /* BitmapImage.h */,
72854E672B6987B600E0181A /* BitmapImageSource.cpp */,
72854E662B6987B600E0181A /* BitmapImageSource.h */,
72C11DAB28492A9200E826DD /* ByteArrayPixelBuffer.cpp */,
72C11DAC28492A9200E826DD /* ByteArrayPixelBuffer.h */,
72C172102983717500136E02 /* CachedSubimage.cpp */,
Expand Down Expand Up @@ -32762,6 +32773,10 @@
1D47658D25CCA778007AF312 /* ImageDecoderIdentifier.h */,
5576A5621D88A70800CCC04C /* ImageFrame.cpp */,
5576A5631D88A70800CCC04C /* ImageFrame.h */,
72854E5C2B6987B300E0181A /* ImageFrameAnimator.cpp */,
72854E5E2B6987B300E0181A /* ImageFrameAnimator.h */,
72854E602B6987B400E0181A /* ImageFrameWorkQueue.cpp */,
72854E622B6987B500E0181A /* ImageFrameWorkQueue.h */,
BC7F44A70B9E324E00A9D081 /* ImageObserver.h */,
A8748D6612CC3763001FBA41 /* ImageOrientation.h */,
7B0C389D2ACED2F000F1FDDC /* ImagePaintingOptions.cpp */,
Expand Down Expand Up @@ -32825,6 +32840,8 @@
314BE3A51B3103FB00141982 /* NamedImageGeneratedImage.h */,
7252396B254CADC200F5FB15 /* NativeImage.cpp */,
55A336F61D8209F40022C4C7 /* NativeImage.h */,
72854E612B6987B400E0181A /* NativeImageSource.cpp */,
72854E5D2B6987B300E0181A /* NativeImageSource.h */,
2DA397E3265C737400468F33 /* NullGraphicsContext.h */,
7B0E6DC92AB463E4005189E8 /* NullImageBufferBackend.cpp */,
7B0E6DC82AB463E4005189E8 /* NullImageBufferBackend.h */,
Expand Down Expand Up @@ -41095,6 +41112,7 @@
A818721E0977D3C0005826D9 /* NameNodeList.h in Headers */,
3227A93128BD744C00BC2697 /* Namespace.h in Headers */,
726D56E3253AE3660002EF90 /* NativeImage.h in Headers */,
72854E692B6987B700E0181A /* NativeImageSource.h in Headers */,
83B2D1751B8BCD6A00A02E47 /* NativeNodeFilter.h in Headers */,
E10B9B6C0B747599003ED890 /* NativeXPathNSResolver.h in Headers */,
93CCF0270AF6C52900018E89 /* NavigationAction.h in Headers */,
Expand Down
1 change: 0 additions & 1 deletion Source/WebCore/html/ImageBitmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,6 @@ class ImageBitmapImageObserver final : public ImageObserver {

void didDraw(const Image&) override { }

bool canDestroyDecodedData(const Image&) override { return true; }
void imageFrameAvailable(const Image&, ImageAnimatingState, const IntRect* = nullptr, DecodingStatus = DecodingStatus::Invalid) override { }
void changedInRect(const Image&, const IntRect* = nullptr) override { }
void scheduleRenderingUpdate(const Image&) override { }
Expand Down
9 changes: 7 additions & 2 deletions Source/WebCore/loader/ImageLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,8 +557,13 @@ void ImageLoader::decode()
resolveDecodePromises();
return;
}
bitmapImage->decode([promises = WTFMove(m_decodingPromises)]() mutable {
resolvePromises(promises);

bitmapImage->decode([promises = WTFMove(m_decodingPromises)](DecodingStatus decodingStatus) mutable {
ASSERT(decodingStatus != DecodingStatus::Decoding);
if (decodingStatus == DecodingStatus::Invalid)
rejectPromises(promises, "Decoding error."_s);
else
resolvePromises(promises);
});
}

Expand Down
8 changes: 5 additions & 3 deletions Source/WebCore/loader/cache/CachedImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,12 @@ void CachedImage::removeAllClientsWaitingForAsyncDecoding()
{
if (m_clientsWaitingForAsyncDecoding.isEmptyIgnoringNullReferences() || !hasImage())
return;

RefPtr bitmapImage = dynamicDowncast<BitmapImage>(image());
if (!bitmapImage)
return;
bitmapImage->stopAsyncDecodingQueue();
bitmapImage->stopDecodingWorkQueue();

for (auto& client : m_clientsWaitingForAsyncDecoding)
client.imageChanged(this);
m_clientsWaitingForAsyncDecoding.clear();
Expand Down Expand Up @@ -438,7 +440,7 @@ void CachedImage::CachedImageObserver::didDraw(const Image& image)
cachedImage->didDraw(image);
}

bool CachedImage::CachedImageObserver::canDestroyDecodedData(const Image& image)
bool CachedImage::CachedImageObserver::canDestroyDecodedData(const Image& image) const
{
for (CachedResourceHandle cachedImage : m_cachedImages) {
if (&image != cachedImage->image())
Expand Down Expand Up @@ -680,7 +682,7 @@ void CachedImage::didDraw(const Image& image)
CachedResource::didAccessDecodedData(timeStamp);
}

bool CachedImage::canDestroyDecodedData(const Image& image)
bool CachedImage::canDestroyDecodedData(const Image& image) const
{
if (&image != m_image)
return false;
Expand Down
4 changes: 2 additions & 2 deletions Source/WebCore/loader/cache/CachedImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class CachedImage final : public CachedResource {
void decodedSizeChanged(const Image&, long long delta) final;
void didDraw(const Image&) final;

bool canDestroyDecodedData(const Image&) final;
bool canDestroyDecodedData(const Image&) const final;
void imageFrameAvailable(const Image&, ImageAnimatingState, const IntRect* changeRect = nullptr, DecodingStatus = DecodingStatus::Invalid) final;
void changedInRect(const Image&, const IntRect*) final;
void scheduleRenderingUpdate(const Image&) final;
Expand All @@ -174,7 +174,7 @@ class CachedImage final : public CachedResource {
void encodedDataStatusChanged(const Image&, EncodedDataStatus);
void decodedSizeChanged(const Image&, long long delta);
void didDraw(const Image&);
bool canDestroyDecodedData(const Image&);
bool canDestroyDecodedData(const Image&) const;
void imageFrameAvailable(const Image&, ImageAnimatingState, const IntRect* changeRect = nullptr, DecodingStatus = DecodingStatus::Invalid);
void changedInRect(const Image&, const IntRect*);
void scheduleRenderingUpdate(const Image&);
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/loader/cache/CachedImageClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class CachedImageClient : public CachedResourceClient {
// If not null, the IntRect is the changed rect of the image.
virtual void imageChanged(CachedImage*, const IntRect* = nullptr) { }

virtual bool canDestroyDecodedData() { return true; }
virtual bool canDestroyDecodedData() const { return true; }

// Called when a new decoded frame for a large image is available or when an animated image is ready to advance to the next frame.
virtual VisibleInViewportState imageFrameAvailable(CachedImage& image, ImageAnimatingState, const IntRect* changeRect) { imageChanged(&image, changeRect); return VisibleInViewportState::No; }
Expand Down
Loading

0 comments on commit 8b78e07

Please sign in to comment.