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

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

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