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

Side by Side Diff: cc/layers/picture_layer_impl.cc

Issue 741683003: cc: Move LayerEvictionTileIterator to a separate file and make it a queue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years 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/layers/picture_layer_impl.h ('k') | cc/layers/picture_layer_impl_perftest.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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/layers/picture_layer_impl.h" 5 #include "cc/layers/picture_layer_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 10
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 is_mask_(false) { 91 is_mask_(false) {
92 layer_tree_impl()->RegisterPictureLayerImpl(this); 92 layer_tree_impl()->RegisterPictureLayerImpl(this);
93 } 93 }
94 94
95 PictureLayerImpl::~PictureLayerImpl() { 95 PictureLayerImpl::~PictureLayerImpl() {
96 if (twin_layer_) 96 if (twin_layer_)
97 twin_layer_->twin_layer_ = nullptr; 97 twin_layer_->twin_layer_ = nullptr;
98 layer_tree_impl()->UnregisterPictureLayerImpl(this); 98 layer_tree_impl()->UnregisterPictureLayerImpl(this);
99 } 99 }
100 100
101 scoped_ptr<TilingSetEvictionQueue> PictureLayerImpl::CreateEvictionQueue(
102 TreePriority tree_priority) {
103 if (!tilings_)
104 return make_scoped_ptr(new TilingSetEvictionQueue());
105 return make_scoped_ptr(
106 new TilingSetEvictionQueue(tilings_.get(), tree_priority));
107 }
108
101 const char* PictureLayerImpl::LayerTypeAsString() const { 109 const char* PictureLayerImpl::LayerTypeAsString() const {
102 return "cc::PictureLayerImpl"; 110 return "cc::PictureLayerImpl";
103 } 111 }
104 112
105 scoped_ptr<LayerImpl> PictureLayerImpl::CreateLayerImpl( 113 scoped_ptr<LayerImpl> PictureLayerImpl::CreateLayerImpl(
106 LayerTreeImpl* tree_impl) { 114 LayerTreeImpl* tree_impl) {
107 return PictureLayerImpl::Create(tree_impl, id()); 115 return PictureLayerImpl::Create(tree_impl, id());
108 } 116 }
109 117
110 void PictureLayerImpl::PushPropertiesTo(LayerImpl* base_layer) { 118 void PictureLayerImpl::PushPropertiesTo(LayerImpl* base_layer) {
(...skipping 1357 matching lines...) Expand 10 before | Expand all | Expand 10 after
1468 while (current_stage_ < arraysize(stages_)) { 1476 while (current_stage_ < arraysize(stages_)) {
1469 IteratorType index = stages_[current_stage_].iterator_type; 1477 IteratorType index = stages_[current_stage_].iterator_type;
1470 TilePriority::PriorityBin tile_type = stages_[current_stage_].tile_type; 1478 TilePriority::PriorityBin tile_type = stages_[current_stage_].tile_type;
1471 1479
1472 if (iterators_[index] && iterators_[index].get_type() == tile_type) 1480 if (iterators_[index] && iterators_[index].get_type() == tile_type)
1473 break; 1481 break;
1474 ++current_stage_; 1482 ++current_stage_;
1475 } 1483 }
1476 } 1484 }
1477 1485
1478 PictureLayerImpl::LayerEvictionTileIterator::LayerEvictionTileIterator()
1479 : layer_(nullptr),
1480 tree_priority_(SAME_PRIORITY_FOR_BOTH_TREES),
1481 current_category_(PictureLayerTiling::EVENTUALLY),
1482 current_tiling_range_type_(PictureLayerTilingSet::HIGHER_THAN_HIGH_RES),
1483 current_tiling_(0u) {
1484 }
1485
1486 PictureLayerImpl::LayerEvictionTileIterator::LayerEvictionTileIterator(
1487 PictureLayerImpl* layer,
1488 TreePriority tree_priority)
1489 : layer_(layer),
1490 tree_priority_(tree_priority),
1491 current_category_(PictureLayerTiling::EVENTUALLY),
1492 current_tiling_range_type_(PictureLayerTilingSet::HIGHER_THAN_HIGH_RES),
1493 current_tiling_(0u) {
1494 // Early out if the layer has no tilings.
1495 if (!layer_->tilings_ || !layer_->tilings_->num_tilings())
1496 return;
1497
1498 current_tiling_ = CurrentTilingRange().start - 1u;
1499 do {
1500 if (!AdvanceToNextTiling())
1501 break;
1502
1503 current_iterator_ = PictureLayerTiling::TilingEvictionTileIterator(
1504 layer_->tilings_->tiling_at(CurrentTilingIndex()),
1505 tree_priority,
1506 current_category_);
1507 } while (!current_iterator_);
1508 }
1509
1510 PictureLayerImpl::LayerEvictionTileIterator::~LayerEvictionTileIterator() {
1511 }
1512
1513 Tile* PictureLayerImpl::LayerEvictionTileIterator::operator*() {
1514 DCHECK(*this);
1515 return *current_iterator_;
1516 }
1517
1518 const Tile* PictureLayerImpl::LayerEvictionTileIterator::operator*() const {
1519 DCHECK(*this);
1520 return *current_iterator_;
1521 }
1522
1523 PictureLayerImpl::LayerEvictionTileIterator&
1524 PictureLayerImpl::LayerEvictionTileIterator::
1525 operator++() {
1526 DCHECK(*this);
1527 ++current_iterator_;
1528 while (!current_iterator_) {
1529 if (!AdvanceToNextTiling())
1530 break;
1531
1532 current_iterator_ = PictureLayerTiling::TilingEvictionTileIterator(
1533 layer_->tilings_->tiling_at(CurrentTilingIndex()),
1534 tree_priority_,
1535 current_category_);
1536 }
1537 return *this;
1538 }
1539
1540 PictureLayerImpl::LayerEvictionTileIterator::operator bool() const {
1541 return !!current_iterator_;
1542 }
1543
1544 bool PictureLayerImpl::LayerEvictionTileIterator::AdvanceToNextCategory() {
1545 switch (current_category_) {
1546 case PictureLayerTiling::EVENTUALLY:
1547 current_category_ =
1548 PictureLayerTiling::EVENTUALLY_AND_REQUIRED_FOR_ACTIVATION;
1549 return true;
1550 case PictureLayerTiling::EVENTUALLY_AND_REQUIRED_FOR_ACTIVATION:
1551 current_category_ = PictureLayerTiling::SOON;
1552 return true;
1553 case PictureLayerTiling::SOON:
1554 current_category_ = PictureLayerTiling::SOON_AND_REQUIRED_FOR_ACTIVATION;
1555 return true;
1556 case PictureLayerTiling::SOON_AND_REQUIRED_FOR_ACTIVATION:
1557 current_category_ = PictureLayerTiling::NOW;
1558 return true;
1559 case PictureLayerTiling::NOW:
1560 current_category_ = PictureLayerTiling::NOW_AND_REQUIRED_FOR_ACTIVATION;
1561 return true;
1562 case PictureLayerTiling::NOW_AND_REQUIRED_FOR_ACTIVATION:
1563 return false;
1564 }
1565 NOTREACHED();
1566 return false;
1567 }
1568
1569 bool
1570 PictureLayerImpl::LayerEvictionTileIterator::AdvanceToNextTilingRangeType() {
1571 switch (current_tiling_range_type_) {
1572 case PictureLayerTilingSet::HIGHER_THAN_HIGH_RES:
1573 current_tiling_range_type_ = PictureLayerTilingSet::LOWER_THAN_LOW_RES;
1574 return true;
1575 case PictureLayerTilingSet::LOWER_THAN_LOW_RES:
1576 current_tiling_range_type_ =
1577 PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES;
1578 return true;
1579 case PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES:
1580 current_tiling_range_type_ = PictureLayerTilingSet::LOW_RES;
1581 return true;
1582 case PictureLayerTilingSet::LOW_RES:
1583 current_tiling_range_type_ = PictureLayerTilingSet::HIGH_RES;
1584 return true;
1585 case PictureLayerTilingSet::HIGH_RES:
1586 if (!AdvanceToNextCategory())
1587 return false;
1588
1589 current_tiling_range_type_ = PictureLayerTilingSet::HIGHER_THAN_HIGH_RES;
1590 return true;
1591 }
1592 NOTREACHED();
1593 return false;
1594 }
1595
1596 bool PictureLayerImpl::LayerEvictionTileIterator::AdvanceToNextTiling() {
1597 DCHECK_NE(current_tiling_, CurrentTilingRange().end);
1598 ++current_tiling_;
1599 while (current_tiling_ == CurrentTilingRange().end) {
1600 if (!AdvanceToNextTilingRangeType())
1601 return false;
1602
1603 current_tiling_ = CurrentTilingRange().start;
1604 }
1605 return true;
1606 }
1607
1608 PictureLayerTilingSet::TilingRange
1609 PictureLayerImpl::LayerEvictionTileIterator::CurrentTilingRange() const {
1610 return layer_->tilings_->GetTilingRange(current_tiling_range_type_);
1611 }
1612
1613 size_t PictureLayerImpl::LayerEvictionTileIterator::CurrentTilingIndex() const {
1614 DCHECK_NE(current_tiling_, CurrentTilingRange().end);
1615 switch (current_tiling_range_type_) {
1616 case PictureLayerTilingSet::HIGHER_THAN_HIGH_RES:
1617 case PictureLayerTilingSet::LOW_RES:
1618 case PictureLayerTilingSet::HIGH_RES:
1619 return current_tiling_;
1620 // Tilings in the following ranges are accessed in reverse order.
1621 case PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES:
1622 case PictureLayerTilingSet::LOWER_THAN_LOW_RES: {
1623 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange();
1624 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start;
1625 return tiling_range.end - 1 - current_tiling_range_offset;
1626 }
1627 }
1628 NOTREACHED();
1629 return 0;
1630 }
1631
1632 } // namespace cc 1486 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_impl.h ('k') | cc/layers/picture_layer_impl_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698