-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cherry-pick 9084db41d592. rdar://problem/107371244
Refactor Canvas noise injection logic and improve support for gradients in post-processed ImageData https://bugs.webkit.org/show_bug.cgi?id=255993 rdar://107371244 Reviewed by Kimmo Kinnunen. Gradients present an interesting problem when post-processing canvas ImageData because tweaking colors result in significant visual anomalies. This change introduces some naive gradient detection by looking at all of the immediate neighbors of a pixel. We decide that a pixel is within a gradient if the current color is between its opposing adjacent colors (e.g., above and below, left and right, etc). If a color is decided to be within a gradient, then we set those adjacent colors as bounds within which we can tweak the current color. In addition, within this change, we move the noise injection logic into its own class, it removes the dependency on supplied colors for post-processing, and it reduces the magnitude of noise from ~5% to ~1%. * Source/WebCore/Headers.cmake: * Source/WebCore/Sources.txt: * Source/WebCore/WebCore.xcodeproj/project.pbxproj: * Source/WebCore/html/CanvasBase.cpp: (WebCore::CanvasBase::makeRenderingResultsAvailable): (WebCore::CanvasBase::didDraw): We clip the rect before passing it into CanvasNoiseInjection, and if the rect is std::nullopt then we pass in the entire canvas. (WebCore::CanvasBase::postProcessPixelBufferResults const): (WebCore::CanvasBase::postProcessDirtyCanvasBuffer const): Deleted. * Source/WebCore/html/CanvasBase.h: * Source/WebCore/html/CanvasNoiseInjection.cpp: Added. (WebCore::CanvasNoiseInjection::updateDirtyRect): (WebCore::isIndexInBounds): (WebCore::setTightnessBounds): (WebCore::getGradientNeighbors): (WebCore::CanvasNoiseInjection::postProcessDirtyCanvasBuffer): (WebCore::CanvasNoiseInjection::postProcessPixelBufferResults const): * Source/WebCore/html/CanvasNoiseInjection.h: Added. * Source/WebCore/html/HTMLCanvasElement.cpp: (WebCore::HTMLCanvasElement::getImageData): Originally-landed-as: 264019@main (bfc25dc). rdar://107371244 Identifier: 263769.34@safari-7616.1.14.10-branch
- Loading branch information
Showing
8 changed files
with
303 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.