aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--dm/DMWriteTask.cpp2
-rw-r--r--gm/tallstretchedbitmaps.cpp2
-rw-r--r--include/core/SkTypes.h3
-rw-r--r--src/core/SkDebug.cpp5
-rwxr-xr-xsrc/core/SkDistanceFieldGen.cpp4
-rw-r--r--src/core/SkDistanceFieldGen.h4
-rwxr-xr-xsrc/gpu/GrDistanceFieldTextContext.cpp4
-rw-r--r--src/gpu/GrInOrderDrawBuffer.cpp4
-rw-r--r--src/gpu/GrProgramDesc.h2
-rw-r--r--src/gpu/GrSWMaskHelper.cpp2
-rw-r--r--src/gpu/GrSWMaskHelper.h2
-rw-r--r--src/gpu/gl/GrGLPathRendering.cpp2
-rw-r--r--src/pdf/SkPDFCatalog.cpp2
-rw-r--r--src/pdf/SkPDFDocument.cpp20
-rw-r--r--src/sfnt/SkOTUtils.cpp2
15 files changed, 32 insertions, 28 deletions
diff --git a/dm/DMWriteTask.cpp b/dm/DMWriteTask.cpp
index fa0d129d68..fbb3c77d9e 100644
--- a/dm/DMWriteTask.cpp
+++ b/dm/DMWriteTask.cpp
@@ -25,7 +25,7 @@ static int split_suffixes(int N, const char* name, SkTArray<SkString>* out) {
for (int i = 0; i < N; i++) {
// We're splitting off suffixes from the back to front.
out->push_back(split[split.count()-i-1]);
- consumed += out->back().size() + 1; // Add one for the _.
+ consumed += SkToInt(out->back().size() + 1); // Add one for the _.
}
return consumed;
}
diff --git a/gm/tallstretchedbitmaps.cpp b/gm/tallstretchedbitmaps.cpp
index 905cee8c65..db55dddb94 100644
--- a/gm/tallstretchedbitmaps.cpp
+++ b/gm/tallstretchedbitmaps.cpp
@@ -69,7 +69,7 @@ protected:
void onOnceBeforeDraw() SK_OVERRIDE {
for (size_t i = 0; i < SK_ARRAY_COUNT(fTallBmps); ++i) {
- int h = (4 + i) * 1024;
+ int h = SkToInt((4 + i) * 1024);
fTallBmps[i].fItemCnt = make_bm(&fTallBmps[i].fBmp, h);
}
diff --git a/include/core/SkTypes.h b/include/core/SkTypes.h
index a38be84d8f..72ebb093c2 100644
--- a/include/core/SkTypes.h
+++ b/include/core/SkTypes.h
@@ -12,6 +12,7 @@
#include "SkUserConfig.h"
#include "SkPostConfig.h"
#include <stdint.h>
+#include <sys/types.h>
/** \file SkTypes.h
*/
@@ -244,6 +245,7 @@ typedef uint8_t SkBool8;
SK_API int SkToInt(intmax_t);
SK_API unsigned SkToUInt(uintmax_t);
SK_API size_t SkToSizeT(uintmax_t);
+ SK_API off_t SkToOffT(intmax_t x);
#else
#define SkToS8(x) ((int8_t)(x))
#define SkToU8(x) ((uint8_t)(x))
@@ -254,6 +256,7 @@ typedef uint8_t SkBool8;
#define SkToInt(x) ((int)(x))
#define SkToUInt(x) ((unsigned)(x))
#define SkToSizeT(x) ((size_t)(x))
+ #define SkToOffT(x) ((off_t)(x))
#endif
/** Returns 0 or 1 based on the condition
diff --git a/src/core/SkDebug.cpp b/src/core/SkDebug.cpp
index b705a650ea..2257c7f6d8 100644
--- a/src/core/SkDebug.cpp
+++ b/src/core/SkDebug.cpp
@@ -56,4 +56,9 @@ size_t SkToSizeT(uintmax_t x) {
return (size_t)x;
}
+off_t SkToOffT(intmax_t x) {
+ SkASSERT((off_t)x == x);
+ return (off_t)x;
+}
+
#endif
diff --git a/src/core/SkDistanceFieldGen.cpp b/src/core/SkDistanceFieldGen.cpp
index 92cf1af20d..30354e09f8 100755
--- a/src/core/SkDistanceFieldGen.cpp
+++ b/src/core/SkDistanceFieldGen.cpp
@@ -461,7 +461,7 @@ static bool generate_distance_field_from_image(unsigned char* distanceField,
// assumes an 8-bit image and distance field
bool SkGenerateDistanceFieldFromA8Image(unsigned char* distanceField,
const unsigned char* image,
- int width, int height, int rowBytes) {
+ int width, int height, size_t rowBytes) {
SkASSERT(distanceField);
SkASSERT(image);
@@ -489,7 +489,7 @@ bool SkGenerateDistanceFieldFromA8Image(unsigned char* distanceField,
// assumes a 1-bit image and 8-bit distance field
bool SkGenerateDistanceFieldFromBWImage(unsigned char* distanceField,
const unsigned char* image,
- int width, int height, int rowBytes) {
+ int width, int height, size_t rowBytes) {
SkASSERT(distanceField);
SkASSERT(image);
diff --git a/src/core/SkDistanceFieldGen.h b/src/core/SkDistanceFieldGen.h
index 0510907f8c..4a09ace107 100644
--- a/src/core/SkDistanceFieldGen.h
+++ b/src/core/SkDistanceFieldGen.h
@@ -35,7 +35,7 @@
*/
bool SkGenerateDistanceFieldFromA8Image(unsigned char* distanceField,
const unsigned char* image,
- int w, int h, int rowBytes);
+ int w, int h, size_t rowBytes);
/** Given 1-bit mask data, generate the associated distance field
@@ -48,7 +48,7 @@ bool SkGenerateDistanceFieldFromA8Image(unsigned char* distanceField,
*/
bool SkGenerateDistanceFieldFromBWImage(unsigned char* distanceField,
const unsigned char* image,
- int w, int h, int rowBytes);
+ int w, int h, size_t rowBytes);
/** Given width and height of original image, return size (in bytes) of distance field
* @param w Width of the original image.
diff --git a/src/gpu/GrDistanceFieldTextContext.cpp b/src/gpu/GrDistanceFieldTextContext.cpp
index d25757c695..a052b641f6 100755
--- a/src/gpu/GrDistanceFieldTextContext.cpp
+++ b/src/gpu/GrDistanceFieldTextContext.cpp
@@ -306,7 +306,7 @@ void GrDistanceFieldTextContext::onDrawPosText(const GrPaint& paint, const SkPai
glyph.getSubYFixed()),
x, y, fontScaler)) {
// couldn't append, send to fallback
- fallbackTxt.push_back_n(SkToU32(text-lastText), lastText);
+ fallbackTxt.push_back_n(SkToInt(text-lastText), lastText);
fallbackPos.push_back(pos[0]);
if (2 == scalarsPerPosition) {
fallbackPos.push_back(pos[1]);
@@ -335,7 +335,7 @@ void GrDistanceFieldTextContext::onDrawPosText(const GrPaint& paint, const SkPai
glyph.getSubYFixed()),
x - advanceX, y - advanceY, fontScaler)) {
// couldn't append, send to fallback
- fallbackTxt.push_back_n(SkToU32(text-lastText), lastText);
+ fallbackTxt.push_back_n(SkToInt(text-lastText), lastText);
fallbackPos.push_back(pos[0]);
if (2 == scalarsPerPosition) {
fallbackPos.push_back(pos[1]);
diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp
index 68d2e3bc9a..62d6818c2b 100644
--- a/src/gpu/GrInOrderDrawBuffer.cpp
+++ b/src/gpu/GrInOrderDrawBuffer.cpp
@@ -332,9 +332,9 @@ void GrInOrderDrawBuffer::onDrawPaths(const GrDrawState& ds,
}
DrawPaths* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPaths, (pathRange));
- dp->fIndicesLocation = savedIndices - fPathIndexBuffer.begin();
+ dp->fIndicesLocation = SkToU32(savedIndices - fPathIndexBuffer.begin());
dp->fIndexType = indexType;
- dp->fTransformsLocation = savedTransforms - fPathTransformBuffer.begin();
+ dp->fTransformsLocation = SkToU32(savedTransforms - fPathTransformBuffer.begin());
dp->fTransformType = transformType;
dp->fCount = count;
dp->fStencilSettings = stencilSettings;
diff --git a/src/gpu/GrProgramDesc.h b/src/gpu/GrProgramDesc.h
index 5b339613c5..022bbc3d44 100644
--- a/src/gpu/GrProgramDesc.h
+++ b/src/gpu/GrProgramDesc.h
@@ -36,7 +36,7 @@ public:
GrProgramDesc& operator= (const GrProgramDesc& other) {
uint32_t keyLength = other.keyLength();
- fKey.reset(keyLength);
+ fKey.reset(SkToInt(keyLength));
memcpy(fKey.begin(), other.fKey.begin(), keyLength);
return *this;
}
diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp
index 142cd92718..b6a7059192 100644
--- a/src/gpu/GrSWMaskHelper.cpp
+++ b/src/gpu/GrSWMaskHelper.cpp
@@ -252,7 +252,7 @@ GrTexture* GrSWMaskHelper::createTexture() {
}
void GrSWMaskHelper::sendTextureData(GrTexture *texture, const GrSurfaceDesc& desc,
- const void *data, int rowbytes) {
+ const void *data, size_t rowbytes) {
// If we aren't reusing scratch textures we don't need to flush before
// writing since no one else will be using 'texture'
bool reuseScratch = fContext->getGpu()->caps()->reuseScratchTextures();
diff --git a/src/gpu/GrSWMaskHelper.h b/src/gpu/GrSWMaskHelper.h
index 1eef46ecff..229b0e5e90 100644
--- a/src/gpu/GrSWMaskHelper.h
+++ b/src/gpu/GrSWMaskHelper.h
@@ -128,7 +128,7 @@ private:
// Actually sends the texture data to the GPU. This is called from
// toTexture with the data filled in depending on the texture config.
void sendTextureData(GrTexture *texture, const GrSurfaceDesc& desc,
- const void *data, int rowbytes);
+ const void *data, size_t rowbytes);
// Compresses the bitmap stored in fBM and sends the compressed data
// to the GPU to be stored in 'texture' using sendTextureData.
diff --git a/src/gpu/gl/GrGLPathRendering.cpp b/src/gpu/gl/GrGLPathRendering.cpp
index 5e0889562d..44b86818e9 100644
--- a/src/gpu/gl/GrGLPathRendering.cpp
+++ b/src/gpu/gl/GrGLPathRendering.cpp
@@ -136,7 +136,7 @@ GrPathRange* GrGLPathRendering::createGlyphs(const SkTypeface* typeface,
const void* fontData = fontStream->getMemoryBase();
if (NULL == fontData) {
// TODO: Find a more efficient way to pass the font data (e.g. open file descriptor).
- fontTempBuffer.reset(SkToU32(fontDataLength));
+ fontTempBuffer.reset(SkToInt(fontDataLength));
fontStream->read(&fontTempBuffer.front(), fontDataLength);
fontData = &fontTempBuffer.front();
}
diff --git a/src/pdf/SkPDFCatalog.cpp b/src/pdf/SkPDFCatalog.cpp
index 8690b3eaea..adb466c859 100644
--- a/src/pdf/SkPDFCatalog.cpp
+++ b/src/pdf/SkPDFCatalog.cpp
@@ -197,7 +197,7 @@ off_t SkPDFCatalog::setSubstituteResourcesOffsets(off_t fileOffset,
SkTSet<SkPDFObject*>* targetSet = getSubstituteList(firstPage);
off_t offsetSum = fileOffset;
for (int i = 0; i < targetSet->count(); ++i) {
- offsetSum += setFileOffset((*targetSet)[i], offsetSum);
+ offsetSum += SkToOffT(setFileOffset((*targetSet)[i], offsetSum));
}
return offsetSum - fileOffset;
}
diff --git a/src/pdf/SkPDFDocument.cpp b/src/pdf/SkPDFDocument.cpp
index 79699a0292..9b1458f832 100644
--- a/src/pdf/SkPDFDocument.cpp
+++ b/src/pdf/SkPDFDocument.cpp
@@ -160,14 +160,12 @@ bool SkPDFDocument::emitPDF(SkWStream* stream) {
perform_font_subsetting(fCatalog.get(), fPages, &fSubstitutes);
// Figure out the size of things and inform the catalog of file offsets.
- off_t fileOffset = headerSize();
- fileOffset += fCatalog->setFileOffset(fDocCatalog, fileOffset);
- fileOffset += fCatalog->setFileOffset(fPages[0], fileOffset);
- fileOffset += fPages[0]->getPageSize(fCatalog.get(),
- (size_t) fileOffset);
+ off_t fileOffset = SkToOffT(this->headerSize());
+ fileOffset += SkToOffT(fCatalog->setFileOffset(fDocCatalog, fileOffset));
+ fileOffset += SkToOffT(fCatalog->setFileOffset(fPages[0], fileOffset));
+ fileOffset += fPages[0]->getPageSize(fCatalog.get(), fileOffset);
for (int i = 0; i < fFirstPageResources->count(); i++) {
- fileOffset += fCatalog->setFileOffset((*fFirstPageResources)[i],
- fileOffset);
+ fileOffset += SkToOffT(fCatalog->setFileOffset((*fFirstPageResources)[i], fileOffset));
}
// Add the size of resources of substitute objects used on page 1.
fileOffset += fCatalog->setSubstituteResourcesOffsets(fileOffset, true);
@@ -177,7 +175,7 @@ bool SkPDFDocument::emitPDF(SkWStream* stream) {
}
for (int i = 0; i < fPageTree.count(); i++) {
- fileOffset += fCatalog->setFileOffset(fPageTree[i], fileOffset);
+ fileOffset += SkToOffT(fCatalog->setFileOffset(fPageTree[i], fileOffset));
}
for (int i = 1; i < fPages.count(); i++) {
@@ -185,12 +183,10 @@ bool SkPDFDocument::emitPDF(SkWStream* stream) {
}
for (int i = 0; i < fOtherPageResources->count(); i++) {
- fileOffset += fCatalog->setFileOffset(
- (*fOtherPageResources)[i], fileOffset);
+ fileOffset += SkToOffT(fCatalog->setFileOffset((*fOtherPageResources)[i], fileOffset));
}
- fileOffset += fCatalog->setSubstituteResourcesOffsets(fileOffset,
- false);
+ fileOffset += fCatalog->setSubstituteResourcesOffsets(fileOffset, false);
fXRefFileOffset = fileOffset;
}
diff --git a/src/sfnt/SkOTUtils.cpp b/src/sfnt/SkOTUtils.cpp
index 0e009528b4..1d3843d061 100644
--- a/src/sfnt/SkOTUtils.cpp
+++ b/src/sfnt/SkOTUtils.cpp
@@ -129,7 +129,7 @@ SkData* SkOTUtils::RenameFont(SkStream* fontData, const char* fontName, int font
nameRecords[i].languageID.windows.value = SkOTTableName::Record::LanguageID::Windows::English_UnitedStates;
nameRecords[i].nameID.predefined.value = namesToCreate[i];
nameRecords[i].offset = SkEndian_SwapBE16(0);
- nameRecords[i].length = SkEndian_SwapBE16(fontNameLen * sizeof(wchar_t));
+ nameRecords[i].length = SkEndian_SwapBE16(SkToU16(fontNameLen * sizeof(wchar_t)));
}
SK_OT_USHORT* nameString = reinterpret_cast<SK_OT_USHORT*>(data + originalDataSize + stringOffset);