| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "mojo/services/gles2/command_buffer_type_conversions.h" | 5 #include "mojo/services/gles2/command_buffer_type_conversions.h" |
| 6 | 6 |
| 7 #include <string.h> | |
| 8 | |
| 9 #include "mojo/services/gles2/command_buffer.mojom.h" | 7 #include "mojo/services/gles2/command_buffer.mojom.h" |
| 10 | 8 |
| 11 namespace mojo { | 9 namespace mojo { |
| 12 | 10 |
| 13 COMPILE_ASSERT(sizeof(base::SharedMemoryHandle) <= sizeof(uint64_t), | |
| 14 mojo_ShmHandle_too_small_for_base_SharedMemoryHandle); | |
| 15 | |
| 16 ShmHandle TypeConverter<ShmHandle, base::SharedMemoryHandle>::ConvertFrom( | |
| 17 const base::SharedMemoryHandle& input, | |
| 18 Buffer* buffer) { | |
| 19 ShmHandle::Builder result(buffer); | |
| 20 uint64_t handle = 0; | |
| 21 memcpy(&handle, &input, sizeof(input)); | |
| 22 result.set_handle_hack(handle); | |
| 23 return result.Finish(); | |
| 24 } | |
| 25 | |
| 26 base::SharedMemoryHandle | |
| 27 TypeConverter<ShmHandle, base::SharedMemoryHandle>::ConvertTo( | |
| 28 const ShmHandle& input) { | |
| 29 base::SharedMemoryHandle output; | |
| 30 uint64_t handle = input.handle_hack(); | |
| 31 memcpy(&output, &handle, sizeof(output)); | |
| 32 return output; | |
| 33 } | |
| 34 | |
| 35 CommandBufferState | 11 CommandBufferState |
| 36 TypeConverter<CommandBufferState, gpu::CommandBuffer::State>::ConvertFrom( | 12 TypeConverter<CommandBufferState, gpu::CommandBuffer::State>::ConvertFrom( |
| 37 const gpu::CommandBuffer::State& input, | 13 const gpu::CommandBuffer::State& input, |
| 38 Buffer* buffer) { | 14 Buffer* buffer) { |
| 39 CommandBufferState::Builder result(buffer); | 15 CommandBufferState::Builder result(buffer); |
| 40 result.set_num_entries(input.num_entries); | 16 result.set_num_entries(input.num_entries); |
| 41 result.set_get_offset(input.get_offset); | 17 result.set_get_offset(input.get_offset); |
| 42 result.set_put_offset(input.put_offset); | 18 result.set_put_offset(input.put_offset); |
| 43 result.set_token(input.token); | 19 result.set_token(input.token); |
| 44 result.set_error(input.error); | 20 result.set_error(input.error); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 56 state.put_offset = input.put_offset(); | 32 state.put_offset = input.put_offset(); |
| 57 state.token = input.token(); | 33 state.token = input.token(); |
| 58 state.error = static_cast<gpu::error::Error>(input.error()); | 34 state.error = static_cast<gpu::error::Error>(input.error()); |
| 59 state.context_lost_reason = | 35 state.context_lost_reason = |
| 60 static_cast<gpu::error::ContextLostReason>(input.context_lost_reason()); | 36 static_cast<gpu::error::ContextLostReason>(input.context_lost_reason()); |
| 61 state.generation = input.generation(); | 37 state.generation = input.generation(); |
| 62 return state; | 38 return state; |
| 63 } | 39 } |
| 64 | 40 |
| 65 } // namespace mojo | 41 } // namespace mojo |
| OLD | NEW |