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

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

Issue 11443004: Maintain global lists of animation controllers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . 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 didAddAnimation() OVERRIDE
175 {
176 m_testHooks->didAddAnimation();
177 }
178
180 void setTestStarted(bool started) { m_testStarted = started; } 179 void setTestStarted(bool started) { m_testStarted = started; }
181 180
182 virtual void didDeferCommit() OVERRIDE 181 virtual void didDeferCommit() OVERRIDE
183 { 182 {
184 m_testHooks->didDeferCommit(); 183 m_testHooks->didDeferCommit();
185 } 184 }
186 185
187 private: 186 private:
188 MockLayerTreeHost(TestHooks* testHooks, cc::LayerTreeHostClient* client, con st cc::LayerTreeSettings& settings) 187 MockLayerTreeHost(TestHooks* testHooks, cc::LayerTreeHostClient* client, con st cc::LayerTreeSettings& settings)
189 : LayerTreeHost(client, settings) 188 : LayerTreeHost(client, settings)
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 void ThreadedTest::postSetNeedsAnimateAndCommitToMainThread() 340 void ThreadedTest::postSetNeedsAnimateAndCommitToMainThread()
342 { 341 {
343 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadedTest::dispatchSet NeedsAnimateAndCommit, base::Unretained(this))); 342 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadedTest::dispatchSet NeedsAnimateAndCommit, base::Unretained(this)));
344 } 343 }
345 344
346 void ThreadedTest::postSetVisibleToMainThread(bool visible) 345 void ThreadedTest::postSetVisibleToMainThread(bool visible)
347 { 346 {
348 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadedTest::dispatchSet Visible, base::Unretained(this), visible)); 347 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadedTest::dispatchSet Visible, base::Unretained(this), visible));
349 } 348 }
350 349
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() 350 void ThreadedTest::doBeginTest()
357 { 351 {
358 m_client = ThreadedMockLayerTreeHostClient::create(this); 352 m_client = ThreadedMockLayerTreeHostClient::create(this);
359 353
360 scoped_refptr<Layer> rootLayer = Layer::create(); 354 scoped_refptr<Layer> rootLayer = Layer::create();
361 scoped_ptr<cc::Thread> implCCThread(NULL); 355 scoped_ptr<cc::Thread> implCCThread(NULL);
362 if (m_implThread) 356 if (m_implThread)
363 implCCThread = cc::ThreadImpl::createForDifferentThread(m_implThread->me ssage_loop_proxy()); 357 implCCThread = cc::ThreadImpl::createForDifferentThread(m_implThread->me ssage_loop_proxy());
364 m_layerTreeHost = MockLayerTreeHost::create(this, m_client.get(), rootLayer, m_settings, implCCThread.Pass()); 358 m_layerTreeHost = MockLayerTreeHost::create(this, m_client.get(), rootLayer, m_settings, implCCThread.Pass());
365 ASSERT_TRUE(m_layerTreeHost.get()); 359 ASSERT_TRUE(m_layerTreeHost.get());
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 m_layerTreeHost->setVisible(visible); 482 m_layerTreeHost->setVisible(visible);
489 } 483 }
490 484
491 void ThreadedTest::dispatchComposite() 485 void ThreadedTest::dispatchComposite()
492 { 486 {
493 m_scheduled = false; 487 m_scheduled = false;
494 if (m_layerTreeHost.get() && !m_finished) 488 if (m_layerTreeHost.get() && !m_finished)
495 m_layerTreeHost->composite(); 489 m_layerTreeHost->composite();
496 } 490 }
497 491
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) 492 void ThreadedTest::runTest(bool threaded)
510 { 493 {
511 if (threaded) { 494 if (threaded) {
512 m_implThread.reset(new base::Thread("ThreadedTest")); 495 m_implThread.reset(new base::Thread("ThreadedTest"));
513 ASSERT_TRUE(m_implThread->Start()); 496 ASSERT_TRUE(m_implThread->Start());
514 } 497 }
515 498
516 m_mainCCThread = cc::ThreadImpl::createForCurrentThread(); 499 m_mainCCThread = cc::ThreadImpl::createForCurrentThread();
517 m_mainThreadProxy = ScopedThreadProxy::create(m_mainCCThread.get()); 500 m_mainThreadProxy = ScopedThreadProxy::create(m_mainCCThread.get());
518 501
(...skipping 12 matching lines...) Expand all
531 ASSERT_FALSE(m_layerTreeHost.get()); 514 ASSERT_FALSE(m_layerTreeHost.get());
532 m_client.reset(); 515 m_client.reset();
533 if (m_timedOut) { 516 if (m_timedOut) {
534 FAIL() << "Test timed out"; 517 FAIL() << "Test timed out";
535 return; 518 return;
536 } 519 }
537 afterTest(); 520 afterTest();
538 } 521 }
539 522
540 } // namespace WebKitTests 523 } // namespace WebKitTests
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698