| 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_NATIVE_METAFILE_H_ | 5 #ifndef PRINTING_NATIVE_METAFILE_H_ |
| 6 #define PRINTING_NATIVE_METAFILE_H_ | 6 #define PRINTING_NATIVE_METAFILE_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "ui/gfx/native_widget_types.h" | 10 #include "ui/gfx/native_widget_types.h" |
| 11 | 11 |
| 12 #if defined(OS_WIN) | 12 #if defined(OS_WIN) |
| 13 #include <windows.h> | 13 #include <windows.h> |
| 14 #include <vector> | 14 #include <vector> |
| 15 #elif defined(OS_MACOSX) | 15 #elif defined(OS_MACOSX) |
| 16 #include <ApplicationServices/ApplicationServices.h> | 16 #include <ApplicationServices/ApplicationServices.h> |
| 17 #include <CoreFoundation/CoreFoundation.h> | 17 #include <CoreFoundation/CoreFoundation.h> |
| 18 #include "base/mac/scoped_cftyperef.h" | 18 #include "base/mac/scoped_cftyperef.h" |
| 19 #endif | 19 #endif |
| 20 | 20 |
| 21 class FilePath; | 21 class FilePath; |
| 22 | 22 |
| 23 namespace gfx { | 23 namespace gfx { |
| 24 class Point; | 24 class Point; |
| 25 class Rect; | 25 class Rect; |
| 26 class Size; | 26 class Size; |
| 27 } | 27 } |
| 28 | 28 |
| 29 namespace skia { | |
| 30 class PlatformDevice; | |
| 31 } | |
| 32 | |
| 33 #if defined(OS_CHROMEOS) | 29 #if defined(OS_CHROMEOS) |
| 34 namespace base { | 30 namespace base { |
| 35 class FileDescriptor; | 31 class FileDescriptor; |
| 36 } | 32 } |
| 37 #endif | 33 #endif |
| 38 | 34 |
| 39 namespace printing { | 35 namespace printing { |
| 40 | 36 |
| 41 // This class creates a graphics context that renders into a data stream | 37 // This class creates a graphics context that renders into a data stream |
| 42 // (usually PDF or EMF). | 38 // (usually PDF or EMF). |
| 43 class NativeMetafile { | 39 class NativeMetafile { |
| 44 public: | 40 public: |
| 45 virtual ~NativeMetafile() {} | 41 virtual ~NativeMetafile() {} |
| 46 | 42 |
| 47 // Initializes a fresh new metafile for rendering. Returns false on failure. | 43 // Initializes a fresh new metafile for rendering. Returns false on failure. |
| 48 // Note: It should only be called from within the renderer process to allocate | 44 // Note: It should only be called from within the renderer process to allocate |
| 49 // rendering resources. | 45 // rendering resources. |
| 50 virtual bool Init() = 0; | 46 virtual bool Init() = 0; |
| 51 | 47 |
| 52 // Initializes the metafile with the data in |src_buffer|. Returns true | 48 // Initializes the metafile with the data in |src_buffer|. Returns true |
| 53 // on success. | 49 // on success. |
| 54 // Note: It should only be called from within the browser process. | 50 // Note: It should only be called from within the browser process. |
| 55 virtual bool InitFromData(const void* src_buffer, uint32 src_buffer_size) = 0; | 51 virtual bool InitFromData(const void* src_buffer, uint32 src_buffer_size) = 0; |
| 56 | 52 |
| 57 // This method calls StartPage and then returns an appropriate | |
| 58 // VectorPlatformDevice implementation bound to the context created by | |
| 59 // StartPage or NULL on error. | |
| 60 virtual skia::PlatformDevice* StartPageForVectorCanvas( | |
| 61 const gfx::Size& page_size, const gfx::Point& content_origin, | |
| 62 const float& scale_factor) = 0; | |
| 63 | |
| 64 // Prepares a context for rendering a new page at the specified | 53 // Prepares a context for rendering a new page at the specified |
| 65 // |content_origin| with the given |page_size| and a |scale_factor| to use for | 54 // |content_origin| with the given |page_size| and a |scale_factor| to use for |
| 66 // the drawing. The units are in points (=1/72 in). Returns true on success. | 55 // the drawing. The units are in points (=1/72 in). Returns true on success. |
| 67 virtual bool StartPage(const gfx::Size& page_size, | 56 virtual bool StartPage(const gfx::Size& page_size, |
| 68 const gfx::Point& content_origin, | 57 const gfx::Point& content_origin, |
| 69 const float& scale_factor) = 0; | 58 const float& scale_factor) = 0; |
| 70 | 59 |
| 71 // Closes the current page and destroys the context used in rendering that | 60 // Closes the current page and destroys the context used in rendering that |
| 72 // page. The results of current page will be appended into the underlying | 61 // page. The results of current page will be appended into the underlying |
| 73 // data stream. Returns true on success. | 62 // data stream. Returns true on success. |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 // Returns true if writing succeeded. | 166 // Returns true if writing succeeded. |
| 178 virtual bool SaveToFD(const base::FileDescriptor& fd) const = 0; | 167 virtual bool SaveToFD(const base::FileDescriptor& fd) const = 0; |
| 179 #endif // if defined(OS_CHROMEOS) | 168 #endif // if defined(OS_CHROMEOS) |
| 180 | 169 |
| 181 #endif | 170 #endif |
| 182 }; | 171 }; |
| 183 | 172 |
| 184 } // namespace printing | 173 } // namespace printing |
| 185 | 174 |
| 186 #endif // PRINTING_NATIVE_METAFILE_H_ | 175 #endif // PRINTING_NATIVE_METAFILE_H_ |
| OLD | NEW |