Changeset 96407 in webkit
- Timestamp:
- Sep 30, 2011 11:09:14 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r96406 r96407 1 2011-09-30 Tim Horton <timothy_horton@apple.com> 2 3 feBlend uses a table of function pointers which reduces inlineability inside the main loop 4 https://bugs.webkit.org/show_bug.cgi?id=69154 5 <rdar://problem/10215221> 6 7 Reviewed by Darin Adler. 8 9 Don't use a table of function pointers inside the feBlend inner loop, instead 10 use switch and inline functions, bringing a 20% performance gain across the 11 board to feBlend. 12 13 No new tests, minor performance improvement. 14 15 * platform/graphics/filters/FEBlend.cpp: 16 (WebCore::normal): 17 (WebCore::multiply): 18 (WebCore::screen): 19 (WebCore::darken): 20 (WebCore::lighten): 21 (WebCore::FEBlend::apply): 22 1 23 2011-09-30 Mark Hahnenberg <mhahnenberg@apple.com> 2 24 -
trunk/Source/WebCore/platform/graphics/filters/FEBlend.cpp
r86765 r96407 62 62 } 63 63 64 static unsigned char unknown(unsigned char, unsigned char, unsigned char, unsigned char) 65 { 66 return 0; 67 } 68 69 static unsigned char normal(unsigned char colorA, unsigned char colorB, unsigned char alphaA, unsigned char) 64 static inline unsigned char normal(unsigned char colorA, unsigned char colorB, unsigned char alphaA, unsigned char) 70 65 { 71 66 return (((255 - alphaA) * colorB + colorA * 255) / 255); 72 67 } 73 68 74 static unsigned char multiply(unsigned char colorA, unsigned char colorB, unsigned char alphaA, unsigned char alphaB)69 static inline unsigned char multiply(unsigned char colorA, unsigned char colorB, unsigned char alphaA, unsigned char alphaB) 75 70 { 76 71 return (((255 - alphaA) * colorB + (255 - alphaB + colorB) * colorA) / 255); 77 72 } 78 73 79 static unsigned char screen(unsigned char colorA, unsigned char colorB, unsigned char, unsigned char)74 static inline unsigned char screen(unsigned char colorA, unsigned char colorB, unsigned char, unsigned char) 80 75 { 81 76 return (((colorB + colorA) * 255 - colorA * colorB) / 255); 82 77 } 83 78 84 static unsigned char darken(unsigned char colorA, unsigned char colorB, unsigned char alphaA, unsigned char alphaB)79 static inline unsigned char darken(unsigned char colorA, unsigned char colorB, unsigned char alphaA, unsigned char alphaB) 85 80 { 86 81 return ((std::min((255 - alphaA) * colorB + colorA * 255, (255 - alphaB) * colorA + colorB * 255)) / 255); 87 82 } 88 83 89 static unsigned char lighten(unsigned char colorA, unsigned char colorB, unsigned char alphaA, unsigned char alphaB)84 static inline unsigned char lighten(unsigned char colorA, unsigned char colorB, unsigned char alphaA, unsigned char alphaB) 90 85 { 91 86 return ((std::max((255 - alphaA) * colorB + colorA * 255, (255 - alphaB) * colorA + colorB * 255)) / 255); … … 116 111 RefPtr<ByteArray> srcPixelArrayB = in2->asPremultipliedImage(effectBDrawingRect); 117 112 118 // Keep synchronized with BlendModeType119 static const BlendType callEffect[] = {unknown, normal, multiply, screen, darken, lighten};120 121 113 unsigned pixelArrayLength = srcPixelArrayA->length(); 122 114 ASSERT(pixelArrayLength == srcPixelArrayB->length()); … … 127 119 unsigned char colorA = srcPixelArrayA->get(pixelOffset + channel); 128 120 unsigned char colorB = srcPixelArrayB->get(pixelOffset + channel); 121 unsigned char result; 129 122 130 unsigned char result = (*callEffect[m_mode])(colorA, colorB, alphaA, alphaB); 123 switch (m_mode) { 124 case FEBLEND_MODE_NORMAL: 125 result = normal(colorA, colorB, alphaA, alphaB); 126 break; 127 case FEBLEND_MODE_MULTIPLY: 128 result = multiply(colorA, colorB, alphaA, alphaB); 129 break; 130 case FEBLEND_MODE_SCREEN: 131 result = screen(colorA, colorB, alphaA, alphaB); 132 break; 133 case FEBLEND_MODE_DARKEN: 134 result = darken(colorA, colorB, alphaA, alphaB); 135 break; 136 case FEBLEND_MODE_LIGHTEN: 137 result = lighten(colorA, colorB, alphaA, alphaB); 138 break; 139 case FEBLEND_MODE_UNKNOWN: 140 default: 141 result = 0; 142 break; 143 } 144 131 145 dstPixelArray->set(pixelOffset + channel, result); 132 146 }
Note: See TracChangeset
for help on using the changeset viewer.