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

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

Issue 2386453003: WIP: Implement APNG (Closed)
Patch Set: Revisit ImageFrame alpha setting. 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
3 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. 3 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 } 211 }
212 212
213 static inline void setRGBARaw(PixelData* dest, 213 static inline void setRGBARaw(PixelData* dest,
214 unsigned r, 214 unsigned r,
215 unsigned g, 215 unsigned g,
216 unsigned b, 216 unsigned b,
217 unsigned a) { 217 unsigned a) {
218 *dest = SkPackARGB32NoCheck(a, r, g, b); 218 *dest = SkPackARGB32NoCheck(a, r, g, b);
219 } 219 }
220 220
221 // Blend the RGBA pixel provided by |r|, |g|, |b|, |a| over the pixel in
222 // |dest|, without premultiplication, and overwrite |dest| with the result.
223 static void blendRGBARaw(PixelData* dest,
224 unsigned r,
225 unsigned g,
226 unsigned b,
227 unsigned a);
228
229 // Blend the pixel, without premultiplication, in |src| over |dst| and
230 // overwrite |src| with the result.
231 static void blendSrcOverDstRaw(PixelData* src, PixelData dst);
232
233 // Blend the RGBA pixel provided by |r|, |g|, |b|, |a| over the pixel in
234 // |dest| and overwrite |dest| with the result. Premultiply the pixel values
235 // before blending.
236 static inline void blendRGBAPremultiply(PixelData* dest,
237 unsigned r,
238 unsigned g,
239 unsigned b,
240 unsigned a) {
241 // If the new pixel is completely transparent, no operation is necessary
242 // since |dest| contains the background pixel.
243 if (a == 0x0)
244 return;
245
246 // If the new pixel is opaque, no need for blending - just write the pixel.
247 if (a == 0xFF)
248 return setRGBAPremultiply(dest, r, g, b, a);
249
250 PixelData src;
251 setRGBAPremultiply(&src, r, g, b, a);
252 *dest = SkPMSrcOver(src, *dest);
253 }
254
255 // Blend the pixel in |src| over |dst| and overwrite |src| with the result.
256 // This assumes the pixel values in |src| are already premultiplied.
257 static inline void blendSrcOverDstPremultiplied(PixelData* src,
258 PixelData dst) {
259 *src = SkPMSrcOver(*src, dst);
260 }
261
221 // Notifies the SkBitmap if any pixels changed and resets the flag. 262 // Notifies the SkBitmap if any pixels changed and resets the flag.
222 inline void notifyBitmapIfPixelsChanged() { 263 inline void notifyBitmapIfPixelsChanged() {
223 if (m_pixelsChanged) 264 if (m_pixelsChanged)
224 m_bitmap.notifyPixelsChanged(); 265 m_bitmap.notifyPixelsChanged();
225 m_pixelsChanged = false; 266 m_pixelsChanged = false;
226 } 267 }
227 268
228 private: 269 private:
229 int width() const { return m_bitmap.width(); } 270 int width() const { return m_bitmap.width(); }
230 271
(...skipping 22 matching lines...) Expand all
253 // The frame that must be decoded before this frame can be decoded. 294 // The frame that must be decoded before this frame can be decoded.
254 // WTF::kNotFound if this frame doesn't require any previous frame. 295 // WTF::kNotFound if this frame doesn't require any previous frame.
255 // This is used by ImageDecoder::clearCacheExceptFrame(), and will never 296 // This is used by ImageDecoder::clearCacheExceptFrame(), and will never
256 // be read for image formats that do not have multiple frames. 297 // be read for image formats that do not have multiple frames.
257 size_t m_requiredPreviousFrameIndex; 298 size_t m_requiredPreviousFrameIndex;
258 }; 299 };
259 300
260 } // namespace blink 301 } // namespace blink
261 302
262 #endif 303 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698