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
3 // found in the LICENSE file.
5 #include "cc/test/layer_tree_test.h"
7 #include "base/command_line.h"
8 #include "cc/animation/animation.h"
9 #include "cc/animation/animation_registrar.h"
10 #include "cc/animation/layer_animation_controller.h"
11 #include "cc/animation/timing_function.h"
12 #include "cc/base/switches.h"
13 #include "cc/input/input_handler.h"
14 #include "cc/layers/content_layer.h"
15 #include "cc/layers/layer.h"
16 #include "cc/layers/layer_impl.h"
17 #include "cc/test/animation_test_common.h"
18 #include "cc/test/fake_layer_tree_host_client.h"
19 #include "cc/test/fake_output_surface.h"
20 #include "cc/test/test_context_provider.h"
21 #include "cc/test/test_shared_bitmap_manager.h"
22 #include "cc/test/tiled_layer_test_common.h"
23 #include "cc/trees/layer_tree_host_client.h"
24 #include "cc/trees/layer_tree_host_impl.h"
25 #include "cc/trees/layer_tree_host_single_thread_client.h"
26 #include "cc/trees/layer_tree_impl.h"
27 #include "cc/trees/single_thread_proxy.h"
28 #include "cc/trees/thread_proxy.h"
29 #include "testing/gmock/include/gmock/gmock.h"
30 #include "ui/gfx/frame_time.h"
31 #include "ui/gfx/size_conversions.h"
35 TestHooks::TestHooks() {}
37 TestHooks::~TestHooks() {}
39 DrawResult
TestHooks::PrepareToDrawOnThread(
40 LayerTreeHostImpl
* host_impl
,
41 LayerTreeHostImpl::FrameData
* frame_data
,
42 DrawResult draw_result
) {
46 base::TimeDelta
TestHooks::LowFrequencyAnimationInterval() const {
47 return base::TimeDelta::FromMilliseconds(16);
50 // Adapts ThreadProxy for test. Injects test hooks for testing.
51 class ThreadProxyForTest
: public ThreadProxy
{
53 static scoped_ptr
<Proxy
> Create(
54 TestHooks
* test_hooks
,
56 scoped_refptr
<base::SingleThreadTaskRunner
> main_task_runner
,
57 scoped_refptr
<base::SingleThreadTaskRunner
> impl_task_runner
) {
58 return make_scoped_ptr(
59 new ThreadProxyForTest(
60 test_hooks
, host
, main_task_runner
, impl_task_runner
))
64 virtual ~ThreadProxyForTest() {}
67 test_hooks_
->Layout();
71 TestHooks
* test_hooks_
;
73 virtual void ScheduledActionSendBeginMainFrame() OVERRIDE
{
74 test_hooks_
->ScheduledActionWillSendBeginMainFrame();
75 ThreadProxy::ScheduledActionSendBeginMainFrame();
76 test_hooks_
->ScheduledActionSendBeginMainFrame();
79 virtual DrawResult
ScheduledActionDrawAndSwapIfPossible() OVERRIDE
{
80 DrawResult result
= ThreadProxy::ScheduledActionDrawAndSwapIfPossible();
81 test_hooks_
->ScheduledActionDrawAndSwapIfPossible();
85 virtual void ScheduledActionAnimate() OVERRIDE
{
86 ThreadProxy::ScheduledActionAnimate();
87 test_hooks_
->ScheduledActionAnimate();
90 virtual void ScheduledActionCommit() OVERRIDE
{
91 ThreadProxy::ScheduledActionCommit();
92 test_hooks_
->ScheduledActionCommit();
95 virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE
{
96 ThreadProxy::ScheduledActionBeginOutputSurfaceCreation();
97 test_hooks_
->ScheduledActionBeginOutputSurfaceCreation();
101 TestHooks
* test_hooks
,
103 scoped_refptr
<base::SingleThreadTaskRunner
> main_task_runner
,
104 scoped_refptr
<base::SingleThreadTaskRunner
> impl_task_runner
)
105 : ThreadProxy(host
, main_task_runner
, impl_task_runner
),
106 test_hooks_(test_hooks
) {}
109 // Adapts LayerTreeHostImpl for test. Runs real code, then invokes test hooks.
110 class LayerTreeHostImplForTesting
: public LayerTreeHostImpl
{
112 static scoped_ptr
<LayerTreeHostImplForTesting
> Create(
113 TestHooks
* test_hooks
,
114 const LayerTreeSettings
& settings
,
115 LayerTreeHostImplClient
* host_impl_client
,
117 SharedBitmapManager
* manager
,
118 RenderingStatsInstrumentation
* stats_instrumentation
) {
119 return make_scoped_ptr(
120 new LayerTreeHostImplForTesting(test_hooks
,
125 stats_instrumentation
));
129 LayerTreeHostImplForTesting(
130 TestHooks
* test_hooks
,
131 const LayerTreeSettings
& settings
,
132 LayerTreeHostImplClient
* host_impl_client
,
134 SharedBitmapManager
* manager
,
135 RenderingStatsInstrumentation
* stats_instrumentation
)
136 : LayerTreeHostImpl(settings
,
139 stats_instrumentation
,
142 test_hooks_(test_hooks
),
143 block_notify_ready_to_activate_for_testing_(false),
144 notify_ready_to_activate_was_blocked_(false) {}
146 virtual void WillBeginImplFrame(const BeginFrameArgs
& args
) OVERRIDE
{
147 LayerTreeHostImpl::WillBeginImplFrame(args
);
148 test_hooks_
->WillBeginImplFrameOnThread(this, args
);
151 virtual void BeginMainFrameAborted(bool did_handle
) OVERRIDE
{
152 LayerTreeHostImpl::BeginMainFrameAborted(did_handle
);
153 test_hooks_
->BeginMainFrameAbortedOnThread(this, did_handle
);
156 virtual void BeginCommit() OVERRIDE
{
157 LayerTreeHostImpl::BeginCommit();
158 test_hooks_
->BeginCommitOnThread(this);
161 virtual void CommitComplete() OVERRIDE
{
162 LayerTreeHostImpl::CommitComplete();
163 test_hooks_
->CommitCompleteOnThread(this);
166 virtual DrawResult
PrepareToDraw(FrameData
* frame
) OVERRIDE
{
167 DrawResult draw_result
= LayerTreeHostImpl::PrepareToDraw(frame
);
168 return test_hooks_
->PrepareToDrawOnThread(this, frame
, draw_result
);
171 virtual void DrawLayers(FrameData
* frame
,
172 base::TimeTicks frame_begin_time
) OVERRIDE
{
173 LayerTreeHostImpl::DrawLayers(frame
, frame_begin_time
);
174 test_hooks_
->DrawLayersOnThread(this);
177 virtual bool SwapBuffers(const LayerTreeHostImpl::FrameData
& frame
) OVERRIDE
{
178 bool result
= LayerTreeHostImpl::SwapBuffers(frame
);
179 test_hooks_
->SwapBuffersOnThread(this, result
);
183 virtual void DidSwapBuffersComplete() OVERRIDE
{
184 LayerTreeHostImpl::DidSwapBuffersComplete();
185 test_hooks_
->SwapBuffersCompleteOnThread(this);
188 virtual void ReclaimResources(const CompositorFrameAck
* ack
) OVERRIDE
{
189 LayerTreeHostImpl::ReclaimResources(ack
);
192 virtual void UpdateVisibleTiles() OVERRIDE
{
193 LayerTreeHostImpl::UpdateVisibleTiles();
194 test_hooks_
->UpdateVisibleTilesOnThread(this);
197 virtual void NotifyReadyToActivate() OVERRIDE
{
198 if (block_notify_ready_to_activate_for_testing_
)
199 notify_ready_to_activate_was_blocked_
= true;
201 client_
->NotifyReadyToActivate();
204 virtual void BlockNotifyReadyToActivateForTesting(bool block
) OVERRIDE
{
205 block_notify_ready_to_activate_for_testing_
= block
;
206 if (!block
&& notify_ready_to_activate_was_blocked_
) {
207 NotifyReadyToActivate();
208 notify_ready_to_activate_was_blocked_
= false;
212 virtual void ActivateSyncTree() OVERRIDE
{
213 test_hooks_
->WillActivateTreeOnThread(this);
214 LayerTreeHostImpl::ActivateSyncTree();
215 DCHECK(!pending_tree());
216 test_hooks_
->DidActivateTreeOnThread(this);
219 virtual bool InitializeRenderer(scoped_ptr
<OutputSurface
> output_surface
)
221 bool success
= LayerTreeHostImpl::InitializeRenderer(output_surface
.Pass());
222 test_hooks_
->InitializedRendererOnThread(this, success
);
226 virtual void SetVisible(bool visible
) OVERRIDE
{
227 LayerTreeHostImpl::SetVisible(visible
);
228 test_hooks_
->DidSetVisibleOnImplTree(this, visible
);
231 virtual void AnimateLayers(base::TimeTicks monotonic_time
) OVERRIDE
{
232 test_hooks_
->WillAnimateLayers(this, monotonic_time
);
233 LayerTreeHostImpl::AnimateLayers(monotonic_time
);
234 test_hooks_
->AnimateLayers(this, monotonic_time
);
237 virtual void UpdateAnimationState(bool start_ready_animations
) OVERRIDE
{
238 LayerTreeHostImpl::UpdateAnimationState(start_ready_animations
);
239 bool has_unfinished_animation
= false;
240 AnimationRegistrar::AnimationControllerMap::const_iterator iter
=
241 active_animation_controllers().begin();
242 for (; iter
!= active_animation_controllers().end(); ++iter
) {
243 if (iter
->second
->HasActiveAnimation()) {
244 has_unfinished_animation
= true;
248 test_hooks_
->UpdateAnimationState(this, has_unfinished_animation
);
251 virtual base::TimeDelta
LowFrequencyAnimationInterval() const OVERRIDE
{
252 return test_hooks_
->LowFrequencyAnimationInterval();
256 TestHooks
* test_hooks_
;
257 bool block_notify_ready_to_activate_for_testing_
;
258 bool notify_ready_to_activate_was_blocked_
;
261 // Implementation of LayerTreeHost callback interface.
262 class LayerTreeHostClientForTesting
: public LayerTreeHostClient
,
263 public LayerTreeHostSingleThreadClient
{
265 static scoped_ptr
<LayerTreeHostClientForTesting
> Create(
266 TestHooks
* test_hooks
) {
267 return make_scoped_ptr(new LayerTreeHostClientForTesting(test_hooks
));
269 virtual ~LayerTreeHostClientForTesting() {}
271 virtual void WillBeginMainFrame(int frame_id
) OVERRIDE
{
272 test_hooks_
->WillBeginMainFrame();
275 virtual void DidBeginMainFrame() OVERRIDE
{
276 test_hooks_
->DidBeginMainFrame();
279 virtual void BeginMainFrame(const BeginFrameArgs
& args
) OVERRIDE
{
280 test_hooks_
->BeginMainFrame(args
);
283 virtual void Layout() OVERRIDE
{ test_hooks_
->Layout(); }
285 virtual void ApplyScrollAndScale(const gfx::Vector2d
& scroll_delta
,
286 float scale
) OVERRIDE
{
287 test_hooks_
->ApplyScrollAndScale(scroll_delta
, scale
);
290 virtual scoped_ptr
<OutputSurface
> CreateOutputSurface(bool fallback
)
292 return test_hooks_
->CreateOutputSurface(fallback
);
295 virtual void DidInitializeOutputSurface() OVERRIDE
{
296 test_hooks_
->DidInitializeOutputSurface();
299 virtual void DidFailToInitializeOutputSurface() OVERRIDE
{
300 test_hooks_
->DidFailToInitializeOutputSurface();
303 virtual void WillCommit() OVERRIDE
{ test_hooks_
->WillCommit(); }
305 virtual void DidCommit() OVERRIDE
{ test_hooks_
->DidCommit(); }
307 virtual void DidCommitAndDrawFrame() OVERRIDE
{
308 test_hooks_
->DidCommitAndDrawFrame();
311 virtual void DidCompleteSwapBuffers() OVERRIDE
{
312 test_hooks_
->DidCompleteSwapBuffers();
315 virtual void DidPostSwapBuffers() OVERRIDE
{}
316 virtual void DidAbortSwapBuffers() OVERRIDE
{}
319 explicit LayerTreeHostClientForTesting(TestHooks
* test_hooks
)
320 : test_hooks_(test_hooks
) {}
322 TestHooks
* test_hooks_
;
325 // Adapts LayerTreeHost for test. Injects LayerTreeHostImplForTesting.
326 class LayerTreeHostForTesting
: public LayerTreeHost
{
328 static scoped_ptr
<LayerTreeHostForTesting
> Create(
329 TestHooks
* test_hooks
,
330 LayerTreeHostClientForTesting
* client
,
331 const LayerTreeSettings
& settings
,
332 scoped_refptr
<base::SingleThreadTaskRunner
> main_task_runner
,
333 scoped_refptr
<base::SingleThreadTaskRunner
> impl_task_runner
) {
334 scoped_ptr
<LayerTreeHostForTesting
> layer_tree_host(
335 new LayerTreeHostForTesting(test_hooks
, client
, settings
));
336 if (impl_task_runner
.get()) {
337 layer_tree_host
->InitializeForTesting(
338 ThreadProxyForTest::Create(test_hooks
,
339 layer_tree_host
.get(),
343 layer_tree_host
->InitializeForTesting(SingleThreadProxy::Create(
344 layer_tree_host
.get(), client
, main_task_runner
));
346 return layer_tree_host
.Pass();
349 virtual scoped_ptr
<LayerTreeHostImpl
> CreateLayerTreeHostImpl(
350 LayerTreeHostImplClient
* host_impl_client
) OVERRIDE
{
351 return LayerTreeHostImplForTesting::Create(
356 shared_bitmap_manager_
.get(),
357 rendering_stats_instrumentation()).PassAs
<LayerTreeHostImpl
>();
360 virtual void SetNeedsCommit() OVERRIDE
{
363 LayerTreeHost::SetNeedsCommit();
366 void set_test_started(bool started
) { test_started_
= started
; }
368 virtual void DidDeferCommit() OVERRIDE
{ test_hooks_
->DidDeferCommit(); }
371 LayerTreeHostForTesting(TestHooks
* test_hooks
,
372 LayerTreeHostClient
* client
,
373 const LayerTreeSettings
& settings
)
374 : LayerTreeHost(client
, NULL
, settings
),
375 shared_bitmap_manager_(new TestSharedBitmapManager()),
376 test_hooks_(test_hooks
),
377 test_started_(false) {}
379 scoped_ptr
<SharedBitmapManager
> shared_bitmap_manager_
;
380 TestHooks
* test_hooks_
;
384 LayerTreeTest::LayerTreeTest()
386 end_when_begin_returns_(false),
391 delegating_renderer_(false),
393 weak_factory_(this) {
394 main_thread_weak_ptr_
= weak_factory_
.GetWeakPtr();
396 // Tests should timeout quickly unless --cc-layer-tree-test-no-timeout was
397 // specified (for running in a debugger).
398 CommandLine
* command_line
= CommandLine::ForCurrentProcess();
399 if (!command_line
->HasSwitch(switches::kCCLayerTreeTestNoTimeout
))
400 timeout_seconds_
= 5;
403 LayerTreeTest::~LayerTreeTest() {}
405 void LayerTreeTest::EndTest() {
410 // For the case where we EndTest during BeginTest(), set a flag to indicate
411 // that the test should end the second BeginTest regains control.
413 end_when_begin_returns_
= true;
415 main_task_runner_
->PostTask(
417 base::Bind(&LayerTreeTest::RealEndTest
, main_thread_weak_ptr_
));
421 void LayerTreeTest::EndTestAfterDelay(int delay_milliseconds
) {
422 main_task_runner_
->PostDelayedTask(
424 base::Bind(&LayerTreeTest::EndTest
, main_thread_weak_ptr_
),
425 base::TimeDelta::FromMilliseconds(delay_milliseconds
));
428 void LayerTreeTest::PostAddAnimationToMainThread(
429 Layer
* layer_to_receive_animation
) {
430 main_task_runner_
->PostTask(
432 base::Bind(&LayerTreeTest::DispatchAddAnimation
,
433 main_thread_weak_ptr_
,
434 base::Unretained(layer_to_receive_animation
),
438 void LayerTreeTest::PostAddInstantAnimationToMainThread(
439 Layer
* layer_to_receive_animation
) {
440 main_task_runner_
->PostTask(
442 base::Bind(&LayerTreeTest::DispatchAddAnimation
,
443 main_thread_weak_ptr_
,
444 base::Unretained(layer_to_receive_animation
),
448 void LayerTreeTest::PostAddLongAnimationToMainThread(
449 Layer
* layer_to_receive_animation
) {
450 main_task_runner_
->PostTask(
452 base::Bind(&LayerTreeTest::DispatchAddAnimation
,
453 main_thread_weak_ptr_
,
454 base::Unretained(layer_to_receive_animation
),
458 void LayerTreeTest::PostSetNeedsCommitToMainThread() {
459 main_task_runner_
->PostTask(FROM_HERE
,
460 base::Bind(&LayerTreeTest::DispatchSetNeedsCommit
,
461 main_thread_weak_ptr_
));
464 void LayerTreeTest::PostSetNeedsUpdateLayersToMainThread() {
465 main_task_runner_
->PostTask(
467 base::Bind(&LayerTreeTest::DispatchSetNeedsUpdateLayers
,
468 main_thread_weak_ptr_
));
471 void LayerTreeTest::PostSetNeedsRedrawToMainThread() {
472 main_task_runner_
->PostTask(FROM_HERE
,
473 base::Bind(&LayerTreeTest::DispatchSetNeedsRedraw
,
474 main_thread_weak_ptr_
));
477 void LayerTreeTest::PostSetNeedsRedrawRectToMainThread(
478 const gfx::Rect
& damage_rect
) {
479 main_task_runner_
->PostTask(
481 base::Bind(&LayerTreeTest::DispatchSetNeedsRedrawRect
,
482 main_thread_weak_ptr_
,
486 void LayerTreeTest::PostSetVisibleToMainThread(bool visible
) {
487 main_task_runner_
->PostTask(
490 &LayerTreeTest::DispatchSetVisible
, main_thread_weak_ptr_
, visible
));
493 void LayerTreeTest::PostSetNextCommitForcesRedrawToMainThread() {
494 main_task_runner_
->PostTask(
496 base::Bind(&LayerTreeTest::DispatchSetNextCommitForcesRedraw
,
497 main_thread_weak_ptr_
));
500 void LayerTreeTest::WillBeginTest() {
501 layer_tree_host_
->SetLayerTreeHostClientReady();
504 void LayerTreeTest::DoBeginTest() {
505 client_
= LayerTreeHostClientForTesting::Create(this);
507 DCHECK(!impl_thread_
|| impl_thread_
->message_loop_proxy().get());
508 layer_tree_host_
= LayerTreeHostForTesting::Create(
512 base::MessageLoopProxy::current(),
513 impl_thread_
? impl_thread_
->message_loop_proxy() : NULL
);
514 ASSERT_TRUE(layer_tree_host_
);
522 if (end_when_begin_returns_
)
525 // Allow commits to happen once BeginTest() has had a chance to post tasks
526 // so that those tasks will happen before the first commit.
527 if (layer_tree_host_
) {
528 static_cast<LayerTreeHostForTesting
*>(layer_tree_host_
.get())
529 ->set_test_started(true);
533 void LayerTreeTest::SetupTree() {
534 if (!layer_tree_host_
->root_layer()) {
535 scoped_refptr
<Layer
> root_layer
= Layer::Create();
536 root_layer
->SetBounds(gfx::Size(1, 1));
537 root_layer
->SetIsDrawable(true);
538 layer_tree_host_
->SetRootLayer(root_layer
);
541 gfx::Size root_bounds
= layer_tree_host_
->root_layer()->bounds();
542 gfx::Size device_root_bounds
= gfx::ToCeiledSize(
543 gfx::ScaleSize(root_bounds
, layer_tree_host_
->device_scale_factor()));
544 layer_tree_host_
->SetViewportSize(device_root_bounds
);
547 void LayerTreeTest::Timeout() {
552 void LayerTreeTest::RealEndTest() {
553 if (layer_tree_host_
&& !timed_out_
&&
554 proxy()->MainFrameWillHappenForTesting()) {
555 main_task_runner_
->PostTask(
557 base::Bind(&LayerTreeTest::RealEndTest
, main_thread_weak_ptr_
));
561 base::MessageLoop::current()->Quit();
564 void LayerTreeTest::DispatchAddAnimation(Layer
* layer_to_receive_animation
,
565 double animation_duration
) {
566 DCHECK(!proxy() || proxy()->IsMainThread());
568 if (layer_to_receive_animation
) {
569 AddOpacityTransitionToLayer(
570 layer_to_receive_animation
, animation_duration
, 0, 0.5, true);
574 void LayerTreeTest::DispatchSetNeedsCommit() {
575 DCHECK(!proxy() || proxy()->IsMainThread());
577 if (layer_tree_host_
)
578 layer_tree_host_
->SetNeedsCommit();
581 void LayerTreeTest::DispatchSetNeedsUpdateLayers() {
582 DCHECK(!proxy() || proxy()->IsMainThread());
584 if (layer_tree_host_
)
585 layer_tree_host_
->SetNeedsUpdateLayers();
588 void LayerTreeTest::DispatchSetNeedsRedraw() {
589 DCHECK(!proxy() || proxy()->IsMainThread());
591 if (layer_tree_host_
)
592 layer_tree_host_
->SetNeedsRedraw();
595 void LayerTreeTest::DispatchSetNeedsRedrawRect(const gfx::Rect
& damage_rect
) {
596 DCHECK(!proxy() || proxy()->IsMainThread());
598 if (layer_tree_host_
)
599 layer_tree_host_
->SetNeedsRedrawRect(damage_rect
);
602 void LayerTreeTest::DispatchSetVisible(bool visible
) {
603 DCHECK(!proxy() || proxy()->IsMainThread());
604 if (layer_tree_host_
)
605 layer_tree_host_
->SetVisible(visible
);
608 void LayerTreeTest::DispatchSetNextCommitForcesRedraw() {
609 DCHECK(!proxy() || proxy()->IsMainThread());
611 if (layer_tree_host_
)
612 layer_tree_host_
->SetNextCommitForcesRedraw();
615 void LayerTreeTest::RunTest(bool threaded
,
616 bool delegating_renderer
,
617 bool impl_side_painting
) {
619 impl_thread_
.reset(new base::Thread("Compositor"));
620 ASSERT_TRUE(impl_thread_
->Start());
623 main_task_runner_
= base::MessageLoopProxy::current();
625 delegating_renderer_
= delegating_renderer
;
627 // Spend less time waiting for BeginFrame because the output is
629 settings_
.refresh_rate
= 200.0;
630 if (impl_side_painting
) {
632 << "Don't run single thread + impl side painting, it doesn't exist.";
633 settings_
.impl_side_painting
= true;
635 InitializeSettings(&settings_
);
637 main_task_runner_
->PostTask(
639 base::Bind(&LayerTreeTest::DoBeginTest
, base::Unretained(this)));
641 if (timeout_seconds_
) {
642 timeout_
.Reset(base::Bind(&LayerTreeTest::Timeout
, base::Unretained(this)));
643 main_task_runner_
->PostDelayedTask(
646 base::TimeDelta::FromSeconds(timeout_seconds_
));
649 base::MessageLoop::current()->Run();
650 DestroyLayerTreeHost();
654 ASSERT_FALSE(layer_tree_host_
.get());
657 FAIL() << "Test timed out";
663 void LayerTreeTest::RunTestWithImplSidePainting() {
664 RunTest(true, false, true);
667 scoped_ptr
<OutputSurface
> LayerTreeTest::CreateOutputSurface(bool fallback
) {
668 scoped_ptr
<FakeOutputSurface
> output_surface
=
669 CreateFakeOutputSurface(fallback
);
670 if (output_surface
) {
671 DCHECK_EQ(delegating_renderer_
,
672 output_surface
->capabilities().delegated_rendering
);
674 output_surface_
= output_surface
.get();
675 return output_surface
.PassAs
<OutputSurface
>();
678 scoped_ptr
<FakeOutputSurface
> LayerTreeTest::CreateFakeOutputSurface(
680 if (delegating_renderer_
)
681 return FakeOutputSurface::CreateDelegating3d();
683 return FakeOutputSurface::Create3d();
686 TestWebGraphicsContext3D
* LayerTreeTest::TestContext() {
687 return static_cast<TestContextProvider
*>(output_surface_
->context_provider())
691 int LayerTreeTest::LastCommittedSourceFrameNumber(LayerTreeHostImpl
* impl
)
693 if (impl
->pending_tree())
694 return impl
->pending_tree()->source_frame_number();
695 if (impl
->active_tree())
696 return impl
->active_tree()->source_frame_number();
697 // Source frames start at 0, so this is invalid.
701 void LayerTreeTest::DestroyLayerTreeHost() {
702 if (layer_tree_host_
&& layer_tree_host_
->root_layer())
703 layer_tree_host_
->root_layer()->SetLayerTreeHost(NULL
);
704 layer_tree_host_
.reset();