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/trees/occlusion_tracker.h" | 5 #include "cc/trees/occlusion_tracker.h" |
6 | 6 |
7 #include "cc/animation/layer_animation_controller.h" | 7 #include "cc/animation/layer_animation_controller.h" |
8 #include "cc/base/math_util.h" | 8 #include "cc/base/math_util.h" |
9 #include "cc/layers/layer.h" | 9 #include "cc/layers/layer.h" |
10 #include "cc/layers/layer_impl.h" | 10 #include "cc/layers/layer_impl.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 TestContentLayerImpl* CreateRoot(const gfx::Transform& transform, | 97 TestContentLayerImpl* CreateRoot(const gfx::Transform& transform, |
98 const gfx::PointF& position, | 98 const gfx::PointF& position, |
99 const gfx::Size& bounds) { | 99 const gfx::Size& bounds) { |
100 LayerTreeImpl* tree = host_->host_impl()->active_tree(); | 100 LayerTreeImpl* tree = host_->host_impl()->active_tree(); |
101 int id = next_layer_impl_id_++; | 101 int id = next_layer_impl_id_++; |
102 scoped_ptr<TestContentLayerImpl> layer(new TestContentLayerImpl(tree, id)); | 102 scoped_ptr<TestContentLayerImpl> layer(new TestContentLayerImpl(tree, id)); |
103 TestContentLayerImpl* layer_ptr = layer.get(); | 103 TestContentLayerImpl* layer_ptr = layer.get(); |
104 SetProperties(layer_ptr, transform, position, bounds); | 104 SetProperties(layer_ptr, transform, position, bounds); |
105 | 105 |
106 DCHECK(!root_.get()); | 106 DCHECK(!root_.get()); |
107 root_ = layer.Pass(); | 107 root_ = std::move(layer); |
108 | 108 |
109 layer_ptr->SetHasRenderSurface(true); | 109 layer_ptr->SetHasRenderSurface(true); |
110 SetRootLayerOnMainThread(layer_ptr); | 110 SetRootLayerOnMainThread(layer_ptr); |
111 | 111 |
112 return layer_ptr; | 112 return layer_ptr; |
113 } | 113 } |
114 | 114 |
115 LayerImpl* CreateLayer(LayerImpl* parent, | 115 LayerImpl* CreateLayer(LayerImpl* parent, |
116 const gfx::Transform& transform, | 116 const gfx::Transform& transform, |
117 const gfx::PointF& position, | 117 const gfx::PointF& position, |
118 const gfx::Size& bounds) { | 118 const gfx::Size& bounds) { |
119 LayerTreeImpl* tree = host_->host_impl()->active_tree(); | 119 LayerTreeImpl* tree = host_->host_impl()->active_tree(); |
120 int id = next_layer_impl_id_++; | 120 int id = next_layer_impl_id_++; |
121 scoped_ptr<LayerImpl> layer = LayerImpl::Create(tree, id); | 121 scoped_ptr<LayerImpl> layer = LayerImpl::Create(tree, id); |
122 LayerImpl* layer_ptr = layer.get(); | 122 LayerImpl* layer_ptr = layer.get(); |
123 SetProperties(layer_ptr, transform, position, bounds); | 123 SetProperties(layer_ptr, transform, position, bounds); |
124 parent->AddChild(layer.Pass()); | 124 parent->AddChild(std::move(layer)); |
125 return layer_ptr; | 125 return layer_ptr; |
126 } | 126 } |
127 | 127 |
128 LayerImpl* CreateSurface(LayerImpl* parent, | 128 LayerImpl* CreateSurface(LayerImpl* parent, |
129 const gfx::Transform& transform, | 129 const gfx::Transform& transform, |
130 const gfx::PointF& position, | 130 const gfx::PointF& position, |
131 const gfx::Size& bounds) { | 131 const gfx::Size& bounds) { |
132 LayerImpl* layer = CreateLayer(parent, transform, position, bounds); | 132 LayerImpl* layer = CreateLayer(parent, transform, position, bounds); |
133 layer->SetHasRenderSurface(true); | 133 layer->SetHasRenderSurface(true); |
134 return layer; | 134 return layer; |
(...skipping 13 matching lines...) Expand all Loading... |
148 if (opaque_layers_) { | 148 if (opaque_layers_) { |
149 layer_ptr->SetContentsOpaque(opaque); | 149 layer_ptr->SetContentsOpaque(opaque); |
150 } else { | 150 } else { |
151 layer_ptr->SetContentsOpaque(false); | 151 layer_ptr->SetContentsOpaque(false); |
152 if (opaque) | 152 if (opaque) |
153 layer_ptr->SetOpaqueContentsRect(gfx::Rect(bounds)); | 153 layer_ptr->SetOpaqueContentsRect(gfx::Rect(bounds)); |
154 else | 154 else |
155 layer_ptr->SetOpaqueContentsRect(gfx::Rect()); | 155 layer_ptr->SetOpaqueContentsRect(gfx::Rect()); |
156 } | 156 } |
157 | 157 |
158 parent->AddChild(layer.Pass()); | 158 parent->AddChild(std::move(layer)); |
159 return layer_ptr; | 159 return layer_ptr; |
160 } | 160 } |
161 | 161 |
162 LayerImpl* CreateReplicaLayer(LayerImpl* owning_layer, | 162 LayerImpl* CreateReplicaLayer(LayerImpl* owning_layer, |
163 const gfx::Transform& transform, | 163 const gfx::Transform& transform, |
164 const gfx::PointF& position, | 164 const gfx::PointF& position, |
165 const gfx::Size& bounds) { | 165 const gfx::Size& bounds) { |
166 LayerTreeImpl* tree = host_->host_impl()->active_tree(); | 166 LayerTreeImpl* tree = host_->host_impl()->active_tree(); |
167 int id = next_layer_impl_id_++; | 167 int id = next_layer_impl_id_++; |
168 scoped_ptr<TestContentLayerImpl> layer(new TestContentLayerImpl(tree, id)); | 168 scoped_ptr<TestContentLayerImpl> layer(new TestContentLayerImpl(tree, id)); |
169 TestContentLayerImpl* layer_ptr = layer.get(); | 169 TestContentLayerImpl* layer_ptr = layer.get(); |
170 SetProperties(layer_ptr, transform, position, bounds); | 170 SetProperties(layer_ptr, transform, position, bounds); |
171 SetReplica(owning_layer, layer.Pass()); | 171 SetReplica(owning_layer, std::move(layer)); |
172 return layer_ptr; | 172 return layer_ptr; |
173 } | 173 } |
174 | 174 |
175 LayerImpl* CreateMaskLayer(LayerImpl* owning_layer, const gfx::Size& bounds) { | 175 LayerImpl* CreateMaskLayer(LayerImpl* owning_layer, const gfx::Size& bounds) { |
176 LayerTreeImpl* tree = host_->host_impl()->active_tree(); | 176 LayerTreeImpl* tree = host_->host_impl()->active_tree(); |
177 int id = next_layer_impl_id_++; | 177 int id = next_layer_impl_id_++; |
178 scoped_ptr<TestContentLayerImpl> layer(new TestContentLayerImpl(tree, id)); | 178 scoped_ptr<TestContentLayerImpl> layer(new TestContentLayerImpl(tree, id)); |
179 TestContentLayerImpl* layer_ptr = layer.get(); | 179 TestContentLayerImpl* layer_ptr = layer.get(); |
180 SetProperties(layer_ptr, identity_matrix, gfx::PointF(), bounds); | 180 SetProperties(layer_ptr, identity_matrix, gfx::PointF(), bounds); |
181 SetMask(owning_layer, layer.Pass()); | 181 SetMask(owning_layer, std::move(layer)); |
182 return layer_ptr; | 182 return layer_ptr; |
183 } | 183 } |
184 | 184 |
185 TestContentLayerImpl* CreateDrawingSurface(LayerImpl* parent, | 185 TestContentLayerImpl* CreateDrawingSurface(LayerImpl* parent, |
186 const gfx::Transform& transform, | 186 const gfx::Transform& transform, |
187 const gfx::PointF& position, | 187 const gfx::PointF& position, |
188 const gfx::Size& bounds, | 188 const gfx::Size& bounds, |
189 bool opaque) { | 189 bool opaque) { |
190 TestContentLayerImpl* layer = | 190 TestContentLayerImpl* layer = |
191 CreateDrawingLayer(parent, transform, position, bounds, opaque); | 191 CreateDrawingLayer(parent, transform, position, bounds, opaque); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 void SetProperties(LayerImpl* layer, | 289 void SetProperties(LayerImpl* layer, |
290 const gfx::Transform& transform, | 290 const gfx::Transform& transform, |
291 const gfx::PointF& position, | 291 const gfx::PointF& position, |
292 const gfx::Size& bounds) { | 292 const gfx::Size& bounds) { |
293 layer->SetTransform(transform); | 293 layer->SetTransform(transform); |
294 layer->SetPosition(position); | 294 layer->SetPosition(position); |
295 layer->SetBounds(bounds); | 295 layer->SetBounds(bounds); |
296 } | 296 } |
297 | 297 |
298 void SetReplica(LayerImpl* owning_layer, scoped_ptr<LayerImpl> layer) { | 298 void SetReplica(LayerImpl* owning_layer, scoped_ptr<LayerImpl> layer) { |
299 owning_layer->SetReplicaLayer(layer.Pass()); | 299 owning_layer->SetReplicaLayer(std::move(layer)); |
300 } | 300 } |
301 | 301 |
302 void SetMask(LayerImpl* owning_layer, scoped_ptr<LayerImpl> layer) { | 302 void SetMask(LayerImpl* owning_layer, scoped_ptr<LayerImpl> layer) { |
303 owning_layer->SetMaskLayer(layer.Pass()); | 303 owning_layer->SetMaskLayer(std::move(layer)); |
304 } | 304 } |
305 | 305 |
306 bool opaque_layers_; | 306 bool opaque_layers_; |
307 FakeLayerTreeHostClient client_; | 307 FakeLayerTreeHostClient client_; |
308 TestTaskGraphRunner task_graph_runner_; | 308 TestTaskGraphRunner task_graph_runner_; |
309 scoped_ptr<FakeLayerTreeHost> host_; | 309 scoped_ptr<FakeLayerTreeHost> host_; |
310 // These hold ownership of the layers for the duration of the test. | 310 // These hold ownership of the layers for the duration of the test. |
311 scoped_ptr<LayerImpl> root_; | 311 scoped_ptr<LayerImpl> root_; |
312 LayerImplList render_surface_layer_list_impl_; | 312 LayerImplList render_surface_layer_list_impl_; |
313 LayerIterator layer_iterator_begin_; | 313 LayerIterator layer_iterator_begin_; |
(...skipping 2196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2510 EXPECT_EQ(gfx::Rect(), | 2510 EXPECT_EQ(gfx::Rect(), |
2511 occlusion.UnoccludedSurfaceContentRect( | 2511 occlusion.UnoccludedSurfaceContentRect( |
2512 surface, gfx::Rect(80, 70, 50, 50))); | 2512 surface, gfx::Rect(80, 70, 50, 50))); |
2513 } | 2513 } |
2514 }; | 2514 }; |
2515 | 2515 |
2516 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestUnoccludedSurfaceQuery) | 2516 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestUnoccludedSurfaceQuery) |
2517 | 2517 |
2518 } // namespace | 2518 } // namespace |
2519 } // namespace cc | 2519 } // namespace cc |
OLD | NEW |