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 10 matching lines...) Expand all Loading... |
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
23 */ | 23 */ |
24 | 24 |
25 #include "config.h" | 25 #include "config.h" |
26 | 26 |
27 #include "cc/CCLayerTreeHostImpl.h" | 27 #include "cc/CCLayerTreeHostImpl.h" |
28 #include "cc/CCQuadCuller.h" | 28 #include "cc/CCQuadCuller.h" |
29 | 29 |
30 #include "CCAnimationTestCommon.h" | 30 #include "CCAnimationTestCommon.h" |
| 31 #include "CCLayerTestCommon.h" |
31 #include "FakeWebGraphicsContext3D.h" | 32 #include "FakeWebGraphicsContext3D.h" |
32 #include "GraphicsContext3DPrivate.h" | 33 #include "GraphicsContext3DPrivate.h" |
33 #include "LayerRendererChromium.h" | 34 #include "LayerRendererChromium.h" |
34 #include "cc/CCLayerImpl.h" | 35 #include "cc/CCLayerImpl.h" |
35 #include "cc/CCScrollbarLayerImpl.h" | 36 #include "cc/CCScrollbarLayerImpl.h" |
36 #include "cc/CCSingleThreadProxy.h" | 37 #include "cc/CCSingleThreadProxy.h" |
37 #include "cc/CCTileDrawQuad.h" | 38 #include "cc/CCTileDrawQuad.h" |
38 #include <gtest/gtest.h> | 39 #include <gtest/gtest.h> |
39 | 40 |
| 41 using namespace CCLayerTestCommon; |
40 using namespace WebCore; | 42 using namespace WebCore; |
41 using namespace WebKit; | 43 using namespace WebKit; |
42 using namespace WebKitTests; | 44 using namespace WebKitTests; |
43 | 45 |
44 namespace { | 46 namespace { |
45 | 47 |
46 class CCLayerTreeHostImplTest : public testing::Test, public CCLayerTreeHostImpl
Client { | 48 class CCLayerTreeHostImplTest : public testing::Test, public CCLayerTreeHostImpl
Client { |
47 public: | 49 public: |
48 CCLayerTreeHostImplTest() | 50 CCLayerTreeHostImplTest() |
49 : m_didRequestCommit(false) | 51 : m_didRequestCommit(false) |
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 | 593 |
592 IntRect opaqueRect; | 594 IntRect opaqueRect; |
593 if (opaque() || m_opaqueContents) | 595 if (opaque() || m_opaqueContents) |
594 opaqueRect = m_quadRect; | 596 opaqueRect = m_quadRect; |
595 else | 597 else |
596 opaqueRect = m_opaqueContentRect; | 598 opaqueRect = m_opaqueContentRect; |
597 OwnPtr<CCDrawQuad> testBlendingDrawQuad = CCTileDrawQuad::create(sharedQ
uadState, m_quadRect, opaqueRect, 0, IntPoint(), IntSize(1, 1), 0, false, false,
false, false, false); | 599 OwnPtr<CCDrawQuad> testBlendingDrawQuad = CCTileDrawQuad::create(sharedQ
uadState, m_quadRect, opaqueRect, 0, IntPoint(), IntSize(1, 1), 0, false, false,
false, false, false); |
598 testBlendingDrawQuad->setQuadVisibleRect(m_quadVisibleRect); | 600 testBlendingDrawQuad->setQuadVisibleRect(m_quadVisibleRect); |
599 EXPECT_EQ(m_blend, testBlendingDrawQuad->needsBlending()); | 601 EXPECT_EQ(m_blend, testBlendingDrawQuad->needsBlending()); |
600 EXPECT_EQ(m_hasRenderSurface, !!renderSurface()); | 602 EXPECT_EQ(m_hasRenderSurface, !!renderSurface()); |
| 603 quadList.append(testBlendingDrawQuad.release()); |
601 } | 604 } |
602 | 605 |
603 void setExpectation(bool blend, bool hasRenderSurface) | 606 void setExpectation(bool blend, bool hasRenderSurface) |
604 { | 607 { |
605 m_blend = blend; | 608 m_blend = blend; |
606 m_hasRenderSurface = hasRenderSurface; | 609 m_hasRenderSurface = hasRenderSurface; |
607 m_quadsAppended = false; | 610 m_quadsAppended = false; |
608 } | 611 } |
609 | 612 |
610 bool quadsAppended() const { return m_quadsAppended; } | 613 bool quadsAppended() const { return m_quadsAppended; } |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 layer1->setQuadVisibleRect(IntRect(5, 5, 2, 5)); | 837 layer1->setQuadVisibleRect(IntRect(5, 5, 2, 5)); |
835 layer1->setOpaqueContents(false); | 838 layer1->setOpaqueContents(false); |
836 layer1->setOpaqueContentRect(IntRect(5, 5, 2, 5)); | 839 layer1->setOpaqueContentRect(IntRect(5, 5, 2, 5)); |
837 layer1->setExpectation(false, false); | 840 layer1->setExpectation(false, false); |
838 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 841 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
839 m_hostImpl->drawLayers(frame); | 842 m_hostImpl->drawLayers(frame); |
840 EXPECT_TRUE(layer1->quadsAppended()); | 843 EXPECT_TRUE(layer1->quadsAppended()); |
841 | 844 |
842 } | 845 } |
843 | 846 |
| 847 TEST_F(CCLayerTreeHostImplTest, viewportCovered) |
| 848 { |
| 849 m_hostImpl->initializeLayerRenderer(createContext()); |
| 850 m_hostImpl->setBackgroundColor(Color::gray); |
| 851 |
| 852 IntSize viewportSize(100, 100); |
| 853 m_hostImpl->setViewportSize(viewportSize); |
| 854 |
| 855 m_hostImpl->setRootLayer(BlendStateCheckLayer::create(0)); |
| 856 BlendStateCheckLayer* root = static_cast<BlendStateCheckLayer*>(m_hostImpl->
rootLayer()); |
| 857 root->setExpectation(false, true); |
| 858 root->setOpaque(true); |
| 859 |
| 860 // No gutter rects |
| 861 { |
| 862 IntRect layerRect(0, 0, 100, 100); |
| 863 root->setPosition(layerRect.location()); |
| 864 root->setBounds(layerRect.size()); |
| 865 root->setContentBounds(layerRect.size()); |
| 866 root->setQuadRect(IntRect(IntPoint(), layerRect.size())); |
| 867 root->setQuadVisibleRect(IntRect(IntPoint(), layerRect.size())); |
| 868 |
| 869 CCLayerTreeHostImpl::FrameData frame; |
| 870 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 871 ASSERT_EQ(1u, frame.renderPasses.size()); |
| 872 |
| 873 size_t numGutterQuads = 0; |
| 874 for (size_t i = 0; i < frame.renderPasses[0]->quadList().size(); ++i) |
| 875 numGutterQuads += (frame.renderPasses[0]->quadList()[i]->material()
== CCDrawQuad::SolidColor) ? 1 : 0; |
| 876 EXPECT_EQ(0u, numGutterQuads); |
| 877 EXPECT_EQ(1u, frame.renderPasses[0]->quadList().size()); |
| 878 |
| 879 verifyQuadsExactlyCoverRect(frame.renderPasses[0]->quadList(), IntRect(-
layerRect.location(), viewportSize)); |
| 880 } |
| 881 |
| 882 // Empty visible content area (fullscreen gutter rect) |
| 883 { |
| 884 IntRect layerRect(0, 0, 0, 0); |
| 885 root->setPosition(layerRect.location()); |
| 886 root->setBounds(layerRect.size()); |
| 887 root->setContentBounds(layerRect.size()); |
| 888 root->setQuadRect(IntRect(IntPoint(), layerRect.size())); |
| 889 root->setQuadVisibleRect(IntRect(IntPoint(), layerRect.size())); |
| 890 |
| 891 CCLayerTreeHostImpl::FrameData frame; |
| 892 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 893 ASSERT_EQ(1u, frame.renderPasses.size()); |
| 894 |
| 895 size_t numGutterQuads = 0; |
| 896 for (size_t i = 0; i < frame.renderPasses[0]->quadList().size(); ++i) |
| 897 numGutterQuads += (frame.renderPasses[0]->quadList()[i]->material()
== CCDrawQuad::SolidColor) ? 1 : 0; |
| 898 EXPECT_EQ(1u, numGutterQuads); |
| 899 EXPECT_EQ(1u, frame.renderPasses[0]->quadList().size()); |
| 900 |
| 901 verifyQuadsExactlyCoverRect(frame.renderPasses[0]->quadList(), IntRect(-
layerRect.location(), viewportSize)); |
| 902 } |
| 903 |
| 904 // Content area in middle of clip rect (four surrounding gutter rects) |
| 905 { |
| 906 IntRect layerRect(50, 50, 20, 20); |
| 907 root->setPosition(layerRect.location()); |
| 908 root->setBounds(layerRect.size()); |
| 909 root->setContentBounds(layerRect.size()); |
| 910 root->setQuadRect(IntRect(IntPoint(), layerRect.size())); |
| 911 root->setQuadVisibleRect(IntRect(IntPoint(), layerRect.size())); |
| 912 |
| 913 CCLayerTreeHostImpl::FrameData frame; |
| 914 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 915 ASSERT_EQ(1u, frame.renderPasses.size()); |
| 916 |
| 917 size_t numGutterQuads = 0; |
| 918 for (size_t i = 0; i < frame.renderPasses[0]->quadList().size(); ++i) |
| 919 numGutterQuads += (frame.renderPasses[0]->quadList()[i]->material()
== CCDrawQuad::SolidColor) ? 1 : 0; |
| 920 EXPECT_EQ(4u, numGutterQuads); |
| 921 EXPECT_EQ(5u, frame.renderPasses[0]->quadList().size()); |
| 922 |
| 923 verifyQuadsExactlyCoverRect(frame.renderPasses[0]->quadList(), IntRect(-
layerRect.location(), viewportSize)); |
| 924 } |
| 925 |
| 926 } |
| 927 |
| 928 |
844 class ReshapeTrackerContext: public FakeWebGraphicsContext3D { | 929 class ReshapeTrackerContext: public FakeWebGraphicsContext3D { |
845 public: | 930 public: |
846 ReshapeTrackerContext() : m_reshapeCalled(false) { } | 931 ReshapeTrackerContext() : m_reshapeCalled(false) { } |
847 | 932 |
848 virtual void reshape(int width, int height) | 933 virtual void reshape(int width, int height) |
849 { | 934 { |
850 m_reshapeCalled = true; | 935 m_reshapeCalled = true; |
851 } | 936 } |
852 | 937 |
853 bool reshapeCalled() const { return m_reshapeCalled; } | 938 bool reshapeCalled() const { return m_reshapeCalled; } |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1062 ASSERT(frame.renderPasses.size() == 1); | 1147 ASSERT(frame.renderPasses.size() == 1); |
1063 CCRenderPass* renderPass = frame.renderPasses[0].get(); | 1148 CCRenderPass* renderPass = frame.renderPasses[0].get(); |
1064 // Scrollbar layer should always generate quads, even after lost context | 1149 // Scrollbar layer should always generate quads, even after lost context |
1065 EXPECT_GT(renderPass->quadList().size(), 0u); | 1150 EXPECT_GT(renderPass->quadList().size(), 0u); |
1066 | 1151 |
1067 m_hostImpl->initializeLayerRenderer(createContext()); | 1152 m_hostImpl->initializeLayerRenderer(createContext()); |
1068 } | 1153 } |
1069 } | 1154 } |
1070 | 1155 |
1071 } // namespace | 1156 } // namespace |
OLD | NEW |