Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 bool shrink_to_fit; | |
|
kmadhusu
2012/06/17 20:18:28
Can you write a default constructor which initiali
Lei Zhang
2012/06/18 20:58:25
Done.
| |
| 58 bool stretch_to_fit; | |
| 59 bool center_horizontally; | |
| 60 bool center_vertically; | |
| 61 bool autorotate; | |
| 62 }; | |
| 63 #endif // defined(OS_MACOSX) | |
| 64 | |
| 42 virtual ~Metafile() {} | 65 virtual ~Metafile() {} |
| 43 | 66 |
| 44 // Initializes a fresh new metafile for rendering. Returns false on failure. | 67 // 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 | 68 // Note: It should only be called from within the renderer process to allocate |
| 46 // rendering resources. | 69 // rendering resources. |
| 47 virtual bool Init() = 0; | 70 virtual bool Init() = 0; |
| 48 | 71 |
| 49 // Initializes the metafile with the data in |src_buffer|. Returns true | 72 // Initializes the metafile with the data in |src_buffer|. Returns true |
| 50 // on success. | 73 // on success. |
| 51 // Note: It should only be called from within the browser process. | 74 // Note: It should only be called from within the browser process. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 | 132 |
| 110 // The slow version of Playback(). It enumerates all the records and play them | 133 // 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 | 134 // 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 | 135 // issue with some printers. See Emf::Record::SafePlayback implementation for |
| 113 // details. | 136 // details. |
| 114 virtual bool SafePlayback(gfx::NativeDrawingContext hdc) const = 0; | 137 virtual bool SafePlayback(gfx::NativeDrawingContext hdc) const = 0; |
| 115 | 138 |
| 116 virtual HENHMETAFILE emf() const = 0; | 139 virtual HENHMETAFILE emf() const = 0; |
| 117 #elif defined(OS_MACOSX) | 140 #elif defined(OS_MACOSX) |
| 118 // Renders the given page into |rect| in the given context. | 141 // Renders the given page into |rect| in the given context. |
| 119 // Pages use a 1-based index. The rendering uses the following arguments | 142 // Pages use a 1-based index. The rendering uses the arguments in |
| 120 // to determine scaling and translation factors. | 143 // |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, | 144 virtual bool RenderPage(unsigned int page_number, |
| 134 gfx::NativeDrawingContext context, | 145 gfx::NativeDrawingContext context, |
| 135 const CGRect rect, | 146 const CGRect rect, |
| 136 bool shrink_to_fit, | 147 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) | 148 #elif defined(OS_CHROMEOS) |
| 141 // Saves the underlying data to the file associated with fd. This function | 149 // Saves the underlying data to the file associated with fd. This function |
| 142 // should ONLY be called after the metafile is closed. | 150 // should ONLY be called after the metafile is closed. |
| 143 // Returns true if writing succeeded. | 151 // Returns true if writing succeeded. |
| 144 virtual bool SaveToFD(const base::FileDescriptor& fd) const = 0; | 152 virtual bool SaveToFD(const base::FileDescriptor& fd) const = 0; |
| 145 #endif // if defined(OS_CHROMEOS) | 153 #endif // if defined(OS_CHROMEOS) |
| 146 }; | 154 }; |
| 147 | 155 |
| 148 } // namespace printing | 156 } // namespace printing |
| 149 | 157 |
| 150 #endif // PRINTING_METAFILE_H_ | 158 #endif // PRINTING_METAFILE_H_ |
| OLD | NEW |