summaryrefslogtreecommitdiff
path: root/Tools/ImageDiff
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2016-04-10 09:28:39 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2016-04-10 09:28:39 +0000
commit32761a6cee1d0dee366b885b7b9c777e67885688 (patch)
treed6bec92bebfb216f4126356e55518842c2f476a1 /Tools/ImageDiff
parenta4e969f4965059196ca948db781e52f7cfebf19e (diff)
downloadWebKitGtk-tarball-32761a6cee1d0dee366b885b7b9c777e67885688.tar.gz
webkitgtk-2.4.11webkitgtk-2.4.11
Diffstat (limited to 'Tools/ImageDiff')
-rw-r--r--Tools/ImageDiff/CMakeLists.txt20
-rw-r--r--Tools/ImageDiff/PlatformGTK.cmake11
-rw-r--r--Tools/ImageDiff/gtk/ImageDiff.cpp17
3 files changed, 6 insertions, 42 deletions
diff --git a/Tools/ImageDiff/CMakeLists.txt b/Tools/ImageDiff/CMakeLists.txt
deleted file mode 100644
index 6ce4ed522..000000000
--- a/Tools/ImageDiff/CMakeLists.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-set(IMAGE_DIFF_DIR "${TOOLS_DIR}/ImageDiff")
-
-set(IMAGE_DIFF_INCLUDE_DIRECTORIES
- ${CMAKE_BINARY_DIR}
- ${WTF_DIR}
-)
-
-set(IMAGE_DIFF_SYSTEM_INCLUDE_DIRECTORIES "")
-
-set(IMAGE_DIFF_LIBRARIES
- WTF
-)
-
-WEBKIT_INCLUDE_CONFIG_FILES_IF_EXISTS()
-
-include_directories(${IMAGE_DIFF_INCLUDE_DIRECTORIES})
-include_directories(SYSTEM ${IMAGE_DIFF_SYSTEM_INCLUDE_DIRECTORIES})
-add_executable(ImageDiff ${IMAGE_DIFF_SOURCES})
-target_link_libraries(ImageDiff ${IMAGE_DIFF_LIBRARIES})
-set_target_properties(ImageDiff PROPERTIES FOLDER "Tools")
diff --git a/Tools/ImageDiff/PlatformGTK.cmake b/Tools/ImageDiff/PlatformGTK.cmake
deleted file mode 100644
index 8b37ca08b..000000000
--- a/Tools/ImageDiff/PlatformGTK.cmake
+++ /dev/null
@@ -1,11 +0,0 @@
-set(IMAGE_DIFF_SOURCES
- ${IMAGE_DIFF_DIR}/gtk/ImageDiff.cpp
-)
-
-list(APPEND IMAGE_DIFF_SYSTEM_INCLUDE_DIRECTORIES
- ${GTK_INCLUDE_DIRS}
-)
-
-list(APPEND IMAGE_DIFF_LIBRARIES
- ${GTK_LIBRARIES}
-)
diff --git a/Tools/ImageDiff/gtk/ImageDiff.cpp b/Tools/ImageDiff/gtk/ImageDiff.cpp
index 5a128d1e3..2cb9f3bce 100644
--- a/Tools/ImageDiff/gtk/ImageDiff.cpp
+++ b/Tools/ImageDiff/gtk/ImageDiff.cpp
@@ -11,7 +11,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Inc. ("Apple") nor the names of
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
@@ -30,7 +30,6 @@
#include <algorithm>
#include <cmath>
#include <cstdio>
-#include <cstdlib>
#include <cstring>
#include <gdk/gdk.h>
@@ -64,27 +63,23 @@ GdkPixbuf* readPixbufFromStdin(long imageSize)
}
gdk_pixbuf_loader_close(loader, 0);
- GdkPixbuf* decodedImage = GDK_PIXBUF(g_object_ref(gdk_pixbuf_loader_get_pixbuf(loader)));
- g_object_unref(loader);
+ GdkPixbuf* decodedImage = gdk_pixbuf_loader_get_pixbuf(loader);
+ g_object_ref(decodedImage);
return decodedImage;
}
-GdkPixbuf* differenceImageFromDifferenceBuffer(unsigned char* buffer, int width, int height, float maxDistance)
+GdkPixbuf* differenceImageFromDifferenceBuffer(unsigned char* buffer, int width, int height)
{
GdkPixbuf* image = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, width, height);
if (!image)
return image;
- bool shouldNormalize = maxDistance > 0 && maxDistance < 1;
int rowStride = gdk_pixbuf_get_rowstride(image);
unsigned char* diffPixels = gdk_pixbuf_get_pixels(image);
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
unsigned char* diffPixel = diffPixels + (y * rowStride) + (x * 3);
- unsigned char bufferPixel = *buffer++;
- if (shouldNormalize)
- bufferPixel /= maxDistance;
- diffPixel[0] = diffPixel[1] = diffPixel[2] = bufferPixel;
+ diffPixel[0] = diffPixel[1] = diffPixel[2] = *buffer++;
}
}
@@ -145,7 +140,7 @@ float calculateDifference(GdkPixbuf* baselineImage, GdkPixbuf* actualImage, GdkP
else {
difference = roundf(difference * 100.0f) / 100.0f;
difference = max(difference, 0.01f); // round to 2 decimal places
- *differenceImage = differenceImageFromDifferenceBuffer(diffBuffer, width, height, maxDistance);
+ *differenceImage = differenceImageFromDifferenceBuffer(diffBuffer, width, height);
}
free(diffBuffer);