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/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 180 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
181 // Set the BeginFrameArgs so that methods which use it are able to. | 181 // Set the BeginFrameArgs so that methods which use it are able to. |
182 host_impl_->WillBeginImplFrame( | 182 host_impl_->WillBeginImplFrame( |
183 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE)); | 183 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE)); |
184 return init; | 184 return init; |
185 } | 185 } |
186 | 186 |
187 void SetupRootLayerImpl(scoped_ptr<LayerImpl> root) { | 187 void SetupRootLayerImpl(scoped_ptr<LayerImpl> root) { |
188 root->SetPosition(gfx::PointF()); | 188 root->SetPosition(gfx::PointF()); |
189 root->SetBounds(gfx::Size(10, 10)); | 189 root->SetBounds(gfx::Size(10, 10)); |
190 root->SetContentBounds(gfx::Size(10, 10)); | |
191 root->SetDrawsContent(true); | 190 root->SetDrawsContent(true); |
192 root->draw_properties().visible_content_rect = gfx::Rect(0, 0, 10, 10); | 191 root->draw_properties().visible_content_rect = gfx::Rect(0, 0, 10, 10); |
193 root->SetHasRenderSurface(true); | 192 root->SetHasRenderSurface(true); |
194 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 193 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
195 } | 194 } |
196 | 195 |
197 static void ExpectClearedScrollDeltasRecursive(LayerImpl* layer) { | 196 static void ExpectClearedScrollDeltasRecursive(LayerImpl* layer) { |
198 ASSERT_EQ(layer->ScrollDelta(), gfx::Vector2d()); | 197 ASSERT_EQ(layer->ScrollDelta(), gfx::Vector2d()); |
199 for (size_t i = 0; i < layer->children().size(); ++i) | 198 for (size_t i = 0; i < layer->children().size(); ++i) |
200 ExpectClearedScrollDeltasRecursive(layer->children()[i]); | 199 ExpectClearedScrollDeltasRecursive(layer->children()[i]); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 const int kOuterViewportClipLayerId = 116; | 234 const int kOuterViewportClipLayerId = 116; |
236 const int kOuterViewportScrollLayerId = 117; | 235 const int kOuterViewportScrollLayerId = 117; |
237 const int kContentLayerId = 118; | 236 const int kContentLayerId = 118; |
238 const int kInnerViewportScrollLayerId = 2; | 237 const int kInnerViewportScrollLayerId = 2; |
239 const int kInnerViewportClipLayerId = 4; | 238 const int kInnerViewportClipLayerId = 4; |
240 const int kPageScaleLayerId = 5; | 239 const int kPageScaleLayerId = 5; |
241 | 240 |
242 scoped_ptr<LayerImpl> root = | 241 scoped_ptr<LayerImpl> root = |
243 LayerImpl::Create(layer_tree_impl, 1); | 242 LayerImpl::Create(layer_tree_impl, 1); |
244 root->SetBounds(content_size); | 243 root->SetBounds(content_size); |
245 root->SetContentBounds(content_size); | |
246 root->SetPosition(gfx::PointF()); | 244 root->SetPosition(gfx::PointF()); |
247 root->SetHasRenderSurface(true); | 245 root->SetHasRenderSurface(true); |
248 | 246 |
249 scoped_ptr<LayerImpl> inner_scroll = | 247 scoped_ptr<LayerImpl> inner_scroll = |
250 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId); | 248 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId); |
251 inner_scroll->SetIsContainerForFixedPositionLayers(true); | 249 inner_scroll->SetIsContainerForFixedPositionLayers(true); |
252 inner_scroll->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); | 250 inner_scroll->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); |
253 | 251 |
254 scoped_ptr<LayerImpl> inner_clip = | 252 scoped_ptr<LayerImpl> inner_clip = |
255 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId); | 253 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId); |
256 inner_clip->SetBounds( | 254 inner_clip->SetBounds( |
257 gfx::Size(content_size.width() / 2, content_size.height() / 2)); | 255 gfx::Size(content_size.width() / 2, content_size.height() / 2)); |
258 | 256 |
259 scoped_ptr<LayerImpl> page_scale = | 257 scoped_ptr<LayerImpl> page_scale = |
260 LayerImpl::Create(layer_tree_impl, kPageScaleLayerId); | 258 LayerImpl::Create(layer_tree_impl, kPageScaleLayerId); |
261 | 259 |
262 inner_scroll->SetScrollClipLayer(inner_clip->id()); | 260 inner_scroll->SetScrollClipLayer(inner_clip->id()); |
263 inner_scroll->SetBounds(content_size); | 261 inner_scroll->SetBounds(content_size); |
264 inner_scroll->SetContentBounds(content_size); | |
265 inner_scroll->SetPosition(gfx::PointF()); | 262 inner_scroll->SetPosition(gfx::PointF()); |
266 | 263 |
267 scoped_ptr<LayerImpl> outer_clip = | 264 scoped_ptr<LayerImpl> outer_clip = |
268 LayerImpl::Create(layer_tree_impl, kOuterViewportClipLayerId); | 265 LayerImpl::Create(layer_tree_impl, kOuterViewportClipLayerId); |
269 outer_clip->SetBounds(content_size); | 266 outer_clip->SetBounds(content_size); |
270 outer_clip->SetIsContainerForFixedPositionLayers(true); | 267 outer_clip->SetIsContainerForFixedPositionLayers(true); |
271 | 268 |
272 scoped_ptr<LayerImpl> outer_scroll = | 269 scoped_ptr<LayerImpl> outer_scroll = |
273 LayerImpl::Create(layer_tree_impl, kOuterViewportScrollLayerId); | 270 LayerImpl::Create(layer_tree_impl, kOuterViewportScrollLayerId); |
274 outer_scroll->SetScrollClipLayer(outer_clip->id()); | 271 outer_scroll->SetScrollClipLayer(outer_clip->id()); |
275 outer_scroll->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); | 272 outer_scroll->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); |
276 outer_scroll->SetBounds(content_size); | 273 outer_scroll->SetBounds(content_size); |
277 outer_scroll->SetContentBounds(content_size); | |
278 outer_scroll->SetPosition(gfx::PointF()); | 274 outer_scroll->SetPosition(gfx::PointF()); |
279 | 275 |
280 scoped_ptr<LayerImpl> contents = | 276 scoped_ptr<LayerImpl> contents = |
281 LayerImpl::Create(layer_tree_impl, kContentLayerId); | 277 LayerImpl::Create(layer_tree_impl, kContentLayerId); |
282 contents->SetDrawsContent(true); | 278 contents->SetDrawsContent(true); |
283 contents->SetBounds(content_size); | 279 contents->SetBounds(content_size); |
284 contents->SetContentBounds(content_size); | |
285 contents->SetPosition(gfx::PointF()); | 280 contents->SetPosition(gfx::PointF()); |
286 | 281 |
287 outer_scroll->AddChild(contents.Pass()); | 282 outer_scroll->AddChild(contents.Pass()); |
288 outer_clip->AddChild(outer_scroll.Pass()); | 283 outer_clip->AddChild(outer_scroll.Pass()); |
289 inner_scroll->AddChild(outer_clip.Pass()); | 284 inner_scroll->AddChild(outer_clip.Pass()); |
290 page_scale->AddChild(inner_scroll.Pass()); | 285 page_scale->AddChild(inner_scroll.Pass()); |
291 inner_clip->AddChild(page_scale.Pass()); | 286 inner_clip->AddChild(page_scale.Pass()); |
292 root->AddChild(inner_clip.Pass()); | 287 root->AddChild(inner_clip.Pass()); |
293 | 288 |
294 layer_tree_impl->SetRootLayer(root.Pass()); | 289 layer_tree_impl->SetRootLayer(root.Pass()); |
(...skipping 16 matching lines...) Expand all Loading... |
311 scoped_ptr<LayerImpl> CreateScrollableLayer(int id, | 306 scoped_ptr<LayerImpl> CreateScrollableLayer(int id, |
312 const gfx::Size& size, | 307 const gfx::Size& size, |
313 LayerImpl* clip_layer) { | 308 LayerImpl* clip_layer) { |
314 DCHECK(clip_layer); | 309 DCHECK(clip_layer); |
315 DCHECK(id != clip_layer->id()); | 310 DCHECK(id != clip_layer->id()); |
316 scoped_ptr<LayerImpl> layer = | 311 scoped_ptr<LayerImpl> layer = |
317 LayerImpl::Create(host_impl_->active_tree(), id); | 312 LayerImpl::Create(host_impl_->active_tree(), id); |
318 layer->SetScrollClipLayer(clip_layer->id()); | 313 layer->SetScrollClipLayer(clip_layer->id()); |
319 layer->SetDrawsContent(true); | 314 layer->SetDrawsContent(true); |
320 layer->SetBounds(size); | 315 layer->SetBounds(size); |
321 layer->SetContentBounds(size); | |
322 clip_layer->SetBounds(gfx::Size(size.width() / 2, size.height() / 2)); | 316 clip_layer->SetBounds(gfx::Size(size.width() / 2, size.height() / 2)); |
323 return layer.Pass(); | 317 return layer.Pass(); |
324 } | 318 } |
325 | 319 |
326 void DrawFrame() { | 320 void DrawFrame() { |
327 LayerTreeHostImpl::FrameData frame; | 321 LayerTreeHostImpl::FrameData frame; |
328 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 322 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
329 host_impl_->DrawLayers(&frame); | 323 host_impl_->DrawLayers(&frame); |
330 host_impl_->DidDrawAllLayers(frame); | 324 host_impl_->DidDrawAllLayers(frame); |
331 } | 325 } |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 633 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
640 | 634 |
641 LayerImpl* child = 0; | 635 LayerImpl* child = 0; |
642 { | 636 { |
643 scoped_ptr<LayerImpl> child_layer = | 637 scoped_ptr<LayerImpl> child_layer = |
644 LayerImpl::Create(host_impl_->active_tree(), 6); | 638 LayerImpl::Create(host_impl_->active_tree(), 6); |
645 child = child_layer.get(); | 639 child = child_layer.get(); |
646 child_layer->SetDrawsContent(true); | 640 child_layer->SetDrawsContent(true); |
647 child_layer->SetPosition(gfx::PointF(0, 20)); | 641 child_layer->SetPosition(gfx::PointF(0, 20)); |
648 child_layer->SetBounds(gfx::Size(50, 50)); | 642 child_layer->SetBounds(gfx::Size(50, 50)); |
649 child_layer->SetContentBounds(gfx::Size(50, 50)); | |
650 scroll->AddChild(child_layer.Pass()); | 643 scroll->AddChild(child_layer.Pass()); |
651 } | 644 } |
652 | 645 |
653 // Touch handler regions determine whether touch events block scroll. | 646 // Touch handler regions determine whether touch events block scroll. |
654 root->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100)); | 647 root->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100)); |
655 EXPECT_FALSE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 10))); | 648 EXPECT_FALSE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 10))); |
656 root->SetScrollBlocksOn(SCROLL_BLOCKS_ON_START_TOUCH | | 649 root->SetScrollBlocksOn(SCROLL_BLOCKS_ON_START_TOUCH | |
657 SCROLL_BLOCKS_ON_WHEEL_EVENT); | 650 SCROLL_BLOCKS_ON_WHEEL_EVENT); |
658 EXPECT_TRUE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 10))); | 651 EXPECT_TRUE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 10))); |
659 | 652 |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1013 } | 1006 } |
1014 | 1007 |
1015 TEST_F(LayerTreeHostImplTest, ScrollWithUserUnscrollableLayers) { | 1008 TEST_F(LayerTreeHostImplTest, ScrollWithUserUnscrollableLayers) { |
1016 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 1009 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
1017 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 1010 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
1018 | 1011 |
1019 gfx::Size overflow_size(400, 400); | 1012 gfx::Size overflow_size(400, 400); |
1020 ASSERT_EQ(1u, scroll_layer->children().size()); | 1013 ASSERT_EQ(1u, scroll_layer->children().size()); |
1021 LayerImpl* overflow = scroll_layer->children()[0]; | 1014 LayerImpl* overflow = scroll_layer->children()[0]; |
1022 overflow->SetBounds(overflow_size); | 1015 overflow->SetBounds(overflow_size); |
1023 overflow->SetContentBounds(overflow_size); | |
1024 overflow->SetScrollClipLayer(scroll_layer->parent()->id()); | 1016 overflow->SetScrollClipLayer(scroll_layer->parent()->id()); |
1025 overflow->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); | 1017 overflow->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); |
1026 overflow->SetPosition(gfx::PointF()); | 1018 overflow->SetPosition(gfx::PointF()); |
1027 | 1019 |
1028 DrawFrame(); | 1020 DrawFrame(); |
1029 gfx::Point scroll_position(10, 10); | 1021 gfx::Point scroll_position(10, 10); |
1030 | 1022 |
1031 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 1023 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
1032 host_impl_->ScrollBegin(scroll_position, InputHandler::WHEEL)); | 1024 host_impl_->ScrollBegin(scroll_position, InputHandler::WHEEL)); |
1033 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); | 1025 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1141 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 1133 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
1142 | 1134 |
1143 // Adjust the content layer to be larger than the outer viewport container so | 1135 // Adjust the content layer to be larger than the outer viewport container so |
1144 // that we get scrolling in both viewports. | 1136 // that we get scrolling in both viewports. |
1145 LayerImpl* content_layer = | 1137 LayerImpl* content_layer = |
1146 host_impl_->OuterViewportScrollLayer()->children().back(); | 1138 host_impl_->OuterViewportScrollLayer()->children().back(); |
1147 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); | 1139 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); |
1148 LayerImpl* inner_clip_layer = | 1140 LayerImpl* inner_clip_layer = |
1149 host_impl_->InnerViewportScrollLayer()->parent()->parent(); | 1141 host_impl_->InnerViewportScrollLayer()->parent()->parent(); |
1150 inner_clip_layer->SetBounds(gfx::Size(100, 100)); | 1142 inner_clip_layer->SetBounds(gfx::Size(100, 100)); |
1151 inner_clip_layer->SetContentBounds(gfx::Size(100, 100)); | |
1152 outer_scroll_layer->SetBounds(gfx::Size(200, 200)); | 1143 outer_scroll_layer->SetBounds(gfx::Size(200, 200)); |
1153 outer_scroll_layer->SetContentBounds(gfx::Size(200, 200)); | |
1154 content_layer->SetBounds(gfx::Size(200, 200)); | 1144 content_layer->SetBounds(gfx::Size(200, 200)); |
1155 content_layer->SetContentBounds(gfx::Size(200, 200)); | |
1156 | 1145 |
1157 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 1146 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
1158 | 1147 |
1159 EXPECT_VECTOR_EQ( | 1148 EXPECT_VECTOR_EQ( |
1160 gfx::Vector2dF(100, 100), | 1149 gfx::Vector2dF(100, 100), |
1161 outer_scroll_layer->MaxScrollOffset()); | 1150 outer_scroll_layer->MaxScrollOffset()); |
1162 | 1151 |
1163 host_impl_->ScrollBegin(gfx::Point(99, 99), InputHandler::GESTURE); | 1152 host_impl_->ScrollBegin(gfx::Point(99, 99), InputHandler::GESTURE); |
1164 host_impl_->PinchGestureBegin(); | 1153 host_impl_->PinchGestureBegin(); |
1165 host_impl_->PinchGestureUpdate(2, gfx::Point(99, 99)); | 1154 host_impl_->PinchGestureUpdate(2, gfx::Point(99, 99)); |
(...skipping 14 matching lines...) Expand all Loading... |
1180 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 1169 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
1181 | 1170 |
1182 // Adjust the content layer to be larger than the outer viewport container so | 1171 // Adjust the content layer to be larger than the outer viewport container so |
1183 // that we get scrolling in both viewports. | 1172 // that we get scrolling in both viewports. |
1184 LayerImpl* content_layer = | 1173 LayerImpl* content_layer = |
1185 host_impl_->OuterViewportScrollLayer()->children().back(); | 1174 host_impl_->OuterViewportScrollLayer()->children().back(); |
1186 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); | 1175 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); |
1187 LayerImpl* inner_clip_layer = | 1176 LayerImpl* inner_clip_layer = |
1188 host_impl_->InnerViewportScrollLayer()->parent()->parent(); | 1177 host_impl_->InnerViewportScrollLayer()->parent()->parent(); |
1189 inner_clip_layer->SetBounds(gfx::Size(100, 100)); | 1178 inner_clip_layer->SetBounds(gfx::Size(100, 100)); |
1190 inner_clip_layer->SetContentBounds(gfx::Size(100, 100)); | |
1191 outer_scroll_layer->SetBounds(gfx::Size(200, 200)); | 1179 outer_scroll_layer->SetBounds(gfx::Size(200, 200)); |
1192 outer_scroll_layer->SetContentBounds(gfx::Size(200, 200)); | |
1193 content_layer->SetBounds(gfx::Size(200, 200)); | 1180 content_layer->SetBounds(gfx::Size(200, 200)); |
1194 content_layer->SetContentBounds(gfx::Size(200, 200)); | |
1195 | 1181 |
1196 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 1182 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
1197 | 1183 |
1198 DrawFrame(); | 1184 DrawFrame(); |
1199 | 1185 |
1200 // Zoom into the page by a 2X factor | 1186 // Zoom into the page by a 2X factor |
1201 float min_page_scale = 1.f, max_page_scale = 4.f; | 1187 float min_page_scale = 1.f, max_page_scale = 4.f; |
1202 float page_scale_factor = 2.f; | 1188 float page_scale_factor = 2.f; |
1203 host_impl_->active_tree()->PushPageScaleFromMainThread( | 1189 host_impl_->active_tree()->PushPageScaleFromMainThread( |
1204 page_scale_factor, min_page_scale, max_page_scale); | 1190 page_scale_factor, min_page_scale, max_page_scale); |
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1800 scoped_ptr<LayerImpl> root = | 1786 scoped_ptr<LayerImpl> root = |
1801 LayerImpl::Create(host_impl_->active_tree(), 1); | 1787 LayerImpl::Create(host_impl_->active_tree(), 1); |
1802 root->SetBounds(viewport_size); | 1788 root->SetBounds(viewport_size); |
1803 | 1789 |
1804 scoped_ptr<LayerImpl> scroll = | 1790 scoped_ptr<LayerImpl> scroll = |
1805 LayerImpl::Create(host_impl_->active_tree(), 2); | 1791 LayerImpl::Create(host_impl_->active_tree(), 2); |
1806 scroll->SetScrollClipLayer(root->id()); | 1792 scroll->SetScrollClipLayer(root->id()); |
1807 scroll->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); | 1793 scroll->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); |
1808 root->SetBounds(viewport_size); | 1794 root->SetBounds(viewport_size); |
1809 scroll->SetBounds(content_size); | 1795 scroll->SetBounds(content_size); |
1810 scroll->SetContentBounds(content_size); | |
1811 scroll->SetIsContainerForFixedPositionLayers(true); | 1796 scroll->SetIsContainerForFixedPositionLayers(true); |
1812 | 1797 |
1813 scoped_ptr<LayerImpl> contents = | 1798 scoped_ptr<LayerImpl> contents = |
1814 LayerImpl::Create(host_impl_->active_tree(), 3); | 1799 LayerImpl::Create(host_impl_->active_tree(), 3); |
1815 contents->SetDrawsContent(true); | 1800 contents->SetDrawsContent(true); |
1816 contents->SetBounds(content_size); | 1801 contents->SetBounds(content_size); |
1817 contents->SetContentBounds(content_size); | |
1818 | 1802 |
1819 scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar = | 1803 scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar = |
1820 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 4, | 1804 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 4, |
1821 VERTICAL, 10, 0, false, true); | 1805 VERTICAL, 10, 0, false, true); |
1822 EXPECT_FLOAT_EQ(0.f, scrollbar->opacity()); | 1806 EXPECT_FLOAT_EQ(0.f, scrollbar->opacity()); |
1823 | 1807 |
1824 scroll->AddChild(contents.Pass()); | 1808 scroll->AddChild(contents.Pass()); |
1825 root->AddChild(scroll.Pass()); | 1809 root->AddChild(scroll.Pass()); |
1826 root->SetHasRenderSurface(true); | 1810 root->SetHasRenderSurface(true); |
1827 scrollbar->SetScrollLayerAndClipLayerByIds(2, 1); | 1811 scrollbar->SetScrollLayerAndClipLayerByIds(2, 1); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1958 scoped_ptr<LayerImpl> root = | 1942 scoped_ptr<LayerImpl> root = |
1959 LayerImpl::Create(host_impl_->active_tree(), 1); | 1943 LayerImpl::Create(host_impl_->active_tree(), 1); |
1960 root->SetBounds(viewport_size); | 1944 root->SetBounds(viewport_size); |
1961 root->SetHasRenderSurface(true); | 1945 root->SetHasRenderSurface(true); |
1962 | 1946 |
1963 scoped_ptr<LayerImpl> scroll = | 1947 scoped_ptr<LayerImpl> scroll = |
1964 LayerImpl::Create(host_impl_->active_tree(), 2); | 1948 LayerImpl::Create(host_impl_->active_tree(), 2); |
1965 scroll->SetScrollClipLayer(root->id()); | 1949 scroll->SetScrollClipLayer(root->id()); |
1966 scroll->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); | 1950 scroll->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); |
1967 scroll->SetBounds(content_size); | 1951 scroll->SetBounds(content_size); |
1968 scroll->SetContentBounds(content_size); | |
1969 scroll->SetIsContainerForFixedPositionLayers(true); | 1952 scroll->SetIsContainerForFixedPositionLayers(true); |
1970 | 1953 |
1971 scoped_ptr<LayerImpl> contents = | 1954 scoped_ptr<LayerImpl> contents = |
1972 LayerImpl::Create(host_impl_->active_tree(), 3); | 1955 LayerImpl::Create(host_impl_->active_tree(), 3); |
1973 contents->SetDrawsContent(true); | 1956 contents->SetDrawsContent(true); |
1974 contents->SetBounds(content_size); | 1957 contents->SetBounds(content_size); |
1975 contents->SetContentBounds(content_size); | |
1976 | 1958 |
1977 // The scrollbar is on the right side. | 1959 // The scrollbar is on the right side. |
1978 scoped_ptr<PaintedScrollbarLayerImpl> scrollbar = | 1960 scoped_ptr<PaintedScrollbarLayerImpl> scrollbar = |
1979 PaintedScrollbarLayerImpl::Create(host_impl_->active_tree(), 5, VERTICAL); | 1961 PaintedScrollbarLayerImpl::Create(host_impl_->active_tree(), 5, VERTICAL); |
1980 scrollbar->SetDrawsContent(true); | 1962 scrollbar->SetDrawsContent(true); |
1981 scrollbar->SetBounds(gfx::Size(15, viewport_size.height())); | 1963 scrollbar->SetBounds(gfx::Size(15, viewport_size.height())); |
1982 scrollbar->SetContentBounds(gfx::Size(15, viewport_size.height())); | |
1983 scrollbar->SetPosition(gfx::Point(285, 0)); | 1964 scrollbar->SetPosition(gfx::Point(285, 0)); |
1984 | 1965 |
1985 scroll->AddChild(contents.Pass()); | 1966 scroll->AddChild(contents.Pass()); |
1986 root->AddChild(scroll.Pass()); | 1967 root->AddChild(scroll.Pass()); |
1987 scrollbar->SetScrollLayerAndClipLayerByIds(2, 1); | 1968 scrollbar->SetScrollLayerAndClipLayerByIds(2, 1); |
1988 root->AddChild(scrollbar.Pass()); | 1969 root->AddChild(scrollbar.Pass()); |
1989 | 1970 |
1990 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 1971 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
1991 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 2, | 1972 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 2, |
1992 Layer::INVALID_ID); | 1973 Layer::INVALID_ID); |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2165 } | 2146 } |
2166 | 2147 |
2167 protected: | 2148 protected: |
2168 DidDrawCheckLayer(LayerTreeImpl* tree_impl, int id) | 2149 DidDrawCheckLayer(LayerTreeImpl* tree_impl, int id) |
2169 : LayerImpl(tree_impl, id), | 2150 : LayerImpl(tree_impl, id), |
2170 will_draw_returns_false_(false), | 2151 will_draw_returns_false_(false), |
2171 will_draw_called_(false), | 2152 will_draw_called_(false), |
2172 append_quads_called_(false), | 2153 append_quads_called_(false), |
2173 did_draw_called_(false) { | 2154 did_draw_called_(false) { |
2174 SetBounds(gfx::Size(10, 10)); | 2155 SetBounds(gfx::Size(10, 10)); |
2175 SetContentBounds(gfx::Size(10, 10)); | |
2176 SetDrawsContent(true); | 2156 SetDrawsContent(true); |
2177 draw_properties().visible_content_rect = gfx::Rect(0, 0, 10, 10); | 2157 draw_properties().visible_content_rect = gfx::Rect(0, 0, 10, 10); |
2178 } | 2158 } |
2179 | 2159 |
2180 private: | 2160 private: |
2181 bool will_draw_returns_false_; | 2161 bool will_draw_returns_false_; |
2182 bool will_draw_called_; | 2162 bool will_draw_called_; |
2183 bool append_quads_called_; | 2163 bool append_quads_called_; |
2184 bool did_draw_called_; | 2164 bool did_draw_called_; |
2185 }; | 2165 }; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2234 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( | 2214 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( |
2235 host_impl_->active_tree()->root_layer()); | 2215 host_impl_->active_tree()->root_layer()); |
2236 root->SetMasksToBounds(true); | 2216 root->SetMasksToBounds(true); |
2237 root->SetHasRenderSurface(true); | 2217 root->SetHasRenderSurface(true); |
2238 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 2218 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
2239 DidDrawCheckLayer* layer = | 2219 DidDrawCheckLayer* layer = |
2240 static_cast<DidDrawCheckLayer*>(root->children()[0]); | 2220 static_cast<DidDrawCheckLayer*>(root->children()[0]); |
2241 // Ensure visible_content_rect for layer is empty. | 2221 // Ensure visible_content_rect for layer is empty. |
2242 layer->SetPosition(gfx::PointF(100.f, 100.f)); | 2222 layer->SetPosition(gfx::PointF(100.f, 100.f)); |
2243 layer->SetBounds(gfx::Size(10, 10)); | 2223 layer->SetBounds(gfx::Size(10, 10)); |
2244 layer->SetContentBounds(gfx::Size(10, 10)); | |
2245 | 2224 |
2246 LayerTreeHostImpl::FrameData frame; | 2225 LayerTreeHostImpl::FrameData frame; |
2247 | 2226 |
2248 EXPECT_FALSE(layer->will_draw_called()); | 2227 EXPECT_FALSE(layer->will_draw_called()); |
2249 EXPECT_FALSE(layer->did_draw_called()); | 2228 EXPECT_FALSE(layer->did_draw_called()); |
2250 | 2229 |
2251 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2230 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
2252 host_impl_->DrawLayers(&frame); | 2231 host_impl_->DrawLayers(&frame); |
2253 host_impl_->DidDrawAllLayers(frame); | 2232 host_impl_->DidDrawAllLayers(frame); |
2254 | 2233 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2286 DidDrawCheckLayer* occluded_layer = | 2265 DidDrawCheckLayer* occluded_layer = |
2287 static_cast<DidDrawCheckLayer*>(root->children()[0]); | 2266 static_cast<DidDrawCheckLayer*>(root->children()[0]); |
2288 | 2267 |
2289 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 2268 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
2290 root->SetHasRenderSurface(true); | 2269 root->SetHasRenderSurface(true); |
2291 DidDrawCheckLayer* top_layer = | 2270 DidDrawCheckLayer* top_layer = |
2292 static_cast<DidDrawCheckLayer*>(root->children()[1]); | 2271 static_cast<DidDrawCheckLayer*>(root->children()[1]); |
2293 // This layer covers the occluded_layer above. Make this layer large so it can | 2272 // This layer covers the occluded_layer above. Make this layer large so it can |
2294 // occlude. | 2273 // occlude. |
2295 top_layer->SetBounds(big_size); | 2274 top_layer->SetBounds(big_size); |
2296 top_layer->SetContentBounds(big_size); | |
2297 top_layer->SetContentsOpaque(true); | 2275 top_layer->SetContentsOpaque(true); |
2298 | 2276 |
2299 LayerTreeHostImpl::FrameData frame; | 2277 LayerTreeHostImpl::FrameData frame; |
2300 | 2278 |
2301 EXPECT_FALSE(occluded_layer->will_draw_called()); | 2279 EXPECT_FALSE(occluded_layer->will_draw_called()); |
2302 EXPECT_FALSE(occluded_layer->did_draw_called()); | 2280 EXPECT_FALSE(occluded_layer->did_draw_called()); |
2303 EXPECT_FALSE(top_layer->will_draw_called()); | 2281 EXPECT_FALSE(top_layer->will_draw_called()); |
2304 EXPECT_FALSE(top_layer->did_draw_called()); | 2282 EXPECT_FALSE(top_layer->did_draw_called()); |
2305 | 2283 |
2306 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2284 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2669 } | 2647 } |
2670 | 2648 |
2671 void SetupTopControlsAndScrollLayer() { | 2649 void SetupTopControlsAndScrollLayer() { |
2672 scoped_ptr<LayerImpl> root = | 2650 scoped_ptr<LayerImpl> root = |
2673 LayerImpl::Create(host_impl_->active_tree(), 1); | 2651 LayerImpl::Create(host_impl_->active_tree(), 1); |
2674 scoped_ptr<LayerImpl> root_clip = | 2652 scoped_ptr<LayerImpl> root_clip = |
2675 LayerImpl::Create(host_impl_->active_tree(), 2); | 2653 LayerImpl::Create(host_impl_->active_tree(), 2); |
2676 root_clip->SetBounds(clip_size_); | 2654 root_clip->SetBounds(clip_size_); |
2677 root->SetScrollClipLayer(root_clip->id()); | 2655 root->SetScrollClipLayer(root_clip->id()); |
2678 root->SetBounds(layer_size_); | 2656 root->SetBounds(layer_size_); |
2679 root->SetContentBounds(layer_size_); | |
2680 root->SetPosition(gfx::PointF()); | 2657 root->SetPosition(gfx::PointF()); |
2681 root->SetDrawsContent(false); | 2658 root->SetDrawsContent(false); |
2682 root->SetIsContainerForFixedPositionLayers(true); | 2659 root->SetIsContainerForFixedPositionLayers(true); |
2683 int inner_viewport_scroll_layer_id = root->id(); | 2660 int inner_viewport_scroll_layer_id = root->id(); |
2684 int page_scale_layer_id = root_clip->id(); | 2661 int page_scale_layer_id = root_clip->id(); |
2685 root_clip->SetHasRenderSurface(true); | 2662 root_clip->SetHasRenderSurface(true); |
2686 root_clip->AddChild(root.Pass()); | 2663 root_clip->AddChild(root.Pass()); |
2687 root_clip->SetHasRenderSurface(true); | 2664 root_clip->SetHasRenderSurface(true); |
2688 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 2665 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); |
2689 host_impl_->active_tree()->SetViewportLayersFromIds( | 2666 host_impl_->active_tree()->SetViewportLayersFromIds( |
2690 Layer::INVALID_ID, page_scale_layer_id, inner_viewport_scroll_layer_id, | 2667 Layer::INVALID_ID, page_scale_layer_id, inner_viewport_scroll_layer_id, |
2691 Layer::INVALID_ID); | 2668 Layer::INVALID_ID); |
2692 // Set a viewport size that is large enough to contain both the top controls | 2669 // Set a viewport size that is large enough to contain both the top controls |
2693 // and some content. | 2670 // and some content. |
2694 host_impl_->SetViewportSize(viewport_size_); | 2671 host_impl_->SetViewportSize(viewport_size_); |
2695 host_impl_->sync_tree()->set_top_controls_shrink_blink_size(true); | 2672 host_impl_->sync_tree()->set_top_controls_shrink_blink_size(true); |
2696 | 2673 |
2697 host_impl_->DidChangeTopControlsPosition(); | 2674 host_impl_->DidChangeTopControlsPosition(); |
2698 | 2675 |
2699 host_impl_->CreatePendingTree(); | 2676 host_impl_->CreatePendingTree(); |
2700 host_impl_->sync_tree()->set_top_controls_height(top_controls_height_); | 2677 host_impl_->sync_tree()->set_top_controls_height(top_controls_height_); |
2701 root = | 2678 root = |
2702 LayerImpl::Create(host_impl_->sync_tree(), 1); | 2679 LayerImpl::Create(host_impl_->sync_tree(), 1); |
2703 root_clip = | 2680 root_clip = |
2704 LayerImpl::Create(host_impl_->sync_tree(), 2); | 2681 LayerImpl::Create(host_impl_->sync_tree(), 2); |
2705 root_clip->SetBounds(clip_size_); | 2682 root_clip->SetBounds(clip_size_); |
2706 root->SetScrollClipLayer(root_clip->id()); | 2683 root->SetScrollClipLayer(root_clip->id()); |
2707 root->SetBounds(layer_size_); | 2684 root->SetBounds(layer_size_); |
2708 root->SetContentBounds(layer_size_); | |
2709 root->SetPosition(gfx::PointF()); | 2685 root->SetPosition(gfx::PointF()); |
2710 root->SetDrawsContent(false); | 2686 root->SetDrawsContent(false); |
2711 root->SetIsContainerForFixedPositionLayers(true); | 2687 root->SetIsContainerForFixedPositionLayers(true); |
2712 inner_viewport_scroll_layer_id = root->id(); | 2688 inner_viewport_scroll_layer_id = root->id(); |
2713 page_scale_layer_id = root_clip->id(); | 2689 page_scale_layer_id = root_clip->id(); |
2714 root_clip->AddChild(root.Pass()); | 2690 root_clip->AddChild(root.Pass()); |
2715 host_impl_->sync_tree()->SetRootLayer(root_clip.Pass()); | 2691 host_impl_->sync_tree()->SetRootLayer(root_clip.Pass()); |
2716 host_impl_->sync_tree()->SetViewportLayersFromIds( | 2692 host_impl_->sync_tree()->SetViewportLayersFromIds( |
2717 Layer::INVALID_ID, page_scale_layer_id, inner_viewport_scroll_layer_id, | 2693 Layer::INVALID_ID, page_scale_layer_id, inner_viewport_scroll_layer_id, |
2718 Layer::INVALID_ID); | 2694 Layer::INVALID_ID); |
(...skipping 21 matching lines...) Expand all Loading... |
2740 LayerImpl::Create(host_impl_->active_tree(), 3); | 2716 LayerImpl::Create(host_impl_->active_tree(), 3); |
2741 | 2717 |
2742 scoped_ptr<LayerImpl> outer_scroll = | 2718 scoped_ptr<LayerImpl> outer_scroll = |
2743 LayerImpl::Create(host_impl_->active_tree(), 4); | 2719 LayerImpl::Create(host_impl_->active_tree(), 4); |
2744 scoped_ptr<LayerImpl> outer_clip = | 2720 scoped_ptr<LayerImpl> outer_clip = |
2745 LayerImpl::Create(host_impl_->active_tree(), 5); | 2721 LayerImpl::Create(host_impl_->active_tree(), 5); |
2746 | 2722 |
2747 root_clip->SetBounds(inner_viewport_size); | 2723 root_clip->SetBounds(inner_viewport_size); |
2748 root->SetScrollClipLayer(root_clip->id()); | 2724 root->SetScrollClipLayer(root_clip->id()); |
2749 root->SetBounds(outer_viewport_size); | 2725 root->SetBounds(outer_viewport_size); |
2750 root->SetContentBounds(outer_viewport_size); | |
2751 root->SetPosition(gfx::PointF()); | 2726 root->SetPosition(gfx::PointF()); |
2752 root->SetDrawsContent(false); | 2727 root->SetDrawsContent(false); |
2753 root->SetIsContainerForFixedPositionLayers(true); | 2728 root->SetIsContainerForFixedPositionLayers(true); |
2754 root_clip->SetHasRenderSurface(true); | 2729 root_clip->SetHasRenderSurface(true); |
2755 outer_clip->SetBounds(outer_viewport_size); | 2730 outer_clip->SetBounds(outer_viewport_size); |
2756 outer_scroll->SetScrollClipLayer(outer_clip->id()); | 2731 outer_scroll->SetScrollClipLayer(outer_clip->id()); |
2757 outer_scroll->SetBounds(scroll_layer_size); | 2732 outer_scroll->SetBounds(scroll_layer_size); |
2758 outer_scroll->SetContentBounds(scroll_layer_size); | |
2759 outer_scroll->SetPosition(gfx::PointF()); | 2733 outer_scroll->SetPosition(gfx::PointF()); |
2760 outer_scroll->SetDrawsContent(false); | 2734 outer_scroll->SetDrawsContent(false); |
2761 outer_scroll->SetIsContainerForFixedPositionLayers(true); | 2735 outer_scroll->SetIsContainerForFixedPositionLayers(true); |
2762 | 2736 |
2763 int inner_viewport_scroll_layer_id = root->id(); | 2737 int inner_viewport_scroll_layer_id = root->id(); |
2764 int outer_viewport_scroll_layer_id = outer_scroll->id(); | 2738 int outer_viewport_scroll_layer_id = outer_scroll->id(); |
2765 int page_scale_layer_id = page_scale->id(); | 2739 int page_scale_layer_id = page_scale->id(); |
2766 | 2740 |
2767 outer_clip->AddChild(outer_scroll.Pass()); | 2741 outer_clip->AddChild(outer_scroll.Pass()); |
2768 root->AddChild(outer_clip.Pass()); | 2742 root->AddChild(outer_clip.Pass()); |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2953 int id = outer_viewport_scroll_layer->id(); | 2927 int id = outer_viewport_scroll_layer->id(); |
2954 | 2928 |
2955 scoped_ptr<LayerImpl> child = | 2929 scoped_ptr<LayerImpl> child = |
2956 LayerImpl::Create(host_impl_->active_tree(), id + 2); | 2930 LayerImpl::Create(host_impl_->active_tree(), id + 2); |
2957 scoped_ptr<LayerImpl> child_clip = | 2931 scoped_ptr<LayerImpl> child_clip = |
2958 LayerImpl::Create(host_impl_->active_tree(), id + 3); | 2932 LayerImpl::Create(host_impl_->active_tree(), id + 3); |
2959 | 2933 |
2960 child_clip->SetBounds(sub_content_layer_size); | 2934 child_clip->SetBounds(sub_content_layer_size); |
2961 child->SetScrollClipLayer(child_clip->id()); | 2935 child->SetScrollClipLayer(child_clip->id()); |
2962 child->SetBounds(sub_content_size); | 2936 child->SetBounds(sub_content_size); |
2963 child->SetContentBounds(sub_content_size); | |
2964 child->SetPosition(gfx::PointF()); | 2937 child->SetPosition(gfx::PointF()); |
2965 child->SetDrawsContent(true); | 2938 child->SetDrawsContent(true); |
2966 child->SetIsContainerForFixedPositionLayers(true); | 2939 child->SetIsContainerForFixedPositionLayers(true); |
2967 | 2940 |
2968 // scroll child to limit | 2941 // scroll child to limit |
2969 child->SetScrollDelta(gfx::Vector2dF(0, 100.f)); | 2942 child->SetScrollDelta(gfx::Vector2dF(0, 100.f)); |
2970 child_clip->AddChild(child.Pass()); | 2943 child_clip->AddChild(child.Pass()); |
2971 outer_viewport_scroll_layer->AddChild(child_clip.Pass()); | 2944 outer_viewport_scroll_layer->AddChild(child_clip.Pass()); |
2972 | 2945 |
2973 // Scroll 25px to hide top controls | 2946 // Scroll 25px to hide top controls |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3309 // Test the configuration where a non-composited root layer is embedded in a | 3282 // Test the configuration where a non-composited root layer is embedded in a |
3310 // scrollable outer layer. | 3283 // scrollable outer layer. |
3311 gfx::Size surface_size(10, 10); | 3284 gfx::Size surface_size(10, 10); |
3312 gfx::Size contents_size(20, 20); | 3285 gfx::Size contents_size(20, 20); |
3313 | 3286 |
3314 scoped_ptr<LayerImpl> content_layer = | 3287 scoped_ptr<LayerImpl> content_layer = |
3315 LayerImpl::Create(host_impl_->active_tree(), 1); | 3288 LayerImpl::Create(host_impl_->active_tree(), 1); |
3316 content_layer->SetDrawsContent(true); | 3289 content_layer->SetDrawsContent(true); |
3317 content_layer->SetPosition(gfx::PointF()); | 3290 content_layer->SetPosition(gfx::PointF()); |
3318 content_layer->SetBounds(contents_size); | 3291 content_layer->SetBounds(contents_size); |
3319 content_layer->SetContentBounds(contents_size); | |
3320 content_layer->SetContentsScale(2.f, 2.f); | 3292 content_layer->SetContentsScale(2.f, 2.f); |
3321 | 3293 |
3322 scoped_ptr<LayerImpl> scroll_clip_layer = | 3294 scoped_ptr<LayerImpl> scroll_clip_layer = |
3323 LayerImpl::Create(host_impl_->active_tree(), 3); | 3295 LayerImpl::Create(host_impl_->active_tree(), 3); |
3324 scroll_clip_layer->SetBounds(surface_size); | 3296 scroll_clip_layer->SetBounds(surface_size); |
3325 | 3297 |
3326 scoped_ptr<LayerImpl> scroll_layer = | 3298 scoped_ptr<LayerImpl> scroll_layer = |
3327 LayerImpl::Create(host_impl_->active_tree(), 2); | 3299 LayerImpl::Create(host_impl_->active_tree(), 2); |
3328 scroll_layer->SetScrollClipLayer(3); | 3300 scroll_layer->SetScrollClipLayer(3); |
3329 scroll_layer->SetBounds(contents_size); | 3301 scroll_layer->SetBounds(contents_size); |
3330 scroll_layer->SetContentBounds(contents_size); | |
3331 scroll_layer->SetPosition(gfx::PointF()); | 3302 scroll_layer->SetPosition(gfx::PointF()); |
3332 scroll_layer->AddChild(content_layer.Pass()); | 3303 scroll_layer->AddChild(content_layer.Pass()); |
3333 scroll_clip_layer->AddChild(scroll_layer.Pass()); | 3304 scroll_clip_layer->AddChild(scroll_layer.Pass()); |
3334 | 3305 |
3335 scroll_clip_layer->SetHasRenderSurface(true); | 3306 scroll_clip_layer->SetHasRenderSurface(true); |
3336 host_impl_->active_tree()->SetRootLayer(scroll_clip_layer.Pass()); | 3307 host_impl_->active_tree()->SetRootLayer(scroll_clip_layer.Pass()); |
3337 host_impl_->SetViewportSize(surface_size); | 3308 host_impl_->SetViewportSize(surface_size); |
3338 DrawFrame(); | 3309 DrawFrame(); |
3339 | 3310 |
3340 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3311 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
3341 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); | 3312 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); |
3342 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 3313 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
3343 host_impl_->ScrollEnd(); | 3314 host_impl_->ScrollEnd(); |
3344 EXPECT_TRUE(did_request_redraw_); | 3315 EXPECT_TRUE(did_request_redraw_); |
3345 EXPECT_TRUE(did_request_commit_); | 3316 EXPECT_TRUE(did_request_commit_); |
3346 } | 3317 } |
3347 | 3318 |
3348 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { | 3319 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { |
3349 gfx::Size surface_size(10, 10); | 3320 gfx::Size surface_size(10, 10); |
3350 gfx::Size contents_size(20, 20); | 3321 gfx::Size contents_size(20, 20); |
3351 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 3322 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
3352 root->SetBounds(surface_size); | 3323 root->SetBounds(surface_size); |
3353 root->SetContentBounds(contents_size); | |
3354 root->AddChild(CreateScrollableLayer(2, contents_size, root.get())); | 3324 root->AddChild(CreateScrollableLayer(2, contents_size, root.get())); |
3355 root->SetHasRenderSurface(true); | 3325 root->SetHasRenderSurface(true); |
3356 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 3326 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
3357 host_impl_->SetViewportSize(surface_size); | 3327 host_impl_->SetViewportSize(surface_size); |
3358 DrawFrame(); | 3328 DrawFrame(); |
3359 | 3329 |
3360 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3330 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
3361 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); | 3331 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); |
3362 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 3332 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
3363 host_impl_->ScrollEnd(); | 3333 host_impl_->ScrollEnd(); |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3599 } | 3569 } |
3600 | 3570 |
3601 TEST_F(LayerTreeHostImplTest, ScrollChildAndChangePageScaleOnMainThread) { | 3571 TEST_F(LayerTreeHostImplTest, ScrollChildAndChangePageScaleOnMainThread) { |
3602 gfx::Size surface_size(30, 30); | 3572 gfx::Size surface_size(30, 30); |
3603 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 3573 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
3604 root->SetBounds(gfx::Size(5, 5)); | 3574 root->SetBounds(gfx::Size(5, 5)); |
3605 root->SetHasRenderSurface(true); | 3575 root->SetHasRenderSurface(true); |
3606 scoped_ptr<LayerImpl> root_scrolling = | 3576 scoped_ptr<LayerImpl> root_scrolling = |
3607 LayerImpl::Create(host_impl_->active_tree(), 2); | 3577 LayerImpl::Create(host_impl_->active_tree(), 2); |
3608 root_scrolling->SetBounds(surface_size); | 3578 root_scrolling->SetBounds(surface_size); |
3609 root_scrolling->SetContentBounds(surface_size); | |
3610 root_scrolling->SetScrollClipLayer(root->id()); | 3579 root_scrolling->SetScrollClipLayer(root->id()); |
3611 root_scrolling->SetIsContainerForFixedPositionLayers(true); | 3580 root_scrolling->SetIsContainerForFixedPositionLayers(true); |
3612 LayerImpl* root_scrolling_ptr = root_scrolling.get(); | 3581 LayerImpl* root_scrolling_ptr = root_scrolling.get(); |
3613 root->AddChild(root_scrolling.Pass()); | 3582 root->AddChild(root_scrolling.Pass()); |
3614 int child_scroll_layer_id = 3; | 3583 int child_scroll_layer_id = 3; |
3615 scoped_ptr<LayerImpl> child_scrolling = CreateScrollableLayer( | 3584 scoped_ptr<LayerImpl> child_scrolling = CreateScrollableLayer( |
3616 child_scroll_layer_id, surface_size, root_scrolling_ptr); | 3585 child_scroll_layer_id, surface_size, root_scrolling_ptr); |
3617 LayerImpl* child = child_scrolling.get(); | 3586 LayerImpl* child = child_scrolling.get(); |
3618 root_scrolling_ptr->AddChild(child_scrolling.Pass()); | 3587 root_scrolling_ptr->AddChild(child_scrolling.Pass()); |
3619 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 3588 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
(...skipping 1062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4682 quads_appended_(false), | 4651 quads_appended_(false), |
4683 quad_rect_(5, 5, 5, 5), | 4652 quad_rect_(5, 5, 5, 5), |
4684 quad_visible_rect_(5, 5, 5, 5), | 4653 quad_visible_rect_(5, 5, 5, 5), |
4685 resource_id_(resource_provider->CreateResource( | 4654 resource_id_(resource_provider->CreateResource( |
4686 gfx::Size(1, 1), | 4655 gfx::Size(1, 1), |
4687 GL_CLAMP_TO_EDGE, | 4656 GL_CLAMP_TO_EDGE, |
4688 ResourceProvider::TEXTURE_HINT_IMMUTABLE, | 4657 ResourceProvider::TEXTURE_HINT_IMMUTABLE, |
4689 RGBA_8888)) { | 4658 RGBA_8888)) { |
4690 resource_provider->AllocateForTesting(resource_id_); | 4659 resource_provider->AllocateForTesting(resource_id_); |
4691 SetBounds(gfx::Size(10, 10)); | 4660 SetBounds(gfx::Size(10, 10)); |
4692 SetContentBounds(gfx::Size(10, 10)); | |
4693 SetDrawsContent(true); | 4661 SetDrawsContent(true); |
4694 } | 4662 } |
4695 | 4663 |
4696 bool blend_; | 4664 bool blend_; |
4697 bool has_render_surface_; | 4665 bool has_render_surface_; |
4698 bool quads_appended_; | 4666 bool quads_appended_; |
4699 gfx::Rect quad_rect_; | 4667 gfx::Rect quad_rect_; |
4700 gfx::Rect opaque_content_rect_; | 4668 gfx::Rect opaque_content_rect_; |
4701 gfx::Rect quad_visible_rect_; | 4669 gfx::Rect quad_visible_rect_; |
4702 ResourceId resource_id_; | 4670 ResourceId resource_id_; |
4703 }; | 4671 }; |
4704 | 4672 |
4705 TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { | 4673 TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { |
4706 { | 4674 { |
4707 scoped_ptr<LayerImpl> root = | 4675 scoped_ptr<LayerImpl> root = |
4708 LayerImpl::Create(host_impl_->active_tree(), 1); | 4676 LayerImpl::Create(host_impl_->active_tree(), 1); |
4709 root->SetBounds(gfx::Size(10, 10)); | 4677 root->SetBounds(gfx::Size(10, 10)); |
4710 root->SetContentBounds(root->bounds()); | |
4711 root->SetDrawsContent(false); | 4678 root->SetDrawsContent(false); |
4712 root->SetHasRenderSurface(true); | 4679 root->SetHasRenderSurface(true); |
4713 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 4680 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
4714 } | 4681 } |
4715 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 4682 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
4716 | 4683 |
4717 root->AddChild( | 4684 root->AddChild( |
4718 BlendStateCheckLayer::Create(host_impl_->active_tree(), | 4685 BlendStateCheckLayer::Create(host_impl_->active_tree(), |
4719 2, | 4686 2, |
4720 host_impl_->resource_provider())); | 4687 host_impl_->resource_provider())); |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4957 host_impl_->active_tree()->root_layer()->children()[0]); | 4924 host_impl_->active_tree()->root_layer()->children()[0]); |
4958 child_->SetExpectation(false, false); | 4925 child_->SetExpectation(false, false); |
4959 child_->SetContentsOpaque(true); | 4926 child_->SetContentsOpaque(true); |
4960 } | 4927 } |
4961 | 4928 |
4962 // Expect no gutter rects. | 4929 // Expect no gutter rects. |
4963 void TestLayerCoversFullViewport() { | 4930 void TestLayerCoversFullViewport() { |
4964 gfx::Rect layer_rect(viewport_size_); | 4931 gfx::Rect layer_rect(viewport_size_); |
4965 child_->SetPosition(layer_rect.origin()); | 4932 child_->SetPosition(layer_rect.origin()); |
4966 child_->SetBounds(layer_rect.size()); | 4933 child_->SetBounds(layer_rect.size()); |
4967 child_->SetContentBounds(layer_rect.size()); | |
4968 child_->SetQuadRect(gfx::Rect(layer_rect.size())); | 4934 child_->SetQuadRect(gfx::Rect(layer_rect.size())); |
4969 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); | 4935 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); |
4970 | 4936 |
4971 LayerTreeHostImpl::FrameData frame; | 4937 LayerTreeHostImpl::FrameData frame; |
4972 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4938 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
4973 ASSERT_EQ(1u, frame.render_passes.size()); | 4939 ASSERT_EQ(1u, frame.render_passes.size()); |
4974 | 4940 |
4975 EXPECT_EQ(0u, CountGutterQuads(frame.render_passes[0]->quad_list)); | 4941 EXPECT_EQ(0u, CountGutterQuads(frame.render_passes[0]->quad_list)); |
4976 EXPECT_EQ(1u, frame.render_passes[0]->quad_list.size()); | 4942 EXPECT_EQ(1u, frame.render_passes[0]->quad_list.size()); |
4977 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list); | 4943 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list); |
4978 | 4944 |
4979 VerifyQuadsExactlyCoverViewport(frame.render_passes[0]->quad_list); | 4945 VerifyQuadsExactlyCoverViewport(frame.render_passes[0]->quad_list); |
4980 host_impl_->DidDrawAllLayers(frame); | 4946 host_impl_->DidDrawAllLayers(frame); |
4981 } | 4947 } |
4982 | 4948 |
4983 // Expect fullscreen gutter rect. | 4949 // Expect fullscreen gutter rect. |
4984 void TestEmptyLayer() { | 4950 void TestEmptyLayer() { |
4985 gfx::Rect layer_rect(0, 0, 0, 0); | 4951 gfx::Rect layer_rect(0, 0, 0, 0); |
4986 child_->SetPosition(layer_rect.origin()); | 4952 child_->SetPosition(layer_rect.origin()); |
4987 child_->SetBounds(layer_rect.size()); | 4953 child_->SetBounds(layer_rect.size()); |
4988 child_->SetContentBounds(layer_rect.size()); | |
4989 child_->SetQuadRect(gfx::Rect(layer_rect.size())); | 4954 child_->SetQuadRect(gfx::Rect(layer_rect.size())); |
4990 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); | 4955 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); |
4991 | 4956 |
4992 LayerTreeHostImpl::FrameData frame; | 4957 LayerTreeHostImpl::FrameData frame; |
4993 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4958 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
4994 ASSERT_EQ(1u, frame.render_passes.size()); | 4959 ASSERT_EQ(1u, frame.render_passes.size()); |
4995 | 4960 |
4996 EXPECT_EQ(1u, CountGutterQuads(frame.render_passes[0]->quad_list)); | 4961 EXPECT_EQ(1u, CountGutterQuads(frame.render_passes[0]->quad_list)); |
4997 EXPECT_EQ(1u, frame.render_passes[0]->quad_list.size()); | 4962 EXPECT_EQ(1u, frame.render_passes[0]->quad_list.size()); |
4998 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list); | 4963 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list); |
4999 | 4964 |
5000 VerifyQuadsExactlyCoverViewport(frame.render_passes[0]->quad_list); | 4965 VerifyQuadsExactlyCoverViewport(frame.render_passes[0]->quad_list); |
5001 host_impl_->DidDrawAllLayers(frame); | 4966 host_impl_->DidDrawAllLayers(frame); |
5002 } | 4967 } |
5003 | 4968 |
5004 // Expect four surrounding gutter rects. | 4969 // Expect four surrounding gutter rects. |
5005 void TestLayerInMiddleOfViewport() { | 4970 void TestLayerInMiddleOfViewport() { |
5006 gfx::Rect layer_rect(500, 500, 200, 200); | 4971 gfx::Rect layer_rect(500, 500, 200, 200); |
5007 child_->SetPosition(layer_rect.origin()); | 4972 child_->SetPosition(layer_rect.origin()); |
5008 child_->SetBounds(layer_rect.size()); | 4973 child_->SetBounds(layer_rect.size()); |
5009 child_->SetContentBounds(layer_rect.size()); | |
5010 child_->SetQuadRect(gfx::Rect(layer_rect.size())); | 4974 child_->SetQuadRect(gfx::Rect(layer_rect.size())); |
5011 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); | 4975 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); |
5012 | 4976 |
5013 LayerTreeHostImpl::FrameData frame; | 4977 LayerTreeHostImpl::FrameData frame; |
5014 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4978 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
5015 ASSERT_EQ(1u, frame.render_passes.size()); | 4979 ASSERT_EQ(1u, frame.render_passes.size()); |
5016 | 4980 |
5017 EXPECT_EQ(4u, CountGutterQuads(frame.render_passes[0]->quad_list)); | 4981 EXPECT_EQ(4u, CountGutterQuads(frame.render_passes[0]->quad_list)); |
5018 EXPECT_EQ(5u, frame.render_passes[0]->quad_list.size()); | 4982 EXPECT_EQ(5u, frame.render_passes[0]->quad_list.size()); |
5019 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list); | 4983 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list); |
5020 | 4984 |
5021 VerifyQuadsExactlyCoverViewport(frame.render_passes[0]->quad_list); | 4985 VerifyQuadsExactlyCoverViewport(frame.render_passes[0]->quad_list); |
5022 host_impl_->DidDrawAllLayers(frame); | 4986 host_impl_->DidDrawAllLayers(frame); |
5023 } | 4987 } |
5024 | 4988 |
5025 // Expect no gutter rects. | 4989 // Expect no gutter rects. |
5026 void TestLayerIsLargerThanViewport() { | 4990 void TestLayerIsLargerThanViewport() { |
5027 gfx::Rect layer_rect(viewport_size_.width() + 10, | 4991 gfx::Rect layer_rect(viewport_size_.width() + 10, |
5028 viewport_size_.height() + 10); | 4992 viewport_size_.height() + 10); |
5029 child_->SetPosition(layer_rect.origin()); | 4993 child_->SetPosition(layer_rect.origin()); |
5030 child_->SetBounds(layer_rect.size()); | 4994 child_->SetBounds(layer_rect.size()); |
5031 child_->SetContentBounds(layer_rect.size()); | |
5032 child_->SetQuadRect(gfx::Rect(layer_rect.size())); | 4995 child_->SetQuadRect(gfx::Rect(layer_rect.size())); |
5033 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); | 4996 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); |
5034 | 4997 |
5035 LayerTreeHostImpl::FrameData frame; | 4998 LayerTreeHostImpl::FrameData frame; |
5036 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4999 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
5037 ASSERT_EQ(1u, frame.render_passes.size()); | 5000 ASSERT_EQ(1u, frame.render_passes.size()); |
5038 | 5001 |
5039 EXPECT_EQ(0u, CountGutterQuads(frame.render_passes[0]->quad_list)); | 5002 EXPECT_EQ(0u, CountGutterQuads(frame.render_passes[0]->quad_list)); |
5040 EXPECT_EQ(1u, frame.render_passes[0]->quad_list.size()); | 5003 EXPECT_EQ(1u, frame.render_passes[0]->quad_list.size()); |
5041 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list); | 5004 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5187 // viewport size is never set. | 5150 // viewport size is never set. |
5188 TEST_F(LayerTreeHostImplTest, ReshapeNotCalledUntilDraw) { | 5151 TEST_F(LayerTreeHostImplTest, ReshapeNotCalledUntilDraw) { |
5189 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); | 5152 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); |
5190 scoped_ptr<OutputSurface> output_surface( | 5153 scoped_ptr<OutputSurface> output_surface( |
5191 FakeOutputSurface::Create3d(provider)); | 5154 FakeOutputSurface::Create3d(provider)); |
5192 CreateHostImpl(DefaultSettings(), output_surface.Pass()); | 5155 CreateHostImpl(DefaultSettings(), output_surface.Pass()); |
5193 | 5156 |
5194 scoped_ptr<LayerImpl> root = | 5157 scoped_ptr<LayerImpl> root = |
5195 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); | 5158 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); |
5196 root->SetBounds(gfx::Size(10, 10)); | 5159 root->SetBounds(gfx::Size(10, 10)); |
5197 root->SetContentBounds(gfx::Size(10, 10)); | |
5198 root->SetDrawsContent(true); | 5160 root->SetDrawsContent(true); |
5199 root->SetHasRenderSurface(true); | 5161 root->SetHasRenderSurface(true); |
5200 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 5162 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
5201 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); | 5163 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); |
5202 provider->TestContext3d()->clear_reshape_called(); | 5164 provider->TestContext3d()->clear_reshape_called(); |
5203 | 5165 |
5204 LayerTreeHostImpl::FrameData frame; | 5166 LayerTreeHostImpl::FrameData frame; |
5205 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 5167 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
5206 host_impl_->SetDeviceScaleFactor(1.f); | 5168 host_impl_->SetDeviceScaleFactor(1.f); |
5207 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 5169 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5259 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE)); | 5221 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE)); |
5260 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); | 5222 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); |
5261 | 5223 |
5262 scoped_ptr<LayerImpl> root = | 5224 scoped_ptr<LayerImpl> root = |
5263 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); | 5225 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); |
5264 root->SetHasRenderSurface(true); | 5226 root->SetHasRenderSurface(true); |
5265 scoped_ptr<LayerImpl> child = | 5227 scoped_ptr<LayerImpl> child = |
5266 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); | 5228 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); |
5267 child->SetPosition(gfx::PointF(12.f, 13.f)); | 5229 child->SetPosition(gfx::PointF(12.f, 13.f)); |
5268 child->SetBounds(gfx::Size(14, 15)); | 5230 child->SetBounds(gfx::Size(14, 15)); |
5269 child->SetContentBounds(gfx::Size(14, 15)); | |
5270 child->SetDrawsContent(true); | 5231 child->SetDrawsContent(true); |
5271 root->SetBounds(gfx::Size(500, 500)); | 5232 root->SetBounds(gfx::Size(500, 500)); |
5272 root->SetContentBounds(gfx::Size(500, 500)); | |
5273 root->SetDrawsContent(true); | 5233 root->SetDrawsContent(true); |
5274 root->AddChild(child.Pass()); | 5234 root->AddChild(child.Pass()); |
5275 layer_tree_host_impl->active_tree()->SetRootLayer(root.Pass()); | 5235 layer_tree_host_impl->active_tree()->SetRootLayer(root.Pass()); |
5276 | 5236 |
5277 LayerTreeHostImpl::FrameData frame; | 5237 LayerTreeHostImpl::FrameData frame; |
5278 | 5238 |
5279 // First frame, the entire screen should get swapped. | 5239 // First frame, the entire screen should get swapped. |
5280 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); | 5240 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); |
5281 layer_tree_host_impl->DrawLayers(&frame); | 5241 layer_tree_host_impl->DrawLayers(&frame); |
5282 layer_tree_host_impl->DidDrawAllLayers(frame); | 5242 layer_tree_host_impl->DidDrawAllLayers(frame); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5316 EXPECT_EQ(expected_swap_rect.ToString(), | 5276 EXPECT_EQ(expected_swap_rect.ToString(), |
5317 fake_output_surface->last_swap_rect().ToString()); | 5277 fake_output_surface->last_swap_rect().ToString()); |
5318 } | 5278 } |
5319 | 5279 |
5320 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) { | 5280 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) { |
5321 scoped_ptr<LayerImpl> root = | 5281 scoped_ptr<LayerImpl> root = |
5322 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); | 5282 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); |
5323 scoped_ptr<LayerImpl> child = | 5283 scoped_ptr<LayerImpl> child = |
5324 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); | 5284 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); |
5325 child->SetBounds(gfx::Size(10, 10)); | 5285 child->SetBounds(gfx::Size(10, 10)); |
5326 child->SetContentBounds(gfx::Size(10, 10)); | |
5327 child->SetDrawsContent(true); | 5286 child->SetDrawsContent(true); |
5328 root->SetBounds(gfx::Size(10, 10)); | 5287 root->SetBounds(gfx::Size(10, 10)); |
5329 root->SetContentBounds(gfx::Size(10, 10)); | |
5330 root->SetDrawsContent(true); | 5288 root->SetDrawsContent(true); |
5331 root->SetHasRenderSurface(true); | 5289 root->SetHasRenderSurface(true); |
5332 root->AddChild(child.Pass()); | 5290 root->AddChild(child.Pass()); |
5333 | 5291 |
5334 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 5292 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
5335 | 5293 |
5336 LayerTreeHostImpl::FrameData frame; | 5294 LayerTreeHostImpl::FrameData frame; |
5337 | 5295 |
5338 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 5296 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
5339 EXPECT_EQ(1u, frame.render_surface_layer_list->size()); | 5297 EXPECT_EQ(1u, frame.render_surface_layer_list->size()); |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5576 scoped_ptr<LayerImpl> grand_child = | 5534 scoped_ptr<LayerImpl> grand_child = |
5577 FakeLayerWithQuads::Create(my_host_impl->active_tree(), 3); | 5535 FakeLayerWithQuads::Create(my_host_impl->active_tree(), 3); |
5578 | 5536 |
5579 gfx::Rect root_rect(0, 0, 100, 100); | 5537 gfx::Rect root_rect(0, 0, 100, 100); |
5580 gfx::Rect child_rect(10, 10, 50, 50); | 5538 gfx::Rect child_rect(10, 10, 50, 50); |
5581 gfx::Rect grand_child_rect(5, 5, 150, 150); | 5539 gfx::Rect grand_child_rect(5, 5, 150, 150); |
5582 | 5540 |
5583 root->SetHasRenderSurface(true); | 5541 root->SetHasRenderSurface(true); |
5584 root->SetPosition(root_rect.origin()); | 5542 root->SetPosition(root_rect.origin()); |
5585 root->SetBounds(root_rect.size()); | 5543 root->SetBounds(root_rect.size()); |
5586 root->SetContentBounds(root->bounds()); | |
5587 root->draw_properties().visible_content_rect = root_rect; | 5544 root->draw_properties().visible_content_rect = root_rect; |
5588 root->SetDrawsContent(false); | 5545 root->SetDrawsContent(false); |
5589 root->render_surface()->SetContentRect(gfx::Rect(root_rect.size())); | 5546 root->render_surface()->SetContentRect(gfx::Rect(root_rect.size())); |
5590 | 5547 |
5591 child->SetPosition(gfx::PointF(child_rect.x(), child_rect.y())); | 5548 child->SetPosition(gfx::PointF(child_rect.x(), child_rect.y())); |
5592 child->SetOpacity(0.5f); | 5549 child->SetOpacity(0.5f); |
5593 child->SetBounds(gfx::Size(child_rect.width(), child_rect.height())); | 5550 child->SetBounds(gfx::Size(child_rect.width(), child_rect.height())); |
5594 child->SetContentBounds(child->bounds()); | |
5595 child->draw_properties().visible_content_rect = child_rect; | 5551 child->draw_properties().visible_content_rect = child_rect; |
5596 child->SetDrawsContent(false); | 5552 child->SetDrawsContent(false); |
5597 child->SetHasRenderSurface(true); | 5553 child->SetHasRenderSurface(true); |
5598 | 5554 |
5599 grand_child->SetPosition(grand_child_rect.origin()); | 5555 grand_child->SetPosition(grand_child_rect.origin()); |
5600 grand_child->SetBounds(grand_child_rect.size()); | 5556 grand_child->SetBounds(grand_child_rect.size()); |
5601 grand_child->SetContentBounds(grand_child->bounds()); | |
5602 grand_child->draw_properties().visible_content_rect = grand_child_rect; | 5557 grand_child->draw_properties().visible_content_rect = grand_child_rect; |
5603 grand_child->SetDrawsContent(true); | 5558 grand_child->SetDrawsContent(true); |
5604 | 5559 |
5605 child->AddChild(grand_child.Pass()); | 5560 child->AddChild(grand_child.Pass()); |
5606 root->AddChild(child.Pass()); | 5561 root->AddChild(child.Pass()); |
5607 | 5562 |
5608 my_host_impl->active_tree()->SetRootLayer(root.Pass()); | 5563 my_host_impl->active_tree()->SetRootLayer(root.Pass()); |
5609 return my_host_impl.Pass(); | 5564 return my_host_impl.Pass(); |
5610 } | 5565 } |
5611 | 5566 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5671 root_layer->SetHasRenderSurface(true); | 5626 root_layer->SetHasRenderSurface(true); |
5672 | 5627 |
5673 scoped_refptr<VideoFrame> softwareFrame = | 5628 scoped_refptr<VideoFrame> softwareFrame = |
5674 media::VideoFrame::CreateColorFrame( | 5629 media::VideoFrame::CreateColorFrame( |
5675 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); | 5630 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); |
5676 FakeVideoFrameProvider provider; | 5631 FakeVideoFrameProvider provider; |
5677 provider.set_frame(softwareFrame); | 5632 provider.set_frame(softwareFrame); |
5678 scoped_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( | 5633 scoped_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( |
5679 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0); | 5634 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0); |
5680 video_layer->SetBounds(gfx::Size(10, 10)); | 5635 video_layer->SetBounds(gfx::Size(10, 10)); |
5681 video_layer->SetContentBounds(gfx::Size(10, 10)); | |
5682 video_layer->SetDrawsContent(true); | 5636 video_layer->SetDrawsContent(true); |
5683 root_layer->AddChild(video_layer.Pass()); | 5637 root_layer->AddChild(video_layer.Pass()); |
5684 | 5638 |
5685 scoped_ptr<IOSurfaceLayerImpl> io_surface_layer = | 5639 scoped_ptr<IOSurfaceLayerImpl> io_surface_layer = |
5686 IOSurfaceLayerImpl::Create(host_impl_->active_tree(), 5); | 5640 IOSurfaceLayerImpl::Create(host_impl_->active_tree(), 5); |
5687 io_surface_layer->SetBounds(gfx::Size(10, 10)); | 5641 io_surface_layer->SetBounds(gfx::Size(10, 10)); |
5688 io_surface_layer->SetContentBounds(gfx::Size(10, 10)); | |
5689 io_surface_layer->SetDrawsContent(true); | 5642 io_surface_layer->SetDrawsContent(true); |
5690 io_surface_layer->SetIOSurfaceProperties(1, gfx::Size(10, 10)); | 5643 io_surface_layer->SetIOSurfaceProperties(1, gfx::Size(10, 10)); |
5691 root_layer->AddChild(io_surface_layer.Pass()); | 5644 root_layer->AddChild(io_surface_layer.Pass()); |
5692 | 5645 |
5693 host_impl_->active_tree()->SetRootLayer(root_layer.Pass()); | 5646 host_impl_->active_tree()->SetRootLayer(root_layer.Pass()); |
5694 | 5647 |
5695 EXPECT_EQ(0u, context3d->NumTextures()); | 5648 EXPECT_EQ(0u, context3d->NumTextures()); |
5696 | 5649 |
5697 LayerTreeHostImpl::FrameData frame; | 5650 LayerTreeHostImpl::FrameData frame; |
5698 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 5651 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5834 host_impl_->DidDrawAllLayers(frame); | 5787 host_impl_->DidDrawAllLayers(frame); |
5835 EXPECT_EQ(expect_to_draw, host_impl_->SwapBuffers(frame)); | 5788 EXPECT_EQ(expect_to_draw, host_impl_->SwapBuffers(frame)); |
5836 } | 5789 } |
5837 }; | 5790 }; |
5838 | 5791 |
5839 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) { | 5792 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) { |
5840 scoped_ptr<SolidColorLayerImpl> root = | 5793 scoped_ptr<SolidColorLayerImpl> root = |
5841 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 5794 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
5842 root->SetPosition(gfx::PointF()); | 5795 root->SetPosition(gfx::PointF()); |
5843 root->SetBounds(gfx::Size(10, 10)); | 5796 root->SetBounds(gfx::Size(10, 10)); |
5844 root->SetContentBounds(gfx::Size(10, 10)); | |
5845 root->SetDrawsContent(true); | 5797 root->SetDrawsContent(true); |
5846 root->SetHasRenderSurface(true); | 5798 root->SetHasRenderSurface(true); |
5847 | 5799 |
5848 // Child layer is in the bottom right corner. | 5800 // Child layer is in the bottom right corner. |
5849 scoped_ptr<SolidColorLayerImpl> child = | 5801 scoped_ptr<SolidColorLayerImpl> child = |
5850 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2); | 5802 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2); |
5851 child->SetPosition(gfx::PointF(9.f, 9.f)); | 5803 child->SetPosition(gfx::PointF(9.f, 9.f)); |
5852 child->SetBounds(gfx::Size(1, 1)); | 5804 child->SetBounds(gfx::Size(1, 1)); |
5853 child->SetContentBounds(gfx::Size(1, 1)); | |
5854 child->SetDrawsContent(true); | 5805 child->SetDrawsContent(true); |
5855 root->AddChild(child.Pass()); | 5806 root->AddChild(child.Pass()); |
5856 | 5807 |
5857 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 5808 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
5858 | 5809 |
5859 // Draw a frame. In the first frame, the entire viewport should be damaged. | 5810 // Draw a frame. In the first frame, the entire viewport should be damaged. |
5860 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); | 5811 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); |
5861 DrawFrameAndTestDamage(full_frame_damage); | 5812 DrawFrameAndTestDamage(full_frame_damage); |
5862 | 5813 |
5863 // The second frame has damage that doesn't touch the child layer. Its quads | 5814 // The second frame has damage that doesn't touch the child layer. Its quads |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6067 | 6018 |
6068 // SolidColorLayerImpl will be drawn. | 6019 // SolidColorLayerImpl will be drawn. |
6069 scoped_ptr<SolidColorLayerImpl> root_layer = | 6020 scoped_ptr<SolidColorLayerImpl> root_layer = |
6070 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 6021 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
6071 | 6022 |
6072 // VideoLayerImpl will not be drawn. | 6023 // VideoLayerImpl will not be drawn. |
6073 FakeVideoFrameProvider provider; | 6024 FakeVideoFrameProvider provider; |
6074 scoped_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( | 6025 scoped_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( |
6075 host_impl_->active_tree(), 2, &provider, media::VIDEO_ROTATION_0); | 6026 host_impl_->active_tree(), 2, &provider, media::VIDEO_ROTATION_0); |
6076 video_layer->SetBounds(gfx::Size(10, 10)); | 6027 video_layer->SetBounds(gfx::Size(10, 10)); |
6077 video_layer->SetContentBounds(gfx::Size(10, 10)); | |
6078 video_layer->SetDrawsContent(true); | 6028 video_layer->SetDrawsContent(true); |
6079 root_layer->AddChild(video_layer.Pass()); | 6029 root_layer->AddChild(video_layer.Pass()); |
6080 SetupRootLayerImpl(root_layer.Pass()); | 6030 SetupRootLayerImpl(root_layer.Pass()); |
6081 | 6031 |
6082 LayerTreeHostImpl::FrameData frame; | 6032 LayerTreeHostImpl::FrameData frame; |
6083 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 6033 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6084 host_impl_->DrawLayers(&frame); | 6034 host_impl_->DrawLayers(&frame); |
6085 host_impl_->DidDrawAllLayers(frame); | 6035 host_impl_->DidDrawAllLayers(frame); |
6086 | 6036 |
6087 EXPECT_EQ(1u, frame.will_draw_layers.size()); | 6037 EXPECT_EQ(1u, frame.will_draw_layers.size()); |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6492 | 6442 |
6493 int page_scale_layer_id = 5; | 6443 int page_scale_layer_id = 5; |
6494 LayerImpl* page_scale_layer = | 6444 LayerImpl* page_scale_layer = |
6495 host_impl_->active_tree()->LayerById(page_scale_layer_id); | 6445 host_impl_->active_tree()->LayerById(page_scale_layer_id); |
6496 | 6446 |
6497 int occluder_layer_id = 6; | 6447 int occluder_layer_id = 6; |
6498 scoped_ptr<LayerImpl> occluder_layer = | 6448 scoped_ptr<LayerImpl> occluder_layer = |
6499 LayerImpl::Create(host_impl_->active_tree(), occluder_layer_id); | 6449 LayerImpl::Create(host_impl_->active_tree(), occluder_layer_id); |
6500 occluder_layer->SetDrawsContent(true); | 6450 occluder_layer->SetDrawsContent(true); |
6501 occluder_layer->SetBounds(content_size); | 6451 occluder_layer->SetBounds(content_size); |
6502 occluder_layer->SetContentBounds(content_size); | |
6503 occluder_layer->SetPosition(gfx::PointF()); | 6452 occluder_layer->SetPosition(gfx::PointF()); |
6504 | 6453 |
6505 // The parent of the occluder is *above* the scroller. | 6454 // The parent of the occluder is *above* the scroller. |
6506 page_scale_layer->AddChild(occluder_layer.Pass()); | 6455 page_scale_layer->AddChild(occluder_layer.Pass()); |
6507 | 6456 |
6508 DrawFrame(); | 6457 DrawFrame(); |
6509 | 6458 |
6510 EXPECT_EQ(InputHandler::SCROLL_UNKNOWN, | 6459 EXPECT_EQ(InputHandler::SCROLL_UNKNOWN, |
6511 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 6460 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); |
6512 } | 6461 } |
6513 | 6462 |
6514 TEST_F(LayerTreeHostImplTest, ScrollUnknownScrollAncestorMismatch) { | 6463 TEST_F(LayerTreeHostImplTest, ScrollUnknownScrollAncestorMismatch) { |
6515 // If we ray cast a scroller this is on the first layer's ancestor chain, but | 6464 // If we ray cast a scroller this is on the first layer's ancestor chain, but |
6516 // is not the first scroller we encounter when walking up from the layer, we | 6465 // is not the first scroller we encounter when walking up from the layer, we |
6517 // should also return SCROLL_UNKNOWN. | 6466 // should also return SCROLL_UNKNOWN. |
6518 gfx::Size content_size(100, 100); | 6467 gfx::Size content_size(100, 100); |
6519 SetupScrollAndContentsLayers(content_size); | 6468 SetupScrollAndContentsLayers(content_size); |
6520 | 6469 |
6521 int scroll_layer_id = 2; | 6470 int scroll_layer_id = 2; |
6522 LayerImpl* scroll_layer = | 6471 LayerImpl* scroll_layer = |
6523 host_impl_->active_tree()->LayerById(scroll_layer_id); | 6472 host_impl_->active_tree()->LayerById(scroll_layer_id); |
6524 scroll_layer->SetDrawsContent(true); | 6473 scroll_layer->SetDrawsContent(true); |
6525 | 6474 |
6526 int occluder_layer_id = 6; | 6475 int occluder_layer_id = 6; |
6527 scoped_ptr<LayerImpl> occluder_layer = | 6476 scoped_ptr<LayerImpl> occluder_layer = |
6528 LayerImpl::Create(host_impl_->active_tree(), occluder_layer_id); | 6477 LayerImpl::Create(host_impl_->active_tree(), occluder_layer_id); |
6529 occluder_layer->SetDrawsContent(true); | 6478 occluder_layer->SetDrawsContent(true); |
6530 occluder_layer->SetBounds(content_size); | 6479 occluder_layer->SetBounds(content_size); |
6531 occluder_layer->SetContentBounds(content_size); | |
6532 occluder_layer->SetPosition(gfx::PointF(-10.f, -10.f)); | 6480 occluder_layer->SetPosition(gfx::PointF(-10.f, -10.f)); |
6533 | 6481 |
6534 int child_scroll_clip_layer_id = 7; | 6482 int child_scroll_clip_layer_id = 7; |
6535 scoped_ptr<LayerImpl> child_scroll_clip = | 6483 scoped_ptr<LayerImpl> child_scroll_clip = |
6536 LayerImpl::Create(host_impl_->active_tree(), child_scroll_clip_layer_id); | 6484 LayerImpl::Create(host_impl_->active_tree(), child_scroll_clip_layer_id); |
6537 | 6485 |
6538 int child_scroll_layer_id = 8; | 6486 int child_scroll_layer_id = 8; |
6539 scoped_ptr<LayerImpl> child_scroll = CreateScrollableLayer( | 6487 scoped_ptr<LayerImpl> child_scroll = CreateScrollableLayer( |
6540 child_scroll_layer_id, content_size, child_scroll_clip.get()); | 6488 child_scroll_layer_id, content_size, child_scroll_clip.get()); |
6541 | 6489 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6593 invisible_scroll_layer->SetDrawsContent(false); | 6541 invisible_scroll_layer->SetDrawsContent(false); |
6594 | 6542 |
6595 scoped_ptr<LayerImpl> child_layer = | 6543 scoped_ptr<LayerImpl> child_layer = |
6596 LayerImpl::Create(host_impl_->active_tree(), 8); | 6544 LayerImpl::Create(host_impl_->active_tree(), 8); |
6597 child_layer->SetDrawsContent(false); | 6545 child_layer->SetDrawsContent(false); |
6598 | 6546 |
6599 scoped_ptr<LayerImpl> grand_child_layer = | 6547 scoped_ptr<LayerImpl> grand_child_layer = |
6600 LayerImpl::Create(host_impl_->active_tree(), 9); | 6548 LayerImpl::Create(host_impl_->active_tree(), 9); |
6601 grand_child_layer->SetDrawsContent(true); | 6549 grand_child_layer->SetDrawsContent(true); |
6602 grand_child_layer->SetBounds(content_size); | 6550 grand_child_layer->SetBounds(content_size); |
6603 grand_child_layer->SetContentBounds(content_size); | |
6604 // Move the grand child so it's not hit by our test point. | 6551 // Move the grand child so it's not hit by our test point. |
6605 grand_child_layer->SetPosition(gfx::PointF(10.f, 10.f)); | 6552 grand_child_layer->SetPosition(gfx::PointF(10.f, 10.f)); |
6606 | 6553 |
6607 child_layer->AddChild(grand_child_layer.Pass()); | 6554 child_layer->AddChild(grand_child_layer.Pass()); |
6608 invisible_scroll_layer->AddChild(child_layer.Pass()); | 6555 invisible_scroll_layer->AddChild(child_layer.Pass()); |
6609 root_scroll_layer->AddChild(invisible_scroll_layer.Pass()); | 6556 root_scroll_layer->AddChild(invisible_scroll_layer.Pass()); |
6610 | 6557 |
6611 DrawFrame(); | 6558 DrawFrame(); |
6612 | 6559 |
6613 // We should have scrolled |invisible_scroll_layer| as it was hit and it has | 6560 // We should have scrolled |invisible_scroll_layer| as it was hit and it has |
(...skipping 16 matching lines...) Expand all Loading... |
6630 | 6577 |
6631 int scroll_layer_id = 2; | 6578 int scroll_layer_id = 2; |
6632 LayerImpl* scroll_layer = | 6579 LayerImpl* scroll_layer = |
6633 host_impl_->active_tree()->LayerById(scroll_layer_id); | 6580 host_impl_->active_tree()->LayerById(scroll_layer_id); |
6634 | 6581 |
6635 int scroll_child_id = 6; | 6582 int scroll_child_id = 6; |
6636 scoped_ptr<LayerImpl> scroll_child = | 6583 scoped_ptr<LayerImpl> scroll_child = |
6637 LayerImpl::Create(host_impl_->active_tree(), scroll_child_id); | 6584 LayerImpl::Create(host_impl_->active_tree(), scroll_child_id); |
6638 scroll_child->SetDrawsContent(true); | 6585 scroll_child->SetDrawsContent(true); |
6639 scroll_child->SetBounds(content_size); | 6586 scroll_child->SetBounds(content_size); |
6640 scroll_child->SetContentBounds(content_size); | |
6641 // Move the scroll child so it's not hit by our test point. | 6587 // Move the scroll child so it's not hit by our test point. |
6642 scroll_child->SetPosition(gfx::PointF(10.f, 10.f)); | 6588 scroll_child->SetPosition(gfx::PointF(10.f, 10.f)); |
6643 | 6589 |
6644 int invisible_scroll_layer_id = 7; | 6590 int invisible_scroll_layer_id = 7; |
6645 scoped_ptr<LayerImpl> invisible_scroll = | 6591 scoped_ptr<LayerImpl> invisible_scroll = |
6646 CreateScrollableLayer(invisible_scroll_layer_id, content_size, root); | 6592 CreateScrollableLayer(invisible_scroll_layer_id, content_size, root); |
6647 invisible_scroll->SetDrawsContent(false); | 6593 invisible_scroll->SetDrawsContent(false); |
6648 | 6594 |
6649 int container_id = 8; | 6595 int container_id = 8; |
6650 scoped_ptr<LayerImpl> container = | 6596 scoped_ptr<LayerImpl> container = |
(...skipping 21 matching lines...) Expand all Loading... |
6672 EXPECT_EQ(7, host_impl_->CurrentlyScrollingLayer()->id()); | 6618 EXPECT_EQ(7, host_impl_->CurrentlyScrollingLayer()->id()); |
6673 } | 6619 } |
6674 | 6620 |
6675 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed | 6621 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed |
6676 // to CompositorFrameMetadata after SwapBuffers(); | 6622 // to CompositorFrameMetadata after SwapBuffers(); |
6677 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { | 6623 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { |
6678 scoped_ptr<SolidColorLayerImpl> root = | 6624 scoped_ptr<SolidColorLayerImpl> root = |
6679 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 6625 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
6680 root->SetPosition(gfx::PointF()); | 6626 root->SetPosition(gfx::PointF()); |
6681 root->SetBounds(gfx::Size(10, 10)); | 6627 root->SetBounds(gfx::Size(10, 10)); |
6682 root->SetContentBounds(gfx::Size(10, 10)); | |
6683 root->SetDrawsContent(true); | 6628 root->SetDrawsContent(true); |
6684 root->SetHasRenderSurface(true); | 6629 root->SetHasRenderSurface(true); |
6685 | 6630 |
6686 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 6631 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
6687 | 6632 |
6688 FakeOutputSurface* fake_output_surface = | 6633 FakeOutputSurface* fake_output_surface = |
6689 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 6634 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); |
6690 | 6635 |
6691 const std::vector<ui::LatencyInfo>& metadata_latency_before = | 6636 const std::vector<ui::LatencyInfo>& metadata_latency_before = |
6692 fake_output_surface->last_sent_frame().metadata.latency_info; | 6637 fake_output_surface->last_sent_frame().metadata.latency_info; |
(...skipping 20 matching lines...) Expand all Loading... |
6713 EXPECT_TRUE(metadata_latency_after[0].FindLatency( | 6658 EXPECT_TRUE(metadata_latency_after[0].FindLatency( |
6714 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL)); | 6659 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL)); |
6715 } | 6660 } |
6716 | 6661 |
6717 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { | 6662 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { |
6718 int root_layer_id = 1; | 6663 int root_layer_id = 1; |
6719 scoped_ptr<SolidColorLayerImpl> root = | 6664 scoped_ptr<SolidColorLayerImpl> root = |
6720 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id); | 6665 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id); |
6721 root->SetPosition(gfx::PointF()); | 6666 root->SetPosition(gfx::PointF()); |
6722 root->SetBounds(gfx::Size(10, 10)); | 6667 root->SetBounds(gfx::Size(10, 10)); |
6723 root->SetContentBounds(gfx::Size(10, 10)); | |
6724 root->SetDrawsContent(true); | 6668 root->SetDrawsContent(true); |
6725 root->SetHasRenderSurface(true); | 6669 root->SetHasRenderSurface(true); |
6726 | 6670 |
6727 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 6671 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
6728 | 6672 |
6729 // Ensure the default frame selection bounds are empty. | 6673 // Ensure the default frame selection bounds are empty. |
6730 FakeOutputSurface* fake_output_surface = | 6674 FakeOutputSurface* fake_output_surface = |
6731 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 6675 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); |
6732 const ViewportSelection& selection_before = | 6676 const ViewportSelection& selection_before = |
6733 fake_output_surface->last_sent_frame().metadata.selection; | 6677 fake_output_surface->last_sent_frame().metadata.selection; |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7274 | 7218 |
7275 scoped_ptr<LayerImpl> inner_clip = | 7219 scoped_ptr<LayerImpl> inner_clip = |
7276 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId); | 7220 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId); |
7277 inner_clip->SetBounds(inner_viewport); | 7221 inner_clip->SetBounds(inner_viewport); |
7278 | 7222 |
7279 scoped_ptr<LayerImpl> page_scale = | 7223 scoped_ptr<LayerImpl> page_scale = |
7280 LayerImpl::Create(layer_tree_impl, kPageScaleLayerId); | 7224 LayerImpl::Create(layer_tree_impl, kPageScaleLayerId); |
7281 | 7225 |
7282 inner_scroll->SetScrollClipLayer(inner_clip->id()); | 7226 inner_scroll->SetScrollClipLayer(inner_clip->id()); |
7283 inner_scroll->SetBounds(outer_viewport); | 7227 inner_scroll->SetBounds(outer_viewport); |
7284 inner_scroll->SetContentBounds(outer_viewport); | |
7285 inner_scroll->SetPosition(gfx::PointF()); | 7228 inner_scroll->SetPosition(gfx::PointF()); |
7286 | 7229 |
7287 scoped_ptr<LayerImpl> outer_clip = | 7230 scoped_ptr<LayerImpl> outer_clip = |
7288 LayerImpl::Create(layer_tree_impl, kOuterViewportClipLayerId); | 7231 LayerImpl::Create(layer_tree_impl, kOuterViewportClipLayerId); |
7289 outer_clip->SetBounds(outer_viewport); | 7232 outer_clip->SetBounds(outer_viewport); |
7290 outer_clip->SetIsContainerForFixedPositionLayers(true); | 7233 outer_clip->SetIsContainerForFixedPositionLayers(true); |
7291 | 7234 |
7292 scoped_ptr<LayerImpl> outer_scroll = | 7235 scoped_ptr<LayerImpl> outer_scroll = |
7293 LayerImpl::Create(layer_tree_impl, kOuterViewportScrollLayerId); | 7236 LayerImpl::Create(layer_tree_impl, kOuterViewportScrollLayerId); |
7294 outer_scroll->SetScrollClipLayer(outer_clip->id()); | 7237 outer_scroll->SetScrollClipLayer(outer_clip->id()); |
7295 outer_scroll->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); | 7238 outer_scroll->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); |
7296 outer_scroll->SetBounds(content_size); | 7239 outer_scroll->SetBounds(content_size); |
7297 outer_scroll->SetContentBounds(content_size); | |
7298 outer_scroll->SetPosition(gfx::PointF()); | 7240 outer_scroll->SetPosition(gfx::PointF()); |
7299 | 7241 |
7300 scoped_ptr<LayerImpl> contents = | 7242 scoped_ptr<LayerImpl> contents = |
7301 LayerImpl::Create(layer_tree_impl, 8); | 7243 LayerImpl::Create(layer_tree_impl, 8); |
7302 contents->SetDrawsContent(true); | 7244 contents->SetDrawsContent(true); |
7303 contents->SetBounds(content_size); | 7245 contents->SetBounds(content_size); |
7304 contents->SetContentBounds(content_size); | |
7305 contents->SetPosition(gfx::PointF()); | 7246 contents->SetPosition(gfx::PointF()); |
7306 | 7247 |
7307 outer_scroll->AddChild(contents.Pass()); | 7248 outer_scroll->AddChild(contents.Pass()); |
7308 outer_clip->AddChild(outer_scroll.Pass()); | 7249 outer_clip->AddChild(outer_scroll.Pass()); |
7309 inner_scroll->AddChild(outer_clip.Pass()); | 7250 inner_scroll->AddChild(outer_clip.Pass()); |
7310 page_scale->AddChild(inner_scroll.Pass()); | 7251 page_scale->AddChild(inner_scroll.Pass()); |
7311 inner_clip->AddChild(page_scale.Pass()); | 7252 inner_clip->AddChild(page_scale.Pass()); |
7312 | 7253 |
7313 inner_clip->SetHasRenderSurface(true); | 7254 inner_clip->SetHasRenderSurface(true); |
7314 layer_tree_impl->SetRootLayer(inner_clip.Pass()); | 7255 layer_tree_impl->SetRootLayer(inner_clip.Pass()); |
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8036 // Hold an unowned pointer to the output surface to use for mock expectations. | 7977 // Hold an unowned pointer to the output surface to use for mock expectations. |
8037 MockReclaimResourcesOutputSurface* mock_output_surface = output_surface.get(); | 7978 MockReclaimResourcesOutputSurface* mock_output_surface = output_surface.get(); |
8038 | 7979 |
8039 CreateHostImpl(DefaultSettings(), output_surface.Pass()); | 7980 CreateHostImpl(DefaultSettings(), output_surface.Pass()); |
8040 EXPECT_CALL(*mock_output_surface, ForceReclaimResources()).Times(1); | 7981 EXPECT_CALL(*mock_output_surface, ForceReclaimResources()).Times(1); |
8041 host_impl_->BeginCommit(); | 7982 host_impl_->BeginCommit(); |
8042 } | 7983 } |
8043 | 7984 |
8044 } // namespace | 7985 } // namespace |
8045 } // namespace cc | 7986 } // namespace cc |
OLD | NEW |