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 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/mac/scoped_cftyperef.h" | 13 #include "base/mac/scoped_cftyperef.h" |
14 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
15 #include "printing/metafile.h" | 15 #include "printing/metafile.h" |
16 | 16 |
17 class FilePath; | 17 class FilePath; |
18 | 18 |
19 namespace gfx { | 19 namespace gfx { |
20 class Rect; | 20 class Rect; |
21 class Size; | 21 class Size; |
22 class Point; | 22 class Point; |
23 } | 23 } |
24 | 24 |
25 namespace printing { | 25 namespace printing { |
26 | 26 |
27 // This class creates a graphics context that renders into a PDF data stream. | 27 // This class creates a graphics context that renders into a PDF data stream. |
28 class PdfMetafileCg : public Metafile, public base::ThreadChecker { | 28 class PRINTING_EXPORT PdfMetafileCg : public Metafile { |
29 public: | 29 public: |
30 PdfMetafileCg(); | 30 PdfMetafileCg(); |
31 virtual ~PdfMetafileCg(); | 31 virtual ~PdfMetafileCg(); |
32 | 32 |
33 // Metafile methods. | 33 // Metafile methods. |
34 virtual bool Init(); | 34 virtual bool Init(); |
35 virtual bool InitFromData(const void* src_buffer, uint32 src_buffer_size); | 35 virtual bool InitFromData(const void* src_buffer, uint32 src_buffer_size); |
36 | 36 |
37 // Not implemented on mac. | 37 // Not implemented on mac. |
38 virtual SkDevice* StartPageForVectorCanvas( | 38 virtual SkDevice* StartPageForVectorCanvas( |
(...skipping 23 matching lines...) Expand all Loading... |
62 const CGRect rect, | 62 const CGRect rect, |
63 bool shrink_to_fit, | 63 bool shrink_to_fit, |
64 bool stretch_to_fit, | 64 bool stretch_to_fit, |
65 bool center_horizontally, | 65 bool center_horizontally, |
66 bool center_vertically) const; | 66 bool center_vertically) const; |
67 | 67 |
68 private: | 68 private: |
69 // Returns a CGPDFDocumentRef version of pdf_data_. | 69 // Returns a CGPDFDocumentRef version of pdf_data_. |
70 CGPDFDocumentRef GetPDFDocument() const; | 70 CGPDFDocumentRef GetPDFDocument() const; |
71 | 71 |
| 72 base::ThreadChecker thread_checker_; |
| 73 |
72 // Context for rendering to the pdf. | 74 // Context for rendering to the pdf. |
73 base::mac::ScopedCFTypeRef<CGContextRef> context_; | 75 base::mac::ScopedCFTypeRef<CGContextRef> context_; |
74 | 76 |
75 // PDF backing store. | 77 // PDF backing store. |
76 base::mac::ScopedCFTypeRef<CFMutableDataRef> pdf_data_; | 78 base::mac::ScopedCFTypeRef<CFMutableDataRef> pdf_data_; |
77 | 79 |
78 // Lazily-created CGPDFDocument representation of pdf_data_. | 80 // Lazily-created CGPDFDocument representation of pdf_data_. |
79 mutable base::mac::ScopedCFTypeRef<CGPDFDocumentRef> pdf_doc_; | 81 mutable base::mac::ScopedCFTypeRef<CGPDFDocumentRef> pdf_doc_; |
80 | 82 |
81 // Whether or not a page is currently open. | 83 // Whether or not a page is currently open. |
82 bool page_is_open_; | 84 bool page_is_open_; |
83 | 85 |
84 // Whether this instantiation of the PdfMetafileCg owns the thread_pdf_docs. | 86 // Whether this instantiation of the PdfMetafileCg owns the thread_pdf_docs. |
85 bool thread_pdf_docs_owned_; | 87 bool thread_pdf_docs_owned_; |
86 | 88 |
87 DISALLOW_COPY_AND_ASSIGN(PdfMetafileCg); | 89 DISALLOW_COPY_AND_ASSIGN(PdfMetafileCg); |
88 }; | 90 }; |
89 | 91 |
90 } // namespace printing | 92 } // namespace printing |
91 | 93 |
92 #endif // PRINTING_PDF_METAFILE_CG_MAC_H_ | 94 #endif // PRINTING_PDF_METAFILE_CG_MAC_H_ |
OLD | NEW |