fix warnings around size_t/int
fix warnings around undeclared (non-static) functions

TBR=bsalomon@google.com

Author: reed@google.com

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

git-svn-id: http://skia.googlecode.com/svn/trunk@14267 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/core/SkDescriptor.h b/src/core/SkDescriptor.h
index e71ff41..c526451 100644
--- a/src/core/SkDescriptor.h
+++ b/src/core/SkDescriptor.h
@@ -37,14 +37,14 @@
 
     uint32_t getLength() const { return fLength; }
 
-    void* addEntry(uint32_t tag, uint32_t length, const void* data = NULL) {
+    void* addEntry(uint32_t tag, size_t length, const void* data = NULL) {
         SkASSERT(tag);
         SkASSERT(SkAlign4(length) == length);
         SkASSERT(this->findEntry(tag, NULL) == NULL);
 
         Entry*  entry = (Entry*)((char*)this + fLength);
         entry->fTag = tag;
-        entry->fLen = length;
+        entry->fLen = SkToU32(length);
         if (data) {
             memcpy(entry + 1, data, length);
         }
diff --git a/src/core/SkDistanceFieldGen.cpp b/src/core/SkDistanceFieldGen.cpp
index aec5f1d..ef0ee86 100755
--- a/src/core/SkDistanceFieldGen.cpp
+++ b/src/core/SkDistanceFieldGen.cpp
@@ -329,9 +329,9 @@
 
 // assumes a padded 8-bit image and distance field
 // width and height are the original width and height of the image
-bool generate_distance_field_from_image(unsigned char* distanceField,
-                                        const unsigned char* copyPtr,
-                                        int width, int height) {
+static bool generate_distance_field_from_image(unsigned char* distanceField,
+                                               const unsigned char* copyPtr,
+                                               int width, int height) {
     SkASSERT(NULL != distanceField);
     SkASSERT(NULL != copyPtr);
 
diff --git a/src/core/SkPackBits.cpp b/src/core/SkPackBits.cpp
index 7a1444b..3c6197b 100644
--- a/src/core/SkPackBits.cpp
+++ b/src/core/SkPackBits.cpp
@@ -10,7 +10,7 @@
 #define GATHER_STATSx
 
 static inline void small_memcpy(void* SK_RESTRICT dst,
-                                const void* SK_RESTRICT src, int n) {
+                                const void* SK_RESTRICT src, size_t n) {
     SkASSERT(n > 0 && n <= 15);
     uint8_t* d = (uint8_t*)dst;
     const uint8_t* s = (const uint8_t*)src;
@@ -34,7 +34,7 @@
     }
 }
 
-static inline void small_memset(void* dst, uint8_t value, int n) {
+static inline void small_memset(void* dst, uint8_t value, size_t n) {
     SkASSERT(n > 0 && n <= 15);
     uint8_t* d = (uint8_t*)dst;
     switch (n) {
@@ -196,7 +196,7 @@
     const uint16_t* stop = src + count;
 
     for (;;) {
-        count = stop - src;
+        count = SkToInt(stop - src);
         SkASSERT(count >= 0);
         if (count == 0) {
             return dst - origDst;
@@ -218,7 +218,7 @@
                     break;
                 }
             } while (*s == value);
-            dst = flush_same16(dst, value, s - src);
+            dst = flush_same16(dst, value, SkToInt(s - src));
         } else {    // accumulate diff values...
             do {
                 if (++s == stop) {
@@ -227,7 +227,7 @@
             } while (*s != s[-1]);
             s -= 1; // back up so we don't grab one of the "same" values that follow
         FLUSH_DIFF:
-            dst = flush_diff16(dst, src, s - src);
+            dst = flush_diff16(dst, src, SkToInt(s - src));
         }
         src = s;
     }
@@ -239,7 +239,7 @@
     const uint8_t* stop = src + count;
 
     for (;;) {
-        count = stop - src;
+        count = SkToInt(stop - src);
         SkASSERT(count >= 0);
         if (count == 0) {
             return dst - origDst;
@@ -260,7 +260,7 @@
                     break;
                 }
             } while (*s == value);
-            dst = flush_same8(dst, value, s - src);
+            dst = flush_same8(dst, value, SkToInt(s - src));
         } else {    // accumulate diff values...
             do {
                 if (++s == stop) {
@@ -271,7 +271,7 @@
             } while (*s != s[-1] || s[-1] != s[-2]);
             s -= 2; // back up so we don't grab the "same" values that follow
         FLUSH_DIFF:
-            dst = flush_diff8(dst, src, s - src);
+            dst = flush_diff8(dst, src, SkToInt(s - src));
         }
         src = s;
     }
@@ -298,7 +298,7 @@
         dst += n;
     }
     SkASSERT(src == stop);
-    return dst - origDst;
+    return SkToInt(dst - origDst);
 }
 
 int SkPackBits::Unpack8(const uint8_t* SK_RESTRICT src, size_t srcSize,
@@ -319,7 +319,7 @@
         dst += n;
     }
     SkASSERT(src == stop);
-    return dst - origDst;
+    return SkToInt(dst - origDst);
 }
 
 enum UnpackState {
@@ -339,7 +339,7 @@
 
     // state 1: do the skip-loop
     while (dstSkip > 0) {
-        unsigned n = *src++;
+        size_t n = *src++;
         if (n <= 127) {   // repeat count (n + 1)
             n += 1;
             if (n > dstSkip) {
@@ -387,7 +387,7 @@
 
     // copy at most dstWrite bytes into dst[]
     while (dstWrite > 0) {
-        unsigned n = *src++;
+        size_t n = *src++;
         if (n <= 127) {   // repeat count (n + 1)
             n += 1;
             if (n > dstWrite) {
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp
index 241175e..176992f 100644
--- a/src/core/SkPaint.cpp
+++ b/src/core/SkPaint.cpp
@@ -536,12 +536,11 @@
         case kUTF8_TextEncoding:
             return SkUTF8_CountUnichars((const char*)textData, byteLength);
         case kUTF16_TextEncoding:
-            return SkUTF16_CountUnichars((const uint16_t*)textData,
-                                         byteLength >> 1);
+            return SkUTF16_CountUnichars((const uint16_t*)textData, SkToInt(byteLength >> 1));
         case kUTF32_TextEncoding:
-            return byteLength >> 2;
+            return SkToInt(byteLength >> 2);
         case kGlyphID_TextEncoding:
-            return byteLength >> 1;
+            return SkToInt(byteLength >> 1);
         default:
             SkDEBUGFAIL("unknown text encoding");
         }
@@ -554,7 +553,7 @@
     if (this->getTextEncoding() == kGlyphID_TextEncoding) {
         // we want to ignore the low bit of byteLength
         memcpy(glyphs, textData, byteLength >> 1 << 1);
-        return byteLength >> 1;
+        return SkToInt(byteLength >> 1);
     }
 
     SkAutoGlyphCache autoCache(*this, NULL, NULL);
@@ -589,7 +588,7 @@
         default:
             SkDEBUGFAIL("unknown text encoding");
     }
-    return gptr - glyphs;
+    return SkToInt(gptr - glyphs);
 }
 
 bool SkPaint::containsText(const void* textData, size_t byteLength) const {
diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp
index 52ea56d..ba18392 100644
--- a/src/core/SkPicturePlayback.cpp
+++ b/src/core/SkPicturePlayback.cpp
@@ -310,14 +310,14 @@
 
 #include "SkStream.h"
 
-static void write_tag_size(SkWriteBuffer& buffer, uint32_t tag, uint32_t size) {
+static void write_tag_size(SkWriteBuffer& buffer, uint32_t tag, size_t size) {
     buffer.writeUInt(tag);
     buffer.writeUInt(size);
 }
 
-static void write_tag_size(SkWStream* stream, uint32_t tag,  uint32_t size) {
+static void write_tag_size(SkWStream* stream, uint32_t tag,  size_t size) {
     stream->write32(tag);
-    stream->write32(size);
+    stream->write32(SkToU32(size));
 }
 
 static size_t compute_chunk_size(SkFlattenable::Factory* array, int count) {
@@ -357,7 +357,7 @@
         if (NULL == name || 0 == *name) {
             stream->writePackedUInt(0);
         } else {
-            uint32_t len = strlen(name);
+            size_t len = strlen(name);
             stream->writePackedUInt(len);
             stream->write(name, len);
         }
diff --git a/src/gpu/GrTHashTable.h b/src/gpu/GrTHashTable.h
index 83462c7..9307425 100644
--- a/src/gpu/GrTHashTable.h
+++ b/src/gpu/GrTHashTable.h
@@ -61,7 +61,10 @@
         kHashCount = 1 << kHashBits,
         kHashMask  = kHashCount - 1
     };
-    static unsigned hash2Index(uint32_t hash) {
+    static unsigned hash2Index(intptr_t hash) {
+        if (sizeof(hash) == 8) {
+            hash ^= hash >> 32;
+        }
         hash ^= hash >> 16;
         if (kHashBits <= 8) {
             hash ^= hash >> 8;
diff --git a/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp b/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp
index 2751e02..cbfbb26 100644
--- a/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp
+++ b/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp
@@ -712,7 +712,7 @@
         case GR_GL_BUFFER_SIZE:
             *params = 0;
             if (buffer)
-                *params = buffer->getSize();
+                *params = SkToInt(buffer->getSize());
             break;
         case GR_GL_BUFFER_USAGE:
             *params = GR_GL_STATIC_DRAW;
diff --git a/src/utils/SkLuaCanvas.cpp b/src/utils/SkLuaCanvas.cpp
index 7e1d5a8..531cbb0 100644
--- a/src/utils/SkLuaCanvas.cpp
+++ b/src/utils/SkLuaCanvas.cpp
@@ -168,7 +168,7 @@
 void SkLuaCanvas::drawPoints(PointMode mode, size_t count,
                                const SkPoint pts[], const SkPaint& paint) {
     AUTO_LUA("drawPoints");
-    lua.pushArrayPoint(pts, count, "points");
+    lua.pushArrayPoint(pts, SkToInt(count), "points");
     lua.pushPaint(paint, "paint");
 }
 
diff --git a/src/utils/SkMatrix22.cpp b/src/utils/SkMatrix22.cpp
index 107e123..a13b729 100644
--- a/src/utils/SkMatrix22.cpp
+++ b/src/utils/SkMatrix22.cpp
@@ -6,6 +6,7 @@
  */
 
 #include "SkMatrix.h"
+#include "SkMatrix22.h"
 #include "SkPoint.h"
 #include "SkScalar.h"
 
diff --git a/src/utils/SkMatrix22.h b/src/utils/SkMatrix22.h
index d0f4ed3..bc567ea 100644
--- a/src/utils/SkMatrix22.h
+++ b/src/utils/SkMatrix22.h
@@ -5,6 +5,9 @@
  * found in the LICENSE file.
  */
 
+#ifndef SkMatrix22_DEFINED
+#define SkMatrix22_DEFINED
+
 #include "SkPoint.h"
 
 class SkMatrix;
@@ -24,3 +27,5 @@
  *  and saves a multiply by not computing r.
  */
 void SkComputeGivensRotation(const SkVector& h, SkMatrix* G);
+
+#endif