Commit 4b219b20 authored by enne's avatar enne Committed by Commit bot

cc: Remove invalidation history

Now that Blink handles animated gifs, this code is not needed.

BUG=467197

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

Cr-Commit-Position: refs/heads/master@{#324084}
parent a22ce7ae
...@@ -95,7 +95,6 @@ void PictureLayer::SetLayerTreeHost(LayerTreeHost* host) { ...@@ -95,7 +95,6 @@ void PictureLayer::SetLayerTreeHost(LayerTreeHost* host) {
host->settings().default_tile_grid_size)); host->settings().default_tile_grid_size));
} }
} }
recording_source_->DidMoveToNewCompositor();
recording_source_->SetSlowdownRasterScaleFactor( recording_source_->SetSlowdownRasterScaleFactor(
host->debug_state().slow_down_raster_scale_factor); host->debug_state().slow_down_raster_scale_factor);
recording_source_->SetGatherPixelRefs(host->settings().gather_pixel_refs); recording_source_->SetGatherPixelRefs(host->settings().gather_pixel_refs);
......
...@@ -123,10 +123,6 @@ bool DisplayListRecordingSource::UpdateAndExpandInvalidation( ...@@ -123,10 +123,6 @@ bool DisplayListRecordingSource::UpdateAndExpandInvalidation(
return true; return true;
} }
void DisplayListRecordingSource::DidMoveToNewCompositor() {
// No invalidation history to worry about here.
}
gfx::Size DisplayListRecordingSource::GetSize() const { gfx::Size DisplayListRecordingSource::GetSize() const {
return size_; return size_;
} }
......
...@@ -24,7 +24,6 @@ class CC_EXPORT DisplayListRecordingSource : public RecordingSource { ...@@ -24,7 +24,6 @@ class CC_EXPORT DisplayListRecordingSource : public RecordingSource {
const gfx::Rect& visible_layer_rect, const gfx::Rect& visible_layer_rect,
int frame_number, int frame_number,
RecordingMode recording_mode) override; RecordingMode recording_mode) override;
void DidMoveToNewCompositor() override;
scoped_refptr<RasterSource> CreateRasterSource( scoped_refptr<RasterSource> CreateRasterSource(
bool can_use_lcd_text) const override; bool can_use_lcd_text) const override;
gfx::Size GetSize() const final; gfx::Size GetSize() const final;
......
...@@ -25,16 +25,6 @@ const int kOpCountThatIsOkToAnalyze = 10; ...@@ -25,16 +25,6 @@ const int kOpCountThatIsOkToAnalyze = 10;
// the base picture in each tile. // the base picture in each tile.
const int kBasePictureSize = 512; const int kBasePictureSize = 512;
// Invalidation frequency settings. kInvalidationFrequencyThreshold is a value
// between 0 and 1 meaning invalidation frequency between 0% and 100% that
// indicates when to stop invalidating offscreen regions.
// kFrequentInvalidationDistanceThreshold defines what it means to be
// "offscreen" in terms of distance to visible in css pixels.
// TODO(vmpstr): Remove invalidation frequency after frequently invalidated
// content is not painted at a higher level.
const float kInvalidationFrequencyThreshold = 0.75f;
const int kFrequentInvalidationDistanceThreshold = 1024;
// TODO(humper): The density threshold here is somewhat arbitrary; need a // TODO(humper): The density threshold here is somewhat arbitrary; need a
// way to set // this from the command line so we can write a benchmark // way to set // this from the command line so we can write a benchmark
// script and find a sweet spot. // script and find a sweet spot.
...@@ -216,11 +206,6 @@ bool PicturePile::UpdateAndExpandInvalidation( ...@@ -216,11 +206,6 @@ bool PicturePile::UpdateAndExpandInvalidation(
return true; return true;
} }
void PicturePile::DidMoveToNewCompositor() {
for (auto& map_pair : picture_map_)
map_pair.second.ResetInvalidationHistory();
}
bool PicturePile::ApplyInvalidationAndResize(const gfx::Rect& interest_rect, bool PicturePile::ApplyInvalidationAndResize(const gfx::Rect& interest_rect,
Region* invalidation, Region* invalidation,
const gfx::Size& layer_size, const gfx::Size& layer_size,
...@@ -265,7 +250,7 @@ bool PicturePile::ApplyInvalidationAndResize(const gfx::Rect& interest_rect, ...@@ -265,7 +250,7 @@ bool PicturePile::ApplyInvalidationAndResize(const gfx::Rect& interest_rect,
for (const auto& key_picture_pair : picture_map_) { for (const auto& key_picture_pair : picture_map_) {
const PictureMapKey& key = key_picture_pair.first; const PictureMapKey& key = key_picture_pair.first;
if (key.first < min_toss_x && key.second < min_toss_y) { if (key.first < min_toss_x && key.second < min_toss_y) {
has_any_recordings_ |= !!key_picture_pair.second.GetPicture(); has_any_recordings_ = true;
continue; continue;
} }
to_erase.push_back(key); to_erase.push_back(key);
...@@ -437,8 +422,8 @@ bool PicturePile::ApplyInvalidationAndResize(const gfx::Rect& interest_rect, ...@@ -437,8 +422,8 @@ bool PicturePile::ApplyInvalidationAndResize(const gfx::Rect& interest_rect,
// can just drop/invalidate everything. // can just drop/invalidate everything.
if (invalidation->Contains(gfx::Rect(old_tiling_size)) || if (invalidation->Contains(gfx::Rect(old_tiling_size)) ||
invalidation->Contains(gfx::Rect(GetSize()))) { invalidation->Contains(gfx::Rect(GetSize()))) {
for (auto& it : picture_map_) updated = !picture_map_.empty();
updated = it.second.Invalidate(frame_number) || updated; picture_map_.clear();
} else { } else {
// Expand invalidation that is on tiles that aren't in the interest rect and // Expand invalidation that is on tiles that aren't in the interest rect and
// will not be re-recorded below. These tiles are no longer valid and should // will not be re-recorded below. These tiles are no longer valid and should
...@@ -478,8 +463,9 @@ bool PicturePile::ApplyInvalidationAndResize(const gfx::Rect& interest_rect, ...@@ -478,8 +463,9 @@ bool PicturePile::ApplyInvalidationAndResize(const gfx::Rect& interest_rect,
if (picture_it == picture_map_.end()) if (picture_it == picture_map_.end())
continue; continue;
// Inform the grid cell that it has been invalidated in this frame. updated = true;
updated = picture_it->second.Invalidate(frame_number) || updated; picture_map_.erase(key);
// Invalidate drops the picture so the whole tile better be invalidated // Invalidate drops the picture so the whole tile better be invalidated
// if it won't be re-recorded below. // if it won't be re-recorded below.
DCHECK_IMPLIES(!tiling_.TileBounds(key.first, key.second) DCHECK_IMPLIES(!tiling_.TileBounds(key.first, key.second)
...@@ -506,29 +492,8 @@ void PicturePile::GetInvalidTileRects(const gfx::Rect& interest_rect, ...@@ -506,29 +492,8 @@ void PicturePile::GetInvalidTileRects(const gfx::Rect& interest_rect,
for (TilingData::Iterator it(&tiling_, interest_rect, include_borders); it; for (TilingData::Iterator it(&tiling_, interest_rect, include_borders); it;
++it) { ++it) {
const PictureMapKey& key = it.index(); const PictureMapKey& key = it.index();
PictureInfo& info = picture_map_[key]; if (picture_map_.find(key) == picture_map_.end())
invalid_tiles->push_back(tiling_.TileBounds(key.first, key.second));
gfx::Rect rect = PaddedRect(key);
int distance_to_visible =
rect.ManhattanInternalDistance(visible_layer_rect);
if (info.NeedsRecording(frame_number, distance_to_visible)) {
gfx::Rect tile = tiling_.TileBounds(key.first, key.second);
invalid_tiles->push_back(tile);
} else if (!info.GetPicture()) {
if (recorded_viewport_.Intersects(rect)) {
// Recorded viewport is just an optimization for a fully recorded
// interest rect. In this case, a tile in that rect has declined
// to be recorded (probably due to frequent invalidations).
// TODO(enne): Shrink the recorded_viewport_ rather than clearing.
recorded_viewport_ = gfx::Rect();
}
// If a tile in the interest rect is not recorded, the entire tile needs
// to be considered invalid, so that we know not to keep around raster
// tiles that intersect this recording tile.
invalidation->Union(tiling_.TileBounds(it.index_x(), it.index_y()));
}
} }
} }
...@@ -570,8 +535,7 @@ void PicturePile::CreatePictures(ContentLayerClient* painter, ...@@ -570,8 +535,7 @@ void PicturePile::CreatePictures(ContentLayerClient* painter,
const PictureMapKey& key = it.index(); const PictureMapKey& key = it.index();
gfx::Rect tile = PaddedRect(key); gfx::Rect tile = PaddedRect(key);
if (padded_record_rect.Contains(tile)) { if (padded_record_rect.Contains(tile)) {
PictureInfo& info = picture_map_[key]; picture_map_[key] = picture;
info.SetPicture(picture);
found_tile_for_recorded_picture = true; found_tile_for_recorded_picture = true;
} }
} }
...@@ -657,8 +621,6 @@ bool PicturePile::CanRasterSlowTileCheck(const gfx::Rect& layer_rect) const { ...@@ -657,8 +621,6 @@ bool PicturePile::CanRasterSlowTileCheck(const gfx::Rect& layer_rect) const {
PictureMap::const_iterator map_iter = picture_map_.find(tile_iter.index()); PictureMap::const_iterator map_iter = picture_map_.find(tile_iter.index());
if (map_iter == picture_map_.end()) if (map_iter == picture_map_.end())
return false; return false;
if (!map_iter->second.GetPicture())
return false;
} }
return true; return true;
} }
...@@ -672,7 +634,7 @@ void PicturePile::DetermineIfSolidColor() { ...@@ -672,7 +634,7 @@ void PicturePile::DetermineIfSolidColor() {
} }
PictureMap::const_iterator it = picture_map_.begin(); PictureMap::const_iterator it = picture_map_.begin();
const Picture* picture = it->second.GetPicture(); const Picture* picture = it->second.get();
// Missing recordings due to frequent invalidations or being too far away // Missing recordings due to frequent invalidations or being too far away
// from the interest rect will cause the a null picture to exist. // from the interest rect will cause the a null picture to exist.
...@@ -685,7 +647,7 @@ void PicturePile::DetermineIfSolidColor() { ...@@ -685,7 +647,7 @@ void PicturePile::DetermineIfSolidColor() {
// Make sure all of the mapped images point to the same picture. // Make sure all of the mapped images point to the same picture.
for (++it; it != picture_map_.end(); ++it) { for (++it; it != picture_map_.end(); ++it) {
if (it->second.GetPicture() != picture) if (it->second.get() != picture)
return; return;
} }
...@@ -715,48 +677,6 @@ void PicturePile::Clear() { ...@@ -715,48 +677,6 @@ void PicturePile::Clear() {
is_solid_color_ = false; is_solid_color_ = false;
} }
PicturePile::PictureInfo::PictureInfo() : last_frame_number_(0) {
}
PicturePile::PictureInfo::~PictureInfo() {
}
void PicturePile::PictureInfo::AdvanceInvalidationHistory(int frame_number) {
DCHECK_GE(frame_number, last_frame_number_);
if (frame_number == last_frame_number_)
return;
invalidation_history_ <<= (frame_number - last_frame_number_);
last_frame_number_ = frame_number;
}
bool PicturePile::PictureInfo::Invalidate(int frame_number) {
AdvanceInvalidationHistory(frame_number);
invalidation_history_.set(0);
bool did_invalidate = !!picture_.get();
picture_ = NULL;
return did_invalidate;
}
bool PicturePile::PictureInfo::NeedsRecording(int frame_number,
int distance_to_visible) {
AdvanceInvalidationHistory(frame_number);
// We only need recording if we don't have a picture. Furthermore, we only
// need a recording if we're within frequent invalidation distance threshold
// or the invalidation is not frequent enough (below invalidation frequency
// threshold).
return !picture_.get() &&
((distance_to_visible <= kFrequentInvalidationDistanceThreshold) ||
(GetInvalidationFrequency() < kInvalidationFrequencyThreshold));
}
void PicturePile::PictureInfo::ResetInvalidationHistory() {
invalidation_history_.reset();
last_frame_number_ = 0;
}
void PicturePile::SetBufferPixels(int new_buffer_pixels) { void PicturePile::SetBufferPixels(int new_buffer_pixels) {
if (new_buffer_pixels == buffer_pixels()) if (new_buffer_pixels == buffer_pixels())
return; return;
...@@ -765,17 +685,4 @@ void PicturePile::SetBufferPixels(int new_buffer_pixels) { ...@@ -765,17 +685,4 @@ void PicturePile::SetBufferPixels(int new_buffer_pixels) {
tiling_.SetBorderTexels(new_buffer_pixels); tiling_.SetBorderTexels(new_buffer_pixels);
} }
void PicturePile::PictureInfo::SetPicture(scoped_refptr<Picture> picture) {
picture_ = picture;
}
const Picture* PicturePile::PictureInfo::GetPicture() const {
return picture_.get();
}
float PicturePile::PictureInfo::GetInvalidationFrequency() const {
return invalidation_history_.count() /
static_cast<float>(INVALIDATION_FRAMES_TRACKED);
}
} // namespace cc } // namespace cc
...@@ -29,7 +29,6 @@ class CC_EXPORT PicturePile : public RecordingSource { ...@@ -29,7 +29,6 @@ class CC_EXPORT PicturePile : public RecordingSource {
const gfx::Rect& visible_layer_rect, const gfx::Rect& visible_layer_rect,
int frame_number, int frame_number,
RecordingMode recording_mode) override; RecordingMode recording_mode) override;
void DidMoveToNewCompositor() override;
scoped_refptr<RasterSource> CreateRasterSource( scoped_refptr<RasterSource> CreateRasterSource(
bool can_use_lcd_text) const override; bool can_use_lcd_text) const override;
gfx::Size GetSize() const final; gfx::Size GetSize() const final;
...@@ -42,36 +41,9 @@ class CC_EXPORT PicturePile : public RecordingSource { ...@@ -42,36 +41,9 @@ class CC_EXPORT PicturePile : public RecordingSource {
void SetUnsuitableForGpuRasterizationForTesting() override; void SetUnsuitableForGpuRasterizationForTesting() override;
gfx::Size GetTileGridSizeForTesting() const override; gfx::Size GetTileGridSizeForTesting() const override;
protected:
class CC_EXPORT PictureInfo {
public:
enum { INVALIDATION_FRAMES_TRACKED = 32 };
PictureInfo();
~PictureInfo();
bool Invalidate(int frame_number);
bool NeedsRecording(int frame_number, int distance_to_visible);
void SetPicture(scoped_refptr<Picture> picture);
const Picture* GetPicture() const;
float GetInvalidationFrequencyForTesting() const {
return GetInvalidationFrequency();
}
void ResetInvalidationHistory();
private:
void AdvanceInvalidationHistory(int frame_number);
float GetInvalidationFrequency() const;
int last_frame_number_;
scoped_refptr<const Picture> picture_;
std::bitset<INVALIDATION_FRAMES_TRACKED> invalidation_history_;
};
typedef std::pair<int, int> PictureMapKey; typedef std::pair<int, int> PictureMapKey;
typedef base::hash_map<PictureMapKey, PictureInfo> PictureMap; typedef base::hash_map<PictureMapKey, scoped_refptr<const Picture>>
PictureMap;
// An internal CanRaster check that goes to the picture_map rather than // An internal CanRaster check that goes to the picture_map rather than
// using the recorded_viewport hint. // using the recorded_viewport hint.
......
...@@ -135,10 +135,8 @@ void PicturePileImpl::CoalesceRasters(const gfx::Rect& canvas_rect, ...@@ -135,10 +135,8 @@ void PicturePileImpl::CoalesceRasters(const gfx::Rect& canvas_rect,
PictureMap::const_iterator map_iter = picture_map_.find(tile_iter.index()); PictureMap::const_iterator map_iter = picture_map_.find(tile_iter.index());
if (map_iter == picture_map_.end()) if (map_iter == picture_map_.end())
continue; continue;
const PictureInfo& info = map_iter->second; const Picture* picture = map_iter->second.get();
const Picture* picture = info.GetPicture(); DCHECK(picture);
if (!picture)
continue;
// This is intentionally *enclosed* rect, so that the clip is aligned on // This is intentionally *enclosed* rect, so that the clip is aligned on
// integral post-scale content pixels and does not extend past the edges // integral post-scale content pixels and does not extend past the edges
...@@ -269,8 +267,8 @@ size_t PicturePileImpl::GetPictureMemoryUsage() const { ...@@ -269,8 +267,8 @@ size_t PicturePileImpl::GetPictureMemoryUsage() const {
size_t total_size = 0; size_t total_size = 0;
std::set<const Picture*> pictures_seen; std::set<const Picture*> pictures_seen;
for (const auto& map_value : picture_map_) { for (const auto& map_value : picture_map_) {
const Picture* picture = map_value.second.GetPicture(); const Picture* picture = map_value.second.get();
if (picture && pictures_seen.insert(picture).second) if (pictures_seen.insert(picture).second)
total_size += picture->ApproximateMemoryUsage(); total_size += picture->ApproximateMemoryUsage();
} }
...@@ -357,8 +355,6 @@ bool PicturePileImpl::CanRasterSlowTileCheck( ...@@ -357,8 +355,6 @@ bool PicturePileImpl::CanRasterSlowTileCheck(
PictureMap::const_iterator map_iter = picture_map_.find(tile_iter.index()); PictureMap::const_iterator map_iter = picture_map_.find(tile_iter.index());
if (map_iter == picture_map_.end()) if (map_iter == picture_map_.end())
return false; return false;
if (!map_iter->second.GetPicture())
return false;
} }
return true; return true;
} }
...@@ -382,8 +378,8 @@ void PicturePileImpl::AsValueInto( ...@@ -382,8 +378,8 @@ void PicturePileImpl::AsValueInto(
if (map_iter == picture_map_.end()) if (map_iter == picture_map_.end())
continue; continue;
const Picture* picture = map_iter->second.GetPicture(); const Picture* picture = map_iter->second.get();
if (picture && (appended_pictures.count(picture) == 0)) { if (appended_pictures.count(picture) == 0) {
appended_pictures.insert(picture); appended_pictures.insert(picture);
TracedValue::AppendIDRef(picture, pictures); TracedValue::AppendIDRef(picture, pictures);
} }
...@@ -439,8 +435,8 @@ void PicturePileImpl::PixelRefIterator::AdvanceToTilePictureWithPixelRefs() { ...@@ -439,8 +435,8 @@ void PicturePileImpl::PixelRefIterator::AdvanceToTilePictureWithPixelRefs() {
if (it == picture_pile_->picture_map_.end()) if (it == picture_pile_->picture_map_.end())
continue; continue;
const Picture* picture = it->second.GetPicture(); const Picture* picture = it->second.get();
if (!picture || (processed_pictures_.count(picture) != 0) || if ((processed_pictures_.count(picture) != 0) ||
!picture->WillPlayBackBitmaps()) !picture->WillPlayBackBitmaps())
continue; continue;
...@@ -454,8 +450,8 @@ void PicturePileImpl::PixelRefIterator::AdvanceToTilePictureWithPixelRefs() { ...@@ -454,8 +450,8 @@ void PicturePileImpl::PixelRefIterator::AdvanceToTilePictureWithPixelRefs() {
void PicturePileImpl::DidBeginTracing() { void PicturePileImpl::DidBeginTracing() {
std::set<const void*> processed_pictures; std::set<const void*> processed_pictures;
for (const auto& map_pair : picture_map_) { for (const auto& map_pair : picture_map_) {
const Picture* picture = map_pair.second.GetPicture(); const Picture* picture = map_pair.second.get();
if (picture && (processed_pictures.count(picture) == 0)) { if (processed_pictures.count(picture) == 0) {
picture->EmitTraceSnapshot(); picture->EmitTraceSnapshot();
processed_pictures.insert(picture); processed_pictures.insert(picture);
} }
......
...@@ -96,10 +96,8 @@ class CC_EXPORT PicturePileImpl : public RasterSource { ...@@ -96,10 +96,8 @@ class CC_EXPORT PicturePileImpl : public RasterSource {
friend class PicturePile; friend class PicturePile;
friend class PixelRefIterator; friend class PixelRefIterator;
// TODO(vmpstr): Change this when pictures are split from invalidation info.
using PictureMapKey = PicturePile::PictureMapKey; using PictureMapKey = PicturePile::PictureMapKey;
using PictureMap = PicturePile::PictureMap; using PictureMap = PicturePile::PictureMap;
using PictureInfo = PicturePile::PictureInfo;
PicturePileImpl(); PicturePileImpl();
explicit PicturePileImpl(const PicturePile* other, bool can_use_lcd_text); explicit PicturePileImpl(const PicturePile* other, bool can_use_lcd_text);
......
This diff is collapsed.
...@@ -39,8 +39,6 @@ class CC_EXPORT RecordingSource { ...@@ -39,8 +39,6 @@ class CC_EXPORT RecordingSource {
int frame_number, int frame_number,
RecordingMode recording_mode) = 0; RecordingMode recording_mode) = 0;
virtual void DidMoveToNewCompositor() = 0;
virtual scoped_refptr<RasterSource> CreateRasterSource( virtual scoped_refptr<RasterSource> CreateRasterSource(
bool can_use_lcd_text) const = 0; bool can_use_lcd_text) const = 0;
......
...@@ -68,7 +68,7 @@ void FakePicturePile::AddRecordingAt(int x, int y) { ...@@ -68,7 +68,7 @@ void FakePicturePile::AddRecordingAt(int x, int y) {
scoped_refptr<Picture> picture( scoped_refptr<Picture> picture(
Picture::Create(bounds, &client_, tile_grid_size_, gather_pixel_refs_, Picture::Create(bounds, &client_, tile_grid_size_, gather_pixel_refs_,
RecordingSource::RECORD_NORMALLY)); RecordingSource::RECORD_NORMALLY));
picture_map_[std::pair<int, int>(x, y)].SetPicture(picture); picture_map_[std::pair<int, int>(x, y)] = picture;
EXPECT_TRUE(HasRecordingAt(x, y)); EXPECT_TRUE(HasRecordingAt(x, y));
has_any_recordings_ = true; has_any_recordings_ = true;
...@@ -88,9 +88,7 @@ void FakePicturePile::RemoveRecordingAt(int x, int y) { ...@@ -88,9 +88,7 @@ void FakePicturePile::RemoveRecordingAt(int x, int y) {
bool FakePicturePile::HasRecordingAt(int x, int y) const { bool FakePicturePile::HasRecordingAt(int x, int y) const {
PictureMap::const_iterator found = picture_map_.find(PictureMapKey(x, y)); PictureMap::const_iterator found = picture_map_.find(PictureMapKey(x, y));
if (found == picture_map_.end()) return found != picture_map_.end();
return false;
return !!found->second.GetPicture();
} }
void FakePicturePile::Rerecord() { void FakePicturePile::Rerecord() {
......
...@@ -17,7 +17,6 @@ namespace cc { ...@@ -17,7 +17,6 @@ namespace cc {
class FakePicturePile : public PicturePile { class FakePicturePile : public PicturePile {
public: public:
using PictureInfo = PicturePile::PictureInfo;
using PictureMapKey = PicturePile::PictureMapKey; using PictureMapKey = PicturePile::PictureMapKey;
using PictureMap = PicturePile::PictureMap; using PictureMap = PicturePile::PictureMap;
......
...@@ -114,9 +114,7 @@ void FakePicturePileImpl::PlaybackToCanvas(SkCanvas* canvas, ...@@ -114,9 +114,7 @@ void FakePicturePileImpl::PlaybackToCanvas(SkCanvas* canvas,
bool FakePicturePileImpl::HasRecordingAt(int x, int y) const { bool FakePicturePileImpl::HasRecordingAt(int x, int y) const {
PictureMap::const_iterator found = picture_map_.find(PictureMapKey(x, y)); PictureMap::const_iterator found = picture_map_.find(PictureMapKey(x, y));
if (found == picture_map_.end()) return found != picture_map_.end();
return false;
return !!found->second.GetPicture();
} }
} // namespace cc } // namespace cc
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