pdfviewer: load image pain settings (like transparency), pass the page number, report failure if at least one render fails, and check that xref section starts with xref keyword.
Review URL: https://codereview.chromium.org/22465006 git-svn-id: http://skia.googlecode.com/svn/trunk@10588 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
9c8b4eaf28
commit
2273f9b45f
@ -658,13 +658,15 @@ static PdfResult doXObject_Image(PdfContext* pdfContext, SkCanvas* canvas, SkPdf
|
||||
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);
|
||||
|
@ -216,14 +216,7 @@ static bool process_pdf(const SkString& inputPath, const SkString& outputDir,
|
||||
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) {
|
||||
@ -233,7 +226,7 @@ static bool process_pdf(const SkString& inputPath, const SkString& outputDir,
|
||||
// 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());
|
||||
}
|
||||
@ -262,12 +255,16 @@ static bool process_pdf(const SkString& inputPath, const SkString& outputDir,
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -225,7 +225,12 @@ SkNativeParsedPDF::~SkNativeParsedPDF() {
|
||||
}
|
||||
|
||||
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user