blob: b44133fddee3fe0c111414074cff250df7e1ea4d [file] [log] [blame]
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001// Copyright (c) 2012 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef PRINTING_PDF_METAFILE_SKIA_H_
6#define PRINTING_PDF_METAFILE_SKIA_H_
7
8#include "base/basictypes.h"
9#include "base/logging.h"
10#include "base/memory/scoped_ptr.h"
11#include "build/build_config.h"
12#include "printing/metafile.h"
13
14#if defined(OS_WIN)
15#include <windows.h>
16#endif
17
18namespace printing {
19
20struct PdfMetafileSkiaData;
21
22// This class uses Skia graphics library to generate a PDF document.
23class PRINTING_EXPORT PdfMetafileSkia : public Metafile {
24 public:
25 PdfMetafileSkia();
26 virtual ~PdfMetafileSkia();
27
28 // Metafile methods.
29 virtual bool Init() OVERRIDE;
30 virtual bool InitFromData(const void* src_buffer,
31 uint32 src_buffer_size) OVERRIDE;
32
Torne (Richard Coles)424c4d72013-08-30 15:14:49 +010033 virtual SkBaseDevice* StartPageForVectorCanvas(
Torne (Richard Coles)58218062012-11-14 11:43:16 +000034 const gfx::Size& page_size,
35 const gfx::Rect& content_area,
36 const float& scale_factor) OVERRIDE;
37
38 virtual bool StartPage(const gfx::Size& page_size,
39 const gfx::Rect& content_area,
40 const float& scale_factor) OVERRIDE;
41 virtual bool FinishPage() OVERRIDE;
42 virtual bool FinishDocument() OVERRIDE;
43
44 virtual uint32 GetDataSize() const OVERRIDE;
45 virtual bool GetData(void* dst_buffer, uint32 dst_buffer_size) const OVERRIDE;
46
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000047 virtual bool SaveTo(const base::FilePath& file_path) const OVERRIDE;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000048
49 virtual gfx::Rect GetPageBounds(unsigned int page_number) const OVERRIDE;
50 virtual unsigned int GetPageCount() const OVERRIDE;
51
52 virtual gfx::NativeDrawingContext context() const OVERRIDE;
53
54#if defined(OS_WIN)
55 virtual bool Playback(gfx::NativeDrawingContext hdc,
56 const RECT* rect) const OVERRIDE;
57 virtual bool SafePlayback(gfx::NativeDrawingContext hdc) const OVERRIDE;
58 virtual HENHMETAFILE emf() const OVERRIDE;
59#elif defined(OS_MACOSX)
60 virtual bool RenderPage(unsigned int page_number,
61 gfx::NativeDrawingContext context,
62 const CGRect rect,
63 const MacRenderPageParams& params) const OVERRIDE;
64#endif
65
Torne (Richard Coles)3551c9c2013-08-23 16:39:15 +010066#if defined(OS_CHROMEOS) || defined(OS_ANDROID)
Torne (Richard Coles)58218062012-11-14 11:43:16 +000067 virtual bool SaveToFD(const base::FileDescriptor& fd) const OVERRIDE;
Torne (Richard Coles)3551c9c2013-08-23 16:39:15 +010068#endif // if defined(OS_CHROMEOS) || defined(OS_ANDROID)
Torne (Richard Coles)58218062012-11-14 11:43:16 +000069
70 // Return a new metafile containing just the current page in draft mode.
71 PdfMetafileSkia* GetMetafileForCurrentPage();
72
73 private:
74 scoped_ptr<PdfMetafileSkiaData> data_;
75
76 // True when finish page is outstanding for current page.
77 bool page_outstanding_;
78
79 DISALLOW_COPY_AND_ASSIGN(PdfMetafileSkia);
80};
81
82} // namespace printing
83
84#endif // PRINTING_PDF_METAFILE_SKIA_H_