Third wave of Win64 warning cleanup

https://codereview.chromium.org/27487003/



git-svn-id: http://skia.googlecode.com/svn/trunk@11817 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/bench/benchmain.cpp b/bench/benchmain.cpp
index 944b114..ae20a8d 100644
--- a/bench/benchmain.cpp
+++ b/bench/benchmain.cpp
@@ -331,7 +331,7 @@
     bool runDefaultConfigs = false;
     // Try user-given configs first.
     for (int i = 0; i < FLAGS_config.count(); i++) {
-        for (size_t j = 0; j < SK_ARRAY_COUNT(gConfigs); j++) {
+        for (int j = 0; j < static_cast<int>(SK_ARRAY_COUNT(gConfigs)); ++j) {
             if (0 == strcmp(FLAGS_config[i], gConfigs[j].name)) {
                 *configs.append() = j;
             } else if (0 == strcmp(FLAGS_config[i], kDefaultsConfigStr)) {
@@ -341,7 +341,7 @@
     }
     // If there weren't any, fill in with defaults.
     if (runDefaultConfigs) {
-        for (size_t i = 0; i < SK_ARRAY_COUNT(gConfigs); ++i) {
+        for (int i = 0; i < static_cast<int>(SK_ARRAY_COUNT(gConfigs)); ++i) {
             if (gConfigs[i].runByDefault) {
                 *configs.append() = i;
             }
diff --git a/gm/canvasstate.cpp b/gm/canvasstate.cpp
index d3eb84e..f2761da 100644
--- a/gm/canvasstate.cpp
+++ b/gm/canvasstate.cpp
@@ -71,7 +71,7 @@
 
         // columns -- flags
         // rows -- permutations of setting the clip and matrix
-        for (size_t i = 0; i < SK_ARRAY_COUNT(flags); ++i) {
+        for (int i = 0; i < static_cast<int>(SK_ARRAY_COUNT(flags)); ++i) {
             for (int j = 0; j < 2; ++j) {
                 for (int k = 0; k < 2; ++k) {
                     this->drawTestPattern(i, (2*j)+k, canvas, flags[i],
diff --git a/gm/shadertext.cpp b/gm/shadertext.cpp
index adcb25e..412516b 100644
--- a/gm/shadertext.cpp
+++ b/gm/shadertext.cpp
@@ -183,7 +183,7 @@
         static const int rowHeight = 60;
         static const int colWidth = 300;
         canvas->save();
-        for (size_t s = 0; s < SK_ARRAY_COUNT(shaders); s++) {
+        for (int s = 0; s < static_cast<int>(SK_ARRAY_COUNT(shaders)); s++) {
             canvas->save();
             int i = 2*s;
             canvas->translate(SkIntToScalar((i / testsPerCol) * colWidth),
diff --git a/gm/texteffects.cpp b/gm/texteffects.cpp
index b46753d..7964de9 100644
--- a/gm/texteffects.cpp
+++ b/gm/texteffects.cpp
@@ -194,7 +194,7 @@
 
         SkString str("Hamburgefons");
 
-        for (size_t i = 0; i < SK_ARRAY_COUNT(gRastProcs); i++) {
+        for (int i = 0; i < static_cast<int>(SK_ARRAY_COUNT(gRastProcs)); i++) {
             apply_shader(&paint, i);
 
             //  paint.setMaskFilter(NULL);
diff --git a/include/core/SkTDArray.h b/include/core/SkTDArray.h
index 8b8bb01..c5e7a02 100644
--- a/include/core/SkTDArray.h
+++ b/include/core/SkTDArray.h
@@ -21,7 +21,7 @@
         fData = NULL;
 #endif
     }
-    SkTDArray(const T src[], size_t count) {
+    SkTDArray(const T src[], int count) {
         SkASSERT(src || count == 0);
 
         fReserve = fCount = 0;
@@ -98,7 +98,7 @@
     /**
      *  Return the number of elements in the array
      */
-    int count() const { return (int)fCount; }
+    int count() const { return fCount; }
 
     /**
      *  return the number of bytes in the array: count * sizeof(T)
@@ -111,11 +111,11 @@
     const T*  end() const { return fArray ? fArray + fCount : NULL; }
 
     T&  operator[](int index) {
-        SkASSERT((unsigned)index < fCount);
+        SkASSERT(index < fCount);
         return fArray[index];
     }
     const T&  operator[](int index) const {
-        SkASSERT((unsigned)index < fCount);
+        SkASSERT(index < fCount);
         return fArray[index];
     }
 
@@ -144,7 +144,7 @@
         fCount = 0;
     }
 
-    void setCount(size_t count) {
+    void setCount(int count) {
         if (count > fReserve) {
             this->growBy(count - fCount);
         } else {
@@ -152,10 +152,10 @@
         }
     }
 
-    void setReserve(size_t reserve) {
+    void setReserve(int reserve) {
         if (reserve > fReserve) {
             SkASSERT(reserve > fCount);
-            size_t count = fCount;
+            int count = fCount;
             this->growBy(reserve - fCount);
             fCount = count;
         }
@@ -170,8 +170,8 @@
     T* append() {
         return this->append(1, NULL);
     }
-    T* append(size_t count, const T* src = NULL) {
-        size_t oldCount = fCount;
+    T* append(int count, const T* src = NULL) {
+        int oldCount = fCount;
         if (count)  {
             SkASSERT(src == NULL || fArray == NULL ||
                     src + count <= fArray || fArray + oldCount <= src);
@@ -190,10 +190,10 @@
         return result;
     }
 
-    T* insert(size_t index) {
+    T* insert(int index) {
         return this->insert(index, 1, NULL);
     }
-    T* insert(size_t index, size_t count, const T* src = NULL) {
+    T* insert(int index, int count, const T* src = NULL) {
         SkASSERT(count);
         SkASSERT(index <= fCount);
         size_t oldCount = fCount;
@@ -206,15 +206,15 @@
         return dst;
     }
 
-    void remove(size_t index, size_t count = 1) {
+    void remove(int index, int count = 1) {
         SkASSERT(index + count <= fCount);
         fCount = fCount - count;
         memmove(fArray + index, fArray + index + count, sizeof(T) * (fCount - index));
     }
 
-    void removeShuffle(size_t index) {
+    void removeShuffle(int index) {
         SkASSERT(index < fCount);
-        size_t newCount = fCount - 1;
+        int newCount = fCount - 1;
         fCount = newCount;
         if (index != newCount) {
             memcpy(fArray + index, fArray + newCount, sizeof(T));
@@ -256,7 +256,7 @@
      * Copies up to max elements into dst. The number of items copied is
      * capped by count - index. The actual number copied is returned.
      */
-    int copyRange(T* dst, size_t index, int max) const {
+    int copyRange(T* dst, int index, int max) const {
         SkASSERT(max >= 0);
         SkASSERT(!max || dst);
         if (index >= fCount) {
@@ -346,13 +346,14 @@
     ArrayT* fData;
 #endif
     T*      fArray;
-    size_t  fReserve, fCount;
+    int     fReserve;
+    int     fCount;
 
-    void growBy(size_t extra) {
+    void growBy(int extra) {
         SkASSERT(extra);
 
         if (fCount + extra > fReserve) {
-            size_t size = fCount + extra + 4;
+            int size = fCount + extra + 4;
             size += size >> 2;
 
             fArray = (T*)sk_realloc_throw(fArray, size * sizeof(T));
diff --git a/src/gpu/gl/GrGLBufferImpl.cpp b/src/gpu/gl/GrGLBufferImpl.cpp
index 1d77070..3c75b9f 100644
--- a/src/gpu/gl/GrGLBufferImpl.cpp
+++ b/src/gpu/gl/GrGLBufferImpl.cpp
@@ -78,7 +78,7 @@
         this->bind(gpu);
         // Let driver know it can discard the old data
         GL_CALL(gpu, BufferData(fBufferType,
-                                fDesc.fSizeInBytes,
+                                (GrGLsizeiptr) fDesc.fSizeInBytes,
                                 NULL,
                                 fDesc.fDynamic ? DYNAMIC_USAGE_PARAM : GR_GL_STATIC_DRAW));
         GR_GL_CALL_RET(gpu->glInterface(),
@@ -119,7 +119,7 @@
 
 #if GR_GL_USE_BUFFER_DATA_NULL_HINT
     if (fDesc.fSizeInBytes == srcSizeInBytes) {
-        GL_CALL(gpu, BufferData(fBufferType, srcSizeInBytes, src, usage));
+        GL_CALL(gpu, BufferData(fBufferType, (GrGLsizeiptr) srcSizeInBytes, src, usage));
     } else {
         // Before we call glBufferSubData we give the driver a hint using
         // glBufferData with NULL. This makes the old buffer contents
@@ -127,8 +127,8 @@
         // draws that reference the old contents. With this hint it can
         // assign a different allocation for the new contents to avoid
         // flushing the gpu past draws consuming the old contents.
-        GL_CALL(gpu, BufferData(fBufferType, fDesc.fSizeInBytes, NULL, usage));
-        GL_CALL(gpu, BufferSubData(fBufferType, 0, srcSizeInBytes, src));
+        GL_CALL(gpu, BufferData(fBufferType, (GrGLsizeiptr) fDesc.fSizeInBytes, NULL, usage));
+        GL_CALL(gpu, BufferSubData(fBufferType, 0, (GrGLsizeiptr) srcSizeInBytes, src));
     }
 #else
     // Note that we're cheating on the size here. Currently no methods
diff --git a/src/gpu/gl/GrGLShaderBuilder.cpp b/src/gpu/gl/GrGLShaderBuilder.cpp
index 8b7d614..7194240 100644
--- a/src/gpu/gl/GrGLShaderBuilder.cpp
+++ b/src/gpu/gl/GrGLShaderBuilder.cpp
@@ -630,7 +630,7 @@
     }
 
     const GrGLchar* sourceStr = shaderSrc.c_str();
-    int sourceLength = shaderSrc.size();
+    GrGLint sourceLength = static_cast<GrGLint>(shaderSrc.size());
     GR_GL_CALL(gli, ShaderSource(shaderId, 1, &sourceStr, &sourceLength));
 
     GrGLint compiled = GR_GL_INIT_ZERO;
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp
index f0815a6..0642fc4 100644
--- a/src/gpu/gl/GrGpuGL.cpp
+++ b/src/gpu/gl/GrGpuGL.cpp
@@ -1167,7 +1167,7 @@
             // make sure driver can allocate memory for this buffer
             GL_ALLOC_CALL(this->glInterface(),
                           BufferData(GR_GL_ARRAY_BUFFER,
-                                     desc.fSizeInBytes,
+                                     (GrGLsizeiptr) desc.fSizeInBytes,
                                      NULL,   // data ptr
                                      desc.fDynamic ? GR_GL_DYNAMIC_DRAW : GR_GL_STATIC_DRAW));
             if (CHECK_ALLOC_ERROR(this->glInterface()) != GR_GL_NO_ERROR) {
@@ -1200,7 +1200,7 @@
             // make sure driver can allocate memory for this buffer
             GL_ALLOC_CALL(this->glInterface(),
                           BufferData(GR_GL_ELEMENT_ARRAY_BUFFER,
-                                     desc.fSizeInBytes,
+                                     (GrGLsizeiptr) desc.fSizeInBytes,
                                      NULL,  // data ptr
                                      desc.fDynamic ? GR_GL_DYNAMIC_DRAW : GR_GL_STATIC_DRAW));
             if (CHECK_ALLOC_ERROR(this->glInterface()) != GR_GL_NO_ERROR) {
@@ -1448,7 +1448,8 @@
     if (rowBytes != tightRowBytes) {
         if (this->glCaps().packRowLengthSupport()) {
             SkASSERT(!(rowBytes % sizeof(GrColor)));
-            GL_CALL(PixelStorei(GR_GL_PACK_ROW_LENGTH, rowBytes / sizeof(GrColor)));
+            GL_CALL(PixelStorei(GR_GL_PACK_ROW_LENGTH, 
+                                static_cast<GrGLint>(rowBytes / sizeof(GrColor))));
             readDstRowBytes = rowBytes;
         } else {
             scratch.reset(tightRowBytes * height);
diff --git a/src/pdf/SkTSet.h b/src/pdf/SkTSet.h
index 1609a9d..f57d30e 100644
--- a/src/pdf/SkTSet.h
+++ b/src/pdf/SkTSet.h
@@ -199,7 +199,7 @@
 
     /** Reserves memory for the set.
      */
-    void setReserve(size_t reserve) {
+    void setReserve(int reserve) {
         SkASSERT(fSetArray);
         SkASSERT(fOrderedArray);
         fSetArray->setReserve(reserve);
diff --git a/src/utils/SkPDFRasterizer.cpp b/src/utils/SkPDFRasterizer.cpp
index bf0ab25..a3b4cb4 100644
--- a/src/utils/SkPDFRasterizer.cpp
+++ b/src/utils/SkPDFRasterizer.cpp
@@ -38,7 +38,7 @@
     return false;
   }
 
-  size_t width = image.width(), height = image.height();
+  int width = image.width(), height = image.height();
   size_t rowSize = image.bytes_per_row();
   char *imgData = image.data();
 
@@ -51,9 +51,9 @@
   SkPMColor* bitmapPixels = (SkPMColor*)bitmap.getPixels();
 
   // do pixel-by-pixel copy to deal with RGBA ordering conversions
-  for (size_t y = 0; y < height; y++) {
+  for (int y = 0; y < height; y++) {
     char *rowData = imgData;
-    for (size_t x = 0; x < width; x++) {
+    for (int x = 0; x < width; x++) {
       uint8_t a = rowData[3];
       uint8_t r = rowData[2];
       uint8_t g = rowData[1];
diff --git a/tests/BitmapCopyTest.cpp b/tests/BitmapCopyTest.cpp
index 81fde73..cccde8a 100644
--- a/tests/BitmapCopyTest.cpp
+++ b/tests/BitmapCopyTest.cpp
@@ -415,7 +415,7 @@
                 reporter->reportFailed(str);
             }
 
-            size_t subW, subH;
+            int subW, subH;
             // Set sizes to be height = 2 to force the last row of the
             // source to be used, thus verifying correct operation if
             // the bitmap is an extracted subset.
@@ -472,7 +472,7 @@
                 // To simplify verifying correctness of copies attach
                 // buf to a SkBitmap, but copies are done using the
                 // raw buffer pointer.
-                const uint32_t bufSize = subH *
+                const size_t bufSize = subH *
                     SkBitmap::ComputeRowBytes(src.getConfig(), subW) * 2;
                 SkAutoMalloc autoBuf (bufSize);
                 uint8_t* buf = static_cast<uint8_t*>(autoBuf.get());
@@ -482,8 +482,8 @@
 
                 // Set up values for each pixel being copied.
                 Coordinates coords(subW * subH);
-                for (size_t x = 0; x < subW; ++x)
-                    for (size_t y = 0; y < subH; ++y)
+                for (int x = 0; x < subW; ++x)
+                    for (int y = 0; y < subH; ++y)
                     {
                         int index = y * subW + x;
                         SkASSERT(index < coords.length);
diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp
index a42112d..c7ddcbc 100644
--- a/tests/PictureTest.cpp
+++ b/tests/PictureTest.cpp
@@ -191,7 +191,7 @@
             SkAutoDataUnref data(SkPictureUtils::GatherPixelRefs(pic, r));
             REPORTER_ASSERT(reporter, data);
             if (data) {
-                int count = data->size() / sizeof(SkPixelRef*);
+                int count = static_cast<int>(data->size() / sizeof(SkPixelRef*));
                 REPORTER_ASSERT(reporter, 1 == count);
                 REPORTER_ASSERT(reporter, *(SkPixelRef**)data->data() == refs[i]);
             }
@@ -209,7 +209,7 @@
 
             SkData* data = SkPictureUtils::GatherPixelRefs(pic, r);
             size_t dataSize = data ? data->size() : 0;
-            int gatherCount = dataSize / sizeof(SkPixelRef*);
+            int gatherCount = static_cast<int>(dataSize / sizeof(SkPixelRef*));
             SkASSERT(gatherCount * sizeof(SkPixelRef*) == dataSize);
             SkPixelRef** gatherRefs = data ? (SkPixelRef**)(data->data()) : NULL;
             SkAutoDataUnref adu(data);