Start cleaning up 64bit Win warnings
https://codereview.chromium.org/27192003/
git-svn-id: http://skia.googlecode.com/svn/trunk@11764 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/core/SkTemplates.h b/include/core/SkTemplates.h
index c63a114..8317b24 100644
--- a/include/core/SkTemplates.h
+++ b/include/core/SkTemplates.h
@@ -231,7 +231,7 @@
/** Wraps SkAutoTArray, with room for up to N elements preallocated
*/
-template <size_t N, typename T> class SkAutoSTArray : SkNoncopyable {
+template <int N, typename T> class SkAutoSTArray : SkNoncopyable {
public:
/** Initialize with no objects */
SkAutoSTArray() {
@@ -241,7 +241,7 @@
/** Allocate count number of T elements
*/
- SkAutoSTArray(size_t count) {
+ SkAutoSTArray(int count) {
fArray = NULL;
fCount = 0;
this->reset(count);
@@ -252,7 +252,7 @@
}
/** Destroys previous objects in the array and default constructs count number of objects */
- void reset(size_t count) {
+ void reset(int count) {
T* start = fArray;
T* iter = start + fCount;
while (iter > start) {
@@ -286,7 +286,7 @@
/** Return the number of T elements in the array
*/
- size_t count() const { return fCount; }
+ int count() const { return fCount; }
/** Return the array of T elements. Will be NULL if count == 0
*/
@@ -295,12 +295,12 @@
/** Return the nth element in the array
*/
T& operator[](int index) const {
- SkASSERT((unsigned)index < fCount);
+ SkASSERT(index < fCount);
return fArray[index];
}
private:
- size_t fCount;
+ int fCount;
T* fArray;
// since we come right after fArray, fStorage should be properly aligned
char fStorage[N * sizeof(T)];
diff --git a/include/core/SkWriter32.h b/include/core/SkWriter32.h
index 0db6540..ba8893e 100644
--- a/include/core/SkWriter32.h
+++ b/include/core/SkWriter32.h
@@ -45,9 +45,9 @@
~SkWriter32();
// return the current offset (will always be a multiple of 4)
- uint32_t bytesWritten() const { return fSize; }
+ size_t bytesWritten() const { return fSize; }
// DEPRECATED: use bytesWritten instead TODO(mtklein): clean up
- uint32_t size() const { return this->bytesWritten(); }
+ size_t size() const { return this->bytesWritten(); }
// Returns true if we've written only into the storage passed into constructor or reset.
// (You may be able to use this to avoid a call to flatten.)
@@ -268,9 +268,9 @@
Block* fHead;
Block* fTail;
size_t fMinSize;
- uint32_t fSize;
+ size_t fSize;
// sum of bytes written in all blocks *before* fTail
- uint32_t fWrittenBeforeLastBlock;
+ size_t fWrittenBeforeLastBlock;
bool isHeadExternallyAllocated() const {
return fHead == &fExternalBlock;
diff --git a/include/utils/SkMeshUtils.h b/include/utils/SkMeshUtils.h
index 564df67..7e0e8f4 100644
--- a/include/utils/SkMeshUtils.h
+++ b/include/utils/SkMeshUtils.h
@@ -27,14 +27,14 @@
bool init(SkPoint tex[], uint16_t indices[],
int texW, int texH, int rows, int cols);
- size_t indexCount() const { return fIndexCount; }
+ int indexCount() const { return fIndexCount; }
const uint16_t* indices() const { return fIndices; }
size_t texCount() const { return fTexCount; }
const SkPoint* tex() const { return fTex; }
private:
- size_t fIndexCount, fTexCount;
+ int fIndexCount, fTexCount;
SkPoint* fTex;
uint16_t* fIndices;
void* fStorage; // may be null
diff --git a/src/core/SkOrderedWriteBuffer.h b/src/core/SkOrderedWriteBuffer.h
index 180f9a4..277b7bf 100644
--- a/src/core/SkOrderedWriteBuffer.h
+++ b/src/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/src/core/SkRTree.cpp b/src/core/SkRTree.cpp
index b6f8e95..e3d2eb6 100644
--- a/src/core/SkRTree.cpp
+++ b/src/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/src/core/SkRTree.h b/src/core/SkRTree.h
index 54421de..2f905e7 100644
--- a/src/core/SkRTree.h
+++ b/src/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/src/gpu/GrBufferAllocPool.cpp b/src/gpu/GrBufferAllocPool.cpp
index 887f8cd..b34fe8a 100644
--- a/src/gpu/GrBufferAllocPool.cpp
+++ b/src/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/src/gpu/GrDefaultPathRenderer.cpp b/src/gpu/GrDefaultPathRenderer.cpp
index bd52ce1..85485c8 100644
--- a/src/gpu/GrDefaultPathRenderer.cpp
+++ b/src/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/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index fc3014e..c33dcb7 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/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/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h
index feba55e..c75bba2 100644
--- a/src/gpu/GrDrawTarget.h
+++ b/src/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/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index 186091f..42b82f6 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/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/src/gpu/GrGpu.h b/src/gpu/GrGpu.h
index 48caf7c..c0a4b8f 100644
--- a/src/gpu/GrGpu.h
+++ b/src/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/src/gpu/GrIndexBuffer.h b/src/gpu/GrIndexBuffer.h
index 69ee86f..e23bc9b 100644
--- a/src/gpu/GrIndexBuffer.h
+++ b/src/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/src/gpu/GrMemoryPool.cpp b/src/gpu/GrMemoryPool.cpp
index deb7d1a..75a3c9a 100644
--- a/src/gpu/GrMemoryPool.cpp
+++ b/src/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/src/gpu/GrRenderTarget.cpp b/src/gpu/GrRenderTarget.cpp
index f558596..49a7614 100644
--- a/src/gpu/GrRenderTarget.cpp
+++ b/src/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/src/gpu/GrResourceCache.cpp b/src/gpu/GrResourceCache.cpp
index 210cbf8..1d0f384 100644
--- a/src/gpu/GrResourceCache.cpp
+++ b/src/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/src/gpu/SkGrFontScaler.cpp b/src/gpu/SkGrFontScaler.cpp
index 3c42af8..6514866 100644
--- a/src/gpu/SkGrFontScaler.cpp
+++ b/src/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/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp
index cdf9be9..5845066 100644
--- a/src/gpu/gl/GrGpuGL.cpp
+++ b/src/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/src/gpu/gl/GrGpuGL.h b/src/gpu/gl/GrGpuGL.h
index aa3f017..65e8207 100644
--- a/src/gpu/gl/GrGpuGL.h
+++ b/src/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/src/ports/SkFontHost_win_dw.cpp b/src/ports/SkFontHost_win_dw.cpp
index 1ab0b7e..974b90f 100644
--- a/src/ports/SkFontHost_win_dw.cpp
+++ b/src/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/src/utils/SkDeferredCanvas.cpp b/src/utils/SkDeferredCanvas.cpp
index 4509038..ce5eb5e 100644
--- a/src/utils/SkDeferredCanvas.cpp
+++ b/src/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/src/utils/SkDumpCanvas.cpp b/src/utils/SkDumpCanvas.cpp
index e471974..0e1a232 100644
--- a/src/utils/SkDumpCanvas.cpp
+++ b/src/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/src/utils/win/SkWGL_win.cpp b/src/utils/win/SkWGL_win.cpp
index ac77c56..3b1966d 100644
--- a/src/utils/win/SkWGL_win.cpp
+++ b/src/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;
}
diff --git a/tools/skdiff_utils.cpp b/tools/skdiff_utils.cpp
index 0eb405a..1f5289b 100644
--- a/tools/skdiff_utils.cpp
+++ b/tools/skdiff_utils.cpp
@@ -102,7 +102,7 @@
const char *input_cstr = input.c_str();
const char *first_char = input_cstr;
const char *match_char;
- int oldSubstringLen = strlen(oldSubstring);
+ size_t oldSubstringLen = strlen(oldSubstring);
while (NULL != (match_char = strstr(first_char, oldSubstring))) {
output.append(first_char, (match_char - first_char));
output.append(newSubstring);
diff --git a/tools/skpdiff/skpdiff_util.cpp b/tools/skpdiff/skpdiff_util.cpp
index 5b19c73..171721c 100644
--- a/tools/skpdiff/skpdiff_util.cpp
+++ b/tools/skpdiff/skpdiff_util.cpp
@@ -130,7 +130,7 @@
return true;
#elif SK_BUILD_FOR_WIN32
char pathDirGlob[MAX_PATH];
- char pathLength = strlen(path);
+ size_t pathLength = strlen(path);
strncpy(pathDirGlob, path, pathLength);
if (path[pathLength - 1] == '/' || path[pathLength - 1] == '\\') {