Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: cc/test/layer_tree_test_common.cc

Issue 11348256: Use an auxiliary list of animation controllers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added registration/unregistration Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "cc/active_animation.h" 8 #include "cc/active_animation.h"
9 #include "cc/content_layer.h" 9 #include "cc/content_layer.h"
10 #include "cc/font_atlas.h" 10 #include "cc/font_atlas.h"
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 layerTreeHost->rootLayer()->setLayerAnimationDelegate(testHooks); 157 layerTreeHost->rootLayer()->setLayerAnimationDelegate(testHooks);
158 158
159 return layerTreeHost.Pass(); 159 return layerTreeHost.Pass();
160 } 160 }
161 161
162 virtual scoped_ptr<cc::LayerTreeHostImpl> createLayerTreeHostImpl(cc::LayerT reeHostImplClient* client) 162 virtual scoped_ptr<cc::LayerTreeHostImpl> createLayerTreeHostImpl(cc::LayerT reeHostImplClient* client)
163 { 163 {
164 return MockLayerTreeHostImpl::create(m_testHooks, settings(), client, pr oxy()).PassAs<cc::LayerTreeHostImpl>(); 164 return MockLayerTreeHostImpl::create(m_testHooks, settings(), client, pr oxy()).PassAs<cc::LayerTreeHostImpl>();
165 } 165 }
166 166
167 virtual void didAddAnimation() OVERRIDE
168 {
169 LayerTreeHost::didAddAnimation();
170 m_testHooks->didAddAnimation();
171 }
172
173 virtual void setNeedsCommit() OVERRIDE 167 virtual void setNeedsCommit() OVERRIDE
174 { 168 {
175 if (!m_testStarted) 169 if (!m_testStarted)
176 return; 170 return;
177 LayerTreeHost::setNeedsCommit(); 171 LayerTreeHost::setNeedsCommit();
178 } 172 }
179 173
174 virtual void ActivateAnimationController(cc::LayerAnimationController* contr oller) OVERRIDE
175 {
176 LayerTreeHost::ActivateAnimationController(controller);
177 m_testHooks->didAddAnimation();
178 }
179
180 void setTestStarted(bool started) { m_testStarted = started; } 180 void setTestStarted(bool started) { m_testStarted = started; }
181 181
182 virtual void didDeferCommit() OVERRIDE 182 virtual void didDeferCommit() OVERRIDE
183 { 183 {
184 m_testHooks->didDeferCommit(); 184 m_testHooks->didDeferCommit();
185 } 185 }
186 186
187 private: 187 private:
188 MockLayerTreeHost(TestHooks* testHooks, cc::LayerTreeHostClient* client, con st cc::LayerTreeSettings& settings) 188 MockLayerTreeHost(TestHooks* testHooks, cc::LayerTreeHostClient* client, con st cc::LayerTreeSettings& settings)
189 : LayerTreeHost(client, settings) 189 : LayerTreeHost(client, settings)
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 void ThreadedTest::postSetNeedsAnimateAndCommitToMainThread() 341 void ThreadedTest::postSetNeedsAnimateAndCommitToMainThread()
342 { 342 {
343 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadedTest::dispatchSet NeedsAnimateAndCommit, base::Unretained(this))); 343 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadedTest::dispatchSet NeedsAnimateAndCommit, base::Unretained(this)));
344 } 344 }
345 345
346 void ThreadedTest::postSetVisibleToMainThread(bool visible) 346 void ThreadedTest::postSetVisibleToMainThread(bool visible)
347 { 347 {
348 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadedTest::dispatchSet Visible, base::Unretained(this), visible)); 348 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadedTest::dispatchSet Visible, base::Unretained(this), visible));
349 } 349 }
350 350
351 void ThreadedTest::postDidAddAnimationToMainThread()
352 {
353 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadedTest::dispatchDid AddAnimation, base::Unretained(this)));
354 }
355
356 void ThreadedTest::doBeginTest() 351 void ThreadedTest::doBeginTest()
357 { 352 {
358 m_client = ThreadedMockLayerTreeHostClient::create(this); 353 m_client = ThreadedMockLayerTreeHostClient::create(this);
359 354
360 scoped_refptr<Layer> rootLayer = Layer::create(); 355 scoped_refptr<Layer> rootLayer = Layer::create();
361 scoped_ptr<cc::Thread> implCCThread(NULL); 356 scoped_ptr<cc::Thread> implCCThread(NULL);
362 if (m_implThread) 357 if (m_implThread)
363 implCCThread = cc::ThreadImpl::createForDifferentThread(m_implThread->me ssage_loop_proxy()); 358 implCCThread = cc::ThreadImpl::createForDifferentThread(m_implThread->me ssage_loop_proxy());
364 m_layerTreeHost = MockLayerTreeHost::create(this, m_client.get(), rootLayer, m_settings, implCCThread.Pass()); 359 m_layerTreeHost = MockLayerTreeHost::create(this, m_client.get(), rootLayer, m_settings, implCCThread.Pass());
365 ASSERT_TRUE(m_layerTreeHost.get()); 360 ASSERT_TRUE(m_layerTreeHost.get());
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 m_layerTreeHost->setVisible(visible); 483 m_layerTreeHost->setVisible(visible);
489 } 484 }
490 485
491 void ThreadedTest::dispatchComposite() 486 void ThreadedTest::dispatchComposite()
492 { 487 {
493 m_scheduled = false; 488 m_scheduled = false;
494 if (m_layerTreeHost.get() && !m_finished) 489 if (m_layerTreeHost.get() && !m_finished)
495 m_layerTreeHost->composite(); 490 m_layerTreeHost->composite();
496 } 491 }
497 492
498 void ThreadedTest::dispatchDidAddAnimation()
499 {
500 DCHECK(!proxy() || proxy()->isMainThread());
501
502 if (m_finished)
503 return;
504
505 if (m_layerTreeHost.get())
506 m_layerTreeHost->didAddAnimation();
507 }
508
509 void ThreadedTest::runTest(bool threaded) 493 void ThreadedTest::runTest(bool threaded)
510 { 494 {
511 if (threaded) { 495 if (threaded) {
512 m_implThread.reset(new base::Thread("ThreadedTest")); 496 m_implThread.reset(new base::Thread("ThreadedTest"));
513 ASSERT_TRUE(m_implThread->Start()); 497 ASSERT_TRUE(m_implThread->Start());
514 } 498 }
515 499
516 m_mainCCThread = cc::ThreadImpl::createForCurrentThread(); 500 m_mainCCThread = cc::ThreadImpl::createForCurrentThread();
517 m_mainThreadProxy = ScopedThreadProxy::create(m_mainCCThread.get()); 501 m_mainThreadProxy = ScopedThreadProxy::create(m_mainCCThread.get());
518 502
(...skipping 12 matching lines...) Expand all
531 ASSERT_FALSE(m_layerTreeHost.get()); 515 ASSERT_FALSE(m_layerTreeHost.get());
532 m_client.reset(); 516 m_client.reset();
533 if (m_timedOut) { 517 if (m_timedOut) {
534 FAIL() << "Test timed out"; 518 FAIL() << "Test timed out";
535 return; 519 return;
536 } 520 }
537 afterTest(); 521 afterTest();
538 } 522 }
539 523
540 } // namespace WebKitTests 524 } // namespace WebKitTests
OLDNEW
« cc/layer_tree_host.h ('K') | « cc/test/layer_tree_test_common.h ('k') | cc/thread_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698