Make Sk4f(float) constructor explicit.
authormtklein <mtklein@chromium.org>
Sat, 7 Mar 2015 00:20:22 +0000 (16:20 -0800)
committerCommit bot <commit-bot@chromium.org>
Sat, 7 Mar 2015 00:20:22 +0000 (16:20 -0800)
BUG=skia:

Review URL: https://codereview.chromium.org/985003003

src/core/Sk4x.h
tests/PMFloatTest.cpp
tests/Sk4xTest.cpp

index 01ce39f074d896e43979cbaaee9d420a45a1eca9..0b9796db9b9bb1e42ee23606e27f3f9deeb4952a 100644 (file)
@@ -25,7 +25,7 @@ typedef Sk4x<int32_t> Sk4i;
 template <typename T> class Sk4x {
 public:
     Sk4x();  // Uninitialized; use Sk4x(0) for zero.
-    /*implicit*/ Sk4x(T);  // Same as Sk4x(T,T,T,T);
+    explicit Sk4x(T);  // Same as Sk4x(T,T,T,T);
     Sk4x(T, T, T, T);
 
     Sk4x(const Sk4x&);
index 13c0a120b861b6ca3fa49ecdd0f6abb31c11eefa..f370b39c664a5a5bc2a5dc23ab49309b2fc2ba75 100644 (file)
@@ -24,7 +24,7 @@ DEF_TEST(SkPMFloat, r) {
 
     // Test SkPMFloat <-> Sk4f conversion.
     Sk4f fs = clamped;
-    SkPMFloat scaled = fs.multiply(0.25f);
+    SkPMFloat scaled = fs.multiply(Sk4f(0.25f));
     REPORTER_ASSERT(r, SkScalarNearlyEqual(63.75f, scaled.a()));
     REPORTER_ASSERT(r, SkScalarNearlyEqual(38.25f, scaled.r()));
     REPORTER_ASSERT(r, SkScalarNearlyEqual( 0.25f, scaled.g()));
index a7a3184d1ec075f2de48d80a224120e140b92ac1..1cecd4f1fcec19ab3fffc74425661c656360eaa4 100644 (file)
@@ -83,7 +83,7 @@ DEF_TEST(Sk4x_Arith, r) {
 }
 
 DEF_TEST(Sk4x_ImplicitPromotion, r) {
-    ASSERT_EQ(Sk4f(2,4,6,8), Sk4f(1,2,3,4).multiply(2.0f));
+    ASSERT_EQ(Sk4f(2,4,6,8), Sk4f(1,2,3,4).multiply(Sk4f(2.0f)));
 }
 
 DEF_TEST(Sk4x_Sqrt, r) {
@@ -91,13 +91,13 @@ DEF_TEST(Sk4x_Sqrt, r) {
            roots(2,  4,  5,  11);
     // .sqrt() should be pretty precise.
     Sk4f error = roots.subtract(squares.sqrt());
-    REPORTER_ASSERT(r, error.greaterThanEqual(0.0f).allTrue());
-    REPORTER_ASSERT(r, error.lessThan(0.000001f).allTrue());
+    REPORTER_ASSERT(r, error.greaterThanEqual(Sk4f(0.0f)).allTrue());
+    REPORTER_ASSERT(r, error.lessThan(Sk4f(0.000001f)).allTrue());
 
     // .rsqrt() isn't so precise (for SSE), but should be pretty close.
     error = roots.subtract(squares.multiply(squares.rsqrt()));
-    REPORTER_ASSERT(r, error.greaterThanEqual(0.0f).allTrue());
-    REPORTER_ASSERT(r, error.lessThan(0.01f).allTrue());
+    REPORTER_ASSERT(r, error.greaterThanEqual(Sk4f(0.0f)).allTrue());
+    REPORTER_ASSERT(r, error.lessThan(Sk4f(0.01f)).allTrue());
 }
 
 DEF_TEST(Sk4x_Comparison, r) {