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" |
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 class SkBaseDevice; |
| 19 |
18 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) | 20 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) |
19 namespace base { | 21 namespace base { |
20 struct FileDescriptor; | 22 struct FileDescriptor; |
21 } | 23 } |
22 #endif | 24 #endif |
23 | 25 |
24 namespace printing { | 26 namespace printing { |
25 | 27 |
26 struct PdfMetafileSkiaData; | 28 struct PdfMetafileSkiaData; |
27 | 29 |
28 // This class uses Skia graphics library to generate a PDF document. | 30 // This class uses Skia graphics library to generate a PDF document. |
29 class PRINTING_EXPORT PdfMetafileSkia : public Metafile { | 31 class PRINTING_EXPORT PdfMetafileSkia : public Metafile { |
30 public: | 32 public: |
31 PdfMetafileSkia(); | 33 PdfMetafileSkia(); |
32 ~PdfMetafileSkia() override; | 34 ~PdfMetafileSkia() override; |
33 | 35 |
34 // Metafile methods. | 36 // Metafile methods. |
35 bool Init() override; | 37 bool Init() override; |
36 bool InitFromData(const void* src_buffer, uint32 src_buffer_size) override; | 38 bool InitFromData(const void* src_buffer, uint32 src_buffer_size) override; |
37 | 39 |
38 SkBaseDevice* StartPageForVectorCanvas(const gfx::Size& page_size, | |
39 const gfx::Rect& content_area, | |
40 const float& scale_factor) override; | |
41 | |
42 bool StartPage(const gfx::Size& page_size, | 40 bool StartPage(const gfx::Size& page_size, |
43 const gfx::Rect& content_area, | 41 const gfx::Rect& content_area, |
44 const float& scale_factor) override; | 42 const float& scale_factor) override; |
45 bool FinishPage() override; | 43 bool FinishPage() override; |
46 bool FinishDocument() override; | 44 bool FinishDocument() override; |
47 | 45 |
48 uint32 GetDataSize() const override; | 46 uint32 GetDataSize() const override; |
49 bool GetData(void* dst_buffer, uint32 dst_buffer_size) const override; | 47 bool GetData(void* dst_buffer, uint32 dst_buffer_size) const override; |
50 | 48 |
51 gfx::Rect GetPageBounds(unsigned int page_number) const override; | 49 gfx::Rect GetPageBounds(unsigned int page_number) const override; |
(...skipping 13 matching lines...) Expand all Loading... |
65 #endif | 63 #endif |
66 | 64 |
67 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) | 65 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) |
68 // TODO(vitalybuka): replace with SaveTo(). | 66 // TODO(vitalybuka): replace with SaveTo(). |
69 bool SaveToFD(const base::FileDescriptor& fd) const; | 67 bool SaveToFD(const base::FileDescriptor& fd) const; |
70 #endif // if defined(OS_CHROMEOS) || defined(OS_ANDROID) | 68 #endif // if defined(OS_CHROMEOS) || defined(OS_ANDROID) |
71 | 69 |
72 // Return a new metafile containing just the current page in draft mode. | 70 // Return a new metafile containing just the current page in draft mode. |
73 scoped_ptr<PdfMetafileSkia> GetMetafileForCurrentPage(); | 71 scoped_ptr<PdfMetafileSkia> GetMetafileForCurrentPage(); |
74 | 72 |
| 73 // This method calls StartPage and then returns an appropriate |
| 74 // VectorPlatformDevice implementation bound to the context created by |
| 75 // StartPage or NULL on error. |
| 76 SkBaseDevice* StartPageForVectorCanvas(const gfx::Size& page_size, |
| 77 const gfx::Rect& content_area, |
| 78 const float& scale_factor); |
75 private: | 79 private: |
76 scoped_ptr<PdfMetafileSkiaData> data_; | 80 scoped_ptr<PdfMetafileSkiaData> data_; |
77 | 81 |
78 // True when finish page is outstanding for current page. | 82 // True when finish page is outstanding for current page. |
79 bool page_outstanding_; | 83 bool page_outstanding_; |
80 | 84 |
81 DISALLOW_COPY_AND_ASSIGN(PdfMetafileSkia); | 85 DISALLOW_COPY_AND_ASSIGN(PdfMetafileSkia); |
82 }; | 86 }; |
83 | 87 |
84 } // namespace printing | 88 } // namespace printing |
85 | 89 |
86 #endif // PRINTING_PDF_METAFILE_SKIA_H_ | 90 #endif // PRINTING_PDF_METAFILE_SKIA_H_ |
OLD | NEW |