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

Side by Side Diff: printing/emf_win.h

Issue 10836330: Rasterize page before printing. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 4 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
« no previous file with comments | « chrome/renderer/print_web_view_helper_win.cc ('k') | printing/emf_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_EMF_WIN_H_ 5 #ifndef PRINTING_EMF_WIN_H_
6 #define PRINTING_EMF_WIN_H_ 6 #define PRINTING_EMF_WIN_H_
7 7
8 #include <windows.h> 8 #include <windows.h>
9 9
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/gtest_prod_util.h" 14 #include "base/gtest_prod_util.h"
15 #include "printing/metafile.h" 15 #include "printing/metafile.h"
16 16
17 class FilePath; 17 class FilePath;
18 18
19 namespace gfx { 19 namespace gfx {
20 class Rect; 20 class Rect;
21 class Size; 21 class Size;
22 } 22 }
23 23
24 namespace printing { 24 namespace printing {
25 25
26 // http://msdn2.microsoft.com/en-us/library/ms535522.aspx
27 // Windows 2000/XP: When a page in a spooled file exceeds approximately 350
28 // MB, it can fail to print and not send an error message.
29 const size_t kMetafileMaxSize = 350*1024*1024;
30
26 // Simple wrapper class that manage an EMF data stream and its virtual HDC. 31 // Simple wrapper class that manage an EMF data stream and its virtual HDC.
27 class PRINTING_EXPORT Emf : public Metafile { 32 class PRINTING_EXPORT Emf : public Metafile {
28 public: 33 public:
29 class Record; 34 class Record;
30 class Enumerator; 35 class Enumerator;
31 struct EnumerationContext; 36 struct EnumerationContext;
32 37
33 // Generates a virtual HDC that will record every GDI commands and compile 38 // Generates a virtual HDC that will record every GDI commands and compile
34 // it in a EMF data stream. 39 // it in a EMF data stream.
35 Emf(); 40 Emf();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 return hdc_; 84 return hdc_;
80 } 85 }
81 86
82 virtual bool Playback(HDC hdc, const RECT* rect) const OVERRIDE; 87 virtual bool Playback(HDC hdc, const RECT* rect) const OVERRIDE;
83 virtual bool SafePlayback(HDC hdc) const OVERRIDE; 88 virtual bool SafePlayback(HDC hdc) const OVERRIDE;
84 89
85 virtual HENHMETAFILE emf() const OVERRIDE { 90 virtual HENHMETAFILE emf() const OVERRIDE {
86 return emf_; 91 return emf_;
87 } 92 }
88 93
94 // Returns true if metafile contains alpha blend.
95 bool IsAlphaBlendUsed() const;
96
97 // Returns new metafile with only bitmap created by playback of the current
98 // metafile. Returns NULL if fails.
99 Emf* RasterizeMetafile(int raster_area_in_pixels) const;
100
89 private: 101 private:
90 FRIEND_TEST_ALL_PREFIXES(EmfTest, DC); 102 FRIEND_TEST_ALL_PREFIXES(EmfTest, DC);
91 FRIEND_TEST_ALL_PREFIXES(EmfPrintingTest, PageBreak); 103 FRIEND_TEST_ALL_PREFIXES(EmfPrintingTest, PageBreak);
92 FRIEND_TEST_ALL_PREFIXES(EmfTest, FileBackedEmf); 104 FRIEND_TEST_ALL_PREFIXES(EmfTest, FileBackedEmf);
93 105
94 // Retrieves the underlying data stream. It is a helper function. 106 // Retrieves the underlying data stream. It is a helper function.
95 bool GetDataAsVector(std::vector<uint8>* buffer) const; 107 bool GetDataAsVector(std::vector<uint8>* buffer) const;
96 108
97 // Playbacks safely one EMF record. 109 // Playbacks safely one EMF record.
98 static int CALLBACK SafePlaybackProc(HDC hdc, 110 static int CALLBACK SafePlaybackProc(HDC hdc,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 std::vector<Record> items_; 192 std::vector<Record> items_;
181 193
182 EnumerationContext context_; 194 EnumerationContext context_;
183 195
184 DISALLOW_COPY_AND_ASSIGN(Enumerator); 196 DISALLOW_COPY_AND_ASSIGN(Enumerator);
185 }; 197 };
186 198
187 } // namespace printing 199 } // namespace printing
188 200
189 #endif // PRINTING_EMF_WIN_H_ 201 #endif // PRINTING_EMF_WIN_H_
OLDNEW
« no previous file with comments | « chrome/renderer/print_web_view_helper_win.cc ('k') | printing/emf_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698