| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "cc/ipc/cc_param_traits.h" | 5 #include "cc/ipc/cc_param_traits.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/numerics/safe_conversions.h" | 10 #include "base/numerics/safe_conversions.h" |
| (...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 } | 711 } |
| 712 | 712 |
| 713 void ParamTraits<cc::SurfaceId>::Log(const param_type& p, std::string* l) { | 713 void ParamTraits<cc::SurfaceId>::Log(const param_type& p, std::string* l) { |
| 714 l->append("SurfaceId("); | 714 l->append("SurfaceId("); |
| 715 LogParam(p.frame_sink_id(), l); | 715 LogParam(p.frame_sink_id(), l); |
| 716 l->append(", "); | 716 l->append(", "); |
| 717 LogParam(p.local_surface_id(), l); | 717 LogParam(p.local_surface_id(), l); |
| 718 l->append(")"); | 718 l->append(")"); |
| 719 } | 719 } |
| 720 | 720 |
| 721 void ParamTraits<cc::SurfaceInfo>::GetSize(base::PickleSizer* s, |
| 722 const param_type& p) { |
| 723 GetParamSize(s, p.id()); |
| 724 GetParamSize(s, p.device_scale_factor()); |
| 725 GetParamSize(s, p.size_in_pixels()); |
| 726 } |
| 727 |
| 728 void ParamTraits<cc::SurfaceInfo>::Write(base::Pickle* m, const param_type& p) { |
| 729 WriteParam(m, p.id()); |
| 730 WriteParam(m, p.device_scale_factor()); |
| 731 WriteParam(m, p.size_in_pixels()); |
| 732 } |
| 733 |
| 734 bool ParamTraits<cc::SurfaceInfo>::Read(const base::Pickle* m, |
| 735 base::PickleIterator* iter, |
| 736 param_type* p) { |
| 737 cc::SurfaceId surface_id; |
| 738 if (!ReadParam(m, iter, &surface_id)) |
| 739 return false; |
| 740 |
| 741 float device_scale_factor; |
| 742 if (!ReadParam(m, iter, &device_scale_factor)) |
| 743 return false; |
| 744 |
| 745 gfx::Size size_in_pixels; |
| 746 if (!ReadParam(m, iter, &size_in_pixels)) |
| 747 return false; |
| 748 |
| 749 *p = cc::SurfaceInfo(surface_id, device_scale_factor, size_in_pixels); |
| 750 return p->is_valid(); |
| 751 } |
| 752 |
| 753 void ParamTraits<cc::SurfaceInfo>::Log(const param_type& p, std::string* l) { |
| 754 l->append("SurfaceInfo("); |
| 755 LogParam(p.id(), l); |
| 756 l->append(", "); |
| 757 LogParam(p.device_scale_factor(), l); |
| 758 l->append(", "); |
| 759 LogParam(p.size_in_pixels(), l); |
| 760 l->append(")"); |
| 761 } |
| 762 |
| 721 void ParamTraits<cc::CompositorFrame>::Write(base::Pickle* m, | 763 void ParamTraits<cc::CompositorFrame>::Write(base::Pickle* m, |
| 722 const param_type& p) { | 764 const param_type& p) { |
| 723 WriteParam(m, p.metadata); | 765 WriteParam(m, p.metadata); |
| 724 size_t to_reserve = 0u; | 766 size_t to_reserve = 0u; |
| 725 to_reserve += p.resource_list.size() * sizeof(cc::TransferableResource); | 767 to_reserve += p.resource_list.size() * sizeof(cc::TransferableResource); |
| 726 for (const auto& pass : p.render_pass_list) { | 768 for (const auto& pass : p.render_pass_list) { |
| 727 to_reserve += sizeof(size_t) * 2; | 769 to_reserve += sizeof(size_t) * 2; |
| 728 to_reserve += ReserveSizeForRenderPassWrite(*pass); | 770 to_reserve += ReserveSizeForRenderPassWrite(*pass); |
| 729 } | 771 } |
| 730 m->Reserve(to_reserve); | 772 m->Reserve(to_reserve); |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 940 #undef CC_IPC_CC_PARAM_TRAITS_MACROS_H_ | 982 #undef CC_IPC_CC_PARAM_TRAITS_MACROS_H_ |
| 941 #include "cc/ipc/cc_param_traits_macros.h" | 983 #include "cc/ipc/cc_param_traits_macros.h" |
| 942 } // namespace IPC | 984 } // namespace IPC |
| 943 | 985 |
| 944 // Generate param traits log methods. | 986 // Generate param traits log methods. |
| 945 #include "ipc/param_traits_log_macros.h" | 987 #include "ipc/param_traits_log_macros.h" |
| 946 namespace IPC { | 988 namespace IPC { |
| 947 #undef CC_IPC_CC_PARAM_TRAITS_MACROS_H_ | 989 #undef CC_IPC_CC_PARAM_TRAITS_MACROS_H_ |
| 948 #include "cc/ipc/cc_param_traits_macros.h" | 990 #include "cc/ipc/cc_param_traits_macros.h" |
| 949 } // namespace IPC | 991 } // namespace IPC |
| OLD | NEW |