Start cleaning up 64bit Win warnings

https://codereview.chromium.org/27192003/



git-svn-id: http://skia.googlecode.com/svn/trunk/src@11764 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/core/SkOrderedWriteBuffer.h b/core/SkOrderedWriteBuffer.h
index 180f9a4..277b7bf 100644
--- a/core/SkOrderedWriteBuffer.h
+++ b/core/SkOrderedWriteBuffer.h
@@ -42,9 +42,9 @@
     void writeToMemory(void* dst) { fWriter.flatten(dst); }
     uint32_t* reserve(size_t size) { return fWriter.reserve(size); }
 
-    uint32_t bytesWritten() const { return fWriter.bytesWritten(); }
+    size_t bytesWritten() const { return fWriter.bytesWritten(); }
     // Deprecated.  Please call bytesWritten instead.  TODO(mtklein): clean up
-    uint32_t size() const { return this->bytesWritten(); }
+    size_t size() const { return this->bytesWritten(); }
 
     virtual void writeByteArray(const void* data, size_t size) SK_OVERRIDE;
     virtual void writeBool(bool value) SK_OVERRIDE;
diff --git a/core/SkRTree.cpp b/core/SkRTree.cpp
index b6f8e95..e3d2eb6 100644
--- a/core/SkRTree.cpp
+++ b/core/SkRTree.cpp
@@ -406,7 +406,7 @@
     if (this->isEmpty()) {
         return;
     }
-    SkASSERT(fCount == (size_t)this->validateSubtree(fRoot.fChild.subtree, fRoot.fBounds, true));
+    SkASSERT(fCount == this->validateSubtree(fRoot.fChild.subtree, fRoot.fBounds, true));
 #endif
 }
 
diff --git a/core/SkRTree.h b/core/SkRTree.h
index 54421de..2f905e7 100644
--- a/core/SkRTree.h
+++ b/core/SkRTree.h
@@ -179,7 +179,7 @@
     const size_t fNodeSize;
 
     // This is the count of data elements (rather than total nodes in the tree)
-    size_t fCount;
+    int fCount;
 
     Branch fRoot;
     SkChunkAlloc fNodes;
diff --git a/gpu/GrBufferAllocPool.cpp b/gpu/GrBufferAllocPool.cpp
index 887f8cd..b34fe8a 100644
--- a/gpu/GrBufferAllocPool.cpp
+++ b/gpu/GrBufferAllocPool.cpp
@@ -203,9 +203,9 @@
         const BufferBlock& back = fBlocks.back();
         size_t usedBytes = back.fBuffer->sizeInBytes() - back.fBytesFree;
         size_t pad = GrSizeAlignUpPad(usedBytes, itemSize);
-        return (back.fBytesFree - pad) / itemSize;
+        return static_cast<int>((back.fBytesFree - pad) / itemSize);
     } else if (fPreallocBuffersInUse < fPreallocBuffers.count()) {
-        return fMinBlockSize / itemSize;
+        return static_cast<int>(fMinBlockSize / itemSize);
     }
     return 0;
 }
@@ -404,7 +404,7 @@
 
     *buffer = (const GrVertexBuffer*) geomBuffer;
     SkASSERT(0 == offset % vertexSize);
-    *startVertex = offset / vertexSize;
+    *startVertex = static_cast<int>(offset / vertexSize);
     return ptr;
 }
 
@@ -425,7 +425,7 @@
 }
 
 int GrVertexBufferAllocPool::preallocatedBufferVertices(size_t vertexSize) const {
-    return INHERITED::preallocatedBufferSize() / vertexSize;
+    return static_cast<int>(INHERITED::preallocatedBufferSize() / vertexSize);
 }
 
 int GrVertexBufferAllocPool::currentBufferVertices(size_t vertexSize) const {
@@ -462,7 +462,7 @@
 
     *buffer = (const GrIndexBuffer*) geomBuffer;
     SkASSERT(0 == offset % sizeof(uint16_t));
-    *startIndex = offset / sizeof(uint16_t);
+    *startIndex = static_cast<int>(offset / sizeof(uint16_t));
     return ptr;
 }
 
@@ -480,7 +480,7 @@
 }
 
 int GrIndexBufferAllocPool::preallocatedBufferIndices() const {
-    return INHERITED::preallocatedBufferSize() / sizeof(uint16_t);
+    return static_cast<int>(INHERITED::preallocatedBufferSize() / sizeof(uint16_t));
 }
 
 int GrIndexBufferAllocPool::currentBufferIndices() const {
diff --git a/gpu/GrDefaultPathRenderer.cpp b/gpu/GrDefaultPathRenderer.cpp
index bd52ce1..85485c8 100644
--- a/gpu/GrDefaultPathRenderer.cpp
+++ b/gpu/GrDefaultPathRenderer.cpp
@@ -317,8 +317,8 @@
     SkASSERT((vert - base) <= maxPts);
     SkASSERT((idx - idxBase) <= maxIdxs);
 
-    *vertexCnt = vert - base;
-    *indexCnt = idx - idxBase;
+    *vertexCnt = static_cast<int>(vert - base);
+    *indexCnt = static_cast<int>(idx - idxBase);
 
     }
     return true;
diff --git a/gpu/GrDrawTarget.cpp b/gpu/GrDrawTarget.cpp
index fc3014e..c33dcb7 100644
--- a/gpu/GrDrawTarget.cpp
+++ b/gpu/GrDrawTarget.cpp
@@ -362,7 +362,7 @@
             maxValidVertex = geoSrc.fVertexCount;
             break;
         case kBuffer_GeometrySrcType:
-            maxValidVertex = geoSrc.fVertexBuffer->sizeInBytes() / geoSrc.fVertexSize;
+            maxValidVertex = static_cast<int>(geoSrc.fVertexBuffer->sizeInBytes() / geoSrc.fVertexSize);
             break;
     }
     if (maxVertex > maxValidVertex) {
@@ -379,7 +379,7 @@
                 maxValidIndex = geoSrc.fIndexCount;
                 break;
             case kBuffer_GeometrySrcType:
-                maxValidIndex = geoSrc.fIndexBuffer->sizeInBytes() / sizeof(uint16_t);
+                maxValidIndex = static_cast<int>(geoSrc.fIndexBuffer->sizeInBytes() / sizeof(uint16_t));
                 break;
         }
         if (maxIndex > maxValidIndex) {
diff --git a/gpu/GrDrawTarget.h b/gpu/GrDrawTarget.h
index feba55e..c75bba2 100644
--- a/gpu/GrDrawTarget.h
+++ b/gpu/GrDrawTarget.h
@@ -688,7 +688,7 @@
             case kArray_GeometrySrcType:
                 return src.fIndexCount;
             case kBuffer_GeometrySrcType:
-                return src.fIndexBuffer->sizeInBytes() / sizeof(uint16_t);
+                return static_cast<int>(src.fIndexBuffer->sizeInBytes() / sizeof(uint16_t));
             default:
                 GrCrash("Unexpected Index Source.");
                 return 0;
diff --git a/gpu/GrGpu.cpp b/gpu/GrGpu.cpp
index 186091f..42b82f6 100644
--- a/gpu/GrGpu.cpp
+++ b/gpu/GrGpu.cpp
@@ -183,12 +183,12 @@
     return this->onWrapBackendRenderTarget(desc);
 }
 
-GrVertexBuffer* GrGpu::createVertexBuffer(uint32_t size, bool dynamic) {
+GrVertexBuffer* GrGpu::createVertexBuffer(size_t size, bool dynamic) {
     this->handleDirtyContext();
     return this->onCreateVertexBuffer(size, dynamic);
 }
 
-GrIndexBuffer* GrGpu::createIndexBuffer(uint32_t size, bool dynamic) {
+GrIndexBuffer* GrGpu::createIndexBuffer(size_t size, bool dynamic) {
     this->handleDirtyContext();
     return this->onCreateIndexBuffer(size, dynamic);
 }
diff --git a/gpu/GrGpu.h b/gpu/GrGpu.h
index 48caf7c..c0a4b8f 100644
--- a/gpu/GrGpu.h
+++ b/gpu/GrGpu.h
@@ -106,7 +106,7 @@
      *
      * @return    The vertex buffer if successful, otherwise NULL.
      */
-    GrVertexBuffer* createVertexBuffer(uint32_t size, bool dynamic);
+    GrVertexBuffer* createVertexBuffer(size_t size, bool dynamic);
 
     /**
      * Creates an index buffer.
@@ -118,7 +118,7 @@
      *
      * @return The index buffer if successful, otherwise NULL.
      */
-    GrIndexBuffer* createIndexBuffer(uint32_t size, bool dynamic);
+    GrIndexBuffer* createIndexBuffer(size_t size, bool dynamic);
 
     /**
      * Creates a path object that can be stenciled using stencilPath(). It is
@@ -421,8 +421,8 @@
                                        size_t rowBytes) = 0;
     virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&) = 0;
     virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&) = 0;
-    virtual GrVertexBuffer* onCreateVertexBuffer(uint32_t size, bool dynamic) = 0;
-    virtual GrIndexBuffer* onCreateIndexBuffer(uint32_t size, bool dynamic) = 0;
+    virtual GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) = 0;
+    virtual GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) = 0;
     virtual GrPath* onCreatePath(const SkPath& path, const SkStrokeRec&) = 0;
 
     // overridden by backend-specific derived class to perform the clear and
diff --git a/gpu/GrIndexBuffer.h b/gpu/GrIndexBuffer.h
index 69ee86f..e23bc9b 100644
--- a/gpu/GrIndexBuffer.h
+++ b/gpu/GrIndexBuffer.h
@@ -21,7 +21,7 @@
      * @return the maximum number of quads using full size of index buffer.
      */
     int maxQuads() const {
-        return this->sizeInBytes() / (sizeof(uint16_t) * 6);
+        return static_cast<int>(this->sizeInBytes() / (sizeof(uint16_t) * 6));
     }
 protected:
     GrIndexBuffer(GrGpu* gpu, bool isWrapped, size_t sizeInBytes, bool dynamic, bool cpuBacked)
diff --git a/gpu/GrMemoryPool.cpp b/gpu/GrMemoryPool.cpp
index deb7d1a..75a3c9a 100644
--- a/gpu/GrMemoryPool.cpp
+++ b/gpu/GrMemoryPool.cpp
@@ -41,7 +41,7 @@
     size = GrSizeAlignUp(size, kAlignment);
     size += kPerAllocPad;
     if (fTail->fFreeSize < size) {
-        int blockSize = size;
+        size_t blockSize = size;
         blockSize = GrMax<size_t>(blockSize, fMinAllocSize);
         BlockHeader* block = CreateBlock(blockSize);
 
diff --git a/gpu/GrRenderTarget.cpp b/gpu/GrRenderTarget.cpp
index f558596..49a7614 100644
--- a/gpu/GrRenderTarget.cpp
+++ b/gpu/GrRenderTarget.cpp
@@ -57,7 +57,7 @@
 }
 
 size_t GrRenderTarget::sizeInBytes() const {
-    int colorBits;
+    size_t colorBits;
     if (kUnknown_GrPixelConfig == fDesc.fConfig) {
         colorBits = 32; // don't know, make a guess
     } else {
diff --git a/gpu/GrResourceCache.cpp b/gpu/GrResourceCache.cpp
index 210cbf8..1d0f384 100644
--- a/gpu/GrResourceCache.cpp
+++ b/gpu/GrResourceCache.cpp
@@ -354,7 +354,7 @@
     // so we don't want to just do a simple loop kicking each
     // entry out. Instead change the budget and purge.
 
-    int savedMaxBytes = fMaxBytes;
+    size_t savedMaxBytes = fMaxBytes;
     int savedMaxCount = fMaxCount;
     fMaxBytes = (size_t) -1;
     fMaxCount = 0;
diff --git a/gpu/SkGrFontScaler.cpp b/gpu/SkGrFontScaler.cpp
index 3c42af8..6514866 100644
--- a/gpu/SkGrFontScaler.cpp
+++ b/gpu/SkGrFontScaler.cpp
@@ -52,7 +52,7 @@
     const SkDescriptor* srcDesc = ((const SkGrDescKey*)&rh)->fDesc;
     size_t lenLH = fDesc->getLength();
     size_t lenRH = srcDesc->getLength();
-    int cmp = memcmp(fDesc, srcDesc, SkMin32(lenLH, lenRH));
+    int cmp = memcmp(fDesc, srcDesc, SkTMin<size_t>(lenLH, lenRH));
     if (0 == cmp) {
         return lenLH < lenRH;
     } else {
diff --git a/gpu/gl/GrGpuGL.cpp b/gpu/gl/GrGpuGL.cpp
index cdf9be9..5845066 100644
--- a/gpu/gl/GrGpuGL.cpp
+++ b/gpu/gl/GrGpuGL.cpp
@@ -1149,7 +1149,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 
-GrVertexBuffer* GrGpuGL::onCreateVertexBuffer(uint32_t size, bool dynamic) {
+GrVertexBuffer* GrGpuGL::onCreateVertexBuffer(size_t size, bool dynamic) {
     GrGLVertexBuffer::Desc desc;
     desc.fDynamic = dynamic;
     desc.fSizeInBytes = size;
@@ -1182,7 +1182,7 @@
     }
 }
 
-GrIndexBuffer* GrGpuGL::onCreateIndexBuffer(uint32_t size, bool dynamic) {
+GrIndexBuffer* GrGpuGL::onCreateIndexBuffer(size_t size, bool dynamic) {
     GrGLIndexBuffer::Desc desc;
     desc.fDynamic = dynamic;
     desc.fSizeInBytes = size;
diff --git a/gpu/gl/GrGpuGL.h b/gpu/gl/GrGpuGL.h
index aa3f017..65e8207 100644
--- a/gpu/gl/GrGpuGL.h
+++ b/gpu/gl/GrGpuGL.h
@@ -117,10 +117,8 @@
     virtual GrTexture* onCreateTexture(const GrTextureDesc& desc,
                                        const void* srcData,
                                        size_t rowBytes) SK_OVERRIDE;
-    virtual GrVertexBuffer* onCreateVertexBuffer(uint32_t size,
-                                                 bool dynamic) SK_OVERRIDE;
-    virtual GrIndexBuffer* onCreateIndexBuffer(uint32_t size,
-                                               bool dynamic) SK_OVERRIDE;
+    virtual GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) SK_OVERRIDE;
+    virtual GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) SK_OVERRIDE;
     virtual GrPath* onCreatePath(const SkPath&, const SkStrokeRec&) SK_OVERRIDE;
     virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&) SK_OVERRIDE;
     virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&) SK_OVERRIDE;
diff --git a/ports/SkFontHost_win_dw.cpp b/ports/SkFontHost_win_dw.cpp
index 1ab0b7e..974b90f 100644
--- a/ports/SkFontHost_win_dw.cpp
+++ b/ports/SkFontHost_win_dw.cpp
@@ -1460,7 +1460,7 @@
     }
 
     glyphToUnicode->setCount(maxGlyph+1);
-    for (size_t j = 0; j < maxGlyph+1u; ++j) {
+    for (USHORT j = 0; j < maxGlyph+1u; ++j) {
         (*glyphToUnicode)[j] = 0;
     }
 
diff --git a/utils/SkDeferredCanvas.cpp b/utils/SkDeferredCanvas.cpp
index 4509038..ce5eb5e 100644
--- a/utils/SkDeferredCanvas.cpp
+++ b/utils/SkDeferredCanvas.cpp
@@ -106,7 +106,7 @@
         PipeBlock previousBloc(fBlock, fBytesWritten);
         fBlockList.push(previousBloc);
     }
-    int32_t blockSize = SkMax32(minRequest, kMinBlockSize);
+    size_t blockSize = SkTMax<size_t>(minRequest, kMinBlockSize);
     fBlock = fAllocator.allocThrow(blockSize);
     fBytesWritten = 0;
     *actual = blockSize;
diff --git a/utils/SkDumpCanvas.cpp b/utils/SkDumpCanvas.cpp
index e471974..0e1a232 100644
--- a/utils/SkDumpCanvas.cpp
+++ b/utils/SkDumpCanvas.cpp
@@ -142,15 +142,15 @@
     // FIXME: this code appears to be untested - and probably unused - and probably wrong
     switch (enc) {
         case SkPaint::kUTF8_TextEncoding:
-            str->appendf("\"%.*s\"%s", SkMax32(byteLen, 32), (const char*) text,
+            str->appendf("\"%.*s\"%s", (int)SkTMax<size_t>(byteLen, 32), (const char*) text,
                         byteLen > 32 ? "..." : "");
             break;
         case SkPaint::kUTF16_TextEncoding:
-            str->appendf("\"%.*ls\"%s", SkMax32(byteLen, 32), (const wchar_t*) text,
+            str->appendf("\"%.*ls\"%s", (int)SkTMax<size_t>(byteLen, 32), (const wchar_t*) text,
                         byteLen > 64 ? "..." : "");
             break;
         case SkPaint::kUTF32_TextEncoding:
-            str->appendf("\"%.*ls\"%s", SkMax32(byteLen, 32), (const wchar_t*) text,
+            str->appendf("\"%.*ls\"%s", (int)SkTMax<size_t>(byteLen, 32), (const wchar_t*) text,
                         byteLen > 128 ? "..." : "");
             break;
         case SkPaint::kGlyphID_TextEncoding:
@@ -444,7 +444,7 @@
 void SkDumpCanvas::drawData(const void* data, size_t length) {
 //    this->dump(kDrawData_Verb, NULL, "drawData(%d)", length);
     this->dump(kDrawData_Verb, NULL, "drawData(%d) %.*s", length,
-               SkMin32(length, 64), data);
+               SkTMin<size_t>(length, 64), data);
 }
 
 void SkDumpCanvas::beginCommentGroup(const char* description) {
diff --git a/utils/win/SkWGL_win.cpp b/utils/win/SkWGL_win.cpp
index ac77c56..3b1966d 100644
--- a/utils/win/SkWGL_win.cpp
+++ b/utils/win/SkWGL_win.cpp
@@ -20,10 +20,10 @@
         return true;
     }
     const char* extensionString = this->getExtensionsString(dc);
-    int extLength = strlen(ext);
+    size_t extLength = strlen(ext);
 
     while (true) {
-        int n = strcspn(extensionString, " ");
+        size_t n = strcspn(extensionString, " ");
         if (n == extLength && 0 == strncmp(ext, extensionString, n)) {
             return true;
         }