<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.6000.16640" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=515510307-01052008><FONT face=Arial size=2>Hey
all,</FONT></SPAN></DIV>
<DIV><SPAN class=515510307-01052008><FONT face=Arial size=2>I discussed this
already with cworth and am looking for feedback on this
issue.</FONT></SPAN></DIV>
<DIV><SPAN class=515510307-01052008><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=515510307-01052008><FONT face=Arial size=2>paint_with_alpha
will return an "incorrect" result when used with a SOURCE operator. According to
the doc, paint_with_alpha is <EM>"<FONT size=3><FONT face="Times New Roman">A
drawing operator that paints the current source everywhere within the current
clip region using a mask of constant alpha value </FONT><CODE>alpha</CODE><FONT
face="Times New Roman">. The effect is similar to </FONT></FONT></EM><A
class=link
href="http://www.cairographics.org/manual/cairo-cairo-t.html#cairo-paint"><CODE
class=function><FONT size=3><EM>cairo_paint()</EM></FONT></CODE></A><FONT
face="Times New Roman" size=3><EM>, but the drawing is faded out using the alpha
value."</EM></FONT></FONT></SPAN></DIV>
<DIV><SPAN class=515510307-01052008><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=515510307-01052008>So doing the following:</SPAN></DIV>
<DIV><SPAN class=515510307-01052008><FONT size=2>
<P>cairo_set_source_rgb (cr, 0.2, 0.6, 0.9);<BR></FONT><FONT
size=2>cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);<BR>cairo_paint_with_alpha
(cr, 0.5);</FONT></P>
<P><SPAN class=515510307-01052008><FONT face=Arial size=2>Should return a
blueish color with a 0.5 alpha all over the surface with no more trace of the
previous contents. Currently, the blueish color is being composited like an OVER
operator. This is because we avoid the SOURCE operator and replace it to
accomodate different backends. So we implement our own definition of SOURCE
which is:</FONT></SPAN></P><SPAN class=515510307-01052008>
<P><FONT color=#008000><FONT size=2>(src IN mask IN clip) ADD (dst OUT (mask IN
clip))<SPAN
class=515510307-01052008>
//see _clip_and_composite_source in
cairo-surface-fallback.c</SPAN></FONT></FONT></P>
<P><FONT><FONT face=Arial size=2><SPAN class=515510307-01052008>According to the
doc, in the paint_with_alpha case, this definition should actually
be:</SPAN></FONT></FONT></P>
<P><FONT><FONT size=2><SPAN class=515510307-01052008><FONT color=#008000>(src IN
mask IN clip) ADD (dst OUT clip)</FONT></SPAN></FONT></FONT></P>
<P><FONT><FONT face=Arial size=2><SPAN class=515510307-01052008>Carl and I came
up with a solution that I included in the attached patch. It works nicely and
corresponds to our doc. However it does worsen performance, which is already
terrible when compositing with a SOURCE operator. The performance benchmark
shows the paint_with_alpha-solid-rgb-source test is 10 times SLOWER than
the over equivalent (you'd expect SOURCE compositing to be faster than
OVER). Quartz is 40 times faster than pixman on that
test.</SPAN></FONT></FONT></P>
<P><FONT><FONT face=Arial size=2><SPAN class=515510307-01052008>This patch will
fix the rendering of paint_with_alpha, but we should look into improving the
performance of SOURCE compositing. I'm not sure how each backend interprets it,
but we shouldn't be penalizing all of them for variations. The
_clip_and_composite_source function really is painful to look at for such a
simple operation. Maybe we could have a composite_source function in the
backends, and fallback to pixman for the backends that don't support it the way
we define it. That would allow us to remove the
nasty:</SPAN></FONT></FONT></P><FONT><FONT><SPAN class=515510307-01052008>
<P><FONT face=Arial color=#0000ff size=2>if</FONT><FONT face=Arial size=2>
(mask) {<BR></FONT><FONT face=Arial color=#008000 size=2>/* These operators
aren't interpreted the same way by the backends;<BR>* they are implemented in
terms of other operators in cairo-gstate.c<BR>*/<BR></FONT><FONT face=Arial
size=2>assert (op != CAIRO_OPERATOR_SOURCE && op !=
CAIRO_OPERATOR_CLEAR);<BR>}</FONT></P>
<P><SPAN class=515510307-01052008><FONT face=Arial size=2>from
_cairo_surface_composite and get really good speed ups both in the backends and
in pixman.</FONT></SPAN></P></SPAN></FONT></FONT>
<P><FONT><FONT face=Arial size=2><SPAN class=515510307-01052008>Comments and
feedback welcome!<BR>Thanks,<BR></SPAN></FONT></FONT><FONT><FONT face=Arial
size=2><SPAN
class=515510307-01052008>Antoine</SPAN></FONT></FONT></P></SPAN></SPAN></DIV></BODY></HTML>