fix size_t/int warnings in pictures
BUG=skia:
R=robertphillips@google.com
Author: reed@google.com
Review URL: https://codereview.chromium.org/244273002
git-svn-id: http://skia.googlecode.com/svn/trunk@14302 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/core/SkMatrixClipStateMgr.cpp b/src/core/SkMatrixClipStateMgr.cpp
index 5f21030..492e041 100644
--- a/src/core/SkMatrixClipStateMgr.cpp
+++ b/src/core/SkMatrixClipStateMgr.cpp
@@ -69,7 +69,7 @@
mgr->writeDeltaMat(*curMatID, curClip.fMatrixID);
*curMatID = curClip.fMatrixID;
- int offset = 0;
+ size_t offset = 0;
switch (curClip.fClipType) {
case kRect_ClipType:
diff --git a/src/core/SkMatrixClipStateMgr.h b/src/core/SkMatrixClipStateMgr.h
index 270eacd..016baa0 100644
--- a/src/core/SkMatrixClipStateMgr.h
+++ b/src/core/SkMatrixClipStateMgr.h
@@ -368,19 +368,19 @@
// skp that must be filled in when the current open state is closed. These are
// here rather then distributed across the MatrixClipState's because saveLayers
// can cause MC states to be nested.
- SkTDArray<int32_t> *fSkipOffsets;
+ SkTDArray<int32_t> *fSkipOffsets; // TODO: should we store u32 or size_t instead?
SkDEBUGCODE(void validate();)
int MCStackPush(SkCanvas::SaveFlags flags);
- void addClipOffset(int offset) {
+ void addClipOffset(size_t offset) {
SkASSERT(NULL != fSkipOffsets);
SkASSERT(kIdentityWideOpenStateID != fCurOpenStateID);
SkASSERT(fCurMCState->fHasOpen);
SkASSERT(!fCurMCState->fIsSaveLayer);
- *fSkipOffsets->append() = offset;
+ *fSkipOffsets->append() = SkToS32(offset);
}
void writeDeltaMat(int currentMatID, int desiredMatID);
diff --git a/src/core/SkPictureFlat.h b/src/core/SkPictureFlat.h
index 4928114..5d1a6b5 100644
--- a/src/core/SkPictureFlat.h
+++ b/src/core/SkPictureFlat.h
@@ -529,7 +529,7 @@
// Reinterpret data in fScratch as an SkFlatData.
SkFlatData* scratch = (SkFlatData*)fScratch.getWriter32()->contiguousArray();
SkASSERT(scratch != NULL);
- scratch->stampHeader(index, dataSize);
+ scratch->stampHeader(index, SkToS32(dataSize));
return *scratch;
}
diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp
index ba18392..05a60e8 100644
--- a/src/core/SkPicturePlayback.cpp
+++ b/src/core/SkPicturePlayback.cpp
@@ -312,7 +312,7 @@
static void write_tag_size(SkWriteBuffer& buffer, uint32_t tag, size_t size) {
buffer.writeUInt(tag);
- buffer.writeUInt(size);
+ buffer.writeUInt(SkToU32(size));
}
static void write_tag_size(SkWStream* stream, uint32_t tag, size_t size) {
@@ -484,7 +484,7 @@
bool SkPicturePlayback::parseStreamTag(SkStream* stream,
uint32_t tag,
- size_t size,
+ uint32_t size,
SkPicture::InstallPixelRefProc proc) {
/*
* By the time we encounter BUFFER_SIZE_TAG, we need to have already seen
@@ -532,8 +532,9 @@
} break;
case SK_PICT_TYPEFACE_TAG: {
SkASSERT(!haveBuffer);
- fTFPlayback.setCount(size);
- for (size_t i = 0; i < size; i++) {
+ const int count = SkToInt(size);
+ fTFPlayback.setCount(count);
+ for (int i = 0; i < count; i++) {
SkAutoTUnref<SkTypeface> tf(SkTypeface::Deserialize(stream));
if (!tf.get()) { // failed to deserialize
// fTFPlayback asserts it never has a null, so we plop in
@@ -594,19 +595,21 @@
}
bool SkPicturePlayback::parseBufferTag(SkReadBuffer& buffer,
- uint32_t tag, size_t size) {
+ uint32_t tag, uint32_t size) {
switch (tag) {
case SK_PICT_BITMAP_BUFFER_TAG: {
+ const int count = SkToInt(size);
fBitmaps = SkTRefArray<SkBitmap>::Create(size);
- for (size_t i = 0; i < size; ++i) {
+ for (int i = 0; i < count; ++i) {
SkBitmap* bm = &fBitmaps->writableAt(i);
buffer.readBitmap(bm);
bm->setImmutable();
}
} break;
case SK_PICT_PAINT_BUFFER_TAG: {
+ const int count = SkToInt(size);
fPaints = SkTRefArray<SkPaint>::Create(size);
- for (size_t i = 0; i < size; ++i) {
+ for (int i = 0; i < count; ++i) {
buffer.readPaint(&fPaints->writableAt(i));
}
} break;
diff --git a/src/core/SkPicturePlayback.h b/src/core/SkPicturePlayback.h
index 62bcb52..cae8841 100644
--- a/src/core/SkPicturePlayback.h
+++ b/src/core/SkPicturePlayback.h
@@ -215,8 +215,8 @@
#endif
private: // these help us with reading/writing
- bool parseStreamTag(SkStream*, uint32_t tag, size_t size, SkPicture::InstallPixelRefProc);
- bool parseBufferTag(SkReadBuffer&, uint32_t tag, size_t size);
+ bool parseStreamTag(SkStream*, uint32_t tag, uint32_t size, SkPicture::InstallPixelRefProc);
+ bool parseBufferTag(SkReadBuffer&, uint32_t tag, uint32_t size);
void flattenToBuffer(SkWriteBuffer&) const;
private:
diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp
index bea3442..e38cfb8 100644
--- a/src/core/SkPictureRecord.cpp
+++ b/src/core/SkPictureRecord.cpp
@@ -69,7 +69,7 @@
// Return the offset of the paint inside a given op's byte stream. A zero
// return value means there is no paint (and you really shouldn't be calling
// this method)
-static inline uint32_t getPaintOffset(DrawType op, uint32_t opSize) {
+static inline size_t getPaintOffset(DrawType op, size_t opSize) {
// These offsets are where the paint would be if the op size doesn't overflow
static const uint8_t gPaintOffsets[LAST_DRAWTYPE_ENUM + 1] = {
0, // UNUSED - no paint
@@ -160,7 +160,7 @@
void SkPictureRecord::recordSave(SaveFlags flags) {
// op + flags
- uint32_t size = kSaveSize;
+ size_t size = kSaveSize;
size_t initialOffset = this->addDraw(SAVE, &size);
this->addInt(flags);
@@ -194,7 +194,7 @@
void SkPictureRecord::recordSaveLayer(const SkRect* bounds, const SkPaint* paint,
SaveFlags flags) {
// op + bool for 'bounds'
- uint32_t size = 2 * kUInt32Size;
+ size_t size = 2 * kUInt32Size;
if (NULL != bounds) {
size += sizeof(*bounds); // + rect
}
@@ -224,7 +224,7 @@
* Read the op code from 'offset' in 'writer'.
*/
#ifdef SK_DEBUG
-static DrawType peek_op(SkWriter32* writer, int32_t offset) {
+static DrawType peek_op(SkWriter32* writer, size_t offset) {
return (DrawType)(writer->readTAt<uint32_t>(offset) >> 24);
}
#endif
@@ -232,7 +232,7 @@
/*
* Read the op code from 'offset' in 'writer' and extract the size too.
*/
-static DrawType peek_op_and_size(SkWriter32* writer, int32_t offset, uint32_t* size) {
+static DrawType peek_op_and_size(SkWriter32* writer, size_t offset, uint32_t* size) {
uint32_t peek = writer->readTAt<uint32_t>(offset);
uint32_t op;
@@ -384,8 +384,8 @@
DRAW_BITMAP_NINE == dbmInfo.fActualOp ||
DRAW_BITMAP_RECT_TO_RECT == dbmInfo.fActualOp);
- uint32_t dbmPaintOffset = getPaintOffset(dbmInfo.fActualOp, dbmInfo.fSize);
- uint32_t slPaintOffset = getPaintOffset(SAVE_LAYER, saveLayerInfo.fSize);
+ size_t dbmPaintOffset = getPaintOffset(dbmInfo.fActualOp, dbmInfo.fSize);
+ size_t slPaintOffset = getPaintOffset(SAVE_LAYER, saveLayerInfo.fSize);
// we have a match, now we need to get the paints involved
uint32_t dbmPaintId = writer->readTAt<uint32_t>(dbmInfo.fOffset + dbmPaintOffset);
@@ -653,12 +653,11 @@
}
void SkPictureRecord::recordRestore(bool fillInSkips) {
- uint32_t initialOffset, size;
if (fillInSkips) {
this->fillRestoreOffsetPlaceholdersForCurrentStackLevel((uint32_t)fWriter.bytesWritten());
}
- size = 1 * kUInt32Size; // RESTORE consists solely of 1 op code
- initialOffset = this->addDraw(RESTORE, &size);
+ size_t size = 1 * kUInt32Size; // RESTORE consists solely of 1 op code
+ size_t initialOffset = this->addDraw(RESTORE, &size);
this->validate(initialOffset, size);
}
@@ -666,7 +665,7 @@
SkASSERT(SkMatrix::kTranslate_Mask == m.getType());
// op + dx + dy
- uint32_t size = 1 * kUInt32Size + 2 * sizeof(SkScalar);
+ size_t size = 1 * kUInt32Size + 2 * sizeof(SkScalar);
size_t initialOffset = this->addDraw(TRANSLATE, &size);
this->addScalar(m.getTranslateX());
this->addScalar(m.getTranslateY());
@@ -677,7 +676,7 @@
SkASSERT(SkMatrix::kScale_Mask == m.getType());
// op + sx + sy
- uint32_t size = 1 * kUInt32Size + 2 * sizeof(SkScalar);
+ size_t size = 1 * kUInt32Size + 2 * sizeof(SkScalar);
size_t initialOffset = this->addDraw(SCALE, &size);
this->addScalar(m.getScaleX());
this->addScalar(m.getScaleY());
@@ -707,7 +706,7 @@
void SkPictureRecord::recordConcat(const SkMatrix& matrix) {
this->validate(fWriter.bytesWritten(), 0);
// op + matrix
- uint32_t size = kUInt32Size + matrix.writeToMemory(NULL);
+ size_t size = kUInt32Size + matrix.writeToMemory(NULL);
size_t initialOffset = this->addDraw(CONCAT, &size);
this->addMatrix(matrix);
this->validate(initialOffset, size);
@@ -720,7 +719,7 @@
#else
this->validate(fWriter.bytesWritten(), 0);
// op + matrix
- uint32_t size = kUInt32Size + matrix.writeToMemory(NULL);
+ size_t size = kUInt32Size + matrix.writeToMemory(NULL);
size_t initialOffset = this->addDraw(SET_MATRIX, &size);
this->addMatrix(matrix);
this->validate(initialOffset, size);
@@ -788,7 +787,7 @@
return offset;
}
#else
-int SkPictureRecord::recordRestoreOffsetPlaceholder(SkRegion::Op op) {
+size_t SkPictureRecord::recordRestoreOffsetPlaceholder(SkRegion::Op op) {
if (fRestoreOffsetStack.isEmpty()) {
return -1;
}
@@ -814,7 +813,7 @@
size_t offset = fWriter.bytesWritten();
this->addInt(prevOffset);
- fRestoreOffsetStack.top() = offset;
+ fRestoreOffsetStack.top() = SkToU32(offset);
return offset;
}
#endif
@@ -829,9 +828,9 @@
this->INHERITED::onClipRect(rect, op, edgeStyle);
}
-int SkPictureRecord::recordClipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
+size_t SkPictureRecord::recordClipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
// id + rect + clip params
- uint32_t size = 1 * kUInt32Size + sizeof(rect) + 1 * kUInt32Size;
+ size_t size = 1 * kUInt32Size + sizeof(rect) + 1 * kUInt32Size;
#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
size += kUInt32Size; // + restore offset
#else
@@ -844,7 +843,7 @@
size_t initialOffset = this->addDraw(CLIP_RECT, &size);
this->addRect(rect);
this->addInt(ClipParams_pack(op, doAA));
- int offset = this->recordRestoreOffsetPlaceholder(op);
+ size_t offset = this->recordRestoreOffsetPlaceholder(op);
this->validate(initialOffset, size);
return offset;
@@ -864,9 +863,9 @@
}
}
-int SkPictureRecord::recordClipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA) {
+size_t SkPictureRecord::recordClipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA) {
// op + rrect + clip params
- uint32_t size = 1 * kUInt32Size + SkRRect::kSizeInMemory + 1 * kUInt32Size;
+ size_t size = 1 * kUInt32Size + SkRRect::kSizeInMemory + 1 * kUInt32Size;
#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
size += kUInt32Size; // + restore offset
#else
@@ -879,7 +878,7 @@
size_t initialOffset = this->addDraw(CLIP_RRECT, &size);
this->addRRect(rrect);
this->addInt(ClipParams_pack(op, doAA));
- int offset = recordRestoreOffsetPlaceholder(op);
+ size_t offset = recordRestoreOffsetPlaceholder(op);
this->validate(initialOffset, size);
return offset;
}
@@ -901,9 +900,9 @@
}
}
-int SkPictureRecord::recordClipPath(int pathID, SkRegion::Op op, bool doAA) {
+size_t SkPictureRecord::recordClipPath(int pathID, SkRegion::Op op, bool doAA) {
// op + path index + clip params
- uint32_t size = 3 * kUInt32Size;
+ size_t size = 3 * kUInt32Size;
#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
size += kUInt32Size; // + restore offset
#else
@@ -916,7 +915,7 @@
size_t initialOffset = this->addDraw(CLIP_PATH, &size);
this->addInt(pathID);
this->addInt(ClipParams_pack(op, doAA));
- int offset = recordRestoreOffsetPlaceholder(op);
+ size_t offset = recordRestoreOffsetPlaceholder(op);
this->validate(initialOffset, size);
return offset;
}
@@ -931,9 +930,9 @@
this->INHERITED::onClipRegion(region, op);
}
-int SkPictureRecord::recordClipRegion(const SkRegion& region, SkRegion::Op op) {
+size_t SkPictureRecord::recordClipRegion(const SkRegion& region, SkRegion::Op op) {
// op + clip params + region
- uint32_t size = 2 * kUInt32Size + region.writeToMemory(NULL);
+ size_t size = 2 * kUInt32Size + region.writeToMemory(NULL);
#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
size += kUInt32Size; // + restore offset
#else
@@ -946,7 +945,7 @@
size_t initialOffset = this->addDraw(CLIP_REGION, &size);
this->addRegion(region);
this->addInt(ClipParams_pack(op, false));
- int offset = this->recordRestoreOffsetPlaceholder(op);
+ size_t offset = this->recordRestoreOffsetPlaceholder(op);
this->validate(initialOffset, size);
return offset;
@@ -959,7 +958,7 @@
#endif
// op + color
- uint32_t size = 2 * kUInt32Size;
+ size_t size = 2 * kUInt32Size;
size_t initialOffset = this->addDraw(DRAW_CLEAR, &size);
this->addInt(color);
this->validate(initialOffset, size);
@@ -972,7 +971,7 @@
#endif
// op + paint index
- uint32_t size = 2 * kUInt32Size;
+ size_t size = 2 * kUInt32Size;
size_t initialOffset = this->addDraw(DRAW_PAINT, &size);
SkASSERT(initialOffset+getPaintOffset(DRAW_PAINT, size) == fWriter.bytesWritten());
this->addPaint(paint);
@@ -987,12 +986,12 @@
#endif
// op + paint index + mode + count + point data
- uint32_t size = 4 * kUInt32Size + count * sizeof(SkPoint);
+ size_t size = 4 * kUInt32Size + count * sizeof(SkPoint);
size_t initialOffset = this->addDraw(DRAW_POINTS, &size);
SkASSERT(initialOffset+getPaintOffset(DRAW_POINTS, size) == fWriter.bytesWritten());
this->addPaint(paint);
this->addInt(mode);
- this->addInt(count);
+ this->addInt(SkToInt(count));
fWriter.writeMul4(pts, count * sizeof(SkPoint));
this->validate(initialOffset, size);
}
@@ -1004,7 +1003,7 @@
#endif
// op + paint index + rect
- uint32_t size = 2 * kUInt32Size + sizeof(oval);
+ size_t size = 2 * kUInt32Size + sizeof(oval);
size_t initialOffset = this->addDraw(DRAW_OVAL, &size);
SkASSERT(initialOffset+getPaintOffset(DRAW_OVAL, size) == fWriter.bytesWritten());
this->addPaint(paint);
@@ -1019,7 +1018,7 @@
#endif
// op + paint index + rect
- uint32_t size = 2 * kUInt32Size + sizeof(rect);
+ size_t size = 2 * kUInt32Size + sizeof(rect);
size_t initialOffset = this->addDraw(DRAW_RECT, &size);
SkASSERT(initialOffset+getPaintOffset(DRAW_RECT, size) == fWriter.bytesWritten());
this->addPaint(paint);
@@ -1039,9 +1038,8 @@
this->SkPictureRecord::drawOval(rrect.getBounds(), paint);
} else {
// op + paint index + rrect
- uint32_t initialOffset, size;
- size = 2 * kUInt32Size + SkRRect::kSizeInMemory;
- initialOffset = this->addDraw(DRAW_RRECT, &size);
+ size_t size = 2 * kUInt32Size + SkRRect::kSizeInMemory;
+ size_t initialOffset = this->addDraw(DRAW_RRECT, &size);
SkASSERT(initialOffset+getPaintOffset(DRAW_RRECT, size) == fWriter.bytesWritten());
this->addPaint(paint);
this->addRRect(rrect);
@@ -1057,9 +1055,8 @@
#endif
// op + paint index + rrects
- uint32_t initialOffset, size;
- size = 2 * kUInt32Size + SkRRect::kSizeInMemory * 2;
- initialOffset = this->addDraw(DRAW_DRRECT, &size);
+ size_t size = 2 * kUInt32Size + SkRRect::kSizeInMemory * 2;
+ size_t initialOffset = this->addDraw(DRAW_DRRECT, &size);
SkASSERT(initialOffset+getPaintOffset(DRAW_DRRECT, size) == fWriter.bytesWritten());
this->addPaint(paint);
this->addRRect(outer);
@@ -1074,7 +1071,7 @@
#endif
// op + paint index + path index
- uint32_t size = 3 * kUInt32Size;
+ size_t size = 3 * kUInt32Size;
size_t initialOffset = this->addDraw(DRAW_PATH, &size);
SkASSERT(initialOffset+getPaintOffset(DRAW_PATH, size) == fWriter.bytesWritten());
this->addPaint(paint);
@@ -1093,7 +1090,7 @@
#endif
// op + paint index + bitmap index + left + top
- uint32_t size = 3 * kUInt32Size + 2 * sizeof(SkScalar);
+ size_t size = 3 * kUInt32Size + 2 * sizeof(SkScalar);
size_t initialOffset = this->addDraw(DRAW_BITMAP, &size);
SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP, size) == fWriter.bytesWritten());
this->addPaintPtr(paint);
@@ -1114,7 +1111,7 @@
fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType);
#endif
// id + paint index + bitmap index + bool for 'src' + flags
- uint32_t size = 5 * kUInt32Size;
+ size_t size = 5 * kUInt32Size;
if (NULL != src) {
size += sizeof(*src); // + rect
}
@@ -1142,7 +1139,7 @@
#endif
// id + paint index + bitmap index + matrix
- uint32_t size = 3 * kUInt32Size + matrix.writeToMemory(NULL);
+ size_t size = 3 * kUInt32Size + matrix.writeToMemory(NULL);
size_t initialOffset = this->addDraw(DRAW_BITMAP_MATRIX, &size);
SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP_MATRIX, size) == fWriter.bytesWritten());
this->addPaintPtr(paint);
@@ -1162,7 +1159,7 @@
#endif
// op + paint index + bitmap id + center + dst rect
- uint32_t size = 3 * kUInt32Size + sizeof(center) + sizeof(dst);
+ size_t size = 3 * kUInt32Size + sizeof(center) + sizeof(dst);
size_t initialOffset = this->addDraw(DRAW_BITMAP_NINE, &size);
SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP_NINE, size) == fWriter.bytesWritten());
this->addPaintPtr(paint);
@@ -1183,7 +1180,7 @@
#endif
// op + paint index + bitmap index + left + top
- uint32_t size = 5 * kUInt32Size;
+ size_t size = 5 * kUInt32Size;
size_t initialOffset = this->addDraw(DRAW_SPRITE, &size);
SkASSERT(initialOffset+getPaintOffset(DRAW_SPRITE, size) == fWriter.bytesWritten());
this->addPaintPtr(paint);
@@ -1222,7 +1219,7 @@
bool fast = !paint.isVerticalText() && paint.canComputeFastBounds();
// op + paint index + length + 'length' worth of chars + x + y
- uint32_t size = 3 * kUInt32Size + SkAlign4(byteLength) + 2 * sizeof(SkScalar);
+ size_t size = 3 * kUInt32Size + SkAlign4(byteLength) + 2 * sizeof(SkScalar);
if (fast) {
size += 2 * sizeof(SkScalar); // + top & bottom
}
@@ -1248,7 +1245,7 @@
fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType);
#endif
- size_t points = paint.countText(text, byteLength);
+ int points = paint.countText(text, byteLength);
if (0 == points)
return;
@@ -1258,7 +1255,7 @@
// check if the caller really should have used drawPosTextH()
{
const SkScalar firstY = pos[0].fY;
- for (size_t index = 1; index < points; index++) {
+ for (int index = 1; index < points; index++) {
if (pos[index].fY != firstY) {
canUseDrawH = false;
if (pos[index].fY < minY) {
@@ -1274,7 +1271,7 @@
bool fast = canUseDrawH && fastBounds;
// op + paint index + length + 'length' worth of data + num points
- uint32_t size = 3 * kUInt32Size + SkAlign4(byteLength) + 1 * kUInt32Size;
+ size_t size = 3 * kUInt32Size + SkAlign4(byteLength) + 1 * kUInt32Size;
if (canUseDrawH) {
if (fast) {
size += 2 * sizeof(SkScalar); // + top & bottom
@@ -1315,7 +1312,7 @@
}
this->addScalar(pos[0].fY);
SkScalar* xptr = (SkScalar*)fWriter.reserve(points * sizeof(SkScalar));
- for (size_t index = 0; index < points; index++)
+ for (int index = 0; index < points; index++)
*xptr++ = pos[index].fX;
} else {
fWriter.writeMul4(pos, points * sizeof(SkPoint));
@@ -1345,14 +1342,14 @@
void SkPictureRecord::drawPosTextHImpl(const void* text, size_t byteLength,
const SkScalar xpos[], SkScalar constY,
const SkPaint& paint, const SkFlatData* flatPaintData) {
- size_t points = paint.countText(text, byteLength);
+ int points = paint.countText(text, byteLength);
if (0 == points)
return;
bool fast = !paint.isVerticalText() && paint.canComputeFastBounds();
// op + paint index + length + 'length' worth of data + num points
- uint32_t size = 3 * kUInt32Size + SkAlign4(byteLength) + 1 * kUInt32Size;
+ size_t size = 3 * kUInt32Size + SkAlign4(byteLength) + 1 * kUInt32Size;
if (fast) {
size += 2 * sizeof(SkScalar); // + top & bottom
}
@@ -1391,7 +1388,7 @@
// op + paint index + length + 'length' worth of data + path index + matrix
const SkMatrix& m = matrix ? *matrix : SkMatrix::I();
- uint32_t size = 3 * kUInt32Size + SkAlign4(byteLength) + kUInt32Size + m.writeToMemory(NULL);
+ size_t size = 3 * kUInt32Size + SkAlign4(byteLength) + kUInt32Size + m.writeToMemory(NULL);
size_t initialOffset = this->addDraw(DRAW_TEXT_ON_PATH, &size);
SkASSERT(initialOffset+getPaintOffset(DRAW_TEXT_ON_PATH, size) == fWriter.bytesWritten());
this->addPaint(paint);
@@ -1408,7 +1405,7 @@
#endif
// op + picture index
- uint32_t size = 2 * kUInt32Size;
+ size_t size = 2 * kUInt32Size;
size_t initialOffset = this->addDraw(DRAW_PICTURE, &size);
this->addPicture(picture);
this->validate(initialOffset, size);
@@ -1442,7 +1439,7 @@
}
// op + paint index + flags + vmode + vCount + vertices
- uint32_t size = 5 * kUInt32Size + vertexCount * sizeof(SkPoint);
+ size_t size = 5 * kUInt32Size + vertexCount * sizeof(SkPoint);
if (flags & DRAW_VERTICES_HAS_TEXS) {
size += vertexCount * sizeof(SkPoint); // + uvs
}
@@ -1489,17 +1486,17 @@
#endif
// op + length + 'length' worth of data
- uint32_t size = 2 * kUInt32Size + SkAlign4(length);
+ size_t size = 2 * kUInt32Size + SkAlign4(length);
size_t initialOffset = this->addDraw(DRAW_DATA, &size);
- this->addInt(length);
+ this->addInt(SkToInt(length));
fWriter.writePad(data, length);
this->validate(initialOffset, size);
}
void SkPictureRecord::beginCommentGroup(const char* description) {
// op/size + length of string + \0 terminated chars
- int length = strlen(description);
- uint32_t size = 2 * kUInt32Size + SkAlign4(length + 1);
+ size_t length = strlen(description);
+ size_t size = 2 * kUInt32Size + SkAlign4(length + 1);
size_t initialOffset = this->addDraw(BEGIN_COMMENT_GROUP, &size);
fWriter.writeString(description, length);
this->validate(initialOffset, size);
@@ -1507,9 +1504,9 @@
void SkPictureRecord::addComment(const char* kywd, const char* value) {
// op/size + 2x length of string + 2x \0 terminated chars
- int kywdLen = strlen(kywd);
- int valueLen = strlen(value);
- uint32_t size = 3 * kUInt32Size + SkAlign4(kywdLen + 1) + SkAlign4(valueLen + 1);
+ size_t kywdLen = strlen(kywd);
+ size_t valueLen = strlen(value);
+ size_t size = 3 * kUInt32Size + SkAlign4(kywdLen + 1) + SkAlign4(valueLen + 1);
size_t initialOffset = this->addDraw(COMMENT, &size);
fWriter.writeString(kywd, kywdLen);
fWriter.writeString(value, valueLen);
@@ -1518,7 +1515,7 @@
void SkPictureRecord::endCommentGroup() {
// op/size
- uint32_t size = 1 * kUInt32Size;
+ size_t size = 1 * kUInt32Size;
size_t initialOffset = this->addDraw(END_COMMENT_GROUP, &size);
this->validate(initialOffset, size);
}
@@ -1526,13 +1523,13 @@
// [op/size] [rect] [skip offset]
static const uint32_t kPushCullOpSize = 2 * kUInt32Size + sizeof(SkRect);
void SkPictureRecord::onPushCull(const SkRect& cullRect) {
- uint32_t size = kPushCullOpSize;
+ size_t size = kPushCullOpSize;
size_t initialOffset = this->addDraw(PUSH_CULL, &size);
// PUSH_CULL's size should stay constant (used to rewind).
SkASSERT(size == kPushCullOpSize);
this->addRect(cullRect);
- fCullOffsetStack.push(fWriter.bytesWritten());
+ fCullOffsetStack.push(SkToU32(fWriter.bytesWritten()));
this->addInt(0);
this->validate(initialOffset, size);
}
@@ -1552,11 +1549,11 @@
}
// op only
- uint32_t size = kUInt32Size;
+ size_t size = kUInt32Size;
size_t initialOffset = this->addDraw(POP_CULL, &size);
// update the cull skip offset to point past this op.
- fWriter.overwriteTAt<uint32_t>(cullSkipOffset, fWriter.bytesWritten());
+ fWriter.overwriteTAt<uint32_t>(cullSkipOffset, SkToU32(fWriter.bytesWritten()));
this->validate(initialOffset, size);
}
@@ -1680,7 +1677,7 @@
#ifdef SK_DEBUG_SIZE
size_t start = fWriter.bytesWritten();
#endif
- addInt(byteLength);
+ addInt(SkToInt(byteLength));
fWriter.writePad(text, byteLength);
#ifdef SK_DEBUG_SIZE
fTextBytes += fWriter.bytesWritten() - start;
diff --git a/src/core/SkPictureRecord.h b/src/core/SkPictureRecord.h
index 2614496..aba14e3 100644
--- a/src/core/SkPictureRecord.h
+++ b/src/core/SkPictureRecord.h
@@ -100,7 +100,7 @@
private:
void handleOptimization(int opt);
- int recordRestoreOffsetPlaceholder(SkRegion::Op);
+ size_t recordRestoreOffsetPlaceholder(SkRegion::Op);
void fillRestoreOffsetPlaceholdersForCurrentStackLevel(uint32_t restoreOffset);
#ifndef SK_COLLAPSE_MATRIX_CLIP_STATE
@@ -125,7 +125,7 @@
* end of blocks could go unused). Possibly add a second addDraw that
* operates in this manner.
*/
- size_t addDraw(DrawType drawType, uint32_t* size) {
+ size_t addDraw(DrawType drawType, size_t* size) {
size_t offset = fWriter.bytesWritten();
this->predrawNotify();
@@ -140,9 +140,9 @@
if (0 != (*size & ~MASK_24) || *size == MASK_24) {
fWriter.writeInt(PACK_8_24(drawType, MASK_24));
*size += 1;
- fWriter.writeInt(*size);
+ fWriter.writeInt(SkToU32(*size));
} else {
- fWriter.writeInt(PACK_8_24(drawType, *size));
+ fWriter.writeInt(PACK_8_24(drawType, SkToU32(*size)));
}
return offset;
@@ -206,7 +206,7 @@
void validateRegions() const;
#else
public:
- void validate(size_t initialOffset, uint32_t size) const {
+ void validate(size_t initialOffset, size_t size) const {
SkASSERT(fWriter.bytesWritten() == initialOffset + size);
}
#endif
@@ -262,10 +262,10 @@
void recordConcat(const SkMatrix& matrix);
void recordTranslate(const SkMatrix& matrix);
void recordScale(const SkMatrix& matrix);
- int recordClipRect(const SkRect& rect, SkRegion::Op op, bool doAA);
- int recordClipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA);
- int recordClipPath(int pathID, SkRegion::Op op, bool doAA);
- int recordClipRegion(const SkRegion& region, SkRegion::Op op);
+ size_t recordClipRect(const SkRect& rect, SkRegion::Op op, bool doAA);
+ size_t recordClipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA);
+ size_t recordClipPath(int pathID, SkRegion::Op op, bool doAA);
+ size_t recordClipRegion(const SkRegion& region, SkRegion::Op op);
void recordSave(SaveFlags flags);
void recordSaveLayer(const SkRect* bounds, const SkPaint* paint, SaveFlags flags);
void recordRestore(bool fillInSkips = true);