| 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/trees/layer_tree_impl.h" | 10 #include "cc/trees/layer_tree_impl.h" |
| 11 #include "third_party/skia/include/core/SkPictureRecorder.h" | 11 #include "third_party/skia/include/core/SkPictureRecorder.h" |
| 12 #include "ui/gfx/rect_conversions.h" | 12 #include "ui/gfx/rect_conversions.h" |
| 13 | 13 |
| 14 namespace cc { | 14 namespace cc { |
| 15 | 15 |
| 16 scoped_refptr<PictureLayer> PictureLayer::Create(ContentLayerClient* client) { | 16 scoped_refptr<PictureLayer> PictureLayer::Create(ContentLayerClient* client) { |
| 17 return make_scoped_refptr(new PictureLayer(client)); | 17 return make_scoped_refptr(new PictureLayer(client)); |
| 18 } | 18 } |
| 19 | 19 |
| 20 PictureLayer::PictureLayer(ContentLayerClient* client) | 20 PictureLayer::PictureLayer(ContentLayerClient* client) |
| 21 : client_(client), | 21 : client_(client), |
| 22 pile_(make_scoped_refptr(new PicturePile())), | 22 pile_(make_scoped_refptr(new PicturePile())), |
| 23 instrumentation_object_tracker_(id()), | 23 instrumentation_object_tracker_(id()), |
| 24 includes_first_paint_invalidation_(false), |
| 24 is_mask_(false), | 25 is_mask_(false), |
| 25 update_source_frame_number_(-1), | 26 update_source_frame_number_(-1), |
| 26 can_use_lcd_text_last_frame_(can_use_lcd_text()) { | 27 can_use_lcd_text_last_frame_(can_use_lcd_text()) { |
| 27 } | 28 } |
| 28 | 29 |
| 29 PictureLayer::~PictureLayer() { | 30 PictureLayer::~PictureLayer() { |
| 30 } | 31 } |
| 31 | 32 |
| 32 scoped_ptr<LayerImpl> PictureLayer::CreateLayerImpl(LayerTreeImpl* tree_impl) { | 33 scoped_ptr<LayerImpl> PictureLayer::CreateLayerImpl(LayerTreeImpl* tree_impl) { |
| 33 return PictureLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>(); | 34 return PictureLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 49 // If update called, then pile size must match bounds pushed to impl layer. | 50 // If update called, then pile size must match bounds pushed to impl layer. |
| 50 DCHECK_EQ(layer_impl->bounds().ToString(), pile_->tiling_size().ToString()); | 51 DCHECK_EQ(layer_impl->bounds().ToString(), pile_->tiling_size().ToString()); |
| 51 } | 52 } |
| 52 | 53 |
| 53 layer_impl->SetIsMask(is_mask_); | 54 layer_impl->SetIsMask(is_mask_); |
| 54 | 55 |
| 55 // Unlike other properties, invalidation must always be set on layer_impl. | 56 // Unlike other properties, invalidation must always be set on layer_impl. |
| 56 // See PictureLayerImpl::PushPropertiesTo for more details. | 57 // See PictureLayerImpl::PushPropertiesTo for more details. |
| 57 layer_impl->invalidation_.Clear(); | 58 layer_impl->invalidation_.Clear(); |
| 58 layer_impl->invalidation_.Swap(&pile_invalidation_); | 59 layer_impl->invalidation_.Swap(&pile_invalidation_); |
| 60 layer_impl->SetIncludesFirstPaintInvalidation( |
| 61 includes_first_paint_invalidation_); |
| 59 layer_impl->pile_ = PicturePileImpl::CreateFromOther(pile_.get()); | 62 layer_impl->pile_ = PicturePileImpl::CreateFromOther(pile_.get()); |
| 60 } | 63 } |
| 61 | 64 |
| 62 void PictureLayer::SetLayerTreeHost(LayerTreeHost* host) { | 65 void PictureLayer::SetLayerTreeHost(LayerTreeHost* host) { |
| 63 Layer::SetLayerTreeHost(host); | 66 Layer::SetLayerTreeHost(host); |
| 64 if (host) { | 67 if (host) { |
| 65 pile_->SetMinContentsScale(host->settings().minimum_contents_scale); | 68 pile_->SetMinContentsScale(host->settings().minimum_contents_scale); |
| 66 pile_->SetTileGridSize(host->settings().default_tile_size); | 69 pile_->SetTileGridSize(host->settings().default_tile_size); |
| 67 pile_->set_slow_down_raster_scale_factor( | 70 pile_->set_slow_down_raster_scale_factor( |
| 68 host->debug_state().slow_down_raster_scale_factor); | 71 host->debug_state().slow_down_raster_scale_factor); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 "source_frame_number", | 109 "source_frame_number", |
| 107 layer_tree_host()->source_frame_number()); | 110 layer_tree_host()->source_frame_number()); |
| 108 devtools_instrumentation::ScopedLayerTreeTask update_layer( | 111 devtools_instrumentation::ScopedLayerTreeTask update_layer( |
| 109 devtools_instrumentation::kUpdateLayer, id(), layer_tree_host()->id()); | 112 devtools_instrumentation::kUpdateLayer, id(), layer_tree_host()->id()); |
| 110 | 113 |
| 111 // Calling paint in WebKit can sometimes cause invalidations, so save | 114 // Calling paint in WebKit can sometimes cause invalidations, so save |
| 112 // off the invalidation prior to calling update. | 115 // off the invalidation prior to calling update. |
| 113 pending_invalidation_.Swap(&pile_invalidation_); | 116 pending_invalidation_.Swap(&pile_invalidation_); |
| 114 pending_invalidation_.Clear(); | 117 pending_invalidation_.Clear(); |
| 115 | 118 |
| 119 bool is_tracing; |
| 120 TRACE_EVENT_CATEGORY_GROUP_ENABLED( |
| 121 TRACE_DISABLED_BY_DEFAULT("cc.debug") "," TRACE_DISABLED_BY_DEFAULT( |
| 122 "devtools.timeline.layers"), |
| 123 &is_tracing); |
| 124 if (is_tracing || layer_tree_host()->debug_state().ShowHudInfo()) { |
| 125 includes_first_paint_invalidation_ = false; |
| 126 if (scoped_refptr<LayerDebugInfo> debug_info = TakeDebugInfo()) { |
| 127 includes_first_paint_invalidation_ = |
| 128 debug_info->IncludesFirstPaintInvalidation(); |
| 129 } |
| 130 } |
| 131 |
| 116 if (layer_tree_host()->settings().record_full_layer) { | 132 if (layer_tree_host()->settings().record_full_layer) { |
| 117 // Workaround for http://crbug.com/235910 - to retain backwards compat | 133 // Workaround for http://crbug.com/235910 - to retain backwards compat |
| 118 // the full page content must always be provided in the picture layer. | 134 // the full page content must always be provided in the picture layer. |
| 119 visible_layer_rect = gfx::Rect(layer_size); | 135 visible_layer_rect = gfx::Rect(layer_size); |
| 120 } | 136 } |
| 121 | 137 |
| 122 // UpdateAndExpandInvalidation will give us an invalidation that covers | 138 // UpdateAndExpandInvalidation will give us an invalidation that covers |
| 123 // anything not explicitly recorded in this frame. We give this region | 139 // anything not explicitly recorded in this frame. We give this region |
| 124 // to the impl side so that it drops tiles that may not have a recording | 140 // to the impl side so that it drops tiles that may not have a recording |
| 125 // for them. | 141 // for them. |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 | 224 |
| 209 bool PictureLayer::HasDrawableContent() const { | 225 bool PictureLayer::HasDrawableContent() const { |
| 210 return client_ && Layer::HasDrawableContent(); | 226 return client_ && Layer::HasDrawableContent(); |
| 211 } | 227 } |
| 212 | 228 |
| 213 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { | 229 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { |
| 214 benchmark->RunOnLayer(this); | 230 benchmark->RunOnLayer(this); |
| 215 } | 231 } |
| 216 | 232 |
| 217 } // namespace cc | 233 } // namespace cc |
| OLD | NEW |