No effect cleanup in pdf code.
Review URL: http://codereview.appspot.com/4927042
git-svn-id: http://skia.googlecode.com/svn/trunk@2146 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/pdf/SkPDFCatalog.cpp b/src/pdf/SkPDFCatalog.cpp
index 90aa78e..bc22e6a 100644
--- a/src/pdf/SkPDFCatalog.cpp
+++ b/src/pdf/SkPDFCatalog.cpp
@@ -29,8 +29,9 @@
return obj;
}
SkASSERT(fNextFirstPageObjNum == 0);
- if (onFirstPage)
+ if (onFirstPage) {
fFirstPageCount++;
+ }
struct Rec newEntry(obj, onFirstPage);
fCatalog.append(1, &newEntry);
@@ -59,8 +60,9 @@
int SkPDFCatalog::findObjectIndex(SkPDFObject* obj) const {
for (int i = 0; i < fCatalog.count(); i++) {
- if (fCatalog[i].fObject == obj)
+ if (fCatalog[i].fObject == obj) {
return i;
+ }
}
// If it's not in the main array, check if it's a substitute object.
for (int i = 0; i < fSubstituteMap.count(); ++i) {
@@ -77,12 +79,14 @@
// to the resource list.
SkASSERT(pos >= 0);
uint32_t currentIndex = pos;
- if (fCatalog[currentIndex].fObjNumAssigned)
+ if (fCatalog[currentIndex].fObjNumAssigned) {
return currentIndex + 1;
+ }
// First assignment.
- if (fNextFirstPageObjNum == 0)
+ if (fNextFirstPageObjNum == 0) {
fNextFirstPageObjNum = fCatalog.count() - fFirstPageCount + 1;
+ }
uint32_t objNum;
if (fCatalog[currentIndex].fOnFirstPage) {
@@ -96,8 +100,9 @@
// When we assign an object an object number, we put it in that array
// offset (minus 1 because object number 0 is reserved).
SkASSERT(!fCatalog[objNum - 1].fObjNumAssigned);
- if (objNum - 1 != currentIndex)
+ if (objNum - 1 != currentIndex) {
SkTSwap(fCatalog[objNum - 1], fCatalog[currentIndex]);
+ }
fCatalog[objNum - 1].fObjNumAssigned = true;
return objNum;
}
@@ -105,7 +110,7 @@
int32_t SkPDFCatalog::emitXrefTable(SkWStream* stream, bool firstPage) {
int first = -1;
int last = fCatalog.count() - 1;
- // TODO(vandebo) support linearized format.
+ // TODO(vandebo): Support linearized format.
// int last = fCatalog.count() - fFirstPageCount - 1;
// if (firstPage) {
// first = fCatalog.count() - fFirstPageCount;
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index 31c6c26..9cdce36 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -54,10 +54,11 @@
kStdFakeBoldInterpValues,
kStdFakeBoldInterpLength);
SkScalar width = SkScalarMul(result.getTextSize(), fakeBoldScale);
- if (result.getStyle() == SkPaint::kFill_Style)
+ if (result.getStyle() == SkPaint::kFill_Style) {
result.setStyle(SkPaint::kStrokeAndFill_Style);
- else
+ } else {
width += result.getStrokeWidth();
+ }
result.setStrokeWidth(width);
}
return result;
@@ -67,8 +68,9 @@
static void align_text(SkDrawCacheProc glyphCacheProc, const SkPaint& paint,
const uint16_t* glyphs, size_t len, SkScalar* x,
SkScalar* y, SkScalar* width) {
- if (paint.getTextAlign() == SkPaint::kLeft_Align && width == NULL)
+ if (paint.getTextAlign() == SkPaint::kLeft_Align && width == NULL) {
return;
+ }
SkMatrix ident;
ident.reset();
@@ -79,16 +81,18 @@
const char* stop = reinterpret_cast<const char*>(glyphs + len);
SkFixed xAdv = 0, yAdv = 0;
- // TODO(vandebo) This probably needs to take kerning into account.
+ // TODO(vandebo): This probably needs to take kerning into account.
while (start < stop) {
const SkGlyph& glyph = glyphCacheProc(cache, &start, 0, 0);
xAdv += glyph.fAdvanceX;
yAdv += glyph.fAdvanceY;
};
- if (width)
+ if (width) {
*width = SkFixedToScalar(xAdv);
- if (paint.getTextAlign() == SkPaint::kLeft_Align)
+ }
+ if (paint.getTextAlign() == SkPaint::kLeft_Align) {
return;
+ }
SkScalar xAdj = SkFixedToScalar(xAdv);
SkScalar yAdj = SkFixedToScalar(yAdv);
@@ -277,7 +281,7 @@
}
}
-// TODO(vandebo) Take advantage of SkClipStack::getSaveCount(), the PDF
+// TODO(vandebo): Take advantage of SkClipStack::getSaveCount(), the PDF
// graphic state stack, and the fact that we can know all the clips used
// on the page to optimize this.
void GraphicStackState::updateClip(const SkClipStack& clipStack,
@@ -1280,7 +1284,7 @@
createFormXObjectFromDevice(dst);
}
}
- // TODO(vandebo) Figure out how/if we can handle the following modes:
+ // TODO(vandebo): Figure out how/if we can handle the following modes:
// SrcAtop, DestAtop, Xor, Plus.
// These xfer modes don't draw source at all.
diff --git a/src/pdf/SkPDFDocument.cpp b/src/pdf/SkPDFDocument.cpp
index e566856..cb87d8f 100644
--- a/src/pdf/SkPDFDocument.cpp
+++ b/src/pdf/SkPDFDocument.cpp
@@ -68,8 +68,9 @@
// The page tree has both child and parent pointers, so it creates a
// reference cycle. We must clear that cycle to properly reclaim memory.
- for (int i = 0; i < fPageTree.count(); i++)
+ for (int i = 0; i < fPageTree.count(); i++) {
fPageTree[i]->clear();
+ }
fPageTree.safeUnrefAll();
fPageResources.safeUnrefAll();
fSubstitutes.safeUnrefAll();
@@ -86,13 +87,13 @@
}
// We haven't emitted the document before if fPageTree is empty.
- if (fPageTree.count() == 0) {
+ if (fPageTree.isEmpty()) {
SkPDFDict* pageTreeRoot;
SkPDFPage::GeneratePageTree(fPages, fCatalog.get(), &fPageTree,
&pageTreeRoot);
fDocCatalog->insert("Pages", new SkPDFObjRef(pageTreeRoot))->unref();
- /* TODO(vandebo) output intent
+ /* TODO(vandebo): output intent
SkRefPtr<SkPDFDict> outputIntent = new SkPDFDict("OutputIntent");
outputIntent->unref(); // SkRefPtr and new both took a reference.
outputIntent->insert("S", new SkPDFName("GTS_PDFA1"))->unref();
@@ -131,21 +132,24 @@
// Add the size of resources of substitute objects used on page 1.
fileOffset += fCatalog->setSubstituteResourcesOffsets(fileOffset, true);
if (fPages.count() > 1) {
- // TODO(vandebo) For linearized format, save the start of the
+ // TODO(vandebo): For linearized format, save the start of the
// first page xref table and calculate the size.
}
- for (int i = 0; i < fPageTree.count(); i++)
+ for (int i = 0; i < fPageTree.count(); i++) {
fileOffset += fCatalog->setFileOffset(fPageTree[i], fileOffset);
+ }
- for (int i = 1; i < fPages.count(); i++)
+ for (int i = 1; i < fPages.count(); i++) {
fileOffset += fPages[i]->getPageSize(fCatalog.get(), fileOffset);
+ }
for (int i = fSecondPageFirstResourceIndex;
i < fPageResources.count();
- i++)
+ i++) {
fileOffset += fCatalog->setFileOffset(fPageResources[i],
fileOffset);
+ }
fileOffset += fCatalog->setSubstituteResourcesOffsets(fileOffset,
false);
@@ -160,9 +164,9 @@
fPageResources[i]->emit(stream, fCatalog.get(), true);
}
fCatalog->emitSubstituteResources(stream, true);
- // TODO(vandebo) support linearized format
+ // TODO(vandebo): Support linearized format
// 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);
// }
@@ -187,7 +191,7 @@
}
bool SkPDFDocument::setPage(int pageNumber, SkPDFDevice* pdfDevice) {
- if (fPageTree.count() != 0) {
+ if (!fPageTree.isEmpty()) {
return false;
}
@@ -209,7 +213,7 @@
}
bool SkPDFDocument::appendPage(SkPDFDevice* pdfDevice) {
- if (fPageTree.count() != 0) {
+ if (!fPageTree.isEmpty()) {
return false;
}
@@ -241,8 +245,8 @@
fTrailerDict = new SkPDFDict();
fTrailerDict->unref(); // SkRefPtr and new both took a reference.
- // TODO(vandebo) Linearized format will take a Prev entry too.
- // TODO(vandebo) PDF/A requires an ID entry.
+ // TODO(vandebo): Linearized format will take a Prev entry too.
+ // TODO(vandebo): PDF/A requires an ID entry.
fTrailerDict->insertInt("Size", objCount);
fTrailerDict->insert("Root",
new SkPDFObjRef(fDocCatalog.get()))->unref();
diff --git a/src/pdf/SkPDFFont.cpp b/src/pdf/SkPDFFont.cpp
index 7fe8b5c..989b276 100644
--- a/src/pdf/SkPDFFont.cpp
+++ b/src/pdf/SkPDFFont.cpp
@@ -44,18 +44,20 @@
// an ASCII section (includes a length), type two is a binary section
// (includes a length) and type three is an EOF marker with no length.
const uint8_t* buf = *src;
- if (*len < 2 || buf[0] != 0x80 || buf[1] != sectionType)
+ if (*len < 2 || buf[0] != 0x80 || buf[1] != sectionType) {
return false;
- if (buf[1] == 3)
+ } else if (buf[1] == 3) {
return true;
- if (*len < 6)
+ } else if (*len < 6) {
return false;
+ }
*size = (size_t)buf[2] | ((size_t)buf[3] << 8) | ((size_t)buf[4] << 16) |
((size_t)buf[5] << 24);
size_t consumed = *size + 6;
- if (consumed > *len)
+ if (consumed > *len) {
return false;
+ }
*src = *src + consumed;
*len = *len - consumed;
return true;
@@ -85,17 +87,20 @@
const char* end = src + size;
const char* dataPos = strstr(src, "eexec");
- if (!dataPos)
+ if (!dataPos) {
return false;
+ }
dataPos += strlen("eexec");
while ((*dataPos == '\n' || *dataPos == '\r' || *dataPos == ' ') &&
- dataPos < end)
+ dataPos < end) {
dataPos++;
+ }
*headerLen = dataPos - src;
const char* trailerPos = strstr(dataPos, "cleartomark");
- if (!trailerPos)
+ if (!trailerPos) {
return false;
+ }
int zeroCount = 0;
for (trailerPos--; trailerPos > dataPos && zeroCount < 512; trailerPos--) {
if (*trailerPos == '\n' || *trailerPos == '\r' || *trailerPos == ' ') {
@@ -106,8 +111,9 @@
return false;
}
}
- if (zeroCount != 512)
+ if (zeroCount != 512) {
return false;
+ }
*hexDataLen = trailerPos - src - *headerLen;
*trailerLen = size - *headerLen - *hexDataLen;
@@ -115,10 +121,12 @@
// Verify that the data section is hex encoded and count the bytes.
int nibbles = 0;
for (; dataPos < trailerPos; dataPos++) {
- if (isspace(*dataPos))
+ if (isspace(*dataPos)) {
continue;
- if (!isxdigit(*dataPos))
+ }
+ if (!isxdigit(*dataPos)) {
return false;
+ }
nibbles++;
}
*dataLen = (nibbles + 1) / 2;
@@ -127,11 +135,15 @@
}
int8_t hexToBin(uint8_t c) {
- if (!isxdigit(c))
+ if (!isxdigit(c)) {
return -1;
- if (c <= '9') return c - '0';
- if (c <= 'F') return c - 'A' + 10;
- if (c <= 'f') return c - 'a' + 10;
+ } else if (c <= '9') {
+ return c - '0';
+ } else if (c <= 'F') {
+ return c - 'A' + 10;
+ } else if (c <= 'f') {
+ return c - 'a' + 10;
+ }
return -1;
}
@@ -158,8 +170,9 @@
while (read < srcLen) {
size_t got = srcStream->read((void *)staticStream->getAtPos(),
srcLen - read);
- if (got == 0)
+ if (got == 0) {
return NULL;
+ }
read += got;
staticStream->seek(read);
}
@@ -169,8 +182,9 @@
static const size_t kBufSize = 4096;
uint8_t buf[kBufSize];
size_t amount;
- while ((amount = srcStream->read(buf, kBufSize)) > 0)
+ while ((amount = srcStream->read(buf, kBufSize)) > 0) {
dynamicStream.write(buf, amount);
+ }
amount = 0;
dynamicStream.write(&amount, 1); // NULL terminator.
data = dynamicStream.copyToData();
@@ -211,8 +225,9 @@
bool highNibble = true;
for (; hexData < trailer; hexData++) {
char curNibble = hexToBin(*hexData);
- if (curNibble < 0)
+ if (curNibble < 0) {
continue;
+ }
if (highNibble) {
dataByte = curNibble << 4;
highNibble = false;
@@ -222,8 +237,9 @@
((char *)result->getAtPos())[outputOffset++] = dataByte;
}
}
- if (!highNibble)
+ if (!highNibble) {
((char *)result->getAtPos())[outputOffset++] = dataByte;
+ }
SkASSERT(outputOffset == *dataLen);
result->seek(*headerLen + outputOffset);
@@ -450,7 +466,9 @@
void append_cmap_sections(const SkTDArray<SkUnichar>& glyphToUnicode,
const SkPDFGlyphSet* subset,
SkDynamicMemoryWStream* cmap) {
- if (glyphToUnicode.count() == 0) return;
+ if (glyphToUnicode.isEmpty()) {
+ return;
+ }
SkTDArray<BFChar> bfcharEntries;
SkTDArray<BFRange> bfrangeEntries;
@@ -795,11 +813,12 @@
// static
bool SkPDFFont::Find(uint32_t fontID, uint16_t glyphID, int* index) {
- // TODO(vandebo) optimize this, do only one search?
+ // TODO(vandebo): Optimize this, do only one search?
FontRec search(NULL, fontID, glyphID);
*index = CanonicalFonts().find(search);
- if (*index >= 0)
+ if (*index >= 0) {
return true;
+ }
search.fGlyphID = 0;
*index = CanonicalFonts().find(search);
return false;
@@ -927,14 +946,16 @@
}
bool SkPDFFont::FontRec::operator==(const SkPDFFont::FontRec& b) const {
- if (fFontID != b.fFontID)
+ if (fFontID != b.fFontID) {
return false;
+ }
if (fFont != NULL && b.fFont != NULL) {
return fFont->fFirstGlyphID == b.fFont->fFirstGlyphID &&
fFont->fLastGlyphID == b.fFont->fLastGlyphID;
}
- if (fGlyphID == 0 || b.fGlyphID == 0)
+ if (fGlyphID == 0 || b.fGlyphID == 0) {
return true;
+ }
if (fFont != NULL) {
return fFont->fFirstGlyphID <= b.fGlyphID &&
@@ -1242,8 +1263,9 @@
}
}
- if (!addFontDescriptor(defaultWidth))
+ if (!addFontDescriptor(defaultWidth)) {
return false;
+ }
insertName("Subtype", "Type1");
insertName("BaseFont", fontInfo()->fFontName);
@@ -1286,8 +1308,9 @@
} else {
firstChar = startIndex + widthRangeEntry->fStartId;
}
- for (int i = startIndex; i < endIndex; i++)
+ for (int i = startIndex; i < endIndex; i++) {
appendWidth(widthRangeEntry->fAdvance[i], emSize, widthArray.get());
+ }
} else {
appendWidth(defaultWidth, 1000, widthArray.get());
}
diff --git a/src/pdf/SkPDFGraphicState.cpp b/src/pdf/SkPDFGraphicState.cpp
index a98c730..3ac0e2f 100644
--- a/src/pdf/SkPDFGraphicState.cpp
+++ b/src/pdf/SkPDFGraphicState.cpp
@@ -39,7 +39,7 @@
case SkXfermode::kDstOut_Mode:
return "Normal";
- // TODO(vandebo) Figure out if we can support more of these modes.
+ // TODO(vandebo): Figure out if we can support more of these modes.
case SkXfermode::kSrcATop_Mode:
case SkXfermode::kDstATop_Mode:
case SkXfermode::kXor_Mode:
diff --git a/src/pdf/SkPDFImage.cpp b/src/pdf/SkPDFImage.cpp
index 8cfbcce..72379b1 100644
--- a/src/pdf/SkPDFImage.cpp
+++ b/src/pdf/SkPDFImage.cpp
@@ -75,10 +75,12 @@
dst += 3;
alphaDst[0] = (SkGetPackedA4444(src[x]) << 4) |
SkGetPackedA4444(src[x + 1]);
- if (alphaDst[0] != 0xFF)
+ if (alphaDst[0] != 0xFF) {
hasAlpha = true;
- if (alphaDst[0])
+ }
+ if (alphaDst[0]) {
isTransparent = false;
+ }
alphaDst++;
}
if (srcRect.width() & 1) {
@@ -87,10 +89,12 @@
dst[1] = (SkGetPackedB4444(src[x]) << 4);
dst += 2;
alphaDst[0] = (SkGetPackedA4444(src[x]) << 4);
- if (alphaDst[0] != 0xF0)
+ if (alphaDst[0] != 0xF0) {
hasAlpha = true;
- if (alphaDst[0] & 0xF0)
+ }
+ if (alphaDst[0] & 0xF0) {
isTransparent = false;
+ }
alphaDst++;
}
}
@@ -126,10 +130,12 @@
dst[2] = SkGetPackedB32(src[x]);
dst += 3;
alphaDst[0] = SkGetPackedA32(src[x]);
- if (alphaDst[0] != 0xFF)
+ if (alphaDst[0] != 0xFF) {
hasAlpha = true;
- if (alphaDst[0])
+ }
+ if (alphaDst[0]) {
isTransparent = false;
+ }
alphaDst++;
}
}
@@ -156,20 +162,24 @@
} else {
alphaDst[0] = src[x / 8];
}
- if (x + 7 < srcRect.fRight && alphaDst[0] != 0xFF)
+ if (x + 7 < srcRect.fRight && alphaDst[0] != 0xFF) {
hasAlpha = true;
- if (x + 7 < srcRect.fRight && alphaDst[0])
+ }
+ if (x + 7 < srcRect.fRight && alphaDst[0]) {
isTransparent = false;
+ }
alphaDst++;
}
// Calculate the mask of bits we're interested in within the
// last byte of alphaDst.
// width mod 8 == 1 -> 0x80 ... width mod 8 == 7 -> 0xFE
uint8_t mask = ~((1 << (8 - (srcRect.width() % 8))) - 1);
- if (srcRect.width() % 8 && (alphaDst[-1] & mask) != mask)
+ if (srcRect.width() % 8 && (alphaDst[-1] & mask) != mask) {
hasAlpha = true;
- if (srcRect.width() % 8 && (alphaDst[-1] & mask))
+ }
+ if (srcRect.width() % 8 && (alphaDst[-1] & mask)) {
isTransparent = false;
+ }
}
break;
}
@@ -185,10 +195,12 @@
uint8_t* src = bitmap.getAddr8(0, y);
for (int x = srcRect.fLeft; x < srcRect.fRight; x++) {
alphaDst[0] = src[x];
- if (alphaDst[0] != 0xFF)
+ if (alphaDst[0] != 0xFF) {
hasAlpha = true;
- if (alphaDst[0])
+ }
+ if (alphaDst[0]) {
isTransparent = false;
+ }
alphaDst++;
}
}
@@ -240,8 +252,9 @@
SkPDFImage* SkPDFImage::CreateImage(const SkBitmap& bitmap,
const SkIRect& srcRect,
const SkPaint& paint) {
- if (bitmap.getConfig() == SkBitmap::kNo_Config)
+ if (bitmap.getConfig() == SkBitmap::kNo_Config) {
return NULL;
+ }
SkStream* imageData = NULL;
SkStream* alphaData = NULL;
@@ -314,10 +327,11 @@
// }
int bitsPerComp = 8;
- if (config == SkBitmap::kARGB_4444_Config)
+ if (config == SkBitmap::kARGB_4444_Config) {
bitsPerComp = 4;
- else if (doingAlpha && config == SkBitmap::kA1_Config)
+ } else if (doingAlpha && config == SkBitmap::kA1_Config) {
bitsPerComp = 1;
+ }
insertInt("BitsPerComponent", bitsPerComp);
if (config == SkBitmap::kRGB_565_Config) {
diff --git a/src/pdf/SkPDFPage.cpp b/src/pdf/SkPDFPage.cpp
index cc8fc48..136ef44 100644
--- a/src/pdf/SkPDFPage.cpp
+++ b/src/pdf/SkPDFPage.cpp
@@ -100,7 +100,7 @@
curNodes[i]->insert(parentName.get(), newNodeRef.get());
kids->append(new SkPDFObjRef(curNodes[i]))->unref();
- // 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.
if (curNodes[i] != pages[0]) {
pageTree->push(curNodes[i]); // Transfer reference.
@@ -127,8 +127,9 @@
pageTree->push(curNodes[0]); // Transfer reference.
catalog->addObject(curNodes[0], false);
- if (rootNode)
+ if (rootNode) {
*rootNode = curNodes[0];
+ }
}
const SkTDArray<SkPDFFont*>& SkPDFPage::getFontResources() const {
diff --git a/src/pdf/SkPDFTypes.cpp b/src/pdf/SkPDFTypes.cpp
index cd1c51e..f97f21b 100644
--- a/src/pdf/SkPDFTypes.cpp
+++ b/src/pdf/SkPDFTypes.cpp
@@ -84,8 +84,9 @@
void SkPDFInt::emitObject(SkWStream* stream, SkPDFCatalog* catalog,
bool indirect) {
- if (indirect)
+ if (indirect) {
return emitIndirectObject(stream, catalog);
+ }
stream->writeDecAsText(fValue);
}
@@ -104,8 +105,9 @@
size_t SkPDFBool::getOutputSize(SkPDFCatalog* catalog, bool indirect) {
SkASSERT(!indirect);
- if (fValue)
+ if (fValue) {
return strlen("true");
+ }
return strlen("false");
}
@@ -114,8 +116,9 @@
void SkPDFScalar::emitObject(SkWStream* stream, SkPDFCatalog* catalog,
bool indirect) {
- if (indirect)
+ if (indirect) {
return emitIndirectObject(stream, catalog);
+ }
Append(fValue, stream);
}
@@ -223,8 +226,9 @@
SkASSERT(wideInput);
SkString result;
result.append("<");
- for (size_t i = 0; i < len; i++)
+ for (size_t i = 0; i < len; i++) {
result.appendHex(win[i], 4);
+ }
result.append(">");
return result;
}
@@ -247,8 +251,9 @@
for (size_t i = 0; i < len; i++) {
SkASSERT(!wideInput || !(win[i] & ~0xFF));
char val = wideInput ? win[i] : cin[i];
- if (val == '\\' || val == '(' || val == ')')
+ if (val == '\\' || val == '(' || val == ')') {
result.append("\\");
+ }
result.append(&val, 1);
}
result.append(")");
@@ -308,27 +313,32 @@
void SkPDFArray::emitObject(SkWStream* stream, SkPDFCatalog* catalog,
bool indirect) {
- if (indirect)
+ if (indirect) {
return emitIndirectObject(stream, catalog);
+ }
stream->writeText("[");
for (int i = 0; i < fValue.count(); i++) {
fValue[i]->emit(stream, catalog, false);
- if (i + 1 < fValue.count())
+ if (i + 1 < fValue.count()) {
stream->writeText(" ");
+ }
}
stream->writeText("]");
}
size_t SkPDFArray::getOutputSize(SkPDFCatalog* catalog, bool indirect) {
- if (indirect)
+ if (indirect) {
return getIndirectOutputSize(catalog);
+ }
size_t result = strlen("[]");
- if (fValue.count())
+ if (fValue.count()) {
result += fValue.count() - 1;
- for (int i = 0; i < fValue.count(); i++)
+ }
+ for (int i = 0; i < fValue.count(); i++) {
result += fValue[i]->getOutputSize(catalog, false);
+ }
return result;
}
@@ -381,8 +391,9 @@
void SkPDFDict::emitObject(SkWStream* stream, SkPDFCatalog* catalog,
bool indirect) {
- if (indirect)
+ if (indirect) {
return emitIndirectObject(stream, catalog);
+ }
stream->writeText("<<");
for (int i = 0; i < fValue.count(); i++) {
@@ -395,8 +406,9 @@
}
size_t SkPDFDict::getOutputSize(SkPDFCatalog* catalog, bool indirect) {
- if (indirect)
+ if (indirect) {
return getIndirectOutputSize(catalog);
+ }
size_t result = strlen("<<>>") + (fValue.count() * 2);
for (int i = 0; i < fValue.count(); i++) {
diff --git a/src/pdf/SkPDFUtils.cpp b/src/pdf/SkPDFUtils.cpp
index f24a994..b596a27 100644
--- a/src/pdf/SkPDFUtils.cpp
+++ b/src/pdf/SkPDFUtils.cpp
@@ -141,18 +141,20 @@
// static
void SkPDFUtils::PaintPath(SkPaint::Style style, SkPath::FillType fill,
SkWStream* content) {
- if (style == SkPaint::kFill_Style)
+ if (style == SkPaint::kFill_Style) {
content->writeText("f");
- else if (style == SkPaint::kStrokeAndFill_Style)
+ } else if (style == SkPaint::kStrokeAndFill_Style) {
content->writeText("B");
- else if (style == SkPaint::kStroke_Style)
+ } else if (style == SkPaint::kStroke_Style) {
content->writeText("S");
+ }
if (style != SkPaint::kStroke_Style) {
NOT_IMPLEMENTED(fill == SkPath::kInverseEvenOdd_FillType, false);
NOT_IMPLEMENTED(fill == SkPath::kInverseWinding_FillType, false);
- if (fill == SkPath::kEvenOdd_FillType)
+ if (fill == SkPath::kEvenOdd_FillType) {
content->writeText("*");
+ }
}
content->writeText("\n");
}