blob: d2d66378b618954d9a3f174a6279cf745cfd8eb4 [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;
edisonn@google.com2a827e82012-10-10 15:20:34 +000025class SkPDFDevice;
26
27namespace sk_tools {
28
29class PdfRenderer : public SkRefCnt {
30public:
31 virtual void init(SkPicture* pict);
32 virtual void setup() {}
33 virtual void render() = 0;
34 virtual void end();
35
36 PdfRenderer()
37 : fPicture(NULL)
38 , fPDFDevice(NULL)
39 {}
40
edisonn@google.com4fa566b2013-01-11 20:30:41 +000041 void write(SkWStream* stream) const;
edisonn@google.com2a827e82012-10-10 15:20:34 +000042
43protected:
44 SkCanvas* setupCanvas();
45 SkCanvas* setupCanvas(int width, int height);
46
47 SkAutoTUnref<SkCanvas> fCanvas;
48 SkPicture* fPicture;
49 SkPDFDevice* fPDFDevice;
50
51
52private:
53 typedef SkRefCnt INHERITED;
54};
55
56class SimplePdfRenderer : public PdfRenderer {
57public:
58 virtual void render() SK_OVERRIDE;
59
60private:
61 typedef PdfRenderer INHERITED;
62};
63
64}
65
66#endif // PdfRenderer_DEFINED