Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Unified Diff: experimental/PdfViewer/SkPdfRenderer.cpp

Issue 21049009: pdfviewer: add doPage function, cet stream from Contents (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | experimental/PdfViewer/pdfparser/native/SkNativeParsedPDF.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: experimental/PdfViewer/SkPdfRenderer.cpp
===================================================================
--- experimental/PdfViewer/SkPdfRenderer.cpp (revision 10423)
+++ experimental/PdfViewer/SkPdfRenderer.cpp (working copy)
@@ -784,6 +784,57 @@
}
}
+static PdfResult doPage(PdfContext* pdfContext, SkCanvas* canvas, SkPdfPageObjectDictionary* skobj) {
+ if (!skobj) {
+ return kIgnoreError_PdfResult;
+ }
+
+ if (!skobj->isContentsAStream(pdfContext->fPdfDoc)) {
+ return kNYI_PdfResult;
+ }
+
+ SkPdfStream* stream = skobj->getContentsAsStream(pdfContext->fPdfDoc);
+
+ if (!stream) {
+ return kIgnoreError_PdfResult;
+ }
+
+ if (CheckRecursiveRendering::IsInRendering(skobj)) {
+ // Oops, corrupt PDF!
+ return kIgnoreError_PdfResult;
+ }
+ CheckRecursiveRendering checkRecursion(skobj);
+
+
+ PdfOp_q(pdfContext, canvas, NULL);
+
+ canvas->save();
+
+ if (skobj->Resources(pdfContext->fPdfDoc)) {
+ pdfContext->fGraphicsState.fResources = skobj->Resources(pdfContext->fPdfDoc);
+ }
+
+ // TODO(edisonn): refactor common path with doXObject()
+ // This is a group?
+ if (skobj->has_Group()) {
+ //TransparencyGroupDictionary* ...
+ }
+
+ SkPdfNativeTokenizer* tokenizer =
+ pdfContext->fPdfDoc->tokenizerOfStream(stream, pdfContext->fTmpPageAllocator);
+ if (tokenizer != NULL) {
+ PdfMainLooper looper(NULL, tokenizer, pdfContext, canvas);
+ looper.loop();
+ delete tokenizer;
+ }
+
+ // TODO(edisonn): should we restore the variable stack at the same state?
+ // There could be operands left, that could be consumed by a parent tokenizer when we pop.
+ canvas->restore();
+ PdfOp_Q(pdfContext, canvas, NULL);
+ return kPartial_PdfResult;
+}
+
PdfResult PdfOp_q(PdfContext* pdfContext, SkCanvas* canvas, PdfTokenLooper** looper) {
pdfContext->fStateStack.push(pdfContext->fGraphicsState);
canvas->save();
@@ -2185,12 +2236,6 @@
PdfContext pdfContext(fPdfDoc);
- SkPdfNativeTokenizer* tokenizer = fPdfDoc->tokenizerOfPage(page, pdfContext.fTmpPageAllocator);
- if (!tokenizer) {
- // TODO(edisonn): report/warning/debug
- return false;
- }
-
pdfContext.fOriginalMatrix = SkMatrix::I();
pdfContext.fGraphicsState.fResources = fPdfDoc->pageResources(page);
@@ -2240,16 +2285,14 @@
canvas->setMatrix(pdfContext.fOriginalMatrix);
-// erase with red before?
+ doPage(&pdfContext, canvas, fPdfDoc->page(page));
+
+ // TODO(edisonn:) erase with white before draw?
// SkPaint paint;
-// paint.setColor(SK_ColorRED);
+// paint.setColor(SK_ColorWHITE);
// canvas->drawRect(rect, paint);
- PdfMainLooper looper(NULL, tokenizer, &pdfContext, canvas);
- looper.loop();
- delete tokenizer;
-
canvas->flush();
return true;
}
« no previous file with comments | « no previous file | experimental/PdfViewer/pdfparser/native/SkNativeParsedPDF.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698