| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "printing/metafile.h" | 14 #include "printing/metafile.h" |
| 15 #include "skia/ext/platform_canvas.h" | 15 #include "skia/ext/platform_canvas.h" |
| 16 | 16 |
| 17 #if defined(OS_WIN) | 17 #if defined(OS_WIN) |
| 18 #include <windows.h> | 18 #include <windows.h> |
| 19 #endif | 19 #endif |
| 20 | 20 |
| 21 class SkCanvas; | 21 class SkCanvas; |
| 22 | 22 |
| 23 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) | 23 namespace printing { |
| 24 namespace base { | |
| 25 struct FileDescriptor; | |
| 26 } | |
| 27 #endif | |
| 28 | 24 |
| 29 namespace printing { | 25 enum SkiaDocumentType { |
| 26 PDF_SKIA_DOCUMENT_TYPE, |
| 27 // MSKP is an experimental, fragile, and diagnostic-only document type. |
| 28 MSKP_SKIA_DOCUMENT_TYPE, |
| 29 }; |
| 30 | 30 |
| 31 struct PdfMetafileSkiaData; | 31 struct PdfMetafileSkiaData; |
| 32 | 32 |
| 33 // This class uses Skia graphics library to generate a PDF document. | 33 // This class uses Skia graphics library to generate a PDF document. |
| 34 class PRINTING_EXPORT PdfMetafileSkia : public Metafile { | 34 class PRINTING_EXPORT PdfMetafileSkia : public Metafile { |
| 35 public: | 35 public: |
| 36 PdfMetafileSkia(); | 36 explicit PdfMetafileSkia(SkiaDocumentType type); |
| 37 ~PdfMetafileSkia() override; | 37 ~PdfMetafileSkia() override; |
| 38 | 38 |
| 39 // Metafile methods. | 39 // Metafile methods. |
| 40 bool Init() override; | 40 bool Init() override; |
| 41 bool InitFromData(const void* src_buffer, uint32_t src_buffer_size) override; | 41 bool InitFromData(const void* src_buffer, uint32_t src_buffer_size) override; |
| 42 | 42 |
| 43 void StartPage(const gfx::Size& page_size, | 43 void StartPage(const gfx::Size& page_size, |
| 44 const gfx::Rect& content_area, | 44 const gfx::Rect& content_area, |
| 45 const float& scale_factor) override; | 45 const float& scale_factor) override; |
| 46 bool FinishPage() override; | 46 bool FinishPage() override; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 61 #elif defined(OS_MACOSX) | 61 #elif defined(OS_MACOSX) |
| 62 bool RenderPage(unsigned int page_number, | 62 bool RenderPage(unsigned int page_number, |
| 63 gfx::NativeDrawingContext context, | 63 gfx::NativeDrawingContext context, |
| 64 const CGRect rect, | 64 const CGRect rect, |
| 65 const MacRenderPageParams& params) const override; | 65 const MacRenderPageParams& params) const override; |
| 66 #endif | 66 #endif |
| 67 | 67 |
| 68 bool SaveTo(base::File* file) const override; | 68 bool SaveTo(base::File* file) const override; |
| 69 | 69 |
| 70 // 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. |
| 71 std::unique_ptr<PdfMetafileSkia> GetMetafileForCurrentPage(); | 71 std::unique_ptr<PdfMetafileSkia> GetMetafileForCurrentPage( |
| 72 SkiaDocumentType type); |
| 72 | 73 |
| 73 // This method calls StartPage and then returns an appropriate | 74 // This method calls StartPage and then returns an appropriate |
| 74 // PlatformCanvas implementation bound to the context created by | 75 // PlatformCanvas implementation bound to the context created by |
| 75 // StartPage or NULL on error. The SkCanvas pointer that | 76 // StartPage or NULL on error. The SkCanvas pointer that |
| 76 // is returned is owned by this PdfMetafileSkia object and does not | 77 // is returned is owned by this PdfMetafileSkia object and does not |
| 77 // need to be ref()ed or unref()ed. The canvas will remain valid | 78 // need to be ref()ed or unref()ed. The canvas will remain valid |
| 78 // until FinishPage() or FinishDocument() is called. | 79 // until FinishPage() or FinishDocument() is called. |
| 79 SkCanvas* GetVectorCanvasForNewPage(const gfx::Size& page_size, | 80 SkCanvas* GetVectorCanvasForNewPage(const gfx::Size& page_size, |
| 80 const gfx::Rect& content_area, | 81 const gfx::Rect& content_area, |
| 81 const float& scale_factor); | 82 const float& scale_factor); |
| 82 | 83 |
| 83 private: | 84 private: |
| 84 std::unique_ptr<PdfMetafileSkiaData> data_; | 85 std::unique_ptr<PdfMetafileSkiaData> data_; |
| 85 | 86 |
| 86 DISALLOW_COPY_AND_ASSIGN(PdfMetafileSkia); | 87 DISALLOW_COPY_AND_ASSIGN(PdfMetafileSkia); |
| 87 }; | 88 }; |
| 88 | 89 |
| 89 } // namespace printing | 90 } // namespace printing |
| 90 | 91 |
| 91 #endif // PRINTING_PDF_METAFILE_SKIA_H_ | 92 #endif // PRINTING_PDF_METAFILE_SKIA_H_ |
| OLD | NEW |