Commit 3bc40f27 authored by vmpstr's avatar vmpstr Committed by Commit bot

Revert of cc: Remove tile sharing from tilings. (patchset #20 id:380001 of...

Revert of cc: Remove tile sharing from tilings. (patchset #20 id:380001 of https://codereview.chromium.org/1051993002/)

Reason for revert:
Several failures happened as a result.

Original issue's description:
> cc: Remove tile sharing from tilings.
>
> This patch removes sharing tiles from tilings. Previously, tiles
> that were not invalidated were shared between the pending and
> the active trees. With this patch, tiles that are exist on the
> active tree and are not invalidated are not created on the pending
> tree, resulting in fewer overall tiles. This improves performance
> of updating and managing tiles.
>
> Also, this patch opens up opportunities for a lot of code clean
> up that can otherwise be confusing when two trees are involved.
>
> R=danakj, enne
>
> Committed: https://crrev.com/0061b75e810f088900a0a8fbdd29ba5595c73016
> Cr-Commit-Position: refs/heads/master@{#326804}

TBR=enne@chromium.org,danakj@chromium.org,timford35@gmail.com
BUG=481421, 481509, 481480

Review URL: https://codereview.chromium.org/1108773003

Cr-Commit-Position: refs/heads/master@{#327093}
parent 631abee3
......@@ -418,9 +418,6 @@ bool TilingData::BaseDifferenceIterator::HasConsiderRect() const {
return consider_left_ != -1;
}
TilingData::DifferenceIterator::DifferenceIterator() {
}
TilingData::DifferenceIterator::DifferenceIterator(
const TilingData* tiling_data,
const gfx::Rect& consider_rect,
......
......@@ -132,7 +132,6 @@ class CC_EXPORT TilingData {
// with |consider| but which also do not intersect with |ignore|.
class CC_EXPORT DifferenceIterator : public BaseDifferenceIterator {
public:
DifferenceIterator();
DifferenceIterator(const TilingData* tiling_data,
const gfx::Rect& consider_rect,
const gfx::Rect& ignore_rect);
......
This diff is collapsed.
......@@ -33,8 +33,8 @@ class EvictionOrderComparator {
const Tile* a_tile = a_queue->Top();
const Tile* b_tile = b_queue->Top();
const TilePriority& a_priority = a_tile->priority();
const TilePriority& b_priority = b_tile->priority();
const TilePriority& a_priority = a_tile->combined_priority();
const TilePriority& b_priority = b_tile->combined_priority();
bool prioritize_low_res = tree_priority_ == SMOOTHNESS_TAKES_PRIORITY;
// If the priority bin differs, b is lower priority if it has the higher
......@@ -61,8 +61,8 @@ class EvictionOrderComparator {
// Otherwise if the occlusion differs, b is lower priority if it is
// occluded.
bool a_is_occluded = a_tile->is_occluded();
bool b_is_occluded = b_tile->is_occluded();
bool a_is_occluded = a_tile->is_occluded_combined();
bool b_is_occluded = b_tile->is_occluded_combined();
if (a_is_occluded != b_is_occluded)
return b_is_occluded;
......@@ -184,8 +184,8 @@ EvictionTilePriorityQueue::PairedTilingSetQueue::NextTileIteratorTree() const {
if (active_tile == pending_tile)
return ACTIVE_TREE;
const TilePriority& active_priority = active_tile->priority();
const TilePriority& pending_priority = pending_tile->priority();
const TilePriority& active_priority = active_tile->combined_priority();
const TilePriority& pending_priority = pending_tile->combined_priority();
// If the bins are the same and activation differs, then return the tree of
// the tile not required for activation.
......
This diff is collapsed.
......@@ -58,7 +58,6 @@ class CC_EXPORT PictureLayerTiling {
public:
static const int kBorderTexels = 1;
PictureLayerTilingClient* client() const { return client_; }
~PictureLayerTiling();
static float CalculateSoonBorderDistance(
......@@ -78,11 +77,8 @@ class CC_EXPORT PictureLayerTiling {
void Invalidate(const Region& layer_invalidation);
void SetRasterSourceOnTiles();
void CreateMissingTilesInLiveTilesRect();
void TakeTilesAndPropertiesFrom(PictureLayerTiling* pending_twin,
const Region& layer_invalidation);
bool IsTileRequiredForActivation(const Tile* tile) const;
bool IsTileRequiredForDraw(const Tile* tile) const;
void CloneTilesAndPropertiesFrom(const PictureLayerTiling& twin_tiling);
void set_resolution(TileResolution resolution) { resolution_ = resolution; }
TileResolution resolution() const { return resolution_; }
......@@ -99,32 +95,34 @@ class CC_EXPORT PictureLayerTiling {
Tile* TileAt(int i, int j) const {
TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j));
return iter == tiles_.end() ? nullptr : iter->second.get();
return (iter == tiles_.end()) ? NULL : iter->second.get();
}
bool has_tiles() const { return !tiles_.empty(); }
// For testing functionality.
void CreateAllTilesForTesting() {
SetLiveTilesRect(gfx::Rect(tiling_data_.tiling_size()));
}
const TilingData& TilingDataForTesting() const { return tiling_data_; }
std::vector<Tile*> AllTilesForTesting() const {
std::vector<Tile*> all_tiles;
for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it)
all_tiles.push_back(it->second.get());
return all_tiles;
}
void UpdateAllTilePrioritiesForTesting() {
for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it)
UpdateTileAndTwinPriority(it->second.get());
}
std::vector<scoped_refptr<Tile>> AllRefTilesForTesting() const {
std::vector<scoped_refptr<Tile>> all_tiles;
for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it)
all_tiles.push_back(it->second);
return all_tiles;
}
void SetAllTilesOccludedForTesting() {
gfx::Rect viewport_in_layer_space =
ScaleToEnclosingRect(current_visible_rect_, 1.0f / contents_scale_);
......@@ -133,10 +131,37 @@ class CC_EXPORT PictureLayerTiling {
SimpleEnclosedRegion(viewport_in_layer_space),
SimpleEnclosedRegion(viewport_in_layer_space));
}
const gfx::Rect& GetCurrentVisibleRectForTesting() const {
return current_visible_rect_;
}
bool IsTileOccluded(const Tile* tile) const;
bool IsTileRequiredForActivationIfVisible(const Tile* tile) const;
bool IsTileRequiredForDrawIfVisible(const Tile* tile) const;
void UpdateTileAndTwinPriority(Tile* tile) const;
TilePriority ComputePriorityForTile(const Tile* tile) const;
void UpdateRequiredStateForTile(Tile* tile, WhichTree tree) const;
bool has_visible_rect_tiles() const { return has_visible_rect_tiles_; }
bool has_skewport_rect_tiles() const { return has_skewport_rect_tiles_; }
bool has_soon_border_rect_tiles() const {
return has_soon_border_rect_tiles_;
}
bool has_eventually_rect_tiles() const { return has_eventually_rect_tiles_; }
const gfx::Rect& current_visible_rect() const {
return current_visible_rect_;
}
const gfx::Rect& current_skewport_rect() const {
return current_skewport_rect_;
}
const gfx::Rect& current_soon_border_rect() const {
return current_soon_border_rect_;
}
const gfx::Rect& current_eventually_rect() const {
return current_eventually_rect_;
}
void VerifyAllTilesHaveCurrentRasterSource() const;
// Iterate over all tiles to fill content_rect. Even if tiles are invalid
......@@ -211,6 +236,10 @@ class CC_EXPORT PictureLayerTiling {
const gfx::Rect& bounding_rect,
RectExpansionCache* cache);
bool has_ever_been_updated() const {
return visible_rect_history_[0].frame_time_in_seconds != 0.0;
}
protected:
friend class CoverageIterator;
friend class TilingSetRasterQueueAll;
......@@ -233,10 +262,12 @@ class CC_EXPORT PictureLayerTiling {
int skewport_extrapolation_limit_in_content_pixels);
void SetLiveTilesRect(const gfx::Rect& live_tiles_rect);
void VerifyLiveTilesRect(bool is_on_recycle_tree) const;
Tile* CreateTile(int i, int j);
Tile* CreateTile(int i,
int j,
const PictureLayerTiling* twin_tiling,
PictureLayerTiling* recycled_twin);
// Returns true if the Tile existed and was removed from the tiling.
bool RemoveTileAt(int i, int j);
bool TilingMatchesTileIndices(const PictureLayerTiling* twin) const;
bool RemoveTileAt(int i, int j, PictureLayerTiling* recycled_twin);
// Computes a skewport. The calculation extrapolates the last visible
// rect and the current visible rect to expand the skewport to where it
......@@ -247,13 +278,14 @@ class CC_EXPORT PictureLayerTiling {
const;
// Save the required data for computing tile priorities later.
void SetTilePriorityRects(float content_to_screen_scale_,
void UpdateTilePriorityRects(float content_to_screen_scale_,
const gfx::Rect& visible_rect_in_content_space,
const gfx::Rect& skewport,
const gfx::Rect& soon_border_rect,
const gfx::Rect& eventually_rect,
const Occlusion& occlusion_in_layer_space);
void UpdateTilePriorityForTree(Tile* tile, WhichTree tree) const;
bool NeedsUpdateForFrameAtTimeAndViewport(
double frame_time_in_seconds,
const gfx::Rect& viewport_in_layer_space) {
......@@ -272,43 +304,6 @@ class CC_EXPORT PictureLayerTiling {
if (visible_rect_history_[1].frame_time_in_seconds == 0.0)
visible_rect_history_[1] = visible_rect_history_[0];
}
bool IsTileOccludedOnCurrentTree(const Tile* tile) const;
bool ShouldCreateTileAt(int i, int j) const;
bool IsTileOccluded(const Tile* tile) const;
void UpdateTileAndTwinPriority(Tile* tile) const;
TilePriority ComputePriorityForTile(const Tile* tile) const;
bool has_visible_rect_tiles() const { return has_visible_rect_tiles_; }
bool has_skewport_rect_tiles() const { return has_skewport_rect_tiles_; }
bool has_soon_border_rect_tiles() const {
return has_soon_border_rect_tiles_;
}
bool has_eventually_rect_tiles() const { return has_eventually_rect_tiles_; }
const gfx::Rect& current_visible_rect() const {
return current_visible_rect_;
}
gfx::Rect pending_visible_rect() const {
const PictureLayerTiling* pending_tiling =
client_->GetTree() == ACTIVE_TREE
? client_->GetPendingOrActiveTwinTiling(this)
: this;
if (pending_tiling)
return pending_tiling->current_visible_rect();
return gfx::Rect();
}
const gfx::Rect& current_skewport_rect() const {
return current_skewport_rect_;
}
const gfx::Rect& current_soon_border_rect() const {
return current_soon_border_rect_;
}
const gfx::Rect& current_eventually_rect() const {
return current_eventually_rect_;
}
bool has_ever_been_updated() const {
return visible_rect_history_[0].frame_time_in_seconds != 0.0;
}
void RemoveTilesInRegion(const Region& layer_region, bool recreate_tiles);
const size_t max_tiles_for_interest_area_;
const float skewport_target_time_in_seconds_;
......
......@@ -55,8 +55,7 @@ PictureLayerTilingSet::~PictureLayerTilingSet() {
void PictureLayerTilingSet::CopyTilingsAndPropertiesFromPendingTwin(
const PictureLayerTilingSet* pending_twin_set,
const scoped_refptr<RasterSource>& raster_source,
const Region& layer_invalidation) {
const scoped_refptr<RasterSource>& raster_source) {
if (pending_twin_set->tilings_.empty()) {
// If the twin (pending) tiling set is empty, it was not updated for the
// current frame. So we drop tilings from our set as well, instead of
......@@ -78,8 +77,7 @@ void PictureLayerTilingSet::CopyTilingsAndPropertiesFromPendingTwin(
this_tiling = tilings_.back();
tiling_sort_required = true;
}
this_tiling->TakeTilesAndPropertiesFrom(pending_twin_tiling,
layer_invalidation);
this_tiling->CloneTilesAndPropertiesFrom(*pending_twin_tiling);
}
if (tiling_sort_required)
......@@ -97,8 +95,7 @@ void PictureLayerTilingSet::UpdateTilingsToCurrentRasterSourceForActivation(
// Copy over tilings that are shared with the |pending_twin_set| tiling set.
// Also, copy all of the properties from twin tilings.
CopyTilingsAndPropertiesFromPendingTwin(pending_twin_set, raster_source,
layer_invalidation);
CopyTilingsAndPropertiesFromPendingTwin(pending_twin_set, raster_source);
// If the tiling is not shared (FindTilingWithScale returns nullptr), then
// invalidate tiles and update them to the new raster source.
......@@ -149,9 +146,6 @@ void PictureLayerTilingSet::UpdateRasterSourceDueToLCDChange(
for (PictureLayerTiling* tiling : tilings_) {
tiling->SetRasterSourceAndResize(raster_source);
tiling->Invalidate(layer_invalidation);
// Since the invalidation changed, we need to create any missing tiles in
// the live tiles rect again.
tiling->CreateMissingTilesInLiveTilesRect();
tiling->VerifyAllTilesHaveCurrentRasterSource();
}
}
......
......@@ -179,8 +179,7 @@ class CC_EXPORT PictureLayerTilingSet {
void CopyTilingsAndPropertiesFromPendingTwin(
const PictureLayerTilingSet* pending_twin_set,
const scoped_refptr<RasterSource>& raster_source,
const Region& layer_invalidation);
const scoped_refptr<RasterSource>& raster_source);
// Remove one tiling.
void Remove(PictureLayerTiling* tiling);
......
......@@ -35,10 +35,28 @@ class RasterOrderComparator {
const Tile* a_tile = a_queue->Top();
const Tile* b_tile = b_queue->Top();
const TilePriority& a_priority = a_tile->priority();
const TilePriority& b_priority = b_tile->priority();
const TilePriority& a_priority =
a_tile->priority_for_tree_priority(tree_priority_);
const TilePriority& b_priority =
b_tile->priority_for_tree_priority(tree_priority_);
bool prioritize_low_res = tree_priority_ == SMOOTHNESS_TAKES_PRIORITY;
// In smoothness mode, we should return pending NOW tiles before active
// EVENTUALLY tiles. So if both priorities here are eventually, we need to
// check the pending priority.
if (prioritize_low_res &&
a_priority.priority_bin == TilePriority::EVENTUALLY &&
b_priority.priority_bin == TilePriority::EVENTUALLY) {
bool a_is_pending_now =
a_tile->priority(PENDING_TREE).priority_bin == TilePriority::NOW;
bool b_is_pending_now =
b_tile->priority(PENDING_TREE).priority_bin == TilePriority::NOW;
if (a_is_pending_now || b_is_pending_now)
return a_is_pending_now < b_is_pending_now;
// In case neither one is pending now, fall through.
}
// If the bin is the same but the resolution is not, then the order will be
// determined by whether we prioritize low res or not.
// TODO(vmpstr): Remove this when TilePriority is no longer a member of Tile
......@@ -66,15 +84,27 @@ class RasterOrderComparator {
WhichTree HigherPriorityTree(TreePriority tree_priority,
const TilingSetRasterQueueAll* active_queue,
const TilingSetRasterQueueAll* pending_queue) {
const Tile* active_tile = active_queue->Top();
const Tile* pending_tile = pending_queue->Top();
const TilePriority& active_priority = active_tile->priority();
const TilePriority& pending_priority = pending_tile->priority();
const TilingSetRasterQueueAll* pending_queue,
const Tile* shared_tile) {
// In cases when we're given an active tile with a non ideal active resolution
// (or pending tile with non ideal pending resolution), we should return the
// other tree. The reason for this is that tiling set iterators will not
// return non ideal tiles and the only way we get here is if we're skipping
// twin tiles, but since it's non-ideal on the twin, we shouldn't skip it.
// TODO(vmpstr): Remove when tiles aren't shared.
const Tile* active_tile = shared_tile ? shared_tile : active_queue->Top();
const Tile* pending_tile = shared_tile ? shared_tile : pending_queue->Top();
if (active_tile->priority(ACTIVE_TREE).resolution == NON_IDEAL_RESOLUTION)
return PENDING_TREE;
if (pending_tile->priority(PENDING_TREE).resolution == NON_IDEAL_RESOLUTION)
return ACTIVE_TREE;
switch (tree_priority) {
case SMOOTHNESS_TAKES_PRIORITY: {
const TilePriority& active_priority = active_tile->priority(ACTIVE_TREE);
const TilePriority& pending_priority =
pending_tile->priority(PENDING_TREE);
// If we're down to eventually bin tiles on the active tree, process the
// pending tree to allow tiles required for activation to be initialized
// when memory policy only allows prepaint.
......@@ -84,18 +114,13 @@ WhichTree HigherPriorityTree(TreePriority tree_priority,
}
return ACTIVE_TREE;
}
case NEW_CONTENT_TAKES_PRIORITY: {
// If we're down to soon bin tiles on the pending tree, process the
// active tree to allow tiles required for activation to be initialized
// when memory policy only allows prepaint. Note that active required for
// activation tiles might come from either now or soon bins.
if (pending_priority.priority_bin >= TilePriority::SOON &&
active_priority.priority_bin <= TilePriority::SOON) {
return ACTIVE_TREE;
}
case NEW_CONTENT_TAKES_PRIORITY:
return PENDING_TREE;
}
case SAME_PRIORITY_FOR_BOTH_TREES: {
const TilePriority& active_priority = active_tile->priority(ACTIVE_TREE);
const TilePriority& pending_priority =
pending_tile->priority(PENDING_TREE);
if (active_priority.IsHigherPriorityThan(pending_priority))
return ACTIVE_TREE;
return PENDING_TREE;
......@@ -165,7 +190,10 @@ RasterTilePriorityQueueAll::PairedTilingSetQueue::PairedTilingSetQueue(
: active_queue_(
CreateTilingSetRasterQueue(layer_pair.active, tree_priority)),
pending_queue_(
CreateTilingSetRasterQueue(layer_pair.pending, tree_priority)) {
CreateTilingSetRasterQueue(layer_pair.pending, tree_priority)),
has_both_layers_(layer_pair.active && layer_pair.pending) {
SkipTilesReturnedByTwin(tree_priority);
TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
"PairedTilingSetQueue::PairedTilingSetQueue",
TRACE_EVENT_SCOPE_THREAD, "state", StateAsValue());
......@@ -207,10 +235,40 @@ void RasterTilePriorityQueueAll::PairedTilingSetQueue::Pop(
DCHECK(returned_tiles_for_debug_.insert(next_queue->Top()).second);
next_queue->Pop();
SkipTilesReturnedByTwin(tree_priority);
// If no empty, use Top to do DCHECK the next iterator.
DCHECK(IsEmpty() || Top(tree_priority));
}
void RasterTilePriorityQueueAll::PairedTilingSetQueue::SkipTilesReturnedByTwin(
TreePriority tree_priority) {
if (!has_both_layers_)
return;
// We have both layers (active and pending) thus we can encounter shared
// tiles twice (from the active iterator and from the pending iterator).
while (!IsEmpty()) {
WhichTree next_tree = NextTileIteratorTree(tree_priority);
TilingSetRasterQueueAll* next_queue =
next_tree == ACTIVE_TREE ? active_queue_.get() : pending_queue_.get();
DCHECK(next_queue && !next_queue->IsEmpty());
// Accept all non-shared tiles.
const Tile* tile = next_queue->Top();
if (!tile->is_shared())
break;
// Accept a shared tile if the next tree is the higher priority one
// corresponding the iterator (active or pending) which usually (but due
// to spiral iterators not always) returns the shared tile first.
if (next_tree == HigherPriorityTree(tree_priority, nullptr, nullptr, tile))
break;
next_queue->Pop();
}
}
WhichTree
RasterTilePriorityQueueAll::PairedTilingSetQueue::NextTileIteratorTree(
TreePriority tree_priority) const {
......@@ -224,7 +282,7 @@ RasterTilePriorityQueueAll::PairedTilingSetQueue::NextTileIteratorTree(
// Now both iterators have tiles, so we have to decide based on tree priority.
return HigherPriorityTree(tree_priority, active_queue_.get(),
pending_queue_.get());
pending_queue_.get(), nullptr);
}
scoped_refptr<base::trace_event::ConvertableToTraceFormat>
......@@ -236,8 +294,10 @@ RasterTilePriorityQueueAll::PairedTilingSetQueue::StateAsValue() const {
TilePriority::PriorityBin active_priority_bin = TilePriority::EVENTUALLY;
TilePriority::PriorityBin pending_priority_bin = TilePriority::EVENTUALLY;
if (active_queue_has_tile) {
active_priority_bin = active_queue_->Top()->priority().priority_bin;
pending_priority_bin = active_queue_->Top()->priority().priority_bin;
active_priority_bin =
active_queue_->Top()->priority(ACTIVE_TREE).priority_bin;
pending_priority_bin =
active_queue_->Top()->priority(PENDING_TREE).priority_bin;
}
state->BeginDictionary("active_queue");
......@@ -250,8 +310,10 @@ RasterTilePriorityQueueAll::PairedTilingSetQueue::StateAsValue() const {
active_priority_bin = TilePriority::EVENTUALLY;
pending_priority_bin = TilePriority::EVENTUALLY;
if (pending_queue_has_tile) {
active_priority_bin = pending_queue_->Top()->priority().priority_bin;
pending_priority_bin = pending_queue_->Top()->priority().priority_bin;
active_priority_bin =
pending_queue_->Top()->priority(ACTIVE_TREE).priority_bin;
pending_priority_bin =
pending_queue_->Top()->priority(PENDING_TREE).priority_bin;
}
state->BeginDictionary("pending_queue");
......
......@@ -31,6 +31,7 @@ class CC_EXPORT RasterTilePriorityQueueAll : public RasterTilePriorityQueue {
void Pop(TreePriority tree_priority);
WhichTree NextTileIteratorTree(TreePriority tree_priority) const;
void SkipTilesReturnedByTwin(TreePriority tree_priority);
scoped_refptr<base::trace_event::ConvertableToTraceFormat> StateAsValue()
const;
......@@ -45,6 +46,7 @@ class CC_EXPORT RasterTilePriorityQueueAll : public RasterTilePriorityQueue {
private:
scoped_ptr<TilingSetRasterQueueAll> active_queue_;
scoped_ptr<TilingSetRasterQueueAll> pending_queue_;
bool has_both_layers_;
// Set of returned tiles (excluding the current one) for DCHECKing.
std::set<const Tile*> returned_tiles_for_debug_;
......
......@@ -18,48 +18,24 @@ void RasterTilePriorityQueueRequired::Build(
const std::vector<PictureLayerImpl::Pair>& paired_layers,
Type type) {
DCHECK_NE(static_cast<int>(type), static_cast<int>(Type::ALL));
if (type == Type::REQUIRED_FOR_DRAW)
BuildRequiredForDraw(paired_layers);
else
BuildRequiredForActivation(paired_layers);
}
void RasterTilePriorityQueueRequired::BuildRequiredForDraw(
const std::vector<PictureLayerImpl::Pair>& paired_layers) {
for (const auto& pair : paired_layers) {
if (!pair.active)
PictureLayerTilingSet* tiling_set = nullptr;
if (type == Type::REQUIRED_FOR_DRAW && pair.active)
tiling_set = pair.active->picture_layer_tiling_set();
else if (type == Type::REQUIRED_FOR_ACTIVATION && pair.pending)
tiling_set = pair.pending->picture_layer_tiling_set();
if (!tiling_set)
continue;
scoped_ptr<TilingSetRasterQueueRequired> tiling_set_queue(
new TilingSetRasterQueueRequired(
pair.active->picture_layer_tiling_set(), Type::REQUIRED_FOR_DRAW));
new TilingSetRasterQueueRequired(tiling_set, type));
if (tiling_set_queue->IsEmpty())
continue;
tiling_set_queues_.push_back(tiling_set_queue.Pass());
}
}
void RasterTilePriorityQueueRequired::BuildRequiredForActivation(
const std::vector<PictureLayerImpl::Pair>& paired_layers) {
for (const auto& pair : paired_layers) {
if (pair.active) {
scoped_ptr<TilingSetRasterQueueRequired> tiling_set_queue(
new TilingSetRasterQueueRequired(
pair.active->picture_layer_tiling_set(),
Type::REQUIRED_FOR_ACTIVATION));
if (!tiling_set_queue->IsEmpty())
tiling_set_queues_.push_back(tiling_set_queue.Pass());
}
if (pair.pending) {
scoped_ptr<TilingSetRasterQueueRequired> tiling_set_queue(
new TilingSetRasterQueueRequired(
pair.pending->picture_layer_tiling_set(),
Type::REQUIRED_FOR_ACTIVATION));
if (!tiling_set_queue->IsEmpty())
tiling_set_queues_.push_back(tiling_set_queue.Pass());
}
}
}
bool RasterTilePriorityQueueRequired::IsEmpty() const {
return tiling_set_queues_.empty();
}
......
......@@ -28,10 +28,6 @@ class RasterTilePriorityQueueRequired : public RasterTilePriorityQueue {
void Build(const std::vector<PictureLayerImpl::Pair>& paired_layers,
Type type);
void BuildRequiredForDraw(
const std::vector<PictureLayerImpl::Pair>& paired_layers);
void BuildRequiredForActivation(
const std::vector<PictureLayerImpl::Pair>& paired_layers);
ScopedPtrVector<TilingSetRasterQueueRequired> tiling_set_queues_;
......
......@@ -32,11 +32,14 @@ Tile::Tile(TileManager* tile_manager,
flags_(flags),
tiling_i_index_(-1),
tiling_j_index_(-1),
is_shared_(false),
required_for_activation_(false),
required_for_draw_(false),
id_(s_next_id_++),
scheduled_priority_(0) {
set_raster_source(raster_source);
for (int i = 0; i <= LAST_TREE; i++)
is_occluded_[i] = false;
}
Tile::~Tile() {
......@@ -59,11 +62,11 @@ void Tile::AsValueWithPriorityInto(const TilePriority& priority,
// TODO(vmpstr): Remove active and pending priority once tracing is using
// combined priority or at least can support both.
res->BeginDictionary("active_priority");
priority_.AsValueInto(res);
priority_[ACTIVE_TREE].AsValueInto(res);
res->EndDictionary();
res->BeginDictionary("pending_priority");
priority_.AsValueInto(res);
priority_[PENDING_TREE].AsValueInto(res);
res->EndDictionary();
res->BeginDictionary("combined_priority");
......@@ -76,7 +79,8 @@ void Tile::AsValueWithPriorityInto(const TilePriority& priority,
res->SetBoolean("has_resource", HasResource());
res->SetBoolean("is_using_gpu_memory", HasResource() || HasRasterTask());
res->SetString("resolution", TileResolutionToString(priority_.resolution));
res->SetString("resolution",
TileResolutionToString(combined_priority().resolution));
res->SetInteger("scheduled_priority", scheduled_priority_);
......
......@@ -31,13 +31,46 @@ class CC_EXPORT Tile : public RefCountedManaged<Tile> {
const RasterSource* raster_source() const { return raster_source_.get(); }
const TilePriority& priority() const { return priority_; }
const TilePriority& priority(WhichTree tree) const {
return priority_[tree];
}
TilePriority priority_for_tree_priority(TreePriority tree_priority) const {
switch (tree_priority) {
case SMOOTHNESS_TAKES_PRIORITY:
return priority_[ACTIVE_TREE];
case NEW_CONTENT_TAKES_PRIORITY:
return priority_[PENDING_TREE];
case SAME_PRIORITY_FOR_BOTH_TREES:
return combined_priority();
default:
NOTREACHED();
return TilePriority();
}
}
TilePriority combined_priority() const {
return TilePriority(priority_[ACTIVE_TREE],
priority_[PENDING_TREE]);
}
void set_priority(const TilePriority& priority) { priority_ = priority; }
void SetPriority(WhichTree tree, const TilePriority& priority) {
priority_[tree] = priority;
}
// TODO(vmpstr): Move this to the iterators.
void set_is_occluded(bool is_occluded) { is_occluded_ = is_occluded; }
bool is_occluded() const { return is_occluded_; }
void set_is_occluded(WhichTree tree, bool is_occluded) {
is_occluded_[tree] = is_occluded;
}
bool is_occluded(WhichTree tree) const { return is_occluded_[tree]; }
void set_shared(bool is_shared) { is_shared_ = is_shared; }
bool is_shared() const { return is_shared_; }
bool is_occluded_combined() const {
return is_occluded_[ACTIVE_TREE] && is_occluded_[PENDING_TREE];
}
// TODO(vmpstr): Move this to the iterators.
bool required_for_activation() const { return required_for_activation_; }
......@@ -75,7 +108,7 @@ class CC_EXPORT Tile : public RefCountedManaged<Tile> {
int source_frame_number() const { return source_frame_number_; }
void set_raster_source(RasterSource* raster_source) {
void set_raster_source(scoped_refptr<RasterSource> raster_source) {
DCHECK(raster_source->CoversRect(content_rect_, contents_scale_))
<< "Recording rect: "
<< gfx::ScaleToEnclosingRect(content_rect_, 1.f / contents_scale_)
......@@ -118,9 +151,9 @@ class CC_EXPORT Tile : public RefCountedManaged<Tile> {
gfx::Size desired_texture_size_;
gfx::Rect content_rect_;
float contents_scale_;
bool is_occluded_;
bool is_occluded_[LAST_TREE + 1];
TilePriority priority_;
TilePriority priority_[LAST_TREE + 1];
TileDrawInfo draw_info_;
int layer_id_;
......@@ -128,6 +161,7 @@ class CC_EXPORT Tile : public RefCountedManaged<Tile> {
int flags_;
int tiling_i_index_;
int tiling_j_index_;
bool is_shared_ : 1;
bool required_for_activation_ : 1;
bool required_for_draw_ : 1;
......
......@@ -451,7 +451,7 @@ TileManager::FreeTileResourcesWithLowerPriorityUntilUsageIsWithinLimit(
break;
Tile* tile = eviction_priority_queue->Top();
if (!other_priority.IsHigherPriorityThan(tile->priority()))
if (!other_priority.IsHigherPriorityThan(tile->combined_priority()))
break;
*usage -= MemoryUsage::FromTile(tile);
......@@ -506,7 +506,7 @@ void TileManager::AssignGpuMemoryToTiles(
scoped_ptr<EvictionTilePriorityQueue> eviction_priority_queue;
for (; !raster_priority_queue->IsEmpty(); raster_priority_queue->Pop()) {
Tile* tile = raster_priority_queue->Top();
TilePriority priority = tile->priority();
TilePriority priority = tile->combined_priority();
if (TilePriorityViolatesMemoryPolicy(priority)) {
TRACE_EVENT_INSTANT0(
......@@ -698,9 +698,9 @@ scoped_refptr<RasterTask> TileManager::CreateRasterTask(Tile* tile) {
return make_scoped_refptr(new RasterTaskImpl(
const_resource, tile->raster_source(), tile->content_rect(),
tile->contents_scale(), tile->priority().resolution, tile->layer_id(),
static_cast<const void*>(tile), tile->source_frame_number(),
tile->use_picture_analysis(),
tile->contents_scale(), tile->combined_priority().resolution,
tile->layer_id(), static_cast<const void*>(tile),
tile->source_frame_number(), tile->use_picture_analysis(),
base::Bind(&TileManager::OnRasterTaskCompleted, base::Unretained(this),
tile->id(), base::Passed(&resource)),
&decode_tasks));
......@@ -805,15 +805,6 @@ bool TileManager::AreRequiredTilesReadyToDraw(
if (!raster_priority_queue->Top()->IsReadyToDraw())
return false;
}
#if DCHECK_IS_ON()
scoped_ptr<RasterTilePriorityQueue> all_queue(
client_->BuildRasterQueue(global_state_.tree_priority, type));
for (; !all_queue->IsEmpty(); all_queue->Pop()) {
auto* tile = all_queue->Top();
DCHECK_IMPLIES(tile->required_for_activation(), tile->IsReadyToDraw());
}
#endif
return true;
}
bool TileManager::IsReadyToActivate() const {
......
This diff is collapsed.
This diff is collapsed.
......@@ -23,10 +23,6 @@ namespace cc {
// EVENTUALLY_RECT - Tiles in the eventually region of the tiling.
// SOON_BORDER_RECT - Tiles in the prepainting skirt of the tiling.
// SKEWPORT_RECT - Tiles in the skewport of the tiling.
// PENDING_VISIBLE_RECT - Tiles that will be visible upon activation, not
// required for activation.
// PENDING_VISIBLE_RECT_REQUIRED_FOR_ACTIVATION - Tiles that will be visible
// upon activation, required for activation.
// VISIBLE_RECT_OCCLUDED - Occluded, not required for activation, visible tiles.
// VISIBLE_RECT_UNOCCLUDED - Unoccluded, not required for activation, visible
// tiles.
......@@ -78,8 +74,6 @@ class CC_EXPORT TilingSetEvictionQueue {
EVENTUALLY_RECT,
SOON_BORDER_RECT,
SKEWPORT_RECT,
PENDING_VISIBLE_RECT,
PENDING_VISIBLE_RECT_REQUIRED_FOR_ACTIVATION,
VISIBLE_RECT_OCCLUDED,
VISIBLE_RECT_UNOCCLUDED,
VISIBLE_RECT_REQUIRED_FOR_ACTIVATION_OCCLUDED,
......@@ -94,8 +88,7 @@ class CC_EXPORT TilingSetEvictionQueue {
EvictionRectIterator();
EvictionRectIterator(std::vector<PictureLayerTiling*>* tilings,
WhichTree tree,
bool skip_shared_out_of_order_tiles,
bool skip_pending_visible_rect);
bool skip_shared_out_of_order_tiles);
bool done() const { return !tile_; }
Tile* operator*() const { return tile_; }
......@@ -112,27 +105,9 @@ class CC_EXPORT TilingSetEvictionQueue {
std::vector<PictureLayerTiling*>* tilings_;
WhichTree tree_;
bool skip_shared_out_of_order_tiles_;
bool skip_pending_visible_rect_;
size_t tiling_index_;
};
class PendingVisibleTilingIterator : public EvictionRectIterator {
public:
PendingVisibleTilingIterator() = default;
PendingVisibleTilingIterator(std::vector<PictureLayerTiling*>* tilings,
WhichTree tree,
bool skip_shared_out_of_order_tiles,
bool return_required_for_activation_tiles);
PendingVisibleTilingIterator& operator++();
private:
bool TileMatchesRequiredFlags(const Tile* tile) const;
TilingData::DifferenceIterator iterator_;
bool return_required_for_activation_tiles_;
};
class VisibleTilingIterator : public EvictionRectIterator {
public:
VisibleTilingIterator() = default;
......@@ -202,7 +177,6 @@ class CC_EXPORT TilingSetEvictionQueue {
EventuallyTilingIterator eventually_iterator_;
SoonBorderTilingIterator soon_iterator_;
SkewportTilingIterator skewport_iterator_;
PendingVisibleTilingIterator pending_visible_iterator_;
VisibleTilingIterator visible_iterator_;
};
......
This diff is collapsed.
......@@ -5,7 +5,6 @@
#ifndef CC_RESOURCES_TILING_SET_RASTER_QUEUE_ALL_H_
#define CC_RESOURCES_TILING_SET_RASTER_QUEUE_ALL_H_
#include "base/containers/stack_container.h"
#include "cc/base/cc_export.h"
#include "cc/resources/picture_layer_tiling_set.h"
#include "cc/resources/tile.h"
......@@ -65,18 +64,6 @@ class CC_EXPORT TilingSetRasterQueueAll {
TilingData::Iterator iterator_;
};
class PendingVisibleTilingIterator : public OnePriorityRectIterator {
public:
PendingVisibleTilingIterator() = default;
PendingVisibleTilingIterator(PictureLayerTiling* tiling,
TilingData* tiling_data);
PendingVisibleTilingIterator& operator++();
private:
TilingData::DifferenceIterator iterator_;
};
// Iterates over skewport only, spiral around the visible rect.
class SkewportTilingIterator : public OnePriorityRectIterator {
public:
......@@ -87,7 +74,6 @@ class CC_EXPORT TilingSetRasterQueueAll {
private:
TilingData::SpiralDifferenceIterator iterator_;
gfx::Rect pending_visible_rect_;
};
// Iterates over soon border only, spiral around the visible rect.
......@@ -101,7 +87,6 @@ class CC_EXPORT TilingSetRasterQueueAll {
private:
TilingData::SpiralDifferenceIterator iterator_;
gfx::Rect pending_visible_rect_;
};
// Iterates over eventually rect only, spiral around the soon rect.
......@@ -115,7 +100,6 @@ class CC_EXPORT TilingSetRasterQueueAll {
private:
TilingData::SpiralDifferenceIterator iterator_;
gfx::Rect pending_visible_rect_;
};
// Iterates over all of the above phases in the following order: visible,
......@@ -125,7 +109,7 @@ class CC_EXPORT TilingSetRasterQueueAll {
TilingIterator();
explicit TilingIterator(PictureLayerTiling* tiling,
TilingData* tiling_data);
~TilingIterator();
~TilingIterator() = default;
bool done() const { return current_tile_ == nullptr; }
const Tile* operator*() const { return current_tile_; }
......@@ -134,7 +118,6 @@ class CC_EXPORT TilingSetRasterQueueAll {
switch (phase_) {
case VISIBLE_RECT:
return TilePriority::NOW;
case PENDING_VISIBLE_RECT:
case SKEWPORT_RECT:
case SOON_BORDER_RECT:
return TilePriority::SOON;
......@@ -148,14 +131,8 @@ class CC_EXPORT TilingSetRasterQueueAll {
TilingIterator& operator++();
private:
// PENDING VISIBLE RECT refers to the visible rect that will become current
// upon activation (ie, the pending tree's visible rect). Tiles in this
// region that are not part of the current visible rect are all handled
// here. Note that when processing a pending tree, this rect is the same as
// the visible rect so no tiles are processed in this case.
enum Phase {
VISIBLE_RECT,
PENDING_VISIBLE_RECT,
SKEWPORT_RECT,
SOON_BORDER_RECT,
EVENTUALLY_RECT
......@@ -170,34 +147,26 @@ class CC_EXPORT TilingSetRasterQueueAll {
Tile* current_tile_;
VisibleTilingIterator visible_iterator_;
PendingVisibleTilingIterator pending_visible_iterator_;
SkewportTilingIterator skewport_iterator_;
SoonBorderTilingIterator soon_border_iterator_;
EventuallyTilingIterator eventually_iterator_;
};
enum IteratorType {
LOW_RES,
HIGH_RES,
ACTIVE_NON_IDEAL_PENDING_HIGH_RES,
NUM_ITERATORS
};
enum IteratorType { LOW_RES, HIGH_RES, NUM_ITERATORS };
void AdvanceToNextStage();
PictureLayerTilingSet* tiling_set_;
struct IterationStage {
IterationStage(IteratorType type, TilePriority::PriorityBin bin);
IteratorType iterator_type;
TilePriority::PriorityBin tile_type;
};
size_t current_stage_;
// The max number of stages is 6: 1 low res, 3 high res, and 2 active non
// ideal pending high res.
base::StackVector<IterationStage, 6> stages_;
// One low res stage, and three high res stages.
IterationStage stages_[4];
TilingIterator iterators_[NUM_ITERATORS];
};
......
......@@ -19,39 +19,19 @@ TilingSetRasterQueueRequired::TilingSetRasterQueueRequired(
DCHECK_NE(static_cast<int>(type),
static_cast<int>(RasterTilePriorityQueue::Type::ALL));
// Required tiles should only come from HIGH_RESOLUTION tilings. However, if
// we want required for activation tiles on the active tree, then it will come
// from tilings whose pending twin is high resolution.
PictureLayerTiling* tiling = nullptr;
if (type == RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION &&
tiling_set->client()->GetTree() == ACTIVE_TREE) {
for (size_t i = 0; i < tiling_set->num_tilings(); ++i) {
PictureLayerTiling* active_tiling = tiling_set->tiling_at(i);
const PictureLayerTiling* pending_twin =
tiling_set->client()->GetPendingOrActiveTwinTiling(active_tiling);
if (pending_twin && pending_twin->resolution() == HIGH_RESOLUTION) {
tiling = active_tiling;
break;
}
}
} else {
tiling = tiling_set->FindTilingWithResolution(HIGH_RESOLUTION);
}
// If we don't have a tiling, then this queue will yield no tiles. See
// PictureLayerImpl::CanHaveTilings for examples of when a HIGH_RESOLUTION
// Any type of required tile would only come from a high resolution tiling.
// The functions that determine this value is
// PictureLayerTiling::IsTileRequiredFor*, which all return false if the
// resolution is not HIGH_RESOLUTION.
PictureLayerTiling* tiling =
tiling_set->FindTilingWithResolution(HIGH_RESOLUTION);
// If we don't have a high res tiling, then this queue will yield no tiles.
// See PictureLayerImpl::CanHaveTilings for examples of when a HIGH_RESOLUTION
// tiling would not be generated.
if (!tiling)
return;
if (type == RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION) {
iterator_ = TilingIterator(tiling, &tiling->tiling_data_,
tiling->pending_visible_rect());
} else {
iterator_ = TilingIterator(tiling, &tiling->tiling_data_,
tiling->current_visible_rect());
}
iterator_ = TilingIterator(tiling, &tiling->tiling_data_);
while (!iterator_.done() && !IsTileRequired(*iterator_))
++iterator_;
}
......@@ -93,11 +73,19 @@ TilingSetRasterQueueRequired::TilingIterator::TilingIterator()
TilingSetRasterQueueRequired::TilingIterator::TilingIterator(
PictureLayerTiling* tiling,
TilingData* tiling_data,
const gfx::Rect& rect)
TilingData* tiling_data)
: tiling_(tiling), tiling_data_(tiling_data), current_tile_(nullptr) {
if (!tiling_->has_visible_rect_tiles()) {
// Verify that if we would create the iterator, then it would be empty (ie
// it would return false when evaluated as a bool).
DCHECK(!TilingData::Iterator(tiling_data_, tiling->current_visible_rect(),
false));
return;
}
visible_iterator_ =
TilingData::Iterator(tiling_data_, rect, false /* include_borders */);
TilingData::Iterator(tiling_data_, tiling_->current_visible_rect(),
false /* include_borders */);
if (!visible_iterator_)
return;
......
......@@ -34,8 +34,7 @@ class CC_EXPORT TilingSetRasterQueueRequired {
public:
TilingIterator();
explicit TilingIterator(PictureLayerTiling* tiling,
TilingData* tiling_data,
const gfx::Rect& rect);
TilingData* tiling_data);
~TilingIterator();
bool done() const { return current_tile_ == nullptr; }
......
......@@ -148,6 +148,9 @@ void FakePictureLayerImpl::CreateAllTiles() {
}
void FakePictureLayerImpl::SetAllTilesVisible() {
WhichTree tree =
layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE;
for (size_t tiling_idx = 0; tiling_idx < tilings_->num_tilings();
++tiling_idx) {
PictureLayerTiling* tiling = tilings_->tiling_at(tiling_idx);
......@@ -158,7 +161,7 @@ void FakePictureLayerImpl::SetAllTilesVisible() {
priority.resolution = HIGH_RESOLUTION;
priority.priority_bin = TilePriority::NOW;
priority.distance_to_visible = 0.f;
tile->set_priority(priority);
tile->SetPriority(tree, priority);
}
}
}
......@@ -170,7 +173,8 @@ void FakePictureLayerImpl::ResetAllTilesPriorities() {
std::vector<Tile*> tiles = tiling->AllTilesForTesting();
for (size_t tile_idx = 0; tile_idx < tiles.size(); ++tile_idx) {
Tile* tile = tiles[tile_idx];
tile->set_priority(TilePriority());
tile->SetPriority(ACTIVE_TREE, TilePriority());
tile->SetPriority(PENDING_TREE, TilePriority());
}
}
}
......@@ -256,14 +260,16 @@ size_t FakePictureLayerImpl::CountTilesRequiredForActivation() const {
if (!layer_tree_impl()->IsPendingTree())
return 0;
return CountTilesRequired(&PictureLayerTiling::IsTileRequiredForActivation);
return CountTilesRequired(
&PictureLayerTiling::IsTileRequiredForActivationIfVisible);
}
size_t FakePictureLayerImpl::CountTilesRequiredForDraw() const {
if (!layer_tree_impl()->IsActiveTree())
return 0;
return CountTilesRequired(&PictureLayerTiling::IsTileRequiredForDraw);
return CountTilesRequired(
&PictureLayerTiling::IsTileRequiredForDrawIfVisible);
}
void FakePictureLayerImpl::ReleaseResources() {
......
......@@ -242,8 +242,8 @@ class LayerTreeHostPictureTestChangeLiveTilesRectWithRecycleTree
EXPECT_TRUE(tiling->TileAt(0, 0));
EXPECT_FALSE(tiling->TileAt(0, num_tiles_y));
// The recycled tiling has no tiles.
EXPECT_FALSE(recycled_tiling->TileAt(0, 0));
// The recycled tiling matches it.
EXPECT_TRUE(recycled_tiling->TileAt(0, 0));
EXPECT_FALSE(recycled_tiling->TileAt(0, num_tiles_y));
// The live tiles rect matches on the recycled tree.
......@@ -266,6 +266,10 @@ class LayerTreeHostPictureTestChangeLiveTilesRectWithRecycleTree
// either.
EXPECT_FALSE(recycled_tiling->TileAt(0, 0));
// The live tiles rect matches on the recycled tree.
EXPECT_EQ(tiling->live_tiles_rect(),
recycled_tiling->live_tiles_rect());
// Make the top of the layer visible again.
picture_impl->SetPosition(gfx::PointF());
impl->SetNeedsRedraw();
......@@ -280,8 +284,8 @@ class LayerTreeHostPictureTestChangeLiveTilesRectWithRecycleTree
EXPECT_TRUE(tiling->TileAt(0, 0));
EXPECT_FALSE(tiling->TileAt(0, num_tiles_y));
// The recycled tiling should have no tiles.
EXPECT_FALSE(recycled_tiling->TileAt(0, 0));
// The recycled tiling should also have tiles at the top.
EXPECT_TRUE(recycled_tiling->TileAt(0, 0));
EXPECT_FALSE(recycled_tiling->TileAt(0, num_tiles_y));
// The live tiles rect matches on the recycled tree.
......@@ -304,15 +308,9 @@ class LayerTreeHostPictureTestChangeLiveTilesRectWithRecycleTree
PictureLayerTiling* tiling = picture_impl->HighResTiling();
int num_tiles_y = tiling->TilingDataForTesting().num_tiles_y();
if (!impl->active_tree()->root_layer()) {
// If active tree doesn't have the layer, then pending tree should have
// all needed tiles.
// The pending layer should always have tiles at the top of it each commit.
// The tile is part of the required for activation set so it should exist.
EXPECT_TRUE(tiling->TileAt(0, 0));
} else {
// Since there was no invalidation, the pending tree shouldn't have any
// tiles.
EXPECT_FALSE(tiling->TileAt(0, 0));
}
EXPECT_FALSE(tiling->TileAt(0, num_tiles_y));
if (did_post_commit_)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment