Re: [css-compositing] some proposals

On Tue, Nov 22, 2011 at 3:38 PM, Alex Danilo <alex@abbra.com> wrote:

> Hi Cyril,
>
> --Original Message--:
> >Hi Alex,
> >
> >Thank you for your answer. See my comments below.
> >
> >-----Original Message-----
> >From: Alex Danilo [mailto:alex@abbra.com]
> >Sent: Tuesday, 22 November 2011 1:01 PM
> >To: www-svg@w3.org; public-fx@w3.org
> >Subject: RE: [css-compositing] some proposals
> >
> >--
> >NB: Sorry for the spam www-svg (note to self: debug mailer agent;-(
> >--
> >Hi Cyril & Rik,
> >
> >        Sorry I've been a bit busy of late so following up now.
> >
> >        First, one thing that's been missed is that in Porter-Duff the
> alpha channel represents a mask. The crux of the original paper is
> representing what happens with shape overlap on a pixel and so in the
> compositing spec. we reproduce the 'square with 4 areas'
> >that has the top section multi-coloured, the left yellow, the right blue
> and the bottom white.
> >
> >        Those areas represent 0, A, B, and AB in the original P-D paper.
> >
> >        In the spec. further down where it says:
> >"The operation used to place objects onto the background is as follows"
> >
> >there are these equations:
> >Dca' = f(Sc, Dc) × Sa × Da  + Y × Sca × (1-Da)  + Z × Dca × (1-Sa)
> >Da'  =         X × Sa × Da  + Y × Sa × (1-Da)   + Z × Da × (1-Sa)
> >
> >        The Porter-Duff mode chosen affects X, Y, and Z.
> >
> >        The blend mode is f(Sc, Dc).
> >[Cyril] So I understand that the proposal to split the modes into two
> parts (P-D and blending) is purely syntactic sugar and it does not change
> the model, right?
>
> Correct.
>
> The model doesn't change but it's slightly more than syntactic
> sugar. By separating out the blending from the P-D you get more
> combinatorial possibilities that you couldn't do nicely if it
> was one property.
>
> >        So for example if you chose blend-mode:multiply, comp-op:src-in;
> you would get:
> >
> >f(Sc,Dc) = Sc × Dc
> >X        = 1
> >Y        = 0
> >Z        = 0
> >[Cyril] According to the current draft: src-in  is f(Sc,Dc)=Sc and X=1
> and Y=Z=0. Multiply is f(Sc,Dc)=Sc x Dc and X=Y=Z=1. So you are saying that
> when you use both the compositing and the blending modes, you keep the
> value of f(Sc,Dc) from the blending and you keep the X, Y, Z values from
> the compositing mode. It make sense but it's not obvious. I would have
> thought that you would somehow compose them. Anyway, I think that if we
> split the spec, the merging of equation needs to be documented.
>
> Yes.
>
> It's not obvious since there was only one property before.
> So I agree it needs to be documented, and in fact it's
> pretty simple once you work out what's really going on.
>
> Rik followed up with a similar message just now and says:
>
> --
> The model is that you calculate the blended image first
> (= f(Sc, Dc)) and then composite it with whatever mode was
> specified. The current spec always assumes that you do
> src-over with blending and that is changing.
> So in the new spec:
> - multiply becomes f(Sc,Dc) = Sc x Dc (no more x, y, z)
> - src-in becomes X = 1, Y = Z = 0 (no more f(Sc, Dc))
> --
>
> What he's really saying is that the AB (colored top section
> of the diagram) is calculated as the blending step, then the
> other areas are done using P-D.
>
> In P-D terms, the areas are _coverage_ over a pixel. The alpha
> channel is a convenience masquerading as a shape channel.
>
> If you imagine that the source and destination are two triangles
> that overlap the pixel - that is what is being shown. i.e. the
> area covered by source consists of a section of the pixel where
> there is no destination color, and a section where there is
> destination color and a section where it doesn't overlap
> the pixel. Same for the destination pixel coverage.
>
> The Porter-Duff terms refer to the part of source that has no
> overlap and so no blend is possible with the destination (the
> left yellow triangle); the destination color that has no
> source overlapping it (the right blue triangle); the area
> not covered by either source or destination (the white area
> at the bottom); and finally the area covered by source and
> destination color where blending of the colors happens (the
> multi-colored triangle at the top).
>
> So, what the blend modes do is alter the function of the
> color mix in the top triangle and that's it. There really
> isn't a conceptual first blend then second 'src-over' or
> whatever since there is only one color channel which ends
> up getting input from the blend function and the areas
> of source and destination that don't intersect.
>
> Clear as mud hey:-)
>
> I'm sure we can turn this discussion into something
> that is readable by general developers since that's
> what would be ideal.
>

Yes, once we figure out how it works, the hard part of explaining it in
layman's term will begin :-)

It would be nice to hear what the browser vendor think of the spec. I'm
intending on defining a CSS description for the compositing spec as well.
The keywords will most likely translate directly from SVG to CSS.

Rik

Received on Wednesday, 23 November 2011 05:07:22 UTC