Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 nullptr; | |
|
vmpstr
2014/11/21 18:08:23
I think this should return some sort of a "default
USE eero AT chromium.org
2014/11/25 11:42:42
The only calling code (apart from perf/unit tests)
vmpstr
2014/11/25 17:37:04
It simplifies the interface. When we call layer->C
USE eero AT chromium.org
2014/11/26 09:17:19
Acknowledged.
| |
| 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 1356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1467 while (current_stage_ < arraysize(stages_)) { | 1475 while (current_stage_ < arraysize(stages_)) { |
| 1468 IteratorType index = stages_[current_stage_].iterator_type; | 1476 IteratorType index = stages_[current_stage_].iterator_type; |
| 1469 TilePriority::PriorityBin tile_type = stages_[current_stage_].tile_type; | 1477 TilePriority::PriorityBin tile_type = stages_[current_stage_].tile_type; |
| 1470 | 1478 |
| 1471 if (iterators_[index] && iterators_[index].get_type() == tile_type) | 1479 if (iterators_[index] && iterators_[index].get_type() == tile_type) |
| 1472 break; | 1480 break; |
| 1473 ++current_stage_; | 1481 ++current_stage_; |
| 1474 } | 1482 } |
| 1475 } | 1483 } |
| 1476 | 1484 |
| 1477 PictureLayerImpl::LayerEvictionTileIterator::LayerEvictionTileIterator() | |
| 1478 : layer_(nullptr), | |
| 1479 tree_priority_(SAME_PRIORITY_FOR_BOTH_TREES), | |
| 1480 current_category_(PictureLayerTiling::EVENTUALLY), | |
| 1481 current_tiling_range_type_(PictureLayerTilingSet::HIGHER_THAN_HIGH_RES), | |
| 1482 current_tiling_(0u) { | |
| 1483 } | |
| 1484 | |
| 1485 PictureLayerImpl::LayerEvictionTileIterator::LayerEvictionTileIterator( | |
| 1486 PictureLayerImpl* layer, | |
| 1487 TreePriority tree_priority) | |
| 1488 : layer_(layer), | |
| 1489 tree_priority_(tree_priority), | |
| 1490 current_category_(PictureLayerTiling::EVENTUALLY), | |
| 1491 current_tiling_range_type_(PictureLayerTilingSet::HIGHER_THAN_HIGH_RES), | |
| 1492 current_tiling_(0u) { | |
| 1493 // Early out if the layer has no tilings. | |
| 1494 if (!layer_->tilings_ || !layer_->tilings_->num_tilings()) | |
| 1495 return; | |
| 1496 | |
| 1497 current_tiling_ = CurrentTilingRange().start - 1u; | |
| 1498 do { | |
| 1499 if (!AdvanceToNextTiling()) | |
| 1500 break; | |
| 1501 | |
| 1502 current_iterator_ = PictureLayerTiling::TilingEvictionTileIterator( | |
| 1503 layer_->tilings_->tiling_at(CurrentTilingIndex()), | |
| 1504 tree_priority, | |
| 1505 current_category_); | |
| 1506 } while (!current_iterator_); | |
| 1507 } | |
| 1508 | |
| 1509 PictureLayerImpl::LayerEvictionTileIterator::~LayerEvictionTileIterator() { | |
| 1510 } | |
| 1511 | |
| 1512 Tile* PictureLayerImpl::LayerEvictionTileIterator::operator*() { | |
| 1513 DCHECK(*this); | |
| 1514 return *current_iterator_; | |
| 1515 } | |
| 1516 | |
| 1517 const Tile* PictureLayerImpl::LayerEvictionTileIterator::operator*() const { | |
| 1518 DCHECK(*this); | |
| 1519 return *current_iterator_; | |
| 1520 } | |
| 1521 | |
| 1522 PictureLayerImpl::LayerEvictionTileIterator& | |
| 1523 PictureLayerImpl::LayerEvictionTileIterator:: | |
| 1524 operator++() { | |
| 1525 DCHECK(*this); | |
| 1526 ++current_iterator_; | |
| 1527 while (!current_iterator_) { | |
| 1528 if (!AdvanceToNextTiling()) | |
| 1529 break; | |
| 1530 | |
| 1531 current_iterator_ = PictureLayerTiling::TilingEvictionTileIterator( | |
| 1532 layer_->tilings_->tiling_at(CurrentTilingIndex()), | |
| 1533 tree_priority_, | |
| 1534 current_category_); | |
| 1535 } | |
| 1536 return *this; | |
| 1537 } | |
| 1538 | |
| 1539 PictureLayerImpl::LayerEvictionTileIterator::operator bool() const { | |
| 1540 return !!current_iterator_; | |
| 1541 } | |
| 1542 | |
| 1543 bool PictureLayerImpl::LayerEvictionTileIterator::AdvanceToNextCategory() { | |
| 1544 switch (current_category_) { | |
| 1545 case PictureLayerTiling::EVENTUALLY: | |
| 1546 current_category_ = | |
| 1547 PictureLayerTiling::EVENTUALLY_AND_REQUIRED_FOR_ACTIVATION; | |
| 1548 return true; | |
| 1549 case PictureLayerTiling::EVENTUALLY_AND_REQUIRED_FOR_ACTIVATION: | |
| 1550 current_category_ = PictureLayerTiling::SOON; | |
| 1551 return true; | |
| 1552 case PictureLayerTiling::SOON: | |
| 1553 current_category_ = PictureLayerTiling::SOON_AND_REQUIRED_FOR_ACTIVATION; | |
| 1554 return true; | |
| 1555 case PictureLayerTiling::SOON_AND_REQUIRED_FOR_ACTIVATION: | |
| 1556 current_category_ = PictureLayerTiling::NOW; | |
| 1557 return true; | |
| 1558 case PictureLayerTiling::NOW: | |
| 1559 current_category_ = PictureLayerTiling::NOW_AND_REQUIRED_FOR_ACTIVATION; | |
| 1560 return true; | |
| 1561 case PictureLayerTiling::NOW_AND_REQUIRED_FOR_ACTIVATION: | |
| 1562 return false; | |
| 1563 } | |
| 1564 NOTREACHED(); | |
| 1565 return false; | |
| 1566 } | |
| 1567 | |
| 1568 bool | |
| 1569 PictureLayerImpl::LayerEvictionTileIterator::AdvanceToNextTilingRangeType() { | |
| 1570 switch (current_tiling_range_type_) { | |
| 1571 case PictureLayerTilingSet::HIGHER_THAN_HIGH_RES: | |
| 1572 current_tiling_range_type_ = PictureLayerTilingSet::LOWER_THAN_LOW_RES; | |
| 1573 return true; | |
| 1574 case PictureLayerTilingSet::LOWER_THAN_LOW_RES: | |
| 1575 current_tiling_range_type_ = | |
| 1576 PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES; | |
| 1577 return true; | |
| 1578 case PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES: | |
| 1579 current_tiling_range_type_ = PictureLayerTilingSet::LOW_RES; | |
| 1580 return true; | |
| 1581 case PictureLayerTilingSet::LOW_RES: | |
| 1582 current_tiling_range_type_ = PictureLayerTilingSet::HIGH_RES; | |
| 1583 return true; | |
| 1584 case PictureLayerTilingSet::HIGH_RES: | |
| 1585 if (!AdvanceToNextCategory()) | |
| 1586 return false; | |
| 1587 | |
| 1588 current_tiling_range_type_ = PictureLayerTilingSet::HIGHER_THAN_HIGH_RES; | |
| 1589 return true; | |
| 1590 } | |
| 1591 NOTREACHED(); | |
| 1592 return false; | |
| 1593 } | |
| 1594 | |
| 1595 bool PictureLayerImpl::LayerEvictionTileIterator::AdvanceToNextTiling() { | |
| 1596 DCHECK_NE(current_tiling_, CurrentTilingRange().end); | |
| 1597 ++current_tiling_; | |
| 1598 while (current_tiling_ == CurrentTilingRange().end) { | |
| 1599 if (!AdvanceToNextTilingRangeType()) | |
| 1600 return false; | |
| 1601 | |
| 1602 current_tiling_ = CurrentTilingRange().start; | |
| 1603 } | |
| 1604 return true; | |
| 1605 } | |
| 1606 | |
| 1607 PictureLayerTilingSet::TilingRange | |
| 1608 PictureLayerImpl::LayerEvictionTileIterator::CurrentTilingRange() const { | |
| 1609 return layer_->tilings_->GetTilingRange(current_tiling_range_type_); | |
| 1610 } | |
| 1611 | |
| 1612 size_t PictureLayerImpl::LayerEvictionTileIterator::CurrentTilingIndex() const { | |
| 1613 DCHECK_NE(current_tiling_, CurrentTilingRange().end); | |
| 1614 switch (current_tiling_range_type_) { | |
| 1615 case PictureLayerTilingSet::HIGHER_THAN_HIGH_RES: | |
| 1616 case PictureLayerTilingSet::LOW_RES: | |
| 1617 case PictureLayerTilingSet::HIGH_RES: | |
| 1618 return current_tiling_; | |
| 1619 // Tilings in the following ranges are accessed in reverse order. | |
| 1620 case PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES: | |
| 1621 case PictureLayerTilingSet::LOWER_THAN_LOW_RES: { | |
| 1622 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); | |
| 1623 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; | |
| 1624 return tiling_range.end - 1 - current_tiling_range_offset; | |
| 1625 } | |
| 1626 } | |
| 1627 NOTREACHED(); | |
| 1628 return 0; | |
| 1629 } | |
| 1630 | |
| 1631 } // namespace cc | 1485 } // namespace cc |
| OLD | NEW |