5e00989a28
prepare to deprecate SkPDFDevice constructor, and route gm and render_pdfs to use SkDocument::Create pdf interface instead. - controlled by a flag add comments where we are supposed to flatten other features (paint, shaders, ... ) R=reed@google.com, bungeman@google.com, scroggo@google.com, vandebo@chromium.org, bsalomon@google.com Author: edisonn@google.com Review URL: https://codereview.chromium.org/24811002 git-svn-id: http://skia.googlecode.com/svn/trunk@11751 2bbb7eff-a529-9590-31e7-b0007b416f81
68 lines
1.4 KiB
C++
68 lines
1.4 KiB
C++
/*
|
|
* Copyright 2012 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#ifndef PdfRenderer_DEFINED
|
|
#define PdfRenderer_DEFINED
|
|
|
|
//
|
|
// PdfRender takes a SkPicture and writes it to a PDF file.
|
|
// An SkPicture can be built manually, or read from an SKP file.
|
|
//
|
|
|
|
#include "SkDocument.h"
|
|
#include "SkMath.h"
|
|
#include "SkPicture.h"
|
|
#include "SkTypes.h"
|
|
#include "SkTDArray.h"
|
|
#include "SkRefCnt.h"
|
|
#include "SkString.h"
|
|
|
|
class SkBitmap;
|
|
class SkCanvas;
|
|
class SkWStream;
|
|
|
|
namespace sk_tools {
|
|
|
|
class PdfRenderer : public SkRefCnt {
|
|
public:
|
|
virtual void init(SkPicture* pict, SkWStream* stream);
|
|
virtual void setup() {}
|
|
virtual bool render() = 0;
|
|
virtual void end();
|
|
|
|
PdfRenderer(SkPicture::EncodeBitmap encoder)
|
|
: fPicture(NULL)
|
|
, fEncoder(encoder)
|
|
, fPdfDoc(NULL)
|
|
{}
|
|
|
|
protected:
|
|
SkCanvas* setupCanvas(SkWStream* stream, int width, int height);
|
|
|
|
SkAutoTUnref<SkCanvas> fCanvas;
|
|
SkPicture* fPicture;
|
|
SkPicture::EncodeBitmap fEncoder;
|
|
SkAutoTUnref<SkDocument> fPdfDoc;
|
|
|
|
private:
|
|
typedef SkRefCnt INHERITED;
|
|
};
|
|
|
|
class SimplePdfRenderer : public PdfRenderer {
|
|
public:
|
|
SimplePdfRenderer(SkPicture::EncodeBitmap encoder)
|
|
: PdfRenderer(encoder) {}
|
|
virtual bool render() SK_OVERRIDE;
|
|
|
|
private:
|
|
typedef PdfRenderer INHERITED;
|
|
};
|
|
|
|
}
|
|
|
|
#endif // PdfRenderer_DEFINED
|