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