skia2/tools/PdfRenderer.h
edisonn@google.com d9dfa18372 Encode images with DCTDecode (JPEG) in PDFs if it makes sense. Fallback to FlateDecode (zip) if it makes sense. Otherewise include uncompressed stream.
This change will reduce the size of PDFs to 50% (in the case of the existing SKPs, we reduce the total size of PDFs from 105MB to 50MB) 
Review URL: https://codereview.appspot.com/7068055

git-svn-id: http://skia.googlecode.com/svn/trunk@8835 2bbb7eff-a529-9590-31e7-b0007b416f81
2013-04-24 13:01:01 +00:00

70 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 "SkMath.h"
#include "SkPDFDevice.h"
#include "SkPicture.h"
#include "SkTypes.h"
#include "SkTDArray.h"
#include "SkRefCnt.h"
#include "SkString.h"
class SkBitmap;
class SkCanvas;
namespace sk_tools {
class PdfRenderer : public SkRefCnt {
public:
virtual void init(SkPicture* pict);
virtual void setup() {}
virtual void render() = 0;
virtual void end();
PdfRenderer(EncodeToDCTStream encoder)
: fPicture(NULL)
, fPDFDevice(NULL)
, fEncoder(encoder)
{}
void write(SkWStream* stream) const;
protected:
SkCanvas* setupCanvas();
SkCanvas* setupCanvas(int width, int height);
SkAutoTUnref<SkCanvas> fCanvas;
SkPicture* fPicture;
SkPDFDevice* fPDFDevice;
EncodeToDCTStream fEncoder;
private:
typedef SkRefCnt INHERITED;
};
class SimplePdfRenderer : public PdfRenderer {
public:
SimplePdfRenderer(EncodeToDCTStream encoder)
: PdfRenderer(encoder) {}
virtual void render() SK_OVERRIDE;
private:
typedef PdfRenderer INHERITED;
};
}
#endif // PdfRenderer_DEFINED