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

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

Issue 683113005: Update from chromium https://crrev.com/302282 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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.h ('k') | cc/quads/list_container_unittest.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 #include "cc/quads/list_container.h" 5 #include "cc/quads/list_container.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "cc/base/scoped_ptr_vector.h" 10 #include "cc/base/scoped_ptr_vector.h"
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 template <typename BaseElementType> 265 template <typename BaseElementType>
266 ListContainer<BaseElementType>::~ListContainer() { 266 ListContainer<BaseElementType>::~ListContainer() {
267 for (Iterator i = begin(); i != end(); ++i) { 267 for (Iterator i = begin(); i != end(); ++i) {
268 i->~BaseElementType(); 268 i->~BaseElementType();
269 } 269 }
270 } 270 }
271 271
272 template <typename BaseElementType> 272 template <typename BaseElementType>
273 void ListContainer<BaseElementType>::EraseAndInvalidateAllPointers( 273 void ListContainer<BaseElementType>::EraseAndInvalidateAllPointers(
274 typename ListContainer<BaseElementType>::Iterator position) { 274 typename ListContainer<BaseElementType>::Iterator position) {
275 BaseElementType* item = &*position; 275 BaseElementType* item = *position;
276 item->~BaseElementType(); 276 item->~BaseElementType();
277 data_->Erase(position); 277 data_->Erase(position);
278 } 278 }
279 279
280 template <typename BaseElementType> 280 template <typename BaseElementType>
281 typename ListContainer<BaseElementType>::ConstReverseIterator 281 typename ListContainer<BaseElementType>::ConstReverseIterator
282 ListContainer<BaseElementType>::crbegin() const { 282 ListContainer<BaseElementType>::crbegin() const {
283 if (data_->IsEmpty()) 283 if (data_->IsEmpty())
284 return ConstReverseIterator(data_.get(), 0, NULL, 0); 284 return ConstReverseIterator(data_.get(), 0, NULL, 0);
285 285
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 if (data_->IsEmpty()) 369 if (data_->IsEmpty())
370 return Iterator(data_.get(), 0, NULL, size()); 370 return Iterator(data_.get(), 0, NULL, size());
371 371
372 size_t last_id = data_->list_count() - 1; 372 size_t last_id = data_->list_count() - 1;
373 return Iterator(data_.get(), last_id, NULL, size()); 373 return Iterator(data_.get(), last_id, NULL, size());
374 } 374 }
375 375
376 template <typename BaseElementType> 376 template <typename BaseElementType>
377 BaseElementType* ListContainer<BaseElementType>::front() { 377 BaseElementType* ListContainer<BaseElementType>::front() {
378 Iterator iter = begin(); 378 Iterator iter = begin();
379 return &*iter; 379 return *iter;
380 } 380 }
381 381
382 template <typename BaseElementType> 382 template <typename BaseElementType>
383 BaseElementType* ListContainer<BaseElementType>::back() { 383 BaseElementType* ListContainer<BaseElementType>::back() {
384 ReverseIterator iter = rbegin(); 384 ReverseIterator iter = rbegin();
385 return &*iter; 385 return *iter;
386 } 386 }
387 387
388 template <typename BaseElementType> 388 template <typename BaseElementType>
389 const BaseElementType* ListContainer<BaseElementType>::front() const { 389 const BaseElementType* ListContainer<BaseElementType>::front() const {
390 ConstIterator iter = begin(); 390 ConstIterator iter = begin();
391 return &*iter; 391 return *iter;
392 } 392 }
393 393
394 template <typename BaseElementType> 394 template <typename BaseElementType>
395 const BaseElementType* ListContainer<BaseElementType>::back() const { 395 const BaseElementType* ListContainer<BaseElementType>::back() const {
396 ConstReverseIterator iter = rbegin(); 396 ConstReverseIterator iter = rbegin();
397 return &*iter; 397 return *iter;
398 } 398 }
399 399
400 template <typename BaseElementType> 400 template <typename BaseElementType>
401 const BaseElementType* ListContainer<BaseElementType>::ElementAt( 401 const BaseElementType* ListContainer<BaseElementType>::ElementAt(
402 size_t index) const { 402 size_t index) const {
403 DCHECK_LT(index, size()); 403 DCHECK_LT(index, size());
404 size_t original_index = index; 404 size_t original_index = index;
405 size_t list_index; 405 size_t list_index;
406 for (list_index = 0; list_index < data_->list_count(); ++list_index) { 406 for (list_index = 0; list_index < data_->list_count(); ++list_index) {
407 size_t current_size = data_->InnerListById(list_index)->size; 407 size_t current_size = data_->InnerListById(list_index)->size;
408 if (index < current_size) 408 if (index < current_size)
409 break; 409 break;
410 index -= current_size; 410 index -= current_size;
411 } 411 }
412 return &*ConstIterator(data_.get(), 412 return *ConstIterator(data_.get(),
413 list_index, 413 list_index,
414 data_->InnerListById(list_index)->ElementAt(index), 414 data_->InnerListById(list_index)->ElementAt(index),
415 original_index); 415 original_index);
416 } 416 }
417 417
418 template <typename BaseElementType> 418 template <typename BaseElementType>
419 BaseElementType* ListContainer<BaseElementType>::ElementAt(size_t index) { 419 BaseElementType* ListContainer<BaseElementType>::ElementAt(size_t index) {
420 DCHECK_LT(index, size()); 420 DCHECK_LT(index, size());
421 size_t original_index = index; 421 size_t original_index = index;
422 size_t list_index; 422 size_t list_index;
423 for (list_index = 0; list_index < data_->list_count(); ++list_index) { 423 for (list_index = 0; list_index < data_->list_count(); ++list_index) {
424 size_t current_size = data_->InnerListById(list_index)->size; 424 size_t current_size = data_->InnerListById(list_index)->size;
425 if (index < current_size) 425 if (index < current_size)
426 break; 426 break;
427 index -= current_size; 427 index -= current_size;
428 } 428 }
429 return &*Iterator(data_.get(), 429 return *Iterator(data_.get(),
430 list_index, 430 list_index,
431 data_->InnerListById(list_index)->ElementAt(index), 431 data_->InnerListById(list_index)->ElementAt(index),
432 original_index); 432 original_index);
433 } 433 }
434 434
435 template <typename BaseElementType> 435 template <typename BaseElementType>
436 BaseElementType* ListContainer<BaseElementType>::Allocate( 436 BaseElementType* ListContainer<BaseElementType>::Allocate(
437 size_t size_of_actual_element_in_bytes) { 437 size_t size_of_actual_element_in_bytes) {
438 DCHECK_LE(size_of_actual_element_in_bytes, data_->element_size()); 438 DCHECK_LE(size_of_actual_element_in_bytes, data_->element_size());
439 void* result = data_->Allocate(); 439 void* result = data_->Allocate();
440 return static_cast<BaseElementType*>(result); 440 return static_cast<BaseElementType*>(result);
441 } 441 }
442 442
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 template <typename BaseElementType> 479 template <typename BaseElementType>
480 ListContainer<BaseElementType>::Iterator::~Iterator() { 480 ListContainer<BaseElementType>::Iterator::~Iterator() {
481 } 481 }
482 482
483 template <typename BaseElementType> 483 template <typename BaseElementType>
484 BaseElementType* ListContainer<BaseElementType>::Iterator::operator->() const { 484 BaseElementType* ListContainer<BaseElementType>::Iterator::operator->() const {
485 return reinterpret_cast<BaseElementType*>(this->item_iterator); 485 return reinterpret_cast<BaseElementType*>(this->item_iterator);
486 } 486 }
487 487
488 template <typename BaseElementType> 488 template <typename BaseElementType>
489 BaseElementType& ListContainer<BaseElementType>::Iterator::operator*() const { 489 BaseElementType* ListContainer<BaseElementType>::Iterator::operator*() const {
490 return *(reinterpret_cast<BaseElementType*>(this->item_iterator)); 490 return reinterpret_cast<BaseElementType*>(this->item_iterator);
491 } 491 }
492 492
493 template <typename BaseElementType> 493 template <typename BaseElementType>
494 typename ListContainer<BaseElementType>::Iterator 494 typename ListContainer<BaseElementType>::Iterator
495 ListContainer<BaseElementType>::Iterator:: 495 ListContainer<BaseElementType>::Iterator::
496 operator++(int unused_post_increment) { 496 operator++(int unused_post_increment) {
497 Iterator tmp = *this; 497 Iterator tmp = *this;
498 operator++(); 498 operator++();
499 return tmp; 499 return tmp;
500 } 500 }
501 501
502 template <typename BaseElementType> 502 template <typename BaseElementType>
503 typename ListContainer<BaseElementType>::Iterator 503 typename ListContainer<BaseElementType>::Iterator&
504 ListContainer<BaseElementType>::Iterator:: 504 ListContainer<BaseElementType>::Iterator::
505 operator++() { 505 operator++() {
506 this->Increment(); 506 this->Increment();
507 ++index_; 507 ++index_;
508 return *this; 508 return *this;
509 } 509 }
510 510
511 template <typename BaseElementType> 511 template <typename BaseElementType>
512 size_t ListContainer<BaseElementType>::Iterator::index() const { 512 size_t ListContainer<BaseElementType>::Iterator::index() const {
513 return index_; 513 return index_;
514 } 514 }
515 515
(...skipping 19 matching lines...) Expand all
535 ListContainer<BaseElementType>::ConstIterator::~ConstIterator() { 535 ListContainer<BaseElementType>::ConstIterator::~ConstIterator() {
536 } 536 }
537 537
538 template <typename BaseElementType> 538 template <typename BaseElementType>
539 const BaseElementType* ListContainer<BaseElementType>::ConstIterator:: 539 const BaseElementType* ListContainer<BaseElementType>::ConstIterator::
540 operator->() const { 540 operator->() const {
541 return reinterpret_cast<const BaseElementType*>(this->item_iterator); 541 return reinterpret_cast<const BaseElementType*>(this->item_iterator);
542 } 542 }
543 543
544 template <typename BaseElementType> 544 template <typename BaseElementType>
545 const BaseElementType& ListContainer<BaseElementType>::ConstIterator:: 545 const BaseElementType* ListContainer<BaseElementType>::ConstIterator::
546 operator*() const { 546 operator*() const {
547 return *(reinterpret_cast<const BaseElementType*>(this->item_iterator)); 547 return reinterpret_cast<const BaseElementType*>(this->item_iterator);
548 } 548 }
549 549
550 template <typename BaseElementType> 550 template <typename BaseElementType>
551 typename ListContainer<BaseElementType>::ConstIterator 551 typename ListContainer<BaseElementType>::ConstIterator
552 ListContainer<BaseElementType>::ConstIterator:: 552 ListContainer<BaseElementType>::ConstIterator::
553 operator++(int unused_post_increment) { 553 operator++(int unused_post_increment) {
554 ConstIterator tmp = *this; 554 ConstIterator tmp = *this;
555 operator++(); 555 operator++();
556 return tmp; 556 return tmp;
557 } 557 }
558 558
559 template <typename BaseElementType> 559 template <typename BaseElementType>
560 typename ListContainer<BaseElementType>::ConstIterator 560 typename ListContainer<BaseElementType>::ConstIterator&
561 ListContainer<BaseElementType>::ConstIterator:: 561 ListContainer<BaseElementType>::ConstIterator::
562 operator++() { 562 operator++() {
563 this->Increment(); 563 this->Increment();
564 ++index_; 564 ++index_;
565 return *this; 565 return *this;
566 } 566 }
567 567
568 template <typename BaseElementType> 568 template <typename BaseElementType>
569 size_t ListContainer<BaseElementType>::ConstIterator::index() const { 569 size_t ListContainer<BaseElementType>::ConstIterator::index() const {
570 return index_; 570 return index_;
571 } 571 }
572 572
(...skipping 13 matching lines...) Expand all
586 ListContainer<BaseElementType>::ReverseIterator::~ReverseIterator() { 586 ListContainer<BaseElementType>::ReverseIterator::~ReverseIterator() {
587 } 587 }
588 588
589 template <typename BaseElementType> 589 template <typename BaseElementType>
590 BaseElementType* ListContainer<BaseElementType>::ReverseIterator::operator->() 590 BaseElementType* ListContainer<BaseElementType>::ReverseIterator::operator->()
591 const { 591 const {
592 return reinterpret_cast<BaseElementType*>(this->item_iterator); 592 return reinterpret_cast<BaseElementType*>(this->item_iterator);
593 } 593 }
594 594
595 template <typename BaseElementType> 595 template <typename BaseElementType>
596 BaseElementType& ListContainer<BaseElementType>::ReverseIterator::operator*() 596 BaseElementType* ListContainer<BaseElementType>::ReverseIterator::operator*()
597 const { 597 const {
598 return *(reinterpret_cast<BaseElementType*>(this->item_iterator)); 598 return reinterpret_cast<BaseElementType*>(this->item_iterator);
599 } 599 }
600 600
601 template <typename BaseElementType> 601 template <typename BaseElementType>
602 typename ListContainer<BaseElementType>::ReverseIterator 602 typename ListContainer<BaseElementType>::ReverseIterator
603 ListContainer<BaseElementType>::ReverseIterator:: 603 ListContainer<BaseElementType>::ReverseIterator::
604 operator++(int unused_post_increment) { 604 operator++(int unused_post_increment) {
605 ReverseIterator tmp = *this; 605 ReverseIterator tmp = *this;
606 operator++(); 606 operator++();
607 return tmp; 607 return tmp;
608 } 608 }
609 609
610 template <typename BaseElementType> 610 template <typename BaseElementType>
611 typename ListContainer<BaseElementType>::ReverseIterator 611 typename ListContainer<BaseElementType>::ReverseIterator&
612 ListContainer<BaseElementType>::ReverseIterator:: 612 ListContainer<BaseElementType>::ReverseIterator::
613 operator++() { 613 operator++() {
614 this->ReverseIncrement(); 614 this->ReverseIncrement();
615 ++index_; 615 ++index_;
616 return *this; 616 return *this;
617 } 617 }
618 618
619 template <typename BaseElementType> 619 template <typename BaseElementType>
620 size_t ListContainer<BaseElementType>::ReverseIterator::index() const { 620 size_t ListContainer<BaseElementType>::ReverseIterator::index() const {
621 return index_; 621 return index_;
622 } 622 }
623 623
(...skipping 19 matching lines...) Expand all
643 ListContainer<BaseElementType>::ConstReverseIterator::~ConstReverseIterator() { 643 ListContainer<BaseElementType>::ConstReverseIterator::~ConstReverseIterator() {
644 } 644 }
645 645
646 template <typename BaseElementType> 646 template <typename BaseElementType>
647 const BaseElementType* ListContainer<BaseElementType>::ConstReverseIterator:: 647 const BaseElementType* ListContainer<BaseElementType>::ConstReverseIterator::
648 operator->() const { 648 operator->() const {
649 return reinterpret_cast<const BaseElementType*>(this->item_iterator); 649 return reinterpret_cast<const BaseElementType*>(this->item_iterator);
650 } 650 }
651 651
652 template <typename BaseElementType> 652 template <typename BaseElementType>
653 const BaseElementType& ListContainer<BaseElementType>::ConstReverseIterator:: 653 const BaseElementType* ListContainer<BaseElementType>::ConstReverseIterator::
654 operator*() const { 654 operator*() const {
655 return *(reinterpret_cast<const BaseElementType*>(this->item_iterator)); 655 return reinterpret_cast<const BaseElementType*>(this->item_iterator);
656 } 656 }
657 657
658 template <typename BaseElementType> 658 template <typename BaseElementType>
659 typename ListContainer<BaseElementType>::ConstReverseIterator 659 typename ListContainer<BaseElementType>::ConstReverseIterator
660 ListContainer<BaseElementType>::ConstReverseIterator:: 660 ListContainer<BaseElementType>::ConstReverseIterator::
661 operator++(int unused_post_increment) { 661 operator++(int unused_post_increment) {
662 ConstReverseIterator tmp = *this; 662 ConstReverseIterator tmp = *this;
663 operator++(); 663 operator++();
664 return tmp; 664 return tmp;
665 } 665 }
666 666
667 template <typename BaseElementType> 667 template <typename BaseElementType>
668 typename ListContainer<BaseElementType>::ConstReverseIterator 668 typename ListContainer<BaseElementType>::ConstReverseIterator&
669 ListContainer<BaseElementType>::ConstReverseIterator:: 669 ListContainer<BaseElementType>::ConstReverseIterator::
670 operator++() { 670 operator++() {
671 this->ReverseIncrement(); 671 this->ReverseIncrement();
672 ++index_; 672 ++index_;
673 return *this; 673 return *this;
674 } 674 }
675 675
676 template <typename BaseElementType> 676 template <typename BaseElementType>
677 size_t ListContainer<BaseElementType>::ConstReverseIterator::index() const { 677 size_t ListContainer<BaseElementType>::ConstReverseIterator::index() const {
678 return index_; 678 return index_;
679 } 679 }
680 680
681 template class ListContainer<SharedQuadState>; 681 template class ListContainer<SharedQuadState>;
682 template class ListContainer<DrawQuad>; 682 template class ListContainer<DrawQuad>;
683 683
684 } // namespace cc 684 } // namespace cc
OLDNEW
« 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