Optimization in image decoding
authorbfulgham@webkit.org <bfulgham@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Nov 2012 05:41:24 +0000 (05:41 +0000)
committerbfulgham@webkit.org <bfulgham@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Nov 2012 05:41:24 +0000 (05:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=88424

Patch by Viatcheslav Ostapenko <v.ostapenko@samsung.com> on 2012-11-27
Reviewed by Brent Fulgham.

Optimization in image decoding.
Reduce branching and multiplications in GIF image decoding loops and functions.
Rebase and update of original patch by Misha Tyutyunik <michael.tyuytunik@nokia.com>

Covered by existing tests.

* platform/image-decoders/gif/GIFImageDecoder.cpp:
(WebCore::GIFImageDecoder::haveDecodedRow):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@135976 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp

index 24f2ecc..71bbbab 100644 (file)
@@ -1,3 +1,19 @@
+2012-11-27  Viatcheslav Ostapenko  <v.ostapenko@samsung.com>
+
+        Optimization in image decoding
+        https://bugs.webkit.org/show_bug.cgi?id=88424
+
+        Reviewed by Brent Fulgham.
+
+        Optimization in image decoding.
+        Reduce branching and multiplications in GIF image decoding loops and functions.
+        Rebase and update of original patch by Misha Tyutyunik <michael.tyuytunik@nokia.com>
+
+        Covered by existing tests.
+
+        * platform/image-decoders/gif/GIFImageDecoder.cpp:
+        (WebCore::GIFImageDecoder::haveDecodedRow):
+
 2012-11-27  Michael Saboff  <msaboff@apple.com>
 
         TextIterator unnecessarily converts 8 bit strings to 16 bits
         Unreviewed. Fix Chromium Win compilation after r135255.
         https://bugs.webkit.org/show_bug.cgi?id=97803
 
-        * WebCore.gypi: removed reference to platform/wince/DragDataWince.cpp which
+        * WebCore.gypi: removed reference to platform/wince/DragDataWince.cpp which
         was deleted in the aforementioned change.
 
 2012-11-19  Kentaro Hara  <haraken@chromium.org>
index 40e131e..8fc4a9a 100644 (file)
@@ -230,12 +230,13 @@ bool GIFImageDecoder::haveDecodedRow(unsigned frameIndex, unsigned char* rowBuff
     if ((buffer.status() == ImageFrame::FrameEmpty) && !initFrameBuffer(frameIndex))
         return false;
 
+    ImageFrame::PixelData* currentAddress = buffer.getAddr(xBegin, yBegin);
     // Write one row's worth of data into the frame.  
     for (int x = xBegin; x < xEnd; ++x) {
         const unsigned char sourceValue = *(rowBuffer + (m_scaled ? m_scaledColumns[x] : x) - frameReader->x_offset);
         if ((!frameReader->is_transparent || (sourceValue != frameReader->tpixel)) && (sourceValue < colorMapSize)) {
             const size_t colorIndex = static_cast<size_t>(sourceValue) * 3;
-            buffer.setRGBA(x, yBegin, colorMap[colorIndex], colorMap[colorIndex + 1], colorMap[colorIndex + 2], 255);
+            buffer.setRGBA(currentAddress, colorMap[colorIndex], colorMap[colorIndex + 1], colorMap[colorIndex + 2], 255);
         } else {
             m_currentBufferSawAlpha = true;
             // We may or may not need to write transparent pixels to the buffer.
@@ -246,8 +247,9 @@ bool GIFImageDecoder::haveDecodedRow(unsigned frameIndex, unsigned char* rowBuff
             // beyond the first, or the initial passes will "show through" the
             // later ones.
             if (writeTransparentPixels)
-                buffer.setRGBA(x, yBegin, 0, 0, 0, 0);
+                buffer.setRGBA(currentAddress, 0, 0, 0, 0);
         }
+        ++currentAddress;
     }
 
     // Tell the frame to copy the row data if need be.