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

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

Issue 1527863002: Serialize PictureLayer properties. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed tests Created 5 years 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 "cc/layers/content_layer_client.h" 8 #include "cc/layers/content_layer_client.h"
9 #include "cc/layers/picture_layer_impl.h" 9 #include "cc/layers/picture_layer_impl.h"
10 #include "cc/playback/display_list_recording_source.h" 10 #include "cc/playback/display_list_recording_source.h"
11 #include "cc/proto/cc_conversions.h"
12 #include "cc/proto/gfx_conversions.h"
13 #include "cc/proto/layer.pb.h"
11 #include "cc/trees/layer_tree_host.h" 14 #include "cc/trees/layer_tree_host.h"
12 #include "cc/trees/layer_tree_impl.h" 15 #include "cc/trees/layer_tree_impl.h"
13 #include "third_party/skia/include/core/SkPictureRecorder.h" 16 #include "third_party/skia/include/core/SkPictureRecorder.h"
14 #include "ui/gfx/geometry/rect_conversions.h" 17 #include "ui/gfx/geometry/rect_conversions.h"
15 18
16 namespace cc { 19 namespace cc {
17 20
18 scoped_refptr<PictureLayer> PictureLayer::Create(const LayerSettings& settings, 21 scoped_refptr<PictureLayer> PictureLayer::Create(const LayerSettings& settings,
19 ContentLayerClient* client) { 22 ContentLayerClient* client) {
20 return make_scoped_refptr(new PictureLayer(settings, client)); 23 return make_scoped_refptr(new PictureLayer(settings, client));
(...skipping 22 matching lines...) Expand all
43 scoped_ptr<LayerImpl> PictureLayer::CreateLayerImpl(LayerTreeImpl* tree_impl) { 46 scoped_ptr<LayerImpl> PictureLayer::CreateLayerImpl(LayerTreeImpl* tree_impl) {
44 return PictureLayerImpl::Create(tree_impl, id(), is_mask_, 47 return PictureLayerImpl::Create(tree_impl, id(), is_mask_,
45 new LayerImpl::SyncedScrollOffset); 48 new LayerImpl::SyncedScrollOffset);
46 } 49 }
47 50
48 void PictureLayer::PushPropertiesTo(LayerImpl* base_layer) { 51 void PictureLayer::PushPropertiesTo(LayerImpl* base_layer) {
49 Layer::PushPropertiesTo(base_layer); 52 Layer::PushPropertiesTo(base_layer);
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
54 int source_frame_number = layer_tree_host()->source_frame_number();
55 gfx::Size impl_bounds = layer_impl->bounds();
David Trainor- moved to gerrit 2015/12/15 17:54:30 So, it looks like LayerImpl::bounds() is set a few
56 gfx::Size recording_source_bounds = recording_source_->GetSize();
57
58 // If update called, then recording source size must match bounds pushed to
59 // impl layer.
60 DCHECK(update_source_frame_number_ != source_frame_number ||
61 impl_bounds == recording_source_bounds)
62 << " bounds " << impl_bounds.ToString() << " recording source "
63 << recording_source_bounds.ToString();
64
65 if (update_source_frame_number_ != source_frame_number &&
66 recording_source_bounds != impl_bounds) {
67 // Update may not get called for the layer (if it's not in the viewport
68 // for example, even though it has resized making the recording source no
69 // longer valid. In this case just destroy the recording source.
70 recording_source_->SetEmptyBounds();
71 }
72
73 layer_impl->SetNearestNeighbor(nearest_neighbor_); 56 layer_impl->SetNearestNeighbor(nearest_neighbor_);
74 57
58 ValidateRecordingSource();
75 // Preserve lcd text settings from the current raster source. 59 // Preserve lcd text settings from the current raster source.
76 bool can_use_lcd_text = layer_impl->RasterSourceUsesLCDText(); 60 bool can_use_lcd_text = layer_impl->RasterSourceUsesLCDText();
77 scoped_refptr<DisplayListRasterSource> raster_source = 61 scoped_refptr<DisplayListRasterSource> raster_source =
78 recording_source_->CreateRasterSource(can_use_lcd_text); 62 recording_source_->CreateRasterSource(can_use_lcd_text);
79 layer_impl->set_gpu_raster_max_texture_size( 63 layer_impl->set_gpu_raster_max_texture_size(
80 layer_tree_host()->device_viewport_size()); 64 layer_tree_host()->device_viewport_size());
81 layer_impl->UpdateRasterSource(raster_source, invalidation_.region(), 65 layer_impl->UpdateRasterSource(raster_source, invalidation_.region(),
82 nullptr); 66 nullptr);
83 DCHECK(invalidation_.IsEmpty()); 67 DCHECK(invalidation_.IsEmpty());
84 } 68 }
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 return; 175 return;
192 176
193 nearest_neighbor_ = nearest_neighbor; 177 nearest_neighbor_ = nearest_neighbor;
194 SetNeedsCommit(); 178 SetNeedsCommit();
195 } 179 }
196 180
197 bool PictureLayer::HasDrawableContent() const { 181 bool PictureLayer::HasDrawableContent() const {
198 return client_ && Layer::HasDrawableContent(); 182 return client_ && Layer::HasDrawableContent();
199 } 183 }
200 184
185 void PictureLayer::LayerSpecificPropertiesToProto(
186 proto::LayerProperties* proto) {
187 Layer::LayerSpecificPropertiesToProto(proto);
188 ValidateRecordingSource();
189
190 proto::PictureLayerProperties* picture = proto->mutable_picture();
191 recording_source_->ToProtobuf(picture->mutable_recording_source());
192 RegionToProto(*invalidation_.region(), picture->mutable_invalidation());
193 RectToProto(last_updated_visible_layer_rect_,
194 picture->mutable_last_updated_visible_layer_rect());
195 picture->set_is_mask(is_mask_);
196 picture->set_nearest_neighbor(nearest_neighbor_);
197
198 picture->set_update_source_frame_number(update_source_frame_number_);
199
200 invalidation_.Clear();
201 }
202
203 void PictureLayer::FromLayerSpecificPropertiesProto(
204 const proto::LayerProperties& proto) {
205 Layer::FromLayerSpecificPropertiesProto(proto);
206 const proto::PictureLayerProperties& picture = proto.picture();
207 recording_source_->FromProtobuf(picture.recording_source());
208
209 Region new_invalidation = RegionFromProto(picture.invalidation());
210 invalidation_.Swap(&new_invalidation);
211 last_updated_visible_layer_rect_ =
212 ProtoToRect(picture.last_updated_visible_layer_rect());
213 is_mask_ = picture.is_mask();
214 nearest_neighbor_ = picture.nearest_neighbor();
215
216 update_source_frame_number_ = picture.update_source_frame_number();
217 }
218
201 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { 219 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) {
202 benchmark->RunOnLayer(this); 220 benchmark->RunOnLayer(this);
203 } 221 }
204 222
223 void PictureLayer::ValidateRecordingSource() {
224 int source_frame_number = layer_tree_host()->source_frame_number();
225 gfx::Size recording_source_bounds = recording_source_->GetSize();
226
227 gfx::Size layer_bounds = bounds();
228 if (paint_properties().source_frame_number == source_frame_number)
229 layer_bounds = paint_properties().bounds;
230
231 // If update called, then recording source size must match bounds pushed to
232 // impl layer.
233 DCHECK(update_source_frame_number_ != source_frame_number ||
234 layer_bounds == recording_source_bounds)
235 << " bounds " << layer_bounds.ToString() << " recording source "
236 << recording_source_bounds.ToString();
237
238 if (update_source_frame_number_ != source_frame_number &&
vmpstr 2015/12/16 04:21:08 This if block should not be in this function. Vali
David Trainor- moved to gerrit 2015/12/16 06:51:52 I'll have to rename the function then. We need th
vmpstr 2015/12/16 18:55:39 Renaming the function is fine as well. You can als
David Trainor- moved to gerrit 2015/12/16 19:10:58 Changed it to DropRecordingSourceContentIfInvalid(
239 recording_source_bounds != layer_bounds) {
240 // Update may not get called for the layer (if it's not in the viewport
241 // for example), even though it has resized making the recording source no
242 // longer valid. In this case just destroy the recording source.
243 recording_source_->SetEmptyBounds();
244 }
245 }
246
205 } // namespace cc 247 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698