WebKit
WebKit copied to clipboard
[Filters] Do not cache the result FilterImages of the SVGFilter if they will take too much memory
4f98e765b8cd500e857ba7f2562209206bd45cce
[Filters] Do not cache the result FilterImages of the SVGFilter if they will take too much memory https://bugs.webkit.org/show_bug.cgi?id=245230 Reviewed by NOBODY (OOPS!). Make all the filter apply() function take an optional FilterResults input. Allow caching the results only if the total estimated memory size is less than 100 MB. To better manage the life cycle of the ImageBufferAllocator when it is owned by FilterImage, FilterImage will now own a std::unique_ptr<ImageBufferAllocator> instead of owning a ImageBufferAllocator&. Creating a new ImageBufferAllocator for every FilterImage should very minimal impact on the allocated memory. Because FilterResults is now optional, we need to move the ImageBufferAllocator from FilterResults. Se we are adding an ImageBufferAllocatorFactory to Filter. ImageBufferAllocatorFactory can create createAllocator() which can be moved to the FilterImage when creating it. * LayoutTests/svg/filters/repeated-drop-shadow-effects-expected.svg: Added. * LayoutTests/svg/filters/repeated-drop-shadow-effects.svg: Added. * Source/WebCore/WebCore.xcodeproj/project.pbxproj: * Source/WebCore/platform/graphics/GraphicsContext.cpp: (WebCore::GraphicsContext::drawFilteredImageBuffer): * Source/WebCore/platform/graphics/GraphicsContext.h: * Source/WebCore/platform/graphics/ImageBuffer.cpp: (WebCore::ImageBuffer::filteredImage): * Source/WebCore/platform/graphics/ImageBufferAllocator.h: (WebCore::ImageBufferAllocatorFactory::createAllocator const): * Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp: (WebCore::DisplayList::DrawFilteredImageBuffer::apply): * Source/WebCore/platform/graphics/displaylists/DisplayListItems.h: * Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp: (WebCore::DisplayList::Recorder::drawFilteredImageBuffer): * Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h: * Source/WebCore/platform/graphics/filters/Filter.cpp: (WebCore::Filter::apply): * Source/WebCore/platform/graphics/filters/Filter.h: (WebCore::Filter::setAllocatorFactory): (WebCore::Filter::createAllocator const): * Source/WebCore/platform/graphics/filters/FilterEffect.cpp: (WebCore::FilterEffect::apply): * Source/WebCore/platform/graphics/filters/FilterEffect.h: * Source/WebCore/platform/graphics/filters/FilterEffectCollection.h: Renamed from Source/WebCore/platform/graphics/filters/FilterEffectVector.h. * Source/WebCore/platform/graphics/filters/FilterFunction.h: (WebCore::FilterFunction::apply): * Source/WebCore/platform/graphics/filters/FilterImage.cpp: (WebCore::FilterImage::create): (WebCore::FilterImage::FilterImage): (WebCore::FilterImage::imageBufferFromPixelBuffer): (WebCore::FilterImage::pixelBuffer): (WebCore::FilterImage::getPixelBuffer): (WebCore::FilterImage::copyPixelBuffer): * Source/WebCore/platform/graphics/filters/FilterImage.h: * Source/WebCore/platform/graphics/filters/FilterResults.cpp: (WebCore::FilterResults::FilterResults): Deleted. * Source/WebCore/platform/graphics/filters/FilterResults.h: (WebCore::FilterResults::allocator const): Deleted. * Source/WebCore/rendering/CSSFilter.cpp: (WebCore::CSSFilter::apply): * Source/WebCore/rendering/CSSFilter.h: * Source/WebCore/rendering/RenderLayerFilters.cpp: (WebCore::RenderLayerFilters::applyFilterEffect): * Source/WebCore/rendering/svg/RenderSVGResourceFilter.cpp: (WebCore::RenderSVGResourceFilter::postApplyResource): * Source/WebCore/svg/graphics/filters/SVGFilter.cpp: (WebCore::SVGFilter::buildExpression): (WebCore::SVGFilter::effectsOfType const): (WebCore::SVGFilter::canCacheResults const): (WebCore::SVGFilter::apply): * Source/WebCore/svg/graphics/filters/SVGFilter.h: * Source/WebKit/GPUProcess/graphics/ImageBufferShareableAllocator.h: (WebKit::ImageBufferShareableAllocatorFactory::ImageBufferShareableAllocatorFactory): * Source/WebKit/GPUProcess/graphics/RemoteDisplayListRecorder.cpp: (WebKit::RemoteDisplayListRecorder::drawFilteredImageBuffer): * Source/WebKit/Platform/IPC/FilterReference.h:
https://github.com/WebKit/WebKit/commit/4f98e765b8cd500e857ba7f2562209206bd45cce
EWS run on previous version of this PR (hash https://github.com/WebKit/WebKit/commit/1f04f35862cfd0cc8789f253098369abd085100e)
EWS run on previous version of this PR (hash https://github.com/WebKit/WebKit/commit/18c3a806c5f8177be23066e7149d757439dbbb48)
EWS run on previous version of this PR (hash https://github.com/WebKit/WebKit/commit/4f98e765b8cd500e857ba7f2562209206bd45cce)
@shallawa - Was just digging through old bugs to reproduce and notice this bug with PR and noticed that this passes all test but didn't landed. It would need rebase but just wanted to confirm that it is intentionally held back for other bits?
EWS run on previous version of this PR (hash https://github.com/WebKit/WebKit/commit/0efce1e63ee15e3585ced33b244f9c8e637c6ddf)
EWS run on current version of this PR (hash https://github.com/WebKit/WebKit/commit/9566658832da91c38dd7578b9b4e49f035467218)
Committed 264807@main (93ee37d30632): https://commits.webkit.org/264807@main
Reviewed commits have been landed. Closing PR #4390 and removing active labels.