fix int/size_t warnings in pipe

BUG=skia:
R=scroggo@google.com

Author: reed@google.com

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

git-svn-id: http://skia.googlecode.com/svn/trunk@14357 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
commit-bot@chromium.org 2014-04-24 18:17:30 +00:00
parent 7eb529fb72
commit b45bd1f7fd
2 changed files with 13 additions and 13 deletions

View File

@ -230,14 +230,14 @@ private:
///////////////////////////////////////////////////////////////////////////////
template <typename T> const T* skip(SkReader32* reader, int count = 1) {
template <typename T> const T* skip(SkReader32* reader, size_t count = 1) {
SkASSERT(count >= 0);
size_t size = sizeof(T) * count;
SkASSERT(SkAlign4(size) == size);
return reinterpret_cast<const T*>(reader->skip(size));
}
template <typename T> const T* skipAlign(SkReader32* reader, int count = 1) {
template <typename T> const T* skipAlign(SkReader32* reader, size_t count = 1) {
SkASSERT(count >= 0);
size_t size = SkAlign4(sizeof(T) * count);
return reinterpret_cast<const T*>(reader->skip(size));

View File

@ -59,7 +59,7 @@ static size_t writeTypeface(SkWriter32* writer, SkTypeface* typeface) {
typeface->serialize(&stream);
size_t size = stream.getOffset();
if (writer) {
writer->write32(size);
writer->write32(SkToU32(size));
SkAutoDataUnref data(stream.copyToData());
writer->writePad(data->data(), size);
}
@ -379,7 +379,7 @@ bool SkGPipeCanvas::shuttleBitmap(const SkBitmap& bm, int32_t slot) {
buffer.setNamedFactoryRecorder(fFactorySet);
buffer.writeBitmap(bm);
this->flattenFactoryNames();
uint32_t size = buffer.bytesWritten();
size_t size = buffer.bytesWritten();
if (this->needOpBytes(size)) {
this->writeOp(kDef_Bitmap_DrawOp, 0, slot);
void* dst = static_cast<void*>(fWriter.reserve(size));
@ -478,7 +478,7 @@ bool SkGPipeCanvas::needOpBytes(size_t needed) {
// Before we wipe out any data that has already been written, read it
// out.
this->doNotify();
size_t blockSize = SkMax32(MIN_BLOCK_SIZE, needed);
size_t blockSize = SkTMax<size_t>(MIN_BLOCK_SIZE, needed);
void* block = fController->requestBlock(blockSize, &fBlockSize);
if (NULL == block) {
// Do not notify the readers, which would call this function again.
@ -704,7 +704,7 @@ void SkGPipeCanvas::drawPoints(PointMode mode, size_t count,
this->writePaint(paint);
if (this->needOpBytes(4 + count * sizeof(SkPoint))) {
this->writeOp(kDrawPoints_DrawOp, mode, 0);
fWriter.write32(count);
fWriter.write32(SkToU32(count));
fWriter.write(pts, count * sizeof(SkPoint));
}
}
@ -855,7 +855,7 @@ void SkGPipeCanvas::onDrawText(const void* text, size_t byteLength, SkScalar x,
this->writePaint(paint);
if (this->needOpBytes(4 + SkAlign4(byteLength) + 2 * sizeof(SkScalar))) {
this->writeOp(kDrawText_DrawOp);
fWriter.write32(byteLength);
fWriter.write32(SkToU32(byteLength));
fWriter.writePad(text, byteLength);
fWriter.writeScalar(x);
fWriter.writeScalar(y);
@ -871,7 +871,7 @@ void SkGPipeCanvas::onDrawPosText(const void* text, size_t byteLength, const SkP
int count = paint.textToGlyphs(text, byteLength, NULL);
if (this->needOpBytes(4 + SkAlign4(byteLength) + 4 + count * sizeof(SkPoint))) {
this->writeOp(kDrawPosText_DrawOp);
fWriter.write32(byteLength);
fWriter.write32(SkToU32(byteLength));
fWriter.writePad(text, byteLength);
fWriter.write32(count);
fWriter.write(pos, count * sizeof(SkPoint));
@ -887,7 +887,7 @@ void SkGPipeCanvas::onDrawPosTextH(const void* text, size_t byteLength, const Sk
int count = paint.textToGlyphs(text, byteLength, NULL);
if (this->needOpBytes(4 + SkAlign4(byteLength) + 4 + count * sizeof(SkScalar) + 4)) {
this->writeOp(kDrawPosTextH_DrawOp);
fWriter.write32(byteLength);
fWriter.write32(SkToU32(byteLength));
fWriter.writePad(text, byteLength);
fWriter.write32(count);
fWriter.write(xpos, count * sizeof(SkScalar));
@ -910,7 +910,7 @@ void SkGPipeCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const
if (this->needOpBytes(size)) {
this->writeOp(kDrawTextOnPath_DrawOp, flags, 0);
fWriter.write32(byteLength);
fWriter.write32(SkToU32(byteLength));
fWriter.writePad(text, byteLength);
fWriter.writePath(path);
@ -989,7 +989,7 @@ void SkGPipeCanvas::drawData(const void* ptr, size_t size) {
if (this->needOpBytes(4 + SkAlign4(size))) {
this->writeOp(kDrawData_DrawOp, 0, data);
if (0 == data) {
fWriter.write32(size);
fWriter.write32(SkToU32(size));
}
fWriter.writePad(ptr, size);
}
@ -1139,7 +1139,7 @@ void SkGPipeCanvas::writePaint(const SkPaint& paint) {
size_t size = (char*)ptr - (char*)storage;
if (size && this->needOpBytes(size)) {
this->writeOp(kPaintOp_DrawOp, 0, size);
this->writeOp(kPaintOp_DrawOp, 0, SkToU32(size));
fWriter.write(storage, size);
for (size_t i = 0; i < size/4; i++) {
// SkDebugf("[%d] %08X\n", i, storage[i]);
@ -1159,7 +1159,7 @@ void SkGPipeCanvas::writePaint(const SkPaint& paint) {
paint.getAnnotation()->writeToBuffer(buffer);
const size_t size = buffer.bytesWritten();
if (this->needOpBytes(size)) {
this->writeOp(kSetAnnotation_DrawOp, 0, size);
this->writeOp(kSetAnnotation_DrawOp, 0, SkToU32(size));
buffer.writeToMemory(fWriter.reserve(size));
}
}