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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
172 void PictureLayer::SetTypeForProtoSerialization(proto::LayerNode* proto) const { | 172 void PictureLayer::SetTypeForProtoSerialization(proto::LayerNode* proto) const { |
173 proto->set_type(proto::LayerNode::PICTURE_LAYER); | 173 proto->set_type(proto::LayerNode::PICTURE_LAYER); |
174 } | 174 } |
175 | 175 |
176 void PictureLayer::LayerSpecificPropertiesToProto( | 176 void PictureLayer::LayerSpecificPropertiesToProto( |
177 proto::LayerProperties* proto) { | 177 proto::LayerProperties* proto) { |
178 Layer::LayerSpecificPropertiesToProto(proto); | 178 Layer::LayerSpecificPropertiesToProto(proto); |
179 DropRecordingSourceContentIfInvalid(); | 179 DropRecordingSourceContentIfInvalid(); |
180 | 180 |
181 proto::PictureLayerProperties* picture = proto->mutable_picture(); | 181 proto::PictureLayerProperties* picture = proto->mutable_picture(); |
182 recording_source_->ToProtobuf( | 182 recording_source_->ToProtobuf(picture->mutable_recording_source()); |
183 picture->mutable_recording_source(), | 183 |
184 layer_tree_host()->image_serialization_processor()); | 184 // Add all SkPicture items to the picture cache. |
185 scoped_refptr<const DisplayItemList> display_list = | |
vmpstr
2016/06/24 18:58:32
i think you can
const scoped_refptr<const Displa
nyquist
2016/06/24 20:31:23
Done.
| |
186 recording_source_->GetDisplayItemList(); | |
187 if (display_list) { | |
188 for (auto it = display_list->begin(); it != display_list->end(); ++it) { | |
189 sk_sp<const SkPicture> picture = it->GetPicture(); | |
190 // Only DrawingDisplayItems have SkPictures. | |
191 if (!picture) | |
192 continue; | |
193 | |
194 layer_tree_host()->engine_picture_cache()->MarkUsed(picture.get()); | |
195 } | |
196 } | |
197 | |
185 RegionToProto(last_updated_invalidation_, picture->mutable_invalidation()); | 198 RegionToProto(last_updated_invalidation_, picture->mutable_invalidation()); |
186 picture->set_is_mask(is_mask_); | 199 picture->set_is_mask(is_mask_); |
187 picture->set_nearest_neighbor(nearest_neighbor_); | 200 picture->set_nearest_neighbor(nearest_neighbor_); |
188 | 201 |
189 picture->set_update_source_frame_number(update_source_frame_number_); | 202 picture->set_update_source_frame_number(update_source_frame_number_); |
190 | 203 |
191 last_updated_invalidation_.Clear(); | 204 last_updated_invalidation_.Clear(); |
192 } | 205 } |
193 | 206 |
194 void PictureLayer::FromLayerSpecificPropertiesProto( | 207 void PictureLayer::FromLayerSpecificPropertiesProto( |
195 const proto::LayerProperties& proto) { | 208 const proto::LayerProperties& proto) { |
196 Layer::FromLayerSpecificPropertiesProto(proto); | 209 Layer::FromLayerSpecificPropertiesProto(proto); |
197 const proto::PictureLayerProperties& picture = proto.picture(); | 210 const proto::PictureLayerProperties& picture = proto.picture(); |
198 // If this is a new layer, ensure it has a recording source. During layer | 211 // If this is a new layer, ensure it has a recording source. During layer |
199 // hierarchy deserialization, ::SetLayerTreeHost(...) is not called, but | 212 // hierarchy deserialization, ::SetLayerTreeHost(...) is not called, but |
200 // instead the member is set directly, so it needs to be set here explicitly. | 213 // instead the member is set directly, so it needs to be set here explicitly. |
201 if (!recording_source_) | 214 if (!recording_source_) |
202 recording_source_.reset(new RecordingSource); | 215 recording_source_.reset(new RecordingSource); |
203 | 216 |
204 recording_source_->FromProtobuf( | 217 std::vector<uint32_t> used_engine_picture_ids; |
205 picture.recording_source(), | 218 recording_source_->FromProtobuf(picture.recording_source(), |
206 layer_tree_host()->image_serialization_processor()); | 219 layer_tree_host()->client_picture_cache(), |
220 &used_engine_picture_ids); | |
221 | |
222 // Inform picture cache about which SkPictures are now in use. | |
223 for (uint32_t engine_picture_id : used_engine_picture_ids) | |
224 layer_tree_host()->client_picture_cache()->MarkUsed(engine_picture_id); | |
207 | 225 |
208 Region new_invalidation = RegionFromProto(picture.invalidation()); | 226 Region new_invalidation = RegionFromProto(picture.invalidation()); |
209 last_updated_invalidation_.Swap(&new_invalidation); | 227 last_updated_invalidation_.Swap(&new_invalidation); |
210 is_mask_ = picture.is_mask(); | 228 is_mask_ = picture.is_mask(); |
211 nearest_neighbor_ = picture.nearest_neighbor(); | 229 nearest_neighbor_ = picture.nearest_neighbor(); |
212 | 230 |
213 update_source_frame_number_ = picture.update_source_frame_number(); | 231 update_source_frame_number_ = picture.update_source_frame_number(); |
214 } | 232 } |
215 | 233 |
216 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { | 234 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { |
(...skipping 18 matching lines...) Expand all Loading... | |
235 if (update_source_frame_number_ != source_frame_number && | 253 if (update_source_frame_number_ != source_frame_number && |
236 recording_source_bounds != layer_bounds) { | 254 recording_source_bounds != layer_bounds) { |
237 // Update may not get called for the layer (if it's not in the viewport | 255 // 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 | 256 // for example), even though it has resized making the recording source no |
239 // longer valid. In this case just destroy the recording source. | 257 // longer valid. In this case just destroy the recording source. |
240 recording_source_->SetEmptyBounds(); | 258 recording_source_->SetEmptyBounds(); |
241 } | 259 } |
242 } | 260 } |
243 | 261 |
244 } // namespace cc | 262 } // namespace cc |
OLD | NEW |