| 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/test/layer_tree_test.h" | 5 #include "cc/test/layer_tree_test.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "cc/animation/animation.h" | 8 #include "cc/animation/animation.h" |
| 9 #include "cc/animation/animation_registrar.h" | 9 #include "cc/animation/animation_registrar.h" |
| 10 #include "cc/animation/layer_animation_controller.h" | 10 #include "cc/animation/layer_animation_controller.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 TestHooks::TestHooks() {} | 30 TestHooks::TestHooks() {} |
| 31 | 31 |
| 32 TestHooks::~TestHooks() {} | 32 TestHooks::~TestHooks() {} |
| 33 | 33 |
| 34 bool TestHooks::PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | 34 bool TestHooks::PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
| 35 LayerTreeHostImpl::FrameData* frame_data, | 35 LayerTreeHostImpl::FrameData* frame_data, |
| 36 bool result) { | 36 bool result) { |
| 37 return true; | 37 return true; |
| 38 } | 38 } |
| 39 | 39 |
| 40 bool TestHooks::CanActivatePendingTree(LayerTreeHostImpl* host_impl) { | |
| 41 return true; | |
| 42 } | |
| 43 | |
| 44 bool TestHooks::CanActivatePendingTreeIfNeeded(LayerTreeHostImpl* host_impl) { | |
| 45 return true; | |
| 46 } | |
| 47 | |
| 48 // Adapts LayerTreeHostImpl for test. Runs real code, then invokes test hooks. | 40 // Adapts LayerTreeHostImpl for test. Runs real code, then invokes test hooks. |
| 49 class LayerTreeHostImplForTesting : public LayerTreeHostImpl { | 41 class LayerTreeHostImplForTesting : public LayerTreeHostImpl { |
| 50 public: | 42 public: |
| 51 static scoped_ptr<LayerTreeHostImplForTesting> Create( | 43 static scoped_ptr<LayerTreeHostImplForTesting> Create( |
| 52 TestHooks* test_hooks, | 44 TestHooks* test_hooks, |
| 53 const LayerTreeSettings& settings, | 45 const LayerTreeSettings& settings, |
| 54 LayerTreeHostImplClient* host_impl_client, | 46 LayerTreeHostImplClient* host_impl_client, |
| 55 Proxy* proxy, | 47 Proxy* proxy, |
| 56 RenderingStatsInstrumentation* stats_instrumentation) { | 48 RenderingStatsInstrumentation* stats_instrumentation) { |
| 57 return make_scoped_ptr( | 49 return make_scoped_ptr( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 68 const LayerTreeSettings& settings, | 60 const LayerTreeSettings& settings, |
| 69 LayerTreeHostImplClient* host_impl_client, | 61 LayerTreeHostImplClient* host_impl_client, |
| 70 Proxy* proxy, | 62 Proxy* proxy, |
| 71 RenderingStatsInstrumentation* stats_instrumentation) | 63 RenderingStatsInstrumentation* stats_instrumentation) |
| 72 : LayerTreeHostImpl(settings, | 64 : LayerTreeHostImpl(settings, |
| 73 host_impl_client, | 65 host_impl_client, |
| 74 proxy, | 66 proxy, |
| 75 stats_instrumentation), | 67 stats_instrumentation), |
| 76 test_hooks_(test_hooks) {} | 68 test_hooks_(test_hooks) {} |
| 77 | 69 |
| 70 virtual void BeginFrame(const BeginFrameArgs& args) OVERRIDE { |
| 71 test_hooks_->WillBeginFrameOnThread(this, args); |
| 72 LayerTreeHostImpl::BeginFrame(args); |
| 73 } |
| 74 |
| 78 virtual void BeginCommit() OVERRIDE { | 75 virtual void BeginCommit() OVERRIDE { |
| 79 LayerTreeHostImpl::BeginCommit(); | 76 LayerTreeHostImpl::BeginCommit(); |
| 80 test_hooks_->BeginCommitOnThread(this); | 77 test_hooks_->BeginCommitOnThread(this); |
| 81 } | 78 } |
| 82 | 79 |
| 83 virtual void CommitComplete() OVERRIDE { | 80 virtual void CommitComplete() OVERRIDE { |
| 84 LayerTreeHostImpl::CommitComplete(); | 81 LayerTreeHostImpl::CommitComplete(); |
| 85 test_hooks_->CommitCompleteOnThread(this); | 82 test_hooks_->CommitCompleteOnThread(this); |
| 86 | 83 |
| 87 if (!settings().impl_side_painting) { | 84 if (!settings().impl_side_painting) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 107 bool result = LayerTreeHostImpl::SwapBuffers(frame); | 104 bool result = LayerTreeHostImpl::SwapBuffers(frame); |
| 108 test_hooks_->SwapBuffersOnThread(this, result); | 105 test_hooks_->SwapBuffersOnThread(this, result); |
| 109 return result; | 106 return result; |
| 110 } | 107 } |
| 111 | 108 |
| 112 virtual void OnSwapBuffersComplete(const CompositorFrameAck* ack) OVERRIDE { | 109 virtual void OnSwapBuffersComplete(const CompositorFrameAck* ack) OVERRIDE { |
| 113 LayerTreeHostImpl::OnSwapBuffersComplete(ack); | 110 LayerTreeHostImpl::OnSwapBuffersComplete(ack); |
| 114 test_hooks_->SwapBuffersCompleteOnThread(this); | 111 test_hooks_->SwapBuffersCompleteOnThread(this); |
| 115 } | 112 } |
| 116 | 113 |
| 117 virtual void ActivatePendingTreeIfNeeded() OVERRIDE { | |
| 118 if (!pending_tree()) | |
| 119 return; | |
| 120 | |
| 121 if (!test_hooks_->CanActivatePendingTreeIfNeeded(this)) | |
| 122 return; | |
| 123 | |
| 124 LayerTreeHostImpl::ActivatePendingTreeIfNeeded(); | |
| 125 } | |
| 126 | |
| 127 virtual void ActivatePendingTree() OVERRIDE { | 114 virtual void ActivatePendingTree() OVERRIDE { |
| 128 if (!test_hooks_->CanActivatePendingTree(this)) | |
| 129 return; | |
| 130 | |
| 131 test_hooks_->WillActivateTreeOnThread(this); | 115 test_hooks_->WillActivateTreeOnThread(this); |
| 132 LayerTreeHostImpl::ActivatePendingTree(); | 116 LayerTreeHostImpl::ActivatePendingTree(); |
| 133 DCHECK(!pending_tree()); | 117 DCHECK(!pending_tree()); |
| 134 test_hooks_->DidActivateTreeOnThread(this); | 118 test_hooks_->DidActivateTreeOnThread(this); |
| 135 } | 119 } |
| 136 | 120 |
| 137 virtual bool InitializeRenderer(scoped_ptr<OutputSurface> output_surface) | 121 virtual bool InitializeRenderer(scoped_ptr<OutputSurface> output_surface) |
| 138 OVERRIDE { | 122 OVERRIDE { |
| 139 bool success = LayerTreeHostImpl::InitializeRenderer(output_surface.Pass()); | 123 bool success = LayerTreeHostImpl::InitializeRenderer(output_surface.Pass()); |
| 140 test_hooks_->InitializedRendererOnThread(this, success); | 124 test_hooks_->InitializedRendererOnThread(this, success); |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 | 608 |
| 625 scoped_refptr<cc::ContextProvider> LayerTreeTest:: | 609 scoped_refptr<cc::ContextProvider> LayerTreeTest:: |
| 626 OffscreenContextProviderForCompositorThread() { | 610 OffscreenContextProviderForCompositorThread() { |
| 627 if (!compositor_thread_contexts_.get() || | 611 if (!compositor_thread_contexts_.get() || |
| 628 compositor_thread_contexts_->DestroyedOnMainThread()) | 612 compositor_thread_contexts_->DestroyedOnMainThread()) |
| 629 compositor_thread_contexts_ = TestContextProvider::Create(); | 613 compositor_thread_contexts_ = TestContextProvider::Create(); |
| 630 return compositor_thread_contexts_; | 614 return compositor_thread_contexts_; |
| 631 } | 615 } |
| 632 | 616 |
| 633 } // namespace cc | 617 } // namespace cc |
| OLD | NEW |