| 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_PDF_METAFILE_SKIA_H_ | 5 #ifndef PRINTING_PDF_METAFILE_SKIA_H_ |
| 6 #define PRINTING_PDF_METAFILE_SKIA_H_ | 6 #define PRINTING_PDF_METAFILE_SKIA_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 12 #include "printing/metafile.h" | 12 #include "printing/metafile.h" |
| 13 | 13 |
| 14 #if defined(OS_WIN) | 14 #if defined(OS_WIN) |
| 15 #include <windows.h> | 15 #include <windows.h> |
| 16 #endif | 16 #endif |
| 17 | 17 |
| 18 namespace printing { | 18 namespace printing { |
| 19 | 19 |
| 20 struct PdfMetafileSkiaData; | 20 struct PdfMetafileSkiaData; |
| 21 | 21 |
| 22 // This class uses Skia graphics library to generate a PDF document. | 22 // This class uses Skia graphics library to generate a PDF document. |
| 23 class PRINTING_EXPORT PdfMetafileSkia : public Metafile { | 23 class PRINTING_EXPORT PdfMetafileSkia : public Metafile { |
| 24 public: | 24 public: |
| 25 PdfMetafileSkia(); | 25 PdfMetafileSkia(); |
| 26 virtual ~PdfMetafileSkia(); | 26 virtual ~PdfMetafileSkia(); |
| 27 | 27 |
| 28 // Metafile methods. | 28 // Metafile methods. |
| 29 virtual bool Init(); | 29 virtual bool Init() OVERRIDE; |
| 30 virtual bool InitFromData(const void* src_buffer, uint32 src_buffer_size); | 30 virtual bool InitFromData(const void* src_buffer, |
| 31 uint32 src_buffer_size) OVERRIDE; |
| 31 | 32 |
| 32 virtual SkDevice* StartPageForVectorCanvas( | 33 virtual SkDevice* StartPageForVectorCanvas( |
| 33 const gfx::Size& page_size, | 34 const gfx::Size& page_size, |
| 34 const gfx::Rect& content_area, | 35 const gfx::Rect& content_area, |
| 35 const float& scale_factor); | 36 const float& scale_factor) OVERRIDE; |
| 36 | 37 |
| 37 virtual bool StartPage(const gfx::Size& page_size, | 38 virtual bool StartPage(const gfx::Size& page_size, |
| 38 const gfx::Rect& content_area, | 39 const gfx::Rect& content_area, |
| 39 const float& scale_factor); | 40 const float& scale_factor) OVERRIDE; |
| 40 virtual bool FinishPage(); | 41 virtual bool FinishPage() OVERRIDE; |
| 41 virtual bool FinishDocument(); | 42 virtual bool FinishDocument() OVERRIDE; |
| 42 | 43 |
| 43 virtual uint32 GetDataSize() const; | 44 virtual uint32 GetDataSize() const OVERRIDE; |
| 44 virtual bool GetData(void* dst_buffer, uint32 dst_buffer_size) const; | 45 virtual bool GetData(void* dst_buffer, uint32 dst_buffer_size) const OVERRIDE; |
| 45 | 46 |
| 46 virtual bool SaveTo(const FilePath& file_path) const; | 47 virtual bool SaveTo(const FilePath& file_path) const OVERRIDE; |
| 47 | 48 |
| 48 virtual gfx::Rect GetPageBounds(unsigned int page_number) const; | 49 virtual gfx::Rect GetPageBounds(unsigned int page_number) const OVERRIDE; |
| 49 virtual unsigned int GetPageCount() const; | 50 virtual unsigned int GetPageCount() const OVERRIDE; |
| 50 | 51 |
| 51 virtual gfx::NativeDrawingContext context() const; | 52 virtual gfx::NativeDrawingContext context() const OVERRIDE; |
| 52 | 53 |
| 53 #if defined(OS_WIN) | 54 #if defined(OS_WIN) |
| 54 virtual bool Playback(gfx::NativeDrawingContext hdc, const RECT* rect) const; | 55 virtual bool Playback(gfx::NativeDrawingContext hdc, |
| 55 virtual bool SafePlayback(gfx::NativeDrawingContext hdc) const; | 56 const RECT* rect) const OVERRIDE; |
| 56 virtual HENHMETAFILE emf() const; | 57 virtual bool SafePlayback(gfx::NativeDrawingContext hdc) const OVERRIDE; |
| 58 virtual HENHMETAFILE emf() const OVERRIDE; |
| 57 #elif defined(OS_MACOSX) | 59 #elif defined(OS_MACOSX) |
| 58 virtual bool RenderPage(unsigned int page_number, | 60 virtual bool RenderPage(unsigned int page_number, |
| 59 CGContextRef context, | 61 CGContextRef context, |
| 60 const CGRect rect, | 62 const CGRect rect, |
| 61 bool shrink_to_fit, | 63 bool shrink_to_fit, |
| 62 bool stretch_to_fit, | 64 bool stretch_to_fit, |
| 63 bool center_horizontally, | 65 bool center_horizontally, |
| 64 bool center_vertically) const; | 66 bool center_vertically) const OVERRIDE; |
| 65 #endif | 67 #endif |
| 66 | 68 |
| 67 #if defined(OS_CHROMEOS) | 69 #if defined(OS_CHROMEOS) |
| 68 virtual bool SaveToFD(const base::FileDescriptor& fd) const; | 70 virtual bool SaveToFD(const base::FileDescriptor& fd) const OVERRIDE; |
| 69 #endif // if defined(OS_CHROMEOS) | 71 #endif // if defined(OS_CHROMEOS) |
| 70 | 72 |
| 71 // Return a new metafile containing just the current page in draft mode. | 73 // Return a new metafile containing just the current page in draft mode. |
| 72 PdfMetafileSkia* GetMetafileForCurrentPage(); | 74 PdfMetafileSkia* GetMetafileForCurrentPage(); |
| 73 | 75 |
| 74 private: | 76 private: |
| 75 scoped_ptr<PdfMetafileSkiaData> data_; | 77 scoped_ptr<PdfMetafileSkiaData> data_; |
| 76 | 78 |
| 77 // True when finish page is outstanding for current page. | 79 // True when finish page is outstanding for current page. |
| 78 bool page_outstanding_; | 80 bool page_outstanding_; |
| 79 | 81 |
| 80 DISALLOW_COPY_AND_ASSIGN(PdfMetafileSkia); | 82 DISALLOW_COPY_AND_ASSIGN(PdfMetafileSkia); |
| 81 }; | 83 }; |
| 82 | 84 |
| 83 } // namespace printing | 85 } // namespace printing |
| 84 | 86 |
| 85 #endif // PRINTING_PDF_METAFILE_SKIA_H_ | 87 #endif // PRINTING_PDF_METAFILE_SKIA_H_ |
| OLD | NEW |