| 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/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 6993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7004 LayerTreeHostImplCountingLostSurfaces() : num_lost_surfaces_(0) {} | 7004 LayerTreeHostImplCountingLostSurfaces() : num_lost_surfaces_(0) {} |
| 7005 virtual void DidLoseOutputSurfaceOnImplThread() OVERRIDE { | 7005 virtual void DidLoseOutputSurfaceOnImplThread() OVERRIDE { |
| 7006 num_lost_surfaces_++; | 7006 num_lost_surfaces_++; |
| 7007 } | 7007 } |
| 7008 | 7008 |
| 7009 protected: | 7009 protected: |
| 7010 int num_lost_surfaces_; | 7010 int num_lost_surfaces_; |
| 7011 }; | 7011 }; |
| 7012 | 7012 |
| 7013 TEST_F(LayerTreeHostImplCountingLostSurfaces, TwiceLostSurface) { | 7013 TEST_F(LayerTreeHostImplCountingLostSurfaces, TwiceLostSurface) { |
| 7014 // The medium term, we plan to remove LayerTreeHostImpl::IsContextLost(). | |
| 7015 // Until then, we need the state variable | |
| 7016 // LayerTreeHostImpl::have_valid_output_surface_ and we can | |
| 7017 // enforce the following behaviour, where calling DidLoseOutputSurface | |
| 7018 // twice in a row only causes one subsequent | |
| 7019 // call to LayerTreeHostImplClient::DidLoseOutputSurfaceOnImplThread(). | |
| 7020 // Really we just need at least one client notification each time | 7014 // Really we just need at least one client notification each time |
| 7021 // we go from having a valid output surface to not having a valid output | 7015 // we go from having a valid output surface to not having a valid output |
| 7022 // surface. | 7016 // surface. |
| 7023 EXPECT_EQ(0, num_lost_surfaces_); | 7017 EXPECT_EQ(0, num_lost_surfaces_); |
| 7024 EXPECT_FALSE(host_impl_->IsContextLost()); | |
| 7025 host_impl_->DidLoseOutputSurface(); | 7018 host_impl_->DidLoseOutputSurface(); |
| 7026 EXPECT_TRUE(host_impl_->IsContextLost()); | |
| 7027 EXPECT_EQ(1, num_lost_surfaces_); | 7019 EXPECT_EQ(1, num_lost_surfaces_); |
| 7028 host_impl_->DidLoseOutputSurface(); | 7020 host_impl_->DidLoseOutputSurface(); |
| 7029 EXPECT_TRUE(host_impl_->IsContextLost()); | 7021 EXPECT_LE(1, num_lost_surfaces_); |
| 7030 EXPECT_EQ(1, num_lost_surfaces_); | |
| 7031 } | 7022 } |
| 7032 | 7023 |
| 7033 } // namespace | 7024 } // namespace |
| 7034 } // namespace cc | 7025 } // namespace cc |
| OLD | NEW |