wpt
wpt copied to clipboard
Generate globalAlpha effect via filters
Currently, there are two ways to produce an opacity effect in Canvas2D: set the globalAlpha property or use the opacity canvas filter. By unifying the paths for the two APIs, the resulting effects are guaranteed to be identical and are easier to maintain and debug. After reference and performance testing, it was decided to do the unification by producing the effect defined with globalAlpha via filters.
The new GetGlobalAlphaAsFilter method, added to CanvasRenderingContext2DState, creates an opacity PaintFilter the with the value specified by globalAlpha. The StateGetFilter method now can receive an additional argument to indicate whether to include this filter, in order to allow the use of this method to get the canvas filters defined by the user. When the argument is set to include the globalAlpha filter, the PaintFilter returned is the result of composing the regular user set filters with the one obtained with GetGlobalAlphaAsFilter. The inclusion of the globalAlpha value in the image_flags, which was the way in which the globalAlpha effect was applied previously, was removed.
Bug: 1344922 Change-Id: Id96acd1f9ae07d2cb3076d27503273ea7408b7a0 Reviewed-on: https://chromium-review.googlesource.com/3763215 WPT-Export-Revision: b1667ef5f64c29faaa55f487289c0386ca3cafd2