| 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 #ifndef CC_QUADS_LIST_CONTAINER_H_ | 5 #ifndef CC_QUADS_LIST_CONTAINER_H_ |
| 6 #define CC_QUADS_LIST_CONTAINER_H_ | 6 #define CC_QUADS_LIST_CONTAINER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "cc/base/cc_export.h" | 10 #include "cc/base/cc_export.h" |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 DerivedElementType* AllocateAndConstruct() { | 202 DerivedElementType* AllocateAndConstruct() { |
| 203 return new (Allocate(sizeof(DerivedElementType))) DerivedElementType; | 203 return new (Allocate(sizeof(DerivedElementType))) DerivedElementType; |
| 204 } | 204 } |
| 205 // Take in derived element type and copy construct it at location generated by | 205 // Take in derived element type and copy construct it at location generated by |
| 206 // Allocate(). | 206 // Allocate(). |
| 207 template <typename DerivedElementType> | 207 template <typename DerivedElementType> |
| 208 DerivedElementType* AllocateAndCopyFrom(const DerivedElementType* source) { | 208 DerivedElementType* AllocateAndCopyFrom(const DerivedElementType* source) { |
| 209 return new (Allocate(sizeof(DerivedElementType))) | 209 return new (Allocate(sizeof(DerivedElementType))) |
| 210 DerivedElementType(*source); | 210 DerivedElementType(*source); |
| 211 } | 211 } |
| 212 // Construct a new element on top of an existing one. |
| 213 template <typename DerivedElementType> |
| 214 DerivedElementType* ReplaceExistingElement(Iterator at) { |
| 215 at->~BaseElementType(); |
| 216 return new (*at) DerivedElementType(); |
| 217 } |
| 212 | 218 |
| 213 size_t size() const; | 219 size_t size() const; |
| 214 bool empty() const; | 220 bool empty() const; |
| 215 void clear(); | 221 void clear(); |
| 216 | 222 |
| 217 size_t AvailableSizeWithoutAnotherAllocationForTesting() const; | 223 size_t AvailableSizeWithoutAnotherAllocationForTesting() const; |
| 218 | 224 |
| 219 private: | 225 private: |
| 220 // Hands out memory location for an element at the end of data structure. | 226 // Hands out memory location for an element at the end of data structure. |
| 221 BaseElementType* Allocate(size_t size_of_actual_element_in_bytes); | 227 BaseElementType* Allocate(size_t size_of_actual_element_in_bytes); |
| 222 | 228 |
| 223 scoped_ptr<ListContainerCharAllocator> data_; | 229 scoped_ptr<ListContainerCharAllocator> data_; |
| 224 | 230 |
| 225 DISALLOW_COPY_AND_ASSIGN(ListContainer); | 231 DISALLOW_COPY_AND_ASSIGN(ListContainer); |
| 226 }; | 232 }; |
| 227 | 233 |
| 228 #if !defined(COMPILER_MSVC) | 234 #if !defined(COMPILER_MSVC) |
| 229 extern template class ListContainer<SharedQuadState>; | 235 extern template class ListContainer<SharedQuadState>; |
| 230 extern template class ListContainer<DrawQuad>; | 236 extern template class ListContainer<DrawQuad>; |
| 231 #endif | 237 #endif |
| 232 } // namespace cc | 238 } // namespace cc |
| 233 | 239 |
| 234 #endif // CC_QUADS_LIST_CONTAINER_H_ | 240 #endif // CC_QUADS_LIST_CONTAINER_H_ |
| OLD | NEW |