| 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 3098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3109 bool did_initialize_gl_; | 3109 bool did_initialize_gl_; |
| 3110 bool did_release_gl_; | 3110 bool did_release_gl_; |
| 3111 int last_source_frame_number_drawn_; | 3111 int last_source_frame_number_drawn_; |
| 3112 }; | 3112 }; |
| 3113 | 3113 |
| 3114 MULTI_THREAD_TEST_F(LayerTreeHostTestDeferredInitialize); | 3114 MULTI_THREAD_TEST_F(LayerTreeHostTestDeferredInitialize); |
| 3115 | 3115 |
| 3116 // Test for UI Resource management. | 3116 // Test for UI Resource management. |
| 3117 class LayerTreeHostTestUIResource : public LayerTreeHostTest { | 3117 class LayerTreeHostTestUIResource : public LayerTreeHostTest { |
| 3118 public: | 3118 public: |
| 3119 LayerTreeHostTestUIResource() : num_ui_resources_(0), num_commits_(0) {} | 3119 LayerTreeHostTestUIResource() : num_ui_resources_(0) {} |
| 3120 | 3120 |
| 3121 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | 3121 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
| 3122 settings->texture_id_allocation_chunk_size = 1; | 3122 settings->texture_id_allocation_chunk_size = 1; |
| 3123 } | 3123 } |
| 3124 | 3124 |
| 3125 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 3125 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
| 3126 | 3126 |
| 3127 virtual void DidCommit() OVERRIDE { | 3127 virtual void DidCommit() OVERRIDE { |
| 3128 int frame = num_commits_; | 3128 int frame = layer_tree_host()->source_frame_number(); |
| 3129 switch (frame) { | 3129 switch (frame) { |
| 3130 case 1: | 3130 case 1: |
| 3131 CreateResource(); | 3131 CreateResource(); |
| 3132 CreateResource(); | 3132 CreateResource(); |
| 3133 PostSetNeedsCommitToMainThread(); | 3133 PostSetNeedsCommitToMainThread(); |
| 3134 break; | 3134 break; |
| 3135 case 2: | 3135 case 2: |
| 3136 // Usually ScopedUIResource are deleted from the manager in their | 3136 // Usually ScopedUIResource are deleted from the manager in their |
| 3137 // destructor. Here we just want to test that a direct call to | 3137 // destructor. Here we just want to test that a direct call to |
| 3138 // DeleteUIResource works. | 3138 // DeleteUIResource works. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3153 ClearResources(); | 3153 ClearResources(); |
| 3154 EndTest(); | 3154 EndTest(); |
| 3155 break; | 3155 break; |
| 3156 } | 3156 } |
| 3157 } | 3157 } |
| 3158 | 3158 |
| 3159 void PerformTest(LayerTreeHostImpl* impl) { | 3159 void PerformTest(LayerTreeHostImpl* impl) { |
| 3160 TestWebGraphicsContext3D* context = static_cast<TestContextProvider*>( | 3160 TestWebGraphicsContext3D* context = static_cast<TestContextProvider*>( |
| 3161 impl->output_surface()->context_provider().get())->TestContext3d(); | 3161 impl->output_surface()->context_provider().get())->TestContext3d(); |
| 3162 | 3162 |
| 3163 int frame = num_commits_; | 3163 int frame = impl->active_tree()->source_frame_number(); |
| 3164 switch (frame) { | 3164 switch (frame) { |
| 3165 case 1: | 3165 case 0: |
| 3166 ASSERT_EQ(0u, context->NumTextures()); | 3166 ASSERT_EQ(0u, context->NumTextures()); |
| 3167 break; | 3167 break; |
| 3168 case 2: | 3168 case 1: |
| 3169 // Created two textures. | 3169 // Created two textures. |
| 3170 ASSERT_EQ(2u, context->NumTextures()); | 3170 ASSERT_EQ(2u, context->NumTextures()); |
| 3171 break; | 3171 break; |
| 3172 case 3: | 3172 case 2: |
| 3173 // One texture left after one deletion. | 3173 // One texture left after one deletion. |
| 3174 ASSERT_EQ(1u, context->NumTextures()); | 3174 ASSERT_EQ(1u, context->NumTextures()); |
| 3175 break; | 3175 break; |
| 3176 case 4: | 3176 case 3: |
| 3177 // Resource manager state should not change when delete is called on an | 3177 // Resource manager state should not change when delete is called on an |
| 3178 // invalid id. | 3178 // invalid id. |
| 3179 ASSERT_EQ(1u, context->NumTextures()); | 3179 ASSERT_EQ(1u, context->NumTextures()); |
| 3180 break; | 3180 break; |
| 3181 case 5: | 3181 case 4: |
| 3182 // Creation after deletion: two more creates should total up to | 3182 // Creation after deletion: two more creates should total up to |
| 3183 // three textures. | 3183 // three textures. |
| 3184 ASSERT_EQ(3u, context->NumTextures()); | 3184 ASSERT_EQ(3u, context->NumTextures()); |
| 3185 break; | 3185 break; |
| 3186 } | 3186 } |
| 3187 } | 3187 } |
| 3188 | 3188 |
| 3189 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 3189 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 3190 ++num_commits_; | |
| 3191 if (!layer_tree_host()->settings().impl_side_painting) | 3190 if (!layer_tree_host()->settings().impl_side_painting) |
| 3192 PerformTest(impl); | 3191 PerformTest(impl); |
| 3193 } | 3192 } |
| 3194 | 3193 |
| 3195 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 3194 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 3196 if (layer_tree_host()->settings().impl_side_painting) | 3195 if (layer_tree_host()->settings().impl_side_painting) |
| 3197 PerformTest(impl); | 3196 PerformTest(impl); |
| 3198 } | 3197 } |
| 3199 | 3198 |
| 3200 virtual void AfterTest() OVERRIDE {} | 3199 virtual void AfterTest() OVERRIDE {} |
| 3201 | 3200 |
| 3202 private: | 3201 private: |
| 3203 // Must clear all resources before exiting. | 3202 // Must clear all resources before exiting. |
| 3204 void ClearResources() { | 3203 void ClearResources() { |
| 3205 for (int i = 0; i < num_ui_resources_; i++) | 3204 for (int i = 0; i < num_ui_resources_; i++) |
| 3206 ui_resources_[i].reset(); | 3205 ui_resources_[i].reset(); |
| 3207 } | 3206 } |
| 3208 | 3207 |
| 3209 void CreateResource() { | 3208 void CreateResource() { |
| 3210 ui_resources_[num_ui_resources_++] = | 3209 ui_resources_[num_ui_resources_++] = |
| 3211 FakeScopedUIResource::Create(layer_tree_host()); | 3210 FakeScopedUIResource::Create(layer_tree_host()); |
| 3212 } | 3211 } |
| 3213 | 3212 |
| 3214 scoped_ptr<FakeScopedUIResource> ui_resources_[5]; | 3213 scoped_ptr<FakeScopedUIResource> ui_resources_[5]; |
| 3215 int num_ui_resources_; | 3214 int num_ui_resources_; |
| 3216 int num_commits_; | |
| 3217 }; | 3215 }; |
| 3218 | 3216 |
| 3219 MULTI_THREAD_TEST_F(LayerTreeHostTestUIResource); | 3217 MULTI_THREAD_TEST_F(LayerTreeHostTestUIResource); |
| 3220 | 3218 |
| 3221 class PushPropertiesCountingLayer : public Layer { | 3219 class PushPropertiesCountingLayer : public Layer { |
| 3222 public: | 3220 public: |
| 3223 static scoped_refptr<PushPropertiesCountingLayer> Create() { | 3221 static scoped_refptr<PushPropertiesCountingLayer> Create() { |
| 3224 return new PushPropertiesCountingLayer(); | 3222 return new PushPropertiesCountingLayer(); |
| 3225 } | 3223 } |
| 3226 | 3224 |
| (...skipping 1540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4767 | 4765 |
| 4768 EndTest(); | 4766 EndTest(); |
| 4769 } | 4767 } |
| 4770 | 4768 |
| 4771 virtual void AfterTest() OVERRIDE {} | 4769 virtual void AfterTest() OVERRIDE {} |
| 4772 }; | 4770 }; |
| 4773 | 4771 |
| 4774 MULTI_THREAD_TEST_F(LayerTreeHostTestSimpleSwapPromiseMonitor); | 4772 MULTI_THREAD_TEST_F(LayerTreeHostTestSimpleSwapPromiseMonitor); |
| 4775 | 4773 |
| 4776 } // namespace cc | 4774 } // namespace cc |
| OLD | NEW |