Address lint issues in pdf directories.

Review URL: http://codereview.appspot.com/4887042

git-svn-id: http://skia.googlecode.com/svn/trunk@2117 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
ctguil@chromium.org 2011-08-15 23:55:03 +00:00
parent 7b5e017169
commit a5c7234e81
13 changed files with 41 additions and 43 deletions

View File

@ -55,7 +55,7 @@ private:
SkASSERT((size_t)index < fBitCount);
size_t internalIndex = index / 32;
SkASSERT(internalIndex < fDwordCount);
return (uint32_t*)fBitData.get() + internalIndex;
return reinterpret_cast<uint32_t*>(fBitData.get()) + internalIndex;
}
};

View File

@ -71,8 +71,7 @@ public:
}
virtual void setMatrixClip(const SkMatrix& m, const SkRegion& r,
const SkClipStack& c)
{
const SkClipStack& c) {
SkDevice::setMatrixClip(m, r, c);
}

View File

@ -48,7 +48,7 @@ public:
class F2BIter {
public:
F2BIter(const SkPDFGlyphSetMap& map);
explicit F2BIter(const SkPDFGlyphSetMap& map);
FontGlyphSetPair* next() const;
void reset(const SkPDFGlyphSetMap& map);

View File

@ -285,22 +285,22 @@ public:
* @return The value argument is returned.
*/
SkPDFObject* append(SkPDFObject* value);
/** Creates a SkPDFInt object and appends it to the array.
* @param value The value to add to the array.
*/
void appendInt(int32_t value);
/** Creates a SkPDFScalar object and appends it to the array.
* @param value The value to add to the array.
*/
void appendScalar(SkScalar value);
/** Creates a SkPDFName object and appends it to the array.
* @param value The value to add to the array.
*/
void appendName(const char name[]);
private:
static const int kMaxLen = 8191;
SkTDArray<SkPDFObject*> fValue;
@ -346,19 +346,19 @@ public:
* @return The value argument is returned.
*/
SkPDFObject* insert(const char key[], SkPDFObject* value);
/** Add the int to the dictionary with the given key.
* @param key The text of the key for this dictionary entry.
* @param value The int value for this dictionary entry.
*/
void insertInt(const char key[], int32_t value);
/** Add the scalar to the dictionary with the given key.
* @param key The text of the key for this dictionary entry.
* @param value The scalar value for this dictionary entry.
*/
void insertScalar(const char key[], SkScalar value);
/** Add the name to the dictionary with the given key.
* @param key The text of the key for this dictionary entry.
* @param name The name for this dictionary entry.
@ -372,7 +372,7 @@ public:
void insertName(const char key[], const SkString& name) {
this->insertName(key, name.c_str());
}
/** Remove all entries from the dictionary.
*/
void clear();

View File

@ -29,7 +29,7 @@ struct SkRect;
PRINT_NOT_IMPL("NOT_IMPLEMENTED: " #condition "\n"); \
SkDEBUGCODE(SkASSERT(!assert);) \
} \
} while(0)
} while (0)
class SkPDFUtils {
public:

View File

@ -24,7 +24,7 @@ SkBitSet::SkBitSet(const SkBitSet& source)
}
const SkBitSet& SkBitSet::operator=(const SkBitSet& rhs) {
if (this == (SkBitSet*)&rhs) {
if (this == &rhs) {
return *this;
}
fBitCount = rhs.fBitCount;
@ -84,7 +84,7 @@ bool SkBitSet::orBits(const SkBitSet& source) {
void SkBitSet::exportTo(SkTDArray<uint32_t>* array) const {
SkASSERT(array);
uint32_t* data = (uint32_t*)fBitData.get();
uint32_t* data = reinterpret_cast<uint32_t*>(fBitData.get());
for (unsigned int i = 0; i < fDwordCount; ++i) {
uint32_t value = data[i];
if (value) { // There are set bits

View File

@ -106,11 +106,11 @@ int32_t SkPDFCatalog::emitXrefTable(SkWStream* stream, bool firstPage) {
int first = -1;
int last = fCatalog.count() - 1;
// TODO(vandebo) support linearized format.
//int last = fCatalog.count() - fFirstPageCount - 1;
//if (firstPage) {
// first = fCatalog.count() - fFirstPageCount;
// last = fCatalog.count() - 1;
//}
// int last = fCatalog.count() - fFirstPageCount - 1;
// if (firstPage) {
// first = fCatalog.count() - fFirstPageCount;
// last = fCatalog.count() - 1;
// }
stream->writeText("xref\n");
stream->writeDecAsText(first + 1);

View File

@ -793,9 +793,8 @@ void SkPDFDevice::drawText(const SkDraw& d, const void* text, size_t len,
// We want the text in glyph id encoding and a writable buffer, so we end
// up making a copy either way.
size_t numGlyphs = paint.textToGlyphs(text, len, NULL);
uint16_t* glyphIDs =
(uint16_t*)sk_malloc_flags(numGlyphs * 2,
SK_MALLOC_TEMP | SK_MALLOC_THROW);
uint16_t* glyphIDs = reinterpret_cast<uint16_t*>(
sk_malloc_flags(numGlyphs * 2, SK_MALLOC_TEMP | SK_MALLOC_THROW));
SkAutoFree autoFreeGlyphIDs(glyphIDs);
if (paint.getTextEncoding() != SkPaint::kGlyphID_TextEncoding) {
paint.textToGlyphs(text, len, glyphIDs);
@ -872,15 +871,15 @@ void SkPDFDevice::drawPosText(const SkDraw& d, const void* text, size_t len,
size_t numGlyphs;
if (paint.getTextEncoding() != SkPaint::kGlyphID_TextEncoding) {
numGlyphs = paint.textToGlyphs(text, len, NULL);
glyphIDs = (uint16_t*)sk_malloc_flags(numGlyphs * 2,
SK_MALLOC_TEMP | SK_MALLOC_THROW);
glyphIDs = reinterpret_cast<uint16_t*>(sk_malloc_flags(
numGlyphs * 2, SK_MALLOC_TEMP | SK_MALLOC_THROW));
glyphStorage.set(glyphIDs);
paint.textToGlyphs(text, len, glyphIDs);
textPaint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
} else {
SkASSERT((len & 1) == 0);
numGlyphs = len / 2;
glyphIDs = (uint16_t*)text;
glyphIDs = reinterpret_cast<uint16_t*>(const_cast<void*>((text)));
}
SkDrawCacheProc glyphCacheProc = textPaint.getDrawCacheProc();

View File

@ -161,10 +161,10 @@ bool SkPDFDocument::emitPDF(SkWStream* stream) {
}
fCatalog->emitSubstituteResources(stream, true);
// TODO(vandebo) support linearized format
//if (fPages.size() > 1) {
// // TODO(vandebo) save the file offset for the first page xref table.
// fCatalog->emitXrefTable(stream, true);
//}
// if (fPages.size() > 1) {
// // TODO(vandebo) save the file offset for the first page xref table.
// fCatalog->emitXrefTable(stream, true);
// }
for (int i = 0; i < fPageTree.count(); i++) {
fPageTree[i]->emitObject(stream, fCatalog.get(), true);
@ -204,7 +204,7 @@ bool SkPDFDocument::setPage(int pageNumber, SkPDFDevice* pdfDevice) {
SkPDFPage* page = new SkPDFPage(pdfDevice);
SkSafeUnref(fPages[pageNumber]);
fPages[pageNumber] = page; // Reference from new passed to fPages.
fPages[pageNumber] = page; // Reference from new passed to fPages.
return true;
}

View File

@ -166,10 +166,10 @@ SkStream* handleType1Stream(SkStream* srcStream, size_t* headerLen,
}
((uint8_t *)src)[srcLen] = 0;
} else {
static const size_t bufSize = 4096;
uint8_t buf[bufSize];
static const size_t kBufSize = 4096;
uint8_t buf[kBufSize];
size_t amount;
while ((amount = srcStream->read(buf, bufSize)) > 0)
while ((amount = srcStream->read(buf, kBufSize)) > 0)
dynamicStream.write(buf, amount);
amount = 0;
dynamicStream.write(&amount, 1); // NULL terminator.

View File

@ -147,7 +147,7 @@ void extractImageData(const SkBitmap& bitmap, const SkIRect& srcRect,
int offset2 = 8 - offset1;
for (int y = srcRect.fTop; y < srcRect.fBottom; y++) {
uint8_t* src = bitmap.getAddr1(0, y);
// This may read up to one byte after src, but the potentially
// This may read up to one byte after src, but the potentially
// invalid bits are never used for computation.
for (int x = srcRect.fLeft; x < srcRect.fRight; x += 8) {
if (offset1) {

View File

@ -103,7 +103,7 @@ void SkPDFPage::GeneratePageTree(const SkTDArray<SkPDFPage*>& pages,
// TODO(vandebo) put the objects in strict access order.
// Probably doesn't matter because they are so small.
if (curNodes[i] != pages[0]) {
pageTree->push(curNodes[i]); // Transfer reference.
pageTree->push(curNodes[i]); // Transfer reference.
catalog->addObject(curNodes[i], false);
} else {
SkSafeUnref(curNodes[i]);
@ -123,9 +123,9 @@ void SkPDFPage::GeneratePageTree(const SkTDArray<SkPDFPage*>& pages,
curNodes = nextRoundNodes;
nextRoundNodes.rewind();
treeCapacity *= kNodeSize;
} while(curNodes.count() > 1);
} while (curNodes.count() > 1);
pageTree->push(curNodes[0]); // Transfer reference.
pageTree->push(curNodes[0]); // Transfer reference.
catalog->addObject(curNodes[0], false);
if (rootNode)
*rootNode = curNodes[0];

View File

@ -200,7 +200,7 @@ static void tileModeCode(SkShader::TileMode mode, SkString* result) {
}
static SkString linearCode(const SkShader::GradientInfo& info) {
SkString function("{pop\n"); // Just ditch the y value.
SkString function("{pop\n"); // Just ditch the y value.
tileModeCode(info.fTileMode, &function);
gradientFunctionCode(info, &function);
function.append("}");
@ -300,7 +300,7 @@ public:
class SkPDFFunctionShader : public SkPDFDict, public SkPDFShader {
public:
SkPDFFunctionShader(SkPDFShader::State* state);
explicit SkPDFFunctionShader(SkPDFShader::State* state);
~SkPDFFunctionShader() {
if (isValid()) {
RemoveShader(this);
@ -325,7 +325,7 @@ private:
class SkPDFImageShader : public SkPDFStream, public SkPDFShader {
public:
SkPDFImageShader(SkPDFShader::State* state);
explicit SkPDFImageShader(SkPDFShader::State* state);
~SkPDFImageShader() {
RemoveShader(this);
fResources.unrefAll();
@ -808,8 +808,8 @@ SkPDFShader::State::State(const SkShader& shader,
} else {
fColorData.set(sk_malloc_throw(
fInfo.fColorCount * (sizeof(SkColor) + sizeof(SkScalar))));
fInfo.fColors = (SkColor*)fColorData.get();
fInfo.fColorOffsets = (SkScalar*)(fInfo.fColors + fInfo.fColorCount);
fInfo.fColors = reinterpret_cast<SkColor*>(fColorData.get());
fInfo.fColorOffsets = reinterpret_cast<SkScalar*>(fInfo.fColors + fInfo.fColorCount);
shader.asAGradient(&fInfo);
}
}