[email protected] | 8f87929 | 2011-04-08 00:21:20 | [diff] [blame] | 1 | // Copyright (c) 2011 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/scoped_ptr.h" | ||||
11 | #include "build/build_config.h" | ||||
[email protected] | 7d748990 | 2011-04-11 21:54:06 | [diff] [blame] | 12 | #include "printing/metafile.h" |
[email protected] | 8f87929 | 2011-04-08 00:21:20 | [diff] [blame] | 13 | |
14 | #if defined(OS_WIN) | ||||
15 | #include <windows.h> | ||||
16 | #endif | ||||
17 | |||||
18 | namespace printing { | ||||
19 | |||||
20 | struct PdfMetafileSkiaData; | ||||
21 | |||||
22 | // This class uses Skia graphics library to generate a PDF document. | ||||
[email protected] | 7d748990 | 2011-04-11 21:54:06 | [diff] [blame] | 23 | class PdfMetafileSkia : public Metafile { |
[email protected] | 8f87929 | 2011-04-08 00:21:20 | [diff] [blame] | 24 | public: |
[email protected] | 7d748990 | 2011-04-11 21:54:06 | [diff] [blame] | 25 | PdfMetafileSkia(); |
[email protected] | 8f87929 | 2011-04-08 00:21:20 | [diff] [blame] | 26 | virtual ~PdfMetafileSkia(); |
27 | |||||
[email protected] | 7d748990 | 2011-04-11 21:54:06 | [diff] [blame] | 28 | // Metafile methods. |
[email protected] | 8f87929 | 2011-04-08 00:21:20 | [diff] [blame] | 29 | virtual bool Init(); |
30 | virtual bool InitFromData(const void* src_buffer, uint32 src_buffer_size); | ||||
31 | |||||
[email protected] | 62f2e80 | 2011-05-26 14:28:35 | [diff] [blame] | 32 | virtual SkDevice* StartPageForVectorCanvas( |
[email protected] | 8f87929 | 2011-04-08 00:21:20 | [diff] [blame] | 33 | const gfx::Size& page_size, |
[email protected] | 39892b9 | 2011-04-30 02:24:44 | [diff] [blame] | 34 | const gfx::Rect& content_area, |
[email protected] | 8f87929 | 2011-04-08 00:21:20 | [diff] [blame] | 35 | const float& scale_factor); |
[email protected] | 62f2e80 | 2011-05-26 14:28:35 | [diff] [blame] | 36 | |
[email protected] | 8f87929 | 2011-04-08 00:21:20 | [diff] [blame] | 37 | virtual bool StartPage(const gfx::Size& page_size, |
[email protected] | 39892b9 | 2011-04-30 02:24:44 | [diff] [blame] | 38 | const gfx::Rect& content_area, |
[email protected] | 8f87929 | 2011-04-08 00:21:20 | [diff] [blame] | 39 | const float& scale_factor); |
40 | virtual bool FinishPage(); | ||||
41 | virtual bool FinishDocument(); | ||||
42 | |||||
43 | virtual uint32 GetDataSize() const; | ||||
44 | virtual bool GetData(void* dst_buffer, uint32 dst_buffer_size) const; | ||||
45 | |||||
46 | virtual bool SaveTo(const FilePath& file_path) const; | ||||
47 | |||||
48 | virtual gfx::Rect GetPageBounds(unsigned int page_number) const; | ||||
49 | virtual unsigned int GetPageCount() const; | ||||
50 | |||||
51 | virtual gfx::NativeDrawingContext context() const; | ||||
52 | |||||
53 | #if defined(OS_WIN) | ||||
54 | virtual bool Playback(gfx::NativeDrawingContext hdc, const RECT* rect) const; | ||||
55 | virtual bool SafePlayback(gfx::NativeDrawingContext hdc) const; | ||||
56 | virtual HENHMETAFILE emf() const; | ||||
57 | #endif // if defined(OS_WIN) | ||||
58 | |||||
59 | #if defined(OS_CHROMEOS) | ||||
[email protected] | 7d748990 | 2011-04-11 21:54:06 | [diff] [blame] | 60 | virtual bool SaveToFD(const base::FileDescriptor& fd) const; |
[email protected] | 8f87929 | 2011-04-08 00:21:20 | [diff] [blame] | 61 | #endif // if defined(OS_CHROMEOS) |
[email protected] | c797a19 | 2011-06-15 16:25:09 | [diff] [blame] | 62 | |
63 | virtual void set_draft(bool draft) const; | ||||
64 | |||||
[email protected] | 8f87929 | 2011-04-08 00:21:20 | [diff] [blame] | 65 | private: |
[email protected] | 8f87929 | 2011-04-08 00:21:20 | [diff] [blame] | 66 | scoped_ptr<PdfMetafileSkiaData> data_; |
67 | |||||
[email protected] | c797a19 | 2011-06-15 16:25:09 | [diff] [blame] | 68 | // True when a draft version of metafile is requested. |
69 | mutable bool draft_; | ||||
70 | |||||
[email protected] | 8f87929 | 2011-04-08 00:21:20 | [diff] [blame] | 71 | DISALLOW_COPY_AND_ASSIGN(PdfMetafileSkia); |
72 | }; | ||||
73 | |||||
74 | } // namespace printing | ||||
75 | |||||
[email protected] | 39892b9 | 2011-04-30 02:24:44 | [diff] [blame] | 76 | #endif // PRINTING_PDF_METAFILE_SKIA_H_ |