Chromium Code Reviews| 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 3075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3086 private: | 3086 private: |
| 3087 FakeContentLayerClient client_; | 3087 FakeContentLayerClient client_; |
| 3088 scoped_refptr<FakePictureLayer> layer_; | 3088 scoped_refptr<FakePictureLayer> layer_; |
| 3089 bool did_initialize_gl_; | 3089 bool did_initialize_gl_; |
| 3090 bool did_release_gl_; | 3090 bool did_release_gl_; |
| 3091 int last_source_frame_number_drawn_; | 3091 int last_source_frame_number_drawn_; |
| 3092 }; | 3092 }; |
| 3093 | 3093 |
| 3094 MULTI_THREAD_TEST_F(LayerTreeHostTestDeferredInitialize); | 3094 MULTI_THREAD_TEST_F(LayerTreeHostTestDeferredInitialize); |
| 3095 | 3095 |
| 3096 class LayerTreeHostTestAbortFrameOnStaleRendererCapabilities | |
| 3097 : public LayerTreeHostTest { | |
| 3098 public: | |
| 3099 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | |
| 3100 settings->impl_side_painting = true; | |
| 3101 } | |
| 3102 | |
| 3103 virtual void SetupTree() OVERRIDE { | |
| 3104 layer_ = FakePictureLayer::Create(&client_); | |
| 3105 // Make sure commits are not aborted due to no update. | |
| 3106 layer_->set_always_update_resources(true); | |
| 3107 layer_tree_host()->SetRootLayer(layer_); | |
| 3108 LayerTreeHostTest::SetupTree(); | |
| 3109 } | |
| 3110 | |
| 3111 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback) | |
| 3112 OVERRIDE { | |
| 3113 scoped_ptr<TestWebGraphicsContext3D> context3d( | |
|
danakj
2014/02/11 19:58:59
unused?
boliu
2014/02/11 21:44:07
Done.
| |
| 3114 TestWebGraphicsContext3D::Create()); | |
| 3115 | |
| 3116 return FakeOutputSurface::CreateDeferredGL( | |
| 3117 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice)); | |
| 3118 } | |
| 3119 | |
| 3120 virtual void BeginTest() OVERRIDE { | |
| 3121 aborted_frame_ = true; | |
| 3122 main_frame_attempts_ = 0; | |
| 3123 PostSetNeedsCommitToMainThread(); | |
| 3124 } | |
| 3125 | |
| 3126 virtual void WillBeginMainFrame() OVERRIDE { | |
| 3127 int frame_number = layer_tree_host()->source_frame_number(); | |
| 3128 EXPECT_EQ(0, frame_number); // Only one frame. | |
| 3129 main_frame_attempts_++; | |
| 3130 // Main frame should only be aborted once. | |
| 3131 EXPECT_LE(main_frame_attempts_, 2); | |
| 3132 | |
| 3133 if (main_frame_attempts_ == 1) { | |
| 3134 // Capabilities updated once on first renderer init. | |
| 3135 EXPECT_EQ(static_cast<size_t>(1), | |
|
danakj
2014/02/11 19:58:59
"1u" instead of static_cast<size_t>(1)
boliu
2014/02/11 21:44:07
Done.
| |
| 3136 layer_->renderer_capabilities_changed_count()); | |
| 3137 layer_->reset_renderer_capabilities_changed_count(); | |
| 3138 | |
| 3139 // Make sure first main frame attemp gets aborted due to stale renderer | |
|
danakj
2014/02/11 19:58:59
attempt
boliu
2014/02/11 21:44:07
Done.
| |
| 3140 // capabilities by synchronously updating renderer capabilities on impl | |
| 3141 // thread. | |
| 3142 CompletionEvent completion; | |
| 3143 ImplThreadTaskRunner()->PostTask( | |
| 3144 FROM_HERE, | |
| 3145 base::Bind(&LayerTreeHostTestAbortFrameOnStaleRendererCapabilities:: | |
| 3146 UpdateRendererCapabilities, | |
| 3147 base::Unretained(this), | |
| 3148 &completion)); | |
| 3149 completion.Wait(); | |
| 3150 } else { | |
| 3151 // Capabilities updated again before second attempt of first frame. | |
| 3152 EXPECT_EQ(static_cast<size_t>(1), | |
|
danakj
2014/02/11 19:58:59
1u
boliu
2014/02/11 21:44:07
Done.
| |
| 3153 layer_->renderer_capabilities_changed_count()); | |
| 3154 layer_->reset_renderer_capabilities_changed_count(); | |
| 3155 } | |
| 3156 } | |
| 3157 | |
| 3158 void UpdateRendererCapabilities(CompletionEvent* completion) { | |
| 3159 // Change renderer capabilities by switching renderers. | |
| 3160 scoped_refptr<TestContextProvider> context_provider = | |
| 3161 TestContextProvider::Create(); | |
| 3162 EXPECT_TRUE( | |
| 3163 output_surface()->InitializeAndSetContext3d(context_provider, NULL)); | |
| 3164 completion->Signal(); | |
| 3165 } | |
| 3166 | |
| 3167 virtual void BeginMainFrameAbortedOnThread(LayerTreeHostImpl* host_impl, | |
| 3168 bool did_handle) OVERRIDE { | |
| 3169 EXPECT_TRUE(did_handle); | |
| 3170 aborted_frame_ = true; | |
|
danakj
2014/02/11 19:58:59
use an int instead so you can test the number of t
boliu
2014/02/11 21:44:07
Done.
| |
| 3171 } | |
| 3172 | |
| 3173 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | |
| 3174 EndTest(); | |
| 3175 } | |
| 3176 | |
| 3177 virtual void AfterTest() OVERRIDE { | |
| 3178 // First main frame should have been attempted twice. | |
| 3179 EXPECT_EQ(2, main_frame_attempts_); | |
| 3180 // First attempted should have been aborted. | |
|
danakj
2014/02/11 19:58:59
attempt
boliu
2014/02/11 21:44:07
Done.
| |
| 3181 EXPECT_TRUE(aborted_frame_); | |
| 3182 } | |
| 3183 | |
| 3184 private: | |
| 3185 FakeContentLayerClient client_; | |
| 3186 scoped_refptr<FakePictureLayer> layer_; | |
| 3187 int main_frame_attempts_; | |
| 3188 bool aborted_frame_; | |
| 3189 }; | |
| 3190 | |
| 3191 MULTI_THREAD_TEST_F(LayerTreeHostTestAbortFrameOnStaleRendererCapabilities); | |
| 3192 | |
| 3096 // Test for UI Resource management. | 3193 // Test for UI Resource management. |
| 3097 class LayerTreeHostTestUIResource : public LayerTreeHostTest { | 3194 class LayerTreeHostTestUIResource : public LayerTreeHostTest { |
| 3098 public: | 3195 public: |
| 3099 LayerTreeHostTestUIResource() : num_ui_resources_(0) {} | 3196 LayerTreeHostTestUIResource() : num_ui_resources_(0) {} |
| 3100 | 3197 |
| 3101 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | 3198 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
| 3102 settings->texture_id_allocation_chunk_size = 1; | 3199 settings->texture_id_allocation_chunk_size = 1; |
| 3103 } | 3200 } |
| 3104 | 3201 |
| 3105 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 3202 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
| (...skipping 1858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4964 | 5061 |
| 4965 EndTest(); | 5062 EndTest(); |
| 4966 } | 5063 } |
| 4967 | 5064 |
| 4968 virtual void AfterTest() OVERRIDE {} | 5065 virtual void AfterTest() OVERRIDE {} |
| 4969 }; | 5066 }; |
| 4970 | 5067 |
| 4971 MULTI_THREAD_TEST_F(LayerTreeHostTestSimpleSwapPromiseMonitor); | 5068 MULTI_THREAD_TEST_F(LayerTreeHostTestSimpleSwapPromiseMonitor); |
| 4972 | 5069 |
| 4973 } // namespace cc | 5070 } // namespace cc |
| OLD | NEW |