| 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 <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 4317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4328 root->AddChild(child.Pass()); | 4328 root->AddChild(child.Pass()); |
| 4329 layer_tree_host_impl->active_tree()->SetRootLayer(root.Pass()); | 4329 layer_tree_host_impl->active_tree()->SetRootLayer(root.Pass()); |
| 4330 | 4330 |
| 4331 LayerTreeHostImpl::FrameData frame; | 4331 LayerTreeHostImpl::FrameData frame; |
| 4332 | 4332 |
| 4333 // First frame, the entire screen should get swapped. | 4333 // First frame, the entire screen should get swapped. |
| 4334 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); | 4334 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); |
| 4335 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); | 4335 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 4336 layer_tree_host_impl->DidDrawAllLayers(frame); | 4336 layer_tree_host_impl->DidDrawAllLayers(frame); |
| 4337 layer_tree_host_impl->SwapBuffers(frame); | 4337 layer_tree_host_impl->SwapBuffers(frame); |
| 4338 EXPECT_EQ(TestContextSupport::SWAP, | 4338 EXPECT_EQ(TestGLES2Interface::SWAP, context_provider->last_swap_type()); |
| 4339 context_provider->support()->last_swap_type()); | |
| 4340 | 4339 |
| 4341 // Second frame, only the damaged area should get swapped. Damage should be | 4340 // Second frame, only the damaged area should get swapped. Damage should be |
| 4342 // the union of old and new child rects. | 4341 // the union of old and new child rects. |
| 4343 // expected damage rect: gfx::Rect(26, 28); | 4342 // expected damage rect: gfx::Rect(26, 28); |
| 4344 // expected swap rect: vertically flipped, with origin at bottom left corner. | 4343 // expected swap rect: vertically flipped, with origin at bottom left corner. |
| 4345 layer_tree_host_impl->active_tree()->root_layer()->children()[0]->SetPosition( | 4344 layer_tree_host_impl->active_tree()->root_layer()->children()[0]->SetPosition( |
| 4346 gfx::PointF()); | 4345 gfx::PointF()); |
| 4347 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); | 4346 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); |
| 4348 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); | 4347 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 4349 host_impl_->DidDrawAllLayers(frame); | 4348 host_impl_->DidDrawAllLayers(frame); |
| 4350 layer_tree_host_impl->SwapBuffers(frame); | 4349 layer_tree_host_impl->SwapBuffers(frame); |
| 4351 | 4350 |
| 4352 // Make sure that partial swap is constrained to the viewport dimensions | 4351 // Make sure that partial swap is constrained to the viewport dimensions |
| 4353 // expected damage rect: gfx::Rect(500, 500); | 4352 // expected damage rect: gfx::Rect(500, 500); |
| 4354 // expected swap rect: flipped damage rect, but also clamped to viewport | 4353 // expected swap rect: flipped damage rect, but also clamped to viewport |
| 4355 EXPECT_EQ(TestContextSupport::PARTIAL_SWAP, | 4354 EXPECT_EQ(TestGLES2Interface::PARTIAL_SWAP, |
| 4356 context_provider->support()->last_swap_type()); | 4355 context_provider->last_swap_type()); |
| 4357 gfx::Rect expected_swap_rect(0, 500-28, 26, 28); | 4356 gfx::Rect expected_swap_rect(0, 500-28, 26, 28); |
| 4358 EXPECT_EQ(expected_swap_rect.ToString(), | 4357 EXPECT_EQ(expected_swap_rect.ToString(), |
| 4359 context_provider->support()-> | 4358 context_provider->last_partial_swap_rect().ToString()); |
| 4360 last_partial_swap_rect().ToString()); | |
| 4361 | 4359 |
| 4362 layer_tree_host_impl->SetViewportSize(gfx::Size(10, 10)); | 4360 layer_tree_host_impl->SetViewportSize(gfx::Size(10, 10)); |
| 4363 // This will damage everything. | 4361 // This will damage everything. |
| 4364 layer_tree_host_impl->active_tree()->root_layer()->SetBackgroundColor( | 4362 layer_tree_host_impl->active_tree()->root_layer()->SetBackgroundColor( |
| 4365 SK_ColorBLACK); | 4363 SK_ColorBLACK); |
| 4366 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); | 4364 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); |
| 4367 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); | 4365 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 4368 host_impl_->DidDrawAllLayers(frame); | 4366 host_impl_->DidDrawAllLayers(frame); |
| 4369 layer_tree_host_impl->SwapBuffers(frame); | 4367 layer_tree_host_impl->SwapBuffers(frame); |
| 4370 | 4368 |
| 4371 EXPECT_EQ(TestContextSupport::SWAP, | 4369 EXPECT_EQ(TestGLES2Interface::SWAP, context_provider->last_swap_type()); |
| 4372 context_provider->support()->last_swap_type()); | |
| 4373 } | 4370 } |
| 4374 | 4371 |
| 4375 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) { | 4372 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) { |
| 4376 scoped_ptr<LayerImpl> root = | 4373 scoped_ptr<LayerImpl> root = |
| 4377 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); | 4374 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); |
| 4378 scoped_ptr<LayerImpl> child = | 4375 scoped_ptr<LayerImpl> child = |
| 4379 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); | 4376 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); |
| 4380 child->SetBounds(gfx::Size(10, 10)); | 4377 child->SetBounds(gfx::Size(10, 10)); |
| 4381 child->SetContentBounds(gfx::Size(10, 10)); | 4378 child->SetContentBounds(gfx::Size(10, 10)); |
| 4382 child->SetDrawsContent(true); | 4379 child->SetDrawsContent(true); |
| (...skipping 2783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7166 // surface. | 7163 // surface. |
| 7167 EXPECT_EQ(0, num_lost_surfaces_); | 7164 EXPECT_EQ(0, num_lost_surfaces_); |
| 7168 host_impl_->DidLoseOutputSurface(); | 7165 host_impl_->DidLoseOutputSurface(); |
| 7169 EXPECT_EQ(1, num_lost_surfaces_); | 7166 EXPECT_EQ(1, num_lost_surfaces_); |
| 7170 host_impl_->DidLoseOutputSurface(); | 7167 host_impl_->DidLoseOutputSurface(); |
| 7171 EXPECT_LE(1, num_lost_surfaces_); | 7168 EXPECT_LE(1, num_lost_surfaces_); |
| 7172 } | 7169 } |
| 7173 | 7170 |
| 7174 } // namespace | 7171 } // namespace |
| 7175 } // namespace cc | 7172 } // namespace cc |
| OLD | NEW |