HTML Canvas clipping region is broken if shadows are present
Categories
(Core :: Graphics: Canvas2D, defect, P3)
Tracking
()
People
(Reporter: simon.sarris, Assigned: lsalzman)
References
(Regression)
Details
(Keywords: regression)
Attachments
(2 files)
(deleted),
text/html
|
Details | |
(deleted),
text/x-phabricator-request
|
dmeehan
:
approval-mozilla-beta+
|
Details |
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36
Steps to reproduce:
This can be easily reproduced with code such as:
<canvas id="canvas" style="border: solid 3px red; width:150px; height:150px;"></canvas>
<script>
var can = document.getElementById('canvas');
can.width = 300;
can.height = 300;
var ctx = can.getContext('2d');
ctx.scale(2,2); // higher density
ctx.shadowOffsetX = 24;
ctx.shadowOffsetY = 24;
ctx.shadowColor = 'blue';
ctx.shadowBlur = 20;
ctx.font = "24px sans-serif";
ctx.rect(40,40,40,40);
ctx.clip();
ctx.fillText("Some text", 50, 35);
ctx.fillRect(50,50,40,80);
<script>
You can see a live version of this bug, here: https://codepen.io/simonsarris/pen/YzEmLgo
I have also attached an .html file with commentary and a reference image for how it ought to look.
This is a serious bug for canvas users, so I suspect it may be a regression, but I have not looked at older versions of Firefox.
Actual results:
No clipping occurs.
Expected results:
Clipping.
Comment 1•3 years ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::Canvas: 2D' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Updated•3 years ago
|
Comment 2•3 years ago
|
||
Lee, looks like we might want to get an assignee on this. Also feel free to adjust the P&S if you feel it is inaccurate.
Assignee | ||
Comment 3•3 years ago
|
||
Does this happen only on Windows? Or other platforms? I can't reproduce on Linux.
Reporter | ||
Comment 4•3 years ago
|
||
Have only tested in Windows 10, where it fails. It may be Windows specific.
Assignee | ||
Comment 5•3 years ago
|
||
Seems like this bug dates back to the original implementation in bug 883004.
Comment 6•3 years ago
|
||
:bas.schouten, since you are the author of the regressor, bug 883004, could you take a look?
For more information, please visit auto_nag documentation.
Assignee | ||
Comment 7•3 years ago
|
||
DrawSurfaceWithShadow is supposed to ignore transforms but still support clipping.
It appears that DrawTargetD2D1 for some reason never actually implemented clipping.
The DrawImage calls on the DC just need to happen within the bounds of PrepareForDrawing
and FinalizeDrawing. Since PrepareForDrawing handles the overriding of the blend mode
via SetPrimitiveBlend, we need to use DrawImage with D2D1_COMPOSITE_MODE_SOURCE_OVER
so that it will blend appropriately.
Updated•3 years ago
|
Assignee | ||
Updated•3 years ago
|
Assignee | ||
Updated•3 years ago
|
Assignee | ||
Updated•3 years ago
|
Comment 10•3 years ago
|
||
Updated•3 years ago
|
Updated•3 years ago
|
Comment 11•3 years ago
|
||
bugherder |
Comment 12•3 years ago
|
||
The patch landed in nightly and beta is affected.
:lsalzman, is this bug important enough to require an uplift?
If not please set status_beta
to wontfix
.
For more information, please visit auto_nag documentation.
Assignee | ||
Comment 13•3 years ago
|
||
Comment on attachment 9267317 [details]
Bug 1758968 - Clip drawing in DrawTargetD2D1::DrawSurfaceWithShadow. r?jrmuizel
Beta/Release Uplift Approval Request
- User impact if declined: Broken clipping of shadows in Canvas2D on Windows.
- Is this code covered by automated tests?: Yes
- Has the fix been verified in Nightly?: Yes
- Needs manual test from QE?: No
- If yes, steps to reproduce:
- List of other uplifts needed: None
- Risk to taking this patch: Low
- Why is the change risky/not risky? (and alternatives if risky):
- String changes made/needed:
Comment 14•3 years ago
|
||
Comment on attachment 9267317 [details]
Bug 1758968 - Clip drawing in DrawTargetD2D1::DrawSurfaceWithShadow. r?jrmuizel
Approved for 99.0b4. Thanks.
Comment 15•3 years ago
|
||
bugherder uplift |
Updated•3 years ago
|
Description
•