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

Side by Side Diff: printing/metafile.h

Issue 10560021: Mac printing: Autorotate printed pages so their orientation is the same as the destination page. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « printing/image_mac.cc ('k') | printing/pdf_metafile_cg_mac.h » ('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) 2011 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_METAFILE_H_ 5 #ifndef PRINTING_METAFILE_H_
6 #define PRINTING_METAFILE_H_ 6 #define PRINTING_METAFILE_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "printing/printing_export.h" 10 #include "printing/printing_export.h"
11 #include "ui/gfx/native_widget_types.h" 11 #include "ui/gfx/native_widget_types.h"
(...skipping 20 matching lines...) Expand all
32 struct FileDescriptor; 32 struct FileDescriptor;
33 } 33 }
34 #endif 34 #endif
35 35
36 namespace printing { 36 namespace printing {
37 37
38 // This class creates a graphics context that renders into a data stream 38 // This class creates a graphics context that renders into a data stream
39 // (usually PDF or EMF). 39 // (usually PDF or EMF).
40 class PRINTING_EXPORT Metafile { 40 class PRINTING_EXPORT Metafile {
41 public: 41 public:
42 #if defined(OS_MACOSX)
43 // |shrink_to_fit| specifies whether the output should be shrunk to fit a
44 // destination page if the source PDF is bigger than the destination page in
45 // any dimension. If this is false, parts of the source PDF page that lie
46 // outside the bounds will be clipped.
47 // |stretch_to_fit| specifies whether the output should be stretched to fit
48 // the destination page if the source page size is smaller in all dimensions.
49 // |center_horizontally| specifies whether the output (after any scaling is
50 // done) should be centered horizontally within the destination page.
51 // |center_vertically| specifies whether the output (after any scaling is
52 // done) should be centered vertically within the destination page.
53 // Note that all scaling preserves the original aspect ratio of the page.
54 // |autorotate| specifies whether the source PDF should be autorotated to fit
55 // on the destination page.
56 struct MacRenderPageParams {
57 MacRenderPageParams()
58 : shrink_to_fit(false),
59 stretch_to_fit(false),
60 center_horizontally(false),
61 center_vertically(false),
62 autorotate(false) {
63 }
64
65 bool shrink_to_fit;
66 bool stretch_to_fit;
67 bool center_horizontally;
68 bool center_vertically;
69 bool autorotate;
70 };
71 #endif // defined(OS_MACOSX)
72
42 virtual ~Metafile() {} 73 virtual ~Metafile() {}
43 74
44 // Initializes a fresh new metafile for rendering. Returns false on failure. 75 // Initializes a fresh new metafile for rendering. Returns false on failure.
45 // Note: It should only be called from within the renderer process to allocate 76 // Note: It should only be called from within the renderer process to allocate
46 // rendering resources. 77 // rendering resources.
47 virtual bool Init() = 0; 78 virtual bool Init() = 0;
48 79
49 // Initializes the metafile with the data in |src_buffer|. Returns true 80 // Initializes the metafile with the data in |src_buffer|. Returns true
50 // on success. 81 // on success.
51 // Note: It should only be called from within the browser process. 82 // Note: It should only be called from within the browser process.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 140
110 // The slow version of Playback(). It enumerates all the records and play them 141 // The slow version of Playback(). It enumerates all the records and play them
111 // back in the HDC. The trick is that it skip over the records known to have 142 // back in the HDC. The trick is that it skip over the records known to have
112 // issue with some printers. See Emf::Record::SafePlayback implementation for 143 // issue with some printers. See Emf::Record::SafePlayback implementation for
113 // details. 144 // details.
114 virtual bool SafePlayback(gfx::NativeDrawingContext hdc) const = 0; 145 virtual bool SafePlayback(gfx::NativeDrawingContext hdc) const = 0;
115 146
116 virtual HENHMETAFILE emf() const = 0; 147 virtual HENHMETAFILE emf() const = 0;
117 #elif defined(OS_MACOSX) 148 #elif defined(OS_MACOSX)
118 // Renders the given page into |rect| in the given context. 149 // Renders the given page into |rect| in the given context.
119 // Pages use a 1-based index. The rendering uses the following arguments 150 // Pages use a 1-based index. The rendering uses the arguments in
120 // to determine scaling and translation factors. 151 // |params| to determine scaling, translation, and rotation.
121 // |shrink_to_fit| specifies whether the output should be shrunk to fit the
122 // supplied |rect| if the page size is larger than |rect| in any dimension.
123 // If this is false, parts of the PDF page that lie outside the bounds will be
124 // clipped.
125 // |stretch_to_fit| specifies whether the output should be stretched to fit
126 // the supplied bounds if the page size is smaller than |rect| in all
127 // dimensions.
128 // |center_horizontally| specifies whether the final image (after any scaling
129 // is done) should be centered horizontally within the given |rect|.
130 // |center_vertically| specifies whether the final image (after any scaling
131 // is done) should be centered vertically within the given |rect|.
132 // Note that all scaling preserves the original aspect ratio of the page.
133 virtual bool RenderPage(unsigned int page_number, 152 virtual bool RenderPage(unsigned int page_number,
134 gfx::NativeDrawingContext context, 153 gfx::NativeDrawingContext context,
135 const CGRect rect, 154 const CGRect rect,
136 bool shrink_to_fit, 155 const MacRenderPageParams& params) const = 0;
137 bool stretch_to_fit,
138 bool center_horizontally,
139 bool center_vertically) const = 0;
140 #elif defined(OS_CHROMEOS) 156 #elif defined(OS_CHROMEOS)
141 // Saves the underlying data to the file associated with fd. This function 157 // Saves the underlying data to the file associated with fd. This function
142 // should ONLY be called after the metafile is closed. 158 // should ONLY be called after the metafile is closed.
143 // Returns true if writing succeeded. 159 // Returns true if writing succeeded.
144 virtual bool SaveToFD(const base::FileDescriptor& fd) const = 0; 160 virtual bool SaveToFD(const base::FileDescriptor& fd) const = 0;
145 #endif // if defined(OS_CHROMEOS) 161 #endif // if defined(OS_CHROMEOS)
146 }; 162 };
147 163
148 } // namespace printing 164 } // namespace printing
149 165
150 #endif // PRINTING_METAFILE_H_ 166 #endif // PRINTING_METAFILE_H_
OLDNEW
« no previous file with comments | « printing/image_mac.cc ('k') | printing/pdf_metafile_cg_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698