From ac4bedcb1098416e46f1907b03878787df6342ce Mon Sep 17 00:00:00 2001 From: "edisonn@google.com" Date: Thu, 25 Jul 2013 21:40:23 +0000 Subject: [PATCH] pdfviewer: set the default background to transparent (to match render_picture default), and fix a bug a with corrupt diffs Review URL: https://codereview.chromium.org/20526002 git-svn-id: http://skia.googlecode.com/svn/trunk@10376 2bbb7eff-a529-9590-31e7-b0007b416f81 --- experimental/PdfViewer/SkPdfFont.h | 17 +++++++++-------- experimental/PdfViewer/pdf_viewer_main.cpp | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/experimental/PdfViewer/SkPdfFont.h b/experimental/PdfViewer/SkPdfFont.h index 247b3f5409..4929a80749 100644 --- a/experimental/PdfViewer/SkPdfFont.h +++ b/experimental/PdfViewer/SkPdfFont.h @@ -363,13 +363,13 @@ public: memset(fChars, 0, sizeof(fChars[0]) * (fLastChar - fFirstChar + 1)); - const SkPdfArray* widths = dict->Widths(parsed); for (unsigned int i = 0 ; i < widths->size(); i++) { - if ((fFirstChar + i) < fFirstChar || (fFirstChar + i) > fLastChar) { - printf("break; error 1\n"); + if ((fFirstChar + i) >= fFirstChar && (fFirstChar + i) <= fLastChar) { + fChars[i].fWidth = (*widths)[i]->numberValue(); + } else { + // TODO(edisonn): report pdf corruption } - fChars[i].fWidth = (*widths)[i]->numberValue(); } const SkPdfArray* diffs = fEncodingDict->Differences(parsed); @@ -378,13 +378,14 @@ public: if ((*diffs)[i]->isInteger()) { j = (unsigned int)(*diffs)[i]->intValue(); } else if ((*diffs)[i]->isName()) { - if (j < fFirstChar || j > fLastChar) { - printf("break; error 2\n"); + if (j >= fFirstChar && j <= fLastChar) { + fChars[j - fFirstChar].fObj = fCharProcs->get((*diffs)[i]); + } else { + // TODO(edisonn): report pdf corruption } - fChars[j - fFirstChar].fObj = fCharProcs->get((*diffs)[i]); j++; } else { - // err + // TODO(edisonn): report bad pdf } } } diff --git a/experimental/PdfViewer/pdf_viewer_main.cpp b/experimental/PdfViewer/pdf_viewer_main.cpp index cfea97411d..d43086fedc 100644 --- a/experimental/PdfViewer/pdf_viewer_main.cpp +++ b/experimental/PdfViewer/pdf_viewer_main.cpp @@ -139,7 +139,7 @@ static bool make_output_filepath(SkString* path, const SkString& dir, PNG_FILE_EXTENSION); } -static void setup_bitmap(SkBitmap* bitmap, int width, int height, SkColor color = SK_ColorWHITE) { +static void setup_bitmap(SkBitmap* bitmap, int width, int height, SkColor color = SK_ColorTRANSPARENT) { bitmap->setConfig(SkBitmap::kARGB_8888_Config, width, height); bitmap->allocPixels();