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

Unified Diff: experimental/PdfViewer/inc/SkPdfTokenLooper.h

Issue 83183004: Simplify SkPdfTokenLooper behavior. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Respond to comment (FIXME) Created 7 years 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/src/SkPdfContext.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: experimental/PdfViewer/inc/SkPdfTokenLooper.h
diff --git a/experimental/PdfViewer/inc/SkPdfTokenLooper.h b/experimental/PdfViewer/inc/SkPdfTokenLooper.h
index 8deca1708eab741f1b3ea45f174bdfe188d8cb05..f3897cc78f5e59f270eba1b0ce2e66e94225d3c3 100644
--- a/experimental/PdfViewer/inc/SkPdfTokenLooper.h
+++ b/experimental/PdfViewer/inc/SkPdfTokenLooper.h
@@ -15,31 +15,54 @@
class SkCanvas;
class SkPdfContext;
+/**
+ * An object which reads tokens from a tokenizer and draws it to an SkCanvas.
+ * FIXME (scroggo): Can this be an interface? See http://goo.gl/AXQtkH
+ */
class SkPdfTokenLooper {
-protected:
- SkPdfTokenLooper* fParent;
- SkPdfNativeTokenizer* fTokenizer;
- SkPdfContext* fPdfContext;
- SkCanvas* fCanvas;
-
public:
- SkPdfTokenLooper(SkPdfTokenLooper* parent,
- SkPdfNativeTokenizer* tokenizer,
- SkPdfContext* pdfContext,
- SkCanvas* canvas)
- : fParent(parent), fTokenizer(tokenizer), fPdfContext(pdfContext), fCanvas(canvas) {}
+ /**
+ * Create a looper with no parent.
+ * @param tokenizer SkPdfNativeTokenizer for reading tokens.
+ * @param pdfContext Context for drawing state.
+ * @param canvas Target SkCanvas for drawing.
+ */
+ SkPdfTokenLooper(SkPdfNativeTokenizer* tokenizer,
+ SkPdfContext* pdfContext,
+ SkCanvas* canvas)
+ : fParent(NULL)
+ , fTokenizer(tokenizer)
+ , fPdfContext(pdfContext)
+ , fCanvas(canvas) {}
+
+ /**
+ * Create a looper as a child of parent. It will share the
+ * SkPdfContext, SkPdfTokenizer, and SkCanvas with its parent.
+ */
+ explicit SkPdfTokenLooper(SkPdfTokenLooper* parent)
+ : fParent(parent)
+ , fTokenizer(parent->fTokenizer)
+ , fPdfContext(parent->fPdfContext)
+ , fCanvas(parent->fCanvas) {}
virtual ~SkPdfTokenLooper() {}
+ /**
+ * Consume a token, and draw to fCanvas as directed.
+ */
virtual SkPdfResult consumeToken(PdfToken& token) = 0;
+
+ /**
+ * Consume all the tokens this looper can handle.
+ */
virtual void loop() = 0;
- void setUp(SkPdfTokenLooper* parent) {
- fParent = parent;
- fTokenizer = parent->fTokenizer;
- fPdfContext = parent->fPdfContext;
- fCanvas = parent->fCanvas;
- }
+protected:
+ // All are unowned pointers.
+ SkPdfTokenLooper* fParent;
+ SkPdfNativeTokenizer* fTokenizer;
+ SkPdfContext* fPdfContext;
+ SkCanvas* fCanvas;
};
#endif // SkPdfTokenLooper_DEFINED
« no previous file with comments | « no previous file | experimental/PdfViewer/src/SkPdfContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698