| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/playback/display_list_recording_source.h" | 5 #include "cc/playback/display_list_recording_source.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 invalidation->Union(no_longer_exposed_region); | 104 invalidation->Union(no_longer_exposed_region); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void DisplayListRecordingSource::FinishDisplayItemListUpdate() { | 107 void DisplayListRecordingSource::FinishDisplayItemListUpdate() { |
| 108 DetermineIfSolidColor(); | 108 DetermineIfSolidColor(); |
| 109 display_list_->EmitTraceSnapshot(); | 109 display_list_->EmitTraceSnapshot(); |
| 110 if (generate_discardable_images_metadata_) | 110 if (generate_discardable_images_metadata_) |
| 111 display_list_->GenerateDiscardableImagesMetadata(); | 111 display_list_->GenerateDiscardableImagesMetadata(); |
| 112 } | 112 } |
| 113 | 113 |
| 114 void DisplayListRecordingSource::SetNeedsDisplayRect( |
| 115 const gfx::Rect& layer_rect) { |
| 116 if (!layer_rect.IsEmpty()) { |
| 117 // Clamp invalidation to the layer bounds. |
| 118 invalidation_.Union(gfx::IntersectRects(layer_rect, gfx::Rect(size_))); |
| 119 } |
| 120 } |
| 121 |
| 114 bool DisplayListRecordingSource::UpdateAndExpandInvalidation( | 122 bool DisplayListRecordingSource::UpdateAndExpandInvalidation( |
| 115 ContentLayerClient* painter, | 123 ContentLayerClient* painter, |
| 116 Region* invalidation, | 124 Region* invalidation, |
| 117 const gfx::Size& layer_size, | 125 const gfx::Size& layer_size, |
| 118 const gfx::Rect& visible_layer_rect, | 126 const gfx::Rect& visible_layer_rect, |
| 119 int frame_number, | 127 int frame_number, |
| 120 RecordingMode recording_mode) { | 128 RecordingMode recording_mode) { |
| 121 ScopedDisplayListRecordingSourceUpdateTimer timer; | 129 ScopedDisplayListRecordingSourceUpdateTimer timer; |
| 122 bool updated = false; | 130 bool updated = false; |
| 123 | 131 |
| 124 // TODO(chrishtr): delete this conditional once synchronized paint launches. | 132 // TODO(chrishtr): delete this conditional once synchronized paint launches. |
| 125 if (size_ != layer_size) { | 133 if (size_ != layer_size) { |
| 126 size_ = layer_size; | 134 size_ = layer_size; |
| 127 updated = true; | 135 updated = true; |
| 128 } | 136 } |
| 129 | 137 |
| 138 invalidation_.Swap(invalidation); |
| 139 invalidation_.Clear(); |
| 140 |
| 130 gfx::Rect new_recorded_viewport = painter->PaintableRegion(); | 141 gfx::Rect new_recorded_viewport = painter->PaintableRegion(); |
| 131 if (new_recorded_viewport != recorded_viewport_) { | 142 if (new_recorded_viewport != recorded_viewport_) { |
| 132 UpdateInvalidationForNewViewport(recorded_viewport_, new_recorded_viewport, | 143 UpdateInvalidationForNewViewport(recorded_viewport_, new_recorded_viewport, |
| 133 invalidation); | 144 invalidation); |
| 134 recorded_viewport_ = new_recorded_viewport; | 145 recorded_viewport_ = new_recorded_viewport; |
| 135 updated = true; | 146 updated = true; |
| 136 } | 147 } |
| 137 | 148 |
| 138 // Count the area that is being invalidated. | 149 // Count the area that is being invalidated. |
| 139 Region recorded_invalidation(*invalidation); | 150 Region recorded_invalidation(*invalidation); |
| 140 recorded_invalidation.Intersect(recorded_viewport_); | 151 recorded_invalidation.Intersect(recorded_viewport_); |
| 141 for (Region::Iterator it(recorded_invalidation); it.has_rect(); it.next()) | 152 for (Region::Iterator it(recorded_invalidation); it.has_rect(); it.next()) |
| 142 timer.AddArea(it.rect().size().GetCheckedArea()); | 153 timer.AddArea(it.rect().size().GetCheckedArea()); |
| 143 | 154 |
| 144 if (!updated && !invalidation->Intersects(recorded_viewport_)) | 155 if (!updated && !invalidation->Intersects(recorded_viewport_)) |
| 145 return false; | 156 return false; |
| 146 | 157 |
| 158 if (invalidation->IsEmpty()) |
| 159 return false; |
| 160 |
| 147 ContentLayerClient::PaintingControlSetting painting_control = | 161 ContentLayerClient::PaintingControlSetting painting_control = |
| 148 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL; | 162 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL; |
| 149 | 163 |
| 150 switch (recording_mode) { | 164 switch (recording_mode) { |
| 151 case RECORD_NORMALLY: | 165 case RECORD_NORMALLY: |
| 152 // Already setup for normal recording. | 166 // Already setup for normal recording. |
| 153 break; | 167 break; |
| 154 case RECORD_WITH_PAINTING_DISABLED: | 168 case RECORD_WITH_PAINTING_DISABLED: |
| 155 painting_control = ContentLayerClient::DISPLAY_LIST_PAINTING_DISABLED; | 169 painting_control = ContentLayerClient::DISPLAY_LIST_PAINTING_DISABLED; |
| 156 break; | 170 break; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 } | 248 } |
| 235 | 249 |
| 236 void DisplayListRecordingSource::Clear() { | 250 void DisplayListRecordingSource::Clear() { |
| 237 recorded_viewport_ = gfx::Rect(); | 251 recorded_viewport_ = gfx::Rect(); |
| 238 display_list_ = nullptr; | 252 display_list_ = nullptr; |
| 239 painter_reported_memory_usage_ = 0; | 253 painter_reported_memory_usage_ = 0; |
| 240 is_solid_color_ = false; | 254 is_solid_color_ = false; |
| 241 } | 255 } |
| 242 | 256 |
| 243 } // namespace cc | 257 } // namespace cc |
| OLD | NEW |