cy += 1;
}
} else {
- // Bits is calculated as the offset into the mask at the point {cx, cy} therfore, all
+ // Bits is calculated as the offset into the mask at the point {cx, cy} therefore, all
// addressing into the bit mask is relative to that point. Since this is an address
// calculated from a arbitrary bit in that byte, calculate the left most bit.
int bitsLeft = cx - ((cx - maskLeft) & 7);
/** SkBlitter and its subclasses are responsible for actually writing pixels
into memory. Besides efficiency, they handle clipping and antialiasing.
+ A SkBlitter subclass contains all the context needed to generate pixels
+ for the destination and how src/generated pixels map to the destination.
+ The coordinates passed to the blitX calls are in destination pixel space.
*/
class SkBlitter {
public:
/// Blit a horizontal run of antialiased pixels; runs[] is a *sparse*
/// zero-terminated run-length encoding of spans of constant alpha values.
+ /// The runs[] and antialias[] work together to represent long runs of pixels with the same
+ /// alphas. The runs[] contains the number of pixels with the same alpha, and antialias[]
+ /// contain the coverage value for that number of pixels. The runs[] (and antialias[]) are
+ /// encoded in a clever way. The runs array is zero terminated, and has enough entries for
+ /// each pixel plus one, in most cases some of the entries will not contain valid data. An entry
+ /// in the runs array contains the number of pixels (np) that have the same alpha value. The
+ /// next np value is found np entries away. For example, if runs[0] = 7, then the next valid
+ /// entry will by at runs[7]. The runs array and antialias[] are coupled by index. So, if the
+ /// np entry is at runs[45] = 12 then the alpha value can be found at antialias[45] = 0x88.
+ /// This would mean to use an alpha value of 0x88 for the next 12 pixels starting at pixel 45.
virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]) = 0;
/// Blit a vertical run of pixels with a constant alpha value.
return;
}
- if (mask.fFormat == SkMask::kBW_Format) {
- SkARGB32_BlendBW(fDevice, mask, clip, fPMColor, SkAlpha255To256(255 - fSrcA));
- } else if (SkMask::kARGB32_Format == mask.fFormat) {
- SkARGB32_Blit32(fDevice, mask, clip, fPMColor);
+ switch (mask.fFormat) {
+ case SkMask::kBW_Format:
+ SkARGB32_BlendBW(fDevice, mask, clip, fPMColor, SkAlpha255To256(255 - fSrcA));
+ break;
+ case SkMask::kARGB32_Format:
+ SkARGB32_Blit32(fDevice, mask, clip, fPMColor);
+ break;
+ default:
+ SkFAIL("Mask format not handled.");
}
}
return;
}
- if (mask.fFormat == SkMask::kBW_Format) {
- SkARGB32_BlitBW(fDevice, mask, clip, fPMColor);
- } else if (SkMask::kARGB32_Format == mask.fFormat) {
- SkARGB32_Blit32(fDevice, mask, clip, fPMColor);
+ switch (mask.fFormat) {
+ case SkMask::kBW_Format:
+ SkARGB32_BlitBW(fDevice, mask, clip, fPMColor);
+ break;
+ case SkMask::kARGB32_Format:
+ SkARGB32_Blit32(fDevice, mask, clip, fPMColor);
+ break;
+ default:
+ SkFAIL("Mask format not handled.");
}
}