| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 { | 623 { |
| 624 OwnPtr<WaitableEvent> doneEvent = adoptPtr(new WaitableEvent()); | 624 OwnPtr<WaitableEvent> doneEvent = adoptPtr(new WaitableEvent()); |
| 625 testThread->taskRunner()->postTask( | 625 testThread->taskRunner()->postTask( |
| 626 location, | 626 location, |
| 627 threadSafeBind(&runRenderingTask, | 627 threadSafeBind(&runRenderingTask, |
| 628 AllowCrossThreadAccess(bridge), | 628 AllowCrossThreadAccess(bridge), |
| 629 AllowCrossThreadAccess(doneEvent.get()))); | 629 AllowCrossThreadAccess(doneEvent.get()))); |
| 630 doneEvent->wait(); | 630 doneEvent->wait(); |
| 631 } | 631 } |
| 632 | 632 |
| 633 #if CANVAS2D_HIBERNATION_ENABLED | 633 #if CANVAS2D_HIBERNATION_ENABLED && CANVAS2D_BACKGROUND_RENDER_SWITCH_TO_CPU |
| 634 TEST_F(Canvas2DLayerBridgeTest, BackgroundRenderingWhileHibernating) | 634 TEST_F(Canvas2DLayerBridgeTest, BackgroundRenderingWhileHibernating) |
| 635 #else | 635 #else |
| 636 TEST_F(Canvas2DLayerBridgeTest, DISABLED_BackgroundRenderingWhileHibernating) | 636 TEST_F(Canvas2DLayerBridgeTest, DISABLED_BackgroundRenderingWhileHibernating) |
| 637 #endif | 637 #endif |
| 638 { | 638 { |
| 639 MockCanvasContext mainMock; | 639 MockCanvasContext mainMock; |
| 640 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); | 640 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); |
| 641 | 641 |
| 642 // The Canvas2DLayerBridge has to be created on the thread that will use it | 642 // The Canvas2DLayerBridge has to be created on the thread that will use it |
| 643 // to avoid WeakPtr thread check issues. | 643 // to avoid WeakPtr thread check issues. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 EXPECT_FALSE(bridge->isHibernating()); | 676 EXPECT_FALSE(bridge->isHibernating()); |
| 677 EXPECT_TRUE(bridge->checkSurfaceValid()); | 677 EXPECT_TRUE(bridge->checkSurfaceValid()); |
| 678 | 678 |
| 679 // Tear down the bridge on the thread so that 'bridge' can go out of scope | 679 // Tear down the bridge on the thread so that 'bridge' can go out of scope |
| 680 // without crashing due to thread checks | 680 // without crashing due to thread checks |
| 681 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); | 681 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); |
| 682 | 682 |
| 683 ::testing::Mock::VerifyAndClearExpectations(&mainMock); | 683 ::testing::Mock::VerifyAndClearExpectations(&mainMock); |
| 684 } | 684 } |
| 685 | 685 |
| 686 #if CANVAS2D_HIBERNATION_ENABLED | 686 #if CANVAS2D_HIBERNATION_ENABLED && CANVAS2D_BACKGROUND_RENDER_SWITCH_TO_CPU |
| 687 TEST_F(Canvas2DLayerBridgeTest, BackgroundRenderingWhileHibernatingWithDeferredR
enderingDisabled) | 687 TEST_F(Canvas2DLayerBridgeTest, BackgroundRenderingWhileHibernatingWithDeferredR
enderingDisabled) |
| 688 #else | 688 #else |
| 689 TEST_F(Canvas2DLayerBridgeTest, DISABLED_BackgroundRenderingWhileHibernatingWith
DeferredRenderingDisabled) | 689 TEST_F(Canvas2DLayerBridgeTest, DISABLED_BackgroundRenderingWhileHibernatingWith
DeferredRenderingDisabled) |
| 690 #endif | 690 #endif |
| 691 { | 691 { |
| 692 MockCanvasContext mainMock; | 692 MockCanvasContext mainMock; |
| 693 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); | 693 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); |
| 694 | 694 |
| 695 // The Canvas2DLayerBridge has to be created on the thread that will use it | 695 // The Canvas2DLayerBridge has to be created on the thread that will use it |
| 696 // to avoid WeakPtr thread check issues. | 696 // to avoid WeakPtr thread check issues. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 EXPECT_TRUE(bridge->isAccelerated()); // Becoming visible causes switch back
to GPU | 737 EXPECT_TRUE(bridge->isAccelerated()); // Becoming visible causes switch back
to GPU |
| 738 EXPECT_FALSE(bridge->isHibernating()); | 738 EXPECT_FALSE(bridge->isHibernating()); |
| 739 EXPECT_TRUE(bridge->checkSurfaceValid()); | 739 EXPECT_TRUE(bridge->checkSurfaceValid()); |
| 740 | 740 |
| 741 // Tear down the bridge on the thread so that 'bridge' can go out of scope | 741 // Tear down the bridge on the thread so that 'bridge' can go out of scope |
| 742 // without crashing due to thread checks | 742 // without crashing due to thread checks |
| 743 EXPECT_CALL(mockImageBuffer, resetCanvas(_)).Times(AnyNumber()); | 743 EXPECT_CALL(mockImageBuffer, resetCanvas(_)).Times(AnyNumber()); |
| 744 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); | 744 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); |
| 745 } | 745 } |
| 746 | 746 |
| 747 #if CANVAS2D_HIBERNATION_ENABLED | 747 #if CANVAS2D_HIBERNATION_ENABLED && CANVAS2D_BACKGROUND_RENDER_SWITCH_TO_CPU |
| 748 TEST_F(Canvas2DLayerBridgeTest, DisableDeferredRenderingWhileHibernating) | 748 TEST_F(Canvas2DLayerBridgeTest, DisableDeferredRenderingWhileHibernating) |
| 749 #else | 749 #else |
| 750 TEST_F(Canvas2DLayerBridgeTest, DISABLED_DisableDeferredRenderingWhileHibernatin
g) | 750 TEST_F(Canvas2DLayerBridgeTest, DISABLED_DisableDeferredRenderingWhileHibernatin
g) |
| 751 #endif | 751 #endif |
| 752 { | 752 { |
| 753 MockCanvasContext mainMock; | 753 MockCanvasContext mainMock; |
| 754 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); | 754 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); |
| 755 | 755 |
| 756 // The Canvas2DLayerBridge has to be created on the thread that will use it | 756 // The Canvas2DLayerBridge has to be created on the thread that will use it |
| 757 // to avoid WeakPtr thread check issues. | 757 // to avoid WeakPtr thread check issues. |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1045 WebExternalTextureMailbox mailbox; | 1045 WebExternalTextureMailbox mailbox; |
| 1046 EXPECT_FALSE(bridge->prepareMailbox(&mailbox, 0)); | 1046 EXPECT_FALSE(bridge->prepareMailbox(&mailbox, 0)); |
| 1047 EXPECT_TRUE(bridge->checkSurfaceValid()); | 1047 EXPECT_TRUE(bridge->checkSurfaceValid()); |
| 1048 | 1048 |
| 1049 // Tear down the bridge on the thread so that 'bridge' can go out of scope | 1049 // Tear down the bridge on the thread so that 'bridge' can go out of scope |
| 1050 // without crashing due to thread checks | 1050 // without crashing due to thread checks |
| 1051 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(Canvas2DLayerBridge::Hibe
rnationEndedWithTeardown)); | 1051 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(Canvas2DLayerBridge::Hibe
rnationEndedWithTeardown)); |
| 1052 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); | 1052 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); |
| 1053 } | 1053 } |
| 1054 | 1054 |
| 1055 #if CANVAS2D_HIBERNATION_ENABLED | 1055 #if CANVAS2D_HIBERNATION_ENABLED && CANVAS2D_BACKGROUND_RENDER_SWITCH_TO_CPU |
| 1056 TEST_F(Canvas2DLayerBridgeTest, PrepareMailboxWhileBackgroundRendering) | 1056 TEST_F(Canvas2DLayerBridgeTest, PrepareMailboxWhileBackgroundRendering) |
| 1057 #else | 1057 #else |
| 1058 TEST_F(Canvas2DLayerBridgeTest, DISABLED_PrepareMailboxWhileBackgroundRendering) | 1058 TEST_F(Canvas2DLayerBridgeTest, DISABLED_PrepareMailboxWhileBackgroundRendering) |
| 1059 #endif | 1059 #endif |
| 1060 { | 1060 { |
| 1061 MockCanvasContext mainMock; | 1061 MockCanvasContext mainMock; |
| 1062 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); | 1062 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); |
| 1063 | 1063 |
| 1064 // The Canvas2DLayerBridge has to be created on the thread that will use it | 1064 // The Canvas2DLayerBridge has to be created on the thread that will use it |
| 1065 // to avoid WeakPtr thread check issues. | 1065 // to avoid WeakPtr thread check issues. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1092 WebExternalTextureMailbox mailbox; | 1092 WebExternalTextureMailbox mailbox; |
| 1093 EXPECT_FALSE(bridge->prepareMailbox(&mailbox, 0)); | 1093 EXPECT_FALSE(bridge->prepareMailbox(&mailbox, 0)); |
| 1094 EXPECT_TRUE(bridge->checkSurfaceValid()); | 1094 EXPECT_TRUE(bridge->checkSurfaceValid()); |
| 1095 | 1095 |
| 1096 // Tear down the bridge on the thread so that 'bridge' can go out of scope | 1096 // Tear down the bridge on the thread so that 'bridge' can go out of scope |
| 1097 // without crashing due to thread checks | 1097 // without crashing due to thread checks |
| 1098 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); | 1098 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); |
| 1099 } | 1099 } |
| 1100 | 1100 |
| 1101 } // namespace blink | 1101 } // namespace blink |
| OLD | NEW |