| 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_common.h" | 5 #include "cc/test/layer_tree_test_common.h" |
| 6 | 6 |
| 7 #include "cc/animation.h" | 7 #include "cc/animation.h" |
| 8 #include "cc/animation_registrar.h" | 8 #include "cc/animation_registrar.h" |
| 9 #include "cc/content_layer.h" | 9 #include "cc/content_layer.h" |
| 10 #include "cc/input_handler.h" | 10 #include "cc/input_handler.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 TestHooks::TestHooks() | 32 TestHooks::TestHooks() |
| 33 { | 33 { |
| 34 bool useSoftwareRendering = false; | 34 bool useSoftwareRendering = false; |
| 35 bool useDelegatingRenderer = false; | 35 bool useDelegatingRenderer = false; |
| 36 m_fakeClient.reset(new FakeLayerImplTreeHostClient(useSoftwareRendering, useDe
legatingRenderer)); | 36 m_fakeClient.reset(new FakeLayerImplTreeHostClient(useSoftwareRendering, useDe
legatingRenderer)); |
| 37 } | 37 } |
| 38 | 38 |
| 39 TestHooks::~TestHooks() { } | 39 TestHooks::~TestHooks() { } |
| 40 | 40 |
| 41 bool TestHooks::prepareToDrawOnThread(cc::LayerTreeHostImpl*, LayerTreeHostImpl:
:FrameData&, bool) | 41 bool TestHooks::prepareToDrawOnThread(cc::LayerTreeHostImpl*, LayerTreeHostImpl:
:FrameData*, bool) |
| 42 { | 42 { |
| 43 return true; | 43 return true; |
| 44 } | 44 } |
| 45 | 45 |
| 46 bool TestHooks::canActivatePendingTree() | 46 bool TestHooks::canActivatePendingTree() |
| 47 { | 47 { |
| 48 return true; | 48 return true; |
| 49 } | 49 } |
| 50 | 50 |
| 51 scoped_ptr<OutputSurface> TestHooks::createOutputSurface() | 51 scoped_ptr<OutputSurface> TestHooks::createOutputSurface() |
| 52 { | 52 { |
| 53 return createFakeOutputSurface(); | 53 return createFakeOutputSurface(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 scoped_refptr<cc::ContextProvider> TestHooks::OffscreenContextProviderForMainThr
ead() | 56 scoped_refptr<cc::ContextProvider> TestHooks::OffscreenContextProviderForMainThr
ead() |
| 57 { | 57 { |
| 58 return m_fakeClient->OffscreenContextProviderForMainThread(); | 58 return m_fakeClient->OffscreenContextProviderForMainThread(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 scoped_refptr<cc::ContextProvider> TestHooks::OffscreenContextProviderForComposi
torThread() | 61 scoped_refptr<cc::ContextProvider> TestHooks::OffscreenContextProviderForComposi
torThread() |
| 62 { | 62 { |
| 63 return m_fakeClient->OffscreenContextProviderForCompositorThread(); | 63 return m_fakeClient->OffscreenContextProviderForCompositorThread(); |
| 64 } | 64 } |
| 65 | 65 |
| 66 scoped_ptr<MockLayerTreeHostImpl> MockLayerTreeHostImpl::create(TestHooks* testH
ooks, const LayerTreeSettings& settings, LayerTreeHostImplClient* client, Proxy*
proxy) | 66 scoped_ptr<MockLayerTreeHostImpl> MockLayerTreeHostImpl::create(TestHooks* testH
ooks, const LayerTreeSettings& settings, LayerTreeHostImplClient* client, Proxy*
proxy) |
| 67 { | 67 { |
| 68 return make_scoped_ptr(new MockLayerTreeHostImpl(testHooks, settings, client
, proxy)); | 68 return make_scoped_ptr(new MockLayerTreeHostImpl(testHooks, settings, client
, proxy)); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void MockLayerTreeHostImpl::beginCommit() | 71 void MockLayerTreeHostImpl::BeginCommit() |
| 72 { | 72 { |
| 73 LayerTreeHostImpl::beginCommit(); | 73 LayerTreeHostImpl::BeginCommit(); |
| 74 m_testHooks->beginCommitOnThread(this); | 74 m_testHooks->beginCommitOnThread(this); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void MockLayerTreeHostImpl::commitComplete() | 77 void MockLayerTreeHostImpl::CommitComplete() |
| 78 { | 78 { |
| 79 LayerTreeHostImpl::commitComplete(); | 79 LayerTreeHostImpl::CommitComplete(); |
| 80 m_testHooks->commitCompleteOnThread(this); | 80 m_testHooks->commitCompleteOnThread(this); |
| 81 | 81 |
| 82 if (!Settings().implSidePainting) | 82 if (!settings().implSidePainting) |
| 83 m_testHooks->treeActivatedOnThread(this); | 83 m_testHooks->treeActivatedOnThread(this); |
| 84 | 84 |
| 85 } | 85 } |
| 86 | 86 |
| 87 bool MockLayerTreeHostImpl::prepareToDraw(FrameData& frame) | 87 bool MockLayerTreeHostImpl::PrepareToDraw(FrameData* frame) |
| 88 { | 88 { |
| 89 bool result = LayerTreeHostImpl::prepareToDraw(frame); | 89 bool result = LayerTreeHostImpl::PrepareToDraw(frame); |
| 90 if (!m_testHooks->prepareToDrawOnThread(this, frame, result)) | 90 if (!m_testHooks->prepareToDrawOnThread(this, frame, result)) |
| 91 result = false; | 91 result = false; |
| 92 return result; | 92 return result; |
| 93 } | 93 } |
| 94 | 94 |
| 95 void MockLayerTreeHostImpl::drawLayers(FrameData& frame) | 95 void MockLayerTreeHostImpl::DrawLayers(FrameData* frame) |
| 96 { | 96 { |
| 97 LayerTreeHostImpl::drawLayers(frame); | 97 LayerTreeHostImpl::DrawLayers(frame); |
| 98 m_testHooks->drawLayersOnThread(this); | 98 m_testHooks->drawLayersOnThread(this); |
| 99 } | 99 } |
| 100 | 100 |
| 101 bool MockLayerTreeHostImpl::activatePendingTreeIfNeeded() | 101 bool MockLayerTreeHostImpl::ActivatePendingTreeIfNeeded() |
| 102 { | 102 { |
| 103 if (!pendingTree()) | 103 if (!pending_tree()) |
| 104 return false; | 104 return false; |
| 105 | 105 |
| 106 if (!m_testHooks->canActivatePendingTree()) | 106 if (!m_testHooks->canActivatePendingTree()) |
| 107 return false; | 107 return false; |
| 108 | 108 |
| 109 bool activated = LayerTreeHostImpl::activatePendingTreeIfNeeded(); | 109 bool activated = LayerTreeHostImpl::ActivatePendingTreeIfNeeded(); |
| 110 if (activated) | 110 if (activated) |
| 111 m_testHooks->treeActivatedOnThread(this); | 111 m_testHooks->treeActivatedOnThread(this); |
| 112 return activated; | 112 return activated; |
| 113 } | 113 } |
| 114 | 114 |
| 115 bool MockLayerTreeHostImpl::initializeRenderer(scoped_ptr<OutputSurface> outputS
urface) | 115 bool MockLayerTreeHostImpl::InitializeRenderer(scoped_ptr<OutputSurface> outputS
urface) |
| 116 { | 116 { |
| 117 bool success = LayerTreeHostImpl::initializeRenderer(outputSurface.Pass()); | 117 bool success = LayerTreeHostImpl::InitializeRenderer(outputSurface.Pass()); |
| 118 m_testHooks->initializedRendererOnThread(this, success); | 118 m_testHooks->initializedRendererOnThread(this, success); |
| 119 return success; | 119 return success; |
| 120 } | 120 } |
| 121 | 121 |
| 122 void MockLayerTreeHostImpl::setVisible(bool visible) | 122 void MockLayerTreeHostImpl::SetVisible(bool visible) |
| 123 { | 123 { |
| 124 LayerTreeHostImpl::setVisible(visible); | 124 LayerTreeHostImpl::SetVisible(visible); |
| 125 m_testHooks->didSetVisibleOnImplTree(this, visible); | 125 m_testHooks->didSetVisibleOnImplTree(this, visible); |
| 126 } | 126 } |
| 127 | 127 |
| 128 void MockLayerTreeHostImpl::animateLayers(base::TimeTicks monotonicTime, base::T
ime wallClockTime) | 128 void MockLayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonicTime, base::T
ime wallClockTime) |
| 129 { | 129 { |
| 130 m_testHooks->willAnimateLayers(this, monotonicTime); | 130 m_testHooks->willAnimateLayers(this, monotonicTime); |
| 131 LayerTreeHostImpl::animateLayers(monotonicTime, wallClockTime); | 131 LayerTreeHostImpl::AnimateLayers(monotonicTime, wallClockTime); |
| 132 m_testHooks->animateLayers(this, monotonicTime); | 132 m_testHooks->animateLayers(this, monotonicTime); |
| 133 } | 133 } |
| 134 | 134 |
| 135 void MockLayerTreeHostImpl::updateAnimationState() | 135 void MockLayerTreeHostImpl::UpdateAnimationState() |
| 136 { | 136 { |
| 137 LayerTreeHostImpl::updateAnimationState(); | 137 LayerTreeHostImpl::UpdateAnimationState(); |
| 138 bool hasUnfinishedAnimation = false; | 138 bool hasUnfinishedAnimation = false; |
| 139 AnimationRegistrar::AnimationControllerMap::const_iterator iter = activeAnim
ationControllers().begin(); | 139 AnimationRegistrar::AnimationControllerMap::const_iterator iter = active_ani
mation_controllers().begin(); |
| 140 for (; iter != activeAnimationControllers().end(); ++iter) { | 140 for (; iter != active_animation_controllers().end(); ++iter) { |
| 141 if (iter->second->HasActiveAnimation()) { | 141 if (iter->second->HasActiveAnimation()) { |
| 142 hasUnfinishedAnimation = true; | 142 hasUnfinishedAnimation = true; |
| 143 break; | 143 break; |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 m_testHooks->updateAnimationState(this, hasUnfinishedAnimation); | 146 m_testHooks->updateAnimationState(this, hasUnfinishedAnimation); |
| 147 } | 147 } |
| 148 | 148 |
| 149 base::TimeDelta MockLayerTreeHostImpl::lowFrequencyAnimationInterval() const | 149 base::TimeDelta MockLayerTreeHostImpl::LowFrequencyAnimationInterval() const |
| 150 { | 150 { |
| 151 return base::TimeDelta::FromMilliseconds(16); | 151 return base::TimeDelta::FromMilliseconds(16); |
| 152 } | 152 } |
| 153 | 153 |
| 154 MockLayerTreeHostImpl::MockLayerTreeHostImpl(TestHooks* testHooks, const LayerTr
eeSettings& settings, LayerTreeHostImplClient* client, Proxy* proxy) | 154 MockLayerTreeHostImpl::MockLayerTreeHostImpl(TestHooks* testHooks, const LayerTr
eeSettings& settings, LayerTreeHostImplClient* client, Proxy* proxy) |
| 155 : LayerTreeHostImpl(settings, client, proxy) | 155 : LayerTreeHostImpl(settings, client, proxy) |
| 156 , m_testHooks(testHooks) | 156 , m_testHooks(testHooks) |
| 157 { | 157 { |
| 158 } | 158 } |
| 159 | 159 |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 ASSERT_FALSE(m_layerTreeHost.get()); | 514 ASSERT_FALSE(m_layerTreeHost.get()); |
| 515 m_client.reset(); | 515 m_client.reset(); |
| 516 if (m_timedOut) { | 516 if (m_timedOut) { |
| 517 FAIL() << "Test timed out"; | 517 FAIL() << "Test timed out"; |
| 518 return; | 518 return; |
| 519 } | 519 } |
| 520 afterTest(); | 520 afterTest(); |
| 521 } | 521 } |
| 522 | 522 |
| 523 } // namespace cc | 523 } // namespace cc |
| OLD | NEW |