Title: [98023] trunk/Tools
Revision
98023
Author
t...@chromium.org
Date
2011-10-20 14:33:29 -0700 (Thu, 20 Oct 2011)

Log Message

[chromium] Remove <stdint.h> from ImageDiff and use
unsigned int instead of uint32_t.

Unreviewed, fixing the chromium win build.

* DumpRenderTree/chromium/ImageDiff.cpp:
(Image::pixelAt):
(Image::setPixelAt):
(maxOf3):
(getRedComponent):
(getGreenComponent):
(getBlueComponent):
(weightedPercentageDifferent):
(createImageDiff):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (98022 => 98023)


--- trunk/Tools/ChangeLog	2011-10-20 21:27:54 UTC (rev 98022)
+++ trunk/Tools/ChangeLog	2011-10-20 21:33:29 UTC (rev 98023)
@@ -1,3 +1,20 @@
+2011-10-20  Tony Chang  <t...@chromium.org>
+
+        [chromium] Remove <stdint.h> from ImageDiff and use
+        unsigned int instead of uint32_t.
+
+        Unreviewed, fixing the chromium win build.
+
+        * DumpRenderTree/chromium/ImageDiff.cpp:
+        (Image::pixelAt):
+        (Image::setPixelAt):
+        (maxOf3):
+        (getRedComponent):
+        (getGreenComponent):
+        (getBlueComponent):
+        (weightedPercentageDifferent):
+        (createImageDiff):
+
 2011-10-20  Hao Zheng  <zheng...@chromium.org>
 
         [Chromium] Reduce dependencies of ImageDiff to compile it for Android.

Modified: trunk/Tools/DumpRenderTree/chromium/ImageDiff.cpp (98022 => 98023)


--- trunk/Tools/DumpRenderTree/chromium/ImageDiff.cpp	2011-10-20 21:27:54 UTC (rev 98022)
+++ trunk/Tools/DumpRenderTree/chromium/ImageDiff.cpp	2011-10-20 21:33:29 UTC (rev 98023)
@@ -40,7 +40,6 @@
 #include <algorithm>
 #include <iterator>
 #include <limits.h>
-#include <stdint.h>
 #include <stdio.h>
 #include <string.h>
 #include <vector>
@@ -79,8 +78,8 @@
 static const int statusError = 2;
 
 // Color codes.
-static const uint32_t rgbaRed = 0x000000ff;
-static const uint32_t rgbaAlpha = 0xff000000;
+static const unsigned int rgbaRed = 0x000000ff;
+static const unsigned int rgbaAlpha = 0xff000000;
 
 class Image {
 public:
@@ -151,19 +150,19 @@
     }
 
     // Returns the RGBA value of the pixel at the given location
-    const uint32_t pixelAt(int x, int y) const
+    const unsigned int pixelAt(int x, int y) const
     {
         ASSERT(x >= 0 && x < m_width);
         ASSERT(y >= 0 && y < m_height);
-        return *reinterpret_cast<const uint32_t*>(&(m_data[(y * m_width + x) * 4]));
+        return *reinterpret_cast<const unsigned int*>(&(m_data[(y * m_width + x) * 4]));
     }
 
-    void setPixelAt(int x, int y, uint32_t color) const
+    void setPixelAt(int x, int y, unsigned int color) const
     {
         ASSERT(x >= 0 && x < m_width);
         ASSERT(y >= 0 && y < m_height);
         void* addr = &const_cast<unsigned char*>(&m_data.front())[(y * m_width + x) * 4];
-        *reinterpret_cast<uint32_t*>(addr) = color;
+        *reinterpret_cast<unsigned int*>(addr) = color;
     }
 
 private:
@@ -207,24 +206,24 @@
     return static_cast<float>(pixelsDifferent) / totalPixels * 100;
 }
 
-inline uint32_t maxOf3(uint32_t a, uint32_t b, uint32_t c)
+inline unsigned int maxOf3(unsigned int a, unsigned int b, unsigned int c)
 {
     if (a < b)
         return std::max(b, c);
     return std::max(a, c);
 }
 
-inline uint32_t getRedComponent(uint32_t color)
+inline unsigned int getRedComponent(unsigned int color)
 {
     return (color << 24) >> 24;
 }
 
-inline uint32_t getGreenComponent(uint32_t color)
+inline unsigned int getGreenComponent(unsigned int color)
 {
     return (color << 16) >> 24;
 }
 
-inline uint32_t getBlueComponent(uint32_t color)
+inline unsigned int getBlueComponent(unsigned int color)
 {
     return (color << 8) >> 24;
 }
@@ -239,20 +238,20 @@
     float weightedPixelsDifferent = 0;
     for (int y = 0; y < h; ++y) {
         for (int x = 0; x < w; ++x) {
-            uint32_t actualColor = actual.pixelAt(x, y);
-            uint32_t baselineColor = baseline.pixelAt(x, y);
+            unsigned int actualColor = actual.pixelAt(x, y);
+            unsigned int baselineColor = baseline.pixelAt(x, y);
             if (baselineColor != actualColor) {
-                uint32_t actualR = getRedComponent(actualColor);
-                uint32_t actualG = getGreenComponent(actualColor);
-                uint32_t actualB = getBlueComponent(actualColor);
-                uint32_t baselineR = getRedComponent(baselineColor);
-                uint32_t baselineG = getGreenComponent(baselineColor);
-                uint32_t baselineB = getBlueComponent(baselineColor);
-                uint32_t deltaR = std::max(actualR, baselineR)
+                unsigned int actualR = getRedComponent(actualColor);
+                unsigned int actualG = getGreenComponent(actualColor);
+                unsigned int actualB = getBlueComponent(actualColor);
+                unsigned int baselineR = getRedComponent(baselineColor);
+                unsigned int baselineG = getGreenComponent(baselineColor);
+                unsigned int baselineB = getBlueComponent(baselineColor);
+                unsigned int deltaR = std::max(actualR, baselineR)
                     - std::min(actualR, baselineR);
-                uint32_t deltaG = std::max(actualG, baselineG)
+                unsigned int deltaG = std::max(actualG, baselineG)
                     - std::min(actualG, baselineG);
-                uint32_t deltaB = std::max(actualB, baselineB)
+                unsigned int deltaB = std::max(actualB, baselineB)
                     - std::min(actualB, baselineB);
                 weightedPixelsDifferent +=
                     static_cast<float>(maxOf3(deltaR, deltaG, deltaB)) / 255;
@@ -392,15 +391,15 @@
     // FIXME: do something with the extra pixels if the image sizes are different.
     for (int y = 0; y < h; ++y) {
         for (int x = 0; x < w; ++x) {
-            uint32_t basePixel = image1.pixelAt(x, y);
+            unsigned int basePixel = image1.pixelAt(x, y);
             if (basePixel != image2.pixelAt(x, y)) {
                 // Set differing pixels red.
                 out->setPixelAt(x, y, rgbaRed | rgbaAlpha);
                 same = false;
             } else {
                 // Set same pixels as faded.
-                uint32_t alpha = basePixel & rgbaAlpha;
-                uint32_t newPixel = basePixel - ((alpha / 2) & rgbaAlpha);
+                unsigned int alpha = basePixel & rgbaAlpha;
+                unsigned int newPixel = basePixel - ((alpha / 2) & rgbaAlpha);
                 out->setPixelAt(x, y, newPixel);
             }
         }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to