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 2997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3008 | 3008 |
3009 virtual void BeginTest() OVERRIDE { | 3009 virtual void BeginTest() OVERRIDE { |
3010 did_initialize_gl_ = false; | 3010 did_initialize_gl_ = false; |
3011 did_release_gl_ = false; | 3011 did_release_gl_ = false; |
3012 last_source_frame_number_drawn_ = -1; // Never drawn. | 3012 last_source_frame_number_drawn_ = -1; // Never drawn. |
3013 PostSetNeedsCommitToMainThread(); | 3013 PostSetNeedsCommitToMainThread(); |
3014 } | 3014 } |
3015 | 3015 |
3016 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback) | 3016 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback) |
3017 OVERRIDE { | 3017 OVERRIDE { |
3018 scoped_ptr<TestWebGraphicsContext3D> context3d( | |
3019 TestWebGraphicsContext3D::Create()); | |
3020 | |
3021 return FakeOutputSurface::CreateDeferredGL( | 3018 return FakeOutputSurface::CreateDeferredGL( |
3022 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice)); | 3019 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice)); |
3023 } | 3020 } |
3024 | 3021 |
3025 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 3022 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
3026 ASSERT_TRUE(host_impl->RootLayer()); | 3023 ASSERT_TRUE(host_impl->RootLayer()); |
3027 FakePictureLayerImpl* layer_impl = | 3024 FakePictureLayerImpl* layer_impl = |
3028 static_cast<FakePictureLayerImpl*>(host_impl->RootLayer()); | 3025 static_cast<FakePictureLayerImpl*>(host_impl->RootLayer()); |
3029 | 3026 |
3030 // The same frame can be draw multiple times if new visible tiles are | 3027 // The same frame can be draw multiple times if new visible tiles are |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3086 private: | 3083 private: |
3087 FakeContentLayerClient client_; | 3084 FakeContentLayerClient client_; |
3088 scoped_refptr<FakePictureLayer> layer_; | 3085 scoped_refptr<FakePictureLayer> layer_; |
3089 bool did_initialize_gl_; | 3086 bool did_initialize_gl_; |
3090 bool did_release_gl_; | 3087 bool did_release_gl_; |
3091 int last_source_frame_number_drawn_; | 3088 int last_source_frame_number_drawn_; |
3092 }; | 3089 }; |
3093 | 3090 |
3094 MULTI_THREAD_TEST_F(LayerTreeHostTestDeferredInitialize); | 3091 MULTI_THREAD_TEST_F(LayerTreeHostTestDeferredInitialize); |
3095 | 3092 |
| 3093 class LayerTreeHostTestAbortFrameOnStaleRendererCapabilities |
| 3094 : public LayerTreeHostTest { |
| 3095 public: |
| 3096 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
| 3097 settings->impl_side_painting = true; |
| 3098 } |
| 3099 |
| 3100 virtual void SetupTree() OVERRIDE { |
| 3101 layer_ = FakePictureLayer::Create(&client_); |
| 3102 // Make sure commits are not aborted due to no update. |
| 3103 layer_->set_always_update_resources(true); |
| 3104 layer_tree_host()->SetRootLayer(layer_); |
| 3105 LayerTreeHostTest::SetupTree(); |
| 3106 } |
| 3107 |
| 3108 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback) |
| 3109 OVERRIDE { |
| 3110 return FakeOutputSurface::CreateDeferredGL( |
| 3111 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice)); |
| 3112 } |
| 3113 |
| 3114 virtual void BeginTest() OVERRIDE { |
| 3115 aborted_frames_ = 0; |
| 3116 main_frame_attempts_ = 0; |
| 3117 PostSetNeedsCommitToMainThread(); |
| 3118 } |
| 3119 |
| 3120 virtual void WillBeginMainFrame() OVERRIDE { |
| 3121 int frame_number = layer_tree_host()->source_frame_number(); |
| 3122 EXPECT_EQ(0, frame_number); // Only one frame. |
| 3123 main_frame_attempts_++; |
| 3124 // Main frame should only be aborted once. |
| 3125 EXPECT_LE(main_frame_attempts_, 2); |
| 3126 |
| 3127 if (main_frame_attempts_ == 1) { |
| 3128 // Capabilities updated once on first renderer init. |
| 3129 EXPECT_EQ(1u, layer_->renderer_capabilities_changed_count()); |
| 3130 layer_->reset_renderer_capabilities_changed_count(); |
| 3131 |
| 3132 // Make sure first main frame attempt gets aborted due to stale renderer |
| 3133 // capabilities by synchronously updating renderer capabilities on impl |
| 3134 // thread. |
| 3135 CompletionEvent completion; |
| 3136 ImplThreadTaskRunner()->PostTask( |
| 3137 FROM_HERE, |
| 3138 base::Bind(&LayerTreeHostTestAbortFrameOnStaleRendererCapabilities:: |
| 3139 UpdateRendererCapabilities, |
| 3140 base::Unretained(this), |
| 3141 &completion)); |
| 3142 completion.Wait(); |
| 3143 } else { |
| 3144 // Capabilities updated again before second attempt of first frame. |
| 3145 EXPECT_EQ(1u, layer_->renderer_capabilities_changed_count()); |
| 3146 layer_->reset_renderer_capabilities_changed_count(); |
| 3147 } |
| 3148 } |
| 3149 |
| 3150 void UpdateRendererCapabilities(CompletionEvent* completion) { |
| 3151 // Change renderer capabilities by switching renderers. |
| 3152 scoped_refptr<TestContextProvider> context_provider = |
| 3153 TestContextProvider::Create(); |
| 3154 EXPECT_TRUE( |
| 3155 output_surface()->InitializeAndSetContext3d(context_provider, NULL)); |
| 3156 completion->Signal(); |
| 3157 } |
| 3158 |
| 3159 virtual void BeginMainFrameAbortedOnThread(LayerTreeHostImpl* host_impl, |
| 3160 bool did_handle) OVERRIDE { |
| 3161 EXPECT_TRUE(did_handle); |
| 3162 aborted_frames_ += 1; |
| 3163 } |
| 3164 |
| 3165 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 3166 EndTest(); |
| 3167 } |
| 3168 |
| 3169 virtual void AfterTest() OVERRIDE { |
| 3170 // First main frame should have been attempted twice. |
| 3171 EXPECT_EQ(2, main_frame_attempts_); |
| 3172 // First attempt should have been aborted. |
| 3173 EXPECT_EQ(1, aborted_frames_); |
| 3174 } |
| 3175 |
| 3176 private: |
| 3177 FakeContentLayerClient client_; |
| 3178 scoped_refptr<FakePictureLayer> layer_; |
| 3179 int main_frame_attempts_; |
| 3180 int aborted_frames_; |
| 3181 }; |
| 3182 |
| 3183 MULTI_THREAD_TEST_F(LayerTreeHostTestAbortFrameOnStaleRendererCapabilities); |
| 3184 |
3096 // Test for UI Resource management. | 3185 // Test for UI Resource management. |
3097 class LayerTreeHostTestUIResource : public LayerTreeHostTest { | 3186 class LayerTreeHostTestUIResource : public LayerTreeHostTest { |
3098 public: | 3187 public: |
3099 LayerTreeHostTestUIResource() : num_ui_resources_(0) {} | 3188 LayerTreeHostTestUIResource() : num_ui_resources_(0) {} |
3100 | 3189 |
3101 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | 3190 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
3102 settings->texture_id_allocation_chunk_size = 1; | 3191 settings->texture_id_allocation_chunk_size = 1; |
3103 } | 3192 } |
3104 | 3193 |
3105 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 3194 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
(...skipping 1858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4964 | 5053 |
4965 EndTest(); | 5054 EndTest(); |
4966 } | 5055 } |
4967 | 5056 |
4968 virtual void AfterTest() OVERRIDE {} | 5057 virtual void AfterTest() OVERRIDE {} |
4969 }; | 5058 }; |
4970 | 5059 |
4971 MULTI_THREAD_TEST_F(LayerTreeHostTestSimpleSwapPromiseMonitor); | 5060 MULTI_THREAD_TEST_F(LayerTreeHostTestSimpleSwapPromiseMonitor); |
4972 | 5061 |
4973 } // namespace cc | 5062 } // namespace cc |
OLD | NEW |