[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; |
[email protected] | b8d85bc | 2011-06-22 13:34:57 | [diff] [blame^] | 57 | #elif defined(OS_MACOSX) |
| 58 | virtual bool RenderPage(unsigned int page_number, |
| 59 | CGContextRef context, |
| 60 | const CGRect rect, |
| 61 | bool shrink_to_fit, |
| 62 | bool stretch_to_fit, |
| 63 | bool center_horizontally, |
| 64 | bool center_vertically) const; |
| 65 | #endif |
[email protected] | 8f87929 | 2011-04-08 00:21:20 | [diff] [blame] | 66 | |
| 67 | #if defined(OS_CHROMEOS) |
[email protected] | 7d748990 | 2011-04-11 21:54:06 | [diff] [blame] | 68 | virtual bool SaveToFD(const base::FileDescriptor& fd) const; |
[email protected] | 8f87929 | 2011-04-08 00:21:20 | [diff] [blame] | 69 | #endif // if defined(OS_CHROMEOS) |
[email protected] | c797a19 | 2011-06-15 16:25:09 | [diff] [blame] | 70 | |
| 71 | virtual void set_draft(bool draft) const; |
| 72 | |
[email protected] | 8f87929 | 2011-04-08 00:21:20 | [diff] [blame] | 73 | private: |
[email protected] | 8f87929 | 2011-04-08 00:21:20 | [diff] [blame] | 74 | scoped_ptr<PdfMetafileSkiaData> data_; |
| 75 | |
[email protected] | c797a19 | 2011-06-15 16:25:09 | [diff] [blame] | 76 | // True when a draft version of metafile is requested. |
| 77 | mutable bool draft_; |
| 78 | |
[email protected] | 8f87929 | 2011-04-08 00:21:20 | [diff] [blame] | 79 | DISALLOW_COPY_AND_ASSIGN(PdfMetafileSkia); |
| 80 | }; |
| 81 | |
| 82 | } // namespace printing |
| 83 | |
[email protected] | 39892b9 | 2011-04-30 02:24:44 | [diff] [blame] | 84 | #endif // PRINTING_PDF_METAFILE_SKIA_H_ |