2013-07-10 22:33:10 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2013 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2013-07-11 14:43:15 +00:00
|
|
|
#ifndef SkPdfRenderer_DEFINED
|
|
|
|
#define SkPdfRenderer_DEFINED
|
2013-07-10 22:33:10 +00:00
|
|
|
|
2013-07-24 15:56:19 +00:00
|
|
|
class SkBitmap;
|
2013-07-10 22:33:10 +00:00
|
|
|
class SkCanvas;
|
2013-08-14 18:26:20 +00:00
|
|
|
class SkPdfNativeDoc;
|
2013-07-28 20:04:35 +00:00
|
|
|
struct SkRect;
|
2013-07-24 15:56:19 +00:00
|
|
|
class SkStream;
|
|
|
|
|
|
|
|
enum SkPdfContent {
|
|
|
|
kNoForms_SkPdfContent,
|
|
|
|
kAll_SkPdfContent,
|
|
|
|
};
|
2013-07-10 22:33:10 +00:00
|
|
|
|
|
|
|
// TODO(edisonn): move in another file
|
|
|
|
class SkPdfRenderer : public SkRefCnt {
|
2013-08-14 18:26:20 +00:00
|
|
|
SkPdfNativeDoc* fPdfDoc;
|
2013-07-10 22:33:10 +00:00
|
|
|
public:
|
|
|
|
SkPdfRenderer() : fPdfDoc(NULL) {}
|
|
|
|
virtual ~SkPdfRenderer() {unload();}
|
|
|
|
|
|
|
|
// TODO(edisonn): add options to render forms, or not
|
2013-07-11 15:20:50 +00:00
|
|
|
bool renderPage(int page, SkCanvas* canvas, const SkRect& dst) const;
|
2013-07-10 22:33:10 +00:00
|
|
|
|
|
|
|
bool load(const SkString inputFileName);
|
2013-07-24 15:56:19 +00:00
|
|
|
bool load(SkStream* stream);
|
2013-07-10 22:33:10 +00:00
|
|
|
bool loaded() const {return fPdfDoc != NULL;}
|
|
|
|
int pages() const;
|
|
|
|
void unload();
|
|
|
|
SkRect MediaBox(int page) const;
|
2013-07-11 12:53:06 +00:00
|
|
|
size_t bytesUsed() const;
|
2013-07-10 22:33:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void reportPdfRenderStats();
|
|
|
|
|
2013-07-24 15:56:19 +00:00
|
|
|
bool SkPDFNativeRenderToBitmap(SkStream* stream,
|
|
|
|
SkBitmap* output,
|
|
|
|
int page = 0,
|
|
|
|
SkPdfContent content = kAll_SkPdfContent,
|
|
|
|
double dpi = 72.0);
|
|
|
|
|
2013-07-11 14:43:15 +00:00
|
|
|
#endif // SkPdfRenderer_DEFINED
|