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

Unified Diff: Source/core/platform/image-decoders/ImageDecoder.h

Issue 17448010: Speed up png decoding by eliminating branches from the core loop that fills ImageFrame with pixels (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Speed up png decoding by eliminating branches from the core loop that fills ImageFrame with pixels Created 7 years, 6 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
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 e58d53fffa1973458b4a6ba836295b48061f1308..24555cd522e6c34b7ecfcc9f9deef57f112f2393 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) {
Noel Gordon 2013/06/26 05:15:26 Why did you change the shape of this routine? The
+ *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);
}
+ inline void setRGBARaw(PixelData* dest, unsigned r, unsigned g, unsigned b, unsigned a)
+ {
+ ASSERT(!m_premultiplyAlpha);
Noel Gordon 2013/06/26 05:15:26 Ditto re the ASSERT, why do we need it all when th
+
+ *dest = SkPackARGB32NoCheck(a, r, g, b);
+ }
+
private:
int width() const
{

Powered by Google App Engine
This is Rietveld 408576698