| Index: cc/playback/display_list_recording_source.cc
|
| diff --git a/cc/playback/display_list_recording_source.cc b/cc/playback/display_list_recording_source.cc
|
| index 3a30cf96758b2ad126b2832d3a9cbbf001e39253..955eb77bac643f6dc204e411502d0d8efd189165 100644
|
| --- a/cc/playback/display_list_recording_source.cc
|
| +++ b/cc/playback/display_list_recording_source.cc
|
| @@ -56,52 +56,18 @@ DisplayListRecordingSource::DisplayListRecordingSource()
|
| DisplayListRecordingSource::~DisplayListRecordingSource() {
|
| }
|
|
|
| -// This method only really makes sense to call if the size of the layer didn't
|
| -// change.
|
| -bool DisplayListRecordingSource::ExposesEnoughNewArea(
|
| - const gfx::Rect& current_recorded_viewport,
|
| - const gfx::Rect& potential_new_recorded_viewport,
|
| - const gfx::Size& layer_size) {
|
| - // If both are empty, nothing to do.
|
| - if (current_recorded_viewport.IsEmpty() &&
|
| - potential_new_recorded_viewport.IsEmpty())
|
| - return false;
|
| -
|
| - // Re-record when going from empty to not-empty, to cover cases where
|
| - // the layer is recorded for the first time, or otherwise becomes visible.
|
| - if (current_recorded_viewport.IsEmpty())
|
| - return true;
|
| -
|
| - // Re-record if the new viewport includes area outside of a skirt around the
|
| - // existing viewport.
|
| - gfx::Rect expanded_viewport(current_recorded_viewport);
|
| - expanded_viewport.Inset(-kMinimumDistanceBeforeUpdatingRecordedViewport,
|
| - -kMinimumDistanceBeforeUpdatingRecordedViewport);
|
| - if (!expanded_viewport.Contains(potential_new_recorded_viewport))
|
| - return true;
|
| -
|
| - // Even if the new viewport doesn't include enough new area to satisfy the
|
| - // condition above, re-record anyway if touches a layer edge not touched by
|
| - // the existing viewport. Viewports are clipped to layer boundaries, so if the
|
| - // new viewport touches a layer edge not touched by the existing viewport,
|
| - // the new viewport must expose new area that touches this layer edge. Since
|
| - // this new area touches a layer edge, it's impossible to expose more area in
|
| - // that direction, so recording cannot be deferred until the exposed new area
|
| - // satisfies the condition above.
|
| - if (potential_new_recorded_viewport.x() == 0 &&
|
| - current_recorded_viewport.x() != 0)
|
| - return true;
|
| - if (potential_new_recorded_viewport.y() == 0 &&
|
| - current_recorded_viewport.y() != 0)
|
| - return true;
|
| - if (potential_new_recorded_viewport.right() == layer_size.width() &&
|
| - current_recorded_viewport.right() != layer_size.width())
|
| - return true;
|
| - if (potential_new_recorded_viewport.bottom() == layer_size.height() &&
|
| - current_recorded_viewport.bottom() != layer_size.height())
|
| - return true;
|
| -
|
| - return false;
|
| +void DisplayListRecordingSource::UpdateInvalidationForNewViewport(
|
| + const gfx::Rect& old_recorded_viewport,
|
| + const gfx::Rect& new_recorded_viewport,
|
| + Region* invalidation) {
|
| + // Invalidate newly-exposed and no-longer-exposed areas.
|
| + Region newly_exposed_region(new_recorded_viewport);
|
| + newly_exposed_region.Subtract(old_recorded_viewport);
|
| + invalidation->Union(newly_exposed_region);
|
| +
|
| + Region no_longer_exposed_region(old_recorded_viewport);
|
| + no_longer_exposed_region.Subtract(new_recorded_viewport);
|
| + invalidation->Union(no_longer_exposed_region);
|
| }
|
|
|
| bool DisplayListRecordingSource::UpdateAndExpandInvalidation(
|
| @@ -114,34 +80,17 @@ bool DisplayListRecordingSource::UpdateAndExpandInvalidation(
|
| ScopedDisplayListRecordingSourceUpdateTimer timer;
|
| bool updated = false;
|
|
|
| + // TODO(chrishtr): delete this conditional once synchronized paint launches.
|
| if (size_ != layer_size) {
|
| size_ = layer_size;
|
| updated = true;
|
| }
|
|
|
| - // The recorded viewport is the visible layer rect, expanded
|
| - // by the pixel record distance, up to a maximum of the total
|
| - // layer size.
|
| - gfx::Rect potential_new_recorded_viewport = visible_layer_rect;
|
| - potential_new_recorded_viewport.Inset(-pixel_record_distance_,
|
| - -pixel_record_distance_);
|
| - potential_new_recorded_viewport.Intersect(gfx::Rect(GetSize()));
|
| -
|
| - if (updated ||
|
| - ExposesEnoughNewArea(recorded_viewport_, potential_new_recorded_viewport,
|
| - GetSize())) {
|
| - gfx::Rect old_recorded_viewport = recorded_viewport_;
|
| - recorded_viewport_ = potential_new_recorded_viewport;
|
| -
|
| - // Invalidate newly-exposed and no-longer-exposed areas.
|
| - Region newly_exposed_region(recorded_viewport_);
|
| - newly_exposed_region.Subtract(old_recorded_viewport);
|
| - invalidation->Union(newly_exposed_region);
|
| -
|
| - Region no_longer_exposed_region(old_recorded_viewport);
|
| - no_longer_exposed_region.Subtract(recorded_viewport_);
|
| - invalidation->Union(no_longer_exposed_region);
|
| -
|
| + gfx::Rect new_recorded_viewport = painter->PaintableRegion();
|
| + if (new_recorded_viewport != recorded_viewport_) {
|
| + UpdateInvalidationForNewViewport(recorded_viewport_, new_recorded_viewport,
|
| + invalidation);
|
| + recorded_viewport_ = new_recorded_viewport;
|
| updated = true;
|
| }
|
|
|
|
|