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

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: 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 side-by-side diff with in-line comments
Download patch
Index: cc/quads/list_container.cc
diff --git a/cc/quads/list_container.cc b/cc/quads/list_container.cc
index 5d092a113e8502e9c34286a1a326ae8b672028e3..0ee5a103e0274ef9283468a346a045e5e8f6f785 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,36 @@ const BaseElementType* ListContainer<BaseElementType>::back() const {
}
template <typename BaseElementType>
+const BaseElementType* ListContainer<BaseElementType>::at(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>::at(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());

Powered by Google App Engine
This is Rietveld 408576698