| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
| 6 | 6 |
| 7 #include "base/memory/weak_ptr.h" | 7 #include "base/memory/weak_ptr.h" |
| 8 #include "cc/layers/layer.h" | 8 #include "cc/layers/layer.h" |
| 9 #include "cc/layers/layer_impl.h" | 9 #include "cc/layers/layer_impl.h" |
| 10 #include "cc/layers/picture_layer.h" | 10 #include "cc/layers/picture_layer.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 class LayerTreeHostScrollTest : public LayerTreeTest {}; | 26 class LayerTreeHostScrollTest : public LayerTreeTest {}; |
| 27 | 27 |
| 28 class LayerTreeHostScrollTestScrollSimple : public LayerTreeHostScrollTest { | 28 class LayerTreeHostScrollTestScrollSimple : public LayerTreeHostScrollTest { |
| 29 public: | 29 public: |
| 30 LayerTreeHostScrollTestScrollSimple() | 30 LayerTreeHostScrollTestScrollSimple() |
| 31 : initial_scroll_(10, 20), | 31 : initial_scroll_(10, 20), |
| 32 second_scroll_(40, 5), | 32 second_scroll_(40, 5), |
| 33 scroll_amount_(2, -1), | 33 scroll_amount_(2, -1), |
| 34 num_scrolls_(0) {} | 34 num_scrolls_(0) {} |
| 35 | 35 |
| 36 virtual void BeginTest() OVERRIDE { | 36 virtual void BeginTest() override { |
| 37 Layer* root_layer = layer_tree_host()->root_layer(); | 37 Layer* root_layer = layer_tree_host()->root_layer(); |
| 38 scoped_refptr<Layer> scroll_layer = Layer::Create(); | 38 scoped_refptr<Layer> scroll_layer = Layer::Create(); |
| 39 root_layer->AddChild(scroll_layer); | 39 root_layer->AddChild(scroll_layer); |
| 40 // Create an effective max_scroll_offset of (100, 100). | 40 // Create an effective max_scroll_offset of (100, 100). |
| 41 scroll_layer->SetBounds(gfx::Size(root_layer->bounds().width() + 100, | 41 scroll_layer->SetBounds(gfx::Size(root_layer->bounds().width() + 100, |
| 42 root_layer->bounds().height() + 100)); | 42 root_layer->bounds().height() + 100)); |
| 43 scroll_layer->SetIsDrawable(true); | 43 scroll_layer->SetIsDrawable(true); |
| 44 scroll_layer->SetIsContainerForFixedPositionLayers(true); | 44 scroll_layer->SetIsContainerForFixedPositionLayers(true); |
| 45 scroll_layer->SetScrollClipLayerId(root_layer->id()); | 45 scroll_layer->SetScrollClipLayerId(root_layer->id()); |
| 46 scroll_layer->SetScrollOffset(initial_scroll_); | 46 scroll_layer->SetScrollOffset(initial_scroll_); |
| 47 layer_tree_host()->RegisterViewportLayers(root_layer, scroll_layer, NULL); | 47 layer_tree_host()->RegisterViewportLayers(root_layer, scroll_layer, NULL); |
| 48 PostSetNeedsCommitToMainThread(); | 48 PostSetNeedsCommitToMainThread(); |
| 49 } | 49 } |
| 50 | 50 |
| 51 virtual void Layout() OVERRIDE { | 51 virtual void Layout() override { |
| 52 Layer* root = layer_tree_host()->root_layer(); | 52 Layer* root = layer_tree_host()->root_layer(); |
| 53 Layer* scroll_layer = root->children()[0].get(); | 53 Layer* scroll_layer = root->children()[0].get(); |
| 54 if (!layer_tree_host()->source_frame_number()) { | 54 if (!layer_tree_host()->source_frame_number()) { |
| 55 EXPECT_VECTOR_EQ(initial_scroll_, scroll_layer->scroll_offset()); | 55 EXPECT_VECTOR_EQ(initial_scroll_, scroll_layer->scroll_offset()); |
| 56 } else { | 56 } else { |
| 57 EXPECT_VECTOR_EQ(gfx::ScrollOffsetWithDelta(initial_scroll_, | 57 EXPECT_VECTOR_EQ(gfx::ScrollOffsetWithDelta(initial_scroll_, |
| 58 scroll_amount_), | 58 scroll_amount_), |
| 59 scroll_layer->scroll_offset()); | 59 scroll_layer->scroll_offset()); |
| 60 | 60 |
| 61 // Pretend like Javascript updated the scroll position itself. | 61 // Pretend like Javascript updated the scroll position itself. |
| 62 scroll_layer->SetScrollOffset(second_scroll_); | 62 scroll_layer->SetScrollOffset(second_scroll_); |
| 63 } | 63 } |
| 64 } | 64 } |
| 65 | 65 |
| 66 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 66 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) override { |
| 67 LayerImpl* root = impl->active_tree()->root_layer(); | 67 LayerImpl* root = impl->active_tree()->root_layer(); |
| 68 LayerImpl* scroll_layer = root->children()[0]; | 68 LayerImpl* scroll_layer = root->children()[0]; |
| 69 EXPECT_VECTOR_EQ(gfx::Vector2d(), scroll_layer->ScrollDelta()); | 69 EXPECT_VECTOR_EQ(gfx::Vector2d(), scroll_layer->ScrollDelta()); |
| 70 | 70 |
| 71 scroll_layer->SetScrollClipLayer(root->id()); | 71 scroll_layer->SetScrollClipLayer(root->id()); |
| 72 scroll_layer->SetBounds( | 72 scroll_layer->SetBounds( |
| 73 gfx::Size(root->bounds().width() + 100, root->bounds().height() + 100)); | 73 gfx::Size(root->bounds().width() + 100, root->bounds().height() + 100)); |
| 74 scroll_layer->ScrollBy(scroll_amount_); | 74 scroll_layer->ScrollBy(scroll_amount_); |
| 75 | 75 |
| 76 switch (impl->active_tree()->source_frame_number()) { | 76 switch (impl->active_tree()->source_frame_number()) { |
| 77 case 0: | 77 case 0: |
| 78 EXPECT_VECTOR_EQ(initial_scroll_, scroll_layer->scroll_offset()); | 78 EXPECT_VECTOR_EQ(initial_scroll_, scroll_layer->scroll_offset()); |
| 79 EXPECT_VECTOR_EQ(scroll_amount_, scroll_layer->ScrollDelta()); | 79 EXPECT_VECTOR_EQ(scroll_amount_, scroll_layer->ScrollDelta()); |
| 80 PostSetNeedsCommitToMainThread(); | 80 PostSetNeedsCommitToMainThread(); |
| 81 break; | 81 break; |
| 82 case 1: | 82 case 1: |
| 83 EXPECT_VECTOR_EQ(scroll_layer->scroll_offset(), second_scroll_); | 83 EXPECT_VECTOR_EQ(scroll_layer->scroll_offset(), second_scroll_); |
| 84 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), scroll_amount_); | 84 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), scroll_amount_); |
| 85 EndTest(); | 85 EndTest(); |
| 86 break; | 86 break; |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 | 89 |
| 90 virtual void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, | 90 virtual void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, |
| 91 float scale, | 91 float scale, |
| 92 float top_controls_delta) OVERRIDE { | 92 float top_controls_delta) override { |
| 93 num_scrolls_++; | 93 num_scrolls_++; |
| 94 } | 94 } |
| 95 | 95 |
| 96 virtual void AfterTest() OVERRIDE { EXPECT_EQ(1, num_scrolls_); } | 96 virtual void AfterTest() override { EXPECT_EQ(1, num_scrolls_); } |
| 97 | 97 |
| 98 private: | 98 private: |
| 99 gfx::ScrollOffset initial_scroll_; | 99 gfx::ScrollOffset initial_scroll_; |
| 100 gfx::ScrollOffset second_scroll_; | 100 gfx::ScrollOffset second_scroll_; |
| 101 gfx::Vector2dF scroll_amount_; | 101 gfx::Vector2dF scroll_amount_; |
| 102 int num_scrolls_; | 102 int num_scrolls_; |
| 103 }; | 103 }; |
| 104 | 104 |
| 105 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestScrollSimple); | 105 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestScrollSimple); |
| 106 | 106 |
| 107 class LayerTreeHostScrollTestScrollMultipleRedraw | 107 class LayerTreeHostScrollTestScrollMultipleRedraw |
| 108 : public LayerTreeHostScrollTest { | 108 : public LayerTreeHostScrollTest { |
| 109 public: | 109 public: |
| 110 LayerTreeHostScrollTestScrollMultipleRedraw() | 110 LayerTreeHostScrollTestScrollMultipleRedraw() |
| 111 : initial_scroll_(40, 10), scroll_amount_(-3, 17), num_scrolls_(0) {} | 111 : initial_scroll_(40, 10), scroll_amount_(-3, 17), num_scrolls_(0) {} |
| 112 | 112 |
| 113 virtual void BeginTest() OVERRIDE { | 113 virtual void BeginTest() override { |
| 114 Layer* root_layer = layer_tree_host()->root_layer(); | 114 Layer* root_layer = layer_tree_host()->root_layer(); |
| 115 scroll_layer_ = Layer::Create(); | 115 scroll_layer_ = Layer::Create(); |
| 116 root_layer->AddChild(scroll_layer_); | 116 root_layer->AddChild(scroll_layer_); |
| 117 // Create an effective max_scroll_offset of (100, 100). | 117 // Create an effective max_scroll_offset of (100, 100). |
| 118 scroll_layer_->SetBounds(gfx::Size(root_layer->bounds().width() + 100, | 118 scroll_layer_->SetBounds(gfx::Size(root_layer->bounds().width() + 100, |
| 119 root_layer->bounds().height() + 100)); | 119 root_layer->bounds().height() + 100)); |
| 120 scroll_layer_->SetIsDrawable(true); | 120 scroll_layer_->SetIsDrawable(true); |
| 121 scroll_layer_->SetIsContainerForFixedPositionLayers(true); | 121 scroll_layer_->SetIsContainerForFixedPositionLayers(true); |
| 122 scroll_layer_->SetScrollClipLayerId(root_layer->id()); | 122 scroll_layer_->SetScrollClipLayerId(root_layer->id()); |
| 123 scroll_layer_->SetScrollOffset(initial_scroll_); | 123 scroll_layer_->SetScrollOffset(initial_scroll_); |
| 124 layer_tree_host()->RegisterViewportLayers(root_layer, scroll_layer_, NULL); | 124 layer_tree_host()->RegisterViewportLayers(root_layer, scroll_layer_, NULL); |
| 125 PostSetNeedsCommitToMainThread(); | 125 PostSetNeedsCommitToMainThread(); |
| 126 } | 126 } |
| 127 | 127 |
| 128 virtual void BeginCommitOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 128 virtual void BeginCommitOnThread(LayerTreeHostImpl* impl) override { |
| 129 switch (layer_tree_host()->source_frame_number()) { | 129 switch (layer_tree_host()->source_frame_number()) { |
| 130 case 0: | 130 case 0: |
| 131 EXPECT_VECTOR_EQ(scroll_layer_->scroll_offset(), initial_scroll_); | 131 EXPECT_VECTOR_EQ(scroll_layer_->scroll_offset(), initial_scroll_); |
| 132 break; | 132 break; |
| 133 case 1: | 133 case 1: |
| 134 EXPECT_VECTOR_EQ( | 134 EXPECT_VECTOR_EQ( |
| 135 scroll_layer_->scroll_offset(), | 135 scroll_layer_->scroll_offset(), |
| 136 gfx::ScrollOffsetWithDelta(initial_scroll_, | 136 gfx::ScrollOffsetWithDelta(initial_scroll_, |
| 137 scroll_amount_ + scroll_amount_)); | 137 scroll_amount_ + scroll_amount_)); |
| 138 case 2: | 138 case 2: |
| 139 EXPECT_VECTOR_EQ( | 139 EXPECT_VECTOR_EQ( |
| 140 scroll_layer_->scroll_offset(), | 140 scroll_layer_->scroll_offset(), |
| 141 gfx::ScrollOffsetWithDelta(initial_scroll_, | 141 gfx::ScrollOffsetWithDelta(initial_scroll_, |
| 142 scroll_amount_ + scroll_amount_)); | 142 scroll_amount_ + scroll_amount_)); |
| 143 break; | 143 break; |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 | 146 |
| 147 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 147 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) override { |
| 148 LayerImpl* scroll_layer = | 148 LayerImpl* scroll_layer = |
| 149 impl->active_tree()->LayerById(scroll_layer_->id()); | 149 impl->active_tree()->LayerById(scroll_layer_->id()); |
| 150 if (impl->active_tree()->source_frame_number() == 0 && | 150 if (impl->active_tree()->source_frame_number() == 0 && |
| 151 impl->SourceAnimationFrameNumber() == 1) { | 151 impl->SourceAnimationFrameNumber() == 1) { |
| 152 // First draw after first commit. | 152 // First draw after first commit. |
| 153 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), gfx::Vector2d()); | 153 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), gfx::Vector2d()); |
| 154 scroll_layer->ScrollBy(scroll_amount_); | 154 scroll_layer->ScrollBy(scroll_amount_); |
| 155 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), scroll_amount_); | 155 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), scroll_amount_); |
| 156 | 156 |
| 157 EXPECT_VECTOR_EQ(scroll_layer->scroll_offset(), initial_scroll_); | 157 EXPECT_VECTOR_EQ(scroll_layer->scroll_offset(), initial_scroll_); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 173 EXPECT_VECTOR_EQ( | 173 EXPECT_VECTOR_EQ( |
| 174 scroll_layer_->scroll_offset(), | 174 scroll_layer_->scroll_offset(), |
| 175 gfx::ScrollOffsetWithDelta(initial_scroll_, | 175 gfx::ScrollOffsetWithDelta(initial_scroll_, |
| 176 scroll_amount_ + scroll_amount_)); | 176 scroll_amount_ + scroll_amount_)); |
| 177 EndTest(); | 177 EndTest(); |
| 178 } | 178 } |
| 179 } | 179 } |
| 180 | 180 |
| 181 virtual void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, | 181 virtual void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, |
| 182 float scale, | 182 float scale, |
| 183 float top_controls_delta) OVERRIDE { | 183 float top_controls_delta) override { |
| 184 num_scrolls_++; | 184 num_scrolls_++; |
| 185 } | 185 } |
| 186 | 186 |
| 187 virtual void AfterTest() OVERRIDE { EXPECT_EQ(1, num_scrolls_); } | 187 virtual void AfterTest() override { EXPECT_EQ(1, num_scrolls_); } |
| 188 | 188 |
| 189 private: | 189 private: |
| 190 gfx::ScrollOffset initial_scroll_; | 190 gfx::ScrollOffset initial_scroll_; |
| 191 gfx::Vector2dF scroll_amount_; | 191 gfx::Vector2dF scroll_amount_; |
| 192 int num_scrolls_; | 192 int num_scrolls_; |
| 193 scoped_refptr<Layer> scroll_layer_; | 193 scoped_refptr<Layer> scroll_layer_; |
| 194 }; | 194 }; |
| 195 | 195 |
| 196 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestScrollMultipleRedraw); | 196 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestScrollMultipleRedraw); |
| 197 | 197 |
| 198 class LayerTreeHostScrollTestScrollAbortedCommit | 198 class LayerTreeHostScrollTestScrollAbortedCommit |
| 199 : public LayerTreeHostScrollTest { | 199 : public LayerTreeHostScrollTest { |
| 200 public: | 200 public: |
| 201 LayerTreeHostScrollTestScrollAbortedCommit() | 201 LayerTreeHostScrollTestScrollAbortedCommit() |
| 202 : initial_scroll_(50, 60), | 202 : initial_scroll_(50, 60), |
| 203 impl_scroll_(-3, 2), | 203 impl_scroll_(-3, 2), |
| 204 second_main_scroll_(14, -3), | 204 second_main_scroll_(14, -3), |
| 205 impl_scale_(2.f), | 205 impl_scale_(2.f), |
| 206 num_will_begin_main_frames_(0), | 206 num_will_begin_main_frames_(0), |
| 207 num_did_begin_main_frames_(0), | 207 num_did_begin_main_frames_(0), |
| 208 num_will_commits_(0), | 208 num_will_commits_(0), |
| 209 num_did_commits_(0), | 209 num_did_commits_(0), |
| 210 num_impl_commits_(0), | 210 num_impl_commits_(0), |
| 211 num_impl_scrolls_(0) {} | 211 num_impl_scrolls_(0) {} |
| 212 | 212 |
| 213 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 213 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 214 | 214 |
| 215 virtual void SetupTree() OVERRIDE { | 215 virtual void SetupTree() override { |
| 216 LayerTreeHostScrollTest::SetupTree(); | 216 LayerTreeHostScrollTest::SetupTree(); |
| 217 Layer* root_layer = layer_tree_host()->root_layer(); | 217 Layer* root_layer = layer_tree_host()->root_layer(); |
| 218 scoped_refptr<Layer> root_scroll_layer = Layer::Create(); | 218 scoped_refptr<Layer> root_scroll_layer = Layer::Create(); |
| 219 root_scroll_layer->SetScrollClipLayerId(root_layer->id()); | 219 root_scroll_layer->SetScrollClipLayerId(root_layer->id()); |
| 220 root_scroll_layer->SetScrollOffset(initial_scroll_); | 220 root_scroll_layer->SetScrollOffset(initial_scroll_); |
| 221 root_scroll_layer->SetBounds(gfx::Size(200, 200)); | 221 root_scroll_layer->SetBounds(gfx::Size(200, 200)); |
| 222 root_scroll_layer->SetIsDrawable(true); | 222 root_scroll_layer->SetIsDrawable(true); |
| 223 root_scroll_layer->SetIsContainerForFixedPositionLayers(true); | 223 root_scroll_layer->SetIsContainerForFixedPositionLayers(true); |
| 224 root_layer->AddChild(root_scroll_layer); | 224 root_layer->AddChild(root_scroll_layer); |
| 225 | 225 |
| 226 layer_tree_host()->RegisterViewportLayers( | 226 layer_tree_host()->RegisterViewportLayers( |
| 227 root_layer, root_scroll_layer, NULL); | 227 root_layer, root_scroll_layer, NULL); |
| 228 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.01f, 100.f); | 228 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.01f, 100.f); |
| 229 } | 229 } |
| 230 | 230 |
| 231 virtual void WillBeginMainFrame() OVERRIDE { | 231 virtual void WillBeginMainFrame() override { |
| 232 num_will_begin_main_frames_++; | 232 num_will_begin_main_frames_++; |
| 233 Layer* root_scroll_layer = | 233 Layer* root_scroll_layer = |
| 234 layer_tree_host()->root_layer()->children()[0].get(); | 234 layer_tree_host()->root_layer()->children()[0].get(); |
| 235 switch (num_will_begin_main_frames_) { | 235 switch (num_will_begin_main_frames_) { |
| 236 case 1: | 236 case 1: |
| 237 // This will not be aborted because of the initial prop changes. | 237 // This will not be aborted because of the initial prop changes. |
| 238 EXPECT_EQ(0, num_impl_scrolls_); | 238 EXPECT_EQ(0, num_impl_scrolls_); |
| 239 EXPECT_EQ(0, layer_tree_host()->source_frame_number()); | 239 EXPECT_EQ(0, layer_tree_host()->source_frame_number()); |
| 240 EXPECT_VECTOR_EQ(root_scroll_layer->scroll_offset(), initial_scroll_); | 240 EXPECT_VECTOR_EQ(root_scroll_layer->scroll_offset(), initial_scroll_); |
| 241 EXPECT_EQ(1.f, layer_tree_host()->page_scale_factor()); | 241 EXPECT_EQ(1.f, layer_tree_host()->page_scale_factor()); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 impl_scroll_ + impl_scroll_ + impl_scroll_ + second_main_scroll_; | 273 impl_scroll_ + impl_scroll_ + impl_scroll_ + second_main_scroll_; |
| 274 EXPECT_VECTOR_EQ(root_scroll_layer->scroll_offset(), | 274 EXPECT_VECTOR_EQ(root_scroll_layer->scroll_offset(), |
| 275 gfx::ScrollOffsetWithDelta(initial_scroll_, delta)); | 275 gfx::ScrollOffsetWithDelta(initial_scroll_, delta)); |
| 276 | 276 |
| 277 // End the test by drawing to verify this commit is also aborted. | 277 // End the test by drawing to verify this commit is also aborted. |
| 278 PostSetNeedsRedrawToMainThread(); | 278 PostSetNeedsRedrawToMainThread(); |
| 279 break; | 279 break; |
| 280 } | 280 } |
| 281 } | 281 } |
| 282 | 282 |
| 283 virtual void DidBeginMainFrame() OVERRIDE { num_did_begin_main_frames_++; } | 283 virtual void DidBeginMainFrame() override { num_did_begin_main_frames_++; } |
| 284 | 284 |
| 285 virtual void WillCommit() OVERRIDE { num_will_commits_++; } | 285 virtual void WillCommit() override { num_will_commits_++; } |
| 286 | 286 |
| 287 virtual void DidCommit() OVERRIDE { num_did_commits_++; } | 287 virtual void DidCommit() override { num_did_commits_++; } |
| 288 | 288 |
| 289 virtual void BeginCommitOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 289 virtual void BeginCommitOnThread(LayerTreeHostImpl* impl) override { |
| 290 num_impl_commits_++; | 290 num_impl_commits_++; |
| 291 } | 291 } |
| 292 | 292 |
| 293 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 293 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) override { |
| 294 LayerImpl* root_scroll_layer = | 294 LayerImpl* root_scroll_layer = |
| 295 impl->active_tree()->root_layer()->children()[0]; | 295 impl->active_tree()->root_layer()->children()[0]; |
| 296 | 296 |
| 297 if (impl->active_tree()->source_frame_number() == 0 && | 297 if (impl->active_tree()->source_frame_number() == 0 && |
| 298 impl->SourceAnimationFrameNumber() == 1) { | 298 impl->SourceAnimationFrameNumber() == 1) { |
| 299 // First draw | 299 // First draw |
| 300 EXPECT_VECTOR_EQ(root_scroll_layer->ScrollDelta(), gfx::Vector2d()); | 300 EXPECT_VECTOR_EQ(root_scroll_layer->ScrollDelta(), gfx::Vector2d()); |
| 301 root_scroll_layer->ScrollBy(impl_scroll_); | 301 root_scroll_layer->ScrollBy(impl_scroll_); |
| 302 EXPECT_VECTOR_EQ(root_scroll_layer->ScrollDelta(), impl_scroll_); | 302 EXPECT_VECTOR_EQ(root_scroll_layer->ScrollDelta(), impl_scroll_); |
| 303 EXPECT_VECTOR_EQ(root_scroll_layer->scroll_offset(), initial_scroll_); | 303 EXPECT_VECTOR_EQ(root_scroll_layer->scroll_offset(), initial_scroll_); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 gfx::ScrollOffsetWithDelta(initial_scroll_, delta)); | 353 gfx::ScrollOffsetWithDelta(initial_scroll_, delta)); |
| 354 EndTest(); | 354 EndTest(); |
| 355 } else { | 355 } else { |
| 356 // Commit for source frame 3 is aborted. | 356 // Commit for source frame 3 is aborted. |
| 357 NOTREACHED(); | 357 NOTREACHED(); |
| 358 } | 358 } |
| 359 } | 359 } |
| 360 | 360 |
| 361 virtual void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, | 361 virtual void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, |
| 362 float scale, | 362 float scale, |
| 363 float top_controls_delta) OVERRIDE { | 363 float top_controls_delta) override { |
| 364 num_impl_scrolls_++; | 364 num_impl_scrolls_++; |
| 365 } | 365 } |
| 366 | 366 |
| 367 virtual void AfterTest() OVERRIDE { | 367 virtual void AfterTest() override { |
| 368 EXPECT_EQ(3, num_impl_scrolls_); | 368 EXPECT_EQ(3, num_impl_scrolls_); |
| 369 // Verify that the embedder sees aborted commits as real commits. | 369 // Verify that the embedder sees aborted commits as real commits. |
| 370 EXPECT_EQ(4, num_will_begin_main_frames_); | 370 EXPECT_EQ(4, num_will_begin_main_frames_); |
| 371 EXPECT_EQ(4, num_did_begin_main_frames_); | 371 EXPECT_EQ(4, num_did_begin_main_frames_); |
| 372 EXPECT_EQ(4, num_will_commits_); | 372 EXPECT_EQ(4, num_will_commits_); |
| 373 EXPECT_EQ(4, num_did_commits_); | 373 EXPECT_EQ(4, num_did_commits_); |
| 374 // ...but the compositor thread only sees two real ones. | 374 // ...but the compositor thread only sees two real ones. |
| 375 EXPECT_EQ(2, num_impl_commits_); | 375 EXPECT_EQ(2, num_impl_commits_); |
| 376 } | 376 } |
| 377 | 377 |
| 378 private: | 378 private: |
| 379 gfx::ScrollOffset initial_scroll_; | 379 gfx::ScrollOffset initial_scroll_; |
| 380 gfx::Vector2dF impl_scroll_; | 380 gfx::Vector2dF impl_scroll_; |
| 381 gfx::Vector2dF second_main_scroll_; | 381 gfx::Vector2dF second_main_scroll_; |
| 382 float impl_scale_; | 382 float impl_scale_; |
| 383 int num_will_begin_main_frames_; | 383 int num_will_begin_main_frames_; |
| 384 int num_did_begin_main_frames_; | 384 int num_did_begin_main_frames_; |
| 385 int num_will_commits_; | 385 int num_will_commits_; |
| 386 int num_did_commits_; | 386 int num_did_commits_; |
| 387 int num_impl_commits_; | 387 int num_impl_commits_; |
| 388 int num_impl_scrolls_; | 388 int num_impl_scrolls_; |
| 389 }; | 389 }; |
| 390 | 390 |
| 391 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestScrollAbortedCommit); | 391 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestScrollAbortedCommit); |
| 392 | 392 |
| 393 class LayerTreeHostScrollTestFractionalScroll : public LayerTreeHostScrollTest { | 393 class LayerTreeHostScrollTestFractionalScroll : public LayerTreeHostScrollTest { |
| 394 public: | 394 public: |
| 395 LayerTreeHostScrollTestFractionalScroll() : scroll_amount_(1.75, 0) {} | 395 LayerTreeHostScrollTestFractionalScroll() : scroll_amount_(1.75, 0) {} |
| 396 | 396 |
| 397 virtual void SetupTree() OVERRIDE { | 397 virtual void SetupTree() override { |
| 398 LayerTreeHostScrollTest::SetupTree(); | 398 LayerTreeHostScrollTest::SetupTree(); |
| 399 Layer* root_layer = layer_tree_host()->root_layer(); | 399 Layer* root_layer = layer_tree_host()->root_layer(); |
| 400 scoped_refptr<Layer> root_scroll_layer = Layer::Create(); | 400 scoped_refptr<Layer> root_scroll_layer = Layer::Create(); |
| 401 root_scroll_layer->SetScrollClipLayerId(root_layer->id()); | 401 root_scroll_layer->SetScrollClipLayerId(root_layer->id()); |
| 402 root_scroll_layer->SetBounds( | 402 root_scroll_layer->SetBounds( |
| 403 gfx::Size(root_layer->bounds().width() + 100, | 403 gfx::Size(root_layer->bounds().width() + 100, |
| 404 root_layer->bounds().height() + 100)); | 404 root_layer->bounds().height() + 100)); |
| 405 root_scroll_layer->SetIsDrawable(true); | 405 root_scroll_layer->SetIsDrawable(true); |
| 406 root_scroll_layer->SetIsContainerForFixedPositionLayers(true); | 406 root_scroll_layer->SetIsContainerForFixedPositionLayers(true); |
| 407 root_layer->AddChild(root_scroll_layer); | 407 root_layer->AddChild(root_scroll_layer); |
| 408 | 408 |
| 409 layer_tree_host()->RegisterViewportLayers( | 409 layer_tree_host()->RegisterViewportLayers( |
| 410 root_layer, root_scroll_layer, NULL); | 410 root_layer, root_scroll_layer, NULL); |
| 411 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.01f, 100.f); | 411 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.01f, 100.f); |
| 412 } | 412 } |
| 413 | 413 |
| 414 virtual void BeginTest() OVERRIDE { | 414 virtual void BeginTest() override { |
| 415 PostSetNeedsCommitToMainThread(); | 415 PostSetNeedsCommitToMainThread(); |
| 416 } | 416 } |
| 417 | 417 |
| 418 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 418 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) override { |
| 419 LayerImpl* root = impl->active_tree()->root_layer(); | 419 LayerImpl* root = impl->active_tree()->root_layer(); |
| 420 LayerImpl* scroll_layer = root->children()[0]; | 420 LayerImpl* scroll_layer = root->children()[0]; |
| 421 | 421 |
| 422 // Check that a fractional scroll delta is correctly accumulated over | 422 // Check that a fractional scroll delta is correctly accumulated over |
| 423 // multiple commits. | 423 // multiple commits. |
| 424 switch (impl->active_tree()->source_frame_number()) { | 424 switch (impl->active_tree()->source_frame_number()) { |
| 425 case 0: | 425 case 0: |
| 426 EXPECT_VECTOR_EQ(scroll_layer->scroll_offset(), gfx::Vector2d(0, 0)); | 426 EXPECT_VECTOR_EQ(scroll_layer->scroll_offset(), gfx::Vector2d(0, 0)); |
| 427 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), gfx::Vector2d(0, 0)); | 427 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), gfx::Vector2d(0, 0)); |
| 428 PostSetNeedsCommitToMainThread(); | 428 PostSetNeedsCommitToMainThread(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 440 gfx::ToFlooredVector2d(scroll_amount_ + scroll_amount_)); | 440 gfx::ToFlooredVector2d(scroll_amount_ + scroll_amount_)); |
| 441 EXPECT_VECTOR_EQ( | 441 EXPECT_VECTOR_EQ( |
| 442 scroll_layer->ScrollDelta(), | 442 scroll_layer->ScrollDelta(), |
| 443 gfx::Vector2dF(fmod(2.0f * scroll_amount_.x(), 1.0f), 0.0f)); | 443 gfx::Vector2dF(fmod(2.0f * scroll_amount_.x(), 1.0f), 0.0f)); |
| 444 EndTest(); | 444 EndTest(); |
| 445 break; | 445 break; |
| 446 } | 446 } |
| 447 scroll_layer->ScrollBy(scroll_amount_); | 447 scroll_layer->ScrollBy(scroll_amount_); |
| 448 } | 448 } |
| 449 | 449 |
| 450 virtual void AfterTest() OVERRIDE {} | 450 virtual void AfterTest() override {} |
| 451 | 451 |
| 452 private: | 452 private: |
| 453 gfx::Vector2dF scroll_amount_; | 453 gfx::Vector2dF scroll_amount_; |
| 454 }; | 454 }; |
| 455 | 455 |
| 456 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestFractionalScroll); | 456 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestFractionalScroll); |
| 457 | 457 |
| 458 class LayerTreeHostScrollTestCaseWithChild : public LayerTreeHostScrollTest { | 458 class LayerTreeHostScrollTestCaseWithChild : public LayerTreeHostScrollTest { |
| 459 public: | 459 public: |
| 460 LayerTreeHostScrollTestCaseWithChild() | 460 LayerTreeHostScrollTestCaseWithChild() |
| 461 : initial_offset_(10, 20), | 461 : initial_offset_(10, 20), |
| 462 javascript_scroll_(40, 5), | 462 javascript_scroll_(40, 5), |
| 463 scroll_amount_(2, -1), | 463 scroll_amount_(2, -1), |
| 464 num_scrolls_(0) {} | 464 num_scrolls_(0) {} |
| 465 | 465 |
| 466 virtual void SetupTree() OVERRIDE { | 466 virtual void SetupTree() override { |
| 467 layer_tree_host()->SetDeviceScaleFactor(device_scale_factor_); | 467 layer_tree_host()->SetDeviceScaleFactor(device_scale_factor_); |
| 468 | 468 |
| 469 scoped_refptr<Layer> root_layer = Layer::Create(); | 469 scoped_refptr<Layer> root_layer = Layer::Create(); |
| 470 root_layer->SetBounds(gfx::Size(10, 10)); | 470 root_layer->SetBounds(gfx::Size(10, 10)); |
| 471 | 471 |
| 472 root_scroll_layer_ = FakePictureLayer::Create(&fake_content_layer_client_); | 472 root_scroll_layer_ = FakePictureLayer::Create(&fake_content_layer_client_); |
| 473 root_scroll_layer_->SetBounds(gfx::Size(110, 110)); | 473 root_scroll_layer_->SetBounds(gfx::Size(110, 110)); |
| 474 | 474 |
| 475 root_scroll_layer_->SetPosition(gfx::Point()); | 475 root_scroll_layer_->SetPosition(gfx::Point()); |
| 476 | 476 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 } | 509 } |
| 510 | 510 |
| 511 expected_scroll_layer_->SetScrollOffset(initial_offset_); | 511 expected_scroll_layer_->SetScrollOffset(initial_offset_); |
| 512 | 512 |
| 513 layer_tree_host()->SetRootLayer(root_layer); | 513 layer_tree_host()->SetRootLayer(root_layer); |
| 514 layer_tree_host()->RegisterViewportLayers( | 514 layer_tree_host()->RegisterViewportLayers( |
| 515 root_layer, root_scroll_layer_, NULL); | 515 root_layer, root_scroll_layer_, NULL); |
| 516 LayerTreeHostScrollTest::SetupTree(); | 516 LayerTreeHostScrollTest::SetupTree(); |
| 517 } | 517 } |
| 518 | 518 |
| 519 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 519 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 520 | 520 |
| 521 virtual void WillCommit() OVERRIDE { | 521 virtual void WillCommit() override { |
| 522 // Keep the test committing (otherwise the early out for no update | 522 // Keep the test committing (otherwise the early out for no update |
| 523 // will stall the test). | 523 // will stall the test). |
| 524 if (layer_tree_host()->source_frame_number() < 2) { | 524 if (layer_tree_host()->source_frame_number() < 2) { |
| 525 layer_tree_host()->SetNeedsCommit(); | 525 layer_tree_host()->SetNeedsCommit(); |
| 526 } | 526 } |
| 527 } | 527 } |
| 528 | 528 |
| 529 void DidScroll() { | 529 void DidScroll() { |
| 530 final_scroll_offset_ = expected_scroll_layer_->scroll_offset(); | 530 final_scroll_offset_ = expected_scroll_layer_->scroll_offset(); |
| 531 } | 531 } |
| 532 | 532 |
| 533 virtual void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, | 533 virtual void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, |
| 534 float scale, | 534 float scale, |
| 535 float top_controls_delta) OVERRIDE { | 535 float top_controls_delta) override { |
| 536 num_scrolls_++; | 536 num_scrolls_++; |
| 537 } | 537 } |
| 538 | 538 |
| 539 virtual void Layout() OVERRIDE { | 539 virtual void Layout() override { |
| 540 EXPECT_VECTOR_EQ(gfx::Vector2d(), | 540 EXPECT_VECTOR_EQ(gfx::Vector2d(), |
| 541 expected_no_scroll_layer_->scroll_offset()); | 541 expected_no_scroll_layer_->scroll_offset()); |
| 542 | 542 |
| 543 switch (layer_tree_host()->source_frame_number()) { | 543 switch (layer_tree_host()->source_frame_number()) { |
| 544 case 0: | 544 case 0: |
| 545 EXPECT_VECTOR_EQ(initial_offset_, | 545 EXPECT_VECTOR_EQ(initial_offset_, |
| 546 expected_scroll_layer_->scroll_offset()); | 546 expected_scroll_layer_->scroll_offset()); |
| 547 break; | 547 break; |
| 548 case 1: | 548 case 1: |
| 549 EXPECT_VECTOR_EQ( | 549 EXPECT_VECTOR_EQ( |
| 550 gfx::ScrollOffsetWithDelta(initial_offset_, scroll_amount_), | 550 gfx::ScrollOffsetWithDelta(initial_offset_, scroll_amount_), |
| 551 expected_scroll_layer_->scroll_offset()); | 551 expected_scroll_layer_->scroll_offset()); |
| 552 | 552 |
| 553 // Pretend like Javascript updated the scroll position itself. | 553 // Pretend like Javascript updated the scroll position itself. |
| 554 expected_scroll_layer_->SetScrollOffset(javascript_scroll_); | 554 expected_scroll_layer_->SetScrollOffset(javascript_scroll_); |
| 555 break; | 555 break; |
| 556 case 2: | 556 case 2: |
| 557 EXPECT_VECTOR_EQ(gfx::ScrollOffsetWithDelta(javascript_scroll_, | 557 EXPECT_VECTOR_EQ(gfx::ScrollOffsetWithDelta(javascript_scroll_, |
| 558 scroll_amount_), | 558 scroll_amount_), |
| 559 expected_scroll_layer_->scroll_offset()); | 559 expected_scroll_layer_->scroll_offset()); |
| 560 break; | 560 break; |
| 561 } | 561 } |
| 562 } | 562 } |
| 563 | 563 |
| 564 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 564 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override { |
| 565 LayerImpl* root_impl = impl->active_tree()->root_layer(); | 565 LayerImpl* root_impl = impl->active_tree()->root_layer(); |
| 566 FakePictureLayerImpl* root_scroll_layer_impl = | 566 FakePictureLayerImpl* root_scroll_layer_impl = |
| 567 static_cast<FakePictureLayerImpl*>(root_impl->children()[0]); | 567 static_cast<FakePictureLayerImpl*>(root_impl->children()[0]); |
| 568 FakePictureLayerImpl* child_layer_impl = static_cast<FakePictureLayerImpl*>( | 568 FakePictureLayerImpl* child_layer_impl = static_cast<FakePictureLayerImpl*>( |
| 569 root_scroll_layer_impl->children()[0]); | 569 root_scroll_layer_impl->children()[0]); |
| 570 | 570 |
| 571 LayerImpl* expected_scroll_layer_impl = NULL; | 571 LayerImpl* expected_scroll_layer_impl = NULL; |
| 572 LayerImpl* expected_no_scroll_layer_impl = NULL; | 572 LayerImpl* expected_no_scroll_layer_impl = NULL; |
| 573 if (scroll_child_layer_) { | 573 if (scroll_child_layer_) { |
| 574 expected_scroll_layer_impl = child_layer_impl; | 574 expected_scroll_layer_impl = child_layer_impl; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 scroll_amount_), | 625 scroll_amount_), |
| 626 expected_scroll_layer_impl->scroll_offset()); | 626 expected_scroll_layer_impl->scroll_offset()); |
| 627 EXPECT_VECTOR_EQ(gfx::Vector2d(), | 627 EXPECT_VECTOR_EQ(gfx::Vector2d(), |
| 628 expected_scroll_layer_impl->ScrollDelta()); | 628 expected_scroll_layer_impl->ScrollDelta()); |
| 629 | 629 |
| 630 EndTest(); | 630 EndTest(); |
| 631 break; | 631 break; |
| 632 } | 632 } |
| 633 } | 633 } |
| 634 | 634 |
| 635 virtual void AfterTest() OVERRIDE { | 635 virtual void AfterTest() override { |
| 636 if (scroll_child_layer_) { | 636 if (scroll_child_layer_) { |
| 637 EXPECT_EQ(0, num_scrolls_); | 637 EXPECT_EQ(0, num_scrolls_); |
| 638 EXPECT_VECTOR_EQ(gfx::ScrollOffsetWithDelta(javascript_scroll_, | 638 EXPECT_VECTOR_EQ(gfx::ScrollOffsetWithDelta(javascript_scroll_, |
| 639 scroll_amount_), | 639 scroll_amount_), |
| 640 final_scroll_offset_); | 640 final_scroll_offset_); |
| 641 } else { | 641 } else { |
| 642 EXPECT_EQ(2, num_scrolls_); | 642 EXPECT_EQ(2, num_scrolls_); |
| 643 EXPECT_VECTOR_EQ(gfx::ScrollOffset(), final_scroll_offset_); | 643 EXPECT_VECTOR_EQ(gfx::ScrollOffset(), final_scroll_offset_); |
| 644 } | 644 } |
| 645 } | 645 } |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 | 741 |
| 742 TEST_F(LayerTreeHostScrollTestCaseWithChild, | 742 TEST_F(LayerTreeHostScrollTestCaseWithChild, |
| 743 DeviceScaleFactor2_ScrollRootScrollLayer_DelegatingRenderer) { | 743 DeviceScaleFactor2_ScrollRootScrollLayer_DelegatingRenderer) { |
| 744 device_scale_factor_ = 2.f; | 744 device_scale_factor_ = 2.f; |
| 745 scroll_child_layer_ = false; | 745 scroll_child_layer_ = false; |
| 746 RunTest(true, true, true); | 746 RunTest(true, true, true); |
| 747 } | 747 } |
| 748 | 748 |
| 749 class ImplSidePaintingScrollTest : public LayerTreeHostScrollTest { | 749 class ImplSidePaintingScrollTest : public LayerTreeHostScrollTest { |
| 750 public: | 750 public: |
| 751 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | 751 virtual void InitializeSettings(LayerTreeSettings* settings) override { |
| 752 settings->impl_side_painting = true; | 752 settings->impl_side_painting = true; |
| 753 } | 753 } |
| 754 | 754 |
| 755 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 755 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) override { |
| 756 if (impl->pending_tree()) | 756 if (impl->pending_tree()) |
| 757 impl->SetNeedsRedraw(); | 757 impl->SetNeedsRedraw(); |
| 758 } | 758 } |
| 759 }; | 759 }; |
| 760 | 760 |
| 761 class ImplSidePaintingScrollTestSimple : public ImplSidePaintingScrollTest { | 761 class ImplSidePaintingScrollTestSimple : public ImplSidePaintingScrollTest { |
| 762 public: | 762 public: |
| 763 ImplSidePaintingScrollTestSimple() | 763 ImplSidePaintingScrollTestSimple() |
| 764 : initial_scroll_(10, 20), | 764 : initial_scroll_(10, 20), |
| 765 main_thread_scroll_(40, 5), | 765 main_thread_scroll_(40, 5), |
| 766 impl_thread_scroll1_(2, -1), | 766 impl_thread_scroll1_(2, -1), |
| 767 impl_thread_scroll2_(-3, 10), | 767 impl_thread_scroll2_(-3, 10), |
| 768 num_scrolls_(0) {} | 768 num_scrolls_(0) {} |
| 769 | 769 |
| 770 virtual void SetupTree() OVERRIDE { | 770 virtual void SetupTree() override { |
| 771 LayerTreeHostScrollTest::SetupTree(); | 771 LayerTreeHostScrollTest::SetupTree(); |
| 772 Layer* root_layer = layer_tree_host()->root_layer(); | 772 Layer* root_layer = layer_tree_host()->root_layer(); |
| 773 scoped_refptr<Layer> root_scroll_layer = Layer::Create(); | 773 scoped_refptr<Layer> root_scroll_layer = Layer::Create(); |
| 774 root_scroll_layer->SetScrollClipLayerId(root_layer->id()); | 774 root_scroll_layer->SetScrollClipLayerId(root_layer->id()); |
| 775 root_scroll_layer->SetScrollOffset(initial_scroll_); | 775 root_scroll_layer->SetScrollOffset(initial_scroll_); |
| 776 root_scroll_layer->SetBounds( | 776 root_scroll_layer->SetBounds( |
| 777 gfx::Size(root_layer->bounds().width() + 100, | 777 gfx::Size(root_layer->bounds().width() + 100, |
| 778 root_layer->bounds().height() + 100)); | 778 root_layer->bounds().height() + 100)); |
| 779 root_scroll_layer->SetIsDrawable(true); | 779 root_scroll_layer->SetIsDrawable(true); |
| 780 root_scroll_layer->SetIsContainerForFixedPositionLayers(true); | 780 root_scroll_layer->SetIsContainerForFixedPositionLayers(true); |
| 781 root_layer->AddChild(root_scroll_layer); | 781 root_layer->AddChild(root_scroll_layer); |
| 782 | 782 |
| 783 layer_tree_host()->RegisterViewportLayers( | 783 layer_tree_host()->RegisterViewportLayers( |
| 784 root_layer, root_scroll_layer, NULL); | 784 root_layer, root_scroll_layer, NULL); |
| 785 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.01f, 100.f); | 785 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.01f, 100.f); |
| 786 } | 786 } |
| 787 | 787 |
| 788 virtual void BeginTest() OVERRIDE { | 788 virtual void BeginTest() override { |
| 789 PostSetNeedsCommitToMainThread(); | 789 PostSetNeedsCommitToMainThread(); |
| 790 } | 790 } |
| 791 | 791 |
| 792 virtual void Layout() OVERRIDE { | 792 virtual void Layout() override { |
| 793 Layer* root = layer_tree_host()->root_layer(); | 793 Layer* root = layer_tree_host()->root_layer(); |
| 794 Layer* scroll_layer = root->children()[0].get(); | 794 Layer* scroll_layer = root->children()[0].get(); |
| 795 if (!layer_tree_host()->source_frame_number()) { | 795 if (!layer_tree_host()->source_frame_number()) { |
| 796 EXPECT_VECTOR_EQ(scroll_layer->scroll_offset(), initial_scroll_); | 796 EXPECT_VECTOR_EQ(scroll_layer->scroll_offset(), initial_scroll_); |
| 797 } else { | 797 } else { |
| 798 EXPECT_VECTOR_EQ( | 798 EXPECT_VECTOR_EQ( |
| 799 scroll_layer->scroll_offset(), | 799 scroll_layer->scroll_offset(), |
| 800 gfx::ScrollOffsetWithDelta(initial_scroll_, impl_thread_scroll1_)); | 800 gfx::ScrollOffsetWithDelta(initial_scroll_, impl_thread_scroll1_)); |
| 801 | 801 |
| 802 // Pretend like Javascript updated the scroll position itself with a | 802 // Pretend like Javascript updated the scroll position itself with a |
| 803 // change of main_thread_scroll. | 803 // change of main_thread_scroll. |
| 804 scroll_layer->SetScrollOffset( | 804 scroll_layer->SetScrollOffset( |
| 805 gfx::ScrollOffsetWithDelta( | 805 gfx::ScrollOffsetWithDelta( |
| 806 initial_scroll_, main_thread_scroll_ + impl_thread_scroll1_)); | 806 initial_scroll_, main_thread_scroll_ + impl_thread_scroll1_)); |
| 807 } | 807 } |
| 808 } | 808 } |
| 809 | 809 |
| 810 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 810 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { |
| 811 // We force a second draw here of the first commit before activating | 811 // We force a second draw here of the first commit before activating |
| 812 // the second commit. | 812 // the second commit. |
| 813 if (impl->active_tree()->source_frame_number() == 0) | 813 if (impl->active_tree()->source_frame_number() == 0) |
| 814 impl->SetNeedsRedraw(); | 814 impl->SetNeedsRedraw(); |
| 815 } | 815 } |
| 816 | 816 |
| 817 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 817 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) override { |
| 818 ImplSidePaintingScrollTest::DrawLayersOnThread(impl); | 818 ImplSidePaintingScrollTest::DrawLayersOnThread(impl); |
| 819 | 819 |
| 820 LayerImpl* root = impl->active_tree()->root_layer(); | 820 LayerImpl* root = impl->active_tree()->root_layer(); |
| 821 LayerImpl* scroll_layer = root->children()[0]; | 821 LayerImpl* scroll_layer = root->children()[0]; |
| 822 LayerImpl* pending_root = | 822 LayerImpl* pending_root = |
| 823 impl->active_tree()->FindPendingTreeLayerById(root->id()); | 823 impl->active_tree()->FindPendingTreeLayerById(root->id()); |
| 824 | 824 |
| 825 switch (impl->active_tree()->source_frame_number()) { | 825 switch (impl->active_tree()->source_frame_number()) { |
| 826 case 0: | 826 case 0: |
| 827 if (!impl->pending_tree()) { | 827 if (!impl->pending_tree()) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 867 initial_scroll_, main_thread_scroll_ + impl_thread_scroll1_)); | 867 initial_scroll_, main_thread_scroll_ + impl_thread_scroll1_)); |
| 868 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), impl_thread_scroll2_); | 868 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), impl_thread_scroll2_); |
| 869 EXPECT_VECTOR_EQ(scroll_layer->sent_scroll_delta(), gfx::Vector2d()); | 869 EXPECT_VECTOR_EQ(scroll_layer->sent_scroll_delta(), gfx::Vector2d()); |
| 870 EndTest(); | 870 EndTest(); |
| 871 break; | 871 break; |
| 872 } | 872 } |
| 873 } | 873 } |
| 874 | 874 |
| 875 virtual void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, | 875 virtual void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, |
| 876 float scale, | 876 float scale, |
| 877 float top_controls_delta) OVERRIDE { | 877 float top_controls_delta) override { |
| 878 num_scrolls_++; | 878 num_scrolls_++; |
| 879 } | 879 } |
| 880 | 880 |
| 881 virtual void AfterTest() OVERRIDE { EXPECT_EQ(1, num_scrolls_); } | 881 virtual void AfterTest() override { EXPECT_EQ(1, num_scrolls_); } |
| 882 | 882 |
| 883 private: | 883 private: |
| 884 gfx::ScrollOffset initial_scroll_; | 884 gfx::ScrollOffset initial_scroll_; |
| 885 gfx::Vector2dF main_thread_scroll_; | 885 gfx::Vector2dF main_thread_scroll_; |
| 886 gfx::Vector2dF impl_thread_scroll1_; | 886 gfx::Vector2dF impl_thread_scroll1_; |
| 887 gfx::Vector2dF impl_thread_scroll2_; | 887 gfx::Vector2dF impl_thread_scroll2_; |
| 888 int num_scrolls_; | 888 int num_scrolls_; |
| 889 }; | 889 }; |
| 890 | 890 |
| 891 MULTI_THREAD_TEST_F(ImplSidePaintingScrollTestSimple); | 891 MULTI_THREAD_TEST_F(ImplSidePaintingScrollTestSimple); |
| 892 | 892 |
| 893 // This test makes sure that layers pick up scrolls that occur between | 893 // This test makes sure that layers pick up scrolls that occur between |
| 894 // beginning a commit and finishing a commit (aka scroll deltas not | 894 // beginning a commit and finishing a commit (aka scroll deltas not |
| 895 // included in sent scroll delta) still apply to layers that don't | 895 // included in sent scroll delta) still apply to layers that don't |
| 896 // push properties. | 896 // push properties. |
| 897 class ImplSidePaintingScrollTestImplOnlyScroll | 897 class ImplSidePaintingScrollTestImplOnlyScroll |
| 898 : public ImplSidePaintingScrollTest { | 898 : public ImplSidePaintingScrollTest { |
| 899 public: | 899 public: |
| 900 ImplSidePaintingScrollTestImplOnlyScroll() | 900 ImplSidePaintingScrollTestImplOnlyScroll() |
| 901 : initial_scroll_(20, 10), impl_thread_scroll_(-2, 3) {} | 901 : initial_scroll_(20, 10), impl_thread_scroll_(-2, 3) {} |
| 902 | 902 |
| 903 virtual void SetupTree() OVERRIDE { | 903 virtual void SetupTree() override { |
| 904 LayerTreeHostScrollTest::SetupTree(); | 904 LayerTreeHostScrollTest::SetupTree(); |
| 905 Layer* root_layer = layer_tree_host()->root_layer(); | 905 Layer* root_layer = layer_tree_host()->root_layer(); |
| 906 scoped_refptr<Layer> root_scroll_layer = Layer::Create(); | 906 scoped_refptr<Layer> root_scroll_layer = Layer::Create(); |
| 907 root_scroll_layer->SetScrollClipLayerId(root_layer->id()); | 907 root_scroll_layer->SetScrollClipLayerId(root_layer->id()); |
| 908 root_scroll_layer->SetScrollOffset(initial_scroll_); | 908 root_scroll_layer->SetScrollOffset(initial_scroll_); |
| 909 root_scroll_layer->SetBounds( | 909 root_scroll_layer->SetBounds( |
| 910 gfx::Size(root_layer->bounds().width() + 100, | 910 gfx::Size(root_layer->bounds().width() + 100, |
| 911 root_layer->bounds().height() + 100)); | 911 root_layer->bounds().height() + 100)); |
| 912 root_scroll_layer->SetIsDrawable(true); | 912 root_scroll_layer->SetIsDrawable(true); |
| 913 root_scroll_layer->SetIsContainerForFixedPositionLayers(true); | 913 root_scroll_layer->SetIsContainerForFixedPositionLayers(true); |
| 914 root_layer->AddChild(root_scroll_layer); | 914 root_layer->AddChild(root_scroll_layer); |
| 915 | 915 |
| 916 layer_tree_host()->RegisterViewportLayers( | 916 layer_tree_host()->RegisterViewportLayers( |
| 917 root_layer, root_scroll_layer, NULL); | 917 root_layer, root_scroll_layer, NULL); |
| 918 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.01f, 100.f); | 918 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.01f, 100.f); |
| 919 } | 919 } |
| 920 | 920 |
| 921 virtual void BeginTest() OVERRIDE { | 921 virtual void BeginTest() override { |
| 922 PostSetNeedsCommitToMainThread(); | 922 PostSetNeedsCommitToMainThread(); |
| 923 } | 923 } |
| 924 | 924 |
| 925 virtual void WillCommit() OVERRIDE { | 925 virtual void WillCommit() override { |
| 926 Layer* root = layer_tree_host()->root_layer(); | 926 Layer* root = layer_tree_host()->root_layer(); |
| 927 Layer* scroll_layer = root->children()[0].get(); | 927 Layer* scroll_layer = root->children()[0].get(); |
| 928 switch (layer_tree_host()->source_frame_number()) { | 928 switch (layer_tree_host()->source_frame_number()) { |
| 929 case 0: | 929 case 0: |
| 930 EXPECT_TRUE(scroll_layer->needs_push_properties()); | 930 EXPECT_TRUE(scroll_layer->needs_push_properties()); |
| 931 break; | 931 break; |
| 932 case 1: | 932 case 1: |
| 933 // Even if this layer doesn't need push properties, it should | 933 // Even if this layer doesn't need push properties, it should |
| 934 // still pick up scrolls that happen on the active layer during | 934 // still pick up scrolls that happen on the active layer during |
| 935 // commit. | 935 // commit. |
| 936 EXPECT_FALSE(scroll_layer->needs_push_properties()); | 936 EXPECT_FALSE(scroll_layer->needs_push_properties()); |
| 937 break; | 937 break; |
| 938 } | 938 } |
| 939 } | 939 } |
| 940 | 940 |
| 941 virtual void BeginCommitOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 941 virtual void BeginCommitOnThread(LayerTreeHostImpl* impl) override { |
| 942 // Scroll after the 2nd commit has started. | 942 // Scroll after the 2nd commit has started. |
| 943 if (impl->active_tree()->source_frame_number() == 0) { | 943 if (impl->active_tree()->source_frame_number() == 0) { |
| 944 LayerImpl* active_root = impl->active_tree()->root_layer(); | 944 LayerImpl* active_root = impl->active_tree()->root_layer(); |
| 945 LayerImpl* active_scroll_layer = active_root->children()[0]; | 945 LayerImpl* active_scroll_layer = active_root->children()[0]; |
| 946 ASSERT_TRUE(active_root); | 946 ASSERT_TRUE(active_root); |
| 947 ASSERT_TRUE(active_scroll_layer); | 947 ASSERT_TRUE(active_scroll_layer); |
| 948 active_scroll_layer->ScrollBy(impl_thread_scroll_); | 948 active_scroll_layer->ScrollBy(impl_thread_scroll_); |
| 949 } | 949 } |
| 950 } | 950 } |
| 951 | 951 |
| 952 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 952 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { |
| 953 // We force a second draw here of the first commit before activating | 953 // We force a second draw here of the first commit before activating |
| 954 // the second commit. | 954 // the second commit. |
| 955 LayerImpl* active_root = impl->active_tree()->root_layer(); | 955 LayerImpl* active_root = impl->active_tree()->root_layer(); |
| 956 LayerImpl* active_scroll_layer = | 956 LayerImpl* active_scroll_layer = |
| 957 active_root ? active_root->children()[0] : NULL; | 957 active_root ? active_root->children()[0] : NULL; |
| 958 LayerImpl* pending_root = impl->pending_tree()->root_layer(); | 958 LayerImpl* pending_root = impl->pending_tree()->root_layer(); |
| 959 LayerImpl* pending_scroll_layer = pending_root->children()[0]; | 959 LayerImpl* pending_scroll_layer = pending_root->children()[0]; |
| 960 | 960 |
| 961 ASSERT_TRUE(pending_root); | 961 ASSERT_TRUE(pending_root); |
| 962 ASSERT_TRUE(pending_scroll_layer); | 962 ASSERT_TRUE(pending_scroll_layer); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 991 gfx::ScrollOffsetWithDelta(initial_scroll_, | 991 gfx::ScrollOffsetWithDelta(initial_scroll_, |
| 992 impl_thread_scroll_)); | 992 impl_thread_scroll_)); |
| 993 EXPECT_VECTOR_EQ(pending_scroll_layer->ScrollDelta(), gfx::Vector2d()); | 993 EXPECT_VECTOR_EQ(pending_scroll_layer->ScrollDelta(), gfx::Vector2d()); |
| 994 EXPECT_VECTOR_EQ(pending_scroll_layer->sent_scroll_delta(), | 994 EXPECT_VECTOR_EQ(pending_scroll_layer->sent_scroll_delta(), |
| 995 gfx::Vector2d()); | 995 gfx::Vector2d()); |
| 996 EndTest(); | 996 EndTest(); |
| 997 break; | 997 break; |
| 998 } | 998 } |
| 999 } | 999 } |
| 1000 | 1000 |
| 1001 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 1001 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) override { |
| 1002 ImplSidePaintingScrollTest::DrawLayersOnThread(impl); | 1002 ImplSidePaintingScrollTest::DrawLayersOnThread(impl); |
| 1003 | 1003 |
| 1004 LayerImpl* root = impl->active_tree()->root_layer(); | 1004 LayerImpl* root = impl->active_tree()->root_layer(); |
| 1005 LayerImpl* scroll_layer = root->children()[0]; | 1005 LayerImpl* scroll_layer = root->children()[0]; |
| 1006 | 1006 |
| 1007 switch (impl->active_tree()->source_frame_number()) { | 1007 switch (impl->active_tree()->source_frame_number()) { |
| 1008 case 0: | 1008 case 0: |
| 1009 EXPECT_VECTOR_EQ(scroll_layer->scroll_offset(), initial_scroll_); | 1009 EXPECT_VECTOR_EQ(scroll_layer->scroll_offset(), initial_scroll_); |
| 1010 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), gfx::Vector2d()); | 1010 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), gfx::Vector2d()); |
| 1011 EXPECT_VECTOR_EQ(scroll_layer->sent_scroll_delta(), gfx::Vector2d()); | 1011 EXPECT_VECTOR_EQ(scroll_layer->sent_scroll_delta(), gfx::Vector2d()); |
| 1012 PostSetNeedsCommitToMainThread(); | 1012 PostSetNeedsCommitToMainThread(); |
| 1013 break; | 1013 break; |
| 1014 case 1: | 1014 case 1: |
| 1015 EXPECT_VECTOR_EQ(scroll_layer->scroll_offset(), initial_scroll_); | 1015 EXPECT_VECTOR_EQ(scroll_layer->scroll_offset(), initial_scroll_); |
| 1016 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), impl_thread_scroll_); | 1016 EXPECT_VECTOR_EQ(scroll_layer->ScrollDelta(), impl_thread_scroll_); |
| 1017 EXPECT_VECTOR_EQ(scroll_layer->sent_scroll_delta(), gfx::Vector2d()); | 1017 EXPECT_VECTOR_EQ(scroll_layer->sent_scroll_delta(), gfx::Vector2d()); |
| 1018 PostSetNeedsCommitToMainThread(); | 1018 PostSetNeedsCommitToMainThread(); |
| 1019 break; | 1019 break; |
| 1020 } | 1020 } |
| 1021 } | 1021 } |
| 1022 | 1022 |
| 1023 virtual void AfterTest() OVERRIDE {} | 1023 virtual void AfterTest() override {} |
| 1024 | 1024 |
| 1025 private: | 1025 private: |
| 1026 gfx::ScrollOffset initial_scroll_; | 1026 gfx::ScrollOffset initial_scroll_; |
| 1027 gfx::Vector2dF impl_thread_scroll_; | 1027 gfx::Vector2dF impl_thread_scroll_; |
| 1028 }; | 1028 }; |
| 1029 | 1029 |
| 1030 MULTI_THREAD_TEST_F(ImplSidePaintingScrollTestImplOnlyScroll); | 1030 MULTI_THREAD_TEST_F(ImplSidePaintingScrollTestImplOnlyScroll); |
| 1031 | 1031 |
| 1032 class LayerTreeHostScrollTestScrollZeroMaxScrollOffset | 1032 class LayerTreeHostScrollTestScrollZeroMaxScrollOffset |
| 1033 : public LayerTreeHostScrollTest { | 1033 : public LayerTreeHostScrollTest { |
| 1034 public: | 1034 public: |
| 1035 LayerTreeHostScrollTestScrollZeroMaxScrollOffset() {} | 1035 LayerTreeHostScrollTestScrollZeroMaxScrollOffset() {} |
| 1036 | 1036 |
| 1037 virtual void SetupTree() OVERRIDE { | 1037 virtual void SetupTree() override { |
| 1038 LayerTreeTest::SetupTree(); | 1038 LayerTreeTest::SetupTree(); |
| 1039 scoped_refptr<Layer> scroll_layer = Layer::Create(); | 1039 scoped_refptr<Layer> scroll_layer = Layer::Create(); |
| 1040 layer_tree_host()->root_layer()->AddChild(scroll_layer); | 1040 layer_tree_host()->root_layer()->AddChild(scroll_layer); |
| 1041 } | 1041 } |
| 1042 | 1042 |
| 1043 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 1043 virtual void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 1044 | 1044 |
| 1045 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 1045 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) override { |
| 1046 LayerImpl* root = impl->active_tree()->root_layer(); | 1046 LayerImpl* root = impl->active_tree()->root_layer(); |
| 1047 LayerImpl* scroll_layer = root->children()[0]; | 1047 LayerImpl* scroll_layer = root->children()[0]; |
| 1048 scroll_layer->SetScrollClipLayer(root->id()); | 1048 scroll_layer->SetScrollClipLayer(root->id()); |
| 1049 | 1049 |
| 1050 // Set max_scroll_offset = (100, 100). | 1050 // Set max_scroll_offset = (100, 100). |
| 1051 scroll_layer->SetBounds( | 1051 scroll_layer->SetBounds( |
| 1052 gfx::Size(root->bounds().width() + 100, root->bounds().height() + 100)); | 1052 gfx::Size(root->bounds().width() + 100, root->bounds().height() + 100)); |
| 1053 EXPECT_EQ(InputHandler::ScrollStarted, | 1053 EXPECT_EQ(InputHandler::ScrollStarted, |
| 1054 scroll_layer->TryScroll(gfx::PointF(0.0f, 1.0f), | 1054 scroll_layer->TryScroll(gfx::PointF(0.0f, 1.0f), |
| 1055 InputHandler::Gesture)); | 1055 InputHandler::Gesture)); |
| 1056 | 1056 |
| 1057 // Set max_scroll_offset = (0, 0). | 1057 // Set max_scroll_offset = (0, 0). |
| 1058 scroll_layer->SetBounds(root->bounds()); | 1058 scroll_layer->SetBounds(root->bounds()); |
| 1059 EXPECT_EQ(InputHandler::ScrollIgnored, | 1059 EXPECT_EQ(InputHandler::ScrollIgnored, |
| 1060 scroll_layer->TryScroll(gfx::PointF(0.0f, 1.0f), | 1060 scroll_layer->TryScroll(gfx::PointF(0.0f, 1.0f), |
| 1061 InputHandler::Gesture)); | 1061 InputHandler::Gesture)); |
| 1062 | 1062 |
| 1063 // Set max_scroll_offset = (-100, -100). | 1063 // Set max_scroll_offset = (-100, -100). |
| 1064 scroll_layer->SetBounds(gfx::Size()); | 1064 scroll_layer->SetBounds(gfx::Size()); |
| 1065 EXPECT_EQ(InputHandler::ScrollIgnored, | 1065 EXPECT_EQ(InputHandler::ScrollIgnored, |
| 1066 scroll_layer->TryScroll(gfx::PointF(0.0f, 1.0f), | 1066 scroll_layer->TryScroll(gfx::PointF(0.0f, 1.0f), |
| 1067 InputHandler::Gesture)); | 1067 InputHandler::Gesture)); |
| 1068 | 1068 |
| 1069 EndTest(); | 1069 EndTest(); |
| 1070 } | 1070 } |
| 1071 | 1071 |
| 1072 virtual void AfterTest() OVERRIDE {} | 1072 virtual void AfterTest() override {} |
| 1073 }; | 1073 }; |
| 1074 | 1074 |
| 1075 SINGLE_AND_MULTI_THREAD_TEST_F( | 1075 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 1076 LayerTreeHostScrollTestScrollZeroMaxScrollOffset); | 1076 LayerTreeHostScrollTestScrollZeroMaxScrollOffset); |
| 1077 | 1077 |
| 1078 class ThreadCheckingInputHandlerClient : public InputHandlerClient { | 1078 class ThreadCheckingInputHandlerClient : public InputHandlerClient { |
| 1079 public: | 1079 public: |
| 1080 ThreadCheckingInputHandlerClient(base::SingleThreadTaskRunner* runner, | 1080 ThreadCheckingInputHandlerClient(base::SingleThreadTaskRunner* runner, |
| 1081 bool* received_stop_flinging) | 1081 bool* received_stop_flinging) |
| 1082 : task_runner_(runner), received_stop_flinging_(received_stop_flinging) {} | 1082 : task_runner_(runner), received_stop_flinging_(received_stop_flinging) {} |
| 1083 | 1083 |
| 1084 virtual void WillShutdown() OVERRIDE { | 1084 virtual void WillShutdown() override { |
| 1085 if (!received_stop_flinging_) | 1085 if (!received_stop_flinging_) |
| 1086 ADD_FAILURE() << "WillShutdown() called before fling stopped"; | 1086 ADD_FAILURE() << "WillShutdown() called before fling stopped"; |
| 1087 } | 1087 } |
| 1088 | 1088 |
| 1089 virtual void Animate(base::TimeTicks time) OVERRIDE { | 1089 virtual void Animate(base::TimeTicks time) override { |
| 1090 if (!task_runner_->BelongsToCurrentThread()) | 1090 if (!task_runner_->BelongsToCurrentThread()) |
| 1091 ADD_FAILURE() << "Animate called on wrong thread"; | 1091 ADD_FAILURE() << "Animate called on wrong thread"; |
| 1092 } | 1092 } |
| 1093 | 1093 |
| 1094 virtual void MainThreadHasStoppedFlinging() OVERRIDE { | 1094 virtual void MainThreadHasStoppedFlinging() override { |
| 1095 if (!task_runner_->BelongsToCurrentThread()) | 1095 if (!task_runner_->BelongsToCurrentThread()) |
| 1096 ADD_FAILURE() << "MainThreadHasStoppedFlinging called on wrong thread"; | 1096 ADD_FAILURE() << "MainThreadHasStoppedFlinging called on wrong thread"; |
| 1097 *received_stop_flinging_ = true; | 1097 *received_stop_flinging_ = true; |
| 1098 } | 1098 } |
| 1099 | 1099 |
| 1100 virtual void DidOverscroll( | 1100 virtual void DidOverscroll( |
| 1101 const gfx::PointF& causal_event_viewport_point, | 1101 const gfx::PointF& causal_event_viewport_point, |
| 1102 const gfx::Vector2dF& accumulated_overscroll, | 1102 const gfx::Vector2dF& accumulated_overscroll, |
| 1103 const gfx::Vector2dF& latest_overscroll_delta) OVERRIDE { | 1103 const gfx::Vector2dF& latest_overscroll_delta) override { |
| 1104 if (!task_runner_->BelongsToCurrentThread()) | 1104 if (!task_runner_->BelongsToCurrentThread()) |
| 1105 ADD_FAILURE() << "DidOverscroll called on wrong thread"; | 1105 ADD_FAILURE() << "DidOverscroll called on wrong thread"; |
| 1106 } | 1106 } |
| 1107 | 1107 |
| 1108 private: | 1108 private: |
| 1109 base::SingleThreadTaskRunner* task_runner_; | 1109 base::SingleThreadTaskRunner* task_runner_; |
| 1110 bool* received_stop_flinging_; | 1110 bool* received_stop_flinging_; |
| 1111 }; | 1111 }; |
| 1112 | 1112 |
| 1113 void BindInputHandlerOnCompositorThread( | 1113 void BindInputHandlerOnCompositorThread( |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1148 impl_thread.Stop(); | 1148 impl_thread.Stop(); |
| 1149 EXPECT_TRUE(received_stop_flinging); | 1149 EXPECT_TRUE(received_stop_flinging); |
| 1150 } | 1150 } |
| 1151 | 1151 |
| 1152 class LayerTreeHostScrollTestLayerStructureChange | 1152 class LayerTreeHostScrollTestLayerStructureChange |
| 1153 : public LayerTreeHostScrollTest { | 1153 : public LayerTreeHostScrollTest { |
| 1154 public: | 1154 public: |
| 1155 LayerTreeHostScrollTestLayerStructureChange() | 1155 LayerTreeHostScrollTestLayerStructureChange() |
| 1156 : scroll_destroy_whole_tree_(false) {} | 1156 : scroll_destroy_whole_tree_(false) {} |
| 1157 | 1157 |
| 1158 virtual void SetupTree() OVERRIDE { | 1158 virtual void SetupTree() override { |
| 1159 scoped_refptr<Layer> root_layer = Layer::Create(); | 1159 scoped_refptr<Layer> root_layer = Layer::Create(); |
| 1160 root_layer->SetBounds(gfx::Size(10, 10)); | 1160 root_layer->SetBounds(gfx::Size(10, 10)); |
| 1161 | 1161 |
| 1162 Layer* root_scroll_layer = | 1162 Layer* root_scroll_layer = |
| 1163 CreateScrollLayer(root_layer.get(), &root_scroll_layer_client_); | 1163 CreateScrollLayer(root_layer.get(), &root_scroll_layer_client_); |
| 1164 CreateScrollLayer(root_layer.get(), &sibling_scroll_layer_client_); | 1164 CreateScrollLayer(root_layer.get(), &sibling_scroll_layer_client_); |
| 1165 CreateScrollLayer(root_scroll_layer, &child_scroll_layer_client_); | 1165 CreateScrollLayer(root_scroll_layer, &child_scroll_layer_client_); |
| 1166 | 1166 |
| 1167 layer_tree_host()->SetRootLayer(root_layer); | 1167 layer_tree_host()->SetRootLayer(root_layer); |
| 1168 LayerTreeHostScrollTest::SetupTree(); | 1168 LayerTreeHostScrollTest::SetupTree(); |
| 1169 } | 1169 } |
| 1170 | 1170 |
| 1171 virtual void BeginTest() OVERRIDE { | 1171 virtual void BeginTest() override { |
| 1172 PostSetNeedsCommitToMainThread(); | 1172 PostSetNeedsCommitToMainThread(); |
| 1173 } | 1173 } |
| 1174 | 1174 |
| 1175 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 1175 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) override { |
| 1176 LayerImpl* root = impl->active_tree()->root_layer(); | 1176 LayerImpl* root = impl->active_tree()->root_layer(); |
| 1177 switch (impl->active_tree()->source_frame_number()) { | 1177 switch (impl->active_tree()->source_frame_number()) { |
| 1178 case 0: | 1178 case 0: |
| 1179 root->child_at(0)->SetScrollDelta(gfx::Vector2dF(5, 5)); | 1179 root->child_at(0)->SetScrollDelta(gfx::Vector2dF(5, 5)); |
| 1180 root->child_at(0)->child_at(0)->SetScrollDelta(gfx::Vector2dF(5, 5)); | 1180 root->child_at(0)->child_at(0)->SetScrollDelta(gfx::Vector2dF(5, 5)); |
| 1181 root->child_at(1)->SetScrollDelta(gfx::Vector2dF(5, 5)); | 1181 root->child_at(1)->SetScrollDelta(gfx::Vector2dF(5, 5)); |
| 1182 PostSetNeedsCommitToMainThread(); | 1182 PostSetNeedsCommitToMainThread(); |
| 1183 break; | 1183 break; |
| 1184 case 1: | 1184 case 1: |
| 1185 EndTest(); | 1185 EndTest(); |
| 1186 break; | 1186 break; |
| 1187 } | 1187 } |
| 1188 } | 1188 } |
| 1189 | 1189 |
| 1190 virtual void AfterTest() OVERRIDE {} | 1190 virtual void AfterTest() override {} |
| 1191 | 1191 |
| 1192 virtual void DidScroll(Layer* layer) { | 1192 virtual void DidScroll(Layer* layer) { |
| 1193 if (scroll_destroy_whole_tree_) { | 1193 if (scroll_destroy_whole_tree_) { |
| 1194 layer_tree_host()->SetRootLayer(NULL); | 1194 layer_tree_host()->SetRootLayer(NULL); |
| 1195 EndTest(); | 1195 EndTest(); |
| 1196 return; | 1196 return; |
| 1197 } | 1197 } |
| 1198 layer->RemoveFromParent(); | 1198 layer->RemoveFromParent(); |
| 1199 } | 1199 } |
| 1200 | 1200 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1238 RunTest(true, false, true); | 1238 RunTest(true, false, true); |
| 1239 } | 1239 } |
| 1240 | 1240 |
| 1241 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) { | 1241 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) { |
| 1242 scroll_destroy_whole_tree_ = true; | 1242 scroll_destroy_whole_tree_ = true; |
| 1243 RunTest(true, false, true); | 1243 RunTest(true, false, true); |
| 1244 } | 1244 } |
| 1245 | 1245 |
| 1246 } // namespace | 1246 } // namespace |
| 1247 } // namespace cc | 1247 } // namespace cc |
| OLD | NEW |