| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/layer_tree_host_impl.h" | 5 #include "cc/layer_tree_host_impl.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 settings.partialSwapEnabled = partialSwap; | 112 settings.partialSwapEnabled = partialSwap; |
| 113 | 113 |
| 114 m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy); | 114 m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy); |
| 115 | 115 |
| 116 m_hostImpl->initializeRenderer(outputSurface.Pass()); | 116 m_hostImpl->initializeRenderer(outputSurface.Pass()); |
| 117 m_hostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); | 117 m_hostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); |
| 118 } | 118 } |
| 119 | 119 |
| 120 void setupRootLayerImpl(scoped_ptr<LayerImpl> root) | 120 void setupRootLayerImpl(scoped_ptr<LayerImpl> root) |
| 121 { | 121 { |
| 122 root->setAnchorPoint(gfx::PointF(0, 0)); | 122 root->SetAnchorPoint(gfx::PointF(0, 0)); |
| 123 root->setPosition(gfx::PointF(0, 0)); | 123 root->SetPosition(gfx::PointF(0, 0)); |
| 124 root->setBounds(gfx::Size(10, 10)); | 124 root->SetBounds(gfx::Size(10, 10)); |
| 125 root->setContentBounds(gfx::Size(10, 10)); | 125 root->SetContentBounds(gfx::Size(10, 10)); |
| 126 root->setDrawsContent(true); | 126 root->SetDrawsContent(true); |
| 127 root->drawProperties().visible_content_rect = gfx::Rect(0, 0, 10, 10); | 127 root->draw_properties().visible_content_rect = gfx::Rect(0, 0, 10, 10); |
| 128 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); | 128 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
| 129 } | 129 } |
| 130 | 130 |
| 131 static void expectClearedScrollDeltasRecursive(LayerImpl* layer) | 131 static void expectClearedScrollDeltasRecursive(LayerImpl* layer) |
| 132 { | 132 { |
| 133 ASSERT_EQ(layer->scrollDelta(), gfx::Vector2d()); | 133 ASSERT_EQ(layer->scroll_delta(), gfx::Vector2d()); |
| 134 for (size_t i = 0; i < layer->children().size(); ++i) | 134 for (size_t i = 0; i < layer->children().size(); ++i) |
| 135 expectClearedScrollDeltasRecursive(layer->children()[i]); | 135 expectClearedScrollDeltasRecursive(layer->children()[i]); |
| 136 } | 136 } |
| 137 | 137 |
| 138 static void expectContains(const ScrollAndScaleSet& scrollInfo, int id, cons
t gfx::Vector2d& scrollDelta) | 138 static void expectContains(const ScrollAndScaleSet& scrollInfo, int id, cons
t gfx::Vector2d& scrollDelta) |
| 139 { | 139 { |
| 140 int timesEncountered = 0; | 140 int timesEncountered = 0; |
| 141 | 141 |
| 142 for (size_t i = 0; i < scrollInfo.scrolls.size(); ++i) { | 142 for (size_t i = 0; i < scrollInfo.scrolls.size(); ++i) { |
| 143 if (scrollInfo.scrolls[i].layerId != id) | 143 if (scrollInfo.scrolls[i].layerId != id) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 157 if (scrollInfo.scrolls[i].layerId != id) | 157 if (scrollInfo.scrolls[i].layerId != id) |
| 158 continue; | 158 continue; |
| 159 timesEncountered++; | 159 timesEncountered++; |
| 160 } | 160 } |
| 161 | 161 |
| 162 ASSERT_EQ(0, timesEncountered); | 162 ASSERT_EQ(0, timesEncountered); |
| 163 } | 163 } |
| 164 | 164 |
| 165 void setupScrollAndContentsLayers(const gfx::Size& contentSize) | 165 void setupScrollAndContentsLayers(const gfx::Size& contentSize) |
| 166 { | 166 { |
| 167 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(),
1); | 167 scoped_ptr<LayerImpl> root = LayerImpl::Create(m_hostImpl->activeTree(),
1); |
| 168 root->setScrollable(true); | 168 root->SetScrollable(true); |
| 169 root->setScrollOffset(gfx::Vector2d(0, 0)); | 169 root->SetScrollOffset(gfx::Vector2d(0, 0)); |
| 170 root->setMaxScrollOffset(gfx::Vector2d(contentSize.width(), contentSize.
height())); | 170 root->SetMaxScrollOffset(gfx::Vector2d(contentSize.width(), contentSize.
height())); |
| 171 root->setBounds(contentSize); | 171 root->SetBounds(contentSize); |
| 172 root->setContentBounds(contentSize); | 172 root->SetContentBounds(contentSize); |
| 173 root->setPosition(gfx::PointF(0, 0)); | 173 root->SetPosition(gfx::PointF(0, 0)); |
| 174 root->setAnchorPoint(gfx::PointF(0, 0)); | 174 root->SetAnchorPoint(gfx::PointF(0, 0)); |
| 175 | 175 |
| 176 scoped_ptr<LayerImpl> contents = LayerImpl::create(m_hostImpl->activeTre
e(), 2); | 176 scoped_ptr<LayerImpl> contents = LayerImpl::Create(m_hostImpl->activeTre
e(), 2); |
| 177 contents->setDrawsContent(true); | 177 contents->SetDrawsContent(true); |
| 178 contents->setBounds(contentSize); | 178 contents->SetBounds(contentSize); |
| 179 contents->setContentBounds(contentSize); | 179 contents->SetContentBounds(contentSize); |
| 180 contents->setPosition(gfx::PointF(0, 0)); | 180 contents->SetPosition(gfx::PointF(0, 0)); |
| 181 contents->setAnchorPoint(gfx::PointF(0, 0)); | 181 contents->SetAnchorPoint(gfx::PointF(0, 0)); |
| 182 root->addChild(contents.Pass()); | 182 root->AddChild(contents.Pass()); |
| 183 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); | 183 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
| 184 m_hostImpl->activeTree()->DidBecomeActive(); | 184 m_hostImpl->activeTree()->DidBecomeActive(); |
| 185 } | 185 } |
| 186 | 186 |
| 187 scoped_ptr<LayerImpl> createScrollableLayer(int id, const gfx::Size& size) | 187 scoped_ptr<LayerImpl> createScrollableLayer(int id, const gfx::Size& size) |
| 188 { | 188 { |
| 189 scoped_ptr<LayerImpl> layer = LayerImpl::create(m_hostImpl->activeTree()
, id); | 189 scoped_ptr<LayerImpl> layer = LayerImpl::Create(m_hostImpl->activeTree()
, id); |
| 190 layer->setScrollable(true); | 190 layer->SetScrollable(true); |
| 191 layer->setDrawsContent(true); | 191 layer->SetDrawsContent(true); |
| 192 layer->setBounds(size); | 192 layer->SetBounds(size); |
| 193 layer->setContentBounds(size); | 193 layer->SetContentBounds(size); |
| 194 layer->setMaxScrollOffset(gfx::Vector2d(size.width() * 2, size.height()
* 2)); | 194 layer->SetMaxScrollOffset(gfx::Vector2d(size.width() * 2, size.height()
* 2)); |
| 195 return layer.Pass(); | 195 return layer.Pass(); |
| 196 } | 196 } |
| 197 | 197 |
| 198 void initializeRendererAndDrawFrame() | 198 void initializeRendererAndDrawFrame() |
| 199 { | 199 { |
| 200 m_hostImpl->initializeRenderer(createOutputSurface()); | 200 m_hostImpl->initializeRenderer(createOutputSurface()); |
| 201 LayerTreeHostImpl::FrameData frame; | 201 LayerTreeHostImpl::FrameData frame; |
| 202 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 202 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 203 m_hostImpl->drawLayers(frame); | 203 m_hostImpl->drawLayers(frame); |
| 204 m_hostImpl->didDrawAllLayers(frame); | 204 m_hostImpl->didDrawAllLayers(frame); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 { | 298 { |
| 299 ASSERT_FALSE(m_hostImpl->rootLayer()); | 299 ASSERT_FALSE(m_hostImpl->rootLayer()); |
| 300 | 300 |
| 301 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; | 301 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; |
| 302 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); | 302 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); |
| 303 } | 303 } |
| 304 | 304 |
| 305 TEST_F(LayerTreeHostImplTest, scrollDeltaTreeButNoChanges) | 305 TEST_F(LayerTreeHostImplTest, scrollDeltaTreeButNoChanges) |
| 306 { | 306 { |
| 307 { | 307 { |
| 308 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(),
1); | 308 scoped_ptr<LayerImpl> root = LayerImpl::Create(m_hostImpl->activeTree(),
1); |
| 309 root->addChild(LayerImpl::create(m_hostImpl->activeTree(), 2)); | 309 root->AddChild(LayerImpl::Create(m_hostImpl->activeTree(), 2)); |
| 310 root->addChild(LayerImpl::create(m_hostImpl->activeTree(), 3)); | 310 root->AddChild(LayerImpl::Create(m_hostImpl->activeTree(), 3)); |
| 311 root->children()[1]->addChild(LayerImpl::create(m_hostImpl->activeTree()
, 4)); | 311 root->children()[1]->AddChild(LayerImpl::Create(m_hostImpl->activeTree()
, 4)); |
| 312 root->children()[1]->addChild(LayerImpl::create(m_hostImpl->activeTree()
, 5)); | 312 root->children()[1]->AddChild(LayerImpl::Create(m_hostImpl->activeTree()
, 5)); |
| 313 root->children()[1]->children()[0]->addChild(LayerImpl::create(m_hostImp
l->activeTree(), 6)); | 313 root->children()[1]->children()[0]->AddChild(LayerImpl::Create(m_hostImp
l->activeTree(), 6)); |
| 314 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); | 314 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
| 315 } | 315 } |
| 316 LayerImpl* root = m_hostImpl->rootLayer(); | 316 LayerImpl* root = m_hostImpl->rootLayer(); |
| 317 | 317 |
| 318 expectClearedScrollDeltasRecursive(root); | 318 expectClearedScrollDeltasRecursive(root); |
| 319 | 319 |
| 320 scoped_ptr<ScrollAndScaleSet> scrollInfo; | 320 scoped_ptr<ScrollAndScaleSet> scrollInfo; |
| 321 | 321 |
| 322 scrollInfo = m_hostImpl->processScrollDeltas(); | 322 scrollInfo = m_hostImpl->processScrollDeltas(); |
| 323 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); | 323 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); |
| 324 expectClearedScrollDeltasRecursive(root); | 324 expectClearedScrollDeltasRecursive(root); |
| 325 | 325 |
| 326 scrollInfo = m_hostImpl->processScrollDeltas(); | 326 scrollInfo = m_hostImpl->processScrollDeltas(); |
| 327 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); | 327 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); |
| 328 expectClearedScrollDeltasRecursive(root); | 328 expectClearedScrollDeltasRecursive(root); |
| 329 } | 329 } |
| 330 | 330 |
| 331 TEST_F(LayerTreeHostImplTest, scrollDeltaRepeatedScrolls) | 331 TEST_F(LayerTreeHostImplTest, scrollDeltaRepeatedScrolls) |
| 332 { | 332 { |
| 333 gfx::Vector2d scrollOffset(20, 30); | 333 gfx::Vector2d scrollOffset(20, 30); |
| 334 gfx::Vector2d scrollDelta(11, -15); | 334 gfx::Vector2d scrollDelta(11, -15); |
| 335 { | 335 { |
| 336 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(),
1); | 336 scoped_ptr<LayerImpl> root = LayerImpl::Create(m_hostImpl->activeTree(),
1); |
| 337 root->setScrollOffset(scrollOffset); | 337 root->SetScrollOffset(scrollOffset); |
| 338 root->setScrollable(true); | 338 root->SetScrollable(true); |
| 339 root->setMaxScrollOffset(gfx::Vector2d(100, 100)); | 339 root->SetMaxScrollOffset(gfx::Vector2d(100, 100)); |
| 340 root->scrollBy(scrollDelta); | 340 root->ScrollBy(scrollDelta); |
| 341 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); | 341 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
| 342 } | 342 } |
| 343 LayerImpl* root = m_hostImpl->rootLayer(); | 343 LayerImpl* root = m_hostImpl->rootLayer(); |
| 344 | 344 |
| 345 scoped_ptr<ScrollAndScaleSet> scrollInfo; | 345 scoped_ptr<ScrollAndScaleSet> scrollInfo; |
| 346 | 346 |
| 347 scrollInfo = m_hostImpl->processScrollDeltas(); | 347 scrollInfo = m_hostImpl->processScrollDeltas(); |
| 348 ASSERT_EQ(scrollInfo->scrolls.size(), 1u); | 348 ASSERT_EQ(scrollInfo->scrolls.size(), 1u); |
| 349 EXPECT_VECTOR_EQ(root->sentScrollDelta(), scrollDelta); | 349 EXPECT_VECTOR_EQ(root->sent_scroll_delta(), scrollDelta); |
| 350 expectContains(*scrollInfo, root->id(), scrollDelta); | 350 expectContains(*scrollInfo, root->id(), scrollDelta); |
| 351 | 351 |
| 352 gfx::Vector2d scrollDelta2(-5, 27); | 352 gfx::Vector2d scrollDelta2(-5, 27); |
| 353 root->scrollBy(scrollDelta2); | 353 root->ScrollBy(scrollDelta2); |
| 354 scrollInfo = m_hostImpl->processScrollDeltas(); | 354 scrollInfo = m_hostImpl->processScrollDeltas(); |
| 355 ASSERT_EQ(scrollInfo->scrolls.size(), 1u); | 355 ASSERT_EQ(scrollInfo->scrolls.size(), 1u); |
| 356 EXPECT_VECTOR_EQ(root->sentScrollDelta(), scrollDelta + scrollDelta2); | 356 EXPECT_VECTOR_EQ(root->sent_scroll_delta(), scrollDelta + scrollDelta2); |
| 357 expectContains(*scrollInfo, root->id(), scrollDelta + scrollDelta2); | 357 expectContains(*scrollInfo, root->id(), scrollDelta + scrollDelta2); |
| 358 | 358 |
| 359 root->scrollBy(gfx::Vector2d()); | 359 root->ScrollBy(gfx::Vector2d()); |
| 360 scrollInfo = m_hostImpl->processScrollDeltas(); | 360 scrollInfo = m_hostImpl->processScrollDeltas(); |
| 361 EXPECT_EQ(root->sentScrollDelta(), scrollDelta + scrollDelta2); | 361 EXPECT_EQ(root->sent_scroll_delta(), scrollDelta + scrollDelta2); |
| 362 } | 362 } |
| 363 | 363 |
| 364 TEST_F(LayerTreeHostImplTest, scrollRootCallsCommitAndRedraw) | 364 TEST_F(LayerTreeHostImplTest, scrollRootCallsCommitAndRedraw) |
| 365 { | 365 { |
| 366 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 366 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 367 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); | 367 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); |
| 368 initializeRendererAndDrawFrame(); | 368 initializeRendererAndDrawFrame(); |
| 369 | 369 |
| 370 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 370 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
| 371 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 371 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 } | 418 } |
| 419 | 419 |
| 420 TEST_F(LayerTreeHostImplTest, clearRootRenderSurfaceAndScroll) | 420 TEST_F(LayerTreeHostImplTest, clearRootRenderSurfaceAndScroll) |
| 421 { | 421 { |
| 422 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 422 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 423 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); | 423 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); |
| 424 initializeRendererAndDrawFrame(); | 424 initializeRendererAndDrawFrame(); |
| 425 | 425 |
| 426 // We should be able to scroll even if the root layer loses its render surfa
ce after the most | 426 // We should be able to scroll even if the root layer loses its render surfa
ce after the most |
| 427 // recent render. | 427 // recent render. |
| 428 m_hostImpl->rootLayer()->clearRenderSurface(); | 428 m_hostImpl->rootLayer()->ClearRenderSurface(); |
| 429 m_hostImpl->activeTree()->set_needs_update_draw_properties(); | 429 m_hostImpl->activeTree()->set_needs_update_draw_properties(); |
| 430 | 430 |
| 431 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 431 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
| 432 } | 432 } |
| 433 | 433 |
| 434 TEST_F(LayerTreeHostImplTest, wheelEventHandlers) | 434 TEST_F(LayerTreeHostImplTest, wheelEventHandlers) |
| 435 { | 435 { |
| 436 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 436 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 437 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); | 437 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); |
| 438 initializeRendererAndDrawFrame(); | 438 initializeRendererAndDrawFrame(); |
| 439 LayerImpl* root = m_hostImpl->rootLayer(); | 439 LayerImpl* root = m_hostImpl->rootLayer(); |
| 440 | 440 |
| 441 root->setHaveWheelEventHandlers(true); | 441 root->SetHaveWheelEventHandlers(true); |
| 442 | 442 |
| 443 // With registered event handlers, wheel scrolls have to go to the main thre
ad. | 443 // With registered event handlers, wheel scrolls have to go to the main thre
ad. |
| 444 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollOnMainThread); | 444 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollOnMainThread); |
| 445 | 445 |
| 446 // But gesture scrolls can still be handled. | 446 // But gesture scrolls can still be handled. |
| 447 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gest
ure), InputHandlerClient::ScrollStarted); | 447 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gest
ure), InputHandlerClient::ScrollStarted); |
| 448 } | 448 } |
| 449 | 449 |
| 450 TEST_F(LayerTreeHostImplTest, shouldScrollOnMainThread) | 450 TEST_F(LayerTreeHostImplTest, shouldScrollOnMainThread) |
| 451 { | 451 { |
| 452 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 452 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 453 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); | 453 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); |
| 454 initializeRendererAndDrawFrame(); | 454 initializeRendererAndDrawFrame(); |
| 455 LayerImpl* root = m_hostImpl->rootLayer(); | 455 LayerImpl* root = m_hostImpl->rootLayer(); |
| 456 | 456 |
| 457 root->setShouldScrollOnMainThread(true); | 457 root->SetShouldScrollOnMainThread(true); |
| 458 | 458 |
| 459 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollOnMainThread); | 459 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollOnMainThread); |
| 460 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gest
ure), InputHandlerClient::ScrollOnMainThread); | 460 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gest
ure), InputHandlerClient::ScrollOnMainThread); |
| 461 } | 461 } |
| 462 | 462 |
| 463 TEST_F(LayerTreeHostImplTest, nonFastScrollableRegionBasic) | 463 TEST_F(LayerTreeHostImplTest, nonFastScrollableRegionBasic) |
| 464 { | 464 { |
| 465 setupScrollAndContentsLayers(gfx::Size(200, 200)); | 465 setupScrollAndContentsLayers(gfx::Size(200, 200)); |
| 466 m_hostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100)); | 466 m_hostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100)); |
| 467 | 467 |
| 468 LayerImpl* root = m_hostImpl->rootLayer(); | 468 LayerImpl* root = m_hostImpl->rootLayer(); |
| 469 root->setContentsScale(2, 2); | 469 root->SetContentsScale(2, 2); |
| 470 root->setNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); | 470 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); |
| 471 | 471 |
| 472 initializeRendererAndDrawFrame(); | 472 initializeRendererAndDrawFrame(); |
| 473 | 473 |
| 474 // All scroll types inside the non-fast scrollable region should fail. | 474 // All scroll types inside the non-fast scrollable region should fail. |
| 475 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(25, 25), InputHandlerClient::Wh
eel), InputHandlerClient::ScrollOnMainThread); | 475 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(25, 25), InputHandlerClient::Wh
eel), InputHandlerClient::ScrollOnMainThread); |
| 476 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(25, 25), InputHandlerClient::Ge
sture), InputHandlerClient::ScrollOnMainThread); | 476 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(25, 25), InputHandlerClient::Ge
sture), InputHandlerClient::ScrollOnMainThread); |
| 477 | 477 |
| 478 // All scroll types outside this region should succeed. | 478 // All scroll types outside this region should succeed. |
| 479 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(75, 75), InputHandlerClient::Wh
eel), InputHandlerClient::ScrollStarted); | 479 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(75, 75), InputHandlerClient::Wh
eel), InputHandlerClient::ScrollStarted); |
| 480 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 480 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
| 481 m_hostImpl->scrollEnd(); | 481 m_hostImpl->scrollEnd(); |
| 482 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(75, 75), InputHandlerClient::Ge
sture), InputHandlerClient::ScrollStarted); | 482 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(75, 75), InputHandlerClient::Ge
sture), InputHandlerClient::ScrollStarted); |
| 483 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 483 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
| 484 m_hostImpl->scrollEnd(); | 484 m_hostImpl->scrollEnd(); |
| 485 } | 485 } |
| 486 | 486 |
| 487 TEST_F(LayerTreeHostImplTest, nonFastScrollableRegionWithOffset) | 487 TEST_F(LayerTreeHostImplTest, nonFastScrollableRegionWithOffset) |
| 488 { | 488 { |
| 489 setupScrollAndContentsLayers(gfx::Size(200, 200)); | 489 setupScrollAndContentsLayers(gfx::Size(200, 200)); |
| 490 m_hostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100)); | 490 m_hostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100)); |
| 491 | 491 |
| 492 LayerImpl* root = m_hostImpl->rootLayer(); | 492 LayerImpl* root = m_hostImpl->rootLayer(); |
| 493 root->setContentsScale(2, 2); | 493 root->SetContentsScale(2, 2); |
| 494 root->setNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); | 494 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); |
| 495 root->setPosition(gfx::PointF(-25, 0)); | 495 root->SetPosition(gfx::PointF(-25, 0)); |
| 496 | 496 |
| 497 initializeRendererAndDrawFrame(); | 497 initializeRendererAndDrawFrame(); |
| 498 | 498 |
| 499 // This point would fall into the non-fast scrollable region except that we'
ve moved the layer down by 25 pixels. | 499 // This point would fall into the non-fast scrollable region except that we'
ve moved the layer down by 25 pixels. |
| 500 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(40, 10), InputHandlerClient::Wh
eel), InputHandlerClient::ScrollStarted); | 500 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(40, 10), InputHandlerClient::Wh
eel), InputHandlerClient::ScrollStarted); |
| 501 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 1)); | 501 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 1)); |
| 502 m_hostImpl->scrollEnd(); | 502 m_hostImpl->scrollEnd(); |
| 503 | 503 |
| 504 // This point is still inside the non-fast region. | 504 // This point is still inside the non-fast region. |
| 505 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(10, 10), InputHandlerClient::Wh
eel), InputHandlerClient::ScrollOnMainThread); | 505 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(10, 10), InputHandlerClient::Wh
eel), InputHandlerClient::ScrollOnMainThread); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 } | 540 } |
| 541 | 541 |
| 542 TEST_F(LayerTreeHostImplTest, clearRootRenderSurfaceAndHitTestTouchHandlerRegion
) | 542 TEST_F(LayerTreeHostImplTest, clearRootRenderSurfaceAndHitTestTouchHandlerRegion
) |
| 543 { | 543 { |
| 544 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 544 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 545 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); | 545 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); |
| 546 initializeRendererAndDrawFrame(); | 546 initializeRendererAndDrawFrame(); |
| 547 | 547 |
| 548 // We should be able to hit test for touch event handlers even if the root l
ayer loses | 548 // We should be able to hit test for touch event handlers even if the root l
ayer loses |
| 549 // its render surface after the most recent render. | 549 // its render surface after the most recent render. |
| 550 m_hostImpl->rootLayer()->clearRenderSurface(); | 550 m_hostImpl->rootLayer()->ClearRenderSurface(); |
| 551 m_hostImpl->activeTree()->set_needs_update_draw_properties(); | 551 m_hostImpl->activeTree()->set_needs_update_draw_properties(); |
| 552 | 552 |
| 553 EXPECT_EQ(m_hostImpl->haveTouchEventHandlersAt(gfx::Point(0, 0)), false); | 553 EXPECT_EQ(m_hostImpl->haveTouchEventHandlersAt(gfx::Point(0, 0)), false); |
| 554 } | 554 } |
| 555 | 555 |
| 556 TEST_F(LayerTreeHostImplTest, implPinchZoom) | 556 TEST_F(LayerTreeHostImplTest, implPinchZoom) |
| 557 { | 557 { |
| 558 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 558 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 559 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); | 559 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); |
| 560 initializeRendererAndDrawFrame(); | 560 initializeRendererAndDrawFrame(); |
| 561 | 561 |
| 562 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); | 562 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); |
| 563 DCHECK(scrollLayer); | 563 DCHECK(scrollLayer); |
| 564 | 564 |
| 565 const float minPageScale = 1, maxPageScale = 4; | 565 const float minPageScale = 1, maxPageScale = 4; |
| 566 const gfx::Transform identityScaleTransform; | 566 const gfx::Transform identityScaleTransform; |
| 567 | 567 |
| 568 // The impl-based pinch zoom should adjust the max scroll position. | 568 // The impl-based pinch zoom should adjust the max scroll position. |
| 569 { | 569 { |
| 570 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(1, minPageScale, m
axPageScale); | 570 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(1, minPageScale, m
axPageScale); |
| 571 m_hostImpl->activeTree()->SetPageScaleDelta(1); | 571 m_hostImpl->activeTree()->SetPageScaleDelta(1); |
| 572 scrollLayer->setImplTransform(identityScaleTransform); | 572 scrollLayer->SetImplTransform(identityScaleTransform); |
| 573 scrollLayer->setScrollDelta(gfx::Vector2d()); | 573 scrollLayer->SetScrollDelta(gfx::Vector2d()); |
| 574 | 574 |
| 575 float pageScaleDelta = 2; | 575 float pageScaleDelta = 2; |
| 576 m_hostImpl->pinchGestureBegin(); | 576 m_hostImpl->pinchGestureBegin(); |
| 577 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(50, 50)); | 577 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(50, 50)); |
| 578 m_hostImpl->pinchGestureEnd(); | 578 m_hostImpl->pinchGestureEnd(); |
| 579 EXPECT_TRUE(m_didRequestRedraw); | 579 EXPECT_TRUE(m_didRequestRedraw); |
| 580 EXPECT_TRUE(m_didRequestCommit); | 580 EXPECT_TRUE(m_didRequestCommit); |
| 581 | 581 |
| 582 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 582 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
| 583 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); | 583 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); |
| 584 | 584 |
| 585 EXPECT_EQ(gfx::Vector2d(75, 75), m_hostImpl->rootLayer()->maxScrollOffse
t()); | 585 EXPECT_EQ(gfx::Vector2d(75, 75), m_hostImpl->rootLayer()->max_scroll_off
set()); |
| 586 } | 586 } |
| 587 | 587 |
| 588 // Scrolling after a pinch gesture should always be in local space. The scr
oll deltas do not | 588 // Scrolling after a pinch gesture should always be in local space. The scr
oll deltas do not |
| 589 // have the page scale factor applied. | 589 // have the page scale factor applied. |
| 590 { | 590 { |
| 591 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(1, minPageScale, m
axPageScale); | 591 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(1, minPageScale, m
axPageScale); |
| 592 m_hostImpl->activeTree()->SetPageScaleDelta(1); | 592 m_hostImpl->activeTree()->SetPageScaleDelta(1); |
| 593 scrollLayer->setImplTransform(identityScaleTransform); | 593 scrollLayer->SetImplTransform(identityScaleTransform); |
| 594 scrollLayer->setScrollDelta(gfx::Vector2d()); | 594 scrollLayer->SetScrollDelta(gfx::Vector2d()); |
| 595 | 595 |
| 596 float pageScaleDelta = 2; | 596 float pageScaleDelta = 2; |
| 597 m_hostImpl->pinchGestureBegin(); | 597 m_hostImpl->pinchGestureBegin(); |
| 598 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(0, 0)); | 598 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(0, 0)); |
| 599 m_hostImpl->pinchGestureEnd(); | 599 m_hostImpl->pinchGestureEnd(); |
| 600 | 600 |
| 601 gfx::Vector2d scrollDelta(0, 10); | 601 gfx::Vector2d scrollDelta(0, 10); |
| 602 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::
Wheel), InputHandlerClient::ScrollStarted); | 602 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::
Wheel), InputHandlerClient::ScrollStarted); |
| 603 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 603 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
| 604 m_hostImpl->scrollEnd(); | 604 m_hostImpl->scrollEnd(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 617 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); | 617 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); |
| 618 DCHECK(scrollLayer); | 618 DCHECK(scrollLayer); |
| 619 | 619 |
| 620 const float minPageScale = 1; | 620 const float minPageScale = 1; |
| 621 const float maxPageScale = 4; | 621 const float maxPageScale = 4; |
| 622 const gfx::Transform identityScaleTransform; | 622 const gfx::Transform identityScaleTransform; |
| 623 | 623 |
| 624 // Basic pinch zoom in gesture | 624 // Basic pinch zoom in gesture |
| 625 { | 625 { |
| 626 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(1, minPageScale, m
axPageScale); | 626 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(1, minPageScale, m
axPageScale); |
| 627 scrollLayer->setImplTransform(identityScaleTransform); | 627 scrollLayer->SetImplTransform(identityScaleTransform); |
| 628 scrollLayer->setScrollDelta(gfx::Vector2d()); | 628 scrollLayer->SetScrollDelta(gfx::Vector2d()); |
| 629 | 629 |
| 630 float pageScaleDelta = 2; | 630 float pageScaleDelta = 2; |
| 631 m_hostImpl->pinchGestureBegin(); | 631 m_hostImpl->pinchGestureBegin(); |
| 632 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(50, 50)); | 632 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(50, 50)); |
| 633 m_hostImpl->pinchGestureEnd(); | 633 m_hostImpl->pinchGestureEnd(); |
| 634 EXPECT_TRUE(m_didRequestRedraw); | 634 EXPECT_TRUE(m_didRequestRedraw); |
| 635 EXPECT_TRUE(m_didRequestCommit); | 635 EXPECT_TRUE(m_didRequestCommit); |
| 636 | 636 |
| 637 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 637 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
| 638 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); | 638 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); |
| 639 } | 639 } |
| 640 | 640 |
| 641 // Zoom-in clamping | 641 // Zoom-in clamping |
| 642 { | 642 { |
| 643 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(1, minPageScale, m
axPageScale); | 643 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(1, minPageScale, m
axPageScale); |
| 644 scrollLayer->setImplTransform(identityScaleTransform); | 644 scrollLayer->SetImplTransform(identityScaleTransform); |
| 645 scrollLayer->setScrollDelta(gfx::Vector2d()); | 645 scrollLayer->SetScrollDelta(gfx::Vector2d()); |
| 646 float pageScaleDelta = 10; | 646 float pageScaleDelta = 10; |
| 647 | 647 |
| 648 m_hostImpl->pinchGestureBegin(); | 648 m_hostImpl->pinchGestureBegin(); |
| 649 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(50, 50)); | 649 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(50, 50)); |
| 650 m_hostImpl->pinchGestureEnd(); | 650 m_hostImpl->pinchGestureEnd(); |
| 651 | 651 |
| 652 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 652 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
| 653 EXPECT_EQ(scrollInfo->pageScaleDelta, maxPageScale); | 653 EXPECT_EQ(scrollInfo->pageScaleDelta, maxPageScale); |
| 654 } | 654 } |
| 655 | 655 |
| 656 // Zoom-out clamping | 656 // Zoom-out clamping |
| 657 { | 657 { |
| 658 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(1, minPageScale, m
axPageScale); | 658 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(1, minPageScale, m
axPageScale); |
| 659 scrollLayer->setImplTransform(identityScaleTransform); | 659 scrollLayer->SetImplTransform(identityScaleTransform); |
| 660 scrollLayer->setScrollDelta(gfx::Vector2d()); | 660 scrollLayer->SetScrollDelta(gfx::Vector2d()); |
| 661 scrollLayer->setScrollOffset(gfx::Vector2d(50, 50)); | 661 scrollLayer->SetScrollOffset(gfx::Vector2d(50, 50)); |
| 662 | 662 |
| 663 float pageScaleDelta = 0.1f; | 663 float pageScaleDelta = 0.1f; |
| 664 m_hostImpl->pinchGestureBegin(); | 664 m_hostImpl->pinchGestureBegin(); |
| 665 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(0, 0)); | 665 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(0, 0)); |
| 666 m_hostImpl->pinchGestureEnd(); | 666 m_hostImpl->pinchGestureEnd(); |
| 667 | 667 |
| 668 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 668 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
| 669 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); | 669 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); |
| 670 | 670 |
| 671 EXPECT_TRUE(scrollInfo->scrolls.empty()); | 671 EXPECT_TRUE(scrollInfo->scrolls.empty()); |
| 672 } | 672 } |
| 673 | 673 |
| 674 // Two-finger panning should not happen based on pinch events only | 674 // Two-finger panning should not happen based on pinch events only |
| 675 { | 675 { |
| 676 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(1, minPageScale, m
axPageScale); | 676 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(1, minPageScale, m
axPageScale); |
| 677 scrollLayer->setImplTransform(identityScaleTransform); | 677 scrollLayer->SetImplTransform(identityScaleTransform); |
| 678 scrollLayer->setScrollDelta(gfx::Vector2d()); | 678 scrollLayer->SetScrollDelta(gfx::Vector2d()); |
| 679 scrollLayer->setScrollOffset(gfx::Vector2d(20, 20)); | 679 scrollLayer->SetScrollOffset(gfx::Vector2d(20, 20)); |
| 680 | 680 |
| 681 float pageScaleDelta = 1; | 681 float pageScaleDelta = 1; |
| 682 m_hostImpl->pinchGestureBegin(); | 682 m_hostImpl->pinchGestureBegin(); |
| 683 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(10, 10)); | 683 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(10, 10)); |
| 684 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(20, 20)); | 684 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(20, 20)); |
| 685 m_hostImpl->pinchGestureEnd(); | 685 m_hostImpl->pinchGestureEnd(); |
| 686 | 686 |
| 687 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 687 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
| 688 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); | 688 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); |
| 689 EXPECT_TRUE(scrollInfo->scrolls.empty()); | 689 EXPECT_TRUE(scrollInfo->scrolls.empty()); |
| 690 } | 690 } |
| 691 | 691 |
| 692 // Two-finger panning should work with interleaved scroll events | 692 // Two-finger panning should work with interleaved scroll events |
| 693 { | 693 { |
| 694 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(1, minPageScale, m
axPageScale); | 694 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(1, minPageScale, m
axPageScale); |
| 695 scrollLayer->setImplTransform(identityScaleTransform); | 695 scrollLayer->SetImplTransform(identityScaleTransform); |
| 696 scrollLayer->setScrollDelta(gfx::Vector2d()); | 696 scrollLayer->SetScrollDelta(gfx::Vector2d()); |
| 697 scrollLayer->setScrollOffset(gfx::Vector2d(20, 20)); | 697 scrollLayer->SetScrollOffset(gfx::Vector2d(20, 20)); |
| 698 | 698 |
| 699 float pageScaleDelta = 1; | 699 float pageScaleDelta = 1; |
| 700 m_hostImpl->scrollBegin(gfx::Point(10, 10), InputHandlerClient::Wheel); | 700 m_hostImpl->scrollBegin(gfx::Point(10, 10), InputHandlerClient::Wheel); |
| 701 m_hostImpl->pinchGestureBegin(); | 701 m_hostImpl->pinchGestureBegin(); |
| 702 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(10, 10)); | 702 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(10, 10)); |
| 703 m_hostImpl->scrollBy(gfx::Point(10, 10), gfx::Vector2d(-10, -10)); | 703 m_hostImpl->scrollBy(gfx::Point(10, 10), gfx::Vector2d(-10, -10)); |
| 704 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(20, 20)); | 704 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(20, 20)); |
| 705 m_hostImpl->pinchGestureEnd(); | 705 m_hostImpl->pinchGestureEnd(); |
| 706 m_hostImpl->scrollEnd(); | 706 m_hostImpl->scrollEnd(); |
| 707 | 707 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 724 const float maxPageScale = 4; | 724 const float maxPageScale = 4; |
| 725 const base::TimeTicks startTime = base::TimeTicks() + base::TimeDelta::FromS
econds(1); | 725 const base::TimeTicks startTime = base::TimeTicks() + base::TimeDelta::FromS
econds(1); |
| 726 const base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); | 726 const base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); |
| 727 const base::TimeTicks halfwayThroughAnimation = startTime + duration / 2; | 727 const base::TimeTicks halfwayThroughAnimation = startTime + duration / 2; |
| 728 const base::TimeTicks endTime = startTime + duration; | 728 const base::TimeTicks endTime = startTime + duration; |
| 729 const gfx::Transform identityScaleTransform; | 729 const gfx::Transform identityScaleTransform; |
| 730 | 730 |
| 731 // Non-anchor zoom-in | 731 // Non-anchor zoom-in |
| 732 { | 732 { |
| 733 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(1, minPageScale, m
axPageScale); | 733 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(1, minPageScale, m
axPageScale); |
| 734 scrollLayer->setImplTransform(identityScaleTransform); | 734 scrollLayer->SetImplTransform(identityScaleTransform); |
| 735 scrollLayer->setScrollOffset(gfx::Vector2d(50, 50)); | 735 scrollLayer->SetScrollOffset(gfx::Vector2d(50, 50)); |
| 736 | 736 |
| 737 m_hostImpl->startPageScaleAnimation(gfx::Vector2d(0, 0), false, 2, start
Time, duration); | 737 m_hostImpl->startPageScaleAnimation(gfx::Vector2d(0, 0), false, 2, start
Time, duration); |
| 738 m_hostImpl->animate(halfwayThroughAnimation, base::Time()); | 738 m_hostImpl->animate(halfwayThroughAnimation, base::Time()); |
| 739 EXPECT_TRUE(m_didRequestRedraw); | 739 EXPECT_TRUE(m_didRequestRedraw); |
| 740 m_hostImpl->animate(endTime, base::Time()); | 740 m_hostImpl->animate(endTime, base::Time()); |
| 741 EXPECT_TRUE(m_didRequestCommit); | 741 EXPECT_TRUE(m_didRequestCommit); |
| 742 | 742 |
| 743 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 743 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
| 744 EXPECT_EQ(scrollInfo->pageScaleDelta, 2); | 744 EXPECT_EQ(scrollInfo->pageScaleDelta, 2); |
| 745 expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(-50, -50)); | 745 expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(-50, -50)); |
| 746 } | 746 } |
| 747 | 747 |
| 748 // Anchor zoom-out | 748 // Anchor zoom-out |
| 749 { | 749 { |
| 750 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(1, minPageScale, m
axPageScale); | 750 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(1, minPageScale, m
axPageScale); |
| 751 scrollLayer->setImplTransform(identityScaleTransform); | 751 scrollLayer->SetImplTransform(identityScaleTransform); |
| 752 scrollLayer->setScrollOffset(gfx::Vector2d(50, 50)); | 752 scrollLayer->SetScrollOffset(gfx::Vector2d(50, 50)); |
| 753 | 753 |
| 754 m_hostImpl->startPageScaleAnimation(gfx::Vector2d(25, 25), true, minPage
Scale, startTime, duration); | 754 m_hostImpl->startPageScaleAnimation(gfx::Vector2d(25, 25), true, minPage
Scale, startTime, duration); |
| 755 m_hostImpl->animate(endTime, base::Time()); | 755 m_hostImpl->animate(endTime, base::Time()); |
| 756 EXPECT_TRUE(m_didRequestRedraw); | 756 EXPECT_TRUE(m_didRequestRedraw); |
| 757 EXPECT_TRUE(m_didRequestCommit); | 757 EXPECT_TRUE(m_didRequestCommit); |
| 758 | 758 |
| 759 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 759 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
| 760 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); | 760 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); |
| 761 // Pushed to (0,0) via clamping against contents layer size. | 761 // Pushed to (0,0) via clamping against contents layer size. |
| 762 expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(-50, -50)); | 762 expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(-50, -50)); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 776 const float maxPageScale = 4; | 776 const float maxPageScale = 4; |
| 777 const base::TimeTicks startTime = base::TimeTicks() + base::TimeDelta::FromS
econds(1); | 777 const base::TimeTicks startTime = base::TimeTicks() + base::TimeDelta::FromS
econds(1); |
| 778 const base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); | 778 const base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); |
| 779 const base::TimeTicks halfwayThroughAnimation = startTime + duration / 2; | 779 const base::TimeTicks halfwayThroughAnimation = startTime + duration / 2; |
| 780 const base::TimeTicks endTime = startTime + duration; | 780 const base::TimeTicks endTime = startTime + duration; |
| 781 const gfx::Transform identityScaleTransform; | 781 const gfx::Transform identityScaleTransform; |
| 782 | 782 |
| 783 // Anchor zoom with unchanged page scale should not change scroll or scale. | 783 // Anchor zoom with unchanged page scale should not change scroll or scale. |
| 784 { | 784 { |
| 785 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(1, minPageScale, m
axPageScale); | 785 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(1, minPageScale, m
axPageScale); |
| 786 scrollLayer->setImplTransform(identityScaleTransform); | 786 scrollLayer->SetImplTransform(identityScaleTransform); |
| 787 scrollLayer->setScrollOffset(gfx::Vector2d(50, 50)); | 787 scrollLayer->SetScrollOffset(gfx::Vector2d(50, 50)); |
| 788 | 788 |
| 789 m_hostImpl->startPageScaleAnimation(gfx::Vector2d(0, 0), true, 1, startT
ime, duration); | 789 m_hostImpl->startPageScaleAnimation(gfx::Vector2d(0, 0), true, 1, startT
ime, duration); |
| 790 m_hostImpl->animate(halfwayThroughAnimation, base::Time()); | 790 m_hostImpl->animate(halfwayThroughAnimation, base::Time()); |
| 791 EXPECT_TRUE(m_didRequestRedraw); | 791 EXPECT_TRUE(m_didRequestRedraw); |
| 792 m_hostImpl->animate(endTime, base::Time()); | 792 m_hostImpl->animate(endTime, base::Time()); |
| 793 EXPECT_TRUE(m_didRequestCommit); | 793 EXPECT_TRUE(m_didRequestCommit); |
| 794 | 794 |
| 795 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 795 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
| 796 EXPECT_EQ(scrollInfo->pageScaleDelta, 1); | 796 EXPECT_EQ(scrollInfo->pageScaleDelta, 1); |
| 797 expectNone(*scrollInfo, scrollLayer->id()); | 797 expectNone(*scrollInfo, scrollLayer->id()); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 EXPECT_EQ(4.0f, metadata.page_scale_factor); | 854 EXPECT_EQ(4.0f, metadata.page_scale_factor); |
| 855 EXPECT_EQ(gfx::SizeF(12.5f, 12.5f), metadata.viewport_size); | 855 EXPECT_EQ(gfx::SizeF(12.5f, 12.5f), metadata.viewport_size); |
| 856 EXPECT_EQ(gfx::SizeF(100.0f, 100.0f), metadata.root_layer_size); | 856 EXPECT_EQ(gfx::SizeF(100.0f, 100.0f), metadata.root_layer_size); |
| 857 EXPECT_EQ(0.5f, metadata.min_page_scale_factor); | 857 EXPECT_EQ(0.5f, metadata.min_page_scale_factor); |
| 858 EXPECT_EQ(4.0f, metadata.max_page_scale_factor); | 858 EXPECT_EQ(4.0f, metadata.max_page_scale_factor); |
| 859 } | 859 } |
| 860 } | 860 } |
| 861 | 861 |
| 862 class DidDrawCheckLayer : public TiledLayerImpl { | 862 class DidDrawCheckLayer : public TiledLayerImpl { |
| 863 public: | 863 public: |
| 864 static scoped_ptr<LayerImpl> create(LayerTreeImpl* treeImpl, int id) { retur
n scoped_ptr<LayerImpl>(new DidDrawCheckLayer(treeImpl, id)); } | 864 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* treeImpl, int id) { retur
n scoped_ptr<LayerImpl>(new DidDrawCheckLayer(treeImpl, id)); } |
| 865 | 865 |
| 866 virtual void didDraw(ResourceProvider*) OVERRIDE | 866 virtual void DidDraw(ResourceProvider*) OVERRIDE |
| 867 { | 867 { |
| 868 m_didDrawCalled = true; | 868 m_didDrawCalled = true; |
| 869 } | 869 } |
| 870 | 870 |
| 871 virtual void willDraw(ResourceProvider*) OVERRIDE | 871 virtual void WillDraw(ResourceProvider*) OVERRIDE |
| 872 { | 872 { |
| 873 m_willDrawCalled = true; | 873 m_willDrawCalled = true; |
| 874 } | 874 } |
| 875 | 875 |
| 876 bool didDrawCalled() const { return m_didDrawCalled; } | 876 bool didDrawCalled() const { return m_didDrawCalled; } |
| 877 bool willDrawCalled() const { return m_willDrawCalled; } | 877 bool willDrawCalled() const { return m_willDrawCalled; } |
| 878 | 878 |
| 879 void clearDidDrawCheck() | 879 void clearDidDrawCheck() |
| 880 { | 880 { |
| 881 m_didDrawCalled = false; | 881 m_didDrawCalled = false; |
| 882 m_willDrawCalled = false; | 882 m_willDrawCalled = false; |
| 883 } | 883 } |
| 884 | 884 |
| 885 protected: | 885 protected: |
| 886 DidDrawCheckLayer(LayerTreeImpl* treeImpl, int id) | 886 DidDrawCheckLayer(LayerTreeImpl* treeImpl, int id) |
| 887 : TiledLayerImpl(treeImpl, id) | 887 : TiledLayerImpl(treeImpl, id) |
| 888 , m_didDrawCalled(false) | 888 , m_didDrawCalled(false) |
| 889 , m_willDrawCalled(false) | 889 , m_willDrawCalled(false) |
| 890 { | 890 { |
| 891 setAnchorPoint(gfx::PointF(0, 0)); | 891 SetAnchorPoint(gfx::PointF(0, 0)); |
| 892 setBounds(gfx::Size(10, 10)); | 892 SetBounds(gfx::Size(10, 10)); |
| 893 setContentBounds(gfx::Size(10, 10)); | 893 SetContentBounds(gfx::Size(10, 10)); |
| 894 setDrawsContent(true); | 894 SetDrawsContent(true); |
| 895 setSkipsDraw(false); | 895 setSkipsDraw(false); |
| 896 drawProperties().visible_content_rect = gfx::Rect(0, 0, 10, 10); | 896 draw_properties().visible_content_rect = gfx::Rect(0, 0, 10, 10); |
| 897 | 897 |
| 898 scoped_ptr<LayerTilingData> tiler = LayerTilingData::create(gfx::Size(10
0, 100), LayerTilingData::HasBorderTexels); | 898 scoped_ptr<LayerTilingData> tiler = LayerTilingData::create(gfx::Size(10
0, 100), LayerTilingData::HasBorderTexels); |
| 899 tiler->setBounds(contentBounds()); | 899 tiler->setBounds(content_bounds()); |
| 900 setTilingData(*tiler.get()); | 900 setTilingData(*tiler.get()); |
| 901 } | 901 } |
| 902 | 902 |
| 903 private: | 903 private: |
| 904 bool m_didDrawCalled; | 904 bool m_didDrawCalled; |
| 905 bool m_willDrawCalled; | 905 bool m_willDrawCalled; |
| 906 }; | 906 }; |
| 907 | 907 |
| 908 TEST_F(LayerTreeHostImplTest, didDrawNotCalledOnHiddenLayer) | 908 TEST_F(LayerTreeHostImplTest, didDrawNotCalledOnHiddenLayer) |
| 909 { | 909 { |
| 910 // The root layer is always drawn, so run this test on a child layer that | 910 // The root layer is always drawn, so run this test on a child layer that |
| 911 // will be masked out by the root layer's bounds. | 911 // will be masked out by the root layer's bounds. |
| 912 m_hostImpl->activeTree()->SetRootLayer(DidDrawCheckLayer::create(m_hostImpl-
>activeTree(), 1)); | 912 m_hostImpl->activeTree()->SetRootLayer(DidDrawCheckLayer::Create(m_hostImpl-
>activeTree(), 1)); |
| 913 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); | 913 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); |
| 914 root->setMasksToBounds(true); | 914 root->SetMasksToBounds(true); |
| 915 | 915 |
| 916 root->addChild(DidDrawCheckLayer::create(m_hostImpl->activeTree(), 2)); | 916 root->AddChild(DidDrawCheckLayer::Create(m_hostImpl->activeTree(), 2)); |
| 917 DidDrawCheckLayer* layer = static_cast<DidDrawCheckLayer*>(root->children()[
0]); | 917 DidDrawCheckLayer* layer = static_cast<DidDrawCheckLayer*>(root->children()[
0]); |
| 918 // Ensure visibleContentRect for layer is empty | 918 // Ensure visibleContentRect for layer is empty |
| 919 layer->setPosition(gfx::PointF(100, 100)); | 919 layer->SetPosition(gfx::PointF(100, 100)); |
| 920 layer->setBounds(gfx::Size(10, 10)); | 920 layer->SetBounds(gfx::Size(10, 10)); |
| 921 layer->setContentBounds(gfx::Size(10, 10)); | 921 layer->SetContentBounds(gfx::Size(10, 10)); |
| 922 | 922 |
| 923 LayerTreeHostImpl::FrameData frame; | 923 LayerTreeHostImpl::FrameData frame; |
| 924 | 924 |
| 925 EXPECT_FALSE(layer->willDrawCalled()); | 925 EXPECT_FALSE(layer->willDrawCalled()); |
| 926 EXPECT_FALSE(layer->didDrawCalled()); | 926 EXPECT_FALSE(layer->didDrawCalled()); |
| 927 | 927 |
| 928 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 928 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 929 m_hostImpl->drawLayers(frame); | 929 m_hostImpl->drawLayers(frame); |
| 930 m_hostImpl->didDrawAllLayers(frame); | 930 m_hostImpl->didDrawAllLayers(frame); |
| 931 | 931 |
| 932 EXPECT_FALSE(layer->willDrawCalled()); | 932 EXPECT_FALSE(layer->willDrawCalled()); |
| 933 EXPECT_FALSE(layer->didDrawCalled()); | 933 EXPECT_FALSE(layer->didDrawCalled()); |
| 934 | 934 |
| 935 EXPECT_TRUE(layer->visibleContentRect().IsEmpty()); | 935 EXPECT_TRUE(layer->visible_content_rect().IsEmpty()); |
| 936 | 936 |
| 937 // Ensure visibleContentRect for layer layer is not empty | 937 // Ensure visibleContentRect for layer layer is not empty |
| 938 layer->setPosition(gfx::PointF(0, 0)); | 938 layer->SetPosition(gfx::PointF(0, 0)); |
| 939 | 939 |
| 940 EXPECT_FALSE(layer->willDrawCalled()); | 940 EXPECT_FALSE(layer->willDrawCalled()); |
| 941 EXPECT_FALSE(layer->didDrawCalled()); | 941 EXPECT_FALSE(layer->didDrawCalled()); |
| 942 | 942 |
| 943 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 943 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 944 m_hostImpl->drawLayers(frame); | 944 m_hostImpl->drawLayers(frame); |
| 945 m_hostImpl->didDrawAllLayers(frame); | 945 m_hostImpl->didDrawAllLayers(frame); |
| 946 | 946 |
| 947 EXPECT_TRUE(layer->willDrawCalled()); | 947 EXPECT_TRUE(layer->willDrawCalled()); |
| 948 EXPECT_TRUE(layer->didDrawCalled()); | 948 EXPECT_TRUE(layer->didDrawCalled()); |
| 949 | 949 |
| 950 EXPECT_FALSE(layer->visibleContentRect().IsEmpty()); | 950 EXPECT_FALSE(layer->visible_content_rect().IsEmpty()); |
| 951 } | 951 } |
| 952 | 952 |
| 953 TEST_F(LayerTreeHostImplTest, willDrawNotCalledOnOccludedLayer) | 953 TEST_F(LayerTreeHostImplTest, willDrawNotCalledOnOccludedLayer) |
| 954 { | 954 { |
| 955 gfx::Size bigSize(1000, 1000); | 955 gfx::Size bigSize(1000, 1000); |
| 956 m_hostImpl->setViewportSize(bigSize, bigSize); | 956 m_hostImpl->setViewportSize(bigSize, bigSize); |
| 957 | 957 |
| 958 m_hostImpl->activeTree()->SetRootLayer(DidDrawCheckLayer::create(m_hostImpl-
>activeTree(), 1)); | 958 m_hostImpl->activeTree()->SetRootLayer(DidDrawCheckLayer::Create(m_hostImpl-
>activeTree(), 1)); |
| 959 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); | 959 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); |
| 960 | 960 |
| 961 root->addChild(DidDrawCheckLayer::create(m_hostImpl->activeTree(), 2)); | 961 root->AddChild(DidDrawCheckLayer::Create(m_hostImpl->activeTree(), 2)); |
| 962 DidDrawCheckLayer* occludedLayer = static_cast<DidDrawCheckLayer*>(root->chi
ldren()[0]); | 962 DidDrawCheckLayer* occludedLayer = static_cast<DidDrawCheckLayer*>(root->chi
ldren()[0]); |
| 963 | 963 |
| 964 root->addChild(DidDrawCheckLayer::create(m_hostImpl->activeTree(), 3)); | 964 root->AddChild(DidDrawCheckLayer::Create(m_hostImpl->activeTree(), 3)); |
| 965 DidDrawCheckLayer* topLayer = static_cast<DidDrawCheckLayer*>(root->children
()[1]); | 965 DidDrawCheckLayer* topLayer = static_cast<DidDrawCheckLayer*>(root->children
()[1]); |
| 966 // This layer covers the occludedLayer above. Make this layer large so it ca
n occlude. | 966 // This layer covers the occludedLayer above. Make this layer large so it ca
n occlude. |
| 967 topLayer->setBounds(bigSize); | 967 topLayer->SetBounds(bigSize); |
| 968 topLayer->setContentBounds(bigSize); | 968 topLayer->SetContentBounds(bigSize); |
| 969 topLayer->setContentsOpaque(true); | 969 topLayer->SetContentsOpaque(true); |
| 970 | 970 |
| 971 LayerTreeHostImpl::FrameData frame; | 971 LayerTreeHostImpl::FrameData frame; |
| 972 | 972 |
| 973 EXPECT_FALSE(occludedLayer->willDrawCalled()); | 973 EXPECT_FALSE(occludedLayer->willDrawCalled()); |
| 974 EXPECT_FALSE(occludedLayer->didDrawCalled()); | 974 EXPECT_FALSE(occludedLayer->didDrawCalled()); |
| 975 EXPECT_FALSE(topLayer->willDrawCalled()); | 975 EXPECT_FALSE(topLayer->willDrawCalled()); |
| 976 EXPECT_FALSE(topLayer->didDrawCalled()); | 976 EXPECT_FALSE(topLayer->didDrawCalled()); |
| 977 | 977 |
| 978 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 978 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 979 m_hostImpl->drawLayers(frame); | 979 m_hostImpl->drawLayers(frame); |
| 980 m_hostImpl->didDrawAllLayers(frame); | 980 m_hostImpl->didDrawAllLayers(frame); |
| 981 | 981 |
| 982 EXPECT_FALSE(occludedLayer->willDrawCalled()); | 982 EXPECT_FALSE(occludedLayer->willDrawCalled()); |
| 983 EXPECT_FALSE(occludedLayer->didDrawCalled()); | 983 EXPECT_FALSE(occludedLayer->didDrawCalled()); |
| 984 EXPECT_TRUE(topLayer->willDrawCalled()); | 984 EXPECT_TRUE(topLayer->willDrawCalled()); |
| 985 EXPECT_TRUE(topLayer->didDrawCalled()); | 985 EXPECT_TRUE(topLayer->didDrawCalled()); |
| 986 } | 986 } |
| 987 | 987 |
| 988 TEST_F(LayerTreeHostImplTest, didDrawCalledOnAllLayers) | 988 TEST_F(LayerTreeHostImplTest, didDrawCalledOnAllLayers) |
| 989 { | 989 { |
| 990 m_hostImpl->activeTree()->SetRootLayer(DidDrawCheckLayer::create(m_hostImpl-
>activeTree(), 1)); | 990 m_hostImpl->activeTree()->SetRootLayer(DidDrawCheckLayer::Create(m_hostImpl-
>activeTree(), 1)); |
| 991 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); | 991 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); |
| 992 | 992 |
| 993 root->addChild(DidDrawCheckLayer::create(m_hostImpl->activeTree(), 2)); | 993 root->AddChild(DidDrawCheckLayer::Create(m_hostImpl->activeTree(), 2)); |
| 994 DidDrawCheckLayer* layer1 = static_cast<DidDrawCheckLayer*>(root->children()
[0]); | 994 DidDrawCheckLayer* layer1 = static_cast<DidDrawCheckLayer*>(root->children()
[0]); |
| 995 | 995 |
| 996 layer1->addChild(DidDrawCheckLayer::create(m_hostImpl->activeTree(), 3)); | 996 layer1->AddChild(DidDrawCheckLayer::Create(m_hostImpl->activeTree(), 3)); |
| 997 DidDrawCheckLayer* layer2 = static_cast<DidDrawCheckLayer*>(layer1->children
()[0]); | 997 DidDrawCheckLayer* layer2 = static_cast<DidDrawCheckLayer*>(layer1->children
()[0]); |
| 998 | 998 |
| 999 layer1->setOpacity(0.3f); | 999 layer1->SetOpacity(0.3f); |
| 1000 layer1->setPreserves3D(false); | 1000 layer1->SetPreserves3d(false); |
| 1001 | 1001 |
| 1002 EXPECT_FALSE(root->didDrawCalled()); | 1002 EXPECT_FALSE(root->didDrawCalled()); |
| 1003 EXPECT_FALSE(layer1->didDrawCalled()); | 1003 EXPECT_FALSE(layer1->didDrawCalled()); |
| 1004 EXPECT_FALSE(layer2->didDrawCalled()); | 1004 EXPECT_FALSE(layer2->didDrawCalled()); |
| 1005 | 1005 |
| 1006 LayerTreeHostImpl::FrameData frame; | 1006 LayerTreeHostImpl::FrameData frame; |
| 1007 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1007 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 1008 m_hostImpl->drawLayers(frame); | 1008 m_hostImpl->drawLayers(frame); |
| 1009 m_hostImpl->didDrawAllLayers(frame); | 1009 m_hostImpl->didDrawAllLayers(frame); |
| 1010 | 1010 |
| 1011 EXPECT_TRUE(root->didDrawCalled()); | 1011 EXPECT_TRUE(root->didDrawCalled()); |
| 1012 EXPECT_TRUE(layer1->didDrawCalled()); | 1012 EXPECT_TRUE(layer1->didDrawCalled()); |
| 1013 EXPECT_TRUE(layer2->didDrawCalled()); | 1013 EXPECT_TRUE(layer2->didDrawCalled()); |
| 1014 | 1014 |
| 1015 EXPECT_NE(root->renderSurface(), layer1->renderSurface()); | 1015 EXPECT_NE(root->render_surface(), layer1->render_surface()); |
| 1016 EXPECT_TRUE(!!layer1->renderSurface()); | 1016 EXPECT_TRUE(!!layer1->render_surface()); |
| 1017 } | 1017 } |
| 1018 | 1018 |
| 1019 class MissingTextureAnimatingLayer : public DidDrawCheckLayer { | 1019 class MissingTextureAnimatingLayer : public DidDrawCheckLayer { |
| 1020 public: | 1020 public: |
| 1021 static scoped_ptr<LayerImpl> create(LayerTreeImpl* treeImpl, int id, bool ti
leMissing, bool skipsDraw, bool animating, ResourceProvider* resourceProvider) | 1021 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* treeImpl, int id, bool ti
leMissing, bool skipsDraw, bool animating, ResourceProvider* resourceProvider) |
| 1022 { | 1022 { |
| 1023 return scoped_ptr<LayerImpl>(new MissingTextureAnimatingLayer(treeImpl,
id, tileMissing, skipsDraw, animating, resourceProvider)); | 1023 return scoped_ptr<LayerImpl>(new MissingTextureAnimatingLayer(treeImpl,
id, tileMissing, skipsDraw, animating, resourceProvider)); |
| 1024 } | 1024 } |
| 1025 | 1025 |
| 1026 private: | 1026 private: |
| 1027 MissingTextureAnimatingLayer(LayerTreeImpl* treeImpl, int id, bool tileMissi
ng, bool skipsDraw, bool animating, ResourceProvider* resourceProvider) | 1027 MissingTextureAnimatingLayer(LayerTreeImpl* treeImpl, int id, bool tileMissi
ng, bool skipsDraw, bool animating, ResourceProvider* resourceProvider) |
| 1028 : DidDrawCheckLayer(treeImpl, id) | 1028 : DidDrawCheckLayer(treeImpl, id) |
| 1029 { | 1029 { |
| 1030 scoped_ptr<LayerTilingData> tilingData = LayerTilingData::create(gfx::Si
ze(10, 10), LayerTilingData::NoBorderTexels); | 1030 scoped_ptr<LayerTilingData> tilingData = LayerTilingData::create(gfx::Si
ze(10, 10), LayerTilingData::NoBorderTexels); |
| 1031 tilingData->setBounds(bounds()); | 1031 tilingData->setBounds(bounds()); |
| 1032 setTilingData(*tilingData.get()); | 1032 setTilingData(*tilingData.get()); |
| 1033 setSkipsDraw(skipsDraw); | 1033 setSkipsDraw(skipsDraw); |
| 1034 if (!tileMissing) { | 1034 if (!tileMissing) { |
| 1035 ResourceProvider::ResourceId resource = resourceProvider->CreateReso
urce(gfx::Size(), GL_RGBA, ResourceProvider::TextureUsageAny); | 1035 ResourceProvider::ResourceId resource = resourceProvider->CreateReso
urce(gfx::Size(), GL_RGBA, ResourceProvider::TextureUsageAny); |
| 1036 resourceProvider->AllocateForTesting(resource); | 1036 resourceProvider->AllocateForTesting(resource); |
| 1037 pushTileProperties(0, 0, resource, gfx::Rect(), false); | 1037 pushTileProperties(0, 0, resource, gfx::Rect(), false); |
| 1038 } | 1038 } |
| 1039 if (animating) | 1039 if (animating) |
| 1040 addAnimatedTransformToLayer(*this, 10, 3, 0); | 1040 addAnimatedTransformToLayer(*this, 10, 3, 0); |
| 1041 } | 1041 } |
| 1042 }; | 1042 }; |
| 1043 | 1043 |
| 1044 TEST_F(LayerTreeHostImplTest, prepareToDrawFailsWhenAnimationUsesCheckerboard) | 1044 TEST_F(LayerTreeHostImplTest, prepareToDrawFailsWhenAnimationUsesCheckerboard) |
| 1045 { | 1045 { |
| 1046 // When the texture is not missing, we draw as usual. | 1046 // When the texture is not missing, we draw as usual. |
| 1047 m_hostImpl->activeTree()->SetRootLayer(DidDrawCheckLayer::create(m_hostImpl-
>activeTree(), 1)); | 1047 m_hostImpl->activeTree()->SetRootLayer(DidDrawCheckLayer::Create(m_hostImpl-
>activeTree(), 1)); |
| 1048 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); | 1048 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); |
| 1049 root->addChild(MissingTextureAnimatingLayer::create(m_hostImpl->activeTree()
, 2, false, false, true, m_hostImpl->resourceProvider())); | 1049 root->AddChild(MissingTextureAnimatingLayer::Create(m_hostImpl->activeTree()
, 2, false, false, true, m_hostImpl->resourceProvider())); |
| 1050 | 1050 |
| 1051 LayerTreeHostImpl::FrameData frame; | 1051 LayerTreeHostImpl::FrameData frame; |
| 1052 | 1052 |
| 1053 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1053 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 1054 m_hostImpl->drawLayers(frame); | 1054 m_hostImpl->drawLayers(frame); |
| 1055 m_hostImpl->didDrawAllLayers(frame); | 1055 m_hostImpl->didDrawAllLayers(frame); |
| 1056 | 1056 |
| 1057 // When a texture is missing and we're not animating, we draw as usual with
checkerboarding. | 1057 // When a texture is missing and we're not animating, we draw as usual with
checkerboarding. |
| 1058 m_hostImpl->activeTree()->SetRootLayer(DidDrawCheckLayer::create(m_hostImpl-
>activeTree(), 3)); | 1058 m_hostImpl->activeTree()->SetRootLayer(DidDrawCheckLayer::Create(m_hostImpl-
>activeTree(), 3)); |
| 1059 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); | 1059 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); |
| 1060 root->addChild(MissingTextureAnimatingLayer::create(m_hostImpl->activeTree()
, 4, true, false, false, m_hostImpl->resourceProvider())); | 1060 root->AddChild(MissingTextureAnimatingLayer::Create(m_hostImpl->activeTree()
, 4, true, false, false, m_hostImpl->resourceProvider())); |
| 1061 | 1061 |
| 1062 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1062 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 1063 m_hostImpl->drawLayers(frame); | 1063 m_hostImpl->drawLayers(frame); |
| 1064 m_hostImpl->didDrawAllLayers(frame); | 1064 m_hostImpl->didDrawAllLayers(frame); |
| 1065 | 1065 |
| 1066 // When a texture is missing and we're animating, we don't want to draw anyt
hing. | 1066 // When a texture is missing and we're animating, we don't want to draw anyt
hing. |
| 1067 m_hostImpl->activeTree()->SetRootLayer(DidDrawCheckLayer::create(m_hostImpl-
>activeTree(), 5)); | 1067 m_hostImpl->activeTree()->SetRootLayer(DidDrawCheckLayer::Create(m_hostImpl-
>activeTree(), 5)); |
| 1068 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); | 1068 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); |
| 1069 root->addChild(MissingTextureAnimatingLayer::create(m_hostImpl->activeTree()
, 6, true, false, true, m_hostImpl->resourceProvider())); | 1069 root->AddChild(MissingTextureAnimatingLayer::Create(m_hostImpl->activeTree()
, 6, true, false, true, m_hostImpl->resourceProvider())); |
| 1070 | 1070 |
| 1071 EXPECT_FALSE(m_hostImpl->prepareToDraw(frame)); | 1071 EXPECT_FALSE(m_hostImpl->prepareToDraw(frame)); |
| 1072 m_hostImpl->drawLayers(frame); | 1072 m_hostImpl->drawLayers(frame); |
| 1073 m_hostImpl->didDrawAllLayers(frame); | 1073 m_hostImpl->didDrawAllLayers(frame); |
| 1074 | 1074 |
| 1075 // When the layer skips draw and we're animating, we still draw the frame. | 1075 // When the layer skips draw and we're animating, we still draw the frame. |
| 1076 m_hostImpl->activeTree()->SetRootLayer(DidDrawCheckLayer::create(m_hostImpl-
>activeTree(), 7)); | 1076 m_hostImpl->activeTree()->SetRootLayer(DidDrawCheckLayer::Create(m_hostImpl-
>activeTree(), 7)); |
| 1077 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); | 1077 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); |
| 1078 root->addChild(MissingTextureAnimatingLayer::create(m_hostImpl->activeTree()
, 8, false, true, true, m_hostImpl->resourceProvider())); | 1078 root->AddChild(MissingTextureAnimatingLayer::Create(m_hostImpl->activeTree()
, 8, false, true, true, m_hostImpl->resourceProvider())); |
| 1079 | 1079 |
| 1080 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1080 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 1081 m_hostImpl->drawLayers(frame); | 1081 m_hostImpl->drawLayers(frame); |
| 1082 m_hostImpl->didDrawAllLayers(frame); | 1082 m_hostImpl->didDrawAllLayers(frame); |
| 1083 } | 1083 } |
| 1084 | 1084 |
| 1085 TEST_F(LayerTreeHostImplTest, scrollRootIgnored) | 1085 TEST_F(LayerTreeHostImplTest, scrollRootIgnored) |
| 1086 { | 1086 { |
| 1087 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1); | 1087 scoped_ptr<LayerImpl> root = LayerImpl::Create(m_hostImpl->activeTree(), 1); |
| 1088 root->setScrollable(false); | 1088 root->SetScrollable(false); |
| 1089 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); | 1089 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
| 1090 initializeRendererAndDrawFrame(); | 1090 initializeRendererAndDrawFrame(); |
| 1091 | 1091 |
| 1092 // Scroll event is ignored because layer is not scrollable. | 1092 // Scroll event is ignored because layer is not scrollable. |
| 1093 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollIgnored); | 1093 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollIgnored); |
| 1094 EXPECT_FALSE(m_didRequestRedraw); | 1094 EXPECT_FALSE(m_didRequestRedraw); |
| 1095 EXPECT_FALSE(m_didRequestCommit); | 1095 EXPECT_FALSE(m_didRequestCommit); |
| 1096 } | 1096 } |
| 1097 | 1097 |
| 1098 TEST_F(LayerTreeHostImplTest, scrollNonScrollableRootWithTopControls) | 1098 TEST_F(LayerTreeHostImplTest, scrollNonScrollableRootWithTopControls) |
| 1099 { | 1099 { |
| 1100 LayerTreeSettings settings; | 1100 LayerTreeSettings settings; |
| 1101 settings.calculateTopControlsPosition = true; | 1101 settings.calculateTopControlsPosition = true; |
| 1102 settings.topControlsHeight = 50; | 1102 settings.topControlsHeight = 50; |
| 1103 | 1103 |
| 1104 m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy); | 1104 m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy); |
| 1105 m_hostImpl->initializeRenderer(createOutputSurface()); | 1105 m_hostImpl->initializeRenderer(createOutputSurface()); |
| 1106 m_hostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); | 1106 m_hostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); |
| 1107 | 1107 |
| 1108 gfx::Size layerSize(5, 5); | 1108 gfx::Size layerSize(5, 5); |
| 1109 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1); | 1109 scoped_ptr<LayerImpl> root = LayerImpl::Create(m_hostImpl->activeTree(), 1); |
| 1110 root->setScrollable(true); | 1110 root->SetScrollable(true); |
| 1111 root->setMaxScrollOffset(gfx::Vector2d(layerSize.width(), layerSize.height()
)); | 1111 root->SetMaxScrollOffset(gfx::Vector2d(layerSize.width(), layerSize.height()
)); |
| 1112 root->setBounds(layerSize); | 1112 root->SetBounds(layerSize); |
| 1113 root->setContentBounds(layerSize); | 1113 root->SetContentBounds(layerSize); |
| 1114 root->setPosition(gfx::PointF(0, 0)); | 1114 root->SetPosition(gfx::PointF(0, 0)); |
| 1115 root->setAnchorPoint(gfx::PointF(0, 0)); | 1115 root->SetAnchorPoint(gfx::PointF(0, 0)); |
| 1116 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); | 1116 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
| 1117 m_hostImpl->activeTree()->FindRootScrollLayer(); | 1117 m_hostImpl->activeTree()->FindRootScrollLayer(); |
| 1118 initializeRendererAndDrawFrame(); | 1118 initializeRendererAndDrawFrame(); |
| 1119 | 1119 |
| 1120 EXPECT_EQ(InputHandlerClient::ScrollIgnored, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); | 1120 EXPECT_EQ(InputHandlerClient::ScrollIgnored, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); |
| 1121 | 1121 |
| 1122 m_hostImpl->topControlsManager()->ScrollBegin(); | 1122 m_hostImpl->topControlsManager()->ScrollBegin(); |
| 1123 m_hostImpl->topControlsManager()->ScrollBy(gfx::Vector2dF(0, 50)); | 1123 m_hostImpl->topControlsManager()->ScrollBy(gfx::Vector2dF(0, 50)); |
| 1124 m_hostImpl->topControlsManager()->ScrollEnd(); | 1124 m_hostImpl->topControlsManager()->ScrollEnd(); |
| 1125 EXPECT_EQ(m_hostImpl->topControlsManager()->content_top_offset(), 0.f); | 1125 EXPECT_EQ(m_hostImpl->topControlsManager()->content_top_offset(), 0.f); |
| 1126 | 1126 |
| 1127 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); | 1127 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); |
| 1128 } | 1128 } |
| 1129 | 1129 |
| 1130 TEST_F(LayerTreeHostImplTest, scrollNonCompositedRoot) | 1130 TEST_F(LayerTreeHostImplTest, scrollNonCompositedRoot) |
| 1131 { | 1131 { |
| 1132 // Test the configuration where a non-composited root layer is embedded in a | 1132 // Test the configuration where a non-composited root layer is embedded in a |
| 1133 // scrollable outer layer. | 1133 // scrollable outer layer. |
| 1134 gfx::Size surfaceSize(10, 10); | 1134 gfx::Size surfaceSize(10, 10); |
| 1135 | 1135 |
| 1136 scoped_ptr<LayerImpl> contentLayer = LayerImpl::create(m_hostImpl->activeTre
e(), 1); | 1136 scoped_ptr<LayerImpl> contentLayer = LayerImpl::Create(m_hostImpl->activeTre
e(), 1); |
| 1137 contentLayer->setDrawsContent(true); | 1137 contentLayer->SetDrawsContent(true); |
| 1138 contentLayer->setPosition(gfx::PointF(0, 0)); | 1138 contentLayer->SetPosition(gfx::PointF(0, 0)); |
| 1139 contentLayer->setAnchorPoint(gfx::PointF(0, 0)); | 1139 contentLayer->SetAnchorPoint(gfx::PointF(0, 0)); |
| 1140 contentLayer->setBounds(surfaceSize); | 1140 contentLayer->SetBounds(surfaceSize); |
| 1141 contentLayer->setContentBounds(gfx::Size(surfaceSize.width() * 2, surfaceSiz
e.height() * 2)); | 1141 contentLayer->SetContentBounds(gfx::Size(surfaceSize.width() * 2, surfaceSiz
e.height() * 2)); |
| 1142 contentLayer->setContentsScale(2, 2); | 1142 contentLayer->SetContentsScale(2, 2); |
| 1143 | 1143 |
| 1144 scoped_ptr<LayerImpl> scrollLayer = LayerImpl::create(m_hostImpl->activeTree
(), 2); | 1144 scoped_ptr<LayerImpl> scrollLayer = LayerImpl::Create(m_hostImpl->activeTree
(), 2); |
| 1145 scrollLayer->setScrollable(true); | 1145 scrollLayer->SetScrollable(true); |
| 1146 scrollLayer->setMaxScrollOffset(gfx::Vector2d(surfaceSize.width(), surfaceSi
ze.height())); | 1146 scrollLayer->SetMaxScrollOffset(gfx::Vector2d(surfaceSize.width(), surfaceSi
ze.height())); |
| 1147 scrollLayer->setBounds(surfaceSize); | 1147 scrollLayer->SetBounds(surfaceSize); |
| 1148 scrollLayer->setContentBounds(surfaceSize); | 1148 scrollLayer->SetContentBounds(surfaceSize); |
| 1149 scrollLayer->setPosition(gfx::PointF(0, 0)); | 1149 scrollLayer->SetPosition(gfx::PointF(0, 0)); |
| 1150 scrollLayer->setAnchorPoint(gfx::PointF(0, 0)); | 1150 scrollLayer->SetAnchorPoint(gfx::PointF(0, 0)); |
| 1151 scrollLayer->addChild(contentLayer.Pass()); | 1151 scrollLayer->AddChild(contentLayer.Pass()); |
| 1152 | 1152 |
| 1153 m_hostImpl->activeTree()->SetRootLayer(scrollLayer.Pass()); | 1153 m_hostImpl->activeTree()->SetRootLayer(scrollLayer.Pass()); |
| 1154 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1154 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
| 1155 initializeRendererAndDrawFrame(); | 1155 initializeRendererAndDrawFrame(); |
| 1156 | 1156 |
| 1157 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 1157 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
| 1158 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 1158 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
| 1159 m_hostImpl->scrollEnd(); | 1159 m_hostImpl->scrollEnd(); |
| 1160 EXPECT_TRUE(m_didRequestRedraw); | 1160 EXPECT_TRUE(m_didRequestRedraw); |
| 1161 EXPECT_TRUE(m_didRequestCommit); | 1161 EXPECT_TRUE(m_didRequestCommit); |
| 1162 } | 1162 } |
| 1163 | 1163 |
| 1164 TEST_F(LayerTreeHostImplTest, scrollChildCallsCommitAndRedraw) | 1164 TEST_F(LayerTreeHostImplTest, scrollChildCallsCommitAndRedraw) |
| 1165 { | 1165 { |
| 1166 gfx::Size surfaceSize(10, 10); | 1166 gfx::Size surfaceSize(10, 10); |
| 1167 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1); | 1167 scoped_ptr<LayerImpl> root = LayerImpl::Create(m_hostImpl->activeTree(), 1); |
| 1168 root->setBounds(surfaceSize); | 1168 root->SetBounds(surfaceSize); |
| 1169 root->setContentBounds(surfaceSize); | 1169 root->SetContentBounds(surfaceSize); |
| 1170 root->addChild(createScrollableLayer(2, surfaceSize)); | 1170 root->AddChild(createScrollableLayer(2, surfaceSize)); |
| 1171 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); | 1171 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
| 1172 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1172 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
| 1173 initializeRendererAndDrawFrame(); | 1173 initializeRendererAndDrawFrame(); |
| 1174 | 1174 |
| 1175 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 1175 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
| 1176 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 1176 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
| 1177 m_hostImpl->scrollEnd(); | 1177 m_hostImpl->scrollEnd(); |
| 1178 EXPECT_TRUE(m_didRequestRedraw); | 1178 EXPECT_TRUE(m_didRequestRedraw); |
| 1179 EXPECT_TRUE(m_didRequestCommit); | 1179 EXPECT_TRUE(m_didRequestCommit); |
| 1180 } | 1180 } |
| 1181 | 1181 |
| 1182 TEST_F(LayerTreeHostImplTest, scrollMissesChild) | 1182 TEST_F(LayerTreeHostImplTest, scrollMissesChild) |
| 1183 { | 1183 { |
| 1184 gfx::Size surfaceSize(10, 10); | 1184 gfx::Size surfaceSize(10, 10); |
| 1185 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1); | 1185 scoped_ptr<LayerImpl> root = LayerImpl::Create(m_hostImpl->activeTree(), 1); |
| 1186 root->addChild(createScrollableLayer(2, surfaceSize)); | 1186 root->AddChild(createScrollableLayer(2, surfaceSize)); |
| 1187 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); | 1187 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
| 1188 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1188 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
| 1189 initializeRendererAndDrawFrame(); | 1189 initializeRendererAndDrawFrame(); |
| 1190 | 1190 |
| 1191 // Scroll event is ignored because the input coordinate is outside the layer
boundaries. | 1191 // Scroll event is ignored because the input coordinate is outside the layer
boundaries. |
| 1192 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(15, 5), InputHandlerClient::Whe
el), InputHandlerClient::ScrollIgnored); | 1192 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(15, 5), InputHandlerClient::Whe
el), InputHandlerClient::ScrollIgnored); |
| 1193 EXPECT_FALSE(m_didRequestRedraw); | 1193 EXPECT_FALSE(m_didRequestRedraw); |
| 1194 EXPECT_FALSE(m_didRequestCommit); | 1194 EXPECT_FALSE(m_didRequestCommit); |
| 1195 } | 1195 } |
| 1196 | 1196 |
| 1197 TEST_F(LayerTreeHostImplTest, scrollMissesBackfacingChild) | 1197 TEST_F(LayerTreeHostImplTest, scrollMissesBackfacingChild) |
| 1198 { | 1198 { |
| 1199 gfx::Size surfaceSize(10, 10); | 1199 gfx::Size surfaceSize(10, 10); |
| 1200 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1); | 1200 scoped_ptr<LayerImpl> root = LayerImpl::Create(m_hostImpl->activeTree(), 1); |
| 1201 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); | 1201 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); |
| 1202 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1202 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
| 1203 | 1203 |
| 1204 gfx::Transform matrix; | 1204 gfx::Transform matrix; |
| 1205 matrix.RotateAboutXAxis(180); | 1205 matrix.RotateAboutXAxis(180); |
| 1206 child->setTransform(matrix); | 1206 child->SetTransform(matrix); |
| 1207 child->setDoubleSided(false); | 1207 child->SetDoubleSided(false); |
| 1208 | 1208 |
| 1209 root->addChild(child.Pass()); | 1209 root->AddChild(child.Pass()); |
| 1210 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); | 1210 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
| 1211 initializeRendererAndDrawFrame(); | 1211 initializeRendererAndDrawFrame(); |
| 1212 | 1212 |
| 1213 // Scroll event is ignored because the scrollable layer is not facing the vi
ewer and there is | 1213 // Scroll event is ignored because the scrollable layer is not facing the vi
ewer and there is |
| 1214 // nothing scrollable behind it. | 1214 // nothing scrollable behind it. |
| 1215 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollIgnored); | 1215 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollIgnored); |
| 1216 EXPECT_FALSE(m_didRequestRedraw); | 1216 EXPECT_FALSE(m_didRequestRedraw); |
| 1217 EXPECT_FALSE(m_didRequestCommit); | 1217 EXPECT_FALSE(m_didRequestCommit); |
| 1218 } | 1218 } |
| 1219 | 1219 |
| 1220 TEST_F(LayerTreeHostImplTest, scrollBlockedByContentLayer) | 1220 TEST_F(LayerTreeHostImplTest, scrollBlockedByContentLayer) |
| 1221 { | 1221 { |
| 1222 gfx::Size surfaceSize(10, 10); | 1222 gfx::Size surfaceSize(10, 10); |
| 1223 scoped_ptr<LayerImpl> contentLayer = createScrollableLayer(1, surfaceSize); | 1223 scoped_ptr<LayerImpl> contentLayer = createScrollableLayer(1, surfaceSize); |
| 1224 contentLayer->setShouldScrollOnMainThread(true); | 1224 contentLayer->SetShouldScrollOnMainThread(true); |
| 1225 contentLayer->setScrollable(false); | 1225 contentLayer->SetScrollable(false); |
| 1226 | 1226 |
| 1227 scoped_ptr<LayerImpl> scrollLayer = createScrollableLayer(2, surfaceSize); | 1227 scoped_ptr<LayerImpl> scrollLayer = createScrollableLayer(2, surfaceSize); |
| 1228 scrollLayer->addChild(contentLayer.Pass()); | 1228 scrollLayer->AddChild(contentLayer.Pass()); |
| 1229 | 1229 |
| 1230 m_hostImpl->activeTree()->SetRootLayer(scrollLayer.Pass()); | 1230 m_hostImpl->activeTree()->SetRootLayer(scrollLayer.Pass()); |
| 1231 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1231 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
| 1232 initializeRendererAndDrawFrame(); | 1232 initializeRendererAndDrawFrame(); |
| 1233 | 1233 |
| 1234 // Scrolling fails because the content layer is asking to be scrolled on the
main thread. | 1234 // Scrolling fails because the content layer is asking to be scrolled on the
main thread. |
| 1235 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollOnMainThread); | 1235 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollOnMainThread); |
| 1236 } | 1236 } |
| 1237 | 1237 |
| 1238 TEST_F(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread) | 1238 TEST_F(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread) |
| 1239 { | 1239 { |
| 1240 gfx::Size surfaceSize(10, 10); | 1240 gfx::Size surfaceSize(10, 10); |
| 1241 float pageScale = 2; | 1241 float pageScale = 2; |
| 1242 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); | 1242 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); |
| 1243 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); | 1243 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
| 1244 m_hostImpl->activeTree()->DidBecomeActive(); | 1244 m_hostImpl->activeTree()->DidBecomeActive(); |
| 1245 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1245 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
| 1246 initializeRendererAndDrawFrame(); | 1246 initializeRendererAndDrawFrame(); |
| 1247 | 1247 |
| 1248 gfx::Vector2d scrollDelta(0, 10); | 1248 gfx::Vector2d scrollDelta(0, 10); |
| 1249 gfx::Vector2d expectedScrollDelta(scrollDelta); | 1249 gfx::Vector2d expectedScrollDelta(scrollDelta); |
| 1250 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); | 1250 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->max_scroll_offset()
); |
| 1251 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 1251 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
| 1252 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 1252 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
| 1253 m_hostImpl->scrollEnd(); | 1253 m_hostImpl->scrollEnd(); |
| 1254 | 1254 |
| 1255 // Set new page scale from main thread. | 1255 // Set new page scale from main thread. |
| 1256 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(pageScale, pageScale,
pageScale); | 1256 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(pageScale, pageScale,
pageScale); |
| 1257 | 1257 |
| 1258 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; | 1258 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; |
| 1259 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); | 1259 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); |
| 1260 | 1260 |
| 1261 // The scroll range should also have been updated. | 1261 // The scroll range should also have been updated. |
| 1262 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll); | 1262 EXPECT_EQ(m_hostImpl->rootLayer()->max_scroll_offset(), expectedMaxScroll); |
| 1263 | 1263 |
| 1264 // The page scale delta remains constant because the impl thread did not sca
le. | 1264 // The page scale delta remains constant because the impl thread did not sca
le. |
| 1265 // TODO: If possible, use gfx::Transform() or Skia equality functions. At | 1265 // TODO: If possible, use gfx::Transform() or Skia equality functions. At |
| 1266 // the moment we avoid that because skia does exact bit-wise equality | 1266 // the moment we avoid that because skia does exact bit-wise equality |
| 1267 // checking that does not consider -0 == +0. | 1267 // checking that does not consider -0 == +0. |
| 1268 // http://code.google.com/p/chromium/issues/detail?id=162747 | 1268 // http://code.google.com/p/chromium/issues/detail?id=162747 |
| 1269 EXPECT_EQ(1.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(0
, 0)); | 1269 EXPECT_EQ(1.0, m_hostImpl->rootLayer()->impl_transform().matrix().getDouble(
0, 0)); |
| 1270 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(0
, 1)); | 1270 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->impl_transform().matrix().getDouble(
0, 1)); |
| 1271 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(0
, 2)); | 1271 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->impl_transform().matrix().getDouble(
0, 2)); |
| 1272 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(0
, 3)); | 1272 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->impl_transform().matrix().getDouble(
0, 3)); |
| 1273 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(1
, 0)); | 1273 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->impl_transform().matrix().getDouble(
1, 0)); |
| 1274 EXPECT_EQ(1.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(1
, 1)); | 1274 EXPECT_EQ(1.0, m_hostImpl->rootLayer()->impl_transform().matrix().getDouble(
1, 1)); |
| 1275 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(1
, 2)); | 1275 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->impl_transform().matrix().getDouble(
1, 2)); |
| 1276 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(1
, 3)); | 1276 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->impl_transform().matrix().getDouble(
1, 3)); |
| 1277 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(2
, 0)); | 1277 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->impl_transform().matrix().getDouble(
2, 0)); |
| 1278 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(2
, 1)); | 1278 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->impl_transform().matrix().getDouble(
2, 1)); |
| 1279 EXPECT_EQ(1.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(2
, 2)); | 1279 EXPECT_EQ(1.0, m_hostImpl->rootLayer()->impl_transform().matrix().getDouble(
2, 2)); |
| 1280 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(2
, 3)); | 1280 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->impl_transform().matrix().getDouble(
2, 3)); |
| 1281 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(3
, 0)); | 1281 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->impl_transform().matrix().getDouble(
3, 0)); |
| 1282 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(3
, 1)); | 1282 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->impl_transform().matrix().getDouble(
3, 1)); |
| 1283 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(3
, 2)); | 1283 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->impl_transform().matrix().getDouble(
3, 2)); |
| 1284 EXPECT_EQ(1.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(3
, 3)); | 1284 EXPECT_EQ(1.0, m_hostImpl->rootLayer()->impl_transform().matrix().getDouble(
3, 3)); |
| 1285 } | 1285 } |
| 1286 | 1286 |
| 1287 TEST_F(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread) | 1287 TEST_F(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread) |
| 1288 { | 1288 { |
| 1289 gfx::Size surfaceSize(10, 10); | 1289 gfx::Size surfaceSize(10, 10); |
| 1290 float pageScale = 2; | 1290 float pageScale = 2; |
| 1291 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); | 1291 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); |
| 1292 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); | 1292 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
| 1293 m_hostImpl->activeTree()->DidBecomeActive(); | 1293 m_hostImpl->activeTree()->DidBecomeActive(); |
| 1294 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1294 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
| 1295 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(1, 1, pageScale); | 1295 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(1, 1, pageScale); |
| 1296 initializeRendererAndDrawFrame(); | 1296 initializeRendererAndDrawFrame(); |
| 1297 | 1297 |
| 1298 gfx::Vector2d scrollDelta(0, 10); | 1298 gfx::Vector2d scrollDelta(0, 10); |
| 1299 gfx::Vector2d expectedScrollDelta(scrollDelta); | 1299 gfx::Vector2d expectedScrollDelta(scrollDelta); |
| 1300 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); | 1300 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->max_scroll_offset()
); |
| 1301 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 1301 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
| 1302 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 1302 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
| 1303 m_hostImpl->scrollEnd(); | 1303 m_hostImpl->scrollEnd(); |
| 1304 | 1304 |
| 1305 // Set new page scale on impl thread by pinching. | 1305 // Set new page scale on impl thread by pinching. |
| 1306 m_hostImpl->pinchGestureBegin(); | 1306 m_hostImpl->pinchGestureBegin(); |
| 1307 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); | 1307 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); |
| 1308 m_hostImpl->pinchGestureEnd(); | 1308 m_hostImpl->pinchGestureEnd(); |
| 1309 drawOneFrame(); | 1309 drawOneFrame(); |
| 1310 | 1310 |
| 1311 // The scroll delta is not scaled because the main thread did not scale. | 1311 // The scroll delta is not scaled because the main thread did not scale. |
| 1312 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; | 1312 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; |
| 1313 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); | 1313 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); |
| 1314 | 1314 |
| 1315 // The scroll range should also have been updated. | 1315 // The scroll range should also have been updated. |
| 1316 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll); | 1316 EXPECT_EQ(m_hostImpl->rootLayer()->max_scroll_offset(), expectedMaxScroll); |
| 1317 | 1317 |
| 1318 // The page scale delta should match the new scale on the impl side. | 1318 // The page scale delta should match the new scale on the impl side. |
| 1319 gfx::Transform expectedScale; | 1319 gfx::Transform expectedScale; |
| 1320 expectedScale.Scale(pageScale, pageScale); | 1320 expectedScale.Scale(pageScale, pageScale); |
| 1321 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedScale); | 1321 EXPECT_EQ(m_hostImpl->rootLayer()->impl_transform(), expectedScale); |
| 1322 } | 1322 } |
| 1323 | 1323 |
| 1324 TEST_F(LayerTreeHostImplTest, pageScaleDeltaAppliedToRootScrollLayerOnly) | 1324 TEST_F(LayerTreeHostImplTest, pageScaleDeltaAppliedToRootScrollLayerOnly) |
| 1325 { | 1325 { |
| 1326 gfx::Size surfaceSize(10, 10); | 1326 gfx::Size surfaceSize(10, 10); |
| 1327 float defaultPageScale = 1; | 1327 float defaultPageScale = 1; |
| 1328 gfx::Transform defaultPageScaleMatrix; | 1328 gfx::Transform defaultPageScaleMatrix; |
| 1329 | 1329 |
| 1330 float newPageScale = 2; | 1330 float newPageScale = 2; |
| 1331 gfx::Transform newPageScaleMatrix; | 1331 gfx::Transform newPageScaleMatrix; |
| 1332 newPageScaleMatrix.Scale(newPageScale, newPageScale); | 1332 newPageScaleMatrix.Scale(newPageScale, newPageScale); |
| 1333 | 1333 |
| 1334 // Create a normal scrollable root layer and another scrollable child layer. | 1334 // Create a normal scrollable root layer and another scrollable child layer. |
| 1335 setupScrollAndContentsLayers(surfaceSize); | 1335 setupScrollAndContentsLayers(surfaceSize); |
| 1336 LayerImpl* root = m_hostImpl->rootLayer(); | 1336 LayerImpl* root = m_hostImpl->rootLayer(); |
| 1337 LayerImpl* child = root->children()[0]; | 1337 LayerImpl* child = root->children()[0]; |
| 1338 | 1338 |
| 1339 scoped_ptr<LayerImpl> scrollableChild = createScrollableLayer(3, surfaceSize
); | 1339 scoped_ptr<LayerImpl> scrollableChild = createScrollableLayer(3, surfaceSize
); |
| 1340 child->addChild(scrollableChild.Pass()); | 1340 child->AddChild(scrollableChild.Pass()); |
| 1341 LayerImpl* grandChild = child->children()[0]; | 1341 LayerImpl* grandChild = child->children()[0]; |
| 1342 | 1342 |
| 1343 // Set new page scale on impl thread by pinching. | 1343 // Set new page scale on impl thread by pinching. |
| 1344 m_hostImpl->pinchGestureBegin(); | 1344 m_hostImpl->pinchGestureBegin(); |
| 1345 m_hostImpl->pinchGestureUpdate(newPageScale, gfx::Point()); | 1345 m_hostImpl->pinchGestureUpdate(newPageScale, gfx::Point()); |
| 1346 m_hostImpl->pinchGestureEnd(); | 1346 m_hostImpl->pinchGestureEnd(); |
| 1347 drawOneFrame(); | 1347 drawOneFrame(); |
| 1348 | 1348 |
| 1349 // The page scale delta should only be applied to the scrollable root layer. | 1349 // The page scale delta should only be applied to the scrollable root layer. |
| 1350 EXPECT_EQ(root->implTransform(), newPageScaleMatrix); | 1350 EXPECT_EQ(root->impl_transform(), newPageScaleMatrix); |
| 1351 EXPECT_EQ(child->implTransform(), defaultPageScaleMatrix); | 1351 EXPECT_EQ(child->impl_transform(), defaultPageScaleMatrix); |
| 1352 EXPECT_EQ(grandChild->implTransform(), defaultPageScaleMatrix); | 1352 EXPECT_EQ(grandChild->impl_transform(), defaultPageScaleMatrix); |
| 1353 | 1353 |
| 1354 // Make sure all the layers are drawn with the page scale delta applied, i.e
., the page scale | 1354 // Make sure all the layers are drawn with the page scale delta applied, i.e
., the page scale |
| 1355 // delta on the root layer is applied hierarchically. | 1355 // delta on the root layer is applied hierarchically. |
| 1356 LayerTreeHostImpl::FrameData frame; | 1356 LayerTreeHostImpl::FrameData frame; |
| 1357 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1357 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 1358 m_hostImpl->drawLayers(frame); | 1358 m_hostImpl->drawLayers(frame); |
| 1359 m_hostImpl->didDrawAllLayers(frame); | 1359 m_hostImpl->didDrawAllLayers(frame); |
| 1360 | 1360 |
| 1361 EXPECT_EQ(root->drawTransform().matrix().getDouble(0, 0), newPageScale); | 1361 EXPECT_EQ(root->draw_transform().matrix().getDouble(0, 0), newPageScale); |
| 1362 EXPECT_EQ(root->drawTransform().matrix().getDouble(1, 1), newPageScale); | 1362 EXPECT_EQ(root->draw_transform().matrix().getDouble(1, 1), newPageScale); |
| 1363 EXPECT_EQ(child->drawTransform().matrix().getDouble(0, 0), newPageScale); | 1363 EXPECT_EQ(child->draw_transform().matrix().getDouble(0, 0), newPageScale); |
| 1364 EXPECT_EQ(child->drawTransform().matrix().getDouble(1, 1), newPageScale); | 1364 EXPECT_EQ(child->draw_transform().matrix().getDouble(1, 1), newPageScale); |
| 1365 EXPECT_EQ(grandChild->drawTransform().matrix().getDouble(0, 0), newPageScale
); | 1365 EXPECT_EQ(grandChild->draw_transform().matrix().getDouble(0, 0), newPageScal
e); |
| 1366 EXPECT_EQ(grandChild->drawTransform().matrix().getDouble(1, 1), newPageScale
); | 1366 EXPECT_EQ(grandChild->draw_transform().matrix().getDouble(1, 1), newPageScal
e); |
| 1367 } | 1367 } |
| 1368 | 1368 |
| 1369 TEST_F(LayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread) | 1369 TEST_F(LayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread) |
| 1370 { | 1370 { |
| 1371 gfx::Size surfaceSize(10, 10); | 1371 gfx::Size surfaceSize(10, 10); |
| 1372 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1); | 1372 scoped_ptr<LayerImpl> root = LayerImpl::Create(m_hostImpl->activeTree(), 1); |
| 1373 root->setBounds(surfaceSize); | 1373 root->SetBounds(surfaceSize); |
| 1374 root->setContentBounds(surfaceSize); | 1374 root->SetContentBounds(surfaceSize); |
| 1375 // Also mark the root scrollable so it becomes the root scroll layer. | 1375 // Also mark the root scrollable so it becomes the root scroll layer. |
| 1376 root->setScrollable(true); | 1376 root->SetScrollable(true); |
| 1377 int scrollLayerId = 2; | 1377 int scrollLayerId = 2; |
| 1378 root->addChild(createScrollableLayer(scrollLayerId, surfaceSize)); | 1378 root->AddChild(createScrollableLayer(scrollLayerId, surfaceSize)); |
| 1379 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); | 1379 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
| 1380 m_hostImpl->activeTree()->DidBecomeActive(); | 1380 m_hostImpl->activeTree()->DidBecomeActive(); |
| 1381 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1381 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
| 1382 initializeRendererAndDrawFrame(); | 1382 initializeRendererAndDrawFrame(); |
| 1383 | 1383 |
| 1384 LayerImpl* child = m_hostImpl->rootLayer()->children()[0]; | 1384 LayerImpl* child = m_hostImpl->rootLayer()->children()[0]; |
| 1385 | 1385 |
| 1386 gfx::Vector2d scrollDelta(0, 10); | 1386 gfx::Vector2d scrollDelta(0, 10); |
| 1387 gfx::Vector2d expectedScrollDelta(scrollDelta); | 1387 gfx::Vector2d expectedScrollDelta(scrollDelta); |
| 1388 gfx::Vector2d expectedMaxScroll(child->maxScrollOffset()); | 1388 gfx::Vector2d expectedMaxScroll(child->max_scroll_offset()); |
| 1389 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 1389 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
| 1390 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 1390 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
| 1391 m_hostImpl->scrollEnd(); | 1391 m_hostImpl->scrollEnd(); |
| 1392 | 1392 |
| 1393 float pageScale = 2; | 1393 float pageScale = 2; |
| 1394 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(pageScale, 1, pageScal
e); | 1394 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(pageScale, 1, pageScal
e); |
| 1395 | 1395 |
| 1396 drawOneFrame(); | 1396 drawOneFrame(); |
| 1397 | 1397 |
| 1398 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; | 1398 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; |
| 1399 expectContains(*scrollInfo.get(), scrollLayerId, expectedScrollDelta); | 1399 expectContains(*scrollInfo.get(), scrollLayerId, expectedScrollDelta); |
| 1400 | 1400 |
| 1401 // The scroll range should not have changed. | 1401 // The scroll range should not have changed. |
| 1402 EXPECT_EQ(child->maxScrollOffset(), expectedMaxScroll); | 1402 EXPECT_EQ(child->max_scroll_offset(), expectedMaxScroll); |
| 1403 | 1403 |
| 1404 // The page scale delta remains constant because the impl thread did not sca
le. | 1404 // The page scale delta remains constant because the impl thread did not sca
le. |
| 1405 gfx::Transform identityTransform; | 1405 gfx::Transform identityTransform; |
| 1406 EXPECT_EQ(child->implTransform(), gfx::Transform()); | 1406 EXPECT_EQ(child->impl_transform(), gfx::Transform()); |
| 1407 } | 1407 } |
| 1408 | 1408 |
| 1409 TEST_F(LayerTreeHostImplTest, scrollChildBeyondLimit) | 1409 TEST_F(LayerTreeHostImplTest, scrollChildBeyondLimit) |
| 1410 { | 1410 { |
| 1411 // Scroll a child layer beyond its maximum scroll range and make sure the | 1411 // Scroll a child layer beyond its maximum scroll range and make sure the |
| 1412 // parent layer is scrolled on the axis on which the child was unable to | 1412 // parent layer is scrolled on the axis on which the child was unable to |
| 1413 // scroll. | 1413 // scroll. |
| 1414 gfx::Size surfaceSize(10, 10); | 1414 gfx::Size surfaceSize(10, 10); |
| 1415 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); | 1415 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); |
| 1416 | 1416 |
| 1417 scoped_ptr<LayerImpl> grandChild = createScrollableLayer(3, surfaceSize); | 1417 scoped_ptr<LayerImpl> grandChild = createScrollableLayer(3, surfaceSize); |
| 1418 grandChild->setScrollOffset(gfx::Vector2d(0, 5)); | 1418 grandChild->SetScrollOffset(gfx::Vector2d(0, 5)); |
| 1419 | 1419 |
| 1420 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); | 1420 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); |
| 1421 child->setScrollOffset(gfx::Vector2d(3, 0)); | 1421 child->SetScrollOffset(gfx::Vector2d(3, 0)); |
| 1422 child->addChild(grandChild.Pass()); | 1422 child->AddChild(grandChild.Pass()); |
| 1423 | 1423 |
| 1424 root->addChild(child.Pass()); | 1424 root->AddChild(child.Pass()); |
| 1425 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); | 1425 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
| 1426 m_hostImpl->activeTree()->DidBecomeActive(); | 1426 m_hostImpl->activeTree()->DidBecomeActive(); |
| 1427 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1427 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
| 1428 initializeRendererAndDrawFrame(); | 1428 initializeRendererAndDrawFrame(); |
| 1429 { | 1429 { |
| 1430 gfx::Vector2d scrollDelta(-8, -7); | 1430 gfx::Vector2d scrollDelta(-8, -7); |
| 1431 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::
Wheel), InputHandlerClient::ScrollStarted); | 1431 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::
Wheel), InputHandlerClient::ScrollStarted); |
| 1432 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 1432 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
| 1433 m_hostImpl->scrollEnd(); | 1433 m_hostImpl->scrollEnd(); |
| 1434 | 1434 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1445 } | 1445 } |
| 1446 | 1446 |
| 1447 TEST_F(LayerTreeHostImplTest, scrollWithoutBubbling) | 1447 TEST_F(LayerTreeHostImplTest, scrollWithoutBubbling) |
| 1448 { | 1448 { |
| 1449 // Scroll a child layer beyond its maximum scroll range and make sure the | 1449 // Scroll a child layer beyond its maximum scroll range and make sure the |
| 1450 // the scroll doesn't bubble up to the parent layer. | 1450 // the scroll doesn't bubble up to the parent layer. |
| 1451 gfx::Size surfaceSize(10, 10); | 1451 gfx::Size surfaceSize(10, 10); |
| 1452 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); | 1452 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); |
| 1453 | 1453 |
| 1454 scoped_ptr<LayerImpl> grandChild = createScrollableLayer(3, surfaceSize); | 1454 scoped_ptr<LayerImpl> grandChild = createScrollableLayer(3, surfaceSize); |
| 1455 grandChild->setScrollOffset(gfx::Vector2d(0, 2)); | 1455 grandChild->SetScrollOffset(gfx::Vector2d(0, 2)); |
| 1456 | 1456 |
| 1457 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); | 1457 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); |
| 1458 child->setScrollOffset(gfx::Vector2d(0, 3)); | 1458 child->SetScrollOffset(gfx::Vector2d(0, 3)); |
| 1459 child->addChild(grandChild.Pass()); | 1459 child->AddChild(grandChild.Pass()); |
| 1460 | 1460 |
| 1461 root->addChild(child.Pass()); | 1461 root->AddChild(child.Pass()); |
| 1462 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); | 1462 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
| 1463 m_hostImpl->activeTree()->DidBecomeActive(); | 1463 m_hostImpl->activeTree()->DidBecomeActive(); |
| 1464 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1464 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
| 1465 initializeRendererAndDrawFrame(); | 1465 initializeRendererAndDrawFrame(); |
| 1466 { | 1466 { |
| 1467 gfx::Vector2d scrollDelta(0, -10); | 1467 gfx::Vector2d scrollDelta(0, -10); |
| 1468 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::
NonBubblingGesture), InputHandlerClient::ScrollStarted); | 1468 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::
NonBubblingGesture), InputHandlerClient::ScrollStarted); |
| 1469 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 1469 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
| 1470 m_hostImpl->scrollEnd(); | 1470 m_hostImpl->scrollEnd(); |
| 1471 | 1471 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1511 | 1511 |
| 1512 // The child should not have scrolled. | 1512 // The child should not have scrolled. |
| 1513 expectContains(*scrollInfo.get(), child->id(), gfx::Vector2d(0, -3)); | 1513 expectContains(*scrollInfo.get(), child->id(), gfx::Vector2d(0, -3)); |
| 1514 | 1514 |
| 1515 | 1515 |
| 1516 // Scrolling should be adjusted from viewport space. | 1516 // Scrolling should be adjusted from viewport space. |
| 1517 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(2, 2, 2); | 1517 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(2, 2, 2); |
| 1518 m_hostImpl->activeTree()->SetPageScaleDelta(1); | 1518 m_hostImpl->activeTree()->SetPageScaleDelta(1); |
| 1519 gfx::Transform scaleTransform; | 1519 gfx::Transform scaleTransform; |
| 1520 scaleTransform.Scale(2, 2); | 1520 scaleTransform.Scale(2, 2); |
| 1521 m_hostImpl->activeTree()->RootLayer()->setImplTransform(scaleTransform); | 1521 m_hostImpl->activeTree()->RootLayer()->SetImplTransform(scaleTransform); |
| 1522 | 1522 |
| 1523 scrollDelta = gfx::Vector2d(0, -2); | 1523 scrollDelta = gfx::Vector2d(0, -2); |
| 1524 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx
::Point(1, 1), InputHandlerClient::NonBubblingGesture)); | 1524 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx
::Point(1, 1), InputHandlerClient::NonBubblingGesture)); |
| 1525 EXPECT_EQ(grandChild, m_hostImpl->currentlyScrollingLayer()); | 1525 EXPECT_EQ(grandChild, m_hostImpl->currentlyScrollingLayer()); |
| 1526 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 1526 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
| 1527 m_hostImpl->scrollEnd(); | 1527 m_hostImpl->scrollEnd(); |
| 1528 | 1528 |
| 1529 scrollInfo = m_hostImpl->processScrollDeltas(); | 1529 scrollInfo = m_hostImpl->processScrollDeltas(); |
| 1530 | 1530 |
| 1531 // Should have scrolled by half the amount in layer space (5 - 2/2) | 1531 // Should have scrolled by half the amount in layer space (5 - 2/2) |
| 1532 expectContains(*scrollInfo.get(), grandChild->id(), gfx::Vector2d(0, 4))
; | 1532 expectContains(*scrollInfo.get(), grandChild->id(), gfx::Vector2d(0, 4))
; |
| 1533 } | 1533 } |
| 1534 } | 1534 } |
| 1535 | 1535 |
| 1536 TEST_F(LayerTreeHostImplTest, scrollEventBubbling) | 1536 TEST_F(LayerTreeHostImplTest, scrollEventBubbling) |
| 1537 { | 1537 { |
| 1538 // When we try to scroll a non-scrollable child layer, the scroll delta | 1538 // When we try to scroll a non-scrollable child layer, the scroll delta |
| 1539 // should be applied to one of its ancestors if possible. | 1539 // should be applied to one of its ancestors if possible. |
| 1540 gfx::Size surfaceSize(10, 10); | 1540 gfx::Size surfaceSize(10, 10); |
| 1541 gfx::Size contentSize(20, 20); | 1541 gfx::Size contentSize(20, 20); |
| 1542 scoped_ptr<LayerImpl> root = createScrollableLayer(1, contentSize); | 1542 scoped_ptr<LayerImpl> root = createScrollableLayer(1, contentSize); |
| 1543 scoped_ptr<LayerImpl> child = createScrollableLayer(2, contentSize); | 1543 scoped_ptr<LayerImpl> child = createScrollableLayer(2, contentSize); |
| 1544 | 1544 |
| 1545 child->setScrollable(false); | 1545 child->SetScrollable(false); |
| 1546 root->addChild(child.Pass()); | 1546 root->AddChild(child.Pass()); |
| 1547 | 1547 |
| 1548 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1548 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
| 1549 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); | 1549 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
| 1550 m_hostImpl->activeTree()->DidBecomeActive(); | 1550 m_hostImpl->activeTree()->DidBecomeActive(); |
| 1551 initializeRendererAndDrawFrame(); | 1551 initializeRendererAndDrawFrame(); |
| 1552 { | 1552 { |
| 1553 gfx::Vector2d scrollDelta(0, 4); | 1553 gfx::Vector2d scrollDelta(0, 4); |
| 1554 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::
Wheel), InputHandlerClient::ScrollStarted); | 1554 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::
Wheel), InputHandlerClient::ScrollStarted); |
| 1555 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 1555 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
| 1556 m_hostImpl->scrollEnd(); | 1556 m_hostImpl->scrollEnd(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1580 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 1580 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
| 1581 } | 1581 } |
| 1582 | 1582 |
| 1583 TEST_F(LayerTreeHostImplTest, scrollAxisAlignedRotatedLayer) | 1583 TEST_F(LayerTreeHostImplTest, scrollAxisAlignedRotatedLayer) |
| 1584 { | 1584 { |
| 1585 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 1585 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 1586 | 1586 |
| 1587 // Rotate the root layer 90 degrees counter-clockwise about its center. | 1587 // Rotate the root layer 90 degrees counter-clockwise about its center. |
| 1588 gfx::Transform rotateTransform; | 1588 gfx::Transform rotateTransform; |
| 1589 rotateTransform.Rotate(-90); | 1589 rotateTransform.Rotate(-90); |
| 1590 m_hostImpl->rootLayer()->setTransform(rotateTransform); | 1590 m_hostImpl->rootLayer()->SetTransform(rotateTransform); |
| 1591 | 1591 |
| 1592 gfx::Size surfaceSize(50, 50); | 1592 gfx::Size surfaceSize(50, 50); |
| 1593 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1593 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
| 1594 initializeRendererAndDrawFrame(); | 1594 initializeRendererAndDrawFrame(); |
| 1595 | 1595 |
| 1596 // Scroll to the right in screen coordinates with a gesture. | 1596 // Scroll to the right in screen coordinates with a gesture. |
| 1597 gfx::Vector2d gestureScrollDelta(10, 0); | 1597 gfx::Vector2d gestureScrollDelta(10, 0); |
| 1598 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gest
ure), InputHandlerClient::ScrollStarted); | 1598 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gest
ure), InputHandlerClient::ScrollStarted); |
| 1599 m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta); | 1599 m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta); |
| 1600 m_hostImpl->scrollEnd(); | 1600 m_hostImpl->scrollEnd(); |
| 1601 | 1601 |
| 1602 // The layer should have scrolled down in its local coordinates. | 1602 // The layer should have scrolled down in its local coordinates. |
| 1603 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; | 1603 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; |
| 1604 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), gfx::Vector
2d(0, gestureScrollDelta.x())); | 1604 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), gfx::Vector
2d(0, gestureScrollDelta.x())); |
| 1605 | 1605 |
| 1606 // Reset and scroll down with the wheel. | 1606 // Reset and scroll down with the wheel. |
| 1607 m_hostImpl->rootLayer()->setScrollDelta(gfx::Vector2dF()); | 1607 m_hostImpl->rootLayer()->SetScrollDelta(gfx::Vector2dF()); |
| 1608 gfx::Vector2d wheelScrollDelta(0, 10); | 1608 gfx::Vector2d wheelScrollDelta(0, 10); |
| 1609 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 1609 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
| 1610 m_hostImpl->scrollBy(gfx::Point(), wheelScrollDelta); | 1610 m_hostImpl->scrollBy(gfx::Point(), wheelScrollDelta); |
| 1611 m_hostImpl->scrollEnd(); | 1611 m_hostImpl->scrollEnd(); |
| 1612 | 1612 |
| 1613 // The layer should have scrolled down in its local coordinates. | 1613 // The layer should have scrolled down in its local coordinates. |
| 1614 scrollInfo = m_hostImpl->processScrollDeltas(); | 1614 scrollInfo = m_hostImpl->processScrollDeltas(); |
| 1615 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), wheelScroll
Delta); | 1615 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), wheelScroll
Delta); |
| 1616 } | 1616 } |
| 1617 | 1617 |
| 1618 TEST_F(LayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer) | 1618 TEST_F(LayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer) |
| 1619 { | 1619 { |
| 1620 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 1620 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 1621 int childLayerId = 3; | 1621 int childLayerId = 3; |
| 1622 float childLayerAngle = -20; | 1622 float childLayerAngle = -20; |
| 1623 | 1623 |
| 1624 // Create a child layer that is rotated to a non-axis-aligned angle. | 1624 // Create a child layer that is rotated to a non-axis-aligned angle. |
| 1625 scoped_ptr<LayerImpl> child = createScrollableLayer(childLayerId, m_hostImpl
->rootLayer()->contentBounds()); | 1625 scoped_ptr<LayerImpl> child = createScrollableLayer(childLayerId, m_hostImpl
->rootLayer()->content_bounds()); |
| 1626 gfx::Transform rotateTransform; | 1626 gfx::Transform rotateTransform; |
| 1627 rotateTransform.Translate(-50, -50); | 1627 rotateTransform.Translate(-50, -50); |
| 1628 rotateTransform.Rotate(childLayerAngle); | 1628 rotateTransform.Rotate(childLayerAngle); |
| 1629 rotateTransform.Translate(50, 50); | 1629 rotateTransform.Translate(50, 50); |
| 1630 child->setTransform(rotateTransform); | 1630 child->SetTransform(rotateTransform); |
| 1631 | 1631 |
| 1632 // Only allow vertical scrolling. | 1632 // Only allow vertical scrolling. |
| 1633 child->setMaxScrollOffset(gfx::Vector2d(0, child->contentBounds().height()))
; | 1633 child->SetMaxScrollOffset(gfx::Vector2d(0, child->content_bounds().height())
); |
| 1634 m_hostImpl->rootLayer()->addChild(child.Pass()); | 1634 m_hostImpl->rootLayer()->AddChild(child.Pass()); |
| 1635 | 1635 |
| 1636 gfx::Size surfaceSize(50, 50); | 1636 gfx::Size surfaceSize(50, 50); |
| 1637 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1637 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
| 1638 initializeRendererAndDrawFrame(); | 1638 initializeRendererAndDrawFrame(); |
| 1639 | 1639 |
| 1640 { | 1640 { |
| 1641 // Scroll down in screen coordinates with a gesture. | 1641 // Scroll down in screen coordinates with a gesture. |
| 1642 gfx::Vector2d gestureScrollDelta(0, 10); | 1642 gfx::Vector2d gestureScrollDelta(0, 10); |
| 1643 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::
Gesture), InputHandlerClient::ScrollStarted); | 1643 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::
Gesture), InputHandlerClient::ScrollStarted); |
| 1644 m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta); | 1644 m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta); |
| 1645 m_hostImpl->scrollEnd(); | 1645 m_hostImpl->scrollEnd(); |
| 1646 | 1646 |
| 1647 // The child layer should have scrolled down in its local coordinates an
amount proportional to | 1647 // The child layer should have scrolled down in its local coordinates an
amount proportional to |
| 1648 // the angle between it and the input scroll delta. | 1648 // the angle between it and the input scroll delta. |
| 1649 gfx::Vector2d expectedScrollDelta(0, gestureScrollDelta.y() * std::cos(M
athUtil::Deg2Rad(childLayerAngle))); | 1649 gfx::Vector2d expectedScrollDelta(0, gestureScrollDelta.y() * std::cos(M
athUtil::Deg2Rad(childLayerAngle))); |
| 1650 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 1650 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
| 1651 expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta); | 1651 expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta); |
| 1652 | 1652 |
| 1653 // The root layer should not have scrolled, because the input delta was
close to the layer's | 1653 // The root layer should not have scrolled, because the input delta was
close to the layer's |
| 1654 // axis of movement. | 1654 // axis of movement. |
| 1655 EXPECT_EQ(scrollInfo->scrolls.size(), 1u); | 1655 EXPECT_EQ(scrollInfo->scrolls.size(), 1u); |
| 1656 } | 1656 } |
| 1657 | 1657 |
| 1658 { | 1658 { |
| 1659 // Now reset and scroll the same amount horizontally. | 1659 // Now reset and scroll the same amount horizontally. |
| 1660 m_hostImpl->rootLayer()->children()[1]->setScrollDelta(gfx::Vector2dF())
; | 1660 m_hostImpl->rootLayer()->children()[1]->SetScrollDelta(gfx::Vector2dF())
; |
| 1661 gfx::Vector2d gestureScrollDelta(10, 0); | 1661 gfx::Vector2d gestureScrollDelta(10, 0); |
| 1662 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::
Gesture), InputHandlerClient::ScrollStarted); | 1662 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::
Gesture), InputHandlerClient::ScrollStarted); |
| 1663 m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta); | 1663 m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta); |
| 1664 m_hostImpl->scrollEnd(); | 1664 m_hostImpl->scrollEnd(); |
| 1665 | 1665 |
| 1666 // The child layer should have scrolled down in its local coordinates an
amount proportional to | 1666 // The child layer should have scrolled down in its local coordinates an
amount proportional to |
| 1667 // the angle between it and the input scroll delta. | 1667 // the angle between it and the input scroll delta. |
| 1668 gfx::Vector2d expectedScrollDelta(0, -gestureScrollDelta.x() * std::sin(
MathUtil::Deg2Rad(childLayerAngle))); | 1668 gfx::Vector2d expectedScrollDelta(0, -gestureScrollDelta.x() * std::sin(
MathUtil::Deg2Rad(childLayerAngle))); |
| 1669 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 1669 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
| 1670 expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta); | 1670 expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta); |
| 1671 | 1671 |
| 1672 // The root layer should have scrolled more, since the input scroll delt
a was mostly | 1672 // The root layer should have scrolled more, since the input scroll delt
a was mostly |
| 1673 // orthogonal to the child layer's vertical scroll axis. | 1673 // orthogonal to the child layer's vertical scroll axis. |
| 1674 gfx::Vector2d expectedRootScrollDelta(gestureScrollDelta.x() * std::pow(
std::cos(MathUtil::Deg2Rad(childLayerAngle)), 2), 0); | 1674 gfx::Vector2d expectedRootScrollDelta(gestureScrollDelta.x() * std::pow(
std::cos(MathUtil::Deg2Rad(childLayerAngle)), 2), 0); |
| 1675 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expecte
dRootScrollDelta); | 1675 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expecte
dRootScrollDelta); |
| 1676 } | 1676 } |
| 1677 } | 1677 } |
| 1678 | 1678 |
| 1679 TEST_F(LayerTreeHostImplTest, scrollScaledLayer) | 1679 TEST_F(LayerTreeHostImplTest, scrollScaledLayer) |
| 1680 { | 1680 { |
| 1681 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 1681 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 1682 | 1682 |
| 1683 // Scale the layer to twice its normal size. | 1683 // Scale the layer to twice its normal size. |
| 1684 int scale = 2; | 1684 int scale = 2; |
| 1685 gfx::Transform scaleTransform; | 1685 gfx::Transform scaleTransform; |
| 1686 scaleTransform.Scale(scale, scale); | 1686 scaleTransform.Scale(scale, scale); |
| 1687 m_hostImpl->rootLayer()->setTransform(scaleTransform); | 1687 m_hostImpl->rootLayer()->SetTransform(scaleTransform); |
| 1688 | 1688 |
| 1689 gfx::Size surfaceSize(50, 50); | 1689 gfx::Size surfaceSize(50, 50); |
| 1690 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1690 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
| 1691 initializeRendererAndDrawFrame(); | 1691 initializeRendererAndDrawFrame(); |
| 1692 | 1692 |
| 1693 // Scroll down in screen coordinates with a gesture. | 1693 // Scroll down in screen coordinates with a gesture. |
| 1694 gfx::Vector2d scrollDelta(0, 10); | 1694 gfx::Vector2d scrollDelta(0, 10); |
| 1695 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gest
ure), InputHandlerClient::ScrollStarted); | 1695 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gest
ure), InputHandlerClient::ScrollStarted); |
| 1696 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 1696 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
| 1697 m_hostImpl->scrollEnd(); | 1697 m_hostImpl->scrollEnd(); |
| 1698 | 1698 |
| 1699 // The layer should have scrolled down in its local coordinates, but half he
amount. | 1699 // The layer should have scrolled down in its local coordinates, but half he
amount. |
| 1700 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; | 1700 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; |
| 1701 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), gfx::Vector
2d(0, scrollDelta.y() / scale)); | 1701 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), gfx::Vector
2d(0, scrollDelta.y() / scale)); |
| 1702 | 1702 |
| 1703 // Reset and scroll down with the wheel. | 1703 // Reset and scroll down with the wheel. |
| 1704 m_hostImpl->rootLayer()->setScrollDelta(gfx::Vector2dF()); | 1704 m_hostImpl->rootLayer()->SetScrollDelta(gfx::Vector2dF()); |
| 1705 gfx::Vector2d wheelScrollDelta(0, 10); | 1705 gfx::Vector2d wheelScrollDelta(0, 10); |
| 1706 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 1706 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
| 1707 m_hostImpl->scrollBy(gfx::Point(), wheelScrollDelta); | 1707 m_hostImpl->scrollBy(gfx::Point(), wheelScrollDelta); |
| 1708 m_hostImpl->scrollEnd(); | 1708 m_hostImpl->scrollEnd(); |
| 1709 | 1709 |
| 1710 // The scale should not have been applied to the scroll delta. | 1710 // The scale should not have been applied to the scroll delta. |
| 1711 scrollInfo = m_hostImpl->processScrollDeltas(); | 1711 scrollInfo = m_hostImpl->processScrollDeltas(); |
| 1712 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), wheelScroll
Delta); | 1712 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), wheelScroll
Delta); |
| 1713 } | 1713 } |
| 1714 | 1714 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1729 } | 1729 } |
| 1730 | 1730 |
| 1731 bool blend() const { return m_blend; } | 1731 bool blend() const { return m_blend; } |
| 1732 | 1732 |
| 1733 private: | 1733 private: |
| 1734 bool m_blend; | 1734 bool m_blend; |
| 1735 }; | 1735 }; |
| 1736 | 1736 |
| 1737 class BlendStateCheckLayer : public LayerImpl { | 1737 class BlendStateCheckLayer : public LayerImpl { |
| 1738 public: | 1738 public: |
| 1739 static scoped_ptr<LayerImpl> create(LayerTreeImpl* treeImpl, int id, Resourc
eProvider* resourceProvider) { return scoped_ptr<LayerImpl>(new BlendStateCheckL
ayer(treeImpl, id, resourceProvider)); } | 1739 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* treeImpl, int id, Resourc
eProvider* resourceProvider) { return scoped_ptr<LayerImpl>(new BlendStateCheckL
ayer(treeImpl, id, resourceProvider)); } |
| 1740 | 1740 |
| 1741 virtual void appendQuads(QuadSink& quadSink, AppendQuadsData& appendQuadsDat
a) OVERRIDE | 1741 virtual void AppendQuads(QuadSink* quadSink, AppendQuadsData* appendQuadsDat
a) OVERRIDE |
| 1742 { | 1742 { |
| 1743 m_quadsAppended = true; | 1743 m_quadsAppended = true; |
| 1744 | 1744 |
| 1745 gfx::Rect opaqueRect; | 1745 gfx::Rect opaqueRect; |
| 1746 if (contentsOpaque()) | 1746 if (contents_opaque()) |
| 1747 opaqueRect = m_quadRect; | 1747 opaqueRect = m_quadRect; |
| 1748 else | 1748 else |
| 1749 opaqueRect = m_opaqueContentRect; | 1749 opaqueRect = m_opaqueContentRect; |
| 1750 | 1750 |
| 1751 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSha
redQuadState()); | 1751 SharedQuadState* sharedQuadState = quadSink->useSharedQuadState(CreateSh
aredQuadState()); |
| 1752 scoped_ptr<TileDrawQuad> testBlendingDrawQuad = TileDrawQuad::Create(); | 1752 scoped_ptr<TileDrawQuad> testBlendingDrawQuad = TileDrawQuad::Create(); |
| 1753 testBlendingDrawQuad->SetNew(sharedQuadState, m_quadRect, opaqueRect, m_
resourceId, gfx::RectF(0, 0, 1, 1), gfx::Size(1, 1), false); | 1753 testBlendingDrawQuad->SetNew(sharedQuadState, m_quadRect, opaqueRect, m_
resourceId, gfx::RectF(0, 0, 1, 1), gfx::Size(1, 1), false); |
| 1754 testBlendingDrawQuad->visible_rect = m_quadVisibleRect; | 1754 testBlendingDrawQuad->visible_rect = m_quadVisibleRect; |
| 1755 EXPECT_EQ(m_blend, testBlendingDrawQuad->ShouldDrawWithBlending()); | 1755 EXPECT_EQ(m_blend, testBlendingDrawQuad->ShouldDrawWithBlending()); |
| 1756 EXPECT_EQ(m_hasRenderSurface, !!renderSurface()); | 1756 EXPECT_EQ(m_hasRenderSurface, !!render_surface()); |
| 1757 quadSink.append(testBlendingDrawQuad.PassAs<DrawQuad>(), appendQuadsData
); | 1757 quadSink->append(testBlendingDrawQuad.PassAs<DrawQuad>(), appendQuadsDat
a); |
| 1758 } | 1758 } |
| 1759 | 1759 |
| 1760 void setExpectation(bool blend, bool hasRenderSurface) | 1760 void setExpectation(bool blend, bool hasRenderSurface) |
| 1761 { | 1761 { |
| 1762 m_blend = blend; | 1762 m_blend = blend; |
| 1763 m_hasRenderSurface = hasRenderSurface; | 1763 m_hasRenderSurface = hasRenderSurface; |
| 1764 m_quadsAppended = false; | 1764 m_quadsAppended = false; |
| 1765 } | 1765 } |
| 1766 | 1766 |
| 1767 bool quadsAppended() const { return m_quadsAppended; } | 1767 bool quadsAppended() const { return m_quadsAppended; } |
| 1768 | 1768 |
| 1769 void setQuadRect(const gfx::Rect& rect) { m_quadRect = rect; } | 1769 void setQuadRect(const gfx::Rect& rect) { m_quadRect = rect; } |
| 1770 void setQuadVisibleRect(const gfx::Rect& rect) { m_quadVisibleRect = rect; } | 1770 void setQuadVisibleRect(const gfx::Rect& rect) { m_quadVisibleRect = rect; } |
| 1771 void setOpaqueContentRect(const gfx::Rect& rect) { m_opaqueContentRect = rec
t; } | 1771 void setOpaqueContentRect(const gfx::Rect& rect) { m_opaqueContentRect = rec
t; } |
| 1772 | 1772 |
| 1773 private: | 1773 private: |
| 1774 BlendStateCheckLayer(LayerTreeImpl* treeImpl, int id, ResourceProvider* reso
urceProvider) | 1774 BlendStateCheckLayer(LayerTreeImpl* treeImpl, int id, ResourceProvider* reso
urceProvider) |
| 1775 : LayerImpl(treeImpl, id) | 1775 : LayerImpl(treeImpl, id) |
| 1776 , m_blend(false) | 1776 , m_blend(false) |
| 1777 , m_hasRenderSurface(false) | 1777 , m_hasRenderSurface(false) |
| 1778 , m_quadsAppended(false) | 1778 , m_quadsAppended(false) |
| 1779 , m_quadRect(5, 5, 5, 5) | 1779 , m_quadRect(5, 5, 5, 5) |
| 1780 , m_quadVisibleRect(5, 5, 5, 5) | 1780 , m_quadVisibleRect(5, 5, 5, 5) |
| 1781 , m_resourceId(resourceProvider->CreateResource(gfx::Size(1, 1), GL_RGBA
, ResourceProvider::TextureUsageAny)) | 1781 , m_resourceId(resourceProvider->CreateResource(gfx::Size(1, 1), GL_RGBA
, ResourceProvider::TextureUsageAny)) |
| 1782 { | 1782 { |
| 1783 resourceProvider->AllocateForTesting(m_resourceId); | 1783 resourceProvider->AllocateForTesting(m_resourceId); |
| 1784 setAnchorPoint(gfx::PointF(0, 0)); | 1784 SetAnchorPoint(gfx::PointF(0, 0)); |
| 1785 setBounds(gfx::Size(10, 10)); | 1785 SetBounds(gfx::Size(10, 10)); |
| 1786 setContentBounds(gfx::Size(10, 10)); | 1786 SetContentBounds(gfx::Size(10, 10)); |
| 1787 setDrawsContent(true); | 1787 SetDrawsContent(true); |
| 1788 } | 1788 } |
| 1789 | 1789 |
| 1790 bool m_blend; | 1790 bool m_blend; |
| 1791 bool m_hasRenderSurface; | 1791 bool m_hasRenderSurface; |
| 1792 bool m_quadsAppended; | 1792 bool m_quadsAppended; |
| 1793 gfx::Rect m_quadRect; | 1793 gfx::Rect m_quadRect; |
| 1794 gfx::Rect m_opaqueContentRect; | 1794 gfx::Rect m_opaqueContentRect; |
| 1795 gfx::Rect m_quadVisibleRect; | 1795 gfx::Rect m_quadVisibleRect; |
| 1796 ResourceProvider::ResourceId m_resourceId; | 1796 ResourceProvider::ResourceId m_resourceId; |
| 1797 }; | 1797 }; |
| 1798 | 1798 |
| 1799 TEST_F(LayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers) | 1799 TEST_F(LayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers) |
| 1800 { | 1800 { |
| 1801 { | 1801 { |
| 1802 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(),
1); | 1802 scoped_ptr<LayerImpl> root = LayerImpl::Create(m_hostImpl->activeTree(),
1); |
| 1803 root->setAnchorPoint(gfx::PointF(0, 0)); | 1803 root->SetAnchorPoint(gfx::PointF(0, 0)); |
| 1804 root->setBounds(gfx::Size(10, 10)); | 1804 root->SetBounds(gfx::Size(10, 10)); |
| 1805 root->setContentBounds(root->bounds()); | 1805 root->SetContentBounds(root->bounds()); |
| 1806 root->setDrawsContent(false); | 1806 root->SetDrawsContent(false); |
| 1807 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); | 1807 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
| 1808 } | 1808 } |
| 1809 LayerImpl* root = m_hostImpl->rootLayer(); | 1809 LayerImpl* root = m_hostImpl->rootLayer(); |
| 1810 | 1810 |
| 1811 root->addChild(BlendStateCheckLayer::create(m_hostImpl->activeTree(), 2, m_h
ostImpl->resourceProvider())); | 1811 root->AddChild(BlendStateCheckLayer::Create(m_hostImpl->activeTree(), 2, m_h
ostImpl->resourceProvider())); |
| 1812 BlendStateCheckLayer* layer1 = static_cast<BlendStateCheckLayer*>(root->chil
dren()[0]); | 1812 BlendStateCheckLayer* layer1 = static_cast<BlendStateCheckLayer*>(root->chil
dren()[0]); |
| 1813 layer1->setPosition(gfx::PointF(2, 2)); | 1813 layer1->SetPosition(gfx::PointF(2, 2)); |
| 1814 | 1814 |
| 1815 LayerTreeHostImpl::FrameData frame; | 1815 LayerTreeHostImpl::FrameData frame; |
| 1816 | 1816 |
| 1817 // Opaque layer, drawn without blending. | 1817 // Opaque layer, drawn without blending. |
| 1818 layer1->setContentsOpaque(true); | 1818 layer1->SetContentsOpaque(true); |
| 1819 layer1->setExpectation(false, false); | 1819 layer1->setExpectation(false, false); |
| 1820 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1820 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 1821 m_hostImpl->drawLayers(frame); | 1821 m_hostImpl->drawLayers(frame); |
| 1822 EXPECT_TRUE(layer1->quadsAppended()); | 1822 EXPECT_TRUE(layer1->quadsAppended()); |
| 1823 m_hostImpl->didDrawAllLayers(frame); | 1823 m_hostImpl->didDrawAllLayers(frame); |
| 1824 | 1824 |
| 1825 // Layer with translucent content and painting, so drawn with blending. | 1825 // Layer with translucent content and painting, so drawn with blending. |
| 1826 layer1->setContentsOpaque(false); | 1826 layer1->SetContentsOpaque(false); |
| 1827 layer1->setExpectation(true, false); | 1827 layer1->setExpectation(true, false); |
| 1828 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1828 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 1829 m_hostImpl->drawLayers(frame); | 1829 m_hostImpl->drawLayers(frame); |
| 1830 EXPECT_TRUE(layer1->quadsAppended()); | 1830 EXPECT_TRUE(layer1->quadsAppended()); |
| 1831 m_hostImpl->didDrawAllLayers(frame); | 1831 m_hostImpl->didDrawAllLayers(frame); |
| 1832 | 1832 |
| 1833 // Layer with translucent opacity, drawn with blending. | 1833 // Layer with translucent opacity, drawn with blending. |
| 1834 layer1->setContentsOpaque(true); | 1834 layer1->SetContentsOpaque(true); |
| 1835 layer1->setOpacity(0.5); | 1835 layer1->SetOpacity(0.5); |
| 1836 layer1->setExpectation(true, false); | 1836 layer1->setExpectation(true, false); |
| 1837 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1837 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 1838 m_hostImpl->drawLayers(frame); | 1838 m_hostImpl->drawLayers(frame); |
| 1839 EXPECT_TRUE(layer1->quadsAppended()); | 1839 EXPECT_TRUE(layer1->quadsAppended()); |
| 1840 m_hostImpl->didDrawAllLayers(frame); | 1840 m_hostImpl->didDrawAllLayers(frame); |
| 1841 | 1841 |
| 1842 // Layer with translucent opacity and painting, drawn with blending. | 1842 // Layer with translucent opacity and painting, drawn with blending. |
| 1843 layer1->setContentsOpaque(true); | 1843 layer1->SetContentsOpaque(true); |
| 1844 layer1->setOpacity(0.5); | 1844 layer1->SetOpacity(0.5); |
| 1845 layer1->setExpectation(true, false); | 1845 layer1->setExpectation(true, false); |
| 1846 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1846 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 1847 m_hostImpl->drawLayers(frame); | 1847 m_hostImpl->drawLayers(frame); |
| 1848 EXPECT_TRUE(layer1->quadsAppended()); | 1848 EXPECT_TRUE(layer1->quadsAppended()); |
| 1849 m_hostImpl->didDrawAllLayers(frame); | 1849 m_hostImpl->didDrawAllLayers(frame); |
| 1850 | 1850 |
| 1851 layer1->addChild(BlendStateCheckLayer::create(m_hostImpl->activeTree(), 3, m
_hostImpl->resourceProvider())); | 1851 layer1->AddChild(BlendStateCheckLayer::Create(m_hostImpl->activeTree(), 3, m
_hostImpl->resourceProvider())); |
| 1852 BlendStateCheckLayer* layer2 = static_cast<BlendStateCheckLayer*>(layer1->ch
ildren()[0]); | 1852 BlendStateCheckLayer* layer2 = static_cast<BlendStateCheckLayer*>(layer1->ch
ildren()[0]); |
| 1853 layer2->setPosition(gfx::PointF(4, 4)); | 1853 layer2->SetPosition(gfx::PointF(4, 4)); |
| 1854 | 1854 |
| 1855 // 2 opaque layers, drawn without blending. | 1855 // 2 opaque layers, drawn without blending. |
| 1856 layer1->setContentsOpaque(true); | 1856 layer1->SetContentsOpaque(true); |
| 1857 layer1->setOpacity(1); | 1857 layer1->SetOpacity(1); |
| 1858 layer1->setExpectation(false, false); | 1858 layer1->setExpectation(false, false); |
| 1859 layer2->setContentsOpaque(true); | 1859 layer2->SetContentsOpaque(true); |
| 1860 layer2->setOpacity(1); | 1860 layer2->SetOpacity(1); |
| 1861 layer2->setExpectation(false, false); | 1861 layer2->setExpectation(false, false); |
| 1862 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1862 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 1863 m_hostImpl->drawLayers(frame); | 1863 m_hostImpl->drawLayers(frame); |
| 1864 EXPECT_TRUE(layer1->quadsAppended()); | 1864 EXPECT_TRUE(layer1->quadsAppended()); |
| 1865 EXPECT_TRUE(layer2->quadsAppended()); | 1865 EXPECT_TRUE(layer2->quadsAppended()); |
| 1866 m_hostImpl->didDrawAllLayers(frame); | 1866 m_hostImpl->didDrawAllLayers(frame); |
| 1867 | 1867 |
| 1868 // Parent layer with translucent content, drawn with blending. | 1868 // Parent layer with translucent content, drawn with blending. |
| 1869 // Child layer with opaque content, drawn without blending. | 1869 // Child layer with opaque content, drawn without blending. |
| 1870 layer1->setContentsOpaque(false); | 1870 layer1->SetContentsOpaque(false); |
| 1871 layer1->setExpectation(true, false); | 1871 layer1->setExpectation(true, false); |
| 1872 layer2->setExpectation(false, false); | 1872 layer2->setExpectation(false, false); |
| 1873 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1873 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 1874 m_hostImpl->drawLayers(frame); | 1874 m_hostImpl->drawLayers(frame); |
| 1875 EXPECT_TRUE(layer1->quadsAppended()); | 1875 EXPECT_TRUE(layer1->quadsAppended()); |
| 1876 EXPECT_TRUE(layer2->quadsAppended()); | 1876 EXPECT_TRUE(layer2->quadsAppended()); |
| 1877 m_hostImpl->didDrawAllLayers(frame); | 1877 m_hostImpl->didDrawAllLayers(frame); |
| 1878 | 1878 |
| 1879 // Parent layer with translucent content but opaque painting, drawn without
blending. | 1879 // Parent layer with translucent content but opaque painting, drawn without
blending. |
| 1880 // Child layer with opaque content, drawn without blending. | 1880 // Child layer with opaque content, drawn without blending. |
| 1881 layer1->setContentsOpaque(true); | 1881 layer1->SetContentsOpaque(true); |
| 1882 layer1->setExpectation(false, false); | 1882 layer1->setExpectation(false, false); |
| 1883 layer2->setExpectation(false, false); | 1883 layer2->setExpectation(false, false); |
| 1884 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1884 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 1885 m_hostImpl->drawLayers(frame); | 1885 m_hostImpl->drawLayers(frame); |
| 1886 EXPECT_TRUE(layer1->quadsAppended()); | 1886 EXPECT_TRUE(layer1->quadsAppended()); |
| 1887 EXPECT_TRUE(layer2->quadsAppended()); | 1887 EXPECT_TRUE(layer2->quadsAppended()); |
| 1888 m_hostImpl->didDrawAllLayers(frame); | 1888 m_hostImpl->didDrawAllLayers(frame); |
| 1889 | 1889 |
| 1890 // Parent layer with translucent opacity and opaque content. Since it has a | 1890 // Parent layer with translucent opacity and opaque content. Since it has a |
| 1891 // drawing child, it's drawn to a render surface which carries the opacity, | 1891 // drawing child, it's drawn to a render surface which carries the opacity, |
| 1892 // so it's itself drawn without blending. | 1892 // so it's itself drawn without blending. |
| 1893 // Child layer with opaque content, drawn without blending (parent surface | 1893 // Child layer with opaque content, drawn without blending (parent surface |
| 1894 // carries the inherited opacity). | 1894 // carries the inherited opacity). |
| 1895 layer1->setContentsOpaque(true); | 1895 layer1->SetContentsOpaque(true); |
| 1896 layer1->setOpacity(0.5); | 1896 layer1->SetOpacity(0.5); |
| 1897 layer1->setExpectation(false, true); | 1897 layer1->setExpectation(false, true); |
| 1898 layer2->setExpectation(false, false); | 1898 layer2->setExpectation(false, false); |
| 1899 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1899 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 1900 m_hostImpl->drawLayers(frame); | 1900 m_hostImpl->drawLayers(frame); |
| 1901 EXPECT_TRUE(layer1->quadsAppended()); | 1901 EXPECT_TRUE(layer1->quadsAppended()); |
| 1902 EXPECT_TRUE(layer2->quadsAppended()); | 1902 EXPECT_TRUE(layer2->quadsAppended()); |
| 1903 m_hostImpl->didDrawAllLayers(frame); | 1903 m_hostImpl->didDrawAllLayers(frame); |
| 1904 | 1904 |
| 1905 // Draw again, but with child non-opaque, to make sure | 1905 // Draw again, but with child non-opaque, to make sure |
| 1906 // layer1 not culled. | 1906 // layer1 not culled. |
| 1907 layer1->setContentsOpaque(true); | 1907 layer1->SetContentsOpaque(true); |
| 1908 layer1->setOpacity(1); | 1908 layer1->SetOpacity(1); |
| 1909 layer1->setExpectation(false, false); | 1909 layer1->setExpectation(false, false); |
| 1910 layer2->setContentsOpaque(true); | 1910 layer2->SetContentsOpaque(true); |
| 1911 layer2->setOpacity(0.5); | 1911 layer2->SetOpacity(0.5); |
| 1912 layer2->setExpectation(true, false); | 1912 layer2->setExpectation(true, false); |
| 1913 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1913 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 1914 m_hostImpl->drawLayers(frame); | 1914 m_hostImpl->drawLayers(frame); |
| 1915 EXPECT_TRUE(layer1->quadsAppended()); | 1915 EXPECT_TRUE(layer1->quadsAppended()); |
| 1916 EXPECT_TRUE(layer2->quadsAppended()); | 1916 EXPECT_TRUE(layer2->quadsAppended()); |
| 1917 m_hostImpl->didDrawAllLayers(frame); | 1917 m_hostImpl->didDrawAllLayers(frame); |
| 1918 | 1918 |
| 1919 // A second way of making the child non-opaque. | 1919 // A second way of making the child non-opaque. |
| 1920 layer1->setContentsOpaque(true); | 1920 layer1->SetContentsOpaque(true); |
| 1921 layer1->setOpacity(1); | 1921 layer1->SetOpacity(1); |
| 1922 layer1->setExpectation(false, false); | 1922 layer1->setExpectation(false, false); |
| 1923 layer2->setContentsOpaque(false); | 1923 layer2->SetContentsOpaque(false); |
| 1924 layer2->setOpacity(1); | 1924 layer2->SetOpacity(1); |
| 1925 layer2->setExpectation(true, false); | 1925 layer2->setExpectation(true, false); |
| 1926 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1926 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 1927 m_hostImpl->drawLayers(frame); | 1927 m_hostImpl->drawLayers(frame); |
| 1928 EXPECT_TRUE(layer1->quadsAppended()); | 1928 EXPECT_TRUE(layer1->quadsAppended()); |
| 1929 EXPECT_TRUE(layer2->quadsAppended()); | 1929 EXPECT_TRUE(layer2->quadsAppended()); |
| 1930 m_hostImpl->didDrawAllLayers(frame); | 1930 m_hostImpl->didDrawAllLayers(frame); |
| 1931 | 1931 |
| 1932 // And when the layer says its not opaque but is painted opaque, it is not b
lended. | 1932 // And when the layer says its not opaque but is painted opaque, it is not b
lended. |
| 1933 layer1->setContentsOpaque(true); | 1933 layer1->SetContentsOpaque(true); |
| 1934 layer1->setOpacity(1); | 1934 layer1->SetOpacity(1); |
| 1935 layer1->setExpectation(false, false); | 1935 layer1->setExpectation(false, false); |
| 1936 layer2->setContentsOpaque(true); | 1936 layer2->SetContentsOpaque(true); |
| 1937 layer2->setOpacity(1); | 1937 layer2->SetOpacity(1); |
| 1938 layer2->setExpectation(false, false); | 1938 layer2->setExpectation(false, false); |
| 1939 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1939 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 1940 m_hostImpl->drawLayers(frame); | 1940 m_hostImpl->drawLayers(frame); |
| 1941 EXPECT_TRUE(layer1->quadsAppended()); | 1941 EXPECT_TRUE(layer1->quadsAppended()); |
| 1942 EXPECT_TRUE(layer2->quadsAppended()); | 1942 EXPECT_TRUE(layer2->quadsAppended()); |
| 1943 m_hostImpl->didDrawAllLayers(frame); | 1943 m_hostImpl->didDrawAllLayers(frame); |
| 1944 | 1944 |
| 1945 // Layer with partially opaque contents, drawn with blending. | 1945 // Layer with partially opaque contents, drawn with blending. |
| 1946 layer1->setContentsOpaque(false); | 1946 layer1->SetContentsOpaque(false); |
| 1947 layer1->setQuadRect(gfx::Rect(5, 5, 5, 5)); | 1947 layer1->setQuadRect(gfx::Rect(5, 5, 5, 5)); |
| 1948 layer1->setQuadVisibleRect(gfx::Rect(5, 5, 5, 5)); | 1948 layer1->setQuadVisibleRect(gfx::Rect(5, 5, 5, 5)); |
| 1949 layer1->setOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); | 1949 layer1->setOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); |
| 1950 layer1->setExpectation(true, false); | 1950 layer1->setExpectation(true, false); |
| 1951 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1951 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 1952 m_hostImpl->drawLayers(frame); | 1952 m_hostImpl->drawLayers(frame); |
| 1953 EXPECT_TRUE(layer1->quadsAppended()); | 1953 EXPECT_TRUE(layer1->quadsAppended()); |
| 1954 m_hostImpl->didDrawAllLayers(frame); | 1954 m_hostImpl->didDrawAllLayers(frame); |
| 1955 | 1955 |
| 1956 // Layer with partially opaque contents partially culled, drawn with blendin
g. | 1956 // Layer with partially opaque contents partially culled, drawn with blendin
g. |
| 1957 layer1->setContentsOpaque(false); | 1957 layer1->SetContentsOpaque(false); |
| 1958 layer1->setQuadRect(gfx::Rect(5, 5, 5, 5)); | 1958 layer1->setQuadRect(gfx::Rect(5, 5, 5, 5)); |
| 1959 layer1->setQuadVisibleRect(gfx::Rect(5, 5, 5, 2)); | 1959 layer1->setQuadVisibleRect(gfx::Rect(5, 5, 5, 2)); |
| 1960 layer1->setOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); | 1960 layer1->setOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); |
| 1961 layer1->setExpectation(true, false); | 1961 layer1->setExpectation(true, false); |
| 1962 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1962 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 1963 m_hostImpl->drawLayers(frame); | 1963 m_hostImpl->drawLayers(frame); |
| 1964 EXPECT_TRUE(layer1->quadsAppended()); | 1964 EXPECT_TRUE(layer1->quadsAppended()); |
| 1965 m_hostImpl->didDrawAllLayers(frame); | 1965 m_hostImpl->didDrawAllLayers(frame); |
| 1966 | 1966 |
| 1967 // Layer with partially opaque contents culled, drawn with blending. | 1967 // Layer with partially opaque contents culled, drawn with blending. |
| 1968 layer1->setContentsOpaque(false); | 1968 layer1->SetContentsOpaque(false); |
| 1969 layer1->setQuadRect(gfx::Rect(5, 5, 5, 5)); | 1969 layer1->setQuadRect(gfx::Rect(5, 5, 5, 5)); |
| 1970 layer1->setQuadVisibleRect(gfx::Rect(7, 5, 3, 5)); | 1970 layer1->setQuadVisibleRect(gfx::Rect(7, 5, 3, 5)); |
| 1971 layer1->setOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); | 1971 layer1->setOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); |
| 1972 layer1->setExpectation(true, false); | 1972 layer1->setExpectation(true, false); |
| 1973 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1973 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 1974 m_hostImpl->drawLayers(frame); | 1974 m_hostImpl->drawLayers(frame); |
| 1975 EXPECT_TRUE(layer1->quadsAppended()); | 1975 EXPECT_TRUE(layer1->quadsAppended()); |
| 1976 m_hostImpl->didDrawAllLayers(frame); | 1976 m_hostImpl->didDrawAllLayers(frame); |
| 1977 | 1977 |
| 1978 // Layer with partially opaque contents and translucent contents culled, dra
wn without blending. | 1978 // Layer with partially opaque contents and translucent contents culled, dra
wn without blending. |
| 1979 layer1->setContentsOpaque(false); | 1979 layer1->SetContentsOpaque(false); |
| 1980 layer1->setQuadRect(gfx::Rect(5, 5, 5, 5)); | 1980 layer1->setQuadRect(gfx::Rect(5, 5, 5, 5)); |
| 1981 layer1->setQuadVisibleRect(gfx::Rect(5, 5, 2, 5)); | 1981 layer1->setQuadVisibleRect(gfx::Rect(5, 5, 2, 5)); |
| 1982 layer1->setOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); | 1982 layer1->setOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); |
| 1983 layer1->setExpectation(false, false); | 1983 layer1->setExpectation(false, false); |
| 1984 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1984 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 1985 m_hostImpl->drawLayers(frame); | 1985 m_hostImpl->drawLayers(frame); |
| 1986 EXPECT_TRUE(layer1->quadsAppended()); | 1986 EXPECT_TRUE(layer1->quadsAppended()); |
| 1987 m_hostImpl->didDrawAllLayers(frame); | 1987 m_hostImpl->didDrawAllLayers(frame); |
| 1988 | 1988 |
| 1989 } | 1989 } |
| 1990 | 1990 |
| 1991 TEST_F(LayerTreeHostImplTest, viewportCovered) | 1991 TEST_F(LayerTreeHostImplTest, viewportCovered) |
| 1992 { | 1992 { |
| 1993 m_hostImpl->initializeRenderer(createOutputSurface()); | 1993 m_hostImpl->initializeRenderer(createOutputSurface()); |
| 1994 m_hostImpl->activeTree()->set_background_color(SK_ColorGRAY); | 1994 m_hostImpl->activeTree()->set_background_color(SK_ColorGRAY); |
| 1995 | 1995 |
| 1996 gfx::Size viewportSize(1000, 1000); | 1996 gfx::Size viewportSize(1000, 1000); |
| 1997 m_hostImpl->setViewportSize(viewportSize, viewportSize); | 1997 m_hostImpl->setViewportSize(viewportSize, viewportSize); |
| 1998 | 1998 |
| 1999 m_hostImpl->activeTree()->SetRootLayer(LayerImpl::create(m_hostImpl->activeT
ree(), 1)); | 1999 m_hostImpl->activeTree()->SetRootLayer(LayerImpl::Create(m_hostImpl->activeT
ree(), 1)); |
| 2000 m_hostImpl->rootLayer()->addChild(BlendStateCheckLayer::create(m_hostImpl->a
ctiveTree(), 2, m_hostImpl->resourceProvider())); | 2000 m_hostImpl->rootLayer()->AddChild(BlendStateCheckLayer::Create(m_hostImpl->a
ctiveTree(), 2, m_hostImpl->resourceProvider())); |
| 2001 BlendStateCheckLayer* child = static_cast<BlendStateCheckLayer*>(m_hostImpl-
>rootLayer()->children()[0]); | 2001 BlendStateCheckLayer* child = static_cast<BlendStateCheckLayer*>(m_hostImpl-
>rootLayer()->children()[0]); |
| 2002 child->setExpectation(false, false); | 2002 child->setExpectation(false, false); |
| 2003 child->setContentsOpaque(true); | 2003 child->SetContentsOpaque(true); |
| 2004 | 2004 |
| 2005 // No gutter rects | 2005 // No gutter rects |
| 2006 { | 2006 { |
| 2007 gfx::Rect layerRect(0, 0, 1000, 1000); | 2007 gfx::Rect layerRect(0, 0, 1000, 1000); |
| 2008 child->setPosition(layerRect.origin()); | 2008 child->SetPosition(layerRect.origin()); |
| 2009 child->setBounds(layerRect.size()); | 2009 child->SetBounds(layerRect.size()); |
| 2010 child->setContentBounds(layerRect.size()); | 2010 child->SetContentBounds(layerRect.size()); |
| 2011 child->setQuadRect(gfx::Rect(gfx::Point(), layerRect.size())); | 2011 child->setQuadRect(gfx::Rect(gfx::Point(), layerRect.size())); |
| 2012 child->setQuadVisibleRect(gfx::Rect(gfx::Point(), layerRect.size())); | 2012 child->setQuadVisibleRect(gfx::Rect(gfx::Point(), layerRect.size())); |
| 2013 | 2013 |
| 2014 LayerTreeHostImpl::FrameData frame; | 2014 LayerTreeHostImpl::FrameData frame; |
| 2015 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2015 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 2016 ASSERT_EQ(1u, frame.renderPasses.size()); | 2016 ASSERT_EQ(1u, frame.renderPasses.size()); |
| 2017 | 2017 |
| 2018 size_t numGutterQuads = 0; | 2018 size_t numGutterQuads = 0; |
| 2019 for (size_t i = 0; i < frame.renderPasses[0]->quad_list.size(); ++i) | 2019 for (size_t i = 0; i < frame.renderPasses[0]->quad_list.size(); ++i) |
| 2020 numGutterQuads += (frame.renderPasses[0]->quad_list[i]->material ==
DrawQuad::SOLID_COLOR) ? 1 : 0; | 2020 numGutterQuads += (frame.renderPasses[0]->quad_list[i]->material ==
DrawQuad::SOLID_COLOR) ? 1 : 0; |
| 2021 EXPECT_EQ(0u, numGutterQuads); | 2021 EXPECT_EQ(0u, numGutterQuads); |
| 2022 EXPECT_EQ(1u, frame.renderPasses[0]->quad_list.size()); | 2022 EXPECT_EQ(1u, frame.renderPasses[0]->quad_list.size()); |
| 2023 | 2023 |
| 2024 LayerTestCommon::verifyQuadsExactlyCoverRect(frame.renderPasses[0]->quad
_list, gfx::Rect(gfx::Point(), viewportSize)); | 2024 LayerTestCommon::verifyQuadsExactlyCoverRect(frame.renderPasses[0]->quad
_list, gfx::Rect(gfx::Point(), viewportSize)); |
| 2025 m_hostImpl->didDrawAllLayers(frame); | 2025 m_hostImpl->didDrawAllLayers(frame); |
| 2026 } | 2026 } |
| 2027 | 2027 |
| 2028 // Empty visible content area (fullscreen gutter rect) | 2028 // Empty visible content area (fullscreen gutter rect) |
| 2029 { | 2029 { |
| 2030 gfx::Rect layerRect(0, 0, 0, 0); | 2030 gfx::Rect layerRect(0, 0, 0, 0); |
| 2031 child->setPosition(layerRect.origin()); | 2031 child->SetPosition(layerRect.origin()); |
| 2032 child->setBounds(layerRect.size()); | 2032 child->SetBounds(layerRect.size()); |
| 2033 child->setContentBounds(layerRect.size()); | 2033 child->SetContentBounds(layerRect.size()); |
| 2034 child->setQuadRect(gfx::Rect(gfx::Point(), layerRect.size())); | 2034 child->setQuadRect(gfx::Rect(gfx::Point(), layerRect.size())); |
| 2035 child->setQuadVisibleRect(gfx::Rect(gfx::Point(), layerRect.size())); | 2035 child->setQuadVisibleRect(gfx::Rect(gfx::Point(), layerRect.size())); |
| 2036 | 2036 |
| 2037 LayerTreeHostImpl::FrameData frame; | 2037 LayerTreeHostImpl::FrameData frame; |
| 2038 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2038 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 2039 ASSERT_EQ(1u, frame.renderPasses.size()); | 2039 ASSERT_EQ(1u, frame.renderPasses.size()); |
| 2040 | 2040 |
| 2041 size_t numGutterQuads = 0; | 2041 size_t numGutterQuads = 0; |
| 2042 for (size_t i = 0; i < frame.renderPasses[0]->quad_list.size(); ++i) | 2042 for (size_t i = 0; i < frame.renderPasses[0]->quad_list.size(); ++i) |
| 2043 numGutterQuads += (frame.renderPasses[0]->quad_list[i]->material ==
DrawQuad::SOLID_COLOR) ? 1 : 0; | 2043 numGutterQuads += (frame.renderPasses[0]->quad_list[i]->material ==
DrawQuad::SOLID_COLOR) ? 1 : 0; |
| 2044 EXPECT_EQ(1u, numGutterQuads); | 2044 EXPECT_EQ(1u, numGutterQuads); |
| 2045 EXPECT_EQ(1u, frame.renderPasses[0]->quad_list.size()); | 2045 EXPECT_EQ(1u, frame.renderPasses[0]->quad_list.size()); |
| 2046 | 2046 |
| 2047 LayerTestCommon::verifyQuadsExactlyCoverRect(frame.renderPasses[0]->quad
_list, gfx::Rect(gfx::Point(), viewportSize)); | 2047 LayerTestCommon::verifyQuadsExactlyCoverRect(frame.renderPasses[0]->quad
_list, gfx::Rect(gfx::Point(), viewportSize)); |
| 2048 m_hostImpl->didDrawAllLayers(frame); | 2048 m_hostImpl->didDrawAllLayers(frame); |
| 2049 } | 2049 } |
| 2050 | 2050 |
| 2051 // Content area in middle of clip rect (four surrounding gutter rects) | 2051 // Content area in middle of clip rect (four surrounding gutter rects) |
| 2052 { | 2052 { |
| 2053 gfx::Rect layerRect(500, 500, 200, 200); | 2053 gfx::Rect layerRect(500, 500, 200, 200); |
| 2054 child->setPosition(layerRect.origin()); | 2054 child->SetPosition(layerRect.origin()); |
| 2055 child->setBounds(layerRect.size()); | 2055 child->SetBounds(layerRect.size()); |
| 2056 child->setContentBounds(layerRect.size()); | 2056 child->SetContentBounds(layerRect.size()); |
| 2057 child->setQuadRect(gfx::Rect(gfx::Point(), layerRect.size())); | 2057 child->setQuadRect(gfx::Rect(gfx::Point(), layerRect.size())); |
| 2058 child->setQuadVisibleRect(gfx::Rect(gfx::Point(), layerRect.size())); | 2058 child->setQuadVisibleRect(gfx::Rect(gfx::Point(), layerRect.size())); |
| 2059 | 2059 |
| 2060 LayerTreeHostImpl::FrameData frame; | 2060 LayerTreeHostImpl::FrameData frame; |
| 2061 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2061 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 2062 ASSERT_EQ(1u, frame.renderPasses.size()); | 2062 ASSERT_EQ(1u, frame.renderPasses.size()); |
| 2063 | 2063 |
| 2064 size_t numGutterQuads = 0; | 2064 size_t numGutterQuads = 0; |
| 2065 for (size_t i = 0; i < frame.renderPasses[0]->quad_list.size(); ++i) | 2065 for (size_t i = 0; i < frame.renderPasses[0]->quad_list.size(); ++i) |
| 2066 numGutterQuads += (frame.renderPasses[0]->quad_list[i]->material ==
DrawQuad::SOLID_COLOR) ? 1 : 0; | 2066 numGutterQuads += (frame.renderPasses[0]->quad_list[i]->material ==
DrawQuad::SOLID_COLOR) ? 1 : 0; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2084 } | 2084 } |
| 2085 | 2085 |
| 2086 bool reshapeCalled() const { return m_reshapeCalled; } | 2086 bool reshapeCalled() const { return m_reshapeCalled; } |
| 2087 | 2087 |
| 2088 private: | 2088 private: |
| 2089 bool m_reshapeCalled; | 2089 bool m_reshapeCalled; |
| 2090 }; | 2090 }; |
| 2091 | 2091 |
| 2092 class FakeDrawableLayerImpl: public LayerImpl { | 2092 class FakeDrawableLayerImpl: public LayerImpl { |
| 2093 public: | 2093 public: |
| 2094 static scoped_ptr<LayerImpl> create(LayerTreeImpl* treeImpl, int id) { retur
n scoped_ptr<LayerImpl>(new FakeDrawableLayerImpl(treeImpl, id)); } | 2094 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* treeImpl, int id) { retur
n scoped_ptr<LayerImpl>(new FakeDrawableLayerImpl(treeImpl, id)); } |
| 2095 protected: | 2095 protected: |
| 2096 FakeDrawableLayerImpl(LayerTreeImpl* treeImpl, int id) : LayerImpl(treeImpl,
id) { } | 2096 FakeDrawableLayerImpl(LayerTreeImpl* treeImpl, int id) : LayerImpl(treeImpl,
id) { } |
| 2097 }; | 2097 }; |
| 2098 | 2098 |
| 2099 // Only reshape when we know we are going to draw. Otherwise, the reshape | 2099 // Only reshape when we know we are going to draw. Otherwise, the reshape |
| 2100 // can leave the window at the wrong size if we never draw and the proper | 2100 // can leave the window at the wrong size if we never draw and the proper |
| 2101 // viewport size is never set. | 2101 // viewport size is never set. |
| 2102 TEST_F(LayerTreeHostImplTest, reshapeNotCalledUntilDraw) | 2102 TEST_F(LayerTreeHostImplTest, reshapeNotCalledUntilDraw) |
| 2103 { | 2103 { |
| 2104 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new ReshapeTrackerContext)).PassAs<OutputSurf
ace>(); | 2104 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new ReshapeTrackerContext)).PassAs<OutputSurf
ace>(); |
| 2105 ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>(
outputSurface->context3d()); | 2105 ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>(
outputSurface->context3d()); |
| 2106 m_hostImpl->initializeRenderer(outputSurface.Pass()); | 2106 m_hostImpl->initializeRenderer(outputSurface.Pass()); |
| 2107 | 2107 |
| 2108 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(m_hostImpl->activ
eTree(), 1); | 2108 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::Create(m_hostImpl->activ
eTree(), 1); |
| 2109 root->setAnchorPoint(gfx::PointF(0, 0)); | 2109 root->SetAnchorPoint(gfx::PointF(0, 0)); |
| 2110 root->setBounds(gfx::Size(10, 10)); | 2110 root->SetBounds(gfx::Size(10, 10)); |
| 2111 root->setDrawsContent(true); | 2111 root->SetDrawsContent(true); |
| 2112 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); | 2112 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
| 2113 EXPECT_FALSE(reshapeTracker->reshapeCalled()); | 2113 EXPECT_FALSE(reshapeTracker->reshapeCalled()); |
| 2114 | 2114 |
| 2115 LayerTreeHostImpl::FrameData frame; | 2115 LayerTreeHostImpl::FrameData frame; |
| 2116 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2116 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 2117 m_hostImpl->drawLayers(frame); | 2117 m_hostImpl->drawLayers(frame); |
| 2118 EXPECT_TRUE(reshapeTracker->reshapeCalled()); | 2118 EXPECT_TRUE(reshapeTracker->reshapeCalled()); |
| 2119 m_hostImpl->didDrawAllLayers(frame); | 2119 m_hostImpl->didDrawAllLayers(frame); |
| 2120 } | 2120 } |
| 2121 | 2121 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2148 PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrack
erContext*>(outputSurface->context3d()); | 2148 PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrack
erContext*>(outputSurface->context3d()); |
| 2149 | 2149 |
| 2150 // This test creates its own LayerTreeHostImpl, so | 2150 // This test creates its own LayerTreeHostImpl, so |
| 2151 // that we can force partial swap enabled. | 2151 // that we can force partial swap enabled. |
| 2152 LayerTreeSettings settings; | 2152 LayerTreeSettings settings; |
| 2153 settings.partialSwapEnabled = true; | 2153 settings.partialSwapEnabled = true; |
| 2154 scoped_ptr<LayerTreeHostImpl> layerTreeHostImpl = LayerTreeHostImpl::create(
settings, this, &m_proxy); | 2154 scoped_ptr<LayerTreeHostImpl> layerTreeHostImpl = LayerTreeHostImpl::create(
settings, this, &m_proxy); |
| 2155 layerTreeHostImpl->initializeRenderer(outputSurface.Pass()); | 2155 layerTreeHostImpl->initializeRenderer(outputSurface.Pass()); |
| 2156 layerTreeHostImpl->setViewportSize(gfx::Size(500, 500), gfx::Size(500, 500))
; | 2156 layerTreeHostImpl->setViewportSize(gfx::Size(500, 500), gfx::Size(500, 500))
; |
| 2157 | 2157 |
| 2158 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(layerTreeHostImpl
->activeTree(), 1); | 2158 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::Create(layerTreeHostImpl
->activeTree(), 1); |
| 2159 scoped_ptr<LayerImpl> child = FakeDrawableLayerImpl::create(layerTreeHostImp
l->activeTree(), 2); | 2159 scoped_ptr<LayerImpl> child = FakeDrawableLayerImpl::Create(layerTreeHostImp
l->activeTree(), 2); |
| 2160 child->setPosition(gfx::PointF(12, 13)); | 2160 child->SetPosition(gfx::PointF(12, 13)); |
| 2161 child->setAnchorPoint(gfx::PointF(0, 0)); | 2161 child->SetAnchorPoint(gfx::PointF(0, 0)); |
| 2162 child->setBounds(gfx::Size(14, 15)); | 2162 child->SetBounds(gfx::Size(14, 15)); |
| 2163 child->setContentBounds(gfx::Size(14, 15)); | 2163 child->SetContentBounds(gfx::Size(14, 15)); |
| 2164 child->setDrawsContent(true); | 2164 child->SetDrawsContent(true); |
| 2165 root->setAnchorPoint(gfx::PointF(0, 0)); | 2165 root->SetAnchorPoint(gfx::PointF(0, 0)); |
| 2166 root->setBounds(gfx::Size(500, 500)); | 2166 root->SetBounds(gfx::Size(500, 500)); |
| 2167 root->setContentBounds(gfx::Size(500, 500)); | 2167 root->SetContentBounds(gfx::Size(500, 500)); |
| 2168 root->setDrawsContent(true); | 2168 root->SetDrawsContent(true); |
| 2169 root->addChild(child.Pass()); | 2169 root->AddChild(child.Pass()); |
| 2170 layerTreeHostImpl->activeTree()->SetRootLayer(root.Pass()); | 2170 layerTreeHostImpl->activeTree()->SetRootLayer(root.Pass()); |
| 2171 | 2171 |
| 2172 LayerTreeHostImpl::FrameData frame; | 2172 LayerTreeHostImpl::FrameData frame; |
| 2173 | 2173 |
| 2174 // First frame, the entire screen should get swapped. | 2174 // First frame, the entire screen should get swapped. |
| 2175 EXPECT_TRUE(layerTreeHostImpl->prepareToDraw(frame)); | 2175 EXPECT_TRUE(layerTreeHostImpl->prepareToDraw(frame)); |
| 2176 layerTreeHostImpl->drawLayers(frame); | 2176 layerTreeHostImpl->drawLayers(frame); |
| 2177 layerTreeHostImpl->didDrawAllLayers(frame); | 2177 layerTreeHostImpl->didDrawAllLayers(frame); |
| 2178 layerTreeHostImpl->swapBuffers(); | 2178 layerTreeHostImpl->swapBuffers(); |
| 2179 gfx::Rect actualSwapRect = partialSwapTracker->partialSwapRect(); | 2179 gfx::Rect actualSwapRect = partialSwapTracker->partialSwapRect(); |
| 2180 gfx::Rect expectedSwapRect = gfx::Rect(gfx::Point(), gfx::Size(500, 500)); | 2180 gfx::Rect expectedSwapRect = gfx::Rect(gfx::Point(), gfx::Size(500, 500)); |
| 2181 EXPECT_EQ(expectedSwapRect.x(), actualSwapRect.x()); | 2181 EXPECT_EQ(expectedSwapRect.x(), actualSwapRect.x()); |
| 2182 EXPECT_EQ(expectedSwapRect.y(), actualSwapRect.y()); | 2182 EXPECT_EQ(expectedSwapRect.y(), actualSwapRect.y()); |
| 2183 EXPECT_EQ(expectedSwapRect.width(), actualSwapRect.width()); | 2183 EXPECT_EQ(expectedSwapRect.width(), actualSwapRect.width()); |
| 2184 EXPECT_EQ(expectedSwapRect.height(), actualSwapRect.height()); | 2184 EXPECT_EQ(expectedSwapRect.height(), actualSwapRect.height()); |
| 2185 | 2185 |
| 2186 // Second frame, only the damaged area should get swapped. Damage should be
the union | 2186 // Second frame, only the damaged area should get swapped. Damage should be
the union |
| 2187 // of old and new child rects. | 2187 // of old and new child rects. |
| 2188 // expected damage rect: gfx::Rect(gfx::Point(), gfx::Size(26, 28)); | 2188 // expected damage rect: gfx::Rect(gfx::Point(), gfx::Size(26, 28)); |
| 2189 // expected swap rect: vertically flipped, with origin at bottom left corner
. | 2189 // expected swap rect: vertically flipped, with origin at bottom left corner
. |
| 2190 layerTreeHostImpl->rootLayer()->children()[0]->setPosition(gfx::PointF(0, 0)
); | 2190 layerTreeHostImpl->rootLayer()->children()[0]->SetPosition(gfx::PointF(0, 0)
); |
| 2191 EXPECT_TRUE(layerTreeHostImpl->prepareToDraw(frame)); | 2191 EXPECT_TRUE(layerTreeHostImpl->prepareToDraw(frame)); |
| 2192 layerTreeHostImpl->drawLayers(frame); | 2192 layerTreeHostImpl->drawLayers(frame); |
| 2193 m_hostImpl->didDrawAllLayers(frame); | 2193 m_hostImpl->didDrawAllLayers(frame); |
| 2194 layerTreeHostImpl->swapBuffers(); | 2194 layerTreeHostImpl->swapBuffers(); |
| 2195 actualSwapRect = partialSwapTracker->partialSwapRect(); | 2195 actualSwapRect = partialSwapTracker->partialSwapRect(); |
| 2196 expectedSwapRect = gfx::Rect(gfx::Point(0, 500-28), gfx::Size(26, 28)); | 2196 expectedSwapRect = gfx::Rect(gfx::Point(0, 500-28), gfx::Size(26, 28)); |
| 2197 EXPECT_EQ(expectedSwapRect.x(), actualSwapRect.x()); | 2197 EXPECT_EQ(expectedSwapRect.x(), actualSwapRect.x()); |
| 2198 EXPECT_EQ(expectedSwapRect.y(), actualSwapRect.y()); | 2198 EXPECT_EQ(expectedSwapRect.y(), actualSwapRect.y()); |
| 2199 EXPECT_EQ(expectedSwapRect.width(), actualSwapRect.width()); | 2199 EXPECT_EQ(expectedSwapRect.width(), actualSwapRect.width()); |
| 2200 EXPECT_EQ(expectedSwapRect.height(), actualSwapRect.height()); | 2200 EXPECT_EQ(expectedSwapRect.height(), actualSwapRect.height()); |
| 2201 | 2201 |
| 2202 // Make sure that partial swap is constrained to the viewport dimensions | 2202 // Make sure that partial swap is constrained to the viewport dimensions |
| 2203 // expected damage rect: gfx::Rect(gfx::Point(), gfx::Size(500, 500)); | 2203 // expected damage rect: gfx::Rect(gfx::Point(), gfx::Size(500, 500)); |
| 2204 // expected swap rect: flipped damage rect, but also clamped to viewport | 2204 // expected swap rect: flipped damage rect, but also clamped to viewport |
| 2205 layerTreeHostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); | 2205 layerTreeHostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); |
| 2206 layerTreeHostImpl->rootLayer()->setOpacity(0.7f); // this will damage everyt
hing | 2206 layerTreeHostImpl->rootLayer()->SetOpacity(0.7f); // this will damage everyt
hing |
| 2207 EXPECT_TRUE(layerTreeHostImpl->prepareToDraw(frame)); | 2207 EXPECT_TRUE(layerTreeHostImpl->prepareToDraw(frame)); |
| 2208 layerTreeHostImpl->drawLayers(frame); | 2208 layerTreeHostImpl->drawLayers(frame); |
| 2209 m_hostImpl->didDrawAllLayers(frame); | 2209 m_hostImpl->didDrawAllLayers(frame); |
| 2210 layerTreeHostImpl->swapBuffers(); | 2210 layerTreeHostImpl->swapBuffers(); |
| 2211 actualSwapRect = partialSwapTracker->partialSwapRect(); | 2211 actualSwapRect = partialSwapTracker->partialSwapRect(); |
| 2212 expectedSwapRect = gfx::Rect(gfx::Point(), gfx::Size(10, 10)); | 2212 expectedSwapRect = gfx::Rect(gfx::Point(), gfx::Size(10, 10)); |
| 2213 EXPECT_EQ(expectedSwapRect.x(), actualSwapRect.x()); | 2213 EXPECT_EQ(expectedSwapRect.x(), actualSwapRect.x()); |
| 2214 EXPECT_EQ(expectedSwapRect.y(), actualSwapRect.y()); | 2214 EXPECT_EQ(expectedSwapRect.y(), actualSwapRect.y()); |
| 2215 EXPECT_EQ(expectedSwapRect.width(), actualSwapRect.width()); | 2215 EXPECT_EQ(expectedSwapRect.width(), actualSwapRect.width()); |
| 2216 EXPECT_EQ(expectedSwapRect.height(), actualSwapRect.height()); | 2216 EXPECT_EQ(expectedSwapRect.height(), actualSwapRect.height()); |
| 2217 } | 2217 } |
| 2218 | 2218 |
| 2219 TEST_F(LayerTreeHostImplTest, rootLayerDoesntCreateExtraSurface) | 2219 TEST_F(LayerTreeHostImplTest, rootLayerDoesntCreateExtraSurface) |
| 2220 { | 2220 { |
| 2221 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(m_hostImpl->activ
eTree(), 1); | 2221 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::Create(m_hostImpl->activ
eTree(), 1); |
| 2222 scoped_ptr<LayerImpl> child = FakeDrawableLayerImpl::create(m_hostImpl->acti
veTree(), 2); | 2222 scoped_ptr<LayerImpl> child = FakeDrawableLayerImpl::Create(m_hostImpl->acti
veTree(), 2); |
| 2223 child->setAnchorPoint(gfx::PointF(0, 0)); | 2223 child->SetAnchorPoint(gfx::PointF(0, 0)); |
| 2224 child->setBounds(gfx::Size(10, 10)); | 2224 child->SetBounds(gfx::Size(10, 10)); |
| 2225 child->setContentBounds(gfx::Size(10, 10)); | 2225 child->SetContentBounds(gfx::Size(10, 10)); |
| 2226 child->setDrawsContent(true); | 2226 child->SetDrawsContent(true); |
| 2227 root->setAnchorPoint(gfx::PointF(0, 0)); | 2227 root->SetAnchorPoint(gfx::PointF(0, 0)); |
| 2228 root->setBounds(gfx::Size(10, 10)); | 2228 root->SetBounds(gfx::Size(10, 10)); |
| 2229 root->setContentBounds(gfx::Size(10, 10)); | 2229 root->SetContentBounds(gfx::Size(10, 10)); |
| 2230 root->setDrawsContent(true); | 2230 root->SetDrawsContent(true); |
| 2231 root->setOpacity(0.7f); | 2231 root->SetOpacity(0.7f); |
| 2232 root->addChild(child.Pass()); | 2232 root->AddChild(child.Pass()); |
| 2233 | 2233 |
| 2234 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); | 2234 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
| 2235 | 2235 |
| 2236 LayerTreeHostImpl::FrameData frame; | 2236 LayerTreeHostImpl::FrameData frame; |
| 2237 | 2237 |
| 2238 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2238 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 2239 EXPECT_EQ(1u, frame.renderSurfaceLayerList->size()); | 2239 EXPECT_EQ(1u, frame.renderSurfaceLayerList->size()); |
| 2240 EXPECT_EQ(1u, frame.renderPasses.size()); | 2240 EXPECT_EQ(1u, frame.renderPasses.size()); |
| 2241 m_hostImpl->didDrawAllLayers(frame); | 2241 m_hostImpl->didDrawAllLayers(frame); |
| 2242 } | 2242 } |
| 2243 | 2243 |
| 2244 class FakeLayerWithQuads : public LayerImpl { | 2244 class FakeLayerWithQuads : public LayerImpl { |
| 2245 public: | 2245 public: |
| 2246 static scoped_ptr<LayerImpl> create(LayerTreeImpl* treeImpl, int id) { retur
n scoped_ptr<LayerImpl>(new FakeLayerWithQuads(treeImpl, id)); } | 2246 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* treeImpl, int id) { retur
n scoped_ptr<LayerImpl>(new FakeLayerWithQuads(treeImpl, id)); } |
| 2247 | 2247 |
| 2248 virtual void appendQuads(QuadSink& quadSink, AppendQuadsData& appendQuadsDat
a) OVERRIDE | 2248 virtual void AppendQuads(QuadSink* quadSink, AppendQuadsData* appendQuadsDat
a) OVERRIDE |
| 2249 { | 2249 { |
| 2250 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSha
redQuadState()); | 2250 SharedQuadState* sharedQuadState = quadSink->useSharedQuadState(CreateSh
aredQuadState()); |
| 2251 | 2251 |
| 2252 SkColor gray = SkColorSetRGB(100, 100, 100); | 2252 SkColor gray = SkColorSetRGB(100, 100, 100); |
| 2253 gfx::Rect quadRect(gfx::Point(0, 0), contentBounds()); | 2253 gfx::Rect quadRect(gfx::Point(0, 0), content_bounds()); |
| 2254 scoped_ptr<SolidColorDrawQuad> myQuad = SolidColorDrawQuad::Create(); | 2254 scoped_ptr<SolidColorDrawQuad> myQuad = SolidColorDrawQuad::Create(); |
| 2255 myQuad->SetNew(sharedQuadState, quadRect, gray); | 2255 myQuad->SetNew(sharedQuadState, quadRect, gray); |
| 2256 quadSink.append(myQuad.PassAs<DrawQuad>(), appendQuadsData); | 2256 quadSink->append(myQuad.PassAs<DrawQuad>(), appendQuadsData); |
| 2257 } | 2257 } |
| 2258 | 2258 |
| 2259 private: | 2259 private: |
| 2260 FakeLayerWithQuads(LayerTreeImpl* treeImpl, int id) | 2260 FakeLayerWithQuads(LayerTreeImpl* treeImpl, int id) |
| 2261 : LayerImpl(treeImpl, id) | 2261 : LayerImpl(treeImpl, id) |
| 2262 { | 2262 { |
| 2263 } | 2263 } |
| 2264 }; | 2264 }; |
| 2265 | 2265 |
| 2266 class MockContext : public TestWebGraphicsContext3D { | 2266 class MockContext : public TestWebGraphicsContext3D { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2353 }; | 2353 }; |
| 2354 | 2354 |
| 2355 TEST_F(LayerTreeHostImplTest, noPartialSwap) | 2355 TEST_F(LayerTreeHostImplTest, noPartialSwap) |
| 2356 { | 2356 { |
| 2357 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new MockContext)).PassAs<OutputSurface>(); | 2357 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new MockContext)).PassAs<OutputSurface>(); |
| 2358 MockContext* mockContext = static_cast<MockContext*>(outputSurface->context3
d()); | 2358 MockContext* mockContext = static_cast<MockContext*>(outputSurface->context3
d()); |
| 2359 MockContextHarness harness(mockContext); | 2359 MockContextHarness harness(mockContext); |
| 2360 | 2360 |
| 2361 // Run test case | 2361 // Run test case |
| 2362 createLayerTreeHost(false, outputSurface.Pass()); | 2362 createLayerTreeHost(false, outputSurface.Pass()); |
| 2363 setupRootLayerImpl(FakeLayerWithQuads::create(m_hostImpl->activeTree(), 1)); | 2363 setupRootLayerImpl(FakeLayerWithQuads::Create(m_hostImpl->activeTree(), 1)); |
| 2364 | 2364 |
| 2365 // without partial swap, and no clipping, no scissor is set. | 2365 // without partial swap, and no clipping, no scissor is set. |
| 2366 harness.mustDrawSolidQuad(); | 2366 harness.mustDrawSolidQuad(); |
| 2367 harness.mustSetNoScissor(); | 2367 harness.mustSetNoScissor(); |
| 2368 { | 2368 { |
| 2369 LayerTreeHostImpl::FrameData frame; | 2369 LayerTreeHostImpl::FrameData frame; |
| 2370 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2370 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 2371 m_hostImpl->drawLayers(frame); | 2371 m_hostImpl->drawLayers(frame); |
| 2372 m_hostImpl->didDrawAllLayers(frame); | 2372 m_hostImpl->didDrawAllLayers(frame); |
| 2373 } | 2373 } |
| 2374 Mock::VerifyAndClearExpectations(&mockContext); | 2374 Mock::VerifyAndClearExpectations(&mockContext); |
| 2375 | 2375 |
| 2376 // without partial swap, but a layer does clip its subtree, one scissor is s
et. | 2376 // without partial swap, but a layer does clip its subtree, one scissor is s
et. |
| 2377 m_hostImpl->rootLayer()->setMasksToBounds(true); | 2377 m_hostImpl->rootLayer()->SetMasksToBounds(true); |
| 2378 harness.mustDrawSolidQuad(); | 2378 harness.mustDrawSolidQuad(); |
| 2379 harness.mustSetScissor(0, 0, 10, 10); | 2379 harness.mustSetScissor(0, 0, 10, 10); |
| 2380 { | 2380 { |
| 2381 LayerTreeHostImpl::FrameData frame; | 2381 LayerTreeHostImpl::FrameData frame; |
| 2382 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2382 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 2383 m_hostImpl->drawLayers(frame); | 2383 m_hostImpl->drawLayers(frame); |
| 2384 m_hostImpl->didDrawAllLayers(frame); | 2384 m_hostImpl->didDrawAllLayers(frame); |
| 2385 } | 2385 } |
| 2386 Mock::VerifyAndClearExpectations(&mockContext); | 2386 Mock::VerifyAndClearExpectations(&mockContext); |
| 2387 } | 2387 } |
| 2388 | 2388 |
| 2389 TEST_F(LayerTreeHostImplTest, partialSwap) | 2389 TEST_F(LayerTreeHostImplTest, partialSwap) |
| 2390 { | 2390 { |
| 2391 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new MockContext)).PassAs<OutputSurface>(); | 2391 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new MockContext)).PassAs<OutputSurface>(); |
| 2392 MockContext* mockContext = static_cast<MockContext*>(outputSurface->context3
d()); | 2392 MockContext* mockContext = static_cast<MockContext*>(outputSurface->context3
d()); |
| 2393 MockContextHarness harness(mockContext); | 2393 MockContextHarness harness(mockContext); |
| 2394 | 2394 |
| 2395 createLayerTreeHost(true, outputSurface.Pass()); | 2395 createLayerTreeHost(true, outputSurface.Pass()); |
| 2396 setupRootLayerImpl(FakeLayerWithQuads::create(m_hostImpl->activeTree(), 1)); | 2396 setupRootLayerImpl(FakeLayerWithQuads::Create(m_hostImpl->activeTree(), 1)); |
| 2397 | 2397 |
| 2398 // The first frame is not a partially-swapped one. | 2398 // The first frame is not a partially-swapped one. |
| 2399 harness.mustSetScissor(0, 0, 10, 10); | 2399 harness.mustSetScissor(0, 0, 10, 10); |
| 2400 harness.mustDrawSolidQuad(); | 2400 harness.mustDrawSolidQuad(); |
| 2401 { | 2401 { |
| 2402 LayerTreeHostImpl::FrameData frame; | 2402 LayerTreeHostImpl::FrameData frame; |
| 2403 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2403 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 2404 m_hostImpl->drawLayers(frame); | 2404 m_hostImpl->drawLayers(frame); |
| 2405 m_hostImpl->didDrawAllLayers(frame); | 2405 m_hostImpl->didDrawAllLayers(frame); |
| 2406 } | 2406 } |
| 2407 Mock::VerifyAndClearExpectations(&mockContext); | 2407 Mock::VerifyAndClearExpectations(&mockContext); |
| 2408 | 2408 |
| 2409 // Damage a portion of the frame. | 2409 // Damage a portion of the frame. |
| 2410 m_hostImpl->rootLayer()->setUpdateRect(gfx::Rect(0, 0, 2, 3)); | 2410 m_hostImpl->rootLayer()->set_update_rect(gfx::Rect(0, 0, 2, 3)); |
| 2411 | 2411 |
| 2412 // The second frame will be partially-swapped (the y coordinates are flipped
). | 2412 // The second frame will be partially-swapped (the y coordinates are flipped
). |
| 2413 harness.mustSetScissor(0, 7, 2, 3); | 2413 harness.mustSetScissor(0, 7, 2, 3); |
| 2414 harness.mustDrawSolidQuad(); | 2414 harness.mustDrawSolidQuad(); |
| 2415 { | 2415 { |
| 2416 LayerTreeHostImpl::FrameData frame; | 2416 LayerTreeHostImpl::FrameData frame; |
| 2417 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2417 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 2418 m_hostImpl->drawLayers(frame); | 2418 m_hostImpl->drawLayers(frame); |
| 2419 m_hostImpl->didDrawAllLayers(frame); | 2419 m_hostImpl->didDrawAllLayers(frame); |
| 2420 } | 2420 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2464 | | | 3 | | 2464 | | | 3 | |
| 2465 | | +-------------------+ | 2465 | | +-------------------+ |
| 2466 | | | | | 2466 | | | | |
| 2467 | +-----------+ | | 2467 | +-----------+ | |
| 2468 | | | 2468 | | |
| 2469 | | | 2469 | | |
| 2470 +--------------------+ | 2470 +--------------------+ |
| 2471 | 2471 |
| 2472 Layers 1, 2 have render surfaces | 2472 Layers 1, 2 have render surfaces |
| 2473 */ | 2473 */ |
| 2474 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl->activeTree(), 1); | 2474 scoped_ptr<LayerImpl> root = LayerImpl::Create(myHostImpl->activeTree(), 1); |
| 2475 scoped_ptr<LayerImpl> child = LayerImpl::create(myHostImpl->activeTree(), 2)
; | 2475 scoped_ptr<LayerImpl> child = LayerImpl::Create(myHostImpl->activeTree(), 2)
; |
| 2476 scoped_ptr<LayerImpl> grandChild = FakeLayerWithQuads::create(myHostImpl->ac
tiveTree(), 3); | 2476 scoped_ptr<LayerImpl> grandChild = FakeLayerWithQuads::Create(myHostImpl->ac
tiveTree(), 3); |
| 2477 | 2477 |
| 2478 gfx::Rect rootRect(0, 0, 100, 100); | 2478 gfx::Rect rootRect(0, 0, 100, 100); |
| 2479 gfx::Rect childRect(10, 10, 50, 50); | 2479 gfx::Rect childRect(10, 10, 50, 50); |
| 2480 gfx::Rect grandChildRect(5, 5, 150, 150); | 2480 gfx::Rect grandChildRect(5, 5, 150, 150); |
| 2481 | 2481 |
| 2482 root->createRenderSurface(); | 2482 root->CreateRenderSurface(); |
| 2483 root->setAnchorPoint(gfx::PointF(0, 0)); | 2483 root->SetAnchorPoint(gfx::PointF(0, 0)); |
| 2484 root->setPosition(gfx::PointF(rootRect.x(), rootRect.y())); | 2484 root->SetPosition(gfx::PointF(rootRect.x(), rootRect.y())); |
| 2485 root->setBounds(gfx::Size(rootRect.width(), rootRect.height())); | 2485 root->SetBounds(gfx::Size(rootRect.width(), rootRect.height())); |
| 2486 root->setContentBounds(root->bounds()); | 2486 root->SetContentBounds(root->bounds()); |
| 2487 root->drawProperties().visible_content_rect = rootRect; | 2487 root->draw_properties().visible_content_rect = rootRect; |
| 2488 root->setDrawsContent(false); | 2488 root->SetDrawsContent(false); |
| 2489 root->renderSurface()->SetContentRect(gfx::Rect(gfx::Point(), gfx::Size(root
Rect.width(), rootRect.height()))); | 2489 root->render_surface()->SetContentRect(gfx::Rect(gfx::Point(), gfx::Size(roo
tRect.width(), rootRect.height()))); |
| 2490 | 2490 |
| 2491 child->setAnchorPoint(gfx::PointF(0, 0)); | 2491 child->SetAnchorPoint(gfx::PointF(0, 0)); |
| 2492 child->setPosition(gfx::PointF(childRect.x(), childRect.y())); | 2492 child->SetPosition(gfx::PointF(childRect.x(), childRect.y())); |
| 2493 child->setOpacity(0.5f); | 2493 child->SetOpacity(0.5f); |
| 2494 child->setBounds(gfx::Size(childRect.width(), childRect.height())); | 2494 child->SetBounds(gfx::Size(childRect.width(), childRect.height())); |
| 2495 child->setContentBounds(child->bounds()); | 2495 child->SetContentBounds(child->bounds()); |
| 2496 child->drawProperties().visible_content_rect = childRect; | 2496 child->draw_properties().visible_content_rect = childRect; |
| 2497 child->setDrawsContent(false); | 2497 child->SetDrawsContent(false); |
| 2498 child->setForceRenderSurface(true); | 2498 child->SetForceRenderSurface(true); |
| 2499 | 2499 |
| 2500 grandChild->setAnchorPoint(gfx::PointF(0, 0)); | 2500 grandChild->SetAnchorPoint(gfx::PointF(0, 0)); |
| 2501 grandChild->setPosition(gfx::Point(grandChildRect.x(), grandChildRect.y())); | 2501 grandChild->SetPosition(gfx::Point(grandChildRect.x(), grandChildRect.y())); |
| 2502 grandChild->setBounds(gfx::Size(grandChildRect.width(), grandChildRect.heigh
t())); | 2502 grandChild->SetBounds(gfx::Size(grandChildRect.width(), grandChildRect.heigh
t())); |
| 2503 grandChild->setContentBounds(grandChild->bounds()); | 2503 grandChild->SetContentBounds(grandChild->bounds()); |
| 2504 grandChild->drawProperties().visible_content_rect = grandChildRect; | 2504 grandChild->draw_properties().visible_content_rect = grandChildRect; |
| 2505 grandChild->setDrawsContent(true); | 2505 grandChild->SetDrawsContent(true); |
| 2506 | 2506 |
| 2507 child->addChild(grandChild.Pass()); | 2507 child->AddChild(grandChild.Pass()); |
| 2508 root->addChild(child.Pass()); | 2508 root->AddChild(child.Pass()); |
| 2509 | 2509 |
| 2510 myHostImpl->activeTree()->SetRootLayer(root.Pass()); | 2510 myHostImpl->activeTree()->SetRootLayer(root.Pass()); |
| 2511 return myHostImpl.Pass(); | 2511 return myHostImpl.Pass(); |
| 2512 } | 2512 } |
| 2513 | 2513 |
| 2514 TEST_F(LayerTreeHostImplTest, contributingLayerEmptyScissorPartialSwap) | 2514 TEST_F(LayerTreeHostImplTest, contributingLayerEmptyScissorPartialSwap) |
| 2515 { | 2515 { |
| 2516 scoped_ptr<LayerTreeHostImpl> myHostImpl = setupLayersForOpacity(true, this,
&m_proxy); | 2516 scoped_ptr<LayerTreeHostImpl> myHostImpl = setupLayersForOpacity(true, this,
&m_proxy); |
| 2517 | 2517 |
| 2518 { | 2518 { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2608 | 2608 |
| 2609 TEST_F(LayerTreeHostImplTest, layersFreeTextures) | 2609 TEST_F(LayerTreeHostImplTest, layersFreeTextures) |
| 2610 { | 2610 { |
| 2611 scoped_ptr<TestWebGraphicsContext3D> context = | 2611 scoped_ptr<TestWebGraphicsContext3D> context = |
| 2612 TestWebGraphicsContext3D::Create(); | 2612 TestWebGraphicsContext3D::Create(); |
| 2613 TestWebGraphicsContext3D* context3d = context.get(); | 2613 TestWebGraphicsContext3D* context3d = context.get(); |
| 2614 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d( | 2614 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d( |
| 2615 context.PassAs<WebKit::WebGraphicsContext3D>()).PassAs<OutputSurface>(); | 2615 context.PassAs<WebKit::WebGraphicsContext3D>()).PassAs<OutputSurface>(); |
| 2616 m_hostImpl->initializeRenderer(outputSurface.Pass()); | 2616 m_hostImpl->initializeRenderer(outputSurface.Pass()); |
| 2617 | 2617 |
| 2618 scoped_ptr<LayerImpl> rootLayer(LayerImpl::create(m_hostImpl->activeTree(),
1)); | 2618 scoped_ptr<LayerImpl> rootLayer(LayerImpl::Create(m_hostImpl->activeTree(),
1)); |
| 2619 rootLayer->setBounds(gfx::Size(10, 10)); | 2619 rootLayer->SetBounds(gfx::Size(10, 10)); |
| 2620 rootLayer->setAnchorPoint(gfx::PointF(0, 0)); | 2620 rootLayer->SetAnchorPoint(gfx::PointF()); |
| 2621 | 2621 |
| 2622 scoped_refptr<VideoFrame> softwareFrame(media::VideoFrame::CreateColorFrame( | 2622 scoped_refptr<VideoFrame> softwareFrame(media::VideoFrame::CreateColorFrame( |
| 2623 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta())); | 2623 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta())); |
| 2624 FakeVideoFrameProvider provider; | 2624 FakeVideoFrameProvider provider; |
| 2625 provider.set_frame(softwareFrame); | 2625 provider.set_frame(softwareFrame); |
| 2626 scoped_ptr<VideoLayerImpl> videoLayer = VideoLayerImpl::create(m_hostImpl->a
ctiveTree(), 4, &provider); | 2626 scoped_ptr<VideoLayerImpl> videoLayer = VideoLayerImpl::Create(m_hostImpl->a
ctiveTree(), 4, &provider); |
| 2627 videoLayer->setBounds(gfx::Size(10, 10)); | 2627 videoLayer->SetBounds(gfx::Size(10, 10)); |
| 2628 videoLayer->setAnchorPoint(gfx::PointF(0, 0)); | 2628 videoLayer->SetAnchorPoint(gfx::PointF(0, 0)); |
| 2629 videoLayer->setContentBounds(gfx::Size(10, 10)); | 2629 videoLayer->SetContentBounds(gfx::Size(10, 10)); |
| 2630 videoLayer->setDrawsContent(true); | 2630 videoLayer->SetDrawsContent(true); |
| 2631 rootLayer->addChild(videoLayer.PassAs<LayerImpl>()); | 2631 rootLayer->AddChild(videoLayer.PassAs<LayerImpl>()); |
| 2632 | 2632 |
| 2633 scoped_ptr<IOSurfaceLayerImpl> ioSurfaceLayer = IOSurfaceLayerImpl::create(m
_hostImpl->activeTree(), 5); | 2633 scoped_ptr<IOSurfaceLayerImpl> ioSurfaceLayer = IOSurfaceLayerImpl::Create(m
_hostImpl->activeTree(), 5); |
| 2634 ioSurfaceLayer->setBounds(gfx::Size(10, 10)); | 2634 ioSurfaceLayer->SetBounds(gfx::Size(10, 10)); |
| 2635 ioSurfaceLayer->setAnchorPoint(gfx::PointF(0, 0)); | 2635 ioSurfaceLayer->SetAnchorPoint(gfx::PointF(0, 0)); |
| 2636 ioSurfaceLayer->setContentBounds(gfx::Size(10, 10)); | 2636 ioSurfaceLayer->SetContentBounds(gfx::Size(10, 10)); |
| 2637 ioSurfaceLayer->setDrawsContent(true); | 2637 ioSurfaceLayer->SetDrawsContent(true); |
| 2638 ioSurfaceLayer->setIOSurfaceProperties(1, gfx::Size(10, 10)); | 2638 ioSurfaceLayer->setIOSurfaceProperties(1, gfx::Size(10, 10)); |
| 2639 rootLayer->addChild(ioSurfaceLayer.PassAs<LayerImpl>()); | 2639 rootLayer->AddChild(ioSurfaceLayer.PassAs<LayerImpl>()); |
| 2640 | 2640 |
| 2641 m_hostImpl->activeTree()->SetRootLayer(rootLayer.Pass()); | 2641 m_hostImpl->activeTree()->SetRootLayer(rootLayer.Pass()); |
| 2642 | 2642 |
| 2643 EXPECT_EQ(0u, context3d->NumTextures()); | 2643 EXPECT_EQ(0u, context3d->NumTextures()); |
| 2644 | 2644 |
| 2645 LayerTreeHostImpl::FrameData frame; | 2645 LayerTreeHostImpl::FrameData frame; |
| 2646 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2646 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 2647 m_hostImpl->drawLayers(frame); | 2647 m_hostImpl->drawLayers(frame); |
| 2648 m_hostImpl->didDrawAllLayers(frame); | 2648 m_hostImpl->didDrawAllLayers(frame); |
| 2649 m_hostImpl->swapBuffers(); | 2649 m_hostImpl->swapBuffers(); |
| 2650 | 2650 |
| 2651 EXPECT_GT(context3d->NumTextures(), 0u); | 2651 EXPECT_GT(context3d->NumTextures(), 0u); |
| 2652 | 2652 |
| 2653 // Kill the layer tree. | 2653 // Kill the layer tree. |
| 2654 m_hostImpl->activeTree()->SetRootLayer(LayerImpl::create(m_hostImpl->activeT
ree(), 100)); | 2654 m_hostImpl->activeTree()->SetRootLayer(LayerImpl::Create(m_hostImpl->activeT
ree(), 100)); |
| 2655 // There should be no textures left in use after. | 2655 // There should be no textures left in use after. |
| 2656 EXPECT_EQ(0u, context3d->NumTextures()); | 2656 EXPECT_EQ(0u, context3d->NumTextures()); |
| 2657 } | 2657 } |
| 2658 | 2658 |
| 2659 class MockDrawQuadsToFillScreenContext : public TestWebGraphicsContext3D { | 2659 class MockDrawQuadsToFillScreenContext : public TestWebGraphicsContext3D { |
| 2660 public: | 2660 public: |
| 2661 MOCK_METHOD1(useProgram, void(WebKit::WebGLId program)); | 2661 MOCK_METHOD1(useProgram, void(WebKit::WebGLId program)); |
| 2662 MOCK_METHOD4(drawElements, void(WebKit::WGC3Denum mode, WebKit::WGC3Dsizei c
ount, WebKit::WGC3Denum type, WebKit::WGC3Dintptr offset)); | 2662 MOCK_METHOD4(drawElements, void(WebKit::WGC3Denum mode, WebKit::WGC3Dsizei c
ount, WebKit::WGC3Denum type, WebKit::WGC3Dintptr offset)); |
| 2663 }; | 2663 }; |
| 2664 | 2664 |
| 2665 TEST_F(LayerTreeHostImplTest, hasTransparentBackground) | 2665 TEST_F(LayerTreeHostImplTest, hasTransparentBackground) |
| 2666 { | 2666 { |
| 2667 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new MockDrawQuadsToFillScreenContext)).PassAs
<OutputSurface>(); | 2667 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new MockDrawQuadsToFillScreenContext)).PassAs
<OutputSurface>(); |
| 2668 MockDrawQuadsToFillScreenContext* mockContext = static_cast<MockDrawQuadsToF
illScreenContext*>(outputSurface->context3d()); | 2668 MockDrawQuadsToFillScreenContext* mockContext = static_cast<MockDrawQuadsToF
illScreenContext*>(outputSurface->context3d()); |
| 2669 | 2669 |
| 2670 // Run test case | 2670 // Run test case |
| 2671 createLayerTreeHost(false, outputSurface.Pass()); | 2671 createLayerTreeHost(false, outputSurface.Pass()); |
| 2672 setupRootLayerImpl(LayerImpl::create(m_hostImpl->activeTree(), 1)); | 2672 setupRootLayerImpl(LayerImpl::Create(m_hostImpl->activeTree(), 1)); |
| 2673 m_hostImpl->activeTree()->set_background_color(SK_ColorWHITE); | 2673 m_hostImpl->activeTree()->set_background_color(SK_ColorWHITE); |
| 2674 | 2674 |
| 2675 // Verify one quad is drawn when transparent background set is not set. | 2675 // Verify one quad is drawn when transparent background set is not set. |
| 2676 m_hostImpl->activeTree()->set_has_transparent_background(false); | 2676 m_hostImpl->activeTree()->set_has_transparent_background(false); |
| 2677 EXPECT_CALL(*mockContext, useProgram(_)) | 2677 EXPECT_CALL(*mockContext, useProgram(_)) |
| 2678 .Times(1); | 2678 .Times(1); |
| 2679 EXPECT_CALL(*mockContext, drawElements(_, _, _, _)) | 2679 EXPECT_CALL(*mockContext, drawElements(_, _, _, _)) |
| 2680 .Times(1); | 2680 .Times(1); |
| 2681 LayerTreeHostImpl::FrameData frame; | 2681 LayerTreeHostImpl::FrameData frame; |
| 2682 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2682 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 2683 m_hostImpl->drawLayers(frame); | 2683 m_hostImpl->drawLayers(frame); |
| 2684 m_hostImpl->didDrawAllLayers(frame); | 2684 m_hostImpl->didDrawAllLayers(frame); |
| 2685 Mock::VerifyAndClearExpectations(&mockContext); | 2685 Mock::VerifyAndClearExpectations(&mockContext); |
| 2686 | 2686 |
| 2687 // Verify no quads are drawn when transparent background is set. | 2687 // Verify no quads are drawn when transparent background is set. |
| 2688 m_hostImpl->activeTree()->set_has_transparent_background(true); | 2688 m_hostImpl->activeTree()->set_has_transparent_background(true); |
| 2689 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2689 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 2690 m_hostImpl->drawLayers(frame); | 2690 m_hostImpl->drawLayers(frame); |
| 2691 m_hostImpl->didDrawAllLayers(frame); | 2691 m_hostImpl->didDrawAllLayers(frame); |
| 2692 Mock::VerifyAndClearExpectations(&mockContext); | 2692 Mock::VerifyAndClearExpectations(&mockContext); |
| 2693 } | 2693 } |
| 2694 | 2694 |
| 2695 static void addDrawingLayerTo(LayerImpl* parent, int id, const gfx::Rect& layerR
ect, LayerImpl** result) | 2695 static void addDrawingLayerTo(LayerImpl* parent, int id, const gfx::Rect& layerR
ect, LayerImpl** result) |
| 2696 { | 2696 { |
| 2697 scoped_ptr<LayerImpl> layer = FakeLayerWithQuads::create(parent->layerTreeIm
pl(), id); | 2697 scoped_ptr<LayerImpl> layer = FakeLayerWithQuads::Create(parent->layer_tree_
impl(), id); |
| 2698 LayerImpl* layerPtr = layer.get(); | 2698 LayerImpl* layerPtr = layer.get(); |
| 2699 layerPtr->setAnchorPoint(gfx::PointF(0, 0)); | 2699 layerPtr->SetAnchorPoint(gfx::PointF(0, 0)); |
| 2700 layerPtr->setPosition(gfx::PointF(layerRect.origin())); | 2700 layerPtr->SetPosition(gfx::PointF(layerRect.origin())); |
| 2701 layerPtr->setBounds(layerRect.size()); | 2701 layerPtr->SetBounds(layerRect.size()); |
| 2702 layerPtr->setContentBounds(layerRect.size()); | 2702 layerPtr->SetContentBounds(layerRect.size()); |
| 2703 layerPtr->setDrawsContent(true); // only children draw content | 2703 layerPtr->SetDrawsContent(true); // only children draw content |
| 2704 layerPtr->setContentsOpaque(true); | 2704 layerPtr->SetContentsOpaque(true); |
| 2705 parent->addChild(layer.Pass()); | 2705 parent->AddChild(layer.Pass()); |
| 2706 if (result) | 2706 if (result) |
| 2707 *result = layerPtr; | 2707 *result = layerPtr; |
| 2708 } | 2708 } |
| 2709 | 2709 |
| 2710 static void setupLayersForTextureCaching(LayerTreeHostImpl* layerTreeHostImpl, L
ayerImpl*& rootPtr, LayerImpl*& intermediateLayerPtr, LayerImpl*& surfaceLayerPt
r, LayerImpl*& childPtr, const gfx::Size& rootSize) | 2710 static void setupLayersForTextureCaching(LayerTreeHostImpl* layerTreeHostImpl, L
ayerImpl*& rootPtr, LayerImpl*& intermediateLayerPtr, LayerImpl*& surfaceLayerPt
r, LayerImpl*& childPtr, const gfx::Size& rootSize) |
| 2711 { | 2711 { |
| 2712 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); | 2712 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); |
| 2713 | 2713 |
| 2714 layerTreeHostImpl->initializeRenderer(outputSurface.Pass()); | 2714 layerTreeHostImpl->initializeRenderer(outputSurface.Pass()); |
| 2715 layerTreeHostImpl->setViewportSize(rootSize, rootSize); | 2715 layerTreeHostImpl->setViewportSize(rootSize, rootSize); |
| 2716 | 2716 |
| 2717 scoped_ptr<LayerImpl> root = LayerImpl::create(layerTreeHostImpl->activeTree
(), 1); | 2717 scoped_ptr<LayerImpl> root = LayerImpl::Create(layerTreeHostImpl->activeTree
(), 1); |
| 2718 rootPtr = root.get(); | 2718 rootPtr = root.get(); |
| 2719 | 2719 |
| 2720 root->setAnchorPoint(gfx::PointF(0, 0)); | 2720 root->SetAnchorPoint(gfx::PointF(0, 0)); |
| 2721 root->setPosition(gfx::PointF(0, 0)); | 2721 root->SetPosition(gfx::PointF(0, 0)); |
| 2722 root->setBounds(rootSize); | 2722 root->SetBounds(rootSize); |
| 2723 root->setContentBounds(rootSize); | 2723 root->SetContentBounds(rootSize); |
| 2724 root->setDrawsContent(true); | 2724 root->SetDrawsContent(true); |
| 2725 layerTreeHostImpl->activeTree()->SetRootLayer(root.Pass()); | 2725 layerTreeHostImpl->activeTree()->SetRootLayer(root.Pass()); |
| 2726 | 2726 |
| 2727 addDrawingLayerTo(rootPtr, 2, gfx::Rect(10, 10, rootSize.width(), rootSize.h
eight()), &intermediateLayerPtr); | 2727 addDrawingLayerTo(rootPtr, 2, gfx::Rect(10, 10, rootSize.width(), rootSize.h
eight()), &intermediateLayerPtr); |
| 2728 intermediateLayerPtr->setDrawsContent(false); // only children draw content | 2728 intermediateLayerPtr->SetDrawsContent(false); // only children draw content |
| 2729 | 2729 |
| 2730 // Surface layer is the layer that changes its opacity | 2730 // Surface layer is the layer that changes its opacity |
| 2731 // It will contain other layers that draw content. | 2731 // It will contain other layers that draw content. |
| 2732 addDrawingLayerTo(intermediateLayerPtr, 3, gfx::Rect(10, 10, rootSize.width(
), rootSize.height()), &surfaceLayerPtr); | 2732 addDrawingLayerTo(intermediateLayerPtr, 3, gfx::Rect(10, 10, rootSize.width(
), rootSize.height()), &surfaceLayerPtr); |
| 2733 surfaceLayerPtr->setDrawsContent(false); // only children draw content | 2733 surfaceLayerPtr->SetDrawsContent(false); // only children draw content |
| 2734 surfaceLayerPtr->setOpacity(0.5f); | 2734 surfaceLayerPtr->SetOpacity(0.5f); |
| 2735 surfaceLayerPtr->setForceRenderSurface(true); // This will cause it to have
a surface | 2735 surfaceLayerPtr->SetForceRenderSurface(true); // This will cause it to have
a surface |
| 2736 | 2736 |
| 2737 // Child of the surface layer will produce some quads | 2737 // Child of the surface layer will produce some quads |
| 2738 addDrawingLayerTo(surfaceLayerPtr, 4, gfx::Rect(5, 5, rootSize.width() - 25,
rootSize.height() - 25), &childPtr); | 2738 addDrawingLayerTo(surfaceLayerPtr, 4, gfx::Rect(5, 5, rootSize.width() - 25,
rootSize.height() - 25), &childPtr); |
| 2739 } | 2739 } |
| 2740 | 2740 |
| 2741 class GLRendererWithReleaseTextures : public GLRenderer { | 2741 class GLRendererWithReleaseTextures : public GLRenderer { |
| 2742 public: | 2742 public: |
| 2743 using GLRenderer::releaseRenderPassTextures; | 2743 using GLRenderer::releaseRenderPassTextures; |
| 2744 }; | 2744 }; |
| 2745 | 2745 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2768 LayerImpl* layerS1Ptr; | 2768 LayerImpl* layerS1Ptr; |
| 2769 LayerImpl* layerS2Ptr; | 2769 LayerImpl* layerS2Ptr; |
| 2770 | 2770 |
| 2771 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); | 2771 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); |
| 2772 | 2772 |
| 2773 gfx::Size rootSize(1000, 1000); | 2773 gfx::Size rootSize(1000, 1000); |
| 2774 | 2774 |
| 2775 myHostImpl->initializeRenderer(outputSurface.Pass()); | 2775 myHostImpl->initializeRenderer(outputSurface.Pass()); |
| 2776 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); | 2776 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); |
| 2777 | 2777 |
| 2778 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl->activeTree(), 1); | 2778 scoped_ptr<LayerImpl> root = LayerImpl::Create(myHostImpl->activeTree(), 1); |
| 2779 rootPtr = root.get(); | 2779 rootPtr = root.get(); |
| 2780 | 2780 |
| 2781 root->setAnchorPoint(gfx::PointF(0, 0)); | 2781 root->SetAnchorPoint(gfx::PointF(0, 0)); |
| 2782 root->setPosition(gfx::PointF(0, 0)); | 2782 root->SetPosition(gfx::PointF(0, 0)); |
| 2783 root->setBounds(rootSize); | 2783 root->SetBounds(rootSize); |
| 2784 root->setContentBounds(rootSize); | 2784 root->SetContentBounds(rootSize); |
| 2785 root->setDrawsContent(true); | 2785 root->SetDrawsContent(true); |
| 2786 root->setMasksToBounds(true); | 2786 root->SetMasksToBounds(true); |
| 2787 myHostImpl->activeTree()->SetRootLayer(root.Pass()); | 2787 myHostImpl->activeTree()->SetRootLayer(root.Pass()); |
| 2788 | 2788 |
| 2789 addDrawingLayerTo(rootPtr, 2, gfx::Rect(300, 300, 300, 300), &layerS1Ptr); | 2789 addDrawingLayerTo(rootPtr, 2, gfx::Rect(300, 300, 300, 300), &layerS1Ptr); |
| 2790 layerS1Ptr->setForceRenderSurface(true); | 2790 layerS1Ptr->SetForceRenderSurface(true); |
| 2791 | 2791 |
| 2792 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(10, 10, 10, 10), 0); // L11 | 2792 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(10, 10, 10, 10), 0); // L11 |
| 2793 addDrawingLayerTo(layerS1Ptr, 4, gfx::Rect(0, 0, 30, 30), 0); // L12 | 2793 addDrawingLayerTo(layerS1Ptr, 4, gfx::Rect(0, 0, 30, 30), 0); // L12 |
| 2794 | 2794 |
| 2795 addDrawingLayerTo(rootPtr, 5, gfx::Rect(550, 250, 300, 400), &layerS2Ptr); | 2795 addDrawingLayerTo(rootPtr, 5, gfx::Rect(550, 250, 300, 400), &layerS2Ptr); |
| 2796 layerS2Ptr->setForceRenderSurface(true); | 2796 layerS2Ptr->SetForceRenderSurface(true); |
| 2797 | 2797 |
| 2798 addDrawingLayerTo(layerS2Ptr, 6, gfx::Rect(20, 20, 5, 5), 0); // L21 | 2798 addDrawingLayerTo(layerS2Ptr, 6, gfx::Rect(20, 20, 5, 5), 0); // L21 |
| 2799 | 2799 |
| 2800 // Initial draw - must receive all quads | 2800 // Initial draw - must receive all quads |
| 2801 { | 2801 { |
| 2802 LayerTreeHostImpl::FrameData frame; | 2802 LayerTreeHostImpl::FrameData frame; |
| 2803 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 2803 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
| 2804 | 2804 |
| 2805 // Must receive 3 render passes. | 2805 // Must receive 3 render passes. |
| 2806 // For Root, there are 2 quads; for S1, there are 2 quads (1 is occluded
); for S2, there is 2 quads. | 2806 // For Root, there are 2 quads; for S1, there are 2 quads (1 is occluded
); for S2, there is 2 quads. |
| 2807 ASSERT_EQ(3U, frame.renderPasses.size()); | 2807 ASSERT_EQ(3U, frame.renderPasses.size()); |
| 2808 | 2808 |
| 2809 EXPECT_EQ(2U, frame.renderPasses[0]->quad_list.size()); | 2809 EXPECT_EQ(2U, frame.renderPasses[0]->quad_list.size()); |
| 2810 EXPECT_EQ(2U, frame.renderPasses[1]->quad_list.size()); | 2810 EXPECT_EQ(2U, frame.renderPasses[1]->quad_list.size()); |
| 2811 EXPECT_EQ(2U, frame.renderPasses[2]->quad_list.size()); | 2811 EXPECT_EQ(2U, frame.renderPasses[2]->quad_list.size()); |
| 2812 | 2812 |
| 2813 myHostImpl->drawLayers(frame); | 2813 myHostImpl->drawLayers(frame); |
| 2814 myHostImpl->didDrawAllLayers(frame); | 2814 myHostImpl->didDrawAllLayers(frame); |
| 2815 } | 2815 } |
| 2816 | 2816 |
| 2817 // "Unocclude" surface S1 and repeat draw. | 2817 // "Unocclude" surface S1 and repeat draw. |
| 2818 // Must remove S2's render pass since it's cached; | 2818 // Must remove S2's render pass since it's cached; |
| 2819 // Must keep S1 quads because texture contained external occlusion. | 2819 // Must keep S1 quads because texture contained external occlusion. |
| 2820 gfx::Transform transform = layerS2Ptr->transform(); | 2820 gfx::Transform transform = layerS2Ptr->transform(); |
| 2821 transform.Translate(150, 150); | 2821 transform.Translate(150, 150); |
| 2822 layerS2Ptr->setTransform(transform); | 2822 layerS2Ptr->SetTransform(transform); |
| 2823 { | 2823 { |
| 2824 LayerTreeHostImpl::FrameData frame; | 2824 LayerTreeHostImpl::FrameData frame; |
| 2825 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 2825 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
| 2826 | 2826 |
| 2827 // Must receive 2 render passes. | 2827 // Must receive 2 render passes. |
| 2828 // For Root, there are 2 quads | 2828 // For Root, there are 2 quads |
| 2829 // For S1, the number of quads depends on what got unoccluded, so not as
serted beyond being positive. | 2829 // For S1, the number of quads depends on what got unoccluded, so not as
serted beyond being positive. |
| 2830 // For S2, there is no render pass | 2830 // For S2, there is no render pass |
| 2831 ASSERT_EQ(2U, frame.renderPasses.size()); | 2831 ASSERT_EQ(2U, frame.renderPasses.size()); |
| 2832 | 2832 |
| 2833 EXPECT_GT(frame.renderPasses[0]->quad_list.size(), 0U); | 2833 EXPECT_GT(frame.renderPasses[0]->quad_list.size(), 0U); |
| 2834 EXPECT_EQ(2U, frame.renderPasses[1]->quad_list.size()); | 2834 EXPECT_EQ(2U, frame.renderPasses[1]->quad_list.size()); |
| 2835 | 2835 |
| 2836 myHostImpl->drawLayers(frame); | 2836 myHostImpl->drawLayers(frame); |
| 2837 myHostImpl->didDrawAllLayers(frame); | 2837 myHostImpl->didDrawAllLayers(frame); |
| 2838 } | 2838 } |
| 2839 | 2839 |
| 2840 // "Re-occlude" surface S1 and repeat draw. | 2840 // "Re-occlude" surface S1 and repeat draw. |
| 2841 // Must remove S1's render pass since it is now available in full. | 2841 // Must remove S1's render pass since it is now available in full. |
| 2842 // S2 has no change so must also be removed. | 2842 // S2 has no change so must also be removed. |
| 2843 transform = layerS2Ptr->transform(); | 2843 transform = layerS2Ptr->transform(); |
| 2844 transform.Translate(-15, -15); | 2844 transform.Translate(-15, -15); |
| 2845 layerS2Ptr->setTransform(transform); | 2845 layerS2Ptr->SetTransform(transform); |
| 2846 { | 2846 { |
| 2847 LayerTreeHostImpl::FrameData frame; | 2847 LayerTreeHostImpl::FrameData frame; |
| 2848 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 2848 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
| 2849 | 2849 |
| 2850 // Must receive 1 render pass - for the root. | 2850 // Must receive 1 render pass - for the root. |
| 2851 ASSERT_EQ(1U, frame.renderPasses.size()); | 2851 ASSERT_EQ(1U, frame.renderPasses.size()); |
| 2852 | 2852 |
| 2853 EXPECT_EQ(2U, frame.renderPasses[0]->quad_list.size()); | 2853 EXPECT_EQ(2U, frame.renderPasses[0]->quad_list.size()); |
| 2854 | 2854 |
| 2855 myHostImpl->drawLayers(frame); | 2855 myHostImpl->drawLayers(frame); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2880 LayerImpl* layerS1Ptr; | 2880 LayerImpl* layerS1Ptr; |
| 2881 LayerImpl* layerS2Ptr; | 2881 LayerImpl* layerS2Ptr; |
| 2882 | 2882 |
| 2883 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); | 2883 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); |
| 2884 | 2884 |
| 2885 gfx::Size rootSize(1000, 1000); | 2885 gfx::Size rootSize(1000, 1000); |
| 2886 | 2886 |
| 2887 myHostImpl->initializeRenderer(outputSurface.Pass()); | 2887 myHostImpl->initializeRenderer(outputSurface.Pass()); |
| 2888 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); | 2888 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); |
| 2889 | 2889 |
| 2890 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl->activeTree(), 1); | 2890 scoped_ptr<LayerImpl> root = LayerImpl::Create(myHostImpl->activeTree(), 1); |
| 2891 rootPtr = root.get(); | 2891 rootPtr = root.get(); |
| 2892 | 2892 |
| 2893 root->setAnchorPoint(gfx::PointF(0, 0)); | 2893 root->SetAnchorPoint(gfx::PointF(0, 0)); |
| 2894 root->setPosition(gfx::PointF(0, 0)); | 2894 root->SetPosition(gfx::PointF(0, 0)); |
| 2895 root->setBounds(rootSize); | 2895 root->SetBounds(rootSize); |
| 2896 root->setContentBounds(rootSize); | 2896 root->SetContentBounds(rootSize); |
| 2897 root->setDrawsContent(true); | 2897 root->SetDrawsContent(true); |
| 2898 root->setMasksToBounds(true); | 2898 root->SetMasksToBounds(true); |
| 2899 myHostImpl->activeTree()->SetRootLayer(root.Pass()); | 2899 myHostImpl->activeTree()->SetRootLayer(root.Pass()); |
| 2900 | 2900 |
| 2901 addDrawingLayerTo(rootPtr, 2, gfx::Rect(0, 0, 800, 800), &layerS1Ptr); | 2901 addDrawingLayerTo(rootPtr, 2, gfx::Rect(0, 0, 800, 800), &layerS1Ptr); |
| 2902 layerS1Ptr->setForceRenderSurface(true); | 2902 layerS1Ptr->SetForceRenderSurface(true); |
| 2903 layerS1Ptr->setDrawsContent(false); | 2903 layerS1Ptr->SetDrawsContent(false); |
| 2904 | 2904 |
| 2905 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(0, 0, 300, 300), 0); // L11 | 2905 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(0, 0, 300, 300), 0); // L11 |
| 2906 addDrawingLayerTo(layerS1Ptr, 4, gfx::Rect(0, 500, 300, 300), 0); // L12 | 2906 addDrawingLayerTo(layerS1Ptr, 4, gfx::Rect(0, 500, 300, 300), 0); // L12 |
| 2907 addDrawingLayerTo(layerS1Ptr, 5, gfx::Rect(500, 0, 300, 300), 0); // L13 | 2907 addDrawingLayerTo(layerS1Ptr, 5, gfx::Rect(500, 0, 300, 300), 0); // L13 |
| 2908 addDrawingLayerTo(layerS1Ptr, 6, gfx::Rect(500, 500, 300, 300), 0); // L14 | 2908 addDrawingLayerTo(layerS1Ptr, 6, gfx::Rect(500, 500, 300, 300), 0); // L14 |
| 2909 addDrawingLayerTo(layerS1Ptr, 9, gfx::Rect(500, 500, 300, 300), 0); // L14 | 2909 addDrawingLayerTo(layerS1Ptr, 9, gfx::Rect(500, 500, 300, 300), 0); // L14 |
| 2910 | 2910 |
| 2911 addDrawingLayerTo(rootPtr, 7, gfx::Rect(450, 450, 450, 450), &layerS2Ptr); | 2911 addDrawingLayerTo(rootPtr, 7, gfx::Rect(450, 450, 450, 450), &layerS2Ptr); |
| 2912 layerS2Ptr->setForceRenderSurface(true); | 2912 layerS2Ptr->SetForceRenderSurface(true); |
| 2913 | 2913 |
| 2914 // Initial draw - must receive all quads | 2914 // Initial draw - must receive all quads |
| 2915 { | 2915 { |
| 2916 LayerTreeHostImpl::FrameData frame; | 2916 LayerTreeHostImpl::FrameData frame; |
| 2917 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 2917 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
| 2918 | 2918 |
| 2919 // Must receive 3 render passes. | 2919 // Must receive 3 render passes. |
| 2920 // For Root, there are 2 quads; for S1, there are 3 quads; for S2, there
is 1 quad. | 2920 // For Root, there are 2 quads; for S1, there are 3 quads; for S2, there
is 1 quad. |
| 2921 ASSERT_EQ(3U, frame.renderPasses.size()); | 2921 ASSERT_EQ(3U, frame.renderPasses.size()); |
| 2922 | 2922 |
| 2923 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size()); | 2923 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size()); |
| 2924 | 2924 |
| 2925 // L14 is culled, so only 3 quads. | 2925 // L14 is culled, so only 3 quads. |
| 2926 EXPECT_EQ(3U, frame.renderPasses[1]->quad_list.size()); | 2926 EXPECT_EQ(3U, frame.renderPasses[1]->quad_list.size()); |
| 2927 EXPECT_EQ(2U, frame.renderPasses[2]->quad_list.size()); | 2927 EXPECT_EQ(2U, frame.renderPasses[2]->quad_list.size()); |
| 2928 | 2928 |
| 2929 myHostImpl->drawLayers(frame); | 2929 myHostImpl->drawLayers(frame); |
| 2930 myHostImpl->didDrawAllLayers(frame); | 2930 myHostImpl->didDrawAllLayers(frame); |
| 2931 } | 2931 } |
| 2932 | 2932 |
| 2933 // "Unocclude" surface S1 and repeat draw. | 2933 // "Unocclude" surface S1 and repeat draw. |
| 2934 // Must remove S2's render pass since it's cached; | 2934 // Must remove S2's render pass since it's cached; |
| 2935 // Must keep S1 quads because texture contained external occlusion. | 2935 // Must keep S1 quads because texture contained external occlusion. |
| 2936 gfx::Transform transform = layerS2Ptr->transform(); | 2936 gfx::Transform transform = layerS2Ptr->transform(); |
| 2937 transform.Translate(100, 100); | 2937 transform.Translate(100, 100); |
| 2938 layerS2Ptr->setTransform(transform); | 2938 layerS2Ptr->SetTransform(transform); |
| 2939 { | 2939 { |
| 2940 LayerTreeHostImpl::FrameData frame; | 2940 LayerTreeHostImpl::FrameData frame; |
| 2941 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 2941 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
| 2942 | 2942 |
| 2943 // Must receive 2 render passes. | 2943 // Must receive 2 render passes. |
| 2944 // For Root, there are 2 quads | 2944 // For Root, there are 2 quads |
| 2945 // For S1, the number of quads depends on what got unoccluded, so not as
serted beyond being positive. | 2945 // For S1, the number of quads depends on what got unoccluded, so not as
serted beyond being positive. |
| 2946 // For S2, there is no render pass | 2946 // For S2, there is no render pass |
| 2947 ASSERT_EQ(2U, frame.renderPasses.size()); | 2947 ASSERT_EQ(2U, frame.renderPasses.size()); |
| 2948 | 2948 |
| 2949 EXPECT_GT(frame.renderPasses[0]->quad_list.size(), 0U); | 2949 EXPECT_GT(frame.renderPasses[0]->quad_list.size(), 0U); |
| 2950 EXPECT_EQ(2U, frame.renderPasses[1]->quad_list.size()); | 2950 EXPECT_EQ(2U, frame.renderPasses[1]->quad_list.size()); |
| 2951 | 2951 |
| 2952 myHostImpl->drawLayers(frame); | 2952 myHostImpl->drawLayers(frame); |
| 2953 myHostImpl->didDrawAllLayers(frame); | 2953 myHostImpl->didDrawAllLayers(frame); |
| 2954 } | 2954 } |
| 2955 | 2955 |
| 2956 // "Re-occlude" surface S1 and repeat draw. | 2956 // "Re-occlude" surface S1 and repeat draw. |
| 2957 // Must remove S1's render pass since it is now available in full. | 2957 // Must remove S1's render pass since it is now available in full. |
| 2958 // S2 has no change so must also be removed. | 2958 // S2 has no change so must also be removed. |
| 2959 transform = layerS2Ptr->transform(); | 2959 transform = layerS2Ptr->transform(); |
| 2960 transform.Translate(-15, -15); | 2960 transform.Translate(-15, -15); |
| 2961 layerS2Ptr->setTransform(transform); | 2961 layerS2Ptr->SetTransform(transform); |
| 2962 { | 2962 { |
| 2963 LayerTreeHostImpl::FrameData frame; | 2963 LayerTreeHostImpl::FrameData frame; |
| 2964 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 2964 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
| 2965 | 2965 |
| 2966 // Must receive 1 render pass - for the root. | 2966 // Must receive 1 render pass - for the root. |
| 2967 ASSERT_EQ(1U, frame.renderPasses.size()); | 2967 ASSERT_EQ(1U, frame.renderPasses.size()); |
| 2968 | 2968 |
| 2969 EXPECT_EQ(2U, frame.renderPasses[0]->quad_list.size()); | 2969 EXPECT_EQ(2U, frame.renderPasses[0]->quad_list.size()); |
| 2970 | 2970 |
| 2971 myHostImpl->drawLayers(frame); | 2971 myHostImpl->drawLayers(frame); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2993 LayerImpl* layerS1Ptr; | 2993 LayerImpl* layerS1Ptr; |
| 2994 LayerImpl* layerS2Ptr; | 2994 LayerImpl* layerS2Ptr; |
| 2995 | 2995 |
| 2996 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); | 2996 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); |
| 2997 | 2997 |
| 2998 gfx::Size rootSize(1000, 1000); | 2998 gfx::Size rootSize(1000, 1000); |
| 2999 | 2999 |
| 3000 myHostImpl->initializeRenderer(outputSurface.Pass()); | 3000 myHostImpl->initializeRenderer(outputSurface.Pass()); |
| 3001 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); | 3001 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); |
| 3002 | 3002 |
| 3003 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl->activeTree(), 1); | 3003 scoped_ptr<LayerImpl> root = LayerImpl::Create(myHostImpl->activeTree(), 1); |
| 3004 rootPtr = root.get(); | 3004 rootPtr = root.get(); |
| 3005 | 3005 |
| 3006 root->setAnchorPoint(gfx::PointF(0, 0)); | 3006 root->SetAnchorPoint(gfx::PointF(0, 0)); |
| 3007 root->setPosition(gfx::PointF(0, 0)); | 3007 root->SetPosition(gfx::PointF(0, 0)); |
| 3008 root->setBounds(rootSize); | 3008 root->SetBounds(rootSize); |
| 3009 root->setContentBounds(rootSize); | 3009 root->SetContentBounds(rootSize); |
| 3010 root->setDrawsContent(true); | 3010 root->SetDrawsContent(true); |
| 3011 root->setMasksToBounds(true); | 3011 root->SetMasksToBounds(true); |
| 3012 myHostImpl->activeTree()->SetRootLayer(root.Pass()); | 3012 myHostImpl->activeTree()->SetRootLayer(root.Pass()); |
| 3013 | 3013 |
| 3014 addDrawingLayerTo(rootPtr, 2, gfx::Rect(0, 0, 400, 400), &layerS1Ptr); | 3014 addDrawingLayerTo(rootPtr, 2, gfx::Rect(0, 0, 400, 400), &layerS1Ptr); |
| 3015 layerS1Ptr->setForceRenderSurface(true); | 3015 layerS1Ptr->SetForceRenderSurface(true); |
| 3016 | 3016 |
| 3017 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(0, 0, 300, 300), 0); // L11 | 3017 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(0, 0, 300, 300), 0); // L11 |
| 3018 addDrawingLayerTo(layerS1Ptr, 4, gfx::Rect(100, 0, 300, 300), 0); // L12 | 3018 addDrawingLayerTo(layerS1Ptr, 4, gfx::Rect(100, 0, 300, 300), 0); // L12 |
| 3019 | 3019 |
| 3020 addDrawingLayerTo(rootPtr, 7, gfx::Rect(200, 0, 300, 300), &layerS2Ptr); | 3020 addDrawingLayerTo(rootPtr, 7, gfx::Rect(200, 0, 300, 300), &layerS2Ptr); |
| 3021 layerS2Ptr->setForceRenderSurface(true); | 3021 layerS2Ptr->SetForceRenderSurface(true); |
| 3022 | 3022 |
| 3023 // Initial draw - must receive all quads | 3023 // Initial draw - must receive all quads |
| 3024 { | 3024 { |
| 3025 LayerTreeHostImpl::FrameData frame; | 3025 LayerTreeHostImpl::FrameData frame; |
| 3026 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 3026 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
| 3027 | 3027 |
| 3028 // Must receive 3 render passes. | 3028 // Must receive 3 render passes. |
| 3029 // For Root, there are 2 quads; for S1, there are 3 quads; for S2, there
is 1 quad. | 3029 // For Root, there are 2 quads; for S1, there are 3 quads; for S2, there
is 1 quad. |
| 3030 ASSERT_EQ(3U, frame.renderPasses.size()); | 3030 ASSERT_EQ(3U, frame.renderPasses.size()); |
| 3031 | 3031 |
| 3032 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size()); | 3032 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size()); |
| 3033 EXPECT_EQ(3U, frame.renderPasses[1]->quad_list.size()); | 3033 EXPECT_EQ(3U, frame.renderPasses[1]->quad_list.size()); |
| 3034 EXPECT_EQ(2U, frame.renderPasses[2]->quad_list.size()); | 3034 EXPECT_EQ(2U, frame.renderPasses[2]->quad_list.size()); |
| 3035 | 3035 |
| 3036 myHostImpl->drawLayers(frame); | 3036 myHostImpl->drawLayers(frame); |
| 3037 myHostImpl->didDrawAllLayers(frame); | 3037 myHostImpl->didDrawAllLayers(frame); |
| 3038 } | 3038 } |
| 3039 | 3039 |
| 3040 // "Unocclude" surface S1 and repeat draw. | 3040 // "Unocclude" surface S1 and repeat draw. |
| 3041 // Must remove S2's render pass since it's cached; | 3041 // Must remove S2's render pass since it's cached; |
| 3042 // Must keep S1 quads because texture contained external occlusion. | 3042 // Must keep S1 quads because texture contained external occlusion. |
| 3043 gfx::Transform transform = layerS2Ptr->transform(); | 3043 gfx::Transform transform = layerS2Ptr->transform(); |
| 3044 transform.Translate(300, 0); | 3044 transform.Translate(300, 0); |
| 3045 layerS2Ptr->setTransform(transform); | 3045 layerS2Ptr->SetTransform(transform); |
| 3046 { | 3046 { |
| 3047 LayerTreeHostImpl::FrameData frame; | 3047 LayerTreeHostImpl::FrameData frame; |
| 3048 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 3048 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
| 3049 | 3049 |
| 3050 // Must receive 2 render passes. | 3050 // Must receive 2 render passes. |
| 3051 // For Root, there are 2 quads | 3051 // For Root, there are 2 quads |
| 3052 // For S1, the number of quads depends on what got unoccluded, so not as
serted beyond being positive. | 3052 // For S1, the number of quads depends on what got unoccluded, so not as
serted beyond being positive. |
| 3053 // For S2, there is no render pass | 3053 // For S2, there is no render pass |
| 3054 ASSERT_EQ(2U, frame.renderPasses.size()); | 3054 ASSERT_EQ(2U, frame.renderPasses.size()); |
| 3055 | 3055 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3075 LayerImpl* rootPtr; | 3075 LayerImpl* rootPtr; |
| 3076 LayerImpl* layerS1Ptr; | 3076 LayerImpl* layerS1Ptr; |
| 3077 | 3077 |
| 3078 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); | 3078 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); |
| 3079 | 3079 |
| 3080 gfx::Size rootSize(1000, 1000); | 3080 gfx::Size rootSize(1000, 1000); |
| 3081 | 3081 |
| 3082 myHostImpl->initializeRenderer(outputSurface.Pass()); | 3082 myHostImpl->initializeRenderer(outputSurface.Pass()); |
| 3083 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); | 3083 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); |
| 3084 | 3084 |
| 3085 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl->activeTree(), 1); | 3085 scoped_ptr<LayerImpl> root = LayerImpl::Create(myHostImpl->activeTree(), 1); |
| 3086 rootPtr = root.get(); | 3086 rootPtr = root.get(); |
| 3087 | 3087 |
| 3088 root->setAnchorPoint(gfx::PointF(0, 0)); | 3088 root->SetAnchorPoint(gfx::PointF(0, 0)); |
| 3089 root->setPosition(gfx::PointF(0, 0)); | 3089 root->SetPosition(gfx::PointF(0, 0)); |
| 3090 root->setBounds(rootSize); | 3090 root->SetBounds(rootSize); |
| 3091 root->setContentBounds(rootSize); | 3091 root->SetContentBounds(rootSize); |
| 3092 root->setDrawsContent(true); | 3092 root->SetDrawsContent(true); |
| 3093 root->setMasksToBounds(true); | 3093 root->SetMasksToBounds(true); |
| 3094 myHostImpl->activeTree()->SetRootLayer(root.Pass()); | 3094 myHostImpl->activeTree()->SetRootLayer(root.Pass()); |
| 3095 | 3095 |
| 3096 addDrawingLayerTo(rootPtr, 2, gfx::Rect(0, 0, 400, 400), &layerS1Ptr); | 3096 addDrawingLayerTo(rootPtr, 2, gfx::Rect(0, 0, 400, 400), &layerS1Ptr); |
| 3097 layerS1Ptr->setForceRenderSurface(true); | 3097 layerS1Ptr->SetForceRenderSurface(true); |
| 3098 gfx::Transform transform = layerS1Ptr->transform(); | 3098 gfx::Transform transform = layerS1Ptr->transform(); |
| 3099 transform.Translate(200, 200); | 3099 transform.Translate(200, 200); |
| 3100 transform.Rotate(45); | 3100 transform.Rotate(45); |
| 3101 transform.Translate(-200, -200); | 3101 transform.Translate(-200, -200); |
| 3102 layerS1Ptr->setTransform(transform); | 3102 layerS1Ptr->SetTransform(transform); |
| 3103 | 3103 |
| 3104 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(200, 0, 200, 400), 0); // L11 | 3104 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(200, 0, 200, 400), 0); // L11 |
| 3105 | 3105 |
| 3106 // Initial draw - must receive all quads | 3106 // Initial draw - must receive all quads |
| 3107 { | 3107 { |
| 3108 LayerTreeHostImpl::FrameData frame; | 3108 LayerTreeHostImpl::FrameData frame; |
| 3109 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 3109 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
| 3110 | 3110 |
| 3111 // Must receive 2 render passes. | 3111 // Must receive 2 render passes. |
| 3112 ASSERT_EQ(2U, frame.renderPasses.size()); | 3112 ASSERT_EQ(2U, frame.renderPasses.size()); |
| 3113 | 3113 |
| 3114 EXPECT_EQ(2U, frame.renderPasses[0]->quad_list.size()); | 3114 EXPECT_EQ(2U, frame.renderPasses[0]->quad_list.size()); |
| 3115 EXPECT_EQ(1U, frame.renderPasses[1]->quad_list.size()); | 3115 EXPECT_EQ(1U, frame.renderPasses[1]->quad_list.size()); |
| 3116 | 3116 |
| 3117 myHostImpl->drawLayers(frame); | 3117 myHostImpl->drawLayers(frame); |
| 3118 myHostImpl->didDrawAllLayers(frame); | 3118 myHostImpl->didDrawAllLayers(frame); |
| 3119 } | 3119 } |
| 3120 | 3120 |
| 3121 // Change opacity and draw. Verify we used cached texture. | 3121 // Change opacity and draw. Verify we used cached texture. |
| 3122 layerS1Ptr->setOpacity(0.2f); | 3122 layerS1Ptr->SetOpacity(0.2f); |
| 3123 { | 3123 { |
| 3124 LayerTreeHostImpl::FrameData frame; | 3124 LayerTreeHostImpl::FrameData frame; |
| 3125 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 3125 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
| 3126 | 3126 |
| 3127 // One render pass must be gone due to cached texture. | 3127 // One render pass must be gone due to cached texture. |
| 3128 ASSERT_EQ(1U, frame.renderPasses.size()); | 3128 ASSERT_EQ(1U, frame.renderPasses.size()); |
| 3129 | 3129 |
| 3130 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size()); | 3130 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size()); |
| 3131 | 3131 |
| 3132 myHostImpl->drawLayers(frame); | 3132 myHostImpl->drawLayers(frame); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 3160 LayerImpl* layerS1Ptr; | 3160 LayerImpl* layerS1Ptr; |
| 3161 LayerImpl* layerS2Ptr; | 3161 LayerImpl* layerS2Ptr; |
| 3162 | 3162 |
| 3163 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); | 3163 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); |
| 3164 | 3164 |
| 3165 gfx::Size rootSize(1000, 1000); | 3165 gfx::Size rootSize(1000, 1000); |
| 3166 | 3166 |
| 3167 myHostImpl->initializeRenderer(outputSurface.Pass()); | 3167 myHostImpl->initializeRenderer(outputSurface.Pass()); |
| 3168 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); | 3168 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); |
| 3169 | 3169 |
| 3170 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl->activeTree(), 1); | 3170 scoped_ptr<LayerImpl> root = LayerImpl::Create(myHostImpl->activeTree(), 1); |
| 3171 rootPtr = root.get(); | 3171 rootPtr = root.get(); |
| 3172 | 3172 |
| 3173 root->setAnchorPoint(gfx::PointF(0, 0)); | 3173 root->SetAnchorPoint(gfx::PointF(0, 0)); |
| 3174 root->setPosition(gfx::PointF(0, 0)); | 3174 root->SetPosition(gfx::PointF(0, 0)); |
| 3175 root->setBounds(rootSize); | 3175 root->SetBounds(rootSize); |
| 3176 root->setContentBounds(rootSize); | 3176 root->SetContentBounds(rootSize); |
| 3177 root->setDrawsContent(true); | 3177 root->SetDrawsContent(true); |
| 3178 root->setMasksToBounds(true); | 3178 root->SetMasksToBounds(true); |
| 3179 myHostImpl->activeTree()->SetRootLayer(root.Pass()); | 3179 myHostImpl->activeTree()->SetRootLayer(root.Pass()); |
| 3180 | 3180 |
| 3181 addDrawingLayerTo(rootPtr, 2, gfx::Rect(300, 300, 300, 300), &layerS1Ptr); | 3181 addDrawingLayerTo(rootPtr, 2, gfx::Rect(300, 300, 300, 300), &layerS1Ptr); |
| 3182 layerS1Ptr->setForceRenderSurface(true); | 3182 layerS1Ptr->SetForceRenderSurface(true); |
| 3183 | 3183 |
| 3184 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(10, 10, 10, 10), 0); // L11 | 3184 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(10, 10, 10, 10), 0); // L11 |
| 3185 addDrawingLayerTo(layerS1Ptr, 4, gfx::Rect(0, 0, 30, 30), 0); // L12 | 3185 addDrawingLayerTo(layerS1Ptr, 4, gfx::Rect(0, 0, 30, 30), 0); // L12 |
| 3186 | 3186 |
| 3187 addDrawingLayerTo(rootPtr, 5, gfx::Rect(550, 250, 300, 400), &layerS2Ptr); | 3187 addDrawingLayerTo(rootPtr, 5, gfx::Rect(550, 250, 300, 400), &layerS2Ptr); |
| 3188 layerS2Ptr->setForceRenderSurface(true); | 3188 layerS2Ptr->SetForceRenderSurface(true); |
| 3189 | 3189 |
| 3190 addDrawingLayerTo(layerS2Ptr, 6, gfx::Rect(20, 20, 5, 5), 0); // L21 | 3190 addDrawingLayerTo(layerS2Ptr, 6, gfx::Rect(20, 20, 5, 5), 0); // L21 |
| 3191 | 3191 |
| 3192 // Initial draw - must receive all quads | 3192 // Initial draw - must receive all quads |
| 3193 { | 3193 { |
| 3194 LayerTreeHostImpl::FrameData frame; | 3194 LayerTreeHostImpl::FrameData frame; |
| 3195 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 3195 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
| 3196 | 3196 |
| 3197 // Must receive 3 render passes. | 3197 // Must receive 3 render passes. |
| 3198 // For Root, there are 2 quads; for S1, there are 2 quads (one is occlud
ed); for S2, there is 2 quads. | 3198 // For Root, there are 2 quads; for S1, there are 2 quads (one is occlud
ed); for S2, there is 2 quads. |
| 3199 ASSERT_EQ(3U, frame.renderPasses.size()); | 3199 ASSERT_EQ(3U, frame.renderPasses.size()); |
| 3200 | 3200 |
| 3201 EXPECT_EQ(2U, frame.renderPasses[0]->quad_list.size()); | 3201 EXPECT_EQ(2U, frame.renderPasses[0]->quad_list.size()); |
| 3202 EXPECT_EQ(2U, frame.renderPasses[1]->quad_list.size()); | 3202 EXPECT_EQ(2U, frame.renderPasses[1]->quad_list.size()); |
| 3203 EXPECT_EQ(2U, frame.renderPasses[2]->quad_list.size()); | 3203 EXPECT_EQ(2U, frame.renderPasses[2]->quad_list.size()); |
| 3204 | 3204 |
| 3205 myHostImpl->drawLayers(frame); | 3205 myHostImpl->drawLayers(frame); |
| 3206 myHostImpl->didDrawAllLayers(frame); | 3206 myHostImpl->didDrawAllLayers(frame); |
| 3207 } | 3207 } |
| 3208 | 3208 |
| 3209 // "Unocclude" surface S1 and repeat draw. | 3209 // "Unocclude" surface S1 and repeat draw. |
| 3210 // Must remove S2's render pass since it's cached; | 3210 // Must remove S2's render pass since it's cached; |
| 3211 // Must keep S1 quads because texture contained external occlusion. | 3211 // Must keep S1 quads because texture contained external occlusion. |
| 3212 gfx::Transform transform = layerS2Ptr->transform(); | 3212 gfx::Transform transform = layerS2Ptr->transform(); |
| 3213 transform.Translate(150, 150); | 3213 transform.Translate(150, 150); |
| 3214 layerS2Ptr->setTransform(transform); | 3214 layerS2Ptr->SetTransform(transform); |
| 3215 { | 3215 { |
| 3216 LayerTreeHostImpl::FrameData frame; | 3216 LayerTreeHostImpl::FrameData frame; |
| 3217 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 3217 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
| 3218 | 3218 |
| 3219 // Must receive 2 render passes. | 3219 // Must receive 2 render passes. |
| 3220 // For Root, there are 2 quads. | 3220 // For Root, there are 2 quads. |
| 3221 // For S1, there are 2 quads. | 3221 // For S1, there are 2 quads. |
| 3222 // For S2, there is no render pass | 3222 // For S2, there is no render pass |
| 3223 ASSERT_EQ(2U, frame.renderPasses.size()); | 3223 ASSERT_EQ(2U, frame.renderPasses.size()); |
| 3224 | 3224 |
| 3225 EXPECT_EQ(2U, frame.renderPasses[0]->quad_list.size()); | 3225 EXPECT_EQ(2U, frame.renderPasses[0]->quad_list.size()); |
| 3226 EXPECT_EQ(2U, frame.renderPasses[1]->quad_list.size()); | 3226 EXPECT_EQ(2U, frame.renderPasses[1]->quad_list.size()); |
| 3227 | 3227 |
| 3228 myHostImpl->drawLayers(frame); | 3228 myHostImpl->drawLayers(frame); |
| 3229 myHostImpl->didDrawAllLayers(frame); | 3229 myHostImpl->didDrawAllLayers(frame); |
| 3230 } | 3230 } |
| 3231 | 3231 |
| 3232 // "Re-occlude" surface S1 and repeat draw. | 3232 // "Re-occlude" surface S1 and repeat draw. |
| 3233 // Must remove S1's render pass since it is now available in full. | 3233 // Must remove S1's render pass since it is now available in full. |
| 3234 // S2 has no change so must also be removed. | 3234 // S2 has no change so must also be removed. |
| 3235 transform = layerS2Ptr->transform(); | 3235 transform = layerS2Ptr->transform(); |
| 3236 transform.Translate(-15, -15); | 3236 transform.Translate(-15, -15); |
| 3237 layerS2Ptr->setTransform(transform); | 3237 layerS2Ptr->SetTransform(transform); |
| 3238 { | 3238 { |
| 3239 LayerTreeHostImpl::FrameData frame; | 3239 LayerTreeHostImpl::FrameData frame; |
| 3240 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 3240 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
| 3241 | 3241 |
| 3242 // Root render pass only. | 3242 // Root render pass only. |
| 3243 ASSERT_EQ(1U, frame.renderPasses.size()); | 3243 ASSERT_EQ(1U, frame.renderPasses.size()); |
| 3244 | 3244 |
| 3245 myHostImpl->drawLayers(frame); | 3245 myHostImpl->drawLayers(frame); |
| 3246 myHostImpl->didDrawAllLayers(frame); | 3246 myHostImpl->didDrawAllLayers(frame); |
| 3247 } | 3247 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3265 | | | 3 | | 3265 | | | 3 | |
| 3266 | | +-------------------+ | 3266 | | +-------------------+ |
| 3267 | | | | | 3267 | | | | |
| 3268 | +-----------+ | | 3268 | +-----------+ | |
| 3269 | | | 3269 | | |
| 3270 | | | 3270 | | |
| 3271 +--------------------+ | 3271 +--------------------+ |
| 3272 | 3272 |
| 3273 Layers 1, 2 have render surfaces | 3273 Layers 1, 2 have render surfaces |
| 3274 */ | 3274 */ |
| 3275 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl->activeTree(), 1); | 3275 scoped_ptr<LayerImpl> root = LayerImpl::Create(myHostImpl->activeTree(), 1); |
| 3276 scoped_ptr<TiledLayerImpl> child = TiledLayerImpl::create(myHostImpl->active
Tree(), 2); | 3276 scoped_ptr<TiledLayerImpl> child = TiledLayerImpl::Create(myHostImpl->active
Tree(), 2); |
| 3277 scoped_ptr<LayerImpl> grandChild = LayerImpl::create(myHostImpl->activeTree(
), 3); | 3277 scoped_ptr<LayerImpl> grandChild = LayerImpl::Create(myHostImpl->activeTree(
), 3); |
| 3278 | 3278 |
| 3279 gfx::Rect rootRect(0, 0, 100, 100); | 3279 gfx::Rect rootRect(0, 0, 100, 100); |
| 3280 gfx::Rect childRect(10, 10, 50, 50); | 3280 gfx::Rect childRect(10, 10, 50, 50); |
| 3281 gfx::Rect grandChildRect(5, 5, 150, 150); | 3281 gfx::Rect grandChildRect(5, 5, 150, 150); |
| 3282 | 3282 |
| 3283 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); | 3283 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); |
| 3284 myHostImpl->initializeRenderer(outputSurface.Pass()); | 3284 myHostImpl->initializeRenderer(outputSurface.Pass()); |
| 3285 | 3285 |
| 3286 root->setAnchorPoint(gfx::PointF(0, 0)); | 3286 root->SetAnchorPoint(gfx::PointF(0, 0)); |
| 3287 root->setPosition(gfx::PointF(rootRect.x(), rootRect.y())); | 3287 root->SetPosition(gfx::PointF(rootRect.x(), rootRect.y())); |
| 3288 root->setBounds(gfx::Size(rootRect.width(), rootRect.height())); | 3288 root->SetBounds(gfx::Size(rootRect.width(), rootRect.height())); |
| 3289 root->setContentBounds(root->bounds()); | 3289 root->SetContentBounds(root->bounds()); |
| 3290 root->setDrawsContent(true); | 3290 root->SetDrawsContent(true); |
| 3291 root->setMasksToBounds(true); | 3291 root->SetMasksToBounds(true); |
| 3292 | 3292 |
| 3293 child->setAnchorPoint(gfx::PointF(0, 0)); | 3293 child->SetAnchorPoint(gfx::PointF(0, 0)); |
| 3294 child->setPosition(gfx::PointF(childRect.x(), childRect.y())); | 3294 child->SetPosition(gfx::PointF(childRect.x(), childRect.y())); |
| 3295 child->setOpacity(0.5); | 3295 child->SetOpacity(0.5); |
| 3296 child->setBounds(gfx::Size(childRect.width(), childRect.height())); | 3296 child->SetBounds(gfx::Size(childRect.width(), childRect.height())); |
| 3297 child->setContentBounds(child->bounds()); | 3297 child->SetContentBounds(child->bounds()); |
| 3298 child->setDrawsContent(true); | 3298 child->SetDrawsContent(true); |
| 3299 child->setSkipsDraw(false); | 3299 child->setSkipsDraw(false); |
| 3300 | 3300 |
| 3301 // child layer has 10x10 tiles. | 3301 // child layer has 10x10 tiles. |
| 3302 scoped_ptr<LayerTilingData> tiler = LayerTilingData::create(gfx::Size(10, 10
), LayerTilingData::HasBorderTexels); | 3302 scoped_ptr<LayerTilingData> tiler = LayerTilingData::create(gfx::Size(10, 10
), LayerTilingData::HasBorderTexels); |
| 3303 tiler->setBounds(child->contentBounds()); | 3303 tiler->setBounds(child->content_bounds()); |
| 3304 child->setTilingData(*tiler.get()); | 3304 child->setTilingData(*tiler.get()); |
| 3305 | 3305 |
| 3306 grandChild->setAnchorPoint(gfx::PointF(0, 0)); | 3306 grandChild->SetAnchorPoint(gfx::PointF(0, 0)); |
| 3307 grandChild->setPosition(gfx::Point(grandChildRect.x(), grandChildRect.y())); | 3307 grandChild->SetPosition(gfx::Point(grandChildRect.x(), grandChildRect.y())); |
| 3308 grandChild->setBounds(gfx::Size(grandChildRect.width(), grandChildRect.heigh
t())); | 3308 grandChild->SetBounds(gfx::Size(grandChildRect.width(), grandChildRect.heigh
t())); |
| 3309 grandChild->setContentBounds(grandChild->bounds()); | 3309 grandChild->SetContentBounds(grandChild->bounds()); |
| 3310 grandChild->setDrawsContent(true); | 3310 grandChild->SetDrawsContent(true); |
| 3311 | 3311 |
| 3312 TiledLayerImpl* childPtr = child.get(); | 3312 TiledLayerImpl* childPtr = child.get(); |
| 3313 RenderPass::Id childPassId(childPtr->id(), 0); | 3313 RenderPass::Id childPassId(childPtr->id(), 0); |
| 3314 | 3314 |
| 3315 child->addChild(grandChild.Pass()); | 3315 child->AddChild(grandChild.Pass()); |
| 3316 root->addChild(child.PassAs<LayerImpl>()); | 3316 root->AddChild(child.PassAs<LayerImpl>()); |
| 3317 myHostImpl->activeTree()->SetRootLayer(root.Pass()); | 3317 myHostImpl->activeTree()->SetRootLayer(root.Pass()); |
| 3318 myHostImpl->setViewportSize(rootRect.size(), rootRect.size()); | 3318 myHostImpl->setViewportSize(rootRect.size(), rootRect.size()); |
| 3319 | 3319 |
| 3320 EXPECT_FALSE(myHostImpl->renderer()->HaveCachedResourcesForRenderPassId(chil
dPassId)); | 3320 EXPECT_FALSE(myHostImpl->renderer()->HaveCachedResourcesForRenderPassId(chil
dPassId)); |
| 3321 | 3321 |
| 3322 { | 3322 { |
| 3323 LayerTreeHostImpl::FrameData frame; | 3323 LayerTreeHostImpl::FrameData frame; |
| 3324 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 3324 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
| 3325 myHostImpl->drawLayers(frame); | 3325 myHostImpl->drawLayers(frame); |
| 3326 myHostImpl->didDrawAllLayers(frame); | 3326 myHostImpl->didDrawAllLayers(frame); |
| 3327 } | 3327 } |
| 3328 | 3328 |
| 3329 // We should have cached textures for surface 2. | 3329 // We should have cached textures for surface 2. |
| 3330 EXPECT_TRUE(myHostImpl->renderer()->HaveCachedResourcesForRenderPassId(child
PassId)); | 3330 EXPECT_TRUE(myHostImpl->renderer()->HaveCachedResourcesForRenderPassId(child
PassId)); |
| 3331 | 3331 |
| 3332 { | 3332 { |
| 3333 LayerTreeHostImpl::FrameData frame; | 3333 LayerTreeHostImpl::FrameData frame; |
| 3334 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 3334 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
| 3335 myHostImpl->drawLayers(frame); | 3335 myHostImpl->drawLayers(frame); |
| 3336 myHostImpl->didDrawAllLayers(frame); | 3336 myHostImpl->didDrawAllLayers(frame); |
| 3337 } | 3337 } |
| 3338 | 3338 |
| 3339 // We should still have cached textures for surface 2 after drawing with no
damage. | 3339 // We should still have cached textures for surface 2 after drawing with no
damage. |
| 3340 EXPECT_TRUE(myHostImpl->renderer()->HaveCachedResourcesForRenderPassId(child
PassId)); | 3340 EXPECT_TRUE(myHostImpl->renderer()->HaveCachedResourcesForRenderPassId(child
PassId)); |
| 3341 | 3341 |
| 3342 // Damage a single tile of surface 2. | 3342 // Damage a single tile of surface 2. |
| 3343 childPtr->setUpdateRect(gfx::Rect(10, 10, 10, 10)); | 3343 childPtr->set_update_rect(gfx::Rect(10, 10, 10, 10)); |
| 3344 | 3344 |
| 3345 { | 3345 { |
| 3346 LayerTreeHostImpl::FrameData frame; | 3346 LayerTreeHostImpl::FrameData frame; |
| 3347 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 3347 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
| 3348 myHostImpl->drawLayers(frame); | 3348 myHostImpl->drawLayers(frame); |
| 3349 myHostImpl->didDrawAllLayers(frame); | 3349 myHostImpl->didDrawAllLayers(frame); |
| 3350 } | 3350 } |
| 3351 | 3351 |
| 3352 // We should have a cached texture for surface 2 again even though it was da
maged. | 3352 // We should have a cached texture for surface 2 again even though it was da
maged. |
| 3353 EXPECT_TRUE(myHostImpl->renderer()->HaveCachedResourcesForRenderPassId(child
PassId)); | 3353 EXPECT_TRUE(myHostImpl->renderer()->HaveCachedResourcesForRenderPassId(child
PassId)); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3398 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size()); | 3398 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size()); |
| 3399 EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[0]->quad_list[0]->ma
terial); | 3399 EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[0]->quad_list[0]->ma
terial); |
| 3400 const RenderPassDrawQuad* quad = RenderPassDrawQuad::MaterialCast(frame.
renderPasses[0]->quad_list[0]); | 3400 const RenderPassDrawQuad* quad = RenderPassDrawQuad::MaterialCast(frame.
renderPasses[0]->quad_list[0]); |
| 3401 EXPECT_TRUE(frame.renderPassesById.find(quad->render_pass_id) == frame.r
enderPassesById.end()); | 3401 EXPECT_TRUE(frame.renderPassesById.find(quad->render_pass_id) == frame.r
enderPassesById.end()); |
| 3402 | 3402 |
| 3403 myHostImpl->drawLayers(frame); | 3403 myHostImpl->drawLayers(frame); |
| 3404 myHostImpl->didDrawAllLayers(frame); | 3404 myHostImpl->didDrawAllLayers(frame); |
| 3405 } | 3405 } |
| 3406 | 3406 |
| 3407 // Change opacity and draw | 3407 // Change opacity and draw |
| 3408 surfaceLayerPtr->setOpacity(0.6f); | 3408 surfaceLayerPtr->SetOpacity(0.6f); |
| 3409 { | 3409 { |
| 3410 LayerTreeHostImpl::FrameData frame; | 3410 LayerTreeHostImpl::FrameData frame; |
| 3411 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 3411 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
| 3412 | 3412 |
| 3413 // Must receive one render pass, as the other one should be culled | 3413 // Must receive one render pass, as the other one should be culled |
| 3414 ASSERT_EQ(1U, frame.renderPasses.size()); | 3414 ASSERT_EQ(1U, frame.renderPasses.size()); |
| 3415 | 3415 |
| 3416 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size()); | 3416 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size()); |
| 3417 EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[0]->quad_list[0]->ma
terial); | 3417 EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[0]->quad_list[0]->ma
terial); |
| 3418 const RenderPassDrawQuad* quad = RenderPassDrawQuad::MaterialCast(frame.
renderPasses[0]->quad_list[0]); | 3418 const RenderPassDrawQuad* quad = RenderPassDrawQuad::MaterialCast(frame.
renderPasses[0]->quad_list[0]); |
| 3419 EXPECT_TRUE(frame.renderPassesById.find(quad->render_pass_id) == frame.r
enderPassesById.end()); | 3419 EXPECT_TRUE(frame.renderPassesById.find(quad->render_pass_id) == frame.r
enderPassesById.end()); |
| 3420 | 3420 |
| 3421 myHostImpl->drawLayers(frame); | 3421 myHostImpl->drawLayers(frame); |
| 3422 myHostImpl->didDrawAllLayers(frame); | 3422 myHostImpl->didDrawAllLayers(frame); |
| 3423 } | 3423 } |
| 3424 | 3424 |
| 3425 // Change less benign property and draw - should have contents changed flag | 3425 // Change less benign property and draw - should have contents changed flag |
| 3426 surfaceLayerPtr->setStackingOrderChanged(true); | 3426 surfaceLayerPtr->SetStackingOrderChanged(true); |
| 3427 { | 3427 { |
| 3428 LayerTreeHostImpl::FrameData frame; | 3428 LayerTreeHostImpl::FrameData frame; |
| 3429 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 3429 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
| 3430 | 3430 |
| 3431 // Must receive two render passes, each with one quad | 3431 // Must receive two render passes, each with one quad |
| 3432 ASSERT_EQ(2U, frame.renderPasses.size()); | 3432 ASSERT_EQ(2U, frame.renderPasses.size()); |
| 3433 | 3433 |
| 3434 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size()); | 3434 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size()); |
| 3435 EXPECT_EQ(DrawQuad::SOLID_COLOR, frame.renderPasses[0]->quad_list[0]->ma
terial); | 3435 EXPECT_EQ(DrawQuad::SOLID_COLOR, frame.renderPasses[0]->quad_list[0]->ma
terial); |
| 3436 | 3436 |
| 3437 EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[1]->quad_list[0]->ma
terial); | 3437 EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[1]->quad_list[0]->ma
terial); |
| 3438 const RenderPassDrawQuad* quad = RenderPassDrawQuad::MaterialCast(frame.
renderPasses[1]->quad_list[0]); | 3438 const RenderPassDrawQuad* quad = RenderPassDrawQuad::MaterialCast(frame.
renderPasses[1]->quad_list[0]); |
| 3439 RenderPass* targetPass = frame.renderPassesById[quad->render_pass_id]; | 3439 RenderPass* targetPass = frame.renderPassesById[quad->render_pass_id]; |
| 3440 ASSERT_TRUE(targetPass); | 3440 ASSERT_TRUE(targetPass); |
| 3441 EXPECT_FALSE(targetPass->damage_rect.IsEmpty()); | 3441 EXPECT_FALSE(targetPass->damage_rect.IsEmpty()); |
| 3442 | 3442 |
| 3443 myHostImpl->drawLayers(frame); | 3443 myHostImpl->drawLayers(frame); |
| 3444 myHostImpl->didDrawAllLayers(frame); | 3444 myHostImpl->didDrawAllLayers(frame); |
| 3445 } | 3445 } |
| 3446 | 3446 |
| 3447 // Change opacity again, and evict the cached surface texture. | 3447 // Change opacity again, and evict the cached surface texture. |
| 3448 surfaceLayerPtr->setOpacity(0.5f); | 3448 surfaceLayerPtr->SetOpacity(0.5f); |
| 3449 static_cast<GLRendererWithReleaseTextures*>(myHostImpl->renderer())->release
RenderPassTextures(); | 3449 static_cast<GLRendererWithReleaseTextures*>(myHostImpl->renderer())->release
RenderPassTextures(); |
| 3450 | 3450 |
| 3451 // Change opacity and draw | 3451 // Change opacity and draw |
| 3452 surfaceLayerPtr->setOpacity(0.6f); | 3452 surfaceLayerPtr->SetOpacity(0.6f); |
| 3453 { | 3453 { |
| 3454 LayerTreeHostImpl::FrameData frame; | 3454 LayerTreeHostImpl::FrameData frame; |
| 3455 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 3455 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
| 3456 | 3456 |
| 3457 // Must receive two render passes | 3457 // Must receive two render passes |
| 3458 ASSERT_EQ(2U, frame.renderPasses.size()); | 3458 ASSERT_EQ(2U, frame.renderPasses.size()); |
| 3459 | 3459 |
| 3460 // Even though not enough properties changed, the entire thing must be | 3460 // Even though not enough properties changed, the entire thing must be |
| 3461 // redrawn as we don't have cached textures | 3461 // redrawn as we don't have cached textures |
| 3462 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size()); | 3462 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size()); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 3488 const RenderPassDrawQuad* quad = RenderPassDrawQuad::MaterialCast(frame.
renderPasses[0]->quad_list[0]); | 3488 const RenderPassDrawQuad* quad = RenderPassDrawQuad::MaterialCast(frame.
renderPasses[0]->quad_list[0]); |
| 3489 EXPECT_TRUE(frame.renderPassesById.find(quad->render_pass_id) == frame.r
enderPassesById.end()); | 3489 EXPECT_TRUE(frame.renderPassesById.find(quad->render_pass_id) == frame.r
enderPassesById.end()); |
| 3490 | 3490 |
| 3491 myHostImpl->drawLayers(frame); | 3491 myHostImpl->drawLayers(frame); |
| 3492 myHostImpl->didDrawAllLayers(frame); | 3492 myHostImpl->didDrawAllLayers(frame); |
| 3493 } | 3493 } |
| 3494 | 3494 |
| 3495 // Change location of the intermediate layer | 3495 // Change location of the intermediate layer |
| 3496 gfx::Transform transform = intermediateLayerPtr->transform(); | 3496 gfx::Transform transform = intermediateLayerPtr->transform(); |
| 3497 transform.matrix().setDouble(0, 3, 1.0001); | 3497 transform.matrix().setDouble(0, 3, 1.0001); |
| 3498 intermediateLayerPtr->setTransform(transform); | 3498 intermediateLayerPtr->SetTransform(transform); |
| 3499 { | 3499 { |
| 3500 LayerTreeHostImpl::FrameData frame; | 3500 LayerTreeHostImpl::FrameData frame; |
| 3501 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 3501 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
| 3502 | 3502 |
| 3503 // Must receive one render pass, as the other one should be culled. | 3503 // Must receive one render pass, as the other one should be culled. |
| 3504 ASSERT_EQ(1U, frame.renderPasses.size()); | 3504 ASSERT_EQ(1U, frame.renderPasses.size()); |
| 3505 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size()); | 3505 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size()); |
| 3506 | 3506 |
| 3507 EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[0]->quad_list[0]->ma
terial); | 3507 EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[0]->quad_list[0]->ma
terial); |
| 3508 const RenderPassDrawQuad* quad = RenderPassDrawQuad::MaterialCast(frame.
renderPasses[0]->quad_list[0]); | 3508 const RenderPassDrawQuad* quad = RenderPassDrawQuad::MaterialCast(frame.
renderPasses[0]->quad_list[0]); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3562 ASSERT_EQ(1U, frame.renderPasses.size()); | 3562 ASSERT_EQ(1U, frame.renderPasses.size()); |
| 3563 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size()); | 3563 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size()); |
| 3564 | 3564 |
| 3565 EXPECT_TRUE(frame.renderPasses[0]->damage_rect.IsEmpty()); | 3565 EXPECT_TRUE(frame.renderPasses[0]->damage_rect.IsEmpty()); |
| 3566 | 3566 |
| 3567 myHostImpl->drawLayers(frame); | 3567 myHostImpl->drawLayers(frame); |
| 3568 myHostImpl->didDrawAllLayers(frame); | 3568 myHostImpl->didDrawAllLayers(frame); |
| 3569 } | 3569 } |
| 3570 | 3570 |
| 3571 // Change opacity and draw | 3571 // Change opacity and draw |
| 3572 surfaceLayerPtr->setOpacity(0.6f); | 3572 surfaceLayerPtr->SetOpacity(0.6f); |
| 3573 { | 3573 { |
| 3574 LayerTreeHostImpl::FrameData frame; | 3574 LayerTreeHostImpl::FrameData frame; |
| 3575 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 3575 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
| 3576 | 3576 |
| 3577 // Must receive one render pass, as the other one should be culled | 3577 // Must receive one render pass, as the other one should be culled |
| 3578 ASSERT_EQ(1U, frame.renderPasses.size()); | 3578 ASSERT_EQ(1U, frame.renderPasses.size()); |
| 3579 | 3579 |
| 3580 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size()); | 3580 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size()); |
| 3581 EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[0]->quad_list[0]->ma
terial); | 3581 EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[0]->quad_list[0]->ma
terial); |
| 3582 const RenderPassDrawQuad* quad = RenderPassDrawQuad::MaterialCast(frame.
renderPasses[0]->quad_list[0]); | 3582 const RenderPassDrawQuad* quad = RenderPassDrawQuad::MaterialCast(frame.
renderPasses[0]->quad_list[0]); |
| 3583 EXPECT_TRUE(frame.renderPassesById.find(quad->render_pass_id) == frame.r
enderPassesById.end()); | 3583 EXPECT_TRUE(frame.renderPassesById.find(quad->render_pass_id) == frame.r
enderPassesById.end()); |
| 3584 | 3584 |
| 3585 myHostImpl->drawLayers(frame); | 3585 myHostImpl->drawLayers(frame); |
| 3586 myHostImpl->didDrawAllLayers(frame); | 3586 myHostImpl->didDrawAllLayers(frame); |
| 3587 } | 3587 } |
| 3588 | 3588 |
| 3589 // Change less benign property and draw - should have contents changed flag | 3589 // Change less benign property and draw - should have contents changed flag |
| 3590 surfaceLayerPtr->setStackingOrderChanged(true); | 3590 surfaceLayerPtr->SetStackingOrderChanged(true); |
| 3591 { | 3591 { |
| 3592 LayerTreeHostImpl::FrameData frame; | 3592 LayerTreeHostImpl::FrameData frame; |
| 3593 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 3593 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
| 3594 | 3594 |
| 3595 // Must receive two render passes, each with one quad | 3595 // Must receive two render passes, each with one quad |
| 3596 ASSERT_EQ(2U, frame.renderPasses.size()); | 3596 ASSERT_EQ(2U, frame.renderPasses.size()); |
| 3597 | 3597 |
| 3598 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size()); | 3598 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size()); |
| 3599 EXPECT_EQ(DrawQuad::SOLID_COLOR, frame.renderPasses[0]->quad_list[0]->ma
terial); | 3599 EXPECT_EQ(DrawQuad::SOLID_COLOR, frame.renderPasses[0]->quad_list[0]->ma
terial); |
| 3600 | 3600 |
| 3601 EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[1]->quad_list[0]->ma
terial); | 3601 EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[1]->quad_list[0]->ma
terial); |
| 3602 const RenderPassDrawQuad* quad = RenderPassDrawQuad::MaterialCast(frame.
renderPasses[1]->quad_list[0]); | 3602 const RenderPassDrawQuad* quad = RenderPassDrawQuad::MaterialCast(frame.
renderPasses[1]->quad_list[0]); |
| 3603 RenderPass* targetPass = frame.renderPassesById[quad->render_pass_id]; | 3603 RenderPass* targetPass = frame.renderPassesById[quad->render_pass_id]; |
| 3604 ASSERT_TRUE(targetPass); | 3604 ASSERT_TRUE(targetPass); |
| 3605 EXPECT_FALSE(targetPass->damage_rect.IsEmpty()); | 3605 EXPECT_FALSE(targetPass->damage_rect.IsEmpty()); |
| 3606 | 3606 |
| 3607 myHostImpl->drawLayers(frame); | 3607 myHostImpl->drawLayers(frame); |
| 3608 myHostImpl->didDrawAllLayers(frame); | 3608 myHostImpl->didDrawAllLayers(frame); |
| 3609 } | 3609 } |
| 3610 | 3610 |
| 3611 // Change opacity again, and evict the cached surface texture. | 3611 // Change opacity again, and evict the cached surface texture. |
| 3612 surfaceLayerPtr->setOpacity(0.5f); | 3612 surfaceLayerPtr->SetOpacity(0.5f); |
| 3613 static_cast<GLRendererWithReleaseTextures*>(myHostImpl->renderer())->release
RenderPassTextures(); | 3613 static_cast<GLRendererWithReleaseTextures*>(myHostImpl->renderer())->release
RenderPassTextures(); |
| 3614 | 3614 |
| 3615 // Change opacity and draw | 3615 // Change opacity and draw |
| 3616 surfaceLayerPtr->setOpacity(0.6f); | 3616 surfaceLayerPtr->SetOpacity(0.6f); |
| 3617 { | 3617 { |
| 3618 LayerTreeHostImpl::FrameData frame; | 3618 LayerTreeHostImpl::FrameData frame; |
| 3619 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 3619 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
| 3620 | 3620 |
| 3621 // Must receive two render passes | 3621 // Must receive two render passes |
| 3622 ASSERT_EQ(2U, frame.renderPasses.size()); | 3622 ASSERT_EQ(2U, frame.renderPasses.size()); |
| 3623 | 3623 |
| 3624 // Even though not enough properties changed, the entire thing must be | 3624 // Even though not enough properties changed, the entire thing must be |
| 3625 // redrawn as we don't have cached textures | 3625 // redrawn as we don't have cached textures |
| 3626 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size()); | 3626 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 3650 ASSERT_EQ(1U, frame.renderPasses.size()); | 3650 ASSERT_EQ(1U, frame.renderPasses.size()); |
| 3651 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size()); | 3651 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size()); |
| 3652 | 3652 |
| 3653 myHostImpl->drawLayers(frame); | 3653 myHostImpl->drawLayers(frame); |
| 3654 myHostImpl->didDrawAllLayers(frame); | 3654 myHostImpl->didDrawAllLayers(frame); |
| 3655 } | 3655 } |
| 3656 | 3656 |
| 3657 // Change location of the intermediate layer | 3657 // Change location of the intermediate layer |
| 3658 gfx::Transform transform = intermediateLayerPtr->transform(); | 3658 gfx::Transform transform = intermediateLayerPtr->transform(); |
| 3659 transform.matrix().setDouble(0, 3, 1.0001); | 3659 transform.matrix().setDouble(0, 3, 1.0001); |
| 3660 intermediateLayerPtr->setTransform(transform); | 3660 intermediateLayerPtr->SetTransform(transform); |
| 3661 { | 3661 { |
| 3662 LayerTreeHostImpl::FrameData frame; | 3662 LayerTreeHostImpl::FrameData frame; |
| 3663 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 3663 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
| 3664 | 3664 |
| 3665 // Must receive one render pass, as the other one should be culled. | 3665 // Must receive one render pass, as the other one should be culled. |
| 3666 ASSERT_EQ(1U, frame.renderPasses.size()); | 3666 ASSERT_EQ(1U, frame.renderPasses.size()); |
| 3667 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size()); | 3667 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size()); |
| 3668 | 3668 |
| 3669 EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[0]->quad_list[0]->ma
terial); | 3669 EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[0]->quad_list[0]->ma
terial); |
| 3670 const RenderPassDrawQuad* quad = RenderPassDrawQuad::MaterialCast(frame.
renderPasses[0]->quad_list[0]); | 3670 const RenderPassDrawQuad* quad = RenderPassDrawQuad::MaterialCast(frame.
renderPasses[0]->quad_list[0]); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3703 EXPECT_FALSE(m_didRequestCommit); | 3703 EXPECT_FALSE(m_didRequestCommit); |
| 3704 } | 3704 } |
| 3705 | 3705 |
| 3706 struct RenderPassRemovalTestData : public LayerTreeHostImpl::FrameData { | 3706 struct RenderPassRemovalTestData : public LayerTreeHostImpl::FrameData { |
| 3707 ScopedPtrHashMap<RenderPass::Id, TestRenderPass> renderPassCache; | 3707 ScopedPtrHashMap<RenderPass::Id, TestRenderPass> renderPassCache; |
| 3708 scoped_ptr<SharedQuadState> sharedQuadState; | 3708 scoped_ptr<SharedQuadState> sharedQuadState; |
| 3709 }; | 3709 }; |
| 3710 | 3710 |
| 3711 class TestRenderer : public GLRenderer, public RendererClient { | 3711 class TestRenderer : public GLRenderer, public RendererClient { |
| 3712 public: | 3712 public: |
| 3713 static scoped_ptr<TestRenderer> create(ResourceProvider* resourceProvider, O
utputSurface* outputSurface, Proxy* proxy) | 3713 static scoped_ptr<TestRenderer> Create(ResourceProvider* resourceProvider, O
utputSurface* outputSurface, Proxy* proxy) |
| 3714 { | 3714 { |
| 3715 scoped_ptr<TestRenderer> renderer(new TestRenderer(resourceProvider, out
putSurface, proxy)); | 3715 scoped_ptr<TestRenderer> renderer(new TestRenderer(resourceProvider, out
putSurface, proxy)); |
| 3716 if (!renderer->initialize()) | 3716 if (!renderer->initialize()) |
| 3717 return scoped_ptr<TestRenderer>(); | 3717 return scoped_ptr<TestRenderer>(); |
| 3718 | 3718 |
| 3719 return renderer.Pass(); | 3719 return renderer.Pass(); |
| 3720 } | 3720 } |
| 3721 | 3721 |
| 3722 void clearCachedTextures() { m_textures.clear(); } | 3722 void clearCachedTextures() { m_textures.clear(); } |
| 3723 void setHaveCachedResourcesForRenderPassId(RenderPass::Id id) { m_textures.i
nsert(id); } | 3723 void setHaveCachedResourcesForRenderPassId(RenderPass::Id id) { m_textures.i
nsert(id); } |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4022 dumpRenderPassTestData(testData, actualResult); | 4022 dumpRenderPassTestData(testData, actualResult); |
| 4023 EXPECT_STREQ(testCase.expectedResult, actualResult) << "In test case: " << t
estCase.name; | 4023 EXPECT_STREQ(testCase.expectedResult, actualResult) << "In test case: " << t
estCase.name; |
| 4024 } | 4024 } |
| 4025 | 4025 |
| 4026 TEST_F(LayerTreeHostImplTest, testRemoveRenderPasses) | 4026 TEST_F(LayerTreeHostImplTest, testRemoveRenderPasses) |
| 4027 { | 4027 { |
| 4028 scoped_ptr<OutputSurface> outputSurface(createOutputSurface()); | 4028 scoped_ptr<OutputSurface> outputSurface(createOutputSurface()); |
| 4029 ASSERT_TRUE(outputSurface->context3d()); | 4029 ASSERT_TRUE(outputSurface->context3d()); |
| 4030 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::Create(outpu
tSurface.get())); | 4030 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::Create(outpu
tSurface.get())); |
| 4031 | 4031 |
| 4032 scoped_ptr<TestRenderer> renderer(TestRenderer::create(resourceProvider.get(
), outputSurface.get(), &m_proxy)); | 4032 scoped_ptr<TestRenderer> renderer(TestRenderer::Create(resourceProvider.get(
), outputSurface.get(), &m_proxy)); |
| 4033 | 4033 |
| 4034 int testCaseIndex = 0; | 4034 int testCaseIndex = 0; |
| 4035 while (removeRenderPassesCases[testCaseIndex].name) { | 4035 while (removeRenderPassesCases[testCaseIndex].name) { |
| 4036 RenderPassRemovalTestData testData; | 4036 RenderPassRemovalTestData testData; |
| 4037 configureRenderPassTestData(removeRenderPassesCases[testCaseIndex].initS
cript, testData, renderer.get()); | 4037 configureRenderPassTestData(removeRenderPassesCases[testCaseIndex].initS
cript, testData, renderer.get()); |
| 4038 LayerTreeHostImpl::removeRenderPasses(LayerTreeHostImpl::CullRenderPasse
sWithCachedTextures(*renderer), testData); | 4038 LayerTreeHostImpl::removeRenderPasses(LayerTreeHostImpl::CullRenderPasse
sWithCachedTextures(*renderer), testData); |
| 4039 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat
a); | 4039 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat
a); |
| 4040 testCaseIndex++; | 4040 testCaseIndex++; |
| 4041 } | 4041 } |
| 4042 } | 4042 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 4054 LayerTreeHostImpl::FrameData frame; | 4054 LayerTreeHostImpl::FrameData frame; |
| 4055 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 4055 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 4056 ASSERT_EQ(1u, frame.renderPasses.size()); | 4056 ASSERT_EQ(1u, frame.renderPasses.size()); |
| 4057 | 4057 |
| 4058 // Verify the damage rect for the root render pass. | 4058 // Verify the damage rect for the root render pass. |
| 4059 const RenderPass* rootRenderPass = frame.renderPasses.back(); | 4059 const RenderPass* rootRenderPass = frame.renderPasses.back(); |
| 4060 EXPECT_RECT_EQ(expectedDamage, rootRenderPass->damage_rect); | 4060 EXPECT_RECT_EQ(expectedDamage, rootRenderPass->damage_rect); |
| 4061 | 4061 |
| 4062 // Verify the root layer's quad is generated and not being culled. | 4062 // Verify the root layer's quad is generated and not being culled. |
| 4063 ASSERT_EQ(1u, rootRenderPass->quad_list.size()); | 4063 ASSERT_EQ(1u, rootRenderPass->quad_list.size()); |
| 4064 gfx::Rect expectedVisibleRect(m_hostImpl->rootLayer()->contentBounds()); | 4064 gfx::Rect expectedVisibleRect(m_hostImpl->rootLayer()->content_bounds())
; |
| 4065 EXPECT_RECT_EQ(expectedVisibleRect, rootRenderPass->quad_list[0]->visibl
e_rect); | 4065 EXPECT_RECT_EQ(expectedVisibleRect, rootRenderPass->quad_list[0]->visibl
e_rect); |
| 4066 | 4066 |
| 4067 m_hostImpl->drawLayers(frame); | 4067 m_hostImpl->drawLayers(frame); |
| 4068 m_hostImpl->didDrawAllLayers(frame); | 4068 m_hostImpl->didDrawAllLayers(frame); |
| 4069 } | 4069 } |
| 4070 }; | 4070 }; |
| 4071 | 4071 |
| 4072 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) | 4072 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) |
| 4073 { | 4073 { |
| 4074 scoped_ptr<SolidColorLayerImpl> root = SolidColorLayerImpl::Create(m_hostImp
l->activeTree(), 1); | 4074 scoped_ptr<SolidColorLayerImpl> root = SolidColorLayerImpl::Create(m_hostImp
l->activeTree(), 1); |
| 4075 root->setAnchorPoint(gfx::PointF(0.f, 0.f)); | 4075 root->SetAnchorPoint(gfx::PointF(0.f, 0.f)); |
| 4076 root->setPosition(gfx::PointF(0.f, 0.f)); | 4076 root->SetPosition(gfx::PointF(0.f, 0.f)); |
| 4077 root->setBounds(gfx::Size(10, 10)); | 4077 root->SetBounds(gfx::Size(10, 10)); |
| 4078 root->setContentBounds(gfx::Size(10, 10)); | 4078 root->SetContentBounds(gfx::Size(10, 10)); |
| 4079 root->setDrawsContent(true); | 4079 root->SetDrawsContent(true); |
| 4080 m_hostImpl->activeTree()->SetRootLayer(root.PassAs<LayerImpl>()); | 4080 m_hostImpl->activeTree()->SetRootLayer(root.PassAs<LayerImpl>()); |
| 4081 | 4081 |
| 4082 // Draw a frame. In the first frame, the entire viewport should be damaged. | 4082 // Draw a frame. In the first frame, the entire viewport should be damaged. |
| 4083 gfx::Rect fullFrameDamage = gfx::Rect(m_hostImpl->DeviceViewportSize()); | 4083 gfx::Rect fullFrameDamage = gfx::Rect(m_hostImpl->DeviceViewportSize()); |
| 4084 drawFrameAndTestDamage(fullFrameDamage); | 4084 drawFrameAndTestDamage(fullFrameDamage); |
| 4085 | 4085 |
| 4086 // The second frame should have no damage, but the quads should still be gen
erated. | 4086 // The second frame should have no damage, but the quads should still be gen
erated. |
| 4087 gfx::Rect noDamage = gfx::Rect(); | 4087 gfx::Rect noDamage = gfx::Rect(); |
| 4088 drawFrameAndTestDamage(noDamage); | 4088 drawFrameAndTestDamage(noDamage); |
| 4089 } | 4089 } |
| 4090 | 4090 |
| 4091 class FakeMaskLayerImpl : public LayerImpl { | 4091 class FakeMaskLayerImpl : public LayerImpl { |
| 4092 public: | 4092 public: |
| 4093 static scoped_ptr<FakeMaskLayerImpl> create(LayerTreeImpl* treeImpl, int id) | 4093 static scoped_ptr<FakeMaskLayerImpl> Create(LayerTreeImpl* treeImpl, int id) |
| 4094 { | 4094 { |
| 4095 return make_scoped_ptr(new FakeMaskLayerImpl(treeImpl, id)); | 4095 return make_scoped_ptr(new FakeMaskLayerImpl(treeImpl, id)); |
| 4096 } | 4096 } |
| 4097 | 4097 |
| 4098 virtual ResourceProvider::ResourceId contentsResourceId() const OVERRIDE { r
eturn 0; } | 4098 virtual ResourceProvider::ResourceId ContentsResourceId() const OVERRIDE { r
eturn 0; } |
| 4099 | 4099 |
| 4100 private: | 4100 private: |
| 4101 FakeMaskLayerImpl(LayerTreeImpl* treeImpl, int id) : LayerImpl(treeImpl, id)
{ } | 4101 FakeMaskLayerImpl(LayerTreeImpl* treeImpl, int id) : LayerImpl(treeImpl, id)
{ } |
| 4102 }; | 4102 }; |
| 4103 | 4103 |
| 4104 TEST_F(LayerTreeHostImplTest, maskLayerWithScaling) | 4104 TEST_F(LayerTreeHostImplTest, maskLayerWithScaling) |
| 4105 { | 4105 { |
| 4106 // Root | 4106 // Root |
| 4107 // | | 4107 // | |
| 4108 // +-- Scaling Layer (adds a 2x scale) | 4108 // +-- Scaling Layer (adds a 2x scale) |
| 4109 // | | 4109 // | |
| 4110 // +-- Content Layer | 4110 // +-- Content Layer |
| 4111 // +--Mask | 4111 // +--Mask |
| 4112 scoped_ptr<LayerImpl> scopedRoot = LayerImpl::create(m_hostImpl->activeTree(
), 1); | 4112 scoped_ptr<LayerImpl> scopedRoot = LayerImpl::Create(m_hostImpl->activeTree(
), 1); |
| 4113 LayerImpl* root = scopedRoot.get(); | 4113 LayerImpl* root = scopedRoot.get(); |
| 4114 m_hostImpl->activeTree()->SetRootLayer(scopedRoot.Pass()); | 4114 m_hostImpl->activeTree()->SetRootLayer(scopedRoot.Pass()); |
| 4115 | 4115 |
| 4116 scoped_ptr<LayerImpl> scopedScalingLayer = LayerImpl::create(m_hostImpl->act
iveTree(), 2); | 4116 scoped_ptr<LayerImpl> scopedScalingLayer = LayerImpl::Create(m_hostImpl->act
iveTree(), 2); |
| 4117 LayerImpl* scalingLayer = scopedScalingLayer.get(); | 4117 LayerImpl* scalingLayer = scopedScalingLayer.get(); |
| 4118 root->addChild(scopedScalingLayer.Pass()); | 4118 root->AddChild(scopedScalingLayer.Pass()); |
| 4119 | 4119 |
| 4120 scoped_ptr<LayerImpl> scopedContentLayer = LayerImpl::create(m_hostImpl->act
iveTree(), 3); | 4120 scoped_ptr<LayerImpl> scopedContentLayer = LayerImpl::Create(m_hostImpl->act
iveTree(), 3); |
| 4121 LayerImpl* contentLayer = scopedContentLayer.get(); | 4121 LayerImpl* contentLayer = scopedContentLayer.get(); |
| 4122 scalingLayer->addChild(scopedContentLayer.Pass()); | 4122 scalingLayer->AddChild(scopedContentLayer.Pass()); |
| 4123 | 4123 |
| 4124 scoped_ptr<FakeMaskLayerImpl> scopedMaskLayer = FakeMaskLayerImpl::create(m_
hostImpl->activeTree(), 4); | 4124 scoped_ptr<FakeMaskLayerImpl> scopedMaskLayer = FakeMaskLayerImpl::Create(m_
hostImpl->activeTree(), 4); |
| 4125 FakeMaskLayerImpl* maskLayer = scopedMaskLayer.get(); | 4125 FakeMaskLayerImpl* maskLayer = scopedMaskLayer.get(); |
| 4126 contentLayer->setMaskLayer(scopedMaskLayer.PassAs<LayerImpl>()); | 4126 contentLayer->SetMaskLayer(scopedMaskLayer.PassAs<LayerImpl>()); |
| 4127 | 4127 |
| 4128 gfx::Size rootSize(100, 100); | 4128 gfx::Size rootSize(100, 100); |
| 4129 root->setBounds(rootSize); | 4129 root->SetBounds(rootSize); |
| 4130 root->setContentBounds(rootSize); | 4130 root->SetContentBounds(rootSize); |
| 4131 root->setPosition(gfx::PointF()); | 4131 root->SetPosition(gfx::PointF()); |
| 4132 root->setAnchorPoint(gfx::PointF()); | 4132 root->SetAnchorPoint(gfx::PointF()); |
| 4133 | 4133 |
| 4134 gfx::Size scalingLayerSize(50, 50); | 4134 gfx::Size scalingLayerSize(50, 50); |
| 4135 scalingLayer->setBounds(scalingLayerSize); | 4135 scalingLayer->SetBounds(scalingLayerSize); |
| 4136 scalingLayer->setContentBounds(scalingLayerSize); | 4136 scalingLayer->SetContentBounds(scalingLayerSize); |
| 4137 scalingLayer->setPosition(gfx::PointF()); | 4137 scalingLayer->SetPosition(gfx::PointF()); |
| 4138 scalingLayer->setAnchorPoint(gfx::PointF()); | 4138 scalingLayer->SetAnchorPoint(gfx::PointF()); |
| 4139 gfx::Transform scale; | 4139 gfx::Transform scale; |
| 4140 scale.Scale(2.0, 2.0); | 4140 scale.Scale(2.0, 2.0); |
| 4141 scalingLayer->setTransform(scale); | 4141 scalingLayer->SetTransform(scale); |
| 4142 | 4142 |
| 4143 contentLayer->setBounds(scalingLayerSize); | 4143 contentLayer->SetBounds(scalingLayerSize); |
| 4144 contentLayer->setContentBounds(scalingLayerSize); | 4144 contentLayer->SetContentBounds(scalingLayerSize); |
| 4145 contentLayer->setPosition(gfx::PointF()); | 4145 contentLayer->SetPosition(gfx::PointF()); |
| 4146 contentLayer->setAnchorPoint(gfx::PointF()); | 4146 contentLayer->SetAnchorPoint(gfx::PointF()); |
| 4147 contentLayer->setDrawsContent(true); | 4147 contentLayer->SetDrawsContent(true); |
| 4148 | 4148 |
| 4149 maskLayer->setBounds(scalingLayerSize); | 4149 maskLayer->SetBounds(scalingLayerSize); |
| 4150 maskLayer->setContentBounds(scalingLayerSize); | 4150 maskLayer->SetContentBounds(scalingLayerSize); |
| 4151 maskLayer->setPosition(gfx::PointF()); | 4151 maskLayer->SetPosition(gfx::PointF()); |
| 4152 maskLayer->setAnchorPoint(gfx::PointF()); | 4152 maskLayer->SetAnchorPoint(gfx::PointF()); |
| 4153 maskLayer->setDrawsContent(true); | 4153 maskLayer->SetDrawsContent(true); |
| 4154 | 4154 |
| 4155 | 4155 |
| 4156 // Check that the tree scaling is correctly taken into account for the mask, | 4156 // Check that the tree scaling is correctly taken into account for the mask, |
| 4157 // that should fully map onto the quad. | 4157 // that should fully map onto the quad. |
| 4158 float deviceScaleFactor = 1.f; | 4158 float deviceScaleFactor = 1.f; |
| 4159 m_hostImpl->setViewportSize(rootSize, rootSize); | 4159 m_hostImpl->setViewportSize(rootSize, rootSize); |
| 4160 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor); | 4160 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor); |
| 4161 { | 4161 { |
| 4162 LayerTreeHostImpl::FrameData frame; | 4162 LayerTreeHostImpl::FrameData frame; |
| 4163 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 4163 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 4193 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), renderPassQuad->mas
k_uv_rect.ToString()); | 4193 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), renderPassQuad->mas
k_uv_rect.ToString()); |
| 4194 | 4194 |
| 4195 m_hostImpl->drawLayers(frame); | 4195 m_hostImpl->drawLayers(frame); |
| 4196 m_hostImpl->didDrawAllLayers(frame); | 4196 m_hostImpl->didDrawAllLayers(frame); |
| 4197 } | 4197 } |
| 4198 | 4198 |
| 4199 | 4199 |
| 4200 // Applying an equivalent content scale on the content layer and the mask | 4200 // Applying an equivalent content scale on the content layer and the mask |
| 4201 // should still result in the same part of the mask being used. | 4201 // should still result in the same part of the mask being used. |
| 4202 gfx::Size contentsBounds(gfx::ToRoundedSize(gfx::ScaleSize(scalingLayerSize,
deviceScaleFactor))); | 4202 gfx::Size contentsBounds(gfx::ToRoundedSize(gfx::ScaleSize(scalingLayerSize,
deviceScaleFactor))); |
| 4203 contentLayer->setContentBounds(contentsBounds); | 4203 contentLayer->SetContentBounds(contentsBounds); |
| 4204 contentLayer->setContentsScale(deviceScaleFactor, deviceScaleFactor); | 4204 contentLayer->SetContentsScale(deviceScaleFactor, deviceScaleFactor); |
| 4205 maskLayer->setContentBounds(contentsBounds); | 4205 maskLayer->SetContentBounds(contentsBounds); |
| 4206 maskLayer->setContentsScale(deviceScaleFactor, deviceScaleFactor); | 4206 maskLayer->SetContentsScale(deviceScaleFactor, deviceScaleFactor); |
| 4207 m_hostImpl->activeTree()->set_needs_update_draw_properties(); | 4207 m_hostImpl->activeTree()->set_needs_update_draw_properties(); |
| 4208 { | 4208 { |
| 4209 LayerTreeHostImpl::FrameData frame; | 4209 LayerTreeHostImpl::FrameData frame; |
| 4210 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 4210 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 4211 | 4211 |
| 4212 ASSERT_EQ(1u, frame.renderPasses.size()); | 4212 ASSERT_EQ(1u, frame.renderPasses.size()); |
| 4213 ASSERT_EQ(1u, frame.renderPasses[0]->quad_list.size()); | 4213 ASSERT_EQ(1u, frame.renderPasses[0]->quad_list.size()); |
| 4214 ASSERT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[0]->quad_list[0]->ma
terial); | 4214 ASSERT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[0]->quad_list[0]->ma
terial); |
| 4215 const RenderPassDrawQuad* renderPassQuad = RenderPassDrawQuad::MaterialC
ast(frame.renderPasses[0]->quad_list[0]); | 4215 const RenderPassDrawQuad* renderPassQuad = RenderPassDrawQuad::MaterialC
ast(frame.renderPasses[0]->quad_list[0]); |
| 4216 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(), renderPassQuad->rect.ToS
tring()); | 4216 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(), renderPassQuad->rect.ToS
tring()); |
| 4217 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), renderPassQuad->mas
k_uv_rect.ToString()); | 4217 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), renderPassQuad->mas
k_uv_rect.ToString()); |
| 4218 | 4218 |
| 4219 m_hostImpl->drawLayers(frame); | 4219 m_hostImpl->drawLayers(frame); |
| 4220 m_hostImpl->didDrawAllLayers(frame); | 4220 m_hostImpl->didDrawAllLayers(frame); |
| 4221 } | 4221 } |
| 4222 } | 4222 } |
| 4223 | 4223 |
| 4224 TEST_F(LayerTreeHostImplTest, maskLayerWithDifferentBounds) | 4224 TEST_F(LayerTreeHostImplTest, maskLayerWithDifferentBounds) |
| 4225 { | 4225 { |
| 4226 // The mask layer has bounds 100x100 but is attached to a layer with bounds
50x50. | 4226 // The mask layer has bounds 100x100 but is attached to a layer with bounds
50x50. |
| 4227 | 4227 |
| 4228 scoped_ptr<LayerImpl> scopedRoot = LayerImpl::create(m_hostImpl->activeTree(
), 1); | 4228 scoped_ptr<LayerImpl> scopedRoot = LayerImpl::Create(m_hostImpl->activeTree(
), 1); |
| 4229 LayerImpl* root = scopedRoot.get(); | 4229 LayerImpl* root = scopedRoot.get(); |
| 4230 m_hostImpl->activeTree()->SetRootLayer(scopedRoot.Pass()); | 4230 m_hostImpl->activeTree()->SetRootLayer(scopedRoot.Pass()); |
| 4231 | 4231 |
| 4232 scoped_ptr<LayerImpl> scopedContentLayer = LayerImpl::create(m_hostImpl->act
iveTree(), 3); | 4232 scoped_ptr<LayerImpl> scopedContentLayer = LayerImpl::Create(m_hostImpl->act
iveTree(), 3); |
| 4233 LayerImpl* contentLayer = scopedContentLayer.get(); | 4233 LayerImpl* contentLayer = scopedContentLayer.get(); |
| 4234 root->addChild(scopedContentLayer.Pass()); | 4234 root->AddChild(scopedContentLayer.Pass()); |
| 4235 | 4235 |
| 4236 scoped_ptr<FakeMaskLayerImpl> scopedMaskLayer = FakeMaskLayerImpl::create(m_
hostImpl->activeTree(), 4); | 4236 scoped_ptr<FakeMaskLayerImpl> scopedMaskLayer = FakeMaskLayerImpl::Create(m_
hostImpl->activeTree(), 4); |
| 4237 FakeMaskLayerImpl* maskLayer = scopedMaskLayer.get(); | 4237 FakeMaskLayerImpl* maskLayer = scopedMaskLayer.get(); |
| 4238 contentLayer->setMaskLayer(scopedMaskLayer.PassAs<LayerImpl>()); | 4238 contentLayer->SetMaskLayer(scopedMaskLayer.PassAs<LayerImpl>()); |
| 4239 | 4239 |
| 4240 gfx::Size rootSize(100, 100); | 4240 gfx::Size rootSize(100, 100); |
| 4241 root->setBounds(rootSize); | 4241 root->SetBounds(rootSize); |
| 4242 root->setContentBounds(rootSize); | 4242 root->SetContentBounds(rootSize); |
| 4243 root->setPosition(gfx::PointF()); | 4243 root->SetPosition(gfx::PointF()); |
| 4244 root->setAnchorPoint(gfx::PointF()); | 4244 root->SetAnchorPoint(gfx::PointF()); |
| 4245 | 4245 |
| 4246 gfx::Size layerSize(50, 50); | 4246 gfx::Size layerSize(50, 50); |
| 4247 contentLayer->setBounds(layerSize); | 4247 contentLayer->SetBounds(layerSize); |
| 4248 contentLayer->setContentBounds(layerSize); | 4248 contentLayer->SetContentBounds(layerSize); |
| 4249 contentLayer->setPosition(gfx::PointF()); | 4249 contentLayer->SetPosition(gfx::PointF()); |
| 4250 contentLayer->setAnchorPoint(gfx::PointF()); | 4250 contentLayer->SetAnchorPoint(gfx::PointF()); |
| 4251 contentLayer->setDrawsContent(true); | 4251 contentLayer->SetDrawsContent(true); |
| 4252 | 4252 |
| 4253 gfx::Size maskSize(100, 100); | 4253 gfx::Size maskSize(100, 100); |
| 4254 maskLayer->setBounds(maskSize); | 4254 maskLayer->SetBounds(maskSize); |
| 4255 maskLayer->setContentBounds(maskSize); | 4255 maskLayer->SetContentBounds(maskSize); |
| 4256 maskLayer->setPosition(gfx::PointF()); | 4256 maskLayer->SetPosition(gfx::PointF()); |
| 4257 maskLayer->setAnchorPoint(gfx::PointF()); | 4257 maskLayer->SetAnchorPoint(gfx::PointF()); |
| 4258 maskLayer->setDrawsContent(true); | 4258 maskLayer->SetDrawsContent(true); |
| 4259 | 4259 |
| 4260 | 4260 |
| 4261 // Check that the mask fills the surface. | 4261 // Check that the mask fills the surface. |
| 4262 float deviceScaleFactor = 1.f; | 4262 float deviceScaleFactor = 1.f; |
| 4263 m_hostImpl->setViewportSize(rootSize, rootSize); | 4263 m_hostImpl->setViewportSize(rootSize, rootSize); |
| 4264 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor); | 4264 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor); |
| 4265 { | 4265 { |
| 4266 LayerTreeHostImpl::FrameData frame; | 4266 LayerTreeHostImpl::FrameData frame; |
| 4267 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 4267 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 4268 | 4268 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 4297 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), renderPassQuad->mas
k_uv_rect.ToString()); | 4297 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), renderPassQuad->mas
k_uv_rect.ToString()); |
| 4298 | 4298 |
| 4299 m_hostImpl->drawLayers(frame); | 4299 m_hostImpl->drawLayers(frame); |
| 4300 m_hostImpl->didDrawAllLayers(frame); | 4300 m_hostImpl->didDrawAllLayers(frame); |
| 4301 } | 4301 } |
| 4302 | 4302 |
| 4303 | 4303 |
| 4304 // Applying an equivalent content scale on the content layer and the mask | 4304 // Applying an equivalent content scale on the content layer and the mask |
| 4305 // should still result in the same part of the mask being used. | 4305 // should still result in the same part of the mask being used. |
| 4306 gfx::Size layerSizeLarge(gfx::ToRoundedSize(gfx::ScaleSize(layerSize, device
ScaleFactor))); | 4306 gfx::Size layerSizeLarge(gfx::ToRoundedSize(gfx::ScaleSize(layerSize, device
ScaleFactor))); |
| 4307 contentLayer->setContentBounds(layerSizeLarge); | 4307 contentLayer->SetContentBounds(layerSizeLarge); |
| 4308 contentLayer->setContentsScale(deviceScaleFactor, deviceScaleFactor); | 4308 contentLayer->SetContentsScale(deviceScaleFactor, deviceScaleFactor); |
| 4309 gfx::Size maskSizeLarge(gfx::ToRoundedSize(gfx::ScaleSize(maskSize, deviceSc
aleFactor))); | 4309 gfx::Size maskSizeLarge(gfx::ToRoundedSize(gfx::ScaleSize(maskSize, deviceSc
aleFactor))); |
| 4310 maskLayer->setContentBounds(maskSizeLarge); | 4310 maskLayer->SetContentBounds(maskSizeLarge); |
| 4311 maskLayer->setContentsScale(deviceScaleFactor, deviceScaleFactor); | 4311 maskLayer->SetContentsScale(deviceScaleFactor, deviceScaleFactor); |
| 4312 m_hostImpl->activeTree()->set_needs_update_draw_properties(); | 4312 m_hostImpl->activeTree()->set_needs_update_draw_properties(); |
| 4313 { | 4313 { |
| 4314 LayerTreeHostImpl::FrameData frame; | 4314 LayerTreeHostImpl::FrameData frame; |
| 4315 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 4315 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 4316 | 4316 |
| 4317 ASSERT_EQ(1u, frame.renderPasses.size()); | 4317 ASSERT_EQ(1u, frame.renderPasses.size()); |
| 4318 ASSERT_EQ(1u, frame.renderPasses[0]->quad_list.size()); | 4318 ASSERT_EQ(1u, frame.renderPasses[0]->quad_list.size()); |
| 4319 ASSERT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[0]->quad_list[0]->ma
terial); | 4319 ASSERT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[0]->quad_list[0]->ma
terial); |
| 4320 const RenderPassDrawQuad* renderPassQuad = RenderPassDrawQuad::MaterialC
ast(frame.renderPasses[0]->quad_list[0]); | 4320 const RenderPassDrawQuad* renderPassQuad = RenderPassDrawQuad::MaterialC
ast(frame.renderPasses[0]->quad_list[0]); |
| 4321 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), renderPassQuad->rect.ToS
tring()); | 4321 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), renderPassQuad->rect.ToS
tring()); |
| 4322 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), renderPassQuad->mas
k_uv_rect.ToString()); | 4322 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), renderPassQuad->mas
k_uv_rect.ToString()); |
| 4323 | 4323 |
| 4324 m_hostImpl->drawLayers(frame); | 4324 m_hostImpl->drawLayers(frame); |
| 4325 m_hostImpl->didDrawAllLayers(frame); | 4325 m_hostImpl->didDrawAllLayers(frame); |
| 4326 } | 4326 } |
| 4327 | 4327 |
| 4328 // Applying a different contents scale to the mask layer will still result | 4328 // Applying a different contents scale to the mask layer will still result |
| 4329 // in the mask covering the owning layer. | 4329 // in the mask covering the owning layer. |
| 4330 maskLayer->setContentBounds(maskSize); | 4330 maskLayer->SetContentBounds(maskSize); |
| 4331 maskLayer->setContentsScale(deviceScaleFactor, deviceScaleFactor); | 4331 maskLayer->SetContentsScale(deviceScaleFactor, deviceScaleFactor); |
| 4332 m_hostImpl->activeTree()->set_needs_update_draw_properties(); | 4332 m_hostImpl->activeTree()->set_needs_update_draw_properties(); |
| 4333 { | 4333 { |
| 4334 LayerTreeHostImpl::FrameData frame; | 4334 LayerTreeHostImpl::FrameData frame; |
| 4335 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 4335 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 4336 | 4336 |
| 4337 ASSERT_EQ(1u, frame.renderPasses.size()); | 4337 ASSERT_EQ(1u, frame.renderPasses.size()); |
| 4338 ASSERT_EQ(1u, frame.renderPasses[0]->quad_list.size()); | 4338 ASSERT_EQ(1u, frame.renderPasses[0]->quad_list.size()); |
| 4339 ASSERT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[0]->quad_list[0]->ma
terial); | 4339 ASSERT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[0]->quad_list[0]->ma
terial); |
| 4340 const RenderPassDrawQuad* renderPassQuad = RenderPassDrawQuad::MaterialC
ast(frame.renderPasses[0]->quad_list[0]); | 4340 const RenderPassDrawQuad* renderPassQuad = RenderPassDrawQuad::MaterialC
ast(frame.renderPasses[0]->quad_list[0]); |
| 4341 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), renderPassQuad->rect.ToS
tring()); | 4341 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), renderPassQuad->rect.ToS
tring()); |
| 4342 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), renderPassQuad->mas
k_uv_rect.ToString()); | 4342 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), renderPassQuad->mas
k_uv_rect.ToString()); |
| 4343 | 4343 |
| 4344 m_hostImpl->drawLayers(frame); | 4344 m_hostImpl->drawLayers(frame); |
| 4345 m_hostImpl->didDrawAllLayers(frame); | 4345 m_hostImpl->didDrawAllLayers(frame); |
| 4346 } | 4346 } |
| 4347 } | 4347 } |
| 4348 | 4348 |
| 4349 } // namespace | 4349 } // namespace |
| 4350 } // namespace cc | 4350 } // namespace cc |
| OLD | NEW |