Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(265)

Side by Side Diff: cc/quads/list_container.h

Issue 448303002: Use custom ListContainer to allocate DrawQuads (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@perftest
Patch Set: use at() for cc message unittest Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/output/software_renderer_unittest.cc ('k') | cc/quads/list_container.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 ConstIterator begin() const; 139 ConstIterator begin() const;
140 ConstIterator end() const; 140 ConstIterator end() const;
141 Iterator begin(); 141 Iterator begin();
142 Iterator end(); 142 Iterator end();
143 143
144 BaseElementType* front(); 144 BaseElementType* front();
145 BaseElementType* back(); 145 BaseElementType* back();
146 const BaseElementType* front() const; 146 const BaseElementType* front() const;
147 const BaseElementType* back() const; 147 const BaseElementType* back() const;
148 148
149 BaseElementType* at(size_t index);
danakj 2014/09/24 20:17:25 This is an O(1) thing on std::vector, which is whe
weiliangc 2014/09/24 20:26:31 Make sense. Done.
150 const BaseElementType* at(size_t index) const;
151
149 // Take in derived element type and construct it at location generated by 152 // Take in derived element type and construct it at location generated by
150 // Allocate(). 153 // Allocate().
151 template <typename DerivedElementType> 154 template <typename DerivedElementType>
152 DerivedElementType* AllocateAndConstruct() { 155 DerivedElementType* AllocateAndConstruct() {
153 DerivedElementType* result = 156 return new (Allocate(sizeof(DerivedElementType))) DerivedElementType;
154 new (Allocate(sizeof(DerivedElementType))) DerivedElementType; 157 }
155 return result; 158 // Take in derived element type and copy construct it at location generated by
159 // Allocate().
160 template <typename DerivedElementType>
161 DerivedElementType* AllocateAndCopyFrom(const DerivedElementType* source) {
162 return new (Allocate(sizeof(DerivedElementType)))
163 DerivedElementType(*source);
156 } 164 }
157 165
158 size_t size() const; 166 size_t size() const;
159 bool empty() const; 167 bool empty() const;
160 void clear(); 168 void clear();
161 169
162 size_t AvailableSizeWithoutAnotherAllocationForTesting() const; 170 size_t AvailableSizeWithoutAnotherAllocationForTesting() const;
163 171
164 private: 172 private:
165 // Hands out memory location for an element at the end of data structure. 173 // Hands out memory location for an element at the end of data structure.
166 BaseElementType* Allocate(size_t size_of_actual_element_in_bytes); 174 BaseElementType* Allocate(size_t size_of_actual_element_in_bytes);
167 175
168 scoped_ptr<ListContainerCharAllocator> data_; 176 scoped_ptr<ListContainerCharAllocator> data_;
169 177
170 DISALLOW_COPY_AND_ASSIGN(ListContainer); 178 DISALLOW_COPY_AND_ASSIGN(ListContainer);
171 }; 179 };
172 180
173 #if !defined(COMPILER_MSVC) 181 #if !defined(COMPILER_MSVC)
174 extern template class ListContainer<SharedQuadState>; 182 extern template class ListContainer<SharedQuadState>;
175 extern template class ListContainer<DrawQuad>; 183 extern template class ListContainer<DrawQuad>;
176 #endif 184 #endif
177 } // namespace cc 185 } // namespace cc
178 186
179 #endif // CC_QUADS_LIST_CONTAINER_H_ 187 #endif // CC_QUADS_LIST_CONTAINER_H_
OLDNEW
« no previous file with comments | « cc/output/software_renderer_unittest.cc ('k') | cc/quads/list_container.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698