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 "ui/gfx/rect_conversions.h" | 10 #include "ui/gfx/rect_conversions.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 } | 35 } |
36 | 36 |
37 void PictureLayer::PushPropertiesTo(LayerImpl* base_layer) { | 37 void PictureLayer::PushPropertiesTo(LayerImpl* base_layer) { |
38 Layer::PushPropertiesTo(base_layer); | 38 Layer::PushPropertiesTo(base_layer); |
39 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer); | 39 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer); |
40 | 40 |
41 if (layer_impl->bounds().IsEmpty()) { | 41 if (layer_impl->bounds().IsEmpty()) { |
42 // Update may not get called for an empty layer, so resize here instead. | 42 // Update may not get called for an empty layer, so resize here instead. |
43 // Using layer_impl because either bounds() or paint_properties().bounds | 43 // Using layer_impl because either bounds() or paint_properties().bounds |
44 // may disagree and either one could have been pushed to layer_impl. | 44 // may disagree and either one could have been pushed to layer_impl. |
45 pile_->Resize(gfx::Size()); | 45 pile_->SetTilingRect(gfx::Rect()); |
46 } else if (update_source_frame_number_ == | 46 } else if (update_source_frame_number_ == |
47 layer_tree_host()->source_frame_number()) { | 47 layer_tree_host()->source_frame_number()) { |
| 48 // TODO(ernstm): This DCHECK is only valid as long as the pile's tiling_rect |
| 49 // is identical to the layer_rect. |
48 // If update called, then pile size must match bounds pushed to impl layer. | 50 // If update called, then pile size must match bounds pushed to impl layer. |
49 DCHECK_EQ(layer_impl->bounds().ToString(), pile_->size().ToString()); | 51 DCHECK_EQ(layer_impl->bounds().ToString(), |
| 52 pile_->tiling_rect().size().ToString()); |
50 } | 53 } |
51 | 54 |
52 layer_impl->SetIsMask(is_mask_); | 55 layer_impl->SetIsMask(is_mask_); |
53 layer_impl->SetHasGpuRasterizationHint(has_gpu_rasterization_hint_); | 56 layer_impl->SetHasGpuRasterizationHint(has_gpu_rasterization_hint_); |
54 | 57 |
55 // Unlike other properties, invalidation must always be set on layer_impl. | 58 // Unlike other properties, invalidation must always be set on layer_impl. |
56 // See PictureLayerImpl::PushPropertiesTo for more details. | 59 // See PictureLayerImpl::PushPropertiesTo for more details. |
57 layer_impl->invalidation_.Clear(); | 60 layer_impl->invalidation_.Clear(); |
58 layer_impl->invalidation_.Swap(&pile_invalidation_); | 61 layer_impl->invalidation_.Swap(&pile_invalidation_); |
59 layer_impl->pile_ = PicturePileImpl::CreateFromOther(pile_.get()); | 62 layer_impl->pile_ = PicturePileImpl::CreateFromOther(pile_.get()); |
(...skipping 19 matching lines...) Expand all Loading... |
79 pending_invalidation_.Union(rect); | 82 pending_invalidation_.Union(rect); |
80 } | 83 } |
81 Layer::SetNeedsDisplayRect(layer_rect); | 84 Layer::SetNeedsDisplayRect(layer_rect); |
82 } | 85 } |
83 | 86 |
84 bool PictureLayer::Update(ResourceUpdateQueue* queue, | 87 bool PictureLayer::Update(ResourceUpdateQueue* queue, |
85 const OcclusionTracker<Layer>* occlusion) { | 88 const OcclusionTracker<Layer>* occlusion) { |
86 update_source_frame_number_ = layer_tree_host()->source_frame_number(); | 89 update_source_frame_number_ = layer_tree_host()->source_frame_number(); |
87 bool updated = Layer::Update(queue, occlusion); | 90 bool updated = Layer::Update(queue, occlusion); |
88 | 91 |
| 92 gfx::Rect visible_layer_rect = gfx::ScaleToEnclosingRect( |
| 93 visible_content_rect(), 1.f / contents_scale_x()); |
| 94 |
| 95 gfx::Rect layer_rect = gfx::Rect(paint_properties().bounds); |
| 96 |
89 if (last_updated_visible_content_rect_ == visible_content_rect() && | 97 if (last_updated_visible_content_rect_ == visible_content_rect() && |
90 pile_->size() == paint_properties().bounds && | 98 pile_->tiling_rect() == layer_rect && |
91 pending_invalidation_.IsEmpty()) { | 99 pending_invalidation_.IsEmpty()) { |
92 // 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. |
93 return updated; | 101 return updated; |
94 } | 102 } |
95 | 103 |
96 TRACE_EVENT1("cc", "PictureLayer::Update", | 104 TRACE_EVENT1("cc", "PictureLayer::Update", |
97 "source_frame_number", | 105 "source_frame_number", |
98 layer_tree_host()->source_frame_number()); | 106 layer_tree_host()->source_frame_number()); |
99 | 107 |
100 pile_->Resize(paint_properties().bounds); | 108 pile_->SetTilingRect(layer_rect); |
101 | 109 |
102 // Calling paint in WebKit can sometimes cause invalidations, so save | 110 // Calling paint in WebKit can sometimes cause invalidations, so save |
103 // off the invalidation prior to calling update. | 111 // off the invalidation prior to calling update. |
104 pending_invalidation_.Swap(&pile_invalidation_); | 112 pending_invalidation_.Swap(&pile_invalidation_); |
105 pending_invalidation_.Clear(); | 113 pending_invalidation_.Clear(); |
106 | 114 |
107 gfx::Rect visible_layer_rect = gfx::ScaleToEnclosingRect( | |
108 visible_content_rect(), 1.f / contents_scale_x()); | |
109 if (layer_tree_host()->settings().using_synchronous_renderer_compositor) { | 115 if (layer_tree_host()->settings().using_synchronous_renderer_compositor) { |
110 // Workaround for http://crbug.com/235910 - to retain backwards compat | 116 // Workaround for http://crbug.com/235910 - to retain backwards compat |
111 // 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. |
112 visible_layer_rect = gfx::Rect(bounds()); | 118 visible_layer_rect = gfx::Rect(bounds()); |
113 } | 119 } |
114 DCHECK(client_); | 120 DCHECK(client_); |
115 updated |= pile_->Update(client_, | 121 updated |= pile_->Update(client_, |
116 SafeOpaqueBackgroundColor(), | 122 SafeOpaqueBackgroundColor(), |
117 contents_opaque(), | 123 contents_opaque(), |
118 client_->FillsBoundsCompletely(), | 124 client_->FillsBoundsCompletely(), |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 client_->PaintContents(canvas, gfx::Rect(width, height), &opaque); | 171 client_->PaintContents(canvas, gfx::Rect(width, height), &opaque); |
166 picture->endRecording(); | 172 picture->endRecording(); |
167 return picture; | 173 return picture; |
168 } | 174 } |
169 | 175 |
170 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { | 176 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { |
171 benchmark->RunOnLayer(this); | 177 benchmark->RunOnLayer(this); |
172 } | 178 } |
173 | 179 |
174 } // namespace cc | 180 } // namespace cc |
OLD | NEW |