OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef PRINTING_PDF_METAFILE_CG_MAC_H_ | 5 #ifndef PRINTING_PDF_METAFILE_CG_MAC_H_ |
6 #define PRINTING_PDF_METAFILE_CG_MAC_H_ | 6 #define PRINTING_PDF_METAFILE_CG_MAC_H_ |
7 | 7 |
8 #include <ApplicationServices/ApplicationServices.h> | 8 #include <ApplicationServices/ApplicationServices.h> |
9 #include <CoreFoundation/CoreFoundation.h> | 9 #include <CoreFoundation/CoreFoundation.h> |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 namespace printing { | 24 namespace printing { |
25 | 25 |
26 // This class creates a graphics context that renders into a PDF data stream. | 26 // This class creates a graphics context that renders into a PDF data stream. |
27 class PRINTING_EXPORT PdfMetafileCg : public Metafile { | 27 class PRINTING_EXPORT PdfMetafileCg : public Metafile { |
28 public: | 28 public: |
29 PdfMetafileCg(); | 29 PdfMetafileCg(); |
30 virtual ~PdfMetafileCg(); | 30 virtual ~PdfMetafileCg(); |
31 | 31 |
32 // Metafile methods. | 32 // Metafile methods. |
33 virtual bool Init(); | 33 virtual bool Init() OVERRIDE; |
34 virtual bool InitFromData(const void* src_buffer, uint32 src_buffer_size); | 34 virtual bool InitFromData(const void* src_buffer, |
| 35 uint32 src_buffer_size) OVERRIDE; |
35 | 36 |
36 // Not implemented on mac. | 37 // Not implemented on mac. |
37 virtual SkDevice* StartPageForVectorCanvas( | 38 virtual SkDevice* StartPageForVectorCanvas( |
38 const gfx::Size& page_size, const gfx::Rect& content_area, | 39 const gfx::Size& page_size, const gfx::Rect& content_area, |
39 const float& scale_factor); | 40 const float& scale_factor) OVERRIDE; |
40 virtual bool StartPage(const gfx::Size& page_size, | 41 virtual bool StartPage(const gfx::Size& page_size, |
41 const gfx::Rect& content_area, | 42 const gfx::Rect& content_area, |
42 const float& scale_factor); | 43 const float& scale_factor) OVERRIDE; |
43 virtual bool FinishPage(); | 44 virtual bool FinishPage() OVERRIDE; |
44 virtual bool FinishDocument(); | 45 virtual bool FinishDocument() OVERRIDE; |
45 | 46 |
46 virtual uint32 GetDataSize() const; | 47 virtual uint32 GetDataSize() const OVERRIDE; |
47 virtual bool GetData(void* dst_buffer, uint32 dst_buffer_size) const; | 48 virtual bool GetData(void* dst_buffer, uint32 dst_buffer_size) const OVERRIDE; |
48 | 49 |
49 // For testing purposes only. | 50 // For testing purposes only. |
50 virtual bool SaveTo(const FilePath& file_path) const; | 51 virtual bool SaveTo(const FilePath& file_path) const OVERRIDE; |
51 | 52 |
52 virtual gfx::Rect GetPageBounds(unsigned int page_number) const; | 53 virtual gfx::Rect GetPageBounds(unsigned int page_number) const OVERRIDE; |
53 virtual unsigned int GetPageCount() const; | 54 virtual unsigned int GetPageCount() const OVERRIDE; |
54 | 55 |
55 // Note: The returned context *must not be retained* past Close(). If it is, | 56 // Note: The returned context *must not be retained* past Close(). If it is, |
56 // the data returned from GetData will not be valid PDF data. | 57 // the data returned from GetData will not be valid PDF data. |
57 virtual CGContextRef context() const; | 58 virtual CGContextRef context() const OVERRIDE; |
58 | 59 |
59 virtual bool RenderPage(unsigned int page_number, | 60 virtual bool RenderPage(unsigned int page_number, |
60 CGContextRef context, | 61 CGContextRef context, |
61 const CGRect rect, | 62 const CGRect rect, |
62 bool shrink_to_fit, | 63 bool shrink_to_fit, |
63 bool stretch_to_fit, | 64 bool stretch_to_fit, |
64 bool center_horizontally, | 65 bool center_horizontally, |
65 bool center_vertically) const; | 66 bool center_vertically) const OVERRIDE; |
66 | 67 |
67 private: | 68 private: |
68 // Returns a CGPDFDocumentRef version of pdf_data_. | 69 // Returns a CGPDFDocumentRef version of pdf_data_. |
69 CGPDFDocumentRef GetPDFDocument() const; | 70 CGPDFDocumentRef GetPDFDocument() const; |
70 | 71 |
71 base::ThreadChecker thread_checker_; | 72 base::ThreadChecker thread_checker_; |
72 | 73 |
73 // Context for rendering to the pdf. | 74 // Context for rendering to the pdf. |
74 base::mac::ScopedCFTypeRef<CGContextRef> context_; | 75 base::mac::ScopedCFTypeRef<CGContextRef> context_; |
75 | 76 |
76 // PDF backing store. | 77 // PDF backing store. |
77 base::mac::ScopedCFTypeRef<CFMutableDataRef> pdf_data_; | 78 base::mac::ScopedCFTypeRef<CFMutableDataRef> pdf_data_; |
78 | 79 |
79 // Lazily-created CGPDFDocument representation of pdf_data_. | 80 // Lazily-created CGPDFDocument representation of pdf_data_. |
80 mutable base::mac::ScopedCFTypeRef<CGPDFDocumentRef> pdf_doc_; | 81 mutable base::mac::ScopedCFTypeRef<CGPDFDocumentRef> pdf_doc_; |
81 | 82 |
82 // Whether or not a page is currently open. | 83 // Whether or not a page is currently open. |
83 bool page_is_open_; | 84 bool page_is_open_; |
84 | 85 |
85 // Whether this instantiation of the PdfMetafileCg owns the thread_pdf_docs. | 86 // Whether this instantiation of the PdfMetafileCg owns the thread_pdf_docs. |
86 bool thread_pdf_docs_owned_; | 87 bool thread_pdf_docs_owned_; |
87 | 88 |
88 DISALLOW_COPY_AND_ASSIGN(PdfMetafileCg); | 89 DISALLOW_COPY_AND_ASSIGN(PdfMetafileCg); |
89 }; | 90 }; |
90 | 91 |
91 } // namespace printing | 92 } // namespace printing |
92 | 93 |
93 #endif // PRINTING_PDF_METAFILE_CG_MAC_H_ | 94 #endif // PRINTING_PDF_METAFILE_CG_MAC_H_ |
OLD | NEW |