SkRect dst = SkRect::MakeXYWH(SkDoubleToScalar(0.0), SkDoubleToScalar(0.0), SkDoubleToScalar(1.0), SkDoubleToScalar(1.0));
// TODO(edisonn): soft mask type? alpha/luminosity.
+ SkPaint paint;
+ pdfContext->fGraphicsState.applyGraphicsState(&paint, false);
+
if (!sMask || sMask->empty()) {
- canvas->drawBitmapRect(*image, dst, NULL);
+ canvas->drawBitmapRect(*image, dst, &paint);
} else {
- canvas->saveLayer(&dst, NULL);
+ canvas->saveLayer(&dst, &paint);
canvas->drawBitmapRect(*image, dst, NULL);
SkPaint xfer;
- pdfContext->fGraphicsState.applyGraphicsState(&xfer, false);
// TODO(edisonn): is the blend mode specified already implicitly/explicitly in pdf?
xfer.setXfermodeMode(SkXfermode::kSrcOut_Mode); // SkXfermode::kSdtOut_Mode
canvas->drawBitmapRect(*sMask, dst, &xfer);
SkString inputFilename;
get_basename(&inputFilename, inputPath);
- SkFILEStream inputStream;
- inputStream.setPath(inputPath.c_str());
- if (!inputStream.isValid()) {
- SkDebugf("Could not open file %s\n", inputPath.c_str());
- return false;
- }
-
- bool success = false;
+ bool success = true;
success = renderer.load(inputPath);
if (FLAGS_showMemoryUsage) {
// TODO(edisonn): bench timers
if (FLAGS_benchLoad > 0) {
for (int i = 0 ; i < FLAGS_benchLoad; i++) {
- success = renderer.load(inputPath);
+ success = renderer.load(inputPath) && success;
if (FLAGS_showMemoryUsage) {
SkDebugf("Memory usage after load %i number : %u\n", i, (unsigned int)renderer.bytesUsed());
}
success = render_page(outputDir, inputFilename, renderer, FLAGS_noExtensionForOnePagePdf && renderer.pages() == 1 ? -1 : renderer.pages() - 1) && success;
} else {
int pn = atoi(FLAGS_pages[0]);
- success = render_page(outputDir, inputFilename, renderer, FLAGS_noExtensionForOnePagePdf && renderer.pages() == 1 ? -1 : renderer.pages() - 1) && pn;
+ success = render_page(outputDir, inputFilename, renderer, FLAGS_noExtensionForOnePagePdf && renderer.pages() == 1 ? -1 : pn) && success;
}
}
}
}
+ if (!success) {
+ SkDebugf("Failures for file %s\n", inputPath.c_str());
+ }
+
return success;
}
}
const unsigned char* SkNativeParsedPDF::readCrossReferenceSection(const unsigned char* xrefStart, const unsigned char* trailerEnd) {
- const unsigned char* current = ignoreLine(xrefStart, trailerEnd); // TODO(edisonn): verify next keyord is "xref", use nextObject here
+ SkPdfObject xref;
+ const unsigned char* current = nextObject(0, xrefStart, trailerEnd, &xref, NULL, NULL);
+
+ if (!xref.isKeyword("xref")) {
+ return trailerEnd;
+ }
SkPdfObject token;
while (current < trailerEnd) {