Index: third_party/WebKit/Source/platform/image-decoders/ImageFrame.h |
diff --git a/third_party/WebKit/Source/platform/image-decoders/ImageFrame.h b/third_party/WebKit/Source/platform/image-decoders/ImageFrame.h |
index 9c5615bfd8ad515126a9c1561ad7764344606de5..b94cd42566073d076472e9854219491a91b9d129 100644 |
--- a/third_party/WebKit/Source/platform/image-decoders/ImageFrame.h |
+++ b/third_party/WebKit/Source/platform/image-decoders/ImageFrame.h |
@@ -218,6 +218,47 @@ class PLATFORM_EXPORT ImageFrame final { |
*dest = SkPackARGB32NoCheck(a, r, g, b); |
} |
+ // Blend the RGBA pixel provided by |r|, |g|, |b|, |a| over the pixel in |
+ // |dest|, without premultiplication, and overwrite |dest| with the result. |
+ static void blendRGBARaw(PixelData* dest, |
+ unsigned r, |
+ unsigned g, |
+ unsigned b, |
+ unsigned a); |
+ |
+ // Blend the pixel, without premultiplication, in |src| over |dst| and |
+ // overwrite |src| with the result. |
+ static void blendSrcOverDstRaw(PixelData* src, PixelData dst); |
+ |
+ // Blend the RGBA pixel provided by |r|, |g|, |b|, |a| over the pixel in |
+ // |dest| and overwrite |dest| with the result. Premultiply the pixel values |
+ // before blending. |
+ static inline void blendRGBAPremultiply(PixelData* dest, |
+ unsigned r, |
+ unsigned g, |
+ unsigned b, |
+ unsigned a) { |
+ // If the new pixel is completely transparent, no operation is necessary |
+ // since |dest| contains the background pixel. |
+ if (a == 0x0) |
+ return; |
+ |
+ // If the new pixel is opaque, no need for blending - just write the pixel. |
+ if (a == 0xFF) |
+ return setRGBAPremultiply(dest, r, g, b, a); |
+ |
+ PixelData src; |
+ setRGBAPremultiply(&src, r, g, b, a); |
+ *dest = SkPMSrcOver(src, *dest); |
+ } |
+ |
+ // Blend the pixel in |src| over |dst| and overwrite |src| with the result. |
+ // This assumes the pixel values in |src| are already premultiplied. |
+ static inline void blendSrcOverDstPremultiplied(PixelData* src, |
+ PixelData dst) { |
+ *src = SkPMSrcOver(*src, dst); |
+ } |
+ |
// Notifies the SkBitmap if any pixels changed and resets the flag. |
inline void notifyBitmapIfPixelsChanged() { |
if (m_pixelsChanged) |