fix warnings on Mac in src/core

Fix these class of warnings:
- unused functions
- unused locals
- sign mismatch
- missing function prototypes
- missing newline at end of file
- 64 to 32 bit truncation

The changes prefer to link in dead code in the debug build
with 'if (false)' than to comment it out, but trivial cases
are commented out or sometimes deleted if it appears to be
a copy/paste error.
Review URL: https://codereview.appspot.com/6301046

git-svn-id: http://skia.googlecode.com/svn/trunk@4182 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/core/SkAAClip.cpp b/src/core/SkAAClip.cpp
index fe0fb28..86c99d8 100644
--- a/src/core/SkAAClip.cpp
+++ b/src/core/SkAAClip.cpp
@@ -1055,6 +1055,9 @@
 
     void validate() {
 #ifdef SK_DEBUG
+        if (false) { // avoid bit rot, suppress warning
+            test_count_left_right_zeros();
+        }
         int prevY = -1;
         for (int i = 0; i < fRows.count(); ++i) {
             const Row& row = fRows[i];
@@ -1324,12 +1327,6 @@
                         const uint8_t* rowA, const SkIRect& rectA,
                         const uint8_t* rowB, const SkIRect& rectB);
 
-static void sectRowProc(SkAAClip::Builder& builder, int bottom,
-                        const uint8_t* rowA, const SkIRect& rectA,
-                        const uint8_t* rowB, const SkIRect& rectB) {
-    
-}
-
 typedef U8CPU (*AlphaProc)(U8CPU alphaA, U8CPU alphaB);
 
 static U8CPU sectAlphaProc(U8CPU alphaA, U8CPU alphaB) {
@@ -1434,6 +1431,7 @@
     }
 }
 
+#if 0 // UNUSED
 static bool intersect(int& min, int& max, int boundsMin, int boundsMax) {
     SkASSERT(min < max);
     SkASSERT(boundsMin < boundsMax);
@@ -1448,6 +1446,7 @@
     }
     return true;
 }
+#endif
 
 static void operatorX(SkAAClip::Builder& builder, int lastY,
                       RowIter& iterA, RowIter& iterB,
@@ -1975,8 +1974,8 @@
     unsigned g = SkGetPackedG16(value);
     unsigned b = SkGetPackedB16(value);
     return SkPackRGB16(SkMulDiv255Round(r, alpha),
-                       SkMulDiv255Round(r, alpha),
-                       SkMulDiv255Round(r, alpha));
+                       SkMulDiv255Round(g, alpha),
+                       SkMulDiv255Round(b, alpha));
 }
 static inline SkPMColor mergeOne(SkPMColor value, unsigned alpha) {
     unsigned a = SkGetPackedA32(value);
@@ -1992,7 +1991,6 @@
 template <typename T> void mergeT(const T* SK_RESTRICT src, int srcN,
                                  const uint8_t* SK_RESTRICT row, int rowN,
                                  T* SK_RESTRICT dst) {
-    SkDEBUGCODE(int accumulated = 0;)
     for (;;) {
         SkASSERT(rowN > 0);
         SkASSERT(srcN > 0);
diff --git a/src/core/SkBitmapProcState_matrix.h b/src/core/SkBitmapProcState_matrix.h
index 0fe0c19..5ea780e 100644
--- a/src/core/SkBitmapProcState_matrix.h
+++ b/src/core/SkBitmapProcState_matrix.h
@@ -26,6 +26,22 @@
     #define PREAMBLE_ARG_Y
 #endif
 
+// declare functions externally to suppress warnings.
+void SCALE_NOFILTER_NAME(const SkBitmapProcState& s,
+                                uint32_t xy[], int count, int x, int y);
+void AFFINE_NOFILTER_NAME(const SkBitmapProcState& s,
+                                 uint32_t xy[], int count, int x, int y);
+void PERSP_NOFILTER_NAME(const SkBitmapProcState& s,
+                                uint32_t* SK_RESTRICT xy,
+                                int count, int x, int y);
+void SCALE_FILTER_NAME(const SkBitmapProcState& s,
+                              uint32_t xy[], int count, int x, int y);
+void AFFINE_FILTER_NAME(const SkBitmapProcState& s,
+                               uint32_t xy[], int count, int x, int y);
+void PERSP_FILTER_NAME(const SkBitmapProcState& s,
+                              uint32_t* SK_RESTRICT xy, int count,
+                              int x, int y);
+
 void SCALE_NOFILTER_NAME(const SkBitmapProcState& s,
                                 uint32_t xy[], int count, int x, int y) {
     SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask |
@@ -189,7 +205,7 @@
     if (dx > 0 &&
             (unsigned)(fx >> 16) <= maxX &&
             (unsigned)((fx + dx * (count - 1)) >> 16) < maxX) {
-        decal_filter_scale(xy, fx, dx, count);
+        decal_filter_scale(xy, (SkFixed) fx, (SkFixed) dx, count);
     } else
 #endif
     {
diff --git a/src/core/SkBitmapProcState_sample.h b/src/core/SkBitmapProcState_sample.h
index e6b587f..7bd0080 100644
--- a/src/core/SkBitmapProcState_sample.h
+++ b/src/core/SkBitmapProcState_sample.h
@@ -23,6 +23,21 @@
     #error "unsupported DSTSIZE"
 #endif
 
+
+// declare functions externally to suppress warnings.
+void MAKENAME(_nofilter_DXDY)(const SkBitmapProcState& s,
+                              const uint32_t* SK_RESTRICT xy,
+                              int count, DSTTYPE* SK_RESTRICT colors);
+void MAKENAME(_nofilter_DX)(const SkBitmapProcState& s,
+                            const uint32_t* SK_RESTRICT xy,
+                            int count, DSTTYPE* SK_RESTRICT colors);
+void MAKENAME(_filter_DX)(const SkBitmapProcState& s,
+                          const uint32_t* SK_RESTRICT xy,
+                           int count, DSTTYPE* SK_RESTRICT colors);
+void MAKENAME(_filter_DXDY)(const SkBitmapProcState& s,
+                            const uint32_t* SK_RESTRICT xy,
+                            int count, DSTTYPE* SK_RESTRICT colors);
+
 void MAKENAME(_nofilter_DXDY)(const SkBitmapProcState& s,
                               const uint32_t* SK_RESTRICT xy,
                               int count, DSTTYPE* SK_RESTRICT colors) {
diff --git a/src/core/SkBlitMask_D32.cpp b/src/core/SkBlitMask_D32.cpp
index c97e9e6..6576acb 100644
--- a/src/core/SkBlitMask_D32.cpp
+++ b/src/core/SkBlitMask_D32.cpp
@@ -353,7 +353,9 @@
 static void A8_RowProc_Opaque(SkPMColor* SK_RESTRICT dst,
                               const uint8_t* SK_RESTRICT mask,
                               const SkPMColor* SK_RESTRICT src, int count) {
+#if 0 // suppress warning
     const uint32_t rbmask = gMask_00FF00FF;
+#endif
     for (int i = 0; i < count; ++i) {
         int m = mask[i];
         if (m) {
@@ -564,7 +566,8 @@
 
     static const RowProc gProcs[] = {
         // need X coordinate to handle BW
-        NULL, NULL, //(RowProc)BW_RowProc_Blend,      (RowProc)BW_RowProc_Opaque,
+        false ? (RowProc)BW_RowProc_Blend : NULL, // suppress unused warning
+        false ? (RowProc)BW_RowProc_Opaque : NULL, // suppress unused warning
         (RowProc)A8_RowProc_Blend,      (RowProc)A8_RowProc_Opaque,
         (RowProc)LCD16_RowProc_Blend,   (RowProc)LCD16_RowProc_Opaque,
         (RowProc)LCD32_RowProc_Blend,   (RowProc)LCD32_RowProc_Opaque,
diff --git a/src/core/SkConcaveToTriangles.cpp b/src/core/SkConcaveToTriangles.cpp
index 2ca6795..4821e69 100644
--- a/src/core/SkConcaveToTriangles.cpp
+++ b/src/core/SkConcaveToTriangles.cpp
@@ -34,6 +34,7 @@
 // - There is no need to use SkTDArray for everything. Use SkAutoTMalloc for
 //   everything else.
 
+#include "SkConcaveToTriangles.h"
 #include "SkTDArray.h"
 #include "SkGeometry.h"
 #include "SkTSort.h"
@@ -420,7 +421,7 @@
 };
 
 
-bool operator<(VertexPtr &v0, VertexPtr &v1) {
+static bool operator<(VertexPtr &v0, VertexPtr &v1) {
     // DebugPrintf("< %p %p\n", &v0, &v1);
     if (v0.vt->point().fY < v1.vt->point().fY)  return true;
     if (v0.vt->point().fY > v1.vt->point().fY)  return false;
@@ -429,14 +430,15 @@
 }
 
 
-bool operator>(VertexPtr &v0, VertexPtr &v1) {
+#if 0 // UNUSED
+static bool operator>(VertexPtr &v0, VertexPtr &v1) {
     // DebugPrintf("> %p %p\n", &v0, &v1);
     if (v0.vt->point().fY > v1.vt->point().fY)  return true;
     if (v0.vt->point().fY < v1.vt->point().fY)  return false;
     if (v0.vt->point().fX > v1.vt->point().fX)  return true;
     else                                        return false;
 }
-
+#endif
 
 static void SetVertexPoints(size_t numPts, const SkPoint *pt, Vertex *vt) {
     for (; numPts-- != 0; ++pt, ++vt)
@@ -675,7 +677,7 @@
 
 
 // Enhance the polygon with trapezoids.
-bool ConvertPointsToVertices(size_t numPts, const SkPoint *pts, Vertex *vta) {
+static bool ConvertPointsToVertices(size_t numPts, const SkPoint *pts, Vertex *vta) {
     DebugPrintf("ConvertPointsToVertices()\n");
 
     // Clear everything.
@@ -835,7 +837,7 @@
 }
 
 
-bool operator<(const SkPoint &p0, const SkPoint &p1) {
+static bool operator<(const SkPoint &p0, const SkPoint &p1) {
     if (p0.fY < p1.fY)  return true;
     if (p0.fY > p1.fY)  return false;
     if (p0.fX < p1.fX)  return true;
@@ -854,7 +856,7 @@
 
 
 // Triangulate an unimonotone chain.
-bool TriangulateMonotone(Vertex *first, Vertex *last,
+static bool TriangulateMonotone(Vertex *first, Vertex *last,
                          SkTDArray<SkPoint> *triangles) {
     DebugPrintf("TriangulateMonotone()\n");
 
@@ -915,7 +917,7 @@
 
 // Split the polygon into sets of unimonotone chains, and eventually call
 // TriangulateMonotone() to convert them into triangles.
-bool Triangulate(Vertex *first, Vertex *last, SkTDArray<SkPoint> *triangles) {
+static bool Triangulate(Vertex *first, Vertex *last, SkTDArray<SkPoint> *triangles) {
     DebugPrintf("Triangulate()\n");
     Vertex *currentVertex = first;
     while (!currentVertex->done()) {
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index 5f63651..a9693c2 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -479,7 +479,6 @@
 void SkPath::moveTo(SkScalar x, SkScalar y) {
     SkDEBUGCODE(this->validate();)
 
-    int      vc = fVerbs.count();
     SkPoint* pt;
 
     // remember our index
@@ -1206,7 +1205,6 @@
 void SkPath::reverseAddPath(const SkPath& src) {
     this->incReserve(src.fPts.count());
 
-    const SkPoint* startPts = src.fPts.begin();
     const SkPoint* pts = src.fPts.end();
     const uint8_t* startVerbs = src.fVerbs.begin();
     const uint8_t* verbs = src.fVerbs.end();
diff --git a/src/core/SkPixelRef.cpp b/src/core/SkPixelRef.cpp
index 88ce76f..310b74d 100644
--- a/src/core/SkPixelRef.cpp
+++ b/src/core/SkPixelRef.cpp
@@ -19,7 +19,7 @@
     SK_DECLARE_STATIC_MUTEX(gPixelRefMutex);
 #endif
 
-SkBaseMutex* get_default_mutex() {
+static SkBaseMutex* get_default_mutex() {
 #ifdef PIXELREF_MUTEX_RING_COUNT
     // atomic_inc might be overkill here. It may be fine if once in a while
     // we hit a race-condition and two subsequent calls get the same index...
diff --git a/src/core/SkPoint.cpp b/src/core/SkPoint.cpp
index c51b7ca..488bacb 100644
--- a/src/core/SkPoint.cpp
+++ b/src/core/SkPoint.cpp
@@ -110,7 +110,7 @@
     float mag2;
     if (!isLengthNearlyZero(pt->fX, pt->fY, &mag2)) {
         float mag = sk_float_sqrt(mag2);
-        float scale = 1.0 / mag;
+        float scale = 1.0f / mag;
         pt->fX = pt->fX * scale;
         pt->fY = pt->fY * scale;
         return mag;
diff --git a/src/core/SkRegion.cpp b/src/core/SkRegion.cpp
index fac948d..e403b19 100644
--- a/src/core/SkRegion.cpp
+++ b/src/core/SkRegion.cpp
@@ -925,10 +925,12 @@
     interval, but we can first trim off the const overhead of the initial TOP
     value, plus the final BOTTOM + 2 sentinels.
  */
+#if 0 // UNUSED
 static int count_to_intervals(int count) {
     SkASSERT(count >= 6);   // a single rect is 6 values
     return (count - 4) >> 1;
 }
+#endif
 
 /*  Given a number of intervals, what is the worst case representation of that
     many intervals?
diff --git a/src/core/SkScalerContext.cpp b/src/core/SkScalerContext.cpp
index d47c314..2cce8ab 100644
--- a/src/core/SkScalerContext.cpp
+++ b/src/core/SkScalerContext.cpp
@@ -341,11 +341,14 @@
     glyph->fMaskFormat = fRec.fMaskFormat;
 }
 
+#if 0 // UNUSED
 static bool isLCD(const SkScalerContext::Rec& rec) {
     return SkMask::kLCD16_Format == rec.fMaskFormat ||
            SkMask::kLCD32_Format == rec.fMaskFormat;
 }
+#endif
 
+#if 0 // UNUSED
 static uint16_t a8_to_rgb565(unsigned a8) {
     return SkPackRGB16(a8 >> 3, a8 >> 2, a8 >> 3);
 }
@@ -368,6 +371,7 @@
         dstP = (uint16_t*)((char*)dstP + dstRB);
     }
 }
+#endif
 
 #define SK_FREETYPE_LCD_LERP    160
 
diff --git a/src/core/SkScan_AntiPath.cpp b/src/core/SkScan_AntiPath.cpp
index 914d813..153778e 100644
--- a/src/core/SkScan_AntiPath.cpp
+++ b/src/core/SkScan_AntiPath.cpp
@@ -235,6 +235,7 @@
 #endif
 }
 
+#if 0 // UNUSED
 static void set_left_rite_runs(SkAlphaRuns& runs, int ileft, U8CPU leftA,
                                int n, U8CPU riteA) {
     SkASSERT(leftA <= 0xFF);
@@ -270,6 +271,7 @@
     }
     run[0] = 0;
 }
+#endif
 
 void SuperBlitter::blitRect(int x, int y, int width, int height) {
     SkASSERT(width > 0);
diff --git a/src/core/SkString.cpp b/src/core/SkString.cpp
index 0e0318b..85fecc9 100644
--- a/src/core/SkString.cpp
+++ b/src/core/SkString.cpp
@@ -101,7 +101,7 @@
     }
 
     do {
-        *--p = SkToU8('0' + dec % 10);
+        *--p = SkToU8('0' + (int32_t) (dec % 10));
         dec /= 10;
         minDigits--;
     } while (dec != 0);