| 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 #ifndef GPU_IPC_GPU_PARAM_TRAITS_H_ | 5 #ifndef GPU_IPC_COMMON_GPU_COMMAND_BUFFER_TRAITS_H_ |
| 6 #define GPU_IPC_GPU_PARAM_TRAITS_H_ | 6 #define GPU_IPC_COMMON_GPU_COMMAND_BUFFER_TRAITS_H_ |
| 7 | 7 |
| 8 #include "gpu/command_buffer/common/command_buffer.h" | 8 #include "gpu/command_buffer/common/command_buffer.h" |
| 9 #include "gpu/command_buffer/common/id_type.h" |
| 9 #include "gpu/gpu_export.h" | 10 #include "gpu/gpu_export.h" |
| 10 #include "gpu/ipc/common/gpu_command_buffer_traits_multi.h" | 11 #include "gpu/ipc/common/gpu_command_buffer_traits_multi.h" |
| 11 #include "gpu/ipc/common/id_type_traits.h" | |
| 12 #include "ipc/ipc_message_utils.h" | 12 #include "ipc/ipc_message_utils.h" |
| 13 #include "ipc/ipc_param_traits.h" |
| 13 | 14 |
| 14 namespace gpu { | 15 namespace gpu { |
| 15 struct Mailbox; | 16 struct Mailbox; |
| 16 struct MailboxHolder; | 17 struct MailboxHolder; |
| 17 struct SyncToken; | 18 struct SyncToken; |
| 18 } | 19 } |
| 19 | 20 |
| 20 namespace IPC { | 21 namespace IPC { |
| 21 | 22 |
| 22 template <> | 23 template <> |
| 23 struct GPU_EXPORT ParamTraits<gpu::CommandBuffer::State> { | 24 struct GPU_EXPORT ParamTraits<gpu::CommandBuffer::State> { |
| 24 typedef gpu::CommandBuffer::State param_type; | 25 using param_type = gpu::CommandBuffer::State; |
| 25 static void GetSize(base::PickleSizer* s, const param_type& p); | 26 static void GetSize(base::PickleSizer* s, const param_type& p); |
| 26 static void Write(base::Pickle* m, const param_type& p); | 27 static void Write(base::Pickle* m, const param_type& p); |
| 27 static bool Read(const base::Pickle* m, | 28 static bool Read(const base::Pickle* m, |
| 28 base::PickleIterator* iter, | 29 base::PickleIterator* iter, |
| 29 param_type* p); | 30 param_type* p); |
| 30 static void Log(const param_type& p, std::string* l); | 31 static void Log(const param_type& p, std::string* l); |
| 31 }; | 32 }; |
| 32 | 33 |
| 33 template <> | 34 template <> |
| 34 struct GPU_EXPORT ParamTraits<gpu::SyncToken> { | 35 struct GPU_EXPORT ParamTraits<gpu::SyncToken> { |
| 35 typedef gpu::SyncToken param_type; | 36 using param_type = gpu::SyncToken; |
| 36 static void GetSize(base::PickleSizer* s, const param_type& p); | 37 static void GetSize(base::PickleSizer* s, const param_type& p); |
| 37 static void Write(base::Pickle* m, const param_type& p); | 38 static void Write(base::Pickle* m, const param_type& p); |
| 38 static bool Read(const base::Pickle* m, | 39 static bool Read(const base::Pickle* m, |
| 39 base::PickleIterator* iter, | 40 base::PickleIterator* iter, |
| 40 param_type* p); | 41 param_type* p); |
| 41 static void Log(const param_type& p, std::string* l); | 42 static void Log(const param_type& p, std::string* l); |
| 42 }; | 43 }; |
| 43 | 44 |
| 44 template<> | 45 template<> |
| 45 struct GPU_EXPORT ParamTraits<gpu::Mailbox> { | 46 struct GPU_EXPORT ParamTraits<gpu::Mailbox> { |
| 46 typedef gpu::Mailbox param_type; | 47 using param_type = gpu::Mailbox; |
| 47 static void GetSize(base::PickleSizer* s, const param_type& p); | 48 static void GetSize(base::PickleSizer* s, const param_type& p); |
| 48 static void Write(base::Pickle* m, const param_type& p); | 49 static void Write(base::Pickle* m, const param_type& p); |
| 49 static bool Read(const base::Pickle* m, | 50 static bool Read(const base::Pickle* m, |
| 50 base::PickleIterator* iter, | 51 base::PickleIterator* iter, |
| 51 param_type* p); | 52 param_type* p); |
| 52 static void Log(const param_type& p, std::string* l); | 53 static void Log(const param_type& p, std::string* l); |
| 53 }; | 54 }; |
| 54 | 55 |
| 55 template <> | 56 template <> |
| 56 struct GPU_EXPORT ParamTraits<gpu::MailboxHolder> { | 57 struct GPU_EXPORT ParamTraits<gpu::MailboxHolder> { |
| 57 typedef gpu::MailboxHolder param_type; | 58 using param_type = gpu::MailboxHolder; |
| 58 static void GetSize(base::PickleSizer* s, const param_type& p); | 59 static void GetSize(base::PickleSizer* s, const param_type& p); |
| 59 static void Write(base::Pickle* m, const param_type& p); | 60 static void Write(base::Pickle* m, const param_type& p); |
| 60 static bool Read(const base::Pickle* m, | 61 static bool Read(const base::Pickle* m, |
| 61 base::PickleIterator* iter, | 62 base::PickleIterator* iter, |
| 62 param_type* p); | 63 param_type* p); |
| 63 static void Log(const param_type& p, std::string* l); | 64 static void Log(const param_type& p, std::string* l); |
| 64 }; | 65 }; |
| 65 | 66 |
| 67 template <typename TypeMarker, typename WrappedType, WrappedType kInvalidValue> |
| 68 struct ParamTraits<gpu::IdType<TypeMarker, WrappedType, kInvalidValue>> { |
| 69 using param_type = gpu::IdType<TypeMarker, WrappedType, kInvalidValue>; |
| 70 static void GetSize(base::PickleSizer* sizer, const param_type& p) { |
| 71 GetParamSize(sizer, p.GetUnsafeValue()); |
| 72 } |
| 73 static void Write(base::Pickle* m, const param_type& p) { |
| 74 WriteParam(m, p.GetUnsafeValue()); |
| 75 } |
| 76 static bool Read(const base::Pickle* m, |
| 77 base::PickleIterator* iter, |
| 78 param_type* r) { |
| 79 WrappedType value; |
| 80 if (!ReadParam(m, iter, &value)) |
| 81 return false; |
| 82 *r = param_type::FromUnsafeValue(value); |
| 83 return true; |
| 84 } |
| 85 static void Log(const param_type& p, std::string* l) { |
| 86 LogParam(p.GetUnsafeValue(), l); |
| 87 } |
| 88 }; |
| 89 |
| 66 } // namespace IPC | 90 } // namespace IPC |
| 67 | 91 |
| 68 #endif // GPU_IPC_GPU_PARAM_TRAITS_H_ | 92 #endif // GPU_IPC_COMMON_GPU_COMMAND_BUFFER_TRAITS_H_ |
| OLD | NEW |