blob: 3524a9d8f94236f63b7e1fd836920851537b4e29 [file] [log] [blame]
edisonn@google.com2a827e82012-10-10 15:20:34 +00001/*
2 * Copyright 2012 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#ifndef PdfRenderer_DEFINED
9#define PdfRenderer_DEFINED
10
11//
12// PdfRender takes a SkPicture and writes it to a PDF file.
13// An SkPicture can be built manually, or read from an SKP file.
14//
15
16#include "SkMath.h"
17#include "SkPicture.h"
18#include "SkTypes.h"
19#include "SkTDArray.h"
20#include "SkRefCnt.h"
21#include "SkString.h"
22
23class SkBitmap;
24class SkCanvas;
25class SkGLContext;
26class SkPDFDevice;
27
28namespace sk_tools {
29
30class PdfRenderer : public SkRefCnt {
31public:
32 virtual void init(SkPicture* pict);
33 virtual void setup() {}
34 virtual void render() = 0;
35 virtual void end();
36
37 PdfRenderer()
38 : fPicture(NULL)
39 , fPDFDevice(NULL)
40 {}
41
edisonn@google.com4fa566b2013-01-11 20:30:41 +000042 void write(SkWStream* stream) const;
edisonn@google.com2a827e82012-10-10 15:20:34 +000043
44protected:
45 SkCanvas* setupCanvas();
46 SkCanvas* setupCanvas(int width, int height);
47
48 SkAutoTUnref<SkCanvas> fCanvas;
49 SkPicture* fPicture;
50 SkPDFDevice* fPDFDevice;
51
52
53private:
54 typedef SkRefCnt INHERITED;
55};
56
57class SimplePdfRenderer : public PdfRenderer {
58public:
59 virtual void render() SK_OVERRIDE;
60
61private:
62 typedef PdfRenderer INHERITED;
63};
64
65}
66
67#endif // PdfRenderer_DEFINED