OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "ui/gfx/ipc/color/gfx_param_traits.h" | 5 #include "ui/gfx/ipc/color/gfx_param_traits.h" |
6 | 6 |
7 #include "ui/gfx/color_space.h" | 7 #include "ui/gfx/color_space.h" |
8 #include "ui/gfx/ipc/color/gfx_param_traits_macros.h" | 8 #include "ui/gfx/ipc/color/gfx_param_traits_macros.h" |
9 | 9 |
10 namespace IPC { | 10 namespace IPC { |
11 | 11 |
12 void ParamTraits<gfx::ColorSpace>::GetSize(base::PickleSizer* s, | 12 void ParamTraits<gfx::ColorSpace>::GetSize(base::PickleSizer* s, |
13 const gfx::ColorSpace& p) { | 13 const gfx::ColorSpace& p) { |
14 GetParamSize(s, p.primaries_); | 14 GetParamSize(s, p.primaries_); |
15 GetParamSize(s, p.transfer_); | 15 GetParamSize(s, p.transfer_); |
16 GetParamSize(s, p.matrix_); | 16 GetParamSize(s, p.matrix_); |
17 GetParamSize(s, p.range_); | 17 GetParamSize(s, p.range_); |
18 GetParamSize(s, p.icc_profile_id_); | 18 GetParamSize(s, p.icc_profile_id_); |
19 if (p.primaries_ == gfx::ColorSpace::PrimaryID::CUSTOM) | 19 if (p.primaries_ == gfx::ColorSpace::PrimaryID::CUSTOM) |
20 s->AddBytes(sizeof(p.custom_primary_matrix_)); | 20 s->AddBytes(sizeof(p.custom_primary_matrix_)); |
21 if (p.transfer_ == gfx::ColorSpace::TransferID::CUSTOM) | 21 if (p.transfer_ == gfx::ColorSpace::TransferID::CUSTOM) |
22 s->AddBytes(sizeof(p.custom_transfer_params_)); | 22 s->AddBytes(sizeof(p.custom_transfer_params_)); |
23 } | 23 } |
24 | 24 |
25 void ParamTraits<gfx::ColorSpace>::Write(base::Pickle* m, | 25 void ParamTraits<gfx::ColorSpace>::Write(base::Pickle* m, |
26 const gfx::ColorSpace& p) { | 26 const gfx::ColorSpace& p) { |
27 WriteParam(m, p.primaries_); | 27 p.Serialize(m); |
28 WriteParam(m, p.transfer_); | |
29 WriteParam(m, p.matrix_); | |
30 WriteParam(m, p.range_); | |
31 WriteParam(m, p.icc_profile_id_); | |
32 if (p.primaries_ == gfx::ColorSpace::PrimaryID::CUSTOM) { | |
33 m->WriteBytes(reinterpret_cast<const char*>(p.custom_primary_matrix_), | |
34 sizeof(p.custom_primary_matrix_)); | |
35 } | |
36 if (p.transfer_ == gfx::ColorSpace::TransferID::CUSTOM) { | |
37 m->WriteBytes(reinterpret_cast<const char*>(p.custom_transfer_params_), | |
38 sizeof(p.custom_transfer_params_)); | |
39 } | |
40 } | 28 } |
41 | 29 |
42 bool ParamTraits<gfx::ColorSpace>::Read(const base::Pickle* m, | 30 bool ParamTraits<gfx::ColorSpace>::Read(const base::Pickle* m, |
43 base::PickleIterator* iter, | 31 base::PickleIterator* iter, |
44 gfx::ColorSpace* r) { | 32 gfx::ColorSpace* r) { |
45 if (!ReadParam(m, iter, &r->primaries_)) | 33 return r->ReadFromPickle(iter); |
46 return false; | |
47 if (!ReadParam(m, iter, &r->transfer_)) | |
48 return false; | |
49 if (!ReadParam(m, iter, &r->matrix_)) | |
50 return false; | |
51 if (!ReadParam(m, iter, &r->range_)) | |
52 return false; | |
53 if (!ReadParam(m, iter, &r->icc_profile_id_)) | |
54 return false; | |
55 if (r->primaries_ == gfx::ColorSpace::PrimaryID::CUSTOM) { | |
56 const char* data = nullptr; | |
57 if (!iter->ReadBytes(&data, sizeof(r->custom_primary_matrix_))) | |
58 return false; | |
59 memcpy(r->custom_primary_matrix_, data, sizeof(r->custom_primary_matrix_)); | |
60 } | |
61 if (r->transfer_ == gfx::ColorSpace::TransferID::CUSTOM) { | |
62 const char* data = nullptr; | |
63 if (!iter->ReadBytes(&data, sizeof(r->custom_transfer_params_))) | |
64 return false; | |
65 memcpy(r->custom_transfer_params_, data, | |
66 sizeof(r->custom_transfer_params_)); | |
67 } | |
68 return true; | |
69 } | 34 } |
70 | 35 |
71 void ParamTraits<gfx::ColorSpace>::Log(const gfx::ColorSpace& p, | 36 void ParamTraits<gfx::ColorSpace>::Log(const gfx::ColorSpace& p, |
72 std::string* l) { | 37 std::string* l) { |
73 l->append("<gfx::ColorSpace>"); | 38 l->append("<gfx::ColorSpace>"); |
74 } | 39 } |
75 | 40 |
76 void ParamTraits<gfx::ICCProfile>::GetSize(base::PickleSizer* s, | 41 void ParamTraits<gfx::ICCProfile>::GetSize(base::PickleSizer* s, |
77 const gfx::ICCProfile& p) { | 42 const gfx::ICCProfile& p) { |
78 GetParamSize(s, p.id_); | 43 GetParamSize(s, p.id_); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 #undef UI_GFX_IPC_COLOR_GFX_PARAM_TRAITS_MACROS_H_ | 90 #undef UI_GFX_IPC_COLOR_GFX_PARAM_TRAITS_MACROS_H_ |
126 #include "ui/gfx/ipc/color/gfx_param_traits_macros.h" | 91 #include "ui/gfx/ipc/color/gfx_param_traits_macros.h" |
127 } // namespace IPC | 92 } // namespace IPC |
128 | 93 |
129 // Generate param traits log methods. | 94 // Generate param traits log methods. |
130 #include "ipc/param_traits_log_macros.h" | 95 #include "ipc/param_traits_log_macros.h" |
131 namespace IPC { | 96 namespace IPC { |
132 #undef UI_GFX_IPC_COLOR_GFX_PARAM_TRAITS_MACROS_H_ | 97 #undef UI_GFX_IPC_COLOR_GFX_PARAM_TRAITS_MACROS_H_ |
133 #include "ui/gfx/ipc/color/gfx_param_traits_macros.h" | 98 #include "ui/gfx/ipc/color/gfx_param_traits_macros.h" |
134 } // namespace IPC | 99 } // namespace IPC |
OLD | NEW |