Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Unified Diff: third_party/WebKit/Source/platform/image-decoders/ImageFrame.h

Issue 1567053002: Animated PNG implementation Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved some code to PNGImageReader.cpp and PNGImageReader.h Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 574b66df089049e866ddfaf8c9bc811a30e10619..9ff7a3ba439efd0436aaba700ae739edbf4733f7 100644
--- a/third_party/WebKit/Source/platform/image-decoders/ImageFrame.h
+++ b/third_party/WebKit/Source/platform/image-decoders/ImageFrame.h
@@ -218,6 +218,51 @@ class PLATFORM_EXPORT ImageFrame final {
*dest = SkPackARGB32NoCheck(a, r, g, b);
}
+ inline void overRGBAPremultiply(PixelData* dest,
+ unsigned r,
+ unsigned g,
+ unsigned b,
+ unsigned a) {
+ enum FractionControl { RoundFractionControl = 257 * 128 };
+
+ if (!a)
+ return;
+
+ if (a < 255) {
+ unsigned alpha = a * 257;
+ r = (r * alpha + RoundFractionControl) >> 16;
+ g = (g * alpha + RoundFractionControl) >> 16;
+ b = (b * alpha + RoundFractionControl) >> 16;
+ *dest = SkPMSrcOver(SkPackARGB32NoCheck(a, r, g, b), *dest);
+ } else {
+ *dest = SkPackARGB32NoCheck(a, r, g, b);
+ }
+ }
+
+ inline void overRGBARaw(PixelData* dest,
+ unsigned r,
+ unsigned g,
+ unsigned b,
+ unsigned a) {
+ if (!a)
+ return;
+
+ unsigned aDest = SkGetPackedA32(*dest);
+ if (aDest && a < 255) {
+ unsigned u = a * 255;
+ unsigned v = (255 - a) * aDest;
+ unsigned alpha = u + v;
+ unsigned rDest = SkGetPackedR32(*dest);
+ unsigned gDest = SkGetPackedG32(*dest);
+ unsigned bDest = SkGetPackedB32(*dest);
+ a = (alpha + (alpha >> 8) + 1) >> 8;
+ r = (r * u + rDest * v) / alpha;
+ g = (g * u + gDest * v) / alpha;
+ b = (b * u + bDest * v) / alpha;
+ }
+ *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 inline void blendRGBARaw(PixelData* dest,

Powered by Google App Engine
This is Rietveld 408576698