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 "cc/layer_tree_host.h" | 5 #include "cc/layer_tree_host.h" |
6 | 6 |
7 #include "base/synchronization/lock.h" | 7 #include "base/synchronization/lock.h" |
8 #include "cc/content_layer.h" | 8 #include "cc/content_layer.h" |
9 #include "cc/content_layer_client.h" | 9 #include "cc/content_layer_client.h" |
10 #include "cc/layer_impl.h" | 10 #include "cc/layer_impl.h" |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 TEST_F(LayerTreeHostTestSetNeedsRedraw, runMultiThread) | 276 TEST_F(LayerTreeHostTestSetNeedsRedraw, runMultiThread) |
277 { | 277 { |
278 runTest(true); | 278 runTest(true); |
279 } | 279 } |
280 | 280 |
281 // If the layerTreeHost says it can't draw, then we should not try to draw. | 281 // If the layerTreeHost says it can't draw, then we should not try to draw. |
282 class LayerTreeHostTestCanDrawBlocksDrawing : public LayerTreeHostTest { | 282 class LayerTreeHostTestCanDrawBlocksDrawing : public LayerTreeHostTest { |
283 public: | 283 public: |
284 LayerTreeHostTestCanDrawBlocksDrawing() | 284 LayerTreeHostTestCanDrawBlocksDrawing() |
285 : m_numCommits(0) | 285 : m_numCommits(0) |
| 286 , m_done(false) |
286 { | 287 { |
287 } | 288 } |
288 | 289 |
289 virtual void beginTest() OVERRIDE | 290 virtual void beginTest() OVERRIDE |
290 { | 291 { |
291 postSetNeedsCommitToMainThread(); | 292 postSetNeedsCommitToMainThread(); |
292 } | 293 } |
293 | 294 |
294 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE | 295 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE |
295 { | 296 { |
| 297 if (m_done) |
| 298 return; |
296 // Only the initial draw should bring us here. | 299 // Only the initial draw should bring us here. |
297 EXPECT_TRUE(impl->canDraw()); | 300 EXPECT_TRUE(impl->canDraw()); |
298 EXPECT_EQ(0, impl->activeTree()->source_frame_number()); | 301 EXPECT_EQ(0, impl->activeTree()->source_frame_number()); |
299 } | 302 } |
300 | 303 |
301 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE | 304 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE |
302 { | 305 { |
| 306 if (m_done) |
| 307 return; |
303 if (m_numCommits >= 1) { | 308 if (m_numCommits >= 1) { |
304 // After the first commit, we should not be able to draw. | 309 // After the first commit, we should not be able to draw. |
305 EXPECT_FALSE(impl->canDraw()); | 310 EXPECT_FALSE(impl->canDraw()); |
306 } | 311 } |
307 } | 312 } |
308 | 313 |
309 virtual void didCommit() OVERRIDE | 314 virtual void didCommit() OVERRIDE |
310 { | 315 { |
311 m_numCommits++; | 316 m_numCommits++; |
312 if (m_numCommits == 1) { | 317 if (m_numCommits == 1) { |
313 // Make the viewport empty so the host says it can't draw. | 318 // Make the viewport empty so the host says it can't draw. |
314 m_layerTreeHost->setViewportSize(gfx::Size(0, 0), gfx::Size(0, 0)); | 319 m_layerTreeHost->setViewportSize(gfx::Size(0, 0), gfx::Size(0, 0)); |
315 | 320 } else if (m_numCommits == 2) { |
316 char pixels[4]; | 321 char pixels[4]; |
317 m_layerTreeHost->compositeAndReadback(static_cast<void*>(&pixels), g
fx::Rect(0, 0, 1, 1)); | 322 m_layerTreeHost->compositeAndReadback(static_cast<void*>(&pixels), g
fx::Rect(0, 0, 1, 1)); |
318 } else if (m_numCommits == 2) { | 323 } else if (m_numCommits == 3) { |
319 m_layerTreeHost->setNeedsRedraw(); | 324 postSetNeedsRedrawToMainThread(); |
320 m_layerTreeHost->setNeedsCommit(); | 325 postSetNeedsCommitToMainThread(); |
321 } else | 326 } else if (m_numCommits == 4) { |
| 327 // Let it draw so we go idle and end the test. |
| 328 m_layerTreeHost->setViewportSize(gfx::Size(1, 1), gfx::Size(1, 1)); |
| 329 m_done = true; |
322 endTest(); | 330 endTest(); |
| 331 } |
323 } | 332 } |
324 | 333 |
325 virtual void afterTest() OVERRIDE | 334 virtual void afterTest() OVERRIDE |
326 { | 335 { |
327 } | 336 } |
328 | 337 |
329 private: | 338 private: |
330 int m_numCommits; | 339 int m_numCommits; |
| 340 bool m_done; |
331 }; | 341 }; |
332 | 342 |
333 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestCanDrawBlocksDrawing) | 343 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestCanDrawBlocksDrawing) |
334 | 344 |
335 // beginLayerWrite should prevent draws from executing until a commit occurs | 345 // beginLayerWrite should prevent draws from executing until a commit occurs |
336 class LayerTreeHostTestWriteLayersRedraw : public LayerTreeHostTest { | 346 class LayerTreeHostTestWriteLayersRedraw : public LayerTreeHostTest { |
337 public: | 347 public: |
338 LayerTreeHostTestWriteLayersRedraw() | 348 LayerTreeHostTestWriteLayersRedraw() |
339 : m_numCommits(0) | 349 : m_numCommits(0) |
340 , m_numDraws(0) | 350 , m_numDraws(0) |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 virtual void beginTest() OVERRIDE | 400 virtual void beginTest() OVERRIDE |
391 { | 401 { |
392 postSetNeedsCommitToMainThread(); | 402 postSetNeedsCommitToMainThread(); |
393 } | 403 } |
394 | 404 |
395 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE | 405 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE |
396 { | 406 { |
397 m_numCommits++; | 407 m_numCommits++; |
398 if (m_numCommits == 2) | 408 if (m_numCommits == 2) |
399 endTest(); | 409 endTest(); |
400 else { | 410 else if (m_numCommits < 2) { |
401 postSetVisibleToMainThread(false); | 411 postSetVisibleToMainThread(false); |
402 postSetVisibleToMainThread(true); | 412 postSetVisibleToMainThread(true); |
403 postAcquireLayerTextures(); | 413 postAcquireLayerTextures(); |
404 postSetNeedsCommitToMainThread(); | 414 postSetNeedsCommitToMainThread(); |
405 } | 415 } |
406 } | 416 } |
407 | 417 |
408 virtual void afterTest() OVERRIDE | 418 virtual void afterTest() OVERRIDE |
409 { | 419 { |
410 } | 420 } |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 } | 511 } |
502 | 512 |
503 virtual void beginTest() OVERRIDE | 513 virtual void beginTest() OVERRIDE |
504 { | 514 { |
505 postSetNeedsCommitToMainThread(); | 515 postSetNeedsCommitToMainThread(); |
506 } | 516 } |
507 | 517 |
508 virtual void animate(base::TimeTicks monotonicTime) OVERRIDE | 518 virtual void animate(base::TimeTicks monotonicTime) OVERRIDE |
509 { | 519 { |
510 // We skip the first commit becasue its the commit that populates the | 520 // We skip the first commit becasue its the commit that populates the |
511 // impl thread with a tree. | 521 // impl thread with a tree. After the second commit, the test is done. |
512 if (!m_numCommits) | 522 if (m_numCommits != 1) |
513 return; | 523 return; |
514 | 524 |
515 m_layerTreeHost->setNeedsAnimate(); | 525 m_layerTreeHost->setNeedsAnimate(); |
516 // Right now, commitRequested is going to be true, because during | 526 // Right now, commitRequested is going to be true, because during |
517 // beginFrame, we force commitRequested to true to prevent requests from | 527 // beginFrame, we force commitRequested to true to prevent requests from |
518 // hitting the impl thread. But, when the next didCommit happens, we sho
uld | 528 // hitting the impl thread. But, when the next didCommit happens, we sho
uld |
519 // verify that commitRequested has gone back to false. | 529 // verify that commitRequested has gone back to false. |
520 } | 530 } |
| 531 |
521 virtual void didCommit() OVERRIDE | 532 virtual void didCommit() OVERRIDE |
522 { | 533 { |
523 if (!m_numCommits) { | 534 if (!m_numCommits) { |
524 EXPECT_FALSE(m_layerTreeHost->commitRequested()); | 535 EXPECT_FALSE(m_layerTreeHost->commitRequested()); |
525 m_layerTreeHost->setNeedsAnimate(); | 536 m_layerTreeHost->setNeedsAnimate(); |
526 EXPECT_FALSE(m_layerTreeHost->commitRequested()); | 537 EXPECT_FALSE(m_layerTreeHost->commitRequested()); |
527 m_numCommits++; | |
528 } | 538 } |
529 | 539 |
530 // Verifies that the setNeedsAnimate we made in ::animate did not | 540 // Verifies that the setNeedsAnimate we made in ::animate did not |
531 // trigger commitRequested. | 541 // trigger commitRequested. |
532 EXPECT_FALSE(m_layerTreeHost->commitRequested()); | 542 EXPECT_FALSE(m_layerTreeHost->commitRequested()); |
533 endTest(); | 543 endTest(); |
| 544 m_numCommits++; |
534 } | 545 } |
535 | 546 |
536 virtual void afterTest() OVERRIDE | 547 virtual void afterTest() OVERRIDE |
537 { | 548 { |
538 } | 549 } |
539 | 550 |
540 private: | 551 private: |
541 int m_numCommits; | 552 int m_numCommits; |
542 }; | 553 }; |
543 | 554 |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 return; | 754 return; |
744 const FloatAnimationCurve* curve = animation->curve()->toFloatAnimationC
urve(); | 755 const FloatAnimationCurve* curve = animation->curve()->toFloatAnimationC
urve(); |
745 float startOpacity = curve->getValue(0); | 756 float startOpacity = curve->getValue(0); |
746 float endOpacity = curve->getValue(curve->duration()); | 757 float endOpacity = curve->getValue(curve->duration()); |
747 float linearlyInterpolatedOpacity = 0.25 * endOpacity + 0.75 * startOpac
ity; | 758 float linearlyInterpolatedOpacity = 0.25 * endOpacity + 0.75 * startOpac
ity; |
748 double time = curve->duration() * 0.25; | 759 double time = curve->duration() * 0.25; |
749 // If the linear timing function associated with this animation was not
picked up, | 760 // If the linear timing function associated with this animation was not
picked up, |
750 // then the linearly interpolated opacity would be different because of
the | 761 // then the linearly interpolated opacity would be different because of
the |
751 // default ease timing function. | 762 // default ease timing function. |
752 EXPECT_FLOAT_EQ(linearlyInterpolatedOpacity, curve->getValue(time)); | 763 EXPECT_FLOAT_EQ(linearlyInterpolatedOpacity, curve->getValue(time)); |
| 764 |
| 765 const ActiveAnimation* animationImpl = layerTreeHostImpl->rootLayer()->l
ayerAnimationController()->getActiveAnimation(0, ActiveAnimation::Opacity); |
| 766 |
| 767 m_layerTreeHost->rootLayer()->layerAnimationController()->removeAnimatio
n(animation->id()); |
| 768 layerTreeHostImpl->rootLayer()->layerAnimationController()->removeAnimat
ion(animationImpl->id()); |
753 endTest(); | 769 endTest(); |
754 } | 770 } |
755 | 771 |
756 virtual void afterTest() OVERRIDE | 772 virtual void afterTest() OVERRIDE |
757 { | 773 { |
758 } | 774 } |
759 | 775 |
760 private: | 776 private: |
761 }; | 777 }; |
762 | 778 |
763 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestAddAnimationWithTimingFunction) | 779 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestAddAnimationWithTimingFunction) |
764 | 780 |
765 // Ensures that main thread animations have their start times synchronized with
impl thread animations. | 781 // Ensures that main thread animations have their start times synchronized with
impl thread animations. |
766 class LayerTreeHostTestSynchronizeAnimationStartTimes : public LayerTreeHostTest
{ | 782 class LayerTreeHostTestSynchronizeAnimationStartTimes : public LayerTreeHostTest
{ |
767 public: | 783 public: |
768 LayerTreeHostTestSynchronizeAnimationStartTimes() | 784 LayerTreeHostTestSynchronizeAnimationStartTimes() |
769 : m_layerTreeHostImpl(0) | 785 : m_mainStartTime(-1) |
| 786 , m_implStartTime(-1) |
770 { | 787 { |
771 } | 788 } |
772 | 789 |
773 virtual void beginTest() OVERRIDE | 790 virtual void beginTest() OVERRIDE |
774 { | 791 { |
775 postAddAnimationToMainThread(m_layerTreeHost->rootLayer()); | 792 postAddAnimationToMainThread(m_layerTreeHost->rootLayer()); |
776 } | 793 } |
777 | 794 |
778 // This is guaranteed to be called before CCLayerTreeHostImpl::animateLayers
. | |
779 virtual void willAnimateLayers(LayerTreeHostImpl* layerTreeHostImpl, base::T
imeTicks monotonicTime) OVERRIDE | |
780 { | |
781 m_layerTreeHostImpl = layerTreeHostImpl; | |
782 } | |
783 | |
784 virtual void notifyAnimationStarted(double time) OVERRIDE | 795 virtual void notifyAnimationStarted(double time) OVERRIDE |
785 { | 796 { |
786 EXPECT_TRUE(m_layerTreeHostImpl); | 797 LayerAnimationController* controller = m_layerTreeHost->rootLayer()->lay
erAnimationController(); |
| 798 ActiveAnimation* animation = controller->getActiveAnimation(0, ActiveAni
mation::Opacity); |
| 799 m_mainStartTime = animation->startTime(); |
| 800 controller->removeAnimation(animation->id()); |
787 | 801 |
788 LayerAnimationController* controllerImpl = m_layerTreeHostImpl->rootLaye
r()->layerAnimationController(); | 802 if (m_implStartTime > 0) |
789 LayerAnimationController* controller = m_layerTreeHost->rootLayer()->lay
erAnimationController(); | 803 endTest(); |
790 ActiveAnimation* animationImpl = controllerImpl->getActiveAnimation(0, A
ctiveAnimation::Opacity); | 804 } |
| 805 |
| 806 virtual void animateLayers(LayerTreeHostImpl* impl, base::TimeTicks monotoni
cTime) |
| 807 { |
| 808 LayerAnimationController* controller = impl->rootLayer()->layerAnimation
Controller(); |
791 ActiveAnimation* animation = controller->getActiveAnimation(0, ActiveAni
mation::Opacity); | 809 ActiveAnimation* animation = controller->getActiveAnimation(0, ActiveAni
mation::Opacity); |
| 810 if (!animation) |
| 811 return; |
792 | 812 |
793 EXPECT_EQ(animationImpl->startTime(), animation->startTime()); | 813 m_implStartTime = animation->startTime(); |
| 814 controller->removeAnimation(animation->id()); |
794 | 815 |
795 endTest(); | 816 if (m_mainStartTime > 0) |
| 817 endTest(); |
796 } | 818 } |
797 | 819 |
798 virtual void afterTest() OVERRIDE | 820 virtual void afterTest() OVERRIDE |
799 { | 821 { |
| 822 EXPECT_FLOAT_EQ(m_implStartTime, m_mainStartTime); |
800 } | 823 } |
801 | 824 |
802 private: | 825 private: |
803 LayerTreeHostImpl* m_layerTreeHostImpl; | 826 double m_mainStartTime; |
| 827 double m_implStartTime; |
804 }; | 828 }; |
805 | 829 |
806 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSynchronizeAnimationStartTimes) | 830 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSynchronizeAnimationStartTimes) |
807 | 831 |
808 // Ensures that main thread animations have their start times synchronized with
impl thread animations. | 832 // Ensures that main thread animations have their start times synchronized with
impl thread animations. |
809 class LayerTreeHostTestAnimationFinishedEvents : public LayerTreeHostTest { | 833 class LayerTreeHostTestAnimationFinishedEvents : public LayerTreeHostTest { |
810 public: | 834 public: |
811 LayerTreeHostTestAnimationFinishedEvents() | 835 LayerTreeHostTestAnimationFinishedEvents() |
812 { | 836 { |
813 } | 837 } |
814 | 838 |
815 virtual void beginTest() OVERRIDE | 839 virtual void beginTest() OVERRIDE |
816 { | 840 { |
817 postAddInstantAnimationToMainThread(); | 841 postAddInstantAnimationToMainThread(); |
818 } | 842 } |
819 | 843 |
820 virtual void notifyAnimationFinished(double time) OVERRIDE | 844 virtual void notifyAnimationFinished(double time) OVERRIDE |
821 { | 845 { |
| 846 const ActiveAnimation* animation = m_layerTreeHost->rootLayer()->layerAn
imationController()->getActiveAnimation(0, ActiveAnimation::Opacity); |
| 847 m_layerTreeHost->rootLayer()->layerAnimationController()->removeAnimatio
n(animation->id()); |
822 endTest(); | 848 endTest(); |
823 } | 849 } |
824 | 850 |
825 virtual void afterTest() OVERRIDE | 851 virtual void afterTest() OVERRIDE |
826 { | 852 { |
827 } | 853 } |
828 | 854 |
829 private: | 855 private: |
830 }; | 856 }; |
831 | 857 |
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1380 m_rootLayer = NULL; | 1406 m_rootLayer = NULL; |
1381 m_childLayer = NULL; | 1407 m_childLayer = NULL; |
1382 } | 1408 } |
1383 | 1409 |
1384 private: | 1410 private: |
1385 FakeContentLayerClient m_client; | 1411 FakeContentLayerClient m_client; |
1386 scoped_refptr<NoScaleContentLayer> m_rootLayer; | 1412 scoped_refptr<NoScaleContentLayer> m_rootLayer; |
1387 scoped_refptr<ContentLayer> m_childLayer; | 1413 scoped_refptr<ContentLayer> m_childLayer; |
1388 }; | 1414 }; |
1389 | 1415 |
1390 // http://crbug.com/164851. | 1416 TEST_F(LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers, runMultiThread
) |
1391 TEST_F(LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers, FLAKY_runMulti
Thread) | |
1392 { | 1417 { |
1393 runTest(true); | 1418 runTest(true); |
1394 } | 1419 } |
1395 | 1420 |
1396 // Verify atomicity of commits and reuse of textures. | 1421 // Verify atomicity of commits and reuse of textures. |
1397 class LayerTreeHostTestAtomicCommit : public LayerTreeHostTest { | 1422 class LayerTreeHostTestAtomicCommit : public LayerTreeHostTest { |
1398 public: | 1423 public: |
1399 LayerTreeHostTestAtomicCommit() | 1424 LayerTreeHostTestAtomicCommit() |
1400 : m_layer(ContentLayerWithUpdateTracking::create(&m_client)) | 1425 : m_layer(ContentLayerWithUpdateTracking::create(&m_client)) |
1401 { | 1426 { |
1402 // Make sure partial texture updates are turned off. | 1427 // Make sure partial texture updates are turned off. |
1403 m_settings.maxPartialTextureUpdates = 0; | 1428 m_settings.maxPartialTextureUpdates = 0; |
1404 } | 1429 } |
1405 | 1430 |
1406 virtual void beginTest() OVERRIDE | 1431 virtual void beginTest() OVERRIDE |
1407 { | 1432 { |
1408 m_layerTreeHost->setRootLayer(m_layer); | 1433 m_layerTreeHost->setRootLayer(m_layer); |
1409 m_layerTreeHost->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); | 1434 m_layerTreeHost->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); |
1410 | 1435 |
1411 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded()); | 1436 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded()); |
1412 ResourceUpdateQueue queue; | 1437 ResourceUpdateQueue queue; |
1413 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; | 1438 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; |
1414 postSetNeedsCommitToMainThread(); | 1439 postSetNeedsCommitToMainThread(); |
1415 postSetNeedsRedrawToMainThread(); | |
1416 } | 1440 } |
1417 | 1441 |
1418 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE | 1442 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE |
1419 { | 1443 { |
1420 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_
cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface
()->Context3D()); | 1444 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_
cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface
()->Context3D()); |
1421 | 1445 |
1422 switch (impl->activeTree()->source_frame_number()) { | 1446 switch (impl->activeTree()->source_frame_number()) { |
1423 case 0: | 1447 case 0: |
1424 // Number of textures should be one. | 1448 // Number of textures should be one. |
1425 ASSERT_EQ(1, context->numTextures()); | 1449 ASSERT_EQ(1, context->numTextures()); |
1426 // Number of textures used for commit should be one. | 1450 // Number of textures used for commit should be one. |
1427 EXPECT_EQ(1, context->numUsedTextures()); | 1451 EXPECT_EQ(1, context->numUsedTextures()); |
1428 // Verify that used texture is correct. | 1452 // Verify that used texture is correct. |
1429 EXPECT_TRUE(context->usedTexture(context->texture(0))); | 1453 EXPECT_TRUE(context->usedTexture(context->texture(0))); |
1430 | 1454 |
1431 context->resetUsedTextures(); | 1455 context->resetUsedTextures(); |
| 1456 postSetNeedsCommitToMainThread(); |
1432 break; | 1457 break; |
1433 case 1: | 1458 case 1: |
1434 // Number of textures should be two as the first texture | 1459 // Number of textures should be two as the first texture |
1435 // is used by impl thread and cannot by used for update. | 1460 // is used by impl thread and cannot by used for update. |
1436 ASSERT_EQ(2, context->numTextures()); | 1461 ASSERT_EQ(2, context->numTextures()); |
1437 // Number of textures used for commit should still be one. | 1462 // Number of textures used for commit should still be one. |
1438 EXPECT_EQ(1, context->numUsedTextures()); | 1463 EXPECT_EQ(1, context->numUsedTextures()); |
1439 // First texture should not have been used. | 1464 // First texture should not have been used. |
1440 EXPECT_FALSE(context->usedTexture(context->texture(0))); | 1465 EXPECT_FALSE(context->usedTexture(context->texture(0))); |
1441 // New texture should have been used. | 1466 // New texture should have been used. |
1442 EXPECT_TRUE(context->usedTexture(context->texture(1))); | 1467 EXPECT_TRUE(context->usedTexture(context->texture(1))); |
1443 | 1468 |
1444 context->resetUsedTextures(); | 1469 context->resetUsedTextures(); |
| 1470 postSetNeedsCommitToMainThread(); |
| 1471 break; |
| 1472 case 2: |
| 1473 endTest(); |
1445 break; | 1474 break; |
1446 default: | 1475 default: |
1447 NOTREACHED(); | 1476 NOTREACHED(); |
1448 break; | 1477 break; |
1449 } | 1478 } |
1450 } | 1479 } |
1451 | 1480 |
1452 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE | 1481 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE |
1453 { | 1482 { |
1454 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_
cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface
()->Context3D()); | 1483 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_
cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface
()->Context3D()); |
1455 | 1484 |
1456 // Number of textures used for draw should always be one. | 1485 // Number of textures used for draw should always be one. |
1457 EXPECT_EQ(1, context->numUsedTextures()); | 1486 EXPECT_EQ(1, context->numUsedTextures()); |
1458 | 1487 context->resetUsedTextures(); |
1459 if (impl->activeTree()->source_frame_number() < 1) { | |
1460 context->resetUsedTextures(); | |
1461 postSetNeedsCommitToMainThread(); | |
1462 postSetNeedsRedrawToMainThread(); | |
1463 } else | |
1464 endTest(); | |
1465 } | 1488 } |
1466 | 1489 |
1467 virtual void layout() OVERRIDE | 1490 virtual void layout() OVERRIDE |
1468 { | 1491 { |
1469 m_layer->setNeedsDisplay(); | 1492 m_layer->setNeedsDisplay(); |
1470 } | 1493 } |
1471 | 1494 |
1472 virtual void afterTest() OVERRIDE | 1495 virtual void afterTest() OVERRIDE |
1473 { | 1496 { |
1474 } | 1497 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1512 m_layerTreeHost->setViewportSize(gfx::Size(10, 20), gfx::Size(10, 20)); | 1535 m_layerTreeHost->setViewportSize(gfx::Size(10, 20), gfx::Size(10, 20)); |
1513 | 1536 |
1514 gfx::Transform identityMatrix; | 1537 gfx::Transform identityMatrix; |
1515 setLayerPropertiesForTesting(m_parent.get(), 0, identityMatrix, gfx::Poi
ntF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 20), true); | 1538 setLayerPropertiesForTesting(m_parent.get(), 0, identityMatrix, gfx::Poi
ntF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 20), true); |
1516 setLayerPropertiesForTesting(m_child.get(), m_parent.get(), identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(0, 10), gfx::Size(10, 10), false); | 1539 setLayerPropertiesForTesting(m_child.get(), m_parent.get(), identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(0, 10), gfx::Size(10, 10), false); |
1517 | 1540 |
1518 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded()); | 1541 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded()); |
1519 ResourceUpdateQueue queue; | 1542 ResourceUpdateQueue queue; |
1520 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; | 1543 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; |
1521 postSetNeedsCommitToMainThread(); | 1544 postSetNeedsCommitToMainThread(); |
1522 postSetNeedsRedrawToMainThread(); | |
1523 } | 1545 } |
1524 | 1546 |
1525 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE | 1547 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE |
1526 { | 1548 { |
1527 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_
cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface
()->Context3D()); | 1549 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_
cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface
()->Context3D()); |
1528 | 1550 |
1529 switch (impl->activeTree()->source_frame_number()) { | 1551 switch (impl->activeTree()->source_frame_number()) { |
1530 case 0: | 1552 case 0: |
1531 // Number of textures should be two. | 1553 // Number of textures should be two. |
1532 ASSERT_EQ(2, context->numTextures()); | 1554 ASSERT_EQ(2, context->numTextures()); |
1533 // Number of textures used for commit should be two. | 1555 // Number of textures used for commit should be two. |
1534 EXPECT_EQ(2, context->numUsedTextures()); | 1556 EXPECT_EQ(2, context->numUsedTextures()); |
1535 // Verify that used textures are correct. | 1557 // Verify that used textures are correct. |
1536 EXPECT_TRUE(context->usedTexture(context->texture(0))); | 1558 EXPECT_TRUE(context->usedTexture(context->texture(0))); |
1537 EXPECT_TRUE(context->usedTexture(context->texture(1))); | 1559 EXPECT_TRUE(context->usedTexture(context->texture(1))); |
1538 | 1560 |
1539 context->resetUsedTextures(); | 1561 context->resetUsedTextures(); |
| 1562 postSetNeedsCommitToMainThread(); |
1540 break; | 1563 break; |
1541 case 1: | 1564 case 1: |
1542 // Number of textures used for commit should still be two. | 1565 // Number of textures used for commit should still be two. |
1543 EXPECT_EQ(2, context->numUsedTextures()); | 1566 EXPECT_EQ(2, context->numUsedTextures()); |
1544 // First two textures should not have been used. | 1567 // First two textures should not have been used. |
1545 EXPECT_FALSE(context->usedTexture(context->texture(0))); | 1568 EXPECT_FALSE(context->usedTexture(context->texture(0))); |
1546 EXPECT_FALSE(context->usedTexture(context->texture(1))); | 1569 EXPECT_FALSE(context->usedTexture(context->texture(1))); |
1547 // New textures should have been used. | 1570 // New textures should have been used. |
1548 EXPECT_TRUE(context->usedTexture(context->texture(2))); | 1571 EXPECT_TRUE(context->usedTexture(context->texture(2))); |
1549 EXPECT_TRUE(context->usedTexture(context->texture(3))); | 1572 EXPECT_TRUE(context->usedTexture(context->texture(3))); |
1550 | 1573 |
1551 context->resetUsedTextures(); | 1574 context->resetUsedTextures(); |
| 1575 postSetNeedsCommitToMainThread(); |
1552 break; | 1576 break; |
1553 case 2: | 1577 case 2: |
1554 // Number of textures used for commit should still be two. | 1578 // Number of textures used for commit should still be two. |
1555 EXPECT_EQ(2, context->numUsedTextures()); | 1579 EXPECT_EQ(2, context->numUsedTextures()); |
1556 | 1580 |
1557 context->resetUsedTextures(); | 1581 context->resetUsedTextures(); |
| 1582 postSetNeedsCommitToMainThread(); |
1558 break; | 1583 break; |
1559 case 3: | 1584 case 3: |
1560 // No textures should be used for commit. | 1585 // No textures should be used for commit. |
1561 EXPECT_EQ(0, context->numUsedTextures()); | 1586 EXPECT_EQ(0, context->numUsedTextures()); |
1562 | 1587 |
1563 context->resetUsedTextures(); | 1588 context->resetUsedTextures(); |
| 1589 postSetNeedsCommitToMainThread(); |
1564 break; | 1590 break; |
1565 case 4: | 1591 case 4: |
1566 // Number of textures used for commit should be one. | 1592 // Number of textures used for commit should be one. |
1567 EXPECT_EQ(1, context->numUsedTextures()); | 1593 EXPECT_EQ(1, context->numUsedTextures()); |
1568 | 1594 |
1569 context->resetUsedTextures(); | 1595 context->resetUsedTextures(); |
| 1596 postSetNeedsCommitToMainThread(); |
| 1597 break; |
| 1598 case 5: |
| 1599 endTest(); |
1570 break; | 1600 break; |
1571 default: | 1601 default: |
1572 NOTREACHED(); | 1602 NOTREACHED(); |
1573 break; | 1603 break; |
1574 } | 1604 } |
1575 } | 1605 } |
1576 | 1606 |
1577 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE | 1607 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE |
1578 { | 1608 { |
1579 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_
cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface
()->Context3D()); | 1609 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_
cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface
()->Context3D()); |
1580 | 1610 |
1581 // Number of textures used for drawing should two except for frame 4 | 1611 // Number of textures used for drawing should two except for frame 4 |
1582 // where the viewport only contains one layer. | 1612 // where the viewport only contains one layer. |
1583 if (impl->activeTree()->source_frame_number() == 3) | 1613 if (impl->activeTree()->source_frame_number() == 3) |
1584 EXPECT_EQ(1, context->numUsedTextures()); | 1614 EXPECT_EQ(1, context->numUsedTextures()); |
1585 else | 1615 else |
1586 EXPECT_EQ(2, context->numUsedTextures()); | 1616 EXPECT_EQ(2, context->numUsedTextures()); |
1587 | 1617 |
1588 if (impl->activeTree()->source_frame_number() < 4) { | 1618 context->resetUsedTextures(); |
1589 context->resetUsedTextures(); | |
1590 postSetNeedsCommitToMainThread(); | |
1591 postSetNeedsRedrawToMainThread(); | |
1592 } else | |
1593 endTest(); | |
1594 } | 1619 } |
1595 | 1620 |
1596 virtual void layout() OVERRIDE | 1621 virtual void layout() OVERRIDE |
1597 { | 1622 { |
1598 switch (m_numCommits++) { | 1623 switch (m_numCommits++) { |
1599 case 0: | 1624 case 0: |
1600 case 1: | 1625 case 1: |
1601 m_parent->setNeedsDisplay(); | 1626 m_parent->setNeedsDisplay(); |
1602 m_child->setNeedsDisplay(); | 1627 m_child->setNeedsDisplay(); |
1603 break; | 1628 break; |
1604 case 2: | 1629 case 2: |
1605 // Damage part of layers. | 1630 // Damage part of layers. |
1606 m_parent->setNeedsDisplayRect(gfx::RectF(0, 0, 5, 5)); | 1631 m_parent->setNeedsDisplayRect(gfx::RectF(0, 0, 5, 5)); |
1607 m_child->setNeedsDisplayRect(gfx::RectF(0, 0, 5, 5)); | 1632 m_child->setNeedsDisplayRect(gfx::RectF(0, 0, 5, 5)); |
1608 break; | 1633 break; |
1609 case 3: | 1634 case 3: |
1610 m_child->setNeedsDisplay(); | 1635 m_child->setNeedsDisplay(); |
1611 m_layerTreeHost->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10
)); | 1636 m_layerTreeHost->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10
)); |
1612 break; | 1637 break; |
1613 case 4: | 1638 case 4: |
1614 m_layerTreeHost->setViewportSize(gfx::Size(10, 20), gfx::Size(10, 20
)); | 1639 m_layerTreeHost->setViewportSize(gfx::Size(10, 20), gfx::Size(10, 20
)); |
1615 break; | 1640 break; |
| 1641 case 5: |
| 1642 break; |
1616 default: | 1643 default: |
1617 NOTREACHED(); | 1644 NOTREACHED(); |
1618 break; | 1645 break; |
1619 } | 1646 } |
1620 } | 1647 } |
1621 | 1648 |
1622 virtual void afterTest() OVERRIDE | 1649 virtual void afterTest() OVERRIDE |
1623 { | 1650 { |
1624 } | 1651 } |
1625 | 1652 |
(...skipping 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3014 virtual void beginTest() OVERRIDE | 3041 virtual void beginTest() OVERRIDE |
3015 { | 3042 { |
3016 m_layerTreeHost->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); | 3043 m_layerTreeHost->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); |
3017 m_layerTreeHost->rootLayer()->setBounds(gfx::Size(10, 10)); | 3044 m_layerTreeHost->rootLayer()->setBounds(gfx::Size(10, 10)); |
3018 | 3045 |
3019 postSetNeedsCommitToMainThread(); | 3046 postSetNeedsCommitToMainThread(); |
3020 } | 3047 } |
3021 | 3048 |
3022 virtual void didCommit() OVERRIDE | 3049 virtual void didCommit() OVERRIDE |
3023 { | 3050 { |
| 3051 if (m_numDrawLayers == 2) |
| 3052 return; |
3024 postSetNeedsCommitToMainThread(); | 3053 postSetNeedsCommitToMainThread(); |
3025 } | 3054 } |
3026 | 3055 |
3027 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE | 3056 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE |
3028 { | 3057 { |
3029 if (m_numDrawLayers == 1) | 3058 if (m_numDrawLayers == 1) |
3030 m_numCommitComplete++; | 3059 m_numCommitComplete++; |
3031 } | 3060 } |
3032 | 3061 |
3033 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE | 3062 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3071 m_contentLayer->setPosition(gfx::PointF(0, 0)); | 3100 m_contentLayer->setPosition(gfx::PointF(0, 0)); |
3072 m_contentLayer->setAnchorPoint(gfx::PointF(0, 0)); | 3101 m_contentLayer->setAnchorPoint(gfx::PointF(0, 0)); |
3073 m_contentLayer->setIsDrawable(true); | 3102 m_contentLayer->setIsDrawable(true); |
3074 m_layerTreeHost->rootLayer()->addChild(m_contentLayer); | 3103 m_layerTreeHost->rootLayer()->addChild(m_contentLayer); |
3075 | 3104 |
3076 postSetNeedsCommitToMainThread(); | 3105 postSetNeedsCommitToMainThread(); |
3077 } | 3106 } |
3078 | 3107 |
3079 virtual void didCommit() OVERRIDE | 3108 virtual void didCommit() OVERRIDE |
3080 { | 3109 { |
| 3110 if (m_numDrawLayers == 2) |
| 3111 return; |
3081 m_contentLayer->setNeedsDisplay(); | 3112 m_contentLayer->setNeedsDisplay(); |
3082 } | 3113 } |
3083 | 3114 |
3084 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE | 3115 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE |
3085 { | 3116 { |
3086 if (m_numDrawLayers == 1) | 3117 if (m_numDrawLayers == 1) |
3087 m_numCommitComplete++; | 3118 m_numCommitComplete++; |
3088 } | 3119 } |
3089 | 3120 |
3090 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE | 3121 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3166 virtual void beginTest() OVERRIDE | 3197 virtual void beginTest() OVERRIDE |
3167 { | 3198 { |
3168 m_layerTreeHost->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); | 3199 m_layerTreeHost->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); |
3169 m_layerTreeHost->rootLayer()->setBounds(gfx::Size(10, 10)); | 3200 m_layerTreeHost->rootLayer()->setBounds(gfx::Size(10, 10)); |
3170 | 3201 |
3171 postSetNeedsCommitToMainThread(); | 3202 postSetNeedsCommitToMainThread(); |
3172 } | 3203 } |
3173 | 3204 |
3174 virtual void animate(base::TimeTicks) OVERRIDE | 3205 virtual void animate(base::TimeTicks) OVERRIDE |
3175 { | 3206 { |
| 3207 if (m_numDrawLayers == 2) |
| 3208 return; |
3176 m_layerTreeHost->setNeedsAnimate(); | 3209 m_layerTreeHost->setNeedsAnimate(); |
3177 } | 3210 } |
3178 | 3211 |
3179 virtual void layout() OVERRIDE | 3212 virtual void layout() OVERRIDE |
3180 { | 3213 { |
3181 m_layerTreeHost->rootLayer()->setNeedsDisplay(); | 3214 m_layerTreeHost->rootLayer()->setNeedsDisplay(); |
3182 } | 3215 } |
3183 | 3216 |
3184 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE | 3217 virtual void commitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE |
3185 { | 3218 { |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3380 LayerTreeSettings settings; | 3413 LayerTreeSettings settings; |
3381 settings.maxPartialTextureUpdates = 4; | 3414 settings.maxPartialTextureUpdates = 4; |
3382 | 3415 |
3383 scoped_ptr<LayerTreeHost> host = LayerTreeHost::create(&client, settings, sc
oped_ptr<Thread>()); | 3416 scoped_ptr<LayerTreeHost> host = LayerTreeHost::create(&client, settings, sc
oped_ptr<Thread>()); |
3384 EXPECT_TRUE(host->initializeRendererIfNeeded()); | 3417 EXPECT_TRUE(host->initializeRendererIfNeeded()); |
3385 EXPECT_EQ(0u, host->settings().maxPartialTextureUpdates); | 3418 EXPECT_EQ(0u, host->settings().maxPartialTextureUpdates); |
3386 } | 3419 } |
3387 | 3420 |
3388 } // namespace | 3421 } // namespace |
3389 } // namespace cc | 3422 } // namespace cc |
OLD | NEW |