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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 host_impl_->animation_host()->AddAnimationTimeline(timeline_); | 210 host_impl_->animation_host()->AddAnimationTimeline(timeline_); |
211 | 211 |
212 return init; | 212 return init; |
213 } | 213 } |
214 | 214 |
215 void SetupRootLayerImpl(std::unique_ptr<LayerImpl> root) { | 215 void SetupRootLayerImpl(std::unique_ptr<LayerImpl> root) { |
216 root->SetPosition(gfx::PointF()); | 216 root->SetPosition(gfx::PointF()); |
217 root->SetBounds(gfx::Size(10, 10)); | 217 root->SetBounds(gfx::Size(10, 10)); |
218 root->SetDrawsContent(true); | 218 root->SetDrawsContent(true); |
219 root->draw_properties().visible_layer_rect = gfx::Rect(0, 0, 10, 10); | 219 root->draw_properties().visible_layer_rect = gfx::Rect(0, 0, 10, 10); |
220 root->SetForceRenderSurface(true); | 220 root->test_properties()->force_render_surface = true; |
221 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 221 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
222 } | 222 } |
223 | 223 |
224 static gfx::Vector2dF ScrollDelta(LayerImpl* layer_impl) { | 224 static gfx::Vector2dF ScrollDelta(LayerImpl* layer_impl) { |
225 gfx::ScrollOffset delta = | 225 gfx::ScrollOffset delta = |
226 layer_impl->layer_tree_impl() | 226 layer_impl->layer_tree_impl() |
227 ->property_trees() | 227 ->property_trees() |
228 ->scroll_tree.GetScrollOffsetDeltaForTesting(layer_impl->id()); | 228 ->scroll_tree.GetScrollOffsetDeltaForTesting(layer_impl->id()); |
229 return gfx::Vector2dF(delta.x(), delta.y()); | 229 return gfx::Vector2dF(delta.x(), delta.y()); |
230 } | 230 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 const int kOuterViewportClipLayerId = 116; | 278 const int kOuterViewportClipLayerId = 116; |
279 const int kOuterViewportScrollLayerId = 117; | 279 const int kOuterViewportScrollLayerId = 117; |
280 const int kContentLayerId = 118; | 280 const int kContentLayerId = 118; |
281 const int kInnerViewportScrollLayerId = 2; | 281 const int kInnerViewportScrollLayerId = 2; |
282 const int kInnerViewportClipLayerId = 4; | 282 const int kInnerViewportClipLayerId = 4; |
283 const int kPageScaleLayerId = 5; | 283 const int kPageScaleLayerId = 5; |
284 | 284 |
285 std::unique_ptr<LayerImpl> root = LayerImpl::Create(layer_tree_impl, 1); | 285 std::unique_ptr<LayerImpl> root = LayerImpl::Create(layer_tree_impl, 1); |
286 root->SetBounds(content_size); | 286 root->SetBounds(content_size); |
287 root->SetPosition(gfx::PointF()); | 287 root->SetPosition(gfx::PointF()); |
288 root->SetForceRenderSurface(true); | 288 root->test_properties()->force_render_surface = true; |
289 | 289 |
290 std::unique_ptr<LayerImpl> inner_scroll = | 290 std::unique_ptr<LayerImpl> inner_scroll = |
291 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId); | 291 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId); |
292 inner_scroll->SetIsContainerForFixedPositionLayers(true); | 292 inner_scroll->SetIsContainerForFixedPositionLayers(true); |
293 inner_scroll->layer_tree_impl() | 293 inner_scroll->layer_tree_impl() |
294 ->property_trees() | 294 ->property_trees() |
295 ->scroll_tree.UpdateScrollOffsetBaseForTesting(inner_scroll->id(), | 295 ->scroll_tree.UpdateScrollOffsetBaseForTesting(inner_scroll->id(), |
296 gfx::ScrollOffset()); | 296 gfx::ScrollOffset()); |
297 | 297 |
298 std::unique_ptr<LayerImpl> inner_clip = | 298 std::unique_ptr<LayerImpl> inner_clip = |
(...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1298 TEST_F(LayerTreeHostImplTest, AnimationSchedulingPendingTree) { | 1298 TEST_F(LayerTreeHostImplTest, AnimationSchedulingPendingTree) { |
1299 EXPECT_FALSE(host_impl_->CommitToActiveTree()); | 1299 EXPECT_FALSE(host_impl_->CommitToActiveTree()); |
1300 | 1300 |
1301 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1301 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
1302 | 1302 |
1303 host_impl_->CreatePendingTree(); | 1303 host_impl_->CreatePendingTree(); |
1304 host_impl_->pending_tree()->SetRootLayer( | 1304 host_impl_->pending_tree()->SetRootLayer( |
1305 LayerImpl::Create(host_impl_->pending_tree(), 1)); | 1305 LayerImpl::Create(host_impl_->pending_tree(), 1)); |
1306 LayerImpl* root = host_impl_->pending_tree()->root_layer(); | 1306 LayerImpl* root = host_impl_->pending_tree()->root_layer(); |
1307 root->SetBounds(gfx::Size(50, 50)); | 1307 root->SetBounds(gfx::Size(50, 50)); |
1308 root->SetForceRenderSurface(true); | 1308 root->test_properties()->force_render_surface = true; |
1309 | 1309 |
1310 root->AddChild(LayerImpl::Create(host_impl_->pending_tree(), 2)); | 1310 root->AddChild(LayerImpl::Create(host_impl_->pending_tree(), 2)); |
1311 LayerImpl* child = root->children()[0]; | 1311 LayerImpl* child = root->children()[0]; |
1312 child->SetBounds(gfx::Size(10, 10)); | 1312 child->SetBounds(gfx::Size(10, 10)); |
1313 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); | 1313 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); |
1314 child->SetDrawsContent(true); | 1314 child->SetDrawsContent(true); |
1315 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 10.0, 3, 0); | 1315 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 10.0, 3, 0); |
1316 | 1316 |
1317 EXPECT_FALSE(did_request_next_frame_); | 1317 EXPECT_FALSE(did_request_next_frame_); |
1318 EXPECT_FALSE(did_request_redraw_); | 1318 EXPECT_FALSE(did_request_redraw_); |
(...skipping 29 matching lines...) Expand all Loading... |
1348 | 1348 |
1349 TEST_F(LayerTreeHostImplTest, AnimationSchedulingActiveTree) { | 1349 TEST_F(LayerTreeHostImplTest, AnimationSchedulingActiveTree) { |
1350 EXPECT_FALSE(host_impl_->CommitToActiveTree()); | 1350 EXPECT_FALSE(host_impl_->CommitToActiveTree()); |
1351 | 1351 |
1352 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1352 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
1353 | 1353 |
1354 host_impl_->active_tree()->SetRootLayer( | 1354 host_impl_->active_tree()->SetRootLayer( |
1355 LayerImpl::Create(host_impl_->active_tree(), 1)); | 1355 LayerImpl::Create(host_impl_->active_tree(), 1)); |
1356 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 1356 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
1357 root->SetBounds(gfx::Size(50, 50)); | 1357 root->SetBounds(gfx::Size(50, 50)); |
1358 root->SetForceRenderSurface(true); | 1358 root->test_properties()->force_render_surface = true; |
1359 | 1359 |
1360 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); | 1360 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); |
1361 LayerImpl* child = root->children()[0]; | 1361 LayerImpl* child = root->children()[0]; |
1362 child->SetBounds(gfx::Size(10, 10)); | 1362 child->SetBounds(gfx::Size(10, 10)); |
1363 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); | 1363 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); |
1364 child->SetDrawsContent(true); | 1364 child->SetDrawsContent(true); |
1365 | 1365 |
1366 // Add a translate from 6,7 to 8,9. | 1366 // Add a translate from 6,7 to 8,9. |
1367 TransformOperations start; | 1367 TransformOperations start; |
1368 start.AppendTranslate(6.f, 7.f, 0.f); | 1368 start.AppendTranslate(6.f, 7.f, 0.f); |
(...skipping 1922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3291 append_quads_called_ = false; | 3291 append_quads_called_ = false; |
3292 did_draw_called_ = false; | 3292 did_draw_called_ = false; |
3293 } | 3293 } |
3294 | 3294 |
3295 static void IgnoreResult(std::unique_ptr<CopyOutputResult> result) {} | 3295 static void IgnoreResult(std::unique_ptr<CopyOutputResult> result) {} |
3296 | 3296 |
3297 void AddCopyRequest() { | 3297 void AddCopyRequest() { |
3298 std::vector<std::unique_ptr<CopyOutputRequest>> requests; | 3298 std::vector<std::unique_ptr<CopyOutputRequest>> requests; |
3299 requests.push_back( | 3299 requests.push_back( |
3300 CopyOutputRequest::CreateRequest(base::Bind(&IgnoreResult))); | 3300 CopyOutputRequest::CreateRequest(base::Bind(&IgnoreResult))); |
3301 SetForceRenderSurface(true); | 3301 test_properties()->force_render_surface = true; |
3302 PassCopyRequests(&requests); | 3302 PassCopyRequests(&requests); |
3303 } | 3303 } |
3304 | 3304 |
3305 protected: | 3305 protected: |
3306 DidDrawCheckLayer(LayerTreeImpl* tree_impl, int id) | 3306 DidDrawCheckLayer(LayerTreeImpl* tree_impl, int id) |
3307 : LayerImpl(tree_impl, id), | 3307 : LayerImpl(tree_impl, id), |
3308 will_draw_returns_false_(false), | 3308 will_draw_returns_false_(false), |
3309 will_draw_called_(false), | 3309 will_draw_called_(false), |
3310 append_quads_called_(false), | 3310 append_quads_called_(false), |
3311 did_draw_called_(false) { | 3311 did_draw_called_(false) { |
(...skipping 11 matching lines...) Expand all Loading... |
3323 | 3323 |
3324 TEST_F(LayerTreeHostImplTest, WillDrawReturningFalseDoesNotCall) { | 3324 TEST_F(LayerTreeHostImplTest, WillDrawReturningFalseDoesNotCall) { |
3325 // The root layer is always drawn, so run this test on a child layer that | 3325 // The root layer is always drawn, so run this test on a child layer that |
3326 // will be masked out by the root layer's bounds. | 3326 // will be masked out by the root layer's bounds. |
3327 host_impl_->active_tree()->SetRootLayer( | 3327 host_impl_->active_tree()->SetRootLayer( |
3328 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 3328 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
3329 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( | 3329 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( |
3330 host_impl_->active_tree()->root_layer()); | 3330 host_impl_->active_tree()->root_layer()); |
3331 | 3331 |
3332 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 3332 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
3333 root->SetForceRenderSurface(true); | 3333 root->test_properties()->force_render_surface = true; |
3334 DidDrawCheckLayer* layer = | 3334 DidDrawCheckLayer* layer = |
3335 static_cast<DidDrawCheckLayer*>(root->children()[0]); | 3335 static_cast<DidDrawCheckLayer*>(root->children()[0]); |
3336 | 3336 |
3337 { | 3337 { |
3338 LayerTreeHostImpl::FrameData frame; | 3338 LayerTreeHostImpl::FrameData frame; |
3339 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 3339 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
3340 host_impl_->DrawLayers(&frame); | 3340 host_impl_->DrawLayers(&frame); |
3341 host_impl_->DidDrawAllLayers(frame); | 3341 host_impl_->DidDrawAllLayers(frame); |
3342 | 3342 |
3343 EXPECT_TRUE(layer->will_draw_called()); | 3343 EXPECT_TRUE(layer->will_draw_called()); |
(...skipping 20 matching lines...) Expand all Loading... |
3364 } | 3364 } |
3365 | 3365 |
3366 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) { | 3366 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) { |
3367 // The root layer is always drawn, so run this test on a child layer that | 3367 // The root layer is always drawn, so run this test on a child layer that |
3368 // will be masked out by the root layer's bounds. | 3368 // will be masked out by the root layer's bounds. |
3369 host_impl_->active_tree()->SetRootLayer( | 3369 host_impl_->active_tree()->SetRootLayer( |
3370 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 3370 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
3371 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( | 3371 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( |
3372 host_impl_->active_tree()->root_layer()); | 3372 host_impl_->active_tree()->root_layer()); |
3373 root->SetMasksToBounds(true); | 3373 root->SetMasksToBounds(true); |
3374 root->SetForceRenderSurface(true); | 3374 root->test_properties()->force_render_surface = true; |
3375 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 3375 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
3376 DidDrawCheckLayer* layer = | 3376 DidDrawCheckLayer* layer = |
3377 static_cast<DidDrawCheckLayer*>(root->children()[0]); | 3377 static_cast<DidDrawCheckLayer*>(root->children()[0]); |
3378 // Ensure visible_layer_rect for layer is empty. | 3378 // Ensure visible_layer_rect for layer is empty. |
3379 layer->SetPosition(gfx::PointF(100.f, 100.f)); | 3379 layer->SetPosition(gfx::PointF(100.f, 100.f)); |
3380 layer->SetBounds(gfx::Size(10, 10)); | 3380 layer->SetBounds(gfx::Size(10, 10)); |
3381 | 3381 |
3382 LayerTreeHostImpl::FrameData frame; | 3382 LayerTreeHostImpl::FrameData frame; |
3383 | 3383 |
3384 EXPECT_FALSE(layer->will_draw_called()); | 3384 EXPECT_FALSE(layer->will_draw_called()); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3419 host_impl_->active_tree()->SetRootLayer( | 3419 host_impl_->active_tree()->SetRootLayer( |
3420 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 3420 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
3421 DidDrawCheckLayer* root = | 3421 DidDrawCheckLayer* root = |
3422 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 3422 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
3423 | 3423 |
3424 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 3424 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
3425 DidDrawCheckLayer* occluded_layer = | 3425 DidDrawCheckLayer* occluded_layer = |
3426 static_cast<DidDrawCheckLayer*>(root->children()[0]); | 3426 static_cast<DidDrawCheckLayer*>(root->children()[0]); |
3427 | 3427 |
3428 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 3428 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
3429 root->SetForceRenderSurface(true); | 3429 root->test_properties()->force_render_surface = true; |
3430 DidDrawCheckLayer* top_layer = | 3430 DidDrawCheckLayer* top_layer = |
3431 static_cast<DidDrawCheckLayer*>(root->children()[1]); | 3431 static_cast<DidDrawCheckLayer*>(root->children()[1]); |
3432 // This layer covers the occluded_layer above. Make this layer large so it can | 3432 // This layer covers the occluded_layer above. Make this layer large so it can |
3433 // occlude. | 3433 // occlude. |
3434 top_layer->SetBounds(big_size); | 3434 top_layer->SetBounds(big_size); |
3435 top_layer->SetContentsOpaque(true); | 3435 top_layer->SetContentsOpaque(true); |
3436 | 3436 |
3437 LayerTreeHostImpl::FrameData frame; | 3437 LayerTreeHostImpl::FrameData frame; |
3438 | 3438 |
3439 EXPECT_FALSE(occluded_layer->will_draw_called()); | 3439 EXPECT_FALSE(occluded_layer->will_draw_called()); |
(...skipping 11 matching lines...) Expand all Loading... |
3451 EXPECT_TRUE(top_layer->did_draw_called()); | 3451 EXPECT_TRUE(top_layer->did_draw_called()); |
3452 } | 3452 } |
3453 | 3453 |
3454 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { | 3454 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { |
3455 host_impl_->active_tree()->SetRootLayer( | 3455 host_impl_->active_tree()->SetRootLayer( |
3456 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 3456 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
3457 DidDrawCheckLayer* root = | 3457 DidDrawCheckLayer* root = |
3458 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 3458 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
3459 | 3459 |
3460 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 3460 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
3461 root->SetForceRenderSurface(true); | 3461 root->test_properties()->force_render_surface = true; |
3462 DidDrawCheckLayer* layer1 = | 3462 DidDrawCheckLayer* layer1 = |
3463 static_cast<DidDrawCheckLayer*>(root->children()[0]); | 3463 static_cast<DidDrawCheckLayer*>(root->children()[0]); |
3464 | 3464 |
3465 layer1->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 3465 layer1->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
3466 DidDrawCheckLayer* layer2 = | 3466 DidDrawCheckLayer* layer2 = |
3467 static_cast<DidDrawCheckLayer*>(layer1->children()[0]); | 3467 static_cast<DidDrawCheckLayer*>(layer1->children()[0]); |
3468 | 3468 |
3469 layer1->SetForceRenderSurface(true); | 3469 layer1->test_properties()->force_render_surface = true; |
3470 layer1->SetShouldFlattenTransform(true); | 3470 layer1->SetShouldFlattenTransform(true); |
3471 | 3471 |
3472 EXPECT_FALSE(root->did_draw_called()); | 3472 EXPECT_FALSE(root->did_draw_called()); |
3473 EXPECT_FALSE(layer1->did_draw_called()); | 3473 EXPECT_FALSE(layer1->did_draw_called()); |
3474 EXPECT_FALSE(layer2->did_draw_called()); | 3474 EXPECT_FALSE(layer2->did_draw_called()); |
3475 | 3475 |
3476 LayerTreeHostImpl::FrameData frame; | 3476 LayerTreeHostImpl::FrameData frame; |
3477 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( | 3477 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( |
3478 host_impl_->active_tree()->root_layer()); | 3478 host_impl_->active_tree()->root_layer()); |
3479 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 3479 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3616 PrepareToDrawSuccessTestCase(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT)); | 3616 PrepareToDrawSuccessTestCase(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT)); |
3617 cases.back().high_res_required = true; | 3617 cases.back().high_res_required = true; |
3618 cases.back().layer_between.has_missing_tile = true; | 3618 cases.back().layer_between.has_missing_tile = true; |
3619 cases.back().layer_before.has_missing_tile = true; | 3619 cases.back().layer_before.has_missing_tile = true; |
3620 cases.back().layer_before.is_animating = true; | 3620 cases.back().layer_before.is_animating = true; |
3621 | 3621 |
3622 host_impl_->active_tree()->SetRootLayer( | 3622 host_impl_->active_tree()->SetRootLayer( |
3623 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 3623 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
3624 DidDrawCheckLayer* root = | 3624 DidDrawCheckLayer* root = |
3625 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 3625 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
3626 root->SetForceRenderSurface(true); | 3626 root->test_properties()->force_render_surface = true; |
3627 | 3627 |
3628 LayerTreeHostImpl::FrameData frame; | 3628 LayerTreeHostImpl::FrameData frame; |
3629 SetNeedsRebuildPropertyTrees(); | 3629 SetNeedsRebuildPropertyTrees(); |
3630 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 3630 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
3631 host_impl_->DrawLayers(&frame); | 3631 host_impl_->DrawLayers(&frame); |
3632 host_impl_->DidDrawAllLayers(frame); | 3632 host_impl_->DidDrawAllLayers(frame); |
3633 host_impl_->SwapBuffers(frame); | 3633 host_impl_->SwapBuffers(frame); |
3634 | 3634 |
3635 for (size_t i = 0; i < cases.size(); ++i) { | 3635 for (size_t i = 0; i < cases.size(); ++i) { |
3636 // Clean up host_impl_ state. | 3636 // Clean up host_impl_ state. |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3715 cases.back().layer_between.has_incomplete_tile = true; | 3715 cases.back().layer_between.has_incomplete_tile = true; |
3716 // 3. High res required with missing tile. | 3716 // 3. High res required with missing tile. |
3717 cases.push_back(PrepareToDrawSuccessTestCase(DRAW_SUCCESS)); | 3717 cases.push_back(PrepareToDrawSuccessTestCase(DRAW_SUCCESS)); |
3718 cases.back().high_res_required = true; | 3718 cases.back().high_res_required = true; |
3719 cases.back().layer_between.has_missing_tile = true; | 3719 cases.back().layer_between.has_missing_tile = true; |
3720 | 3720 |
3721 host_impl_->active_tree()->SetRootLayer( | 3721 host_impl_->active_tree()->SetRootLayer( |
3722 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 3722 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
3723 DidDrawCheckLayer* root = | 3723 DidDrawCheckLayer* root = |
3724 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 3724 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
3725 root->SetForceRenderSurface(true); | 3725 root->test_properties()->force_render_surface = true; |
3726 | 3726 |
3727 SetNeedsRebuildPropertyTrees(); | 3727 SetNeedsRebuildPropertyTrees(); |
3728 host_impl_->OnDraw(external_transform, external_viewport, external_clip, | 3728 host_impl_->OnDraw(external_transform, external_viewport, external_clip, |
3729 resourceless_software_draw); | 3729 resourceless_software_draw); |
3730 | 3730 |
3731 for (size_t i = 0; i < cases.size(); ++i) { | 3731 for (size_t i = 0; i < cases.size(); ++i) { |
3732 const auto& testcase = cases[i]; | 3732 const auto& testcase = cases[i]; |
3733 std::vector<LayerImpl*> to_remove; | 3733 std::vector<LayerImpl*> to_remove; |
3734 for (const auto& child : root->children()) | 3734 for (const auto& child : root->children()) |
3735 to_remove.push_back(child); | 3735 to_remove.push_back(child); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3776 SetNeedsRebuildPropertyTrees(); | 3776 SetNeedsRebuildPropertyTrees(); |
3777 host_impl_->OnDraw(external_transform, external_viewport, external_clip, | 3777 host_impl_->OnDraw(external_transform, external_viewport, external_clip, |
3778 resourceless_software_draw); | 3778 resourceless_software_draw); |
3779 } | 3779 } |
3780 } | 3780 } |
3781 | 3781 |
3782 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { | 3782 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { |
3783 std::unique_ptr<LayerImpl> root = | 3783 std::unique_ptr<LayerImpl> root = |
3784 LayerImpl::Create(host_impl_->active_tree(), 1); | 3784 LayerImpl::Create(host_impl_->active_tree(), 1); |
3785 root->SetScrollClipLayer(Layer::INVALID_ID); | 3785 root->SetScrollClipLayer(Layer::INVALID_ID); |
3786 root->SetForceRenderSurface(true); | 3786 root->test_properties()->force_render_surface = true; |
3787 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 3787 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
3788 SetNeedsRebuildPropertyTrees(); | 3788 SetNeedsRebuildPropertyTrees(); |
3789 DrawFrame(); | 3789 DrawFrame(); |
3790 | 3790 |
3791 // Scroll event is ignored because layer is not scrollable. | 3791 // Scroll event is ignored because layer is not scrollable. |
3792 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 3792 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
3793 BeginState(gfx::Point()).get(), InputHandler::WHEEL); | 3793 BeginState(gfx::Point()).get(), InputHandler::WHEEL); |
3794 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); | 3794 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); |
3795 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, | 3795 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, |
3796 status.main_thread_scrolling_reasons); | 3796 status.main_thread_scrolling_reasons); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3874 | 3874 |
3875 std::unique_ptr<LayerImpl> outer_scroll = LayerImpl::Create(tree_impl, 4); | 3875 std::unique_ptr<LayerImpl> outer_scroll = LayerImpl::Create(tree_impl, 4); |
3876 std::unique_ptr<LayerImpl> outer_clip = LayerImpl::Create(tree_impl, 5); | 3876 std::unique_ptr<LayerImpl> outer_clip = LayerImpl::Create(tree_impl, 5); |
3877 | 3877 |
3878 root_clip->SetBounds(inner_viewport_size); | 3878 root_clip->SetBounds(inner_viewport_size); |
3879 root->SetScrollClipLayer(root_clip->id()); | 3879 root->SetScrollClipLayer(root_clip->id()); |
3880 root->SetBounds(outer_viewport_size); | 3880 root->SetBounds(outer_viewport_size); |
3881 root->SetPosition(gfx::PointF()); | 3881 root->SetPosition(gfx::PointF()); |
3882 root->SetDrawsContent(false); | 3882 root->SetDrawsContent(false); |
3883 root->SetIsContainerForFixedPositionLayers(true); | 3883 root->SetIsContainerForFixedPositionLayers(true); |
3884 root_clip->SetForceRenderSurface(true); | 3884 root_clip->test_properties()->force_render_surface = true; |
3885 outer_clip->SetBounds(outer_viewport_size); | 3885 outer_clip->SetBounds(outer_viewport_size); |
3886 outer_scroll->SetScrollClipLayer(outer_clip->id()); | 3886 outer_scroll->SetScrollClipLayer(outer_clip->id()); |
3887 outer_scroll->SetBounds(scroll_layer_size); | 3887 outer_scroll->SetBounds(scroll_layer_size); |
3888 outer_scroll->SetPosition(gfx::PointF()); | 3888 outer_scroll->SetPosition(gfx::PointF()); |
3889 outer_scroll->SetDrawsContent(false); | 3889 outer_scroll->SetDrawsContent(false); |
3890 outer_scroll->SetIsContainerForFixedPositionLayers(true); | 3890 outer_scroll->SetIsContainerForFixedPositionLayers(true); |
3891 | 3891 |
3892 int inner_viewport_scroll_layer_id = root->id(); | 3892 int inner_viewport_scroll_layer_id = root->id(); |
3893 int outer_viewport_scroll_layer_id = outer_scroll->id(); | 3893 int outer_viewport_scroll_layer_id = outer_scroll->id(); |
3894 int page_scale_layer_id = page_scale->id(); | 3894 int page_scale_layer_id = page_scale->id(); |
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4684 scroll_clip_layer->SetBounds(surface_size); | 4684 scroll_clip_layer->SetBounds(surface_size); |
4685 | 4685 |
4686 std::unique_ptr<LayerImpl> scroll_layer = | 4686 std::unique_ptr<LayerImpl> scroll_layer = |
4687 LayerImpl::Create(host_impl_->active_tree(), 2); | 4687 LayerImpl::Create(host_impl_->active_tree(), 2); |
4688 scroll_layer->SetScrollClipLayer(3); | 4688 scroll_layer->SetScrollClipLayer(3); |
4689 scroll_layer->SetBounds(contents_size); | 4689 scroll_layer->SetBounds(contents_size); |
4690 scroll_layer->SetPosition(gfx::PointF()); | 4690 scroll_layer->SetPosition(gfx::PointF()); |
4691 scroll_layer->AddChild(std::move(content_layer)); | 4691 scroll_layer->AddChild(std::move(content_layer)); |
4692 scroll_clip_layer->AddChild(std::move(scroll_layer)); | 4692 scroll_clip_layer->AddChild(std::move(scroll_layer)); |
4693 | 4693 |
4694 scroll_clip_layer->SetForceRenderSurface(true); | 4694 scroll_clip_layer->test_properties()->force_render_surface = true; |
4695 host_impl_->active_tree()->SetRootLayer(std::move(scroll_clip_layer)); | 4695 host_impl_->active_tree()->SetRootLayer(std::move(scroll_clip_layer)); |
4696 host_impl_->SetViewportSize(surface_size); | 4696 host_impl_->SetViewportSize(surface_size); |
4697 SetNeedsRebuildPropertyTrees(); | 4697 SetNeedsRebuildPropertyTrees(); |
4698 DrawFrame(); | 4698 DrawFrame(); |
4699 | 4699 |
4700 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4700 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
4701 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 4701 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
4702 InputHandler::WHEEL) | 4702 InputHandler::WHEEL) |
4703 .thread); | 4703 .thread); |
4704 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); | 4704 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
4705 host_impl_->ScrollEnd(EndState().get()); | 4705 host_impl_->ScrollEnd(EndState().get()); |
4706 EXPECT_TRUE(did_request_redraw_); | 4706 EXPECT_TRUE(did_request_redraw_); |
4707 EXPECT_TRUE(did_request_commit_); | 4707 EXPECT_TRUE(did_request_commit_); |
4708 } | 4708 } |
4709 | 4709 |
4710 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { | 4710 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { |
4711 gfx::Size surface_size(10, 10); | 4711 gfx::Size surface_size(10, 10); |
4712 gfx::Size contents_size(20, 20); | 4712 gfx::Size contents_size(20, 20); |
4713 std::unique_ptr<LayerImpl> root = | 4713 std::unique_ptr<LayerImpl> root = |
4714 LayerImpl::Create(host_impl_->active_tree(), 1); | 4714 LayerImpl::Create(host_impl_->active_tree(), 1); |
4715 root->SetBounds(surface_size); | 4715 root->SetBounds(surface_size); |
4716 root->AddChild(CreateScrollableLayer(2, contents_size, root.get())); | 4716 root->AddChild(CreateScrollableLayer(2, contents_size, root.get())); |
4717 root->SetForceRenderSurface(true); | 4717 root->test_properties()->force_render_surface = true; |
4718 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 4718 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
4719 host_impl_->SetViewportSize(surface_size); | 4719 host_impl_->SetViewportSize(surface_size); |
4720 SetNeedsRebuildPropertyTrees(); | 4720 SetNeedsRebuildPropertyTrees(); |
4721 DrawFrame(); | 4721 DrawFrame(); |
4722 | 4722 |
4723 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4723 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
4724 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 4724 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
4725 InputHandler::WHEEL) | 4725 InputHandler::WHEEL) |
4726 .thread); | 4726 .thread); |
4727 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); | 4727 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
4728 host_impl_->ScrollEnd(EndState().get()); | 4728 host_impl_->ScrollEnd(EndState().get()); |
4729 EXPECT_TRUE(did_request_redraw_); | 4729 EXPECT_TRUE(did_request_redraw_); |
4730 EXPECT_TRUE(did_request_commit_); | 4730 EXPECT_TRUE(did_request_commit_); |
4731 } | 4731 } |
4732 | 4732 |
4733 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { | 4733 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { |
4734 gfx::Size surface_size(10, 10); | 4734 gfx::Size surface_size(10, 10); |
4735 std::unique_ptr<LayerImpl> root = | 4735 std::unique_ptr<LayerImpl> root = |
4736 LayerImpl::Create(host_impl_->active_tree(), 1); | 4736 LayerImpl::Create(host_impl_->active_tree(), 1); |
4737 root->AddChild(CreateScrollableLayer(2, surface_size, root.get())); | 4737 root->AddChild(CreateScrollableLayer(2, surface_size, root.get())); |
4738 root->SetForceRenderSurface(true); | 4738 root->test_properties()->force_render_surface = true; |
4739 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 4739 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
4740 host_impl_->SetViewportSize(surface_size); | 4740 host_impl_->SetViewportSize(surface_size); |
4741 SetNeedsRebuildPropertyTrees(); | 4741 SetNeedsRebuildPropertyTrees(); |
4742 DrawFrame(); | 4742 DrawFrame(); |
4743 | 4743 |
4744 // Scroll event is ignored because the input coordinate is outside the layer | 4744 // Scroll event is ignored because the input coordinate is outside the layer |
4745 // boundaries. | 4745 // boundaries. |
4746 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 4746 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
4747 BeginState(gfx::Point(15, 5)).get(), InputHandler::WHEEL); | 4747 BeginState(gfx::Point(15, 5)).get(), InputHandler::WHEEL); |
4748 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); | 4748 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); |
4749 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, | 4749 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, |
4750 status.main_thread_scrolling_reasons); | 4750 status.main_thread_scrolling_reasons); |
4751 | 4751 |
4752 EXPECT_FALSE(did_request_redraw_); | 4752 EXPECT_FALSE(did_request_redraw_); |
4753 EXPECT_FALSE(did_request_commit_); | 4753 EXPECT_FALSE(did_request_commit_); |
4754 } | 4754 } |
4755 | 4755 |
4756 TEST_F(LayerTreeHostImplTest, ScrollMissesBackfacingChild) { | 4756 TEST_F(LayerTreeHostImplTest, ScrollMissesBackfacingChild) { |
4757 gfx::Size surface_size(10, 10); | 4757 gfx::Size surface_size(10, 10); |
4758 std::unique_ptr<LayerImpl> root = | 4758 std::unique_ptr<LayerImpl> root = |
4759 LayerImpl::Create(host_impl_->active_tree(), 1); | 4759 LayerImpl::Create(host_impl_->active_tree(), 1); |
4760 root->SetForceRenderSurface(true); | 4760 root->test_properties()->force_render_surface = true; |
4761 std::unique_ptr<LayerImpl> child = | 4761 std::unique_ptr<LayerImpl> child = |
4762 CreateScrollableLayer(2, surface_size, root.get()); | 4762 CreateScrollableLayer(2, surface_size, root.get()); |
4763 host_impl_->SetViewportSize(surface_size); | 4763 host_impl_->SetViewportSize(surface_size); |
4764 | 4764 |
4765 gfx::Transform matrix; | 4765 gfx::Transform matrix; |
4766 matrix.RotateAboutXAxis(180.0); | 4766 matrix.RotateAboutXAxis(180.0); |
4767 child->SetTransform(matrix); | 4767 child->SetTransform(matrix); |
4768 child->SetDoubleSided(false); | 4768 child->test_properties()->double_sided = false; |
4769 | 4769 |
4770 root->AddChild(std::move(child)); | 4770 root->AddChild(std::move(child)); |
4771 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 4771 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
4772 SetNeedsRebuildPropertyTrees(); | 4772 SetNeedsRebuildPropertyTrees(); |
4773 DrawFrame(); | 4773 DrawFrame(); |
4774 | 4774 |
4775 // Scroll event is ignored because the scrollable layer is not facing the | 4775 // Scroll event is ignored because the scrollable layer is not facing the |
4776 // viewer and there is nothing scrollable behind it. | 4776 // viewer and there is nothing scrollable behind it. |
4777 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 4777 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
4778 BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL); | 4778 BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL); |
(...skipping 14 matching lines...) Expand all Loading... |
4793 content_layer->set_main_thread_scrolling_reasons( | 4793 content_layer->set_main_thread_scrolling_reasons( |
4794 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | 4794 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); |
4795 content_layer->SetScrollClipLayer(Layer::INVALID_ID); | 4795 content_layer->SetScrollClipLayer(Layer::INVALID_ID); |
4796 | 4796 |
4797 // Note: we can use the same clip layer for both since both calls to | 4797 // Note: we can use the same clip layer for both since both calls to |
4798 // CreateScrollableLayer() use the same surface size. | 4798 // CreateScrollableLayer() use the same surface size. |
4799 std::unique_ptr<LayerImpl> scroll_layer = | 4799 std::unique_ptr<LayerImpl> scroll_layer = |
4800 CreateScrollableLayer(2, surface_size, clip_layer.get()); | 4800 CreateScrollableLayer(2, surface_size, clip_layer.get()); |
4801 scroll_layer->AddChild(std::move(content_layer)); | 4801 scroll_layer->AddChild(std::move(content_layer)); |
4802 clip_layer->AddChild(std::move(scroll_layer)); | 4802 clip_layer->AddChild(std::move(scroll_layer)); |
4803 clip_layer->SetForceRenderSurface(true); | 4803 clip_layer->test_properties()->force_render_surface = true; |
4804 | 4804 |
4805 host_impl_->active_tree()->SetRootLayer(std::move(clip_layer)); | 4805 host_impl_->active_tree()->SetRootLayer(std::move(clip_layer)); |
4806 host_impl_->SetViewportSize(surface_size); | 4806 host_impl_->SetViewportSize(surface_size); |
4807 SetNeedsRebuildPropertyTrees(); | 4807 SetNeedsRebuildPropertyTrees(); |
4808 DrawFrame(); | 4808 DrawFrame(); |
4809 | 4809 |
4810 // Scrolling fails because the content layer is asking to be scrolled on the | 4810 // Scrolling fails because the content layer is asking to be scrolled on the |
4811 // main thread. | 4811 // main thread. |
4812 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 4812 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
4813 BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL); | 4813 BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5012 } | 5012 } |
5013 | 5013 |
5014 TEST_F(LayerTreeHostImplTest, ScrollChildBeyondLimit) { | 5014 TEST_F(LayerTreeHostImplTest, ScrollChildBeyondLimit) { |
5015 // Scroll a child layer beyond its maximum scroll range and make sure the | 5015 // Scroll a child layer beyond its maximum scroll range and make sure the |
5016 // parent layer isn't scrolled. | 5016 // parent layer isn't scrolled. |
5017 gfx::Size surface_size(10, 10); | 5017 gfx::Size surface_size(10, 10); |
5018 gfx::Size content_size(20, 20); | 5018 gfx::Size content_size(20, 20); |
5019 std::unique_ptr<LayerImpl> root = | 5019 std::unique_ptr<LayerImpl> root = |
5020 LayerImpl::Create(host_impl_->active_tree(), 1); | 5020 LayerImpl::Create(host_impl_->active_tree(), 1); |
5021 root->SetBounds(surface_size); | 5021 root->SetBounds(surface_size); |
5022 root->SetForceRenderSurface(true); | 5022 root->test_properties()->force_render_surface = true; |
5023 std::unique_ptr<LayerImpl> grand_child = | 5023 std::unique_ptr<LayerImpl> grand_child = |
5024 CreateScrollableLayer(3, content_size, root.get()); | 5024 CreateScrollableLayer(3, content_size, root.get()); |
5025 | 5025 |
5026 std::unique_ptr<LayerImpl> child = | 5026 std::unique_ptr<LayerImpl> child = |
5027 CreateScrollableLayer(2, content_size, root.get()); | 5027 CreateScrollableLayer(2, content_size, root.get()); |
5028 LayerImpl* grand_child_layer = grand_child.get(); | 5028 LayerImpl* grand_child_layer = grand_child.get(); |
5029 child->AddChild(std::move(grand_child)); | 5029 child->AddChild(std::move(grand_child)); |
5030 | 5030 |
5031 LayerImpl* child_layer = child.get(); | 5031 LayerImpl* child_layer = child.get(); |
5032 root->AddChild(std::move(child)); | 5032 root->AddChild(std::move(child)); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5069 | 5069 |
5070 TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) { | 5070 TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) { |
5071 // Scroll a child layer beyond its maximum scroll range and make sure the | 5071 // Scroll a child layer beyond its maximum scroll range and make sure the |
5072 // the scroll doesn't bubble up to the parent layer. | 5072 // the scroll doesn't bubble up to the parent layer. |
5073 gfx::Size surface_size(20, 20); | 5073 gfx::Size surface_size(20, 20); |
5074 gfx::Size viewport_size(10, 10); | 5074 gfx::Size viewport_size(10, 10); |
5075 std::unique_ptr<LayerImpl> root_ptr = | 5075 std::unique_ptr<LayerImpl> root_ptr = |
5076 LayerImpl::Create(host_impl_->active_tree(), 1); | 5076 LayerImpl::Create(host_impl_->active_tree(), 1); |
5077 std::unique_ptr<LayerImpl> root_clip = | 5077 std::unique_ptr<LayerImpl> root_clip = |
5078 LayerImpl::Create(host_impl_->active_tree(), 2); | 5078 LayerImpl::Create(host_impl_->active_tree(), 2); |
5079 root_clip->SetForceRenderSurface(true); | 5079 root_clip->test_properties()->force_render_surface = true; |
5080 std::unique_ptr<LayerImpl> root_scrolling = | 5080 std::unique_ptr<LayerImpl> root_scrolling = |
5081 CreateScrollableLayer(3, surface_size, root_clip.get()); | 5081 CreateScrollableLayer(3, surface_size, root_clip.get()); |
5082 root_scrolling->SetIsContainerForFixedPositionLayers(true); | 5082 root_scrolling->SetIsContainerForFixedPositionLayers(true); |
5083 | 5083 |
5084 std::unique_ptr<LayerImpl> grand_child = | 5084 std::unique_ptr<LayerImpl> grand_child = |
5085 CreateScrollableLayer(5, surface_size, root_clip.get()); | 5085 CreateScrollableLayer(5, surface_size, root_clip.get()); |
5086 | 5086 |
5087 std::unique_ptr<LayerImpl> child = | 5087 std::unique_ptr<LayerImpl> child = |
5088 CreateScrollableLayer(4, surface_size, root_clip.get()); | 5088 CreateScrollableLayer(4, surface_size, root_clip.get()); |
5089 LayerImpl* grand_child_layer = grand_child.get(); | 5089 LayerImpl* grand_child_layer = grand_child.get(); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5201 } | 5201 } |
5202 TEST_F(LayerTreeHostImplTest, ScrollEventBubbling) { | 5202 TEST_F(LayerTreeHostImplTest, ScrollEventBubbling) { |
5203 // When we try to scroll a non-scrollable child layer, the scroll delta | 5203 // When we try to scroll a non-scrollable child layer, the scroll delta |
5204 // should be applied to one of its ancestors if possible. | 5204 // should be applied to one of its ancestors if possible. |
5205 gfx::Size surface_size(10, 10); | 5205 gfx::Size surface_size(10, 10); |
5206 gfx::Size content_size(20, 20); | 5206 gfx::Size content_size(20, 20); |
5207 std::unique_ptr<LayerImpl> root_ptr = | 5207 std::unique_ptr<LayerImpl> root_ptr = |
5208 LayerImpl::Create(host_impl_->active_tree(), 4); | 5208 LayerImpl::Create(host_impl_->active_tree(), 4); |
5209 std::unique_ptr<LayerImpl> root_clip = | 5209 std::unique_ptr<LayerImpl> root_clip = |
5210 LayerImpl::Create(host_impl_->active_tree(), 3); | 5210 LayerImpl::Create(host_impl_->active_tree(), 3); |
5211 root_clip->SetForceRenderSurface(true); | 5211 root_clip->test_properties()->force_render_surface = true; |
5212 std::unique_ptr<LayerImpl> root_scroll = | 5212 std::unique_ptr<LayerImpl> root_scroll = |
5213 CreateScrollableLayer(1, content_size, root_clip.get()); | 5213 CreateScrollableLayer(1, content_size, root_clip.get()); |
5214 // Make 'root' the clip layer for child: since they have the same sizes the | 5214 // Make 'root' the clip layer for child: since they have the same sizes the |
5215 // child will have zero max_scroll_offset and scrolls will bubble. | 5215 // child will have zero max_scroll_offset and scrolls will bubble. |
5216 std::unique_ptr<LayerImpl> child = | 5216 std::unique_ptr<LayerImpl> child = |
5217 CreateScrollableLayer(2, content_size, root_scroll.get()); | 5217 CreateScrollableLayer(2, content_size, root_scroll.get()); |
5218 child->SetIsContainerForFixedPositionLayers(true); | 5218 child->SetIsContainerForFixedPositionLayers(true); |
5219 root_scroll->SetBounds(content_size); | 5219 root_scroll->SetBounds(content_size); |
5220 | 5220 |
5221 int root_scroll_id = root_scroll->id(); | 5221 int root_scroll_id = root_scroll->id(); |
(...skipping 29 matching lines...) Expand all Loading... |
5251 | 5251 |
5252 TEST_F(LayerTreeHostImplTest, ScrollBeforeRedraw) { | 5252 TEST_F(LayerTreeHostImplTest, ScrollBeforeRedraw) { |
5253 gfx::Size surface_size(10, 10); | 5253 gfx::Size surface_size(10, 10); |
5254 std::unique_ptr<LayerImpl> root_ptr = | 5254 std::unique_ptr<LayerImpl> root_ptr = |
5255 LayerImpl::Create(host_impl_->active_tree(), 1); | 5255 LayerImpl::Create(host_impl_->active_tree(), 1); |
5256 std::unique_ptr<LayerImpl> root_clip = | 5256 std::unique_ptr<LayerImpl> root_clip = |
5257 LayerImpl::Create(host_impl_->active_tree(), 2); | 5257 LayerImpl::Create(host_impl_->active_tree(), 2); |
5258 std::unique_ptr<LayerImpl> root_scroll = | 5258 std::unique_ptr<LayerImpl> root_scroll = |
5259 CreateScrollableLayer(3, surface_size, root_clip.get()); | 5259 CreateScrollableLayer(3, surface_size, root_clip.get()); |
5260 root_scroll->SetIsContainerForFixedPositionLayers(true); | 5260 root_scroll->SetIsContainerForFixedPositionLayers(true); |
5261 root_clip->SetForceRenderSurface(true); | 5261 root_clip->test_properties()->force_render_surface = true; |
5262 root_clip->AddChild(std::move(root_scroll)); | 5262 root_clip->AddChild(std::move(root_scroll)); |
5263 root_ptr->AddChild(std::move(root_clip)); | 5263 root_ptr->AddChild(std::move(root_clip)); |
5264 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr)); | 5264 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr)); |
5265 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, | 5265 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, |
5266 Layer::INVALID_ID); | 5266 Layer::INVALID_ID); |
5267 host_impl_->active_tree()->DidBecomeActive(); | 5267 host_impl_->active_tree()->DidBecomeActive(); |
5268 host_impl_->SetViewportSize(surface_size); | 5268 host_impl_->SetViewportSize(surface_size); |
5269 | 5269 |
5270 // Draw one frame and then immediately rebuild the layer tree to mimic a tree | 5270 // Draw one frame and then immediately rebuild the layer tree to mimic a tree |
5271 // synchronization. | 5271 // synchronization. |
5272 SetNeedsRebuildPropertyTrees(); | 5272 SetNeedsRebuildPropertyTrees(); |
5273 DrawFrame(); | 5273 DrawFrame(); |
5274 host_impl_->active_tree()->ClearLayers(); | 5274 host_impl_->active_tree()->ClearLayers(); |
5275 std::unique_ptr<LayerImpl> root_ptr2 = | 5275 std::unique_ptr<LayerImpl> root_ptr2 = |
5276 LayerImpl::Create(host_impl_->active_tree(), 4); | 5276 LayerImpl::Create(host_impl_->active_tree(), 4); |
5277 std::unique_ptr<LayerImpl> root_clip2 = | 5277 std::unique_ptr<LayerImpl> root_clip2 = |
5278 LayerImpl::Create(host_impl_->active_tree(), 5); | 5278 LayerImpl::Create(host_impl_->active_tree(), 5); |
5279 std::unique_ptr<LayerImpl> root_scroll2 = | 5279 std::unique_ptr<LayerImpl> root_scroll2 = |
5280 CreateScrollableLayer(6, surface_size, root_clip2.get()); | 5280 CreateScrollableLayer(6, surface_size, root_clip2.get()); |
5281 root_scroll2->SetIsContainerForFixedPositionLayers(true); | 5281 root_scroll2->SetIsContainerForFixedPositionLayers(true); |
5282 root_clip2->AddChild(std::move(root_scroll2)); | 5282 root_clip2->AddChild(std::move(root_scroll2)); |
5283 root_clip2->SetForceRenderSurface(true); | 5283 root_clip2->test_properties()->force_render_surface = true; |
5284 root_ptr2->AddChild(std::move(root_clip2)); | 5284 root_ptr2->AddChild(std::move(root_clip2)); |
5285 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr2)); | 5285 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr2)); |
5286 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 6, | 5286 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 6, |
5287 Layer::INVALID_ID); | 5287 Layer::INVALID_ID); |
5288 host_impl_->active_tree()->DidBecomeActive(); | 5288 host_impl_->active_tree()->DidBecomeActive(); |
5289 | 5289 |
5290 // Scrolling should still work even though we did not draw yet. | 5290 // Scrolling should still work even though we did not draw yet. |
5291 SetNeedsRebuildPropertyTrees(); | 5291 SetNeedsRebuildPropertyTrees(); |
5292 RebuildPropertyTrees(); | 5292 RebuildPropertyTrees(); |
5293 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5293 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5900 } | 5900 } |
5901 | 5901 |
5902 | 5902 |
5903 TEST_F(LayerTreeHostImplTest, OverscrollChildWithoutBubbling) { | 5903 TEST_F(LayerTreeHostImplTest, OverscrollChildWithoutBubbling) { |
5904 // Scroll child layers beyond their maximum scroll range and make sure root | 5904 // Scroll child layers beyond their maximum scroll range and make sure root |
5905 // overscroll does not accumulate. | 5905 // overscroll does not accumulate. |
5906 InputHandlerScrollResult scroll_result; | 5906 InputHandlerScrollResult scroll_result; |
5907 gfx::Size surface_size(10, 10); | 5907 gfx::Size surface_size(10, 10); |
5908 std::unique_ptr<LayerImpl> root_clip = | 5908 std::unique_ptr<LayerImpl> root_clip = |
5909 LayerImpl::Create(host_impl_->active_tree(), 4); | 5909 LayerImpl::Create(host_impl_->active_tree(), 4); |
5910 root_clip->SetForceRenderSurface(true); | 5910 root_clip->test_properties()->force_render_surface = true; |
5911 | 5911 |
5912 std::unique_ptr<LayerImpl> root = | 5912 std::unique_ptr<LayerImpl> root = |
5913 CreateScrollableLayer(1, surface_size, root_clip.get()); | 5913 CreateScrollableLayer(1, surface_size, root_clip.get()); |
5914 | 5914 |
5915 std::unique_ptr<LayerImpl> grand_child = | 5915 std::unique_ptr<LayerImpl> grand_child = |
5916 CreateScrollableLayer(3, surface_size, root_clip.get()); | 5916 CreateScrollableLayer(3, surface_size, root_clip.get()); |
5917 | 5917 |
5918 std::unique_ptr<LayerImpl> child = | 5918 std::unique_ptr<LayerImpl> child = |
5919 CreateScrollableLayer(2, surface_size, root_clip.get()); | 5919 CreateScrollableLayer(2, surface_size, root_clip.get()); |
5920 LayerImpl* grand_child_layer = grand_child.get(); | 5920 LayerImpl* grand_child_layer = grand_child.get(); |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6189 gfx::Rect quad_visible_rect_; | 6189 gfx::Rect quad_visible_rect_; |
6190 ResourceId resource_id_; | 6190 ResourceId resource_id_; |
6191 }; | 6191 }; |
6192 | 6192 |
6193 TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { | 6193 TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { |
6194 { | 6194 { |
6195 std::unique_ptr<LayerImpl> root = | 6195 std::unique_ptr<LayerImpl> root = |
6196 LayerImpl::Create(host_impl_->active_tree(), 1); | 6196 LayerImpl::Create(host_impl_->active_tree(), 1); |
6197 root->SetBounds(gfx::Size(10, 10)); | 6197 root->SetBounds(gfx::Size(10, 10)); |
6198 root->SetDrawsContent(false); | 6198 root->SetDrawsContent(false); |
6199 root->SetForceRenderSurface(true); | 6199 root->test_properties()->force_render_surface = true; |
6200 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 6200 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
6201 } | 6201 } |
6202 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 6202 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
6203 | 6203 |
6204 root->AddChild( | 6204 root->AddChild( |
6205 BlendStateCheckLayer::Create(host_impl_->active_tree(), | 6205 BlendStateCheckLayer::Create(host_impl_->active_tree(), |
6206 2, | 6206 2, |
6207 host_impl_->resource_provider())); | 6207 host_impl_->resource_provider())); |
6208 BlendStateCheckLayer* layer1 = | 6208 BlendStateCheckLayer* layer1 = |
6209 static_cast<BlendStateCheckLayer*>(root->children()[0]); | 6209 static_cast<BlendStateCheckLayer*>(root->children()[0]); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6311 host_impl_->DidDrawAllLayers(frame); | 6311 host_impl_->DidDrawAllLayers(frame); |
6312 | 6312 |
6313 // Parent layer with translucent opacity and opaque content. Since it has a | 6313 // Parent layer with translucent opacity and opaque content. Since it has a |
6314 // drawing child, it's drawn to a render surface which carries the opacity, | 6314 // drawing child, it's drawn to a render surface which carries the opacity, |
6315 // so it's itself drawn without blending. | 6315 // so it's itself drawn without blending. |
6316 // Child layer with opaque content, drawn without blending (parent surface | 6316 // Child layer with opaque content, drawn without blending (parent surface |
6317 // carries the inherited opacity). | 6317 // carries the inherited opacity). |
6318 layer1->SetContentsOpaque(true); | 6318 layer1->SetContentsOpaque(true); |
6319 layer1->SetOpacity(0.5f); | 6319 layer1->SetOpacity(0.5f); |
6320 layer1->NoteLayerPropertyChanged(); | 6320 layer1->NoteLayerPropertyChanged(); |
6321 layer1->SetForceRenderSurface(true); | 6321 layer1->test_properties()->force_render_surface = true; |
6322 layer1->SetExpectation(false, true); | 6322 layer1->SetExpectation(false, true); |
6323 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6323 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6324 layer2->SetExpectation(false, false); | 6324 layer2->SetExpectation(false, false); |
6325 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6325 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6326 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( | 6326 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( |
6327 host_impl_->active_tree()->root_layer()); | 6327 host_impl_->active_tree()->root_layer()); |
6328 SetNeedsRebuildPropertyTrees(); | 6328 SetNeedsRebuildPropertyTrees(); |
6329 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6329 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
6330 host_impl_->DrawLayers(&frame); | 6330 host_impl_->DrawLayers(&frame); |
6331 EXPECT_TRUE(layer1->quads_appended()); | 6331 EXPECT_TRUE(layer1->quads_appended()); |
6332 EXPECT_TRUE(layer2->quads_appended()); | 6332 EXPECT_TRUE(layer2->quads_appended()); |
6333 host_impl_->DidDrawAllLayers(frame); | 6333 host_impl_->DidDrawAllLayers(frame); |
6334 layer1->SetForceRenderSurface(false); | 6334 layer1->test_properties()->force_render_surface = false; |
6335 | 6335 |
6336 // Draw again, but with child non-opaque, to make sure | 6336 // Draw again, but with child non-opaque, to make sure |
6337 // layer1 not culled. | 6337 // layer1 not culled. |
6338 layer1->SetContentsOpaque(true); | 6338 layer1->SetContentsOpaque(true); |
6339 layer1->SetOpacity(1.f); | 6339 layer1->SetOpacity(1.f); |
6340 layer1->NoteLayerPropertyChanged(); | 6340 layer1->NoteLayerPropertyChanged(); |
6341 layer1->SetExpectation(false, false); | 6341 layer1->SetExpectation(false, false); |
6342 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6342 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6343 layer2->SetContentsOpaque(true); | 6343 layer2->SetContentsOpaque(true); |
6344 layer2->SetOpacity(0.5f); | 6344 layer2->SetOpacity(0.5f); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6455 return FakeOutputSurface::CreateSoftware( | 6455 return FakeOutputSurface::CreateSoftware( |
6456 base::WrapUnique(new SoftwareOutputDevice())); | 6456 base::WrapUnique(new SoftwareOutputDevice())); |
6457 } | 6457 } |
6458 return FakeOutputSurface::Create3d(); | 6458 return FakeOutputSurface::Create3d(); |
6459 } | 6459 } |
6460 | 6460 |
6461 void SetupActiveTreeLayers() { | 6461 void SetupActiveTreeLayers() { |
6462 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); | 6462 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); |
6463 host_impl_->active_tree()->SetRootLayer( | 6463 host_impl_->active_tree()->SetRootLayer( |
6464 LayerImpl::Create(host_impl_->active_tree(), 1)); | 6464 LayerImpl::Create(host_impl_->active_tree(), 1)); |
6465 host_impl_->active_tree()->root_layer()->SetForceRenderSurface(true); | 6465 host_impl_->active_tree() |
| 6466 ->root_layer() |
| 6467 ->test_properties() |
| 6468 ->force_render_surface = true; |
6466 host_impl_->active_tree()->root_layer()->AddChild( | 6469 host_impl_->active_tree()->root_layer()->AddChild( |
6467 BlendStateCheckLayer::Create(host_impl_->active_tree(), | 6470 BlendStateCheckLayer::Create(host_impl_->active_tree(), |
6468 2, | 6471 2, |
6469 host_impl_->resource_provider())); | 6472 host_impl_->resource_provider())); |
6470 child_ = static_cast<BlendStateCheckLayer*>( | 6473 child_ = static_cast<BlendStateCheckLayer*>( |
6471 host_impl_->active_tree()->root_layer()->children()[0]); | 6474 host_impl_->active_tree()->root_layer()->children()[0]); |
6472 child_->SetExpectation(false, false); | 6475 child_->SetExpectation(false, false); |
6473 child_->SetContentsOpaque(true); | 6476 child_->SetContentsOpaque(true); |
6474 } | 6477 } |
6475 | 6478 |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6758 TEST_F(LayerTreeHostImplTest, ReshapeNotCalledUntilDraw) { | 6761 TEST_F(LayerTreeHostImplTest, ReshapeNotCalledUntilDraw) { |
6759 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); | 6762 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); |
6760 std::unique_ptr<OutputSurface> output_surface( | 6763 std::unique_ptr<OutputSurface> output_surface( |
6761 FakeOutputSurface::Create3d(provider)); | 6764 FakeOutputSurface::Create3d(provider)); |
6762 CreateHostImpl(DefaultSettings(), std::move(output_surface)); | 6765 CreateHostImpl(DefaultSettings(), std::move(output_surface)); |
6763 | 6766 |
6764 std::unique_ptr<LayerImpl> root = | 6767 std::unique_ptr<LayerImpl> root = |
6765 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); | 6768 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); |
6766 root->SetBounds(gfx::Size(10, 10)); | 6769 root->SetBounds(gfx::Size(10, 10)); |
6767 root->SetDrawsContent(true); | 6770 root->SetDrawsContent(true); |
6768 root->SetForceRenderSurface(true); | 6771 root->test_properties()->force_render_surface = true; |
6769 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 6772 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
6770 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); | 6773 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); |
6771 provider->TestContext3d()->clear_reshape_called(); | 6774 provider->TestContext3d()->clear_reshape_called(); |
6772 | 6775 |
6773 LayerTreeHostImpl::FrameData frame; | 6776 LayerTreeHostImpl::FrameData frame; |
6774 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 6777 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
6775 host_impl_->active_tree()->SetDeviceScaleFactor(1.f); | 6778 host_impl_->active_tree()->SetDeviceScaleFactor(1.f); |
6776 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6779 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
6777 host_impl_->DrawLayers(&frame); | 6780 host_impl_->DrawLayers(&frame); |
6778 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); | 6781 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6824 settings, this, &task_runner_provider_, &stats_instrumentation_, | 6827 settings, this, &task_runner_provider_, &stats_instrumentation_, |
6825 &shared_bitmap_manager_, NULL, &task_graph_runner_, 0); | 6828 &shared_bitmap_manager_, NULL, &task_graph_runner_, 0); |
6826 layer_tree_host_impl->SetVisible(true); | 6829 layer_tree_host_impl->SetVisible(true); |
6827 layer_tree_host_impl->InitializeRenderer(output_surface.get()); | 6830 layer_tree_host_impl->InitializeRenderer(output_surface.get()); |
6828 layer_tree_host_impl->WillBeginImplFrame( | 6831 layer_tree_host_impl->WillBeginImplFrame( |
6829 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE)); | 6832 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE)); |
6830 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); | 6833 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); |
6831 | 6834 |
6832 std::unique_ptr<LayerImpl> root = | 6835 std::unique_ptr<LayerImpl> root = |
6833 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); | 6836 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); |
6834 root->SetForceRenderSurface(true); | 6837 root->test_properties()->force_render_surface = true; |
6835 std::unique_ptr<LayerImpl> child = | 6838 std::unique_ptr<LayerImpl> child = |
6836 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); | 6839 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); |
6837 child->SetPosition(gfx::PointF(12.f, 13.f)); | 6840 child->SetPosition(gfx::PointF(12.f, 13.f)); |
6838 child->SetBounds(gfx::Size(14, 15)); | 6841 child->SetBounds(gfx::Size(14, 15)); |
6839 child->SetDrawsContent(true); | 6842 child->SetDrawsContent(true); |
6840 root->SetBounds(gfx::Size(500, 500)); | 6843 root->SetBounds(gfx::Size(500, 500)); |
6841 root->SetDrawsContent(true); | 6844 root->SetDrawsContent(true); |
6842 root->AddChild(std::move(child)); | 6845 root->AddChild(std::move(child)); |
6843 layer_tree_host_impl->active_tree()->SetRootLayer(std::move(root)); | 6846 layer_tree_host_impl->active_tree()->SetRootLayer(std::move(root)); |
6844 | 6847 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6894 | 6897 |
6895 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) { | 6898 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) { |
6896 std::unique_ptr<LayerImpl> root = | 6899 std::unique_ptr<LayerImpl> root = |
6897 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); | 6900 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); |
6898 std::unique_ptr<LayerImpl> child = | 6901 std::unique_ptr<LayerImpl> child = |
6899 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); | 6902 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); |
6900 child->SetBounds(gfx::Size(10, 10)); | 6903 child->SetBounds(gfx::Size(10, 10)); |
6901 child->SetDrawsContent(true); | 6904 child->SetDrawsContent(true); |
6902 root->SetBounds(gfx::Size(10, 10)); | 6905 root->SetBounds(gfx::Size(10, 10)); |
6903 root->SetDrawsContent(true); | 6906 root->SetDrawsContent(true); |
6904 root->SetForceRenderSurface(true); | 6907 root->test_properties()->force_render_surface = true; |
6905 root->AddChild(std::move(child)); | 6908 root->AddChild(std::move(child)); |
6906 | 6909 |
6907 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 6910 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
6908 | 6911 |
6909 LayerTreeHostImpl::FrameData frame; | 6912 LayerTreeHostImpl::FrameData frame; |
6910 | 6913 |
6911 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6914 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
6912 EXPECT_EQ(1u, frame.render_surface_layer_list->size()); | 6915 EXPECT_EQ(1u, frame.render_surface_layer_list->size()); |
6913 EXPECT_EQ(1u, frame.render_passes.size()); | 6916 EXPECT_EQ(1u, frame.render_passes.size()); |
6914 host_impl_->DidDrawAllLayers(frame); | 6917 host_impl_->DidDrawAllLayers(frame); |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7146 LayerImpl::Create(my_host_impl->active_tree(), 1); | 7149 LayerImpl::Create(my_host_impl->active_tree(), 1); |
7147 std::unique_ptr<LayerImpl> child = | 7150 std::unique_ptr<LayerImpl> child = |
7148 LayerImpl::Create(my_host_impl->active_tree(), 2); | 7151 LayerImpl::Create(my_host_impl->active_tree(), 2); |
7149 std::unique_ptr<LayerImpl> grand_child = | 7152 std::unique_ptr<LayerImpl> grand_child = |
7150 FakeLayerWithQuads::Create(my_host_impl->active_tree(), 3); | 7153 FakeLayerWithQuads::Create(my_host_impl->active_tree(), 3); |
7151 | 7154 |
7152 gfx::Rect root_rect(0, 0, 100, 100); | 7155 gfx::Rect root_rect(0, 0, 100, 100); |
7153 gfx::Rect child_rect(10, 10, 50, 50); | 7156 gfx::Rect child_rect(10, 10, 50, 50); |
7154 gfx::Rect grand_child_rect(5, 5, 150, 150); | 7157 gfx::Rect grand_child_rect(5, 5, 150, 150); |
7155 | 7158 |
7156 root->SetForceRenderSurface(true); | 7159 root->test_properties()->force_render_surface = true; |
7157 root->SetPosition(gfx::PointF(root_rect.origin())); | 7160 root->SetPosition(gfx::PointF(root_rect.origin())); |
7158 root->SetBounds(root_rect.size()); | 7161 root->SetBounds(root_rect.size()); |
7159 root->draw_properties().visible_layer_rect = root_rect; | 7162 root->draw_properties().visible_layer_rect = root_rect; |
7160 root->SetDrawsContent(false); | 7163 root->SetDrawsContent(false); |
7161 | 7164 |
7162 child->SetPosition(gfx::PointF(child_rect.x(), child_rect.y())); | 7165 child->SetPosition(gfx::PointF(child_rect.x(), child_rect.y())); |
7163 child->SetOpacity(0.5f); | 7166 child->SetOpacity(0.5f); |
7164 child->SetBounds(gfx::Size(child_rect.width(), child_rect.height())); | 7167 child->SetBounds(gfx::Size(child_rect.width(), child_rect.height())); |
7165 child->draw_properties().visible_layer_rect = child_rect; | 7168 child->draw_properties().visible_layer_rect = child_rect; |
7166 child->SetDrawsContent(false); | 7169 child->SetDrawsContent(false); |
7167 child->SetForceRenderSurface(true); | 7170 child->test_properties()->force_render_surface = true; |
7168 | 7171 |
7169 grand_child->SetPosition(gfx::PointF(grand_child_rect.origin())); | 7172 grand_child->SetPosition(gfx::PointF(grand_child_rect.origin())); |
7170 grand_child->SetBounds(grand_child_rect.size()); | 7173 grand_child->SetBounds(grand_child_rect.size()); |
7171 grand_child->draw_properties().visible_layer_rect = grand_child_rect; | 7174 grand_child->draw_properties().visible_layer_rect = grand_child_rect; |
7172 grand_child->SetDrawsContent(true); | 7175 grand_child->SetDrawsContent(true); |
7173 | 7176 |
7174 child->AddChild(std::move(grand_child)); | 7177 child->AddChild(std::move(grand_child)); |
7175 root->AddChild(std::move(child)); | 7178 root->AddChild(std::move(child)); |
7176 | 7179 |
7177 my_host_impl->active_tree()->SetRootLayer(std::move(root)); | 7180 my_host_impl->active_tree()->SetRootLayer(std::move(root)); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7243 std::unique_ptr<TestWebGraphicsContext3D> context = | 7246 std::unique_ptr<TestWebGraphicsContext3D> context = |
7244 TestWebGraphicsContext3D::Create(); | 7247 TestWebGraphicsContext3D::Create(); |
7245 TestWebGraphicsContext3D* context3d = context.get(); | 7248 TestWebGraphicsContext3D* context3d = context.get(); |
7246 std::unique_ptr<OutputSurface> output_surface( | 7249 std::unique_ptr<OutputSurface> output_surface( |
7247 FakeOutputSurface::Create3d(std::move(context))); | 7250 FakeOutputSurface::Create3d(std::move(context))); |
7248 CreateHostImpl(DefaultSettings(), std::move(output_surface)); | 7251 CreateHostImpl(DefaultSettings(), std::move(output_surface)); |
7249 | 7252 |
7250 std::unique_ptr<LayerImpl> root_layer = | 7253 std::unique_ptr<LayerImpl> root_layer = |
7251 LayerImpl::Create(host_impl_->active_tree(), 1); | 7254 LayerImpl::Create(host_impl_->active_tree(), 1); |
7252 root_layer->SetBounds(gfx::Size(10, 10)); | 7255 root_layer->SetBounds(gfx::Size(10, 10)); |
7253 root_layer->SetForceRenderSurface(true); | 7256 root_layer->test_properties()->force_render_surface = true; |
7254 | 7257 |
7255 scoped_refptr<VideoFrame> softwareFrame = | 7258 scoped_refptr<VideoFrame> softwareFrame = |
7256 media::VideoFrame::CreateColorFrame( | 7259 media::VideoFrame::CreateColorFrame( |
7257 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); | 7260 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); |
7258 FakeVideoFrameProvider provider; | 7261 FakeVideoFrameProvider provider; |
7259 provider.set_frame(softwareFrame); | 7262 provider.set_frame(softwareFrame); |
7260 std::unique_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( | 7263 std::unique_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( |
7261 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0); | 7264 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0); |
7262 video_layer->SetBounds(gfx::Size(10, 10)); | 7265 video_layer->SetBounds(gfx::Size(10, 10)); |
7263 video_layer->SetDrawsContent(true); | 7266 video_layer->SetDrawsContent(true); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7368 EXPECT_EQ(expect_to_draw, host_impl_->SwapBuffers(frame)); | 7371 EXPECT_EQ(expect_to_draw, host_impl_->SwapBuffers(frame)); |
7369 } | 7372 } |
7370 }; | 7373 }; |
7371 | 7374 |
7372 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) { | 7375 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) { |
7373 std::unique_ptr<SolidColorLayerImpl> root = | 7376 std::unique_ptr<SolidColorLayerImpl> root = |
7374 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 7377 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
7375 root->SetPosition(gfx::PointF()); | 7378 root->SetPosition(gfx::PointF()); |
7376 root->SetBounds(gfx::Size(10, 10)); | 7379 root->SetBounds(gfx::Size(10, 10)); |
7377 root->SetDrawsContent(true); | 7380 root->SetDrawsContent(true); |
7378 root->SetForceRenderSurface(true); | 7381 root->test_properties()->force_render_surface = true; |
7379 | 7382 |
7380 // Child layer is in the bottom right corner. | 7383 // Child layer is in the bottom right corner. |
7381 std::unique_ptr<SolidColorLayerImpl> child = | 7384 std::unique_ptr<SolidColorLayerImpl> child = |
7382 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2); | 7385 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2); |
7383 child->SetPosition(gfx::PointF(9.f, 9.f)); | 7386 child->SetPosition(gfx::PointF(9.f, 9.f)); |
7384 child->SetBounds(gfx::Size(1, 1)); | 7387 child->SetBounds(gfx::Size(1, 1)); |
7385 child->SetDrawsContent(true); | 7388 child->SetDrawsContent(true); |
7386 root->AddChild(std::move(child)); | 7389 root->AddChild(std::move(child)); |
7387 | 7390 |
7388 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 7391 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7425 host_impl_->SetViewportSize(device_viewport_size); | 7428 host_impl_->SetViewportSize(device_viewport_size); |
7426 | 7429 |
7427 host_impl_->CreatePendingTree(); | 7430 host_impl_->CreatePendingTree(); |
7428 host_impl_->pending_tree()->SetDeviceScaleFactor(device_scale_factor); | 7431 host_impl_->pending_tree()->SetDeviceScaleFactor(device_scale_factor); |
7429 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f / 16.f, | 7432 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f / 16.f, |
7430 16.f); | 7433 16.f); |
7431 | 7434 |
7432 std::unique_ptr<LayerImpl> scoped_root = | 7435 std::unique_ptr<LayerImpl> scoped_root = |
7433 LayerImpl::Create(host_impl_->pending_tree(), 1); | 7436 LayerImpl::Create(host_impl_->pending_tree(), 1); |
7434 LayerImpl* root = scoped_root.get(); | 7437 LayerImpl* root = scoped_root.get(); |
7435 root->SetForceRenderSurface(true); | 7438 root->test_properties()->force_render_surface = true; |
7436 | 7439 |
7437 host_impl_->pending_tree()->SetRootLayer(std::move(scoped_root)); | 7440 host_impl_->pending_tree()->SetRootLayer(std::move(scoped_root)); |
7438 | 7441 |
7439 std::unique_ptr<LayerImpl> scoped_scrolling_layer = | 7442 std::unique_ptr<LayerImpl> scoped_scrolling_layer = |
7440 LayerImpl::Create(host_impl_->pending_tree(), 2); | 7443 LayerImpl::Create(host_impl_->pending_tree(), 2); |
7441 LayerImpl* scrolling_layer = scoped_scrolling_layer.get(); | 7444 LayerImpl* scrolling_layer = scoped_scrolling_layer.get(); |
7442 root->AddChild(std::move(scoped_scrolling_layer)); | 7445 root->AddChild(std::move(scoped_scrolling_layer)); |
7443 | 7446 |
7444 gfx::Size content_layer_bounds(100000, 100); | 7447 gfx::Size content_layer_bounds(100000, 100); |
7445 scoped_refptr<FakeRasterSource> raster_source( | 7448 scoped_refptr<FakeRasterSource> raster_source( |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7800 | 7803 |
7801 TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) { | 7804 TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) { |
7802 // When flinging via touch, only the child should scroll (we should not | 7805 // When flinging via touch, only the child should scroll (we should not |
7803 // bubble). | 7806 // bubble). |
7804 gfx::Size surface_size(10, 10); | 7807 gfx::Size surface_size(10, 10); |
7805 gfx::Size content_size(20, 20); | 7808 gfx::Size content_size(20, 20); |
7806 std::unique_ptr<LayerImpl> root_ptr = | 7809 std::unique_ptr<LayerImpl> root_ptr = |
7807 LayerImpl::Create(host_impl_->active_tree(), 4); | 7810 LayerImpl::Create(host_impl_->active_tree(), 4); |
7808 std::unique_ptr<LayerImpl> root_clip = | 7811 std::unique_ptr<LayerImpl> root_clip = |
7809 LayerImpl::Create(host_impl_->active_tree(), 3); | 7812 LayerImpl::Create(host_impl_->active_tree(), 3); |
7810 root_clip->SetForceRenderSurface(true); | 7813 root_clip->test_properties()->force_render_surface = true; |
7811 | 7814 |
7812 std::unique_ptr<LayerImpl> root_scroll = | 7815 std::unique_ptr<LayerImpl> root_scroll = |
7813 CreateScrollableLayer(1, content_size, root_clip.get()); | 7816 CreateScrollableLayer(1, content_size, root_clip.get()); |
7814 root_scroll->SetIsContainerForFixedPositionLayers(true); | 7817 root_scroll->SetIsContainerForFixedPositionLayers(true); |
7815 std::unique_ptr<LayerImpl> child = | 7818 std::unique_ptr<LayerImpl> child = |
7816 CreateScrollableLayer(2, content_size, root_clip.get()); | 7819 CreateScrollableLayer(2, content_size, root_clip.get()); |
7817 | 7820 |
7818 root_scroll->AddChild(std::move(child)); | 7821 root_scroll->AddChild(std::move(child)); |
7819 int root_id = root_scroll->id(); | 7822 int root_id = root_scroll->id(); |
7820 root_clip->AddChild(std::move(root_scroll)); | 7823 root_clip->AddChild(std::move(root_scroll)); |
(...skipping 30 matching lines...) Expand all Loading... |
7851 ExpectNone(*scroll_info.get(), root_id); | 7854 ExpectNone(*scroll_info.get(), root_id); |
7852 } | 7855 } |
7853 } | 7856 } |
7854 | 7857 |
7855 TEST_F(LayerTreeHostImplTest, TouchFlingShouldContinueScrollingCurrentLayer) { | 7858 TEST_F(LayerTreeHostImplTest, TouchFlingShouldContinueScrollingCurrentLayer) { |
7856 // Scroll a child layer beyond its maximum scroll range and make sure the | 7859 // Scroll a child layer beyond its maximum scroll range and make sure the |
7857 // the scroll doesn't bubble up to the parent layer. | 7860 // the scroll doesn't bubble up to the parent layer. |
7858 gfx::Size surface_size(10, 10); | 7861 gfx::Size surface_size(10, 10); |
7859 std::unique_ptr<LayerImpl> root = | 7862 std::unique_ptr<LayerImpl> root = |
7860 LayerImpl::Create(host_impl_->active_tree(), 1); | 7863 LayerImpl::Create(host_impl_->active_tree(), 1); |
7861 root->SetForceRenderSurface(true); | 7864 root->test_properties()->force_render_surface = true; |
7862 std::unique_ptr<LayerImpl> root_scrolling = | 7865 std::unique_ptr<LayerImpl> root_scrolling = |
7863 CreateScrollableLayer(2, surface_size, root.get()); | 7866 CreateScrollableLayer(2, surface_size, root.get()); |
7864 | 7867 |
7865 std::unique_ptr<LayerImpl> grand_child = | 7868 std::unique_ptr<LayerImpl> grand_child = |
7866 CreateScrollableLayer(4, surface_size, root.get()); | 7869 CreateScrollableLayer(4, surface_size, root.get()); |
7867 grand_child->layer_tree_impl() | 7870 grand_child->layer_tree_impl() |
7868 ->property_trees() | 7871 ->property_trees() |
7869 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child->id(), | 7872 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child->id(), |
7870 gfx::ScrollOffset(0, 2)); | 7873 gfx::ScrollOffset(0, 2)); |
7871 | 7874 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7940 host_impl_->ScrollEnd(EndState().get()); | 7943 host_impl_->ScrollEnd(EndState().get()); |
7941 } | 7944 } |
7942 } | 7945 } |
7943 | 7946 |
7944 TEST_F(LayerTreeHostImplTest, WheelFlingShouldntBubble) { | 7947 TEST_F(LayerTreeHostImplTest, WheelFlingShouldntBubble) { |
7945 // When flinging via wheel, we shouldn't bubble. | 7948 // When flinging via wheel, we shouldn't bubble. |
7946 gfx::Size surface_size(10, 10); | 7949 gfx::Size surface_size(10, 10); |
7947 gfx::Size content_size(20, 20); | 7950 gfx::Size content_size(20, 20); |
7948 std::unique_ptr<LayerImpl> root_clip = | 7951 std::unique_ptr<LayerImpl> root_clip = |
7949 LayerImpl::Create(host_impl_->active_tree(), 3); | 7952 LayerImpl::Create(host_impl_->active_tree(), 3); |
7950 root_clip->SetForceRenderSurface(true); | 7953 root_clip->test_properties()->force_render_surface = true; |
7951 std::unique_ptr<LayerImpl> root_scroll = | 7954 std::unique_ptr<LayerImpl> root_scroll = |
7952 CreateScrollableLayer(1, content_size, root_clip.get()); | 7955 CreateScrollableLayer(1, content_size, root_clip.get()); |
7953 int root_scroll_id = root_scroll->id(); | 7956 int root_scroll_id = root_scroll->id(); |
7954 std::unique_ptr<LayerImpl> child = | 7957 std::unique_ptr<LayerImpl> child = |
7955 CreateScrollableLayer(2, content_size, root_clip.get()); | 7958 CreateScrollableLayer(2, content_size, root_clip.get()); |
7956 | 7959 |
7957 root_scroll->AddChild(std::move(child)); | 7960 root_scroll->AddChild(std::move(child)); |
7958 root_clip->AddChild(std::move(root_scroll)); | 7961 root_clip->AddChild(std::move(root_scroll)); |
7959 | 7962 |
7960 host_impl_->SetViewportSize(surface_size); | 7963 host_impl_->SetViewportSize(surface_size); |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8195 } | 8198 } |
8196 | 8199 |
8197 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed | 8200 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed |
8198 // to CompositorFrameMetadata after SwapBuffers(); | 8201 // to CompositorFrameMetadata after SwapBuffers(); |
8199 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { | 8202 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { |
8200 std::unique_ptr<SolidColorLayerImpl> root = | 8203 std::unique_ptr<SolidColorLayerImpl> root = |
8201 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 8204 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
8202 root->SetPosition(gfx::PointF()); | 8205 root->SetPosition(gfx::PointF()); |
8203 root->SetBounds(gfx::Size(10, 10)); | 8206 root->SetBounds(gfx::Size(10, 10)); |
8204 root->SetDrawsContent(true); | 8207 root->SetDrawsContent(true); |
8205 root->SetForceRenderSurface(true); | 8208 root->test_properties()->force_render_surface = true; |
8206 | 8209 |
8207 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 8210 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
8208 | 8211 |
8209 FakeOutputSurface* fake_output_surface = | 8212 FakeOutputSurface* fake_output_surface = |
8210 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 8213 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); |
8211 | 8214 |
8212 const std::vector<ui::LatencyInfo>& metadata_latency_before = | 8215 const std::vector<ui::LatencyInfo>& metadata_latency_before = |
8213 fake_output_surface->last_sent_frame().metadata.latency_info; | 8216 fake_output_surface->last_sent_frame().metadata.latency_info; |
8214 EXPECT_TRUE(metadata_latency_before.empty()); | 8217 EXPECT_TRUE(metadata_latency_before.empty()); |
8215 | 8218 |
(...skipping 19 matching lines...) Expand all Loading... |
8235 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL)); | 8238 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL)); |
8236 } | 8239 } |
8237 | 8240 |
8238 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { | 8241 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { |
8239 int root_layer_id = 1; | 8242 int root_layer_id = 1; |
8240 std::unique_ptr<SolidColorLayerImpl> root = | 8243 std::unique_ptr<SolidColorLayerImpl> root = |
8241 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id); | 8244 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id); |
8242 root->SetPosition(gfx::PointF()); | 8245 root->SetPosition(gfx::PointF()); |
8243 root->SetBounds(gfx::Size(10, 10)); | 8246 root->SetBounds(gfx::Size(10, 10)); |
8244 root->SetDrawsContent(true); | 8247 root->SetDrawsContent(true); |
8245 root->SetForceRenderSurface(true); | 8248 root->test_properties()->force_render_surface = true; |
8246 | 8249 |
8247 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 8250 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
8248 | 8251 |
8249 // Ensure the default frame selection bounds are empty. | 8252 // Ensure the default frame selection bounds are empty. |
8250 FakeOutputSurface* fake_output_surface = | 8253 FakeOutputSurface* fake_output_surface = |
8251 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 8254 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); |
8252 const ViewportSelection& selection_before = | 8255 const ViewportSelection& selection_before = |
8253 fake_output_surface->last_sent_frame().metadata.selection; | 8256 fake_output_surface->last_sent_frame().metadata.selection; |
8254 EXPECT_EQ(ViewportSelectionBound(), selection_before.start); | 8257 EXPECT_EQ(ViewportSelectionBound(), selection_before.start); |
8255 EXPECT_EQ(ViewportSelectionBound(), selection_before.end); | 8258 EXPECT_EQ(ViewportSelectionBound(), selection_before.end); |
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8931 contents->SetDrawsContent(true); | 8934 contents->SetDrawsContent(true); |
8932 contents->SetBounds(content_size); | 8935 contents->SetBounds(content_size); |
8933 contents->SetPosition(gfx::PointF()); | 8936 contents->SetPosition(gfx::PointF()); |
8934 | 8937 |
8935 outer_scroll->AddChild(std::move(contents)); | 8938 outer_scroll->AddChild(std::move(contents)); |
8936 outer_clip->AddChild(std::move(outer_scroll)); | 8939 outer_clip->AddChild(std::move(outer_scroll)); |
8937 inner_scroll->AddChild(std::move(outer_clip)); | 8940 inner_scroll->AddChild(std::move(outer_clip)); |
8938 page_scale->AddChild(std::move(inner_scroll)); | 8941 page_scale->AddChild(std::move(inner_scroll)); |
8939 inner_clip->AddChild(std::move(page_scale)); | 8942 inner_clip->AddChild(std::move(page_scale)); |
8940 | 8943 |
8941 inner_clip->SetForceRenderSurface(true); | 8944 inner_clip->test_properties()->force_render_surface = true; |
8942 layer_tree_impl->SetRootLayer(std::move(inner_clip)); | 8945 layer_tree_impl->SetRootLayer(std::move(inner_clip)); |
8943 layer_tree_impl->SetViewportLayersFromIds( | 8946 layer_tree_impl->SetViewportLayersFromIds( |
8944 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportScrollLayerId, | 8947 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportScrollLayerId, |
8945 kOuterViewportScrollLayerId); | 8948 kOuterViewportScrollLayerId); |
8946 | 8949 |
8947 host_impl_->active_tree()->DidBecomeActive(); | 8950 host_impl_->active_tree()->DidBecomeActive(); |
8948 } | 8951 } |
8949 }; | 8952 }; |
8950 | 8953 |
8951 TEST_F(LayerTreeHostImplVirtualViewportTest, ScrollBothInnerAndOuterLayer) { | 8954 TEST_F(LayerTreeHostImplVirtualViewportTest, ScrollBothInnerAndOuterLayer) { |
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9534 EXPECT_EQ(gfx::Rect(50, 50), content_layer->visible_layer_rect()); | 9537 EXPECT_EQ(gfx::Rect(50, 50), content_layer->visible_layer_rect()); |
9535 } | 9538 } |
9536 | 9539 |
9537 TEST_F(LayerTreeHostImplTest, ExternalTransformAffectsSublayerScaleFactor) { | 9540 TEST_F(LayerTreeHostImplTest, ExternalTransformAffectsSublayerScaleFactor) { |
9538 const gfx::Size layer_size(100, 100); | 9541 const gfx::Size layer_size(100, 100); |
9539 SetupScrollAndContentsLayers(layer_size); | 9542 SetupScrollAndContentsLayers(layer_size); |
9540 LayerImpl* content_layer = | 9543 LayerImpl* content_layer = |
9541 host_impl_->active_tree()->OuterViewportScrollLayer()->children()[0]; | 9544 host_impl_->active_tree()->OuterViewportScrollLayer()->children()[0]; |
9542 content_layer->AddChild(LayerImpl::Create(host_impl_->active_tree(), 100)); | 9545 content_layer->AddChild(LayerImpl::Create(host_impl_->active_tree(), 100)); |
9543 LayerImpl* test_layer = host_impl_->active_tree()->LayerById(100); | 9546 LayerImpl* test_layer = host_impl_->active_tree()->LayerById(100); |
9544 test_layer->SetForceRenderSurface(true); | 9547 test_layer->test_properties()->force_render_surface = true; |
9545 test_layer->SetDrawsContent(true); | 9548 test_layer->SetDrawsContent(true); |
9546 test_layer->SetBounds(layer_size); | 9549 test_layer->SetBounds(layer_size); |
9547 gfx::Transform perspective_transform; | 9550 gfx::Transform perspective_transform; |
9548 perspective_transform.ApplyPerspectiveDepth(2); | 9551 perspective_transform.ApplyPerspectiveDepth(2); |
9549 test_layer->SetTransform(perspective_transform); | 9552 test_layer->SetTransform(perspective_transform); |
9550 | 9553 |
9551 SetNeedsRebuildPropertyTrees(); | 9554 SetNeedsRebuildPropertyTrees(); |
9552 RebuildPropertyTrees(); | 9555 RebuildPropertyTrees(); |
9553 bool update_lcd_text = false; | 9556 bool update_lcd_text = false; |
9554 | 9557 |
(...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10584 TEST_F(LayerTreeHostImplTest, SubLayerScaleForNodeInSubtreeOfPageScaleLayer) { | 10587 TEST_F(LayerTreeHostImplTest, SubLayerScaleForNodeInSubtreeOfPageScaleLayer) { |
10585 // Checks that the sublayer scale of a transform node in the subtree of the | 10588 // Checks that the sublayer scale of a transform node in the subtree of the |
10586 // page scale layer is updated without a property tree rebuild. | 10589 // page scale layer is updated without a property tree rebuild. |
10587 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 3.f); | 10590 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 3.f); |
10588 CreateScrollAndContentsLayers(host_impl_->active_tree(), gfx::Size(100, 100)); | 10591 CreateScrollAndContentsLayers(host_impl_->active_tree(), gfx::Size(100, 100)); |
10589 LayerImpl* page_scale_layer = host_impl_->active_tree()->PageScaleLayer(); | 10592 LayerImpl* page_scale_layer = host_impl_->active_tree()->PageScaleLayer(); |
10590 page_scale_layer->AddChild(LayerImpl::Create(host_impl_->active_tree(), 100)); | 10593 page_scale_layer->AddChild(LayerImpl::Create(host_impl_->active_tree(), 100)); |
10591 | 10594 |
10592 LayerImpl* in_subtree_of_page_scale_layer = | 10595 LayerImpl* in_subtree_of_page_scale_layer = |
10593 host_impl_->active_tree()->LayerById(100); | 10596 host_impl_->active_tree()->LayerById(100); |
10594 in_subtree_of_page_scale_layer->SetForceRenderSurface(true); | 10597 in_subtree_of_page_scale_layer->test_properties()->force_render_surface = |
| 10598 true; |
10595 SetNeedsRebuildPropertyTrees(); | 10599 SetNeedsRebuildPropertyTrees(); |
10596 RebuildPropertyTrees(); | 10600 RebuildPropertyTrees(); |
10597 DrawFrame(); | 10601 DrawFrame(); |
10598 TransformNode* node = | 10602 TransformNode* node = |
10599 host_impl_->active_tree()->property_trees()->transform_tree.Node( | 10603 host_impl_->active_tree()->property_trees()->transform_tree.Node( |
10600 in_subtree_of_page_scale_layer->transform_tree_index()); | 10604 in_subtree_of_page_scale_layer->transform_tree_index()); |
10601 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(1.f, 1.f)); | 10605 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(1.f, 1.f)); |
10602 | 10606 |
10603 host_impl_->active_tree()->SetPageScaleOnActiveTree(2.f); | 10607 host_impl_->active_tree()->SetPageScaleOnActiveTree(2.f); |
10604 DrawFrame(); | 10608 DrawFrame(); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10669 // There should not be any jitter measured till we hit the fixed point hits | 10673 // There should not be any jitter measured till we hit the fixed point hits |
10670 // threshold. | 10674 // threshold. |
10671 float expected_jitter = | 10675 float expected_jitter = |
10672 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0; | 10676 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0; |
10673 EXPECT_EQ(jitter, expected_jitter); | 10677 EXPECT_EQ(jitter, expected_jitter); |
10674 } | 10678 } |
10675 } | 10679 } |
10676 | 10680 |
10677 } // namespace | 10681 } // namespace |
10678 } // namespace cc | 10682 } // namespace cc |
OLD | NEW |