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

Side by Side Diff: printing/emf_win.h

Issue 6695013: Cleanup NativeMetafile (win) interface and EMF class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 9 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « content/plugin/webplugin_delegate_stub.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include <vector> 9 #include <vector>
10 10
(...skipping 11 matching lines...) Expand all
22 22
23 namespace printing { 23 namespace printing {
24 24
25 // Simple wrapper class that manage an EMF data stream and its virtual HDC. 25 // Simple wrapper class that manage an EMF data stream and its virtual HDC.
26 class Emf : public NativeMetafile { 26 class Emf : public NativeMetafile {
27 public: 27 public:
28 class Record; 28 class Record;
29 class Enumerator; 29 class Enumerator;
30 struct EnumerationContext; 30 struct EnumerationContext;
31 31
32 // Generates a virtual HDC that will record every GDI commands and compile
33 // it in a EMF data stream.
34 Emf();
32 virtual ~Emf(); 35 virtual ~Emf();
33 36
37 // Generates a new metafile that will record every GDI command, and will
38 // be saved to |metafile_path|.
39 virtual bool InitToFile(const FilePath& metafile_path);
40
41 // Initializes the Emf with the data in |metafile_path|.
42 virtual bool InitFromFile(const FilePath& metafile_path);
43
34 // NativeMetafile methods. 44 // NativeMetafile methods.
35 virtual bool Init() { return true; } 45 virtual bool Init();
36 virtual bool InitFromData(const void* src_buffer, uint32 src_buffer_size); 46 virtual bool InitFromData(const void* src_buffer, uint32 src_buffer_size);
37 47
38 virtual skia::PlatformDevice* StartPageForVectorCanvas( 48 virtual skia::PlatformDevice* StartPageForVectorCanvas(
39 const gfx::Size& page_size, const gfx::Point& content_origin, 49 const gfx::Size& page_size, const gfx::Point& content_origin,
40 const float& scale_factor); 50 const float& scale_factor);
41 // Inserts a custom GDICOMMENT records indicating StartPage/EndPage calls 51 // Inserts a custom GDICOMMENT records indicating StartPage/EndPage calls
42 // (since StartPage and EndPage do not work in a metafile DC). Only valid 52 // (since StartPage and EndPage do not work in a metafile DC). Only valid
43 // when hdc_ is non-NULL. |page_size| and |content_origin| are ignored. 53 // when hdc_ is non-NULL. |page_size| and |content_origin| are ignored.
44 // |scale_factor| must be 1.0. 54 // |scale_factor| must be 1.0.
45 virtual bool StartPage(const gfx::Size& page_size, 55 virtual bool StartPage(const gfx::Size& page_size,
(...skipping 15 matching lines...) Expand all
61 71
62 virtual unsigned int GetPageCount() const { 72 virtual unsigned int GetPageCount() const {
63 // TODO(dpapad): count the number of times StartPage() is called 73 // TODO(dpapad): count the number of times StartPage() is called
64 return 1; 74 return 1;
65 } 75 }
66 76
67 virtual HDC context() const { 77 virtual HDC context() const {
68 return hdc_; 78 return hdc_;
69 } 79 }
70 80
71 virtual bool CreateDc(HDC sibling, const RECT* rect);
72 virtual bool CreateFileBackedDc(HDC sibling,
73 const RECT* rect,
74 const FilePath& path);
75 virtual bool CreateFromFile(const FilePath& file_path);
76
77 virtual void CloseEmf();
78
79 virtual bool Playback(HDC hdc, const RECT* rect) const; 81 virtual bool Playback(HDC hdc, const RECT* rect) const;
80 virtual bool SafePlayback(HDC hdc) const; 82 virtual bool SafePlayback(HDC hdc) const;
81 83
82 virtual bool GetData(std::vector<uint8>* buffer) const; 84 virtual bool GetData(std::vector<uint8>* buffer) const;
83 85
84 virtual HENHMETAFILE emf() const { 86 virtual HENHMETAFILE emf() const {
85 return emf_; 87 return emf_;
86 } 88 }
87 89
88 protected:
89 Emf();
90
91 private: 90 private:
92 friend class NativeMetafileFactory;
93 FRIEND_TEST_ALL_PREFIXES(EmfTest, DC);
94 FRIEND_TEST_ALL_PREFIXES(EmfTest, FileBackedDC);
95 FRIEND_TEST_ALL_PREFIXES(EmfPrintingTest, Enumerate);
96 FRIEND_TEST_ALL_PREFIXES(EmfPrintingTest, PageBreak);
97
98 // Playbacks safely one EMF record. 91 // Playbacks safely one EMF record.
99 static int CALLBACK SafePlaybackProc(HDC hdc, 92 static int CALLBACK SafePlaybackProc(HDC hdc,
100 HANDLETABLE* handle_table, 93 HANDLETABLE* handle_table,
101 const ENHMETARECORD* record, 94 const ENHMETARECORD* record,
102 int objects_count, 95 int objects_count,
103 LPARAM param); 96 LPARAM param);
104 97
105 // Compiled EMF data handle. 98 // Compiled EMF data handle.
106 HENHMETAFILE emf_; 99 HENHMETAFILE emf_;
107 100
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 std::vector<Record> items_; 168 std::vector<Record> items_;
176 169
177 EnumerationContext context_; 170 EnumerationContext context_;
178 171
179 DISALLOW_COPY_AND_ASSIGN(Enumerator); 172 DISALLOW_COPY_AND_ASSIGN(Enumerator);
180 }; 173 };
181 174
182 } // namespace printing 175 } // namespace printing
183 176
184 #endif // PRINTING_EMF_WIN_H_ 177 #endif // PRINTING_EMF_WIN_H_
OLDNEW
« no previous file with comments | « content/plugin/webplugin_delegate_stub.cc ('k') | printing/emf_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698