Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(329)

Side by Side Diff: cc/layers/picture_layer.cc

Issue 1982893002: [blimp] Add SkPicture caching support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git merge origin/master Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 19 matching lines...) Expand all
30 is_mask_(false), 30 is_mask_(false),
31 nearest_neighbor_(false) {} 31 nearest_neighbor_(false) {}
32 32
33 PictureLayer::PictureLayer(ContentLayerClient* client, 33 PictureLayer::PictureLayer(ContentLayerClient* client,
34 std::unique_ptr<RecordingSource> source) 34 std::unique_ptr<RecordingSource> source)
35 : PictureLayer(client) { 35 : PictureLayer(client) {
36 recording_source_ = std::move(source); 36 recording_source_ = std::move(source);
37 } 37 }
38 38
39 PictureLayer::~PictureLayer() { 39 PictureLayer::~PictureLayer() {
40 // If there is a RecordingSource, it needs to be unregistered.
41 if (recording_source_)
42 recording_source_->MarkForUnregistration();
40 } 43 }
41 44
42 std::unique_ptr<LayerImpl> PictureLayer::CreateLayerImpl( 45 std::unique_ptr<LayerImpl> PictureLayer::CreateLayerImpl(
43 LayerTreeImpl* tree_impl) { 46 LayerTreeImpl* tree_impl) {
44 return PictureLayerImpl::Create(tree_impl, id(), is_mask_); 47 return PictureLayerImpl::Create(tree_impl, id(), is_mask_);
45 } 48 }
46 49
47 void PictureLayer::PushPropertiesTo(LayerImpl* base_layer) { 50 void PictureLayer::PushPropertiesTo(LayerImpl* base_layer) {
48 Layer::PushPropertiesTo(base_layer); 51 Layer::PushPropertiesTo(base_layer);
49 TRACE_EVENT0("cc", "PictureLayer::PushPropertiesTo"); 52 TRACE_EVENT0("cc", "PictureLayer::PushPropertiesTo");
50 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer); 53 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer);
51 // TODO(danakj): Make is_mask_ a constructor parameter for PictureLayer. 54 // TODO(danakj): Make is_mask_ a constructor parameter for PictureLayer.
52 DCHECK_EQ(layer_impl->is_mask(), is_mask_); 55 DCHECK_EQ(layer_impl->is_mask(), is_mask_);
53 DropRecordingSourceContentIfInvalid(); 56 DropRecordingSourceContentIfInvalid();
54 57
55 layer_impl->SetNearestNeighbor(nearest_neighbor_); 58 layer_impl->SetNearestNeighbor(nearest_neighbor_);
56 59
57 // Preserve lcd text settings from the current raster source. 60 // Preserve lcd text settings from the current raster source.
58 bool can_use_lcd_text = layer_impl->RasterSourceUsesLCDText(); 61 bool can_use_lcd_text = layer_impl->RasterSourceUsesLCDText();
59 scoped_refptr<RasterSource> raster_source = 62 scoped_refptr<RasterSource> raster_source =
60 recording_source_->CreateRasterSource(can_use_lcd_text); 63 recording_source_->CreateRasterSource(can_use_lcd_text);
61 layer_impl->set_gpu_raster_max_texture_size( 64 layer_impl->set_gpu_raster_max_texture_size(
62 layer_tree_host()->device_viewport_size()); 65 layer_tree_host()->device_viewport_size());
63 layer_impl->UpdateRasterSource(raster_source, &last_updated_invalidation_, 66 layer_impl->UpdateRasterSource(raster_source, &last_updated_invalidation_,
64 nullptr); 67 nullptr);
65 DCHECK(last_updated_invalidation_.IsEmpty()); 68 DCHECK(last_updated_invalidation_.IsEmpty());
66 } 69 }
67 70
68 void PictureLayer::SetLayerTreeHost(LayerTreeHost* host) { 71 void PictureLayer::SetLayerTreeHost(LayerTreeHost* host) {
72 LayerTreeHost* old_host = layer_tree_host();
69 Layer::SetLayerTreeHost(host); 73 Layer::SetLayerTreeHost(host);
74 if (old_host == host)
vmpstr 2016/06/01 00:10:56 When does this happen? Should this check be even h
nyquist 2016/06/04 00:24:57 Removed now.
75 return;
76
77 if (old_host && recording_source_) {
78 // The LayerTreeHost has changed and there was already a recording source,
79 // so unregister everything in the RecordingSource.
80 recording_source_->MarkForUnregistration();
vmpstr 2016/06/01 00:10:56 This feels wrong.
nyquist 2016/06/04 00:24:57 Removed this block.
81 recording_source_->set_engine_picture_cache(nullptr);
82 recording_source_->set_client_picture_cache(nullptr);
83 }
84
70 if (!host) 85 if (!host)
71 return; 86 return;
72 87
73 if (!recording_source_) 88 if (!recording_source_)
74 recording_source_.reset(new RecordingSource); 89 recording_source_.reset(new RecordingSource);
vmpstr 2016/06/01 00:10:56 This makes me believe that we can just do the Unma
nyquist 2016/06/04 00:24:57 Done.
90
91 // Ensure the recording source has a pointer to the correct picture cache.
92 if (layer_tree_host()->IsRemoteServer()) {
93 recording_source_->set_engine_picture_cache(
vmpstr 2016/06/01 00:10:57 likewise, we can mark things in the set function?
nyquist 2016/06/04 00:24:57 Done.
94 layer_tree_host()->engine_picture_cache());
95 }
96 if (layer_tree_host()->IsRemoteClient()) {
97 recording_source_->set_client_picture_cache(
98 layer_tree_host()->client_picture_cache());
99 }
100 // Ensure that the currently empty RecordingSource is set in the marked state.
101 recording_source_->MarkForRegistration();
102
75 recording_source_->SetSlowdownRasterScaleFactor( 103 recording_source_->SetSlowdownRasterScaleFactor(
76 host->debug_state().slow_down_raster_scale_factor); 104 host->debug_state().slow_down_raster_scale_factor);
77 // If we need to enable image decode tasks, then we have to generate the 105 // If we need to enable image decode tasks, then we have to generate the
78 // discardable images metadata. 106 // discardable images metadata.
79 const LayerTreeSettings& settings = layer_tree_host()->settings(); 107 const LayerTreeSettings& settings = layer_tree_host()->settings();
80 recording_source_->SetGenerateDiscardableImagesMetadata( 108 recording_source_->SetGenerateDiscardableImagesMetadata(
81 settings.image_decode_tasks_enabled); 109 settings.image_decode_tasks_enabled);
82 } 110 }
83 111
84 void PictureLayer::SetNeedsDisplayRect(const gfx::Rect& layer_rect) { 112 void PictureLayer::SetNeedsDisplayRect(const gfx::Rect& layer_rect) {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 void PictureLayer::SetTypeForProtoSerialization(proto::LayerNode* proto) const { 200 void PictureLayer::SetTypeForProtoSerialization(proto::LayerNode* proto) const {
173 proto->set_type(proto::LayerNode::PICTURE_LAYER); 201 proto->set_type(proto::LayerNode::PICTURE_LAYER);
174 } 202 }
175 203
176 void PictureLayer::LayerSpecificPropertiesToProto( 204 void PictureLayer::LayerSpecificPropertiesToProto(
177 proto::LayerProperties* proto) { 205 proto::LayerProperties* proto) {
178 Layer::LayerSpecificPropertiesToProto(proto); 206 Layer::LayerSpecificPropertiesToProto(proto);
179 DropRecordingSourceContentIfInvalid(); 207 DropRecordingSourceContentIfInvalid();
180 208
181 proto::PictureLayerProperties* picture = proto->mutable_picture(); 209 proto::PictureLayerProperties* picture = proto->mutable_picture();
182 recording_source_->ToProtobuf( 210 recording_source_->ToProtobuf(picture->mutable_recording_source());
183 picture->mutable_recording_source(), 211
184 layer_tree_host()->image_serialization_processor());
185 RegionToProto(last_updated_invalidation_, picture->mutable_invalidation()); 212 RegionToProto(last_updated_invalidation_, picture->mutable_invalidation());
186 picture->set_is_mask(is_mask_); 213 picture->set_is_mask(is_mask_);
187 picture->set_nearest_neighbor(nearest_neighbor_); 214 picture->set_nearest_neighbor(nearest_neighbor_);
188 215
189 picture->set_update_source_frame_number(update_source_frame_number_); 216 picture->set_update_source_frame_number(update_source_frame_number_);
190 217
191 last_updated_invalidation_.Clear(); 218 last_updated_invalidation_.Clear();
192 } 219 }
193 220
194 void PictureLayer::FromLayerSpecificPropertiesProto( 221 void PictureLayer::FromLayerSpecificPropertiesProto(
195 const proto::LayerProperties& proto) { 222 const proto::LayerProperties& proto) {
196 Layer::FromLayerSpecificPropertiesProto(proto); 223 Layer::FromLayerSpecificPropertiesProto(proto);
197 const proto::PictureLayerProperties& picture = proto.picture(); 224 const proto::PictureLayerProperties& picture = proto.picture();
198 // If this is a new layer, ensure it has a recording source. During layer 225 // If this is a new layer, ensure it has a recording source. During layer
199 // hierarchy deserialization, ::SetLayerTreeHost(...) is not called, but 226 // hierarchy deserialization, ::SetLayerTreeHost(...) is not called, but
200 // instead the member is set directly, so it needs to be set here explicitly. 227 // instead the member is set directly, so it needs to be set here explicitly.
201 if (!recording_source_) 228 if (!recording_source_) {
202 recording_source_.reset(new RecordingSource); 229 recording_source_.reset(new RecordingSource);
230 // A RecordingSource is only ever deserialized on the client.
231 recording_source_->set_client_picture_cache(
232 layer_tree_host()->client_picture_cache());
233 }
203 234
204 recording_source_->FromProtobuf( 235 recording_source_->FromProtobuf(picture.recording_source());
205 picture.recording_source(),
206 layer_tree_host()->image_serialization_processor());
207 236
208 Region new_invalidation = RegionFromProto(picture.invalidation()); 237 Region new_invalidation = RegionFromProto(picture.invalidation());
209 last_updated_invalidation_.Swap(&new_invalidation); 238 last_updated_invalidation_.Swap(&new_invalidation);
210 is_mask_ = picture.is_mask(); 239 is_mask_ = picture.is_mask();
211 nearest_neighbor_ = picture.nearest_neighbor(); 240 nearest_neighbor_ = picture.nearest_neighbor();
212 241
213 update_source_frame_number_ = picture.update_source_frame_number(); 242 update_source_frame_number_ = picture.update_source_frame_number();
214 } 243 }
215 244
216 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { 245 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) {
(...skipping 18 matching lines...) Expand all
235 if (update_source_frame_number_ != source_frame_number && 264 if (update_source_frame_number_ != source_frame_number &&
236 recording_source_bounds != layer_bounds) { 265 recording_source_bounds != layer_bounds) {
237 // Update may not get called for the layer (if it's not in the viewport 266 // 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 267 // for example), even though it has resized making the recording source no
239 // longer valid. In this case just destroy the recording source. 268 // longer valid. In this case just destroy the recording source.
240 recording_source_->SetEmptyBounds(); 269 recording_source_->SetEmptyBounds();
241 } 270 }
242 } 271 }
243 272
244 } // namespace cc 273 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698