Closed Bug 743578 Opened 12 years ago Closed 9 years ago

Canvas: path with bezierCurveTo() does not always fill correctly

Categories

(Core :: Graphics, defect)

x86
All
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 1063486

People

(Reporter: jordan.osete, Unassigned)

References

Details

(Keywords: regression)

Attachments

(2 files)

Attached file canvas_curve_bug.htm
User Agent: Mozilla/5.0 (X11; Linux i686; rv:13.0) Gecko/20120406 Firefox/13.0a2
Build ID: 20120406042011

Steps to reproduce:

When filling a path with multiple bezierCurveTo(), it may not always fill the whole path, depending on the orientation of the curves. Please see testcase for details.
Comment on attachment 613193 [details]
canvas_curve_bug.htm

(Changed attachment mime type to text/html)
Attachment #613193 - Attachment mime type: text/plain → text/html
Might actually be a duplicate of bug 664383.
Regression window(with HWA off)
Cannot reproduce:
http://hg.mozilla.org/mozilla-central/rev/2968d19b0165
Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.3a5pre) Gecko/20100426 Minefield/3.7a5pre ID:20100426040533
Can reprodce:
http://hg.mozilla.org/mozilla-central/rev/f236632a9747
Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.3a5pre) Gecko/20100426 Minefield/3.7a5pre ID:20100426084628
Pushlog:
http://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=2968d19b0165&tochange=f236632a9747

Triggered by:
f236632a9747	Jeff Muizelaar — Bug 542605. Update cairo to 12d521df8acc483b2daa844d4f05dc2fe2765ba6. r=vlad,jwatt,bas Reland after fixing quartz related clipping bug and a bunch of other ones
Blocks: 542605
Status: UNCONFIRMED → NEW
Component: Untriaged → Graphics
Ever confirmed: true
Keywords: regression
OS: Linux → All
Product: Firefox → Core
QA Contact: untriaged → thebes
Version: 13 Branch → Trunk
By the way, it seems that if context.lineJoin is set to "round" or "bevel", the stroke is not correctly drawn either.
A simple workaround for the time being is to rewrite bezierCurveTo() so that it draws a single, extremely short straight line at the end of each curve, thus avoiding having two curves in a row.
It actually modifies very slightly the shape drawn, but the naked eye shouldn't tell the difference, as the straight line is very short.

function installWorkaroundBug743578()
{
    var c2dp = CanvasRenderingContext2D.prototype,
        oldBezier = c2dp.bezierCurveTo;
    c2dp.bezierCurveTo = function( a, b, c, d, g, h )
    {
        var alpha = 1/1000,
            e = alpha * c + ( 1 - alpha ) * g,
            f = alpha * d + ( 1 - alpha ) * h;
        oldBezier.call( this, a, b, c, d, e, f );
        this.lineTo( g, h );
    };
}
if( browser.isMozilla() )  // you might even want to detect the bug itself instead of the browser
{
    installWorkaroundBug743578();
}
The code was not changing current_point when adding the bounds for a curve. This caused us to compute the wrong bounds.

This has been fixed upstream a different way.
Attachment #653834 - Flags: review?(joe)
Comment on attachment 653834 [details] [diff] [review]
Don't forget to add the current point when computing the bounds

You'll need to add this to the patches too, and somehow mark it as not to be applied when we upgrade.
Attachment #653834 - Flags: review?(joe) → review+
1 year old patch.
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: