CoreGraphics is Right After All

by Ed on September 23, 2008

A while back I wrote about a potential issue with compositing using Quartz. I’m happy to finally conclude that there in fact is no issue. Yes, Quartz does behave differently than Cairo, but I believe Quartz has the more consistent behavior throughout all its modes. I came to this realization after talking to the engineer who does the compositing work in Quartz.

The main difference is that Quartz will only ever touch pixels within the ‘clip’ of an object, whereas it seems that Cairo will touch pixels outside of it. After thinking about it for a bit this makes much more sense, and seems to be a much simpler thing to implement as well, so I’m not sure why Cairo seems to take the tack they do.

So for example, if you fill a circle in Quartz, only the pixels inside the realm of influence (the circular path itself) will have the Porter-Duff blending applied. This is why things look different in Safari and Firefox when using these modes in a canvas object.

I reported in my prior post that I thought that it should affect pixels outside the circle, but this no longer makes sense to me after talking with that engineer. Now, if you were to blit an image of the circle, the area of influence would be the image rect (intersected with any clip, obviously). Then you’d get results more like what you’d expect. So basically, once you know that fact, you can likely still do most of the things you’d want to do using these blend modes.

So in the end it just seems like limiting the blending to the effective clip area is the better method. It’s far simpler to implement, since much like painting the circle in say, source over, you only affect pixels inside the circle. Ever. And that is a constant through all composition modes. This makes it consistent and predictable.

So in the end, it’s right, as far as I’m concerned (and Apple, of course)!

{ 0 comments… add one now }

Leave a Comment

Previous post:

Next post: