Commit 1fa20849 authored by vmpstr's avatar vmpstr Committed by Commit bot

cc: Refactored UpdateTilingsToCurrentRasterSource a bit; added comments

This patch is just a small refactor with a few more comments explaining
what this function is meant to do. I've been confused in the past when
trying to remember what this function does, so hopefully this helps...

R=danakj, enne

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

Cr-Commit-Position: refs/heads/master@{#318931}
parent 342edfc5
...@@ -53,48 +53,53 @@ PictureLayerTilingSet::PictureLayerTilingSet( ...@@ -53,48 +53,53 @@ PictureLayerTilingSet::PictureLayerTilingSet(
PictureLayerTilingSet::~PictureLayerTilingSet() { PictureLayerTilingSet::~PictureLayerTilingSet() {
} }
void PictureLayerTilingSet::UpdateTilingsToCurrentRasterSource( void PictureLayerTilingSet::CopyTilingsFromPendingTwin(
scoped_refptr<RasterSource> raster_source, const PictureLayerTilingSet* pending_twin_set,
const PictureLayerTilingSet* twin_set, const scoped_refptr<RasterSource>& raster_source) {
const Region& layer_invalidation, if (pending_twin_set->tilings_.empty()) {
float minimum_contents_scale,
float maximum_contents_scale) {
RemoveTilingsBelowScale(minimum_contents_scale);
RemoveTilingsAboveScale(maximum_contents_scale);
// Copy over tilings that are shared with the |twin_set| tiling set (if it
// exists).
if (twin_set) {
if (twin_set->tilings_.empty()) {
// If the twin (pending) tiling set is empty, it was not updated for the // 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 // current frame. So we drop tilings from our set as well, instead of
// leaving behind unshared tilings that are all non-ideal. // leaving behind unshared tilings that are all non-ideal.
RemoveAllTilings(); RemoveAllTilings();
} }
for (PictureLayerTiling* twin_tiling : twin_set->tilings_) { for (PictureLayerTiling* pending_twin_tiling : pending_twin_set->tilings_) {
float contents_scale = twin_tiling->contents_scale(); float contents_scale = pending_twin_tiling->contents_scale();
DCHECK_GE(contents_scale, minimum_contents_scale);
DCHECK_LE(contents_scale, maximum_contents_scale);
PictureLayerTiling* this_tiling = FindTilingWithScale(contents_scale); PictureLayerTiling* this_tiling = FindTilingWithScale(contents_scale);
if (!this_tiling) { if (!this_tiling) {
scoped_ptr<PictureLayerTiling> new_tiling = PictureLayerTiling::Create( scoped_ptr<PictureLayerTiling> new_tiling = PictureLayerTiling::Create(
contents_scale, raster_source, client_, contents_scale, raster_source, client_, max_tiles_for_interest_area_,
max_tiles_for_interest_area_, skewport_target_time_in_seconds_, skewport_target_time_in_seconds_,
skewport_extrapolation_limit_in_content_pixels_); skewport_extrapolation_limit_in_content_pixels_);
tilings_.push_back(new_tiling.Pass()); tilings_.push_back(new_tiling.Pass());
this_tiling = tilings_.back(); this_tiling = tilings_.back();
} }
this_tiling->CloneTilesAndPropertiesFrom(*twin_tiling); this_tiling->CloneTilesAndPropertiesFrom(*pending_twin_tiling);
}
} }
}
void PictureLayerTilingSet::UpdateTilingsToCurrentRasterSource(
scoped_refptr<RasterSource> raster_source,
const PictureLayerTilingSet* pending_twin_set,
const Region& layer_invalidation,
float minimum_contents_scale,
float maximum_contents_scale) {
RemoveTilingsBelowScale(minimum_contents_scale);
RemoveTilingsAboveScale(maximum_contents_scale);
// For unshared tilings, invalidate tiles and update them to the new raster // Copy over tilings that are shared with the |pending_twin_set| tiling set
// source. // (if it exists).
if (pending_twin_set)
CopyTilingsFromPendingTwin(pending_twin_set, raster_source);
// If the tiling is not shared (FindTilingWithScale returns nullptr) or if
// |this| is the sync set (pending_twin_set is nullptr), then invalidate
// tiles and update them to the new raster source.
for (PictureLayerTiling* tiling : tilings_) { for (PictureLayerTiling* tiling : tilings_) {
if (twin_set && twin_set->FindTilingWithScale(tiling->contents_scale())) if (pending_twin_set &&
pending_twin_set->FindTilingWithScale(tiling->contents_scale())) {
continue; continue;
}
tiling->SetRasterSourceAndResize(raster_source); tiling->SetRasterSourceAndResize(raster_source);
tiling->Invalidate(layer_invalidation); tiling->Invalidate(layer_invalidation);
...@@ -104,9 +109,9 @@ void PictureLayerTilingSet::UpdateTilingsToCurrentRasterSource( ...@@ -104,9 +109,9 @@ void PictureLayerTilingSet::UpdateTilingsToCurrentRasterSource(
// raster source. // raster source.
tiling->CreateMissingTilesInLiveTilesRect(); tiling->CreateMissingTilesInLiveTilesRect();
// If |twin_set| is present, use the resolutions from there. Otherwise leave // If |pending_twin_set| is present, then |this| is active and |tiling| is
// all resolutions as they are. // not in the pending set, which means it is now NON_IDEAL_RESOLUTION.
if (twin_set) if (pending_twin_set)
tiling->set_resolution(NON_IDEAL_RESOLUTION); tiling->set_resolution(NON_IDEAL_RESOLUTION);
} }
...@@ -126,11 +131,12 @@ void PictureLayerTilingSet::UpdateTilingsToCurrentRasterSource( ...@@ -126,11 +131,12 @@ void PictureLayerTilingSet::UpdateTilingsToCurrentRasterSource(
DCHECK_LE(NumHighResTilings(), 1); DCHECK_LE(NumHighResTilings(), 1);
// When commiting from the main thread the high res tiling may get dropped, // When commiting from the main thread the high res tiling may get dropped,
// but when cloning to the active tree, there should always be one. // but when cloning to the active tree, there should always be one.
if (twin_set) { if (pending_twin_set) {
DCHECK_EQ(1, NumHighResTilings()) DCHECK_EQ(1, NumHighResTilings())
<< " num tilings on active: " << tilings_.size() << " num tilings on active: " << tilings_.size()
<< " num tilings on pending: " << twin_set->tilings_.size() << " num tilings on pending: " << pending_twin_set->tilings_.size()
<< " num high res on pending: " << twin_set->NumHighResTilings() << " num high res on pending: "
<< pending_twin_set->NumHighResTilings()
<< " are on active tree: " << (client_->GetTree() == ACTIVE_TREE); << " are on active tree: " << (client_->GetTree() == ACTIVE_TREE);
} }
} }
......
...@@ -55,9 +55,15 @@ class CC_EXPORT PictureLayerTilingSet { ...@@ -55,9 +55,15 @@ class CC_EXPORT PictureLayerTilingSet {
PictureLayerTilingSet* recycled_twin_set); PictureLayerTilingSet* recycled_twin_set);
void RemoveNonIdealTilings(); void RemoveNonIdealTilings();
// This function can be called on both the active and pending tree.
// |pending_twin_set| represents the current pending twin. In situations where
// this is called on the active tree in two trees situations,
// |pending_twin_set| represents the tiling set from the pending twin layer.
// In situations where this is called on the sync tree (whether it's pending
// or active in cases of one tree), |pending_twin_set| should be nullptr.
void UpdateTilingsToCurrentRasterSource( void UpdateTilingsToCurrentRasterSource(
scoped_refptr<RasterSource> raster_source, scoped_refptr<RasterSource> raster_source,
const PictureLayerTilingSet* twin_set, const PictureLayerTilingSet* pending_twin_set,
const Region& layer_invalidation, const Region& layer_invalidation,
float minimum_contents_scale, float minimum_contents_scale,
float maximum_contents_scale); float maximum_contents_scale);
...@@ -163,6 +169,10 @@ class CC_EXPORT PictureLayerTilingSet { ...@@ -163,6 +169,10 @@ class CC_EXPORT PictureLayerTilingSet {
float skewport_target_time_in_seconds, float skewport_target_time_in_seconds,
int skewport_extrapolation_limit_in_content_pixels); int skewport_extrapolation_limit_in_content_pixels);
void CopyTilingsFromPendingTwin(
const PictureLayerTilingSet* pending_twin_set,
const scoped_refptr<RasterSource>& raster_source);
// Remove one tiling. // Remove one tiling.
void Remove(PictureLayerTiling* tiling); void Remove(PictureLayerTiling* tiling);
......
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