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 | |
21 namespace base { | 17 namespace base { |
22 class File; | 18 class File; |
23 } | 19 } |
24 | 20 |
25 namespace gfx { | 21 namespace gfx { |
26 class Rect; | 22 class Rect; |
27 class Size; | 23 class Size; |
28 } | 24 } |
29 | 25 |
30 namespace printing { | 26 namespace printing { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 // Copies the first |dst_buffer_size| bytes of the underlying data stream into | 92 // Copies the first |dst_buffer_size| bytes of the underlying data stream into |
97 // |dst_buffer|. This function should ONLY be called after Close() is invoked. | 93 // |dst_buffer|. This function should ONLY be called after Close() is invoked. |
98 // Returns true if the copy succeeds. | 94 // Returns true if the copy succeeds. |
99 virtual bool GetData(void* dst_buffer, uint32_t dst_buffer_size) const = 0; | 95 virtual bool GetData(void* dst_buffer, uint32_t dst_buffer_size) const = 0; |
100 | 96 |
101 virtual gfx::Rect GetPageBounds(unsigned int page_number) const = 0; | 97 virtual gfx::Rect GetPageBounds(unsigned int page_number) const = 0; |
102 virtual unsigned int GetPageCount() const = 0; | 98 virtual unsigned int GetPageCount() const = 0; |
103 | 99 |
104 virtual skia::NativeDrawingContext context() const = 0; | 100 virtual skia::NativeDrawingContext context() const = 0; |
105 | 101 |
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 | |
119 // MetfilePlayer | 102 // MetfilePlayer |
120 bool GetDataAsVector(std::vector<char>* buffer) const override; | 103 bool GetDataAsVector(std::vector<char>* buffer) const override; |
121 bool SaveTo(base::File* file) const override; | 104 bool SaveTo(base::File* file) const override; |
122 | 105 |
123 private: | 106 private: |
124 DISALLOW_COPY_AND_ASSIGN(Metafile); | 107 DISALLOW_COPY_AND_ASSIGN(Metafile); |
125 }; | 108 }; |
126 | 109 |
127 } // namespace printing | 110 } // namespace printing |
128 | 111 |
129 #endif // PRINTING_METAFILE_H_ | 112 #endif // PRINTING_METAFILE_H_ |
OLD | NEW |