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