| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef PRINTING_NATIVE_METAFILE_LINUX_H_ | |
| 6 #define PRINTING_NATIVE_METAFILE_LINUX_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 | |
| 10 typedef struct _cairo_surface cairo_surface_t; | |
| 11 typedef struct _cairo cairo_t; | |
| 12 | |
| 13 namespace base { | |
| 14 struct FileDescriptor; | |
| 15 } | |
| 16 | |
| 17 class FilePath; | |
| 18 | |
| 19 namespace printing { | |
| 20 | |
| 21 // This class is used to generate a PDF stream and to store rendering results | |
| 22 // in a string buffer. | |
| 23 class NativeMetafile { | |
| 24 public: | |
| 25 virtual ~NativeMetafile() {} | |
| 26 | |
| 27 // Initializes to a fresh new metafile. Returns true on success. | |
| 28 // Note: It should only be called from the renderer process to allocate | |
| 29 // rendering resources. | |
| 30 virtual bool Init() = 0; | |
| 31 | |
| 32 // Initializes a copy of metafile from PDF stream data. | |
| 33 // Returns true on success. | |
| 34 // |src_buffer| should point to the shared memory which stores PDF | |
| 35 // contents generated in the renderer. | |
| 36 // Note: It should only be called from the browser process to initialize | |
| 37 // |data_|. | |
| 38 virtual bool Init(const void* src_buffer, uint32 src_buffer_size) = 0; | |
| 39 | |
| 40 // Sets raw PDF data for the document. This is used when a cairo drawing | |
| 41 // surface has already been created. This method will cause all subsequent | |
| 42 // drawing on the surface to be discarded (in Close()). If Init() has not yet | |
| 43 // been called this method simply calls the second version of Init. | |
| 44 virtual bool SetRawData(const void* src_buffer, uint32 src_buffer_size) = 0; | |
| 45 | |
| 46 // Prepares a new cairo surface/context for rendering a new page. | |
| 47 // The unit is in point (=1/72 in). | |
| 48 // Returns NULL when failed. | |
| 49 virtual cairo_t* StartPage(double width_in_points, | |
| 50 double height_in_points, | |
| 51 double margin_top_in_points, | |
| 52 double margin_right_in_points, | |
| 53 double margin_bottom_in_points, | |
| 54 double margin_left_in_points) = 0; | |
| 55 | |
| 56 // Destroys the surface and the context used in rendering current page. | |
| 57 // The results of current page will be appended into buffer |data_|. | |
| 58 // Returns true on success. | |
| 59 virtual bool FinishPage() = 0; | |
| 60 | |
| 61 // Closes resulting PDF file. No further rendering is allowed. | |
| 62 virtual void Close() = 0; | |
| 63 | |
| 64 // Returns size of PDF contents stored in buffer |data_|. | |
| 65 // This function should ONLY be called after PDF file is closed. | |
| 66 virtual uint32 GetDataSize() const = 0; | |
| 67 | |
| 68 // Copies PDF contents stored in buffer |data_| into |dst_buffer|. | |
| 69 // This function should ONLY be called after PDF file is closed. | |
| 70 // Returns true only when success. | |
| 71 virtual bool GetData(void* dst_buffer, uint32 dst_buffer_size) const = 0; | |
| 72 | |
| 73 // Saves PDF contents stored in buffer |data_| into the file | |
| 74 // associated with |fd|. | |
| 75 // This function should ONLY be called after PDF file is closed. | |
| 76 virtual bool SaveTo(const base::FileDescriptor& fd) const = 0; | |
| 77 }; | |
| 78 | |
| 79 } // namespace printing | |
| 80 | |
| 81 #endif // PRINTING_NATIVE_METAFILE_LINUX_H_ | |
| OLD | NEW |