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

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

Issue 1812733003: Store recording invalidations in DisplayListRecordingSource, save them via Update. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « cc/layers/picture_layer.h ('k') | cc/layers/picture_layer_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 DropRecordingSourceContentIfInvalid(); 52 DropRecordingSourceContentIfInvalid();
53 53
54 layer_impl->SetNearestNeighbor(nearest_neighbor_); 54 layer_impl->SetNearestNeighbor(nearest_neighbor_);
55 55
56 // Preserve lcd text settings from the current raster source. 56 // Preserve lcd text settings from the current raster source.
57 bool can_use_lcd_text = layer_impl->RasterSourceUsesLCDText(); 57 bool can_use_lcd_text = layer_impl->RasterSourceUsesLCDText();
58 scoped_refptr<DisplayListRasterSource> raster_source = 58 scoped_refptr<DisplayListRasterSource> raster_source =
59 recording_source_->CreateRasterSource(can_use_lcd_text); 59 recording_source_->CreateRasterSource(can_use_lcd_text);
60 layer_impl->set_gpu_raster_max_texture_size( 60 layer_impl->set_gpu_raster_max_texture_size(
61 layer_tree_host()->device_viewport_size()); 61 layer_tree_host()->device_viewport_size());
62 layer_impl->UpdateRasterSource(raster_source, invalidation_.region(), 62 layer_impl->UpdateRasterSource(raster_source, &last_updated_invalidation_,
63 nullptr); 63 nullptr);
64 DCHECK(invalidation_.IsEmpty()); 64 DCHECK(last_updated_invalidation_.IsEmpty());
65 } 65 }
66 66
67 void PictureLayer::SetLayerTreeHost(LayerTreeHost* host) { 67 void PictureLayer::SetLayerTreeHost(LayerTreeHost* host) {
68 Layer::SetLayerTreeHost(host); 68 Layer::SetLayerTreeHost(host);
69 if (!host) 69 if (!host)
70 return; 70 return;
71 71
72 if (!recording_source_) 72 if (!recording_source_)
73 recording_source_.reset(new DisplayListRecordingSource); 73 recording_source_.reset(new DisplayListRecordingSource);
74 recording_source_->SetSlowdownRasterScaleFactor( 74 recording_source_->SetSlowdownRasterScaleFactor(
75 host->debug_state().slow_down_raster_scale_factor); 75 host->debug_state().slow_down_raster_scale_factor);
76 // If we need to enable image decode tasks, then we have to generate the 76 // If we need to enable image decode tasks, then we have to generate the
77 // discardable images metadata. 77 // discardable images metadata.
78 const LayerTreeSettings& settings = layer_tree_host()->settings(); 78 const LayerTreeSettings& settings = layer_tree_host()->settings();
79 recording_source_->SetGenerateDiscardableImagesMetadata( 79 recording_source_->SetGenerateDiscardableImagesMetadata(
80 settings.image_decode_tasks_enabled); 80 settings.image_decode_tasks_enabled);
81 } 81 }
82 82
83 void PictureLayer::SetNeedsDisplayRect(const gfx::Rect& layer_rect) { 83 void PictureLayer::SetNeedsDisplayRect(const gfx::Rect& layer_rect) {
84 DCHECK(!layer_tree_host() || !layer_tree_host()->in_paint_layer_contents()); 84 DCHECK(!layer_tree_host() || !layer_tree_host()->in_paint_layer_contents());
85 if (!layer_rect.IsEmpty()) { 85 if (recording_source_)
86 // Clamp invalidation to the layer bounds. 86 recording_source_->SetNeedsDisplayRect(layer_rect);
87 invalidation_.Union(gfx::IntersectRects(layer_rect, gfx::Rect(bounds())));
88 }
89 Layer::SetNeedsDisplayRect(layer_rect); 87 Layer::SetNeedsDisplayRect(layer_rect);
90 } 88 }
91 89
92 bool PictureLayer::Update() { 90 bool PictureLayer::Update() {
93 update_source_frame_number_ = layer_tree_host()->source_frame_number(); 91 update_source_frame_number_ = layer_tree_host()->source_frame_number();
94 bool updated = Layer::Update(); 92 bool updated = Layer::Update();
95 93
96 gfx::Rect update_rect = visible_layer_rect(); 94 gfx::Rect update_rect = visible_layer_rect();
97 gfx::Size layer_size = paint_properties().bounds; 95 gfx::Size layer_size = paint_properties().bounds;
98 96
99 if (last_updated_visible_layer_rect_ == update_rect &&
100 recording_source_->GetSize() == layer_size && invalidation_.IsEmpty()) {
101 // Only early out if the visible content rect of this layer hasn't changed.
102 return updated;
103 }
104
105 recording_source_->SetBackgroundColor(SafeOpaqueBackgroundColor()); 97 recording_source_->SetBackgroundColor(SafeOpaqueBackgroundColor());
106 recording_source_->SetRequiresClear(!contents_opaque() && 98 recording_source_->SetRequiresClear(!contents_opaque() &&
107 !client_->FillsBoundsCompletely()); 99 !client_->FillsBoundsCompletely());
108 100
109 TRACE_EVENT1("cc", "PictureLayer::Update", 101 TRACE_EVENT1("cc", "PictureLayer::Update",
110 "source_frame_number", 102 "source_frame_number",
111 layer_tree_host()->source_frame_number()); 103 layer_tree_host()->source_frame_number());
112 devtools_instrumentation::ScopedLayerTreeTask update_layer( 104 devtools_instrumentation::ScopedLayerTreeTask update_layer(
113 devtools_instrumentation::kUpdateLayer, id(), layer_tree_host()->id()); 105 devtools_instrumentation::kUpdateLayer, id(), layer_tree_host()->id());
114 106
115 // UpdateAndExpandInvalidation will give us an invalidation that covers 107 // UpdateAndExpandInvalidation will give us an invalidation that covers
116 // anything not explicitly recorded in this frame. We give this region 108 // anything not explicitly recorded in this frame. We give this region
117 // to the impl side so that it drops tiles that may not have a recording 109 // to the impl side so that it drops tiles that may not have a recording
118 // for them. 110 // for them.
119 DCHECK(client_); 111 DCHECK(client_);
120 updated |= recording_source_->UpdateAndExpandInvalidation( 112 updated |= recording_source_->UpdateAndExpandInvalidation(
121 client_, invalidation_.region(), layer_size, update_rect, 113 client_, &last_updated_invalidation_, layer_size, update_rect,
122 update_source_frame_number_, DisplayListRecordingSource::RECORD_NORMALLY); 114 update_source_frame_number_, DisplayListRecordingSource::RECORD_NORMALLY);
123 last_updated_visible_layer_rect_ = visible_layer_rect(); 115 last_updated_visible_layer_rect_ = visible_layer_rect();
124 116
125 if (updated) { 117 if (updated) {
126 SetNeedsPushProperties(); 118 SetNeedsPushProperties();
127 } else { 119 } else {
128 // If this invalidation did not affect the recording source, then it can be 120 // If this invalidation did not affect the recording source, then it can be
129 // cleared as an optimization. 121 // cleared as an optimization.
130 invalidation_.Clear(); 122 last_updated_invalidation_.Clear();
131 } 123 }
132 124
133 return updated; 125 return updated;
134 } 126 }
135 127
136 void PictureLayer::SetIsMask(bool is_mask) { 128 void PictureLayer::SetIsMask(bool is_mask) {
137 is_mask_ = is_mask; 129 is_mask_ = is_mask;
138 } 130 }
139 131
140 skia::RefPtr<SkPicture> PictureLayer::GetPicture() const { 132 skia::RefPtr<SkPicture> PictureLayer::GetPicture() const {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 177
186 void PictureLayer::LayerSpecificPropertiesToProto( 178 void PictureLayer::LayerSpecificPropertiesToProto(
187 proto::LayerProperties* proto) { 179 proto::LayerProperties* proto) {
188 Layer::LayerSpecificPropertiesToProto(proto); 180 Layer::LayerSpecificPropertiesToProto(proto);
189 DropRecordingSourceContentIfInvalid(); 181 DropRecordingSourceContentIfInvalid();
190 182
191 proto::PictureLayerProperties* picture = proto->mutable_picture(); 183 proto::PictureLayerProperties* picture = proto->mutable_picture();
192 recording_source_->ToProtobuf( 184 recording_source_->ToProtobuf(
193 picture->mutable_recording_source(), 185 picture->mutable_recording_source(),
194 layer_tree_host()->image_serialization_processor()); 186 layer_tree_host()->image_serialization_processor());
195 RegionToProto(*invalidation_.region(), picture->mutable_invalidation()); 187 RegionToProto(last_updated_invalidation_, picture->mutable_invalidation());
196 RectToProto(last_updated_visible_layer_rect_, 188 RectToProto(last_updated_visible_layer_rect_,
197 picture->mutable_last_updated_visible_layer_rect()); 189 picture->mutable_last_updated_visible_layer_rect());
198 picture->set_is_mask(is_mask_); 190 picture->set_is_mask(is_mask_);
199 picture->set_nearest_neighbor(nearest_neighbor_); 191 picture->set_nearest_neighbor(nearest_neighbor_);
200 192
201 picture->set_update_source_frame_number(update_source_frame_number_); 193 picture->set_update_source_frame_number(update_source_frame_number_);
202 194
203 invalidation_.Clear(); 195 last_updated_invalidation_.Clear();
204 } 196 }
205 197
206 void PictureLayer::FromLayerSpecificPropertiesProto( 198 void PictureLayer::FromLayerSpecificPropertiesProto(
207 const proto::LayerProperties& proto) { 199 const proto::LayerProperties& proto) {
208 Layer::FromLayerSpecificPropertiesProto(proto); 200 Layer::FromLayerSpecificPropertiesProto(proto);
209 const proto::PictureLayerProperties& picture = proto.picture(); 201 const proto::PictureLayerProperties& picture = proto.picture();
210 // If this is a new layer, ensure it has a recording source. During layer 202 // If this is a new layer, ensure it has a recording source. During layer
211 // hierarchy deserialization, ::SetLayerTreeHost(...) is not called, but 203 // hierarchy deserialization, ::SetLayerTreeHost(...) is not called, but
212 // instead the member is set directly, so it needs to be set here explicitly. 204 // instead the member is set directly, so it needs to be set here explicitly.
213 if (!recording_source_) 205 if (!recording_source_)
214 recording_source_.reset(new DisplayListRecordingSource); 206 recording_source_.reset(new DisplayListRecordingSource);
215 207
216 recording_source_->FromProtobuf( 208 recording_source_->FromProtobuf(
217 picture.recording_source(), 209 picture.recording_source(),
218 layer_tree_host()->image_serialization_processor()); 210 layer_tree_host()->image_serialization_processor());
219 211
220 Region new_invalidation = RegionFromProto(picture.invalidation()); 212 Region new_invalidation = RegionFromProto(picture.invalidation());
221 invalidation_.Swap(&new_invalidation); 213 last_updated_invalidation_.Swap(&new_invalidation);
222 last_updated_visible_layer_rect_ = 214 last_updated_visible_layer_rect_ =
223 ProtoToRect(picture.last_updated_visible_layer_rect()); 215 ProtoToRect(picture.last_updated_visible_layer_rect());
224 is_mask_ = picture.is_mask(); 216 is_mask_ = picture.is_mask();
225 nearest_neighbor_ = picture.nearest_neighbor(); 217 nearest_neighbor_ = picture.nearest_neighbor();
226 218
227 update_source_frame_number_ = picture.update_source_frame_number(); 219 update_source_frame_number_ = picture.update_source_frame_number();
228 } 220 }
229 221
230 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { 222 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) {
231 benchmark->RunOnLayer(this); 223 benchmark->RunOnLayer(this);
(...skipping 17 matching lines...) Expand all
249 if (update_source_frame_number_ != source_frame_number && 241 if (update_source_frame_number_ != source_frame_number &&
250 recording_source_bounds != layer_bounds) { 242 recording_source_bounds != layer_bounds) {
251 // Update may not get called for the layer (if it's not in the viewport 243 // Update may not get called for the layer (if it's not in the viewport
252 // for example), even though it has resized making the recording source no 244 // for example), even though it has resized making the recording source no
253 // longer valid. In this case just destroy the recording source. 245 // longer valid. In this case just destroy the recording source.
254 recording_source_->SetEmptyBounds(); 246 recording_source_->SetEmptyBounds();
255 } 247 }
256 } 248 }
257 249
258 } // namespace cc 250 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer.h ('k') | cc/layers/picture_layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698