Chromium Code Reviews| 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/location.h" | 7 #include "base/location.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 2061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2072 void AfterTest() override {} | 2072 void AfterTest() override {} |
| 2073 | 2073 |
| 2074 private: | 2074 private: |
| 2075 gfx::ScrollOffset initial_scroll_; | 2075 gfx::ScrollOffset initial_scroll_; |
| 2076 gfx::ScrollOffset second_scroll_; | 2076 gfx::ScrollOffset second_scroll_; |
| 2077 gfx::Vector2dF scroll_amount_; | 2077 gfx::Vector2dF scroll_amount_; |
| 2078 }; | 2078 }; |
| 2079 | 2079 |
| 2080 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostScrollTestPropertyTreeUpdate); | 2080 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostScrollTestPropertyTreeUpdate); |
| 2081 | 2081 |
| 2082 // Disabled due to flakes/crashes, see https://crbug.com/697652. | 2082 class LayerTreeHostScrollTestImplSideInvalidation |
| 2083 class DISABLED_LayerTreeHostScrollTestImplSideInvalidation | |
| 2084 : public LayerTreeHostScrollTest { | 2083 : public LayerTreeHostScrollTest { |
| 2085 void BeginTest() override { | 2084 void BeginTest() override { |
| 2086 layer_tree_host()->outer_viewport_scroll_layer()->set_did_scroll_callback( | 2085 layer_tree_host()->outer_viewport_scroll_layer()->set_did_scroll_callback( |
| 2087 base::Bind(&DISABLED_LayerTreeHostScrollTestImplSideInvalidation:: | 2086 base::Bind(&LayerTreeHostScrollTestImplSideInvalidation:: |
| 2088 DidScrollOuterViewport, | 2087 DidScrollOuterViewport, |
| 2089 base::Unretained(this))); | 2088 base::Unretained(this))); |
| 2090 PostSetNeedsCommitToMainThread(); | 2089 PostSetNeedsCommitToMainThread(); |
| 2091 } | 2090 } |
| 2092 | 2091 |
| 2093 void DidScrollOuterViewport(const gfx::ScrollOffset& offset) { | 2092 void DidScrollOuterViewport(const gfx::ScrollOffset& offset) { |
| 2094 // Defer responding to the main frame until an impl-side pending tree is | 2093 // Defer responding to the main frame until an impl-side pending tree is |
| 2095 // created for the invalidation request. | 2094 // created for the invalidation request. |
| 2096 { | 2095 { |
| 2097 CompletionEvent completion; | 2096 CompletionEvent completion; |
| 2098 task_runner_provider()->ImplThreadTaskRunner()->PostTask( | 2097 task_runner_provider()->ImplThreadTaskRunner()->PostTask( |
| 2099 FROM_HERE, | 2098 FROM_HERE, base::Bind(&LayerTreeHostScrollTestImplSideInvalidation:: |
| 2100 base::Bind(&DISABLED_LayerTreeHostScrollTestImplSideInvalidation:: | 2099 WaitForInvalidationOnImplThread, |
| 2101 WaitForInvalidationOnImplThread, | 2100 base::Unretained(this), &completion)); |
| 2102 base::Unretained(this), &completion)); | |
| 2103 completion.Wait(); | 2101 completion.Wait(); |
| 2104 } | 2102 } |
| 2105 | 2103 |
| 2106 switch (++num_of_deltas_) { | 2104 switch (++num_of_deltas_) { |
| 2107 case 1: { | 2105 case 1: { |
| 2108 // First set of deltas is here. The impl thread will scroll to the | 2106 // First set of deltas is here. The impl thread will scroll to the |
| 2109 // second case on activation, so add a delta from the main thread that | 2107 // second case on activation, so add a delta from the main thread that |
| 2110 // takes us to the final value. | 2108 // takes us to the final value. |
| 2111 Layer* outer_viewport_layer = | 2109 Layer* outer_viewport_layer = |
| 2112 layer_tree_host()->outer_viewport_scroll_layer(); | 2110 layer_tree_host()->outer_viewport_scroll_layer(); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2164 // after this tree is activated. | 2162 // after this tree is activated. |
| 2165 host_impl->RequestImplSideInvalidation(); | 2163 host_impl->RequestImplSideInvalidation(); |
| 2166 break; | 2164 break; |
| 2167 default: | 2165 default: |
| 2168 NOTREACHED(); | 2166 NOTREACHED(); |
| 2169 } | 2167 } |
| 2170 } | 2168 } |
| 2171 | 2169 |
| 2172 void BeginMainFrameAbortedOnThread(LayerTreeHostImpl* host_impl, | 2170 void BeginMainFrameAbortedOnThread(LayerTreeHostImpl* host_impl, |
| 2173 CommitEarlyOutReason reason) override { | 2171 CommitEarlyOutReason reason) override { |
| 2174 // The aborted main frame is bound to come after the fourth activation, | |
| 2175 // since the activation should occur synchronously after the impl-side | |
| 2176 // invalidation, and the main thread is released after this activation. It | |
| 2177 // should leave the scroll offset unchanged. | |
| 2178 EXPECT_EQ(reason, CommitEarlyOutReason::FINISHED_NO_UPDATES); | 2172 EXPECT_EQ(reason, CommitEarlyOutReason::FINISHED_NO_UPDATES); |
|
danakj
2017/03/06 16:41:44
btw these EXPECT_EQ are all backward, it should be
Khushal
2017/03/06 21:46:25
Done.
| |
| 2179 EXPECT_EQ(num_of_activations_, 4); | |
| 2180 EXPECT_EQ(num_of_main_frames_, 3); | 2173 EXPECT_EQ(num_of_main_frames_, 3); |
| 2181 EXPECT_EQ(host_impl->active_tree() | 2174 EXPECT_EQ(host_impl->active_tree() |
| 2182 ->OuterViewportScrollLayer() | 2175 ->OuterViewportScrollLayer() |
| 2183 ->CurrentScrollOffset(), | 2176 ->CurrentScrollOffset(), |
| 2184 outer_viewport_offsets_[2]); | 2177 outer_viewport_offsets_[2]); |
| 2185 EndTest(); | |
| 2186 } | 2178 } |
| 2187 | 2179 |
| 2188 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { | 2180 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { |
| 2189 switch (++num_of_activations_) { | 2181 switch (++num_of_activations_) { |
| 2190 case 1: | 2182 case 1: |
| 2191 // Now that we have the active tree, scroll a layer and ask for a commit | 2183 // Now that we have the active tree, scroll a layer and ask for a commit |
| 2192 // to send a BeginMainFrame with the scroll delta to the main thread. | 2184 // to send a BeginMainFrame with the scroll delta to the main thread. |
| 2193 host_impl->active_tree() | 2185 host_impl->active_tree() |
| 2194 ->OuterViewportScrollLayer() | 2186 ->OuterViewportScrollLayer() |
| 2195 ->SetCurrentScrollOffset(outer_viewport_offsets_[0]); | 2187 ->SetCurrentScrollOffset(outer_viewport_offsets_[0]); |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 2221 EXPECT_EQ(host_impl->active_tree() | 2213 EXPECT_EQ(host_impl->active_tree() |
| 2222 ->OuterViewportScrollLayer() | 2214 ->OuterViewportScrollLayer() |
| 2223 ->CurrentScrollOffset(), | 2215 ->CurrentScrollOffset(), |
| 2224 outer_viewport_offsets_[2]); | 2216 outer_viewport_offsets_[2]); |
| 2225 break; | 2217 break; |
| 2226 default: | 2218 default: |
| 2227 NOTREACHED(); | 2219 NOTREACHED(); |
| 2228 } | 2220 } |
| 2229 } | 2221 } |
| 2230 | 2222 |
| 2223 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { | |
| 2224 if (++num_of_draws_ == 4) | |
| 2225 EndTest(); | |
| 2226 } | |
| 2227 | |
| 2231 void AfterTest() override { | 2228 void AfterTest() override { |
| 2232 EXPECT_EQ(num_of_activations_, 4); | 2229 EXPECT_EQ(num_of_activations_, 4); |
| 2233 EXPECT_EQ(num_of_deltas_, 2); | 2230 EXPECT_EQ(num_of_deltas_, 2); |
| 2234 EXPECT_EQ(num_of_main_frames_, 3); | 2231 EXPECT_EQ(num_of_main_frames_, 3); |
| 2235 } | 2232 } |
| 2236 | 2233 |
| 2237 const gfx::ScrollOffset outer_viewport_offsets_[3] = { | 2234 const gfx::ScrollOffset outer_viewport_offsets_[3] = { |
| 2238 gfx::ScrollOffset(20, 20), gfx::ScrollOffset(50, 50), | 2235 gfx::ScrollOffset(20, 20), gfx::ScrollOffset(50, 50), |
| 2239 gfx::ScrollOffset(70, 70)}; | 2236 gfx::ScrollOffset(70, 70)}; |
| 2240 | 2237 |
| 2241 // Impl thread. | 2238 // Impl thread. |
| 2242 int num_of_activations_ = 0; | 2239 int num_of_activations_ = 0; |
| 2240 int num_of_draws_ = 0; | |
| 2243 int num_of_main_frames_ = 0; | 2241 int num_of_main_frames_ = 0; |
| 2244 bool invalidated_on_impl_thread_ = false; | 2242 bool invalidated_on_impl_thread_ = false; |
| 2245 CompletionEvent* impl_side_invalidation_event_ = nullptr; | 2243 CompletionEvent* impl_side_invalidation_event_ = nullptr; |
| 2246 | 2244 |
| 2247 // Main thread. | 2245 // Main thread. |
| 2248 int num_of_deltas_ = 0; | 2246 int num_of_deltas_ = 0; |
| 2249 }; | 2247 }; |
| 2250 | 2248 |
| 2251 MULTI_THREAD_TEST_F(DISABLED_LayerTreeHostScrollTestImplSideInvalidation); | 2249 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestImplSideInvalidation); |
| 2252 | 2250 |
| 2253 } // namespace | 2251 } // namespace |
| 2254 } // namespace cc | 2252 } // namespace cc |
| OLD | NEW |