Why is ColorFunction called more than once for every color cell

I was trying to use a custom ColorFunction with Raster and I noticed it gets called seemingly a random number of times for each colour cell.

i=0;  mycolourfn[a_] := ( i++; Print[i, a]; RGBColor@Append[Take[RotateLeft[a], 3], Last[a]]);  Graphics[Raster[{ {{1, 0, 0, 1}, {0, 1, 0, 1}, {0, 0, 1, 1}},  {{1, 0, 0, 0.5}, {0, 1, 0, 0.5}, {0, 0, 1, 0.5}}},  ColorFunction -> mycolourfn]] 

1{1.,0.,0.,1.} 2{1.,0.,0.,1.} …. 20{0,1,0,0.5} 21{0,0,1,0.5}

So here mycolourfn gets called 21 times while there are only 6 colour cells and also a different number of times per colour cell. It seems completely random how many times mycolourfn gets called if you change the number of colour cells.

What I wanted to do was create a ColorFunction with a variable like i here, to keep track of what cell it was on and do something slightly different based on where it was. Of course, that didn’t quite work out properly. I realised a short while later that this sort of modification is probably best done on the data itself and then passing that to Raster instead of messing around with ColorFunction.

But I’m still curious. Why is it not called the same number of times as there are colour cells?