[email protected] | da00dc1 | 2011-10-06 21:39:26 | [diff] [blame] | 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_PDF_RENDER_SETTINGS_H_ |
| 6 | #define PRINTING_PDF_RENDER_SETTINGS_H_ |
| 7 | |
tzik | 904f1945 | 2015-11-18 20:34:55 | [diff] [blame] | 8 | #include "ipc/ipc_message_utils.h" |
[email protected] | da00dc1 | 2011-10-06 21:39:26 | [diff] [blame] | 9 | #include "ipc/ipc_param_traits.h" |
| 10 | #include "printing/printing_export.h" |
tfarina | 3b0452d | 2014-12-31 15:20:09 | [diff] [blame] | 11 | #include "ui/gfx/geometry/rect.h" |
tzik | 904f1945 | 2015-11-18 20:34:55 | [diff] [blame] | 12 | #include "ui/gfx/ipc/gfx_param_traits.h" |
markdittmer | 99d77bf | 2016-03-31 19:03:24 | [diff] [blame^] | 13 | #include "ui/gfx/ipc/skia/gfx_skia_param_traits.h" |
[email protected] | da00dc1 | 2011-10-06 21:39:26 | [diff] [blame] | 14 | |
| 15 | namespace printing { |
| 16 | |
tzik | 904f1945 | 2015-11-18 20:34:55 | [diff] [blame] | 17 | // Defining PDF rendering settings. |
| 18 | class PdfRenderSettings { |
[email protected] | da00dc1 | 2011-10-06 21:39:26 | [diff] [blame] | 19 | public: |
tzik | 904f1945 | 2015-11-18 20:34:55 | [diff] [blame] | 20 | PdfRenderSettings() {} |
[email protected] | da00dc1 | 2011-10-06 21:39:26 | [diff] [blame] | 21 | PdfRenderSettings(gfx::Rect area, int dpi, bool autorotate) |
tzik | 904f1945 | 2015-11-18 20:34:55 | [diff] [blame] | 22 | : area_(area), dpi_(dpi), autorotate_(autorotate) {} |
[email protected] | da00dc1 | 2011-10-06 21:39:26 | [diff] [blame] | 23 | ~PdfRenderSettings() {} |
| 24 | |
tzik | 904f1945 | 2015-11-18 20:34:55 | [diff] [blame] | 25 | const gfx::Rect& area() const { return area_; } |
| 26 | int dpi() const { return dpi_; } |
| 27 | bool autorotate() const { return autorotate_; } |
| 28 | |
| 29 | gfx::Rect area_; |
| 30 | int dpi_; |
| 31 | bool autorotate_; |
[email protected] | da00dc1 | 2011-10-06 21:39:26 | [diff] [blame] | 32 | }; |
| 33 | |
| 34 | } // namespace printing |
| 35 | |
| 36 | namespace IPC { |
| 37 | template <> |
tzik | 904f1945 | 2015-11-18 20:34:55 | [diff] [blame] | 38 | struct ParamTraits<printing::PdfRenderSettings> { |
| 39 | typedef printing::PdfRenderSettings param_type; |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame] | 40 | static void Write(base::Pickle* m, const param_type& p) { |
tzik | 904f1945 | 2015-11-18 20:34:55 | [diff] [blame] | 41 | WriteParam(m, p.area_); |
| 42 | WriteParam(m, p.dpi_); |
| 43 | WriteParam(m, p.autorotate_); |
| 44 | } |
| 45 | |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame] | 46 | static bool Read(const base::Pickle* m, |
| 47 | base::PickleIterator* iter, |
tzik | 904f1945 | 2015-11-18 20:34:55 | [diff] [blame] | 48 | param_type* r) { |
| 49 | return ReadParam(m, iter, &r->area_) && |
| 50 | ReadParam(m, iter, &r->dpi_) && |
| 51 | ReadParam(m, iter, &r->autorotate_); |
| 52 | } |
| 53 | |
| 54 | static void Log(const param_type& p, std::string* l) { |
| 55 | LogParam(p.area_, l); |
| 56 | l->append(", "); |
| 57 | LogParam(p.dpi_, l); |
| 58 | l->append(", "); |
| 59 | LogParam(p.autorotate_, l); |
| 60 | } |
[email protected] | da00dc1 | 2011-10-06 21:39:26 | [diff] [blame] | 61 | }; |
| 62 | |
| 63 | } // namespace IPC |
| 64 | |
| 65 | #endif // PRINTING_PDF_RENDER_SETTINGS_H_ |