Chromium Code Reviews| Index: Source/core/platform/image-decoders/ImageDecoder.h |
| diff --git a/Source/core/platform/image-decoders/ImageDecoder.h b/Source/core/platform/image-decoders/ImageDecoder.h |
| index 591548dc1b66be8314bbdbc14affef93a64acc24..d965d3a3361c0acbdee256c6a8b8ec73a2ab7fcd 100644 |
| --- a/Source/core/platform/image-decoders/ImageDecoder.h |
| +++ b/Source/core/platform/image-decoders/ImageDecoder.h |
| @@ -175,24 +175,46 @@ namespace WebCore { |
| return (fixed * v) >> fixPointShift; |
| } |
| + inline void setRGB(PixelData* dest, unsigned r, unsigned g, unsigned b) |
| + { |
| + *dest = SkPackARGB32NoCheck(255, r, g, b); |
| + } |
| + |
| inline void setRGBA(PixelData* dest, unsigned r, unsigned g, unsigned b, unsigned a) |
| { |
| - if (m_premultiplyAlpha && a < 255) { |
| - if (!a) { |
| - *dest = 0; |
| - return; |
| - } |
| + if (m_premultiplyAlpha) |
| + setRGBAPremultiply(dest, r, g, b, a); |
| + else |
| + setRGBARaw(dest, r, g, b, a); |
| + } |
| + |
| + inline void setRGBAPremultiply(PixelData* dest, unsigned r, unsigned g, unsigned b, unsigned a) |
| + { |
| + ASSERT(m_premultiplyAlpha); |
| + if (!a) { |
| + *dest = 0; |
| + return; |
| + } |
| + if (a < 255) { |
| unsigned alphaMult = a * fixPointMult; |
| r = fixPointUnsignedMultiply(r, alphaMult); |
| g = fixPointUnsignedMultiply(g, alphaMult); |
| b = fixPointUnsignedMultiply(b, alphaMult); |
| } |
| + |
| // Call the "NoCheck" version since we may deliberately pass non-premultiplied |
| // values, and we don't want an assert. |
| *dest = SkPackARGB32NoCheck(a, r, g, b); |
|
Nico
2013/06/24 17:54:16
Maybe the body of this function could be just
*
|
| } |
| + inline void setRGBARaw(PixelData* dest, unsigned r, unsigned g, unsigned b, unsigned a) |
| + { |
| + ASSERT(!m_premultiplyAlpha); |
| + |
| + *dest = SkPackARGB32NoCheck(a, r, g, b); |
| + } |
| + |
| private: |
| int width() const |
| { |