| 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.h" | 5 #include "cc/trees/layer_tree_host.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
| (...skipping 2981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2992 | 2992 |
| 2993 class LayerTreeHostTestDeferredInitialize : public LayerTreeHostTest { | 2993 class LayerTreeHostTestDeferredInitialize : public LayerTreeHostTest { |
| 2994 public: | 2994 public: |
| 2995 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | 2995 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
| 2996 // PictureLayer can only be used with impl side painting enabled. | 2996 // PictureLayer can only be used with impl side painting enabled. |
| 2997 settings->impl_side_painting = true; | 2997 settings->impl_side_painting = true; |
| 2998 } | 2998 } |
| 2999 | 2999 |
| 3000 virtual void SetupTree() OVERRIDE { | 3000 virtual void SetupTree() OVERRIDE { |
| 3001 layer_ = FakePictureLayer::Create(&client_); | 3001 layer_ = FakePictureLayer::Create(&client_); |
| 3002 layer_->reset_renderer_capabilities_changed_count(); |
| 3002 // Force commits to not be aborted so new frames get drawn, otherwise | 3003 // Force commits to not be aborted so new frames get drawn, otherwise |
| 3003 // the renderer gets deferred initialized but nothing new needs drawing. | 3004 // the renderer gets deferred initialized but nothing new needs drawing. |
| 3004 layer_->set_always_update_resources(true); | 3005 layer_->set_always_update_resources(true); |
| 3005 layer_tree_host()->SetRootLayer(layer_); | 3006 layer_tree_host()->SetRootLayer(layer_); |
| 3006 LayerTreeHostTest::SetupTree(); | 3007 LayerTreeHostTest::SetupTree(); |
| 3007 } | 3008 } |
| 3008 | 3009 |
| 3009 virtual void BeginTest() OVERRIDE { | 3010 virtual void BeginTest() OVERRIDE { |
| 3010 did_initialize_gl_ = false; | 3011 did_initialize_gl_ = false; |
| 3011 did_release_gl_ = false; | 3012 did_release_gl_ = false; |
| 3012 last_source_frame_number_drawn_ = -1; // Never drawn. | 3013 last_source_frame_number_drawn_ = -1; // Never drawn. |
| 3013 PostSetNeedsCommitToMainThread(); | 3014 PostSetNeedsCommitToMainThread(); |
| 3014 } | 3015 } |
| 3015 | 3016 |
| 3016 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback) | 3017 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback) |
| 3017 OVERRIDE { | 3018 OVERRIDE { |
| 3018 scoped_ptr<TestWebGraphicsContext3D> context3d( | |
| 3019 TestWebGraphicsContext3D::Create()); | |
| 3020 | |
| 3021 return FakeOutputSurface::CreateDeferredGL( | 3019 return FakeOutputSurface::CreateDeferredGL( |
| 3022 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice)); | 3020 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice)); |
| 3023 } | 3021 } |
| 3024 | 3022 |
| 3025 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 3023 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 3026 ASSERT_TRUE(host_impl->RootLayer()); | 3024 ASSERT_TRUE(host_impl->RootLayer()); |
| 3027 FakePictureLayerImpl* layer_impl = | 3025 FakePictureLayerImpl* layer_impl = |
| 3028 static_cast<FakePictureLayerImpl*>(host_impl->RootLayer()); | 3026 static_cast<FakePictureLayerImpl*>(host_impl->RootLayer()); |
| 3029 | 3027 |
| 3030 // The same frame can be draw multiple times if new visible tiles are | 3028 // The same frame can be draw multiple times if new visible tiles are |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3074 EXPECT_TRUE(did_initialize_gl_); | 3072 EXPECT_TRUE(did_initialize_gl_); |
| 3075 EXPECT_FALSE(did_release_gl_); | 3073 EXPECT_FALSE(did_release_gl_); |
| 3076 // ReleaseGL calls SetNeedsCommit. | 3074 // ReleaseGL calls SetNeedsCommit. |
| 3077 static_cast<FakeOutputSurface*>(host_impl->output_surface())->ReleaseGL(); | 3075 static_cast<FakeOutputSurface*>(host_impl->output_surface())->ReleaseGL(); |
| 3078 did_release_gl_ = true; | 3076 did_release_gl_ = true; |
| 3079 } | 3077 } |
| 3080 | 3078 |
| 3081 virtual void AfterTest() OVERRIDE { | 3079 virtual void AfterTest() OVERRIDE { |
| 3082 EXPECT_TRUE(did_initialize_gl_); | 3080 EXPECT_TRUE(did_initialize_gl_); |
| 3083 EXPECT_TRUE(did_release_gl_); | 3081 EXPECT_TRUE(did_release_gl_); |
| 3082 // Renderer capabilities changed one for first initialization, |
| 3083 // once for DeferredInitialize, and once for ReleaseGL. |
| 3084 EXPECT_EQ(3u, layer_->renderer_capabilities_changed_count()); |
| 3084 } | 3085 } |
| 3085 | 3086 |
| 3086 private: | 3087 private: |
| 3087 FakeContentLayerClient client_; | 3088 FakeContentLayerClient client_; |
| 3088 scoped_refptr<FakePictureLayer> layer_; | 3089 scoped_refptr<FakePictureLayer> layer_; |
| 3089 bool did_initialize_gl_; | 3090 bool did_initialize_gl_; |
| 3090 bool did_release_gl_; | 3091 bool did_release_gl_; |
| 3091 int last_source_frame_number_drawn_; | 3092 int last_source_frame_number_drawn_; |
| 3092 }; | 3093 }; |
| 3093 | 3094 |
| (...skipping 1870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4964 | 4965 |
| 4965 EndTest(); | 4966 EndTest(); |
| 4966 } | 4967 } |
| 4967 | 4968 |
| 4968 virtual void AfterTest() OVERRIDE {} | 4969 virtual void AfterTest() OVERRIDE {} |
| 4969 }; | 4970 }; |
| 4970 | 4971 |
| 4971 MULTI_THREAD_TEST_F(LayerTreeHostTestSimpleSwapPromiseMonitor); | 4972 MULTI_THREAD_TEST_F(LayerTreeHostTestSimpleSwapPromiseMonitor); |
| 4972 | 4973 |
| 4973 } // namespace cc | 4974 } // namespace cc |
| OLD | NEW |