OLD | NEW |
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 "cc/layer_tree_host_impl.h" | 5 #include "cc/layer_tree_host_impl.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 | 113 |
114 myHostImpl->initializeRenderer(graphicsContext.Pass()); | 114 myHostImpl->initializeRenderer(graphicsContext.Pass()); |
115 myHostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); | 115 myHostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); |
116 | 116 |
117 root->setAnchorPoint(gfx::PointF(0, 0)); | 117 root->setAnchorPoint(gfx::PointF(0, 0)); |
118 root->setPosition(gfx::PointF(0, 0)); | 118 root->setPosition(gfx::PointF(0, 0)); |
119 root->setBounds(gfx::Size(10, 10)); | 119 root->setBounds(gfx::Size(10, 10)); |
120 root->setContentBounds(gfx::Size(10, 10)); | 120 root->setContentBounds(gfx::Size(10, 10)); |
121 root->setDrawsContent(true); | 121 root->setDrawsContent(true); |
122 root->drawProperties().visible_content_rect = gfx::Rect(0, 0, 10, 10); | 122 root->drawProperties().visible_content_rect = gfx::Rect(0, 0, 10, 10); |
| 123 root->setLayerTreeHostImpl(myHostImpl.get()); |
123 myHostImpl->setRootLayer(root.Pass()); | 124 myHostImpl->setRootLayer(root.Pass()); |
124 return myHostImpl.Pass(); | 125 return myHostImpl.Pass(); |
125 } | 126 } |
126 | 127 |
127 static void expectClearedScrollDeltasRecursive(LayerImpl* layer) | 128 static void expectClearedScrollDeltasRecursive(LayerImpl* layer) |
128 { | 129 { |
129 ASSERT_EQ(layer->scrollDelta(), gfx::Vector2d()); | 130 ASSERT_EQ(layer->scrollDelta(), gfx::Vector2d()); |
130 for (size_t i = 0; i < layer->children().size(); ++i) | 131 for (size_t i = 0; i < layer->children().size(); ++i) |
131 expectClearedScrollDeltasRecursive(layer->children()[i]); | 132 expectClearedScrollDeltasRecursive(layer->children()[i]); |
132 } | 133 } |
(...skipping 28 matching lines...) Expand all Loading... |
161 void setupScrollAndContentsLayers(const gfx::Size& contentSize) | 162 void setupScrollAndContentsLayers(const gfx::Size& contentSize) |
162 { | 163 { |
163 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 164 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
164 root->setScrollable(true); | 165 root->setScrollable(true); |
165 root->setScrollOffset(gfx::Vector2d(0, 0)); | 166 root->setScrollOffset(gfx::Vector2d(0, 0)); |
166 root->setMaxScrollOffset(gfx::Vector2d(contentSize.width(), contentSize.
height())); | 167 root->setMaxScrollOffset(gfx::Vector2d(contentSize.width(), contentSize.
height())); |
167 root->setBounds(contentSize); | 168 root->setBounds(contentSize); |
168 root->setContentBounds(contentSize); | 169 root->setContentBounds(contentSize); |
169 root->setPosition(gfx::PointF(0, 0)); | 170 root->setPosition(gfx::PointF(0, 0)); |
170 root->setAnchorPoint(gfx::PointF(0, 0)); | 171 root->setAnchorPoint(gfx::PointF(0, 0)); |
| 172 root->setLayerTreeHostImpl(m_hostImpl.get()); |
171 | 173 |
172 scoped_ptr<LayerImpl> contents = LayerImpl::create(2); | 174 scoped_ptr<LayerImpl> contents = LayerImpl::create(2); |
173 contents->setDrawsContent(true); | 175 contents->setDrawsContent(true); |
174 contents->setBounds(contentSize); | 176 contents->setBounds(contentSize); |
175 contents->setContentBounds(contentSize); | 177 contents->setContentBounds(contentSize); |
176 contents->setPosition(gfx::PointF(0, 0)); | 178 contents->setPosition(gfx::PointF(0, 0)); |
177 contents->setAnchorPoint(gfx::PointF(0, 0)); | 179 contents->setAnchorPoint(gfx::PointF(0, 0)); |
| 180 contents->setLayerTreeHostImpl(m_hostImpl.get()); |
178 root->addChild(contents.Pass()); | 181 root->addChild(contents.Pass()); |
179 m_hostImpl->setRootLayer(root.Pass()); | 182 m_hostImpl->setRootLayer(root.Pass()); |
180 } | 183 } |
181 | 184 |
182 static scoped_ptr<LayerImpl> createScrollableLayer(int id, const gfx::Size&
size) | 185 scoped_ptr<LayerImpl> createScrollableLayer(int id, const gfx::Size& size) |
183 { | 186 { |
184 scoped_ptr<LayerImpl> layer = LayerImpl::create(id); | 187 scoped_ptr<LayerImpl> layer = LayerImpl::create(id); |
185 layer->setScrollable(true); | 188 layer->setScrollable(true); |
186 layer->setDrawsContent(true); | 189 layer->setDrawsContent(true); |
187 layer->setBounds(size); | 190 layer->setBounds(size); |
188 layer->setContentBounds(size); | 191 layer->setContentBounds(size); |
189 layer->setMaxScrollOffset(gfx::Vector2d(size.width() * 2, size.height()
* 2)); | 192 layer->setMaxScrollOffset(gfx::Vector2d(size.width() * 2, size.height()
* 2)); |
| 193 layer->setLayerTreeHostImpl(m_hostImpl.get()); |
190 return layer.Pass(); | 194 return layer.Pass(); |
191 } | 195 } |
192 | 196 |
193 void initializeRendererAndDrawFrame() | 197 void initializeRendererAndDrawFrame() |
194 { | 198 { |
195 m_hostImpl->initializeRenderer(createContext()); | 199 m_hostImpl->initializeRenderer(createContext()); |
196 LayerTreeHostImpl::FrameData frame; | 200 LayerTreeHostImpl::FrameData frame; |
197 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 201 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
198 m_hostImpl->drawLayers(frame); | 202 m_hostImpl->drawLayers(frame); |
199 m_hostImpl->didDrawAllLayers(frame); | 203 m_hostImpl->didDrawAllLayers(frame); |
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
922 bool m_willDrawCalled; | 926 bool m_willDrawCalled; |
923 }; | 927 }; |
924 | 928 |
925 TEST_P(LayerTreeHostImplTest, didDrawNotCalledOnHiddenLayer) | 929 TEST_P(LayerTreeHostImplTest, didDrawNotCalledOnHiddenLayer) |
926 { | 930 { |
927 // The root layer is always drawn, so run this test on a child layer that | 931 // The root layer is always drawn, so run this test on a child layer that |
928 // will be masked out by the root layer's bounds. | 932 // will be masked out by the root layer's bounds. |
929 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); | 933 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); |
930 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); | 934 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); |
931 root->setMasksToBounds(true); | 935 root->setMasksToBounds(true); |
| 936 root->setLayerTreeHostImpl(m_hostImpl.get()); |
932 | 937 |
933 root->addChild(DidDrawCheckLayer::create(2)); | 938 root->addChild(DidDrawCheckLayer::create(2)); |
934 DidDrawCheckLayer* layer = static_cast<DidDrawCheckLayer*>(root->children()[
0]); | 939 DidDrawCheckLayer* layer = static_cast<DidDrawCheckLayer*>(root->children()[
0]); |
| 940 layer->setLayerTreeHostImpl(m_hostImpl.get()); |
| 941 |
935 // Ensure visibleContentRect for layer is empty | 942 // Ensure visibleContentRect for layer is empty |
936 layer->setPosition(gfx::PointF(100, 100)); | 943 layer->setPosition(gfx::PointF(100, 100)); |
937 layer->setBounds(gfx::Size(10, 10)); | 944 layer->setBounds(gfx::Size(10, 10)); |
938 layer->setContentBounds(gfx::Size(10, 10)); | 945 layer->setContentBounds(gfx::Size(10, 10)); |
939 | 946 |
940 LayerTreeHostImpl::FrameData frame; | 947 LayerTreeHostImpl::FrameData frame; |
941 | 948 |
942 EXPECT_FALSE(layer->willDrawCalled()); | 949 EXPECT_FALSE(layer->willDrawCalled()); |
943 EXPECT_FALSE(layer->didDrawCalled()); | 950 EXPECT_FALSE(layer->didDrawCalled()); |
944 | 951 |
(...skipping 22 matching lines...) Expand all Loading... |
967 EXPECT_FALSE(layer->visibleContentRect().IsEmpty()); | 974 EXPECT_FALSE(layer->visibleContentRect().IsEmpty()); |
968 } | 975 } |
969 | 976 |
970 TEST_P(LayerTreeHostImplTest, willDrawNotCalledOnOccludedLayer) | 977 TEST_P(LayerTreeHostImplTest, willDrawNotCalledOnOccludedLayer) |
971 { | 978 { |
972 gfx::Size bigSize(1000, 1000); | 979 gfx::Size bigSize(1000, 1000); |
973 m_hostImpl->setViewportSize(bigSize, bigSize); | 980 m_hostImpl->setViewportSize(bigSize, bigSize); |
974 | 981 |
975 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); | 982 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); |
976 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); | 983 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); |
| 984 root->setLayerTreeHostImpl(m_hostImpl.get()); |
977 | 985 |
978 root->addChild(DidDrawCheckLayer::create(2)); | 986 root->addChild(DidDrawCheckLayer::create(2)); |
979 DidDrawCheckLayer* occludedLayer = static_cast<DidDrawCheckLayer*>(root->chi
ldren()[0]); | 987 DidDrawCheckLayer* occludedLayer = static_cast<DidDrawCheckLayer*>(root->chi
ldren()[0]); |
| 988 occludedLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
980 | 989 |
981 root->addChild(DidDrawCheckLayer::create(3)); | 990 root->addChild(DidDrawCheckLayer::create(3)); |
982 DidDrawCheckLayer* topLayer = static_cast<DidDrawCheckLayer*>(root->children
()[1]); | 991 DidDrawCheckLayer* topLayer = static_cast<DidDrawCheckLayer*>(root->children
()[1]); |
| 992 topLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
983 // This layer covers the occludedLayer above. Make this layer large so it ca
n occlude. | 993 // This layer covers the occludedLayer above. Make this layer large so it ca
n occlude. |
984 topLayer->setBounds(bigSize); | 994 topLayer->setBounds(bigSize); |
985 topLayer->setContentBounds(bigSize); | 995 topLayer->setContentBounds(bigSize); |
986 topLayer->setContentsOpaque(true); | 996 topLayer->setContentsOpaque(true); |
987 | 997 |
988 LayerTreeHostImpl::FrameData frame; | 998 LayerTreeHostImpl::FrameData frame; |
989 | 999 |
990 EXPECT_FALSE(occludedLayer->willDrawCalled()); | 1000 EXPECT_FALSE(occludedLayer->willDrawCalled()); |
991 EXPECT_FALSE(occludedLayer->didDrawCalled()); | 1001 EXPECT_FALSE(occludedLayer->didDrawCalled()); |
992 EXPECT_FALSE(topLayer->willDrawCalled()); | 1002 EXPECT_FALSE(topLayer->willDrawCalled()); |
993 EXPECT_FALSE(topLayer->didDrawCalled()); | 1003 EXPECT_FALSE(topLayer->didDrawCalled()); |
994 | 1004 |
995 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1005 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
996 m_hostImpl->drawLayers(frame); | 1006 m_hostImpl->drawLayers(frame); |
997 m_hostImpl->didDrawAllLayers(frame); | 1007 m_hostImpl->didDrawAllLayers(frame); |
998 | 1008 |
999 EXPECT_FALSE(occludedLayer->willDrawCalled()); | 1009 EXPECT_FALSE(occludedLayer->willDrawCalled()); |
1000 EXPECT_FALSE(occludedLayer->didDrawCalled()); | 1010 EXPECT_FALSE(occludedLayer->didDrawCalled()); |
1001 EXPECT_TRUE(topLayer->willDrawCalled()); | 1011 EXPECT_TRUE(topLayer->willDrawCalled()); |
1002 EXPECT_TRUE(topLayer->didDrawCalled()); | 1012 EXPECT_TRUE(topLayer->didDrawCalled()); |
1003 } | 1013 } |
1004 | 1014 |
1005 TEST_P(LayerTreeHostImplTest, didDrawCalledOnAllLayers) | 1015 TEST_P(LayerTreeHostImplTest, didDrawCalledOnAllLayers) |
1006 { | 1016 { |
1007 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); | 1017 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); |
1008 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); | 1018 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); |
| 1019 root->setLayerTreeHostImpl(m_hostImpl.get()); |
1009 | 1020 |
1010 root->addChild(DidDrawCheckLayer::create(2)); | 1021 root->addChild(DidDrawCheckLayer::create(2)); |
1011 DidDrawCheckLayer* layer1 = static_cast<DidDrawCheckLayer*>(root->children()
[0]); | 1022 DidDrawCheckLayer* layer1 = static_cast<DidDrawCheckLayer*>(root->children()
[0]); |
| 1023 layer1->setLayerTreeHostImpl(m_hostImpl.get()); |
1012 | 1024 |
1013 layer1->addChild(DidDrawCheckLayer::create(3)); | 1025 layer1->addChild(DidDrawCheckLayer::create(3)); |
1014 DidDrawCheckLayer* layer2 = static_cast<DidDrawCheckLayer*>(layer1->children
()[0]); | 1026 DidDrawCheckLayer* layer2 = static_cast<DidDrawCheckLayer*>(layer1->children
()[0]); |
| 1027 layer2->setLayerTreeHostImpl(m_hostImpl.get()); |
1015 | 1028 |
1016 layer1->setOpacity(0.3f); | 1029 layer1->setOpacity(0.3f); |
1017 layer1->setPreserves3D(false); | 1030 layer1->setPreserves3D(false); |
1018 | 1031 |
1019 EXPECT_FALSE(root->didDrawCalled()); | 1032 EXPECT_FALSE(root->didDrawCalled()); |
1020 EXPECT_FALSE(layer1->didDrawCalled()); | 1033 EXPECT_FALSE(layer1->didDrawCalled()); |
1021 EXPECT_FALSE(layer2->didDrawCalled()); | 1034 EXPECT_FALSE(layer2->didDrawCalled()); |
1022 | 1035 |
1023 LayerTreeHostImpl::FrameData frame; | 1036 LayerTreeHostImpl::FrameData frame; |
1024 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1037 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1056 addAnimatedTransformToLayer(*this, 10, 3, 0); | 1069 addAnimatedTransformToLayer(*this, 10, 3, 0); |
1057 } | 1070 } |
1058 }; | 1071 }; |
1059 | 1072 |
1060 TEST_P(LayerTreeHostImplTest, prepareToDrawFailsWhenAnimationUsesCheckerboard) | 1073 TEST_P(LayerTreeHostImplTest, prepareToDrawFailsWhenAnimationUsesCheckerboard) |
1061 { | 1074 { |
1062 // When the texture is not missing, we draw as usual. | 1075 // When the texture is not missing, we draw as usual. |
1063 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); | 1076 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); |
1064 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); | 1077 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); |
1065 root->addChild(MissingTextureAnimatingLayer::create(2, false, false, true, m
_hostImpl->resourceProvider())); | 1078 root->addChild(MissingTextureAnimatingLayer::create(2, false, false, true, m
_hostImpl->resourceProvider())); |
| 1079 root->setLayerTreeHostImpl(m_hostImpl.get()); |
| 1080 root->children()[0]->setLayerTreeHostImpl(m_hostImpl.get()); |
1066 | 1081 |
1067 LayerTreeHostImpl::FrameData frame; | 1082 LayerTreeHostImpl::FrameData frame; |
1068 | 1083 |
1069 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1084 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
1070 m_hostImpl->drawLayers(frame); | 1085 m_hostImpl->drawLayers(frame); |
1071 m_hostImpl->didDrawAllLayers(frame); | 1086 m_hostImpl->didDrawAllLayers(frame); |
1072 | 1087 |
1073 // When a texture is missing and we're not animating, we draw as usual with
checkerboarding. | 1088 // When a texture is missing and we're not animating, we draw as usual with
checkerboarding. |
1074 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); | 1089 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); |
1075 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); | 1090 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); |
1076 root->addChild(MissingTextureAnimatingLayer::create(2, true, false, false, m
_hostImpl->resourceProvider())); | 1091 root->addChild(MissingTextureAnimatingLayer::create(2, true, false, false, m
_hostImpl->resourceProvider())); |
| 1092 root->setLayerTreeHostImpl(m_hostImpl.get()); |
| 1093 root->children()[0]->setLayerTreeHostImpl(m_hostImpl.get()); |
1077 | 1094 |
1078 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1095 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
1079 m_hostImpl->drawLayers(frame); | 1096 m_hostImpl->drawLayers(frame); |
1080 m_hostImpl->didDrawAllLayers(frame); | 1097 m_hostImpl->didDrawAllLayers(frame); |
1081 | 1098 |
1082 // When a texture is missing and we're animating, we don't want to draw anyt
hing. | 1099 // When a texture is missing and we're animating, we don't want to draw anyt
hing. |
1083 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); | 1100 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); |
1084 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); | 1101 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); |
1085 root->addChild(MissingTextureAnimatingLayer::create(2, true, false, true, m_
hostImpl->resourceProvider())); | 1102 root->addChild(MissingTextureAnimatingLayer::create(2, true, false, true, m_
hostImpl->resourceProvider())); |
| 1103 root->setLayerTreeHostImpl(m_hostImpl.get()); |
| 1104 root->children()[0]->setLayerTreeHostImpl(m_hostImpl.get()); |
1086 | 1105 |
1087 EXPECT_FALSE(m_hostImpl->prepareToDraw(frame)); | 1106 EXPECT_FALSE(m_hostImpl->prepareToDraw(frame)); |
1088 m_hostImpl->drawLayers(frame); | 1107 m_hostImpl->drawLayers(frame); |
1089 m_hostImpl->didDrawAllLayers(frame); | 1108 m_hostImpl->didDrawAllLayers(frame); |
1090 | 1109 |
1091 // When the layer skips draw and we're animating, we still draw the frame. | 1110 // When the layer skips draw and we're animating, we still draw the frame. |
1092 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); | 1111 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1)); |
1093 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); | 1112 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); |
1094 root->addChild(MissingTextureAnimatingLayer::create(2, false, true, true, m_
hostImpl->resourceProvider())); | 1113 root->addChild(MissingTextureAnimatingLayer::create(2, false, true, true, m_
hostImpl->resourceProvider())); |
| 1114 root->setLayerTreeHostImpl(m_hostImpl.get()); |
| 1115 root->children()[0]->setLayerTreeHostImpl(m_hostImpl.get()); |
1095 | 1116 |
1096 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1117 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
1097 m_hostImpl->drawLayers(frame); | 1118 m_hostImpl->drawLayers(frame); |
1098 m_hostImpl->didDrawAllLayers(frame); | 1119 m_hostImpl->didDrawAllLayers(frame); |
1099 } | 1120 } |
1100 | 1121 |
1101 TEST_P(LayerTreeHostImplTest, scrollRootIgnored) | 1122 TEST_P(LayerTreeHostImplTest, scrollRootIgnored) |
1102 { | 1123 { |
1103 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 1124 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
1104 root->setScrollable(false); | 1125 root->setScrollable(false); |
(...skipping 13 matching lines...) Expand all Loading... |
1118 gfx::Size surfaceSize(10, 10); | 1139 gfx::Size surfaceSize(10, 10); |
1119 | 1140 |
1120 scoped_ptr<LayerImpl> contentLayer = LayerImpl::create(1); | 1141 scoped_ptr<LayerImpl> contentLayer = LayerImpl::create(1); |
1121 contentLayer->setUseLCDText(true); | 1142 contentLayer->setUseLCDText(true); |
1122 contentLayer->setDrawsContent(true); | 1143 contentLayer->setDrawsContent(true); |
1123 contentLayer->setPosition(gfx::PointF(0, 0)); | 1144 contentLayer->setPosition(gfx::PointF(0, 0)); |
1124 contentLayer->setAnchorPoint(gfx::PointF(0, 0)); | 1145 contentLayer->setAnchorPoint(gfx::PointF(0, 0)); |
1125 contentLayer->setBounds(surfaceSize); | 1146 contentLayer->setBounds(surfaceSize); |
1126 contentLayer->setContentBounds(gfx::Size(surfaceSize.width() * 2, surfaceSiz
e.height() * 2)); | 1147 contentLayer->setContentBounds(gfx::Size(surfaceSize.width() * 2, surfaceSiz
e.height() * 2)); |
1127 contentLayer->setContentsScale(2, 2); | 1148 contentLayer->setContentsScale(2, 2); |
| 1149 contentLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
1128 | 1150 |
1129 scoped_ptr<LayerImpl> scrollLayer = LayerImpl::create(2); | 1151 scoped_ptr<LayerImpl> scrollLayer = LayerImpl::create(2); |
1130 scrollLayer->setScrollable(true); | 1152 scrollLayer->setScrollable(true); |
1131 scrollLayer->setMaxScrollOffset(gfx::Vector2d(surfaceSize.width(), surfaceSi
ze.height())); | 1153 scrollLayer->setMaxScrollOffset(gfx::Vector2d(surfaceSize.width(), surfaceSi
ze.height())); |
1132 scrollLayer->setBounds(surfaceSize); | 1154 scrollLayer->setBounds(surfaceSize); |
1133 scrollLayer->setContentBounds(surfaceSize); | 1155 scrollLayer->setContentBounds(surfaceSize); |
1134 scrollLayer->setPosition(gfx::PointF(0, 0)); | 1156 scrollLayer->setPosition(gfx::PointF(0, 0)); |
1135 scrollLayer->setAnchorPoint(gfx::PointF(0, 0)); | 1157 scrollLayer->setAnchorPoint(gfx::PointF(0, 0)); |
1136 scrollLayer->addChild(contentLayer.Pass()); | 1158 scrollLayer->addChild(contentLayer.Pass()); |
| 1159 scrollLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
1137 | 1160 |
1138 m_hostImpl->setRootLayer(scrollLayer.Pass()); | 1161 m_hostImpl->setRootLayer(scrollLayer.Pass()); |
1139 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1162 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1140 initializeRendererAndDrawFrame(); | 1163 initializeRendererAndDrawFrame(); |
1141 | 1164 |
1142 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 1165 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
1143 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 1166 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
1144 m_hostImpl->scrollEnd(); | 1167 m_hostImpl->scrollEnd(); |
1145 EXPECT_TRUE(m_didRequestRedraw); | 1168 EXPECT_TRUE(m_didRequestRedraw); |
1146 EXPECT_TRUE(m_didRequestCommit); | 1169 EXPECT_TRUE(m_didRequestCommit); |
1147 } | 1170 } |
1148 | 1171 |
1149 TEST_P(LayerTreeHostImplTest, scrollChildCallsCommitAndRedraw) | 1172 TEST_P(LayerTreeHostImplTest, scrollChildCallsCommitAndRedraw) |
1150 { | 1173 { |
1151 gfx::Size surfaceSize(10, 10); | 1174 gfx::Size surfaceSize(10, 10); |
1152 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 1175 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
1153 root->setBounds(surfaceSize); | 1176 root->setBounds(surfaceSize); |
1154 root->setContentBounds(surfaceSize); | 1177 root->setContentBounds(surfaceSize); |
| 1178 root->setLayerTreeHostImpl(m_hostImpl.get()); |
1155 root->addChild(createScrollableLayer(2, surfaceSize)); | 1179 root->addChild(createScrollableLayer(2, surfaceSize)); |
1156 m_hostImpl->setRootLayer(root.Pass()); | 1180 m_hostImpl->setRootLayer(root.Pass()); |
1157 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1181 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1158 initializeRendererAndDrawFrame(); | 1182 initializeRendererAndDrawFrame(); |
1159 | 1183 |
1160 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 1184 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
1161 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 1185 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
1162 m_hostImpl->scrollEnd(); | 1186 m_hostImpl->scrollEnd(); |
1163 EXPECT_TRUE(m_didRequestRedraw); | 1187 EXPECT_TRUE(m_didRequestRedraw); |
1164 EXPECT_TRUE(m_didRequestCommit); | 1188 EXPECT_TRUE(m_didRequestCommit); |
1165 } | 1189 } |
1166 | 1190 |
1167 TEST_P(LayerTreeHostImplTest, scrollMissesChild) | 1191 TEST_P(LayerTreeHostImplTest, scrollMissesChild) |
1168 { | 1192 { |
1169 gfx::Size surfaceSize(10, 10); | 1193 gfx::Size surfaceSize(10, 10); |
1170 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 1194 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
| 1195 root->setLayerTreeHostImpl(m_hostImpl.get()); |
1171 root->addChild(createScrollableLayer(2, surfaceSize)); | 1196 root->addChild(createScrollableLayer(2, surfaceSize)); |
1172 m_hostImpl->setRootLayer(root.Pass()); | 1197 m_hostImpl->setRootLayer(root.Pass()); |
1173 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1198 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1174 initializeRendererAndDrawFrame(); | 1199 initializeRendererAndDrawFrame(); |
1175 | 1200 |
1176 // Scroll event is ignored because the input coordinate is outside the layer
boundaries. | 1201 // Scroll event is ignored because the input coordinate is outside the layer
boundaries. |
1177 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(15, 5), InputHandlerClient::Whe
el), InputHandlerClient::ScrollIgnored); | 1202 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(15, 5), InputHandlerClient::Whe
el), InputHandlerClient::ScrollIgnored); |
1178 EXPECT_FALSE(m_didRequestRedraw); | 1203 EXPECT_FALSE(m_didRequestRedraw); |
1179 EXPECT_FALSE(m_didRequestCommit); | 1204 EXPECT_FALSE(m_didRequestCommit); |
1180 } | 1205 } |
1181 | 1206 |
1182 TEST_P(LayerTreeHostImplTest, scrollMissesBackfacingChild) | 1207 TEST_P(LayerTreeHostImplTest, scrollMissesBackfacingChild) |
1183 { | 1208 { |
1184 gfx::Size surfaceSize(10, 10); | 1209 gfx::Size surfaceSize(10, 10); |
1185 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 1210 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
| 1211 root->setLayerTreeHostImpl(m_hostImpl.get()); |
1186 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); | 1212 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); |
| 1213 child->setLayerTreeHostImpl(m_hostImpl.get()); |
1187 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1214 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1188 | 1215 |
1189 gfx::Transform matrix; | 1216 gfx::Transform matrix; |
1190 MathUtil::rotateEulerAngles(&matrix, 180, 0, 0); | 1217 MathUtil::rotateEulerAngles(&matrix, 180, 0, 0); |
1191 child->setTransform(matrix); | 1218 child->setTransform(matrix); |
1192 child->setDoubleSided(false); | 1219 child->setDoubleSided(false); |
1193 | 1220 |
1194 root->addChild(child.Pass()); | 1221 root->addChild(child.Pass()); |
1195 m_hostImpl->setRootLayer(root.Pass()); | 1222 m_hostImpl->setRootLayer(root.Pass()); |
1196 initializeRendererAndDrawFrame(); | 1223 initializeRendererAndDrawFrame(); |
1197 | 1224 |
1198 // Scroll event is ignored because the scrollable layer is not facing the vi
ewer and there is | 1225 // Scroll event is ignored because the scrollable layer is not facing the vi
ewer and there is |
1199 // nothing scrollable behind it. | 1226 // nothing scrollable behind it. |
1200 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollIgnored); | 1227 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollIgnored); |
1201 EXPECT_FALSE(m_didRequestRedraw); | 1228 EXPECT_FALSE(m_didRequestRedraw); |
1202 EXPECT_FALSE(m_didRequestCommit); | 1229 EXPECT_FALSE(m_didRequestCommit); |
1203 } | 1230 } |
1204 | 1231 |
1205 TEST_P(LayerTreeHostImplTest, scrollBlockedByContentLayer) | 1232 TEST_P(LayerTreeHostImplTest, scrollBlockedByContentLayer) |
1206 { | 1233 { |
1207 gfx::Size surfaceSize(10, 10); | 1234 gfx::Size surfaceSize(10, 10); |
1208 scoped_ptr<LayerImpl> contentLayer = createScrollableLayer(1, surfaceSize); | 1235 scoped_ptr<LayerImpl> contentLayer = createScrollableLayer(1, surfaceSize); |
1209 contentLayer->setShouldScrollOnMainThread(true); | 1236 contentLayer->setShouldScrollOnMainThread(true); |
1210 contentLayer->setScrollable(false); | 1237 contentLayer->setScrollable(false); |
| 1238 contentLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
1211 | 1239 |
1212 scoped_ptr<LayerImpl> scrollLayer = createScrollableLayer(2, surfaceSize); | 1240 scoped_ptr<LayerImpl> scrollLayer = createScrollableLayer(2, surfaceSize); |
1213 scrollLayer->addChild(contentLayer.Pass()); | 1241 scrollLayer->addChild(contentLayer.Pass()); |
| 1242 scrollLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
1214 | 1243 |
1215 m_hostImpl->setRootLayer(scrollLayer.Pass()); | 1244 m_hostImpl->setRootLayer(scrollLayer.Pass()); |
1216 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1245 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1217 initializeRendererAndDrawFrame(); | 1246 initializeRendererAndDrawFrame(); |
1218 | 1247 |
1219 // Scrolling fails because the content layer is asking to be scrolled on the
main thread. | 1248 // Scrolling fails because the content layer is asking to be scrolled on the
main thread. |
1220 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollOnMainThread); | 1249 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollOnMainThread); |
1221 } | 1250 } |
1222 | 1251 |
1223 TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread) | 1252 TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread) |
1224 { | 1253 { |
1225 gfx::Size surfaceSize(10, 10); | 1254 gfx::Size surfaceSize(10, 10); |
1226 float pageScale = 2; | 1255 float pageScale = 2; |
1227 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); | 1256 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); |
| 1257 root->setLayerTreeHostImpl(m_hostImpl.get()); |
1228 m_hostImpl->setRootLayer(root.Pass()); | 1258 m_hostImpl->setRootLayer(root.Pass()); |
1229 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1259 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1230 initializeRendererAndDrawFrame(); | 1260 initializeRendererAndDrawFrame(); |
1231 | 1261 |
1232 gfx::Vector2d scrollDelta(0, 10); | 1262 gfx::Vector2d scrollDelta(0, 10); |
1233 gfx::Vector2d expectedScrollDelta(scrollDelta); | 1263 gfx::Vector2d expectedScrollDelta(scrollDelta); |
1234 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); | 1264 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); |
1235 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 1265 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
1236 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 1266 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
1237 m_hostImpl->scrollEnd(); | 1267 m_hostImpl->scrollEnd(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1270 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(3
, 1)); | 1300 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(3
, 1)); |
1271 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(3
, 2)); | 1301 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(3
, 2)); |
1272 EXPECT_EQ(1.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(3
, 3)); | 1302 EXPECT_EQ(1.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(3
, 3)); |
1273 } | 1303 } |
1274 | 1304 |
1275 TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread) | 1305 TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread) |
1276 { | 1306 { |
1277 gfx::Size surfaceSize(10, 10); | 1307 gfx::Size surfaceSize(10, 10); |
1278 float pageScale = 2; | 1308 float pageScale = 2; |
1279 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); | 1309 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); |
| 1310 root->setLayerTreeHostImpl(m_hostImpl.get()); |
1280 m_hostImpl->setRootLayer(root.Pass()); | 1311 m_hostImpl->setRootLayer(root.Pass()); |
1281 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1312 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1282 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); | 1313 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); |
1283 initializeRendererAndDrawFrame(); | 1314 initializeRendererAndDrawFrame(); |
1284 | 1315 |
1285 gfx::Vector2d scrollDelta(0, 10); | 1316 gfx::Vector2d scrollDelta(0, 10); |
1286 gfx::Vector2d expectedScrollDelta(scrollDelta); | 1317 gfx::Vector2d expectedScrollDelta(scrollDelta); |
1287 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); | 1318 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); |
1288 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 1319 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
1289 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 1320 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1692 }; | 1723 }; |
1693 | 1724 |
1694 TEST_P(LayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers) | 1725 TEST_P(LayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers) |
1695 { | 1726 { |
1696 { | 1727 { |
1697 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 1728 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
1698 root->setAnchorPoint(gfx::PointF(0, 0)); | 1729 root->setAnchorPoint(gfx::PointF(0, 0)); |
1699 root->setBounds(gfx::Size(10, 10)); | 1730 root->setBounds(gfx::Size(10, 10)); |
1700 root->setContentBounds(root->bounds()); | 1731 root->setContentBounds(root->bounds()); |
1701 root->setDrawsContent(false); | 1732 root->setDrawsContent(false); |
| 1733 root->setLayerTreeHostImpl(m_hostImpl.get()); |
1702 m_hostImpl->setRootLayer(root.Pass()); | 1734 m_hostImpl->setRootLayer(root.Pass()); |
1703 } | 1735 } |
1704 LayerImpl* root = m_hostImpl->rootLayer(); | 1736 LayerImpl* root = m_hostImpl->rootLayer(); |
1705 | 1737 |
1706 root->addChild(BlendStateCheckLayer::create(2, m_hostImpl->resourceProvider(
))); | 1738 root->addChild(BlendStateCheckLayer::create(2, m_hostImpl->resourceProvider(
))); |
1707 BlendStateCheckLayer* layer1 = static_cast<BlendStateCheckLayer*>(root->chil
dren()[0]); | 1739 BlendStateCheckLayer* layer1 = static_cast<BlendStateCheckLayer*>(root->chil
dren()[0]); |
1708 layer1->setPosition(gfx::PointF(2, 2)); | 1740 layer1->setPosition(gfx::PointF(2, 2)); |
| 1741 layer1->setLayerTreeHostImpl(m_hostImpl.get()); |
1709 | 1742 |
1710 LayerTreeHostImpl::FrameData frame; | 1743 LayerTreeHostImpl::FrameData frame; |
1711 | 1744 |
1712 // Opaque layer, drawn without blending. | 1745 // Opaque layer, drawn without blending. |
1713 layer1->setContentsOpaque(true); | 1746 layer1->setContentsOpaque(true); |
1714 layer1->setExpectation(false, false); | 1747 layer1->setExpectation(false, false); |
1715 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1748 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
1716 m_hostImpl->drawLayers(frame); | 1749 m_hostImpl->drawLayers(frame); |
1717 EXPECT_TRUE(layer1->quadsAppended()); | 1750 EXPECT_TRUE(layer1->quadsAppended()); |
1718 m_hostImpl->didDrawAllLayers(frame); | 1751 m_hostImpl->didDrawAllLayers(frame); |
(...skipping 20 matching lines...) Expand all Loading... |
1739 layer1->setOpacity(0.5); | 1772 layer1->setOpacity(0.5); |
1740 layer1->setExpectation(true, false); | 1773 layer1->setExpectation(true, false); |
1741 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1774 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
1742 m_hostImpl->drawLayers(frame); | 1775 m_hostImpl->drawLayers(frame); |
1743 EXPECT_TRUE(layer1->quadsAppended()); | 1776 EXPECT_TRUE(layer1->quadsAppended()); |
1744 m_hostImpl->didDrawAllLayers(frame); | 1777 m_hostImpl->didDrawAllLayers(frame); |
1745 | 1778 |
1746 layer1->addChild(BlendStateCheckLayer::create(3, m_hostImpl->resourceProvide
r())); | 1779 layer1->addChild(BlendStateCheckLayer::create(3, m_hostImpl->resourceProvide
r())); |
1747 BlendStateCheckLayer* layer2 = static_cast<BlendStateCheckLayer*>(layer1->ch
ildren()[0]); | 1780 BlendStateCheckLayer* layer2 = static_cast<BlendStateCheckLayer*>(layer1->ch
ildren()[0]); |
1748 layer2->setPosition(gfx::PointF(4, 4)); | 1781 layer2->setPosition(gfx::PointF(4, 4)); |
| 1782 layer2->setLayerTreeHostImpl(m_hostImpl.get()); |
1749 | 1783 |
1750 // 2 opaque layers, drawn without blending. | 1784 // 2 opaque layers, drawn without blending. |
1751 layer1->setContentsOpaque(true); | 1785 layer1->setContentsOpaque(true); |
1752 layer1->setOpacity(1); | 1786 layer1->setOpacity(1); |
1753 layer1->setExpectation(false, false); | 1787 layer1->setExpectation(false, false); |
1754 layer2->setContentsOpaque(true); | 1788 layer2->setContentsOpaque(true); |
1755 layer2->setOpacity(1); | 1789 layer2->setOpacity(1); |
1756 layer2->setExpectation(false, false); | 1790 layer2->setExpectation(false, false); |
1757 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1791 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
1758 m_hostImpl->drawLayers(frame); | 1792 m_hostImpl->drawLayers(frame); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1886 TEST_P(LayerTreeHostImplTest, viewportCovered) | 1920 TEST_P(LayerTreeHostImplTest, viewportCovered) |
1887 { | 1921 { |
1888 m_hostImpl->initializeRenderer(createContext()); | 1922 m_hostImpl->initializeRenderer(createContext()); |
1889 m_hostImpl->setBackgroundColor(SK_ColorGRAY); | 1923 m_hostImpl->setBackgroundColor(SK_ColorGRAY); |
1890 | 1924 |
1891 gfx::Size viewportSize(1000, 1000); | 1925 gfx::Size viewportSize(1000, 1000); |
1892 m_hostImpl->setViewportSize(viewportSize, viewportSize); | 1926 m_hostImpl->setViewportSize(viewportSize, viewportSize); |
1893 | 1927 |
1894 m_hostImpl->setRootLayer(LayerImpl::create(1)); | 1928 m_hostImpl->setRootLayer(LayerImpl::create(1)); |
1895 m_hostImpl->rootLayer()->addChild(BlendStateCheckLayer::create(2, m_hostImpl
->resourceProvider())); | 1929 m_hostImpl->rootLayer()->addChild(BlendStateCheckLayer::create(2, m_hostImpl
->resourceProvider())); |
| 1930 m_hostImpl->rootLayer()->setLayerTreeHostImpl(m_hostImpl.get()); |
1896 BlendStateCheckLayer* child = static_cast<BlendStateCheckLayer*>(m_hostImpl-
>rootLayer()->children()[0]); | 1931 BlendStateCheckLayer* child = static_cast<BlendStateCheckLayer*>(m_hostImpl-
>rootLayer()->children()[0]); |
1897 child->setExpectation(false, false); | 1932 child->setExpectation(false, false); |
1898 child->setContentsOpaque(true); | 1933 child->setContentsOpaque(true); |
| 1934 child->setLayerTreeHostImpl(m_hostImpl.get()); |
1899 | 1935 |
1900 // No gutter rects | 1936 // No gutter rects |
1901 { | 1937 { |
1902 gfx::Rect layerRect(0, 0, 1000, 1000); | 1938 gfx::Rect layerRect(0, 0, 1000, 1000); |
1903 child->setPosition(layerRect.origin()); | 1939 child->setPosition(layerRect.origin()); |
1904 child->setBounds(layerRect.size()); | 1940 child->setBounds(layerRect.size()); |
1905 child->setContentBounds(layerRect.size()); | 1941 child->setContentBounds(layerRect.size()); |
1906 child->setQuadRect(gfx::Rect(gfx::Point(), layerRect.size())); | 1942 child->setQuadRect(gfx::Rect(gfx::Point(), layerRect.size())); |
1907 child->setQuadVisibleRect(gfx::Rect(gfx::Point(), layerRect.size())); | 1943 child->setQuadVisibleRect(gfx::Rect(gfx::Point(), layerRect.size())); |
1908 | 1944 |
1909 LayerTreeHostImpl::FrameData frame; | 1945 LayerTreeHostImpl::FrameData frame; |
| 1946 EXPECT_TRUE(m_hostImpl->needsUpdateLayers()); |
1910 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1947 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
1911 ASSERT_EQ(1u, frame.renderPasses.size()); | 1948 ASSERT_EQ(1u, frame.renderPasses.size()); |
1912 | 1949 |
1913 size_t numGutterQuads = 0; | 1950 size_t numGutterQuads = 0; |
1914 for (size_t i = 0; i < frame.renderPasses[0]->quad_list.size(); ++i) | 1951 for (size_t i = 0; i < frame.renderPasses[0]->quad_list.size(); ++i) |
1915 numGutterQuads += (frame.renderPasses[0]->quad_list[i]->material ==
DrawQuad::SOLID_COLOR) ? 1 : 0; | 1952 numGutterQuads += (frame.renderPasses[0]->quad_list[i]->material ==
DrawQuad::SOLID_COLOR) ? 1 : 0; |
1916 EXPECT_EQ(0u, numGutterQuads); | 1953 EXPECT_EQ(0u, numGutterQuads); |
1917 EXPECT_EQ(1u, frame.renderPasses[0]->quad_list.size()); | 1954 EXPECT_EQ(1u, frame.renderPasses[0]->quad_list.size()); |
1918 | 1955 |
1919 verifyQuadsExactlyCoverRect(frame.renderPasses[0]->quad_list, gfx::Rect(
gfx::Point(), viewportSize)); | 1956 verifyQuadsExactlyCoverRect(frame.renderPasses[0]->quad_list, gfx::Rect(
gfx::Point(), viewportSize)); |
1920 m_hostImpl->didDrawAllLayers(frame); | 1957 m_hostImpl->didDrawAllLayers(frame); |
1921 } | 1958 } |
1922 | 1959 |
1923 // Empty visible content area (fullscreen gutter rect) | 1960 // Empty visible content area (fullscreen gutter rect) |
1924 { | 1961 { |
1925 gfx::Rect layerRect(0, 0, 0, 0); | 1962 gfx::Rect layerRect(0, 0, 0, 0); |
1926 child->setPosition(layerRect.origin()); | 1963 child->setPosition(layerRect.origin()); |
1927 child->setBounds(layerRect.size()); | 1964 child->setBounds(layerRect.size()); |
1928 child->setContentBounds(layerRect.size()); | 1965 child->setContentBounds(layerRect.size()); |
1929 child->setQuadRect(gfx::Rect(gfx::Point(), layerRect.size())); | 1966 child->setQuadRect(gfx::Rect(gfx::Point(), layerRect.size())); |
1930 child->setQuadVisibleRect(gfx::Rect(gfx::Point(), layerRect.size())); | 1967 child->setQuadVisibleRect(gfx::Rect(gfx::Point(), layerRect.size())); |
1931 | 1968 |
1932 LayerTreeHostImpl::FrameData frame; | 1969 LayerTreeHostImpl::FrameData frame; |
| 1970 EXPECT_TRUE(m_hostImpl->needsUpdateLayers()); |
1933 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1971 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
1934 ASSERT_EQ(1u, frame.renderPasses.size()); | 1972 ASSERT_EQ(1u, frame.renderPasses.size()); |
1935 m_hostImpl->didDrawAllLayers(frame); | |
1936 | 1973 |
1937 size_t numGutterQuads = 0; | 1974 size_t numGutterQuads = 0; |
1938 for (size_t i = 0; i < frame.renderPasses[0]->quad_list.size(); ++i) | 1975 for (size_t i = 0; i < frame.renderPasses[0]->quad_list.size(); ++i) |
1939 numGutterQuads += (frame.renderPasses[0]->quad_list[i]->material ==
DrawQuad::SOLID_COLOR) ? 1 : 0; | 1976 numGutterQuads += (frame.renderPasses[0]->quad_list[i]->material ==
DrawQuad::SOLID_COLOR) ? 1 : 0; |
1940 EXPECT_EQ(1u, numGutterQuads); | 1977 EXPECT_EQ(1u, numGutterQuads); |
1941 EXPECT_EQ(1u, frame.renderPasses[0]->quad_list.size()); | 1978 EXPECT_EQ(1u, frame.renderPasses[0]->quad_list.size()); |
1942 | 1979 |
1943 verifyQuadsExactlyCoverRect(frame.renderPasses[0]->quad_list, gfx::Rect(
gfx::Point(), viewportSize)); | 1980 verifyQuadsExactlyCoverRect(frame.renderPasses[0]->quad_list, gfx::Rect(
gfx::Point(), viewportSize)); |
1944 m_hostImpl->didDrawAllLayers(frame); | 1981 m_hostImpl->didDrawAllLayers(frame); |
1945 } | 1982 } |
1946 | 1983 |
1947 // Content area in middle of clip rect (four surrounding gutter rects) | 1984 // Content area in middle of clip rect (four surrounding gutter rects) |
1948 { | 1985 { |
1949 gfx::Rect layerRect(500, 500, 200, 200); | 1986 gfx::Rect layerRect(500, 500, 200, 200); |
1950 child->setPosition(layerRect.origin()); | 1987 child->setPosition(layerRect.origin()); |
1951 child->setBounds(layerRect.size()); | 1988 child->setBounds(layerRect.size()); |
1952 child->setContentBounds(layerRect.size()); | 1989 child->setContentBounds(layerRect.size()); |
1953 child->setQuadRect(gfx::Rect(gfx::Point(), layerRect.size())); | 1990 child->setQuadRect(gfx::Rect(gfx::Point(), layerRect.size())); |
1954 child->setQuadVisibleRect(gfx::Rect(gfx::Point(), layerRect.size())); | 1991 child->setQuadVisibleRect(gfx::Rect(gfx::Point(), layerRect.size())); |
1955 | 1992 |
1956 LayerTreeHostImpl::FrameData frame; | 1993 LayerTreeHostImpl::FrameData frame; |
| 1994 EXPECT_TRUE(m_hostImpl->needsUpdateLayers()); |
1957 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1995 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
1958 ASSERT_EQ(1u, frame.renderPasses.size()); | 1996 ASSERT_EQ(1u, frame.renderPasses.size()); |
1959 | 1997 |
1960 size_t numGutterQuads = 0; | 1998 size_t numGutterQuads = 0; |
1961 for (size_t i = 0; i < frame.renderPasses[0]->quad_list.size(); ++i) | 1999 for (size_t i = 0; i < frame.renderPasses[0]->quad_list.size(); ++i) |
1962 numGutterQuads += (frame.renderPasses[0]->quad_list[i]->material ==
DrawQuad::SOLID_COLOR) ? 1 : 0; | 2000 numGutterQuads += (frame.renderPasses[0]->quad_list[i]->material ==
DrawQuad::SOLID_COLOR) ? 1 : 0; |
1963 EXPECT_EQ(4u, numGutterQuads); | 2001 EXPECT_EQ(4u, numGutterQuads); |
1964 EXPECT_EQ(5u, frame.renderPasses[0]->quad_list.size()); | 2002 EXPECT_EQ(5u, frame.renderPasses[0]->quad_list.size()); |
1965 | 2003 |
1966 verifyQuadsExactlyCoverRect(frame.renderPasses[0]->quad_list, gfx::Rect(
gfx::Point(), viewportSize)); | 2004 verifyQuadsExactlyCoverRect(frame.renderPasses[0]->quad_list, gfx::Rect(
gfx::Point(), viewportSize)); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2051 layerTreeHostImpl->initializeRenderer(outputSurface.Pass()); | 2089 layerTreeHostImpl->initializeRenderer(outputSurface.Pass()); |
2052 layerTreeHostImpl->setViewportSize(gfx::Size(500, 500), gfx::Size(500, 500))
; | 2090 layerTreeHostImpl->setViewportSize(gfx::Size(500, 500), gfx::Size(500, 500))
; |
2053 | 2091 |
2054 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(1); | 2092 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(1); |
2055 scoped_ptr<LayerImpl> child = FakeDrawableLayerImpl::create(2); | 2093 scoped_ptr<LayerImpl> child = FakeDrawableLayerImpl::create(2); |
2056 child->setPosition(gfx::PointF(12, 13)); | 2094 child->setPosition(gfx::PointF(12, 13)); |
2057 child->setAnchorPoint(gfx::PointF(0, 0)); | 2095 child->setAnchorPoint(gfx::PointF(0, 0)); |
2058 child->setBounds(gfx::Size(14, 15)); | 2096 child->setBounds(gfx::Size(14, 15)); |
2059 child->setContentBounds(gfx::Size(14, 15)); | 2097 child->setContentBounds(gfx::Size(14, 15)); |
2060 child->setDrawsContent(true); | 2098 child->setDrawsContent(true); |
| 2099 child->setLayerTreeHostImpl(layerTreeHostImpl.get()); |
2061 root->setAnchorPoint(gfx::PointF(0, 0)); | 2100 root->setAnchorPoint(gfx::PointF(0, 0)); |
2062 root->setBounds(gfx::Size(500, 500)); | 2101 root->setBounds(gfx::Size(500, 500)); |
2063 root->setContentBounds(gfx::Size(500, 500)); | 2102 root->setContentBounds(gfx::Size(500, 500)); |
2064 root->setDrawsContent(true); | 2103 root->setDrawsContent(true); |
2065 root->addChild(child.Pass()); | 2104 root->addChild(child.Pass()); |
| 2105 root->setLayerTreeHostImpl(layerTreeHostImpl.get()); |
2066 layerTreeHostImpl->setRootLayer(root.Pass()); | 2106 layerTreeHostImpl->setRootLayer(root.Pass()); |
2067 | 2107 |
2068 LayerTreeHostImpl::FrameData frame; | 2108 LayerTreeHostImpl::FrameData frame; |
2069 | 2109 |
2070 // First frame, the entire screen should get swapped. | 2110 // First frame, the entire screen should get swapped. |
2071 EXPECT_TRUE(layerTreeHostImpl->prepareToDraw(frame)); | 2111 EXPECT_TRUE(layerTreeHostImpl->prepareToDraw(frame)); |
2072 layerTreeHostImpl->drawLayers(frame); | 2112 layerTreeHostImpl->drawLayers(frame); |
2073 layerTreeHostImpl->didDrawAllLayers(frame); | 2113 layerTreeHostImpl->didDrawAllLayers(frame); |
2074 layerTreeHostImpl->swapBuffers(); | 2114 layerTreeHostImpl->swapBuffers(); |
2075 gfx::Rect actualSwapRect = partialSwapTracker->partialSwapRect(); | 2115 gfx::Rect actualSwapRect = partialSwapTracker->partialSwapRect(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2113 } | 2153 } |
2114 | 2154 |
2115 TEST_P(LayerTreeHostImplTest, rootLayerDoesntCreateExtraSurface) | 2155 TEST_P(LayerTreeHostImplTest, rootLayerDoesntCreateExtraSurface) |
2116 { | 2156 { |
2117 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(1); | 2157 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(1); |
2118 scoped_ptr<LayerImpl> child = FakeDrawableLayerImpl::create(2); | 2158 scoped_ptr<LayerImpl> child = FakeDrawableLayerImpl::create(2); |
2119 child->setAnchorPoint(gfx::PointF(0, 0)); | 2159 child->setAnchorPoint(gfx::PointF(0, 0)); |
2120 child->setBounds(gfx::Size(10, 10)); | 2160 child->setBounds(gfx::Size(10, 10)); |
2121 child->setContentBounds(gfx::Size(10, 10)); | 2161 child->setContentBounds(gfx::Size(10, 10)); |
2122 child->setDrawsContent(true); | 2162 child->setDrawsContent(true); |
| 2163 child->setLayerTreeHostImpl(m_hostImpl.get()); |
2123 root->setAnchorPoint(gfx::PointF(0, 0)); | 2164 root->setAnchorPoint(gfx::PointF(0, 0)); |
2124 root->setBounds(gfx::Size(10, 10)); | 2165 root->setBounds(gfx::Size(10, 10)); |
2125 root->setContentBounds(gfx::Size(10, 10)); | 2166 root->setContentBounds(gfx::Size(10, 10)); |
2126 root->setDrawsContent(true); | 2167 root->setDrawsContent(true); |
2127 root->setOpacity(0.7f); | 2168 root->setOpacity(0.7f); |
2128 root->addChild(child.Pass()); | 2169 root->addChild(child.Pass()); |
| 2170 root->setLayerTreeHostImpl(m_hostImpl.get()); |
2129 | 2171 |
2130 m_hostImpl->setRootLayer(root.Pass()); | 2172 m_hostImpl->setRootLayer(root.Pass()); |
2131 | 2173 |
2132 LayerTreeHostImpl::FrameData frame; | 2174 LayerTreeHostImpl::FrameData frame; |
2133 | 2175 |
2134 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2176 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
2135 EXPECT_EQ(1u, frame.renderSurfaceLayerList->size()); | 2177 EXPECT_EQ(1u, frame.renderSurfaceLayerList->size()); |
2136 EXPECT_EQ(1u, frame.renderPasses.size()); | 2178 EXPECT_EQ(1u, frame.renderPasses.size()); |
2137 m_hostImpl->didDrawAllLayers(frame); | 2179 m_hostImpl->didDrawAllLayers(frame); |
2138 } | 2180 } |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2379 gfx::Rect grandChildRect(5, 5, 150, 150); | 2421 gfx::Rect grandChildRect(5, 5, 150, 150); |
2380 | 2422 |
2381 root->createRenderSurface(); | 2423 root->createRenderSurface(); |
2382 root->setAnchorPoint(gfx::PointF(0, 0)); | 2424 root->setAnchorPoint(gfx::PointF(0, 0)); |
2383 root->setPosition(gfx::PointF(rootRect.x(), rootRect.y())); | 2425 root->setPosition(gfx::PointF(rootRect.x(), rootRect.y())); |
2384 root->setBounds(gfx::Size(rootRect.width(), rootRect.height())); | 2426 root->setBounds(gfx::Size(rootRect.width(), rootRect.height())); |
2385 root->setContentBounds(root->bounds()); | 2427 root->setContentBounds(root->bounds()); |
2386 root->drawProperties().visible_content_rect = rootRect; | 2428 root->drawProperties().visible_content_rect = rootRect; |
2387 root->setDrawsContent(false); | 2429 root->setDrawsContent(false); |
2388 root->renderSurface()->setContentRect(gfx::Rect(gfx::Point(), gfx::Size(root
Rect.width(), rootRect.height()))); | 2430 root->renderSurface()->setContentRect(gfx::Rect(gfx::Point(), gfx::Size(root
Rect.width(), rootRect.height()))); |
| 2431 root->setLayerTreeHostImpl(myHostImpl.get()); |
2389 | 2432 |
2390 child->setAnchorPoint(gfx::PointF(0, 0)); | 2433 child->setAnchorPoint(gfx::PointF(0, 0)); |
2391 child->setPosition(gfx::PointF(childRect.x(), childRect.y())); | 2434 child->setPosition(gfx::PointF(childRect.x(), childRect.y())); |
2392 child->setOpacity(0.5f); | 2435 child->setOpacity(0.5f); |
2393 child->setBounds(gfx::Size(childRect.width(), childRect.height())); | 2436 child->setBounds(gfx::Size(childRect.width(), childRect.height())); |
2394 child->setContentBounds(child->bounds()); | 2437 child->setContentBounds(child->bounds()); |
2395 child->drawProperties().visible_content_rect = childRect; | 2438 child->drawProperties().visible_content_rect = childRect; |
2396 child->setDrawsContent(false); | 2439 child->setDrawsContent(false); |
2397 child->setForceRenderSurface(true); | 2440 child->setForceRenderSurface(true); |
| 2441 child->setLayerTreeHostImpl(myHostImpl.get()); |
2398 | 2442 |
2399 grandChild->setAnchorPoint(gfx::PointF(0, 0)); | 2443 grandChild->setAnchorPoint(gfx::PointF(0, 0)); |
2400 grandChild->setPosition(gfx::Point(grandChildRect.x(), grandChildRect.y())); | 2444 grandChild->setPosition(gfx::Point(grandChildRect.x(), grandChildRect.y())); |
2401 grandChild->setBounds(gfx::Size(grandChildRect.width(), grandChildRect.heigh
t())); | 2445 grandChild->setBounds(gfx::Size(grandChildRect.width(), grandChildRect.heigh
t())); |
2402 grandChild->setContentBounds(grandChild->bounds()); | 2446 grandChild->setContentBounds(grandChild->bounds()); |
2403 grandChild->drawProperties().visible_content_rect = grandChildRect; | 2447 grandChild->drawProperties().visible_content_rect = grandChildRect; |
2404 grandChild->setDrawsContent(true); | 2448 grandChild->setDrawsContent(true); |
| 2449 grandChild->setLayerTreeHostImpl(myHostImpl.get()); |
2405 | 2450 |
2406 child->addChild(grandChild.Pass()); | 2451 child->addChild(grandChild.Pass()); |
2407 root->addChild(child.Pass()); | 2452 root->addChild(child.Pass()); |
2408 | 2453 |
2409 myHostImpl->setRootLayer(root.Pass()); | 2454 myHostImpl->setRootLayer(root.Pass()); |
2410 return myHostImpl.Pass(); | 2455 return myHostImpl.Pass(); |
2411 } | 2456 } |
2412 | 2457 |
2413 TEST_P(LayerTreeHostImplTest, contributingLayerEmptyScissorPartialSwap) | 2458 TEST_P(LayerTreeHostImplTest, contributingLayerEmptyScissorPartialSwap) |
2414 { | 2459 { |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2783 return pass.PassAs<RenderPass>(); | 2828 return pass.PassAs<RenderPass>(); |
2784 } | 2829 } |
2785 | 2830 |
2786 TEST_P(LayerTreeHostImplTest, dontUseOldResourcesAfterLostContext) | 2831 TEST_P(LayerTreeHostImplTest, dontUseOldResourcesAfterLostContext) |
2787 { | 2832 { |
2788 int layerId = 1; | 2833 int layerId = 1; |
2789 | 2834 |
2790 scoped_ptr<LayerImpl> rootLayer(LayerImpl::create(layerId++)); | 2835 scoped_ptr<LayerImpl> rootLayer(LayerImpl::create(layerId++)); |
2791 rootLayer->setBounds(gfx::Size(10, 10)); | 2836 rootLayer->setBounds(gfx::Size(10, 10)); |
2792 rootLayer->setAnchorPoint(gfx::PointF(0, 0)); | 2837 rootLayer->setAnchorPoint(gfx::PointF(0, 0)); |
| 2838 rootLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
2793 | 2839 |
2794 scoped_ptr<TiledLayerImpl> tileLayer = TiledLayerImpl::create(layerId++); | 2840 scoped_ptr<TiledLayerImpl> tileLayer = TiledLayerImpl::create(layerId++); |
2795 tileLayer->setBounds(gfx::Size(10, 10)); | 2841 tileLayer->setBounds(gfx::Size(10, 10)); |
2796 tileLayer->setAnchorPoint(gfx::PointF(0, 0)); | 2842 tileLayer->setAnchorPoint(gfx::PointF(0, 0)); |
2797 tileLayer->setContentBounds(gfx::Size(10, 10)); | 2843 tileLayer->setContentBounds(gfx::Size(10, 10)); |
2798 tileLayer->setDrawsContent(true); | 2844 tileLayer->setDrawsContent(true); |
2799 tileLayer->setSkipsDraw(false); | 2845 tileLayer->setSkipsDraw(false); |
2800 scoped_ptr<LayerTilingData> tilingData(LayerTilingData::create(gfx::Size(10,
10), LayerTilingData::NoBorderTexels)); | 2846 scoped_ptr<LayerTilingData> tilingData(LayerTilingData::create(gfx::Size(10,
10), LayerTilingData::NoBorderTexels)); |
2801 tilingData->setBounds(gfx::Size(10, 10)); | 2847 tilingData->setBounds(gfx::Size(10, 10)); |
2802 tileLayer->setTilingData(*tilingData); | 2848 tileLayer->setTilingData(*tilingData); |
2803 tileLayer->pushTileProperties(0, 0, 1, gfx::Rect(0, 0, 10, 10), false); | 2849 tileLayer->pushTileProperties(0, 0, 1, gfx::Rect(0, 0, 10, 10), false); |
| 2850 tileLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
2804 rootLayer->addChild(tileLayer.PassAs<LayerImpl>()); | 2851 rootLayer->addChild(tileLayer.PassAs<LayerImpl>()); |
2805 | 2852 |
2806 scoped_ptr<TextureLayerImpl> textureLayer = TextureLayerImpl::create(layerId
++); | 2853 scoped_ptr<TextureLayerImpl> textureLayer = TextureLayerImpl::create(layerId
++); |
2807 textureLayer->setBounds(gfx::Size(10, 10)); | 2854 textureLayer->setBounds(gfx::Size(10, 10)); |
2808 textureLayer->setAnchorPoint(gfx::PointF(0, 0)); | 2855 textureLayer->setAnchorPoint(gfx::PointF(0, 0)); |
2809 textureLayer->setContentBounds(gfx::Size(10, 10)); | 2856 textureLayer->setContentBounds(gfx::Size(10, 10)); |
2810 textureLayer->setDrawsContent(true); | 2857 textureLayer->setDrawsContent(true); |
2811 textureLayer->setTextureId(StrictWebGraphicsContext3D::kExternalTextureId); | 2858 textureLayer->setTextureId(StrictWebGraphicsContext3D::kExternalTextureId); |
| 2859 textureLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
2812 rootLayer->addChild(textureLayer.PassAs<LayerImpl>()); | 2860 rootLayer->addChild(textureLayer.PassAs<LayerImpl>()); |
2813 | 2861 |
2814 scoped_ptr<TiledLayerImpl> maskLayer = TiledLayerImpl::create(layerId++); | 2862 scoped_ptr<TiledLayerImpl> maskLayer = TiledLayerImpl::create(layerId++); |
2815 maskLayer->setBounds(gfx::Size(10, 10)); | 2863 maskLayer->setBounds(gfx::Size(10, 10)); |
2816 maskLayer->setAnchorPoint(gfx::PointF(0, 0)); | 2864 maskLayer->setAnchorPoint(gfx::PointF(0, 0)); |
2817 maskLayer->setContentBounds(gfx::Size(10, 10)); | 2865 maskLayer->setContentBounds(gfx::Size(10, 10)); |
2818 maskLayer->setDrawsContent(true); | 2866 maskLayer->setDrawsContent(true); |
2819 maskLayer->setSkipsDraw(false); | 2867 maskLayer->setSkipsDraw(false); |
2820 maskLayer->setTilingData(*tilingData); | 2868 maskLayer->setTilingData(*tilingData); |
2821 maskLayer->pushTileProperties(0, 0, 1, gfx::Rect(0, 0, 10, 10), false); | 2869 maskLayer->pushTileProperties(0, 0, 1, gfx::Rect(0, 0, 10, 10), false); |
| 2870 maskLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
2822 | 2871 |
2823 scoped_ptr<TextureLayerImpl> textureLayerWithMask = TextureLayerImpl::create
(layerId++); | 2872 scoped_ptr<TextureLayerImpl> textureLayerWithMask = TextureLayerImpl::create
(layerId++); |
2824 textureLayerWithMask->setBounds(gfx::Size(10, 10)); | 2873 textureLayerWithMask->setBounds(gfx::Size(10, 10)); |
2825 textureLayerWithMask->setAnchorPoint(gfx::PointF(0, 0)); | 2874 textureLayerWithMask->setAnchorPoint(gfx::PointF(0, 0)); |
2826 textureLayerWithMask->setContentBounds(gfx::Size(10, 10)); | 2875 textureLayerWithMask->setContentBounds(gfx::Size(10, 10)); |
2827 textureLayerWithMask->setDrawsContent(true); | 2876 textureLayerWithMask->setDrawsContent(true); |
2828 textureLayerWithMask->setTextureId(StrictWebGraphicsContext3D::kExternalText
ureId); | 2877 textureLayerWithMask->setTextureId(StrictWebGraphicsContext3D::kExternalText
ureId); |
2829 textureLayerWithMask->setMaskLayer(maskLayer.PassAs<LayerImpl>()); | 2878 textureLayerWithMask->setMaskLayer(maskLayer.PassAs<LayerImpl>()); |
| 2879 textureLayerWithMask->setLayerTreeHostImpl(m_hostImpl.get()); |
2830 rootLayer->addChild(textureLayerWithMask.PassAs<LayerImpl>()); | 2880 rootLayer->addChild(textureLayerWithMask.PassAs<LayerImpl>()); |
2831 | 2881 |
2832 FakeVideoFrame videoFrame(VideoFrame::CreateColorFrame(gfx::Size(4, 4), | 2882 FakeVideoFrame videoFrame(VideoFrame::CreateColorFrame(gfx::Size(4, 4), |
2833 0x80, 0x80, 0x80, | 2883 0x80, 0x80, 0x80, |
2834 base::TimeDelta())); | 2884 base::TimeDelta())); |
2835 VideoLayerImpl::FrameUnwrapper unwrapper = | 2885 VideoLayerImpl::FrameUnwrapper unwrapper = |
2836 base::Bind(FakeVideoFrame::toVideoFrame); | 2886 base::Bind(FakeVideoFrame::toVideoFrame); |
2837 FakeVideoFrameProvider provider; | 2887 FakeVideoFrameProvider provider; |
2838 provider.setFrame(&videoFrame); | 2888 provider.setFrame(&videoFrame); |
2839 scoped_ptr<VideoLayerImpl> videoLayer = VideoLayerImpl::create(layerId++, &p
rovider, unwrapper); | 2889 scoped_ptr<VideoLayerImpl> videoLayer = VideoLayerImpl::create(layerId++, &p
rovider, unwrapper); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2999 private: | 3049 private: |
3000 base::hash_map<WebGLId, bool> m_textures; | 3050 base::hash_map<WebGLId, bool> m_textures; |
3001 unsigned m_numTextures; | 3051 unsigned m_numTextures; |
3002 }; | 3052 }; |
3003 | 3053 |
3004 TEST_P(LayerTreeHostImplTest, layersFreeTextures) | 3054 TEST_P(LayerTreeHostImplTest, layersFreeTextures) |
3005 { | 3055 { |
3006 scoped_ptr<LayerImpl> rootLayer(LayerImpl::create(1)); | 3056 scoped_ptr<LayerImpl> rootLayer(LayerImpl::create(1)); |
3007 rootLayer->setBounds(gfx::Size(10, 10)); | 3057 rootLayer->setBounds(gfx::Size(10, 10)); |
3008 rootLayer->setAnchorPoint(gfx::PointF(0, 0)); | 3058 rootLayer->setAnchorPoint(gfx::PointF(0, 0)); |
| 3059 rootLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
3009 | 3060 |
3010 scoped_ptr<TiledLayerImpl> tileLayer = TiledLayerImpl::create(2); | 3061 scoped_ptr<TiledLayerImpl> tileLayer = TiledLayerImpl::create(2); |
3011 tileLayer->setBounds(gfx::Size(10, 10)); | 3062 tileLayer->setBounds(gfx::Size(10, 10)); |
3012 tileLayer->setAnchorPoint(gfx::PointF(0, 0)); | 3063 tileLayer->setAnchorPoint(gfx::PointF(0, 0)); |
3013 tileLayer->setContentBounds(gfx::Size(10, 10)); | 3064 tileLayer->setContentBounds(gfx::Size(10, 10)); |
3014 tileLayer->setDrawsContent(true); | 3065 tileLayer->setDrawsContent(true); |
3015 tileLayer->setSkipsDraw(false); | 3066 tileLayer->setSkipsDraw(false); |
3016 scoped_ptr<LayerTilingData> tilingData(LayerTilingData::create(gfx::Size(10,
10), LayerTilingData::NoBorderTexels)); | 3067 scoped_ptr<LayerTilingData> tilingData(LayerTilingData::create(gfx::Size(10,
10), LayerTilingData::NoBorderTexels)); |
3017 tilingData->setBounds(gfx::Size(10, 10)); | 3068 tilingData->setBounds(gfx::Size(10, 10)); |
3018 tileLayer->setTilingData(*tilingData); | 3069 tileLayer->setTilingData(*tilingData); |
3019 tileLayer->pushTileProperties(0, 0, 1, gfx::Rect(0, 0, 10, 10), false); | 3070 tileLayer->pushTileProperties(0, 0, 1, gfx::Rect(0, 0, 10, 10), false); |
| 3071 tileLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
3020 rootLayer->addChild(tileLayer.PassAs<LayerImpl>()); | 3072 rootLayer->addChild(tileLayer.PassAs<LayerImpl>()); |
3021 | 3073 |
3022 scoped_ptr<TextureLayerImpl> textureLayer = TextureLayerImpl::create(3); | 3074 scoped_ptr<TextureLayerImpl> textureLayer = TextureLayerImpl::create(3); |
3023 textureLayer->setBounds(gfx::Size(10, 10)); | 3075 textureLayer->setBounds(gfx::Size(10, 10)); |
3024 textureLayer->setAnchorPoint(gfx::PointF(0, 0)); | 3076 textureLayer->setAnchorPoint(gfx::PointF(0, 0)); |
3025 textureLayer->setContentBounds(gfx::Size(10, 10)); | 3077 textureLayer->setContentBounds(gfx::Size(10, 10)); |
3026 textureLayer->setDrawsContent(true); | 3078 textureLayer->setDrawsContent(true); |
3027 textureLayer->setTextureId(1); | 3079 textureLayer->setTextureId(1); |
| 3080 textureLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
3028 rootLayer->addChild(textureLayer.PassAs<LayerImpl>()); | 3081 rootLayer->addChild(textureLayer.PassAs<LayerImpl>()); |
3029 | 3082 |
3030 VideoLayerImpl::FrameUnwrapper unwrapper = | 3083 VideoLayerImpl::FrameUnwrapper unwrapper = |
3031 base::Bind(FakeVideoFrame::toVideoFrame); | 3084 base::Bind(FakeVideoFrame::toVideoFrame); |
3032 FakeVideoFrameProvider provider; | 3085 FakeVideoFrameProvider provider; |
3033 scoped_ptr<VideoLayerImpl> videoLayer = VideoLayerImpl::create(4, &provider,
unwrapper); | 3086 scoped_ptr<VideoLayerImpl> videoLayer = VideoLayerImpl::create(4, &provider,
unwrapper); |
3034 videoLayer->setBounds(gfx::Size(10, 10)); | 3087 videoLayer->setBounds(gfx::Size(10, 10)); |
3035 videoLayer->setAnchorPoint(gfx::PointF(0, 0)); | 3088 videoLayer->setAnchorPoint(gfx::PointF(0, 0)); |
3036 videoLayer->setContentBounds(gfx::Size(10, 10)); | 3089 videoLayer->setContentBounds(gfx::Size(10, 10)); |
3037 videoLayer->setDrawsContent(true); | 3090 videoLayer->setDrawsContent(true); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3106 static void addDrawingLayerTo(LayerImpl* parent, int id, const gfx::Rect& layerR
ect, LayerImpl** result) | 3159 static void addDrawingLayerTo(LayerImpl* parent, int id, const gfx::Rect& layerR
ect, LayerImpl** result) |
3107 { | 3160 { |
3108 scoped_ptr<LayerImpl> layer = FakeLayerWithQuads::create(id); | 3161 scoped_ptr<LayerImpl> layer = FakeLayerWithQuads::create(id); |
3109 LayerImpl* layerPtr = layer.get(); | 3162 LayerImpl* layerPtr = layer.get(); |
3110 layerPtr->setAnchorPoint(gfx::PointF(0, 0)); | 3163 layerPtr->setAnchorPoint(gfx::PointF(0, 0)); |
3111 layerPtr->setPosition(gfx::PointF(layerRect.origin())); | 3164 layerPtr->setPosition(gfx::PointF(layerRect.origin())); |
3112 layerPtr->setBounds(layerRect.size()); | 3165 layerPtr->setBounds(layerRect.size()); |
3113 layerPtr->setContentBounds(layerRect.size()); | 3166 layerPtr->setContentBounds(layerRect.size()); |
3114 layerPtr->setDrawsContent(true); // only children draw content | 3167 layerPtr->setDrawsContent(true); // only children draw content |
3115 layerPtr->setContentsOpaque(true); | 3168 layerPtr->setContentsOpaque(true); |
| 3169 layerPtr->setLayerTreeHostImpl(parent ? parent->layerTreeHostImpl() : 0); |
3116 parent->addChild(layer.Pass()); | 3170 parent->addChild(layer.Pass()); |
3117 if (result) | 3171 if (result) |
3118 *result = layerPtr; | 3172 *result = layerPtr; |
3119 } | 3173 } |
3120 | 3174 |
3121 static void setupLayersForTextureCaching(LayerTreeHostImpl* layerTreeHostImpl, L
ayerImpl*& rootPtr, LayerImpl*& intermediateLayerPtr, LayerImpl*& surfaceLayerPt
r, LayerImpl*& childPtr, const gfx::Size& rootSize) | 3175 static void setupLayersForTextureCaching(LayerTreeHostImpl* layerTreeHostImpl, L
ayerImpl*& rootPtr, LayerImpl*& intermediateLayerPtr, LayerImpl*& surfaceLayerPt
r, LayerImpl*& childPtr, const gfx::Size& rootSize) |
3122 { | 3176 { |
3123 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); | 3177 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); |
3124 | 3178 |
3125 layerTreeHostImpl->initializeRenderer(context.Pass()); | 3179 layerTreeHostImpl->initializeRenderer(context.Pass()); |
3126 layerTreeHostImpl->setViewportSize(rootSize, rootSize); | 3180 layerTreeHostImpl->setViewportSize(rootSize, rootSize); |
3127 | 3181 |
3128 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3182 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
3129 rootPtr = root.get(); | 3183 rootPtr = root.get(); |
3130 | 3184 |
3131 root->setAnchorPoint(gfx::PointF(0, 0)); | 3185 root->setAnchorPoint(gfx::PointF(0, 0)); |
3132 root->setPosition(gfx::PointF(0, 0)); | 3186 root->setPosition(gfx::PointF(0, 0)); |
3133 root->setBounds(rootSize); | 3187 root->setBounds(rootSize); |
3134 root->setContentBounds(rootSize); | 3188 root->setContentBounds(rootSize); |
3135 root->setDrawsContent(true); | 3189 root->setDrawsContent(true); |
| 3190 root->setLayerTreeHostImpl(layerTreeHostImpl); |
3136 layerTreeHostImpl->setRootLayer(root.Pass()); | 3191 layerTreeHostImpl->setRootLayer(root.Pass()); |
3137 | 3192 |
3138 addDrawingLayerTo(rootPtr, 2, gfx::Rect(10, 10, rootSize.width(), rootSize.h
eight()), &intermediateLayerPtr); | 3193 addDrawingLayerTo(rootPtr, 2, gfx::Rect(10, 10, rootSize.width(), rootSize.h
eight()), &intermediateLayerPtr); |
3139 intermediateLayerPtr->setDrawsContent(false); // only children draw content | 3194 intermediateLayerPtr->setDrawsContent(false); // only children draw content |
3140 | 3195 |
3141 // Surface layer is the layer that changes its opacity | 3196 // Surface layer is the layer that changes its opacity |
3142 // It will contain other layers that draw content. | 3197 // It will contain other layers that draw content. |
3143 addDrawingLayerTo(intermediateLayerPtr, 3, gfx::Rect(10, 10, rootSize.width(
), rootSize.height()), &surfaceLayerPtr); | 3198 addDrawingLayerTo(intermediateLayerPtr, 3, gfx::Rect(10, 10, rootSize.width(
), rootSize.height()), &surfaceLayerPtr); |
3144 surfaceLayerPtr->setDrawsContent(false); // only children draw content | 3199 surfaceLayerPtr->setDrawsContent(false); // only children draw content |
3145 surfaceLayerPtr->setOpacity(0.5f); | 3200 surfaceLayerPtr->setOpacity(0.5f); |
(...skipping 27 matching lines...) Expand all Loading... |
3173 | 3228 |
3174 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3229 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
3175 rootPtr = root.get(); | 3230 rootPtr = root.get(); |
3176 | 3231 |
3177 root->setAnchorPoint(gfx::PointF(0, 0)); | 3232 root->setAnchorPoint(gfx::PointF(0, 0)); |
3178 root->setPosition(gfx::PointF(0, 0)); | 3233 root->setPosition(gfx::PointF(0, 0)); |
3179 root->setBounds(rootSize); | 3234 root->setBounds(rootSize); |
3180 root->setContentBounds(rootSize); | 3235 root->setContentBounds(rootSize); |
3181 root->setDrawsContent(true); | 3236 root->setDrawsContent(true); |
3182 root->setMasksToBounds(true); | 3237 root->setMasksToBounds(true); |
| 3238 root->setLayerTreeHostImpl(myHostImpl.get()); |
3183 myHostImpl->setRootLayer(root.Pass()); | 3239 myHostImpl->setRootLayer(root.Pass()); |
3184 | 3240 |
3185 addDrawingLayerTo(rootPtr, 3, gfx::Rect(0, 0, rootSize.width(), rootSize.hei
ght()), &surfaceLayerPtr); | 3241 addDrawingLayerTo(rootPtr, 3, gfx::Rect(0, 0, rootSize.width(), rootSize.hei
ght()), &surfaceLayerPtr); |
3186 surfaceLayerPtr->setDrawsContent(false); | 3242 surfaceLayerPtr->setDrawsContent(false); |
3187 | 3243 |
3188 // Surface layer is the layer that changes its opacity | 3244 // Surface layer is the layer that changes its opacity |
3189 // It will contain other layers that draw content. | 3245 // It will contain other layers that draw content. |
3190 surfaceLayerPtr->setOpacity(0.5f); | 3246 surfaceLayerPtr->setOpacity(0.5f); |
3191 surfaceLayerPtr->setForceRenderSurface(true); // This will cause it to have
a surface | 3247 surfaceLayerPtr->setForceRenderSurface(true); // This will cause it to have
a surface |
3192 | 3248 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3284 | 3340 |
3285 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3341 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
3286 rootPtr = root.get(); | 3342 rootPtr = root.get(); |
3287 | 3343 |
3288 root->setAnchorPoint(gfx::PointF(0, 0)); | 3344 root->setAnchorPoint(gfx::PointF(0, 0)); |
3289 root->setPosition(gfx::PointF(0, 0)); | 3345 root->setPosition(gfx::PointF(0, 0)); |
3290 root->setBounds(rootSize); | 3346 root->setBounds(rootSize); |
3291 root->setContentBounds(rootSize); | 3347 root->setContentBounds(rootSize); |
3292 root->setDrawsContent(true); | 3348 root->setDrawsContent(true); |
3293 root->setMasksToBounds(true); | 3349 root->setMasksToBounds(true); |
| 3350 root->setLayerTreeHostImpl(myHostImpl.get()); |
| 3351 root->setLayerTreeHostImpl(myHostImpl.get()); |
3294 myHostImpl->setRootLayer(root.Pass()); | 3352 myHostImpl->setRootLayer(root.Pass()); |
3295 | 3353 |
3296 addDrawingLayerTo(rootPtr, 2, gfx::Rect(300, 300, 300, 300), &layerS1Ptr); | 3354 addDrawingLayerTo(rootPtr, 2, gfx::Rect(300, 300, 300, 300), &layerS1Ptr); |
3297 layerS1Ptr->setForceRenderSurface(true); | 3355 layerS1Ptr->setForceRenderSurface(true); |
| 3356 layerS1Ptr->setLayerTreeHostImpl(myHostImpl.get()); |
3298 | 3357 |
3299 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(10, 10, 10, 10), 0); // L11 | 3358 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(10, 10, 10, 10), 0); // L11 |
3300 addDrawingLayerTo(layerS1Ptr, 4, gfx::Rect(0, 0, 30, 30), 0); // L12 | 3359 addDrawingLayerTo(layerS1Ptr, 4, gfx::Rect(0, 0, 30, 30), 0); // L12 |
3301 | 3360 |
3302 addDrawingLayerTo(rootPtr, 5, gfx::Rect(550, 250, 300, 400), &layerS2Ptr); | 3361 addDrawingLayerTo(rootPtr, 5, gfx::Rect(550, 250, 300, 400), &layerS2Ptr); |
3303 layerS2Ptr->setForceRenderSurface(true); | 3362 layerS2Ptr->setForceRenderSurface(true); |
| 3363 layerS2Ptr->setLayerTreeHostImpl(myHostImpl.get()); |
3304 | 3364 |
3305 addDrawingLayerTo(layerS2Ptr, 6, gfx::Rect(20, 20, 5, 5), 0); // L21 | 3365 addDrawingLayerTo(layerS2Ptr, 6, gfx::Rect(20, 20, 5, 5), 0); // L21 |
3306 | 3366 |
3307 // Initial draw - must receive all quads | 3367 // Initial draw - must receive all quads |
3308 { | 3368 { |
3309 LayerTreeHostImpl::FrameData frame; | 3369 LayerTreeHostImpl::FrameData frame; |
3310 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 3370 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
3311 | 3371 |
3312 // Must receive 3 render passes. | 3372 // Must receive 3 render passes. |
3313 // For Root, there are 2 quads; for S1, there are 2 quads (1 is occluded
); for S2, there is 2 quads. | 3373 // For Root, there are 2 quads; for S1, there are 2 quads (1 is occluded
); for S2, there is 2 quads. |
(...skipping 29 matching lines...) Expand all Loading... |
3343 myHostImpl->drawLayers(frame); | 3403 myHostImpl->drawLayers(frame); |
3344 myHostImpl->didDrawAllLayers(frame); | 3404 myHostImpl->didDrawAllLayers(frame); |
3345 } | 3405 } |
3346 | 3406 |
3347 // "Re-occlude" surface S1 and repeat draw. | 3407 // "Re-occlude" surface S1 and repeat draw. |
3348 // Must remove S1's render pass since it is now available in full. | 3408 // Must remove S1's render pass since it is now available in full. |
3349 // S2 has no change so must also be removed. | 3409 // S2 has no change so must also be removed. |
3350 transform = layerS2Ptr->transform(); | 3410 transform = layerS2Ptr->transform(); |
3351 transform.Translate(-15, -15); | 3411 transform.Translate(-15, -15); |
3352 layerS2Ptr->setTransform(transform); | 3412 layerS2Ptr->setTransform(transform); |
| 3413 EXPECT_TRUE(myHostImpl->needsUpdateLayers()); |
3353 { | 3414 { |
3354 LayerTreeHostImpl::FrameData frame; | 3415 LayerTreeHostImpl::FrameData frame; |
3355 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 3416 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
3356 | 3417 |
3357 // Must receive 1 render pass - for the root. | 3418 // Must receive 1 render pass - for the root. |
3358 ASSERT_EQ(1U, frame.renderPasses.size()); | 3419 ASSERT_EQ(1U, frame.renderPasses.size()); |
3359 | 3420 |
3360 EXPECT_EQ(2U, frame.renderPasses[0]->quad_list.size()); | 3421 EXPECT_EQ(2U, frame.renderPasses[0]->quad_list.size()); |
3361 | 3422 |
3362 myHostImpl->drawLayers(frame); | 3423 myHostImpl->drawLayers(frame); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3395 | 3456 |
3396 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3457 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
3397 rootPtr = root.get(); | 3458 rootPtr = root.get(); |
3398 | 3459 |
3399 root->setAnchorPoint(gfx::PointF(0, 0)); | 3460 root->setAnchorPoint(gfx::PointF(0, 0)); |
3400 root->setPosition(gfx::PointF(0, 0)); | 3461 root->setPosition(gfx::PointF(0, 0)); |
3401 root->setBounds(rootSize); | 3462 root->setBounds(rootSize); |
3402 root->setContentBounds(rootSize); | 3463 root->setContentBounds(rootSize); |
3403 root->setDrawsContent(true); | 3464 root->setDrawsContent(true); |
3404 root->setMasksToBounds(true); | 3465 root->setMasksToBounds(true); |
| 3466 root->setLayerTreeHostImpl(myHostImpl.get()); |
3405 myHostImpl->setRootLayer(root.Pass()); | 3467 myHostImpl->setRootLayer(root.Pass()); |
3406 | 3468 |
3407 addDrawingLayerTo(rootPtr, 2, gfx::Rect(0, 0, 800, 800), &layerS1Ptr); | 3469 addDrawingLayerTo(rootPtr, 2, gfx::Rect(0, 0, 800, 800), &layerS1Ptr); |
3408 layerS1Ptr->setForceRenderSurface(true); | 3470 layerS1Ptr->setForceRenderSurface(true); |
3409 layerS1Ptr->setDrawsContent(false); | 3471 layerS1Ptr->setDrawsContent(false); |
3410 | 3472 |
3411 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(0, 0, 300, 300), 0); // L11 | 3473 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(0, 0, 300, 300), 0); // L11 |
3412 addDrawingLayerTo(layerS1Ptr, 4, gfx::Rect(0, 500, 300, 300), 0); // L12 | 3474 addDrawingLayerTo(layerS1Ptr, 4, gfx::Rect(0, 500, 300, 300), 0); // L12 |
3413 addDrawingLayerTo(layerS1Ptr, 5, gfx::Rect(500, 0, 300, 300), 0); // L13 | 3475 addDrawingLayerTo(layerS1Ptr, 5, gfx::Rect(500, 0, 300, 300), 0); // L13 |
3414 addDrawingLayerTo(layerS1Ptr, 6, gfx::Rect(500, 500, 300, 300), 0); // L14 | 3476 addDrawingLayerTo(layerS1Ptr, 6, gfx::Rect(500, 500, 300, 300), 0); // L14 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3507 | 3569 |
3508 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3570 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
3509 rootPtr = root.get(); | 3571 rootPtr = root.get(); |
3510 | 3572 |
3511 root->setAnchorPoint(gfx::PointF(0, 0)); | 3573 root->setAnchorPoint(gfx::PointF(0, 0)); |
3512 root->setPosition(gfx::PointF(0, 0)); | 3574 root->setPosition(gfx::PointF(0, 0)); |
3513 root->setBounds(rootSize); | 3575 root->setBounds(rootSize); |
3514 root->setContentBounds(rootSize); | 3576 root->setContentBounds(rootSize); |
3515 root->setDrawsContent(true); | 3577 root->setDrawsContent(true); |
3516 root->setMasksToBounds(true); | 3578 root->setMasksToBounds(true); |
| 3579 root->setLayerTreeHostImpl(myHostImpl.get()); |
3517 myHostImpl->setRootLayer(root.Pass()); | 3580 myHostImpl->setRootLayer(root.Pass()); |
3518 | 3581 |
3519 addDrawingLayerTo(rootPtr, 2, gfx::Rect(0, 0, 400, 400), &layerS1Ptr); | 3582 addDrawingLayerTo(rootPtr, 2, gfx::Rect(0, 0, 400, 400), &layerS1Ptr); |
3520 layerS1Ptr->setForceRenderSurface(true); | 3583 layerS1Ptr->setForceRenderSurface(true); |
3521 | 3584 |
3522 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(0, 0, 300, 300), 0); // L11 | 3585 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(0, 0, 300, 300), 0); // L11 |
3523 addDrawingLayerTo(layerS1Ptr, 4, gfx::Rect(100, 0, 300, 300), 0); // L12 | 3586 addDrawingLayerTo(layerS1Ptr, 4, gfx::Rect(100, 0, 300, 300), 0); // L12 |
3524 | 3587 |
3525 addDrawingLayerTo(rootPtr, 7, gfx::Rect(200, 0, 300, 300), &layerS2Ptr); | 3588 addDrawingLayerTo(rootPtr, 7, gfx::Rect(200, 0, 300, 300), &layerS2Ptr); |
3526 layerS2Ptr->setForceRenderSurface(true); | 3589 layerS2Ptr->setForceRenderSurface(true); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3588 | 3651 |
3589 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3652 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
3590 rootPtr = root.get(); | 3653 rootPtr = root.get(); |
3591 | 3654 |
3592 root->setAnchorPoint(gfx::PointF(0, 0)); | 3655 root->setAnchorPoint(gfx::PointF(0, 0)); |
3593 root->setPosition(gfx::PointF(0, 0)); | 3656 root->setPosition(gfx::PointF(0, 0)); |
3594 root->setBounds(rootSize); | 3657 root->setBounds(rootSize); |
3595 root->setContentBounds(rootSize); | 3658 root->setContentBounds(rootSize); |
3596 root->setDrawsContent(true); | 3659 root->setDrawsContent(true); |
3597 root->setMasksToBounds(true); | 3660 root->setMasksToBounds(true); |
| 3661 root->setLayerTreeHostImpl(myHostImpl.get()); |
3598 myHostImpl->setRootLayer(root.Pass()); | 3662 myHostImpl->setRootLayer(root.Pass()); |
3599 | 3663 |
3600 addDrawingLayerTo(rootPtr, 2, gfx::Rect(0, 0, 400, 400), &layerS1Ptr); | 3664 addDrawingLayerTo(rootPtr, 2, gfx::Rect(0, 0, 400, 400), &layerS1Ptr); |
3601 layerS1Ptr->setForceRenderSurface(true); | 3665 layerS1Ptr->setForceRenderSurface(true); |
3602 gfx::Transform transform = layerS1Ptr->transform(); | 3666 gfx::Transform transform = layerS1Ptr->transform(); |
3603 transform.Translate(200, 200); | 3667 transform.Translate(200, 200); |
3604 transform.Rotate(45); | 3668 transform.Rotate(45); |
3605 transform.Translate(-200, -200); | 3669 transform.Translate(-200, -200); |
3606 layerS1Ptr->setTransform(transform); | 3670 layerS1Ptr->setTransform(transform); |
3607 | 3671 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3672 | 3736 |
3673 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3737 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
3674 rootPtr = root.get(); | 3738 rootPtr = root.get(); |
3675 | 3739 |
3676 root->setAnchorPoint(gfx::PointF(0, 0)); | 3740 root->setAnchorPoint(gfx::PointF(0, 0)); |
3677 root->setPosition(gfx::PointF(0, 0)); | 3741 root->setPosition(gfx::PointF(0, 0)); |
3678 root->setBounds(rootSize); | 3742 root->setBounds(rootSize); |
3679 root->setContentBounds(rootSize); | 3743 root->setContentBounds(rootSize); |
3680 root->setDrawsContent(true); | 3744 root->setDrawsContent(true); |
3681 root->setMasksToBounds(true); | 3745 root->setMasksToBounds(true); |
| 3746 root->setLayerTreeHostImpl(myHostImpl.get()); |
3682 myHostImpl->setRootLayer(root.Pass()); | 3747 myHostImpl->setRootLayer(root.Pass()); |
3683 | 3748 |
3684 addDrawingLayerTo(rootPtr, 2, gfx::Rect(300, 300, 300, 300), &layerS1Ptr); | 3749 addDrawingLayerTo(rootPtr, 2, gfx::Rect(300, 300, 300, 300), &layerS1Ptr); |
3685 layerS1Ptr->setForceRenderSurface(true); | 3750 layerS1Ptr->setForceRenderSurface(true); |
3686 | 3751 |
3687 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(10, 10, 10, 10), 0); // L11 | 3752 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(10, 10, 10, 10), 0); // L11 |
3688 addDrawingLayerTo(layerS1Ptr, 4, gfx::Rect(0, 0, 30, 30), 0); // L12 | 3753 addDrawingLayerTo(layerS1Ptr, 4, gfx::Rect(0, 0, 30, 30), 0); // L12 |
3689 | 3754 |
3690 addDrawingLayerTo(rootPtr, 5, gfx::Rect(550, 250, 300, 400), &layerS2Ptr); | 3755 addDrawingLayerTo(rootPtr, 5, gfx::Rect(550, 250, 300, 400), &layerS2Ptr); |
3691 layerS2Ptr->setForceRenderSurface(true); | 3756 layerS2Ptr->setForceRenderSurface(true); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3784 | 3849 |
3785 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); | 3850 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); |
3786 myHostImpl->initializeRenderer(context.Pass()); | 3851 myHostImpl->initializeRenderer(context.Pass()); |
3787 | 3852 |
3788 root->setAnchorPoint(gfx::PointF(0, 0)); | 3853 root->setAnchorPoint(gfx::PointF(0, 0)); |
3789 root->setPosition(gfx::PointF(rootRect.x(), rootRect.y())); | 3854 root->setPosition(gfx::PointF(rootRect.x(), rootRect.y())); |
3790 root->setBounds(gfx::Size(rootRect.width(), rootRect.height())); | 3855 root->setBounds(gfx::Size(rootRect.width(), rootRect.height())); |
3791 root->setContentBounds(root->bounds()); | 3856 root->setContentBounds(root->bounds()); |
3792 root->setDrawsContent(true); | 3857 root->setDrawsContent(true); |
3793 root->setMasksToBounds(true); | 3858 root->setMasksToBounds(true); |
| 3859 root->setLayerTreeHostImpl(myHostImpl.get()); |
3794 | 3860 |
3795 child->setAnchorPoint(gfx::PointF(0, 0)); | 3861 child->setAnchorPoint(gfx::PointF(0, 0)); |
3796 child->setPosition(gfx::PointF(childRect.x(), childRect.y())); | 3862 child->setPosition(gfx::PointF(childRect.x(), childRect.y())); |
3797 child->setOpacity(0.5); | 3863 child->setOpacity(0.5); |
3798 child->setBounds(gfx::Size(childRect.width(), childRect.height())); | 3864 child->setBounds(gfx::Size(childRect.width(), childRect.height())); |
3799 child->setContentBounds(child->bounds()); | 3865 child->setContentBounds(child->bounds()); |
3800 child->setDrawsContent(true); | 3866 child->setDrawsContent(true); |
3801 child->setSkipsDraw(false); | 3867 child->setSkipsDraw(false); |
| 3868 child->setLayerTreeHostImpl(myHostImpl.get()); |
3802 | 3869 |
3803 // child layer has 10x10 tiles. | 3870 // child layer has 10x10 tiles. |
3804 scoped_ptr<LayerTilingData> tiler = LayerTilingData::create(gfx::Size(10, 10
), LayerTilingData::HasBorderTexels); | 3871 scoped_ptr<LayerTilingData> tiler = LayerTilingData::create(gfx::Size(10, 10
), LayerTilingData::HasBorderTexels); |
3805 tiler->setBounds(child->contentBounds()); | 3872 tiler->setBounds(child->contentBounds()); |
3806 child->setTilingData(*tiler.get()); | 3873 child->setTilingData(*tiler.get()); |
3807 | 3874 |
3808 grandChild->setAnchorPoint(gfx::PointF(0, 0)); | 3875 grandChild->setAnchorPoint(gfx::PointF(0, 0)); |
3809 grandChild->setPosition(gfx::Point(grandChildRect.x(), grandChildRect.y())); | 3876 grandChild->setPosition(gfx::Point(grandChildRect.x(), grandChildRect.y())); |
3810 grandChild->setBounds(gfx::Size(grandChildRect.width(), grandChildRect.heigh
t())); | 3877 grandChild->setBounds(gfx::Size(grandChildRect.width(), grandChildRect.heigh
t())); |
3811 grandChild->setContentBounds(grandChild->bounds()); | 3878 grandChild->setContentBounds(grandChild->bounds()); |
3812 grandChild->setDrawsContent(true); | 3879 grandChild->setDrawsContent(true); |
| 3880 grandChild->setLayerTreeHostImpl(myHostImpl.get()); |
3813 | 3881 |
3814 TiledLayerImpl* childPtr = child.get(); | 3882 TiledLayerImpl* childPtr = child.get(); |
3815 RenderPass::Id childPassId(childPtr->id(), 0); | 3883 RenderPass::Id childPassId(childPtr->id(), 0); |
3816 | 3884 |
3817 child->addChild(grandChild.Pass()); | 3885 child->addChild(grandChild.Pass()); |
3818 root->addChild(child.PassAs<LayerImpl>()); | 3886 root->addChild(child.PassAs<LayerImpl>()); |
3819 myHostImpl->setRootLayer(root.Pass()); | 3887 myHostImpl->setRootLayer(root.Pass()); |
3820 myHostImpl->setViewportSize(rootRect.size(), rootRect.size()); | 3888 myHostImpl->setViewportSize(rootRect.size(), rootRect.size()); |
3821 | 3889 |
3822 EXPECT_FALSE(myHostImpl->renderer()->haveCachedResourcesForRenderPassId(chil
dPassId)); | 3890 EXPECT_FALSE(myHostImpl->renderer()->haveCachedResourcesForRenderPassId(chil
dPassId)); |
(...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4895 { | 4963 { |
4896 pinchZoomPanViewportAndScrollBoundaryTest(2); | 4964 pinchZoomPanViewportAndScrollBoundaryTest(2); |
4897 } | 4965 } |
4898 | 4966 |
4899 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, | 4967 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, |
4900 LayerTreeHostImplTest, | 4968 LayerTreeHostImplTest, |
4901 ::testing::Values(false, true)); | 4969 ::testing::Values(false, true)); |
4902 | 4970 |
4903 } // namespace | 4971 } // namespace |
4904 } // namespace cc | 4972 } // namespace cc |
OLD | NEW |