| 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> |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 const float& scale_factor) override; | 67 const float& scale_factor) override; |
| 68 bool FinishPage() override; | 68 bool FinishPage() override; |
| 69 bool FinishDocument() override; | 69 bool FinishDocument() override; |
| 70 | 70 |
| 71 uint32 GetDataSize() const override; | 71 uint32 GetDataSize() const override; |
| 72 bool GetData(void* buffer, uint32 size) const override; | 72 bool GetData(void* buffer, uint32 size) const override; |
| 73 | 73 |
| 74 // Should be passed to Playback to keep the exact same size. | 74 // Should be passed to Playback to keep the exact same size. |
| 75 gfx::Rect GetPageBounds(unsigned int page_number) const override; | 75 gfx::Rect GetPageBounds(unsigned int page_number) const override; |
| 76 | 76 |
| 77 unsigned int GetPageCount() const override { return 1; } | 77 unsigned int GetPageCount() const override; |
| 78 | 78 HDC context() const override; |
| 79 HDC context() const override { | |
| 80 return hdc_; | |
| 81 } | |
| 82 | |
| 83 bool Playback(HDC hdc, const RECT* rect) const override; | 79 bool Playback(HDC hdc, const RECT* rect) const override; |
| 84 bool SafePlayback(HDC hdc) const override; | 80 bool SafePlayback(HDC hdc) const override; |
| 85 | 81 |
| 86 HENHMETAFILE emf() const { return emf_; } | 82 HENHMETAFILE emf() const { return emf_; } |
| 87 | 83 |
| 88 // Returns true if metafile contains alpha blend. | 84 // Returns true if metafile contains alpha blend. |
| 89 bool IsAlphaBlendUsed() const; | 85 bool IsAlphaBlendUsed() const; |
| 90 | 86 |
| 91 // Returns new metafile with only bitmap created by playback of the current | 87 // Returns new metafile with only bitmap created by playback of the current |
| 92 // metafile. Returns NULL if fails. | 88 // metafile. Returns NULL if fails. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 class PRINTING_EXPORT Emf::Enumerator { | 152 class PRINTING_EXPORT Emf::Enumerator { |
| 157 public: | 153 public: |
| 158 // Iterator type used for iterating the records. | 154 // Iterator type used for iterating the records. |
| 159 typedef std::vector<Record>::const_iterator const_iterator; | 155 typedef std::vector<Record>::const_iterator const_iterator; |
| 160 | 156 |
| 161 // Enumerates the records at construction time. |hdc| and |rect| are | 157 // Enumerates the records at construction time. |hdc| and |rect| are |
| 162 // both optional at the same time or must both be valid. | 158 // both optional at the same time or must both be valid. |
| 163 // Warning: |emf| must be kept valid for the time this object is alive. | 159 // Warning: |emf| must be kept valid for the time this object is alive. |
| 164 Enumerator(const Emf& emf, HDC hdc, const RECT* rect); | 160 Enumerator(const Emf& emf, HDC hdc, const RECT* rect); |
| 165 | 161 |
| 162 ~Enumerator(); |
| 163 |
| 166 // Retrieves the first Record. | 164 // Retrieves the first Record. |
| 167 const_iterator begin() const; | 165 const_iterator begin() const; |
| 168 | 166 |
| 169 // Retrieves the end of the array. | 167 // Retrieves the end of the array. |
| 170 const_iterator end() const; | 168 const_iterator end() const; |
| 171 | 169 |
| 172 private: | 170 private: |
| 173 FRIEND_TEST_ALL_PREFIXES(EmfPrintingTest, Enumerate); | 171 FRIEND_TEST_ALL_PREFIXES(EmfPrintingTest, Enumerate); |
| 174 | 172 |
| 175 // Processes one EMF record and saves it in the items_ array. | 173 // Processes one EMF record and saves it in the items_ array. |
| 176 static int CALLBACK EnhMetaFileProc(HDC hdc, | 174 static int CALLBACK EnhMetaFileProc(HDC hdc, |
| 177 HANDLETABLE* handle_table, | 175 HANDLETABLE* handle_table, |
| 178 const ENHMETARECORD* record, | 176 const ENHMETARECORD* record, |
| 179 int objects_count, | 177 int objects_count, |
| 180 LPARAM param); | 178 LPARAM param); |
| 181 | 179 |
| 182 // The collection of every EMF records in the currently loaded EMF buffer. | 180 // The collection of every EMF records in the currently loaded EMF buffer. |
| 183 // Initialized by Enumerate(). It keeps pointers to the EMF buffer held by | 181 // Initialized by Enumerate(). It keeps pointers to the EMF buffer held by |
| 184 // Emf::emf_. The entries become invalid once Emf::CloseEmf() is called. | 182 // Emf::emf_. The entries become invalid once Emf::CloseEmf() is called. |
| 185 std::vector<Record> items_; | 183 std::vector<Record> items_; |
| 186 | 184 |
| 187 EnumerationContext context_; | 185 EnumerationContext context_; |
| 188 | 186 |
| 189 DISALLOW_COPY_AND_ASSIGN(Enumerator); | 187 DISALLOW_COPY_AND_ASSIGN(Enumerator); |
| 190 }; | 188 }; |
| 191 | 189 |
| 192 } // namespace printing | 190 } // namespace printing |
| 193 | 191 |
| 194 #endif // PRINTING_EMF_WIN_H_ | 192 #endif // PRINTING_EMF_WIN_H_ |
| OLD | NEW |