| 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_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" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #endif | 22 #endif |
| 23 | 23 |
| 24 namespace printing { | 24 namespace printing { |
| 25 | 25 |
| 26 struct PdfMetafileSkiaData; | 26 struct PdfMetafileSkiaData; |
| 27 | 27 |
| 28 // This class uses Skia graphics library to generate a PDF document. | 28 // This class uses Skia graphics library to generate a PDF document. |
| 29 class PRINTING_EXPORT PdfMetafileSkia : public Metafile { | 29 class PRINTING_EXPORT PdfMetafileSkia : public Metafile { |
| 30 public: | 30 public: |
| 31 PdfMetafileSkia(); | 31 PdfMetafileSkia(); |
| 32 virtual ~PdfMetafileSkia(); | 32 ~PdfMetafileSkia() override; |
| 33 | 33 |
| 34 // Metafile methods. | 34 // Metafile methods. |
| 35 virtual bool Init() override; | 35 bool Init() override; |
| 36 virtual bool InitFromData(const void* src_buffer, | 36 bool InitFromData(const void* src_buffer, uint32 src_buffer_size) override; |
| 37 uint32 src_buffer_size) override; | |
| 38 | 37 |
| 39 virtual SkBaseDevice* StartPageForVectorCanvas( | 38 SkBaseDevice* StartPageForVectorCanvas(const gfx::Size& page_size, |
| 40 const gfx::Size& page_size, | 39 const gfx::Rect& content_area, |
| 41 const gfx::Rect& content_area, | 40 const float& scale_factor) override; |
| 42 const float& scale_factor) override; | |
| 43 | 41 |
| 44 virtual bool StartPage(const gfx::Size& page_size, | 42 bool StartPage(const gfx::Size& page_size, |
| 45 const gfx::Rect& content_area, | 43 const gfx::Rect& content_area, |
| 46 const float& scale_factor) override; | 44 const float& scale_factor) override; |
| 47 virtual bool FinishPage() override; | 45 bool FinishPage() override; |
| 48 virtual bool FinishDocument() override; | 46 bool FinishDocument() override; |
| 49 | 47 |
| 50 virtual uint32 GetDataSize() const override; | 48 uint32 GetDataSize() const override; |
| 51 virtual bool GetData(void* dst_buffer, uint32 dst_buffer_size) const override; | 49 bool GetData(void* dst_buffer, uint32 dst_buffer_size) const override; |
| 52 | 50 |
| 53 virtual gfx::Rect GetPageBounds(unsigned int page_number) const override; | 51 gfx::Rect GetPageBounds(unsigned int page_number) const override; |
| 54 virtual unsigned int GetPageCount() const override; | 52 unsigned int GetPageCount() const override; |
| 55 | 53 |
| 56 virtual gfx::NativeDrawingContext context() const override; | 54 gfx::NativeDrawingContext context() const override; |
| 57 | 55 |
| 58 #if defined(OS_WIN) | 56 #if defined(OS_WIN) |
| 59 virtual bool Playback(gfx::NativeDrawingContext hdc, | 57 virtual bool Playback(gfx::NativeDrawingContext hdc, |
| 60 const RECT* rect) const override; | 58 const RECT* rect) const override; |
| 61 virtual bool SafePlayback(gfx::NativeDrawingContext hdc) const override; | 59 virtual bool SafePlayback(gfx::NativeDrawingContext hdc) const override; |
| 62 #elif defined(OS_MACOSX) | 60 #elif defined(OS_MACOSX) |
| 63 virtual bool RenderPage(unsigned int page_number, | 61 bool RenderPage(unsigned int page_number, |
| 64 gfx::NativeDrawingContext context, | 62 gfx::NativeDrawingContext context, |
| 65 const CGRect rect, | 63 const CGRect rect, |
| 66 const MacRenderPageParams& params) const override; | 64 const MacRenderPageParams& params) const override; |
| 67 #endif | 65 #endif |
| 68 | 66 |
| 69 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) | 67 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) |
| 70 // TODO(vitalybuka): replace with SaveTo(). | 68 // TODO(vitalybuka): replace with SaveTo(). |
| 71 bool SaveToFD(const base::FileDescriptor& fd) const; | 69 bool SaveToFD(const base::FileDescriptor& fd) const; |
| 72 #endif // if defined(OS_CHROMEOS) || defined(OS_ANDROID) | 70 #endif // if defined(OS_CHROMEOS) || defined(OS_ANDROID) |
| 73 | 71 |
| 74 // Return a new metafile containing just the current page in draft mode. | 72 // Return a new metafile containing just the current page in draft mode. |
| 75 scoped_ptr<PdfMetafileSkia> GetMetafileForCurrentPage(); | 73 scoped_ptr<PdfMetafileSkia> GetMetafileForCurrentPage(); |
| 76 | 74 |
| 77 private: | 75 private: |
| 78 scoped_ptr<PdfMetafileSkiaData> data_; | 76 scoped_ptr<PdfMetafileSkiaData> data_; |
| 79 | 77 |
| 80 // True when finish page is outstanding for current page. | 78 // True when finish page is outstanding for current page. |
| 81 bool page_outstanding_; | 79 bool page_outstanding_; |
| 82 | 80 |
| 83 DISALLOW_COPY_AND_ASSIGN(PdfMetafileSkia); | 81 DISALLOW_COPY_AND_ASSIGN(PdfMetafileSkia); |
| 84 }; | 82 }; |
| 85 | 83 |
| 86 } // namespace printing | 84 } // namespace printing |
| 87 | 85 |
| 88 #endif // PRINTING_PDF_METAFILE_SKIA_H_ | 86 #endif // PRINTING_PDF_METAFILE_SKIA_H_ |
| OLD | NEW |