W3C home > Mailing lists > Public > whatwg@whatwg.org > July 2010

[whatwg] Canvas: clarification of compositing operations needed

From: David Flanagan <david@davidflanagan.com>
Date: Thu, 29 Jul 2010 10:04:05 -0700
Message-ID: <4C51B485.4050904@davidflanagan.com>
Tab Atkins Jr. wrote:
> On Wed, Jul 28, 2010 at 11:39 PM, David Flanagan
> <david at davidflanagan.com> wrote:
>> James Robinson wrote:
>>> For example, I think
>>> drawing a 20x20 image into a 500x500 canvas without scaling with a
>>> globalCompositeOperation of 'copy' should result in only the 20x20 region
>>> being cleared out, not the entire canvas.
>> Yikes!  It hadn't occurred to me that copy should behave that way.  But
>> you're right that that is what the spec requires.  Opera does it that way.
>>  Firefox, thankfully, does not.
>>
>> Perhaps independently of the debate over infinite bitmap vs. shape extents,
>> we can agree that "copy" is a special value that means "do not perform
>> compositing"
> 
> That value already exists - it's called "source-over". 

You've lost me.  Are we disagreeing over the meaning of "composite".  It 
seems to me that "source-over" is clearly doing compositing: the result 
pixel is a blend of the source and destination pixels.


  "copy" does
> some special compositing stuff no matter whether you do "global" or
> "local" compositing - try using 'copy' when the source has .1 opacity.

The "copy" operation does not blend pixels: the result pixel is just the 
source pixel.  So when try what you suggest and draw with almost 
transparent pixels using the copy operation, the result is almost 
transparent pixels, regardless of what was under them.  That, to me, 
means that no compositing is being done.  What am I missing here?  What 
kind of "special stuff" is going on with "copy" compositing?

I'd argue that "copy" is the 2nd most important compositing operation 
after "source-over". Everyone but Opera violates the spec and treats it 
as a "local" operation.  If I understand correctly, the reason that the 
spec can't be changed to define compositing as a local operation is that 
vendors can't agree on what "local" means w.r.t. antialiasing, shadows, 
etc.

But since "copy" is a really important value, I propose that we sidestep 
the larger issue and explicitly state that when globalCompositeOperation 
is set to "copy" it means "just draw the damn pixels like we used to do 
in the olden days before we got all fancy with alpha channels and 
stuff".  A refinement would be to add a new value "none" and make "copy" 
a synonym for "none".

	David
Received on Thursday, 29 July 2010 10:04:05 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:25 UTC