| 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 "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
| 9 #include "cc/blimp/client_picture_cache.h" | 9 #include "cc/blimp/client_picture_cache.h" |
| 10 #include "cc/blimp/engine_picture_cache.h" | 10 #include "cc/blimp/engine_picture_cache.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 } | 72 } |
| 73 | 73 |
| 74 void PictureLayer::SetLayerTreeHost(LayerTreeHost* host) { | 74 void PictureLayer::SetLayerTreeHost(LayerTreeHost* host) { |
| 75 Layer::SetLayerTreeHost(host); | 75 Layer::SetLayerTreeHost(host); |
| 76 if (!host) | 76 if (!host) |
| 77 return; | 77 return; |
| 78 | 78 |
| 79 if (!recording_source_) | 79 if (!recording_source_) |
| 80 recording_source_.reset(new RecordingSource); | 80 recording_source_.reset(new RecordingSource); |
| 81 recording_source_->SetSlowdownRasterScaleFactor( | 81 recording_source_->SetSlowdownRasterScaleFactor( |
| 82 host->debug_state().slow_down_raster_scale_factor); | 82 host->GetDebugState().slow_down_raster_scale_factor); |
| 83 // If we need to enable image decode tasks, then we have to generate the | 83 // If we need to enable image decode tasks, then we have to generate the |
| 84 // discardable images metadata. | 84 // discardable images metadata. |
| 85 const LayerTreeSettings& settings = layer_tree_host()->settings(); | 85 const LayerTreeSettings& settings = layer_tree_host()->GetSettings(); |
| 86 recording_source_->SetGenerateDiscardableImagesMetadata( | 86 recording_source_->SetGenerateDiscardableImagesMetadata( |
| 87 settings.image_decode_tasks_enabled); | 87 settings.image_decode_tasks_enabled); |
| 88 } | 88 } |
| 89 | 89 |
| 90 void PictureLayer::SetNeedsDisplayRect(const gfx::Rect& layer_rect) { | 90 void PictureLayer::SetNeedsDisplayRect(const gfx::Rect& layer_rect) { |
| 91 DCHECK(!layer_tree_host() || !GetLayerTree()->in_paint_layer_contents()); | 91 DCHECK(!layer_tree_host() || !GetLayerTree()->in_paint_layer_contents()); |
| 92 if (recording_source_) | 92 if (recording_source_) |
| 93 recording_source_->SetNeedsDisplayRect(layer_rect); | 93 recording_source_->SetNeedsDisplayRect(layer_rect); |
| 94 Layer::SetNeedsDisplayRect(layer_rect); | 94 Layer::SetNeedsDisplayRect(layer_rect); |
| 95 } | 95 } |
| 96 | 96 |
| 97 bool PictureLayer::Update() { | 97 bool PictureLayer::Update() { |
| 98 update_source_frame_number_ = layer_tree_host()->source_frame_number(); | 98 update_source_frame_number_ = layer_tree_host()->SourceFrameNumber(); |
| 99 bool updated = Layer::Update(); | 99 bool updated = Layer::Update(); |
| 100 | 100 |
| 101 gfx::Size layer_size = paint_properties().bounds; | 101 gfx::Size layer_size = paint_properties().bounds; |
| 102 | 102 |
| 103 recording_source_->SetBackgroundColor(SafeOpaqueBackgroundColor()); | 103 recording_source_->SetBackgroundColor(SafeOpaqueBackgroundColor()); |
| 104 recording_source_->SetRequiresClear( | 104 recording_source_->SetRequiresClear( |
| 105 !contents_opaque() && | 105 !contents_opaque() && |
| 106 !picture_layer_inputs_.client->FillsBoundsCompletely()); | 106 !picture_layer_inputs_.client->FillsBoundsCompletely()); |
| 107 | 107 |
| 108 TRACE_EVENT1("cc", "PictureLayer::Update", | 108 TRACE_EVENT1("cc", "PictureLayer::Update", "source_frame_number", |
| 109 "source_frame_number", | 109 layer_tree_host()->SourceFrameNumber()); |
| 110 layer_tree_host()->source_frame_number()); | |
| 111 devtools_instrumentation::ScopedLayerTreeTask update_layer( | 110 devtools_instrumentation::ScopedLayerTreeTask update_layer( |
| 112 devtools_instrumentation::kUpdateLayer, id(), layer_tree_host()->id()); | 111 devtools_instrumentation::kUpdateLayer, id(), layer_tree_host()->GetId()); |
| 113 | 112 |
| 114 // UpdateAndExpandInvalidation will give us an invalidation that covers | 113 // UpdateAndExpandInvalidation will give us an invalidation that covers |
| 115 // anything not explicitly recorded in this frame. We give this region | 114 // anything not explicitly recorded in this frame. We give this region |
| 116 // to the impl side so that it drops tiles that may not have a recording | 115 // to the impl side so that it drops tiles that may not have a recording |
| 117 // for them. | 116 // for them. |
| 118 DCHECK(picture_layer_inputs_.client); | 117 DCHECK(picture_layer_inputs_.client); |
| 119 | 118 |
| 120 picture_layer_inputs_.recorded_viewport = | 119 picture_layer_inputs_.recorded_viewport = |
| 121 picture_layer_inputs_.client->PaintableRegion(); | 120 picture_layer_inputs_.client->PaintableRegion(); |
| 122 | 121 |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 picture_layer_inputs_.nearest_neighbor = picture.nearest_neighbor(); | 280 picture_layer_inputs_.nearest_neighbor = picture.nearest_neighbor(); |
| 282 | 281 |
| 283 update_source_frame_number_ = picture.update_source_frame_number(); | 282 update_source_frame_number_ = picture.update_source_frame_number(); |
| 284 } | 283 } |
| 285 | 284 |
| 286 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { | 285 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { |
| 287 benchmark->RunOnLayer(this); | 286 benchmark->RunOnLayer(this); |
| 288 } | 287 } |
| 289 | 288 |
| 290 void PictureLayer::DropRecordingSourceContentIfInvalid() { | 289 void PictureLayer::DropRecordingSourceContentIfInvalid() { |
| 291 int source_frame_number = layer_tree_host()->source_frame_number(); | 290 int source_frame_number = layer_tree_host()->SourceFrameNumber(); |
| 292 gfx::Size recording_source_bounds = recording_source_->GetSize(); | 291 gfx::Size recording_source_bounds = recording_source_->GetSize(); |
| 293 | 292 |
| 294 gfx::Size layer_bounds = bounds(); | 293 gfx::Size layer_bounds = bounds(); |
| 295 if (paint_properties().source_frame_number == source_frame_number) | 294 if (paint_properties().source_frame_number == source_frame_number) |
| 296 layer_bounds = paint_properties().bounds; | 295 layer_bounds = paint_properties().bounds; |
| 297 | 296 |
| 298 // If update called, then recording source size must match bounds pushed to | 297 // If update called, then recording source size must match bounds pushed to |
| 299 // impl layer. | 298 // impl layer. |
| 300 DCHECK(update_source_frame_number_ != source_frame_number || | 299 DCHECK(update_source_frame_number_ != source_frame_number || |
| 301 layer_bounds == recording_source_bounds) | 300 layer_bounds == recording_source_bounds) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 312 picture_layer_inputs_.display_list = nullptr; | 311 picture_layer_inputs_.display_list = nullptr; |
| 313 picture_layer_inputs_.painter_reported_memory_usage = 0; | 312 picture_layer_inputs_.painter_reported_memory_usage = 0; |
| 314 } | 313 } |
| 315 } | 314 } |
| 316 | 315 |
| 317 const DisplayItemList* PictureLayer::GetDisplayItemList() { | 316 const DisplayItemList* PictureLayer::GetDisplayItemList() { |
| 318 return picture_layer_inputs_.display_list.get(); | 317 return picture_layer_inputs_.display_list.get(); |
| 319 } | 318 } |
| 320 | 319 |
| 321 } // namespace cc | 320 } // namespace cc |
| OLD | NEW |