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;
}
};
}
virtual void setMatrixClip(const SkMatrix& m, const SkRegion& r,
- const SkClipStack& c)
- {
+ const SkClipStack& c) {
SkDevice::setMatrixClip(m, r, c);
}
class F2BIter {
public:
- F2BIter(const SkPDFGlyphSetMap& map);
+ explicit F2BIter(const SkPDFGlyphSetMap& map);
FontGlyphSetPair* next() const;
void reset(const SkPDFGlyphSetMap& map);
* @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;
* @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.
void insertName(const char key[], const SkString& name) {
this->insertName(key, name.c_str());
}
-
+
/** Remove all entries from the dictionary.
*/
void clear();
PRINT_NOT_IMPL("NOT_IMPLEMENTED: " #condition "\n"); \
SkDEBUGCODE(SkASSERT(!assert);) \
} \
- } while(0)
+ } while (0)
class SkPDFUtils {
public:
}
const SkBitSet& SkBitSet::operator=(const SkBitSet& rhs) {
- if (this == (SkBitSet*)&rhs) {
+ if (this == &rhs) {
return *this;
}
fBitCount = rhs.fBitCount;
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
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);
// 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);
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();
}
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);
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;
}
}
((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.
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) {
// 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]);
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];
}
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("}");
class SkPDFFunctionShader : public SkPDFDict, public SkPDFShader {
public:
- SkPDFFunctionShader(SkPDFShader::State* state);
+ explicit SkPDFFunctionShader(SkPDFShader::State* state);
~SkPDFFunctionShader() {
if (isValid()) {
RemoveShader(this);
class SkPDFImageShader : public SkPDFStream, public SkPDFShader {
public:
- SkPDFImageShader(SkPDFShader::State* state);
+ explicit SkPDFImageShader(SkPDFShader::State* state);
~SkPDFImageShader() {
RemoveShader(this);
fResources.unrefAll();
} 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);
}
}