Diff
Modified: trunk/Source/WTF/ChangeLog (127000 => 127001)
--- trunk/Source/WTF/ChangeLog 2012-08-29 14:48:31 UTC (rev 127000)
+++ trunk/Source/WTF/ChangeLog 2012-08-29 15:33:07 UTC (rev 127001)
@@ -1,3 +1,17 @@
+2012-08-29 Dominik Röttsches <[email protected]>
+
+ The 2d.imageData.object.round canvas test is failing
+ https://bugs.webkit.org/show_bug.cgi?id=40272
+
+ Reviewed by Benjamin Poulain.
+
+ Updating previous patch to address Benjamin's comments.
+ #ifdef in Uint8ClampedArray removed, fallback implementation for MSVC on non-X86 added.
+
+ * wtf/MathExtras.h:
+ (lrint): Fallback implementation for non-X86 & MSVC case.
+ * wtf/Uint8ClampedArray.h: Removed #ifdef.
+
2012-08-28 Sheriff Bot <[email protected]>
Unreviewed, rolling out r126914.
Modified: trunk/Source/WTF/wtf/MathExtras.h (127000 => 127001)
--- trunk/Source/WTF/wtf/MathExtras.h 2012-08-29 14:48:31 UTC (rev 127000)
+++ trunk/Source/WTF/wtf/MathExtras.h 2012-08-29 15:33:07 UTC (rev 127001)
@@ -205,17 +205,23 @@
// MSVC's math functions do not bring lrint.
inline long int lrint(double flt)
{
- int intgr;
+ int64_t intgr;
#if CPU(X86)
__asm {
fld flt
fistp intgr
};
#else
-#pragma message("Falling back to casting for lrint(), causes rounding inaccuracy in halfway case.")
- intgr = static_cast<int>(flt);
+ ASSERT(isfinite(flt));
+ double rounded = round(flt);
+ intgr = static_cast<int64_t>(rounded);
+ // If the fractional part is exactly 0.5, we need to check whether
+ // the rounded result is even. If it is not we need to add 1 to
+ // negative values and subtract one from positive values.
+ if (fabs(intgr - flt) == 0.5 & intgr)
+ intgr -= ((intgr >> 62) | 1); // 1 with the sign of result, i.e. -1 or 1.
#endif
- return intgr;
+ return static_cast<long int>(intgr);
}
#endif // COMPILER(MSVC)
Modified: trunk/Source/WTF/wtf/Uint8ClampedArray.h (127000 => 127001)
--- trunk/Source/WTF/wtf/Uint8ClampedArray.h 2012-08-29 14:48:31 UTC (rev 127000)
+++ trunk/Source/WTF/wtf/Uint8ClampedArray.h 2012-08-29 15:33:07 UTC (rev 127001)
@@ -31,9 +31,7 @@
#include <wtf/Platform.h>
#include <wtf/Uint8Array.h>
-#if COMPILER(MSVC)
#include <wtf/MathExtras.h>
-#endif
namespace WTF {
Modified: trunk/Tools/ChangeLog (127000 => 127001)
--- trunk/Tools/ChangeLog 2012-08-29 14:48:31 UTC (rev 127000)
+++ trunk/Tools/ChangeLog 2012-08-29 15:33:07 UTC (rev 127001)
@@ -1,3 +1,22 @@
+2012-08-29 Dominik Röttsches <[email protected]>
+
+ The 2d.imageData.object.round canvas test is failing
+ https://bugs.webkit.org/show_bug.cgi?id=40272
+
+ Reviewed by Benjamin Poulain.
+
+ Updating patch to address Benjamin's review comments.
+ Adding a WTF test to test lrint implementation.
+
+ * TestWebKitAPI/CMakeLists.txt: Added MathExtras.cpp test file.
+ * TestWebKitAPI/GNUmakefile.am: Added MathExtras.cpp test file.
+ * TestWebKitAPI/TestWebKitAPI.gypi: Added MathExtras.cpp test file.
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: Added MathExtras.cpp test file.
+ * TestWebKitAPI/Tests/WTF/MathExtras.cpp: Added this test file containing a test for lrint().
+ (TestWebKitAPI):
+ (TestWebKitAPI::TEST):
+ * TestWebKitAPI/win/TestWebKitAPI.vcproj: Added MathExtras.cpp test file.
+
2012-08-29 Florin Malita <[email protected]>
Unreviewed, updating Kelly Norton's email address at his request.
Modified: trunk/Tools/TestWebKitAPI/CMakeLists.txt (127000 => 127001)
--- trunk/Tools/TestWebKitAPI/CMakeLists.txt 2012-08-29 14:48:31 UTC (rev 127000)
+++ trunk/Tools/TestWebKitAPI/CMakeLists.txt 2012-08-29 15:33:07 UTC (rev 127001)
@@ -72,6 +72,7 @@
${TESTWEBKITAPI_DIR}/Tests/WTF/Functional.cpp
${TESTWEBKITAPI_DIR}/Tests/WTF/HashMap.cpp
${TESTWEBKITAPI_DIR}/Tests/WTF/IntegerToStringConversion.cpp
+ ${TESTWEBKITAPI_DIR}/Tests/WTF/MathExtras.cpp
${TESTWEBKITAPI_DIR}/Tests/WTF/MetaAllocator.cpp
${TESTWEBKITAPI_DIR}/Tests/WTF/RedBlackTree.cpp
${TESTWEBKITAPI_DIR}/Tests/WTF/SaturatedArithmeticOperations.cpp
Modified: trunk/Tools/TestWebKitAPI/GNUmakefile.am (127000 => 127001)
--- trunk/Tools/TestWebKitAPI/GNUmakefile.am 2012-08-29 14:48:31 UTC (rev 127000)
+++ trunk/Tools/TestWebKitAPI/GNUmakefile.am 2012-08-29 15:33:07 UTC (rev 127001)
@@ -56,6 +56,7 @@
Tools/TestWebKitAPI/Tests/WTF/Functional.cpp \
Tools/TestWebKitAPI/Tests/WTF/HashMap.cpp \
Tools/TestWebKitAPI/Tests/WTF/IntegerToStringConversion.cpp \
+ Tools/TestWebKitAPI/Tests/WTF/MathExtras.cpp \
Tools/TestWebKitAPI/Tests/WTF/MediaTime.cpp \
Tools/TestWebKitAPI/Tests/WTF/RedBlackTree.cpp \
Tools/TestWebKitAPI/Tests/WTF/SaturatedArithmeticOperations.cpp \
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.gypi (127000 => 127001)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.gypi 2012-08-29 14:48:31 UTC (rev 127000)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.gypi 2012-08-29 15:33:07 UTC (rev 127001)
@@ -36,6 +36,7 @@
'Tests/WTF/CString.cpp',
'Tests/WTF/Functional.cpp',
'Tests/WTF/HashMap.cpp',
+ 'Tests/WTF/MathExtras.cpp',
'Tests/WTF/MediaTime.cpp',
'Tests/WTF/RedBlackTree.cpp',
'Tests/WTF/SaturatedArithmeticOperations.cpp',
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (127000 => 127001)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2012-08-29 14:48:31 UTC (rev 127000)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2012-08-29 15:33:07 UTC (rev 127001)
@@ -90,6 +90,7 @@
A5E2027315B2181900C13E14 /* WindowlessWebViewWithMedia.mm in Sources */ = {isa = PBXBuildFile; fileRef = A5E2027215B2181900C13E14 /* WindowlessWebViewWithMedia.mm */; };
A5E2027515B21F6E00C13E14 /* WindowlessWebViewWithMedia.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = A5E2027015B2180600C13E14 /* WindowlessWebViewWithMedia.html */; };
A7A966DB140ECCC8005EF9B4 /* CheckedArithmeticOperations.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7A966DA140ECCC8005EF9B4 /* CheckedArithmeticOperations.cpp */; };
+ B4039F9D15E6D8B3007255D6 /* MathExtras.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B4039F9C15E6D8B3007255D6 /* MathExtras.cpp */; };
B55F11A01516834F00915916 /* AttributedString.mm in Sources */ = {isa = PBXBuildFile; fileRef = B55F119F1516834F00915916 /* AttributedString.mm */; };
B55F11B71517D03300915916 /* attributedStringCustomFont.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = B55F11B01517A2C400915916 /* attributedStringCustomFont.html */; };
B55F11BE15191A0600915916 /* Ahem.ttf in Copy Resources */ = {isa = PBXBuildFile; fileRef = B55F11B9151916E600915916 /* Ahem.ttf */; };
@@ -325,6 +326,7 @@
A5E2027015B2180600C13E14 /* WindowlessWebViewWithMedia.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = WindowlessWebViewWithMedia.html; sourceTree = "<group>"; };
A5E2027215B2181900C13E14 /* WindowlessWebViewWithMedia.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WindowlessWebViewWithMedia.mm; sourceTree = "<group>"; };
A7A966DA140ECCC8005EF9B4 /* CheckedArithmeticOperations.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CheckedArithmeticOperations.cpp; path = WTF/CheckedArithmeticOperations.cpp; sourceTree = "<group>"; };
+ B4039F9C15E6D8B3007255D6 /* MathExtras.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MathExtras.cpp; path = WTF/MathExtras.cpp; sourceTree = "<group>"; };
B55F119F1516834F00915916 /* AttributedString.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AttributedString.mm; sourceTree = "<group>"; };
B55F11B01517A2C400915916 /* attributedStringCustomFont.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = attributedStringCustomFont.html; sourceTree = "<group>"; };
B55F11B9151916E600915916 /* Ahem.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = Ahem.ttf; sourceTree = "<group>"; };
@@ -642,6 +644,7 @@
1AA9E55714980A9900001A8A /* Functional.cpp */,
0BCD833414857CE400EA2003 /* HashMap.cpp */,
26B2DFF815BDE599004F691D /* HashSet.cpp */,
+ B4039F9C15E6D8B3007255D6 /* MathExtras.cpp */,
14F3B11215E45EAB00210069 /* SaturatedArithmeticOperations.cpp */,
266FAFD215E5775200F61D5B /* IntegerToStringConversion.cpp */,
81B50192140F232300D9EB58 /* StringBuilder.cpp */,
@@ -925,6 +928,7 @@
52CB47411448FB9300873995 /* LoadAlternateHTMLStringWithNonDirectoryURL.cpp in Sources */,
33DC8911141953A300747EF7 /* LoadCanceledNoServerRedirectCallback.cpp in Sources */,
BC131A9B1171316900B69727 /* main.mm in Sources */,
+ B4039F9D15E6D8B3007255D6 /* MathExtras.cpp in Sources */,
CD5497B415857F0C00B5BC30 /* MediaTime.cpp in Sources */,
E1220DA0155B25480013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.mm in Sources */,
517E7DFC15110EA600D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.mm in Sources */,
Added: trunk/Tools/TestWebKitAPI/Tests/WTF/MathExtras.cpp (0 => 127001)
--- trunk/Tools/TestWebKitAPI/Tests/WTF/MathExtras.cpp (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/MathExtras.cpp 2012-08-29 15:33:07 UTC (rev 127001)
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2012 Intel Corporation
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include <wtf/MathExtras.h>
+
+namespace TestWebKitAPI {
+
+TEST(WTF, Lrint)
+{
+ EXPECT_EQ(lrint(-7.5), -8);
+ EXPECT_EQ(lrint(-8.5), -8);
+ EXPECT_EQ(lrint(-0.5), 0);
+ EXPECT_EQ(lrint(0.5), 0);
+ EXPECT_EQ(lrint(-0.5), 0);
+ EXPECT_EQ(lrint(1.3), 1);
+ EXPECT_EQ(lrint(1.7), 2);
+ EXPECT_EQ(lrint(0), 0);
+ EXPECT_EQ(lrint(-0), 0);
+ // Largest double number with 0.5 precision and one halfway rounding case below.
+ EXPECT_EQ(lrint(pow(2.0, 52) - 0.5), pow(2.0, 52));
+ EXPECT_EQ(lrint(pow(2.0, 52) - 1.5), pow(2.0, 52) - 2);
+ // Smallest double number with 0.5 precision and one halfway rounding case above.
+ EXPECT_EQ(lrint(-pow(2.0, 52) + 0.5), -pow(2.0, 52));
+ EXPECT_EQ(lrint(-pow(2.0, 52) + 1.5), -pow(2.0, 52) + 2);
+}
+
+} // namespace TestWebKitAPI
Modified: trunk/Tools/TestWebKitAPI/win/TestWebKitAPI.vcproj (127000 => 127001)
--- trunk/Tools/TestWebKitAPI/win/TestWebKitAPI.vcproj 2012-08-29 14:48:31 UTC (rev 127000)
+++ trunk/Tools/TestWebKitAPI/win/TestWebKitAPI.vcproj 2012-08-29 15:33:07 UTC (rev 127001)
@@ -652,6 +652,10 @@
>
</File>
<File
+ RelativePath="..\Tests\WTF\MathExtras.cpp"
+ >
+ </File>
+ <File
RelativePath="..\Tests\WTF\MediaTime.cpp"
>
</File>