Fix miscellaneous compiler warnings from Visual Studio 2010.
Changes serialization path for MorphologyImageFilter, handling of Windows
HRESULTS; otherwise just tweaks tests.



git-svn-id: http://skia.googlecode.com/svn/trunk@3642 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gm/bitmapcopy.cpp b/gm/bitmapcopy.cpp
index 249ec43..edf6445 100644
--- a/gm/bitmapcopy.cpp
+++ b/gm/bitmapcopy.cpp
@@ -30,13 +30,17 @@
 static void draw_checks(SkCanvas* canvas, int width, int height) {
     SkPaint paint;
     paint.setColor(SK_ColorRED);
-    canvas->drawRectCoords(0, 0, width / 2, height / 2, paint);
+    canvas->drawRectCoords(SkIntToScalar(0), SkIntToScalar(0),
+        SkIntToScalar(width / 2), SkIntToScalar(height / 2), paint);
     paint.setColor(SK_ColorGREEN);
-    canvas->drawRectCoords(width / 2, 0, width, height / 2, paint);
+    canvas->drawRectCoords(SkIntToScalar(width / 2), SkIntToScalar(0),
+        SkIntToScalar(width), SkIntToScalar(height / 2), paint);
     paint.setColor(SK_ColorBLUE);
-    canvas->drawRectCoords(0, height / 2, width / 2, height, paint);
+    canvas->drawRectCoords(SkIntToScalar(0), SkIntToScalar(height / 2),
+        SkIntToScalar(width / 2), SkIntToScalar(height), paint);
     paint.setColor(SK_ColorYELLOW);
-    canvas->drawRectCoords(width / 2, height / 2, width, height, paint);
+    canvas->drawRectCoords(SkIntToScalar(width / 2), SkIntToScalar(height / 2),
+        SkIntToScalar(width), SkIntToScalar(height), paint);
 }
 
 class BitmapCopyGM : public GM {
diff --git a/gm/colormatrix.cpp b/gm/colormatrix.cpp
index 3cc9c02..cc5cfbc 100644
--- a/gm/colormatrix.cpp
+++ b/gm/colormatrix.cpp
@@ -61,7 +61,8 @@
             for (int x = 0; x < width; ++x) {
                 SkPaint paint;
                 paint.setColor(SkColorSetARGB(255, x * 255 / width, y * 255 / height, 0));
-                canvas.drawRect(SkRect::MakeXYWH(x, y, 1, 1), paint);
+                canvas.drawRect(SkRect::MakeXYWH(SkIntToScalar(x),
+                    SkIntToScalar(y), SK_Scalar1, SK_Scalar1), paint);
             }
         }
         return bm;
diff --git a/gm/imageblur.cpp b/gm/imageblur.cpp
index 841441e..c8dd5d7 100644
--- a/gm/imageblur.cpp
+++ b/gm/imageblur.cpp
@@ -39,8 +39,9 @@
             int x = rand() % WIDTH;
             int y = rand() % HEIGHT;
             paint.setColor(rand() % 0x1000000 | 0xFF000000);
-            paint.setTextSize(rand() % 300);
-            canvas->drawText(str, strlen(str), x, y, paint);
+            paint.setTextSize(SkIntToScalar(rand() % 300));
+            canvas->drawText(str, strlen(str), SkIntToScalar(x),
+                             SkIntToScalar(y), paint);
         }
         canvas->restore();
     }
diff --git a/gm/verttext2.cpp b/gm/verttext2.cpp
index 3bfb471..9ffefec 100644
--- a/gm/verttext2.cpp
+++ b/gm/verttext2.cpp
@@ -73,7 +73,8 @@
         paint.setTextSize(textHeight);
 
         canvas->drawText(string.c_str(), string.size(), y, 
-                alignment == SkPaint::kLeft_Align ? 10 : 240, paint);
+                SkIntToScalar(alignment == SkPaint::kLeft_Align ? 10 : 240),
+                paint);
         y += textHeight;
     }
 
diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp
index aac6f84..2de4b3c 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -10,8 +10,8 @@
 
 SkMorphologyImageFilter::SkMorphologyImageFilter(SkFlattenableReadBuffer& buffer)
   : INHERITED(buffer) {
-    fRadius.fWidth = buffer.readScalar();
-    fRadius.fHeight = buffer.readScalar();
+    fRadius.fWidth = buffer.readInt();
+    fRadius.fHeight = buffer.readInt();
 }
 
 SkMorphologyImageFilter::SkMorphologyImageFilter(int radiusX, int radiusY)
@@ -21,8 +21,8 @@
 
 void SkMorphologyImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const {
     this->INHERITED::flatten(buffer);
-    buffer.writeScalar(fRadius.fWidth);
-    buffer.writeScalar(fRadius.fHeight);
+    buffer.writeInt(fRadius.fWidth);
+    buffer.writeInt(fRadius.fHeight);
 }
 
 static void erode(const SkPMColor* src, SkPMColor* dst,
diff --git a/src/utils/win/SkHRESULT.cpp b/src/utils/win/SkHRESULT.cpp
index 740b8b8..3d463f8 100644
--- a/src/utils/win/SkHRESULT.cpp
+++ b/src/utils/win/SkHRESULT.cpp
@@ -11,7 +11,7 @@
 
 void SkTraceHR(const char* file, unsigned long line,
                HRESULT hr, const char* msg) {
-    if (NULL != msg) SkDEBUGF(("%s\n", msg));
+    SkDEBUGCODE(if (NULL != msg) SkDEBUGF(("%s\n", msg)));
     SkDEBUGF(("%s(%lu) : error 0x%x: ", file, line, hr));
     
     LPSTR errorText = NULL;
diff --git a/tests/FillPathTest.cpp b/tests/FillPathTest.cpp
index 8271851..b14f5bc 100644
--- a/tests/FillPathTest.cpp
+++ b/tests/FillPathTest.cpp
@@ -39,7 +39,8 @@
   int expected_lines = 5;
   clip.set(0, height - expected_lines, width, height);
   path.moveTo(0.0, 0.0);
-  path.quadTo(width/2, height, width, 0.0);
+  path.quadTo(SkIntToScalar(width/2), SkIntToScalar(height),
+              SkIntToScalar(width), 0.0);
   path.close();
   path.setFillType(SkPath::kInverseWinding_FillType);
   SkScan::FillPath(path, clip, &blitter);
diff --git a/tests/MathTest.cpp b/tests/MathTest.cpp
index fef93cd..fe162b1 100644
--- a/tests/MathTest.cpp
+++ b/tests/MathTest.cpp
@@ -245,8 +245,8 @@
 static void unittest_isfinite(skiatest::Reporter* reporter) {
 #ifdef SK_SCALAR_IS_FLOAT
     float nan = sk_float_asin(2);
-    float inf = 1.0 / make_zero();
-    float big = 3.40282e+038;
+    float inf = 1.0f / make_zero();
+    float big = 3.40282e+038f;
 
     REPORTER_ASSERT(reporter, !SkScalarIsNaN(inf));
     REPORTER_ASSERT(reporter, !SkScalarIsNaN(-inf));
@@ -416,9 +416,13 @@
     for (i = 0; i < 10000; i++) {
         SkPoint p;
 
-        p.setLength(rand.nextS(), rand.nextS(), SK_Scalar1);
+        // These random values are being treated as 32-bit-patterns, not as
+        // ints; calling SkIntToScalar() here produces crashes.
+        p.setLength(rand.nextS(),
+                    rand.nextS(), SK_Scalar1);
         check_length(reporter, p, SK_Scalar1);
-        p.setLength(rand.nextS() >> 13, rand.nextS() >> 13, SK_Scalar1);
+        p.setLength(rand.nextS() >> 13,
+                    rand.nextS() >> 13, SK_Scalar1);
         check_length(reporter, p, SK_Scalar1);
     }
 
diff --git a/tests/PointTest.cpp b/tests/PointTest.cpp
index 876a272..db9c803 100644
--- a/tests/PointTest.cpp
+++ b/tests/PointTest.cpp
@@ -36,10 +36,10 @@
 
 void PointTest(skiatest::Reporter* reporter) {
     test_length(reporter, SkIntToScalar(3), SkIntToScalar(4), SkIntToScalar(5));
-    test_length(reporter, SkFloatToScalar(0.6), SkFloatToScalar(0.8),
+    test_length(reporter, SkFloatToScalar(0.6f), SkFloatToScalar(0.8f),
                 SK_Scalar1);
     test_Normalize(reporter, SkIntToScalar(3), SkIntToScalar(4));
-    test_Normalize(reporter, SkFloatToScalar(0.6), SkFloatToScalar(0.8));
+    test_Normalize(reporter, SkFloatToScalar(0.6f), SkFloatToScalar(0.8f));
 }
 
 #include "TestClassDef.h"