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;
}
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);
}
#include "SkUserConfig.h"
#include "SkPostConfig.h"
#include <stdint.h>
+#include <sys/types.h>
/** \file SkTypes.h
*/
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))
#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
return (size_t)x;
}
+off_t SkToOffT(intmax_t x) {
+ SkASSERT((off_t)x == x);
+ return (off_t)x;
+}
+
#endif
// 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);
// 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);
*/
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
*/
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.
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]);
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]);
}
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;
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;
}
}
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();
// 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.
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();
}
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;
}
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);
}
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++) {
}
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;
}
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);