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

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

Issue 18099004: Improve PNG decode performance: avoid branching in the row write loop (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: template patch. Created 6 years, 7 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/platform/image-decoders/ImageFrame.h
diff --git a/Source/platform/image-decoders/ImageFrame.h b/Source/platform/image-decoders/ImageFrame.h
index bb665a9140c1f5e3d180b55379e4106f36f9acbb..0246efe21c91994b4f602870a0a4cad4cb531e08 100644
--- a/Source/platform/image-decoders/ImageFrame.h
+++ b/Source/platform/image-decoders/ImageFrame.h
@@ -162,11 +162,20 @@ public:
setRGBA(getAddr(x, y), r, g, b, a);
}
+ inline void setRGBA(PixelData* dest, unsigned r, unsigned g, unsigned b, unsigned a)
+ {
+ if (m_premultiplyAlpha)
Peter Kasting 2014/05/12 19:36:11 We could simplify this to just: setRGBA<m_pre
Noel Gordon 2014/05/13 01:39:19 Doesn't compile on any C++ compiler I know. VS2010
Peter Kasting 2014/05/13 01:54:56 Huh, that's odd. I could swear I've done precisel
+ setRGBA<true>(dest, r, g, b, a);
+ else
+ *dest = SkPackARGB32NoCheck(a, r, g, b);
+ }
+
static const unsigned div255 = static_cast<unsigned>(1.0 / 255 * (1 << 24)) + 1;
+ template <bool Premultiply>
inline void setRGBA(PixelData* dest, unsigned r, unsigned g, unsigned b, unsigned a)
Peter Kasting 2014/05/12 19:36:11 This can be static, can't it?
Noel Gordon 2014/05/13 01:39:19 Could be, but you'd then add function calling over
Peter Kasting 2014/05/13 01:54:56 Why? Can't something be both static and inline?
{
- if (m_premultiplyAlpha && a < 255) {
+ if (Premultiply && a < 255) {
if (!a) {
*dest = 0;
return;

Powered by Google App Engine
This is Rietveld 408576698