<?xml version="1.0"?>
<paste-with-annotations>
  <paste>
    <number>
      <integer>95564</integer>
    </number>
    <user>
      <string>kov</string>
    </user>
    <title>
      <string>avoid function calls for pixel handling</string>
    </title>
    <contents>
      <string>diff --git a/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp b/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp
index 124c7cf..8abcfb6 100644
--- a/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp
+++ b/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp
@@ -180,17 +180,23 @@ PassRefPtr&lt;ImageData&gt; getImageData(const IntRect&amp; rect, const ImageBufferData&amp; d
     for (int y = 0; y &lt; numRows; ++y) {
         unsigned* row = reinterpret_cast&lt;unsigned*&gt;(dataSrc + stride * (y + originy));
         for (int x = 0; x &lt; numColumns; x++) {
-            int basex = x * 4;
+            unsigned char* destPixel = &amp;destRows[x * 4];
             unsigned* pixel = row + x + originx;
-            Color pixelColor;
-            if (multiplied == Unmultiplied)
-                pixelColor = colorFromPremultipliedARGB(*pixel);
-            else
-                pixelColor = Color(*pixel);
-            destRows[basex]     = pixelColor.red();
-            destRows[basex + 1] = pixelColor.green();
-            destRows[basex + 2] = pixelColor.blue();
-            destRows[basex + 3] = pixelColor.alpha();
+            Color pixelColor = Color(*pixel);
+
+            if (multiplied == Unmultiplied) {
+                unsigned alpha = pixelColor.alpha();
+
+                destPixel[0] = alpha ? pixelColor.red() * 255 / alpha : 0;
+                destPixel[1] = alpha ? pixelColor.green() * 255 / alpha : 0;
+                destPixel[2] = alpha ? pixelColor.blue() * 255 / alpha : 0;
+                destPixel[3] = alpha;
+            } else {
+                destPixel[0] = pixelColor.red();
+                destPixel[1] = pixelColor.green();
+                destPixel[2] = pixelColor.blue();
+                destPixel[3] = pixelColor.alpha();
+            }
         }
         destRows += destBytesPerRow;
     }
@@ -250,20 +256,22 @@ void putImageData(ImageData*&amp; source, const IntRect&amp; sourceRect, const IntPoint&amp;
         for (int x = 0; x &lt; numColumns; x++) {
             int basex = x * 4;
             unsigned* pixel = row + x + destx;
-            Color pixelColor(srcRows[basex],
-                    srcRows[basex + 1],
-                    srcRows[basex + 2],
-                    srcRows[basex + 3]);
-            if (multiplied == Unmultiplied)
-                *pixel = premultipliedARGBFromColor(pixelColor);
-            else
-                *pixel = pixelColor.rgb();
+            if (multiplied == Unmultiplied) {
+                unsigned char alpha = srcRows[basex + 3];
+
+                pixel[basex] = (srcRows[basex] * alpha + 254) / 255;
+                pixel[basex + 1] = (srcRows[basex + 1] * alpha + 254) / 255;
+                pixel[basex + 2] = (srcRows[basex + 2] * alpha + 254) / 255;
+                pixel[basex + 3] = alpha;
+            } else {
+                *pixel = srcRows[basex];
+            }
         }
         srcRows += srcBytesPerRow;
     }
-    cairo_surface_mark_dirty_rectangle (data.m_surface,
-                                        destx, desty,
-                                        numColumns, numRows);
+    cairo_surface_mark_dirty_rectangle(data.m_surface,
+                                       destx, desty,
+                                       numColumns, numRows);
 }
 
 void ImageBuffer::putUnmultipliedImageData(ImageData* source, const IntRect&amp; sourceRect, const IntPoint&amp; destPoint)
</string>
    </contents>
    <universal-time>
      <integer>3476038329</integer>
    </universal-time>
    <channel>
      <string>#webkit-gtk</string>
    </channel>
    <colorization-mode>
      <string>WebKit (text or diff)</string>
    </colorization-mode>
    <maybe-spam>
      <null/>
    </maybe-spam>
    <is-unicode>
      <keyword>TRUE</keyword>
    </is-unicode>
    <deletion-requested>
      <null/>
    </deletion-requested>
    <deletion-requested-email>
      <null/>
    </deletion-requested-email>
    <expiration-time>
      <null/>
    </expiration-time>
  </paste>
</paste-with-annotations>
