| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "CCThreadedTest.h" | 7 #include "CCThreadedTest.h" |
| 8 | 8 |
| 9 #include "CCActiveAnimation.h" | 9 #include "CCActiveAnimation.h" |
| 10 #include "CCAnimationTestCommon.h" | 10 #include "CCAnimationTestCommon.h" |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadedTest::dispat
chSetVisible, visible)); | 372 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadedTest::dispat
chSetVisible, visible)); |
| 373 } | 373 } |
| 374 | 374 |
| 375 void CCThreadedTest::postDidAddAnimationToMainThread() | 375 void CCThreadedTest::postDidAddAnimationToMainThread() |
| 376 { | 376 { |
| 377 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadedTest::dispat
chDidAddAnimation)); | 377 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadedTest::dispat
chDidAddAnimation)); |
| 378 } | 378 } |
| 379 | 379 |
| 380 void CCThreadedTest::doBeginTest() | 380 void CCThreadedTest::doBeginTest() |
| 381 { | 381 { |
| 382 ASSERT(CCProxy::isMainThread()); | 382 DCHECK(CCProxy::isMainThread()); |
| 383 m_client = MockLayerTreeHostClient::create(this); | 383 m_client = MockLayerTreeHostClient::create(this); |
| 384 | 384 |
| 385 scoped_refptr<LayerChromium> rootLayer = LayerChromium::create(); | 385 scoped_refptr<LayerChromium> rootLayer = LayerChromium::create(); |
| 386 m_layerTreeHost = MockLayerTreeHost::create(this, m_client.get(), rootLayer,
m_settings); | 386 m_layerTreeHost = MockLayerTreeHost::create(this, m_client.get(), rootLayer,
m_settings); |
| 387 ASSERT_TRUE(m_layerTreeHost.get()); | 387 ASSERT_TRUE(m_layerTreeHost.get()); |
| 388 rootLayer->setLayerTreeHost(m_layerTreeHost.get()); | 388 rootLayer->setLayerTreeHost(m_layerTreeHost.get()); |
| 389 m_layerTreeHost->setSurfaceReady(); | 389 m_layerTreeHost->setSurfaceReady(); |
| 390 | 390 |
| 391 m_started = true; | 391 m_started = true; |
| 392 m_beginning = true; | 392 m_beginning = true; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 405 void CCThreadedTest::scheduleComposite() | 405 void CCThreadedTest::scheduleComposite() |
| 406 { | 406 { |
| 407 if (!m_started || m_scheduled || m_finished) | 407 if (!m_started || m_scheduled || m_finished) |
| 408 return; | 408 return; |
| 409 m_scheduled = true; | 409 m_scheduled = true; |
| 410 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadedTest::dispat
chComposite)); | 410 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadedTest::dispat
chComposite)); |
| 411 } | 411 } |
| 412 | 412 |
| 413 void CCThreadedTest::realEndTest() | 413 void CCThreadedTest::realEndTest() |
| 414 { | 414 { |
| 415 ASSERT(CCProxy::isMainThread()); | 415 DCHECK(CCProxy::isMainThread()); |
| 416 WebKit::Platform::current()->currentThread()->exitRunLoop(); | 416 WebKit::Platform::current()->currentThread()->exitRunLoop(); |
| 417 } | 417 } |
| 418 | 418 |
| 419 void CCThreadedTest::dispatchSetNeedsAnimate() | 419 void CCThreadedTest::dispatchSetNeedsAnimate() |
| 420 { | 420 { |
| 421 ASSERT(CCProxy::isMainThread()); | 421 DCHECK(CCProxy::isMainThread()); |
| 422 | 422 |
| 423 if (m_finished) | 423 if (m_finished) |
| 424 return; | 424 return; |
| 425 | 425 |
| 426 if (m_layerTreeHost.get()) | 426 if (m_layerTreeHost.get()) |
| 427 m_layerTreeHost->setNeedsAnimate(); | 427 m_layerTreeHost->setNeedsAnimate(); |
| 428 } | 428 } |
| 429 | 429 |
| 430 void CCThreadedTest::dispatchAddInstantAnimation() | 430 void CCThreadedTest::dispatchAddInstantAnimation() |
| 431 { | 431 { |
| 432 ASSERT(CCProxy::isMainThread()); | 432 DCHECK(CCProxy::isMainThread()); |
| 433 | 433 |
| 434 if (m_finished) | 434 if (m_finished) |
| 435 return; | 435 return; |
| 436 | 436 |
| 437 if (m_layerTreeHost.get() && m_layerTreeHost->rootLayer()) | 437 if (m_layerTreeHost.get() && m_layerTreeHost->rootLayer()) |
| 438 addOpacityTransitionToLayer(*m_layerTreeHost->rootLayer(), 0, 0, 0.5, fa
lse); | 438 addOpacityTransitionToLayer(*m_layerTreeHost->rootLayer(), 0, 0, 0.5, fa
lse); |
| 439 } | 439 } |
| 440 | 440 |
| 441 void CCThreadedTest::dispatchAddAnimation() | 441 void CCThreadedTest::dispatchAddAnimation() |
| 442 { | 442 { |
| 443 ASSERT(CCProxy::isMainThread()); | 443 DCHECK(CCProxy::isMainThread()); |
| 444 | 444 |
| 445 if (m_finished) | 445 if (m_finished) |
| 446 return; | 446 return; |
| 447 | 447 |
| 448 if (m_layerTreeHost.get() && m_layerTreeHost->rootLayer()) | 448 if (m_layerTreeHost.get() && m_layerTreeHost->rootLayer()) |
| 449 addOpacityTransitionToLayer(*m_layerTreeHost->rootLayer(), 10, 0, 0.5, t
rue); | 449 addOpacityTransitionToLayer(*m_layerTreeHost->rootLayer(), 10, 0, 0.5, t
rue); |
| 450 } | 450 } |
| 451 | 451 |
| 452 void CCThreadedTest::dispatchSetNeedsAnimateAndCommit() | 452 void CCThreadedTest::dispatchSetNeedsAnimateAndCommit() |
| 453 { | 453 { |
| 454 ASSERT(CCProxy::isMainThread()); | 454 DCHECK(CCProxy::isMainThread()); |
| 455 | 455 |
| 456 if (m_finished) | 456 if (m_finished) |
| 457 return; | 457 return; |
| 458 | 458 |
| 459 if (m_layerTreeHost.get()) { | 459 if (m_layerTreeHost.get()) { |
| 460 m_layerTreeHost->setNeedsAnimate(); | 460 m_layerTreeHost->setNeedsAnimate(); |
| 461 m_layerTreeHost->setNeedsCommit(); | 461 m_layerTreeHost->setNeedsCommit(); |
| 462 } | 462 } |
| 463 } | 463 } |
| 464 | 464 |
| 465 void CCThreadedTest::dispatchSetNeedsCommit() | 465 void CCThreadedTest::dispatchSetNeedsCommit() |
| 466 { | 466 { |
| 467 ASSERT(CCProxy::isMainThread()); | 467 DCHECK(CCProxy::isMainThread()); |
| 468 | 468 |
| 469 if (m_finished) | 469 if (m_finished) |
| 470 return; | 470 return; |
| 471 | 471 |
| 472 if (m_layerTreeHost.get()) | 472 if (m_layerTreeHost.get()) |
| 473 m_layerTreeHost->setNeedsCommit(); | 473 m_layerTreeHost->setNeedsCommit(); |
| 474 } | 474 } |
| 475 | 475 |
| 476 void CCThreadedTest::dispatchAcquireLayerTextures() | 476 void CCThreadedTest::dispatchAcquireLayerTextures() |
| 477 { | 477 { |
| 478 ASSERT(CCProxy::isMainThread()); | 478 DCHECK(CCProxy::isMainThread()); |
| 479 | 479 |
| 480 if (m_finished) | 480 if (m_finished) |
| 481 return; | 481 return; |
| 482 | 482 |
| 483 if (m_layerTreeHost.get()) | 483 if (m_layerTreeHost.get()) |
| 484 m_layerTreeHost->acquireLayerTextures(); | 484 m_layerTreeHost->acquireLayerTextures(); |
| 485 } | 485 } |
| 486 | 486 |
| 487 void CCThreadedTest::dispatchSetNeedsRedraw() | 487 void CCThreadedTest::dispatchSetNeedsRedraw() |
| 488 { | 488 { |
| 489 ASSERT(CCProxy::isMainThread()); | 489 DCHECK(CCProxy::isMainThread()); |
| 490 | 490 |
| 491 if (m_finished) | 491 if (m_finished) |
| 492 return; | 492 return; |
| 493 | 493 |
| 494 if (m_layerTreeHost.get()) | 494 if (m_layerTreeHost.get()) |
| 495 m_layerTreeHost->setNeedsRedraw(); | 495 m_layerTreeHost->setNeedsRedraw(); |
| 496 } | 496 } |
| 497 | 497 |
| 498 void CCThreadedTest::dispatchSetVisible(bool visible) | 498 void CCThreadedTest::dispatchSetVisible(bool visible) |
| 499 { | 499 { |
| 500 ASSERT(CCProxy::isMainThread()); | 500 DCHECK(CCProxy::isMainThread()); |
| 501 | 501 |
| 502 if (m_finished) | 502 if (m_finished) |
| 503 return; | 503 return; |
| 504 | 504 |
| 505 if (m_layerTreeHost.get()) | 505 if (m_layerTreeHost.get()) |
| 506 m_layerTreeHost->setVisible(visible); | 506 m_layerTreeHost->setVisible(visible); |
| 507 } | 507 } |
| 508 | 508 |
| 509 void CCThreadedTest::dispatchComposite() | 509 void CCThreadedTest::dispatchComposite() |
| 510 { | 510 { |
| 511 m_scheduled = false; | 511 m_scheduled = false; |
| 512 if (m_layerTreeHost.get() && !m_finished) | 512 if (m_layerTreeHost.get() && !m_finished) |
| 513 m_layerTreeHost->composite(); | 513 m_layerTreeHost->composite(); |
| 514 } | 514 } |
| 515 | 515 |
| 516 void CCThreadedTest::dispatchDidAddAnimation() | 516 void CCThreadedTest::dispatchDidAddAnimation() |
| 517 { | 517 { |
| 518 ASSERT(CCProxy::isMainThread()); | 518 DCHECK(CCProxy::isMainThread()); |
| 519 | 519 |
| 520 if (m_finished) | 520 if (m_finished) |
| 521 return; | 521 return; |
| 522 | 522 |
| 523 if (m_layerTreeHost.get()) | 523 if (m_layerTreeHost.get()) |
| 524 m_layerTreeHost->didAddAnimation(); | 524 m_layerTreeHost->didAddAnimation(); |
| 525 } | 525 } |
| 526 | 526 |
| 527 void CCThreadedTest::runTest(bool threaded) | 527 void CCThreadedTest::runTest(bool threaded) |
| 528 { | 528 { |
| 529 // For these tests, we will enable threaded animations. | 529 // For these tests, we will enable threaded animations. |
| 530 Platform::current()->compositorSupport()->setAcceleratedAnimationEnabled(tru
e); | 530 Platform::current()->compositorSupport()->setAcceleratedAnimationEnabled(tru
e); |
| 531 | 531 |
| 532 if (threaded) { | 532 if (threaded) { |
| 533 m_webThread = adoptPtr(WebKit::Platform::current()->createThread("CCThre
adedTest")); | 533 m_webThread = adoptPtr(WebKit::Platform::current()->createThread("CCThre
adedTest")); |
| 534 Platform::current()->compositorSupport()->initialize(m_webThread.get()); | 534 Platform::current()->compositorSupport()->initialize(m_webThread.get()); |
| 535 } else | 535 } else |
| 536 Platform::current()->compositorSupport()->initialize(0); | 536 Platform::current()->compositorSupport()->initialize(0); |
| 537 | 537 |
| 538 ASSERT(CCProxy::isMainThread()); | 538 DCHECK(CCProxy::isMainThread()); |
| 539 m_mainThreadProxy = CCScopedThreadProxy::create(CCProxy::mainThread()); | 539 m_mainThreadProxy = CCScopedThreadProxy::create(CCProxy::mainThread()); |
| 540 | 540 |
| 541 initializeSettings(m_settings); | 541 initializeSettings(m_settings); |
| 542 | 542 |
| 543 m_beginTask = new BeginTask(this); | 543 m_beginTask = new BeginTask(this); |
| 544 WebKit::Platform::current()->currentThread()->postDelayedTask(m_beginTask, 0
); // postDelayedTask takes ownership of the task | 544 WebKit::Platform::current()->currentThread()->postDelayedTask(m_beginTask, 0
); // postDelayedTask takes ownership of the task |
| 545 m_timeoutTask = new TimeoutTask(this); | 545 m_timeoutTask = new TimeoutTask(this); |
| 546 WebKit::Platform::current()->currentThread()->postDelayedTask(m_timeoutTask,
5000); | 546 WebKit::Platform::current()->currentThread()->postDelayedTask(m_timeoutTask,
5000); |
| 547 WebKit::Platform::current()->currentThread()->enterRunLoop(); | 547 WebKit::Platform::current()->currentThread()->enterRunLoop(); |
| 548 | 548 |
| 549 if (m_layerTreeHost.get() && m_layerTreeHost->rootLayer()) | 549 if (m_layerTreeHost.get() && m_layerTreeHost->rootLayer()) |
| 550 m_layerTreeHost->rootLayer()->setLayerTreeHost(0); | 550 m_layerTreeHost->rootLayer()->setLayerTreeHost(0); |
| 551 m_layerTreeHost.reset(); | 551 m_layerTreeHost.reset(); |
| 552 | 552 |
| 553 if (m_timeoutTask) | 553 if (m_timeoutTask) |
| 554 m_timeoutTask->clearTest(); | 554 m_timeoutTask->clearTest(); |
| 555 | 555 |
| 556 ASSERT_FALSE(m_layerTreeHost.get()); | 556 ASSERT_FALSE(m_layerTreeHost.get()); |
| 557 m_client.clear(); | 557 m_client.clear(); |
| 558 if (m_timedOut) { | 558 if (m_timedOut) { |
| 559 FAIL() << "Test timed out"; | 559 FAIL() << "Test timed out"; |
| 560 Platform::current()->compositorSupport()->shutdown(); | 560 Platform::current()->compositorSupport()->shutdown(); |
| 561 return; | 561 return; |
| 562 } | 562 } |
| 563 afterTest(); | 563 afterTest(); |
| 564 Platform::current()->compositorSupport()->shutdown(); | 564 Platform::current()->compositorSupport()->shutdown(); |
| 565 } | 565 } |
| 566 | 566 |
| 567 } // namespace WebKitTests | 567 } // namespace WebKitTests |
| OLD | NEW |