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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
126 return ref; | 126 return ref; |
127 } | 127 } |
128 | 128 |
129 static LayerPtrType PassLayerPtr(LayerPtrType* layer) { | 129 static LayerPtrType PassLayerPtr(LayerPtrType* layer) { |
130 LayerPtrType ref(*layer); | 130 LayerPtrType ref(*layer); |
131 *layer = NULL; | 131 *layer = NULL; |
132 return ref; | 132 return ref; |
133 } | 133 } |
134 | 134 |
135 static void DestroyLayer(LayerPtrType* layer) { *layer = NULL; } | 135 static void DestroyLayer(LayerPtrType* layer) { *layer = NULL; } |
136 | |
137 static void UpdateData(LayerType* layerType) {} | |
136 }; | 138 }; |
137 | 139 |
138 struct OcclusionTrackerTestImplThreadTypes { | 140 struct OcclusionTrackerTestImplThreadTypes { |
139 typedef LayerImpl LayerType; | 141 typedef LayerImpl LayerType; |
140 typedef LayerTreeImpl HostType; | 142 typedef LayerTreeImpl HostType; |
141 typedef RenderSurfaceImpl RenderSurfaceType; | 143 typedef RenderSurfaceImpl RenderSurfaceType; |
142 typedef TestContentLayerImpl ContentLayerType; | 144 typedef TestContentLayerImpl ContentLayerType; |
143 typedef scoped_ptr<LayerImpl> LayerPtrType; | 145 typedef scoped_ptr<LayerImpl> LayerPtrType; |
144 typedef scoped_ptr<ContentLayerType> ContentLayerPtrType; | 146 typedef scoped_ptr<ContentLayerType> ContentLayerPtrType; |
145 typedef LayerIterator<LayerImpl> TestLayerIterator; | 147 typedef LayerIterator<LayerImpl> TestLayerIterator; |
146 typedef OcclusionTracker<LayerImpl> OcclusionTrackerType; | 148 typedef OcclusionTracker<LayerImpl> OcclusionTrackerType; |
147 | 149 |
148 static LayerPtrType CreateLayer(HostType* host) { | 150 static LayerPtrType CreateLayer(HostType* host) { |
149 return LayerImpl::Create(host, next_layer_impl_id++); | 151 return LayerImpl::Create(host, next_layer_impl_id++); |
150 } | 152 } |
151 static ContentLayerPtrType CreateContentLayer(HostType* host) { | 153 static ContentLayerPtrType CreateContentLayer(HostType* host) { |
152 return make_scoped_ptr(new ContentLayerType(host, next_layer_impl_id++)); | 154 return make_scoped_ptr(new ContentLayerType(host, next_layer_impl_id++)); |
153 } | 155 } |
154 static int next_layer_impl_id; | 156 static int next_layer_impl_id; |
155 | 157 |
156 static LayerPtrType PassLayerPtr(LayerPtrType* layer) { | 158 static LayerPtrType PassLayerPtr(LayerPtrType* layer) { |
157 return layer->Pass(); | 159 return layer->Pass(); |
158 } | 160 } |
159 | 161 |
160 static LayerPtrType PassLayerPtr(ContentLayerPtrType* layer) { | 162 static LayerPtrType PassLayerPtr(ContentLayerPtrType* layer) { |
161 return layer->PassAs<LayerType>(); | 163 return layer->PassAs<LayerType>(); |
162 } | 164 } |
163 | 165 |
164 static void DestroyLayer(LayerPtrType* layer) { layer->reset(); } | 166 static void DestroyLayer(LayerPtrType* layer) { layer->reset(); } |
167 | |
168 static void UpdateData(LayerType* layer) { | |
danakj
2014/07/17 17:21:26
Let's give this a more descriptive name. How about
awoloszyn
2014/07/17 20:45:01
Done.
| |
169 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(layer); | |
170 } | |
165 }; | 171 }; |
166 | 172 |
167 int OcclusionTrackerTestImplThreadTypes::next_layer_impl_id = 1; | 173 int OcclusionTrackerTestImplThreadTypes::next_layer_impl_id = 1; |
168 | 174 |
169 template <typename Types> class OcclusionTrackerTest : public testing::Test { | 175 template <typename Types> class OcclusionTrackerTest : public testing::Test { |
170 protected: | 176 protected: |
171 explicit OcclusionTrackerTest(bool opaque_layers) | 177 explicit OcclusionTrackerTest(bool opaque_layers) |
172 : opaque_layers_(opaque_layers), host_(FakeLayerTreeHost::Create()) {} | 178 : opaque_layers_(opaque_layers), host_(FakeLayerTreeHost::Create()) {} |
173 | 179 |
174 virtual void RunMyTest() = 0; | 180 virtual void RunMyTest() = 0; |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
297 CopyOutputRequest::CreateBitmapRequest(base::Bind( | 303 CopyOutputRequest::CreateBitmapRequest(base::Bind( |
298 &OcclusionTrackerTest<Types>::CopyOutputCallback, | 304 &OcclusionTrackerTest<Types>::CopyOutputCallback, |
299 base::Unretained(this)))); | 305 base::Unretained(this)))); |
300 layer->PassCopyRequests(&requests); | 306 layer->PassCopyRequests(&requests); |
301 } | 307 } |
302 | 308 |
303 void CalcDrawEtc(TestContentLayerImpl* root) { | 309 void CalcDrawEtc(TestContentLayerImpl* root) { |
304 DCHECK(root == root_.get()); | 310 DCHECK(root == root_.get()); |
305 DCHECK(!root->render_surface()); | 311 DCHECK(!root->render_surface()); |
306 | 312 |
313 Types::UpdateData(root); | |
307 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 314 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
308 root, root->bounds(), &render_surface_layer_list_impl_); | 315 root, root->bounds(), &render_surface_layer_list_impl_); |
309 inputs.can_adjust_raster_scales = true; | 316 inputs.can_adjust_raster_scales = true; |
310 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 317 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
311 | 318 |
312 layer_iterator_ = layer_iterator_begin_ = | 319 layer_iterator_ = layer_iterator_begin_ = |
313 Types::TestLayerIterator::Begin(&render_surface_layer_list_impl_); | 320 Types::TestLayerIterator::Begin(&render_surface_layer_list_impl_); |
314 } | 321 } |
315 | 322 |
316 void CalcDrawEtc(TestContentLayer* root) { | 323 void CalcDrawEtc(TestContentLayer* root) { |
(...skipping 3232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3549 occlusion.occlusion_from_outside_target().ToString()); | 3556 occlusion.occlusion_from_outside_target().ToString()); |
3550 EXPECT_EQ(gfx::Rect().ToString(), | 3557 EXPECT_EQ(gfx::Rect().ToString(), |
3551 occlusion.occlusion_from_inside_target().ToString()); | 3558 occlusion.occlusion_from_inside_target().ToString()); |
3552 } | 3559 } |
3553 }; | 3560 }; |
3554 | 3561 |
3555 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestHiddenCopyRequestDoesNotOcclude) | 3562 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestHiddenCopyRequestDoesNotOcclude) |
3556 | 3563 |
3557 } // namespace | 3564 } // namespace |
3558 } // namespace cc | 3565 } // namespace cc |
OLD | NEW |