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

Side by Side Diff: cc/quads/list_container_unittest.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, 2 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/quads/list_container.cc ('k') | cc/quads/render_pass.h » ('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 #include "cc/quads/list_container.h" 5 #include "cc/quads/list_container.h"
6 6
7 #include <vector> 7 #include <vector>
8 #include "cc/quads/draw_quad.h" 8 #include "cc/quads/draw_quad.h"
9 #include "cc/quads/largest_draw_quad.h" 9 #include "cc/quads/largest_draw_quad.h"
10 #include "cc/quads/render_pass_draw_quad.h" 10 #include "cc/quads/render_pass_draw_quad.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 testing::InSequence s; 129 testing::InSequence s;
130 EXPECT_CALL(*dq_1, Destruct()); 130 EXPECT_CALL(*dq_1, Destruct());
131 EXPECT_CALL(separator, Call()); 131 EXPECT_CALL(separator, Call());
132 EXPECT_CALL(*dq_1, Destruct()).Times(0); 132 EXPECT_CALL(*dq_1, Destruct()).Times(0);
133 } 133 }
134 134
135 list.EraseAndInvalidateAllPointers(list.begin()); 135 list.EraseAndInvalidateAllPointers(list.begin());
136 separator.Call(); 136 separator.Call();
137 } 137 }
138 138
139 TEST(ListContainerTest, SimpleIndexAccessSharedQuadState) {
140 ListContainer<SharedQuadState> list;
141
142 size_t size = 3;
143 SharedQuadState* sqs_1 = list.AllocateAndConstruct<SharedQuadState>();
144 SharedQuadState* sqs_2 = list.AllocateAndConstruct<SharedQuadState>();
145 SharedQuadState* sqs_3 = list.AllocateAndConstruct<SharedQuadState>();
146
147 EXPECT_EQ(size, list.size());
148 EXPECT_EQ(sqs_1, list.front());
149 EXPECT_EQ(sqs_3, list.back());
150 EXPECT_EQ(list.front(), list.ElementAt(0));
151 EXPECT_EQ(sqs_2, list.ElementAt(1));
152 EXPECT_EQ(list.back(), list.ElementAt(2));
153 }
154
139 TEST(ListContainerTest, SimpleInsertionSharedQuadState) { 155 TEST(ListContainerTest, SimpleInsertionSharedQuadState) {
140 ListContainer<SharedQuadState> list; 156 ListContainer<SharedQuadState> list;
141 157
142 size_t size = 3; 158 size_t size = 3;
143 SharedQuadState* sqs_1 = list.AllocateAndConstruct<SharedQuadState>(); 159 SharedQuadState* sqs_1 = list.AllocateAndConstruct<SharedQuadState>();
144 list.AllocateAndConstruct<SharedQuadState>(); 160 list.AllocateAndConstruct<SharedQuadState>();
145 SharedQuadState* sqs_3 = list.AllocateAndConstruct<SharedQuadState>(); 161 SharedQuadState* sqs_3 = list.AllocateAndConstruct<SharedQuadState>();
146 162
147 EXPECT_EQ(size, list.size()); 163 EXPECT_EQ(size, list.size());
148 EXPECT_EQ(sqs_1, list.front()); 164 EXPECT_EQ(sqs_1, list.front());
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 475
460 int i = 0; 476 int i = 0;
461 for (std::vector<SimpleDrawQuad*>::const_iterator sdq_iter = sdq_list.begin(); 477 for (std::vector<SimpleDrawQuad*>::const_iterator sdq_iter = sdq_list.begin();
462 sdq_iter < sdq_list.end(); 478 sdq_iter < sdq_list.end();
463 ++sdq_iter) { 479 ++sdq_iter) {
464 EXPECT_EQ(i, (*sdq_iter)->get_value()); 480 EXPECT_EQ(i, (*sdq_iter)->get_value());
465 ++i; 481 ++i;
466 } 482 }
467 } 483 }
468 484
485 TEST(ListContainerTest, SimpleManipulationWithIndexSimpleDrawQuad) {
486 ListContainer<DrawQuad> list(sizeof(kLargestDrawQuad));
487 std::vector<SimpleDrawQuad*> dq_list;
488 size_t size = 10;
489 for (size_t i = 0; i < size; ++i) {
490 dq_list.push_back(list.AllocateAndConstruct<SimpleDrawQuad>());
491 }
492 EXPECT_EQ(size, list.size());
493
494 for (size_t i = 0; i < size; ++i) {
495 static_cast<SimpleDrawQuad*>(list.ElementAt(i))->set_value(i);
496 }
497
498 int i = 0;
499 for (std::vector<SimpleDrawQuad*>::const_iterator dq_iter = dq_list.begin();
500 dq_iter != dq_list.end();
501 ++dq_iter, ++i) {
502 EXPECT_EQ(i, (*dq_iter)->get_value());
503 }
504 }
505
506 TEST(ListContainerTest,
507 SimpleManipulationWithIndexMoreThanOneAllocationSimpleDrawQuad) {
508 ListContainer<DrawQuad> list(sizeof(kLargestDrawQuad), 2);
509 std::vector<SimpleDrawQuad*> dq_list;
510 size_t size = 10;
511 for (size_t i = 0; i < size; ++i) {
512 dq_list.push_back(list.AllocateAndConstruct<SimpleDrawQuad>());
513 }
514 EXPECT_EQ(size, list.size());
515
516 for (size_t i = 0; i < size; ++i) {
517 static_cast<SimpleDrawQuad*>(list.ElementAt(i))->set_value(i);
518 }
519
520 int i = 0;
521 for (std::vector<SimpleDrawQuad*>::const_iterator dq_iter = dq_list.begin();
522 dq_iter != dq_list.end();
523 ++dq_iter, ++i) {
524 EXPECT_EQ(i, (*dq_iter)->get_value());
525 }
526 }
527
469 } // namespace 528 } // namespace
470 } // namespace cc 529 } // namespace cc
OLDNEW
« no previous file with comments | « cc/quads/list_container.cc ('k') | cc/quads/render_pass.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698