| Index: cc/resources/picture_layer_tiling.cc
|
| diff --git a/cc/resources/picture_layer_tiling.cc b/cc/resources/picture_layer_tiling.cc
|
| index 939e0b163d4a459aa50d0437a9aec5b94c2f8230..3604465c68409b8bc2d90b7b0a35c9c062f72a2b 100644
|
| --- a/cc/resources/picture_layer_tiling.cc
|
| +++ b/cc/resources/picture_layer_tiling.cc
|
| @@ -10,6 +10,8 @@
|
|
|
| #include "base/debug/trace_event.h"
|
| #include "cc/base/math_util.h"
|
| +#include "cc/resources/tile.h"
|
| +#include "cc/resources/tile_priority.h"
|
| #include "ui/gfx/point_conversions.h"
|
| #include "ui/gfx/rect_conversions.h"
|
| #include "ui/gfx/safe_integer_conversions.h"
|
| @@ -64,16 +66,9 @@ gfx::SizeF PictureLayerTiling::ContentSizeF() const {
|
| return gfx::ScaleSize(layer_bounds_, contents_scale_);
|
| }
|
|
|
| -Tile* PictureLayerTiling::TileAt(int i, int j) const {
|
| - TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j));
|
| - if (iter == tiles_.end())
|
| - return NULL;
|
| - return iter->second.get();
|
| -}
|
| -
|
| -void PictureLayerTiling::CreateTile(int i,
|
| - int j,
|
| - const PictureLayerTiling* twin_tiling) {
|
| +Tile* PictureLayerTiling::CreateTile(int i,
|
| + int j,
|
| + const PictureLayerTiling* twin_tiling) {
|
| TileMapKey key(i, j);
|
| DCHECK(tiles_.find(key) == tiles_.end());
|
|
|
| @@ -90,7 +85,7 @@ void PictureLayerTiling::CreateTile(int i,
|
| gfx::ScaleToEnclosingRect(paint_rect, 1.0f / contents_scale_);
|
| if (!client_->GetInvalidation()->Intersects(rect)) {
|
| tiles_[key] = candidate_tile;
|
| - return;
|
| + return candidate_tile;
|
| }
|
| }
|
| }
|
| @@ -99,6 +94,7 @@ void PictureLayerTiling::CreateTile(int i,
|
| scoped_refptr<Tile> tile = client_->CreateTile(this, tile_rect);
|
| if (tile.get())
|
| tiles_[key] = tile;
|
| + return tile.get();
|
| }
|
|
|
| Region PictureLayerTiling::OpaqueRegionInContentRect(
|
| @@ -430,8 +426,15 @@ void PictureLayerTiling::UpdateTilePriorities(
|
| last_impl_frame_time_in_seconds_ = current_frame_time_in_seconds;
|
| last_visible_rect_in_content_space_ = visible_rect_in_content_space;
|
|
|
| - // Assign now priority to all visible tiles.
|
| + current_visible_rect_in_content_space_ = visible_rect_in_content_space;
|
| + current_skewport_ = skewport;
|
| + current_eventually_rect_ = eventually_rect;
|
| +
|
| TilePriority now_priority(resolution_, TilePriority::NOW, 0);
|
| + float content_to_screen_scale =
|
| + 1.0f / (contents_scale_ * layer_contents_scale);
|
| +
|
| + // Assign now priority to all visible tiles.
|
| for (TilingData::Iterator iter(&tiling_data_, visible_rect_in_content_space);
|
| iter;
|
| ++iter) {
|
| @@ -443,9 +446,7 @@ void PictureLayerTiling::UpdateTilePriorities(
|
| tile->SetPriority(tree, now_priority);
|
| }
|
|
|
| - // Assign soon priority to all tiles in the skewport that are not visible.
|
| - float content_to_screen_scale =
|
| - 1.0f / (contents_scale_ * layer_contents_scale);
|
| + // Assign soon priority to skewport tiles.
|
| for (TilingData::DifferenceIterator iter(
|
| &tiling_data_, skewport, visible_rect_in_content_space);
|
| iter;
|
| @@ -466,8 +467,7 @@ void PictureLayerTiling::UpdateTilePriorities(
|
| tile->SetPriority(tree, priority);
|
| }
|
|
|
| - // Assign eventually priority to all tiles in the eventually rect that are not
|
| - // in the skewport.
|
| + // Assign eventually priority to interest rect tiles.
|
| for (TilingData::DifferenceIterator iter(
|
| &tiling_data_, eventually_rect, skewport);
|
| iter;
|
| @@ -723,4 +723,97 @@ gfx::Rect PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy(
|
| return result;
|
| }
|
|
|
| +PictureLayerTiling::TilingRasterTileIterator::TilingRasterTileIterator()
|
| + : tiling_(NULL), current_tile_(NULL) {}
|
| +
|
| +PictureLayerTiling::TilingRasterTileIterator::TilingRasterTileIterator(
|
| + PictureLayerTiling* tiling,
|
| + WhichTree tree)
|
| + : tiling_(tiling),
|
| + type_(VISIBLE),
|
| + visible_rect_in_content_space_(
|
| + tiling_->current_visible_rect_in_content_space_),
|
| + skewport_in_content_space_(tiling_->current_skewport_),
|
| + eventually_rect_in_content_space_(tiling_->current_eventually_rect_),
|
| + tree_(tree),
|
| + current_tile_(NULL),
|
| + visible_iterator_(&tiling->tiling_data_, visible_rect_in_content_space_),
|
| + spiral_iterator_(&tiling->tiling_data_,
|
| + skewport_in_content_space_,
|
| + visible_rect_in_content_space_,
|
| + visible_rect_in_content_space_) {
|
| + if (!visible_iterator_) {
|
| + AdvancePhase();
|
| + return;
|
| + }
|
| +
|
| + current_tile_ =
|
| + tiling_->TileAt(visible_iterator_.index_x(), visible_iterator_.index_y());
|
| + if (!current_tile_ || !TileNeedsRaster(current_tile_))
|
| + ++(*this);
|
| +}
|
| +
|
| +PictureLayerTiling::TilingRasterTileIterator::~TilingRasterTileIterator() {}
|
| +
|
| +void PictureLayerTiling::TilingRasterTileIterator::AdvancePhase() {
|
| + DCHECK_LT(type_, EVENTUALLY);
|
| +
|
| + do {
|
| + type_ = static_cast<Type>(type_ + 1);
|
| + if (type_ == EVENTUALLY) {
|
| + spiral_iterator_ = TilingData::SpiralDifferenceIterator(
|
| + &tiling_->tiling_data_,
|
| + eventually_rect_in_content_space_,
|
| + skewport_in_content_space_,
|
| + visible_rect_in_content_space_);
|
| + }
|
| +
|
| + while (spiral_iterator_) {
|
| + current_tile_ = tiling_->TileAt(spiral_iterator_.index_x(),
|
| + spiral_iterator_.index_y());
|
| + if (current_tile_ && TileNeedsRaster(current_tile_))
|
| + break;
|
| + ++spiral_iterator_;
|
| + }
|
| +
|
| + if (!spiral_iterator_ && type_ == EVENTUALLY)
|
| + break;
|
| + } while (!spiral_iterator_);
|
| +}
|
| +
|
| +PictureLayerTiling::TilingRasterTileIterator&
|
| +PictureLayerTiling::TilingRasterTileIterator::
|
| +operator++() {
|
| + current_tile_ = NULL;
|
| + while (!current_tile_ || !TileNeedsRaster(current_tile_)) {
|
| + std::pair<int, int> next_index;
|
| + switch (type_) {
|
| + case VISIBLE:
|
| + ++visible_iterator_;
|
| + if (!visible_iterator_) {
|
| + AdvancePhase();
|
| + return *this;
|
| + }
|
| + next_index = visible_iterator_.index();
|
| + break;
|
| + case SKEWPORT:
|
| + ++spiral_iterator_;
|
| + if (!spiral_iterator_) {
|
| + AdvancePhase();
|
| + return *this;
|
| + }
|
| + next_index = spiral_iterator_.index();
|
| + break;
|
| + case EVENTUALLY:
|
| + ++spiral_iterator_;
|
| + if (!spiral_iterator_)
|
| + return *this;
|
| + next_index = spiral_iterator_.index();
|
| + break;
|
| + }
|
| + current_tile_ = tiling_->TileAt(next_index.first, next_index.second);
|
| + }
|
| + return *this;
|
| +}
|
| +
|
| } // namespace cc
|
|
|