diff options
author | 2014-01-27 13:42:58 +0000 | |
---|---|---|
committer | 2014-01-27 13:42:58 +0000 | |
commit | 7fa2a65c0cfc714364490cb715171461143024e0 (patch) | |
tree | b7e40b0ca71a7ac8d957d150f038603cde2dcd3c /src | |
parent | 1a5e51f94ed8cb01600184119e52bb64bdb3dccc (diff) |
fix more 64bit warnings
BUG=skia:
Review URL: https://codereview.chromium.org/147683003
git-svn-id: http://skia.googlecode.com/svn/trunk@13190 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkDebug.cpp | 5 | ||||
-rw-r--r-- | src/core/SkFlate.cpp | 4 | ||||
-rw-r--r-- | src/core/SkPictureFlat.h | 4 | ||||
-rwxr-xr-x | src/ports/SkFontHost_mac.cpp | 24 | ||||
-rw-r--r-- | src/ports/SkImageDecoder_CG.cpp | 4 | ||||
-rw-r--r-- | src/utils/SkLua.cpp | 2 | ||||
-rw-r--r-- | src/utils/SkLuaCanvas.cpp | 3 | ||||
-rw-r--r-- | src/views/mac/SkOptionsTableView.mm | 10 |
8 files changed, 31 insertions, 25 deletions
diff --git a/src/core/SkDebug.cpp b/src/core/SkDebug.cpp index 772352248d..d484f5eaff 100644 --- a/src/core/SkDebug.cpp +++ b/src/core/SkDebug.cpp @@ -46,4 +46,9 @@ int SkToInt(intmax_t x) { return (int)x; } +unsigned SkToUInt(uintmax_t x) { + SkASSERT((unsigned)x == x); + return (unsigned)x; +} + #endif diff --git a/src/core/SkFlate.cpp b/src/core/SkFlate.cpp index 8258cdcd1d..2b4e36d727 100644 --- a/src/core/SkFlate.cpp +++ b/src/core/SkFlate.cpp @@ -61,7 +61,7 @@ bool doFlate(bool compress, SkStream* src, SkWStream* dst) { flateData.avail_in = 0; } else { flateData.next_in = input; - flateData.avail_in = inputLength; + flateData.avail_in = SkToUInt(inputLength); } rc = Z_OK; @@ -83,7 +83,7 @@ bool doFlate(bool compress, SkStream* src, SkWStream* dst) { if (read == 0) break; flateData.next_in = inputBuffer; - flateData.avail_in = read; + flateData.avail_in = SkToUInt(read); } if (compress) rc = deflate(&flateData, Z_NO_FLUSH); diff --git a/src/core/SkPictureFlat.h b/src/core/SkPictureFlat.h index 06a9840975..d92e4c45df 100644 --- a/src/core/SkPictureFlat.h +++ b/src/core/SkPictureFlat.h @@ -272,7 +272,7 @@ public: buffer.setFlags(controller->getWriteBufferFlags()); Traits::flatten(buffer, obj); - uint32_t size = buffer.size(); + size_t size = buffer.size(); SkASSERT(SkIsAlign4(size)); // Allocate enough memory to hold SkFlatData struct and the flat data itself. @@ -282,7 +282,7 @@ public: // Put the serialized contents into the data section of the new allocation. buffer.writeToMemory(result->data()); // Stamp the index, size and checksum in the header. - result->stampHeader(index, size); + result->stampHeader(index, SkToS32(size)); return result; } diff --git a/src/ports/SkFontHost_mac.cpp b/src/ports/SkFontHost_mac.cpp index c27bd67443..04af696608 100755 --- a/src/ports/SkFontHost_mac.cpp +++ b/src/ports/SkFontHost_mac.cpp @@ -149,7 +149,7 @@ static CGFloat CGRectGetWidth_inline(const CGRect& rect) { /////////////////////////////////////////////////////////////////////////////// static void sk_memset_rect32(uint32_t* ptr, uint32_t value, - size_t width, size_t height, size_t rowBytes) { + int width, int height, size_t rowBytes) { SkASSERT(width); SkASSERT(width * sizeof(uint32_t) <= rowBytes); @@ -1441,7 +1441,7 @@ static SkTypeface* create_from_dataProvider(CGDataProviderRef provider) { // so the performance impact isn't too bad. static void populate_glyph_to_unicode_slow(CTFontRef ctFont, CFIndex glyphCount, SkTDArray<SkUnichar>* glyphToUnicode) { - glyphToUnicode->setCount(glyphCount); + glyphToUnicode->setCount(SkToInt(glyphCount)); SkUnichar* out = glyphToUnicode->begin(); sk_bzero(out, glyphCount * sizeof(SkUnichar)); UniChar unichar = 0; @@ -1485,7 +1485,7 @@ static void populate_glyph_to_unicode(CTFontRef ctFont, CFIndex glyphCount, length = 8192; } const UInt8* bits = CFDataGetBytePtr(bitmap); - glyphToUnicode->setCount(glyphCount); + glyphToUnicode->setCount(SkToInt(glyphCount)); SkUnichar* out = glyphToUnicode->begin(); sk_bzero(out, glyphCount * sizeof(SkUnichar)); for (int i = 0; i < length; i++) { @@ -1625,7 +1625,7 @@ SkAdvancedTypefaceMetrics* SkTypeface_Mac::onGetAdvancedTypefaceMetrics( } else { info->fGlyphWidths.reset( skia_advanced_typeface_metrics_utils::getAdvanceData(ctFont.get(), - glyphCount, + SkToInt(glyphCount), glyphIDs, glyphIDsCount, &getWidthAdvance)); @@ -1724,8 +1724,8 @@ SkStream* SkTypeface_Mac::onOpenStream(int* ttcIndex) const { entry->tag = SkEndian_SwapBE32(tableTags[tableIndex]); entry->checksum = SkEndian_SwapBE32(SkOTUtils::CalcTableChecksum((SK_OT_ULONG*)dataPtr, tableSize)); - entry->offset = SkEndian_SwapBE32(dataPtr - dataStart); - entry->logicalLength = SkEndian_SwapBE32(tableSize); + entry->offset = SkEndian_SwapBE32(SkToU32(dataPtr - dataStart)); + entry->logicalLength = SkEndian_SwapBE32(SkToU32(tableSize)); dataPtr += (tableSize + 3) & ~3; ++entry; @@ -1785,7 +1785,7 @@ int SkTypeface_Mac::onGetTableTags(SkFontTableTag tags[]) const { if (NULL == cfArray) { return 0; } - int count = CFArrayGetCount(cfArray); + int count = SkToInt(CFArrayGetCount(cfArray)); if (tags) { for (int i = 0; i < count; ++i) { uintptr_t fontTag = reinterpret_cast<uintptr_t>(CFArrayGetValueAtIndex(cfArray, i)); @@ -1930,7 +1930,7 @@ int SkTypeface_Mac::onCharsToGlyphs(const void* chars, Encoding encoding, SkUnichar uni = SkUTF8_NextUnichar(&utf8); utf16 += SkUTF16_FromUnichar(uni, utf16); } - srcCount = utf16 - src; + srcCount = SkToInt(utf16 - src); break; } case kUTF16_Encoding: { @@ -1951,7 +1951,7 @@ int SkTypeface_Mac::onCharsToGlyphs(const void* chars, Encoding encoding, for (int i = 0; i < glyphCount; ++i) { utf16 += SkUTF16_FromUnichar(utf32[i], utf16); } - srcCount = utf16 - src; + srcCount = SkToInt(utf16 - src); break; } } @@ -1999,7 +1999,7 @@ int SkTypeface_Mac::onCharsToGlyphs(const void* chars, Encoding encoding, } int SkTypeface_Mac::onCountGlyphs() const { - return CTFontGetGlyphCount(fFontRef); + return SkToInt(CTFontGetGlyphCount(fFontRef)); } /////////////////////////////////////////////////////////////////////////////// @@ -2142,7 +2142,7 @@ public: if (NULL == fArray) { fArray = CFArrayCreate(NULL, NULL, 0, NULL); } - fCount = CFArrayGetCount(fArray); + fCount = SkToInt(CFArrayGetCount(fArray)); } virtual ~SkFontStyleSet_Mac() { @@ -2219,7 +2219,7 @@ class SkFontMgr_Mac : public SkFontMgr { void lazyInit() { if (NULL == fNames) { fNames = SkCTFontManagerCopyAvailableFontFamilyNames(); - fCount = fNames ? CFArrayGetCount(fNames) : 0; + fCount = fNames ? SkToInt(CFArrayGetCount(fNames)) : 0; } } diff --git a/src/ports/SkImageDecoder_CG.cpp b/src/ports/SkImageDecoder_CG.cpp index beb6ed11e4..90c282dc9b 100644 --- a/src/ports/SkImageDecoder_CG.cpp +++ b/src/ports/SkImageDecoder_CG.cpp @@ -66,8 +66,8 @@ bool SkImageDecoder_CG::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) { } SkAutoTCallVProc<CGImage, CGImageRelease> arimage(image); - const int width = CGImageGetWidth(image); - const int height = CGImageGetHeight(image); + const int width = SkToInt(CGImageGetWidth(image)); + const int height = SkToInt(CGImageGetHeight(image)); bm->setConfig(SkBitmap::kARGB_8888_Config, width, height); if (SkImageDecoder::kDecodeBounds_Mode == mode) { return true; diff --git a/src/utils/SkLua.cpp b/src/utils/SkLua.cpp index 8bc646f0c7..9bbdc6c6ad 100644 --- a/src/utils/SkLua.cpp +++ b/src/utils/SkLua.cpp @@ -1029,7 +1029,7 @@ static int lrrect_type(lua_State* L) { } static int lrrect_radii(lua_State* L) { - int corner = lua_tointeger(L, 2); + int corner = SkToInt(lua_tointeger(L, 2)); SkVector v; if (corner < 0 || corner > 3) { SkDebugf("bad corner index %d", corner); diff --git a/src/utils/SkLuaCanvas.cpp b/src/utils/SkLuaCanvas.cpp index c5ec006913..0136231ce1 100644 --- a/src/utils/SkLuaCanvas.cpp +++ b/src/utils/SkLuaCanvas.cpp @@ -57,7 +57,8 @@ void AutoCallLua::pushEncodedText(SkPaint::TextEncoding enc, const void* text, this->pushString(str, "text"); } break; case SkPaint::kGlyphID_TextEncoding: - this->pushArrayU16((const uint16_t*)text, length >> 1, "glyphs"); + this->pushArrayU16((const uint16_t*)text, SkToInt(length >> 1), + "glyphs"); break; case SkPaint::kUTF32_TextEncoding: break; diff --git a/src/views/mac/SkOptionsTableView.mm b/src/views/mac/SkOptionsTableView.mm index 7a6afe42b3..b4cdbf4119 100644 --- a/src/views/mac/SkOptionsTableView.mm +++ b/src/views/mac/SkOptionsTableView.mm @@ -66,7 +66,7 @@ int menuIndex = fMenus->find(const_cast<SkOSMenu *>(menu)); if (menuIndex >= 0 && menuIndex < fMenus->count()) { NSUInteger first = 0; - for (NSInteger i = 0; i < menuIndex; ++i) { + for (int i = 0; i < menuIndex; ++i) { first += (*fMenus)[i]->getCount(); } [fItems removeObjectsInRange:NSMakeRange(first, [fItems count] - first)]; @@ -148,7 +148,7 @@ } - (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { - int columnIndex = [tableView columnWithIdentifier:[tableColumn identifier]]; + NSInteger columnIndex = [tableView columnWithIdentifier:[tableColumn identifier]]; if (columnIndex == 0) { const SkOSMenu::Item* item = ((SkOptionItem*)[fItems objectAtIndex:row]).fItem; NSString* label = [NSString stringWithUTF8String:item->getLabel()]; @@ -163,7 +163,7 @@ - (NSCell *)tableView:(NSTableView *)tableView dataCellForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { if (tableColumn) { - int columnIndex = [tableView columnWithIdentifier:[tableColumn identifier]]; + NSInteger columnIndex = [tableView columnWithIdentifier:[tableColumn identifier]]; if (columnIndex == 1) return [((SkOptionItem*)[fItems objectAtIndex:row]).fCell copy]; else @@ -173,7 +173,7 @@ } - (void)tableView:(NSTableView *)tableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { - int columnIndex = [tableView columnWithIdentifier:[tableColumn identifier]]; + NSInteger columnIndex = [tableView columnWithIdentifier:[tableColumn identifier]]; if (columnIndex == 1) { SkOptionItem* option = (SkOptionItem*)[self.fItems objectAtIndex:row]; NSCell* storedCell = option.fCell; @@ -207,7 +207,7 @@ } - (void)tableView:(NSTableView *)tableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { - int columnIndex = [tableView columnWithIdentifier:[tableColumn identifier]]; + NSInteger columnIndex = [tableView columnWithIdentifier:[tableColumn identifier]]; if (columnIndex == 1) { SkOptionItem* option = (SkOptionItem*)[self.fItems objectAtIndex:row]; NSCell* cell = option.fCell; |