OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // 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 | 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 11 matching lines...) Expand all Loading... |
22 class Rect; | 22 class Rect; |
23 class Size; | 23 class Size; |
24 } | 24 } |
25 | 25 |
26 namespace printing { | 26 namespace printing { |
27 | 27 |
28 // This class creates a graphics context that renders into a PDF data stream. | 28 // This class creates a graphics context that renders into a PDF data stream. |
29 class PRINTING_EXPORT PdfMetafileCg : public Metafile { | 29 class PRINTING_EXPORT PdfMetafileCg : public Metafile { |
30 public: | 30 public: |
31 PdfMetafileCg(); | 31 PdfMetafileCg(); |
32 virtual ~PdfMetafileCg(); | 32 ~PdfMetafileCg() override; |
33 | 33 |
34 // Metafile methods. | 34 // Metafile methods. |
35 virtual bool Init() override; | 35 bool Init() override; |
36 virtual bool InitFromData(const void* src_buffer, | 36 bool InitFromData(const void* src_buffer, uint32 src_buffer_size) override; |
37 uint32 src_buffer_size) override; | |
38 | 37 |
39 // Not implemented on mac. | 38 // Not implemented on mac. |
40 virtual SkBaseDevice* StartPageForVectorCanvas( | 39 SkBaseDevice* StartPageForVectorCanvas(const gfx::Size& page_size, |
41 const gfx::Size& page_size, const gfx::Rect& content_area, | 40 const gfx::Rect& content_area, |
42 const float& scale_factor) override; | 41 const float& scale_factor) override; |
43 virtual bool StartPage(const gfx::Size& page_size, | 42 bool StartPage(const gfx::Size& page_size, |
44 const gfx::Rect& content_area, | 43 const gfx::Rect& content_area, |
45 const float& scale_factor) override; | 44 const float& scale_factor) override; |
46 virtual bool FinishPage() override; | 45 bool FinishPage() override; |
47 virtual bool FinishDocument() override; | 46 bool FinishDocument() override; |
48 | 47 |
49 virtual uint32 GetDataSize() const override; | 48 uint32 GetDataSize() const override; |
50 virtual bool GetData(void* dst_buffer, uint32 dst_buffer_size) const override; | 49 bool GetData(void* dst_buffer, uint32 dst_buffer_size) const override; |
51 | 50 |
52 virtual gfx::Rect GetPageBounds(unsigned int page_number) const override; | 51 gfx::Rect GetPageBounds(unsigned int page_number) const override; |
53 virtual unsigned int GetPageCount() const override; | 52 unsigned int GetPageCount() const override; |
54 | 53 |
55 // Note: The returned context *must not be retained* past Close(). If it is, | 54 // 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. | 55 // the data returned from GetData will not be valid PDF data. |
57 virtual CGContextRef context() const override; | 56 CGContextRef context() const override; |
58 | 57 |
59 virtual bool RenderPage(unsigned int page_number, | 58 bool RenderPage(unsigned int page_number, |
60 gfx::NativeDrawingContext context, | 59 gfx::NativeDrawingContext context, |
61 const CGRect rect, | 60 const CGRect rect, |
62 const MacRenderPageParams& params) const override; | 61 const MacRenderPageParams& params) const override; |
63 | 62 |
64 private: | 63 private: |
65 // Returns a CGPDFDocumentRef version of pdf_data_. | 64 // Returns a CGPDFDocumentRef version of pdf_data_. |
66 CGPDFDocumentRef GetPDFDocument() const; | 65 CGPDFDocumentRef GetPDFDocument() const; |
67 | 66 |
68 base::ThreadChecker thread_checker_; | 67 base::ThreadChecker thread_checker_; |
69 | 68 |
70 // Context for rendering to the pdf. | 69 // Context for rendering to the pdf. |
71 base::ScopedCFTypeRef<CGContextRef> context_; | 70 base::ScopedCFTypeRef<CGContextRef> context_; |
72 | 71 |
73 // PDF backing store. | 72 // PDF backing store. |
74 base::ScopedCFTypeRef<CFMutableDataRef> pdf_data_; | 73 base::ScopedCFTypeRef<CFMutableDataRef> pdf_data_; |
75 | 74 |
76 // Lazily-created CGPDFDocument representation of pdf_data_. | 75 // Lazily-created CGPDFDocument representation of pdf_data_. |
77 mutable base::ScopedCFTypeRef<CGPDFDocumentRef> pdf_doc_; | 76 mutable base::ScopedCFTypeRef<CGPDFDocumentRef> pdf_doc_; |
78 | 77 |
79 // Whether or not a page is currently open. | 78 // Whether or not a page is currently open. |
80 bool page_is_open_; | 79 bool page_is_open_; |
81 | 80 |
82 // Whether this instantiation of the PdfMetafileCg owns the thread_pdf_docs. | 81 // Whether this instantiation of the PdfMetafileCg owns the thread_pdf_docs. |
83 bool thread_pdf_docs_owned_; | 82 bool thread_pdf_docs_owned_; |
84 | 83 |
85 DISALLOW_COPY_AND_ASSIGN(PdfMetafileCg); | 84 DISALLOW_COPY_AND_ASSIGN(PdfMetafileCg); |
86 }; | 85 }; |
87 | 86 |
88 } // namespace printing | 87 } // namespace printing |
89 | 88 |
90 #endif // PRINTING_PDF_METAFILE_CG_MAC_H_ | 89 #endif // PRINTING_PDF_METAFILE_CG_MAC_H_ |
OLD | NEW |