OLD | NEW |
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 | 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/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
14 #include "printing/metafile.h" | 15 #include "printing/metafile.h" |
15 | 16 |
16 class FilePath; | 17 class FilePath; |
17 | 18 |
18 namespace gfx { | 19 namespace gfx { |
19 class Rect; | 20 class Rect; |
20 class Size; | 21 class Size; |
21 } | 22 } |
22 | 23 |
(...skipping 12 matching lines...) Expand all Loading... |
35 virtual ~Emf(); | 36 virtual ~Emf(); |
36 | 37 |
37 // Generates a new metafile that will record every GDI command, and will | 38 // Generates a new metafile that will record every GDI command, and will |
38 // be saved to |metafile_path|. | 39 // be saved to |metafile_path|. |
39 virtual bool InitToFile(const FilePath& metafile_path); | 40 virtual bool InitToFile(const FilePath& metafile_path); |
40 | 41 |
41 // Initializes the Emf with the data in |metafile_path|. | 42 // Initializes the Emf with the data in |metafile_path|. |
42 virtual bool InitFromFile(const FilePath& metafile_path); | 43 virtual bool InitFromFile(const FilePath& metafile_path); |
43 | 44 |
44 // Metafile methods. | 45 // Metafile methods. |
45 virtual bool Init(); | 46 virtual bool Init() OVERRIDE; |
46 virtual bool InitFromData(const void* src_buffer, uint32 src_buffer_size); | 47 virtual bool InitFromData(const void* src_buffer, |
| 48 uint32 src_buffer_size) OVERRIDE; |
47 | 49 |
48 virtual SkDevice* StartPageForVectorCanvas( | 50 virtual SkDevice* StartPageForVectorCanvas( |
49 const gfx::Size& page_size, const gfx::Rect& content_area, | 51 const gfx::Size& page_size, const gfx::Rect& content_area, |
50 const float& scale_factor); | 52 const float& scale_factor) OVERRIDE; |
51 // Inserts a custom GDICOMMENT records indicating StartPage/EndPage calls | 53 // Inserts a custom GDICOMMENT records indicating StartPage/EndPage calls |
52 // (since StartPage and EndPage do not work in a metafile DC). Only valid | 54 // (since StartPage and EndPage do not work in a metafile DC). Only valid |
53 // when hdc_ is non-NULL. |page_size|, |content_area|, and |scale_factor| are | 55 // when hdc_ is non-NULL. |page_size|, |content_area|, and |scale_factor| are |
54 // ignored. | 56 // ignored. |
55 virtual bool StartPage(const gfx::Size& page_size, | 57 virtual bool StartPage(const gfx::Size& page_size, |
56 const gfx::Rect& content_area, | 58 const gfx::Rect& content_area, |
57 const float& scale_factor); | 59 const float& scale_factor) OVERRIDE; |
58 virtual bool FinishPage(); | 60 virtual bool FinishPage() OVERRIDE; |
59 virtual bool FinishDocument(); | 61 virtual bool FinishDocument() OVERRIDE; |
60 | 62 |
61 virtual uint32 GetDataSize() const; | 63 virtual uint32 GetDataSize() const OVERRIDE; |
62 virtual bool GetData(void* buffer, uint32 size) const; | 64 virtual bool GetData(void* buffer, uint32 size) const OVERRIDE; |
63 | 65 |
64 // Saves the EMF data to a file as-is. It is recommended to use the .emf file | 66 // Saves the EMF data to a file as-is. It is recommended to use the .emf file |
65 // extension but it is not enforced. This function synchronously writes to the | 67 // extension but it is not enforced. This function synchronously writes to the |
66 // file. For testing only. | 68 // file. For testing only. |
67 virtual bool SaveTo(const FilePath& file_path) const; | 69 virtual bool SaveTo(const FilePath& file_path) const OVERRIDE; |
68 | 70 |
69 // Should be passed to Playback to keep the exact same size. | 71 // Should be passed to Playback to keep the exact same size. |
70 virtual gfx::Rect GetPageBounds(unsigned int page_number) const; | 72 virtual gfx::Rect GetPageBounds(unsigned int page_number) const OVERRIDE; |
71 | 73 |
72 virtual unsigned int GetPageCount() const { | 74 virtual unsigned int GetPageCount() const OVERRIDE { |
73 return page_count_; | 75 return page_count_; |
74 } | 76 } |
75 | 77 |
76 virtual HDC context() const { | 78 virtual HDC context() const OVERRIDE { |
77 return hdc_; | 79 return hdc_; |
78 } | 80 } |
79 | 81 |
80 virtual bool Playback(HDC hdc, const RECT* rect) const; | 82 virtual bool Playback(HDC hdc, const RECT* rect) const OVERRIDE; |
81 virtual bool SafePlayback(HDC hdc) const; | 83 virtual bool SafePlayback(HDC hdc) const OVERRIDE; |
82 | 84 |
83 virtual HENHMETAFILE emf() const { | 85 virtual HENHMETAFILE emf() const OVERRIDE { |
84 return emf_; | 86 return emf_; |
85 } | 87 } |
86 | 88 |
87 private: | 89 private: |
88 FRIEND_TEST_ALL_PREFIXES(EmfTest, DC); | 90 FRIEND_TEST_ALL_PREFIXES(EmfTest, DC); |
89 FRIEND_TEST_ALL_PREFIXES(EmfPrintingTest, PageBreak); | 91 FRIEND_TEST_ALL_PREFIXES(EmfPrintingTest, PageBreak); |
90 FRIEND_TEST_ALL_PREFIXES(EmfTest, FileBackedEmf); | 92 FRIEND_TEST_ALL_PREFIXES(EmfTest, FileBackedEmf); |
91 | 93 |
92 // Retrieves the underlying data stream. It is a helper function. | 94 // Retrieves the underlying data stream. It is a helper function. |
93 bool GetDataAsVector(std::vector<uint8>* buffer) const; | 95 bool GetDataAsVector(std::vector<uint8>* buffer) const; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 std::vector<Record> items_; | 176 std::vector<Record> items_; |
175 | 177 |
176 EnumerationContext context_; | 178 EnumerationContext context_; |
177 | 179 |
178 DISALLOW_COPY_AND_ASSIGN(Enumerator); | 180 DISALLOW_COPY_AND_ASSIGN(Enumerator); |
179 }; | 181 }; |
180 | 182 |
181 } // namespace printing | 183 } // namespace printing |
182 | 184 |
183 #endif // PRINTING_EMF_WIN_H_ | 185 #endif // PRINTING_EMF_WIN_H_ |
OLD | NEW |