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); SkASSERT((size_t)index < fBitCount);
size_t internalIndex = index / 32; size_t internalIndex = index / 32;
SkASSERT(internalIndex < fDwordCount); 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, virtual void setMatrixClip(const SkMatrix& m, const SkRegion& r,
const SkClipStack& c) const SkClipStack& c) {
{
SkDevice::setMatrixClip(m, r, c); SkDevice::setMatrixClip(m, r, c);
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -106,11 +106,11 @@ int32_t SkPDFCatalog::emitXrefTable(SkWStream* stream, bool firstPage) {
int first = -1; int first = -1;
int last = fCatalog.count() - 1; int last = fCatalog.count() - 1;
// TODO(vandebo) support linearized format. // TODO(vandebo) support linearized format.
//int last = fCatalog.count() - fFirstPageCount - 1; // int last = fCatalog.count() - fFirstPageCount - 1;
//if (firstPage) { // if (firstPage) {
// first = fCatalog.count() - fFirstPageCount; // first = fCatalog.count() - fFirstPageCount;
// last = fCatalog.count() - 1; // last = fCatalog.count() - 1;
//} // }
stream->writeText("xref\n"); stream->writeText("xref\n");
stream->writeDecAsText(first + 1); 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 // We want the text in glyph id encoding and a writable buffer, so we end
// up making a copy either way. // up making a copy either way.
size_t numGlyphs = paint.textToGlyphs(text, len, NULL); size_t numGlyphs = paint.textToGlyphs(text, len, NULL);
uint16_t* glyphIDs = uint16_t* glyphIDs = reinterpret_cast<uint16_t*>(
(uint16_t*)sk_malloc_flags(numGlyphs * 2, sk_malloc_flags(numGlyphs * 2, SK_MALLOC_TEMP | SK_MALLOC_THROW));
SK_MALLOC_TEMP | SK_MALLOC_THROW);
SkAutoFree autoFreeGlyphIDs(glyphIDs); SkAutoFree autoFreeGlyphIDs(glyphIDs);
if (paint.getTextEncoding() != SkPaint::kGlyphID_TextEncoding) { if (paint.getTextEncoding() != SkPaint::kGlyphID_TextEncoding) {
paint.textToGlyphs(text, len, glyphIDs); paint.textToGlyphs(text, len, glyphIDs);
@ -872,15 +871,15 @@ void SkPDFDevice::drawPosText(const SkDraw& d, const void* text, size_t len,
size_t numGlyphs; size_t numGlyphs;
if (paint.getTextEncoding() != SkPaint::kGlyphID_TextEncoding) { if (paint.getTextEncoding() != SkPaint::kGlyphID_TextEncoding) {
numGlyphs = paint.textToGlyphs(text, len, NULL); numGlyphs = paint.textToGlyphs(text, len, NULL);
glyphIDs = (uint16_t*)sk_malloc_flags(numGlyphs * 2, glyphIDs = reinterpret_cast<uint16_t*>(sk_malloc_flags(
SK_MALLOC_TEMP | SK_MALLOC_THROW); numGlyphs * 2, SK_MALLOC_TEMP | SK_MALLOC_THROW));
glyphStorage.set(glyphIDs); glyphStorage.set(glyphIDs);
paint.textToGlyphs(text, len, glyphIDs); paint.textToGlyphs(text, len, glyphIDs);
textPaint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); textPaint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
} else { } else {
SkASSERT((len & 1) == 0); SkASSERT((len & 1) == 0);
numGlyphs = len / 2; numGlyphs = len / 2;
glyphIDs = (uint16_t*)text; glyphIDs = reinterpret_cast<uint16_t*>(const_cast<void*>((text)));
} }
SkDrawCacheProc glyphCacheProc = textPaint.getDrawCacheProc(); SkDrawCacheProc glyphCacheProc = textPaint.getDrawCacheProc();

View File

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

View File

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

View File

@ -147,7 +147,7 @@ void extractImageData(const SkBitmap& bitmap, const SkIRect& srcRect,
int offset2 = 8 - offset1; int offset2 = 8 - offset1;
for (int y = srcRect.fTop; y < srcRect.fBottom; y++) { for (int y = srcRect.fTop; y < srcRect.fBottom; y++) {
uint8_t* src = bitmap.getAddr1(0, 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. // invalid bits are never used for computation.
for (int x = srcRect.fLeft; x < srcRect.fRight; x += 8) { for (int x = srcRect.fLeft; x < srcRect.fRight; x += 8) {
if (offset1) { if (offset1) {

View File

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

View File

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