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 "gpu/command_buffer/service/common_decoder.h" | 5 #include "gpu/command_buffer/service/common_decoder.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 | 172 |
173 CommonDecoder::Bucket* CommonDecoder::GetBucket(uint32_t bucket_id) const { | 173 CommonDecoder::Bucket* CommonDecoder::GetBucket(uint32_t bucket_id) const { |
174 BucketMap::const_iterator iter(buckets_.find(bucket_id)); | 174 BucketMap::const_iterator iter(buckets_.find(bucket_id)); |
175 return iter != buckets_.end() ? &(*iter->second) : NULL; | 175 return iter != buckets_.end() ? &(*iter->second) : NULL; |
176 } | 176 } |
177 | 177 |
178 CommonDecoder::Bucket* CommonDecoder::CreateBucket(uint32_t bucket_id) { | 178 CommonDecoder::Bucket* CommonDecoder::CreateBucket(uint32_t bucket_id) { |
179 Bucket* bucket = GetBucket(bucket_id); | 179 Bucket* bucket = GetBucket(bucket_id); |
180 if (!bucket) { | 180 if (!bucket) { |
181 bucket = new Bucket(); | 181 bucket = new Bucket(); |
182 buckets_[bucket_id] = linked_ptr<Bucket>(bucket); | 182 buckets_[bucket_id] = std::unique_ptr<Bucket>(bucket); |
183 } | 183 } |
184 return bucket; | 184 return bucket; |
185 } | 185 } |
186 | 186 |
187 namespace { | 187 namespace { |
188 | 188 |
189 // Returns the address of the first byte after a struct. | 189 // Returns the address of the first byte after a struct. |
190 template <typename T> | 190 template <typename T> |
191 const void* AddressAfterStruct(const T& pod) { | 191 const void* AddressAfterStruct(const T& pod) { |
192 return reinterpret_cast<const uint8_t*>(&pod) + sizeof(pod); | 192 return reinterpret_cast<const uint8_t*>(&pod) + sizeof(pod); |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 } | 350 } |
351 const void* src = bucket->GetData(offset, size); | 351 const void* src = bucket->GetData(offset, size); |
352 if (!src) { | 352 if (!src) { |
353 return error::kInvalidArguments; | 353 return error::kInvalidArguments; |
354 } | 354 } |
355 memcpy(data, src, size); | 355 memcpy(data, src, size); |
356 return error::kNoError; | 356 return error::kNoError; |
357 } | 357 } |
358 | 358 |
359 } // namespace gpu | 359 } // namespace gpu |
OLD | NEW |