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 "CCGraphicsContext.h" | 9 #include "CCGraphicsContext.h" |
10 #include "CCLayerTreeHostImpl.h" | 10 #include "CCLayerTreeHostImpl.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 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2499 WebTransformationMatrix identityMatrix; | 2499 WebTransformationMatrix identityMatrix; |
2500 setLayerPropertiesForTesting(m_layer.get(), 0, identityMatrix, FloatPoin
t(0, 0), FloatPoint(0, 0), IntSize(10, 20), true); | 2500 setLayerPropertiesForTesting(m_layer.get(), 0, identityMatrix, FloatPoin
t(0, 0), FloatPoint(0, 0), IntSize(10, 20), true); |
2501 } | 2501 } |
2502 | 2502 |
2503 class EvictTexturesTask : public WebKit::WebThread::Task { | 2503 class EvictTexturesTask : public WebKit::WebThread::Task { |
2504 public: | 2504 public: |
2505 EvictTexturesTask(CCLayerTreeHostTestEvictTextures* test) : m_test(test)
{ } | 2505 EvictTexturesTask(CCLayerTreeHostTestEvictTextures* test) : m_test(test)
{ } |
2506 virtual ~EvictTexturesTask() { } | 2506 virtual ~EvictTexturesTask() { } |
2507 virtual void run() OVERRIDE | 2507 virtual void run() OVERRIDE |
2508 { | 2508 { |
2509 ASSERT(m_test->m_implForEvictTextures); | 2509 DCHECK(m_test->m_implForEvictTextures); |
2510 m_test->m_implForEvictTextures->releaseContentsTextures(); | 2510 m_test->m_implForEvictTextures->releaseContentsTextures(); |
2511 } | 2511 } |
2512 | 2512 |
2513 private: | 2513 private: |
2514 CCLayerTreeHostTestEvictTextures* m_test; | 2514 CCLayerTreeHostTestEvictTextures* m_test; |
2515 }; | 2515 }; |
2516 | 2516 |
2517 void postEvictTextures() | 2517 void postEvictTextures() |
2518 { | 2518 { |
2519 ASSERT(webThread()); | 2519 DCHECK(webThread()); |
2520 webThread()->postTask(new EvictTexturesTask(this)); | 2520 webThread()->postTask(new EvictTexturesTask(this)); |
2521 } | 2521 } |
2522 | 2522 |
2523 // Commit 1: Just commit and draw normally, then post an eviction at the end | 2523 // Commit 1: Just commit and draw normally, then post an eviction at the end |
2524 // that will trigger a commit. | 2524 // that will trigger a commit. |
2525 // Commit 2: Triggered by the eviction, let it go through and then set | 2525 // Commit 2: Triggered by the eviction, let it go through and then set |
2526 // needsCommit. | 2526 // needsCommit. |
2527 // Commit 3: Triggered by the setNeedsCommit. In layout(), post an eviction | 2527 // Commit 3: Triggered by the setNeedsCommit. In layout(), post an eviction |
2528 // task, which will be handled before the commit. Don't set needsCommit, it | 2528 // task, which will be handled before the commit. Don't set needsCommit, it |
2529 // should have been posted. A frame should not be drawn (note, | 2529 // should have been posted. A frame should not be drawn (note, |
(...skipping 29 matching lines...) Expand all Loading... |
2559 EXPECT_TRUE(m_layer->haveBackingTexture()); | 2559 EXPECT_TRUE(m_layer->haveBackingTexture()); |
2560 m_layerTreeHost->setNeedsCommit(); | 2560 m_layerTreeHost->setNeedsCommit(); |
2561 break; | 2561 break; |
2562 case 5: | 2562 case 5: |
2563 break; | 2563 break; |
2564 case 6: | 2564 case 6: |
2565 EXPECT_TRUE(m_layer->haveBackingTexture()); | 2565 EXPECT_TRUE(m_layer->haveBackingTexture()); |
2566 endTest(); | 2566 endTest(); |
2567 break; | 2567 break; |
2568 default: | 2568 default: |
2569 ASSERT_NOT_REACHED(); | 2569 NOTREACHED(); |
2570 break; | 2570 break; |
2571 } | 2571 } |
2572 } | 2572 } |
2573 | 2573 |
2574 virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE | 2574 virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE |
2575 { | 2575 { |
2576 m_implForEvictTextures = impl; | 2576 m_implForEvictTextures = impl; |
2577 } | 2577 } |
2578 | 2578 |
2579 virtual void layout() OVERRIDE | 2579 virtual void layout() OVERRIDE |
(...skipping 12 matching lines...) Expand all Loading... |
2592 break; | 2592 break; |
2593 case 5: | 2593 case 5: |
2594 postEvictTextures(); | 2594 postEvictTextures(); |
2595 break; | 2595 break; |
2596 case 6: | 2596 case 6: |
2597 // We couldn't check in didCommitAndDrawFrame on commit 5, so check
here. | 2597 // We couldn't check in didCommitAndDrawFrame on commit 5, so check
here. |
2598 EXPECT_FALSE(m_layer->haveBackingTexture()); | 2598 EXPECT_FALSE(m_layer->haveBackingTexture()); |
2599 postEvictTextures(); | 2599 postEvictTextures(); |
2600 break; | 2600 break; |
2601 default: | 2601 default: |
2602 ASSERT_NOT_REACHED(); | 2602 NOTREACHED(); |
2603 break; | 2603 break; |
2604 } | 2604 } |
2605 } | 2605 } |
2606 | 2606 |
2607 virtual void afterTest() OVERRIDE | 2607 virtual void afterTest() OVERRIDE |
2608 { | 2608 { |
2609 } | 2609 } |
2610 | 2610 |
2611 private: | 2611 private: |
2612 MockContentLayerChromiumClient m_client; | 2612 MockContentLayerChromiumClient m_client; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2656 if (webThread()) | 2656 if (webThread()) |
2657 webThread()->postTask(new EvictTexturesTask(this)); | 2657 webThread()->postTask(new EvictTexturesTask(this)); |
2658 else { | 2658 else { |
2659 DebugScopedSetImplThread impl; | 2659 DebugScopedSetImplThread impl; |
2660 evictTexturesOnImplThread(); | 2660 evictTexturesOnImplThread(); |
2661 } | 2661 } |
2662 } | 2662 } |
2663 | 2663 |
2664 void evictTexturesOnImplThread() | 2664 void evictTexturesOnImplThread() |
2665 { | 2665 { |
2666 ASSERT(m_implForEvictTextures); | 2666 DCHECK(m_implForEvictTextures); |
2667 m_implForEvictTextures->releaseContentsTextures(); | 2667 m_implForEvictTextures->releaseContentsTextures(); |
2668 } | 2668 } |
2669 | 2669 |
2670 // Commit 1: Just commit and draw normally, then at the end, set ourselves | 2670 // Commit 1: Just commit and draw normally, then at the end, set ourselves |
2671 // invisible (to prevent a commit that would recreate textures after | 2671 // invisible (to prevent a commit that would recreate textures after |
2672 // eviction, before the context recovery), and post a task that will evict | 2672 // eviction, before the context recovery), and post a task that will evict |
2673 // textures, then cause the context to be lost, and then set ourselves | 2673 // textures, then cause the context to be lost, and then set ourselves |
2674 // visible again (to allow commits, since that's what causes context | 2674 // visible again (to allow commits, since that's what causes context |
2675 // recovery in single thread). | 2675 // recovery in single thread). |
2676 virtual void didCommitAndDrawFrame() OVERRIDE | 2676 virtual void didCommitAndDrawFrame() OVERRIDE |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2966 int m_numCommitComplete; | 2966 int m_numCommitComplete; |
2967 int m_numDrawLayers; | 2967 int m_numDrawLayers; |
2968 }; | 2968 }; |
2969 | 2969 |
2970 TEST_F(CCLayerTreeHostTestContinuousAnimate, runMultiThread) | 2970 TEST_F(CCLayerTreeHostTestContinuousAnimate, runMultiThread) |
2971 { | 2971 { |
2972 runTest(true); | 2972 runTest(true); |
2973 } | 2973 } |
2974 | 2974 |
2975 } // namespace | 2975 } // namespace |
OLD | NEW |