| 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" |
| 11 #include "base/hash_tables.h" | 11 #include "base/hash_tables.h" |
| 12 #include "cc/delegated_renderer_layer_impl.h" | 12 #include "cc/delegated_renderer_layer_impl.h" |
| 13 #include "cc/geometry.h" | 13 #include "cc/geometry.h" |
| 14 #include "cc/gl_renderer.h" | 14 #include "cc/gl_renderer.h" |
| 15 #include "cc/heads_up_display_layer_impl.h" | 15 #include "cc/heads_up_display_layer_impl.h" |
| 16 #include "cc/io_surface_layer_impl.h" | 16 #include "cc/io_surface_layer_impl.h" |
| 17 #include "cc/layer_impl.h" | 17 #include "cc/layer_impl.h" |
| 18 #include "cc/layer_tiling_data.h" | 18 #include "cc/layer_tiling_data.h" |
| 19 #include "cc/math_util.h" | 19 #include "cc/math_util.h" |
| 20 #include "cc/quad_sink.h" | 20 #include "cc/quad_sink.h" |
| 21 #include "cc/render_pass_draw_quad.h" | 21 #include "cc/render_pass_draw_quad.h" |
| 22 #include "cc/scrollbar_geometry_fixed_thumb.h" | 22 #include "cc/scrollbar_geometry_fixed_thumb.h" |
| 23 #include "cc/scrollbar_layer_impl.h" | 23 #include "cc/scrollbar_layer_impl.h" |
| 24 #include "cc/settings.h" | |
| 25 #include "cc/single_thread_proxy.h" | 24 #include "cc/single_thread_proxy.h" |
| 26 #include "cc/solid_color_draw_quad.h" | 25 #include "cc/solid_color_draw_quad.h" |
| 27 #include "cc/test/animation_test_common.h" | 26 #include "cc/test/animation_test_common.h" |
| 28 #include "cc/test/fake_proxy.h" | 27 #include "cc/test/fake_proxy.h" |
| 29 #include "cc/test/fake_web_compositor_output_surface.h" | 28 #include "cc/test/fake_web_compositor_output_surface.h" |
| 30 #include "cc/test/fake_web_graphics_context_3d.h" | 29 #include "cc/test/fake_web_graphics_context_3d.h" |
| 31 #include "cc/test/fake_web_scrollbar_theme_geometry.h" | 30 #include "cc/test/fake_web_scrollbar_theme_geometry.h" |
| 32 #include "cc/test/geometry_test_utils.h" | 31 #include "cc/test/geometry_test_utils.h" |
| 33 #include "cc/test/layer_test_common.h" | 32 #include "cc/test/layer_test_common.h" |
| 34 #include "cc/test/render_pass_test_common.h" | 33 #include "cc/test/render_pass_test_common.h" |
| 35 #include "cc/test/test_common.h" | |
| 36 #include "cc/texture_draw_quad.h" | 34 #include "cc/texture_draw_quad.h" |
| 37 #include "cc/texture_layer_impl.h" | 35 #include "cc/texture_layer_impl.h" |
| 38 #include "cc/tile_draw_quad.h" | 36 #include "cc/tile_draw_quad.h" |
| 39 #include "cc/tiled_layer_impl.h" | 37 #include "cc/tiled_layer_impl.h" |
| 40 #include "cc/video_layer_impl.h" | 38 #include "cc/video_layer_impl.h" |
| 41 #include "media/base/media.h" | 39 #include "media/base/media.h" |
| 42 #include "media/base/video_frame.h" | 40 #include "media/base/video_frame.h" |
| 43 #include "testing/gmock/include/gmock/gmock.h" | 41 #include "testing/gmock/include/gmock/gmock.h" |
| 44 #include "testing/gtest/include/gtest/gtest.h" | 42 #include "testing/gtest/include/gtest/gtest.h" |
| 45 #include "ui/gfx/size_conversions.h" | 43 #include "ui/gfx/size_conversions.h" |
| 46 #include "ui/gfx/vector2d_conversions.h" | 44 #include "ui/gfx/vector2d_conversions.h" |
| 47 #include <public/WebVideoFrame.h> | 45 #include <public/WebVideoFrame.h> |
| 48 #include <public/WebVideoFrameProvider.h> | 46 #include <public/WebVideoFrameProvider.h> |
| 49 | 47 |
| 50 using namespace LayerTestCommon; | 48 using namespace LayerTestCommon; |
| 51 using namespace WebKit; | 49 using namespace WebKit; |
| 52 using namespace WebKitTests; | 50 using namespace WebKitTests; |
| 53 | 51 |
| 54 using media::VideoFrame; | 52 using media::VideoFrame; |
| 55 using ::testing::Mock; | 53 using ::testing::Mock; |
| 56 using ::testing::Return; | 54 using ::testing::Return; |
| 57 using ::testing::AnyNumber; | 55 using ::testing::AnyNumber; |
| 58 using ::testing::AtLeast; | 56 using ::testing::AtLeast; |
| 59 using ::testing::_; | 57 using ::testing::_; |
| 60 | 58 |
| 61 namespace cc { | 59 namespace cc { |
| 62 namespace { | 60 namespace { |
| 63 | 61 |
| 64 // This test is parametrized to run all tests with the | 62 // This test is parametrized to run all tests with the |
| 65 // Settings::pageScalePinchZoomEnabled field enabled and disabled. | 63 // m_settings.pageScalePinchZoomEnabled field enabled and disabled. |
| 66 class LayerTreeHostImplTest : public testing::TestWithParam<bool>, | 64 class LayerTreeHostImplTest : public testing::TestWithParam<bool>, |
| 67 public LayerTreeHostImplClient { | 65 public LayerTreeHostImplClient { |
| 68 public: | 66 public: |
| 69 LayerTreeHostImplTest() | 67 LayerTreeHostImplTest() |
| 70 : m_proxy(scoped_ptr<Thread>(NULL)) | 68 : m_proxy(scoped_ptr<Thread>(NULL)) |
| 71 , m_alwaysImplThread(&m_proxy) | 69 , m_alwaysImplThread(&m_proxy) |
| 72 , m_alwaysMainThreadBlocked(&m_proxy) | 70 , m_alwaysMainThreadBlocked(&m_proxy) |
| 73 , m_onCanDrawStateChangedCalled(false) | 71 , m_onCanDrawStateChangedCalled(false) |
| 74 , m_didRequestCommit(false) | 72 , m_didRequestCommit(false) |
| 75 , m_didRequestRedraw(false) | 73 , m_didRequestRedraw(false) |
| 76 , m_reduceMemoryResult(true) | 74 , m_reduceMemoryResult(true) |
| 77 { | 75 { |
| 78 media::InitializeMediaLibraryForTesting(); | 76 media::InitializeMediaLibraryForTesting(); |
| 79 } | 77 } |
| 80 | 78 |
| 81 virtual void SetUp() | 79 virtual void SetUp() |
| 82 { | 80 { |
| 83 Settings::setPageScalePinchZoomEnabled(GetParam()); | |
| 84 LayerTreeSettings settings; | 81 LayerTreeSettings settings; |
| 85 settings.minimumOcclusionTrackingSize = gfx::Size(); | 82 settings.minimumOcclusionTrackingSize = gfx::Size(); |
| 83 settings.pageScalePinchZoomEnabled = GetParam(); |
| 86 | 84 |
| 87 m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy); | 85 m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy); |
| 88 m_hostImpl->initializeRenderer(createContext()); | 86 m_hostImpl->initializeRenderer(createContext()); |
| 89 m_hostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); | 87 m_hostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); |
| 90 } | 88 } |
| 91 | 89 |
| 92 virtual void TearDown() | 90 virtual void TearDown() |
| 93 { | 91 { |
| 94 } | 92 } |
| 95 | 93 |
| 96 virtual void didLoseContextOnImplThread() OVERRIDE { } | 94 virtual void didLoseContextOnImplThread() OVERRIDE { } |
| 97 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { } | 95 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { } |
| 98 virtual void onVSyncParametersChanged(base::TimeTicks, base::TimeDelta) OVER
RIDE { } | 96 virtual void onVSyncParametersChanged(base::TimeTicks, base::TimeDelta) OVER
RIDE { } |
| 99 virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE { m_onCanDrawState
ChangedCalled = true; } | 97 virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE { m_onCanDrawState
ChangedCalled = true; } |
| 100 virtual void setNeedsRedrawOnImplThread() OVERRIDE { m_didRequestRedraw = tr
ue; } | 98 virtual void setNeedsRedrawOnImplThread() OVERRIDE { m_didRequestRedraw = tr
ue; } |
| 101 virtual void setNeedsCommitOnImplThread() OVERRIDE { m_didRequestCommit = tr
ue; } | 99 virtual void setNeedsCommitOnImplThread() OVERRIDE { m_didRequestCommit = tr
ue; } |
| 102 virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<Animatio
nEventsVector>, base::Time wallClockTime) OVERRIDE { } | 100 virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<Animatio
nEventsVector>, base::Time wallClockTime) OVERRIDE { } |
| 103 virtual bool reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int
priorityCutoff) OVERRIDE { return m_reduceMemoryResult; } | 101 virtual bool reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int
priorityCutoff) OVERRIDE { return m_reduceMemoryResult; } |
| 104 virtual void sendManagedMemoryStats() OVERRIDE { } | 102 virtual void sendManagedMemoryStats() OVERRIDE { } |
| 105 | 103 |
| 106 void setReduceMemoryResult(bool reduceMemoryResult) { m_reduceMemoryResult =
reduceMemoryResult; } | 104 void setReduceMemoryResult(bool reduceMemoryResult) { m_reduceMemoryResult =
reduceMemoryResult; } |
| 107 | 105 |
| 108 scoped_ptr<LayerTreeHostImpl> createLayerTreeHost(bool partialSwap, scoped_p
tr<GraphicsContext> graphicsContext, scoped_ptr<LayerImpl> root) | 106 scoped_ptr<LayerTreeHostImpl> createLayerTreeHost(bool partialSwap, scoped_p
tr<GraphicsContext> graphicsContext, scoped_ptr<LayerImpl> root) |
| 109 { | 107 { |
| 110 Settings::setPartialSwapEnabled(partialSwap); | |
| 111 | |
| 112 LayerTreeSettings settings; | 108 LayerTreeSettings settings; |
| 113 settings.minimumOcclusionTrackingSize = gfx::Size(); | 109 settings.minimumOcclusionTrackingSize = gfx::Size(); |
| 110 settings.partialSwapEnabled = partialSwap; |
| 114 | 111 |
| 115 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(set
tings, this, &m_proxy); | 112 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(set
tings, this, &m_proxy); |
| 116 | 113 |
| 117 myHostImpl->initializeRenderer(graphicsContext.Pass()); | 114 myHostImpl->initializeRenderer(graphicsContext.Pass()); |
| 118 myHostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); | 115 myHostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); |
| 119 | 116 |
| 120 root->setAnchorPoint(gfx::PointF(0, 0)); | 117 root->setAnchorPoint(gfx::PointF(0, 0)); |
| 121 root->setPosition(gfx::PointF(0, 0)); | 118 root->setPosition(gfx::PointF(0, 0)); |
| 122 root->setBounds(gfx::Size(10, 10)); | 119 root->setBounds(gfx::Size(10, 10)); |
| 123 root->setContentBounds(gfx::Size(10, 10)); | 120 root->setContentBounds(gfx::Size(10, 10)); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 | 194 |
| 198 FakeProxy m_proxy; | 195 FakeProxy m_proxy; |
| 199 DebugScopedSetImplThread m_alwaysImplThread; | 196 DebugScopedSetImplThread m_alwaysImplThread; |
| 200 DebugScopedSetMainThreadBlocked m_alwaysMainThreadBlocked; | 197 DebugScopedSetMainThreadBlocked m_alwaysMainThreadBlocked; |
| 201 | 198 |
| 202 scoped_ptr<LayerTreeHostImpl> m_hostImpl; | 199 scoped_ptr<LayerTreeHostImpl> m_hostImpl; |
| 203 bool m_onCanDrawStateChangedCalled; | 200 bool m_onCanDrawStateChangedCalled; |
| 204 bool m_didRequestCommit; | 201 bool m_didRequestCommit; |
| 205 bool m_didRequestRedraw; | 202 bool m_didRequestRedraw; |
| 206 bool m_reduceMemoryResult; | 203 bool m_reduceMemoryResult; |
| 207 ScopedSettings m_scopedSettings; | |
| 208 }; | 204 }; |
| 209 | 205 |
| 210 class FakeWebGraphicsContext3DMakeCurrentFails : public FakeWebGraphicsContext3D
{ | 206 class FakeWebGraphicsContext3DMakeCurrentFails : public FakeWebGraphicsContext3D
{ |
| 211 public: | 207 public: |
| 212 virtual bool makeContextCurrent() { return false; } | 208 virtual bool makeContextCurrent() { return false; } |
| 213 }; | 209 }; |
| 214 | 210 |
| 215 TEST_P(LayerTreeHostImplTest, notifyIfCanDrawChanged) | 211 TEST_P(LayerTreeHostImplTest, notifyIfCanDrawChanged) |
| 216 { | 212 { |
| 217 // Note: It is not possible to disable the renderer once it has been set, | 213 // Note: It is not possible to disable the renderer once it has been set, |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 | 488 |
| 493 deviceScaleFactor = 1; | 489 deviceScaleFactor = 1; |
| 494 m_hostImpl->setViewportSize(layoutViewport, layoutViewport); | 490 m_hostImpl->setViewportSize(layoutViewport, layoutViewport); |
| 495 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor); | 491 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor); |
| 496 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), gfx::Vector2d(75, 75))
; | 492 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), gfx::Vector2d(75, 75))
; |
| 497 } | 493 } |
| 498 | 494 |
| 499 TEST_P(LayerTreeHostImplTest, implPinchZoom) | 495 TEST_P(LayerTreeHostImplTest, implPinchZoom) |
| 500 { | 496 { |
| 501 // This test is specific to the page-scale based pinch zoom. | 497 // This test is specific to the page-scale based pinch zoom. |
| 502 if (!Settings::pageScalePinchZoomEnabled()) | 498 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) |
| 503 return; | 499 return; |
| 504 | 500 |
| 505 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 501 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 506 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); | 502 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); |
| 507 initializeRendererAndDrawFrame(); | 503 initializeRendererAndDrawFrame(); |
| 508 | 504 |
| 509 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); | 505 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); |
| 510 DCHECK(scrollLayer); | 506 DCHECK(scrollLayer); |
| 511 | 507 |
| 512 const float minPageScale = 1, maxPageScale = 4; | 508 const float minPageScale = 1, maxPageScale = 4; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 | 551 |
| 556 TEST_P(LayerTreeHostImplTest, pinchGesture) | 552 TEST_P(LayerTreeHostImplTest, pinchGesture) |
| 557 { | 553 { |
| 558 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 554 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 559 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); | 555 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); |
| 560 initializeRendererAndDrawFrame(); | 556 initializeRendererAndDrawFrame(); |
| 561 | 557 |
| 562 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); | 558 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); |
| 563 DCHECK(scrollLayer); | 559 DCHECK(scrollLayer); |
| 564 | 560 |
| 565 const float minPageScale = Settings::pageScalePinchZoomEnabled() ? 1 : 0.5; | 561 const float minPageScale = m_hostImpl->settings().pageScalePinchZoomEnabled
? 1 : 0.5; |
| 566 const float maxPageScale = 4; | 562 const float maxPageScale = 4; |
| 567 const WebTransformationMatrix identityScaleTransform; | 563 const WebTransformationMatrix identityScaleTransform; |
| 568 | 564 |
| 569 // Basic pinch zoom in gesture | 565 // Basic pinch zoom in gesture |
| 570 { | 566 { |
| 571 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); | 567 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); |
| 572 scrollLayer->setImplTransform(identityScaleTransform); | 568 scrollLayer->setImplTransform(identityScaleTransform); |
| 573 scrollLayer->setScrollDelta(gfx::Vector2d()); | 569 scrollLayer->setScrollDelta(gfx::Vector2d()); |
| 574 | 570 |
| 575 float pageScaleDelta = 2; | 571 float pageScaleDelta = 2; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 606 scrollLayer->setScrollOffset(gfx::Vector2d(50, 50)); | 602 scrollLayer->setScrollOffset(gfx::Vector2d(50, 50)); |
| 607 | 603 |
| 608 float pageScaleDelta = 0.1f; | 604 float pageScaleDelta = 0.1f; |
| 609 m_hostImpl->pinchGestureBegin(); | 605 m_hostImpl->pinchGestureBegin(); |
| 610 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(0, 0)); | 606 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(0, 0)); |
| 611 m_hostImpl->pinchGestureEnd(); | 607 m_hostImpl->pinchGestureEnd(); |
| 612 | 608 |
| 613 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 609 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
| 614 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); | 610 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); |
| 615 | 611 |
| 616 if (!Settings::pageScalePinchZoomEnabled()) { | 612 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) { |
| 617 // Pushed to (0,0) via clamping against contents layer size. | 613 // Pushed to (0,0) via clamping against contents layer size. |
| 618 expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(-50, -5
0)); | 614 expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(-50, -5
0)); |
| 619 } else { | 615 } else { |
| 620 EXPECT_TRUE(scrollInfo->scrolls.empty()); | 616 EXPECT_TRUE(scrollInfo->scrolls.empty()); |
| 621 } | 617 } |
| 622 } | 618 } |
| 623 | 619 |
| 624 // Two-finger panning | 620 // Two-finger panning |
| 625 { | 621 { |
| 626 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); | 622 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 | 690 |
| 695 TEST_P(LayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhilePinchZooming) | 691 TEST_P(LayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhilePinchZooming) |
| 696 { | 692 { |
| 697 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 693 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 698 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); | 694 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); |
| 699 initializeRendererAndDrawFrame(); | 695 initializeRendererAndDrawFrame(); |
| 700 | 696 |
| 701 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); | 697 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); |
| 702 DCHECK(scrollLayer); | 698 DCHECK(scrollLayer); |
| 703 | 699 |
| 704 const float minPageScale = Settings::pageScalePinchZoomEnabled() ? 1 : 0.5; | 700 const float minPageScale = m_hostImpl->settings().pageScalePinchZoomEnabled
? 1 : 0.5; |
| 705 const float maxPageScale = 4; | 701 const float maxPageScale = 4; |
| 706 | 702 |
| 707 // Pinch zoom in. | 703 // Pinch zoom in. |
| 708 { | 704 { |
| 709 // Start a pinch in gesture at the bottom right corner of the viewport. | 705 // Start a pinch in gesture at the bottom right corner of the viewport. |
| 710 const float zoomInDelta = 2; | 706 const float zoomInDelta = 2; |
| 711 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); | 707 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); |
| 712 m_hostImpl->pinchGestureBegin(); | 708 m_hostImpl->pinchGestureBegin(); |
| 713 m_hostImpl->pinchGestureUpdate(zoomInDelta, gfx::Point(50, 50)); | 709 m_hostImpl->pinchGestureUpdate(zoomInDelta, gfx::Point(50, 50)); |
| 714 | 710 |
| 715 // Because we are pinch zooming in, we shouldn't get any scroll or page | 711 // Because we are pinch zooming in, we shouldn't get any scroll or page |
| 716 // scale deltas. | 712 // scale deltas. |
| 717 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 713 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
| 718 EXPECT_EQ(scrollInfo->pageScaleDelta, 1); | 714 EXPECT_EQ(scrollInfo->pageScaleDelta, 1); |
| 719 EXPECT_EQ(scrollInfo->scrolls.size(), 0u); | 715 EXPECT_EQ(scrollInfo->scrolls.size(), 0u); |
| 720 | 716 |
| 721 // Once the gesture ends, we get the final scroll and page scale values. | 717 // Once the gesture ends, we get the final scroll and page scale values. |
| 722 m_hostImpl->pinchGestureEnd(); | 718 m_hostImpl->pinchGestureEnd(); |
| 723 scrollInfo = m_hostImpl->processScrollDeltas(); | 719 scrollInfo = m_hostImpl->processScrollDeltas(); |
| 724 EXPECT_EQ(scrollInfo->pageScaleDelta, zoomInDelta); | 720 EXPECT_EQ(scrollInfo->pageScaleDelta, zoomInDelta); |
| 725 if (!Settings::pageScalePinchZoomEnabled()) { | 721 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) { |
| 726 expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(25, 25)
); | 722 expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(25, 25)
); |
| 727 } else { | 723 } else { |
| 728 EXPECT_TRUE(scrollInfo->scrolls.empty()); | 724 EXPECT_TRUE(scrollInfo->scrolls.empty()); |
| 729 } | 725 } |
| 730 } | 726 } |
| 731 | 727 |
| 732 // Pinch zoom out. | 728 // Pinch zoom out. |
| 733 { | 729 { |
| 734 // Start a pinch out gesture at the bottom right corner of the viewport. | 730 // Start a pinch out gesture at the bottom right corner of the viewport. |
| 735 const float zoomOutDelta = 0.75; | 731 const float zoomOutDelta = 0.75; |
| 736 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); | 732 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); |
| 737 m_hostImpl->pinchGestureBegin(); | 733 m_hostImpl->pinchGestureBegin(); |
| 738 m_hostImpl->pinchGestureUpdate(zoomOutDelta, gfx::Point(50, 50)); | 734 m_hostImpl->pinchGestureUpdate(zoomOutDelta, gfx::Point(50, 50)); |
| 739 | 735 |
| 740 // Since we are pinch zooming out, we should get an update to zoom all | 736 // Since we are pinch zooming out, we should get an update to zoom all |
| 741 // the way out to the minimum page scale. | 737 // the way out to the minimum page scale. |
| 742 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 738 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
| 743 if (!Settings::pageScalePinchZoomEnabled()) { | 739 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) { |
| 744 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); | 740 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); |
| 745 expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(0, 0)); | 741 expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(0, 0)); |
| 746 } else { | 742 } else { |
| 747 EXPECT_EQ(scrollInfo->pageScaleDelta, 1); | 743 EXPECT_EQ(scrollInfo->pageScaleDelta, 1); |
| 748 EXPECT_TRUE(scrollInfo->scrolls.empty()); | 744 EXPECT_TRUE(scrollInfo->scrolls.empty()); |
| 749 } | 745 } |
| 750 | 746 |
| 751 // Once the gesture ends, we get the final scroll and page scale values. | 747 // Once the gesture ends, we get the final scroll and page scale values. |
| 752 m_hostImpl->pinchGestureEnd(); | 748 m_hostImpl->pinchGestureEnd(); |
| 753 scrollInfo = m_hostImpl->processScrollDeltas(); | 749 scrollInfo = m_hostImpl->processScrollDeltas(); |
| 754 if (Settings::pageScalePinchZoomEnabled()) { | 750 if (m_hostImpl->settings().pageScalePinchZoomEnabled) { |
| 755 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); | 751 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); |
| 756 expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(25, 25)
); | 752 expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(25, 25)
); |
| 757 } else { | 753 } else { |
| 758 EXPECT_EQ(scrollInfo->pageScaleDelta, zoomOutDelta); | 754 EXPECT_EQ(scrollInfo->pageScaleDelta, zoomOutDelta); |
| 759 expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(8, 8)); | 755 expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(8, 8)); |
| 760 } | 756 } |
| 761 } | 757 } |
| 762 } | 758 } |
| 763 | 759 |
| 764 TEST_P(LayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhileAnimatingPage
Scale) | 760 TEST_P(LayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhileAnimatingPage
Scale) |
| 765 { | 761 { |
| 766 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 762 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 767 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); | 763 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); |
| 768 initializeRendererAndDrawFrame(); | 764 initializeRendererAndDrawFrame(); |
| 769 | 765 |
| 770 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); | 766 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); |
| 771 DCHECK(scrollLayer); | 767 DCHECK(scrollLayer); |
| 772 | 768 |
| 773 const float minPageScale = 0.5; | 769 const float minPageScale = 0.5; |
| 774 const float maxPageScale = 4; | 770 const float maxPageScale = 4; |
| 775 const base::TimeTicks startTime = base::TimeTicks() + base::TimeDelta::FromS
econds(1); | 771 const base::TimeTicks startTime = base::TimeTicks() + base::TimeDelta::FromS
econds(1); |
| 776 const base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); | 772 const base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); |
| 777 const base::TimeTicks halfwayThroughAnimation = startTime + duration / 2; | 773 const base::TimeTicks halfwayThroughAnimation = startTime + duration / 2; |
| 778 const base::TimeTicks endTime = startTime + duration; | 774 const base::TimeTicks endTime = startTime + duration; |
| 779 | 775 |
| 780 const float pageScaleDelta = 2; | 776 const float pageScaleDelta = 2; |
| 781 gfx::Vector2d target(25, 25); | 777 gfx::Vector2d target(25, 25); |
| 782 gfx::Vector2d scaledTarget = target; | 778 gfx::Vector2d scaledTarget = target; |
| 783 if (!Settings::pageScalePinchZoomEnabled()) | 779 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) |
| 784 scaledTarget = gfx::Vector2d(12, 12); | 780 scaledTarget = gfx::Vector2d(12, 12); |
| 785 | 781 |
| 786 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); | 782 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); |
| 787 m_hostImpl->startPageScaleAnimation(target, false, pageScaleDelta, startTime
, duration); | 783 m_hostImpl->startPageScaleAnimation(target, false, pageScaleDelta, startTime
, duration); |
| 788 | 784 |
| 789 // We should immediately get the final zoom and scroll values for the | 785 // We should immediately get the final zoom and scroll values for the |
| 790 // animation. | 786 // animation. |
| 791 m_hostImpl->animate(halfwayThroughAnimation, base::Time()); | 787 m_hostImpl->animate(halfwayThroughAnimation, base::Time()); |
| 792 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; | 788 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; |
| 793 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); | 789 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1163 gfx::Vector2d scrollDelta(0, 10); | 1159 gfx::Vector2d scrollDelta(0, 10); |
| 1164 gfx::Vector2d expectedScrollDelta(scrollDelta); | 1160 gfx::Vector2d expectedScrollDelta(scrollDelta); |
| 1165 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); | 1161 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); |
| 1166 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); |
| 1167 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 1163 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
| 1168 m_hostImpl->scrollEnd(); | 1164 m_hostImpl->scrollEnd(); |
| 1169 | 1165 |
| 1170 // Set new page scale from main thread. | 1166 // Set new page scale from main thread. |
| 1171 m_hostImpl->setPageScaleFactorAndLimits(pageScale, pageScale, pageScale); | 1167 m_hostImpl->setPageScaleFactorAndLimits(pageScale, pageScale, pageScale); |
| 1172 | 1168 |
| 1173 if (!Settings::pageScalePinchZoomEnabled()) { | 1169 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) { |
| 1174 // The scale should apply to the scroll delta. | 1170 // The scale should apply to the scroll delta. |
| 1175 expectedScrollDelta = gfx::ToFlooredVector2d(gfx::ScaleVector2d(expected
ScrollDelta, pageScale)); | 1171 expectedScrollDelta = gfx::ToFlooredVector2d(gfx::ScaleVector2d(expected
ScrollDelta, pageScale)); |
| 1176 } | 1172 } |
| 1177 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; | 1173 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; |
| 1178 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); | 1174 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); |
| 1179 | 1175 |
| 1180 // The scroll range should also have been updated. | 1176 // The scroll range should also have been updated. |
| 1181 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll); | 1177 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll); |
| 1182 | 1178 |
| 1183 // The page scale delta remains constant because the impl thread did not sca
le. | 1179 // The page scale delta remains constant because the impl thread did not sca
le. |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1286 gfx::Vector2d expectedMaxScroll(child->maxScrollOffset()); | 1282 gfx::Vector2d expectedMaxScroll(child->maxScrollOffset()); |
| 1287 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 1283 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
| 1288 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 1284 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
| 1289 m_hostImpl->scrollEnd(); | 1285 m_hostImpl->scrollEnd(); |
| 1290 | 1286 |
| 1291 float pageScale = 2; | 1287 float pageScale = 2; |
| 1292 m_hostImpl->setPageScaleFactorAndLimits(pageScale, 1, pageScale); | 1288 m_hostImpl->setPageScaleFactorAndLimits(pageScale, 1, pageScale); |
| 1293 | 1289 |
| 1294 m_hostImpl->updateRootScrollLayerImplTransform(); | 1290 m_hostImpl->updateRootScrollLayerImplTransform(); |
| 1295 | 1291 |
| 1296 if (!Settings::pageScalePinchZoomEnabled()) { | 1292 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) { |
| 1297 // The scale should apply to the scroll delta. | 1293 // The scale should apply to the scroll delta. |
| 1298 expectedScrollDelta = gfx::ToFlooredVector2d(gfx::ScaleVector2d(expected
ScrollDelta, pageScale)); | 1294 expectedScrollDelta = gfx::ToFlooredVector2d(gfx::ScaleVector2d(expected
ScrollDelta, pageScale)); |
| 1299 } | 1295 } |
| 1300 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; | 1296 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; |
| 1301 expectContains(*scrollInfo.get(), scrollLayerId, expectedScrollDelta); | 1297 expectContains(*scrollInfo.get(), scrollLayerId, expectedScrollDelta); |
| 1302 | 1298 |
| 1303 // The scroll range should not have changed. | 1299 // The scroll range should not have changed. |
| 1304 EXPECT_EQ(child->maxScrollOffset(), expectedMaxScroll); | 1300 EXPECT_EQ(child->maxScrollOffset(), expectedMaxScroll); |
| 1305 | 1301 |
| 1306 // The page scale delta remains constant because the impl thread did not sca
le. | 1302 // The page scale delta remains constant because the impl thread did not sca
le. |
| (...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1950 // Make sure damage tracking propagates all the way to the graphics context, | 1946 // Make sure damage tracking propagates all the way to the graphics context, |
| 1951 // where it should request to swap only the subBuffer that is damaged. | 1947 // where it should request to swap only the subBuffer that is damaged. |
| 1952 TEST_P(LayerTreeHostImplTest, partialSwapReceivesDamageRect) | 1948 TEST_P(LayerTreeHostImplTest, partialSwapReceivesDamageRect) |
| 1953 { | 1949 { |
| 1954 scoped_ptr<GraphicsContext> outputSurface = FakeWebCompositorOutputSurface::
create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapTrackerContext)).
PassAs<GraphicsContext>(); | 1950 scoped_ptr<GraphicsContext> outputSurface = FakeWebCompositorOutputSurface::
create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapTrackerContext)).
PassAs<GraphicsContext>(); |
| 1955 PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrack
erContext*>(outputSurface->context3D()); | 1951 PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrack
erContext*>(outputSurface->context3D()); |
| 1956 | 1952 |
| 1957 // This test creates its own LayerTreeHostImpl, so | 1953 // This test creates its own LayerTreeHostImpl, so |
| 1958 // that we can force partial swap enabled. | 1954 // that we can force partial swap enabled. |
| 1959 LayerTreeSettings settings; | 1955 LayerTreeSettings settings; |
| 1960 Settings::setPartialSwapEnabled(true); | 1956 settings.partialSwapEnabled = true; |
| 1961 scoped_ptr<LayerTreeHostImpl> layerTreeHostImpl = LayerTreeHostImpl::create(
settings, this, &m_proxy); | 1957 scoped_ptr<LayerTreeHostImpl> layerTreeHostImpl = LayerTreeHostImpl::create(
settings, this, &m_proxy); |
| 1962 layerTreeHostImpl->initializeRenderer(outputSurface.Pass()); | 1958 layerTreeHostImpl->initializeRenderer(outputSurface.Pass()); |
| 1963 layerTreeHostImpl->setViewportSize(gfx::Size(500, 500), gfx::Size(500, 500))
; | 1959 layerTreeHostImpl->setViewportSize(gfx::Size(500, 500), gfx::Size(500, 500))
; |
| 1964 | 1960 |
| 1965 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(1); | 1961 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(1); |
| 1966 scoped_ptr<LayerImpl> child = FakeDrawableLayerImpl::create(2); | 1962 scoped_ptr<LayerImpl> child = FakeDrawableLayerImpl::create(2); |
| 1967 child->setPosition(gfx::PointF(12, 13)); | 1963 child->setPosition(gfx::PointF(12, 13)); |
| 1968 child->setAnchorPoint(gfx::PointF(0, 0)); | 1964 child->setAnchorPoint(gfx::PointF(0, 0)); |
| 1969 child->setBounds(gfx::Size(14, 15)); | 1965 child->setBounds(gfx::Size(14, 15)); |
| 1970 child->setContentBounds(gfx::Size(14, 15)); | 1966 child->setContentBounds(gfx::Size(14, 15)); |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2233 // Unlimited texture size. | 2229 // Unlimited texture size. |
| 2234 virtual void getIntegerv(WGC3Denum pname, WGC3Dint* value) | 2230 virtual void getIntegerv(WGC3Denum pname, WGC3Dint* value) |
| 2235 { | 2231 { |
| 2236 if (pname == GL_MAX_TEXTURE_SIZE) | 2232 if (pname == GL_MAX_TEXTURE_SIZE) |
| 2237 *value = 8192; | 2233 *value = 8192; |
| 2238 } | 2234 } |
| 2239 }; | 2235 }; |
| 2240 | 2236 |
| 2241 static scoped_ptr<LayerTreeHostImpl> setupLayersForOpacity(bool partialSwap, Lay
erTreeHostImplClient* client, Proxy* proxy) | 2237 static scoped_ptr<LayerTreeHostImpl> setupLayersForOpacity(bool partialSwap, Lay
erTreeHostImplClient* client, Proxy* proxy) |
| 2242 { | 2238 { |
| 2243 Settings::setPartialSwapEnabled(partialSwap); | |
| 2244 | |
| 2245 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); | 2239 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); |
| 2246 | 2240 |
| 2247 LayerTreeSettings settings; | 2241 LayerTreeSettings settings; |
| 2242 settings.partialSwapEnabled = partialSwap; |
| 2248 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, client, proxy); | 2243 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, client, proxy); |
| 2249 myHostImpl->initializeRenderer(context.Pass()); | 2244 myHostImpl->initializeRenderer(context.Pass()); |
| 2250 myHostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100)); | 2245 myHostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100)); |
| 2251 | 2246 |
| 2252 /* | 2247 /* |
| 2253 Layers are created as follows: | 2248 Layers are created as follows: |
| 2254 | 2249 |
| 2255 +--------------------+ | 2250 +--------------------+ |
| 2256 | 1 | | 2251 | 1 | |
| 2257 | +-----------+ | | 2252 | +-----------+ | |
| (...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3043 addDrawingLayerTo(surfaceLayerPtr, 4, gfx::Rect(5, 5, rootSize.width() - 25,
rootSize.height() - 25), &childPtr); | 3038 addDrawingLayerTo(surfaceLayerPtr, 4, gfx::Rect(5, 5, rootSize.width() - 25,
rootSize.height() - 25), &childPtr); |
| 3044 } | 3039 } |
| 3045 | 3040 |
| 3046 class GLRendererWithReleaseTextures : public GLRenderer { | 3041 class GLRendererWithReleaseTextures : public GLRenderer { |
| 3047 public: | 3042 public: |
| 3048 using GLRenderer::releaseRenderPassTextures; | 3043 using GLRenderer::releaseRenderPassTextures; |
| 3049 }; | 3044 }; |
| 3050 | 3045 |
| 3051 TEST_P(LayerTreeHostImplTest, textureCachingWithClipping) | 3046 TEST_P(LayerTreeHostImplTest, textureCachingWithClipping) |
| 3052 { | 3047 { |
| 3053 Settings::setPartialSwapEnabled(true); | |
| 3054 | |
| 3055 LayerTreeSettings settings; | 3048 LayerTreeSettings settings; |
| 3056 settings.minimumOcclusionTrackingSize = gfx::Size(); | 3049 settings.minimumOcclusionTrackingSize = gfx::Size(); |
| 3050 settings.partialSwapEnabled = true; |
| 3057 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this, &m_proxy); | 3051 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this, &m_proxy); |
| 3058 | 3052 |
| 3059 LayerImpl* rootPtr; | 3053 LayerImpl* rootPtr; |
| 3060 LayerImpl* surfaceLayerPtr; | 3054 LayerImpl* surfaceLayerPtr; |
| 3061 | 3055 |
| 3062 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); | 3056 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); |
| 3063 | 3057 |
| 3064 gfx::Size rootSize(100, 100); | 3058 gfx::Size rootSize(100, 100); |
| 3065 | 3059 |
| 3066 myHostImpl->initializeRenderer(context.Pass()); | 3060 myHostImpl->initializeRenderer(context.Pass()); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3140 EXPECT_EQ(2U, frame.renderPasses[0]->quadList().size()); | 3134 EXPECT_EQ(2U, frame.renderPasses[0]->quadList().size()); |
| 3141 ASSERT_EQ(1U, frame.renderPasses[1]->quadList().size()); | 3135 ASSERT_EQ(1U, frame.renderPasses[1]->quadList().size()); |
| 3142 | 3136 |
| 3143 myHostImpl->drawLayers(frame); | 3137 myHostImpl->drawLayers(frame); |
| 3144 myHostImpl->didDrawAllLayers(frame); | 3138 myHostImpl->didDrawAllLayers(frame); |
| 3145 } | 3139 } |
| 3146 } | 3140 } |
| 3147 | 3141 |
| 3148 TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusion) | 3142 TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusion) |
| 3149 { | 3143 { |
| 3150 Settings::setPartialSwapEnabled(false); | |
| 3151 | |
| 3152 LayerTreeSettings settings; | 3144 LayerTreeSettings settings; |
| 3153 settings.minimumOcclusionTrackingSize = gfx::Size(); | 3145 settings.minimumOcclusionTrackingSize = gfx::Size(); |
| 3154 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this, &m_proxy); | 3146 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this, &m_proxy); |
| 3155 | 3147 |
| 3156 // Layers are structure as follows: | 3148 // Layers are structure as follows: |
| 3157 // | 3149 // |
| 3158 // R +-- S1 +- L10 (owning) | 3150 // R +-- S1 +- L10 (owning) |
| 3159 // | +- L11 | 3151 // | +- L11 |
| 3160 // | +- L12 | 3152 // | +- L12 |
| 3161 // | | 3153 // | |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3256 EXPECT_EQ(2U, frame.renderPasses[0]->quadList().size()); | 3248 EXPECT_EQ(2U, frame.renderPasses[0]->quadList().size()); |
| 3257 | 3249 |
| 3258 myHostImpl->drawLayers(frame); | 3250 myHostImpl->drawLayers(frame); |
| 3259 myHostImpl->didDrawAllLayers(frame); | 3251 myHostImpl->didDrawAllLayers(frame); |
| 3260 } | 3252 } |
| 3261 | 3253 |
| 3262 } | 3254 } |
| 3263 | 3255 |
| 3264 TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionEarlyOut) | 3256 TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionEarlyOut) |
| 3265 { | 3257 { |
| 3266 Settings::setPartialSwapEnabled(false); | |
| 3267 | |
| 3268 LayerTreeSettings settings; | 3258 LayerTreeSettings settings; |
| 3269 settings.minimumOcclusionTrackingSize = gfx::Size(); | 3259 settings.minimumOcclusionTrackingSize = gfx::Size(); |
| 3270 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this, &m_proxy); | 3260 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this, &m_proxy); |
| 3271 | 3261 |
| 3272 // Layers are structure as follows: | 3262 // Layers are structure as follows: |
| 3273 // | 3263 // |
| 3274 // R +-- S1 +- L10 (owning, non drawing) | 3264 // R +-- S1 +- L10 (owning, non drawing) |
| 3275 // | +- L11 (corner, unoccluded) | 3265 // | +- L11 (corner, unoccluded) |
| 3276 // | +- L12 (corner, unoccluded) | 3266 // | +- L12 (corner, unoccluded) |
| 3277 // | +- L13 (corner, unoccluded) | 3267 // | +- L13 (corner, unoccluded) |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3372 | 3362 |
| 3373 EXPECT_EQ(2U, frame.renderPasses[0]->quadList().size()); | 3363 EXPECT_EQ(2U, frame.renderPasses[0]->quadList().size()); |
| 3374 | 3364 |
| 3375 myHostImpl->drawLayers(frame); | 3365 myHostImpl->drawLayers(frame); |
| 3376 myHostImpl->didDrawAllLayers(frame); | 3366 myHostImpl->didDrawAllLayers(frame); |
| 3377 } | 3367 } |
| 3378 } | 3368 } |
| 3379 | 3369 |
| 3380 TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionExternalOverInternal) | 3370 TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionExternalOverInternal) |
| 3381 { | 3371 { |
| 3382 Settings::setPartialSwapEnabled(false); | |
| 3383 | |
| 3384 LayerTreeSettings settings; | 3372 LayerTreeSettings settings; |
| 3385 settings.minimumOcclusionTrackingSize = gfx::Size(); | 3373 settings.minimumOcclusionTrackingSize = gfx::Size(); |
| 3386 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this, &m_proxy); | 3374 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this, &m_proxy); |
| 3387 | 3375 |
| 3388 // Layers are structured as follows: | 3376 // Layers are structured as follows: |
| 3389 // | 3377 // |
| 3390 // R +-- S1 +- L10 (owning, drawing) | 3378 // R +-- S1 +- L10 (owning, drawing) |
| 3391 // | +- L11 (corner, occluded by L12) | 3379 // | +- L11 (corner, occluded by L12) |
| 3392 // | +- L12 (opposite corner) | 3380 // | +- L12 (opposite corner) |
| 3393 // | | 3381 // | |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3461 EXPECT_GT(frame.renderPasses[0]->quadList().size(), 0U); | 3449 EXPECT_GT(frame.renderPasses[0]->quadList().size(), 0U); |
| 3462 EXPECT_EQ(2U, frame.renderPasses[1]->quadList().size()); | 3450 EXPECT_EQ(2U, frame.renderPasses[1]->quadList().size()); |
| 3463 | 3451 |
| 3464 myHostImpl->drawLayers(frame); | 3452 myHostImpl->drawLayers(frame); |
| 3465 myHostImpl->didDrawAllLayers(frame); | 3453 myHostImpl->didDrawAllLayers(frame); |
| 3466 } | 3454 } |
| 3467 } | 3455 } |
| 3468 | 3456 |
| 3469 TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionExternalNotAligned) | 3457 TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionExternalNotAligned) |
| 3470 { | 3458 { |
| 3471 Settings::setPartialSwapEnabled(false); | |
| 3472 | |
| 3473 LayerTreeSettings settings; | 3459 LayerTreeSettings settings; |
| 3474 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this, &m_proxy); | 3460 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this, &m_proxy); |
| 3475 | 3461 |
| 3476 // Layers are structured as follows: | 3462 // Layers are structured as follows: |
| 3477 // | 3463 // |
| 3478 // R +-- S1 +- L10 (rotated, drawing) | 3464 // R +-- S1 +- L10 (rotated, drawing) |
| 3479 // +- L11 (occupies half surface) | 3465 // +- L11 (occupies half surface) |
| 3480 | 3466 |
| 3481 LayerImpl* rootPtr; | 3467 LayerImpl* rootPtr; |
| 3482 LayerImpl* layerS1Ptr; | 3468 LayerImpl* layerS1Ptr; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3535 | 3521 |
| 3536 EXPECT_EQ(1U, frame.renderPasses[0]->quadList().size()); | 3522 EXPECT_EQ(1U, frame.renderPasses[0]->quadList().size()); |
| 3537 | 3523 |
| 3538 myHostImpl->drawLayers(frame); | 3524 myHostImpl->drawLayers(frame); |
| 3539 myHostImpl->didDrawAllLayers(frame); | 3525 myHostImpl->didDrawAllLayers(frame); |
| 3540 } | 3526 } |
| 3541 } | 3527 } |
| 3542 | 3528 |
| 3543 TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionPartialSwap) | 3529 TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionPartialSwap) |
| 3544 { | 3530 { |
| 3545 Settings::setPartialSwapEnabled(true); | |
| 3546 | |
| 3547 LayerTreeSettings settings; | 3531 LayerTreeSettings settings; |
| 3548 settings.minimumOcclusionTrackingSize = gfx::Size(); | 3532 settings.minimumOcclusionTrackingSize = gfx::Size(); |
| 3533 settings.partialSwapEnabled = true; |
| 3549 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this, &m_proxy); | 3534 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this, &m_proxy); |
| 3550 | 3535 |
| 3551 // Layers are structure as follows: | 3536 // Layers are structure as follows: |
| 3552 // | 3537 // |
| 3553 // R +-- S1 +- L10 (owning) | 3538 // R +-- S1 +- L10 (owning) |
| 3554 // | +- L11 | 3539 // | +- L11 |
| 3555 // | +- L12 | 3540 // | +- L12 |
| 3556 // | | 3541 // | |
| 3557 // +-- S2 +- L20 (owning) | 3542 // +-- S2 +- L20 (owning) |
| 3558 // +- L21 | 3543 // +- L21 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3648 // Root render pass only. | 3633 // Root render pass only. |
| 3649 ASSERT_EQ(1U, frame.renderPasses.size()); | 3634 ASSERT_EQ(1U, frame.renderPasses.size()); |
| 3650 | 3635 |
| 3651 myHostImpl->drawLayers(frame); | 3636 myHostImpl->drawLayers(frame); |
| 3652 myHostImpl->didDrawAllLayers(frame); | 3637 myHostImpl->didDrawAllLayers(frame); |
| 3653 } | 3638 } |
| 3654 } | 3639 } |
| 3655 | 3640 |
| 3656 TEST_P(LayerTreeHostImplTest, textureCachingWithScissor) | 3641 TEST_P(LayerTreeHostImplTest, textureCachingWithScissor) |
| 3657 { | 3642 { |
| 3658 Settings::setPartialSwapEnabled(false); | |
| 3659 | |
| 3660 LayerTreeSettings settings; | 3643 LayerTreeSettings settings; |
| 3661 settings.minimumOcclusionTrackingSize = gfx::Size(); | 3644 settings.minimumOcclusionTrackingSize = gfx::Size(); |
| 3662 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this, &m_proxy); | 3645 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this, &m_proxy); |
| 3663 | 3646 |
| 3664 /* | 3647 /* |
| 3665 Layers are created as follows: | 3648 Layers are created as follows: |
| 3666 | 3649 |
| 3667 +--------------------+ | 3650 +--------------------+ |
| 3668 | 1 | | 3651 | 1 | |
| 3669 | +-----------+ | | 3652 | +-----------+ | |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3755 myHostImpl->drawLayers(frame); | 3738 myHostImpl->drawLayers(frame); |
| 3756 myHostImpl->didDrawAllLayers(frame); | 3739 myHostImpl->didDrawAllLayers(frame); |
| 3757 } | 3740 } |
| 3758 | 3741 |
| 3759 // We should have a cached texture for surface 2 again even though it was da
maged. | 3742 // We should have a cached texture for surface 2 again even though it was da
maged. |
| 3760 EXPECT_TRUE(myHostImpl->renderer()->haveCachedResourcesForRenderPassId(child
PassId)); | 3743 EXPECT_TRUE(myHostImpl->renderer()->haveCachedResourcesForRenderPassId(child
PassId)); |
| 3761 } | 3744 } |
| 3762 | 3745 |
| 3763 TEST_P(LayerTreeHostImplTest, surfaceTextureCaching) | 3746 TEST_P(LayerTreeHostImplTest, surfaceTextureCaching) |
| 3764 { | 3747 { |
| 3765 Settings::setPartialSwapEnabled(true); | |
| 3766 | |
| 3767 LayerTreeSettings settings; | 3748 LayerTreeSettings settings; |
| 3768 settings.minimumOcclusionTrackingSize = gfx::Size(); | 3749 settings.minimumOcclusionTrackingSize = gfx::Size(); |
| 3750 settings.partialSwapEnabled = true; |
| 3769 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this, &m_proxy); | 3751 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this, &m_proxy); |
| 3770 | 3752 |
| 3771 LayerImpl* rootPtr; | 3753 LayerImpl* rootPtr; |
| 3772 LayerImpl* intermediateLayerPtr; | 3754 LayerImpl* intermediateLayerPtr; |
| 3773 LayerImpl* surfaceLayerPtr; | 3755 LayerImpl* surfaceLayerPtr; |
| 3774 LayerImpl* childPtr; | 3756 LayerImpl* childPtr; |
| 3775 | 3757 |
| 3776 setupLayersForTextureCaching(myHostImpl.get(), rootPtr, intermediateLayerPtr
, surfaceLayerPtr, childPtr, gfx::Size(100, 100)); | 3758 setupLayersForTextureCaching(myHostImpl.get(), rootPtr, intermediateLayerPtr
, surfaceLayerPtr, childPtr, gfx::Size(100, 100)); |
| 3777 | 3759 |
| 3778 { | 3760 { |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3916 RenderPass* targetPass = frame.renderPassesById.get(quad->renderPassId()
); | 3898 RenderPass* targetPass = frame.renderPassesById.get(quad->renderPassId()
); |
| 3917 EXPECT_TRUE(targetPass->damageRect().IsEmpty()); | 3899 EXPECT_TRUE(targetPass->damageRect().IsEmpty()); |
| 3918 | 3900 |
| 3919 myHostImpl->drawLayers(frame); | 3901 myHostImpl->drawLayers(frame); |
| 3920 myHostImpl->didDrawAllLayers(frame); | 3902 myHostImpl->didDrawAllLayers(frame); |
| 3921 } | 3903 } |
| 3922 } | 3904 } |
| 3923 | 3905 |
| 3924 TEST_P(LayerTreeHostImplTest, surfaceTextureCachingNoPartialSwap) | 3906 TEST_P(LayerTreeHostImplTest, surfaceTextureCachingNoPartialSwap) |
| 3925 { | 3907 { |
| 3926 Settings::setPartialSwapEnabled(false); | |
| 3927 | |
| 3928 LayerTreeSettings settings; | 3908 LayerTreeSettings settings; |
| 3929 settings.minimumOcclusionTrackingSize = gfx::Size(); | 3909 settings.minimumOcclusionTrackingSize = gfx::Size(); |
| 3930 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this, &m_proxy); | 3910 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this, &m_proxy); |
| 3931 | 3911 |
| 3932 LayerImpl* rootPtr; | 3912 LayerImpl* rootPtr; |
| 3933 LayerImpl* intermediateLayerPtr; | 3913 LayerImpl* intermediateLayerPtr; |
| 3934 LayerImpl* surfaceLayerPtr; | 3914 LayerImpl* surfaceLayerPtr; |
| 3935 LayerImpl* childPtr; | 3915 LayerImpl* childPtr; |
| 3936 | 3916 |
| 3937 setupLayersForTextureCaching(myHostImpl.get(), rootPtr, intermediateLayerPtr
, surfaceLayerPtr, childPtr, gfx::Size(100, 100)); | 3917 setupLayersForTextureCaching(myHostImpl.get(), rootPtr, intermediateLayerPtr
, surfaceLayerPtr, childPtr, gfx::Size(100, 100)); |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4439 testCaseIndex++; | 4419 testCaseIndex++; |
| 4440 } | 4420 } |
| 4441 } | 4421 } |
| 4442 | 4422 |
| 4443 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, | 4423 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, |
| 4444 LayerTreeHostImplTest, | 4424 LayerTreeHostImplTest, |
| 4445 ::testing::Values(false, true)); | 4425 ::testing::Values(false, true)); |
| 4446 | 4426 |
| 4447 } // namespace | 4427 } // namespace |
| 4448 } // namespace cc | 4428 } // namespace cc |
| OLD | NEW |