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

Unified Diff: cc/quads/list_container.cc

Issue 448303002: Use custom ListContainer to allocate DrawQuads (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@perftest
Patch Set: change header files to try fix compile error 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/quads/list_container.h ('k') | cc/quads/list_container_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/quads/list_container.cc
diff --git a/cc/quads/list_container.cc b/cc/quads/list_container.cc
index 5d092a113e8502e9c34286a1a326ae8b672028e3..b1501c0de862d50c4164849daa18a1709fcf32b7 100644
--- a/cc/quads/list_container.cc
+++ b/cc/quads/list_container.cc
@@ -68,6 +68,7 @@ class ListContainer<BaseElementType>::ListContainerCharAllocator {
char* Begin() const { return data.get(); }
char* End() const { return data.get() + size * step; }
char* LastElement() const { return data.get() + (size - 1) * step; }
+ char* ElementAt(size_t index) const { return data.get() + index * step; }
private:
DISALLOW_COPY_AND_ASSIGN(InnerList);
@@ -373,6 +374,37 @@ const BaseElementType* ListContainer<BaseElementType>::back() const {
}
template <typename BaseElementType>
+const BaseElementType* ListContainer<BaseElementType>::ElementAt(
+ size_t index) const {
+ DCHECK_LT(index, size());
+ size_t list_index;
+ for (list_index = 0; list_index < data_->list_count(); ++list_index) {
+ size_t current_size = data_->InnerListById(list_index)->size;
+ if (index < current_size)
+ break;
+ index -= current_size;
+ }
+ return &*ConstIterator(data_.get(),
+ list_index,
+ data_->InnerListById(list_index)->ElementAt(index));
+}
+
+template <typename BaseElementType>
+BaseElementType* ListContainer<BaseElementType>::ElementAt(size_t index) {
+ DCHECK_LT(index, size());
+ size_t list_index;
+ for (list_index = 0; list_index < data_->list_count(); ++list_index) {
+ size_t current_size = data_->InnerListById(list_index)->size;
+ if (index < current_size)
+ break;
+ index -= current_size;
+ }
+ return &*Iterator(data_.get(),
+ list_index,
+ data_->InnerListById(list_index)->ElementAt(index));
+}
+
+template <typename BaseElementType>
BaseElementType* ListContainer<BaseElementType>::Allocate(
size_t size_of_actual_element_in_bytes) {
DCHECK_LE(size_of_actual_element_in_bytes, data_->element_size());
« no previous file with comments | « cc/quads/list_container.h ('k') | cc/quads/list_container_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698