| 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 is_mask_(false), | |
| 25 update_source_frame_number_(-1), | 24 update_source_frame_number_(-1), |
| 26 can_use_lcd_text_last_frame_(can_use_lcd_text()) { | 25 can_use_lcd_text_last_frame_(can_use_lcd_text()) { |
| 27 } | 26 } |
| 28 | 27 |
| 29 PictureLayer::~PictureLayer() { | 28 PictureLayer::~PictureLayer() { |
| 30 } | 29 } |
| 31 | 30 |
| 32 scoped_ptr<LayerImpl> PictureLayer::CreateLayerImpl(LayerTreeImpl* tree_impl) { | 31 scoped_ptr<LayerImpl> PictureLayer::CreateLayerImpl(LayerTreeImpl* tree_impl) { |
| 33 return PictureLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>(); | 32 return PictureLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>(); |
| 34 } | 33 } |
| 35 | 34 |
| 36 void PictureLayer::PushPropertiesTo(LayerImpl* base_layer) { | 35 void PictureLayer::PushPropertiesTo(LayerImpl* base_layer) { |
| 37 Layer::PushPropertiesTo(base_layer); | 36 Layer::PushPropertiesTo(base_layer); |
| 38 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer); | 37 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer); |
| 39 | 38 |
| 40 if (layer_impl->bounds().IsEmpty()) { | 39 if (layer_impl->bounds().IsEmpty()) { |
| 41 // Update may not get called for an empty layer, so resize here instead. | 40 // Update may not get called for an empty layer, so resize here instead. |
| 42 // Using layer_impl because either bounds() or paint_properties().bounds | 41 // Using layer_impl because either bounds() or paint_properties().bounds |
| 43 // may disagree and either one could have been pushed to layer_impl. | 42 // may disagree and either one could have been pushed to layer_impl. |
| 44 pile_->SetEmptyBounds(); | 43 pile_->SetEmptyBounds(); |
| 45 } else if (update_source_frame_number_ == | 44 } else if (update_source_frame_number_ == |
| 46 layer_tree_host()->source_frame_number()) { | 45 layer_tree_host()->source_frame_number()) { |
| 47 // TODO(ernstm): This DCHECK is only valid as long as the pile's tiling_rect | 46 // TODO(ernstm): This DCHECK is only valid as long as the pile's tiling_rect |
| 48 // is identical to the layer_rect. | 47 // is identical to the layer_rect. |
| 49 // If update called, then pile size must match bounds pushed to impl layer. | 48 // If update called, then pile size must match bounds pushed to impl layer. |
| 50 DCHECK_EQ(layer_impl->bounds().ToString(), pile_->tiling_size().ToString()); | 49 DCHECK_EQ(layer_impl->bounds().ToString(), pile_->tiling_size().ToString()); |
| 51 } | 50 } |
| 52 | 51 |
| 53 layer_impl->SetIsMask(is_mask_); | |
| 54 | |
| 55 // Unlike other properties, invalidation must always be set on layer_impl. | 52 // Unlike other properties, invalidation must always be set on layer_impl. |
| 56 // See PictureLayerImpl::PushPropertiesTo for more details. | 53 // See PictureLayerImpl::PushPropertiesTo for more details. |
| 57 layer_impl->invalidation_.Clear(); | 54 layer_impl->invalidation_.Clear(); |
| 58 layer_impl->invalidation_.Swap(&pile_invalidation_); | 55 layer_impl->invalidation_.Swap(&pile_invalidation_); |
| 59 layer_impl->pile_ = PicturePileImpl::CreateFromOther(pile_.get()); | 56 layer_impl->pile_ = PicturePileImpl::CreateFromOther(pile_.get()); |
| 60 } | 57 } |
| 61 | 58 |
| 62 void PictureLayer::SetLayerTreeHost(LayerTreeHost* host) { | 59 void PictureLayer::SetLayerTreeHost(LayerTreeHost* host) { |
| 63 Layer::SetLayerTreeHost(host); | 60 Layer::SetLayerTreeHost(host); |
| 64 if (host) { | 61 if (host) { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 } else { | 139 } else { |
| 143 // If this invalidation did not affect the pile, then it can be cleared as | 140 // If this invalidation did not affect the pile, then it can be cleared as |
| 144 // an optimization. | 141 // an optimization. |
| 145 pile_invalidation_.Clear(); | 142 pile_invalidation_.Clear(); |
| 146 } | 143 } |
| 147 | 144 |
| 148 return updated; | 145 return updated; |
| 149 } | 146 } |
| 150 | 147 |
| 151 void PictureLayer::SetIsMask(bool is_mask) { | 148 void PictureLayer::SetIsMask(bool is_mask) { |
| 152 is_mask_ = is_mask; | 149 pile_->set_is_mask(is_mask); |
| 153 } | 150 } |
| 154 | 151 |
| 155 Picture::RecordingMode PictureLayer::RecordingMode() const { | 152 Picture::RecordingMode PictureLayer::RecordingMode() const { |
| 156 switch (layer_tree_host()->settings().recording_mode) { | 153 switch (layer_tree_host()->settings().recording_mode) { |
| 157 case LayerTreeSettings::RecordNormally: | 154 case LayerTreeSettings::RecordNormally: |
| 158 return Picture::RECORD_NORMALLY; | 155 return Picture::RECORD_NORMALLY; |
| 159 case LayerTreeSettings::RecordWithSkRecord: | 156 case LayerTreeSettings::RecordWithSkRecord: |
| 160 return Picture::RECORD_WITH_SKRECORD; | 157 return Picture::RECORD_WITH_SKRECORD; |
| 161 } | 158 } |
| 162 NOTREACHED(); | 159 NOTREACHED(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 | 205 |
| 209 bool PictureLayer::HasDrawableContent() const { | 206 bool PictureLayer::HasDrawableContent() const { |
| 210 return client_ && Layer::HasDrawableContent(); | 207 return client_ && Layer::HasDrawableContent(); |
| 211 } | 208 } |
| 212 | 209 |
| 213 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { | 210 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { |
| 214 benchmark->RunOnLayer(this); | 211 benchmark->RunOnLayer(this); |
| 215 } | 212 } |
| 216 | 213 |
| 217 } // namespace cc | 214 } // namespace cc |
| OLD | NEW |