RESOLVED FIXED 43213
ctx.clearRect improperly clears shadow
https://bugs.webkit.org/show_bug.cgi?id=43213
Summary ctx.clearRect improperly clears shadow
Matthew Delaney
Reported 2010-07-29 14:29:45 PDT
Per the canvas spec: "Shapes are painted without affecting the current path, and are subject to the clipping region, and, with the exception of clearRect(), also shadow effects, global alpha, and global composition operators." Currently, we're clearing the rect properly but also clearing the shadow (and apparently not properly neglecting the rest of the attributes as well).
Attachments
Patch (10.82 KB, patch)
2010-07-29 16:45 PDT, Matthew Delaney
no flags
Patch (11.53 KB, patch)
2010-07-30 13:09 PDT, Matthew Delaney
no flags
Patch (10.96 KB, patch)
2010-07-30 13:24 PDT, Matthew Delaney
no flags
Patch (10.97 KB, patch)
2010-07-30 15:58 PDT, Matthew Delaney
no flags
Patch (10.96 KB, patch)
2010-07-30 16:09 PDT, Matthew Delaney
no flags
Matthew Delaney
Comment 1 2010-07-29 16:45:07 PDT
Darin Adler
Comment 2 2010-07-29 20:43:45 PDT
Comment on attachment 63009 [details] Patch > + GraphicsContext* c = drawingContext(); I suggest the name "context" here instead of just "c". > + c->setShadow(FloatSize(width, -height), state().m_shadowBlur, state().m_shadowColor, DeviceColorSpace); I suggest just passing FloatSize(), 0, and Color::transparent instead of fetching the values we just set in state(). > + save(); > + setAllAttributesToDefault(); > willDraw(rect); > c->clearRect(rect); > + restore(); Does this extra work hurt performance? How much?
Matthew Delaney
Comment 3 2010-07-30 13:09:05 PDT
Darin Adler
Comment 4 2010-07-30 13:14:05 PDT
Comment on attachment 63095 [details] Patch > Index: LayoutTests/canvas/philip/tests/2d.composite.operation.clear.html > =================================================================== > --- LayoutTests/canvas/philip/tests/2d.composite.operation.clear.html (revision 64316) > +++ LayoutTests/canvas/philip/tests/2d.composite.operation.clear.html (working copy) > @@ -26,7 +26,7 @@ > _addTest(function(canvas, ctx) { > > ctx.globalCompositeOperation = 'xor'; > -ctx.globalCompositeOperation = 'clear'; > +ctx.globalCompositeOperation = 'foobar!'; Changing this test doesn't make a lot of sense given its name, and is separate from what you're doing here, so this should not be included in the patch.
Matthew Delaney
Comment 5 2010-07-30 13:24:01 PDT
Sorry, stray file from a different patch. And on the performance, I'm seeing a different of 2 usec on average for that block of code (save() to restore(), inclusive) increasing from 5 to 7 usec.
Matthew Delaney
Comment 6 2010-07-30 13:24:14 PDT
Oliver Hunt
Comment 7 2010-07-30 14:31:29 PDT
Comment on attachment 63097 [details] Patch r=me
WebKit Commit Bot
Comment 8 2010-07-30 15:45:40 PDT
Comment on attachment 63097 [details] Patch Rejecting patch 63097 from commit-queue. Failed to run "['WebKitTools/Scripts/build-webkit', '--debug']" exit_code: 1 Last 500 characters of output: bin/yacc /bin/sh -c /Users/eseidel/Projects/CommitQueue/WebKitBuild/WebCore.build/Debug/WebCore.build/Script-5DF50887116F3077005202AB.sh ** BUILD FAILED ** The following build commands failed: WebCore: Distributed-CompileC /Users/eseidel/Projects/CommitQueue/WebKitBuild/WebCore.build/Debug/WebCore.build/Objects-normal/i386/CanvasRenderingContext2D.o /Users/eseidel/Projects/CommitQueue/WebCore/html/canvas/CanvasRenderingContext2D.cpp normal i386 c++ com.apple.compilers.gcc.4_2 (1 failure) Full output: http://queues.webkit.org/results/3592638
Matthew Delaney
Comment 9 2010-07-30 15:58:16 PDT
Darin Adler
Comment 10 2010-07-30 16:00:45 PDT
Comment on attachment 63114 [details] Patch > + state().m_globalAlpha = (float)1.0; Our consensus on best practice is to just put "1" in cases like this. If you really want a float, then 1.0f is the way to do it. (float)1.0 is not preferred style. > + context->setAlpha((float)1.0); Ditto.
Matthew Delaney
Comment 11 2010-07-30 16:09:40 PDT
Matthew Delaney
Comment 12 2010-07-30 16:10:19 PDT
Gotcha. Here's the fix!
WebKit Commit Bot
Comment 13 2010-07-30 22:08:26 PDT
Comment on attachment 63115 [details] Patch Clearing flags on attachment: 63115 Committed r64407: <http://trac.webkit.org/changeset/64407>
WebKit Commit Bot
Comment 14 2010-07-30 22:08:30 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.