OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "o3d/gpu_plugin/system_services/shared_memory.h" | 5 #include "o3d/gpu_plugin/system_services/shared_memory.h" |
6 | 6 |
7 namespace o3d { | 7 namespace o3d { |
8 namespace gpu_plugin { | 8 namespace gpu_plugin { |
9 | 9 |
10 SharedMemory::SharedMemory(NPP npp) | 10 SharedMemory::SharedMemory(NPP npp) |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 ptr = shared_memory_->memory(); | 58 ptr = shared_memory_->memory(); |
59 } | 59 } |
60 | 60 |
61 return true; | 61 return true; |
62 } | 62 } |
63 | 63 |
64 bool SharedMemory::SetInt32(int32 offset, int32 value) { | 64 bool SharedMemory::SetInt32(int32 offset, int32 value) { |
65 if (!ptr) | 65 if (!ptr) |
66 return false; | 66 return false; |
67 | 67 |
68 if (offset < 0 || offset + sizeof(value) >= size) | 68 if (offset < 0 || offset * sizeof(value) >= size) |
69 return false; | 69 return false; |
70 | 70 |
71 if ((offset % sizeof(value)) != 0) | 71 reinterpret_cast<int32*>(ptr)[offset] = value; |
72 return false; | |
73 | |
74 *reinterpret_cast<int32*>(static_cast<int8*>(ptr) + offset) = value; | |
75 return true; | 72 return true; |
76 } | 73 } |
77 | 74 |
| 75 bool SharedMemory::SetFloat(int32 offset, float value) { |
| 76 if (!ptr) |
| 77 return false; |
| 78 |
| 79 if (offset < 0 || offset * sizeof(value) >= size) |
| 80 return false; |
| 81 |
| 82 reinterpret_cast<float*>(ptr)[offset] = value; |
| 83 return true; |
| 84 } |
78 } // namespace gpu_plugin | 85 } // namespace gpu_plugin |
79 } // namespace o3d | 86 } // namespace o3d |
OLD | NEW |