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/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "cc/layers/content_layer.h" | 8 #include "cc/layers/content_layer.h" |
9 #include "cc/layers/delegated_frame_provider.h" | 9 #include "cc/layers/delegated_frame_provider.h" |
10 #include "cc/layers/delegated_frame_resource_collection.h" | 10 #include "cc/layers/delegated_frame_resource_collection.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 79 |
80 virtual scoped_ptr<TestWebGraphicsContext3D> CreateContext3d() { | 80 virtual scoped_ptr<TestWebGraphicsContext3D> CreateContext3d() { |
81 return TestWebGraphicsContext3D::Create(); | 81 return TestWebGraphicsContext3D::Create(); |
82 } | 82 } |
83 | 83 |
84 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback) | 84 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback) |
85 OVERRIDE { | 85 OVERRIDE { |
86 if (times_to_fail_create_) { | 86 if (times_to_fail_create_) { |
87 --times_to_fail_create_; | 87 --times_to_fail_create_; |
88 ExpectCreateToFail(); | 88 ExpectCreateToFail(); |
89 return scoped_ptr<FakeOutputSurface>(); | 89 return nullptr; |
90 } | 90 } |
91 | 91 |
92 scoped_ptr<TestWebGraphicsContext3D> context3d = CreateContext3d(); | 92 scoped_ptr<TestWebGraphicsContext3D> context3d = CreateContext3d(); |
93 context3d_ = context3d.get(); | 93 context3d_ = context3d.get(); |
94 | 94 |
95 if (context_should_support_io_surface_) { | 95 if (context_should_support_io_surface_) { |
96 context3d_->set_have_extension_io_surface(true); | 96 context3d_->set_have_extension_io_surface(true); |
97 context3d_->set_have_extension_egl_image(true); | 97 context3d_->set_have_extension_egl_image(true); |
98 } | 98 } |
99 | 99 |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 } | 356 } |
357 | 357 |
358 virtual void BeginTest() OVERRIDE { | 358 virtual void BeginTest() OVERRIDE { |
359 PostSetNeedsCommitToMainThread(); | 359 PostSetNeedsCommitToMainThread(); |
360 EndTest(); | 360 EndTest(); |
361 } | 361 } |
362 | 362 |
363 virtual scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback) | 363 virtual scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback) |
364 OVERRIDE { | 364 OVERRIDE { |
365 EXPECT_TRUE(false); | 365 EXPECT_TRUE(false); |
366 return scoped_ptr<OutputSurface>(); | 366 return nullptr; |
367 } | 367 } |
368 | 368 |
369 virtual void DidInitializeOutputSurface() OVERRIDE { EXPECT_TRUE(false); } | 369 virtual void DidInitializeOutputSurface() OVERRIDE { EXPECT_TRUE(false); } |
370 | 370 |
371 virtual void AfterTest() OVERRIDE { | 371 virtual void AfterTest() OVERRIDE { |
372 } | 372 } |
373 }; | 373 }; |
374 | 374 |
375 SINGLE_AND_MULTI_THREAD_TEST_F( | 375 SINGLE_AND_MULTI_THREAD_TEST_F( |
376 LayerTreeHostClientNotReadyDoesNotCreateOutputSurface); | 376 LayerTreeHostClientNotReadyDoesNotCreateOutputSurface); |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
871 gfx::Transform()); | 871 gfx::Transform()); |
872 | 872 |
873 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); | 873 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); |
874 pass->SetNew(RenderPassId(1, 1), | 874 pass->SetNew(RenderPassId(1, 1), |
875 gfx::Rect(0, 0, 10, 10), | 875 gfx::Rect(0, 0, 10, 10), |
876 gfx::Rect(0, 0, 10, 10), | 876 gfx::Rect(0, 0, 10, 10), |
877 gfx::Transform()); | 877 gfx::Transform()); |
878 pass->AppendOneOfEveryQuadType(child_resource_provider_.get(), | 878 pass->AppendOneOfEveryQuadType(child_resource_provider_.get(), |
879 RenderPassId(2, 1)); | 879 RenderPassId(2, 1)); |
880 | 880 |
881 frame_data->render_pass_list.push_back(pass_for_quad.PassAs<RenderPass>()); | 881 frame_data->render_pass_list.push_back(pass_for_quad.Pass()); |
882 frame_data->render_pass_list.push_back(pass.PassAs<RenderPass>()); | 882 frame_data->render_pass_list.push_back(pass.Pass()); |
883 | 883 |
884 delegated_resource_collection_ = new DelegatedFrameResourceCollection; | 884 delegated_resource_collection_ = new DelegatedFrameResourceCollection; |
885 delegated_frame_provider_ = new DelegatedFrameProvider( | 885 delegated_frame_provider_ = new DelegatedFrameProvider( |
886 delegated_resource_collection_.get(), frame_data.Pass()); | 886 delegated_resource_collection_.get(), frame_data.Pass()); |
887 | 887 |
888 ResourceProvider::ResourceId resource = | 888 ResourceProvider::ResourceId resource = |
889 child_resource_provider_->CreateResource( | 889 child_resource_provider_->CreateResource( |
890 gfx::Size(4, 4), | 890 gfx::Size(4, 4), |
891 GL_CLAMP_TO_EDGE, | 891 GL_CLAMP_TO_EDGE, |
892 ResourceProvider::TextureHintImmutable, | 892 ResourceProvider::TextureHintImmutable, |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1249 EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread()); | 1249 EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread()); |
1250 switch (step) { | 1250 switch (step) { |
1251 case 0: | 1251 case 0: |
1252 ui_resource_ = FakeScopedUIResource::Create(layer_tree_host()); | 1252 ui_resource_ = FakeScopedUIResource::Create(layer_tree_host()); |
1253 // Expects a valid UIResourceId. | 1253 // Expects a valid UIResourceId. |
1254 EXPECT_NE(0, ui_resource_->id()); | 1254 EXPECT_NE(0, ui_resource_->id()); |
1255 PostSetNeedsCommitToMainThread(); | 1255 PostSetNeedsCommitToMainThread(); |
1256 break; | 1256 break; |
1257 case 4: | 1257 case 4: |
1258 // Release resource before ending the test. | 1258 // Release resource before ending the test. |
1259 ui_resource_.reset(); | 1259 ui_resource_ = nullptr; |
1260 EndTest(); | 1260 EndTest(); |
1261 break; | 1261 break; |
1262 case 5: | 1262 case 5: |
1263 NOTREACHED(); | 1263 NOTREACHED(); |
1264 break; | 1264 break; |
1265 } | 1265 } |
1266 } | 1266 } |
1267 | 1267 |
1268 virtual void StepCompleteOnImplThread(LayerTreeHostImpl* impl) OVERRIDE { | 1268 virtual void StepCompleteOnImplThread(LayerTreeHostImpl* impl) OVERRIDE { |
1269 LayerTreeHostContextTest::CommitCompleteOnThread(impl); | 1269 LayerTreeHostContextTest::CommitCompleteOnThread(impl); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1309 case 0: | 1309 case 0: |
1310 ui_resource_ = FakeScopedUIResource::Create(layer_tree_host()); | 1310 ui_resource_ = FakeScopedUIResource::Create(layer_tree_host()); |
1311 // Lose the context on the impl thread before the commit. | 1311 // Lose the context on the impl thread before the commit. |
1312 PostLoseContextToImplThread(); | 1312 PostLoseContextToImplThread(); |
1313 break; | 1313 break; |
1314 case 2: | 1314 case 2: |
1315 // Sequence 2: | 1315 // Sequence 2: |
1316 // Currently one resource has been created. | 1316 // Currently one resource has been created. |
1317 test_id0_ = ui_resource_->id(); | 1317 test_id0_ = ui_resource_->id(); |
1318 // Delete this resource. | 1318 // Delete this resource. |
1319 ui_resource_.reset(); | 1319 ui_resource_ = nullptr; |
1320 // Create another resource. | 1320 // Create another resource. |
1321 ui_resource_ = FakeScopedUIResource::Create(layer_tree_host()); | 1321 ui_resource_ = FakeScopedUIResource::Create(layer_tree_host()); |
1322 test_id1_ = ui_resource_->id(); | 1322 test_id1_ = ui_resource_->id(); |
1323 // Sanity check that two resource creations return different ids. | 1323 // Sanity check that two resource creations return different ids. |
1324 EXPECT_NE(test_id0_, test_id1_); | 1324 EXPECT_NE(test_id0_, test_id1_); |
1325 // Lose the context on the impl thread before the commit. | 1325 // Lose the context on the impl thread before the commit. |
1326 PostLoseContextToImplThread(); | 1326 PostLoseContextToImplThread(); |
1327 break; | 1327 break; |
1328 case 3: | 1328 case 3: |
1329 // Clear the manager of resources. | 1329 // Clear the manager of resources. |
1330 ui_resource_.reset(); | 1330 ui_resource_ = nullptr; |
1331 PostSetNeedsCommitToMainThread(); | 1331 PostSetNeedsCommitToMainThread(); |
1332 break; | 1332 break; |
1333 case 4: | 1333 case 4: |
1334 // Sequence 3: | 1334 // Sequence 3: |
1335 ui_resource_ = FakeScopedUIResource::Create(layer_tree_host()); | 1335 ui_resource_ = FakeScopedUIResource::Create(layer_tree_host()); |
1336 test_id0_ = ui_resource_->id(); | 1336 test_id0_ = ui_resource_->id(); |
1337 // Sanity check the UIResourceId should not be 0. | 1337 // Sanity check the UIResourceId should not be 0. |
1338 EXPECT_NE(0, test_id0_); | 1338 EXPECT_NE(0, test_id0_); |
1339 // Usually ScopedUIResource are deleted from the manager in their | 1339 // Usually ScopedUIResource are deleted from the manager in their |
1340 // destructor (so usually ui_resource_.reset()). But here we need | 1340 // destructor (so usually ui_resource_ = nullptr). But here we need |
1341 // ui_resource_ for the next step, so call DeleteUIResource directly. | 1341 // ui_resource_ for the next step, so call DeleteUIResource directly. |
1342 layer_tree_host()->DeleteUIResource(test_id0_); | 1342 layer_tree_host()->DeleteUIResource(test_id0_); |
1343 // Delete the resouce and then lose the context. | 1343 // Delete the resouce and then lose the context. |
1344 PostLoseContextToImplThread(); | 1344 PostLoseContextToImplThread(); |
1345 break; | 1345 break; |
1346 case 5: | 1346 case 5: |
1347 // Release resource before ending the test. | 1347 // Release resource before ending the test. |
1348 ui_resource_.reset(); | 1348 ui_resource_ = nullptr; |
1349 EndTest(); | 1349 EndTest(); |
1350 break; | 1350 break; |
1351 case 6: | 1351 case 6: |
1352 NOTREACHED(); | 1352 NOTREACHED(); |
1353 break; | 1353 break; |
1354 } | 1354 } |
1355 } | 1355 } |
1356 | 1356 |
1357 virtual void StepCompleteOnImplThread(LayerTreeHostImpl* impl) OVERRIDE { | 1357 virtual void StepCompleteOnImplThread(LayerTreeHostImpl* impl) OVERRIDE { |
1358 LayerTreeHostContextTest::CommitCompleteOnThread(impl); | 1358 LayerTreeHostContextTest::CommitCompleteOnThread(impl); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1402 class UIResourceLostBeforeActivateTree : public UIResourceLostTest { | 1402 class UIResourceLostBeforeActivateTree : public UIResourceLostTest { |
1403 virtual void StepCompleteOnMainThread(int step) OVERRIDE { | 1403 virtual void StepCompleteOnMainThread(int step) OVERRIDE { |
1404 EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread()); | 1404 EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread()); |
1405 switch (step) { | 1405 switch (step) { |
1406 case 0: | 1406 case 0: |
1407 ui_resource_ = FakeScopedUIResource::Create(layer_tree_host()); | 1407 ui_resource_ = FakeScopedUIResource::Create(layer_tree_host()); |
1408 PostSetNeedsCommitToMainThread(); | 1408 PostSetNeedsCommitToMainThread(); |
1409 break; | 1409 break; |
1410 case 3: | 1410 case 3: |
1411 test_id_ = ui_resource_->id(); | 1411 test_id_ = ui_resource_->id(); |
1412 ui_resource_.reset(); | 1412 ui_resource_ = nullptr; |
1413 PostSetNeedsCommitToMainThread(); | 1413 PostSetNeedsCommitToMainThread(); |
1414 break; | 1414 break; |
1415 case 5: | 1415 case 5: |
1416 // Release resource before ending the test. | 1416 // Release resource before ending the test. |
1417 ui_resource_.reset(); | 1417 ui_resource_ = nullptr; |
1418 EndTest(); | 1418 EndTest(); |
1419 break; | 1419 break; |
1420 case 6: | 1420 case 6: |
1421 // Make sure no extra commits happened. | 1421 // Make sure no extra commits happened. |
1422 NOTREACHED(); | 1422 NOTREACHED(); |
1423 } | 1423 } |
1424 } | 1424 } |
1425 | 1425 |
1426 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 1426 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
1427 LayerTreeHostContextTest::CommitCompleteOnThread(impl); | 1427 LayerTreeHostContextTest::CommitCompleteOnThread(impl); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1498 ui_resource_ = FakeScopedUIResource::Create(layer_tree_host()); | 1498 ui_resource_ = FakeScopedUIResource::Create(layer_tree_host()); |
1499 EXPECT_NE(0, ui_resource_->id()); | 1499 EXPECT_NE(0, ui_resource_->id()); |
1500 PostSetNeedsCommitToMainThread(); | 1500 PostSetNeedsCommitToMainThread(); |
1501 break; | 1501 break; |
1502 case 2: | 1502 case 2: |
1503 // Make the tree not visible. | 1503 // Make the tree not visible. |
1504 PostSetVisibleToMainThread(false); | 1504 PostSetVisibleToMainThread(false); |
1505 break; | 1505 break; |
1506 case 3: | 1506 case 3: |
1507 // Release resource before ending the test. | 1507 // Release resource before ending the test. |
1508 ui_resource_.reset(); | 1508 ui_resource_ = nullptr; |
1509 EndTest(); | 1509 EndTest(); |
1510 break; | 1510 break; |
1511 case 4: | 1511 case 4: |
1512 NOTREACHED(); | 1512 NOTREACHED(); |
1513 } | 1513 } |
1514 } | 1514 } |
1515 | 1515 |
1516 virtual void DidSetVisibleOnImplTree(LayerTreeHostImpl* impl, | 1516 virtual void DidSetVisibleOnImplTree(LayerTreeHostImpl* impl, |
1517 bool visible) OVERRIDE { | 1517 bool visible) OVERRIDE { |
1518 TestWebGraphicsContext3D* context = TestContext(); | 1518 TestWebGraphicsContext3D* context = TestContext(); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1706 virtual void AfterTest() OVERRIDE {} | 1706 virtual void AfterTest() OVERRIDE {} |
1707 | 1707 |
1708 bool deferred_; | 1708 bool deferred_; |
1709 }; | 1709 }; |
1710 | 1710 |
1711 SINGLE_AND_MULTI_THREAD_TEST_F( | 1711 SINGLE_AND_MULTI_THREAD_TEST_F( |
1712 LayerTreeHostContextTestLoseAfterSendingBeginMainFrame); | 1712 LayerTreeHostContextTestLoseAfterSendingBeginMainFrame); |
1713 | 1713 |
1714 } // namespace | 1714 } // namespace |
1715 } // namespace cc | 1715 } // namespace cc |
OLD | NEW |