| 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 23 matching lines...) Expand all  Loading... | 
| 34 // Simple wrapper class that manage an EMF data stream and its virtual HDC. | 34 // Simple wrapper class that manage an EMF data stream and its virtual HDC. | 
| 35 class PRINTING_EXPORT Emf : public Metafile { | 35 class PRINTING_EXPORT Emf : public Metafile { | 
| 36  public: | 36  public: | 
| 37   class Record; | 37   class Record; | 
| 38   class Enumerator; | 38   class Enumerator; | 
| 39   struct EnumerationContext; | 39   struct EnumerationContext; | 
| 40 | 40 | 
| 41   // Generates a virtual HDC that will record every GDI commands and compile | 41   // Generates a virtual HDC that will record every GDI commands and compile | 
| 42   // it in a EMF data stream. | 42   // it in a EMF data stream. | 
| 43   Emf(); | 43   Emf(); | 
| 44   virtual ~Emf(); | 44   ~Emf() override; | 
| 45 | 45 | 
| 46   // Closes metafile. | 46   // Closes metafile. | 
| 47   void Close(); | 47   void Close(); | 
| 48 | 48 | 
| 49   // Generates a new metafile that will record every GDI command, and will | 49   // Generates a new metafile that will record every GDI command, and will | 
| 50   // be saved to |metafile_path|. | 50   // be saved to |metafile_path|. | 
| 51   bool InitToFile(const base::FilePath& metafile_path); | 51   bool InitToFile(const base::FilePath& metafile_path); | 
| 52 | 52 | 
| 53   // Initializes the Emf with the data in |metafile_path|. | 53   // Initializes the Emf with the data in |metafile_path|. | 
| 54   bool InitFromFile(const base::FilePath& metafile_path); | 54   bool InitFromFile(const base::FilePath& metafile_path); | 
| 55 | 55 | 
| 56   // Metafile methods. | 56   // Metafile methods. | 
| 57   virtual bool Init() override; | 57   bool Init() override; | 
| 58   virtual bool InitFromData(const void* src_buffer, | 58   bool InitFromData(const void* src_buffer, | 
| 59                             uint32 src_buffer_size) override; | 59                     uint32 src_buffer_size) override; | 
| 60 | 60 | 
| 61   // Inserts a custom GDICOMMENT records indicating StartPage/EndPage calls | 61   // Inserts a custom GDICOMMENT records indicating StartPage/EndPage calls | 
| 62   // (since StartPage and EndPage do not work in a metafile DC). Only valid | 62   // (since StartPage and EndPage do not work in a metafile DC). Only valid | 
| 63   // when hdc_ is non-NULL. |page_size|, |content_area|, and |scale_factor| are | 63   // when hdc_ is non-NULL. |page_size|, |content_area|, and |scale_factor| are | 
| 64   // ignored. | 64   // ignored. | 
| 65   virtual bool StartPage(const gfx::Size& page_size, | 65   bool StartPage(const gfx::Size& page_size, | 
| 66                          const gfx::Rect& content_area, | 66                  const gfx::Rect& content_area, | 
| 67                          const float& scale_factor) override; | 67                  const float& scale_factor) override; | 
| 68   virtual bool FinishPage() override; | 68   bool FinishPage() override; | 
| 69   virtual bool FinishDocument() override; | 69   bool FinishDocument() override; | 
| 70 | 70 | 
| 71   virtual uint32 GetDataSize() const override; | 71   uint32 GetDataSize() const override; | 
| 72   virtual 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   virtual gfx::Rect GetPageBounds(unsigned int page_number) const override; | 75   gfx::Rect GetPageBounds(unsigned int page_number) const override; | 
| 76 | 76 | 
| 77   virtual unsigned int GetPageCount() const override { return 1; } | 77   unsigned int GetPageCount() const override { return 1; } | 
| 78 | 78 | 
| 79   virtual HDC context() const override { | 79   HDC context() const override { | 
| 80     return hdc_; | 80     return hdc_; | 
| 81   } | 81   } | 
| 82 | 82 | 
| 83   virtual bool Playback(HDC hdc, const RECT* rect) const override; | 83   bool Playback(HDC hdc, const RECT* rect) const override; | 
| 84   virtual bool SafePlayback(HDC hdc) const override; | 84   bool SafePlayback(HDC hdc) const override; | 
| 85 | 85 | 
| 86   HENHMETAFILE emf() const { return emf_; } | 86   HENHMETAFILE emf() const { return emf_; } | 
| 87 | 87 | 
| 88   // Returns true if metafile contains alpha blend. | 88   // Returns true if metafile contains alpha blend. | 
| 89   bool IsAlphaBlendUsed() const; | 89   bool IsAlphaBlendUsed() const; | 
| 90 | 90 | 
| 91   // Returns new metafile with only bitmap created by playback of the current | 91   // Returns new metafile with only bitmap created by playback of the current | 
| 92   // metafile. Returns NULL if fails. | 92   // metafile. Returns NULL if fails. | 
| 93   scoped_ptr<Emf> RasterizeMetafile(int raster_area_in_pixels) const; | 93   scoped_ptr<Emf> RasterizeMetafile(int raster_area_in_pixels) const; | 
| 94 | 94 | 
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 185   std::vector<Record> items_; | 185   std::vector<Record> items_; | 
| 186 | 186 | 
| 187   EnumerationContext context_; | 187   EnumerationContext context_; | 
| 188 | 188 | 
| 189   DISALLOW_COPY_AND_ASSIGN(Enumerator); | 189   DISALLOW_COPY_AND_ASSIGN(Enumerator); | 
| 190 }; | 190 }; | 
| 191 | 191 | 
| 192 }  // namespace printing | 192 }  // namespace printing | 
| 193 | 193 | 
| 194 #endif  // PRINTING_EMF_WIN_H_ | 194 #endif  // PRINTING_EMF_WIN_H_ | 
| OLD | NEW | 
|---|