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/layers/content_layer_client.h" | 9 #include "cc/layers/content_layer_client.h" |
10 #include "cc/layers/picture_layer_impl.h" | 10 #include "cc/layers/picture_layer_impl.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
60 recording_source_->CreateRasterSource(can_use_lcd_text); | 60 recording_source_->CreateRasterSource(can_use_lcd_text); |
61 layer_impl->set_gpu_raster_max_texture_size( | 61 layer_impl->set_gpu_raster_max_texture_size( |
62 layer_tree_host()->device_viewport_size()); | 62 layer_tree_host()->device_viewport_size()); |
63 layer_impl->UpdateRasterSource(raster_source, &last_updated_invalidation_, | 63 layer_impl->UpdateRasterSource(raster_source, &last_updated_invalidation_, |
64 nullptr); | 64 nullptr); |
65 DCHECK(last_updated_invalidation_.IsEmpty()); | 65 DCHECK(last_updated_invalidation_.IsEmpty()); |
66 } | 66 } |
67 | 67 |
68 void PictureLayer::SetLayerTreeHost(LayerTreeHost* host) { | 68 void PictureLayer::SetLayerTreeHost(LayerTreeHost* host) { |
69 Layer::SetLayerTreeHost(host); | 69 Layer::SetLayerTreeHost(host); |
70 if (!host) | 70 if (!host) |
vmpstr
2016/06/16 22:09:59
Should this if also reset the cache on a recording
nyquist
2016/06/24 11:11:14
Unnecessary now.
| |
71 return; | 71 return; |
72 | 72 |
73 if (!recording_source_) | 73 if (!recording_source_) |
74 recording_source_.reset(new RecordingSource); | 74 recording_source_.reset(new RecordingSource); |
75 | |
76 // Ensure the recording source has a pointer to the correct picture cache. | |
77 if (layer_tree_host()->IsRemoteServer()) { | |
78 recording_source_->SetEnginePictureCache( | |
79 layer_tree_host()->engine_picture_cache()); | |
80 } | |
81 if (layer_tree_host()->IsRemoteClient()) { | |
82 recording_source_->SetClientPictureCache( | |
83 layer_tree_host()->client_picture_cache()); | |
84 } | |
85 | |
75 recording_source_->SetSlowdownRasterScaleFactor( | 86 recording_source_->SetSlowdownRasterScaleFactor( |
76 host->debug_state().slow_down_raster_scale_factor); | 87 host->debug_state().slow_down_raster_scale_factor); |
77 // If we need to enable image decode tasks, then we have to generate the | 88 // If we need to enable image decode tasks, then we have to generate the |
78 // discardable images metadata. | 89 // discardable images metadata. |
79 const LayerTreeSettings& settings = layer_tree_host()->settings(); | 90 const LayerTreeSettings& settings = layer_tree_host()->settings(); |
80 recording_source_->SetGenerateDiscardableImagesMetadata( | 91 recording_source_->SetGenerateDiscardableImagesMetadata( |
81 settings.image_decode_tasks_enabled); | 92 settings.image_decode_tasks_enabled); |
82 } | 93 } |
83 | 94 |
84 void PictureLayer::SetNeedsDisplayRect(const gfx::Rect& layer_rect) { | 95 void PictureLayer::SetNeedsDisplayRect(const gfx::Rect& layer_rect) { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
172 void PictureLayer::SetTypeForProtoSerialization(proto::LayerNode* proto) const { | 183 void PictureLayer::SetTypeForProtoSerialization(proto::LayerNode* proto) const { |
173 proto->set_type(proto::LayerNode::PICTURE_LAYER); | 184 proto->set_type(proto::LayerNode::PICTURE_LAYER); |
174 } | 185 } |
175 | 186 |
176 void PictureLayer::LayerSpecificPropertiesToProto( | 187 void PictureLayer::LayerSpecificPropertiesToProto( |
177 proto::LayerProperties* proto) { | 188 proto::LayerProperties* proto) { |
178 Layer::LayerSpecificPropertiesToProto(proto); | 189 Layer::LayerSpecificPropertiesToProto(proto); |
179 DropRecordingSourceContentIfInvalid(); | 190 DropRecordingSourceContentIfInvalid(); |
180 | 191 |
181 proto::PictureLayerProperties* picture = proto->mutable_picture(); | 192 proto::PictureLayerProperties* picture = proto->mutable_picture(); |
182 recording_source_->ToProtobuf( | 193 recording_source_->ToProtobuf(picture->mutable_recording_source()); |
183 picture->mutable_recording_source(), | 194 |
184 layer_tree_host()->image_serialization_processor()); | |
185 RegionToProto(last_updated_invalidation_, picture->mutable_invalidation()); | 195 RegionToProto(last_updated_invalidation_, picture->mutable_invalidation()); |
186 picture->set_is_mask(is_mask_); | 196 picture->set_is_mask(is_mask_); |
187 picture->set_nearest_neighbor(nearest_neighbor_); | 197 picture->set_nearest_neighbor(nearest_neighbor_); |
188 | 198 |
189 picture->set_update_source_frame_number(update_source_frame_number_); | 199 picture->set_update_source_frame_number(update_source_frame_number_); |
190 | 200 |
191 last_updated_invalidation_.Clear(); | 201 last_updated_invalidation_.Clear(); |
192 } | 202 } |
193 | 203 |
194 void PictureLayer::FromLayerSpecificPropertiesProto( | 204 void PictureLayer::FromLayerSpecificPropertiesProto( |
195 const proto::LayerProperties& proto) { | 205 const proto::LayerProperties& proto) { |
196 Layer::FromLayerSpecificPropertiesProto(proto); | 206 Layer::FromLayerSpecificPropertiesProto(proto); |
197 const proto::PictureLayerProperties& picture = proto.picture(); | 207 const proto::PictureLayerProperties& picture = proto.picture(); |
198 // If this is a new layer, ensure it has a recording source. During layer | 208 // If this is a new layer, ensure it has a recording source. During layer |
199 // hierarchy deserialization, ::SetLayerTreeHost(...) is not called, but | 209 // hierarchy deserialization, ::SetLayerTreeHost(...) is not called, but |
200 // instead the member is set directly, so it needs to be set here explicitly. | 210 // instead the member is set directly, so it needs to be set here explicitly. |
201 if (!recording_source_) | 211 if (!recording_source_) { |
202 recording_source_.reset(new RecordingSource); | 212 recording_source_.reset(new RecordingSource); |
213 // A RecordingSource is only ever deserialized on the client. | |
214 recording_source_->SetClientPictureCache( | |
215 layer_tree_host()->client_picture_cache()); | |
216 } | |
203 | 217 |
204 recording_source_->FromProtobuf( | 218 recording_source_->FromProtobuf(picture.recording_source()); |
205 picture.recording_source(), | |
206 layer_tree_host()->image_serialization_processor()); | |
207 | 219 |
208 Region new_invalidation = RegionFromProto(picture.invalidation()); | 220 Region new_invalidation = RegionFromProto(picture.invalidation()); |
209 last_updated_invalidation_.Swap(&new_invalidation); | 221 last_updated_invalidation_.Swap(&new_invalidation); |
210 is_mask_ = picture.is_mask(); | 222 is_mask_ = picture.is_mask(); |
211 nearest_neighbor_ = picture.nearest_neighbor(); | 223 nearest_neighbor_ = picture.nearest_neighbor(); |
212 | 224 |
213 update_source_frame_number_ = picture.update_source_frame_number(); | 225 update_source_frame_number_ = picture.update_source_frame_number(); |
214 } | 226 } |
215 | 227 |
216 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { | 228 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { |
(...skipping 18 matching lines...) Expand all Loading... | |
235 if (update_source_frame_number_ != source_frame_number && | 247 if (update_source_frame_number_ != source_frame_number && |
236 recording_source_bounds != layer_bounds) { | 248 recording_source_bounds != layer_bounds) { |
237 // Update may not get called for the layer (if it's not in the viewport | 249 // Update may not get called for the layer (if it's not in the viewport |
238 // for example), even though it has resized making the recording source no | 250 // for example), even though it has resized making the recording source no |
239 // longer valid. In this case just destroy the recording source. | 251 // longer valid. In this case just destroy the recording source. |
240 recording_source_->SetEmptyBounds(); | 252 recording_source_->SetEmptyBounds(); |
241 } | 253 } |
242 } | 254 } |
243 | 255 |
244 } // namespace cc | 256 } // namespace cc |
OLD | NEW |