color_a sum_a now un-premultiply the alpha if sum_a color_r sum_r sum_

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
*color_a = sum_a;
// now un-premultiply the alpha
if (sum_a > 0.0) {
*color_r = sum_r / sum_a;
*color_g = sum_g / sum_a;
*color_b = sum_b / sum_a;
} else {
// it is all transparent, so don't care about the colors
// (let's make them ugly so bugs will be visible)
*color_r = 0.0;
*color_g = 1.0;
*color_b = 0.0;
}