| 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/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "cc/layers/content_layer.h" | 8 #include "cc/layers/content_layer.h" |
| 9 #include "cc/layers/heads_up_display_layer.h" | 9 #include "cc/layers/heads_up_display_layer.h" |
| 10 #include "cc/layers/io_surface_layer.h" | 10 #include "cc/layers/io_surface_layer.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 base::Bind(&LayerTreeHostContextTest::CreateOffscreenContext3d, | 148 base::Bind(&LayerTreeHostContextTest::CreateOffscreenContext3d, |
| 149 base::Unretained(this))); | 149 base::Unretained(this))); |
| 150 } | 150 } |
| 151 return offscreen_contexts_compositor_thread_; | 151 return offscreen_contexts_compositor_thread_; |
| 152 } | 152 } |
| 153 | 153 |
| 154 virtual bool PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | 154 virtual bool PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
| 155 LayerTreeHostImpl::FrameData* frame, | 155 LayerTreeHostImpl::FrameData* frame, |
| 156 bool result) | 156 bool result) |
| 157 OVERRIDE { | 157 OVERRIDE { |
| 158 EXPECT_TRUE(result); | 158 bool expect_success = !frame->has_no_damage; |
| 159 EXPECT_EQ(expect_success, result); |
| 159 if (!times_to_lose_during_draw_) | 160 if (!times_to_lose_during_draw_) |
| 160 return result; | 161 return result; |
| 161 | 162 |
| 162 --times_to_lose_during_draw_; | 163 --times_to_lose_during_draw_; |
| 163 context3d_->set_times_make_current_succeeds(0); | 164 context3d_->set_times_make_current_succeeds(0); |
| 164 | 165 |
| 165 times_to_fail_create_ = times_to_fail_recreate_; | 166 times_to_fail_create_ = times_to_fail_recreate_; |
| 166 times_to_fail_recreate_ = 0; | 167 times_to_fail_recreate_ = 0; |
| 167 times_to_fail_initialize_ = times_to_fail_reinitialize_; | 168 times_to_fail_initialize_ = times_to_fail_reinitialize_; |
| 168 times_to_fail_reinitialize_ = 0; | 169 times_to_fail_reinitialize_ = 0; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 return; | 263 return; |
| 263 | 264 |
| 264 recovered_context_ = false; | 265 recovered_context_ = false; |
| 265 if (NextTestCase()) | 266 if (NextTestCase()) |
| 266 InvalidateAndSetNeedsCommit(); | 267 InvalidateAndSetNeedsCommit(); |
| 267 else | 268 else |
| 268 EndTest(); | 269 EndTest(); |
| 269 } | 270 } |
| 270 | 271 |
| 271 virtual void InvalidateAndSetNeedsCommit() { | 272 virtual void InvalidateAndSetNeedsCommit() { |
| 272 layer_tree_host()->SetNeedsCommit(); | 273 // Cause damage so we try to draw. |
| 274 layer_tree_host()->root_layer()->SetNeedsDisplay(); |
| 273 } | 275 } |
| 274 | 276 |
| 275 bool NextTestCase() { | 277 bool NextTestCase() { |
| 276 static const TestCase kTests[] = { | 278 static const TestCase kTests[] = { |
| 277 // Losing the context and failing to recreate it (or losing it again | 279 // Losing the context and failing to recreate it (or losing it again |
| 278 // immediately) a small number of times should succeed. | 280 // immediately) a small number of times should succeed. |
| 279 { 1, // times_to_lose_during_commit | 281 { 1, // times_to_lose_during_commit |
| 280 0, // times_to_lose_during_draw | 282 0, // times_to_lose_during_draw |
| 281 3, // times_to_fail_reinitialize | 283 3, // times_to_fail_reinitialize |
| 282 0, // times_to_fail_recreate | 284 0, // times_to_fail_recreate |
| (...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1043 | 1045 |
| 1044 if (host_impl->active_tree()->source_frame_number() == 3) { | 1046 if (host_impl->active_tree()->source_frame_number() == 3) { |
| 1045 // On the third commit we're recovering from context loss. Hardware | 1047 // On the third commit we're recovering from context loss. Hardware |
| 1046 // video frames should not be reused by the VideoFrameProvider, but | 1048 // video frames should not be reused by the VideoFrameProvider, but |
| 1047 // software frames can be. | 1049 // software frames can be. |
| 1048 hw_frame_provider_.set_frame(NULL); | 1050 hw_frame_provider_.set_frame(NULL); |
| 1049 scaled_hw_frame_provider_.set_frame(NULL); | 1051 scaled_hw_frame_provider_.set_frame(NULL); |
| 1050 } | 1052 } |
| 1051 } | 1053 } |
| 1052 | 1054 |
| 1053 virtual bool PrepareToDrawOnThread( | 1055 virtual bool PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
| 1054 LayerTreeHostImpl* host_impl, | 1056 LayerTreeHostImpl::FrameData* frame, |
| 1055 LayerTreeHostImpl::FrameData* frame, | 1057 bool result) OVERRIDE { |
| 1056 bool result) OVERRIDE { | |
| 1057 if (host_impl->active_tree()->source_frame_number() == 2) { | 1058 if (host_impl->active_tree()->source_frame_number() == 2) { |
| 1058 // Lose the context during draw on the second commit. This will cause | 1059 // Lose the context during draw on the second commit. This will cause |
| 1059 // a third commit to recover. | 1060 // a third commit to recover. |
| 1060 if (context3d_) | 1061 if (context3d_) |
| 1061 context3d_->set_times_bind_texture_succeeds(4); | 1062 context3d_->set_times_bind_texture_succeeds(4); |
| 1062 } | 1063 } |
| 1063 return true; | 1064 return true; |
| 1064 } | 1065 } |
| 1065 | 1066 |
| 1066 virtual void DidCommitAndDrawFrame() OVERRIDE { | 1067 virtual void DidCommitAndDrawFrame() OVERRIDE { |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1220 | 1221 |
| 1221 private: | 1222 private: |
| 1222 int commits_; | 1223 int commits_; |
| 1223 scoped_refptr<FakeScrollbarLayer> scrollbar_layer_; | 1224 scoped_refptr<FakeScrollbarLayer> scrollbar_layer_; |
| 1224 }; | 1225 }; |
| 1225 | 1226 |
| 1226 SINGLE_AND_MULTI_THREAD_TEST_F(ScrollbarLayerLostContext); | 1227 SINGLE_AND_MULTI_THREAD_TEST_F(ScrollbarLayerLostContext); |
| 1227 | 1228 |
| 1228 } // namespace | 1229 } // namespace |
| 1229 } // namespace cc | 1230 } // namespace cc |
| OLD | NEW |