| 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 3921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3932 | 3932 |
| 3933 TEST_F(LayerTreeHostTestTreeActivationCallback, DelegatingRenderer) { | 3933 TEST_F(LayerTreeHostTestTreeActivationCallback, DelegatingRenderer) { |
| 3934 RunTest(true, true, true); | 3934 RunTest(true, true, true); |
| 3935 } | 3935 } |
| 3936 | 3936 |
| 3937 class LayerInvalidateCausesDraw : public LayerTreeHostTest { | 3937 class LayerInvalidateCausesDraw : public LayerTreeHostTest { |
| 3938 public: | 3938 public: |
| 3939 LayerInvalidateCausesDraw() : num_commits_(0), num_draws_(0) {} | 3939 LayerInvalidateCausesDraw() : num_commits_(0), num_draws_(0) {} |
| 3940 | 3940 |
| 3941 virtual void BeginTest() OVERRIDE { | 3941 virtual void BeginTest() OVERRIDE { |
| 3942 ASSERT_TRUE(!!invalidate_layer_) | 3942 ASSERT_TRUE(!!invalidate_layer_.get()) |
| 3943 << "Derived tests must set this in SetupTree"; | 3943 << "Derived tests must set this in SetupTree"; |
| 3944 | 3944 |
| 3945 // One initial commit. | 3945 // One initial commit. |
| 3946 PostSetNeedsCommitToMainThread(); | 3946 PostSetNeedsCommitToMainThread(); |
| 3947 } | 3947 } |
| 3948 | 3948 |
| 3949 virtual void DidCommitAndDrawFrame() OVERRIDE { | 3949 virtual void DidCommitAndDrawFrame() OVERRIDE { |
| 3950 // After commit, invalidate the layer. This should cause a commit. | 3950 // After commit, invalidate the layer. This should cause a commit. |
| 3951 if (layer_tree_host()->source_frame_number() == 1) | 3951 if (layer_tree_host()->source_frame_number() == 1) |
| 3952 invalidate_layer_->SetNeedsDisplay(); | 3952 invalidate_layer_->SetNeedsDisplay(); |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4325 | 4325 |
| 4326 class LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface | 4326 class LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface |
| 4327 : public LayerTreeHostTest { | 4327 : public LayerTreeHostTest { |
| 4328 protected: | 4328 protected: |
| 4329 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface() | 4329 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface() |
| 4330 : first_output_surface_memory_limit_(4321234), | 4330 : first_output_surface_memory_limit_(4321234), |
| 4331 second_output_surface_memory_limit_(1234321) {} | 4331 second_output_surface_memory_limit_(1234321) {} |
| 4332 | 4332 |
| 4333 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback) | 4333 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback) |
| 4334 OVERRIDE { | 4334 OVERRIDE { |
| 4335 if (!first_context_provider_) { | 4335 if (!first_context_provider_.get()) { |
| 4336 first_context_provider_ = TestContextProvider::Create(); | 4336 first_context_provider_ = TestContextProvider::Create(); |
| 4337 } else { | 4337 } else { |
| 4338 EXPECT_FALSE(second_context_provider_); | 4338 EXPECT_FALSE(second_context_provider_.get()); |
| 4339 second_context_provider_ = TestContextProvider::Create(); | 4339 second_context_provider_ = TestContextProvider::Create(); |
| 4340 } | 4340 } |
| 4341 | 4341 |
| 4342 scoped_refptr<TestContextProvider> provider(second_context_provider_ | 4342 scoped_refptr<TestContextProvider> provider(second_context_provider_.get() |
| 4343 ? second_context_provider_ | 4343 ? second_context_provider_ |
| 4344 : first_context_provider_); | 4344 : first_context_provider_); |
| 4345 scoped_ptr<FakeOutputSurface> output_surface; | 4345 scoped_ptr<FakeOutputSurface> output_surface; |
| 4346 if (delegating_renderer()) | 4346 if (delegating_renderer()) |
| 4347 output_surface = FakeOutputSurface::CreateDelegating3d(provider); | 4347 output_surface = FakeOutputSurface::CreateDelegating3d(provider); |
| 4348 else | 4348 else |
| 4349 output_surface = FakeOutputSurface::Create3d(provider); | 4349 output_surface = FakeOutputSurface::Create3d(provider); |
| 4350 output_surface->SetMemoryPolicyToSetAtBind( | 4350 output_surface->SetMemoryPolicyToSetAtBind( |
| 4351 make_scoped_ptr(new ManagedMemoryPolicy( | 4351 make_scoped_ptr(new ManagedMemoryPolicy( |
| 4352 second_context_provider_ ? second_output_surface_memory_limit_ | 4352 second_context_provider_.get() ? second_output_surface_memory_limit_ |
| 4353 : first_output_surface_memory_limit_, | 4353 : first_output_surface_memory_limit_, |
| 4354 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE, | 4354 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE, |
| 4355 ManagedMemoryPolicy::kDefaultNumResourcesLimit))); | 4355 ManagedMemoryPolicy::kDefaultNumResourcesLimit))); |
| 4356 return output_surface.Pass(); | 4356 return output_surface.Pass(); |
| 4357 } | 4357 } |
| 4358 | 4358 |
| 4359 virtual void SetupTree() OVERRIDE { | 4359 virtual void SetupTree() OVERRIDE { |
| 4360 root_ = FakeContentLayer::Create(&client_); | 4360 root_ = FakeContentLayer::Create(&client_); |
| 4361 root_->SetBounds(gfx::Size(20, 20)); | 4361 root_->SetBounds(gfx::Size(20, 20)); |
| 4362 layer_tree_host()->SetRootLayer(root_); | 4362 layer_tree_host()->SetRootLayer(root_); |
| 4363 LayerTreeHostTest::SetupTree(); | 4363 LayerTreeHostTest::SetupTree(); |
| (...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4992 milliseconds_per_frame)); | 4992 milliseconds_per_frame)); |
| 4993 } | 4993 } |
| 4994 | 4994 |
| 4995 virtual void BeginMainFrame(const BeginFrameArgs& args) OVERRIDE { | 4995 virtual void BeginMainFrame(const BeginFrameArgs& args) OVERRIDE { |
| 4996 child_layer_->SetNeedsDisplay(); | 4996 child_layer_->SetNeedsDisplay(); |
| 4997 } | 4997 } |
| 4998 | 4998 |
| 4999 virtual void AfterTest() OVERRIDE { | 4999 virtual void AfterTest() OVERRIDE { |
| 5000 EXPECT_LE(kExpectedNumCommits, num_commits_); | 5000 EXPECT_LE(kExpectedNumCommits, num_commits_); |
| 5001 EXPECT_LE(kExpectedNumCommits, num_draws_); | 5001 EXPECT_LE(kExpectedNumCommits, num_draws_); |
| 5002 int update_count = content_layer_ ? content_layer_->PaintContentsCount() | 5002 int update_count = content_layer_.get() |
| 5003 : picture_layer_->update_count(); | 5003 ? content_layer_->PaintContentsCount() |
| 5004 : picture_layer_->update_count(); |
| 5004 EXPECT_LE(kExpectedNumCommits, update_count); | 5005 EXPECT_LE(kExpectedNumCommits, update_count); |
| 5005 } | 5006 } |
| 5006 | 5007 |
| 5007 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 5008 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 5008 if (++num_draws_ == kExpectedNumCommits) | 5009 if (++num_draws_ == kExpectedNumCommits) |
| 5009 EndTest(); | 5010 EndTest(); |
| 5010 } | 5011 } |
| 5011 | 5012 |
| 5012 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 5013 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 5013 ++num_commits_; | 5014 ++num_commits_; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 5032 const gfx::Size bounds_; | 5033 const gfx::Size bounds_; |
| 5033 FakeContentLayerClient client_; | 5034 FakeContentLayerClient client_; |
| 5034 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; | 5035 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; |
| 5035 scoped_refptr<FakePictureLayer> picture_layer_; | 5036 scoped_refptr<FakePictureLayer> picture_layer_; |
| 5036 Layer* child_layer_; | 5037 Layer* child_layer_; |
| 5037 }; | 5038 }; |
| 5038 | 5039 |
| 5039 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); | 5040 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); |
| 5040 | 5041 |
| 5041 } // namespace cc | 5042 } // namespace cc |
| OLD | NEW |