| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 namespace { | 52 namespace { |
| 53 | 53 |
| 54 class CCLayerTreeHostImplTest : public testing::Test, public CCLayerTreeHostImpl
Client { | 54 class CCLayerTreeHostImplTest : public testing::Test, public CCLayerTreeHostImpl
Client { |
| 55 public: | 55 public: |
| 56 CCLayerTreeHostImplTest() | 56 CCLayerTreeHostImplTest() |
| 57 : m_didRequestCommit(false) | 57 : m_didRequestCommit(false) |
| 58 , m_didRequestRedraw(false) | 58 , m_didRequestRedraw(false) |
| 59 { | 59 { |
| 60 CCSettings settings; | 60 CCSettings settings; |
| 61 m_hostImpl = CCLayerTreeHostImpl::create(settings, this); | 61 m_hostImpl = CCLayerTreeHostImpl::create(settings, this); |
| 62 m_hostImpl->initializeLayerRenderer(createContext()); |
| 63 m_hostImpl->setViewportSize(IntSize(10, 10)); |
| 62 } | 64 } |
| 63 | 65 |
| 64 virtual void didLoseContextOnImplThread() OVERRIDE { } | 66 virtual void didLoseContextOnImplThread() OVERRIDE { } |
| 65 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { } | 67 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { } |
| 66 virtual void setNeedsRedrawOnImplThread() OVERRIDE { m_didRequestRedraw = tr
ue; } | 68 virtual void setNeedsRedrawOnImplThread() OVERRIDE { m_didRequestRedraw = tr
ue; } |
| 67 virtual void setNeedsCommitOnImplThread() OVERRIDE { m_didRequestCommit = tr
ue; } | 69 virtual void setNeedsCommitOnImplThread() OVERRIDE { m_didRequestCommit = tr
ue; } |
| 68 virtual void postAnimationEventsToMainThreadOnImplThread(PassOwnPtr<CCAnimat
ionEventsVector>, double wallClockTime) OVERRIDE { } | 70 virtual void postAnimationEventsToMainThreadOnImplThread(PassOwnPtr<CCAnimat
ionEventsVector>, double wallClockTime) OVERRIDE { } |
| 69 virtual void postSetContentsMemoryAllocationLimitBytesToMainThreadOnImplThre
ad(size_t) OVERRIDE { } | 71 virtual void postSetContentsMemoryAllocationLimitBytesToMainThreadOnImplThre
ad(size_t) OVERRIDE { } |
| 70 | 72 |
| 71 static void expectClearedScrollDeltasRecursive(CCLayerImpl* layer) | 73 static void expectClearedScrollDeltasRecursive(CCLayerImpl* layer) |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(75, 75), CCInputHandlerClient::Wh
eel), CCInputHandlerClient::ScrollStarted); | 249 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(75, 75), CCInputHandlerClient::Wh
eel), CCInputHandlerClient::ScrollStarted); |
| 248 m_hostImpl->scrollBy(IntSize(0, 10)); | 250 m_hostImpl->scrollBy(IntSize(0, 10)); |
| 249 m_hostImpl->scrollEnd(); | 251 m_hostImpl->scrollEnd(); |
| 250 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(75, 75), CCInputHandlerClient::Ge
sture), CCInputHandlerClient::ScrollStarted); | 252 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(75, 75), CCInputHandlerClient::Ge
sture), CCInputHandlerClient::ScrollStarted); |
| 251 m_hostImpl->scrollBy(IntSize(0, 10)); | 253 m_hostImpl->scrollBy(IntSize(0, 10)); |
| 252 m_hostImpl->scrollEnd(); | 254 m_hostImpl->scrollEnd(); |
| 253 } | 255 } |
| 254 | 256 |
| 255 TEST_F(CCLayerTreeHostImplTest, nonFastScrollableRegionWithOffset) | 257 TEST_F(CCLayerTreeHostImplTest, nonFastScrollableRegionWithOffset) |
| 256 { | 258 { |
| 257 m_hostImpl->initializeLayerRenderer(createContext()); | |
| 258 | |
| 259 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(0); | 259 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(0); |
| 260 root->setScrollable(true); | 260 root->setScrollable(true); |
| 261 root->setScrollPosition(IntPoint(0, 0)); | 261 root->setScrollPosition(IntPoint(0, 0)); |
| 262 root->setMaxScrollPosition(IntSize(100, 100)); | 262 root->setMaxScrollPosition(IntSize(100, 100)); |
| 263 root->setNonFastScrollableRegion(IntRect(0, 0, 50, 50)); | 263 root->setNonFastScrollableRegion(IntRect(0, 0, 50, 50)); |
| 264 root->setPosition(FloatPoint(-25, 0)); | 264 root->setPosition(FloatPoint(-25, 0)); |
| 265 m_hostImpl->setRootLayer(root.release()); | 265 m_hostImpl->setRootLayer(root.release()); |
| 266 CCLayerTreeHostImpl::FrameData frame; | 266 CCLayerTreeHostImpl::FrameData frame; |
| 267 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 267 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 268 m_hostImpl->drawLayers(frame); // Update draw transforms so we can correctly
map points into layer space. | 268 m_hostImpl->drawLayers(frame); // Update draw transforms so we can correctly
map points into layer space. |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 setDrawsContent(true); | 433 setDrawsContent(true); |
| 434 } | 434 } |
| 435 | 435 |
| 436 private: | 436 private: |
| 437 bool m_didDrawCalled; | 437 bool m_didDrawCalled; |
| 438 bool m_willDrawCalled; | 438 bool m_willDrawCalled; |
| 439 }; | 439 }; |
| 440 | 440 |
| 441 TEST_F(CCLayerTreeHostImplTest, didDrawNotCalledOnHiddenLayer) | 441 TEST_F(CCLayerTreeHostImplTest, didDrawNotCalledOnHiddenLayer) |
| 442 { | 442 { |
| 443 m_hostImpl->initializeLayerRenderer(createContext()); | 443 // The root layer is always drawn, so run this test on a child layer that |
| 444 | 444 // will be masked out by the root layer's bounds. |
| 445 // Ensure visibleLayerRect for root layer is empty | |
| 446 m_hostImpl->setViewportSize(IntSize(0, 0)); | |
| 447 | |
| 448 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(0)); | 445 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(0)); |
| 449 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); | 446 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); |
| 447 root->setMasksToBounds(true); |
| 448 |
| 449 root->addChild(DidDrawCheckLayer::create(1)); |
| 450 DidDrawCheckLayer* layer = static_cast<DidDrawCheckLayer*>(root->children()[
0].get()); |
| 451 // Ensure visibleLayerRect for layer is empty |
| 452 layer->setPosition(FloatPoint(100, 100)); |
| 453 layer->setBounds(IntSize(10, 10)); |
| 454 layer->setContentBounds(IntSize(10, 10)); |
| 450 | 455 |
| 451 CCLayerTreeHostImpl::FrameData frame; | 456 CCLayerTreeHostImpl::FrameData frame; |
| 452 | 457 |
| 453 EXPECT_FALSE(root->willDrawCalled()); | 458 EXPECT_FALSE(layer->willDrawCalled()); |
| 454 EXPECT_FALSE(root->didDrawCalled()); | 459 EXPECT_FALSE(layer->didDrawCalled()); |
| 455 | 460 |
| 456 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 461 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 457 m_hostImpl->drawLayers(frame); | 462 m_hostImpl->drawLayers(frame); |
| 458 m_hostImpl->didDrawAllLayers(frame); | 463 m_hostImpl->didDrawAllLayers(frame); |
| 459 | 464 |
| 460 EXPECT_FALSE(root->willDrawCalled()); | 465 EXPECT_FALSE(layer->willDrawCalled()); |
| 461 EXPECT_FALSE(root->didDrawCalled()); | 466 EXPECT_FALSE(layer->didDrawCalled()); |
| 462 | 467 |
| 463 EXPECT_TRUE(root->visibleLayerRect().isEmpty()); | 468 EXPECT_TRUE(layer->visibleLayerRect().isEmpty()); |
| 464 | 469 |
| 465 // Ensure visibleLayerRect for root layer is not empty | 470 // Ensure visibleLayerRect for layer layer is not empty |
| 466 m_hostImpl->setViewportSize(IntSize(10, 10)); | 471 layer->setPosition(FloatPoint(0, 0)); |
| 467 | 472 |
| 468 EXPECT_FALSE(root->willDrawCalled()); | 473 EXPECT_FALSE(layer->willDrawCalled()); |
| 469 EXPECT_FALSE(root->didDrawCalled()); | 474 EXPECT_FALSE(layer->didDrawCalled()); |
| 470 | 475 |
| 471 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 476 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 472 m_hostImpl->drawLayers(frame); | 477 m_hostImpl->drawLayers(frame); |
| 473 m_hostImpl->didDrawAllLayers(frame); | 478 m_hostImpl->didDrawAllLayers(frame); |
| 474 | 479 |
| 475 EXPECT_TRUE(root->willDrawCalled()); | 480 EXPECT_TRUE(layer->willDrawCalled()); |
| 476 EXPECT_TRUE(root->didDrawCalled()); | 481 EXPECT_TRUE(layer->didDrawCalled()); |
| 477 | 482 |
| 478 EXPECT_FALSE(root->visibleLayerRect().isEmpty()); | 483 EXPECT_FALSE(layer->visibleLayerRect().isEmpty()); |
| 479 } | 484 } |
| 480 | 485 |
| 481 TEST_F(CCLayerTreeHostImplTest, didDrawCalledOnAllLayers) | 486 TEST_F(CCLayerTreeHostImplTest, didDrawCalledOnAllLayers) |
| 482 { | 487 { |
| 483 m_hostImpl->initializeLayerRenderer(createContext()); | |
| 484 m_hostImpl->setViewportSize(IntSize(10, 10)); | |
| 485 | |
| 486 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(0)); | 488 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(0)); |
| 487 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); | 489 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); |
| 488 | 490 |
| 489 root->addChild(DidDrawCheckLayer::create(1)); | 491 root->addChild(DidDrawCheckLayer::create(1)); |
| 490 DidDrawCheckLayer* layer1 = static_cast<DidDrawCheckLayer*>(root->children()
[0].get()); | 492 DidDrawCheckLayer* layer1 = static_cast<DidDrawCheckLayer*>(root->children()
[0].get()); |
| 491 | 493 |
| 492 layer1->addChild(DidDrawCheckLayer::create(2)); | 494 layer1->addChild(DidDrawCheckLayer::create(2)); |
| 493 DidDrawCheckLayer* layer2 = static_cast<DidDrawCheckLayer*>(layer1->children
()[0].get()); | 495 DidDrawCheckLayer* layer2 = static_cast<DidDrawCheckLayer*>(layer1->children
()[0].get()); |
| 494 | 496 |
| 495 layer1->setOpacity(0.3f); | 497 layer1->setOpacity(0.3f); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 526 setSkipsDraw(skipsDraw); | 528 setSkipsDraw(skipsDraw); |
| 527 if (!tileMissing) | 529 if (!tileMissing) |
| 528 pushTileProperties(0, 0, 1, IntRect()); | 530 pushTileProperties(0, 0, 1, IntRect()); |
| 529 if (animating) | 531 if (animating) |
| 530 addAnimatedTransformToLayer(*this, 10, 3, 0); | 532 addAnimatedTransformToLayer(*this, 10, 3, 0); |
| 531 } | 533 } |
| 532 }; | 534 }; |
| 533 | 535 |
| 534 TEST_F(CCLayerTreeHostImplTest, prepareToDrawFailsWhenAnimationUsesCheckerboard) | 536 TEST_F(CCLayerTreeHostImplTest, prepareToDrawFailsWhenAnimationUsesCheckerboard) |
| 535 { | 537 { |
| 536 m_hostImpl->initializeLayerRenderer(createContext()); | |
| 537 m_hostImpl->setViewportSize(IntSize(10, 10)); | |
| 538 | |
| 539 // When the texture is not missing, we draw as usual. | 538 // When the texture is not missing, we draw as usual. |
| 540 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(0)); | 539 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(0)); |
| 541 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); | 540 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); |
| 542 root->addChild(MissingTextureAnimatingLayer::create(1, false, false, true)); | 541 root->addChild(MissingTextureAnimatingLayer::create(1, false, false, true)); |
| 543 | 542 |
| 544 CCLayerTreeHostImpl::FrameData frame; | 543 CCLayerTreeHostImpl::FrameData frame; |
| 545 | 544 |
| 546 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 545 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 547 m_hostImpl->drawLayers(frame); | 546 m_hostImpl->drawLayers(frame); |
| 548 m_hostImpl->didDrawAllLayers(frame); | 547 m_hostImpl->didDrawAllLayers(frame); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 bool m_quadsAppended; | 652 bool m_quadsAppended; |
| 654 bool m_opaqueContents; | 653 bool m_opaqueContents; |
| 655 IntRect m_quadRect; | 654 IntRect m_quadRect; |
| 656 IntRect m_opaqueContentRect; | 655 IntRect m_opaqueContentRect; |
| 657 IntRect m_quadVisibleRect; | 656 IntRect m_quadVisibleRect; |
| 658 }; | 657 }; |
| 659 | 658 |
| 660 // https://bugs.webkit.org/show_bug.cgi?id=75783 | 659 // https://bugs.webkit.org/show_bug.cgi?id=75783 |
| 661 TEST_F(CCLayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers) | 660 TEST_F(CCLayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers) |
| 662 { | 661 { |
| 663 m_hostImpl->initializeLayerRenderer(createContext()); | |
| 664 m_hostImpl->setViewportSize(IntSize(10, 10)); | |
| 665 | |
| 666 { | 662 { |
| 667 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(0); | 663 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(0); |
| 668 root->setAnchorPoint(FloatPoint(0, 0)); | 664 root->setAnchorPoint(FloatPoint(0, 0)); |
| 669 root->setBounds(IntSize(10, 10)); | 665 root->setBounds(IntSize(10, 10)); |
| 670 root->setDrawsContent(false); | 666 root->setDrawsContent(false); |
| 671 m_hostImpl->setRootLayer(root.release()); | 667 m_hostImpl->setRootLayer(root.release()); |
| 672 } | 668 } |
| 673 CCLayerImpl* root = m_hostImpl->rootLayer(); | 669 CCLayerImpl* root = m_hostImpl->rootLayer(); |
| 674 | 670 |
| 675 root->addChild(BlendStateCheckLayer::create(1)); | 671 root->addChild(BlendStateCheckLayer::create(1)); |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 layer1->setExpectation(false, false); | 867 layer1->setExpectation(false, false); |
| 872 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 868 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 873 m_hostImpl->drawLayers(frame); | 869 m_hostImpl->drawLayers(frame); |
| 874 EXPECT_TRUE(layer1->quadsAppended()); | 870 EXPECT_TRUE(layer1->quadsAppended()); |
| 875 m_hostImpl->didDrawAllLayers(frame); | 871 m_hostImpl->didDrawAllLayers(frame); |
| 876 | 872 |
| 877 } | 873 } |
| 878 | 874 |
| 879 TEST_F(CCLayerTreeHostImplTest, viewportCovered) | 875 TEST_F(CCLayerTreeHostImplTest, viewportCovered) |
| 880 { | 876 { |
| 881 m_hostImpl->initializeLayerRenderer(createContext()); | |
| 882 m_hostImpl->setBackgroundColor(Color::gray); | 877 m_hostImpl->setBackgroundColor(Color::gray); |
| 883 | 878 |
| 884 IntSize viewportSize(1000, 1000); | 879 IntSize viewportSize(1000, 1000); |
| 885 m_hostImpl->setViewportSize(viewportSize); | 880 m_hostImpl->setViewportSize(viewportSize); |
| 886 | 881 |
| 887 m_hostImpl->setRootLayer(BlendStateCheckLayer::create(0)); | 882 m_hostImpl->setRootLayer(BlendStateCheckLayer::create(0)); |
| 888 BlendStateCheckLayer* root = static_cast<BlendStateCheckLayer*>(m_hostImpl->
rootLayer()); | 883 BlendStateCheckLayer* root = static_cast<BlendStateCheckLayer*>(m_hostImpl->
rootLayer()); |
| 889 root->setExpectation(false, true); | 884 root->setExpectation(false, true); |
| 890 root->setOpaque(true); | 885 root->setOpaque(true); |
| 891 | 886 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 983 }; | 978 }; |
| 984 | 979 |
| 985 // Only reshape when we know we are going to draw. Otherwise, the reshape | 980 // Only reshape when we know we are going to draw. Otherwise, the reshape |
| 986 // can leave the window at the wrong size if we never draw and the proper | 981 // can leave the window at the wrong size if we never draw and the proper |
| 987 // viewport size is never set. | 982 // viewport size is never set. |
| 988 TEST_F(CCLayerTreeHostImplTest, reshapeNotCalledUntilDraw) | 983 TEST_F(CCLayerTreeHostImplTest, reshapeNotCalledUntilDraw) |
| 989 { | 984 { |
| 990 ReshapeTrackerContext* reshapeTracker = new ReshapeTrackerContext(); | 985 ReshapeTrackerContext* reshapeTracker = new ReshapeTrackerContext(); |
| 991 RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphics
ContextFromWebContext(adoptPtr(reshapeTracker), GraphicsContext3D::RenderDirectl
yToHostWindow); | 986 RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphics
ContextFromWebContext(adoptPtr(reshapeTracker), GraphicsContext3D::RenderDirectl
yToHostWindow); |
| 992 m_hostImpl->initializeLayerRenderer(context); | 987 m_hostImpl->initializeLayerRenderer(context); |
| 993 m_hostImpl->setViewportSize(IntSize(10, 10)); | |
| 994 | 988 |
| 995 CCLayerImpl* root = new FakeDrawableCCLayerImpl(1); | 989 CCLayerImpl* root = new FakeDrawableCCLayerImpl(1); |
| 996 root->setAnchorPoint(FloatPoint(0, 0)); | 990 root->setAnchorPoint(FloatPoint(0, 0)); |
| 997 root->setBounds(IntSize(10, 10)); | 991 root->setBounds(IntSize(10, 10)); |
| 998 root->setDrawsContent(true); | 992 root->setDrawsContent(true); |
| 999 m_hostImpl->setRootLayer(adoptPtr(root)); | 993 m_hostImpl->setRootLayer(adoptPtr(root)); |
| 1000 EXPECT_FALSE(reshapeTracker->reshapeCalled()); | 994 EXPECT_FALSE(reshapeTracker->reshapeCalled()); |
| 1001 | 995 |
| 1002 CCLayerTreeHostImpl::FrameData frame; | 996 CCLayerTreeHostImpl::FrameData frame; |
| 1003 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 997 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1118 : CCLayerImpl(id) | 1112 : CCLayerImpl(id) |
| 1119 , m_didLoseContextCalled(false) | 1113 , m_didLoseContextCalled(false) |
| 1120 { | 1114 { |
| 1121 } | 1115 } |
| 1122 | 1116 |
| 1123 bool m_didLoseContextCalled; | 1117 bool m_didLoseContextCalled; |
| 1124 }; | 1118 }; |
| 1125 | 1119 |
| 1126 TEST_F(CCLayerTreeHostImplTest, contextLostAndRestoredNotificationSentToAllLayer
s) | 1120 TEST_F(CCLayerTreeHostImplTest, contextLostAndRestoredNotificationSentToAllLayer
s) |
| 1127 { | 1121 { |
| 1128 m_hostImpl->initializeLayerRenderer(createContext()); | |
| 1129 m_hostImpl->setViewportSize(IntSize(10, 10)); | |
| 1130 | |
| 1131 m_hostImpl->setRootLayer(ContextLostNotificationCheckLayer::create(0)); | 1122 m_hostImpl->setRootLayer(ContextLostNotificationCheckLayer::create(0)); |
| 1132 ContextLostNotificationCheckLayer* root = static_cast<ContextLostNotificatio
nCheckLayer*>(m_hostImpl->rootLayer()); | 1123 ContextLostNotificationCheckLayer* root = static_cast<ContextLostNotificatio
nCheckLayer*>(m_hostImpl->rootLayer()); |
| 1133 | 1124 |
| 1134 root->addChild(ContextLostNotificationCheckLayer::create(1)); | 1125 root->addChild(ContextLostNotificationCheckLayer::create(1)); |
| 1135 ContextLostNotificationCheckLayer* layer1 = static_cast<ContextLostNotificat
ionCheckLayer*>(root->children()[0].get()); | 1126 ContextLostNotificationCheckLayer* layer1 = static_cast<ContextLostNotificat
ionCheckLayer*>(root->children()[0].get()); |
| 1136 | 1127 |
| 1137 layer1->addChild(ContextLostNotificationCheckLayer::create(2)); | 1128 layer1->addChild(ContextLostNotificationCheckLayer::create(2)); |
| 1138 ContextLostNotificationCheckLayer* layer2 = static_cast<ContextLostNotificat
ionCheckLayer*>(layer1->children()[0].get()); | 1129 ContextLostNotificationCheckLayer* layer2 = static_cast<ContextLostNotificat
ionCheckLayer*>(layer1->children()[0].get()); |
| 1139 | 1130 |
| 1140 EXPECT_FALSE(root->didLoseContextCalled()); | 1131 EXPECT_FALSE(root->didLoseContextCalled()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1165 static PassOwnPtr<ScrollbarLayerFakePaint> create(int id) { return adoptPtr(
new ScrollbarLayerFakePaint(id)); } | 1156 static PassOwnPtr<ScrollbarLayerFakePaint> create(int id) { return adoptPtr(
new ScrollbarLayerFakePaint(id)); } |
| 1166 | 1157 |
| 1167 virtual void paint(GraphicsContext*) { } | 1158 virtual void paint(GraphicsContext*) { } |
| 1168 | 1159 |
| 1169 private: | 1160 private: |
| 1170 ScrollbarLayerFakePaint(int id) : CCScrollbarLayerImpl(id) { } | 1161 ScrollbarLayerFakePaint(int id) : CCScrollbarLayerImpl(id) { } |
| 1171 }; | 1162 }; |
| 1172 | 1163 |
| 1173 TEST_F(CCLayerTreeHostImplTest, scrollbarLayerLostContext) | 1164 TEST_F(CCLayerTreeHostImplTest, scrollbarLayerLostContext) |
| 1174 { | 1165 { |
| 1175 m_hostImpl->initializeLayerRenderer(createContext()); | |
| 1176 m_hostImpl->setViewportSize(IntSize(10, 10)); | |
| 1177 | |
| 1178 m_hostImpl->setRootLayer(ScrollbarLayerFakePaint::create(0)); | 1166 m_hostImpl->setRootLayer(ScrollbarLayerFakePaint::create(0)); |
| 1179 ScrollbarLayerFakePaint* scrollbar = static_cast<ScrollbarLayerFakePaint*>(m
_hostImpl->rootLayer()); | 1167 ScrollbarLayerFakePaint* scrollbar = static_cast<ScrollbarLayerFakePaint*>(m
_hostImpl->rootLayer()); |
| 1180 scrollbar->setBounds(IntSize(1, 1)); | 1168 scrollbar->setBounds(IntSize(1, 1)); |
| 1181 scrollbar->setContentBounds(IntSize(1, 1)); | 1169 scrollbar->setContentBounds(IntSize(1, 1)); |
| 1182 scrollbar->setDrawsContent(true); | 1170 scrollbar->setDrawsContent(true); |
| 1183 | 1171 |
| 1184 for (int i = 0; i < 2; ++i) { | 1172 for (int i = 0; i < 2; ++i) { |
| 1185 CCLayerTreeHostImpl::FrameData frame; | 1173 CCLayerTreeHostImpl::FrameData frame; |
| 1186 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1174 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 1187 ASSERT(frame.renderPasses.size() == 1); | 1175 ASSERT(frame.renderPasses.size() == 1); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1315 virtual WebVideoFrame* getCurrentFrame() { return &m_frame; } | 1303 virtual WebVideoFrame* getCurrentFrame() { return &m_frame; } |
| 1316 virtual void putCurrentFrame(WebVideoFrame*) { } | 1304 virtual void putCurrentFrame(WebVideoFrame*) { } |
| 1317 | 1305 |
| 1318 private: | 1306 private: |
| 1319 FakeVideoFrame m_frame; | 1307 FakeVideoFrame m_frame; |
| 1320 Client* m_client; | 1308 Client* m_client; |
| 1321 }; | 1309 }; |
| 1322 | 1310 |
| 1323 TEST_F(CCLayerTreeHostImplTest, dontUseOldResourcesAfterLostContext) | 1311 TEST_F(CCLayerTreeHostImplTest, dontUseOldResourcesAfterLostContext) |
| 1324 { | 1312 { |
| 1325 m_hostImpl->initializeLayerRenderer(createContext()); | |
| 1326 m_hostImpl->setViewportSize(IntSize(10, 10)); | |
| 1327 | |
| 1328 OwnPtr<CCLayerImpl> rootLayer(CCLayerImpl::create(0)); | 1313 OwnPtr<CCLayerImpl> rootLayer(CCLayerImpl::create(0)); |
| 1329 rootLayer->setBounds(IntSize(10, 10)); | 1314 rootLayer->setBounds(IntSize(10, 10)); |
| 1330 rootLayer->setAnchorPoint(FloatPoint(0, 0)); | 1315 rootLayer->setAnchorPoint(FloatPoint(0, 0)); |
| 1331 | 1316 |
| 1332 OwnPtr<CCTiledLayerImpl> tileLayer = CCTiledLayerImpl::create(1); | 1317 OwnPtr<CCTiledLayerImpl> tileLayer = CCTiledLayerImpl::create(1); |
| 1333 tileLayer->setBounds(IntSize(10, 10)); | 1318 tileLayer->setBounds(IntSize(10, 10)); |
| 1334 tileLayer->setAnchorPoint(FloatPoint(0, 0)); | 1319 tileLayer->setAnchorPoint(FloatPoint(0, 0)); |
| 1335 tileLayer->setContentBounds(IntSize(10, 10)); | 1320 tileLayer->setContentBounds(IntSize(10, 10)); |
| 1336 tileLayer->setDrawsContent(true); | 1321 tileLayer->setDrawsContent(true); |
| 1337 tileLayer->setSkipsDraw(false); | 1322 tileLayer->setSkipsDraw(false); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1368 // Lose the context, replacing it with a StrictWebGraphicsContext3D, that | 1353 // Lose the context, replacing it with a StrictWebGraphicsContext3D, that |
| 1369 // will warn if any resource from the previous context gets used. | 1354 // will warn if any resource from the previous context gets used. |
| 1370 m_hostImpl->initializeLayerRenderer(StrictWebGraphicsContext3D::createGraphi
csContext()); | 1355 m_hostImpl->initializeLayerRenderer(StrictWebGraphicsContext3D::createGraphi
csContext()); |
| 1371 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1356 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 1372 m_hostImpl->drawLayers(frame); | 1357 m_hostImpl->drawLayers(frame); |
| 1373 m_hostImpl->didDrawAllLayers(frame); | 1358 m_hostImpl->didDrawAllLayers(frame); |
| 1374 m_hostImpl->swapBuffers(); | 1359 m_hostImpl->swapBuffers(); |
| 1375 } | 1360 } |
| 1376 | 1361 |
| 1377 } // namespace | 1362 } // namespace |
| OLD | NEW |