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 "cc/layers/content_layer_client.h" | 7 #include "cc/layers/content_layer_client.h" |
8 #include "cc/layers/picture_layer_impl.h" | 8 #include "cc/layers/picture_layer_impl.h" |
9 #include "cc/trees/layer_tree_impl.h" | 9 #include "cc/trees/layer_tree_impl.h" |
10 #include "third_party/skia/include/core/SkPictureRecorder.h" | 10 #include "third_party/skia/include/core/SkPictureRecorder.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 if (layer_impl->bounds().IsEmpty()) { | 43 if (layer_impl->bounds().IsEmpty()) { |
44 // Update may not get called for an empty layer, so resize here instead. | 44 // Update may not get called for an empty layer, so resize here instead. |
45 // Using layer_impl because either bounds() or paint_properties().bounds | 45 // Using layer_impl because either bounds() or paint_properties().bounds |
46 // may disagree and either one could have been pushed to layer_impl. | 46 // may disagree and either one could have been pushed to layer_impl. |
47 pile_->SetEmptyBounds(); | 47 pile_->SetEmptyBounds(); |
48 } else if (update_source_frame_number_ == | 48 } else if (update_source_frame_number_ == |
49 layer_tree_host()->source_frame_number()) { | 49 layer_tree_host()->source_frame_number()) { |
50 // TODO(ernstm): This DCHECK is only valid as long as the pile's tiling_rect | 50 // TODO(ernstm): This DCHECK is only valid as long as the pile's tiling_rect |
51 // is identical to the layer_rect. | 51 // is identical to the layer_rect. |
52 // If update called, then pile size must match bounds pushed to impl layer. | 52 // If update called, then pile size must match bounds pushed to impl layer. |
53 DCHECK_EQ(layer_impl->bounds().ToString(), | 53 DCHECK_EQ(layer_impl->bounds().ToString(), pile_->tiling_size().ToString()); |
54 pile_->tiling_rect().size().ToString()); | |
55 } | 54 } |
56 | 55 |
57 layer_impl->SetIsMask(is_mask_); | 56 layer_impl->SetIsMask(is_mask_); |
58 | 57 |
59 // Unlike other properties, invalidation must always be set on layer_impl. | 58 // Unlike other properties, invalidation must always be set on layer_impl. |
60 // See PictureLayerImpl::PushPropertiesTo for more details. | 59 // See PictureLayerImpl::PushPropertiesTo for more details. |
61 layer_impl->invalidation_.Clear(); | 60 layer_impl->invalidation_.Clear(); |
62 layer_impl->invalidation_.Swap(&pile_invalidation_); | 61 layer_impl->invalidation_.Swap(&pile_invalidation_); |
63 layer_impl->pile_ = PicturePileImpl::CreateFromOther(pile_.get()); | 62 layer_impl->pile_ = PicturePileImpl::CreateFromOther(pile_.get()); |
64 } | 63 } |
(...skipping 22 matching lines...) Expand all Loading... |
87 | 86 |
88 bool PictureLayer::Update(ResourceUpdateQueue* queue, | 87 bool PictureLayer::Update(ResourceUpdateQueue* queue, |
89 const OcclusionTracker<Layer>* occlusion) { | 88 const OcclusionTracker<Layer>* occlusion) { |
90 update_source_frame_number_ = layer_tree_host()->source_frame_number(); | 89 update_source_frame_number_ = layer_tree_host()->source_frame_number(); |
91 bool updated = Layer::Update(queue, occlusion); | 90 bool updated = Layer::Update(queue, occlusion); |
92 | 91 |
93 UpdateCanUseLCDText(); | 92 UpdateCanUseLCDText(); |
94 | 93 |
95 gfx::Rect visible_layer_rect = gfx::ScaleToEnclosingRect( | 94 gfx::Rect visible_layer_rect = gfx::ScaleToEnclosingRect( |
96 visible_content_rect(), 1.f / contents_scale_x()); | 95 visible_content_rect(), 1.f / contents_scale_x()); |
97 | 96 gfx::Size layer_size = paint_properties().bounds; |
98 gfx::Rect layer_rect = gfx::Rect(paint_properties().bounds); | |
99 | 97 |
100 if (last_updated_visible_content_rect_ == visible_content_rect() && | 98 if (last_updated_visible_content_rect_ == visible_content_rect() && |
101 pile_->tiling_rect() == layer_rect && pending_invalidation_.IsEmpty()) { | 99 pile_->tiling_size() == layer_size && pending_invalidation_.IsEmpty()) { |
102 // Only early out if the visible content rect of this layer hasn't changed. | 100 // Only early out if the visible content rect of this layer hasn't changed. |
103 return updated; | 101 return updated; |
104 } | 102 } |
105 | 103 |
106 TRACE_EVENT1("cc", "PictureLayer::Update", | 104 TRACE_EVENT1("cc", "PictureLayer::Update", |
107 "source_frame_number", | 105 "source_frame_number", |
108 layer_tree_host()->source_frame_number()); | 106 layer_tree_host()->source_frame_number()); |
109 devtools_instrumentation::ScopedLayerTreeTask update_layer( | 107 devtools_instrumentation::ScopedLayerTreeTask update_layer( |
110 devtools_instrumentation::kUpdateLayer, id(), layer_tree_host()->id()); | 108 devtools_instrumentation::kUpdateLayer, id(), layer_tree_host()->id()); |
111 | 109 |
112 // Calling paint in WebKit can sometimes cause invalidations, so save | 110 // Calling paint in WebKit can sometimes cause invalidations, so save |
113 // off the invalidation prior to calling update. | 111 // off the invalidation prior to calling update. |
114 pending_invalidation_.Swap(&pile_invalidation_); | 112 pending_invalidation_.Swap(&pile_invalidation_); |
115 pending_invalidation_.Clear(); | 113 pending_invalidation_.Clear(); |
116 | 114 |
117 if (layer_tree_host()->settings().record_full_layer) { | 115 if (layer_tree_host()->settings().record_full_layer) { |
118 // Workaround for http://crbug.com/235910 - to retain backwards compat | 116 // Workaround for http://crbug.com/235910 - to retain backwards compat |
119 // the full page content must always be provided in the picture layer. | 117 // the full page content must always be provided in the picture layer. |
120 visible_layer_rect = gfx::Rect(bounds()); | 118 visible_layer_rect = gfx::Rect(layer_size); |
121 } | 119 } |
122 | 120 |
123 // UpdateAndExpandInvalidation will give us an invalidation that covers | 121 // UpdateAndExpandInvalidation will give us an invalidation that covers |
124 // anything not explicitly recorded in this frame. We give this region | 122 // anything not explicitly recorded in this frame. We give this region |
125 // to the impl side so that it drops tiles that may not have a recording | 123 // to the impl side so that it drops tiles that may not have a recording |
126 // for them. | 124 // for them. |
127 DCHECK(client_); | 125 DCHECK(client_); |
128 updated |= | 126 updated |= |
129 pile_->UpdateAndExpandInvalidation(client_, | 127 pile_->UpdateAndExpandInvalidation(client_, |
130 &pile_invalidation_, | 128 &pile_invalidation_, |
131 SafeOpaqueBackgroundColor(), | 129 SafeOpaqueBackgroundColor(), |
132 contents_opaque(), | 130 contents_opaque(), |
133 client_->FillsBoundsCompletely(), | 131 client_->FillsBoundsCompletely(), |
134 layer_rect, | 132 layer_size, |
135 visible_layer_rect, | 133 visible_layer_rect, |
136 update_source_frame_number_, | 134 update_source_frame_number_, |
137 RecordingMode(), | 135 RecordingMode(), |
138 rendering_stats_instrumentation()); | 136 rendering_stats_instrumentation()); |
139 last_updated_visible_content_rect_ = visible_content_rect(); | 137 last_updated_visible_content_rect_ = visible_content_rect(); |
140 | 138 |
141 if (updated) { | 139 if (updated) { |
142 SetNeedsPushProperties(); | 140 SetNeedsPushProperties(); |
143 } else { | 141 } else { |
144 // If this invalidation did not affect the pile, then it can be cleared as | 142 // If this invalidation did not affect the pile, then it can be cleared as |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 | 198 |
201 bool PictureLayer::IsSuitableForGpuRasterization() const { | 199 bool PictureLayer::IsSuitableForGpuRasterization() const { |
202 return pile_->is_suitable_for_gpu_rasterization(); | 200 return pile_->is_suitable_for_gpu_rasterization(); |
203 } | 201 } |
204 | 202 |
205 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { | 203 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { |
206 benchmark->RunOnLayer(this); | 204 benchmark->RunOnLayer(this); |
207 } | 205 } |
208 | 206 |
209 } // namespace cc | 207 } // namespace cc |
OLD | NEW |