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 #include "skia/ext/vector_canvas.h" |
13 | 14 |
14 #if defined(OS_WIN) | 15 #if defined(OS_WIN) |
15 #include <windows.h> | 16 #include <windows.h> |
16 #endif | 17 #endif |
17 | 18 |
18 class SkBaseDevice; | 19 class SkBaseDevice; |
19 | 20 |
20 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) | 21 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) |
21 namespace base { | 22 namespace base { |
22 struct FileDescriptor; | 23 struct FileDescriptor; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 virtual bool Playback(gfx::NativeDrawingContext hdc, | 56 virtual bool Playback(gfx::NativeDrawingContext hdc, |
56 const RECT* rect) const override; | 57 const RECT* rect) const override; |
57 virtual bool SafePlayback(gfx::NativeDrawingContext hdc) const override; | 58 virtual bool SafePlayback(gfx::NativeDrawingContext hdc) const override; |
58 #elif defined(OS_MACOSX) | 59 #elif defined(OS_MACOSX) |
59 bool RenderPage(unsigned int page_number, | 60 bool RenderPage(unsigned int page_number, |
60 gfx::NativeDrawingContext context, | 61 gfx::NativeDrawingContext context, |
61 const CGRect rect, | 62 const CGRect rect, |
62 const MacRenderPageParams& params) const override; | 63 const MacRenderPageParams& params) const override; |
63 #endif | 64 #endif |
64 | 65 |
| 66 bool SaveTo(base::File* file) const override; |
| 67 |
65 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) | 68 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) |
66 // TODO(vitalybuka): replace with SaveTo(). | 69 // TODO(vitalybuka): replace with SaveTo(). |
67 bool SaveToFD(const base::FileDescriptor& fd) const; | 70 bool SaveToFD(const base::FileDescriptor& fd) const; |
68 #endif // if defined(OS_CHROMEOS) || defined(OS_ANDROID) | 71 #endif // if defined(OS_CHROMEOS) || defined(OS_ANDROID) |
69 | 72 |
70 // 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. |
71 scoped_ptr<PdfMetafileSkia> GetMetafileForCurrentPage(); | 74 scoped_ptr<PdfMetafileSkia> GetMetafileForCurrentPage(); |
72 | 75 |
73 // This method calls StartPage and then returns an appropriate | 76 // This method calls StartPage and then returns an appropriate |
74 // VectorPlatformDevice implementation bound to the context created by | 77 // VectorCanvas implementation bound to the context created by |
75 // StartPage or NULL on error. | 78 // StartPage or NULL on error. The skia::VectorCanvas pointer that |
76 SkBaseDevice* StartPageForVectorCanvas(const gfx::Size& page_size, | 79 // is returned is owned by this PdfMetafileSkia object and does not |
77 const gfx::Rect& content_area, | 80 // need to be ref()ed or unref()ed. The canvas will remain valid |
78 const float& scale_factor); | 81 // until FinishPage() or FinishDocument() is called. |
| 82 skia::VectorCanvas* GetVectorCanvasForNewPage(const gfx::Size& page_size, |
| 83 const gfx::Rect& content_area, |
| 84 const float& scale_factor); |
| 85 |
79 private: | 86 private: |
80 scoped_ptr<PdfMetafileSkiaData> data_; | 87 scoped_ptr<PdfMetafileSkiaData> data_; |
81 | 88 |
82 // True when finish page is outstanding for current page. | |
83 bool page_outstanding_; | |
84 | |
85 DISALLOW_COPY_AND_ASSIGN(PdfMetafileSkia); | 89 DISALLOW_COPY_AND_ASSIGN(PdfMetafileSkia); |
86 }; | 90 }; |
87 | 91 |
88 } // namespace printing | 92 } // namespace printing |
89 | 93 |
90 #endif // PRINTING_PDF_METAFILE_SKIA_H_ | 94 #endif // PRINTING_PDF_METAFILE_SKIA_H_ |
OLD | NEW |