| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/layers/picture_layer.h" | 5 #include "cc/layers/picture_layer.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "cc/layers/content_layer_client.h" | 8 #include "cc/layers/content_layer_client.h" |
| 9 #include "cc/layers/picture_layer_impl.h" | 9 #include "cc/layers/picture_layer_impl.h" |
| 10 #include "cc/playback/display_list_recording_source.h" | 10 #include "cc/playback/display_list_recording_source.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 pending_invalidation_.Union( | 110 pending_invalidation_.Union( |
| 111 gfx::IntersectRects(layer_rect, gfx::Rect(bounds()))); | 111 gfx::IntersectRects(layer_rect, gfx::Rect(bounds()))); |
| 112 } | 112 } |
| 113 Layer::SetNeedsDisplayRect(layer_rect); | 113 Layer::SetNeedsDisplayRect(layer_rect); |
| 114 } | 114 } |
| 115 | 115 |
| 116 bool PictureLayer::Update(ResourceUpdateQueue* queue) { | 116 bool PictureLayer::Update(ResourceUpdateQueue* queue) { |
| 117 update_source_frame_number_ = layer_tree_host()->source_frame_number(); | 117 update_source_frame_number_ = layer_tree_host()->source_frame_number(); |
| 118 bool updated = Layer::Update(queue); | 118 bool updated = Layer::Update(queue); |
| 119 | 119 |
| 120 gfx::Rect visible_layer_rect = visible_content_rect(); | 120 gfx::Rect update_rect = visible_layer_rect(); |
| 121 gfx::Size layer_size = paint_properties().bounds; | 121 gfx::Size layer_size = paint_properties().bounds; |
| 122 | 122 |
| 123 if (last_updated_visible_content_rect_ == visible_content_rect() && | 123 if (last_updated_visible_layer_rect_ == update_rect && |
| 124 recording_source_->GetSize() == layer_size && | 124 recording_source_->GetSize() == layer_size && |
| 125 pending_invalidation_.IsEmpty()) { | 125 pending_invalidation_.IsEmpty()) { |
| 126 // Only early out if the visible content rect of this layer hasn't changed. | 126 // Only early out if the visible content rect of this layer hasn't changed. |
| 127 return updated; | 127 return updated; |
| 128 } | 128 } |
| 129 | 129 |
| 130 recording_source_->SetBackgroundColor(SafeOpaqueBackgroundColor()); | 130 recording_source_->SetBackgroundColor(SafeOpaqueBackgroundColor()); |
| 131 recording_source_->SetRequiresClear(!contents_opaque() && | 131 recording_source_->SetRequiresClear(!contents_opaque() && |
| 132 !client_->FillsBoundsCompletely()); | 132 !client_->FillsBoundsCompletely()); |
| 133 | 133 |
| 134 TRACE_EVENT1("cc", "PictureLayer::Update", | 134 TRACE_EVENT1("cc", "PictureLayer::Update", |
| 135 "source_frame_number", | 135 "source_frame_number", |
| 136 layer_tree_host()->source_frame_number()); | 136 layer_tree_host()->source_frame_number()); |
| 137 devtools_instrumentation::ScopedLayerTreeTask update_layer( | 137 devtools_instrumentation::ScopedLayerTreeTask update_layer( |
| 138 devtools_instrumentation::kUpdateLayer, id(), layer_tree_host()->id()); | 138 devtools_instrumentation::kUpdateLayer, id(), layer_tree_host()->id()); |
| 139 | 139 |
| 140 // Calling paint in WebKit can sometimes cause invalidations, so save | 140 // Calling paint in WebKit can sometimes cause invalidations, so save |
| 141 // off the invalidation prior to calling update. | 141 // off the invalidation prior to calling update. |
| 142 pending_invalidation_.Swap(&recording_invalidation_); | 142 pending_invalidation_.Swap(&recording_invalidation_); |
| 143 pending_invalidation_.Clear(); | 143 pending_invalidation_.Clear(); |
| 144 | 144 |
| 145 if (layer_tree_host()->settings().record_full_layer) { | 145 if (layer_tree_host()->settings().record_full_layer) { |
| 146 // Workaround for http://crbug.com/235910 - to retain backwards compat | 146 // Workaround for http://crbug.com/235910 - to retain backwards compat |
| 147 // the full page content must always be provided in the picture layer. | 147 // the full page content must always be provided in the picture layer. |
| 148 visible_layer_rect = gfx::Rect(layer_size); | 148 update_rect = gfx::Rect(layer_size); |
| 149 } | 149 } |
| 150 | 150 |
| 151 // UpdateAndExpandInvalidation will give us an invalidation that covers | 151 // UpdateAndExpandInvalidation will give us an invalidation that covers |
| 152 // anything not explicitly recorded in this frame. We give this region | 152 // anything not explicitly recorded in this frame. We give this region |
| 153 // to the impl side so that it drops tiles that may not have a recording | 153 // to the impl side so that it drops tiles that may not have a recording |
| 154 // for them. | 154 // for them. |
| 155 DCHECK(client_); | 155 DCHECK(client_); |
| 156 updated |= recording_source_->UpdateAndExpandInvalidation( | 156 updated |= recording_source_->UpdateAndExpandInvalidation( |
| 157 client_, &recording_invalidation_, layer_size, visible_layer_rect, | 157 client_, &recording_invalidation_, layer_size, update_rect, |
| 158 update_source_frame_number_, RecordingSource::RECORD_NORMALLY); | 158 update_source_frame_number_, RecordingSource::RECORD_NORMALLY); |
| 159 last_updated_visible_content_rect_ = visible_content_rect(); | 159 last_updated_visible_layer_rect_ = visible_layer_rect(); |
| 160 | 160 |
| 161 if (updated) { | 161 if (updated) { |
| 162 SetNeedsPushProperties(); | 162 SetNeedsPushProperties(); |
| 163 } else { | 163 } else { |
| 164 // If this invalidation did not affect the recording source, then it can be | 164 // If this invalidation did not affect the recording source, then it can be |
| 165 // cleared as an optimization. | 165 // cleared as an optimization. |
| 166 recording_invalidation_.Clear(); | 166 recording_invalidation_.Clear(); |
| 167 } | 167 } |
| 168 | 168 |
| 169 return updated; | 169 return updated; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 | 229 |
| 230 bool PictureLayer::HasDrawableContent() const { | 230 bool PictureLayer::HasDrawableContent() const { |
| 231 return client_ && Layer::HasDrawableContent(); | 231 return client_ && Layer::HasDrawableContent(); |
| 232 } | 232 } |
| 233 | 233 |
| 234 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { | 234 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { |
| 235 benchmark->RunOnLayer(this); | 235 benchmark->RunOnLayer(this); |
| 236 } | 236 } |
| 237 | 237 |
| 238 } // namespace cc | 238 } // namespace cc |
| OLD | NEW |