| 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_METAFILE_H_ | 5 #ifndef PRINTING_METAFILE_H_ |
| 6 #define PRINTING_METAFILE_H_ | 6 #define PRINTING_METAFILE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 #elif defined(OS_MACOSX) | 79 #elif defined(OS_MACOSX) |
| 80 // Renders the given page into |rect| in the given context. | 80 // Renders the given page into |rect| in the given context. |
| 81 // Pages use a 1-based index. The rendering uses the arguments in | 81 // Pages use a 1-based index. The rendering uses the arguments in |
| 82 // |params| to determine scaling, translation, and rotation. | 82 // |params| to determine scaling, translation, and rotation. |
| 83 virtual bool RenderPage(unsigned int page_number, | 83 virtual bool RenderPage(unsigned int page_number, |
| 84 gfx::NativeDrawingContext context, | 84 gfx::NativeDrawingContext context, |
| 85 const CGRect rect, | 85 const CGRect rect, |
| 86 const MacRenderPageParams& params) const = 0; | 86 const MacRenderPageParams& params) const = 0; |
| 87 #endif // if defined(OS_WIN) | 87 #endif // if defined(OS_WIN) |
| 88 | 88 |
| 89 // Populates the buffer with the underlying data. This function should ONLY be |
| 90 // called after the metafile is closed. Returns true if writing succeeded. |
| 91 virtual bool GetDataAsVector(std::vector<char>* buffer) const = 0; |
| 92 |
| 89 // Saves the underlying data to the given file. This function should ONLY be | 93 // Saves the underlying data to the given file. This function should ONLY be |
| 90 // called after the metafile is closed. Returns true if writing succeeded. | 94 // called after the metafile is closed. Returns true if writing succeeded. |
| 91 virtual bool SaveTo(base::File* file) const = 0; | 95 virtual bool SaveTo(base::File* file) const = 0; |
| 92 | 96 |
| 93 private: | 97 private: |
| 94 DISALLOW_COPY_AND_ASSIGN(MetafilePlayer); | 98 DISALLOW_COPY_AND_ASSIGN(MetafilePlayer); |
| 95 }; | 99 }; |
| 96 | 100 |
| 97 // This class creates a graphics context that renders into a data stream | 101 // This class creates a graphics context that renders into a data stream |
| 98 // (usually PDF or EMF). | 102 // (usually PDF or EMF). |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 // "logical units" and is optional. If |rect| is NULL, the natural EMF bounds | 152 // "logical units" and is optional. If |rect| is NULL, the natural EMF bounds |
| 149 // are used. | 153 // are used. |
| 150 // Note: Windows has been known to have stack buffer overflow in its GDI | 154 // Note: Windows has been known to have stack buffer overflow in its GDI |
| 151 // functions, whether used directly or indirectly through precompiled EMF | 155 // functions, whether used directly or indirectly through precompiled EMF |
| 152 // data. We have to accept the risk here. Since it is used only for printing, | 156 // data. We have to accept the risk here. Since it is used only for printing, |
| 153 // it requires user intervention. | 157 // it requires user intervention. |
| 154 virtual bool Playback(gfx::NativeDrawingContext hdc, | 158 virtual bool Playback(gfx::NativeDrawingContext hdc, |
| 155 const RECT* rect) const = 0; | 159 const RECT* rect) const = 0; |
| 156 #endif // OS_WIN | 160 #endif // OS_WIN |
| 157 | 161 |
| 158 bool GetDataAsVector(std::vector<char>* buffer) const; | 162 // MetfilePlayer |
| 159 | 163 bool GetDataAsVector(std::vector<char>* buffer) const override; |
| 160 bool SaveTo(base::File* file) const override; | 164 bool SaveTo(base::File* file) const override; |
| 161 | 165 |
| 162 private: | 166 private: |
| 163 DISALLOW_COPY_AND_ASSIGN(Metafile); | 167 DISALLOW_COPY_AND_ASSIGN(Metafile); |
| 164 }; | 168 }; |
| 165 | 169 |
| 166 } // namespace printing | 170 } // namespace printing |
| 167 | 171 |
| 168 #endif // PRINTING_METAFILE_H_ | 172 #endif // PRINTING_METAFILE_H_ |
| OLD | NEW |