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 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 { | 647 { |
648 OwnPtr<WaitableEvent> doneEvent = adoptPtr(new WaitableEvent()); | 648 OwnPtr<WaitableEvent> doneEvent = adoptPtr(new WaitableEvent()); |
649 testThread->getWebTaskRunner()->postTask( | 649 testThread->getWebTaskRunner()->postTask( |
650 location, | 650 location, |
651 threadSafeBind(&runRenderingTask, | 651 threadSafeBind(&runRenderingTask, |
652 AllowCrossThreadAccess(bridge), | 652 AllowCrossThreadAccess(bridge), |
653 AllowCrossThreadAccess(doneEvent.get()))); | 653 AllowCrossThreadAccess(doneEvent.get()))); |
654 doneEvent->wait(); | 654 doneEvent->wait(); |
655 } | 655 } |
656 | 656 |
657 #if CANVAS2D_HIBERNATION_ENABLED | 657 #if CANVAS2D_HIBERNATION_ENABLED && CANVAS2D_BACKGROUND_RENDER_SWITCH_TO_CPU |
658 TEST_F(Canvas2DLayerBridgeTest, BackgroundRenderingWhileHibernating) | 658 TEST_F(Canvas2DLayerBridgeTest, BackgroundRenderingWhileHibernating) |
659 #else | 659 #else |
660 TEST_F(Canvas2DLayerBridgeTest, DISABLED_BackgroundRenderingWhileHibernating) | 660 TEST_F(Canvas2DLayerBridgeTest, DISABLED_BackgroundRenderingWhileHibernating) |
661 #endif | 661 #endif |
662 { | 662 { |
663 MockCanvasContext mainMock; | 663 MockCanvasContext mainMock; |
664 MockGLES2Interface mockGL; | 664 MockGLES2Interface mockGL; |
665 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); | 665 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); |
666 | 666 |
667 // The Canvas2DLayerBridge has to be created on the thread that will use it | 667 // The Canvas2DLayerBridge has to be created on the thread that will use it |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 EXPECT_FALSE(bridge->isHibernating()); | 701 EXPECT_FALSE(bridge->isHibernating()); |
702 EXPECT_TRUE(bridge->checkSurfaceValid()); | 702 EXPECT_TRUE(bridge->checkSurfaceValid()); |
703 | 703 |
704 // Tear down the bridge on the thread so that 'bridge' can go out of scope | 704 // Tear down the bridge on the thread so that 'bridge' can go out of scope |
705 // without crashing due to thread checks | 705 // without crashing due to thread checks |
706 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); | 706 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); |
707 | 707 |
708 ::testing::Mock::VerifyAndClearExpectations(&mainMock); | 708 ::testing::Mock::VerifyAndClearExpectations(&mainMock); |
709 } | 709 } |
710 | 710 |
711 #if CANVAS2D_HIBERNATION_ENABLED | 711 #if CANVAS2D_HIBERNATION_ENABLED && CANVAS2D_BACKGROUND_RENDER_SWITCH_TO_CPU |
712 TEST_F(Canvas2DLayerBridgeTest, BackgroundRenderingWhileHibernatingWithDeferredR
enderingDisabled) | 712 TEST_F(Canvas2DLayerBridgeTest, BackgroundRenderingWhileHibernatingWithDeferredR
enderingDisabled) |
713 #else | 713 #else |
714 TEST_F(Canvas2DLayerBridgeTest, DISABLED_BackgroundRenderingWhileHibernatingWith
DeferredRenderingDisabled) | 714 TEST_F(Canvas2DLayerBridgeTest, DISABLED_BackgroundRenderingWhileHibernatingWith
DeferredRenderingDisabled) |
715 #endif | 715 #endif |
716 { | 716 { |
717 MockCanvasContext mainMock; | 717 MockCanvasContext mainMock; |
718 MockGLES2Interface mockGL; | 718 MockGLES2Interface mockGL; |
719 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); | 719 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); |
720 | 720 |
721 // The Canvas2DLayerBridge has to be created on the thread that will use it | 721 // The Canvas2DLayerBridge has to be created on the thread that will use it |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 EXPECT_TRUE(bridge->isAccelerated()); // Becoming visible causes switch back
to GPU | 763 EXPECT_TRUE(bridge->isAccelerated()); // Becoming visible causes switch back
to GPU |
764 EXPECT_FALSE(bridge->isHibernating()); | 764 EXPECT_FALSE(bridge->isHibernating()); |
765 EXPECT_TRUE(bridge->checkSurfaceValid()); | 765 EXPECT_TRUE(bridge->checkSurfaceValid()); |
766 | 766 |
767 // Tear down the bridge on the thread so that 'bridge' can go out of scope | 767 // Tear down the bridge on the thread so that 'bridge' can go out of scope |
768 // without crashing due to thread checks | 768 // without crashing due to thread checks |
769 EXPECT_CALL(mockImageBuffer, resetCanvas(_)).Times(AnyNumber()); | 769 EXPECT_CALL(mockImageBuffer, resetCanvas(_)).Times(AnyNumber()); |
770 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); | 770 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); |
771 } | 771 } |
772 | 772 |
773 #if CANVAS2D_HIBERNATION_ENABLED | 773 #if CANVAS2D_HIBERNATION_ENABLED && CANVAS2D_BACKGROUND_RENDER_SWITCH_TO_CPU |
774 TEST_F(Canvas2DLayerBridgeTest, DisableDeferredRenderingWhileHibernating) | 774 TEST_F(Canvas2DLayerBridgeTest, DisableDeferredRenderingWhileHibernating) |
775 #else | 775 #else |
776 TEST_F(Canvas2DLayerBridgeTest, DISABLED_DisableDeferredRenderingWhileHibernatin
g) | 776 TEST_F(Canvas2DLayerBridgeTest, DISABLED_DisableDeferredRenderingWhileHibernatin
g) |
777 #endif | 777 #endif |
778 { | 778 { |
779 MockCanvasContext mainMock; | 779 MockCanvasContext mainMock; |
780 MockGLES2Interface mockGL; | 780 MockGLES2Interface mockGL; |
781 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); | 781 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); |
782 | 782 |
783 // The Canvas2DLayerBridge has to be created on the thread that will use it | 783 // The Canvas2DLayerBridge has to be created on the thread that will use it |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1078 WebExternalTextureMailbox mailbox; | 1078 WebExternalTextureMailbox mailbox; |
1079 EXPECT_FALSE(bridge->prepareMailbox(&mailbox, 0)); | 1079 EXPECT_FALSE(bridge->prepareMailbox(&mailbox, 0)); |
1080 EXPECT_TRUE(bridge->checkSurfaceValid()); | 1080 EXPECT_TRUE(bridge->checkSurfaceValid()); |
1081 | 1081 |
1082 // Tear down the bridge on the thread so that 'bridge' can go out of scope | 1082 // Tear down the bridge on the thread so that 'bridge' can go out of scope |
1083 // without crashing due to thread checks | 1083 // without crashing due to thread checks |
1084 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(Canvas2DLayerBridge::Hibe
rnationEndedWithTeardown)); | 1084 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(Canvas2DLayerBridge::Hibe
rnationEndedWithTeardown)); |
1085 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); | 1085 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); |
1086 } | 1086 } |
1087 | 1087 |
1088 #if CANVAS2D_HIBERNATION_ENABLED | 1088 #if CANVAS2D_HIBERNATION_ENABLED && CANVAS2D_BACKGROUND_RENDER_SWITCH_TO_CPU |
1089 TEST_F(Canvas2DLayerBridgeTest, PrepareMailboxWhileBackgroundRendering) | 1089 TEST_F(Canvas2DLayerBridgeTest, PrepareMailboxWhileBackgroundRendering) |
1090 #else | 1090 #else |
1091 TEST_F(Canvas2DLayerBridgeTest, DISABLED_PrepareMailboxWhileBackgroundRendering) | 1091 TEST_F(Canvas2DLayerBridgeTest, DISABLED_PrepareMailboxWhileBackgroundRendering) |
1092 #endif | 1092 #endif |
1093 { | 1093 { |
1094 MockCanvasContext mainMock; | 1094 MockCanvasContext mainMock; |
1095 MockGLES2Interface mockGL; | 1095 MockGLES2Interface mockGL; |
1096 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); | 1096 OwnPtr<WebThread> testThread = adoptPtr(Platform::current()->createThread("T
estThread")); |
1097 | 1097 |
1098 // The Canvas2DLayerBridge has to be created on the thread that will use it | 1098 // The Canvas2DLayerBridge has to be created on the thread that will use it |
(...skipping 27 matching lines...) Expand all Loading... |
1126 WebExternalTextureMailbox mailbox; | 1126 WebExternalTextureMailbox mailbox; |
1127 EXPECT_FALSE(bridge->prepareMailbox(&mailbox, 0)); | 1127 EXPECT_FALSE(bridge->prepareMailbox(&mailbox, 0)); |
1128 EXPECT_TRUE(bridge->checkSurfaceValid()); | 1128 EXPECT_TRUE(bridge->checkSurfaceValid()); |
1129 | 1129 |
1130 // Tear down the bridge on the thread so that 'bridge' can go out of scope | 1130 // Tear down the bridge on the thread so that 'bridge' can go out of scope |
1131 // without crashing due to thread checks | 1131 // without crashing due to thread checks |
1132 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); | 1132 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); |
1133 } | 1133 } |
1134 | 1134 |
1135 } // namespace blink | 1135 } // namespace blink |
OLD | NEW |