Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: cc/CCLayerTreeHostTest.cpp

Issue 11048044: cc: Switch to Chromium DCHECKs and LOGs (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
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 916 matching lines...) Expand 10 before | Expand all | Expand 10 after
2526 WebTransformationMatrix identityMatrix; 2526 WebTransformationMatrix identityMatrix;
2527 setLayerPropertiesForTesting(m_layer.get(), 0, identityMatrix, FloatPoin t(0, 0), FloatPoint(0, 0), IntSize(10, 20), true); 2527 setLayerPropertiesForTesting(m_layer.get(), 0, identityMatrix, FloatPoin t(0, 0), FloatPoint(0, 0), IntSize(10, 20), true);
2528 } 2528 }
2529 2529
2530 class EvictTexturesTask : public WebKit::WebThread::Task { 2530 class EvictTexturesTask : public WebKit::WebThread::Task {
2531 public: 2531 public:
2532 EvictTexturesTask(CCLayerTreeHostTestEvictTextures* test) : m_test(test) { } 2532 EvictTexturesTask(CCLayerTreeHostTestEvictTextures* test) : m_test(test) { }
2533 virtual ~EvictTexturesTask() { } 2533 virtual ~EvictTexturesTask() { }
2534 virtual void run() OVERRIDE 2534 virtual void run() OVERRIDE
2535 { 2535 {
2536 ASSERT(m_test->m_implForEvictTextures); 2536 DCHECK(m_test->m_implForEvictTextures);
2537 m_test->m_implForEvictTextures->releaseContentsTextures(); 2537 m_test->m_implForEvictTextures->releaseContentsTextures();
2538 } 2538 }
2539 2539
2540 private: 2540 private:
2541 CCLayerTreeHostTestEvictTextures* m_test; 2541 CCLayerTreeHostTestEvictTextures* m_test;
2542 }; 2542 };
2543 2543
2544 void postEvictTextures() 2544 void postEvictTextures()
2545 { 2545 {
2546 ASSERT(webThread()); 2546 DCHECK(webThread());
2547 webThread()->postTask(new EvictTexturesTask(this)); 2547 webThread()->postTask(new EvictTexturesTask(this));
2548 } 2548 }
2549 2549
2550 // Commit 1: Just commit and draw normally, then post an eviction at the end 2550 // Commit 1: Just commit and draw normally, then post an eviction at the end
2551 // that will trigger a commit. 2551 // that will trigger a commit.
2552 // Commit 2: Triggered by the eviction, let it go through and then set 2552 // Commit 2: Triggered by the eviction, let it go through and then set
2553 // needsCommit. 2553 // needsCommit.
2554 // Commit 3: Triggered by the setNeedsCommit. In layout(), post an eviction 2554 // Commit 3: Triggered by the setNeedsCommit. In layout(), post an eviction
2555 // task, which will be handled before the commit. Don't set needsCommit, it 2555 // task, which will be handled before the commit. Don't set needsCommit, it
2556 // should have been posted. A frame should not be drawn (note, 2556 // should have been posted. A frame should not be drawn (note,
(...skipping 29 matching lines...) Expand all
2586 EXPECT_TRUE(m_layer->updated()); 2586 EXPECT_TRUE(m_layer->updated());
2587 m_layerTreeHost->setNeedsCommit(); 2587 m_layerTreeHost->setNeedsCommit();
2588 break; 2588 break;
2589 case 5: 2589 case 5:
2590 break; 2590 break;
2591 case 6: 2591 case 6:
2592 EXPECT_TRUE(m_layer->updated()); 2592 EXPECT_TRUE(m_layer->updated());
2593 endTest(); 2593 endTest();
2594 break; 2594 break;
2595 default: 2595 default:
2596 ASSERT_NOT_REACHED(); 2596 NOTREACHED();
2597 break; 2597 break;
2598 } 2598 }
2599 } 2599 }
2600 2600
2601 virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE 2601 virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE
2602 { 2602 {
2603 m_implForEvictTextures = impl; 2603 m_implForEvictTextures = impl;
2604 } 2604 }
2605 2605
2606 virtual void layout() OVERRIDE 2606 virtual void layout() OVERRIDE
(...skipping 12 matching lines...) Expand all
2619 break; 2619 break;
2620 case 5: 2620 case 5:
2621 postEvictTextures(); 2621 postEvictTextures();
2622 break; 2622 break;
2623 case 6: 2623 case 6:
2624 // We couldn't check in didCommitAndDrawFrame on commit 5, so check here. 2624 // We couldn't check in didCommitAndDrawFrame on commit 5, so check here.
2625 EXPECT_FALSE(m_layer->updated()); 2625 EXPECT_FALSE(m_layer->updated());
2626 postEvictTextures(); 2626 postEvictTextures();
2627 break; 2627 break;
2628 default: 2628 default:
2629 ASSERT_NOT_REACHED(); 2629 NOTREACHED();
2630 break; 2630 break;
2631 } 2631 }
2632 m_layer->resetUpdated(); 2632 m_layer->resetUpdated();
2633 } 2633 }
2634 2634
2635 virtual void afterTest() OVERRIDE 2635 virtual void afterTest() OVERRIDE
2636 { 2636 {
2637 } 2637 }
2638 2638
2639 private: 2639 private:
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2684 if (webThread()) 2684 if (webThread())
2685 webThread()->postTask(new EvictTexturesTask(this)); 2685 webThread()->postTask(new EvictTexturesTask(this));
2686 else { 2686 else {
2687 DebugScopedSetImplThread impl; 2687 DebugScopedSetImplThread impl;
2688 evictTexturesOnImplThread(); 2688 evictTexturesOnImplThread();
2689 } 2689 }
2690 } 2690 }
2691 2691
2692 void evictTexturesOnImplThread() 2692 void evictTexturesOnImplThread()
2693 { 2693 {
2694 ASSERT(m_implForEvictTextures); 2694 DCHECK(m_implForEvictTextures);
2695 m_implForEvictTextures->releaseContentsTextures(); 2695 m_implForEvictTextures->releaseContentsTextures();
2696 } 2696 }
2697 2697
2698 // Commit 1: Just commit and draw normally, then at the end, set ourselves 2698 // Commit 1: Just commit and draw normally, then at the end, set ourselves
2699 // invisible (to prevent a commit that would recreate textures after 2699 // invisible (to prevent a commit that would recreate textures after
2700 // eviction, before the context recovery), and post a task that will evict 2700 // eviction, before the context recovery), and post a task that will evict
2701 // textures, then cause the context to be lost, and then set ourselves 2701 // textures, then cause the context to be lost, and then set ourselves
2702 // visible again (to allow commits, since that's what causes context 2702 // visible again (to allow commits, since that's what causes context
2703 // recovery in single thread). 2703 // recovery in single thread).
2704 virtual void didCommitAndDrawFrame() OVERRIDE 2704 virtual void didCommitAndDrawFrame() OVERRIDE
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
2994 int m_numCommitComplete; 2994 int m_numCommitComplete;
2995 int m_numDrawLayers; 2995 int m_numDrawLayers;
2996 }; 2996 };
2997 2997
2998 TEST_F(CCLayerTreeHostTestContinuousAnimate, runMultiThread) 2998 TEST_F(CCLayerTreeHostTestContinuousAnimate, runMultiThread)
2999 { 2999 {
3000 runTest(true); 3000 runTest(true);
3001 } 3001 }
3002 3002
3003 } // namespace 3003 } // namespace
OLDNEW
« cc/CCCompletionEvent.h ('K') | « cc/CCLayerTreeHostImplTest.cpp ('k') | cc/CCMathUtil.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698