Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1099)

Side by Side Diff: printing/pdf_metafile_cg_mac.h

Issue 2839323002: Revert of printing::Metafile: Simplify OS_MACOSX-specific code path (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « printing/metafile.h ('k') | printing/pdf_metafile_cg_mac.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include <stdint.h> 10 #include <stdint.h>
(...skipping 27 matching lines...) Expand all
38 uint32_t GetDataSize() const override; 38 uint32_t GetDataSize() const override;
39 bool GetData(void* dst_buffer, uint32_t dst_buffer_size) const override; 39 bool GetData(void* dst_buffer, uint32_t dst_buffer_size) const override;
40 40
41 gfx::Rect GetPageBounds(unsigned int page_number) const override; 41 gfx::Rect GetPageBounds(unsigned int page_number) const override;
42 unsigned int GetPageCount() const override; 42 unsigned int GetPageCount() const override;
43 43
44 // Note: The returned context *must not be retained* past Close(). If it is, 44 // Note: The returned context *must not be retained* past Close(). If it is,
45 // the data returned from GetData will not be valid PDF data. 45 // the data returned from GetData will not be valid PDF data.
46 CGContextRef context() const override; 46 CGContextRef context() const override;
47 47
48 // |shrink_to_fit| specifies whether the output should be shrunk to fit a 48 bool RenderPage(unsigned int page_number,
49 // destination page if the source PDF is bigger than the destination page in 49 skia::NativeDrawingContext context,
50 // any dimension. If this is false, parts of the source PDF page that lie 50 const CGRect rect,
51 // outside the bounds will be clipped. 51 const MacRenderPageParams& params) const override;
52 //
53 // |stretch_to_fit| specifies whether the output should be stretched to fit
54 // the destination page if the source page size is smaller in all dimensions.
55 //
56 // |center_horizontally| specifies whether the output (after any scaling is
57 // done) should be centered horizontally within the destination page.
58 //
59 // |center_vertically| specifies whether the output (after any scaling is
60 // done) should be centered vertically within the destination page.
61 // Note that all scaling preserves the original aspect ratio of the page.
62 //
63 // |autorotate| specifies whether the source PDF should be autorotated to fit
64 // on the destination page.
65 struct RenderPageParams {
66 bool shrink_to_fit = false;
67 bool stretch_to_fit = false;
68 bool center_horizontally = false;
69 bool center_vertically = false;
70 bool autorotate = false;
71 };
72 // Renders the given page from |src_buffer| into |rect| in the given context.
73 // Pages use a 1-based index. The rendering uses the arguments in
74 // |params| to determine scaling, translation, and rotation.
75 static bool RenderPage(const std::vector<char>& src_buffer,
76 unsigned int page_number,
77 CGContextRef context,
78 const CGRect rect,
79 const RenderPageParams& params);
80 52
81 private: 53 private:
82 // Returns a CGPDFDocumentRef version of |pdf_data_|. 54 // Returns a CGPDFDocumentRef version of |pdf_data_|.
83 CGPDFDocumentRef GetPDFDocument() const; 55 CGPDFDocumentRef GetPDFDocument() const;
84 56
85 // Context for rendering to the pdf. 57 // Context for rendering to the pdf.
86 base::ScopedCFTypeRef<CGContextRef> context_; 58 base::ScopedCFTypeRef<CGContextRef> context_;
87 59
88 // PDF backing store. 60 // PDF backing store.
89 base::ScopedCFTypeRef<CFMutableDataRef> pdf_data_; 61 base::ScopedCFTypeRef<CFMutableDataRef> pdf_data_;
90 62
91 // Lazily-created CGPDFDocument representation of |pdf_data_|. 63 // Lazily-created CGPDFDocument representation of |pdf_data_|.
92 mutable base::ScopedCFTypeRef<CGPDFDocumentRef> pdf_doc_; 64 mutable base::ScopedCFTypeRef<CGPDFDocumentRef> pdf_doc_;
93 65
94 // Whether or not a page is currently open. 66 // Whether or not a page is currently open.
95 bool page_is_open_; 67 bool page_is_open_;
96 68
97 DISALLOW_COPY_AND_ASSIGN(PdfMetafileCg); 69 DISALLOW_COPY_AND_ASSIGN(PdfMetafileCg);
98 }; 70 };
99 71
100 } // namespace printing 72 } // namespace printing
101 73
102 #endif // PRINTING_PDF_METAFILE_CG_MAC_H_ 74 #endif // PRINTING_PDF_METAFILE_CG_MAC_H_
OLDNEW
« no previous file with comments | « printing/metafile.h ('k') | printing/pdf_metafile_cg_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698