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

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

Issue 15466004: Make image decoders faster by refactoring hot loops that fills the lines of ImageFrame. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Make image decoders faster by refactoring hot loops that fills the lines of ImageFrame. 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
« no previous file with comments | « no previous file | Source/core/platform/image-decoders/jpeg/JPEGImageDecoder.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 591548dc1b66be8314bbdbc14affef93a64acc24..9a05e212b8df0c6a2f95eb74aef81250af39a320 100644
--- a/Source/core/platform/image-decoders/ImageDecoder.h
+++ b/Source/core/platform/image-decoders/ImageDecoder.h
@@ -175,24 +175,61 @@ namespace WebCore {
return (fixed * v) >> fixPointShift;
}
+ inline void setRGB(PixelData* dest, unsigned r, unsigned g, unsigned b)
+ {
+ checkAddress(dest);
+ *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, a, r, g, b);
+ else
+ setRGBANoPremultiply(dest, a, r, g, b);
+ }
+
+ inline void setRGBAPremultiply(PixelData* dest, unsigned r, unsigned g, unsigned b, unsigned a)
+ {
+ checkAddress(dest);
+ ASSERT(m_premultiplyAlpha);
+ if (!a) {
+ *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 setRGBANoPremultiply(PixelData* dest, unsigned r, unsigned g, unsigned b, unsigned a)
+ {
+ checkAddress(dest);
+ ASSERT(!m_premultiplyAlpha);
+
+ *dest = SkPackARGB32NoCheck(a, r, g, b);
+ }
+
+ inline void setInvertedCMYK(PixelData* dest, unsigned c, unsigned m, unsigned y, unsigned k)
+ {
+ checkAddress(dest);
+
+ unsigned kMult = k * fixPointMult;
+ unsigned r = fixPointUnsignedMultiply(c, kMult);
+ unsigned g = fixPointUnsignedMultiply(m, kMult);
+ unsigned b = fixPointUnsignedMultiply(y, kMult);
+
+ *dest = SkPackARGB32NoCheck(255, r, g, b);
+ }
+
private:
int width() const
{
@@ -204,6 +241,11 @@ namespace WebCore {
return m_bitmap->bitmap().height();
}
+ void checkAddress(PixelData* address)
Peter Kasting 2013/06/12 18:47:07 I would just omit this. The previous code had a s
+ {
+ ASSERT(getAddr(0, 0) <= address && address <= getAddr(0, 0) + width() * height() * m_hasAlpha ? 4 : 3);
+ }
+
RefPtr<NativeImageSkia> m_bitmap;
SkBitmap::Allocator* m_allocator;
bool m_hasAlpha;
« no previous file with comments | « no previous file | Source/core/platform/image-decoders/jpeg/JPEGImageDecoder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698