| 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 #ifndef CC_TEST_LAYER_TREE_TEST_COMMON_H_ | 5 #ifndef CC_TEST_LAYER_TREE_TEST_COMMON_H_ |
| 6 #define CC_TEST_LAYER_TREE_TEST_COMMON_H_ | 6 #define CC_TEST_LAYER_TREE_TEST_COMMON_H_ |
| 7 | 7 |
| 8 #include "cc/layer_tree_host.h" | 8 #include "cc/layer_tree_host.h" |
| 9 #include "base/hash_tables.h" | 9 #include "base/hash_tables.h" |
| 10 #include "cc/layer_tree_host_impl.h" | 10 #include "cc/layer_tree_host_impl.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 void dispatchAddAnimation(); | 105 void dispatchAddAnimation(); |
| 106 void dispatchSetNeedsAnimateAndCommit(); | 106 void dispatchSetNeedsAnimateAndCommit(); |
| 107 void dispatchSetNeedsCommit(); | 107 void dispatchSetNeedsCommit(); |
| 108 void dispatchAcquireLayerTextures(); | 108 void dispatchAcquireLayerTextures(); |
| 109 void dispatchSetNeedsRedraw(); | 109 void dispatchSetNeedsRedraw(); |
| 110 void dispatchSetVisible(bool); | 110 void dispatchSetVisible(bool); |
| 111 void dispatchComposite(); | 111 void dispatchComposite(); |
| 112 void dispatchDidAddAnimation(); | 112 void dispatchDidAddAnimation(); |
| 113 | 113 |
| 114 virtual void runTest(bool threaded); | 114 virtual void runTest(bool threaded); |
| 115 WebKit::WebThread* webThread() const { return m_webThread.get(); } | 115 WebKit::WebThread* webThread() const { return m_webImplThread.get(); } |
| 116 cc::Proxy* proxy() const { return m_layerTreeHost->proxy(); } |
| 116 | 117 |
| 117 cc::LayerTreeSettings m_settings; | 118 cc::LayerTreeSettings m_settings; |
| 118 scoped_ptr<MockLayerImplTreeHostClient> m_client; | 119 scoped_ptr<MockLayerImplTreeHostClient> m_client; |
| 119 scoped_ptr<cc::LayerTreeHost> m_layerTreeHost; | 120 scoped_ptr<cc::LayerTreeHost> m_layerTreeHost; |
| 120 | 121 |
| 121 protected: | 122 protected: |
| 122 RefPtr<cc::ScopedThreadProxy> m_mainThreadProxy; | 123 RefPtr<cc::ScopedThreadProxy> m_mainThreadProxy; |
| 123 | 124 |
| 124 private: | 125 private: |
| 125 bool m_beginning; | 126 bool m_beginning; |
| 126 bool m_endWhenBeginReturns; | 127 bool m_endWhenBeginReturns; |
| 127 bool m_timedOut; | 128 bool m_timedOut; |
| 128 bool m_finished; | 129 bool m_finished; |
| 129 bool m_scheduled; | 130 bool m_scheduled; |
| 130 bool m_started; | 131 bool m_started; |
| 131 | 132 |
| 132 scoped_ptr<WebKit::WebThread> m_webThread; | 133 scoped_ptr<WebKit::WebThread> m_webImplThread; |
| 134 cc::Thread* m_implThread; |
| 133 TimeoutTask* m_timeoutTask; | 135 TimeoutTask* m_timeoutTask; |
| 134 BeginTask* m_beginTask; | 136 BeginTask* m_beginTask; |
| 135 }; | 137 }; |
| 136 | 138 |
| 137 class ThreadedTestThreadOnly : public ThreadedTest { | 139 class ThreadedTestThreadOnly : public ThreadedTest { |
| 138 public: | 140 public: |
| 139 void runTestThreaded() | 141 void runTestThreaded() |
| 140 { | 142 { |
| 141 ThreadedTest::runTest(true); | 143 ThreadedTest::runTest(true); |
| 142 } | 144 } |
| 143 }; | 145 }; |
| 144 | 146 |
| 145 // Adapts LayerTreeHostImpl for test. Runs real code, then invokes test hooks. | 147 // Adapts LayerTreeHostImpl for test. Runs real code, then invokes test hooks. |
| 146 class MockLayerTreeHostImpl : public cc::LayerTreeHostImpl { | 148 class MockLayerTreeHostImpl : public cc::LayerTreeHostImpl { |
| 147 public: | 149 public: |
| 148 static scoped_ptr<MockLayerTreeHostImpl> create(TestHooks*, const cc::LayerT
reeSettings&, cc::LayerTreeHostImplClient*); | 150 static scoped_ptr<MockLayerTreeHostImpl> create(TestHooks*, const cc::LayerT
reeSettings&, cc::LayerTreeHostImplClient*, cc::Proxy*); |
| 149 | 151 |
| 150 virtual void beginCommit() OVERRIDE; | 152 virtual void beginCommit() OVERRIDE; |
| 151 virtual void commitComplete() OVERRIDE; | 153 virtual void commitComplete() OVERRIDE; |
| 152 virtual bool prepareToDraw(FrameData&) OVERRIDE; | 154 virtual bool prepareToDraw(FrameData&) OVERRIDE; |
| 153 virtual void drawLayers(const FrameData&) OVERRIDE; | 155 virtual void drawLayers(const FrameData&) OVERRIDE; |
| 154 | 156 |
| 155 // Make these public. | 157 // Make these public. |
| 156 typedef std::vector<cc::LayerImpl*> LayerList; | 158 typedef std::vector<cc::LayerImpl*> LayerList; |
| 157 using LayerTreeHostImpl::calculateRenderSurfaceLayerList; | 159 using LayerTreeHostImpl::calculateRenderSurfaceLayerList; |
| 158 | 160 |
| 159 protected: | 161 protected: |
| 160 virtual void animateLayers(double monotonicTime, double wallClockTime) OVERR
IDE; | 162 virtual void animateLayers(double monotonicTime, double wallClockTime) OVERR
IDE; |
| 161 virtual base::TimeDelta lowFrequencyAnimationInterval() const OVERRIDE; | 163 virtual base::TimeDelta lowFrequencyAnimationInterval() const OVERRIDE; |
| 162 | 164 |
| 163 private: | 165 private: |
| 164 MockLayerTreeHostImpl(TestHooks*, const cc::LayerTreeSettings&, cc::LayerTre
eHostImplClient*); | 166 MockLayerTreeHostImpl(TestHooks*, const cc::LayerTreeSettings&, cc::LayerTre
eHostImplClient*, cc::Proxy*); |
| 165 | 167 |
| 166 TestHooks* m_testHooks; | 168 TestHooks* m_testHooks; |
| 167 }; | 169 }; |
| 168 | 170 |
| 169 class CompositorFakeWebGraphicsContext3DWithTextureTracking : public WebKit::Com
positorFakeWebGraphicsContext3D { | 171 class CompositorFakeWebGraphicsContext3DWithTextureTracking : public WebKit::Com
positorFakeWebGraphicsContext3D { |
| 170 public: | 172 public: |
| 171 static scoped_ptr<CompositorFakeWebGraphicsContext3DWithTextureTracking> cre
ate(Attributes); | 173 static scoped_ptr<CompositorFakeWebGraphicsContext3DWithTextureTracking> cre
ate(Attributes); |
| 172 virtual ~CompositorFakeWebGraphicsContext3DWithTextureTracking(); | 174 virtual ~CompositorFakeWebGraphicsContext3DWithTextureTracking(); |
| 173 | 175 |
| 174 virtual WebKit::WebGLId createTexture(); | 176 virtual WebKit::WebGLId createTexture(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 198 TEST_F(TEST_FIXTURE_NAME, runSingleThread) \ | 200 TEST_F(TEST_FIXTURE_NAME, runSingleThread) \ |
| 199 { \ | 201 { \ |
| 200 runTest(false); \ | 202 runTest(false); \ |
| 201 } \ | 203 } \ |
| 202 TEST_F(TEST_FIXTURE_NAME, runMultiThread) \ | 204 TEST_F(TEST_FIXTURE_NAME, runMultiThread) \ |
| 203 { \ | 205 { \ |
| 204 runTest(true); \ | 206 runTest(true); \ |
| 205 } | 207 } |
| 206 | 208 |
| 207 #endif // CC_TEST_LAYER_TREE_TEST_COMMON_H_ | 209 #endif // CC_TEST_LAYER_TREE_TEST_COMMON_H_ |
| OLD | NEW |