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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 virtual void didLoseOutputSurfaceOnImplThread() OVERRIDE { } | 94 virtual void didLoseOutputSurfaceOnImplThread() OVERRIDE { } |
95 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { } | 95 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { } |
96 virtual void onVSyncParametersChanged(base::TimeTicks, base::TimeDelta) OVER
RIDE { } | 96 virtual void onVSyncParametersChanged(base::TimeTicks, base::TimeDelta) OVER
RIDE { } |
97 virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE { m_onCanDrawState
ChangedCalled = true; } | 97 virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE { m_onCanDrawState
ChangedCalled = true; } |
98 virtual void setNeedsRedrawOnImplThread() OVERRIDE { m_didRequestRedraw = tr
ue; } | 98 virtual void setNeedsRedrawOnImplThread() OVERRIDE { m_didRequestRedraw = tr
ue; } |
99 virtual void setNeedsCommitOnImplThread() OVERRIDE { m_didRequestCommit = tr
ue; } | 99 virtual void setNeedsCommitOnImplThread() OVERRIDE { m_didRequestCommit = tr
ue; } |
100 virtual void setNeedsManageTilesOnImplThread() OVERRIDE { } | 100 virtual void setNeedsManageTilesOnImplThread() OVERRIDE { } |
101 virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<Animatio
nEventsVector>, base::Time wallClockTime) OVERRIDE { } | 101 virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<Animatio
nEventsVector>, base::Time wallClockTime) OVERRIDE { } |
102 virtual bool reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int
priorityCutoff) OVERRIDE { return m_reduceMemoryResult; } | 102 virtual bool reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int
priorityCutoff) OVERRIDE { return m_reduceMemoryResult; } |
103 virtual void sendManagedMemoryStats() OVERRIDE { } | 103 virtual void sendManagedMemoryStats() OVERRIDE { } |
| 104 virtual void onReceivedLatencyInfo(const WebKit::WebLatencyInfoImpl& latency
Info) OVERRIDE { } |
104 | 105 |
105 void setReduceMemoryResult(bool reduceMemoryResult) { m_reduceMemoryResult =
reduceMemoryResult; } | 106 void setReduceMemoryResult(bool reduceMemoryResult) { m_reduceMemoryResult =
reduceMemoryResult; } |
106 | 107 |
107 void createLayerTreeHost(bool partialSwap, scoped_ptr<OutputSurface> outputS
urface) | 108 void createLayerTreeHost(bool partialSwap, scoped_ptr<OutputSurface> outputS
urface) |
108 { | 109 { |
109 LayerTreeSettings settings; | 110 LayerTreeSettings settings; |
110 settings.minimumOcclusionTrackingSize = gfx::Size(); | 111 settings.minimumOcclusionTrackingSize = gfx::Size(); |
111 settings.partialSwapEnabled = partialSwap; | 112 settings.partialSwapEnabled = partialSwap; |
112 | 113 |
113 m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy); | 114 m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy); |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 EXPECT_EQ(root->sentScrollDelta(), scrollDelta + scrollDelta2); | 352 EXPECT_EQ(root->sentScrollDelta(), scrollDelta + scrollDelta2); |
352 } | 353 } |
353 | 354 |
354 TEST_P(LayerTreeHostImplTest, scrollRootCallsCommitAndRedraw) | 355 TEST_P(LayerTreeHostImplTest, scrollRootCallsCommitAndRedraw) |
355 { | 356 { |
356 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 357 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
357 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); | 358 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); |
358 initializeRendererAndDrawFrame(); | 359 initializeRendererAndDrawFrame(); |
359 | 360 |
360 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 361 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
361 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 362 m_hostImpl->scrollBy(0, gfx::Point(), gfx::Vector2d(0, 10)); |
362 m_hostImpl->scrollEnd(); | 363 m_hostImpl->scrollEnd(); |
363 EXPECT_TRUE(m_didRequestRedraw); | 364 EXPECT_TRUE(m_didRequestRedraw); |
364 EXPECT_TRUE(m_didRequestCommit); | 365 EXPECT_TRUE(m_didRequestCommit); |
365 } | 366 } |
366 | 367 |
367 TEST_P(LayerTreeHostImplTest, scrollWithoutRootLayer) | 368 TEST_P(LayerTreeHostImplTest, scrollWithoutRootLayer) |
368 { | 369 { |
369 // We should not crash when trying to scroll an empty layer tree. | 370 // We should not crash when trying to scroll an empty layer tree. |
370 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollIgnored); | 371 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollIgnored); |
371 } | 372 } |
(...skipping 22 matching lines...) Expand all Loading... |
394 initializeRendererAndDrawFrame(); | 395 initializeRendererAndDrawFrame(); |
395 | 396 |
396 // We should not crash if the tree is replaced while we are scrolling. | 397 // We should not crash if the tree is replaced while we are scrolling. |
397 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 398 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
398 m_hostImpl->detachLayerTree(); | 399 m_hostImpl->detachLayerTree(); |
399 | 400 |
400 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 401 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
401 | 402 |
402 // We should still be scrolling, because the scrolled layer also exists in t
he new tree. | 403 // We should still be scrolling, because the scrolled layer also exists in t
he new tree. |
403 gfx::Vector2d scrollDelta(0, 10); | 404 gfx::Vector2d scrollDelta(0, 10); |
404 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 405 m_hostImpl->scrollBy(0, gfx::Point(), scrollDelta); |
405 m_hostImpl->scrollEnd(); | 406 m_hostImpl->scrollEnd(); |
406 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; | 407 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; |
407 expectContains(*scrollInfo, scrollLayerId, scrollDelta); | 408 expectContains(*scrollInfo, scrollLayerId, scrollDelta); |
408 } | 409 } |
409 | 410 |
410 TEST_P(LayerTreeHostImplTest, clearRootRenderSurfaceAndScroll) | 411 TEST_P(LayerTreeHostImplTest, clearRootRenderSurfaceAndScroll) |
411 { | 412 { |
412 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 413 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
413 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); | 414 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); |
414 initializeRendererAndDrawFrame(); | 415 initializeRendererAndDrawFrame(); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 root->setNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); | 461 root->setNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); |
461 | 462 |
462 initializeRendererAndDrawFrame(); | 463 initializeRendererAndDrawFrame(); |
463 | 464 |
464 // All scroll types inside the non-fast scrollable region should fail. | 465 // All scroll types inside the non-fast scrollable region should fail. |
465 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(25, 25), InputHandlerClient::Wh
eel), InputHandlerClient::ScrollOnMainThread); | 466 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(25, 25), InputHandlerClient::Wh
eel), InputHandlerClient::ScrollOnMainThread); |
466 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(25, 25), InputHandlerClient::Ge
sture), InputHandlerClient::ScrollOnMainThread); | 467 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(25, 25), InputHandlerClient::Ge
sture), InputHandlerClient::ScrollOnMainThread); |
467 | 468 |
468 // All scroll types outside this region should succeed. | 469 // All scroll types outside this region should succeed. |
469 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(75, 75), InputHandlerClient::Wh
eel), InputHandlerClient::ScrollStarted); | 470 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(75, 75), InputHandlerClient::Wh
eel), InputHandlerClient::ScrollStarted); |
470 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 471 m_hostImpl->scrollBy(0, gfx::Point(), gfx::Vector2d(0, 10)); |
471 m_hostImpl->scrollEnd(); | 472 m_hostImpl->scrollEnd(); |
472 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(75, 75), InputHandlerClient::Ge
sture), InputHandlerClient::ScrollStarted); | 473 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(75, 75), InputHandlerClient::Ge
sture), InputHandlerClient::ScrollStarted); |
473 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 474 m_hostImpl->scrollBy(0, gfx::Point(), gfx::Vector2d(0, 10)); |
474 m_hostImpl->scrollEnd(); | 475 m_hostImpl->scrollEnd(); |
475 } | 476 } |
476 | 477 |
477 TEST_P(LayerTreeHostImplTest, nonFastScrollableRegionWithOffset) | 478 TEST_P(LayerTreeHostImplTest, nonFastScrollableRegionWithOffset) |
478 { | 479 { |
479 setupScrollAndContentsLayers(gfx::Size(200, 200)); | 480 setupScrollAndContentsLayers(gfx::Size(200, 200)); |
480 m_hostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100)); | 481 m_hostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100)); |
481 | 482 |
482 LayerImpl* root = m_hostImpl->rootLayer(); | 483 LayerImpl* root = m_hostImpl->rootLayer(); |
483 root->setContentsScale(2, 2); | 484 root->setContentsScale(2, 2); |
484 root->setNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); | 485 root->setNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); |
485 root->setPosition(gfx::PointF(-25, 0)); | 486 root->setPosition(gfx::PointF(-25, 0)); |
486 | 487 |
487 initializeRendererAndDrawFrame(); | 488 initializeRendererAndDrawFrame(); |
488 | 489 |
489 // This point would fall into the non-fast scrollable region except that we'
ve moved the layer down by 25 pixels. | 490 // This point would fall into the non-fast scrollable region except that we'
ve moved the layer down by 25 pixels. |
490 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(40, 10), InputHandlerClient::Wh
eel), InputHandlerClient::ScrollStarted); | 491 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(40, 10), InputHandlerClient::Wh
eel), InputHandlerClient::ScrollStarted); |
491 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 1)); | 492 m_hostImpl->scrollBy(0, gfx::Point(), gfx::Vector2d(0, 1)); |
492 m_hostImpl->scrollEnd(); | 493 m_hostImpl->scrollEnd(); |
493 | 494 |
494 // This point is still inside the non-fast region. | 495 // This point is still inside the non-fast region. |
495 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(10, 10), InputHandlerClient::Wh
eel), InputHandlerClient::ScrollOnMainThread); | 496 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(10, 10), InputHandlerClient::Wh
eel), InputHandlerClient::ScrollOnMainThread); |
496 } | 497 } |
497 | 498 |
498 TEST_P(LayerTreeHostImplTest, scrollByReturnsCorrectValue) | 499 TEST_P(LayerTreeHostImplTest, scrollByReturnsCorrectValue) |
499 { | 500 { |
500 setupScrollAndContentsLayers(gfx::Size(200, 200)); | 501 setupScrollAndContentsLayers(gfx::Size(200, 200)); |
501 m_hostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100)); | 502 m_hostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100)); |
502 | 503 |
503 initializeRendererAndDrawFrame(); | 504 initializeRendererAndDrawFrame(); |
504 | 505 |
505 EXPECT_EQ(InputHandlerClient::ScrollStarted, | 506 EXPECT_EQ(InputHandlerClient::ScrollStarted, |
506 m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture)); | 507 m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture)); |
507 | 508 |
508 // Trying to scroll to the left/top will not succeed. | 509 // Trying to scroll to the left/top will not succeed. |
509 EXPECT_FALSE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(-10, 0))); | 510 EXPECT_FALSE(m_hostImpl->scrollBy(0, gfx::Point(), gfx::Vector2d(-10, 0))); |
510 EXPECT_FALSE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, -10))); | 511 EXPECT_FALSE(m_hostImpl->scrollBy(0, gfx::Point(), gfx::Vector2d(0, -10))); |
511 EXPECT_FALSE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(-10, -10))); | 512 EXPECT_FALSE(m_hostImpl->scrollBy(0, gfx::Point(), gfx::Vector2d(-10, -10)))
; |
512 | 513 |
513 // Scrolling to the right/bottom will succeed. | 514 // Scrolling to the right/bottom will succeed. |
514 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(10, 0))); | 515 EXPECT_TRUE(m_hostImpl->scrollBy(0, gfx::Point(), gfx::Vector2d(10, 0))); |
515 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10))); | 516 EXPECT_TRUE(m_hostImpl->scrollBy(0, gfx::Point(), gfx::Vector2d(0, 10))); |
516 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(10, 10))); | 517 EXPECT_TRUE(m_hostImpl->scrollBy(0, gfx::Point(), gfx::Vector2d(10, 10))); |
517 | 518 |
518 // Scrolling to left/top will now succeed. | 519 // Scrolling to left/top will now succeed. |
519 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(-10, 0))); | 520 EXPECT_TRUE(m_hostImpl->scrollBy(0, gfx::Point(), gfx::Vector2d(-10, 0))); |
520 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, -10))); | 521 EXPECT_TRUE(m_hostImpl->scrollBy(0, gfx::Point(), gfx::Vector2d(0, -10))); |
521 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(-10, -10))); | 522 EXPECT_TRUE(m_hostImpl->scrollBy(0, gfx::Point(), gfx::Vector2d(-10, -10))); |
522 | 523 |
523 // Scrolling diagonally against an edge will succeed. | 524 // Scrolling diagonally against an edge will succeed. |
524 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(10, -10))); | 525 EXPECT_TRUE(m_hostImpl->scrollBy(0, gfx::Point(), gfx::Vector2d(10, -10))); |
525 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(-10, 0))); | 526 EXPECT_TRUE(m_hostImpl->scrollBy(0, gfx::Point(), gfx::Vector2d(-10, 0))); |
526 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(-10, 10))); | 527 EXPECT_TRUE(m_hostImpl->scrollBy(0, gfx::Point(), gfx::Vector2d(-10, 10))); |
527 | 528 |
528 // Trying to scroll more than the available space will also succeed. | 529 // Trying to scroll more than the available space will also succeed. |
529 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(5000, 5000))); | 530 EXPECT_TRUE(m_hostImpl->scrollBy(0, gfx::Point(), gfx::Vector2d(5000, 5000))
); |
530 } | 531 } |
531 | 532 |
532 TEST_P(LayerTreeHostImplTest, maxScrollOffsetChangedByDeviceScaleFactor) | 533 TEST_P(LayerTreeHostImplTest, maxScrollOffsetChangedByDeviceScaleFactor) |
533 { | 534 { |
534 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 535 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
535 | 536 |
536 float deviceScaleFactor = 2; | 537 float deviceScaleFactor = 2; |
537 gfx::Size layoutViewport(25, 25); | 538 gfx::Size layoutViewport(25, 25); |
538 gfx::Size deviceViewport(gfx::ToFlooredSize(gfx::ScaleSize(layoutViewport, d
eviceScaleFactor))); | 539 gfx::Size deviceViewport(gfx::ToFlooredSize(gfx::ScaleSize(layoutViewport, d
eviceScaleFactor))); |
539 m_hostImpl->setViewportSize(layoutViewport, deviceViewport); | 540 m_hostImpl->setViewportSize(layoutViewport, deviceViewport); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 scrollLayer->setImplTransform(identityScaleTransform); | 589 scrollLayer->setImplTransform(identityScaleTransform); |
589 scrollLayer->setScrollDelta(gfx::Vector2d()); | 590 scrollLayer->setScrollDelta(gfx::Vector2d()); |
590 | 591 |
591 float pageScaleDelta = 2; | 592 float pageScaleDelta = 2; |
592 m_hostImpl->pinchGestureBegin(); | 593 m_hostImpl->pinchGestureBegin(); |
593 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(0, 0)); | 594 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(0, 0)); |
594 m_hostImpl->pinchGestureEnd(); | 595 m_hostImpl->pinchGestureEnd(); |
595 | 596 |
596 gfx::Vector2d scrollDelta(0, 10); | 597 gfx::Vector2d scrollDelta(0, 10); |
597 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::
Wheel), InputHandlerClient::ScrollStarted); | 598 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::
Wheel), InputHandlerClient::ScrollStarted); |
598 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 599 m_hostImpl->scrollBy(0, gfx::Point(), scrollDelta); |
599 m_hostImpl->scrollEnd(); | 600 m_hostImpl->scrollEnd(); |
600 | 601 |
601 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 602 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
602 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD
elta); | 603 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD
elta); |
603 } | 604 } |
604 } | 605 } |
605 | 606 |
606 TEST_P(LayerTreeHostImplTest, pinchGesture) | 607 TEST_P(LayerTreeHostImplTest, pinchGesture) |
607 { | 608 { |
608 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 609 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 { | 694 { |
694 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); | 695 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); |
695 scrollLayer->setImplTransform(identityScaleTransform); | 696 scrollLayer->setImplTransform(identityScaleTransform); |
696 scrollLayer->setScrollDelta(gfx::Vector2d()); | 697 scrollLayer->setScrollDelta(gfx::Vector2d()); |
697 scrollLayer->setScrollOffset(gfx::Vector2d(20, 20)); | 698 scrollLayer->setScrollOffset(gfx::Vector2d(20, 20)); |
698 | 699 |
699 float pageScaleDelta = 1; | 700 float pageScaleDelta = 1; |
700 m_hostImpl->scrollBegin(gfx::Point(10, 10), InputHandlerClient::Wheel); | 701 m_hostImpl->scrollBegin(gfx::Point(10, 10), InputHandlerClient::Wheel); |
701 m_hostImpl->pinchGestureBegin(); | 702 m_hostImpl->pinchGestureBegin(); |
702 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(10, 10)); | 703 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(10, 10)); |
703 m_hostImpl->scrollBy(gfx::Point(10, 10), gfx::Vector2d(-10, -10)); | 704 m_hostImpl->scrollBy(0, gfx::Point(10, 10), gfx::Vector2d(-10, -10)); |
704 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(20, 20)); | 705 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(20, 20)); |
705 m_hostImpl->pinchGestureEnd(); | 706 m_hostImpl->pinchGestureEnd(); |
706 m_hostImpl->scrollEnd(); | 707 m_hostImpl->scrollEnd(); |
707 | 708 |
708 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 709 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
709 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); | 710 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); |
710 expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(-10, -10)); | 711 expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(-10, -10)); |
711 } | 712 } |
712 } | 713 } |
713 | 714 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
860 // We should immediately get the final zoom and scroll values for the | 861 // We should immediately get the final zoom and scroll values for the |
861 // animation. | 862 // animation. |
862 m_hostImpl->animate(halfwayThroughAnimation, base::Time()); | 863 m_hostImpl->animate(halfwayThroughAnimation, base::Time()); |
863 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; | 864 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; |
864 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); | 865 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); |
865 expectContains(*scrollInfo, scrollLayer->id(), scaledTarget); | 866 expectContains(*scrollInfo, scrollLayer->id(), scaledTarget); |
866 | 867 |
867 // Scrolling during the animation is ignored. | 868 // Scrolling during the animation is ignored. |
868 const gfx::Vector2d scrollDelta(0, 10); | 869 const gfx::Vector2d scrollDelta(0, 10); |
869 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(target.x(), target.y()), InputH
andlerClient::Wheel), InputHandlerClient::ScrollStarted); | 870 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(target.x(), target.y()), InputH
andlerClient::Wheel), InputHandlerClient::ScrollStarted); |
870 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 871 m_hostImpl->scrollBy(0, gfx::Point(), scrollDelta); |
871 m_hostImpl->scrollEnd(); | 872 m_hostImpl->scrollEnd(); |
872 | 873 |
873 // The final page scale and scroll deltas should match what we got | 874 // The final page scale and scroll deltas should match what we got |
874 // earlier. | 875 // earlier. |
875 m_hostImpl->animate(endTime, base::Time()); | 876 m_hostImpl->animate(endTime, base::Time()); |
876 scrollInfo = m_hostImpl->processScrollDeltas(); | 877 scrollInfo = m_hostImpl->processScrollDeltas(); |
877 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); | 878 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); |
878 expectContains(*scrollInfo, scrollLayer->id(), scaledTarget); | 879 expectContains(*scrollInfo, scrollLayer->id(), scaledTarget); |
879 } | 880 } |
880 | 881 |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1134 scrollLayer->setContentBounds(surfaceSize); | 1135 scrollLayer->setContentBounds(surfaceSize); |
1135 scrollLayer->setPosition(gfx::PointF(0, 0)); | 1136 scrollLayer->setPosition(gfx::PointF(0, 0)); |
1136 scrollLayer->setAnchorPoint(gfx::PointF(0, 0)); | 1137 scrollLayer->setAnchorPoint(gfx::PointF(0, 0)); |
1137 scrollLayer->addChild(contentLayer.Pass()); | 1138 scrollLayer->addChild(contentLayer.Pass()); |
1138 | 1139 |
1139 m_hostImpl->setRootLayer(scrollLayer.Pass()); | 1140 m_hostImpl->setRootLayer(scrollLayer.Pass()); |
1140 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1141 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1141 initializeRendererAndDrawFrame(); | 1142 initializeRendererAndDrawFrame(); |
1142 | 1143 |
1143 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 1144 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
1144 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 1145 m_hostImpl->scrollBy(0, gfx::Point(), gfx::Vector2d(0, 10)); |
1145 m_hostImpl->scrollEnd(); | 1146 m_hostImpl->scrollEnd(); |
1146 EXPECT_TRUE(m_didRequestRedraw); | 1147 EXPECT_TRUE(m_didRequestRedraw); |
1147 EXPECT_TRUE(m_didRequestCommit); | 1148 EXPECT_TRUE(m_didRequestCommit); |
1148 } | 1149 } |
1149 | 1150 |
1150 TEST_P(LayerTreeHostImplTest, scrollChildCallsCommitAndRedraw) | 1151 TEST_P(LayerTreeHostImplTest, scrollChildCallsCommitAndRedraw) |
1151 { | 1152 { |
1152 gfx::Size surfaceSize(10, 10); | 1153 gfx::Size surfaceSize(10, 10); |
1153 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1); | 1154 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1); |
1154 root->setBounds(surfaceSize); | 1155 root->setBounds(surfaceSize); |
1155 root->setContentBounds(surfaceSize); | 1156 root->setContentBounds(surfaceSize); |
1156 root->addChild(createScrollableLayer(2, surfaceSize)); | 1157 root->addChild(createScrollableLayer(2, surfaceSize)); |
1157 m_hostImpl->setRootLayer(root.Pass()); | 1158 m_hostImpl->setRootLayer(root.Pass()); |
1158 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1159 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1159 initializeRendererAndDrawFrame(); | 1160 initializeRendererAndDrawFrame(); |
1160 | 1161 |
1161 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 1162 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
1162 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 1163 m_hostImpl->scrollBy(0, gfx::Point(), gfx::Vector2d(0, 10)); |
1163 m_hostImpl->scrollEnd(); | 1164 m_hostImpl->scrollEnd(); |
1164 EXPECT_TRUE(m_didRequestRedraw); | 1165 EXPECT_TRUE(m_didRequestRedraw); |
1165 EXPECT_TRUE(m_didRequestCommit); | 1166 EXPECT_TRUE(m_didRequestCommit); |
1166 } | 1167 } |
1167 | 1168 |
1168 TEST_P(LayerTreeHostImplTest, scrollMissesChild) | 1169 TEST_P(LayerTreeHostImplTest, scrollMissesChild) |
1169 { | 1170 { |
1170 gfx::Size surfaceSize(10, 10); | 1171 gfx::Size surfaceSize(10, 10); |
1171 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1); | 1172 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1); |
1172 root->addChild(createScrollableLayer(2, surfaceSize)); | 1173 root->addChild(createScrollableLayer(2, surfaceSize)); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1227 float pageScale = 2; | 1228 float pageScale = 2; |
1228 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); | 1229 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); |
1229 m_hostImpl->setRootLayer(root.Pass()); | 1230 m_hostImpl->setRootLayer(root.Pass()); |
1230 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1231 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1231 initializeRendererAndDrawFrame(); | 1232 initializeRendererAndDrawFrame(); |
1232 | 1233 |
1233 gfx::Vector2d scrollDelta(0, 10); | 1234 gfx::Vector2d scrollDelta(0, 10); |
1234 gfx::Vector2d expectedScrollDelta(scrollDelta); | 1235 gfx::Vector2d expectedScrollDelta(scrollDelta); |
1235 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); | 1236 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); |
1236 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 1237 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
1237 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 1238 m_hostImpl->scrollBy(0, gfx::Point(), scrollDelta); |
1238 m_hostImpl->scrollEnd(); | 1239 m_hostImpl->scrollEnd(); |
1239 | 1240 |
1240 // Set new page scale from main thread. | 1241 // Set new page scale from main thread. |
1241 m_hostImpl->setPageScaleFactorAndLimits(pageScale, pageScale, pageScale); | 1242 m_hostImpl->setPageScaleFactorAndLimits(pageScale, pageScale, pageScale); |
1242 | 1243 |
1243 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) { | 1244 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) { |
1244 // The scale should apply to the scroll delta. | 1245 // The scale should apply to the scroll delta. |
1245 expectedScrollDelta = gfx::ToFlooredVector2d(gfx::ScaleVector2d(expected
ScrollDelta, pageScale)); | 1246 expectedScrollDelta = gfx::ToFlooredVector2d(gfx::ScaleVector2d(expected
ScrollDelta, pageScale)); |
1246 } | 1247 } |
1247 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; | 1248 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1280 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); | 1281 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); |
1281 m_hostImpl->setRootLayer(root.Pass()); | 1282 m_hostImpl->setRootLayer(root.Pass()); |
1282 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1283 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1283 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); | 1284 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); |
1284 initializeRendererAndDrawFrame(); | 1285 initializeRendererAndDrawFrame(); |
1285 | 1286 |
1286 gfx::Vector2d scrollDelta(0, 10); | 1287 gfx::Vector2d scrollDelta(0, 10); |
1287 gfx::Vector2d expectedScrollDelta(scrollDelta); | 1288 gfx::Vector2d expectedScrollDelta(scrollDelta); |
1288 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); | 1289 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); |
1289 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 1290 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
1290 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 1291 m_hostImpl->scrollBy(0, gfx::Point(), scrollDelta); |
1291 m_hostImpl->scrollEnd(); | 1292 m_hostImpl->scrollEnd(); |
1292 | 1293 |
1293 // Set new page scale on impl thread by pinching. | 1294 // Set new page scale on impl thread by pinching. |
1294 m_hostImpl->pinchGestureBegin(); | 1295 m_hostImpl->pinchGestureBegin(); |
1295 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); | 1296 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); |
1296 m_hostImpl->pinchGestureEnd(); | 1297 m_hostImpl->pinchGestureEnd(); |
1297 m_hostImpl->updateRootScrollLayerImplTransform(); | 1298 m_hostImpl->updateRootScrollLayerImplTransform(); |
1298 | 1299 |
1299 // The scroll delta is not scaled because the main thread did not scale. | 1300 // The scroll delta is not scaled because the main thread did not scale. |
1300 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; | 1301 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1367 m_hostImpl->setRootLayer(root.Pass()); | 1368 m_hostImpl->setRootLayer(root.Pass()); |
1368 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1369 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1369 initializeRendererAndDrawFrame(); | 1370 initializeRendererAndDrawFrame(); |
1370 | 1371 |
1371 LayerImpl* child = m_hostImpl->rootLayer()->children()[0]; | 1372 LayerImpl* child = m_hostImpl->rootLayer()->children()[0]; |
1372 | 1373 |
1373 gfx::Vector2d scrollDelta(0, 10); | 1374 gfx::Vector2d scrollDelta(0, 10); |
1374 gfx::Vector2d expectedScrollDelta(scrollDelta); | 1375 gfx::Vector2d expectedScrollDelta(scrollDelta); |
1375 gfx::Vector2d expectedMaxScroll(child->maxScrollOffset()); | 1376 gfx::Vector2d expectedMaxScroll(child->maxScrollOffset()); |
1376 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 1377 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
1377 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 1378 m_hostImpl->scrollBy(0, gfx::Point(), scrollDelta); |
1378 m_hostImpl->scrollEnd(); | 1379 m_hostImpl->scrollEnd(); |
1379 | 1380 |
1380 float pageScale = 2; | 1381 float pageScale = 2; |
1381 m_hostImpl->setPageScaleFactorAndLimits(pageScale, 1, pageScale); | 1382 m_hostImpl->setPageScaleFactorAndLimits(pageScale, 1, pageScale); |
1382 | 1383 |
1383 m_hostImpl->updateRootScrollLayerImplTransform(); | 1384 m_hostImpl->updateRootScrollLayerImplTransform(); |
1384 | 1385 |
1385 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) { | 1386 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) { |
1386 // The scale should apply to the scroll delta. | 1387 // The scale should apply to the scroll delta. |
1387 expectedScrollDelta = gfx::ToFlooredVector2d(gfx::ScaleVector2d(expected
ScrollDelta, pageScale)); | 1388 expectedScrollDelta = gfx::ToFlooredVector2d(gfx::ScaleVector2d(expected
ScrollDelta, pageScale)); |
(...skipping 24 matching lines...) Expand all Loading... |
1412 child->setScrollOffset(gfx::Vector2d(3, 0)); | 1413 child->setScrollOffset(gfx::Vector2d(3, 0)); |
1413 child->addChild(grandChild.Pass()); | 1414 child->addChild(grandChild.Pass()); |
1414 | 1415 |
1415 root->addChild(child.Pass()); | 1416 root->addChild(child.Pass()); |
1416 m_hostImpl->setRootLayer(root.Pass()); | 1417 m_hostImpl->setRootLayer(root.Pass()); |
1417 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1418 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1418 initializeRendererAndDrawFrame(); | 1419 initializeRendererAndDrawFrame(); |
1419 { | 1420 { |
1420 gfx::Vector2d scrollDelta(-8, -7); | 1421 gfx::Vector2d scrollDelta(-8, -7); |
1421 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::
Wheel), InputHandlerClient::ScrollStarted); | 1422 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::
Wheel), InputHandlerClient::ScrollStarted); |
1422 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 1423 m_hostImpl->scrollBy(0, gfx::Point(), scrollDelta); |
1423 m_hostImpl->scrollEnd(); | 1424 m_hostImpl->scrollEnd(); |
1424 | 1425 |
1425 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 1426 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
1426 | 1427 |
1427 // The grand child should have scrolled up to its limit. | 1428 // The grand child should have scrolled up to its limit. |
1428 LayerImpl* child = m_hostImpl->rootLayer()->children()[0]; | 1429 LayerImpl* child = m_hostImpl->rootLayer()->children()[0]; |
1429 LayerImpl* grandChild = child->children()[0]; | 1430 LayerImpl* grandChild = child->children()[0]; |
1430 expectContains(*scrollInfo.get(), grandChild->id(), gfx::Vector2d(0, -5)
); | 1431 expectContains(*scrollInfo.get(), grandChild->id(), gfx::Vector2d(0, -5)
); |
1431 | 1432 |
1432 // The child should have only scrolled on the other axis. | 1433 // The child should have only scrolled on the other axis. |
(...skipping 11 matching lines...) Expand all Loading... |
1444 | 1445 |
1445 child->setScrollable(false); | 1446 child->setScrollable(false); |
1446 root->addChild(child.Pass()); | 1447 root->addChild(child.Pass()); |
1447 | 1448 |
1448 m_hostImpl->setRootLayer(root.Pass()); | 1449 m_hostImpl->setRootLayer(root.Pass()); |
1449 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1450 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1450 initializeRendererAndDrawFrame(); | 1451 initializeRendererAndDrawFrame(); |
1451 { | 1452 { |
1452 gfx::Vector2d scrollDelta(0, 4); | 1453 gfx::Vector2d scrollDelta(0, 4); |
1453 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::
Wheel), InputHandlerClient::ScrollStarted); | 1454 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::
Wheel), InputHandlerClient::ScrollStarted); |
1454 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 1455 m_hostImpl->scrollBy(0, gfx::Point(), scrollDelta); |
1455 m_hostImpl->scrollEnd(); | 1456 m_hostImpl->scrollEnd(); |
1456 | 1457 |
1457 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 1458 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
1458 | 1459 |
1459 // Only the root should have scrolled. | 1460 // Only the root should have scrolled. |
1460 ASSERT_EQ(scrollInfo->scrolls.size(), 1u); | 1461 ASSERT_EQ(scrollInfo->scrolls.size(), 1u); |
1461 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD
elta); | 1462 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD
elta); |
1462 } | 1463 } |
1463 } | 1464 } |
1464 | 1465 |
(...skipping 21 matching lines...) Expand all Loading... |
1486 rotateTransform.Rotate(-90); | 1487 rotateTransform.Rotate(-90); |
1487 m_hostImpl->rootLayer()->setTransform(rotateTransform); | 1488 m_hostImpl->rootLayer()->setTransform(rotateTransform); |
1488 | 1489 |
1489 gfx::Size surfaceSize(50, 50); | 1490 gfx::Size surfaceSize(50, 50); |
1490 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1491 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1491 initializeRendererAndDrawFrame(); | 1492 initializeRendererAndDrawFrame(); |
1492 | 1493 |
1493 // Scroll to the right in screen coordinates with a gesture. | 1494 // Scroll to the right in screen coordinates with a gesture. |
1494 gfx::Vector2d gestureScrollDelta(10, 0); | 1495 gfx::Vector2d gestureScrollDelta(10, 0); |
1495 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gest
ure), InputHandlerClient::ScrollStarted); | 1496 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gest
ure), InputHandlerClient::ScrollStarted); |
1496 m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta); | 1497 m_hostImpl->scrollBy(0, gfx::Point(), gestureScrollDelta); |
1497 m_hostImpl->scrollEnd(); | 1498 m_hostImpl->scrollEnd(); |
1498 | 1499 |
1499 // The layer should have scrolled down in its local coordinates. | 1500 // The layer should have scrolled down in its local coordinates. |
1500 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; | 1501 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; |
1501 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), gfx::Vector
2d(0, gestureScrollDelta.x())); | 1502 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), gfx::Vector
2d(0, gestureScrollDelta.x())); |
1502 | 1503 |
1503 // Reset and scroll down with the wheel. | 1504 // Reset and scroll down with the wheel. |
1504 m_hostImpl->rootLayer()->setScrollDelta(gfx::Vector2dF()); | 1505 m_hostImpl->rootLayer()->setScrollDelta(gfx::Vector2dF()); |
1505 gfx::Vector2d wheelScrollDelta(0, 10); | 1506 gfx::Vector2d wheelScrollDelta(0, 10); |
1506 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 1507 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
1507 m_hostImpl->scrollBy(gfx::Point(), wheelScrollDelta); | 1508 m_hostImpl->scrollBy(0, gfx::Point(), wheelScrollDelta); |
1508 m_hostImpl->scrollEnd(); | 1509 m_hostImpl->scrollEnd(); |
1509 | 1510 |
1510 // The layer should have scrolled down in its local coordinates. | 1511 // The layer should have scrolled down in its local coordinates. |
1511 scrollInfo = m_hostImpl->processScrollDeltas(); | 1512 scrollInfo = m_hostImpl->processScrollDeltas(); |
1512 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), wheelScroll
Delta); | 1513 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), wheelScroll
Delta); |
1513 } | 1514 } |
1514 | 1515 |
1515 TEST_P(LayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer) | 1516 TEST_P(LayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer) |
1516 { | 1517 { |
1517 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 1518 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
(...skipping 13 matching lines...) Expand all Loading... |
1531 m_hostImpl->rootLayer()->addChild(child.Pass()); | 1532 m_hostImpl->rootLayer()->addChild(child.Pass()); |
1532 | 1533 |
1533 gfx::Size surfaceSize(50, 50); | 1534 gfx::Size surfaceSize(50, 50); |
1534 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1535 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1535 initializeRendererAndDrawFrame(); | 1536 initializeRendererAndDrawFrame(); |
1536 | 1537 |
1537 { | 1538 { |
1538 // Scroll down in screen coordinates with a gesture. | 1539 // Scroll down in screen coordinates with a gesture. |
1539 gfx::Vector2d gestureScrollDelta(0, 10); | 1540 gfx::Vector2d gestureScrollDelta(0, 10); |
1540 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::
Gesture), InputHandlerClient::ScrollStarted); | 1541 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::
Gesture), InputHandlerClient::ScrollStarted); |
1541 m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta); | 1542 m_hostImpl->scrollBy(0, gfx::Point(), gestureScrollDelta); |
1542 m_hostImpl->scrollEnd(); | 1543 m_hostImpl->scrollEnd(); |
1543 | 1544 |
1544 // The child layer should have scrolled down in its local coordinates an
amount proportional to | 1545 // The child layer should have scrolled down in its local coordinates an
amount proportional to |
1545 // the angle between it and the input scroll delta. | 1546 // the angle between it and the input scroll delta. |
1546 gfx::Vector2d expectedScrollDelta(0, gestureScrollDelta.y() * std::cos(M
athUtil::Deg2Rad(childLayerAngle))); | 1547 gfx::Vector2d expectedScrollDelta(0, gestureScrollDelta.y() * std::cos(M
athUtil::Deg2Rad(childLayerAngle))); |
1547 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 1548 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
1548 expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta); | 1549 expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta); |
1549 | 1550 |
1550 // The root layer should not have scrolled, because the input delta was
close to the layer's | 1551 // The root layer should not have scrolled, because the input delta was
close to the layer's |
1551 // axis of movement. | 1552 // axis of movement. |
1552 EXPECT_EQ(scrollInfo->scrolls.size(), 1u); | 1553 EXPECT_EQ(scrollInfo->scrolls.size(), 1u); |
1553 } | 1554 } |
1554 | 1555 |
1555 { | 1556 { |
1556 // Now reset and scroll the same amount horizontally. | 1557 // Now reset and scroll the same amount horizontally. |
1557 m_hostImpl->rootLayer()->children()[1]->setScrollDelta(gfx::Vector2dF())
; | 1558 m_hostImpl->rootLayer()->children()[1]->setScrollDelta(gfx::Vector2dF())
; |
1558 gfx::Vector2d gestureScrollDelta(10, 0); | 1559 gfx::Vector2d gestureScrollDelta(10, 0); |
1559 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::
Gesture), InputHandlerClient::ScrollStarted); | 1560 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::
Gesture), InputHandlerClient::ScrollStarted); |
1560 m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta); | 1561 m_hostImpl->scrollBy(0, gfx::Point(), gestureScrollDelta); |
1561 m_hostImpl->scrollEnd(); | 1562 m_hostImpl->scrollEnd(); |
1562 | 1563 |
1563 // The child layer should have scrolled down in its local coordinates an
amount proportional to | 1564 // The child layer should have scrolled down in its local coordinates an
amount proportional to |
1564 // the angle between it and the input scroll delta. | 1565 // the angle between it and the input scroll delta. |
1565 gfx::Vector2d expectedScrollDelta(0, -gestureScrollDelta.x() * std::sin(
MathUtil::Deg2Rad(childLayerAngle))); | 1566 gfx::Vector2d expectedScrollDelta(0, -gestureScrollDelta.x() * std::sin(
MathUtil::Deg2Rad(childLayerAngle))); |
1566 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 1567 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
1567 expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta); | 1568 expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta); |
1568 | 1569 |
1569 // The root layer should have scrolled more, since the input scroll delt
a was mostly | 1570 // The root layer should have scrolled more, since the input scroll delt
a was mostly |
1570 // orthogonal to the child layer's vertical scroll axis. | 1571 // orthogonal to the child layer's vertical scroll axis. |
(...skipping 12 matching lines...) Expand all Loading... |
1583 scaleTransform.Scale(scale, scale); | 1584 scaleTransform.Scale(scale, scale); |
1584 m_hostImpl->rootLayer()->setTransform(scaleTransform); | 1585 m_hostImpl->rootLayer()->setTransform(scaleTransform); |
1585 | 1586 |
1586 gfx::Size surfaceSize(50, 50); | 1587 gfx::Size surfaceSize(50, 50); |
1587 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1588 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1588 initializeRendererAndDrawFrame(); | 1589 initializeRendererAndDrawFrame(); |
1589 | 1590 |
1590 // Scroll down in screen coordinates with a gesture. | 1591 // Scroll down in screen coordinates with a gesture. |
1591 gfx::Vector2d scrollDelta(0, 10); | 1592 gfx::Vector2d scrollDelta(0, 10); |
1592 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gest
ure), InputHandlerClient::ScrollStarted); | 1593 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gest
ure), InputHandlerClient::ScrollStarted); |
1593 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 1594 m_hostImpl->scrollBy(0, gfx::Point(), scrollDelta); |
1594 m_hostImpl->scrollEnd(); | 1595 m_hostImpl->scrollEnd(); |
1595 | 1596 |
1596 // The layer should have scrolled down in its local coordinates, but half he
amount. | 1597 // The layer should have scrolled down in its local coordinates, but half he
amount. |
1597 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; | 1598 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; |
1598 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), gfx::Vector
2d(0, scrollDelta.y() / scale)); | 1599 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), gfx::Vector
2d(0, scrollDelta.y() / scale)); |
1599 | 1600 |
1600 // Reset and scroll down with the wheel. | 1601 // Reset and scroll down with the wheel. |
1601 m_hostImpl->rootLayer()->setScrollDelta(gfx::Vector2dF()); | 1602 m_hostImpl->rootLayer()->setScrollDelta(gfx::Vector2dF()); |
1602 gfx::Vector2d wheelScrollDelta(0, 10); | 1603 gfx::Vector2d wheelScrollDelta(0, 10); |
1603 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 1604 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
1604 m_hostImpl->scrollBy(gfx::Point(), wheelScrollDelta); | 1605 m_hostImpl->scrollBy(0, gfx::Point(), wheelScrollDelta); |
1605 m_hostImpl->scrollEnd(); | 1606 m_hostImpl->scrollEnd(); |
1606 | 1607 |
1607 // The scale should not have been applied to the scroll delta. | 1608 // The scale should not have been applied to the scroll delta. |
1608 scrollInfo = m_hostImpl->processScrollDeltas(); | 1609 scrollInfo = m_hostImpl->processScrollDeltas(); |
1609 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), wheelScroll
Delta); | 1610 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), wheelScroll
Delta); |
1610 } | 1611 } |
1611 | 1612 |
1612 class BlendStateTrackerContext: public FakeWebGraphicsContext3D { | 1613 class BlendStateTrackerContext: public FakeWebGraphicsContext3D { |
1613 public: | 1614 public: |
1614 BlendStateTrackerContext() : m_blend(false) { } | 1615 BlendStateTrackerContext() : m_blend(false) { } |
(...skipping 2606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4221 | 4222 |
4222 // RendererClient implementation. | 4223 // RendererClient implementation. |
4223 virtual const gfx::Size& deviceViewportSize() const OVERRIDE { return m_view
portSize; } | 4224 virtual const gfx::Size& deviceViewportSize() const OVERRIDE { return m_view
portSize; } |
4224 virtual const LayerTreeSettings& settings() const OVERRIDE { return m_settin
gs; } | 4225 virtual const LayerTreeSettings& settings() const OVERRIDE { return m_settin
gs; } |
4225 virtual void didLoseOutputSurface() OVERRIDE { } | 4226 virtual void didLoseOutputSurface() OVERRIDE { } |
4226 virtual void onSwapBuffersComplete() OVERRIDE { } | 4227 virtual void onSwapBuffersComplete() OVERRIDE { } |
4227 virtual void setFullRootLayerDamage() OVERRIDE { } | 4228 virtual void setFullRootLayerDamage() OVERRIDE { } |
4228 virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERR
IDE { } | 4229 virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERR
IDE { } |
4229 virtual void enforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy) O
VERRIDE { } | 4230 virtual void enforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy) O
VERRIDE { } |
4230 virtual bool hasImplThread() const OVERRIDE { return false; } | 4231 virtual bool hasImplThread() const OVERRIDE { return false; } |
| 4232 virtual void onReceivedLatencyInfo(const WebKit::WebLatencyInfoImpl&) OVERRI
DE { } |
4231 | 4233 |
4232 protected: | 4234 protected: |
4233 TestRenderer(ResourceProvider* resourceProvider, Proxy* proxy) : GLRenderer(
this, resourceProvider) { } | 4235 TestRenderer(ResourceProvider* resourceProvider, Proxy* proxy) : GLRenderer(
this, resourceProvider) { } |
4234 | 4236 |
4235 private: | 4237 private: |
4236 LayerTreeSettings m_settings; | 4238 LayerTreeSettings m_settings; |
4237 gfx::Size m_viewportSize; | 4239 gfx::Size m_viewportSize; |
4238 base::hash_set<RenderPass::Id> m_textures; | 4240 base::hash_set<RenderPass::Id> m_textures; |
4239 }; | 4241 }; |
4240 | 4242 |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4568 // so no point in continuing without it. | 4570 // so no point in continuing without it. |
4569 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) | 4571 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) |
4570 return; | 4572 return; |
4571 | 4573 |
4572 m_didRequestCommit = false; | 4574 m_didRequestCommit = false; |
4573 m_didRequestRedraw = false; | 4575 m_didRequestRedraw = false; |
4574 | 4576 |
4575 // This scroll will force the viewport to pan horizontally. | 4577 // This scroll will force the viewport to pan horizontally. |
4576 gfx::Vector2d scrollDelta(5, 0); | 4578 gfx::Vector2d scrollDelta(5, 0); |
4577 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); | 4579 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); |
4578 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 4580 m_hostImpl->scrollBy(0, gfx::Point(), scrollDelta); |
4579 m_hostImpl->scrollEnd(); | 4581 m_hostImpl->scrollEnd(); |
4580 | 4582 |
4581 EXPECT_EQ(true, m_didRequestCommit); | 4583 EXPECT_EQ(true, m_didRequestCommit); |
4582 EXPECT_EQ(true, m_didRequestRedraw); | 4584 EXPECT_EQ(true, m_didRequestRedraw); |
4583 | 4585 |
4584 m_didRequestCommit = false; | 4586 m_didRequestCommit = false; |
4585 m_didRequestRedraw = false; | 4587 m_didRequestRedraw = false; |
4586 | 4588 |
4587 // This scroll will force the viewport to pan vertically. | 4589 // This scroll will force the viewport to pan vertically. |
4588 scrollDelta = gfx::Vector2d(0, 5); | 4590 scrollDelta = gfx::Vector2d(0, 5); |
4589 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); | 4591 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); |
4590 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 4592 m_hostImpl->scrollBy(0, gfx::Point(), scrollDelta); |
4591 m_hostImpl->scrollEnd(); | 4593 m_hostImpl->scrollEnd(); |
4592 | 4594 |
4593 EXPECT_EQ(true, m_didRequestCommit); | 4595 EXPECT_EQ(true, m_didRequestCommit); |
4594 EXPECT_EQ(true, m_didRequestRedraw); | 4596 EXPECT_EQ(true, m_didRequestRedraw); |
4595 } | 4597 } |
4596 | 4598 |
4597 TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportForcesCommitDeviceScaleFactor1
) | 4599 TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportForcesCommitDeviceScaleFactor1
) |
4598 { | 4600 { |
4599 pinchZoomPanViewportForcesCommitRedraw(1); | 4601 pinchZoomPanViewportForcesCommitRedraw(1); |
4600 } | 4602 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4636 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform); | 4638 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform); |
4637 | 4639 |
4638 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled, | 4640 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled, |
4639 // so no point in continuing without it. | 4641 // so no point in continuing without it. |
4640 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) | 4642 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) |
4641 return; | 4643 return; |
4642 | 4644 |
4643 gfx::Vector2d scrollDelta(5, 0); | 4645 gfx::Vector2d scrollDelta(5, 0); |
4644 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); | 4646 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); |
4645 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); | 4647 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); |
4646 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 4648 m_hostImpl->scrollBy(0, gfx::Point(), scrollDelta); |
4647 m_hostImpl->scrollEnd(); | 4649 m_hostImpl->scrollEnd(); |
4648 m_hostImpl->updateRootScrollLayerImplTransform(); | 4650 m_hostImpl->updateRootScrollLayerImplTransform(); |
4649 | 4651 |
4650 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostI
mpl->deviceScaleFactor()); | 4652 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostI
mpl->deviceScaleFactor()); |
4651 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati
on.y()); | 4653 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati
on.y()); |
4652 | 4654 |
4653 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); | 4655 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); |
4654 // No change expected. | 4656 // No change expected. |
4655 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); | 4657 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); |
4656 // None of the scroll delta should have been used for document scroll. | 4658 // None of the scroll delta should have been used for document scroll. |
4657 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; | 4659 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; |
4658 expectNone(*scrollInfo.get(), m_hostImpl->rootLayer()->id()); | 4660 expectNone(*scrollInfo.get(), m_hostImpl->rootLayer()->id()); |
4659 | 4661 |
4660 // Test scroll in y-direction also. | 4662 // Test scroll in y-direction also. |
4661 scrollDelta = gfx::Vector2d(0, 5); | 4663 scrollDelta = gfx::Vector2d(0, 5); |
4662 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); | 4664 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); |
4663 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 4665 m_hostImpl->scrollBy(0, gfx::Point(), scrollDelta); |
4664 m_hostImpl->scrollEnd(); | 4666 m_hostImpl->scrollEnd(); |
4665 m_hostImpl->updateRootScrollLayerImplTransform(); | 4667 m_hostImpl->updateRootScrollLayerImplTransform(); |
4666 | 4668 |
4667 expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostImpl->deviceScal
eFactor()); | 4669 expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostImpl->deviceScal
eFactor()); |
4668 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati
on.y()); | 4670 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati
on.y()); |
4669 | 4671 |
4670 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); | 4672 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); |
4671 // No change expected. | 4673 // No change expected. |
4672 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); | 4674 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); |
4673 // None of the scroll delta should have been used for document scroll. | 4675 // None of the scroll delta should have been used for document scroll. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4719 // so no point in continuing without it. | 4721 // so no point in continuing without it. |
4720 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) | 4722 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) |
4721 return; | 4723 return; |
4722 | 4724 |
4723 // Scroll document only: scrollDelta chosen to move document horizontally | 4725 // Scroll document only: scrollDelta chosen to move document horizontally |
4724 // to its max scroll offset. | 4726 // to its max scroll offset. |
4725 gfx::Vector2d scrollDelta(3, 0); | 4727 gfx::Vector2d scrollDelta(3, 0); |
4726 gfx::Vector2d expectedScrollDelta(scrollDelta); | 4728 gfx::Vector2d expectedScrollDelta(scrollDelta); |
4727 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); | 4729 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); |
4728 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); | 4730 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); |
4729 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 4731 m_hostImpl->scrollBy(0, gfx::Point(), scrollDelta); |
4730 m_hostImpl->scrollEnd(); | 4732 m_hostImpl->scrollEnd(); |
4731 m_hostImpl->updateRootScrollLayerImplTransform(); | 4733 m_hostImpl->updateRootScrollLayerImplTransform(); |
4732 | 4734 |
4733 // The scroll delta is not scaled because the main thread did not scale. | 4735 // The scroll delta is not scaled because the main thread did not scale. |
4734 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; | 4736 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; |
4735 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); | 4737 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); |
4736 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); | 4738 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); |
4737 | 4739 |
4738 // Verify we did not change the implTransform this time. | 4740 // Verify we did not change the implTransform this time. |
4739 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); | 4741 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); |
4740 | 4742 |
4741 // Further scrolling should move the pinchZoomViewport only. | 4743 // Further scrolling should move the pinchZoomViewport only. |
4742 scrollDelta = gfx::Vector2d(2, 0); | 4744 scrollDelta = gfx::Vector2d(2, 0); |
4743 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); | 4745 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); |
4744 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 4746 m_hostImpl->scrollBy(0, gfx::Point(), scrollDelta); |
4745 m_hostImpl->scrollEnd(); | 4747 m_hostImpl->scrollEnd(); |
4746 m_hostImpl->updateRootScrollLayerImplTransform(); | 4748 m_hostImpl->updateRootScrollLayerImplTransform(); |
4747 | 4749 |
4748 gfx::Vector2d expectedPanDelta(scrollDelta); | 4750 gfx::Vector2d expectedPanDelta(scrollDelta); |
4749 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_
hostImpl->deviceScaleFactor()); | 4751 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_
hostImpl->deviceScaleFactor()); |
4750 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati
on.y()); | 4752 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati
on.y()); |
4751 | 4753 |
4752 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform); | 4754 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform); |
4753 | 4755 |
4754 // The scroll delta on the main thread should not have been affected by this
. | 4756 // The scroll delta on the main thread should not have been affected by this
. |
4755 scrollInfo = m_hostImpl->processScrollDeltas(); | 4757 scrollInfo = m_hostImpl->processScrollDeltas(); |
4756 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); | 4758 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); |
4757 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); | 4759 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); |
4758 | 4760 |
4759 // Perform same test sequence in y-direction also. | 4761 // Perform same test sequence in y-direction also. |
4760 // Document only scroll. | 4762 // Document only scroll. |
4761 scrollDelta = gfx::Vector2d(0, 4); | 4763 scrollDelta = gfx::Vector2d(0, 4); |
4762 expectedScrollDelta += scrollDelta; | 4764 expectedScrollDelta += scrollDelta; |
4763 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); | 4765 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); |
4764 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 4766 m_hostImpl->scrollBy(0, gfx::Point(), scrollDelta); |
4765 m_hostImpl->scrollEnd(); | 4767 m_hostImpl->scrollEnd(); |
4766 m_hostImpl->updateRootScrollLayerImplTransform(); | 4768 m_hostImpl->updateRootScrollLayerImplTransform(); |
4767 | 4769 |
4768 // The scroll delta is not scaled because the main thread did not scale. | 4770 // The scroll delta is not scaled because the main thread did not scale. |
4769 scrollInfo = m_hostImpl->processScrollDeltas(); | 4771 scrollInfo = m_hostImpl->processScrollDeltas(); |
4770 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); | 4772 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); |
4771 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); | 4773 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); |
4772 | 4774 |
4773 // Verify we did not change the implTransform this time. | 4775 // Verify we did not change the implTransform this time. |
4774 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); | 4776 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); |
4775 | 4777 |
4776 // pinchZoomViewport scroll only. | 4778 // pinchZoomViewport scroll only. |
4777 scrollDelta = gfx::Vector2d(0, 1); | 4779 scrollDelta = gfx::Vector2d(0, 1); |
4778 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); | 4780 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); |
4779 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 4781 m_hostImpl->scrollBy(0, gfx::Point(), scrollDelta); |
4780 m_hostImpl->scrollEnd(); | 4782 m_hostImpl->scrollEnd(); |
4781 m_hostImpl->updateRootScrollLayerImplTransform(); | 4783 m_hostImpl->updateRootScrollLayerImplTransform(); |
4782 | 4784 |
4783 expectedPanDelta = scrollDelta; | 4785 expectedPanDelta = scrollDelta; |
4784 expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->devic
eScaleFactor()); | 4786 expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->devic
eScaleFactor()); |
4785 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati
on.y()); | 4787 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati
on.y()); |
4786 | 4788 |
4787 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); | 4789 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); |
4788 | 4790 |
4789 // The scroll delta on the main thread should not have been affected by this
. | 4791 // The scroll delta on the main thread should not have been affected by this
. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4838 // so no point in continuing without it. | 4840 // so no point in continuing without it. |
4839 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) | 4841 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) |
4840 return; | 4842 return; |
4841 | 4843 |
4842 // Scroll document and pann zoomViewport in one scroll-delta. | 4844 // Scroll document and pann zoomViewport in one scroll-delta. |
4843 gfx::Vector2d scrollDelta(5, 0); | 4845 gfx::Vector2d scrollDelta(5, 0); |
4844 gfx::Vector2d expectedScrollDelta(gfx::Vector2d(3, 0)); // This component ge
ts handled by document scroll. | 4846 gfx::Vector2d expectedScrollDelta(gfx::Vector2d(3, 0)); // This component ge
ts handled by document scroll. |
4845 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); | 4847 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); |
4846 | 4848 |
4847 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); | 4849 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); |
4848 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 4850 m_hostImpl->scrollBy(0, gfx::Point(), scrollDelta); |
4849 m_hostImpl->scrollEnd(); | 4851 m_hostImpl->scrollEnd(); |
4850 m_hostImpl->updateRootScrollLayerImplTransform(); | 4852 m_hostImpl->updateRootScrollLayerImplTransform(); |
4851 | 4853 |
4852 // The scroll delta is not scaled because the main thread did not scale. | 4854 // The scroll delta is not scaled because the main thread did not scale. |
4853 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; | 4855 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; |
4854 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); | 4856 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); |
4855 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); | 4857 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); |
4856 | 4858 |
4857 gfx::Vector2d expectedPanDelta(2, 0); // This component gets handled by zoom
Viewport pan. | 4859 gfx::Vector2d expectedPanDelta(2, 0); // This component gets handled by zoom
Viewport pan. |
4858 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_
hostImpl->deviceScaleFactor()); | 4860 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_
hostImpl->deviceScaleFactor()); |
4859 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati
on.y()); | 4861 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati
on.y()); |
4860 | 4862 |
4861 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform); | 4863 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform); |
4862 | 4864 |
4863 // Perform same test sequence in y-direction also. | 4865 // Perform same test sequence in y-direction also. |
4864 scrollDelta = gfx::Vector2d(0, 5); | 4866 scrollDelta = gfx::Vector2d(0, 5); |
4865 expectedScrollDelta += gfx::Vector2d(0, 4); // This component gets handled b
y document scroll. | 4867 expectedScrollDelta += gfx::Vector2d(0, 4); // This component gets handled b
y document scroll. |
4866 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); | 4868 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); |
4867 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 4869 m_hostImpl->scrollBy(0, gfx::Point(), scrollDelta); |
4868 m_hostImpl->scrollEnd(); | 4870 m_hostImpl->scrollEnd(); |
4869 m_hostImpl->updateRootScrollLayerImplTransform(); | 4871 m_hostImpl->updateRootScrollLayerImplTransform(); |
4870 | 4872 |
4871 // The scroll delta is not scaled because the main thread did not scale. | 4873 // The scroll delta is not scaled because the main thread did not scale. |
4872 scrollInfo = m_hostImpl->processScrollDeltas(); // This component gets handl
ed by zoomViewport pan. | 4874 scrollInfo = m_hostImpl->processScrollDeltas(); // This component gets handl
ed by zoomViewport pan. |
4873 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); | 4875 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); |
4874 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); | 4876 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); |
4875 | 4877 |
4876 expectedPanDelta = gfx::Vector2d(0, 1); | 4878 expectedPanDelta = gfx::Vector2d(0, 1); |
4877 expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->devic
eScaleFactor()); | 4879 expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->devic
eScaleFactor()); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4928 gfx::Rect noDamage = gfx::Rect(m_hostImpl->deviceViewportSize()); | 4930 gfx::Rect noDamage = gfx::Rect(m_hostImpl->deviceViewportSize()); |
4929 drawFrameAndTestDamage(noDamage); | 4931 drawFrameAndTestDamage(noDamage); |
4930 } | 4932 } |
4931 | 4933 |
4932 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, | 4934 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, |
4933 LayerTreeHostImplTest, | 4935 LayerTreeHostImplTest, |
4934 ::testing::Values(false, true)); | 4936 ::testing::Values(false, true)); |
4935 | 4937 |
4936 } // namespace | 4938 } // namespace |
4937 } // namespace cc | 4939 } // namespace cc |
OLD | NEW |