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 "CCLayerTreeHost.h" | 7 #include "CCLayerTreeHost.h" |
8 | 8 |
9 #include "CCGeometryTestUtils.h" | 9 #include "CCGeometryTestUtils.h" |
10 #include "CCGraphicsContext.h" | 10 #include "CCGraphicsContext.h" |
(...skipping 1411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1422 // Number of textures used for commit should still be one. | 1422 // Number of textures used for commit should still be one. |
1423 EXPECT_EQ(1, context->numUsedTextures()); | 1423 EXPECT_EQ(1, context->numUsedTextures()); |
1424 // First texture should not have been used. | 1424 // First texture should not have been used. |
1425 EXPECT_FALSE(context->usedTexture(context->texture(0))); | 1425 EXPECT_FALSE(context->usedTexture(context->texture(0))); |
1426 // New texture should have been used. | 1426 // New texture should have been used. |
1427 EXPECT_TRUE(context->usedTexture(context->texture(1))); | 1427 EXPECT_TRUE(context->usedTexture(context->texture(1))); |
1428 | 1428 |
1429 context->resetUsedTextures(); | 1429 context->resetUsedTextures(); |
1430 break; | 1430 break; |
1431 default: | 1431 default: |
1432 ASSERT_NOT_REACHED(); | 1432 NOTREACHED(); |
1433 break; | 1433 break; |
1434 } | 1434 } |
1435 } | 1435 } |
1436 | 1436 |
1437 virtual void drawLayersOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE | 1437 virtual void drawLayersOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE |
1438 { | 1438 { |
1439 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_
cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->context()->co
ntext3D()); | 1439 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_
cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->context()->co
ntext3D()); |
1440 | 1440 |
1441 // Number of textures used for draw should always be one. | 1441 // Number of textures used for draw should always be one. |
1442 EXPECT_EQ(1, context->numUsedTextures()); | 1442 EXPECT_EQ(1, context->numUsedTextures()); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1544 | 1544 |
1545 context->resetUsedTextures(); | 1545 context->resetUsedTextures(); |
1546 break; | 1546 break; |
1547 case 4: | 1547 case 4: |
1548 // Number of textures used for commit should be one. | 1548 // Number of textures used for commit should be one. |
1549 EXPECT_EQ(1, context->numUsedTextures()); | 1549 EXPECT_EQ(1, context->numUsedTextures()); |
1550 | 1550 |
1551 context->resetUsedTextures(); | 1551 context->resetUsedTextures(); |
1552 break; | 1552 break; |
1553 default: | 1553 default: |
1554 ASSERT_NOT_REACHED(); | 1554 NOTREACHED(); |
1555 break; | 1555 break; |
1556 } | 1556 } |
1557 } | 1557 } |
1558 | 1558 |
1559 virtual void drawLayersOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE | 1559 virtual void drawLayersOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE |
1560 { | 1560 { |
1561 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_
cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->context()->co
ntext3D()); | 1561 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_
cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->context()->co
ntext3D()); |
1562 | 1562 |
1563 // Number of textures used for drawing should two except for frame 4 | 1563 // Number of textures used for drawing should two except for frame 4 |
1564 // where the viewport only contains one layer. | 1564 // where the viewport only contains one layer. |
(...skipping 24 matching lines...) Expand all Loading... |
1589 m_child->setNeedsDisplayRect(FloatRect(0, 0, 5, 5)); | 1589 m_child->setNeedsDisplayRect(FloatRect(0, 0, 5, 5)); |
1590 break; | 1590 break; |
1591 case 3: | 1591 case 3: |
1592 m_child->setNeedsDisplay(); | 1592 m_child->setNeedsDisplay(); |
1593 m_layerTreeHost->setViewportSize(IntSize(10, 10), IntSize(10, 10)); | 1593 m_layerTreeHost->setViewportSize(IntSize(10, 10), IntSize(10, 10)); |
1594 break; | 1594 break; |
1595 case 4: | 1595 case 4: |
1596 m_layerTreeHost->setViewportSize(IntSize(10, 20), IntSize(10, 20)); | 1596 m_layerTreeHost->setViewportSize(IntSize(10, 20), IntSize(10, 20)); |
1597 break; | 1597 break; |
1598 default: | 1598 default: |
1599 ASSERT_NOT_REACHED(); | 1599 NOTREACHED(); |
1600 break; | 1600 break; |
1601 } | 1601 } |
1602 } | 1602 } |
1603 | 1603 |
1604 virtual void afterTest() OVERRIDE | 1604 virtual void afterTest() OVERRIDE |
1605 { | 1605 { |
1606 } | 1606 } |
1607 | 1607 |
1608 private: | 1608 private: |
1609 MockContentLayerChromiumClient m_client; | 1609 MockContentLayerChromiumClient m_client; |
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2500 WebTransformationMatrix identityMatrix; | 2500 WebTransformationMatrix identityMatrix; |
2501 setLayerPropertiesForTesting(m_layer.get(), 0, identityMatrix, FloatPoin
t(0, 0), FloatPoint(0, 0), IntSize(10, 20), true); | 2501 setLayerPropertiesForTesting(m_layer.get(), 0, identityMatrix, FloatPoin
t(0, 0), FloatPoint(0, 0), IntSize(10, 20), true); |
2502 } | 2502 } |
2503 | 2503 |
2504 class EvictTexturesTask : public WebKit::WebThread::Task { | 2504 class EvictTexturesTask : public WebKit::WebThread::Task { |
2505 public: | 2505 public: |
2506 EvictTexturesTask(CCLayerTreeHostTestEvictTextures* test) : m_test(test)
{ } | 2506 EvictTexturesTask(CCLayerTreeHostTestEvictTextures* test) : m_test(test)
{ } |
2507 virtual ~EvictTexturesTask() { } | 2507 virtual ~EvictTexturesTask() { } |
2508 virtual void run() OVERRIDE | 2508 virtual void run() OVERRIDE |
2509 { | 2509 { |
2510 ASSERT(m_test->m_implForEvictTextures); | 2510 CC_DCHECK(m_test->m_implForEvictTextures); |
2511 m_test->m_implForEvictTextures->releaseContentsTextures(); | 2511 m_test->m_implForEvictTextures->releaseContentsTextures(); |
2512 } | 2512 } |
2513 | 2513 |
2514 private: | 2514 private: |
2515 CCLayerTreeHostTestEvictTextures* m_test; | 2515 CCLayerTreeHostTestEvictTextures* m_test; |
2516 }; | 2516 }; |
2517 | 2517 |
2518 void postEvictTextures() | 2518 void postEvictTextures() |
2519 { | 2519 { |
2520 ASSERT(webThread()); | 2520 CC_DCHECK(webThread()); |
2521 webThread()->postTask(new EvictTexturesTask(this)); | 2521 webThread()->postTask(new EvictTexturesTask(this)); |
2522 } | 2522 } |
2523 | 2523 |
2524 // Commit 1: Just commit and draw normally, then post an eviction at the end | 2524 // Commit 1: Just commit and draw normally, then post an eviction at the end |
2525 // that will trigger a commit. | 2525 // that will trigger a commit. |
2526 // Commit 2: Triggered by the eviction, let it go through and then set | 2526 // Commit 2: Triggered by the eviction, let it go through and then set |
2527 // needsCommit. | 2527 // needsCommit. |
2528 // Commit 3: Triggered by the setNeedsCommit. In layout(), post an eviction | 2528 // Commit 3: Triggered by the setNeedsCommit. In layout(), post an eviction |
2529 // task, which will be handled before the commit. Don't set needsCommit, it | 2529 // task, which will be handled before the commit. Don't set needsCommit, it |
2530 // should have been posted. A frame should not be drawn (note, | 2530 // should have been posted. A frame should not be drawn (note, |
(...skipping 29 matching lines...) Expand all Loading... |
2560 EXPECT_TRUE(m_layer->haveBackingTexture()); | 2560 EXPECT_TRUE(m_layer->haveBackingTexture()); |
2561 m_layerTreeHost->setNeedsCommit(); | 2561 m_layerTreeHost->setNeedsCommit(); |
2562 break; | 2562 break; |
2563 case 5: | 2563 case 5: |
2564 break; | 2564 break; |
2565 case 6: | 2565 case 6: |
2566 EXPECT_TRUE(m_layer->haveBackingTexture()); | 2566 EXPECT_TRUE(m_layer->haveBackingTexture()); |
2567 endTest(); | 2567 endTest(); |
2568 break; | 2568 break; |
2569 default: | 2569 default: |
2570 ASSERT_NOT_REACHED(); | 2570 NOTREACHED(); |
2571 break; | 2571 break; |
2572 } | 2572 } |
2573 } | 2573 } |
2574 | 2574 |
2575 virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE | 2575 virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE |
2576 { | 2576 { |
2577 m_implForEvictTextures = impl; | 2577 m_implForEvictTextures = impl; |
2578 } | 2578 } |
2579 | 2579 |
2580 virtual void layout() OVERRIDE | 2580 virtual void layout() OVERRIDE |
(...skipping 12 matching lines...) Expand all Loading... |
2593 break; | 2593 break; |
2594 case 5: | 2594 case 5: |
2595 postEvictTextures(); | 2595 postEvictTextures(); |
2596 break; | 2596 break; |
2597 case 6: | 2597 case 6: |
2598 // We couldn't check in didCommitAndDrawFrame on commit 5, so check
here. | 2598 // We couldn't check in didCommitAndDrawFrame on commit 5, so check
here. |
2599 EXPECT_FALSE(m_layer->haveBackingTexture()); | 2599 EXPECT_FALSE(m_layer->haveBackingTexture()); |
2600 postEvictTextures(); | 2600 postEvictTextures(); |
2601 break; | 2601 break; |
2602 default: | 2602 default: |
2603 ASSERT_NOT_REACHED(); | 2603 NOTREACHED(); |
2604 break; | 2604 break; |
2605 } | 2605 } |
2606 } | 2606 } |
2607 | 2607 |
2608 virtual void afterTest() OVERRIDE | 2608 virtual void afterTest() OVERRIDE |
2609 { | 2609 { |
2610 } | 2610 } |
2611 | 2611 |
2612 private: | 2612 private: |
2613 MockContentLayerChromiumClient m_client; | 2613 MockContentLayerChromiumClient m_client; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2657 if (webThread()) | 2657 if (webThread()) |
2658 webThread()->postTask(new EvictTexturesTask(this)); | 2658 webThread()->postTask(new EvictTexturesTask(this)); |
2659 else { | 2659 else { |
2660 DebugScopedSetImplThread impl; | 2660 DebugScopedSetImplThread impl; |
2661 evictTexturesOnImplThread(); | 2661 evictTexturesOnImplThread(); |
2662 } | 2662 } |
2663 } | 2663 } |
2664 | 2664 |
2665 void evictTexturesOnImplThread() | 2665 void evictTexturesOnImplThread() |
2666 { | 2666 { |
2667 ASSERT(m_implForEvictTextures); | 2667 CC_DCHECK(m_implForEvictTextures); |
2668 m_implForEvictTextures->releaseContentsTextures(); | 2668 m_implForEvictTextures->releaseContentsTextures(); |
2669 } | 2669 } |
2670 | 2670 |
2671 // Commit 1: Just commit and draw normally, then at the end, set ourselves | 2671 // Commit 1: Just commit and draw normally, then at the end, set ourselves |
2672 // invisible (to prevent a commit that would recreate textures after | 2672 // invisible (to prevent a commit that would recreate textures after |
2673 // eviction, before the context recovery), and post a task that will evict | 2673 // eviction, before the context recovery), and post a task that will evict |
2674 // textures, then cause the context to be lost, and then set ourselves | 2674 // textures, then cause the context to be lost, and then set ourselves |
2675 // visible again (to allow commits, since that's what causes context | 2675 // visible again (to allow commits, since that's what causes context |
2676 // recovery in single thread). | 2676 // recovery in single thread). |
2677 virtual void didCommitAndDrawFrame() OVERRIDE | 2677 virtual void didCommitAndDrawFrame() OVERRIDE |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2967 int m_numCommitComplete; | 2967 int m_numCommitComplete; |
2968 int m_numDrawLayers; | 2968 int m_numDrawLayers; |
2969 }; | 2969 }; |
2970 | 2970 |
2971 TEST_F(CCLayerTreeHostTestContinuousAnimate, runMultiThread) | 2971 TEST_F(CCLayerTreeHostTestContinuousAnimate, runMultiThread) |
2972 { | 2972 { |
2973 runTest(true); | 2973 runTest(true); |
2974 } | 2974 } |
2975 | 2975 |
2976 } // namespace | 2976 } // namespace |
OLD | NEW |