diff options
author | 2016-06-24 13:02:31 -0700 | |
---|---|---|
committer | 2016-06-24 13:02:31 -0700 | |
commit | 3be72b0413ebc7cb1133e704169e3d543830d8e7 (patch) | |
tree | 15cc62665dc22ccc9a11fa9197c25f96c7eb6cf2 /src | |
parent | a4535a34d1b317543307df6901debfefe7132569 (diff) |
Add documention on SkBlitter for runs, and small cleanups.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2054213002
Review-Url: https://codereview.chromium.org/2054213002
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkBlitter.cpp | 2 | ||||
-rw-r--r-- | src/core/SkBlitter.h | 13 | ||||
-rw-r--r-- | src/core/SkBlitter_ARGB32.cpp | 26 |
3 files changed, 32 insertions, 9 deletions
diff --git a/src/core/SkBlitter.cpp b/src/core/SkBlitter.cpp index 43471946c1..f5d13dc5f1 100644 --- a/src/core/SkBlitter.cpp +++ b/src/core/SkBlitter.cpp @@ -158,7 +158,7 @@ void SkBlitter::blitMask(const SkMask& mask, const SkIRect& clip) { 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); diff --git a/src/core/SkBlitter.h b/src/core/SkBlitter.h index 42ef34249a..0e5fedd7eb 100644 --- a/src/core/SkBlitter.h +++ b/src/core/SkBlitter.h @@ -22,6 +22,9 @@ struct SkMask; /** 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: @@ -32,6 +35,16 @@ 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. diff --git a/src/core/SkBlitter_ARGB32.cpp b/src/core/SkBlitter_ARGB32.cpp index af62f2eb1d..7adab55445 100644 --- a/src/core/SkBlitter_ARGB32.cpp +++ b/src/core/SkBlitter_ARGB32.cpp @@ -174,10 +174,15 @@ void SkARGB32_Blitter::blitMask(const SkMask& mask, const SkIRect& clip) { 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."); } } @@ -189,10 +194,15 @@ void SkARGB32_Opaque_Blitter::blitMask(const SkMask& mask, 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."); } } |