blob: 0a37c6024fa1172c3cceca353576daff5c7fe066 [file] [log] [blame]
edisonn@google.com222382b2013-07-10 22:33:10 +00001/*
2 * Copyright 2013 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8
edisonn@google.com15b11182013-07-11 14:43:15 +00009#ifndef SkPdfRenderer_DEFINED
10#define SkPdfRenderer_DEFINED
edisonn@google.com222382b2013-07-10 22:33:10 +000011
edisonn@google.comaf54a512013-09-13 19:33:42 +000012// TODO(edisonn): how to remove this dependency? Should I remove the ref counting?
13#include "SkRefCnt.h"
14// TODO(edisonn): remove this dependency
15#include "SkString.h"
16
edisonn@google.com147adb12013-07-24 15:56:19 +000017class SkBitmap;
edisonn@google.com222382b2013-07-10 22:33:10 +000018class SkCanvas;
edisonn@google.com3aa35552013-08-14 18:26:20 +000019class SkPdfNativeDoc;
edisonn@google.com96ba3aa2013-07-28 20:04:35 +000020struct SkRect;
edisonn@google.com147adb12013-07-24 15:56:19 +000021class SkStream;
edisonn@google.comaf54a512013-09-13 19:33:42 +000022class SkString;
edisonn@google.com147adb12013-07-24 15:56:19 +000023
24enum SkPdfContent {
25 kNoForms_SkPdfContent,
26 kAll_SkPdfContent,
27};
edisonn@google.com222382b2013-07-10 22:33:10 +000028
29// TODO(edisonn): move in another file
30class SkPdfRenderer : public SkRefCnt {
edisonn@google.com3aa35552013-08-14 18:26:20 +000031 SkPdfNativeDoc* fPdfDoc;
edisonn@google.com222382b2013-07-10 22:33:10 +000032public:
33 SkPdfRenderer() : fPdfDoc(NULL) {}
34 virtual ~SkPdfRenderer() {unload();}
35
36 // TODO(edisonn): add options to render forms, or not
edisonn@google.com444e25a2013-07-11 15:20:50 +000037 bool renderPage(int page, SkCanvas* canvas, const SkRect& dst) const;
edisonn@google.com222382b2013-07-10 22:33:10 +000038
39 bool load(const SkString inputFileName);
edisonn@google.com147adb12013-07-24 15:56:19 +000040 bool load(SkStream* stream);
edisonn@google.com222382b2013-07-10 22:33:10 +000041 bool loaded() const {return fPdfDoc != NULL;}
42 int pages() const;
43 void unload();
44 SkRect MediaBox(int page) const;
edisonn@google.com7b328fd2013-07-11 12:53:06 +000045 size_t bytesUsed() const;
edisonn@google.com222382b2013-07-10 22:33:10 +000046};
47
48void reportPdfRenderStats();
49
edisonn@google.com147adb12013-07-24 15:56:19 +000050bool SkPDFNativeRenderToBitmap(SkStream* stream,
51 SkBitmap* output,
52 int page = 0,
53 SkPdfContent content = kAll_SkPdfContent,
54 double dpi = 72.0);
55
edisonn@google.com15b11182013-07-11 14:43:15 +000056#endif // SkPdfRenderer_DEFINED