BUG=skia:

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

git-svn-id: http://skia.googlecode.com/svn/trunk@13190 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
reed@google.com 2014-01-27 13:42:58 +00:00
Родитель 1a5e51f94e
Коммит 7fa2a65c0c
25 изменённых файлов: 58 добавлений и 49 удалений

Просмотреть файл

@ -33,7 +33,7 @@ protected:
virtual void onDraw(SkCanvas* canvas) {
// explicitly add spaces, to test a prev. bug
const char* text = "Ham bur ge fons";
size_t len = strlen(text);
int len = SkToInt(strlen(text));
SkPath path;
SkPaint paint;
@ -54,7 +54,7 @@ protected:
SkLCGRandom rand;
SkScalar x = SkIntToScalar(20);
SkScalar y = SkIntToScalar(100);
for (size_t i = 0; i < len; ++i) {
for (int i = 0; i < len; ++i) {
pos[i].set(x, y + rand.nextSScalar1() * 24);
x += widths[i];
}

Просмотреть файл

@ -71,7 +71,7 @@ protected:
// 0(may use hairline rendering), 10(common case for stroke-style)
// 40 and 50(>= geometry width/height, make the contour filled in fact)
static const int kStrokeWidth[] = {0, 10, 40, 50};
size_t numWidths = SK_ARRAY_COUNT(kStrokeWidth);
int numWidths = SK_ARRAY_COUNT(kStrokeWidth);
static const SkPaint::Style kStyle[] = {
SkPaint::kStroke_Style, SkPaint::kStrokeAndFill_Style
@ -98,7 +98,7 @@ protected:
for (size_t style = 0; style < SK_ARRAY_COUNT(kStyle); ++style) {
for (size_t cap = 0; cap < SK_ARRAY_COUNT(kCap); ++cap) {
for (size_t join = 0; join < SK_ARRAY_COUNT(kJoin); ++join) {
for (size_t width = 0; width < numWidths; ++width) {
for (int width = 0; width < numWidths; ++width) {
canvas->save();
SetLocation(canvas, counter, SkPaint::kJoinCount * numWidths);

Просмотреть файл

@ -86,7 +86,7 @@ protected:
SkPaint paint;
int x = 0, y = 0;
for (size_t i = 0; i < 4; i++) {
for (int i = 0; i < 4; i++) {
SkBitmap* bitmap = (i & 0x01) ? &fCheckerboard : &fBitmap;
SkIRect cropRect = SkIRect::MakeXYWH(i * 12,
i * 8,

Просмотреть файл

@ -27,8 +27,8 @@ protected:
}
virtual SkISize onISize() SK_OVERRIDE {
size_t width = kNumPolygons * kCellSize + 40;
size_t height = (kNumJoins * kNumStrokeWidths + kNumExtraStyles) * kCellSize + 40;
int width = kNumPolygons * kCellSize + 40;
int height = (kNumJoins * kNumStrokeWidths + kNumExtraStyles) * kCellSize + 40;
return SkISize::Make(width, height);
}

Просмотреть файл

@ -117,7 +117,7 @@ protected:
canvas->translate(SkIntToScalar(8), SkIntToScalar(8));
for (size_t i = 0; i < SK_ARRAY_COUNT(gFilterProc); ++i) {
for (int i = 0; i < (int)SK_ARRAY_COUNT(gFilterProc); ++i) {
int ix = i % 4;
int iy = i / 4;

Просмотреть файл

@ -50,7 +50,7 @@ protected:
SkPaint paint;
paint.setAntiAlias(true);
for (size_t i = 0; i < SK_ARRAY_COUNT(gFaces); i++) {
for (int i = 0; i < (int)SK_ARRAY_COUNT(gFaces); i++) {
this->drawWithFace(text, i, y, paint, canvas);
}
// Now go backwards

Просмотреть файл

@ -218,6 +218,7 @@ typedef uint8_t SkBool8;
SK_API int32_t SkToS32(intmax_t);
SK_API uint32_t SkToU32(uintmax_t);
SK_API int SkToInt(intmax_t);
SK_API unsigned SkToUInt(uintmax_t);
#else
#define SkToS8(x) ((int8_t)(x))
#define SkToU8(x) ((uint8_t)(x))
@ -226,6 +227,7 @@ typedef uint8_t SkBool8;
#define SkToS32(x) ((int32_t)(x))
#define SkToU32(x) ((uint32_t)(x))
#define SkToInt(x) ((int)(x))
#define SkToUInt(x) ((unsigned)(x))
#endif
/** Returns 0 or 1 based on the condition

Просмотреть файл

@ -336,10 +336,10 @@ protected:
SkRect rect = {0, 0, SkIntToScalar(40), SkIntToScalar(40) };
SkRect rect2 = {0, 0, SkIntToScalar(65), SkIntToScalar(20) };
SkScalar left = 0, top = 0, x = 0, y = 0;
size_t index;
int index;
char ascii[] = "ascii...";
size_t asciiLength = sizeof(ascii) - 1;
int asciiLength = sizeof(ascii) - 1;
char utf8[] = "utf8" "\xe2\x80\xa6";
short utf16[] = {'u', 't', 'f', '1', '6', 0x2026 };
short utf16simple[] = {'u', 't', 'f', '1', '6', '!' };
@ -602,7 +602,7 @@ SkCornerPathEffect.h:28:class SkCornerPathEffect : public SkPathEffect {
SkString str("GOOGLE");
for (size_t i = 0; i < SK_ARRAY_COUNT(gRastProcs); i++) {
apply_shader(&paint, i);
apply_shader(&paint, (int)i);
// paint.setMaskFilter(NULL);
// paint.setColor(SK_ColorBLACK);

Просмотреть файл

@ -128,7 +128,7 @@ static bool readTitleFromPrefs(SkString* title) {
return false;
}
int len = stream.getLength();
size_t len = stream.getLength();
SkString data(len);
stream.read(data.writable_str(), len);
const char* s = data.c_str();

Просмотреть файл

@ -96,7 +96,7 @@ protected:
for (int invA = 0; invA < 2; ++invA) {
for (size_t op = 0; op < SK_ARRAY_COUNT(gOps); ++op) {
int idx = invA * SK_ARRAY_COUNT(gOps) + op;
size_t idx = invA * SK_ARRAY_COUNT(gOps) + op;
if (!(idx % 3)) {
canvas->restore();
canvas->translate(0, SkIntToScalar(250));

Просмотреть файл

@ -112,7 +112,7 @@ public:
SkBitmap* fBitmaps;
SkAutoDataUnref* fEncodedPNGs;
SkAutoDataUnref* fEncodedJPEGs;
size_t fBitmapCount;
int fBitmapCount;
EncodeView() {
#if 1
@ -120,7 +120,7 @@ public:
fBitmaps = new SkBitmap[fBitmapCount];
fEncodedPNGs = new SkAutoDataUnref[fBitmapCount];
fEncodedJPEGs = new SkAutoDataUnref[fBitmapCount];
for (size_t i = 0; i < fBitmapCount; i++) {
for (int i = 0; i < fBitmapCount; i++) {
make_image(&fBitmaps[i], gConfigs[i], i);
for (size_t j = 0; j < SK_ARRAY_COUNT(gTypes); j++) {
@ -181,7 +181,7 @@ protected:
SkScalar x = 0, y = 0, maxX = 0;
const int SPACER = 10;
for (size_t i = 0; i < fBitmapCount; i++) {
for (int i = 0; i < fBitmapCount; i++) {
canvas->drawText(gConfigLabels[i], strlen(gConfigLabels[i]),
x + SkIntToScalar(fBitmaps[i].width()) / 2, 0,
paint);

Просмотреть файл

@ -74,11 +74,12 @@ static bool check_bitmap_margin(const SkBitmap& bm, int margin) {
return false;
}
// left column
if (!check_zeros(bm.getAddr32(i, 0), bm.height(), rb >> 2)) {
if (!check_zeros(bm.getAddr32(i, 0), bm.height(), SkToInt(rb >> 2))) {
return false;
}
int right = bm.width() - margin + i;
if (!check_zeros(bm.getAddr32(right, 0), bm.height(), rb >> 2)) {
if (!check_zeros(bm.getAddr32(right, 0), bm.height(),
SkToInt(rb >> 2))) {
return false;
}
}

Просмотреть файл

@ -314,7 +314,7 @@ protected:
unsigned modi) SK_OVERRIDE {
for (size_t i = 0; i < SK_ARRAY_COUNT(fPts); i++) {
if (hittest(fPts[i], x, y)) {
return new PtClick(this, i);
return new PtClick(this, (int)i);
}
}
return this->INHERITED::onFindClickHandler(x, y, modi);

Просмотреть файл

@ -123,7 +123,7 @@ inline float roundf(float x) { return (x-floor(x))>0.5 ? ceil(x) : floor(x); }
#ifdef SK_DEBUG
static void make_rgn(SkRegion* rgn, int left, int top, int right, int bottom,
size_t count, int32_t runs[]) {
int count, int32_t runs[]) {
SkIRect r;
r.set(left, top, right, bottom);

Просмотреть файл

@ -333,7 +333,7 @@ protected:
unsigned modi) SK_OVERRIDE {
for (size_t i = 0; i < SK_ARRAY_COUNT(fPts); ++i) {
if (hittest(fPts[i], x, y)) {
return new MyClick(this, i);
return new MyClick(this, (int)i);
}
}
return this->INHERITED::onFindClickHandler(x, y, modi);

Просмотреть файл

@ -186,7 +186,7 @@ protected:
canvas->save();
for (size_t s = 0; s < SK_ARRAY_COUNT(shaders); s++) {
canvas->save();
int i = 2*s;
size_t i = 2*s;
canvas->translate(SkIntToScalar((i / testsPerCol) * colWidth),
SkIntToScalar((i % testsPerCol) * rowHeight));
paint.setShader(shaders[s])->unref();

Просмотреть файл

@ -646,7 +646,7 @@ static void texteffect_slide(SkCanvas* canvas) {
paint.setAntiAlias(true);
paint.setColor(SK_ColorBLUE);
for (size_t i = 0; i < SK_ARRAY_COUNT(gRastProcs); i++) {
apply_shader(&paint, i);
apply_shader(&paint, (int)i);
canvas->drawText(str, len, x, y, paint);
y += 80;
if (i == 4) {

Просмотреть файл

@ -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

Просмотреть файл

@ -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);

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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;
}
}

Просмотреть файл

@ -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;

Просмотреть файл

@ -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);

Просмотреть файл

@ -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;

Просмотреть файл

@ -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;