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_PDF_RENDER_SETTINGS_H_ | 5 #ifndef PRINTING_PDF_RENDER_SETTINGS_H_ |
6 #define PRINTING_PDF_RENDER_SETTINGS_H_ | 6 #define PRINTING_PDF_RENDER_SETTINGS_H_ |
7 | 7 |
8 #include "ipc/ipc_message_utils.h" | 8 #include "ipc/ipc_message_utils.h" |
9 #include "ipc/ipc_param_traits.h" | 9 #include "ipc/ipc_param_traits.h" |
10 #include "printing/printing_export.h" | 10 #include "printing/printing_export.h" |
| 11 #include "ui/gfx/geometry/point.h" |
11 #include "ui/gfx/geometry/rect.h" | 12 #include "ui/gfx/geometry/rect.h" |
12 #include "ui/gfx/ipc/geometry/gfx_param_traits.h" | 13 #include "ui/gfx/ipc/geometry/gfx_param_traits.h" |
13 #include "ui/gfx/ipc/skia/gfx_skia_param_traits.h" | 14 #include "ui/gfx/ipc/skia/gfx_skia_param_traits.h" |
14 | 15 |
15 namespace printing { | 16 namespace printing { |
16 | 17 |
17 // Defining PDF rendering settings. | 18 // Defining PDF rendering settings. |
18 struct PdfRenderSettings { | 19 struct PdfRenderSettings { |
19 PdfRenderSettings() : dpi(0), autorotate(false) {} | 20 enum class Mode : uint8_t { |
20 PdfRenderSettings(gfx::Rect area, int dpi, bool autorotate) | 21 NORMAL = 0, |
21 : area(area), dpi(dpi), autorotate(autorotate) {} | 22 #if defined(OS_WIN) |
| 23 GDI_TEXT, |
| 24 POSTSCRIPT_LEVEL2, |
| 25 POSTSCRIPT_LEVEL3, |
| 26 #endif |
| 27 }; |
| 28 |
| 29 PdfRenderSettings() : dpi(0), autorotate(false), mode(Mode::NORMAL) {} |
| 30 PdfRenderSettings(gfx::Rect area, |
| 31 gfx::Point offsets, |
| 32 int dpi, |
| 33 bool autorotate, |
| 34 Mode mode) |
| 35 : area(area), |
| 36 offsets(offsets), |
| 37 dpi(dpi), |
| 38 autorotate(autorotate), |
| 39 mode(mode) {} |
22 ~PdfRenderSettings() {} | 40 ~PdfRenderSettings() {} |
23 | 41 |
24 gfx::Rect area; | 42 gfx::Rect area; |
| 43 gfx::Point offsets; |
25 int dpi; | 44 int dpi; |
26 bool autorotate; | 45 bool autorotate; |
| 46 Mode mode; |
27 }; | 47 }; |
28 | 48 |
29 } // namespace printing | 49 } // namespace printing |
30 | 50 |
31 namespace IPC { | 51 namespace IPC { |
32 template <> | 52 template <> |
33 struct ParamTraits<printing::PdfRenderSettings> { | 53 struct ParamTraits<printing::PdfRenderSettings> { |
34 typedef printing::PdfRenderSettings param_type; | 54 using param_type = printing::PdfRenderSettings; |
35 static void Write(base::Pickle* m, const param_type& p) { | 55 static void Write(base::Pickle* m, const param_type& p) { |
36 WriteParam(m, p.area); | 56 WriteParam(m, p.area); |
| 57 WriteParam(m, p.offsets); |
37 WriteParam(m, p.dpi); | 58 WriteParam(m, p.dpi); |
38 WriteParam(m, p.autorotate); | 59 WriteParam(m, p.autorotate); |
| 60 WriteParam(m, static_cast<uint8_t>(p.mode)); |
39 } | 61 } |
40 | 62 |
41 static bool Read(const base::Pickle* m, | 63 static bool Read(const base::Pickle* m, |
42 base::PickleIterator* iter, | 64 base::PickleIterator* iter, |
43 param_type* r) { | 65 param_type* r) { |
44 return ReadParam(m, iter, &r->area) && | 66 uint8_t mode = 0; |
45 ReadParam(m, iter, &r->dpi) && | 67 bool ret = ReadParam(m, iter, &r->area) && |
46 ReadParam(m, iter, &r->autorotate); | 68 ReadParam(m, iter, &r->offsets) && ReadParam(m, iter, &r->dpi) && |
| 69 ReadParam(m, iter, &r->autorotate) && ReadParam(m, iter, &mode); |
| 70 if (ret) |
| 71 r->mode = static_cast<printing::PdfRenderSettings::Mode>(mode); |
| 72 return ret; |
47 } | 73 } |
48 | 74 |
49 static void Log(const param_type& p, std::string* l) { | 75 static void Log(const param_type& p, std::string* l) { |
50 LogParam(p.area, l); | 76 LogParam(p.area, l); |
51 l->append(", "); | 77 l->append(", "); |
| 78 LogParam(p.offsets, l); |
| 79 l->append(", "); |
52 LogParam(p.dpi, l); | 80 LogParam(p.dpi, l); |
53 l->append(", "); | 81 l->append(", "); |
54 LogParam(p.autorotate, l); | 82 LogParam(p.autorotate, l); |
| 83 l->append(", "); |
| 84 LogParam(static_cast<uint8_t>(p.mode), l); |
55 } | 85 } |
56 }; | 86 }; |
57 | 87 |
58 } // namespace IPC | 88 } // namespace IPC |
59 | 89 |
60 #endif // PRINTING_PDF_RENDER_SETTINGS_H_ | 90 #endif // PRINTING_PDF_RENDER_SETTINGS_H_ |
OLD | NEW |