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

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

Issue 742343002: cc: Move LayerRasterTileIterator 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 } 99 }
100 100
101 scoped_ptr<TilingSetEvictionQueue> PictureLayerImpl::CreateEvictionQueue( 101 scoped_ptr<TilingSetEvictionQueue> PictureLayerImpl::CreateEvictionQueue(
102 TreePriority tree_priority) { 102 TreePriority tree_priority) {
103 if (!tilings_) 103 if (!tilings_)
104 return make_scoped_ptr(new TilingSetEvictionQueue()); 104 return make_scoped_ptr(new TilingSetEvictionQueue());
105 return make_scoped_ptr( 105 return make_scoped_ptr(
106 new TilingSetEvictionQueue(tilings_.get(), tree_priority)); 106 new TilingSetEvictionQueue(tilings_.get(), tree_priority));
107 } 107 }
108 108
109 scoped_ptr<TilingSetRasterQueue> PictureLayerImpl::CreateRasterQueue(
110 bool prioritize_low_res) {
111 if (!tilings_)
112 return make_scoped_ptr(new TilingSetRasterQueue());
113 return make_scoped_ptr(
114 new TilingSetRasterQueue(tilings_.get(), prioritize_low_res));
115 }
116
109 const char* PictureLayerImpl::LayerTypeAsString() const { 117 const char* PictureLayerImpl::LayerTypeAsString() const {
110 return "cc::PictureLayerImpl"; 118 return "cc::PictureLayerImpl";
111 } 119 }
112 120
113 scoped_ptr<LayerImpl> PictureLayerImpl::CreateLayerImpl( 121 scoped_ptr<LayerImpl> PictureLayerImpl::CreateLayerImpl(
114 LayerTreeImpl* tree_impl) { 122 LayerTreeImpl* tree_impl) {
115 return PictureLayerImpl::Create(tree_impl, id()); 123 return PictureLayerImpl::Create(tree_impl, id());
116 } 124 }
117 125
118 void PictureLayerImpl::PushPropertiesTo(LayerImpl* base_layer) { 126 void PictureLayerImpl::PushPropertiesTo(LayerImpl* base_layer) {
(...skipping 1242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1361 } 1369 }
1362 1370
1363 bool PictureLayerImpl::AllTilesRequiredForDrawAreReadyToDraw() const { 1371 bool PictureLayerImpl::AllTilesRequiredForDrawAreReadyToDraw() const {
1364 if (!layer_tree_impl()->IsActiveTree()) 1372 if (!layer_tree_impl()->IsActiveTree())
1365 return true; 1373 return true;
1366 1374
1367 return AllTilesRequiredAreReadyToDraw( 1375 return AllTilesRequiredAreReadyToDraw(
1368 &PictureLayerTiling::IsTileRequiredForDrawIfVisible); 1376 &PictureLayerTiling::IsTileRequiredForDrawIfVisible);
1369 } 1377 }
1370 1378
1371 PictureLayerImpl::LayerRasterTileIterator::LayerRasterTileIterator()
1372 : layer_(nullptr), current_stage_(arraysize(stages_)) {
1373 }
1374
1375 PictureLayerImpl::LayerRasterTileIterator::LayerRasterTileIterator(
1376 PictureLayerImpl* layer,
1377 bool prioritize_low_res)
1378 : layer_(layer), current_stage_(0) {
1379 DCHECK(layer_);
1380
1381 // Early out if the layer has no tilings.
1382 if (!layer_->tilings_ || !layer_->tilings_->num_tilings()) {
1383 current_stage_ = arraysize(stages_);
1384 return;
1385 }
1386
1387 // Tiles without valid priority are treated as having lowest priority and
1388 // never considered for raster.
1389 if (!layer_->HasValidTilePriorities()) {
1390 current_stage_ = arraysize(stages_);
1391 return;
1392 }
1393
1394 // Find high and low res tilings and initialize the iterators.
1395 for (size_t i = 0; i < layer_->tilings_->num_tilings(); ++i) {
1396 PictureLayerTiling* tiling = layer_->tilings_->tiling_at(i);
1397 if (tiling->resolution() == HIGH_RESOLUTION) {
1398 iterators_[HIGH_RES] =
1399 PictureLayerTiling::TilingRasterTileIterator(tiling);
1400 }
1401
1402 if (prioritize_low_res && tiling->resolution() == LOW_RESOLUTION) {
1403 iterators_[LOW_RES] =
1404 PictureLayerTiling::TilingRasterTileIterator(tiling);
1405 }
1406 }
1407
1408 if (prioritize_low_res) {
1409 stages_[0].iterator_type = LOW_RES;
1410 stages_[0].tile_type = TilePriority::NOW;
1411
1412 stages_[1].iterator_type = HIGH_RES;
1413 stages_[1].tile_type = TilePriority::NOW;
1414 } else {
1415 stages_[0].iterator_type = HIGH_RES;
1416 stages_[0].tile_type = TilePriority::NOW;
1417
1418 stages_[1].iterator_type = LOW_RES;
1419 stages_[1].tile_type = TilePriority::NOW;
1420 }
1421
1422 stages_[2].iterator_type = HIGH_RES;
1423 stages_[2].tile_type = TilePriority::SOON;
1424
1425 stages_[3].iterator_type = HIGH_RES;
1426 stages_[3].tile_type = TilePriority::EVENTUALLY;
1427
1428 IteratorType index = stages_[current_stage_].iterator_type;
1429 TilePriority::PriorityBin tile_type = stages_[current_stage_].tile_type;
1430 if (!iterators_[index] || iterators_[index].get_type() != tile_type)
1431 AdvanceToNextStage();
1432 }
1433
1434 PictureLayerImpl::LayerRasterTileIterator::~LayerRasterTileIterator() {}
1435
1436 PictureLayerImpl::LayerRasterTileIterator::operator bool() const {
1437 return current_stage_ < arraysize(stages_);
1438 }
1439
1440 PictureLayerImpl::LayerRasterTileIterator&
1441 PictureLayerImpl::LayerRasterTileIterator::
1442 operator++() {
1443 IteratorType index = stages_[current_stage_].iterator_type;
1444 TilePriority::PriorityBin tile_type = stages_[current_stage_].tile_type;
1445
1446 // First advance the iterator.
1447 DCHECK(iterators_[index]);
1448 DCHECK(iterators_[index].get_type() == tile_type);
1449 ++iterators_[index];
1450
1451 if (!iterators_[index] || iterators_[index].get_type() != tile_type)
1452 AdvanceToNextStage();
1453
1454 return *this;
1455 }
1456
1457 Tile* PictureLayerImpl::LayerRasterTileIterator::operator*() {
1458 DCHECK(*this);
1459
1460 IteratorType index = stages_[current_stage_].iterator_type;
1461 DCHECK(iterators_[index]);
1462 DCHECK(iterators_[index].get_type() == stages_[current_stage_].tile_type);
1463
1464 return *iterators_[index];
1465 }
1466
1467 const Tile* PictureLayerImpl::LayerRasterTileIterator::operator*() const {
1468 DCHECK(*this);
1469
1470 IteratorType index = stages_[current_stage_].iterator_type;
1471 DCHECK(iterators_[index]);
1472 DCHECK(iterators_[index].get_type() == stages_[current_stage_].tile_type);
1473
1474 return *iterators_[index];
1475 }
1476
1477 void PictureLayerImpl::LayerRasterTileIterator::AdvanceToNextStage() {
1478 DCHECK_LT(current_stage_, arraysize(stages_));
1479 ++current_stage_;
1480 while (current_stage_ < arraysize(stages_)) {
1481 IteratorType index = stages_[current_stage_].iterator_type;
1482 TilePriority::PriorityBin tile_type = stages_[current_stage_].tile_type;
1483
1484 if (iterators_[index] && iterators_[index].get_type() == tile_type)
1485 break;
1486 ++current_stage_;
1487 }
1488 }
1489
1490 } // namespace cc 1379 } // 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