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" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 // Update may not get called for the layer (if it's not in the viewport | 50 // Update may not get called for the layer (if it's not in the viewport |
51 // for example, even though it has resized making the pile no longer | 51 // for example, even though it has resized making the pile no longer |
52 // valid. In this case just destroy the pile. | 52 // valid. In this case just destroy the pile. |
53 pile_.SetEmptyBounds(); | 53 pile_.SetEmptyBounds(); |
54 } | 54 } |
55 | 55 |
56 // Unlike other properties, invalidation must always be set on layer_impl. | 56 // Unlike other properties, invalidation must always be set on layer_impl. |
57 // See PictureLayerImpl::PushPropertiesTo for more details. | 57 // See PictureLayerImpl::PushPropertiesTo for more details. |
58 layer_impl->invalidation_.Clear(); | 58 layer_impl->invalidation_.Clear(); |
59 layer_impl->invalidation_.Swap(&pile_invalidation_); | 59 layer_impl->invalidation_.Swap(&pile_invalidation_); |
60 layer_impl->UpdatePile(PicturePileImpl::CreateFromOther(&pile_)); | 60 layer_impl->UpdatePile(CreatePicturePileImpl()); |
61 } | 61 } |
62 | 62 |
63 void PictureLayer::SetLayerTreeHost(LayerTreeHost* host) { | 63 void PictureLayer::SetLayerTreeHost(LayerTreeHost* host) { |
64 Layer::SetLayerTreeHost(host); | 64 Layer::SetLayerTreeHost(host); |
65 if (host) { | 65 if (host) { |
66 pile_.SetMinContentsScale(host->settings().minimum_contents_scale); | 66 pile_.SetMinContentsScale(host->settings().minimum_contents_scale); |
67 pile_.SetTileGridSize(host->settings().default_tile_grid_size); | 67 pile_.SetTileGridSize(host->settings().default_tile_grid_size); |
68 pile_.set_slow_down_raster_scale_factor( | 68 pile_.set_slow_down_raster_scale_factor( |
69 host->debug_state().slow_down_raster_scale_factor); | 69 host->debug_state().slow_down_raster_scale_factor); |
70 pile_.set_show_debug_picture_borders( | 70 pile_.set_show_debug_picture_borders( |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 | 158 |
159 void PictureLayer::UpdateCanUseLCDText() { | 159 void PictureLayer::UpdateCanUseLCDText() { |
160 if (can_use_lcd_text_last_frame_ == can_use_lcd_text()) | 160 if (can_use_lcd_text_last_frame_ == can_use_lcd_text()) |
161 return; | 161 return; |
162 | 162 |
163 can_use_lcd_text_last_frame_ = can_use_lcd_text(); | 163 can_use_lcd_text_last_frame_ = can_use_lcd_text(); |
164 if (client_) | 164 if (client_) |
165 client_->DidChangeLayerCanUseLCDText(); | 165 client_->DidChangeLayerCanUseLCDText(); |
166 } | 166 } |
167 | 167 |
| 168 scoped_refptr<PicturePileImpl> PictureLayer::CreatePicturePileImpl() { |
| 169 return PicturePileImpl::CreateFromOther(&pile_); |
| 170 } |
| 171 |
168 skia::RefPtr<SkPicture> PictureLayer::GetPicture() const { | 172 skia::RefPtr<SkPicture> PictureLayer::GetPicture() const { |
169 // We could either flatten the PicturePile into a single SkPicture, | 173 // We could either flatten the PicturePile into a single SkPicture, |
170 // or paint a fresh one depending on what we intend to do with the | 174 // or paint a fresh one depending on what we intend to do with the |
171 // picture. For now we just paint a fresh one to get consistent results. | 175 // picture. For now we just paint a fresh one to get consistent results. |
172 if (!DrawsContent()) | 176 if (!DrawsContent()) |
173 return skia::RefPtr<SkPicture>(); | 177 return skia::RefPtr<SkPicture>(); |
174 | 178 |
175 int width = bounds().width(); | 179 int width = bounds().width(); |
176 int height = bounds().height(); | 180 int height = bounds().height(); |
177 | 181 |
(...skipping 17 matching lines...) Expand all Loading... |
195 | 199 |
196 bool PictureLayer::HasDrawableContent() const { | 200 bool PictureLayer::HasDrawableContent() const { |
197 return client_ && Layer::HasDrawableContent(); | 201 return client_ && Layer::HasDrawableContent(); |
198 } | 202 } |
199 | 203 |
200 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { | 204 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { |
201 benchmark->RunOnLayer(this); | 205 benchmark->RunOnLayer(this); |
202 } | 206 } |
203 | 207 |
204 } // namespace cc | 208 } // namespace cc |
OLD | NEW |