| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 invalidation->Union(no_longer_exposed_region); | 110 invalidation->Union(no_longer_exposed_region); |
| 111 } | 111 } |
| 112 | 112 |
| 113 void DisplayListRecordingSource::FinishDisplayItemListUpdate() { | 113 void DisplayListRecordingSource::FinishDisplayItemListUpdate() { |
| 114 DetermineIfSolidColor(); | 114 DetermineIfSolidColor(); |
| 115 display_list_->EmitTraceSnapshot(); | 115 display_list_->EmitTraceSnapshot(); |
| 116 if (generate_discardable_images_metadata_) | 116 if (generate_discardable_images_metadata_) |
| 117 display_list_->GenerateDiscardableImagesMetadata(); | 117 display_list_->GenerateDiscardableImagesMetadata(); |
| 118 } | 118 } |
| 119 | 119 |
| 120 void DisplayListRecordingSource::SetNeedsDisplayRect( |
| 121 const gfx::Rect& layer_rect) { |
| 122 if (!layer_rect.IsEmpty()) { |
| 123 // Clamp invalidation to the layer bounds. |
| 124 invalidation_.Union(gfx::IntersectRects(layer_rect, gfx::Rect(size_))); |
| 125 } |
| 126 } |
| 127 |
| 120 bool DisplayListRecordingSource::UpdateAndExpandInvalidation( | 128 bool DisplayListRecordingSource::UpdateAndExpandInvalidation( |
| 121 ContentLayerClient* painter, | 129 ContentLayerClient* painter, |
| 122 Region* invalidation, | 130 Region* invalidation, |
| 123 const gfx::Size& layer_size, | 131 const gfx::Size& layer_size, |
| 124 const gfx::Rect& visible_layer_rect, | 132 const gfx::Rect& visible_layer_rect, |
| 125 int frame_number, | 133 int frame_number, |
| 126 RecordingMode recording_mode) { | 134 RecordingMode recording_mode) { |
| 127 ScopedDisplayListRecordingSourceUpdateTimer timer; | 135 ScopedDisplayListRecordingSourceUpdateTimer timer; |
| 128 bool updated = false; | 136 bool updated = false; |
| 129 | 137 |
| 130 // TODO(chrishtr): delete this conditional once synchronized paint launches. | 138 // TODO(chrishtr): delete this conditional once synchronized paint launches. |
| 131 if (size_ != layer_size) { | 139 if (size_ != layer_size) { |
| 132 size_ = layer_size; | 140 size_ = layer_size; |
| 133 updated = true; | 141 updated = true; |
| 134 } | 142 } |
| 135 | 143 |
| 144 invalidation_.Swap(invalidation); |
| 145 invalidation_.Clear(); |
| 146 |
| 136 gfx::Rect new_recorded_viewport = painter->PaintableRegion(); | 147 gfx::Rect new_recorded_viewport = painter->PaintableRegion(); |
| 137 if (new_recorded_viewport != recorded_viewport_) { | 148 if (new_recorded_viewport != recorded_viewport_) { |
| 138 UpdateInvalidationForNewViewport(recorded_viewport_, new_recorded_viewport, | 149 UpdateInvalidationForNewViewport(recorded_viewport_, new_recorded_viewport, |
| 139 invalidation); | 150 invalidation); |
| 140 recorded_viewport_ = new_recorded_viewport; | 151 recorded_viewport_ = new_recorded_viewport; |
| 141 updated = true; | 152 updated = true; |
| 142 } | 153 } |
| 143 | 154 |
| 144 // Count the area that is being invalidated. | 155 // Count the area that is being invalidated. |
| 145 Region recorded_invalidation(*invalidation); | 156 Region recorded_invalidation(*invalidation); |
| 146 recorded_invalidation.Intersect(recorded_viewport_); | 157 recorded_invalidation.Intersect(recorded_viewport_); |
| 147 for (Region::Iterator it(recorded_invalidation); it.has_rect(); it.next()) | 158 for (Region::Iterator it(recorded_invalidation); it.has_rect(); it.next()) |
| 148 timer.AddArea(it.rect().size().GetCheckedArea()); | 159 timer.AddArea(it.rect().size().GetCheckedArea()); |
| 149 | 160 |
| 150 if (!updated && !invalidation->Intersects(recorded_viewport_)) | 161 if (!updated && !invalidation->Intersects(recorded_viewport_)) |
| 151 return false; | 162 return false; |
| 152 | 163 |
| 164 if (invalidation->IsEmpty()) |
| 165 return false; |
| 166 |
| 153 ContentLayerClient::PaintingControlSetting painting_control = | 167 ContentLayerClient::PaintingControlSetting painting_control = |
| 154 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL; | 168 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL; |
| 155 | 169 |
| 156 switch (recording_mode) { | 170 switch (recording_mode) { |
| 157 case RECORD_NORMALLY: | 171 case RECORD_NORMALLY: |
| 158 // Already setup for normal recording. | 172 // Already setup for normal recording. |
| 159 break; | 173 break; |
| 160 case RECORD_WITH_PAINTING_DISABLED: | 174 case RECORD_WITH_PAINTING_DISABLED: |
| 161 painting_control = ContentLayerClient::DISPLAY_LIST_PAINTING_DISABLED; | 175 painting_control = ContentLayerClient::DISPLAY_LIST_PAINTING_DISABLED; |
| 162 break; | 176 break; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 } | 254 } |
| 241 | 255 |
| 242 void DisplayListRecordingSource::Clear() { | 256 void DisplayListRecordingSource::Clear() { |
| 243 recorded_viewport_ = gfx::Rect(); | 257 recorded_viewport_ = gfx::Rect(); |
| 244 display_list_ = nullptr; | 258 display_list_ = nullptr; |
| 245 painter_reported_memory_usage_ = 0; | 259 painter_reported_memory_usage_ = 0; |
| 246 is_solid_color_ = false; | 260 is_solid_color_ = false; |
| 247 } | 261 } |
| 248 | 262 |
| 249 } // namespace cc | 263 } // namespace cc |
| OLD | NEW |