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> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
14 #include "printing/native_drawing_context.h" | 14 #include "printing/native_drawing_context.h" |
15 #include "printing/printing_export.h" | 15 #include "printing/printing_export.h" |
16 | 16 |
| 17 #if defined(OS_WIN) |
| 18 #include <windows.h> |
| 19 #endif |
| 20 |
17 namespace base { | 21 namespace base { |
18 class File; | 22 class File; |
19 } | 23 } |
20 | 24 |
21 namespace gfx { | 25 namespace gfx { |
22 class Rect; | 26 class Rect; |
23 class Size; | 27 class Size; |
24 } | 28 } |
25 | 29 |
26 namespace printing { | 30 namespace printing { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 // Copies the first |dst_buffer_size| bytes of the underlying data stream into | 96 // Copies the first |dst_buffer_size| bytes of the underlying data stream into |
93 // |dst_buffer|. This function should ONLY be called after Close() is invoked. | 97 // |dst_buffer|. This function should ONLY be called after Close() is invoked. |
94 // Returns true if the copy succeeds. | 98 // Returns true if the copy succeeds. |
95 virtual bool GetData(void* dst_buffer, uint32_t dst_buffer_size) const = 0; | 99 virtual bool GetData(void* dst_buffer, uint32_t dst_buffer_size) const = 0; |
96 | 100 |
97 virtual gfx::Rect GetPageBounds(unsigned int page_number) const = 0; | 101 virtual gfx::Rect GetPageBounds(unsigned int page_number) const = 0; |
98 virtual unsigned int GetPageCount() const = 0; | 102 virtual unsigned int GetPageCount() const = 0; |
99 | 103 |
100 virtual skia::NativeDrawingContext context() const = 0; | 104 virtual skia::NativeDrawingContext context() const = 0; |
101 | 105 |
| 106 #if defined(OS_WIN) |
| 107 // "Plays" the EMF buffer in a HDC. It is the same effect as calling the |
| 108 // original GDI function that were called when recording the EMF. |rect| is in |
| 109 // "logical units" and is optional. If |rect| is NULL, the natural EMF bounds |
| 110 // are used. |
| 111 // Note: Windows has been known to have stack buffer overflow in its GDI |
| 112 // functions, whether used directly or indirectly through precompiled EMF |
| 113 // data. We have to accept the risk here. Since it is used only for printing, |
| 114 // it requires user intervention. |
| 115 virtual bool Playback(skia::NativeDrawingContext hdc, |
| 116 const RECT* rect) const = 0; |
| 117 #endif // OS_WIN |
| 118 |
102 // MetfilePlayer | 119 // MetfilePlayer |
103 bool GetDataAsVector(std::vector<char>* buffer) const override; | 120 bool GetDataAsVector(std::vector<char>* buffer) const override; |
104 bool SaveTo(base::File* file) const override; | 121 bool SaveTo(base::File* file) const override; |
105 | 122 |
106 private: | 123 private: |
107 DISALLOW_COPY_AND_ASSIGN(Metafile); | 124 DISALLOW_COPY_AND_ASSIGN(Metafile); |
108 }; | 125 }; |
109 | 126 |
110 } // namespace printing | 127 } // namespace printing |
111 | 128 |
112 #endif // PRINTING_METAFILE_H_ | 129 #endif // PRINTING_METAFILE_H_ |
OLD | NEW |