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

Side by Side Diff: printing/metafile.h

Issue 2400873002: keep only one typedef for the native drawing context (Closed)
Patch Set: native_drawing_context.h Created 4 years, 2 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
OLDNEW
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/printing_export.h" 14 #include "printing/printing_export.h"
15 #include "ui/gfx/native_widget_types.h" 15 #include "skia/ext/native_drawing_context.h"
16 16
17 #if defined(OS_WIN) 17 #if defined(OS_WIN)
18 #include <windows.h> 18 #include <windows.h>
19 #elif defined(OS_MACOSX) 19 #elif defined(OS_MACOSX)
20 #include <ApplicationServices/ApplicationServices.h> 20 #include <ApplicationServices/ApplicationServices.h>
21 #include <CoreFoundation/CoreFoundation.h> 21 #include <CoreFoundation/CoreFoundation.h>
22 #include "base/mac/scoped_cftyperef.h" 22 #include "base/mac/scoped_cftyperef.h"
23 #endif 23 #endif
24 24
25 namespace base { 25 namespace base {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 }; 67 };
68 #endif // defined(OS_MACOSX) 68 #endif // defined(OS_MACOSX)
69 MetafilePlayer(); 69 MetafilePlayer();
70 virtual ~MetafilePlayer(); 70 virtual ~MetafilePlayer();
71 71
72 #if defined(OS_WIN) 72 #if defined(OS_WIN)
73 // The slow version of Playback(). It enumerates all the records and play them 73 // The slow version of Playback(). It enumerates all the records and play them
74 // back in the HDC. The trick is that it skip over the records known to have 74 // back in the HDC. The trick is that it skip over the records known to have
75 // issue with some printers. See Emf::Record::SafePlayback implementation for 75 // issue with some printers. See Emf::Record::SafePlayback implementation for
76 // details. 76 // details.
77 virtual bool SafePlayback(gfx::NativeDrawingContext hdc) const = 0; 77 virtual bool SafePlayback(skia::NativeDrawingContext hdc) const = 0;
78 78
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 skia::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 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. 90 // called after the metafile is closed. Returns true if writing succeeded.
91 virtual bool GetDataAsVector(std::vector<char>* buffer) const = 0; 91 virtual bool GetDataAsVector(std::vector<char>* buffer) const = 0;
92 92
93 // 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
94 // called after the metafile is closed. Returns true if writing succeeded. 94 // called after the metafile is closed. Returns true if writing succeeded.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 virtual uint32_t GetDataSize() const = 0; 137 virtual uint32_t GetDataSize() const = 0;
138 138
139 // Copies the first |dst_buffer_size| bytes of the underlying data stream into 139 // Copies the first |dst_buffer_size| bytes of the underlying data stream into
140 // |dst_buffer|. This function should ONLY be called after Close() is invoked. 140 // |dst_buffer|. This function should ONLY be called after Close() is invoked.
141 // Returns true if the copy succeeds. 141 // Returns true if the copy succeeds.
142 virtual bool GetData(void* dst_buffer, uint32_t dst_buffer_size) const = 0; 142 virtual bool GetData(void* dst_buffer, uint32_t dst_buffer_size) const = 0;
143 143
144 virtual gfx::Rect GetPageBounds(unsigned int page_number) const = 0; 144 virtual gfx::Rect GetPageBounds(unsigned int page_number) const = 0;
145 virtual unsigned int GetPageCount() const = 0; 145 virtual unsigned int GetPageCount() const = 0;
146 146
147 virtual gfx::NativeDrawingContext context() const = 0; 147 virtual skia::NativeDrawingContext context() const = 0;
148 148
149 #if defined(OS_WIN) 149 #if defined(OS_WIN)
150 // "Plays" the EMF buffer in a HDC. It is the same effect as calling the 150 // "Plays" the EMF buffer in a HDC. It is the same effect as calling the
151 // original GDI function that were called when recording the EMF. |rect| is in 151 // original GDI function that were called when recording the EMF. |rect| is in
152 // "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
153 // are used. 153 // are used.
154 // 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
155 // functions, whether used directly or indirectly through precompiled EMF 155 // functions, whether used directly or indirectly through precompiled EMF
156 // 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,
157 // it requires user intervention. 157 // it requires user intervention.
158 virtual bool Playback(gfx::NativeDrawingContext hdc, 158 virtual bool Playback(skia::NativeDrawingContext hdc,
159 const RECT* rect) const = 0; 159 const RECT* rect) const = 0;
160 #endif // OS_WIN 160 #endif // OS_WIN
161 161
162 // MetfilePlayer 162 // MetfilePlayer
163 bool GetDataAsVector(std::vector<char>* buffer) const override; 163 bool GetDataAsVector(std::vector<char>* buffer) const override;
164 bool SaveTo(base::File* file) const override; 164 bool SaveTo(base::File* file) const override;
165 165
166 private: 166 private:
167 DISALLOW_COPY_AND_ASSIGN(Metafile); 167 DISALLOW_COPY_AND_ASSIGN(Metafile);
168 }; 168 };
169 169
170 } // namespace printing 170 } // namespace printing
171 171
172 #endif // PRINTING_METAFILE_H_ 172 #endif // PRINTING_METAFILE_H_
OLDNEW
« no previous file with comments | « content/browser/compositor/software_output_device_win.cc ('k') | printing/pdf_metafile_cg_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698