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

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

Issue 1312843006: Animated PNG implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 4 months 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
« no previous file with comments | « Source/platform/blink_platform.gypi ('k') | Source/platform/image-decoders/png/PNGImageDecoder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/image-decoders/ImageFrame.h
diff --git a/Source/platform/image-decoders/ImageFrame.h b/Source/platform/image-decoders/ImageFrame.h
index fb7425755bd77887066531b171c6c8dc21c5b2d8..0a2a13162e201066bf2bb22cd146e425b8f8a5ea 100644
--- a/Source/platform/image-decoders/ImageFrame.h
+++ b/Source/platform/image-decoders/ImageFrame.h
@@ -178,6 +178,45 @@ public:
*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);
+ }
+
// Notifies the SkBitmap if any pixels changed and resets the flag.
inline void notifyBitmapIfPixelsChanged()
{
« no previous file with comments | « Source/platform/blink_platform.gypi ('k') | Source/platform/image-decoders/png/PNGImageDecoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698