| 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/test/layer_test_common.h" | 5 #include "cc/test/layer_test_common.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "cc/animation/animation_host.h" | 9 #include "cc/animation/animation_host.h" |
| 10 #include "cc/animation/animation_id_provider.h" | 10 #include "cc/animation/animation_id_provider.h" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 } | 116 } |
| 117 } | 117 } |
| 118 | 118 |
| 119 LayerTestCommon::LayerImplTest::LayerImplTest() | 119 LayerTestCommon::LayerImplTest::LayerImplTest() |
| 120 : LayerImplTest(LayerTreeSettings()) {} | 120 : LayerImplTest(LayerTreeSettings()) {} |
| 121 | 121 |
| 122 LayerTestCommon::LayerImplTest::LayerImplTest(const LayerTreeSettings& settings) | 122 LayerTestCommon::LayerImplTest::LayerImplTest(const LayerTreeSettings& settings) |
| 123 : client_(FakeLayerTreeHostClient::DIRECT_3D), | 123 : client_(FakeLayerTreeHostClient::DIRECT_3D), |
| 124 output_surface_(FakeOutputSurface::Create3d()), | 124 output_surface_(FakeOutputSurface::Create3d()), |
| 125 host_(FakeLayerTreeHost::Create(&client_, &task_graph_runner_, settings)), | 125 host_(FakeLayerTreeHost::Create(&client_, &task_graph_runner_, settings)), |
| 126 root_layer_impl_(LayerImpl::Create(host_->host_impl()->active_tree(), 1)), | |
| 127 render_pass_(RenderPass::Create()), | 126 render_pass_(RenderPass::Create()), |
| 128 layer_impl_id_(2) { | 127 layer_impl_id_(2) { |
| 129 root_layer_impl_->SetHasRenderSurface(true); | 128 scoped_ptr<LayerImpl> root_layer_impl = |
| 129 LayerImpl::Create(host_->host_impl()->active_tree(), 1); |
| 130 root_layer_impl->SetHasRenderSurface(true); |
| 131 host_->host_impl()->active_tree()->SetRootLayer(std::move(root_layer_impl)); |
| 130 host_->host_impl()->SetVisible(true); | 132 host_->host_impl()->SetVisible(true); |
| 131 host_->host_impl()->InitializeRenderer(output_surface_.get()); | 133 host_->host_impl()->InitializeRenderer(output_surface_.get()); |
| 132 | 134 |
| 133 const int timeline_id = AnimationIdProvider::NextTimelineId(); | 135 const int timeline_id = AnimationIdProvider::NextTimelineId(); |
| 134 timeline_ = AnimationTimeline::Create(timeline_id); | 136 timeline_ = AnimationTimeline::Create(timeline_id); |
| 135 host_->animation_host()->AddAnimationTimeline(timeline_); | 137 host_->animation_host()->AddAnimationTimeline(timeline_); |
| 136 // Create impl-side instance. | 138 // Create impl-side instance. |
| 137 host_->animation_host()->PushPropertiesTo( | 139 host_->animation_host()->PushPropertiesTo( |
| 138 host_->host_impl()->animation_host()); | 140 host_->host_impl()->animation_host()); |
| 139 timeline_impl_ = | 141 timeline_impl_ = |
| 140 host_->host_impl()->animation_host()->GetTimelineById(timeline_id); | 142 host_->host_impl()->animation_host()->GetTimelineById(timeline_id); |
| 141 } | 143 } |
| 142 | 144 |
| 143 LayerTestCommon::LayerImplTest::~LayerImplTest() { | 145 LayerTestCommon::LayerImplTest::~LayerImplTest() { |
| 144 host_->animation_host()->RemoveAnimationTimeline(timeline_); | 146 host_->animation_host()->RemoveAnimationTimeline(timeline_); |
| 145 timeline_ = nullptr; | 147 timeline_ = nullptr; |
| 146 } | 148 } |
| 147 | 149 |
| 148 void LayerTestCommon::LayerImplTest::CalcDrawProps( | 150 void LayerTestCommon::LayerImplTest::CalcDrawProps( |
| 149 const gfx::Size& viewport_size) { | 151 const gfx::Size& viewport_size) { |
| 150 LayerImplList layer_list; | 152 LayerImplList layer_list; |
| 151 host_->host_impl()->active_tree()->IncrementRenderSurfaceListIdForTesting(); | 153 host_->host_impl()->active_tree()->IncrementRenderSurfaceListIdForTesting(); |
| 152 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 154 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 153 root_layer_impl_.get(), viewport_size, &layer_list, | 155 host_->host_impl()->active_tree()->root_layer(), viewport_size, |
| 156 &layer_list, |
| 154 host_->host_impl()->active_tree()->current_render_surface_list_id()); | 157 host_->host_impl()->active_tree()->current_render_surface_list_id()); |
| 155 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 158 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
| 156 } | 159 } |
| 157 | 160 |
| 158 void LayerTestCommon::LayerImplTest::AppendQuadsWithOcclusion( | 161 void LayerTestCommon::LayerImplTest::AppendQuadsWithOcclusion( |
| 159 LayerImpl* layer_impl, | 162 LayerImpl* layer_impl, |
| 160 const gfx::Rect& occluded) { | 163 const gfx::Rect& occluded) { |
| 161 AppendQuadsData data; | 164 AppendQuadsData data; |
| 162 | 165 |
| 163 render_pass_->quad_list.clear(); | 166 render_pass_->quad_list.clear(); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 SimpleEnclosedRegion()), | 207 SimpleEnclosedRegion()), |
| 205 SK_ColorBLACK, 1.f, nullptr, &data, RenderPassId(1, 1)); | 208 SK_ColorBLACK, 1.f, nullptr, &data, RenderPassId(1, 1)); |
| 206 } | 209 } |
| 207 | 210 |
| 208 void EmptyCopyOutputCallback(scoped_ptr<CopyOutputResult> result) {} | 211 void EmptyCopyOutputCallback(scoped_ptr<CopyOutputResult> result) {} |
| 209 | 212 |
| 210 void LayerTestCommon::LayerImplTest::RequestCopyOfOutput() { | 213 void LayerTestCommon::LayerImplTest::RequestCopyOfOutput() { |
| 211 std::vector<scoped_ptr<CopyOutputRequest>> copy_requests; | 214 std::vector<scoped_ptr<CopyOutputRequest>> copy_requests; |
| 212 copy_requests.push_back( | 215 copy_requests.push_back( |
| 213 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); | 216 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); |
| 214 root_layer_impl_->PassCopyRequests(©_requests); | 217 host_->host_impl()->active_tree()->root_layer()->PassCopyRequests( |
| 218 ©_requests); |
| 215 } | 219 } |
| 216 | 220 |
| 217 } // namespace cc | 221 } // namespace cc |
| OLD | NEW |