Occluded items in a 2D canvas bleed into the edges of a clip
Reported by
vancamp....@gmail.com,
May 3 2017
|
||||
Issue descriptionUserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36 Steps to reproduce the problem: 1. Layer two things on top of each other in a 2D canvas context such that the foreground item completely occludes the background item. 2. Apply a clip to the canvas. 3. What is the expected behavior? The foreground should get clipped to the path, and the background should remain invisible behind the foreground. What went wrong? The edges of the background become visible along the clipped path. Did this work before? N/A Does this work in other browsers? Yes Chrome version: 58.0.3029.81 Channel: stable OS Version: 10.0 Flash Version: In Firefox, I get the expected result of a smooth yellow circle with no visible black bleeding through the edges. Edge and Safari both exhibit similar behavior, though with slightly different appearances to their bled edges.
,
May 3 2017
,
May 3 2017
Assigned to junov@ for triage as I'll be OoO soon.
,
May 8 2017
This is because of clip anti-aliasing. Clip anti-aliasing was enabled by default in Chrome 55 because it is generally a desirable behavior, and it matches other browsers. The bleeding that you observe is the result of successive draws being clipped individually, and the edge pixels that have fractional coverage are getting alpha-blended. We do no intend to backtrack on clip anti-aliasing since it is generally an improvement in rendering quality. For your use case, you can easily workaround the issue by applying the clip to the results of compositing the background and foreground. You can do this, for example, by using two canvases: 1) draw background object to canvas 1. 2) draw foreground object to canvas 1. 3) specify a clip path on canvas 2. 4) draw canvas 1 onto canvas 2 (drawImage). |
||||
►
Sign in to add a comment |
||||
Comment 1 by sureshkumari@chromium.org
, May 3 2017Owner: zakerinasab@chromium.org
Status: Assigned (was: Unconfirmed)