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->SetUseGpuRasterization(ShouldUseGpuRasterization()); | 56 layer_impl->SetUseGpuRasterization(ShouldUseGpuRasterization()); |
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 && pending_invalidation_.IsEmpty()) { |
91 pending_invalidation_.IsEmpty()) { | |
92 // Only early out if the visible content rect of this layer hasn't changed. | 99 // Only early out if the visible content rect of this layer hasn't changed. |
93 return updated; | 100 return updated; |
94 } | 101 } |
95 | 102 |
96 TRACE_EVENT1("cc", "PictureLayer::Update", | 103 TRACE_EVENT1("cc", "PictureLayer::Update", |
97 "source_frame_number", | 104 "source_frame_number", |
98 layer_tree_host()->source_frame_number()); | 105 layer_tree_host()->source_frame_number()); |
99 | 106 |
100 pile_->Resize(paint_properties().bounds); | 107 pile_->SetTilingRect(layer_rect); |
101 | 108 |
102 // Calling paint in WebKit can sometimes cause invalidations, so save | 109 // Calling paint in WebKit can sometimes cause invalidations, so save |
103 // off the invalidation prior to calling update. | 110 // off the invalidation prior to calling update. |
104 pending_invalidation_.Swap(&pile_invalidation_); | 111 pending_invalidation_.Swap(&pile_invalidation_); |
105 pending_invalidation_.Clear(); | 112 pending_invalidation_.Clear(); |
106 | 113 |
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) { | 114 if (layer_tree_host()->settings().using_synchronous_renderer_compositor) { |
110 // Workaround for http://crbug.com/235910 - to retain backwards compat | 115 // Workaround for http://crbug.com/235910 - to retain backwards compat |
111 // the full page content must always be provided in the picture layer. | 116 // the full page content must always be provided in the picture layer. |
112 visible_layer_rect = gfx::Rect(bounds()); | 117 visible_layer_rect = gfx::Rect(bounds()); |
113 } | 118 } |
114 DCHECK(client_); | 119 DCHECK(client_); |
115 updated |= pile_->Update(client_, | 120 updated |= pile_->Update(client_, |
116 SafeOpaqueBackgroundColor(), | 121 SafeOpaqueBackgroundColor(), |
117 contents_opaque(), | 122 contents_opaque(), |
118 client_->FillsBoundsCompletely(), | 123 client_->FillsBoundsCompletely(), |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 client_->PaintContents(canvas, gfx::Rect(width, height), &opaque); | 196 client_->PaintContents(canvas, gfx::Rect(width, height), &opaque); |
192 picture->endRecording(); | 197 picture->endRecording(); |
193 return picture; | 198 return picture; |
194 } | 199 } |
195 | 200 |
196 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { | 201 void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) { |
197 benchmark->RunOnLayer(this); | 202 benchmark->RunOnLayer(this); |
198 } | 203 } |
199 | 204 |
200 } // namespace cc | 205 } // namespace cc |
OLD | NEW |