OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 bool isSafe = (start <= end) && (end <= this->size()); | 135 bool isSafe = (start <= end) && (end <= this->size()); |
136 ASSERT(isSafe); | 136 ASSERT(isSafe); |
137 if (!isSafe) | 137 if (!isSafe) |
138 return; | 138 return; |
139 | 139 |
140 // This expression cannot overflow because end - start cannot be | 140 // This expression cannot overflow because end - start cannot be |
141 // greater than m_size, which is safe due to the check in allocate(). | 141 // greater than m_size, which is safe due to the check in allocate(). |
142 memcpy(this->data() + start, sourceData, sizeof(T) * (end - start)); | 142 memcpy(this->data() + start, sourceData, sizeof(T) * (end - start)); |
143 } | 143 } |
144 | 144 |
145 template<typename MemoryObjectInfo> | |
146 void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const | |
147 { | |
148 typename MemoryObjectInfo::ClassInfo info(memoryObjectInfo, this); | |
149 info.addRawBuffer(m_allocation, m_size * sizeof(T), "AudioArrayData", "a
llocation"); | |
150 info.ignoreMember(m_alignedData); | |
151 } | |
152 | |
153 private: | 145 private: |
154 static T* alignedAddress(T* address, intptr_t alignment) | 146 static T* alignedAddress(T* address, intptr_t alignment) |
155 { | 147 { |
156 intptr_t value = reinterpret_cast<intptr_t>(address); | 148 intptr_t value = reinterpret_cast<intptr_t>(address); |
157 return reinterpret_cast<T*>((value + alignment - 1) & ~(alignment - 1)); | 149 return reinterpret_cast<T*>((value + alignment - 1) & ~(alignment - 1)); |
158 } | 150 } |
159 | 151 |
160 T* m_allocation; | 152 T* m_allocation; |
161 T* m_alignedData; | 153 T* m_alignedData; |
162 size_t m_size; | 154 size_t m_size; |
163 }; | 155 }; |
164 | 156 |
165 typedef AudioArray<float> AudioFloatArray; | 157 typedef AudioArray<float> AudioFloatArray; |
166 typedef AudioArray<double> AudioDoubleArray; | 158 typedef AudioArray<double> AudioDoubleArray; |
167 | 159 |
168 } // WebCore | 160 } // WebCore |
169 | 161 |
170 #endif // AudioArray_h | 162 #endif // AudioArray_h |
OLD | NEW |