| 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_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 Loading... |
| 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 Loading... |
| 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_ |
| OLD | NEW |