# [cairo] Operator optimization based on source or dest opacity

Soeren Sandmann sandmann at daimi.au.dk
Fri Feb 29 19:24:52 PST 2008

```Hi Antoine,

> >- I really don't think it's necessary to have a separate
> >pixman_transformed_image_is_opaque(). For destination images, the
> >   transform and filter are always going to be NULL, so the
> > additional check is very quick.
>
> I'll trust you on this one, but where is this specified?

Not specified as such, but it's just not a useful thing to do, so
people won't. I can't imagine cairo ever does, for example. I don't
think it's worth complicating the code for this case.

> >- The if statement in pixman_transformed_image_is_opaque() is
> >difficult to follow for me. It's also broken in at least one case:
> >convolution filters can introduce translucency even when there
> >weren't any to begin with.
>
> How can a convolution filter introduce translucency in an opaque
> image that extends?

If the convolution has negative coefficients, then the alpha channel
of the pixel would get something subtracted from it.

> >   Also, I'm not confident that the pi/2 rotation transformation
> > check is correct. Doesn't it need the rotation to be around the center of
> >   the image?
>
> Any affine transform other than non pi/2-multiple rotations (and
> shears) are allowed, as long as we use a nearest filter. Whether the
> rotation is around the center of the image or not is irrelevant.

Suppose we have an image with REPEAT_NONE, a NEAREST filter, and this
affine transformation:

[ 1  0 -10 ]
[ 0  1 -10 ]
[ 0  0   1 ]

When we fetch (0, 0, 1), we get the source pixel at (-10, -10, 1),
which will be 0 since we have REPEAT_NONE. But the if statement in
your patch will claim that the image is opaque, as far as I can tell.

I am probably missing something here. What is special about
pi/2-multiple rotations? I could see pi-multiple rotations around the
center of the image being special since that would just turn the image
upside down and therefore not introduce any new blank pixels.

Soren
```